index.js 6.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344154345154346154347154348154349154350154351154352154353154354154355154356154357154358154359154360154361154362154363154364154365154366154367154368154369154370154371154372154373154374154375154376154377154378154379154380154381154382154383154384154385154386154387154388154389154390154391154392154393154394154395154396154397154398154399154400154401154402154403154404154405154406154407154408154409154410154411154412154413154414154415154416154417154418154419154420154421154422154423154424154425154426154427154428154429154430154431154432154433154434154435154436154437154438154439154440154441154442154443154444154445154446154447154448154449154450154451154452154453154454154455154456154457154458154459154460154461154462154463154464154465154466154467154468154469154470154471154472154473154474154475154476154477154478154479154480154481154482154483154484154485154486154487154488154489154490154491154492154493154494154495154496154497154498154499154500154501154502154503154504154505154506154507154508154509154510154511154512154513154514154515154516154517154518154519154520154521154522154523154524154525154526154527154528154529154530154531154532154533154534154535154536154537154538154539154540154541154542154543154544154545154546154547154548154549154550154551154552154553154554154555154556154557154558154559154560154561154562154563154564154565154566154567154568154569154570154571154572154573154574154575154576154577154578154579154580154581154582154583154584154585154586154587154588154589154590154591154592154593154594154595154596154597154598154599154600154601154602154603154604154605154606154607154608154609154610154611154612154613154614154615154616154617154618154619154620154621154622154623154624154625154626154627154628154629154630154631154632154633154634154635154636154637154638154639154640154641154642154643154644154645154646154647154648154649154650154651154652154653154654154655154656154657154658154659154660154661154662154663154664154665154666154667154668154669154670154671154672154673154674154675154676154677154678154679154680154681154682154683154684154685154686154687154688154689154690154691154692154693154694154695154696154697154698154699154700154701154702154703154704154705154706154707154708154709154710154711154712154713154714154715154716154717154718154719154720154721154722154723154724154725154726154727154728154729154730154731154732154733154734154735154736154737154738154739154740154741154742154743154744154745154746154747154748154749154750154751154752154753154754154755154756154757154758154759154760154761154762154763154764154765154766154767154768154769154770154771154772154773154774154775154776154777154778154779154780154781154782154783154784154785154786154787154788154789154790154791154792154793154794154795154796154797154798154799154800154801154802154803154804154805154806154807154808154809154810154811154812154813154814154815154816154817154818154819154820154821154822154823154824154825154826154827154828154829154830154831154832154833154834154835154836154837154838154839154840154841154842154843154844154845154846154847154848154849154850154851154852154853154854154855154856154857154858154859154860154861154862154863154864154865154866154867154868154869154870154871154872154873154874154875154876154877154878154879154880154881154882154883154884154885154886154887154888154889154890154891154892154893154894154895154896154897154898154899154900154901154902154903154904154905154906154907154908154909154910154911154912154913154914154915154916154917154918154919154920154921154922154923154924154925154926154927154928154929154930154931154932154933154934154935154936154937154938154939154940154941154942154943154944154945154946154947154948154949154950154951154952154953154954154955154956154957154958154959154960154961154962154963154964154965154966154967154968154969154970154971154972154973154974154975154976154977154978154979154980154981154982154983154984154985154986154987154988154989154990154991154992154993154994154995154996154997154998154999155000155001155002155003155004155005155006155007155008155009155010155011155012155013155014155015155016155017155018155019155020155021155022155023155024155025155026155027155028155029155030155031155032155033155034155035155036155037155038155039155040155041155042155043155044155045155046155047155048155049155050155051155052155053155054155055155056155057155058155059155060155061155062155063155064155065155066155067155068155069155070155071155072155073155074155075155076155077155078155079155080155081155082155083155084155085155086155087155088155089155090155091155092155093155094155095155096155097155098155099155100155101155102155103155104155105155106155107155108155109155110155111155112155113155114155115155116155117155118155119155120155121155122155123155124155125155126155127155128155129155130155131155132155133155134155135155136155137155138155139155140155141155142155143155144155145155146155147155148155149155150155151155152155153155154155155155156155157155158155159155160155161155162155163155164155165155166155167155168155169155170155171155172155173155174155175155176155177155178155179155180155181155182155183155184155185155186155187155188155189155190155191155192155193155194155195155196155197155198155199155200155201155202155203155204155205155206155207155208155209155210155211155212155213155214155215155216155217155218155219155220155221155222155223155224155225155226155227155228155229155230155231155232155233155234155235155236155237155238155239155240155241155242155243155244155245155246155247155248155249155250155251155252155253155254155255155256155257155258155259155260155261155262155263155264155265155266155267155268155269155270155271155272155273155274155275155276155277155278155279155280155281155282155283155284155285155286155287155288155289155290155291155292155293155294155295155296155297155298155299155300155301155302155303155304155305155306155307155308155309155310155311155312155313155314155315155316155317155318155319155320155321155322155323155324155325155326155327155328155329155330155331155332155333155334155335155336155337155338155339155340155341155342155343155344155345155346155347155348155349155350155351155352155353155354155355155356155357155358155359155360155361155362155363155364155365155366155367155368155369155370155371155372155373155374155375155376155377155378155379155380155381155382155383155384155385155386155387155388155389155390155391155392155393155394155395155396155397155398155399155400155401155402155403155404155405155406155407155408155409155410155411155412155413155414155415155416155417155418155419155420155421155422155423155424155425155426155427155428155429155430155431155432155433155434155435155436155437155438155439155440155441155442155443155444155445155446155447155448155449155450155451155452155453155454155455155456155457155458155459155460155461155462155463155464155465155466155467155468155469155470155471155472155473155474155475155476155477155478155479155480155481155482155483155484155485155486155487155488155489155490155491155492155493155494155495155496155497155498155499155500155501155502155503155504155505155506155507155508155509155510155511155512155513155514155515155516155517155518155519155520155521155522155523155524155525155526155527155528155529155530155531155532155533155534155535155536155537155538155539155540155541155542155543155544155545155546155547155548155549155550155551155552155553155554155555155556155557155558155559155560155561155562155563155564155565155566155567155568155569155570155571155572155573155574155575155576155577155578155579155580155581155582155583155584155585155586155587155588155589155590155591155592155593155594155595155596155597155598155599155600155601155602155603155604155605155606155607155608155609155610155611155612155613155614155615155616155617155618155619155620155621155622155623155624155625155626155627155628155629155630155631155632155633155634155635155636155637155638155639155640155641155642155643155644155645155646155647155648155649155650155651155652155653155654155655155656155657155658155659155660155661155662155663155664155665155666155667155668155669155670155671155672155673155674155675155676155677155678155679155680155681155682155683155684155685155686155687155688155689155690155691155692155693155694155695155696155697155698155699155700155701155702155703155704155705155706155707155708155709155710155711155712155713155714155715155716155717155718155719155720155721155722155723155724155725155726155727155728155729155730155731155732155733155734155735155736155737155738155739155740155741155742155743155744155745155746155747155748155749155750155751155752155753155754155755155756155757155758155759155760155761155762155763155764155765155766155767155768155769155770155771155772155773155774155775155776155777155778155779155780155781155782155783155784155785155786155787155788155789155790155791155792155793155794155795155796155797155798155799155800155801155802155803155804155805155806155807155808155809155810155811155812155813155814155815155816155817155818155819155820155821155822155823155824155825155826155827155828155829155830155831155832155833155834155835155836155837155838155839155840155841155842155843155844155845155846155847155848155849155850155851155852155853155854155855155856155857155858155859155860155861155862155863155864155865155866155867155868155869155870155871155872155873155874155875155876155877155878155879155880155881155882155883155884155885155886155887155888155889155890155891155892155893155894155895155896155897155898155899155900155901155902155903155904155905155906155907155908155909155910155911155912155913155914155915155916155917155918155919155920155921155922155923155924155925155926155927155928155929155930155931155932155933155934155935155936155937155938155939155940155941155942155943155944155945155946155947155948155949155950155951155952155953155954155955155956155957155958155959155960155961155962155963155964155965155966155967155968155969155970155971155972155973155974155975155976155977155978155979155980155981155982155983155984155985155986155987155988155989155990155991155992155993155994155995155996155997155998155999156000156001156002156003156004156005156006156007156008156009156010156011156012156013156014156015156016156017156018156019156020156021156022156023156024156025156026156027156028156029156030156031156032156033156034156035156036156037156038156039156040156041156042156043156044156045156046156047156048156049156050156051156052156053156054156055156056156057156058156059156060156061156062156063156064156065156066156067156068156069156070156071156072156073156074156075156076156077156078156079156080156081156082156083156084156085156086156087156088156089156090156091156092156093156094156095156096156097156098156099156100156101156102156103156104156105156106156107156108156109156110156111156112156113156114156115156116156117156118156119156120156121156122156123156124156125156126156127156128156129156130156131156132156133156134156135156136156137156138156139156140156141156142156143156144156145156146156147156148156149156150156151156152156153156154156155156156156157156158156159156160156161156162156163156164156165156166156167156168156169156170156171156172156173156174156175156176156177156178156179156180156181156182156183156184156185156186156187156188156189156190156191156192156193156194156195156196156197156198156199156200156201156202156203156204156205156206156207156208156209156210156211156212156213156214156215156216156217156218156219156220156221156222156223156224156225156226156227156228156229156230156231156232156233156234156235156236156237156238156239156240156241156242156243156244156245156246156247156248156249156250156251156252156253156254156255156256156257156258156259156260156261156262156263156264156265156266156267156268156269156270156271156272156273156274156275156276156277156278156279156280156281156282156283156284156285156286156287156288156289156290156291156292156293156294156295156296156297156298156299156300156301156302156303156304156305156306156307156308156309156310156311156312156313156314156315156316156317156318156319156320156321156322156323156324156325156326156327156328156329156330156331156332156333156334156335156336156337156338156339156340156341156342156343156344156345156346156347156348156349156350156351156352156353156354156355156356156357156358156359156360156361156362156363156364156365156366156367156368156369156370156371156372156373156374156375156376156377156378156379156380156381156382156383156384156385156386156387156388156389156390156391156392156393156394156395156396156397156398156399156400156401156402156403156404156405156406156407156408156409156410156411156412156413156414156415156416156417156418156419156420156421156422156423156424156425156426156427156428156429156430156431156432156433156434156435156436156437156438156439156440156441156442156443156444156445156446156447156448156449156450156451156452156453156454156455156456156457156458156459156460156461156462156463156464156465156466156467156468156469156470156471156472156473156474156475156476156477156478156479156480156481156482156483156484156485156486156487156488156489156490156491156492156493156494156495156496156497156498156499156500156501156502156503156504156505156506156507156508156509156510156511156512156513156514156515156516156517156518156519156520156521156522156523156524156525156526156527156528156529156530156531156532156533156534156535156536156537156538156539156540156541156542156543156544156545156546156547156548156549156550156551156552156553156554156555156556156557156558156559156560156561156562156563156564156565156566156567156568156569156570156571156572156573156574156575156576156577156578156579156580156581156582156583156584156585156586156587156588156589156590156591156592156593156594156595156596156597156598156599156600156601156602156603156604156605156606156607156608156609156610156611156612156613156614156615156616156617156618156619156620156621156622156623156624156625156626156627156628156629156630156631156632156633156634156635156636156637156638156639156640156641156642156643156644156645156646156647156648156649156650156651156652156653156654156655156656156657156658156659156660156661156662156663156664156665156666156667156668156669156670156671156672156673156674156675156676156677156678156679156680156681156682156683156684156685156686156687156688156689156690156691156692156693156694156695156696156697156698156699156700156701156702156703156704156705156706156707156708156709156710156711156712156713156714156715156716156717156718156719156720156721156722156723156724156725156726156727156728156729156730156731156732156733156734156735156736156737156738156739156740156741156742156743156744156745156746156747156748156749156750156751156752156753156754156755156756156757156758156759156760156761156762156763156764156765156766156767156768156769156770156771156772156773156774156775156776156777156778156779156780156781156782156783156784156785156786156787156788156789156790156791156792156793156794156795156796156797156798156799156800156801156802156803156804156805156806156807156808156809156810156811156812156813156814156815156816156817156818156819156820156821156822156823156824156825156826156827156828156829156830156831156832156833156834156835156836156837156838156839156840156841156842156843156844156845156846156847156848156849156850156851156852156853156854156855156856156857156858156859156860156861156862156863156864156865156866156867156868156869156870156871156872156873156874156875156876156877156878156879156880156881156882156883156884156885156886156887156888156889156890156891156892156893156894156895156896156897156898156899156900156901156902156903156904156905156906156907156908156909156910156911156912156913156914156915156916156917156918156919156920156921156922156923156924156925156926156927156928156929156930156931156932156933156934156935156936156937156938156939156940156941156942156943156944156945156946156947156948156949156950156951156952156953156954156955156956156957156958156959156960156961156962156963156964156965156966156967156968156969156970156971156972156973156974156975156976156977156978156979156980156981156982156983156984156985156986156987156988156989156990156991156992156993156994156995156996156997156998156999157000157001157002157003157004157005157006157007157008157009157010157011157012157013157014157015157016157017157018157019157020157021157022157023157024157025157026157027157028157029157030157031157032157033157034157035157036157037157038157039157040157041157042157043157044157045157046157047157048157049157050157051157052157053157054157055157056157057157058157059157060157061157062157063157064157065157066157067157068157069157070157071157072157073157074157075157076157077157078157079157080157081157082157083157084157085157086157087157088157089157090157091157092157093157094157095157096157097157098157099157100157101157102157103157104157105157106157107157108157109157110157111157112157113157114157115157116157117157118157119157120157121157122157123157124157125157126157127157128157129157130157131157132157133157134157135157136157137157138157139157140157141157142157143157144157145157146157147157148157149157150157151157152157153157154157155157156157157157158157159157160157161157162157163157164157165157166157167157168157169157170157171157172157173157174157175157176157177157178157179157180157181157182157183157184157185157186157187157188157189157190157191157192157193157194157195157196157197157198157199157200157201157202157203157204157205157206157207157208157209157210157211157212157213157214157215157216157217157218157219157220157221157222157223157224157225157226157227157228157229157230157231157232157233157234157235157236157237157238157239157240157241157242157243157244157245157246157247157248157249157250157251157252157253157254157255157256157257157258157259157260157261157262157263157264157265157266157267157268157269157270157271157272157273157274157275157276157277157278157279157280157281157282157283157284157285157286157287157288157289157290157291157292157293157294157295157296157297157298157299157300157301157302157303157304157305157306157307157308157309157310157311157312157313157314157315157316157317157318157319157320157321157322157323157324157325157326157327157328157329157330157331157332157333157334157335157336157337157338157339157340157341157342157343157344157345157346157347157348157349157350157351157352157353157354157355157356157357157358157359157360157361157362157363157364157365157366157367157368157369157370157371157372157373157374157375157376157377157378157379157380157381157382157383157384157385157386157387157388157389157390157391157392157393157394157395157396157397157398157399157400157401157402157403157404157405157406157407157408157409157410157411157412157413157414157415157416157417157418157419157420157421157422157423157424157425157426157427157428157429157430157431157432157433157434157435157436157437157438157439157440157441157442157443157444157445157446157447157448157449157450157451157452157453157454157455157456157457157458157459157460157461157462157463157464157465157466157467157468157469157470157471157472157473157474157475157476157477157478157479157480157481157482157483157484157485157486157487157488157489157490157491157492157493157494157495157496157497157498157499157500157501157502157503157504157505157506157507157508157509157510157511157512157513157514157515157516157517157518157519157520157521157522157523157524157525157526157527157528157529157530157531157532157533157534157535157536157537157538157539157540157541157542157543157544157545157546157547157548157549157550157551157552157553157554157555157556157557157558157559157560157561157562157563157564157565157566157567157568157569157570157571157572157573157574157575157576157577157578157579157580157581157582157583157584157585157586157587157588157589157590157591157592157593157594157595157596157597157598157599157600157601157602157603157604157605157606157607157608157609157610157611157612157613157614157615157616157617157618157619157620157621157622157623157624157625157626157627157628157629157630157631157632157633157634157635157636157637157638157639157640157641157642157643157644157645157646157647157648157649157650157651157652157653157654157655157656157657157658157659157660157661157662157663157664157665157666157667157668157669157670157671157672157673157674157675157676157677157678157679157680157681157682157683157684157685157686157687157688157689157690157691157692157693157694157695157696157697157698157699157700157701157702157703157704157705157706157707157708157709157710157711157712157713157714157715157716157717157718157719157720157721157722157723157724157725157726157727157728157729157730157731157732157733157734157735157736157737157738157739157740157741157742157743157744157745157746157747157748157749157750157751157752157753157754157755157756157757157758157759157760157761157762157763157764157765157766157767157768157769157770157771157772157773157774157775157776157777157778157779157780157781157782157783157784157785157786157787157788157789157790157791157792157793157794157795157796157797157798157799157800157801157802157803157804157805157806157807157808157809157810157811157812157813157814157815157816157817157818157819157820157821157822157823157824157825157826157827157828157829157830157831157832157833157834157835157836157837157838157839157840157841157842157843157844157845157846157847157848157849157850157851157852157853157854157855157856157857157858157859157860157861157862157863157864157865157866157867157868157869157870157871157872157873157874157875157876157877157878157879157880157881157882157883157884157885157886157887157888157889157890157891157892157893157894157895157896157897157898157899157900157901157902157903157904157905157906157907157908157909157910157911157912157913157914157915157916157917157918157919157920157921157922157923157924157925157926157927157928157929157930157931157932157933157934157935157936157937157938157939157940157941157942157943157944157945157946157947157948157949157950157951157952157953157954157955157956157957157958157959157960157961157962157963157964157965157966157967157968157969157970157971157972157973157974157975157976157977157978157979157980157981157982157983157984157985157986157987157988157989157990157991157992157993157994157995157996157997157998157999158000158001158002158003158004158005158006158007158008158009158010158011158012158013158014158015158016158017158018158019158020158021158022158023158024158025158026158027158028158029158030158031158032158033158034158035158036158037158038158039158040158041158042158043158044158045158046158047158048158049158050158051158052158053158054158055158056158057158058158059158060158061158062158063158064158065158066158067158068158069158070158071158072158073158074158075158076158077158078158079158080158081158082158083158084158085158086158087158088158089158090158091158092158093158094158095158096158097158098158099158100158101158102158103158104158105158106158107158108158109158110158111158112158113158114158115158116158117158118158119158120158121158122158123158124158125158126158127158128158129158130158131158132158133158134158135158136158137158138158139158140158141158142158143158144158145158146158147158148158149158150158151158152158153158154158155158156158157158158158159158160158161158162158163158164158165158166158167158168158169158170158171158172158173158174158175158176158177158178158179158180158181158182158183158184158185158186158187158188158189158190158191158192158193158194158195158196158197158198158199158200158201158202158203158204158205158206158207158208158209158210158211158212158213158214158215158216158217158218158219158220158221158222158223158224158225158226158227158228158229158230158231158232158233158234158235158236158237158238158239158240158241158242158243158244158245158246158247158248158249158250158251158252158253158254158255158256158257158258158259158260158261158262158263158264158265158266158267158268158269158270158271158272158273158274158275158276158277158278158279158280158281158282158283158284158285158286158287158288158289158290158291158292158293158294158295158296158297158298158299158300158301158302158303158304158305158306158307158308158309158310158311158312158313158314158315158316158317158318158319158320158321158322158323158324158325158326158327158328158329158330158331158332158333158334158335158336158337158338158339158340158341158342158343158344158345158346158347158348158349158350158351158352158353158354158355158356158357158358158359158360158361158362158363158364158365158366158367158368158369158370158371158372158373158374158375158376158377158378158379158380158381158382158383158384158385158386158387158388158389158390158391158392158393158394158395158396158397158398158399158400158401158402158403158404158405158406158407158408158409158410158411158412158413158414158415158416158417158418158419158420158421158422158423158424158425158426158427158428158429158430158431158432158433158434158435158436158437158438158439158440158441158442158443158444158445158446158447158448158449158450158451158452158453158454158455158456158457158458158459158460158461158462158463158464158465158466158467158468158469158470158471158472158473158474158475158476158477158478158479158480158481158482158483158484158485158486158487158488158489158490158491158492158493158494158495158496158497158498158499158500158501158502158503158504158505158506158507158508158509158510158511158512158513158514158515158516158517158518158519158520158521158522158523158524158525158526158527158528158529158530158531158532158533158534158535158536158537158538158539158540158541158542158543158544158545158546158547158548158549158550158551158552158553158554158555158556158557158558158559158560158561158562158563158564158565158566158567158568158569158570158571158572158573158574158575158576158577158578158579158580158581158582158583158584158585158586158587158588158589158590158591158592158593158594158595158596158597158598158599158600158601158602158603158604158605158606158607158608158609158610158611158612158613158614158615158616158617158618158619158620158621158622158623158624158625158626158627158628158629158630158631158632158633158634158635158636158637158638158639158640158641158642158643158644158645158646158647158648158649158650158651158652158653158654158655158656158657158658158659158660158661158662158663158664158665158666158667158668158669158670158671158672158673158674158675158676158677158678158679158680158681158682158683158684158685158686158687158688158689158690158691158692158693158694158695158696158697158698158699158700158701158702158703158704158705158706158707158708158709158710158711158712158713158714158715158716158717158718158719158720158721158722158723158724158725158726158727158728158729158730158731158732158733158734158735158736158737158738158739158740158741158742158743158744158745158746158747158748158749158750158751158752158753158754158755158756158757158758158759158760158761158762158763158764158765158766158767158768158769158770158771158772158773158774158775158776158777158778158779158780158781158782158783158784158785158786158787158788158789158790158791158792158793158794158795158796158797158798158799158800158801158802158803158804158805158806158807158808158809158810158811158812158813158814158815158816158817158818158819158820158821158822158823158824158825158826158827158828158829158830158831158832158833158834158835158836158837158838158839158840158841158842158843158844158845158846158847158848158849158850158851158852158853158854158855158856158857158858158859158860158861158862158863158864158865158866158867158868158869158870158871158872158873158874158875158876158877158878158879158880158881158882158883158884158885158886158887158888158889158890158891158892158893158894158895158896158897158898158899158900158901158902158903158904158905158906158907158908158909158910158911158912158913158914158915158916158917158918158919158920158921158922158923158924158925158926158927158928158929158930158931158932158933158934158935158936158937158938158939158940158941158942158943158944158945158946158947158948158949158950158951158952158953158954158955158956158957158958158959158960158961158962158963158964158965158966158967158968158969158970158971158972158973158974158975158976158977158978158979158980158981158982158983158984158985158986158987158988158989158990158991158992158993158994158995158996158997158998158999159000159001159002159003159004159005159006159007159008159009159010159011159012159013159014159015159016159017159018159019159020159021159022159023159024159025159026159027159028159029159030159031159032159033159034159035159036159037159038159039159040159041159042159043159044159045159046159047159048159049159050159051159052159053159054159055159056159057159058159059159060159061159062159063159064159065159066159067159068159069159070159071159072159073159074159075159076159077159078159079159080159081159082159083159084159085159086159087159088159089159090159091159092159093159094159095159096159097159098159099159100159101159102159103159104159105159106159107159108159109159110159111159112159113159114159115159116159117159118159119159120159121159122159123159124159125159126159127159128159129159130159131159132159133159134159135159136159137159138159139159140159141159142159143159144159145159146159147159148159149159150159151159152159153159154159155159156159157159158159159159160159161159162159163159164159165159166159167159168159169159170159171159172159173159174159175159176159177159178159179159180159181159182159183159184159185159186159187159188159189159190159191159192159193159194159195159196159197159198159199159200159201159202159203159204159205159206159207159208159209159210159211159212159213159214159215159216159217159218159219159220159221159222159223159224159225159226159227159228159229159230159231159232159233159234159235159236159237159238159239159240159241159242159243159244159245159246159247159248159249159250159251159252159253159254159255159256159257159258159259159260159261159262159263159264159265159266159267159268159269159270159271159272159273159274159275159276159277159278159279159280159281159282159283159284159285159286159287159288159289159290159291159292159293159294159295159296159297159298159299159300159301159302159303159304159305159306159307159308159309159310159311159312159313159314159315159316159317159318159319159320159321159322159323159324159325159326159327159328159329159330159331159332159333159334159335159336159337159338159339159340159341159342159343159344159345159346159347159348159349159350159351159352159353159354159355159356159357159358159359159360159361159362159363159364159365159366159367159368159369159370159371159372159373159374159375159376159377159378159379159380159381159382159383159384159385159386159387159388159389159390159391159392159393159394159395159396159397159398159399159400159401159402159403159404159405159406159407159408159409159410159411159412159413159414159415159416159417159418159419159420159421159422159423159424159425159426159427159428159429159430159431159432159433159434159435159436159437159438159439159440159441159442159443159444159445159446159447159448159449159450159451159452159453159454159455159456159457159458159459159460159461159462159463159464159465159466159467159468159469159470159471159472159473159474159475159476159477159478159479159480159481159482159483159484159485159486159487159488159489159490159491159492159493159494159495159496159497159498159499159500159501159502159503159504159505159506159507159508159509159510159511159512159513159514159515159516159517159518159519159520159521159522159523159524159525159526159527159528159529159530159531159532159533159534159535159536159537159538159539159540159541159542159543159544159545159546159547159548159549159550159551159552159553159554159555159556159557159558159559159560159561159562159563159564159565159566159567159568159569159570159571159572159573159574159575159576159577159578159579159580159581159582159583159584159585159586159587159588159589159590159591159592159593159594159595159596159597159598159599159600159601159602159603159604159605159606159607159608159609159610159611159612159613159614159615159616159617159618159619159620159621159622159623159624159625159626159627159628159629159630159631159632159633159634159635159636159637159638159639159640159641159642159643159644159645159646159647159648159649159650159651159652159653159654159655159656159657159658159659159660159661159662159663159664159665159666159667159668159669159670159671159672159673159674159675159676159677159678159679159680159681159682159683159684159685159686159687159688159689159690159691159692159693159694159695159696159697159698159699159700159701159702159703159704159705159706159707159708159709159710159711159712159713159714159715159716159717159718159719159720159721159722159723159724159725159726159727159728159729159730159731159732159733159734159735159736159737159738159739159740159741159742159743159744159745159746159747159748159749159750159751159752159753159754159755159756159757159758159759159760159761159762159763159764159765159766159767159768159769159770159771159772159773159774159775159776159777159778159779159780159781159782159783159784159785159786159787159788159789159790159791159792159793159794159795159796159797159798159799159800159801159802159803159804159805159806159807159808159809159810159811159812159813159814159815159816159817159818159819159820159821159822159823159824159825159826159827159828159829159830159831159832159833159834159835159836159837159838159839159840159841159842159843159844159845159846159847159848159849159850159851159852159853159854159855159856159857159858159859159860159861159862159863159864159865159866159867159868159869159870159871159872159873159874159875159876159877159878159879159880159881159882159883159884159885159886159887159888159889159890159891159892159893159894159895159896159897159898159899159900159901159902159903159904159905159906159907159908159909159910159911159912159913159914159915159916159917159918159919159920159921159922159923159924159925159926159927159928159929159930159931159932159933159934159935159936159937159938159939159940159941159942159943159944159945159946159947159948159949159950159951159952159953159954159955159956159957159958159959159960159961159962159963159964159965159966159967159968159969159970159971159972159973159974159975159976159977159978159979159980159981159982159983159984159985159986159987159988159989159990159991159992159993159994159995159996159997159998159999160000160001160002160003160004160005160006160007160008160009160010160011160012160013160014160015160016160017160018160019160020160021160022160023160024160025160026160027160028160029160030160031160032160033160034160035160036160037160038160039160040160041160042160043160044160045160046160047160048160049160050160051160052160053160054160055160056160057160058160059160060160061160062160063160064160065160066160067160068160069160070160071160072160073160074160075160076160077160078160079160080160081160082160083160084160085160086160087160088160089160090160091160092160093160094160095160096160097160098160099160100160101160102160103160104160105160106160107160108160109160110160111160112160113160114160115160116160117160118160119160120160121160122160123160124160125160126160127160128160129160130160131160132160133160134160135160136160137160138160139160140160141160142160143160144160145160146160147160148160149160150160151160152160153160154160155160156160157160158160159160160160161160162160163160164160165160166160167160168160169160170160171160172160173160174160175160176160177160178160179160180160181160182160183160184160185160186160187160188160189160190160191160192160193160194160195160196160197160198160199160200160201160202160203160204160205160206160207160208160209160210160211160212160213160214160215160216160217160218160219160220160221160222160223160224160225160226160227160228160229160230160231160232160233160234160235160236160237160238160239160240160241160242160243160244160245160246160247160248160249160250160251160252160253160254160255160256160257160258160259160260160261160262160263160264160265160266160267160268160269160270160271160272160273160274160275160276160277160278160279160280160281160282160283160284160285160286160287160288160289160290160291160292160293160294160295160296160297160298160299160300160301160302160303160304160305160306160307160308160309160310160311160312160313160314160315160316160317160318160319160320160321160322160323160324160325160326160327160328160329160330160331160332160333160334160335160336160337160338160339160340160341160342160343160344160345160346160347160348160349160350160351160352160353160354160355160356160357160358160359160360160361160362160363160364160365160366160367160368160369160370160371160372160373160374160375160376160377160378160379160380160381160382160383160384160385160386160387160388160389160390160391160392160393160394160395160396160397160398160399160400160401160402160403160404160405160406160407160408160409160410160411160412160413160414160415160416160417160418160419160420160421160422160423160424160425160426160427160428160429160430160431160432160433160434160435160436160437160438160439160440160441160442160443160444160445160446160447160448160449160450160451160452160453160454160455160456160457160458160459160460160461160462160463160464160465160466160467160468160469160470160471160472160473160474160475160476160477160478160479160480160481160482160483160484160485160486160487160488160489160490160491160492160493160494160495160496160497160498160499160500160501160502160503160504160505160506160507160508160509160510160511160512160513160514160515160516160517160518160519160520160521160522160523160524160525160526160527160528160529160530160531160532160533160534160535160536160537160538160539160540160541160542160543160544160545160546160547160548160549160550160551160552160553160554160555160556160557160558160559160560160561160562160563160564160565160566160567160568160569160570160571160572160573160574160575160576160577160578160579160580160581160582160583160584160585160586160587160588160589160590160591160592160593160594160595160596160597160598160599160600160601160602160603160604160605160606160607160608160609160610160611160612160613160614160615160616160617160618160619160620160621160622160623160624160625160626160627160628160629160630160631160632160633160634160635160636160637160638160639160640160641160642160643160644160645160646160647160648160649160650160651160652160653160654160655160656160657160658160659160660160661160662160663160664160665160666160667160668160669160670160671160672160673160674160675160676160677160678160679160680160681160682160683160684160685160686160687160688160689160690160691160692160693160694160695160696160697160698160699160700160701160702160703160704160705160706160707160708160709160710160711160712160713160714160715160716160717160718160719160720160721160722160723160724160725160726160727160728160729160730160731160732160733160734160735160736160737160738160739160740160741160742160743160744160745160746160747160748160749160750160751160752160753160754160755160756160757160758160759160760160761160762160763160764160765160766160767160768160769160770160771160772160773160774160775160776160777160778160779160780160781160782160783160784160785160786160787160788160789160790160791160792160793160794160795160796160797160798160799160800160801160802160803160804160805160806160807160808160809160810160811160812160813160814160815160816160817160818160819160820160821160822160823160824160825160826160827160828160829160830160831160832160833160834160835160836160837160838160839160840160841160842160843160844160845160846160847160848160849160850160851160852160853160854160855160856160857160858160859160860160861160862160863160864160865160866160867160868160869160870160871160872160873160874160875160876160877160878160879160880160881160882160883160884160885160886160887160888160889160890160891160892160893160894160895160896160897160898160899160900160901160902160903160904160905160906160907160908160909160910160911160912160913160914160915160916160917160918160919160920160921160922160923160924160925160926160927160928160929160930160931160932160933160934160935160936160937160938160939160940160941160942160943160944160945160946160947160948160949160950160951160952160953160954160955160956160957160958160959160960160961160962160963160964160965160966160967160968160969160970160971160972160973160974160975160976160977160978160979160980160981160982160983160984160985160986160987160988160989160990160991160992160993160994160995160996160997160998160999161000161001161002161003161004161005161006161007161008161009161010161011161012161013161014161015161016161017161018161019161020161021161022161023161024161025161026161027161028161029161030161031161032161033161034161035161036161037161038161039161040161041161042161043161044161045161046161047161048161049161050161051161052161053161054161055161056161057161058161059161060161061161062161063161064161065161066161067161068161069161070161071161072161073161074161075161076161077161078161079161080161081161082161083161084161085161086161087161088161089161090161091161092161093161094161095161096161097161098161099161100161101161102161103161104161105161106161107161108161109161110161111161112161113161114161115161116161117161118161119161120161121161122161123161124161125161126161127161128161129161130161131161132161133161134161135161136161137161138161139161140161141161142161143161144161145161146161147161148161149161150161151161152161153161154161155161156161157161158161159161160161161161162161163161164161165161166161167161168161169161170161171161172161173161174161175161176161177161178161179161180161181161182161183161184161185161186161187161188161189161190161191161192161193161194161195161196161197161198161199161200161201161202161203161204161205161206161207161208161209161210161211161212161213161214161215161216161217161218161219161220161221161222161223161224161225161226161227161228161229161230161231161232161233161234161235161236161237161238161239161240161241161242161243161244161245161246161247161248161249161250161251161252161253161254161255161256161257161258161259161260161261161262161263161264161265161266161267161268161269161270161271161272161273161274161275161276161277161278161279161280161281161282161283161284161285161286161287161288161289161290161291161292161293161294161295161296161297161298161299161300161301161302161303161304161305161306161307161308161309161310161311161312161313161314161315161316161317161318161319161320161321161322161323161324161325161326161327161328161329161330161331161332161333161334161335161336161337161338161339161340161341161342161343161344161345161346161347161348161349161350161351161352161353161354161355161356161357161358161359161360161361161362161363161364161365161366161367161368161369161370161371161372161373161374161375161376161377161378161379161380161381161382161383161384161385161386161387161388161389161390161391161392161393161394161395161396161397161398161399161400161401161402161403161404161405161406161407161408161409161410161411161412161413161414161415161416161417161418161419161420161421161422161423161424161425161426161427161428161429161430161431161432161433161434161435161436161437161438161439161440161441161442161443161444161445161446161447161448161449161450161451161452161453161454161455161456161457161458161459161460161461161462161463161464161465161466161467161468161469161470161471161472161473161474161475161476161477161478161479161480161481161482161483161484161485161486161487161488161489161490161491161492161493161494161495161496161497161498161499161500161501161502161503161504161505161506161507161508161509161510161511161512161513161514161515161516161517161518161519161520161521161522161523161524161525161526161527161528161529161530161531161532161533161534161535161536161537161538161539161540161541161542161543161544161545161546161547161548161549161550161551161552161553161554161555161556161557161558161559161560161561161562161563161564161565161566161567161568161569161570161571161572161573161574161575161576161577161578161579161580161581161582161583161584161585161586161587161588161589161590161591161592161593161594161595161596161597161598161599161600161601161602161603161604161605161606161607161608161609161610161611161612161613161614161615161616161617161618161619161620161621161622161623161624161625161626161627161628161629161630161631161632161633161634161635161636161637161638161639161640161641161642161643161644161645161646161647161648161649161650161651161652161653161654161655161656161657161658161659161660161661161662161663161664161665161666161667161668161669161670161671161672161673161674161675161676161677161678161679161680161681161682161683161684161685161686161687161688161689161690161691161692161693161694161695161696161697161698161699161700161701161702161703161704161705161706161707161708161709161710161711161712161713161714161715161716161717161718161719161720161721161722161723161724161725161726161727161728161729161730161731161732161733161734161735161736161737161738161739161740161741161742161743161744161745161746161747161748161749161750161751161752161753161754161755161756161757161758161759161760161761161762161763161764161765161766161767161768161769161770161771161772161773161774161775161776161777161778161779161780161781161782161783161784161785161786161787161788161789161790161791161792161793161794161795161796161797161798161799161800161801161802161803161804161805161806161807161808161809161810161811161812161813161814161815161816161817161818161819161820161821161822161823161824161825161826161827161828161829161830161831161832161833161834161835161836161837161838161839161840161841161842161843161844161845161846161847161848161849161850161851161852161853161854161855161856161857161858161859161860161861161862161863161864161865161866161867161868161869161870161871161872161873161874161875161876161877161878161879161880161881161882161883161884161885161886161887161888161889161890161891161892161893161894161895161896161897161898161899161900161901161902161903161904161905161906161907161908161909161910161911161912161913161914161915161916161917161918161919161920161921161922161923161924161925161926161927161928161929161930161931161932161933161934161935161936161937161938161939161940161941161942161943161944161945161946161947161948161949161950161951161952161953161954161955161956161957161958161959161960161961161962161963161964161965161966161967161968161969161970161971161972161973161974161975161976161977161978161979161980161981161982161983161984161985161986161987161988161989161990161991161992161993161994161995161996161997161998161999162000162001162002162003162004162005162006162007162008162009162010162011162012162013162014162015162016162017162018162019162020162021162022162023162024162025162026162027162028162029162030162031162032162033162034162035162036162037162038162039162040162041162042162043162044162045162046162047162048162049162050162051162052162053162054162055162056162057162058162059162060162061162062162063162064162065162066162067162068162069162070162071162072162073162074162075162076162077162078162079162080162081162082162083162084162085162086162087162088162089162090162091162092162093162094162095162096162097162098162099162100162101162102162103162104162105162106162107162108162109162110162111162112162113162114162115162116162117162118162119162120162121162122162123162124162125162126162127162128162129162130162131162132162133162134162135162136162137162138162139162140162141162142162143162144162145162146162147162148162149162150162151162152162153162154162155162156162157162158162159162160162161162162162163162164162165162166162167162168162169162170162171162172162173162174162175162176162177162178162179162180162181162182162183162184162185162186162187162188162189162190162191162192162193162194162195162196162197162198162199162200162201162202162203162204162205162206162207162208162209162210162211162212162213162214162215162216162217162218162219162220162221162222162223162224162225162226162227162228162229162230162231162232162233162234162235162236162237162238162239162240162241162242162243162244162245162246162247162248162249162250162251162252162253162254162255162256162257162258162259162260162261162262162263162264162265162266162267162268162269162270162271162272162273162274162275162276162277162278162279162280162281162282162283162284162285162286162287162288162289162290162291162292162293162294162295162296162297162298162299162300162301162302162303162304162305162306162307162308162309162310162311162312162313162314162315162316162317162318162319162320162321162322162323162324162325162326162327162328162329162330162331162332162333162334162335162336162337162338162339162340162341162342162343162344162345162346162347162348162349162350162351162352162353162354162355162356162357162358162359162360162361162362162363162364162365162366162367162368162369162370162371162372162373162374162375162376162377162378162379162380162381162382162383162384162385162386162387162388162389162390162391162392162393162394162395162396162397162398162399162400162401162402162403162404162405162406162407162408162409162410162411162412162413162414162415162416162417162418162419162420162421162422162423162424162425162426162427162428162429162430162431162432162433162434162435162436162437162438162439162440162441162442162443162444162445162446162447162448162449162450162451162452162453162454162455162456162457162458162459162460162461162462162463162464162465162466162467162468162469162470162471162472162473162474162475162476162477162478162479162480162481162482162483162484162485162486162487162488162489162490162491162492162493162494162495162496162497162498162499162500162501162502162503162504162505162506162507162508162509162510162511162512162513162514162515162516162517162518162519162520162521162522162523162524162525162526162527162528162529162530162531162532162533162534162535162536162537162538162539162540162541162542162543162544162545162546162547162548162549162550162551162552162553162554162555162556162557162558162559162560162561162562162563162564162565162566162567162568162569162570162571162572162573162574162575162576162577162578162579162580162581162582162583162584162585162586162587162588162589162590162591162592162593162594162595162596162597162598162599162600162601162602162603162604162605162606162607162608162609162610162611162612162613162614162615162616162617162618162619162620162621162622162623162624162625162626162627162628162629162630162631162632162633162634162635162636162637162638162639162640162641162642162643162644162645162646162647162648162649162650162651162652162653162654162655162656162657162658162659162660162661162662162663162664162665162666162667162668162669162670162671162672162673162674162675162676162677162678162679162680162681162682162683162684162685162686162687162688162689162690162691162692162693162694162695162696162697162698162699162700162701162702162703162704162705162706162707162708162709162710162711162712162713162714162715162716162717162718162719162720162721162722162723162724162725162726162727162728162729162730162731162732162733162734162735162736162737162738162739162740162741162742162743162744162745162746162747162748162749162750162751162752162753162754162755162756162757162758162759162760162761162762162763162764162765162766162767162768162769162770162771162772162773162774162775162776162777162778162779162780162781162782162783162784162785162786162787162788162789162790162791162792162793162794162795162796162797162798162799162800162801162802162803162804162805162806162807162808162809162810162811162812162813162814162815162816162817162818162819162820162821162822162823162824162825162826162827162828162829162830162831162832162833162834162835162836162837162838162839162840162841162842162843162844162845162846162847162848162849162850162851162852162853162854162855162856162857162858162859162860162861162862162863162864162865162866162867162868162869162870162871162872162873162874162875162876162877162878162879162880162881162882162883162884162885162886162887162888162889162890162891162892162893162894162895162896162897162898162899162900162901162902162903162904162905162906162907162908162909162910162911162912162913162914162915162916162917162918162919162920162921162922162923162924162925162926162927162928162929162930162931162932162933162934162935162936162937162938162939162940162941162942162943162944162945162946162947162948162949162950162951162952162953162954162955162956162957162958162959162960162961162962162963162964162965162966162967162968162969162970162971162972162973162974162975162976162977162978162979162980162981162982162983162984162985162986162987162988162989162990162991162992162993162994162995162996162997162998162999163000163001163002163003163004163005163006163007163008163009163010163011163012163013163014163015163016163017163018163019163020163021163022163023163024163025163026163027163028163029163030163031163032163033163034163035163036163037163038163039163040163041163042163043163044163045163046163047163048163049163050163051163052163053163054163055163056163057163058163059163060163061163062163063163064163065163066163067163068163069163070163071163072163073163074163075163076163077163078163079163080163081163082163083163084163085163086163087163088163089163090163091163092163093163094163095163096163097163098163099163100163101163102163103163104163105163106163107163108163109163110163111163112163113163114163115163116163117163118163119163120163121163122163123163124163125163126163127163128163129163130163131163132163133163134163135163136163137163138163139163140163141163142163143163144163145163146163147163148163149163150163151163152163153163154163155163156163157163158163159163160163161163162163163163164163165163166163167163168163169163170163171163172163173163174163175163176163177163178163179163180163181163182163183163184163185163186163187163188163189163190163191163192163193163194163195163196163197163198163199163200163201163202163203163204163205163206163207163208163209163210163211163212163213163214163215163216163217163218163219163220163221163222163223163224163225163226163227163228163229163230163231163232163233163234163235163236163237163238163239163240163241163242163243163244163245163246163247163248163249163250163251163252163253163254163255163256163257163258163259163260163261163262163263163264163265163266163267163268163269163270163271163272163273163274163275163276163277163278163279163280163281163282163283163284163285163286163287163288163289163290163291163292163293163294163295163296163297163298163299163300163301163302163303163304163305163306163307163308163309163310163311163312163313163314163315163316163317163318163319163320163321163322163323163324163325163326163327163328163329163330163331163332163333163334163335163336163337163338163339163340163341163342163343163344163345163346163347163348163349163350163351163352163353163354163355163356163357163358163359163360163361163362163363163364163365163366163367163368163369163370163371163372163373163374163375163376163377163378163379163380163381163382163383163384163385163386163387163388163389163390163391163392163393163394163395163396163397163398163399163400163401163402163403163404163405163406163407163408163409163410163411163412163413163414163415163416163417163418163419163420163421163422163423163424163425163426163427163428163429163430163431163432163433163434163435163436163437163438163439163440163441163442163443163444163445163446163447163448163449163450163451163452163453163454163455163456163457163458163459163460163461163462163463163464163465163466163467163468163469163470163471163472163473163474163475163476163477163478163479163480163481163482163483163484163485163486163487163488163489163490163491163492163493163494163495163496163497163498163499163500163501163502163503163504163505163506163507163508163509163510163511163512163513163514163515163516163517163518163519163520163521163522163523163524163525163526163527163528163529163530163531163532163533163534163535163536163537163538163539163540163541163542163543163544163545163546163547163548163549163550163551163552163553163554163555163556163557163558163559163560163561163562163563163564163565163566163567163568163569163570163571163572163573163574163575163576163577163578163579163580163581163582163583163584163585163586163587163588163589163590163591163592163593163594163595163596163597163598163599163600163601163602163603163604163605163606163607163608163609163610163611163612163613163614163615163616163617163618163619163620163621163622163623163624163625163626163627163628163629163630163631163632163633163634163635163636163637163638163639163640163641163642163643163644163645163646163647163648163649163650163651163652163653163654163655163656163657163658163659163660163661163662163663163664163665163666163667163668163669163670163671163672163673163674163675163676163677163678163679163680163681163682163683163684163685163686163687163688163689163690163691163692163693163694163695163696163697163698163699163700163701163702163703163704163705163706163707163708163709163710163711163712163713163714163715163716163717163718163719163720163721163722163723163724163725163726163727163728163729163730163731163732163733163734163735163736163737163738163739163740163741163742163743163744163745163746163747163748163749163750163751163752163753163754163755163756163757163758163759163760163761163762163763163764163765163766163767163768163769163770163771163772163773163774163775163776163777163778163779163780163781163782163783163784163785163786163787163788163789163790163791163792163793163794163795163796163797163798163799163800163801163802163803163804163805163806163807163808163809163810163811163812163813163814163815163816163817163818163819163820163821163822163823163824163825163826163827163828163829163830163831163832163833163834163835163836163837163838163839163840163841163842163843163844163845163846163847163848163849163850163851163852163853163854163855163856163857163858163859163860163861163862163863163864163865163866163867163868163869163870163871163872163873163874163875163876163877163878163879163880163881163882163883163884163885163886163887163888163889163890163891163892163893163894163895163896163897163898163899163900163901163902163903163904163905163906163907163908163909163910163911163912163913163914163915163916163917163918163919163920163921163922163923163924163925163926163927163928163929163930163931163932163933163934163935163936163937163938163939163940163941163942163943163944163945163946163947163948163949163950163951163952163953163954163955163956163957163958163959163960163961163962163963163964163965163966163967163968163969163970163971163972163973163974163975163976163977163978163979163980163981163982163983163984163985163986163987163988163989163990163991163992163993163994163995163996163997163998163999164000164001164002164003164004164005164006164007164008164009164010164011164012164013164014164015164016164017164018164019164020164021164022164023164024164025164026164027164028164029164030164031164032164033164034164035164036164037164038164039164040164041164042164043164044164045164046164047164048164049164050164051164052164053164054164055164056164057164058164059164060164061164062164063164064164065164066164067164068164069164070164071164072164073164074164075164076164077164078164079164080164081164082164083164084164085164086164087164088164089164090164091164092164093164094164095164096164097164098164099164100164101164102164103164104164105164106164107164108164109164110164111164112164113164114164115164116164117164118164119164120164121164122164123164124164125164126164127164128164129164130164131164132164133164134164135164136164137164138164139164140164141164142164143164144164145164146164147164148164149164150164151164152164153164154164155164156164157164158164159164160164161164162164163164164164165164166164167164168164169164170164171164172164173164174164175164176164177164178164179164180164181164182164183164184164185164186164187164188164189164190164191164192164193164194164195164196164197164198164199164200164201164202164203164204164205164206164207164208164209164210164211164212164213164214164215164216164217164218164219164220164221164222164223164224164225164226164227164228164229164230164231164232164233164234164235164236164237164238164239164240164241164242164243164244164245164246164247164248164249164250164251164252164253164254164255164256164257164258164259164260164261164262164263164264164265164266164267164268164269164270164271164272164273164274164275164276164277164278164279164280164281164282164283164284164285164286164287164288164289164290164291164292164293164294164295164296164297164298164299164300164301164302164303164304164305164306164307164308164309164310164311164312164313164314164315164316164317164318164319164320164321164322164323164324164325164326164327164328164329164330164331164332164333164334164335164336164337164338164339164340164341164342164343164344164345164346164347164348164349164350164351164352164353164354164355164356164357164358164359164360164361164362164363164364164365164366164367164368164369164370164371164372164373164374164375164376164377164378164379164380164381164382164383164384164385164386164387164388164389164390164391164392164393164394164395164396164397164398164399164400164401164402164403164404164405164406164407164408164409164410164411164412164413164414164415164416164417164418164419164420164421164422164423164424164425164426164427164428164429164430164431164432164433164434164435164436164437164438164439164440164441164442164443164444164445164446164447164448164449164450164451164452164453164454164455164456164457164458164459164460164461164462164463164464164465164466164467164468164469164470164471164472164473164474164475164476164477164478164479164480164481164482164483164484164485164486164487164488164489164490164491164492164493164494164495164496164497164498164499164500164501164502164503164504164505164506164507164508164509164510164511164512164513164514164515164516164517164518164519164520164521164522164523164524164525164526164527164528164529164530164531164532164533164534164535164536164537164538164539164540164541164542164543164544164545164546164547164548164549164550164551164552164553164554164555164556164557164558164559164560164561164562164563164564164565164566164567164568164569164570164571164572164573164574164575164576164577164578164579164580164581164582164583164584164585164586164587164588164589164590164591164592164593164594164595164596164597164598164599164600164601164602164603164604164605164606164607164608164609164610164611164612164613164614164615164616164617164618164619164620164621164622164623164624164625164626164627164628164629164630164631164632164633164634164635164636164637164638164639164640164641164642164643164644164645164646164647164648164649164650164651164652164653164654164655164656164657164658164659164660164661164662164663164664164665164666164667164668164669164670164671164672164673164674164675164676164677164678164679164680164681164682164683164684164685164686164687164688164689164690164691164692164693164694164695164696164697164698164699164700164701164702164703164704164705164706164707164708164709164710164711164712164713164714164715164716164717164718164719164720164721164722164723164724164725164726164727164728164729164730164731164732164733164734164735164736164737164738164739164740164741164742164743164744164745164746164747164748164749164750164751164752164753164754164755164756164757164758164759164760164761164762164763164764164765164766164767164768164769164770164771164772164773164774164775164776164777164778164779164780164781164782164783164784164785164786164787164788164789164790164791164792164793164794164795164796164797164798164799164800164801164802164803164804164805164806164807164808164809164810164811164812164813164814164815164816164817164818164819164820164821164822164823164824164825164826164827164828164829164830164831164832164833164834164835164836164837164838164839164840164841164842164843164844164845164846164847164848164849164850164851164852164853164854164855164856164857164858164859164860164861164862164863164864164865164866164867164868164869164870164871164872164873164874164875164876164877164878164879164880164881164882164883164884164885164886164887164888164889164890164891164892164893164894164895164896164897164898164899164900164901164902164903164904164905164906164907164908164909164910164911164912164913164914164915164916164917164918164919164920164921164922164923164924164925164926164927164928164929164930164931164932164933164934164935164936164937164938164939164940164941164942164943164944164945164946164947164948164949164950164951164952164953164954164955164956164957164958164959164960164961164962164963164964164965164966164967164968164969164970164971164972164973164974164975164976164977164978164979164980164981164982164983164984164985164986164987164988164989164990164991164992164993164994164995164996164997164998164999165000165001165002165003165004165005165006165007165008165009165010165011165012165013165014165015165016165017165018165019165020165021165022165023165024165025165026165027165028165029165030165031165032165033165034165035165036165037165038165039165040165041165042165043165044165045165046165047165048165049165050165051165052165053165054165055165056165057165058165059165060165061165062165063165064165065165066165067165068165069165070165071165072165073165074165075165076165077165078165079165080165081165082165083165084165085165086165087165088165089165090165091165092165093165094165095165096165097165098165099165100165101165102165103165104165105165106165107165108165109165110165111165112165113165114165115165116165117165118165119165120165121165122165123165124165125165126165127165128165129165130165131165132165133165134165135165136165137165138165139165140165141165142165143165144165145165146165147165148165149165150165151165152165153165154165155165156165157165158165159165160165161165162165163165164165165165166165167165168165169165170165171165172165173165174165175165176165177165178165179165180165181165182165183165184165185165186165187165188165189165190165191165192165193165194165195165196165197165198165199165200165201165202165203165204165205165206165207165208165209165210165211165212165213165214165215165216165217165218165219165220165221165222165223165224165225165226165227165228165229165230165231165232165233165234165235165236165237165238165239165240165241165242165243165244165245165246165247165248165249165250165251165252165253165254165255165256165257165258165259165260165261165262165263165264165265165266165267165268165269165270165271165272165273165274165275165276165277165278165279165280165281165282165283165284165285165286165287165288165289165290165291165292165293165294165295165296165297165298165299165300165301165302165303165304165305165306165307165308165309165310165311165312165313165314165315165316165317165318165319165320165321165322165323165324165325165326165327165328165329165330165331165332165333165334165335165336165337165338165339165340165341165342165343165344165345165346165347165348165349165350165351165352165353165354165355165356165357165358165359165360165361165362165363165364165365165366165367165368165369165370165371165372165373165374165375165376165377165378165379165380165381165382165383165384165385165386165387165388165389165390165391165392165393165394165395165396165397165398165399165400165401165402165403165404165405165406165407165408165409165410165411165412165413165414165415165416165417165418165419165420165421165422165423165424165425165426165427165428165429165430165431165432165433165434165435165436165437165438165439165440165441165442165443165444165445165446165447165448165449165450165451165452165453165454165455165456165457165458165459165460165461165462165463165464165465165466165467165468165469165470165471165472165473165474165475165476165477165478165479165480165481165482165483165484165485165486165487165488165489165490165491165492165493165494165495165496165497165498165499165500165501165502165503165504165505165506165507165508165509165510165511165512165513165514165515165516165517165518165519165520165521165522165523165524165525165526165527165528165529165530165531165532165533165534165535165536165537165538165539165540165541165542165543165544165545165546165547165548165549165550165551165552165553165554165555165556165557165558165559165560165561165562165563165564165565165566165567165568165569165570165571165572165573165574165575165576165577165578165579165580165581165582165583165584165585165586165587165588165589165590165591165592165593165594165595165596165597165598165599165600165601165602165603165604165605165606165607165608165609165610165611165612165613165614165615165616165617165618165619165620165621165622165623165624165625165626165627165628165629165630165631165632165633165634165635165636165637165638165639165640165641165642165643165644165645165646165647165648165649165650165651165652165653165654165655165656165657165658165659165660165661165662165663165664165665165666165667165668165669165670165671165672165673165674165675165676165677165678165679165680165681165682165683165684165685165686165687165688165689165690165691165692165693165694165695165696165697165698165699165700165701165702165703165704165705165706165707165708165709165710165711165712165713165714165715165716165717165718165719165720165721165722165723165724165725165726165727165728165729165730165731165732165733165734165735165736165737165738165739165740165741165742165743165744165745165746165747165748165749165750165751165752165753165754165755165756165757165758165759165760165761165762165763165764165765165766165767165768165769165770165771165772165773165774165775165776165777165778165779165780165781165782165783165784165785165786165787165788165789165790165791165792165793165794165795165796165797165798165799165800165801165802165803165804165805165806165807165808165809165810165811165812165813165814165815165816165817165818165819165820165821165822165823165824165825165826165827165828165829165830165831165832165833165834165835165836165837165838165839165840165841165842165843165844165845165846165847165848165849165850165851165852165853165854165855165856165857165858165859165860165861165862165863165864165865165866165867165868165869165870165871165872165873165874165875165876165877165878165879165880165881165882165883165884165885165886165887165888165889165890165891165892165893165894165895165896165897165898165899165900165901165902165903165904165905165906165907165908165909165910165911165912165913165914165915165916165917165918165919165920165921165922165923165924165925165926165927165928165929165930165931165932165933165934165935165936165937165938165939165940165941165942165943165944165945165946165947165948165949165950165951165952165953165954165955165956165957165958165959165960165961165962165963165964165965165966165967165968165969165970165971165972165973165974165975165976165977165978165979165980165981165982165983165984165985165986165987165988165989165990165991165992165993165994165995165996165997165998165999166000166001166002166003166004166005166006166007166008166009166010166011166012166013166014166015166016166017166018166019166020166021166022166023166024166025166026166027166028166029166030166031166032166033166034166035166036166037166038166039166040166041166042166043166044166045166046166047166048166049166050166051166052166053166054166055166056166057166058166059166060166061166062166063166064166065166066166067166068166069166070166071166072166073166074166075166076166077166078166079166080166081166082166083166084166085166086166087166088166089166090166091166092166093166094166095166096166097166098166099166100166101166102166103166104166105166106166107166108166109166110166111166112166113166114166115166116166117166118166119166120166121166122166123166124166125166126166127166128166129166130166131166132166133166134166135166136166137166138166139166140166141166142166143166144166145166146166147166148166149166150166151166152166153166154166155166156166157166158166159166160166161166162166163166164166165166166166167166168166169166170166171166172166173166174166175166176166177166178166179166180166181166182166183166184166185166186166187166188166189166190166191166192166193166194166195166196166197166198166199166200166201166202166203166204166205166206166207166208166209166210166211166212166213166214166215166216166217166218166219166220166221166222166223166224166225166226166227166228166229166230166231166232166233166234166235166236166237166238166239166240166241166242166243166244166245166246166247166248166249166250166251166252166253166254166255166256166257166258166259166260166261166262166263166264166265166266166267166268166269166270166271166272166273166274166275166276166277166278166279166280166281166282166283166284166285166286166287166288166289166290166291166292166293166294166295166296166297166298166299166300166301166302166303166304166305166306166307166308166309166310166311166312166313166314166315166316166317166318166319166320166321166322166323166324166325166326166327166328166329166330166331166332166333166334166335166336166337166338166339166340166341166342166343166344166345166346166347166348166349166350166351166352166353166354166355166356166357166358166359166360166361166362166363166364166365166366166367166368166369166370166371166372166373166374166375166376166377166378166379166380166381166382166383166384166385166386166387166388166389166390166391166392166393166394166395166396166397166398166399166400166401166402166403166404166405166406166407166408166409166410166411166412166413166414166415166416166417166418166419166420166421166422166423166424166425166426166427166428166429166430166431166432166433166434166435166436166437166438166439166440166441166442166443166444166445166446166447166448166449166450166451166452166453166454166455166456166457166458166459166460166461166462166463166464166465166466166467166468166469166470166471166472166473166474166475166476166477166478166479166480166481166482166483166484166485166486166487166488166489166490166491166492166493166494166495166496166497166498166499166500166501166502166503166504166505166506166507166508166509166510166511166512166513166514166515166516166517166518166519166520166521166522166523166524166525166526166527166528166529166530166531166532166533166534166535166536166537166538166539166540166541166542166543166544166545166546166547166548166549166550166551166552166553166554166555166556166557166558166559166560166561166562166563166564166565166566166567166568166569166570166571166572166573166574166575166576166577166578166579166580166581166582166583166584166585166586166587166588166589166590166591166592166593166594166595166596166597166598166599166600166601166602166603166604166605166606166607166608166609166610166611166612166613166614166615166616166617166618166619166620166621166622166623166624166625166626166627166628166629166630166631166632166633166634166635166636166637166638166639166640166641166642166643166644166645166646166647166648166649166650166651166652166653166654166655166656166657166658166659166660166661166662166663166664166665166666166667166668166669166670166671166672166673166674166675166676166677166678166679166680166681166682166683166684166685166686166687166688166689166690166691166692166693166694166695166696166697166698166699166700166701166702166703166704166705166706166707166708166709166710166711166712166713166714166715166716166717166718166719166720166721166722166723166724166725166726166727166728166729166730166731166732166733166734166735166736166737166738166739166740166741166742166743166744166745166746166747166748166749166750166751166752166753166754166755166756166757166758166759166760166761166762166763166764166765166766166767166768166769166770166771166772166773166774166775166776166777166778166779166780166781166782166783166784166785166786166787166788166789166790166791166792166793166794166795166796166797166798166799166800166801166802166803166804166805166806166807166808166809166810166811166812166813166814166815166816166817166818166819166820166821166822166823166824166825166826166827166828166829166830166831166832166833166834166835166836166837166838166839166840166841166842166843166844166845166846166847166848166849166850166851166852166853166854166855166856166857166858166859166860166861166862166863166864166865166866166867166868166869166870166871166872166873166874166875166876166877166878166879166880166881166882166883166884166885166886166887166888166889166890166891166892166893166894166895166896166897166898166899166900166901166902166903166904166905166906166907166908166909166910166911166912166913166914166915166916166917166918166919166920166921166922166923166924166925166926166927166928166929166930166931166932166933166934166935166936166937166938166939166940166941166942166943166944166945166946166947166948166949166950166951166952166953166954166955166956166957166958166959166960166961166962166963166964166965166966166967166968166969166970166971166972166973166974166975166976166977166978166979166980166981166982166983166984166985166986166987166988166989166990166991166992166993166994166995166996166997166998166999167000167001167002167003167004167005167006167007167008167009167010167011167012167013167014167015167016167017167018167019167020167021167022167023167024167025167026167027167028167029167030167031167032167033167034167035167036167037167038167039167040167041167042167043167044167045167046167047167048167049167050167051167052167053167054167055167056167057167058167059167060167061167062167063167064167065167066167067167068167069167070167071167072167073167074167075167076167077167078167079167080167081167082167083167084167085167086167087167088167089167090167091167092167093167094167095167096167097167098167099167100167101167102167103167104167105167106167107167108167109167110167111167112167113167114167115167116167117167118167119167120167121167122167123167124167125167126167127167128167129167130167131167132167133167134167135167136167137167138167139167140167141167142167143167144167145167146167147167148167149167150167151167152167153167154167155167156167157167158167159167160167161167162167163167164167165167166167167167168167169167170167171167172167173167174167175167176167177167178167179167180167181167182167183167184167185167186167187167188167189167190167191167192167193167194167195167196167197167198167199167200167201167202167203167204167205167206167207167208167209167210167211167212167213167214167215167216167217167218167219167220167221167222167223167224167225167226167227167228167229167230167231167232167233167234167235167236167237167238167239167240167241167242167243167244167245167246167247167248167249167250167251167252167253167254167255167256167257167258167259167260167261167262167263167264167265167266167267167268167269167270167271167272167273167274167275167276167277167278167279167280167281167282167283167284167285167286167287167288167289167290167291167292167293167294167295167296167297167298167299167300167301167302167303167304167305167306167307167308167309167310167311167312167313167314167315167316167317167318167319167320167321167322167323167324167325167326167327167328167329167330167331167332167333167334167335167336167337167338167339167340167341167342167343167344167345167346167347167348167349167350167351167352167353167354167355167356167357167358167359167360167361167362167363167364167365167366167367167368167369167370167371167372167373167374167375167376167377167378167379167380167381167382167383167384167385167386167387167388167389167390167391167392167393167394167395167396167397167398167399167400167401167402167403167404167405167406167407167408167409167410167411167412167413167414167415167416167417167418167419167420167421167422167423167424167425167426167427167428167429167430167431167432167433167434167435167436167437167438167439167440167441167442167443167444167445167446167447167448167449167450167451167452167453167454167455167456167457167458167459167460167461167462167463167464167465167466167467167468167469167470167471167472167473167474167475167476167477167478167479167480167481167482167483167484167485167486167487167488167489167490167491167492167493167494167495167496167497167498167499167500167501167502167503167504167505167506167507167508167509167510167511167512167513167514167515167516167517167518167519167520167521167522167523167524167525167526167527167528167529167530167531167532167533167534167535167536167537167538167539167540167541167542167543167544167545167546167547167548167549167550167551167552167553167554167555167556167557167558167559167560167561167562167563167564167565167566167567167568167569167570167571167572167573167574167575167576167577167578167579167580167581167582167583167584167585167586167587167588167589167590167591167592167593167594167595167596167597167598167599167600167601167602167603167604167605167606167607167608167609167610167611167612167613167614167615167616167617167618167619167620167621167622167623167624167625167626167627167628167629167630167631167632167633167634167635167636167637167638167639167640167641167642167643167644167645167646167647167648167649167650167651167652167653167654167655167656167657167658167659167660167661167662167663167664167665167666167667167668167669167670167671167672167673167674167675167676167677167678167679167680167681167682167683167684167685167686167687167688167689167690167691167692167693167694167695167696167697167698167699167700167701167702167703167704167705167706167707167708167709167710167711167712167713167714167715167716167717167718167719167720167721167722167723167724167725167726167727167728167729167730167731167732167733167734167735167736167737167738167739167740167741167742167743167744167745167746167747167748167749167750167751167752167753167754167755167756167757167758167759167760167761167762167763167764167765167766167767167768167769167770167771167772167773167774167775167776167777167778167779167780167781167782167783167784167785167786167787167788167789167790167791167792167793167794167795167796167797167798167799167800167801167802167803167804167805167806167807167808167809167810167811167812167813167814167815167816167817167818167819167820167821167822167823167824167825167826167827167828167829167830167831167832167833167834167835167836167837167838167839167840167841167842167843167844167845167846167847167848167849167850167851167852167853167854167855167856167857167858167859167860167861167862167863167864167865167866167867167868167869167870167871167872167873167874167875167876167877167878167879167880167881167882167883167884167885167886167887167888167889167890167891167892167893167894167895167896167897167898167899167900167901167902167903167904167905167906167907167908167909167910167911167912167913167914167915167916167917167918167919167920167921167922167923167924167925167926167927167928167929167930167931167932167933167934167935167936167937167938167939167940167941167942167943167944167945167946167947167948167949167950167951167952167953167954167955167956167957167958167959167960167961167962167963167964167965167966167967167968167969167970167971167972167973167974167975167976167977167978167979167980167981167982167983167984167985167986167987167988167989167990167991167992167993167994167995167996167997167998167999168000168001168002168003168004168005168006168007168008168009168010168011168012168013168014168015168016168017168018168019168020168021168022168023168024168025168026168027168028168029168030168031168032168033168034168035168036168037168038168039168040168041168042168043168044168045168046168047168048168049168050168051168052168053168054168055168056168057168058168059168060168061168062168063168064168065168066168067168068168069168070168071168072168073168074168075168076168077168078168079168080168081168082168083168084168085168086168087168088168089168090168091168092168093168094168095168096168097168098168099168100168101168102168103168104168105168106168107168108168109168110168111168112168113168114168115168116168117168118168119168120168121168122168123168124168125168126168127168128168129168130168131168132168133168134168135168136168137168138168139168140168141168142168143168144168145168146168147168148168149168150168151168152168153168154168155168156168157168158168159168160168161168162168163168164168165168166168167168168168169168170168171168172168173168174168175168176168177168178168179168180168181168182168183168184168185168186168187168188168189168190168191168192168193168194168195168196168197168198168199168200168201168202168203168204168205168206168207168208168209168210168211168212168213168214168215168216168217168218168219168220168221168222168223168224168225168226168227168228168229168230168231168232168233168234168235168236168237168238168239168240168241168242168243168244168245168246168247168248168249168250168251168252168253168254168255168256168257168258168259168260168261168262168263168264168265168266168267168268168269168270168271168272168273168274168275168276168277168278168279168280168281168282168283168284168285168286168287168288168289168290168291168292168293168294168295168296168297168298168299168300168301168302168303168304168305168306168307168308168309168310168311168312168313168314168315168316168317168318168319168320168321168322168323168324168325168326168327168328168329168330168331168332168333168334168335168336168337168338168339168340168341168342168343168344168345168346168347168348168349168350168351168352168353168354168355168356168357168358168359168360168361168362168363168364168365168366168367168368168369168370168371168372168373168374168375168376168377168378168379168380168381168382168383168384168385168386168387168388168389168390168391168392168393168394168395168396168397168398168399168400168401168402168403168404168405168406168407168408168409168410168411168412168413168414168415168416168417168418168419168420168421168422168423168424168425168426168427168428168429168430168431168432168433168434168435168436168437168438168439168440168441168442168443168444168445168446168447168448168449168450168451168452168453168454168455168456168457168458168459168460168461168462168463168464168465168466168467168468168469168470168471168472168473168474168475168476168477168478168479168480168481168482168483168484168485168486168487168488168489168490168491168492168493168494168495168496168497168498168499168500168501168502168503168504168505168506168507168508168509168510168511168512168513168514168515168516168517168518168519168520168521168522168523168524168525168526168527168528168529168530168531168532168533168534168535168536168537168538168539168540168541168542168543168544168545168546168547168548168549168550168551168552168553168554168555168556168557168558168559168560168561168562168563168564168565168566168567168568168569168570168571168572168573168574168575168576168577168578168579168580168581168582168583168584168585168586168587168588168589168590168591168592168593168594168595168596168597168598168599168600168601168602168603168604168605168606168607168608168609168610168611168612168613168614168615168616168617168618168619168620168621168622168623168624168625168626168627168628168629168630168631168632168633168634168635168636168637168638168639168640168641168642168643168644168645168646168647168648168649168650168651168652168653168654168655168656168657168658168659168660168661168662168663168664168665168666168667168668168669168670168671168672168673168674168675168676168677168678168679168680168681168682168683168684168685168686168687168688168689168690168691168692168693168694168695168696168697168698168699168700168701168702168703168704168705168706168707168708168709168710168711168712168713168714168715168716168717168718168719168720168721168722168723168724168725168726168727168728168729168730168731168732168733168734168735168736168737168738168739168740168741168742168743168744168745168746168747168748168749168750168751168752168753168754168755168756168757168758168759168760168761168762168763168764168765168766168767168768168769168770168771168772168773168774168775168776168777168778168779168780168781168782168783168784168785168786168787168788168789168790168791168792168793168794168795168796168797168798168799168800168801168802168803168804168805168806168807168808168809168810168811168812168813168814168815168816168817168818168819168820168821168822168823168824168825168826168827168828168829168830168831168832168833168834168835168836168837168838168839168840168841168842
  1. var vr = Object.defineProperty
  2. , yr = Object.defineProperties;
  3. var Tr = Object.getOwnPropertyDescriptors;
  4. var or = Object.getOwnPropertySymbols;
  5. var _r = Object.prototype.hasOwnProperty
  6. , mr = Object.prototype.propertyIsEnumerable;
  7. var sr = (a,e,i)=>e in a ? vr(a, e, {
  8. enumerable: !0,
  9. configurable: !0,
  10. writable: !0,
  11. value: i
  12. }) : a[e] = i
  13. , $t = (a,e)=>{
  14. for (var i in e || (e = {}))
  15. _r.call(e, i) && sr(a, i, e[i]);
  16. if (or)
  17. for (var i of or(e))
  18. mr.call(e, i) && sr(a, i, e[i]);
  19. return a
  20. }
  21. , Zt = (a,e)=>yr(a, Tr(e));
  22. var gr = (a,e)=>{
  23. var i = {};
  24. for (var o in a)
  25. _r.call(a, o) && e.indexOf(o) < 0 && (i[o] = a[o]);
  26. if (a != null && or)
  27. for (var o of or(a))
  28. e.indexOf(o) < 0 && mr.call(a, o) && (i[o] = a[o]);
  29. return i
  30. }
  31. ;
  32. var Tt = (a,e,i)=>(sr(a, typeof e != "symbol" ? e + "" : e, i),
  33. i);
  34. function _mergeNamespaces(a, e) {
  35. return e.forEach(function(i) {
  36. i && typeof i != "string" && !Array.isArray(i) && Object.keys(i).forEach(function(o) {
  37. if (o !== "default" && !(o in a)) {
  38. var s = Object.getOwnPropertyDescriptor(i, o);
  39. Object.defineProperty(a, o, s.get ? s : {
  40. enumerable: !0,
  41. get: function() {
  42. return i[o]
  43. }
  44. })
  45. }
  46. })
  47. }),
  48. Object.freeze(Object.defineProperty(a, Symbol.toStringTag, {
  49. value: "Module"
  50. }))
  51. }
  52. const p$2 = function() {
  53. const e = document.createElement("link").relList;
  54. if (e && e.supports && e.supports("modulepreload"))
  55. return;
  56. for (const s of document.querySelectorAll('link[rel="modulepreload"]'))
  57. o(s);
  58. new MutationObserver(s=>{
  59. for (const c of s)
  60. if (c.type === "childList")
  61. for (const d of c.addedNodes)
  62. d.tagName === "LINK" && d.rel === "modulepreload" && o(d)
  63. }
  64. ).observe(document, {
  65. childList: !0,
  66. subtree: !0
  67. });
  68. function i(s) {
  69. const c = {};
  70. return s.integrity && (c.integrity = s.integrity),
  71. s.referrerpolicy && (c.referrerPolicy = s.referrerpolicy),
  72. s.crossorigin === "use-credentials" ? c.credentials = "include" : s.crossorigin === "anonymous" ? c.credentials = "omit" : c.credentials = "same-origin",
  73. c
  74. }
  75. function o(s) {
  76. if (s.ep)
  77. return;
  78. s.ep = !0;
  79. const c = i(s);
  80. fetch(s.href, c)
  81. }
  82. };
  83. p$2();
  84. var commonjsGlobal = typeof globalThis != "undefined" ? globalThis : typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : {};
  85. function commonjsRequire(a) {
  86. throw new Error('Could not dynamically require "' + a + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')
  87. }
  88. var react = {
  89. exports: {}
  90. }
  91. , react_production_min = {};
  92. /*
  93. object-assign
  94. (c) Sindre Sorhus
  95. @license MIT
  96. */
  97. var getOwnPropertySymbols = Object.getOwnPropertySymbols
  98. , hasOwnProperty = Object.prototype.hasOwnProperty
  99. , propIsEnumerable = Object.prototype.propertyIsEnumerable;
  100. function toObject(a) {
  101. if (a == null)
  102. throw new TypeError("Object.assign cannot be called with null or undefined");
  103. return Object(a)
  104. }
  105. function shouldUseNative() {
  106. try {
  107. if (!Object.assign)
  108. return !1;
  109. var a = new String("abc");
  110. if (a[5] = "de",
  111. Object.getOwnPropertyNames(a)[0] === "5")
  112. return !1;
  113. for (var e = {}, i = 0; i < 10; i++)
  114. e["_" + String.fromCharCode(i)] = i;
  115. var o = Object.getOwnPropertyNames(e).map(function(c) {
  116. return e[c]
  117. });
  118. if (o.join("") !== "0123456789")
  119. return !1;
  120. var s = {};
  121. return "abcdefghijklmnopqrst".split("").forEach(function(c) {
  122. s[c] = c
  123. }),
  124. Object.keys(Object.assign({}, s)).join("") === "abcdefghijklmnopqrst"
  125. } catch {
  126. return !1
  127. }
  128. }
  129. var objectAssign = shouldUseNative() ? Object.assign : function(a, e) {
  130. for (var i, o = toObject(a), s, c = 1; c < arguments.length; c++) {
  131. i = Object(arguments[c]);
  132. for (var d in i)
  133. hasOwnProperty.call(i, d) && (o[d] = i[d]);
  134. if (getOwnPropertySymbols) {
  135. s = getOwnPropertySymbols(i);
  136. for (var _ = 0; _ < s.length; _++)
  137. propIsEnumerable.call(i, s[_]) && (o[s[_]] = i[s[_]])
  138. }
  139. }
  140. return o
  141. }
  142. ;
  143. /** @license React v17.0.2
  144. * react.production.min.js
  145. *
  146. * Copyright (c) Facebook, Inc. and its affiliates.
  147. *
  148. * This source code is licensed under the MIT license found in the
  149. * LICENSE file in the root directory of this source tree.
  150. */
  151. var l = objectAssign
  152. , n$1 = 60103
  153. , p$1 = 60106;
  154. react_production_min.Fragment = 60107;
  155. react_production_min.StrictMode = 60108;
  156. react_production_min.Profiler = 60114;
  157. var q$1 = 60109
  158. , r$1 = 60110
  159. , t = 60112;
  160. react_production_min.Suspense = 60113;
  161. var u = 60115
  162. , v = 60116;
  163. if (typeof Symbol == "function" && Symbol.for) {
  164. var w = Symbol.for;
  165. n$1 = w("react.element"),
  166. p$1 = w("react.portal"),
  167. react_production_min.Fragment = w("react.fragment"),
  168. react_production_min.StrictMode = w("react.strict_mode"),
  169. react_production_min.Profiler = w("react.profiler"),
  170. q$1 = w("react.provider"),
  171. r$1 = w("react.context"),
  172. t = w("react.forward_ref"),
  173. react_production_min.Suspense = w("react.suspense"),
  174. u = w("react.memo"),
  175. v = w("react.lazy")
  176. }
  177. var x = typeof Symbol == "function" && Symbol.iterator;
  178. function y$1(a) {
  179. return a === null || typeof a != "object" ? null : (a = x && a[x] || a["@@iterator"],
  180. typeof a == "function" ? a : null)
  181. }
  182. function z(a) {
  183. for (var e = "https://reactjs.org/docs/error-decoder.html?invariant=" + a, i = 1; i < arguments.length; i++)
  184. e += "&args[]=" + encodeURIComponent(arguments[i]);
  185. return "Minified React error #" + a + "; visit " + e + " for the full message or use the non-minified dev environment for full errors and additional helpful warnings."
  186. }
  187. var A = {
  188. isMounted: function() {
  189. return !1
  190. },
  191. enqueueForceUpdate: function() {},
  192. enqueueReplaceState: function() {},
  193. enqueueSetState: function() {}
  194. }
  195. , B$1 = {};
  196. function C(a, e, i) {
  197. this.props = a,
  198. this.context = e,
  199. this.refs = B$1,
  200. this.updater = i || A
  201. }
  202. C.prototype.isReactComponent = {};
  203. C.prototype.setState = function(a, e) {
  204. if (typeof a != "object" && typeof a != "function" && a != null)
  205. throw Error(z(85));
  206. this.updater.enqueueSetState(this, a, e, "setState")
  207. }
  208. ;
  209. C.prototype.forceUpdate = function(a) {
  210. this.updater.enqueueForceUpdate(this, a, "forceUpdate")
  211. }
  212. ;
  213. function D$1() {}
  214. D$1.prototype = C.prototype;
  215. function E$1(a, e, i) {
  216. this.props = a,
  217. this.context = e,
  218. this.refs = B$1,
  219. this.updater = i || A
  220. }
  221. var F$1 = E$1.prototype = new D$1;
  222. F$1.constructor = E$1;
  223. l(F$1, C.prototype);
  224. F$1.isPureReactComponent = !0;
  225. var G$1 = {
  226. current: null
  227. }
  228. , H$1 = Object.prototype.hasOwnProperty
  229. , I$1 = {
  230. key: !0,
  231. ref: !0,
  232. __self: !0,
  233. __source: !0
  234. };
  235. function J(a, e, i) {
  236. var o, s = {}, c = null, d = null;
  237. if (e != null)
  238. for (o in e.ref !== void 0 && (d = e.ref),
  239. e.key !== void 0 && (c = "" + e.key),
  240. e)
  241. H$1.call(e, o) && !I$1.hasOwnProperty(o) && (s[o] = e[o]);
  242. var _ = arguments.length - 2;
  243. if (_ === 1)
  244. s.children = i;
  245. else if (1 < _) {
  246. for (var b = Array(_), k = 0; k < _; k++)
  247. b[k] = arguments[k + 2];
  248. s.children = b
  249. }
  250. if (a && a.defaultProps)
  251. for (o in _ = a.defaultProps,
  252. _)
  253. s[o] === void 0 && (s[o] = _[o]);
  254. return {
  255. $$typeof: n$1,
  256. type: a,
  257. key: c,
  258. ref: d,
  259. props: s,
  260. _owner: G$1.current
  261. }
  262. }
  263. function K(a, e) {
  264. return {
  265. $$typeof: n$1,
  266. type: a.type,
  267. key: e,
  268. ref: a.ref,
  269. props: a.props,
  270. _owner: a._owner
  271. }
  272. }
  273. function L(a) {
  274. return typeof a == "object" && a !== null && a.$$typeof === n$1
  275. }
  276. function escape$1(a) {
  277. var e = {
  278. "=": "=0",
  279. ":": "=2"
  280. };
  281. return "$" + a.replace(/[=:]/g, function(i) {
  282. return e[i]
  283. })
  284. }
  285. var M$1 = /\/+/g;
  286. function N$1(a, e) {
  287. return typeof a == "object" && a !== null && a.key != null ? escape$1("" + a.key) : e.toString(36)
  288. }
  289. function O$1(a, e, i, o, s) {
  290. var c = typeof a;
  291. (c === "undefined" || c === "boolean") && (a = null);
  292. var d = !1;
  293. if (a === null)
  294. d = !0;
  295. else
  296. switch (c) {
  297. case "string":
  298. case "number":
  299. d = !0;
  300. break;
  301. case "object":
  302. switch (a.$$typeof) {
  303. case n$1:
  304. case p$1:
  305. d = !0
  306. }
  307. }
  308. if (d)
  309. return d = a,
  310. s = s(d),
  311. a = o === "" ? "." + N$1(d, 0) : o,
  312. Array.isArray(s) ? (i = "",
  313. a != null && (i = a.replace(M$1, "$&/") + "/"),
  314. O$1(s, e, i, "", function(k) {
  315. return k
  316. })) : s != null && (L(s) && (s = K(s, i + (!s.key || d && d.key === s.key ? "" : ("" + s.key).replace(M$1, "$&/") + "/") + a)),
  317. e.push(s)),
  318. 1;
  319. if (d = 0,
  320. o = o === "" ? "." : o + ":",
  321. Array.isArray(a))
  322. for (var _ = 0; _ < a.length; _++) {
  323. c = a[_];
  324. var b = o + N$1(c, _);
  325. d += O$1(c, e, i, b, s)
  326. }
  327. else if (b = y$1(a),
  328. typeof b == "function")
  329. for (a = b.call(a),
  330. _ = 0; !(c = a.next()).done; )
  331. c = c.value,
  332. b = o + N$1(c, _++),
  333. d += O$1(c, e, i, b, s);
  334. else if (c === "object")
  335. throw e = "" + a,
  336. Error(z(31, e === "[object Object]" ? "object with keys {" + Object.keys(a).join(", ") + "}" : e));
  337. return d
  338. }
  339. function P$1(a, e, i) {
  340. if (a == null)
  341. return a;
  342. var o = []
  343. , s = 0;
  344. return O$1(a, o, "", "", function(c) {
  345. return e.call(i, c, s++)
  346. }),
  347. o
  348. }
  349. function Q(a) {
  350. if (a._status === -1) {
  351. var e = a._result;
  352. e = e(),
  353. a._status = 0,
  354. a._result = e,
  355. e.then(function(i) {
  356. a._status === 0 && (i = i.default,
  357. a._status = 1,
  358. a._result = i)
  359. }, function(i) {
  360. a._status === 0 && (a._status = 2,
  361. a._result = i)
  362. })
  363. }
  364. if (a._status === 1)
  365. return a._result;
  366. throw a._result
  367. }
  368. var R$1 = {
  369. current: null
  370. };
  371. function S$1() {
  372. var a = R$1.current;
  373. if (a === null)
  374. throw Error(z(321));
  375. return a
  376. }
  377. var T$1 = {
  378. ReactCurrentDispatcher: R$1,
  379. ReactCurrentBatchConfig: {
  380. transition: 0
  381. },
  382. ReactCurrentOwner: G$1,
  383. IsSomeRendererActing: {
  384. current: !1
  385. },
  386. assign: l
  387. };
  388. react_production_min.Children = {
  389. map: P$1,
  390. forEach: function(a, e, i) {
  391. P$1(a, function() {
  392. e.apply(this, arguments)
  393. }, i)
  394. },
  395. count: function(a) {
  396. var e = 0;
  397. return P$1(a, function() {
  398. e++
  399. }),
  400. e
  401. },
  402. toArray: function(a) {
  403. return P$1(a, function(e) {
  404. return e
  405. }) || []
  406. },
  407. only: function(a) {
  408. if (!L(a))
  409. throw Error(z(143));
  410. return a
  411. }
  412. };
  413. react_production_min.Component = C;
  414. react_production_min.PureComponent = E$1;
  415. react_production_min.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = T$1;
  416. react_production_min.cloneElement = function(a, e, i) {
  417. if (a == null)
  418. throw Error(z(267, a));
  419. var o = l({}, a.props)
  420. , s = a.key
  421. , c = a.ref
  422. , d = a._owner;
  423. if (e != null) {
  424. if (e.ref !== void 0 && (c = e.ref,
  425. d = G$1.current),
  426. e.key !== void 0 && (s = "" + e.key),
  427. a.type && a.type.defaultProps)
  428. var _ = a.type.defaultProps;
  429. for (b in e)
  430. H$1.call(e, b) && !I$1.hasOwnProperty(b) && (o[b] = e[b] === void 0 && _ !== void 0 ? _[b] : e[b])
  431. }
  432. var b = arguments.length - 2;
  433. if (b === 1)
  434. o.children = i;
  435. else if (1 < b) {
  436. _ = Array(b);
  437. for (var k = 0; k < b; k++)
  438. _[k] = arguments[k + 2];
  439. o.children = _
  440. }
  441. return {
  442. $$typeof: n$1,
  443. type: a.type,
  444. key: s,
  445. ref: c,
  446. props: o,
  447. _owner: d
  448. }
  449. }
  450. ;
  451. react_production_min.createContext = function(a, e) {
  452. return e === void 0 && (e = null),
  453. a = {
  454. $$typeof: r$1,
  455. _calculateChangedBits: e,
  456. _currentValue: a,
  457. _currentValue2: a,
  458. _threadCount: 0,
  459. Provider: null,
  460. Consumer: null
  461. },
  462. a.Provider = {
  463. $$typeof: q$1,
  464. _context: a
  465. },
  466. a.Consumer = a
  467. }
  468. ;
  469. react_production_min.createElement = J;
  470. react_production_min.createFactory = function(a) {
  471. var e = J.bind(null, a);
  472. return e.type = a,
  473. e
  474. }
  475. ;
  476. react_production_min.createRef = function() {
  477. return {
  478. current: null
  479. }
  480. }
  481. ;
  482. react_production_min.forwardRef = function(a) {
  483. return {
  484. $$typeof: t,
  485. render: a
  486. }
  487. }
  488. ;
  489. react_production_min.isValidElement = L;
  490. react_production_min.lazy = function(a) {
  491. return {
  492. $$typeof: v,
  493. _payload: {
  494. _status: -1,
  495. _result: a
  496. },
  497. _init: Q
  498. }
  499. }
  500. ;
  501. react_production_min.memo = function(a, e) {
  502. return {
  503. $$typeof: u,
  504. type: a,
  505. compare: e === void 0 ? null : e
  506. }
  507. }
  508. ;
  509. react_production_min.useCallback = function(a, e) {
  510. return S$1().useCallback(a, e)
  511. }
  512. ;
  513. react_production_min.useContext = function(a, e) {
  514. return S$1().useContext(a, e)
  515. }
  516. ;
  517. react_production_min.useDebugValue = function() {}
  518. ;
  519. react_production_min.useEffect = function(a, e) {
  520. return S$1().useEffect(a, e)
  521. }
  522. ;
  523. react_production_min.useImperativeHandle = function(a, e, i) {
  524. return S$1().useImperativeHandle(a, e, i)
  525. }
  526. ;
  527. react_production_min.useLayoutEffect = function(a, e) {
  528. return S$1().useLayoutEffect(a, e)
  529. }
  530. ;
  531. react_production_min.useMemo = function(a, e) {
  532. return S$1().useMemo(a, e)
  533. }
  534. ;
  535. react_production_min.useReducer = function(a, e, i) {
  536. return S$1().useReducer(a, e, i)
  537. }
  538. ;
  539. react_production_min.useRef = function(a) {
  540. return S$1().useRef(a)
  541. }
  542. ;
  543. react_production_min.useState = function(a) {
  544. return S$1().useState(a)
  545. }
  546. ;
  547. react_production_min.version = "17.0.2";
  548. react.exports = react_production_min;
  549. var React = react.exports
  550. , reactDom = {
  551. exports: {}
  552. }
  553. , reactDom_production_min = {}
  554. , scheduler = {
  555. exports: {}
  556. }
  557. , scheduler_production_min = {};
  558. /** @license React v0.20.2
  559. * scheduler.production.min.js
  560. *
  561. * Copyright (c) Facebook, Inc. and its affiliates.
  562. *
  563. * This source code is licensed under the MIT license found in the
  564. * LICENSE file in the root directory of this source tree.
  565. */
  566. (function(a) {
  567. var e, i, o, s;
  568. if (typeof performance == "object" && typeof performance.now == "function") {
  569. var c = performance;
  570. a.unstable_now = function() {
  571. return c.now()
  572. }
  573. } else {
  574. var d = Date
  575. , _ = d.now();
  576. a.unstable_now = function() {
  577. return d.now() - _
  578. }
  579. }
  580. if (typeof window == "undefined" || typeof MessageChannel != "function") {
  581. var b = null
  582. , k = null
  583. , j = function() {
  584. if (b !== null)
  585. try {
  586. var bt = a.unstable_now();
  587. b(!0, bt),
  588. b = null
  589. } catch (Rt) {
  590. throw setTimeout(j, 0),
  591. Rt
  592. }
  593. };
  594. e = function(bt) {
  595. b !== null ? setTimeout(e, 0, bt) : (b = bt,
  596. setTimeout(j, 0))
  597. }
  598. ,
  599. i = function(bt, Rt) {
  600. k = setTimeout(bt, Rt)
  601. }
  602. ,
  603. o = function() {
  604. clearTimeout(k)
  605. }
  606. ,
  607. a.unstable_shouldYield = function() {
  608. return !1
  609. }
  610. ,
  611. s = a.unstable_forceFrameRate = function() {}
  612. } else {
  613. var $ = window.setTimeout
  614. , _e = window.clearTimeout;
  615. if (typeof console != "undefined") {
  616. var et = window.cancelAnimationFrame;
  617. typeof window.requestAnimationFrame != "function" && console.error("This browser doesn't support requestAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills"),
  618. typeof et != "function" && console.error("This browser doesn't support cancelAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills")
  619. }
  620. var tt = !1
  621. , rt = null
  622. , it = -1
  623. , nt = 5
  624. , ot = 0;
  625. a.unstable_shouldYield = function() {
  626. return a.unstable_now() >= ot
  627. }
  628. ,
  629. s = function() {}
  630. ,
  631. a.unstable_forceFrameRate = function(bt) {
  632. 0 > bt || 125 < bt ? console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported") : nt = 0 < bt ? Math.floor(1e3 / bt) : 5
  633. }
  634. ;
  635. var at = new MessageChannel
  636. , st = at.port2;
  637. at.port1.onmessage = function() {
  638. if (rt !== null) {
  639. var bt = a.unstable_now();
  640. ot = bt + nt;
  641. try {
  642. rt(!0, bt) ? st.postMessage(null) : (tt = !1,
  643. rt = null)
  644. } catch (Rt) {
  645. throw st.postMessage(null),
  646. Rt
  647. }
  648. } else
  649. tt = !1
  650. }
  651. ,
  652. e = function(bt) {
  653. rt = bt,
  654. tt || (tt = !0,
  655. st.postMessage(null))
  656. }
  657. ,
  658. i = function(bt, Rt) {
  659. it = $(function() {
  660. bt(a.unstable_now())
  661. }, Rt)
  662. }
  663. ,
  664. o = function() {
  665. _e(it),
  666. it = -1
  667. }
  668. }
  669. function ut(bt, Rt) {
  670. var Mt = bt.length;
  671. bt.push(Rt);
  672. e: for (; ; ) {
  673. var Pt = Mt - 1 >>> 1
  674. , It = bt[Pt];
  675. if (It !== void 0 && 0 < ft(It, Rt))
  676. bt[Pt] = Rt,
  677. bt[Mt] = It,
  678. Mt = Pt;
  679. else
  680. break e
  681. }
  682. }
  683. function ct(bt) {
  684. return bt = bt[0],
  685. bt === void 0 ? null : bt
  686. }
  687. function lt(bt) {
  688. var Rt = bt[0];
  689. if (Rt !== void 0) {
  690. var Mt = bt.pop();
  691. if (Mt !== Rt) {
  692. bt[0] = Mt;
  693. e: for (var Pt = 0, It = bt.length; Pt < It; ) {
  694. var Dt = 2 * (Pt + 1) - 1
  695. , Ct = bt[Dt]
  696. , Ot = Dt + 1
  697. , wt = bt[Ot];
  698. if (Ct !== void 0 && 0 > ft(Ct, Mt))
  699. wt !== void 0 && 0 > ft(wt, Ct) ? (bt[Pt] = wt,
  700. bt[Ot] = Mt,
  701. Pt = Ot) : (bt[Pt] = Ct,
  702. bt[Dt] = Mt,
  703. Pt = Dt);
  704. else if (wt !== void 0 && 0 > ft(wt, Mt))
  705. bt[Pt] = wt,
  706. bt[Ot] = Mt,
  707. Pt = Ot;
  708. else
  709. break e
  710. }
  711. }
  712. return Rt
  713. }
  714. return null
  715. }
  716. function ft(bt, Rt) {
  717. var Mt = bt.sortIndex - Rt.sortIndex;
  718. return Mt !== 0 ? Mt : bt.id - Rt.id
  719. }
  720. var ht = []
  721. , pt = []
  722. , dt = 1
  723. , _t = null
  724. , mt = 3
  725. , vt = !1
  726. , yt = !1
  727. , Et = !1;
  728. function At(bt) {
  729. for (var Rt = ct(pt); Rt !== null; ) {
  730. if (Rt.callback === null)
  731. lt(pt);
  732. else if (Rt.startTime <= bt)
  733. lt(pt),
  734. Rt.sortIndex = Rt.expirationTime,
  735. ut(ht, Rt);
  736. else
  737. break;
  738. Rt = ct(pt)
  739. }
  740. }
  741. function gt(bt) {
  742. if (Et = !1,
  743. At(bt),
  744. !yt)
  745. if (ct(ht) !== null)
  746. yt = !0,
  747. e(St);
  748. else {
  749. var Rt = ct(pt);
  750. Rt !== null && i(gt, Rt.startTime - bt)
  751. }
  752. }
  753. function St(bt, Rt) {
  754. yt = !1,
  755. Et && (Et = !1,
  756. o()),
  757. vt = !0;
  758. var Mt = mt;
  759. try {
  760. for (At(Rt),
  761. _t = ct(ht); _t !== null && (!(_t.expirationTime > Rt) || bt && !a.unstable_shouldYield()); ) {
  762. var Pt = _t.callback;
  763. if (typeof Pt == "function") {
  764. _t.callback = null,
  765. mt = _t.priorityLevel;
  766. var It = Pt(_t.expirationTime <= Rt);
  767. Rt = a.unstable_now(),
  768. typeof It == "function" ? _t.callback = It : _t === ct(ht) && lt(ht),
  769. At(Rt)
  770. } else
  771. lt(ht);
  772. _t = ct(ht)
  773. }
  774. if (_t !== null)
  775. var Dt = !0;
  776. else {
  777. var Ct = ct(pt);
  778. Ct !== null && i(gt, Ct.startTime - Rt),
  779. Dt = !1
  780. }
  781. return Dt
  782. } finally {
  783. _t = null,
  784. mt = Mt,
  785. vt = !1
  786. }
  787. }
  788. var xt = s;
  789. a.unstable_IdlePriority = 5,
  790. a.unstable_ImmediatePriority = 1,
  791. a.unstable_LowPriority = 4,
  792. a.unstable_NormalPriority = 3,
  793. a.unstable_Profiling = null,
  794. a.unstable_UserBlockingPriority = 2,
  795. a.unstable_cancelCallback = function(bt) {
  796. bt.callback = null
  797. }
  798. ,
  799. a.unstable_continueExecution = function() {
  800. yt || vt || (yt = !0,
  801. e(St))
  802. }
  803. ,
  804. a.unstable_getCurrentPriorityLevel = function() {
  805. return mt
  806. }
  807. ,
  808. a.unstable_getFirstCallbackNode = function() {
  809. return ct(ht)
  810. }
  811. ,
  812. a.unstable_next = function(bt) {
  813. switch (mt) {
  814. case 1:
  815. case 2:
  816. case 3:
  817. var Rt = 3;
  818. break;
  819. default:
  820. Rt = mt
  821. }
  822. var Mt = mt;
  823. mt = Rt;
  824. try {
  825. return bt()
  826. } finally {
  827. mt = Mt
  828. }
  829. }
  830. ,
  831. a.unstable_pauseExecution = function() {}
  832. ,
  833. a.unstable_requestPaint = xt,
  834. a.unstable_runWithPriority = function(bt, Rt) {
  835. switch (bt) {
  836. case 1:
  837. case 2:
  838. case 3:
  839. case 4:
  840. case 5:
  841. break;
  842. default:
  843. bt = 3
  844. }
  845. var Mt = mt;
  846. mt = bt;
  847. try {
  848. return Rt()
  849. } finally {
  850. mt = Mt
  851. }
  852. }
  853. ,
  854. a.unstable_scheduleCallback = function(bt, Rt, Mt) {
  855. var Pt = a.unstable_now();
  856. switch (typeof Mt == "object" && Mt !== null ? (Mt = Mt.delay,
  857. Mt = typeof Mt == "number" && 0 < Mt ? Pt + Mt : Pt) : Mt = Pt,
  858. bt) {
  859. case 1:
  860. var It = -1;
  861. break;
  862. case 2:
  863. It = 250;
  864. break;
  865. case 5:
  866. It = 1073741823;
  867. break;
  868. case 4:
  869. It = 1e4;
  870. break;
  871. default:
  872. It = 5e3
  873. }
  874. return It = Mt + It,
  875. bt = {
  876. id: dt++,
  877. callback: Rt,
  878. priorityLevel: bt,
  879. startTime: Mt,
  880. expirationTime: It,
  881. sortIndex: -1
  882. },
  883. Mt > Pt ? (bt.sortIndex = Mt,
  884. ut(pt, bt),
  885. ct(ht) === null && bt === ct(pt) && (Et ? o() : Et = !0,
  886. i(gt, Mt - Pt))) : (bt.sortIndex = It,
  887. ut(ht, bt),
  888. yt || vt || (yt = !0,
  889. e(St))),
  890. bt
  891. }
  892. ,
  893. a.unstable_wrapCallback = function(bt) {
  894. var Rt = mt;
  895. return function() {
  896. var Mt = mt;
  897. mt = Rt;
  898. try {
  899. return bt.apply(this, arguments)
  900. } finally {
  901. mt = Mt
  902. }
  903. }
  904. }
  905. }
  906. )(scheduler_production_min);
  907. scheduler.exports = scheduler_production_min;
  908. /** @license React v17.0.2
  909. * react-dom.production.min.js
  910. *
  911. * Copyright (c) Facebook, Inc. and its affiliates.
  912. *
  913. * This source code is licensed under the MIT license found in the
  914. * LICENSE file in the root directory of this source tree.
  915. */
  916. var aa = react.exports
  917. , m$1 = objectAssign
  918. , r = scheduler.exports;
  919. function y(a) {
  920. for (var e = "https://reactjs.org/docs/error-decoder.html?invariant=" + a, i = 1; i < arguments.length; i++)
  921. e += "&args[]=" + encodeURIComponent(arguments[i]);
  922. return "Minified React error #" + a + "; visit " + e + " for the full message or use the non-minified dev environment for full errors and additional helpful warnings."
  923. }
  924. if (!aa)
  925. throw Error(y(227));
  926. var ba = new Set
  927. , ca = {};
  928. function da(a, e) {
  929. ea(a, e),
  930. ea(a + "Capture", e)
  931. }
  932. function ea(a, e) {
  933. for (ca[a] = e,
  934. a = 0; a < e.length; a++)
  935. ba.add(e[a])
  936. }
  937. var fa = !(typeof window == "undefined" || typeof window.document == "undefined" || typeof window.document.createElement == "undefined")
  938. , ha = /^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/
  939. , ia = Object.prototype.hasOwnProperty
  940. , ja = {}
  941. , ka = {};
  942. function la(a) {
  943. return ia.call(ka, a) ? !0 : ia.call(ja, a) ? !1 : ha.test(a) ? ka[a] = !0 : (ja[a] = !0,
  944. !1)
  945. }
  946. function ma(a, e, i, o) {
  947. if (i !== null && i.type === 0)
  948. return !1;
  949. switch (typeof e) {
  950. case "function":
  951. case "symbol":
  952. return !0;
  953. case "boolean":
  954. return o ? !1 : i !== null ? !i.acceptsBooleans : (a = a.toLowerCase().slice(0, 5),
  955. a !== "data-" && a !== "aria-");
  956. default:
  957. return !1
  958. }
  959. }
  960. function na(a, e, i, o) {
  961. if (e === null || typeof e == "undefined" || ma(a, e, i, o))
  962. return !0;
  963. if (o)
  964. return !1;
  965. if (i !== null)
  966. switch (i.type) {
  967. case 3:
  968. return !e;
  969. case 4:
  970. return e === !1;
  971. case 5:
  972. return isNaN(e);
  973. case 6:
  974. return isNaN(e) || 1 > e
  975. }
  976. return !1
  977. }
  978. function B(a, e, i, o, s, c, d) {
  979. this.acceptsBooleans = e === 2 || e === 3 || e === 4,
  980. this.attributeName = o,
  981. this.attributeNamespace = s,
  982. this.mustUseProperty = i,
  983. this.propertyName = a,
  984. this.type = e,
  985. this.sanitizeURL = c,
  986. this.removeEmptyString = d
  987. }
  988. var D = {};
  989. "children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(a) {
  990. D[a] = new B(a,0,!1,a,null,!1,!1)
  991. });
  992. [["acceptCharset", "accept-charset"], ["className", "class"], ["htmlFor", "for"], ["httpEquiv", "http-equiv"]].forEach(function(a) {
  993. var e = a[0];
  994. D[e] = new B(e,1,!1,a[1],null,!1,!1)
  995. });
  996. ["contentEditable", "draggable", "spellCheck", "value"].forEach(function(a) {
  997. D[a] = new B(a,2,!1,a.toLowerCase(),null,!1,!1)
  998. });
  999. ["autoReverse", "externalResourcesRequired", "focusable", "preserveAlpha"].forEach(function(a) {
  1000. D[a] = new B(a,2,!1,a,null,!1,!1)
  1001. });
  1002. "allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(a) {
  1003. D[a] = new B(a,3,!1,a.toLowerCase(),null,!1,!1)
  1004. });
  1005. ["checked", "multiple", "muted", "selected"].forEach(function(a) {
  1006. D[a] = new B(a,3,!0,a,null,!1,!1)
  1007. });
  1008. ["capture", "download"].forEach(function(a) {
  1009. D[a] = new B(a,4,!1,a,null,!1,!1)
  1010. });
  1011. ["cols", "rows", "size", "span"].forEach(function(a) {
  1012. D[a] = new B(a,6,!1,a,null,!1,!1)
  1013. });
  1014. ["rowSpan", "start"].forEach(function(a) {
  1015. D[a] = new B(a,5,!1,a.toLowerCase(),null,!1,!1)
  1016. });
  1017. var oa = /[\-:]([a-z])/g;
  1018. function pa(a) {
  1019. return a[1].toUpperCase()
  1020. }
  1021. "accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(a) {
  1022. var e = a.replace(oa, pa);
  1023. D[e] = new B(e,1,!1,a,null,!1,!1)
  1024. });
  1025. "xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(a) {
  1026. var e = a.replace(oa, pa);
  1027. D[e] = new B(e,1,!1,a,"http://www.w3.org/1999/xlink",!1,!1)
  1028. });
  1029. ["xml:base", "xml:lang", "xml:space"].forEach(function(a) {
  1030. var e = a.replace(oa, pa);
  1031. D[e] = new B(e,1,!1,a,"http://www.w3.org/XML/1998/namespace",!1,!1)
  1032. });
  1033. ["tabIndex", "crossOrigin"].forEach(function(a) {
  1034. D[a] = new B(a,1,!1,a.toLowerCase(),null,!1,!1)
  1035. });
  1036. D.xlinkHref = new B("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);
  1037. ["src", "href", "action", "formAction"].forEach(function(a) {
  1038. D[a] = new B(a,1,!1,a.toLowerCase(),null,!0,!0)
  1039. });
  1040. function qa(a, e, i, o) {
  1041. var s = D.hasOwnProperty(e) ? D[e] : null
  1042. , c = s !== null ? s.type === 0 : o ? !1 : !(!(2 < e.length) || e[0] !== "o" && e[0] !== "O" || e[1] !== "n" && e[1] !== "N");
  1043. c || (na(e, i, s, o) && (i = null),
  1044. o || s === null ? la(e) && (i === null ? a.removeAttribute(e) : a.setAttribute(e, "" + i)) : s.mustUseProperty ? a[s.propertyName] = i === null ? s.type === 3 ? !1 : "" : i : (e = s.attributeName,
  1045. o = s.attributeNamespace,
  1046. i === null ? a.removeAttribute(e) : (s = s.type,
  1047. i = s === 3 || s === 4 && i === !0 ? "" : "" + i,
  1048. o ? a.setAttributeNS(o, e, i) : a.setAttribute(e, i))))
  1049. }
  1050. var ra = aa.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
  1051. , sa = 60103
  1052. , ta = 60106
  1053. , ua = 60107
  1054. , wa = 60108
  1055. , xa = 60114
  1056. , ya = 60109
  1057. , za = 60110
  1058. , Aa = 60112
  1059. , Ba = 60113
  1060. , Ca = 60120
  1061. , Da = 60115
  1062. , Ea = 60116
  1063. , Fa = 60121
  1064. , Ga = 60128
  1065. , Ha = 60129
  1066. , Ia = 60130
  1067. , Ja = 60131;
  1068. if (typeof Symbol == "function" && Symbol.for) {
  1069. var E = Symbol.for;
  1070. sa = E("react.element"),
  1071. ta = E("react.portal"),
  1072. ua = E("react.fragment"),
  1073. wa = E("react.strict_mode"),
  1074. xa = E("react.profiler"),
  1075. ya = E("react.provider"),
  1076. za = E("react.context"),
  1077. Aa = E("react.forward_ref"),
  1078. Ba = E("react.suspense"),
  1079. Ca = E("react.suspense_list"),
  1080. Da = E("react.memo"),
  1081. Ea = E("react.lazy"),
  1082. Fa = E("react.block"),
  1083. E("react.scope"),
  1084. Ga = E("react.opaque.id"),
  1085. Ha = E("react.debug_trace_mode"),
  1086. Ia = E("react.offscreen"),
  1087. Ja = E("react.legacy_hidden")
  1088. }
  1089. var Ka = typeof Symbol == "function" && Symbol.iterator;
  1090. function La(a) {
  1091. return a === null || typeof a != "object" ? null : (a = Ka && a[Ka] || a["@@iterator"],
  1092. typeof a == "function" ? a : null)
  1093. }
  1094. var Ma;
  1095. function Na(a) {
  1096. if (Ma === void 0)
  1097. try {
  1098. throw Error()
  1099. } catch (i) {
  1100. var e = i.stack.trim().match(/\n( *(at )?)/);
  1101. Ma = e && e[1] || ""
  1102. }
  1103. return `
  1104. ` + Ma + a
  1105. }
  1106. var Oa = !1;
  1107. function Pa(a, e) {
  1108. if (!a || Oa)
  1109. return "";
  1110. Oa = !0;
  1111. var i = Error.prepareStackTrace;
  1112. Error.prepareStackTrace = void 0;
  1113. try {
  1114. if (e)
  1115. if (e = function() {
  1116. throw Error()
  1117. }
  1118. ,
  1119. Object.defineProperty(e.prototype, "props", {
  1120. set: function() {
  1121. throw Error()
  1122. }
  1123. }),
  1124. typeof Reflect == "object" && Reflect.construct) {
  1125. try {
  1126. Reflect.construct(e, [])
  1127. } catch (b) {
  1128. var o = b
  1129. }
  1130. Reflect.construct(a, [], e)
  1131. } else {
  1132. try {
  1133. e.call()
  1134. } catch (b) {
  1135. o = b
  1136. }
  1137. a.call(e.prototype)
  1138. }
  1139. else {
  1140. try {
  1141. throw Error()
  1142. } catch (b) {
  1143. o = b
  1144. }
  1145. a()
  1146. }
  1147. } catch (b) {
  1148. if (b && o && typeof b.stack == "string") {
  1149. for (var s = b.stack.split(`
  1150. `), c = o.stack.split(`
  1151. `), d = s.length - 1, _ = c.length - 1; 1 <= d && 0 <= _ && s[d] !== c[_]; )
  1152. _--;
  1153. for (; 1 <= d && 0 <= _; d--,
  1154. _--)
  1155. if (s[d] !== c[_]) {
  1156. if (d !== 1 || _ !== 1)
  1157. do
  1158. if (d--,
  1159. _--,
  1160. 0 > _ || s[d] !== c[_])
  1161. return `
  1162. ` + s[d].replace(" at new ", " at ");
  1163. while (1 <= d && 0 <= _);
  1164. break
  1165. }
  1166. }
  1167. } finally {
  1168. Oa = !1,
  1169. Error.prepareStackTrace = i
  1170. }
  1171. return (a = a ? a.displayName || a.name : "") ? Na(a) : ""
  1172. }
  1173. function Qa(a) {
  1174. switch (a.tag) {
  1175. case 5:
  1176. return Na(a.type);
  1177. case 16:
  1178. return Na("Lazy");
  1179. case 13:
  1180. return Na("Suspense");
  1181. case 19:
  1182. return Na("SuspenseList");
  1183. case 0:
  1184. case 2:
  1185. case 15:
  1186. return a = Pa(a.type, !1),
  1187. a;
  1188. case 11:
  1189. return a = Pa(a.type.render, !1),
  1190. a;
  1191. case 22:
  1192. return a = Pa(a.type._render, !1),
  1193. a;
  1194. case 1:
  1195. return a = Pa(a.type, !0),
  1196. a;
  1197. default:
  1198. return ""
  1199. }
  1200. }
  1201. function Ra(a) {
  1202. if (a == null)
  1203. return null;
  1204. if (typeof a == "function")
  1205. return a.displayName || a.name || null;
  1206. if (typeof a == "string")
  1207. return a;
  1208. switch (a) {
  1209. case ua:
  1210. return "Fragment";
  1211. case ta:
  1212. return "Portal";
  1213. case xa:
  1214. return "Profiler";
  1215. case wa:
  1216. return "StrictMode";
  1217. case Ba:
  1218. return "Suspense";
  1219. case Ca:
  1220. return "SuspenseList"
  1221. }
  1222. if (typeof a == "object")
  1223. switch (a.$$typeof) {
  1224. case za:
  1225. return (a.displayName || "Context") + ".Consumer";
  1226. case ya:
  1227. return (a._context.displayName || "Context") + ".Provider";
  1228. case Aa:
  1229. var e = a.render;
  1230. return e = e.displayName || e.name || "",
  1231. a.displayName || (e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef");
  1232. case Da:
  1233. return Ra(a.type);
  1234. case Fa:
  1235. return Ra(a._render);
  1236. case Ea:
  1237. e = a._payload,
  1238. a = a._init;
  1239. try {
  1240. return Ra(a(e))
  1241. } catch {}
  1242. }
  1243. return null
  1244. }
  1245. function Sa(a) {
  1246. switch (typeof a) {
  1247. case "boolean":
  1248. case "number":
  1249. case "object":
  1250. case "string":
  1251. case "undefined":
  1252. return a;
  1253. default:
  1254. return ""
  1255. }
  1256. }
  1257. function Ta(a) {
  1258. var e = a.type;
  1259. return (a = a.nodeName) && a.toLowerCase() === "input" && (e === "checkbox" || e === "radio")
  1260. }
  1261. function Ua(a) {
  1262. var e = Ta(a) ? "checked" : "value"
  1263. , i = Object.getOwnPropertyDescriptor(a.constructor.prototype, e)
  1264. , o = "" + a[e];
  1265. if (!a.hasOwnProperty(e) && typeof i != "undefined" && typeof i.get == "function" && typeof i.set == "function") {
  1266. var s = i.get
  1267. , c = i.set;
  1268. return Object.defineProperty(a, e, {
  1269. configurable: !0,
  1270. get: function() {
  1271. return s.call(this)
  1272. },
  1273. set: function(d) {
  1274. o = "" + d,
  1275. c.call(this, d)
  1276. }
  1277. }),
  1278. Object.defineProperty(a, e, {
  1279. enumerable: i.enumerable
  1280. }),
  1281. {
  1282. getValue: function() {
  1283. return o
  1284. },
  1285. setValue: function(d) {
  1286. o = "" + d
  1287. },
  1288. stopTracking: function() {
  1289. a._valueTracker = null,
  1290. delete a[e]
  1291. }
  1292. }
  1293. }
  1294. }
  1295. function Va(a) {
  1296. a._valueTracker || (a._valueTracker = Ua(a))
  1297. }
  1298. function Wa(a) {
  1299. if (!a)
  1300. return !1;
  1301. var e = a._valueTracker;
  1302. if (!e)
  1303. return !0;
  1304. var i = e.getValue()
  1305. , o = "";
  1306. return a && (o = Ta(a) ? a.checked ? "true" : "false" : a.value),
  1307. a = o,
  1308. a !== i ? (e.setValue(a),
  1309. !0) : !1
  1310. }
  1311. function Xa(a) {
  1312. if (a = a || (typeof document != "undefined" ? document : void 0),
  1313. typeof a == "undefined")
  1314. return null;
  1315. try {
  1316. return a.activeElement || a.body
  1317. } catch {
  1318. return a.body
  1319. }
  1320. }
  1321. function Ya(a, e) {
  1322. var i = e.checked;
  1323. return m$1({}, e, {
  1324. defaultChecked: void 0,
  1325. defaultValue: void 0,
  1326. value: void 0,
  1327. checked: i != null ? i : a._wrapperState.initialChecked
  1328. })
  1329. }
  1330. function Za(a, e) {
  1331. var i = e.defaultValue == null ? "" : e.defaultValue
  1332. , o = e.checked != null ? e.checked : e.defaultChecked;
  1333. i = Sa(e.value != null ? e.value : i),
  1334. a._wrapperState = {
  1335. initialChecked: o,
  1336. initialValue: i,
  1337. controlled: e.type === "checkbox" || e.type === "radio" ? e.checked != null : e.value != null
  1338. }
  1339. }
  1340. function $a(a, e) {
  1341. e = e.checked,
  1342. e != null && qa(a, "checked", e, !1)
  1343. }
  1344. function ab(a, e) {
  1345. $a(a, e);
  1346. var i = Sa(e.value)
  1347. , o = e.type;
  1348. if (i != null)
  1349. o === "number" ? (i === 0 && a.value === "" || a.value != i) && (a.value = "" + i) : a.value !== "" + i && (a.value = "" + i);
  1350. else if (o === "submit" || o === "reset") {
  1351. a.removeAttribute("value");
  1352. return
  1353. }
  1354. e.hasOwnProperty("value") ? bb(a, e.type, i) : e.hasOwnProperty("defaultValue") && bb(a, e.type, Sa(e.defaultValue)),
  1355. e.checked == null && e.defaultChecked != null && (a.defaultChecked = !!e.defaultChecked)
  1356. }
  1357. function cb(a, e, i) {
  1358. if (e.hasOwnProperty("value") || e.hasOwnProperty("defaultValue")) {
  1359. var o = e.type;
  1360. if (!(o !== "submit" && o !== "reset" || e.value !== void 0 && e.value !== null))
  1361. return;
  1362. e = "" + a._wrapperState.initialValue,
  1363. i || e === a.value || (a.value = e),
  1364. a.defaultValue = e
  1365. }
  1366. i = a.name,
  1367. i !== "" && (a.name = ""),
  1368. a.defaultChecked = !!a._wrapperState.initialChecked,
  1369. i !== "" && (a.name = i)
  1370. }
  1371. function bb(a, e, i) {
  1372. (e !== "number" || Xa(a.ownerDocument) !== a) && (i == null ? a.defaultValue = "" + a._wrapperState.initialValue : a.defaultValue !== "" + i && (a.defaultValue = "" + i))
  1373. }
  1374. function db(a) {
  1375. var e = "";
  1376. return aa.Children.forEach(a, function(i) {
  1377. i != null && (e += i)
  1378. }),
  1379. e
  1380. }
  1381. function eb(a, e) {
  1382. return a = m$1({
  1383. children: void 0
  1384. }, e),
  1385. (e = db(e.children)) && (a.children = e),
  1386. a
  1387. }
  1388. function fb(a, e, i, o) {
  1389. if (a = a.options,
  1390. e) {
  1391. e = {};
  1392. for (var s = 0; s < i.length; s++)
  1393. e["$" + i[s]] = !0;
  1394. for (i = 0; i < a.length; i++)
  1395. s = e.hasOwnProperty("$" + a[i].value),
  1396. a[i].selected !== s && (a[i].selected = s),
  1397. s && o && (a[i].defaultSelected = !0)
  1398. } else {
  1399. for (i = "" + Sa(i),
  1400. e = null,
  1401. s = 0; s < a.length; s++) {
  1402. if (a[s].value === i) {
  1403. a[s].selected = !0,
  1404. o && (a[s].defaultSelected = !0);
  1405. return
  1406. }
  1407. e !== null || a[s].disabled || (e = a[s])
  1408. }
  1409. e !== null && (e.selected = !0)
  1410. }
  1411. }
  1412. function gb(a, e) {
  1413. if (e.dangerouslySetInnerHTML != null)
  1414. throw Error(y(91));
  1415. return m$1({}, e, {
  1416. value: void 0,
  1417. defaultValue: void 0,
  1418. children: "" + a._wrapperState.initialValue
  1419. })
  1420. }
  1421. function hb(a, e) {
  1422. var i = e.value;
  1423. if (i == null) {
  1424. if (i = e.children,
  1425. e = e.defaultValue,
  1426. i != null) {
  1427. if (e != null)
  1428. throw Error(y(92));
  1429. if (Array.isArray(i)) {
  1430. if (!(1 >= i.length))
  1431. throw Error(y(93));
  1432. i = i[0]
  1433. }
  1434. e = i
  1435. }
  1436. e == null && (e = ""),
  1437. i = e
  1438. }
  1439. a._wrapperState = {
  1440. initialValue: Sa(i)
  1441. }
  1442. }
  1443. function ib(a, e) {
  1444. var i = Sa(e.value)
  1445. , o = Sa(e.defaultValue);
  1446. i != null && (i = "" + i,
  1447. i !== a.value && (a.value = i),
  1448. e.defaultValue == null && a.defaultValue !== i && (a.defaultValue = i)),
  1449. o != null && (a.defaultValue = "" + o)
  1450. }
  1451. function jb(a) {
  1452. var e = a.textContent;
  1453. e === a._wrapperState.initialValue && e !== "" && e !== null && (a.value = e)
  1454. }
  1455. var kb = {
  1456. html: "http://www.w3.org/1999/xhtml",
  1457. mathml: "http://www.w3.org/1998/Math/MathML",
  1458. svg: "http://www.w3.org/2000/svg"
  1459. };
  1460. function lb(a) {
  1461. switch (a) {
  1462. case "svg":
  1463. return "http://www.w3.org/2000/svg";
  1464. case "math":
  1465. return "http://www.w3.org/1998/Math/MathML";
  1466. default:
  1467. return "http://www.w3.org/1999/xhtml"
  1468. }
  1469. }
  1470. function mb(a, e) {
  1471. return a == null || a === "http://www.w3.org/1999/xhtml" ? lb(e) : a === "http://www.w3.org/2000/svg" && e === "foreignObject" ? "http://www.w3.org/1999/xhtml" : a
  1472. }
  1473. var nb, ob = function(a) {
  1474. return typeof MSApp != "undefined" && MSApp.execUnsafeLocalFunction ? function(e, i, o, s) {
  1475. MSApp.execUnsafeLocalFunction(function() {
  1476. return a(e, i, o, s)
  1477. })
  1478. }
  1479. : a
  1480. }(function(a, e) {
  1481. if (a.namespaceURI !== kb.svg || "innerHTML"in a)
  1482. a.innerHTML = e;
  1483. else {
  1484. for (nb = nb || document.createElement("div"),
  1485. nb.innerHTML = "<svg>" + e.valueOf().toString() + "</svg>",
  1486. e = nb.firstChild; a.firstChild; )
  1487. a.removeChild(a.firstChild);
  1488. for (; e.firstChild; )
  1489. a.appendChild(e.firstChild)
  1490. }
  1491. });
  1492. function pb(a, e) {
  1493. if (e) {
  1494. var i = a.firstChild;
  1495. if (i && i === a.lastChild && i.nodeType === 3) {
  1496. i.nodeValue = e;
  1497. return
  1498. }
  1499. }
  1500. a.textContent = e
  1501. }
  1502. var qb = {
  1503. animationIterationCount: !0,
  1504. borderImageOutset: !0,
  1505. borderImageSlice: !0,
  1506. borderImageWidth: !0,
  1507. boxFlex: !0,
  1508. boxFlexGroup: !0,
  1509. boxOrdinalGroup: !0,
  1510. columnCount: !0,
  1511. columns: !0,
  1512. flex: !0,
  1513. flexGrow: !0,
  1514. flexPositive: !0,
  1515. flexShrink: !0,
  1516. flexNegative: !0,
  1517. flexOrder: !0,
  1518. gridArea: !0,
  1519. gridRow: !0,
  1520. gridRowEnd: !0,
  1521. gridRowSpan: !0,
  1522. gridRowStart: !0,
  1523. gridColumn: !0,
  1524. gridColumnEnd: !0,
  1525. gridColumnSpan: !0,
  1526. gridColumnStart: !0,
  1527. fontWeight: !0,
  1528. lineClamp: !0,
  1529. lineHeight: !0,
  1530. opacity: !0,
  1531. order: !0,
  1532. orphans: !0,
  1533. tabSize: !0,
  1534. widows: !0,
  1535. zIndex: !0,
  1536. zoom: !0,
  1537. fillOpacity: !0,
  1538. floodOpacity: !0,
  1539. stopOpacity: !0,
  1540. strokeDasharray: !0,
  1541. strokeDashoffset: !0,
  1542. strokeMiterlimit: !0,
  1543. strokeOpacity: !0,
  1544. strokeWidth: !0
  1545. }
  1546. , rb = ["Webkit", "ms", "Moz", "O"];
  1547. Object.keys(qb).forEach(function(a) {
  1548. rb.forEach(function(e) {
  1549. e = e + a.charAt(0).toUpperCase() + a.substring(1),
  1550. qb[e] = qb[a]
  1551. })
  1552. });
  1553. function sb(a, e, i) {
  1554. return e == null || typeof e == "boolean" || e === "" ? "" : i || typeof e != "number" || e === 0 || qb.hasOwnProperty(a) && qb[a] ? ("" + e).trim() : e + "px"
  1555. }
  1556. function tb(a, e) {
  1557. a = a.style;
  1558. for (var i in e)
  1559. if (e.hasOwnProperty(i)) {
  1560. var o = i.indexOf("--") === 0
  1561. , s = sb(i, e[i], o);
  1562. i === "float" && (i = "cssFloat"),
  1563. o ? a.setProperty(i, s) : a[i] = s
  1564. }
  1565. }
  1566. var ub = m$1({
  1567. menuitem: !0
  1568. }, {
  1569. area: !0,
  1570. base: !0,
  1571. br: !0,
  1572. col: !0,
  1573. embed: !0,
  1574. hr: !0,
  1575. img: !0,
  1576. input: !0,
  1577. keygen: !0,
  1578. link: !0,
  1579. meta: !0,
  1580. param: !0,
  1581. source: !0,
  1582. track: !0,
  1583. wbr: !0
  1584. });
  1585. function vb(a, e) {
  1586. if (e) {
  1587. if (ub[a] && (e.children != null || e.dangerouslySetInnerHTML != null))
  1588. throw Error(y(137, a));
  1589. if (e.dangerouslySetInnerHTML != null) {
  1590. if (e.children != null)
  1591. throw Error(y(60));
  1592. if (!(typeof e.dangerouslySetInnerHTML == "object" && "__html"in e.dangerouslySetInnerHTML))
  1593. throw Error(y(61))
  1594. }
  1595. if (e.style != null && typeof e.style != "object")
  1596. throw Error(y(62))
  1597. }
  1598. }
  1599. function wb(a, e) {
  1600. if (a.indexOf("-") === -1)
  1601. return typeof e.is == "string";
  1602. switch (a) {
  1603. case "annotation-xml":
  1604. case "color-profile":
  1605. case "font-face":
  1606. case "font-face-src":
  1607. case "font-face-uri":
  1608. case "font-face-format":
  1609. case "font-face-name":
  1610. case "missing-glyph":
  1611. return !1;
  1612. default:
  1613. return !0
  1614. }
  1615. }
  1616. function xb(a) {
  1617. return a = a.target || a.srcElement || window,
  1618. a.correspondingUseElement && (a = a.correspondingUseElement),
  1619. a.nodeType === 3 ? a.parentNode : a
  1620. }
  1621. var yb = null
  1622. , zb = null
  1623. , Ab = null;
  1624. function Bb(a) {
  1625. if (a = Cb(a)) {
  1626. if (typeof yb != "function")
  1627. throw Error(y(280));
  1628. var e = a.stateNode;
  1629. e && (e = Db(e),
  1630. yb(a.stateNode, a.type, e))
  1631. }
  1632. }
  1633. function Eb(a) {
  1634. zb ? Ab ? Ab.push(a) : Ab = [a] : zb = a
  1635. }
  1636. function Fb() {
  1637. if (zb) {
  1638. var a = zb
  1639. , e = Ab;
  1640. if (Ab = zb = null,
  1641. Bb(a),
  1642. e)
  1643. for (a = 0; a < e.length; a++)
  1644. Bb(e[a])
  1645. }
  1646. }
  1647. function Gb(a, e) {
  1648. return a(e)
  1649. }
  1650. function Hb(a, e, i, o, s) {
  1651. return a(e, i, o, s)
  1652. }
  1653. function Ib() {}
  1654. var Jb = Gb
  1655. , Kb = !1
  1656. , Lb = !1;
  1657. function Mb() {
  1658. (zb !== null || Ab !== null) && (Ib(),
  1659. Fb())
  1660. }
  1661. function Nb(a, e, i) {
  1662. if (Lb)
  1663. return a(e, i);
  1664. Lb = !0;
  1665. try {
  1666. return Jb(a, e, i)
  1667. } finally {
  1668. Lb = !1,
  1669. Mb()
  1670. }
  1671. }
  1672. function Ob(a, e) {
  1673. var i = a.stateNode;
  1674. if (i === null)
  1675. return null;
  1676. var o = Db(i);
  1677. if (o === null)
  1678. return null;
  1679. i = o[e];
  1680. e: switch (e) {
  1681. case "onClick":
  1682. case "onClickCapture":
  1683. case "onDoubleClick":
  1684. case "onDoubleClickCapture":
  1685. case "onMouseDown":
  1686. case "onMouseDownCapture":
  1687. case "onMouseMove":
  1688. case "onMouseMoveCapture":
  1689. case "onMouseUp":
  1690. case "onMouseUpCapture":
  1691. case "onMouseEnter":
  1692. (o = !o.disabled) || (a = a.type,
  1693. o = !(a === "button" || a === "input" || a === "select" || a === "textarea")),
  1694. a = !o;
  1695. break e;
  1696. default:
  1697. a = !1
  1698. }
  1699. if (a)
  1700. return null;
  1701. if (i && typeof i != "function")
  1702. throw Error(y(231, e, typeof i));
  1703. return i
  1704. }
  1705. var Pb = !1;
  1706. if (fa)
  1707. try {
  1708. var Qb = {};
  1709. Object.defineProperty(Qb, "passive", {
  1710. get: function() {
  1711. Pb = !0
  1712. }
  1713. }),
  1714. window.addEventListener("test", Qb, Qb),
  1715. window.removeEventListener("test", Qb, Qb)
  1716. } catch {
  1717. Pb = !1
  1718. }
  1719. function Rb(a, e, i, o, s, c, d, _, b) {
  1720. var k = Array.prototype.slice.call(arguments, 3);
  1721. try {
  1722. e.apply(i, k)
  1723. } catch (j) {
  1724. this.onError(j)
  1725. }
  1726. }
  1727. var Sb = !1
  1728. , Tb = null
  1729. , Ub = !1
  1730. , Vb = null
  1731. , Wb = {
  1732. onError: function(a) {
  1733. Sb = !0,
  1734. Tb = a
  1735. }
  1736. };
  1737. function Xb(a, e, i, o, s, c, d, _, b) {
  1738. Sb = !1,
  1739. Tb = null,
  1740. Rb.apply(Wb, arguments)
  1741. }
  1742. function Yb(a, e, i, o, s, c, d, _, b) {
  1743. if (Xb.apply(this, arguments),
  1744. Sb) {
  1745. if (Sb) {
  1746. var k = Tb;
  1747. Sb = !1,
  1748. Tb = null
  1749. } else
  1750. throw Error(y(198));
  1751. Ub || (Ub = !0,
  1752. Vb = k)
  1753. }
  1754. }
  1755. function Zb(a) {
  1756. var e = a
  1757. , i = a;
  1758. if (a.alternate)
  1759. for (; e.return; )
  1760. e = e.return;
  1761. else {
  1762. a = e;
  1763. do
  1764. e = a,
  1765. (e.flags & 1026) !== 0 && (i = e.return),
  1766. a = e.return;
  1767. while (a)
  1768. }
  1769. return e.tag === 3 ? i : null
  1770. }
  1771. function $b(a) {
  1772. if (a.tag === 13) {
  1773. var e = a.memoizedState;
  1774. if (e === null && (a = a.alternate,
  1775. a !== null && (e = a.memoizedState)),
  1776. e !== null)
  1777. return e.dehydrated
  1778. }
  1779. return null
  1780. }
  1781. function ac(a) {
  1782. if (Zb(a) !== a)
  1783. throw Error(y(188))
  1784. }
  1785. function bc(a) {
  1786. var e = a.alternate;
  1787. if (!e) {
  1788. if (e = Zb(a),
  1789. e === null)
  1790. throw Error(y(188));
  1791. return e !== a ? null : a
  1792. }
  1793. for (var i = a, o = e; ; ) {
  1794. var s = i.return;
  1795. if (s === null)
  1796. break;
  1797. var c = s.alternate;
  1798. if (c === null) {
  1799. if (o = s.return,
  1800. o !== null) {
  1801. i = o;
  1802. continue
  1803. }
  1804. break
  1805. }
  1806. if (s.child === c.child) {
  1807. for (c = s.child; c; ) {
  1808. if (c === i)
  1809. return ac(s),
  1810. a;
  1811. if (c === o)
  1812. return ac(s),
  1813. e;
  1814. c = c.sibling
  1815. }
  1816. throw Error(y(188))
  1817. }
  1818. if (i.return !== o.return)
  1819. i = s,
  1820. o = c;
  1821. else {
  1822. for (var d = !1, _ = s.child; _; ) {
  1823. if (_ === i) {
  1824. d = !0,
  1825. i = s,
  1826. o = c;
  1827. break
  1828. }
  1829. if (_ === o) {
  1830. d = !0,
  1831. o = s,
  1832. i = c;
  1833. break
  1834. }
  1835. _ = _.sibling
  1836. }
  1837. if (!d) {
  1838. for (_ = c.child; _; ) {
  1839. if (_ === i) {
  1840. d = !0,
  1841. i = c,
  1842. o = s;
  1843. break
  1844. }
  1845. if (_ === o) {
  1846. d = !0,
  1847. o = c,
  1848. i = s;
  1849. break
  1850. }
  1851. _ = _.sibling
  1852. }
  1853. if (!d)
  1854. throw Error(y(189))
  1855. }
  1856. }
  1857. if (i.alternate !== o)
  1858. throw Error(y(190))
  1859. }
  1860. if (i.tag !== 3)
  1861. throw Error(y(188));
  1862. return i.stateNode.current === i ? a : e
  1863. }
  1864. function cc(a) {
  1865. if (a = bc(a),
  1866. !a)
  1867. return null;
  1868. for (var e = a; ; ) {
  1869. if (e.tag === 5 || e.tag === 6)
  1870. return e;
  1871. if (e.child)
  1872. e.child.return = e,
  1873. e = e.child;
  1874. else {
  1875. if (e === a)
  1876. break;
  1877. for (; !e.sibling; ) {
  1878. if (!e.return || e.return === a)
  1879. return null;
  1880. e = e.return
  1881. }
  1882. e.sibling.return = e.return,
  1883. e = e.sibling
  1884. }
  1885. }
  1886. return null
  1887. }
  1888. function dc(a, e) {
  1889. for (var i = a.alternate; e !== null; ) {
  1890. if (e === a || e === i)
  1891. return !0;
  1892. e = e.return
  1893. }
  1894. return !1
  1895. }
  1896. var ec, fc, gc, hc, ic = !1, jc = [], kc = null, lc = null, mc = null, nc = new Map, oc = new Map, pc = [], qc = "mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");
  1897. function rc(a, e, i, o, s) {
  1898. return {
  1899. blockedOn: a,
  1900. domEventName: e,
  1901. eventSystemFlags: i | 16,
  1902. nativeEvent: s,
  1903. targetContainers: [o]
  1904. }
  1905. }
  1906. function sc(a, e) {
  1907. switch (a) {
  1908. case "focusin":
  1909. case "focusout":
  1910. kc = null;
  1911. break;
  1912. case "dragenter":
  1913. case "dragleave":
  1914. lc = null;
  1915. break;
  1916. case "mouseover":
  1917. case "mouseout":
  1918. mc = null;
  1919. break;
  1920. case "pointerover":
  1921. case "pointerout":
  1922. nc.delete(e.pointerId);
  1923. break;
  1924. case "gotpointercapture":
  1925. case "lostpointercapture":
  1926. oc.delete(e.pointerId)
  1927. }
  1928. }
  1929. function tc(a, e, i, o, s, c) {
  1930. return a === null || a.nativeEvent !== c ? (a = rc(e, i, o, s, c),
  1931. e !== null && (e = Cb(e),
  1932. e !== null && fc(e)),
  1933. a) : (a.eventSystemFlags |= o,
  1934. e = a.targetContainers,
  1935. s !== null && e.indexOf(s) === -1 && e.push(s),
  1936. a)
  1937. }
  1938. function uc(a, e, i, o, s) {
  1939. switch (e) {
  1940. case "focusin":
  1941. return kc = tc(kc, a, e, i, o, s),
  1942. !0;
  1943. case "dragenter":
  1944. return lc = tc(lc, a, e, i, o, s),
  1945. !0;
  1946. case "mouseover":
  1947. return mc = tc(mc, a, e, i, o, s),
  1948. !0;
  1949. case "pointerover":
  1950. var c = s.pointerId;
  1951. return nc.set(c, tc(nc.get(c) || null, a, e, i, o, s)),
  1952. !0;
  1953. case "gotpointercapture":
  1954. return c = s.pointerId,
  1955. oc.set(c, tc(oc.get(c) || null, a, e, i, o, s)),
  1956. !0
  1957. }
  1958. return !1
  1959. }
  1960. function vc(a) {
  1961. var e = wc(a.target);
  1962. if (e !== null) {
  1963. var i = Zb(e);
  1964. if (i !== null) {
  1965. if (e = i.tag,
  1966. e === 13) {
  1967. if (e = $b(i),
  1968. e !== null) {
  1969. a.blockedOn = e,
  1970. hc(a.lanePriority, function() {
  1971. r.unstable_runWithPriority(a.priority, function() {
  1972. gc(i)
  1973. })
  1974. });
  1975. return
  1976. }
  1977. } else if (e === 3 && i.stateNode.hydrate) {
  1978. a.blockedOn = i.tag === 3 ? i.stateNode.containerInfo : null;
  1979. return
  1980. }
  1981. }
  1982. }
  1983. a.blockedOn = null
  1984. }
  1985. function xc(a) {
  1986. if (a.blockedOn !== null)
  1987. return !1;
  1988. for (var e = a.targetContainers; 0 < e.length; ) {
  1989. var i = yc(a.domEventName, a.eventSystemFlags, e[0], a.nativeEvent);
  1990. if (i !== null)
  1991. return e = Cb(i),
  1992. e !== null && fc(e),
  1993. a.blockedOn = i,
  1994. !1;
  1995. e.shift()
  1996. }
  1997. return !0
  1998. }
  1999. function zc(a, e, i) {
  2000. xc(a) && i.delete(e)
  2001. }
  2002. function Ac() {
  2003. for (ic = !1; 0 < jc.length; ) {
  2004. var a = jc[0];
  2005. if (a.blockedOn !== null) {
  2006. a = Cb(a.blockedOn),
  2007. a !== null && ec(a);
  2008. break
  2009. }
  2010. for (var e = a.targetContainers; 0 < e.length; ) {
  2011. var i = yc(a.domEventName, a.eventSystemFlags, e[0], a.nativeEvent);
  2012. if (i !== null) {
  2013. a.blockedOn = i;
  2014. break
  2015. }
  2016. e.shift()
  2017. }
  2018. a.blockedOn === null && jc.shift()
  2019. }
  2020. kc !== null && xc(kc) && (kc = null),
  2021. lc !== null && xc(lc) && (lc = null),
  2022. mc !== null && xc(mc) && (mc = null),
  2023. nc.forEach(zc),
  2024. oc.forEach(zc)
  2025. }
  2026. function Bc(a, e) {
  2027. a.blockedOn === e && (a.blockedOn = null,
  2028. ic || (ic = !0,
  2029. r.unstable_scheduleCallback(r.unstable_NormalPriority, Ac)))
  2030. }
  2031. function Cc(a) {
  2032. function e(s) {
  2033. return Bc(s, a)
  2034. }
  2035. if (0 < jc.length) {
  2036. Bc(jc[0], a);
  2037. for (var i = 1; i < jc.length; i++) {
  2038. var o = jc[i];
  2039. o.blockedOn === a && (o.blockedOn = null)
  2040. }
  2041. }
  2042. for (kc !== null && Bc(kc, a),
  2043. lc !== null && Bc(lc, a),
  2044. mc !== null && Bc(mc, a),
  2045. nc.forEach(e),
  2046. oc.forEach(e),
  2047. i = 0; i < pc.length; i++)
  2048. o = pc[i],
  2049. o.blockedOn === a && (o.blockedOn = null);
  2050. for (; 0 < pc.length && (i = pc[0],
  2051. i.blockedOn === null); )
  2052. vc(i),
  2053. i.blockedOn === null && pc.shift()
  2054. }
  2055. function Dc(a, e) {
  2056. var i = {};
  2057. return i[a.toLowerCase()] = e.toLowerCase(),
  2058. i["Webkit" + a] = "webkit" + e,
  2059. i["Moz" + a] = "moz" + e,
  2060. i
  2061. }
  2062. var Ec = {
  2063. animationend: Dc("Animation", "AnimationEnd"),
  2064. animationiteration: Dc("Animation", "AnimationIteration"),
  2065. animationstart: Dc("Animation", "AnimationStart"),
  2066. transitionend: Dc("Transition", "TransitionEnd")
  2067. }
  2068. , Fc = {}
  2069. , Gc = {};
  2070. fa && (Gc = document.createElement("div").style,
  2071. "AnimationEvent"in window || (delete Ec.animationend.animation,
  2072. delete Ec.animationiteration.animation,
  2073. delete Ec.animationstart.animation),
  2074. "TransitionEvent"in window || delete Ec.transitionend.transition);
  2075. function Hc(a) {
  2076. if (Fc[a])
  2077. return Fc[a];
  2078. if (!Ec[a])
  2079. return a;
  2080. var e = Ec[a], i;
  2081. for (i in e)
  2082. if (e.hasOwnProperty(i) && i in Gc)
  2083. return Fc[a] = e[i];
  2084. return a
  2085. }
  2086. var Ic = Hc("animationend")
  2087. , Jc = Hc("animationiteration")
  2088. , Kc = Hc("animationstart")
  2089. , Lc = Hc("transitionend")
  2090. , Mc = new Map
  2091. , Nc = new Map
  2092. , Oc = ["abort", "abort", Ic, "animationEnd", Jc, "animationIteration", Kc, "animationStart", "canplay", "canPlay", "canplaythrough", "canPlayThrough", "durationchange", "durationChange", "emptied", "emptied", "encrypted", "encrypted", "ended", "ended", "error", "error", "gotpointercapture", "gotPointerCapture", "load", "load", "loadeddata", "loadedData", "loadedmetadata", "loadedMetadata", "loadstart", "loadStart", "lostpointercapture", "lostPointerCapture", "playing", "playing", "progress", "progress", "seeking", "seeking", "stalled", "stalled", "suspend", "suspend", "timeupdate", "timeUpdate", Lc, "transitionEnd", "waiting", "waiting"];
  2093. function Pc(a, e) {
  2094. for (var i = 0; i < a.length; i += 2) {
  2095. var o = a[i]
  2096. , s = a[i + 1];
  2097. s = "on" + (s[0].toUpperCase() + s.slice(1)),
  2098. Nc.set(o, e),
  2099. Mc.set(o, s),
  2100. da(s, [o])
  2101. }
  2102. }
  2103. var Qc = r.unstable_now;
  2104. Qc();
  2105. var F = 8;
  2106. function Rc(a) {
  2107. if ((1 & a) !== 0)
  2108. return F = 15,
  2109. 1;
  2110. if ((2 & a) !== 0)
  2111. return F = 14,
  2112. 2;
  2113. if ((4 & a) !== 0)
  2114. return F = 13,
  2115. 4;
  2116. var e = 24 & a;
  2117. return e !== 0 ? (F = 12,
  2118. e) : (a & 32) !== 0 ? (F = 11,
  2119. 32) : (e = 192 & a,
  2120. e !== 0 ? (F = 10,
  2121. e) : (a & 256) !== 0 ? (F = 9,
  2122. 256) : (e = 3584 & a,
  2123. e !== 0 ? (F = 8,
  2124. e) : (a & 4096) !== 0 ? (F = 7,
  2125. 4096) : (e = 4186112 & a,
  2126. e !== 0 ? (F = 6,
  2127. e) : (e = 62914560 & a,
  2128. e !== 0 ? (F = 5,
  2129. e) : a & 67108864 ? (F = 4,
  2130. 67108864) : (a & 134217728) !== 0 ? (F = 3,
  2131. 134217728) : (e = 805306368 & a,
  2132. e !== 0 ? (F = 2,
  2133. e) : (1073741824 & a) !== 0 ? (F = 1,
  2134. 1073741824) : (F = 8,
  2135. a))))))
  2136. }
  2137. function Sc(a) {
  2138. switch (a) {
  2139. case 99:
  2140. return 15;
  2141. case 98:
  2142. return 10;
  2143. case 97:
  2144. case 96:
  2145. return 8;
  2146. case 95:
  2147. return 2;
  2148. default:
  2149. return 0
  2150. }
  2151. }
  2152. function Tc(a) {
  2153. switch (a) {
  2154. case 15:
  2155. case 14:
  2156. return 99;
  2157. case 13:
  2158. case 12:
  2159. case 11:
  2160. case 10:
  2161. return 98;
  2162. case 9:
  2163. case 8:
  2164. case 7:
  2165. case 6:
  2166. case 4:
  2167. case 5:
  2168. return 97;
  2169. case 3:
  2170. case 2:
  2171. case 1:
  2172. return 95;
  2173. case 0:
  2174. return 90;
  2175. default:
  2176. throw Error(y(358, a))
  2177. }
  2178. }
  2179. function Uc(a, e) {
  2180. var i = a.pendingLanes;
  2181. if (i === 0)
  2182. return F = 0;
  2183. var o = 0
  2184. , s = 0
  2185. , c = a.expiredLanes
  2186. , d = a.suspendedLanes
  2187. , _ = a.pingedLanes;
  2188. if (c !== 0)
  2189. o = c,
  2190. s = F = 15;
  2191. else if (c = i & 134217727,
  2192. c !== 0) {
  2193. var b = c & ~d;
  2194. b !== 0 ? (o = Rc(b),
  2195. s = F) : (_ &= c,
  2196. _ !== 0 && (o = Rc(_),
  2197. s = F))
  2198. } else
  2199. c = i & ~d,
  2200. c !== 0 ? (o = Rc(c),
  2201. s = F) : _ !== 0 && (o = Rc(_),
  2202. s = F);
  2203. if (o === 0)
  2204. return 0;
  2205. if (o = 31 - Vc(o),
  2206. o = i & ((0 > o ? 0 : 1 << o) << 1) - 1,
  2207. e !== 0 && e !== o && (e & d) === 0) {
  2208. if (Rc(e),
  2209. s <= F)
  2210. return e;
  2211. F = s
  2212. }
  2213. if (e = a.entangledLanes,
  2214. e !== 0)
  2215. for (a = a.entanglements,
  2216. e &= o; 0 < e; )
  2217. i = 31 - Vc(e),
  2218. s = 1 << i,
  2219. o |= a[i],
  2220. e &= ~s;
  2221. return o
  2222. }
  2223. function Wc(a) {
  2224. return a = a.pendingLanes & -1073741825,
  2225. a !== 0 ? a : a & 1073741824 ? 1073741824 : 0
  2226. }
  2227. function Xc(a, e) {
  2228. switch (a) {
  2229. case 15:
  2230. return 1;
  2231. case 14:
  2232. return 2;
  2233. case 12:
  2234. return a = Yc(24 & ~e),
  2235. a === 0 ? Xc(10, e) : a;
  2236. case 10:
  2237. return a = Yc(192 & ~e),
  2238. a === 0 ? Xc(8, e) : a;
  2239. case 8:
  2240. return a = Yc(3584 & ~e),
  2241. a === 0 && (a = Yc(4186112 & ~e),
  2242. a === 0 && (a = 512)),
  2243. a;
  2244. case 2:
  2245. return e = Yc(805306368 & ~e),
  2246. e === 0 && (e = 268435456),
  2247. e
  2248. }
  2249. throw Error(y(358, a))
  2250. }
  2251. function Yc(a) {
  2252. return a & -a
  2253. }
  2254. function Zc(a) {
  2255. for (var e = [], i = 0; 31 > i; i++)
  2256. e.push(a);
  2257. return e
  2258. }
  2259. function $c(a, e, i) {
  2260. a.pendingLanes |= e;
  2261. var o = e - 1;
  2262. a.suspendedLanes &= o,
  2263. a.pingedLanes &= o,
  2264. a = a.eventTimes,
  2265. e = 31 - Vc(e),
  2266. a[e] = i
  2267. }
  2268. var Vc = Math.clz32 ? Math.clz32 : ad
  2269. , bd = Math.log
  2270. , cd = Math.LN2;
  2271. function ad(a) {
  2272. return a === 0 ? 32 : 31 - (bd(a) / cd | 0) | 0
  2273. }
  2274. var dd = r.unstable_UserBlockingPriority
  2275. , ed = r.unstable_runWithPriority
  2276. , fd = !0;
  2277. function gd(a, e, i, o) {
  2278. Kb || Ib();
  2279. var s = hd
  2280. , c = Kb;
  2281. Kb = !0;
  2282. try {
  2283. Hb(s, a, e, i, o)
  2284. } finally {
  2285. (Kb = c) || Mb()
  2286. }
  2287. }
  2288. function id(a, e, i, o) {
  2289. ed(dd, hd.bind(null, a, e, i, o))
  2290. }
  2291. function hd(a, e, i, o) {
  2292. if (fd) {
  2293. var s;
  2294. if ((s = (e & 4) === 0) && 0 < jc.length && -1 < qc.indexOf(a))
  2295. a = rc(null, a, e, i, o),
  2296. jc.push(a);
  2297. else {
  2298. var c = yc(a, e, i, o);
  2299. if (c === null)
  2300. s && sc(a, o);
  2301. else {
  2302. if (s) {
  2303. if (-1 < qc.indexOf(a)) {
  2304. a = rc(c, a, e, i, o),
  2305. jc.push(a);
  2306. return
  2307. }
  2308. if (uc(c, a, e, i, o))
  2309. return;
  2310. sc(a, o)
  2311. }
  2312. jd(a, e, o, null, i)
  2313. }
  2314. }
  2315. }
  2316. }
  2317. function yc(a, e, i, o) {
  2318. var s = xb(o);
  2319. if (s = wc(s),
  2320. s !== null) {
  2321. var c = Zb(s);
  2322. if (c === null)
  2323. s = null;
  2324. else {
  2325. var d = c.tag;
  2326. if (d === 13) {
  2327. if (s = $b(c),
  2328. s !== null)
  2329. return s;
  2330. s = null
  2331. } else if (d === 3) {
  2332. if (c.stateNode.hydrate)
  2333. return c.tag === 3 ? c.stateNode.containerInfo : null;
  2334. s = null
  2335. } else
  2336. c !== s && (s = null)
  2337. }
  2338. }
  2339. return jd(a, e, o, s, i),
  2340. null
  2341. }
  2342. var kd = null
  2343. , ld = null
  2344. , md = null;
  2345. function nd() {
  2346. if (md)
  2347. return md;
  2348. var a, e = ld, i = e.length, o, s = "value"in kd ? kd.value : kd.textContent, c = s.length;
  2349. for (a = 0; a < i && e[a] === s[a]; a++)
  2350. ;
  2351. var d = i - a;
  2352. for (o = 1; o <= d && e[i - o] === s[c - o]; o++)
  2353. ;
  2354. return md = s.slice(a, 1 < o ? 1 - o : void 0)
  2355. }
  2356. function od(a) {
  2357. var e = a.keyCode;
  2358. return "charCode"in a ? (a = a.charCode,
  2359. a === 0 && e === 13 && (a = 13)) : a = e,
  2360. a === 10 && (a = 13),
  2361. 32 <= a || a === 13 ? a : 0
  2362. }
  2363. function pd() {
  2364. return !0
  2365. }
  2366. function qd() {
  2367. return !1
  2368. }
  2369. function rd(a) {
  2370. function e(i, o, s, c, d) {
  2371. this._reactName = i,
  2372. this._targetInst = s,
  2373. this.type = o,
  2374. this.nativeEvent = c,
  2375. this.target = d,
  2376. this.currentTarget = null;
  2377. for (var _ in a)
  2378. a.hasOwnProperty(_) && (i = a[_],
  2379. this[_] = i ? i(c) : c[_]);
  2380. return this.isDefaultPrevented = (c.defaultPrevented != null ? c.defaultPrevented : c.returnValue === !1) ? pd : qd,
  2381. this.isPropagationStopped = qd,
  2382. this
  2383. }
  2384. return m$1(e.prototype, {
  2385. preventDefault: function() {
  2386. this.defaultPrevented = !0;
  2387. var i = this.nativeEvent;
  2388. i && (i.preventDefault ? i.preventDefault() : typeof i.returnValue != "unknown" && (i.returnValue = !1),
  2389. this.isDefaultPrevented = pd)
  2390. },
  2391. stopPropagation: function() {
  2392. var i = this.nativeEvent;
  2393. i && (i.stopPropagation ? i.stopPropagation() : typeof i.cancelBubble != "unknown" && (i.cancelBubble = !0),
  2394. this.isPropagationStopped = pd)
  2395. },
  2396. persist: function() {},
  2397. isPersistent: pd
  2398. }),
  2399. e
  2400. }
  2401. var sd = {
  2402. eventPhase: 0,
  2403. bubbles: 0,
  2404. cancelable: 0,
  2405. timeStamp: function(a) {
  2406. return a.timeStamp || Date.now()
  2407. },
  2408. defaultPrevented: 0,
  2409. isTrusted: 0
  2410. }, td = rd(sd), ud = m$1({}, sd, {
  2411. view: 0,
  2412. detail: 0
  2413. }), vd = rd(ud), wd, xd, yd, Ad = m$1({}, ud, {
  2414. screenX: 0,
  2415. screenY: 0,
  2416. clientX: 0,
  2417. clientY: 0,
  2418. pageX: 0,
  2419. pageY: 0,
  2420. ctrlKey: 0,
  2421. shiftKey: 0,
  2422. altKey: 0,
  2423. metaKey: 0,
  2424. getModifierState: zd,
  2425. button: 0,
  2426. buttons: 0,
  2427. relatedTarget: function(a) {
  2428. return a.relatedTarget === void 0 ? a.fromElement === a.srcElement ? a.toElement : a.fromElement : a.relatedTarget
  2429. },
  2430. movementX: function(a) {
  2431. return "movementX"in a ? a.movementX : (a !== yd && (yd && a.type === "mousemove" ? (wd = a.screenX - yd.screenX,
  2432. xd = a.screenY - yd.screenY) : xd = wd = 0,
  2433. yd = a),
  2434. wd)
  2435. },
  2436. movementY: function(a) {
  2437. return "movementY"in a ? a.movementY : xd
  2438. }
  2439. }), Bd = rd(Ad), Cd = m$1({}, Ad, {
  2440. dataTransfer: 0
  2441. }), Dd = rd(Cd), Ed = m$1({}, ud, {
  2442. relatedTarget: 0
  2443. }), Fd = rd(Ed), Gd = m$1({}, sd, {
  2444. animationName: 0,
  2445. elapsedTime: 0,
  2446. pseudoElement: 0
  2447. }), Hd = rd(Gd), Id = m$1({}, sd, {
  2448. clipboardData: function(a) {
  2449. return "clipboardData"in a ? a.clipboardData : window.clipboardData
  2450. }
  2451. }), Jd = rd(Id), Kd = m$1({}, sd, {
  2452. data: 0
  2453. }), Ld = rd(Kd), Md = {
  2454. Esc: "Escape",
  2455. Spacebar: " ",
  2456. Left: "ArrowLeft",
  2457. Up: "ArrowUp",
  2458. Right: "ArrowRight",
  2459. Down: "ArrowDown",
  2460. Del: "Delete",
  2461. Win: "OS",
  2462. Menu: "ContextMenu",
  2463. Apps: "ContextMenu",
  2464. Scroll: "ScrollLock",
  2465. MozPrintableKey: "Unidentified"
  2466. }, Nd = {
  2467. 8: "Backspace",
  2468. 9: "Tab",
  2469. 12: "Clear",
  2470. 13: "Enter",
  2471. 16: "Shift",
  2472. 17: "Control",
  2473. 18: "Alt",
  2474. 19: "Pause",
  2475. 20: "CapsLock",
  2476. 27: "Escape",
  2477. 32: " ",
  2478. 33: "PageUp",
  2479. 34: "PageDown",
  2480. 35: "End",
  2481. 36: "Home",
  2482. 37: "ArrowLeft",
  2483. 38: "ArrowUp",
  2484. 39: "ArrowRight",
  2485. 40: "ArrowDown",
  2486. 45: "Insert",
  2487. 46: "Delete",
  2488. 112: "F1",
  2489. 113: "F2",
  2490. 114: "F3",
  2491. 115: "F4",
  2492. 116: "F5",
  2493. 117: "F6",
  2494. 118: "F7",
  2495. 119: "F8",
  2496. 120: "F9",
  2497. 121: "F10",
  2498. 122: "F11",
  2499. 123: "F12",
  2500. 144: "NumLock",
  2501. 145: "ScrollLock",
  2502. 224: "Meta"
  2503. }, Od = {
  2504. Alt: "altKey",
  2505. Control: "ctrlKey",
  2506. Meta: "metaKey",
  2507. Shift: "shiftKey"
  2508. };
  2509. function Pd(a) {
  2510. var e = this.nativeEvent;
  2511. return e.getModifierState ? e.getModifierState(a) : (a = Od[a]) ? !!e[a] : !1
  2512. }
  2513. function zd() {
  2514. return Pd
  2515. }
  2516. var Qd = m$1({}, ud, {
  2517. key: function(a) {
  2518. if (a.key) {
  2519. var e = Md[a.key] || a.key;
  2520. if (e !== "Unidentified")
  2521. return e
  2522. }
  2523. return a.type === "keypress" ? (a = od(a),
  2524. a === 13 ? "Enter" : String.fromCharCode(a)) : a.type === "keydown" || a.type === "keyup" ? Nd[a.keyCode] || "Unidentified" : ""
  2525. },
  2526. code: 0,
  2527. location: 0,
  2528. ctrlKey: 0,
  2529. shiftKey: 0,
  2530. altKey: 0,
  2531. metaKey: 0,
  2532. repeat: 0,
  2533. locale: 0,
  2534. getModifierState: zd,
  2535. charCode: function(a) {
  2536. return a.type === "keypress" ? od(a) : 0
  2537. },
  2538. keyCode: function(a) {
  2539. return a.type === "keydown" || a.type === "keyup" ? a.keyCode : 0
  2540. },
  2541. which: function(a) {
  2542. return a.type === "keypress" ? od(a) : a.type === "keydown" || a.type === "keyup" ? a.keyCode : 0
  2543. }
  2544. })
  2545. , Rd = rd(Qd)
  2546. , Sd = m$1({}, Ad, {
  2547. pointerId: 0,
  2548. width: 0,
  2549. height: 0,
  2550. pressure: 0,
  2551. tangentialPressure: 0,
  2552. tiltX: 0,
  2553. tiltY: 0,
  2554. twist: 0,
  2555. pointerType: 0,
  2556. isPrimary: 0
  2557. })
  2558. , Td = rd(Sd)
  2559. , Ud = m$1({}, ud, {
  2560. touches: 0,
  2561. targetTouches: 0,
  2562. changedTouches: 0,
  2563. altKey: 0,
  2564. metaKey: 0,
  2565. ctrlKey: 0,
  2566. shiftKey: 0,
  2567. getModifierState: zd
  2568. })
  2569. , Vd = rd(Ud)
  2570. , Wd = m$1({}, sd, {
  2571. propertyName: 0,
  2572. elapsedTime: 0,
  2573. pseudoElement: 0
  2574. })
  2575. , Xd = rd(Wd)
  2576. , Yd = m$1({}, Ad, {
  2577. deltaX: function(a) {
  2578. return "deltaX"in a ? a.deltaX : "wheelDeltaX"in a ? -a.wheelDeltaX : 0
  2579. },
  2580. deltaY: function(a) {
  2581. return "deltaY"in a ? a.deltaY : "wheelDeltaY"in a ? -a.wheelDeltaY : "wheelDelta"in a ? -a.wheelDelta : 0
  2582. },
  2583. deltaZ: 0,
  2584. deltaMode: 0
  2585. })
  2586. , Zd = rd(Yd)
  2587. , $d = [9, 13, 27, 32]
  2588. , ae = fa && "CompositionEvent"in window
  2589. , be = null;
  2590. fa && "documentMode"in document && (be = document.documentMode);
  2591. var ce = fa && "TextEvent"in window && !be
  2592. , de = fa && (!ae || be && 8 < be && 11 >= be)
  2593. , ee = String.fromCharCode(32)
  2594. , fe = !1;
  2595. function ge(a, e) {
  2596. switch (a) {
  2597. case "keyup":
  2598. return $d.indexOf(e.keyCode) !== -1;
  2599. case "keydown":
  2600. return e.keyCode !== 229;
  2601. case "keypress":
  2602. case "mousedown":
  2603. case "focusout":
  2604. return !0;
  2605. default:
  2606. return !1
  2607. }
  2608. }
  2609. function he(a) {
  2610. return a = a.detail,
  2611. typeof a == "object" && "data"in a ? a.data : null
  2612. }
  2613. var ie = !1;
  2614. function je(a, e) {
  2615. switch (a) {
  2616. case "compositionend":
  2617. return he(e);
  2618. case "keypress":
  2619. return e.which !== 32 ? null : (fe = !0,
  2620. ee);
  2621. case "textInput":
  2622. return a = e.data,
  2623. a === ee && fe ? null : a;
  2624. default:
  2625. return null
  2626. }
  2627. }
  2628. function ke(a, e) {
  2629. if (ie)
  2630. return a === "compositionend" || !ae && ge(a, e) ? (a = nd(),
  2631. md = ld = kd = null,
  2632. ie = !1,
  2633. a) : null;
  2634. switch (a) {
  2635. case "paste":
  2636. return null;
  2637. case "keypress":
  2638. if (!(e.ctrlKey || e.altKey || e.metaKey) || e.ctrlKey && e.altKey) {
  2639. if (e.char && 1 < e.char.length)
  2640. return e.char;
  2641. if (e.which)
  2642. return String.fromCharCode(e.which)
  2643. }
  2644. return null;
  2645. case "compositionend":
  2646. return de && e.locale !== "ko" ? null : e.data;
  2647. default:
  2648. return null
  2649. }
  2650. }
  2651. var le = {
  2652. color: !0,
  2653. date: !0,
  2654. datetime: !0,
  2655. "datetime-local": !0,
  2656. email: !0,
  2657. month: !0,
  2658. number: !0,
  2659. password: !0,
  2660. range: !0,
  2661. search: !0,
  2662. tel: !0,
  2663. text: !0,
  2664. time: !0,
  2665. url: !0,
  2666. week: !0
  2667. };
  2668. function me(a) {
  2669. var e = a && a.nodeName && a.nodeName.toLowerCase();
  2670. return e === "input" ? !!le[a.type] : e === "textarea"
  2671. }
  2672. function ne(a, e, i, o) {
  2673. Eb(o),
  2674. e = oe(e, "onChange"),
  2675. 0 < e.length && (i = new td("onChange","change",null,i,o),
  2676. a.push({
  2677. event: i,
  2678. listeners: e
  2679. }))
  2680. }
  2681. var pe = null
  2682. , qe = null;
  2683. function re(a) {
  2684. se(a, 0)
  2685. }
  2686. function te(a) {
  2687. var e = ue(a);
  2688. if (Wa(e))
  2689. return a
  2690. }
  2691. function ve(a, e) {
  2692. if (a === "change")
  2693. return e
  2694. }
  2695. var we = !1;
  2696. if (fa) {
  2697. var xe;
  2698. if (fa) {
  2699. var ye = "oninput"in document;
  2700. if (!ye) {
  2701. var ze = document.createElement("div");
  2702. ze.setAttribute("oninput", "return;"),
  2703. ye = typeof ze.oninput == "function"
  2704. }
  2705. xe = ye
  2706. } else
  2707. xe = !1;
  2708. we = xe && (!document.documentMode || 9 < document.documentMode)
  2709. }
  2710. function Ae() {
  2711. pe && (pe.detachEvent("onpropertychange", Be),
  2712. qe = pe = null)
  2713. }
  2714. function Be(a) {
  2715. if (a.propertyName === "value" && te(qe)) {
  2716. var e = [];
  2717. if (ne(e, qe, a, xb(a)),
  2718. a = re,
  2719. Kb)
  2720. a(e);
  2721. else {
  2722. Kb = !0;
  2723. try {
  2724. Gb(a, e)
  2725. } finally {
  2726. Kb = !1,
  2727. Mb()
  2728. }
  2729. }
  2730. }
  2731. }
  2732. function Ce(a, e, i) {
  2733. a === "focusin" ? (Ae(),
  2734. pe = e,
  2735. qe = i,
  2736. pe.attachEvent("onpropertychange", Be)) : a === "focusout" && Ae()
  2737. }
  2738. function De(a) {
  2739. if (a === "selectionchange" || a === "keyup" || a === "keydown")
  2740. return te(qe)
  2741. }
  2742. function Ee(a, e) {
  2743. if (a === "click")
  2744. return te(e)
  2745. }
  2746. function Fe(a, e) {
  2747. if (a === "input" || a === "change")
  2748. return te(e)
  2749. }
  2750. function Ge(a, e) {
  2751. return a === e && (a !== 0 || 1 / a === 1 / e) || a !== a && e !== e
  2752. }
  2753. var He = typeof Object.is == "function" ? Object.is : Ge
  2754. , Ie = Object.prototype.hasOwnProperty;
  2755. function Je(a, e) {
  2756. if (He(a, e))
  2757. return !0;
  2758. if (typeof a != "object" || a === null || typeof e != "object" || e === null)
  2759. return !1;
  2760. var i = Object.keys(a)
  2761. , o = Object.keys(e);
  2762. if (i.length !== o.length)
  2763. return !1;
  2764. for (o = 0; o < i.length; o++)
  2765. if (!Ie.call(e, i[o]) || !He(a[i[o]], e[i[o]]))
  2766. return !1;
  2767. return !0
  2768. }
  2769. function Ke(a) {
  2770. for (; a && a.firstChild; )
  2771. a = a.firstChild;
  2772. return a
  2773. }
  2774. function Le(a, e) {
  2775. var i = Ke(a);
  2776. a = 0;
  2777. for (var o; i; ) {
  2778. if (i.nodeType === 3) {
  2779. if (o = a + i.textContent.length,
  2780. a <= e && o >= e)
  2781. return {
  2782. node: i,
  2783. offset: e - a
  2784. };
  2785. a = o
  2786. }
  2787. e: {
  2788. for (; i; ) {
  2789. if (i.nextSibling) {
  2790. i = i.nextSibling;
  2791. break e
  2792. }
  2793. i = i.parentNode
  2794. }
  2795. i = void 0
  2796. }
  2797. i = Ke(i)
  2798. }
  2799. }
  2800. function Me(a, e) {
  2801. return a && e ? a === e ? !0 : a && a.nodeType === 3 ? !1 : e && e.nodeType === 3 ? Me(a, e.parentNode) : "contains"in a ? a.contains(e) : a.compareDocumentPosition ? !!(a.compareDocumentPosition(e) & 16) : !1 : !1
  2802. }
  2803. function Ne() {
  2804. for (var a = window, e = Xa(); e instanceof a.HTMLIFrameElement; ) {
  2805. try {
  2806. var i = typeof e.contentWindow.location.href == "string"
  2807. } catch {
  2808. i = !1
  2809. }
  2810. if (i)
  2811. a = e.contentWindow;
  2812. else
  2813. break;
  2814. e = Xa(a.document)
  2815. }
  2816. return e
  2817. }
  2818. function Oe(a) {
  2819. var e = a && a.nodeName && a.nodeName.toLowerCase();
  2820. return e && (e === "input" && (a.type === "text" || a.type === "search" || a.type === "tel" || a.type === "url" || a.type === "password") || e === "textarea" || a.contentEditable === "true")
  2821. }
  2822. var Pe = fa && "documentMode"in document && 11 >= document.documentMode
  2823. , Qe = null
  2824. , Re = null
  2825. , Se = null
  2826. , Te = !1;
  2827. function Ue(a, e, i) {
  2828. var o = i.window === i ? i.document : i.nodeType === 9 ? i : i.ownerDocument;
  2829. Te || Qe == null || Qe !== Xa(o) || (o = Qe,
  2830. "selectionStart"in o && Oe(o) ? o = {
  2831. start: o.selectionStart,
  2832. end: o.selectionEnd
  2833. } : (o = (o.ownerDocument && o.ownerDocument.defaultView || window).getSelection(),
  2834. o = {
  2835. anchorNode: o.anchorNode,
  2836. anchorOffset: o.anchorOffset,
  2837. focusNode: o.focusNode,
  2838. focusOffset: o.focusOffset
  2839. }),
  2840. Se && Je(Se, o) || (Se = o,
  2841. o = oe(Re, "onSelect"),
  2842. 0 < o.length && (e = new td("onSelect","select",null,e,i),
  2843. a.push({
  2844. event: e,
  2845. listeners: o
  2846. }),
  2847. e.target = Qe)))
  2848. }
  2849. Pc("cancel cancel click click close close contextmenu contextMenu copy copy cut cut auxclick auxClick dblclick doubleClick dragend dragEnd dragstart dragStart drop drop focusin focus focusout blur input input invalid invalid keydown keyDown keypress keyPress keyup keyUp mousedown mouseDown mouseup mouseUp paste paste pause pause play play pointercancel pointerCancel pointerdown pointerDown pointerup pointerUp ratechange rateChange reset reset seeked seeked submit submit touchcancel touchCancel touchend touchEnd touchstart touchStart volumechange volumeChange".split(" "), 0);
  2850. Pc("drag drag dragenter dragEnter dragexit dragExit dragleave dragLeave dragover dragOver mousemove mouseMove mouseout mouseOut mouseover mouseOver pointermove pointerMove pointerout pointerOut pointerover pointerOver scroll scroll toggle toggle touchmove touchMove wheel wheel".split(" "), 1);
  2851. Pc(Oc, 2);
  2852. for (var Ve = "change selectionchange textInput compositionstart compositionend compositionupdate".split(" "), We = 0; We < Ve.length; We++)
  2853. Nc.set(Ve[We], 0);
  2854. ea("onMouseEnter", ["mouseout", "mouseover"]);
  2855. ea("onMouseLeave", ["mouseout", "mouseover"]);
  2856. ea("onPointerEnter", ["pointerout", "pointerover"]);
  2857. ea("onPointerLeave", ["pointerout", "pointerover"]);
  2858. da("onChange", "change click focusin focusout input keydown keyup selectionchange".split(" "));
  2859. da("onSelect", "focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));
  2860. da("onBeforeInput", ["compositionend", "keypress", "textInput", "paste"]);
  2861. da("onCompositionEnd", "compositionend focusout keydown keypress keyup mousedown".split(" "));
  2862. da("onCompositionStart", "compositionstart focusout keydown keypress keyup mousedown".split(" "));
  2863. da("onCompositionUpdate", "compositionupdate focusout keydown keypress keyup mousedown".split(" "));
  2864. var Xe = "abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange seeked seeking stalled suspend timeupdate volumechange waiting".split(" ")
  2865. , Ye = new Set("cancel close invalid load scroll toggle".split(" ").concat(Xe));
  2866. function Ze(a, e, i) {
  2867. var o = a.type || "unknown-event";
  2868. a.currentTarget = i,
  2869. Yb(o, e, void 0, a),
  2870. a.currentTarget = null
  2871. }
  2872. function se(a, e) {
  2873. e = (e & 4) !== 0;
  2874. for (var i = 0; i < a.length; i++) {
  2875. var o = a[i]
  2876. , s = o.event;
  2877. o = o.listeners;
  2878. e: {
  2879. var c = void 0;
  2880. if (e)
  2881. for (var d = o.length - 1; 0 <= d; d--) {
  2882. var _ = o[d]
  2883. , b = _.instance
  2884. , k = _.currentTarget;
  2885. if (_ = _.listener,
  2886. b !== c && s.isPropagationStopped())
  2887. break e;
  2888. Ze(s, _, k),
  2889. c = b
  2890. }
  2891. else
  2892. for (d = 0; d < o.length; d++) {
  2893. if (_ = o[d],
  2894. b = _.instance,
  2895. k = _.currentTarget,
  2896. _ = _.listener,
  2897. b !== c && s.isPropagationStopped())
  2898. break e;
  2899. Ze(s, _, k),
  2900. c = b
  2901. }
  2902. }
  2903. }
  2904. if (Ub)
  2905. throw a = Vb,
  2906. Ub = !1,
  2907. Vb = null,
  2908. a
  2909. }
  2910. function G(a, e) {
  2911. var i = $e(e)
  2912. , o = a + "__bubble";
  2913. i.has(o) || (af(e, a, 2, !1),
  2914. i.add(o))
  2915. }
  2916. var bf = "_reactListening" + Math.random().toString(36).slice(2);
  2917. function cf(a) {
  2918. a[bf] || (a[bf] = !0,
  2919. ba.forEach(function(e) {
  2920. Ye.has(e) || df(e, !1, a, null),
  2921. df(e, !0, a, null)
  2922. }))
  2923. }
  2924. function df(a, e, i, o) {
  2925. var s = 4 < arguments.length && arguments[4] !== void 0 ? arguments[4] : 0
  2926. , c = i;
  2927. if (a === "selectionchange" && i.nodeType !== 9 && (c = i.ownerDocument),
  2928. o !== null && !e && Ye.has(a)) {
  2929. if (a !== "scroll")
  2930. return;
  2931. s |= 2,
  2932. c = o
  2933. }
  2934. var d = $e(c)
  2935. , _ = a + "__" + (e ? "capture" : "bubble");
  2936. d.has(_) || (e && (s |= 4),
  2937. af(c, a, s, e),
  2938. d.add(_))
  2939. }
  2940. function af(a, e, i, o) {
  2941. var s = Nc.get(e);
  2942. switch (s === void 0 ? 2 : s) {
  2943. case 0:
  2944. s = gd;
  2945. break;
  2946. case 1:
  2947. s = id;
  2948. break;
  2949. default:
  2950. s = hd
  2951. }
  2952. i = s.bind(null, e, i, a),
  2953. s = void 0,
  2954. !Pb || e !== "touchstart" && e !== "touchmove" && e !== "wheel" || (s = !0),
  2955. o ? s !== void 0 ? a.addEventListener(e, i, {
  2956. capture: !0,
  2957. passive: s
  2958. }) : a.addEventListener(e, i, !0) : s !== void 0 ? a.addEventListener(e, i, {
  2959. passive: s
  2960. }) : a.addEventListener(e, i, !1)
  2961. }
  2962. function jd(a, e, i, o, s) {
  2963. var c = o;
  2964. if ((e & 1) === 0 && (e & 2) === 0 && o !== null)
  2965. e: for (; ; ) {
  2966. if (o === null)
  2967. return;
  2968. var d = o.tag;
  2969. if (d === 3 || d === 4) {
  2970. var _ = o.stateNode.containerInfo;
  2971. if (_ === s || _.nodeType === 8 && _.parentNode === s)
  2972. break;
  2973. if (d === 4)
  2974. for (d = o.return; d !== null; ) {
  2975. var b = d.tag;
  2976. if ((b === 3 || b === 4) && (b = d.stateNode.containerInfo,
  2977. b === s || b.nodeType === 8 && b.parentNode === s))
  2978. return;
  2979. d = d.return
  2980. }
  2981. for (; _ !== null; ) {
  2982. if (d = wc(_),
  2983. d === null)
  2984. return;
  2985. if (b = d.tag,
  2986. b === 5 || b === 6) {
  2987. o = c = d;
  2988. continue e
  2989. }
  2990. _ = _.parentNode
  2991. }
  2992. }
  2993. o = o.return
  2994. }
  2995. Nb(function() {
  2996. var k = c
  2997. , j = xb(i)
  2998. , $ = [];
  2999. e: {
  3000. var _e = Mc.get(a);
  3001. if (_e !== void 0) {
  3002. var et = td
  3003. , tt = a;
  3004. switch (a) {
  3005. case "keypress":
  3006. if (od(i) === 0)
  3007. break e;
  3008. case "keydown":
  3009. case "keyup":
  3010. et = Rd;
  3011. break;
  3012. case "focusin":
  3013. tt = "focus",
  3014. et = Fd;
  3015. break;
  3016. case "focusout":
  3017. tt = "blur",
  3018. et = Fd;
  3019. break;
  3020. case "beforeblur":
  3021. case "afterblur":
  3022. et = Fd;
  3023. break;
  3024. case "click":
  3025. if (i.button === 2)
  3026. break e;
  3027. case "auxclick":
  3028. case "dblclick":
  3029. case "mousedown":
  3030. case "mousemove":
  3031. case "mouseup":
  3032. case "mouseout":
  3033. case "mouseover":
  3034. case "contextmenu":
  3035. et = Bd;
  3036. break;
  3037. case "drag":
  3038. case "dragend":
  3039. case "dragenter":
  3040. case "dragexit":
  3041. case "dragleave":
  3042. case "dragover":
  3043. case "dragstart":
  3044. case "drop":
  3045. et = Dd;
  3046. break;
  3047. case "touchcancel":
  3048. case "touchend":
  3049. case "touchmove":
  3050. case "touchstart":
  3051. et = Vd;
  3052. break;
  3053. case Ic:
  3054. case Jc:
  3055. case Kc:
  3056. et = Hd;
  3057. break;
  3058. case Lc:
  3059. et = Xd;
  3060. break;
  3061. case "scroll":
  3062. et = vd;
  3063. break;
  3064. case "wheel":
  3065. et = Zd;
  3066. break;
  3067. case "copy":
  3068. case "cut":
  3069. case "paste":
  3070. et = Jd;
  3071. break;
  3072. case "gotpointercapture":
  3073. case "lostpointercapture":
  3074. case "pointercancel":
  3075. case "pointerdown":
  3076. case "pointermove":
  3077. case "pointerout":
  3078. case "pointerover":
  3079. case "pointerup":
  3080. et = Td
  3081. }
  3082. var rt = (e & 4) !== 0
  3083. , it = !rt && a === "scroll"
  3084. , nt = rt ? _e !== null ? _e + "Capture" : null : _e;
  3085. rt = [];
  3086. for (var ot = k, at; ot !== null; ) {
  3087. at = ot;
  3088. var st = at.stateNode;
  3089. if (at.tag === 5 && st !== null && (at = st,
  3090. nt !== null && (st = Ob(ot, nt),
  3091. st != null && rt.push(ef(ot, st, at)))),
  3092. it)
  3093. break;
  3094. ot = ot.return
  3095. }
  3096. 0 < rt.length && (_e = new et(_e,tt,null,i,j),
  3097. $.push({
  3098. event: _e,
  3099. listeners: rt
  3100. }))
  3101. }
  3102. }
  3103. if ((e & 7) === 0) {
  3104. e: {
  3105. if (_e = a === "mouseover" || a === "pointerover",
  3106. et = a === "mouseout" || a === "pointerout",
  3107. _e && (e & 16) === 0 && (tt = i.relatedTarget || i.fromElement) && (wc(tt) || tt[ff]))
  3108. break e;
  3109. if ((et || _e) && (_e = j.window === j ? j : (_e = j.ownerDocument) ? _e.defaultView || _e.parentWindow : window,
  3110. et ? (tt = i.relatedTarget || i.toElement,
  3111. et = k,
  3112. tt = tt ? wc(tt) : null,
  3113. tt !== null && (it = Zb(tt),
  3114. tt !== it || tt.tag !== 5 && tt.tag !== 6) && (tt = null)) : (et = null,
  3115. tt = k),
  3116. et !== tt)) {
  3117. if (rt = Bd,
  3118. st = "onMouseLeave",
  3119. nt = "onMouseEnter",
  3120. ot = "mouse",
  3121. (a === "pointerout" || a === "pointerover") && (rt = Td,
  3122. st = "onPointerLeave",
  3123. nt = "onPointerEnter",
  3124. ot = "pointer"),
  3125. it = et == null ? _e : ue(et),
  3126. at = tt == null ? _e : ue(tt),
  3127. _e = new rt(st,ot + "leave",et,i,j),
  3128. _e.target = it,
  3129. _e.relatedTarget = at,
  3130. st = null,
  3131. wc(j) === k && (rt = new rt(nt,ot + "enter",tt,i,j),
  3132. rt.target = at,
  3133. rt.relatedTarget = it,
  3134. st = rt),
  3135. it = st,
  3136. et && tt)
  3137. t: {
  3138. for (rt = et,
  3139. nt = tt,
  3140. ot = 0,
  3141. at = rt; at; at = gf(at))
  3142. ot++;
  3143. for (at = 0,
  3144. st = nt; st; st = gf(st))
  3145. at++;
  3146. for (; 0 < ot - at; )
  3147. rt = gf(rt),
  3148. ot--;
  3149. for (; 0 < at - ot; )
  3150. nt = gf(nt),
  3151. at--;
  3152. for (; ot--; ) {
  3153. if (rt === nt || nt !== null && rt === nt.alternate)
  3154. break t;
  3155. rt = gf(rt),
  3156. nt = gf(nt)
  3157. }
  3158. rt = null
  3159. }
  3160. else
  3161. rt = null;
  3162. et !== null && hf($, _e, et, rt, !1),
  3163. tt !== null && it !== null && hf($, it, tt, rt, !0)
  3164. }
  3165. }
  3166. e: {
  3167. if (_e = k ? ue(k) : window,
  3168. et = _e.nodeName && _e.nodeName.toLowerCase(),
  3169. et === "select" || et === "input" && _e.type === "file")
  3170. var ut = ve;
  3171. else if (me(_e))
  3172. if (we)
  3173. ut = Fe;
  3174. else {
  3175. ut = De;
  3176. var ct = Ce
  3177. }
  3178. else
  3179. (et = _e.nodeName) && et.toLowerCase() === "input" && (_e.type === "checkbox" || _e.type === "radio") && (ut = Ee);
  3180. if (ut && (ut = ut(a, k))) {
  3181. ne($, ut, i, j);
  3182. break e
  3183. }
  3184. ct && ct(a, _e, k),
  3185. a === "focusout" && (ct = _e._wrapperState) && ct.controlled && _e.type === "number" && bb(_e, "number", _e.value)
  3186. }
  3187. switch (ct = k ? ue(k) : window,
  3188. a) {
  3189. case "focusin":
  3190. (me(ct) || ct.contentEditable === "true") && (Qe = ct,
  3191. Re = k,
  3192. Se = null);
  3193. break;
  3194. case "focusout":
  3195. Se = Re = Qe = null;
  3196. break;
  3197. case "mousedown":
  3198. Te = !0;
  3199. break;
  3200. case "contextmenu":
  3201. case "mouseup":
  3202. case "dragend":
  3203. Te = !1,
  3204. Ue($, i, j);
  3205. break;
  3206. case "selectionchange":
  3207. if (Pe)
  3208. break;
  3209. case "keydown":
  3210. case "keyup":
  3211. Ue($, i, j)
  3212. }
  3213. var lt;
  3214. if (ae)
  3215. e: {
  3216. switch (a) {
  3217. case "compositionstart":
  3218. var ft = "onCompositionStart";
  3219. break e;
  3220. case "compositionend":
  3221. ft = "onCompositionEnd";
  3222. break e;
  3223. case "compositionupdate":
  3224. ft = "onCompositionUpdate";
  3225. break e
  3226. }
  3227. ft = void 0
  3228. }
  3229. else
  3230. ie ? ge(a, i) && (ft = "onCompositionEnd") : a === "keydown" && i.keyCode === 229 && (ft = "onCompositionStart");
  3231. ft && (de && i.locale !== "ko" && (ie || ft !== "onCompositionStart" ? ft === "onCompositionEnd" && ie && (lt = nd()) : (kd = j,
  3232. ld = "value"in kd ? kd.value : kd.textContent,
  3233. ie = !0)),
  3234. ct = oe(k, ft),
  3235. 0 < ct.length && (ft = new Ld(ft,a,null,i,j),
  3236. $.push({
  3237. event: ft,
  3238. listeners: ct
  3239. }),
  3240. lt ? ft.data = lt : (lt = he(i),
  3241. lt !== null && (ft.data = lt)))),
  3242. (lt = ce ? je(a, i) : ke(a, i)) && (k = oe(k, "onBeforeInput"),
  3243. 0 < k.length && (j = new Ld("onBeforeInput","beforeinput",null,i,j),
  3244. $.push({
  3245. event: j,
  3246. listeners: k
  3247. }),
  3248. j.data = lt))
  3249. }
  3250. se($, e)
  3251. })
  3252. }
  3253. function ef(a, e, i) {
  3254. return {
  3255. instance: a,
  3256. listener: e,
  3257. currentTarget: i
  3258. }
  3259. }
  3260. function oe(a, e) {
  3261. for (var i = e + "Capture", o = []; a !== null; ) {
  3262. var s = a
  3263. , c = s.stateNode;
  3264. s.tag === 5 && c !== null && (s = c,
  3265. c = Ob(a, i),
  3266. c != null && o.unshift(ef(a, c, s)),
  3267. c = Ob(a, e),
  3268. c != null && o.push(ef(a, c, s))),
  3269. a = a.return
  3270. }
  3271. return o
  3272. }
  3273. function gf(a) {
  3274. if (a === null)
  3275. return null;
  3276. do
  3277. a = a.return;
  3278. while (a && a.tag !== 5);
  3279. return a || null
  3280. }
  3281. function hf(a, e, i, o, s) {
  3282. for (var c = e._reactName, d = []; i !== null && i !== o; ) {
  3283. var _ = i
  3284. , b = _.alternate
  3285. , k = _.stateNode;
  3286. if (b !== null && b === o)
  3287. break;
  3288. _.tag === 5 && k !== null && (_ = k,
  3289. s ? (b = Ob(i, c),
  3290. b != null && d.unshift(ef(i, b, _))) : s || (b = Ob(i, c),
  3291. b != null && d.push(ef(i, b, _)))),
  3292. i = i.return
  3293. }
  3294. d.length !== 0 && a.push({
  3295. event: e,
  3296. listeners: d
  3297. })
  3298. }
  3299. function jf() {}
  3300. var kf = null
  3301. , lf = null;
  3302. function mf(a, e) {
  3303. switch (a) {
  3304. case "button":
  3305. case "input":
  3306. case "select":
  3307. case "textarea":
  3308. return !!e.autoFocus
  3309. }
  3310. return !1
  3311. }
  3312. function nf(a, e) {
  3313. return a === "textarea" || a === "option" || a === "noscript" || typeof e.children == "string" || typeof e.children == "number" || typeof e.dangerouslySetInnerHTML == "object" && e.dangerouslySetInnerHTML !== null && e.dangerouslySetInnerHTML.__html != null
  3314. }
  3315. var of = typeof setTimeout == "function" ? setTimeout : void 0
  3316. , pf = typeof clearTimeout == "function" ? clearTimeout : void 0;
  3317. function qf(a) {
  3318. a.nodeType === 1 ? a.textContent = "" : a.nodeType === 9 && (a = a.body,
  3319. a != null && (a.textContent = ""))
  3320. }
  3321. function rf(a) {
  3322. for (; a != null; a = a.nextSibling) {
  3323. var e = a.nodeType;
  3324. if (e === 1 || e === 3)
  3325. break
  3326. }
  3327. return a
  3328. }
  3329. function sf(a) {
  3330. a = a.previousSibling;
  3331. for (var e = 0; a; ) {
  3332. if (a.nodeType === 8) {
  3333. var i = a.data;
  3334. if (i === "$" || i === "$!" || i === "$?") {
  3335. if (e === 0)
  3336. return a;
  3337. e--
  3338. } else
  3339. i === "/$" && e++
  3340. }
  3341. a = a.previousSibling
  3342. }
  3343. return null
  3344. }
  3345. var tf = 0;
  3346. function uf(a) {
  3347. return {
  3348. $$typeof: Ga,
  3349. toString: a,
  3350. valueOf: a
  3351. }
  3352. }
  3353. var vf = Math.random().toString(36).slice(2)
  3354. , wf = "__reactFiber$" + vf
  3355. , xf = "__reactProps$" + vf
  3356. , ff = "__reactContainer$" + vf
  3357. , yf = "__reactEvents$" + vf;
  3358. function wc(a) {
  3359. var e = a[wf];
  3360. if (e)
  3361. return e;
  3362. for (var i = a.parentNode; i; ) {
  3363. if (e = i[ff] || i[wf]) {
  3364. if (i = e.alternate,
  3365. e.child !== null || i !== null && i.child !== null)
  3366. for (a = sf(a); a !== null; ) {
  3367. if (i = a[wf])
  3368. return i;
  3369. a = sf(a)
  3370. }
  3371. return e
  3372. }
  3373. a = i,
  3374. i = a.parentNode
  3375. }
  3376. return null
  3377. }
  3378. function Cb(a) {
  3379. return a = a[wf] || a[ff],
  3380. !a || a.tag !== 5 && a.tag !== 6 && a.tag !== 13 && a.tag !== 3 ? null : a
  3381. }
  3382. function ue(a) {
  3383. if (a.tag === 5 || a.tag === 6)
  3384. return a.stateNode;
  3385. throw Error(y(33))
  3386. }
  3387. function Db(a) {
  3388. return a[xf] || null
  3389. }
  3390. function $e(a) {
  3391. var e = a[yf];
  3392. return e === void 0 && (e = a[yf] = new Set),
  3393. e
  3394. }
  3395. var zf = []
  3396. , Af = -1;
  3397. function Bf(a) {
  3398. return {
  3399. current: a
  3400. }
  3401. }
  3402. function H(a) {
  3403. 0 > Af || (a.current = zf[Af],
  3404. zf[Af] = null,
  3405. Af--)
  3406. }
  3407. function I(a, e) {
  3408. Af++,
  3409. zf[Af] = a.current,
  3410. a.current = e
  3411. }
  3412. var Cf = {}
  3413. , M = Bf(Cf)
  3414. , N = Bf(!1)
  3415. , Df = Cf;
  3416. function Ef(a, e) {
  3417. var i = a.type.contextTypes;
  3418. if (!i)
  3419. return Cf;
  3420. var o = a.stateNode;
  3421. if (o && o.__reactInternalMemoizedUnmaskedChildContext === e)
  3422. return o.__reactInternalMemoizedMaskedChildContext;
  3423. var s = {}, c;
  3424. for (c in i)
  3425. s[c] = e[c];
  3426. return o && (a = a.stateNode,
  3427. a.__reactInternalMemoizedUnmaskedChildContext = e,
  3428. a.__reactInternalMemoizedMaskedChildContext = s),
  3429. s
  3430. }
  3431. function Ff(a) {
  3432. return a = a.childContextTypes,
  3433. a != null
  3434. }
  3435. function Gf() {
  3436. H(N),
  3437. H(M)
  3438. }
  3439. function Hf(a, e, i) {
  3440. if (M.current !== Cf)
  3441. throw Error(y(168));
  3442. I(M, e),
  3443. I(N, i)
  3444. }
  3445. function If(a, e, i) {
  3446. var o = a.stateNode;
  3447. if (a = e.childContextTypes,
  3448. typeof o.getChildContext != "function")
  3449. return i;
  3450. o = o.getChildContext();
  3451. for (var s in o)
  3452. if (!(s in a))
  3453. throw Error(y(108, Ra(e) || "Unknown", s));
  3454. return m$1({}, i, o)
  3455. }
  3456. function Jf(a) {
  3457. return a = (a = a.stateNode) && a.__reactInternalMemoizedMergedChildContext || Cf,
  3458. Df = M.current,
  3459. I(M, a),
  3460. I(N, N.current),
  3461. !0
  3462. }
  3463. function Kf(a, e, i) {
  3464. var o = a.stateNode;
  3465. if (!o)
  3466. throw Error(y(169));
  3467. i ? (a = If(a, e, Df),
  3468. o.__reactInternalMemoizedMergedChildContext = a,
  3469. H(N),
  3470. H(M),
  3471. I(M, a)) : H(N),
  3472. I(N, i)
  3473. }
  3474. var Lf = null
  3475. , Mf = null
  3476. , Nf = r.unstable_runWithPriority
  3477. , Of = r.unstable_scheduleCallback
  3478. , Pf = r.unstable_cancelCallback
  3479. , Qf = r.unstable_shouldYield
  3480. , Rf = r.unstable_requestPaint
  3481. , Sf = r.unstable_now
  3482. , Tf = r.unstable_getCurrentPriorityLevel
  3483. , Uf = r.unstable_ImmediatePriority
  3484. , Vf = r.unstable_UserBlockingPriority
  3485. , Wf = r.unstable_NormalPriority
  3486. , Xf = r.unstable_LowPriority
  3487. , Yf = r.unstable_IdlePriority
  3488. , Zf = {}
  3489. , $f = Rf !== void 0 ? Rf : function() {}
  3490. , ag = null
  3491. , bg = null
  3492. , cg = !1
  3493. , dg = Sf()
  3494. , O = 1e4 > dg ? Sf : function() {
  3495. return Sf() - dg
  3496. }
  3497. ;
  3498. function eg() {
  3499. switch (Tf()) {
  3500. case Uf:
  3501. return 99;
  3502. case Vf:
  3503. return 98;
  3504. case Wf:
  3505. return 97;
  3506. case Xf:
  3507. return 96;
  3508. case Yf:
  3509. return 95;
  3510. default:
  3511. throw Error(y(332))
  3512. }
  3513. }
  3514. function fg(a) {
  3515. switch (a) {
  3516. case 99:
  3517. return Uf;
  3518. case 98:
  3519. return Vf;
  3520. case 97:
  3521. return Wf;
  3522. case 96:
  3523. return Xf;
  3524. case 95:
  3525. return Yf;
  3526. default:
  3527. throw Error(y(332))
  3528. }
  3529. }
  3530. function gg(a, e) {
  3531. return a = fg(a),
  3532. Nf(a, e)
  3533. }
  3534. function hg(a, e, i) {
  3535. return a = fg(a),
  3536. Of(a, e, i)
  3537. }
  3538. function ig() {
  3539. if (bg !== null) {
  3540. var a = bg;
  3541. bg = null,
  3542. Pf(a)
  3543. }
  3544. jg()
  3545. }
  3546. function jg() {
  3547. if (!cg && ag !== null) {
  3548. cg = !0;
  3549. var a = 0;
  3550. try {
  3551. var e = ag;
  3552. gg(99, function() {
  3553. for (; a < e.length; a++) {
  3554. var i = e[a];
  3555. do
  3556. i = i(!0);
  3557. while (i !== null)
  3558. }
  3559. }),
  3560. ag = null
  3561. } catch (i) {
  3562. throw ag !== null && (ag = ag.slice(a + 1)),
  3563. Of(Uf, ig),
  3564. i
  3565. } finally {
  3566. cg = !1
  3567. }
  3568. }
  3569. }
  3570. var kg = ra.ReactCurrentBatchConfig;
  3571. function lg(a, e) {
  3572. if (a && a.defaultProps) {
  3573. e = m$1({}, e),
  3574. a = a.defaultProps;
  3575. for (var i in a)
  3576. e[i] === void 0 && (e[i] = a[i]);
  3577. return e
  3578. }
  3579. return e
  3580. }
  3581. var mg = Bf(null)
  3582. , ng = null
  3583. , og = null
  3584. , pg = null;
  3585. function qg() {
  3586. pg = og = ng = null
  3587. }
  3588. function rg(a) {
  3589. var e = mg.current;
  3590. H(mg),
  3591. a.type._context._currentValue = e
  3592. }
  3593. function sg(a, e) {
  3594. for (; a !== null; ) {
  3595. var i = a.alternate;
  3596. if ((a.childLanes & e) === e) {
  3597. if (i === null || (i.childLanes & e) === e)
  3598. break;
  3599. i.childLanes |= e
  3600. } else
  3601. a.childLanes |= e,
  3602. i !== null && (i.childLanes |= e);
  3603. a = a.return
  3604. }
  3605. }
  3606. function tg(a, e) {
  3607. ng = a,
  3608. pg = og = null,
  3609. a = a.dependencies,
  3610. a !== null && a.firstContext !== null && ((a.lanes & e) !== 0 && (ug = !0),
  3611. a.firstContext = null)
  3612. }
  3613. function vg(a, e) {
  3614. if (pg !== a && e !== !1 && e !== 0)
  3615. if ((typeof e != "number" || e === 1073741823) && (pg = a,
  3616. e = 1073741823),
  3617. e = {
  3618. context: a,
  3619. observedBits: e,
  3620. next: null
  3621. },
  3622. og === null) {
  3623. if (ng === null)
  3624. throw Error(y(308));
  3625. og = e,
  3626. ng.dependencies = {
  3627. lanes: 0,
  3628. firstContext: e,
  3629. responders: null
  3630. }
  3631. } else
  3632. og = og.next = e;
  3633. return a._currentValue
  3634. }
  3635. var wg = !1;
  3636. function xg(a) {
  3637. a.updateQueue = {
  3638. baseState: a.memoizedState,
  3639. firstBaseUpdate: null,
  3640. lastBaseUpdate: null,
  3641. shared: {
  3642. pending: null
  3643. },
  3644. effects: null
  3645. }
  3646. }
  3647. function yg(a, e) {
  3648. a = a.updateQueue,
  3649. e.updateQueue === a && (e.updateQueue = {
  3650. baseState: a.baseState,
  3651. firstBaseUpdate: a.firstBaseUpdate,
  3652. lastBaseUpdate: a.lastBaseUpdate,
  3653. shared: a.shared,
  3654. effects: a.effects
  3655. })
  3656. }
  3657. function zg(a, e) {
  3658. return {
  3659. eventTime: a,
  3660. lane: e,
  3661. tag: 0,
  3662. payload: null,
  3663. callback: null,
  3664. next: null
  3665. }
  3666. }
  3667. function Ag(a, e) {
  3668. if (a = a.updateQueue,
  3669. a !== null) {
  3670. a = a.shared;
  3671. var i = a.pending;
  3672. i === null ? e.next = e : (e.next = i.next,
  3673. i.next = e),
  3674. a.pending = e
  3675. }
  3676. }
  3677. function Bg(a, e) {
  3678. var i = a.updateQueue
  3679. , o = a.alternate;
  3680. if (o !== null && (o = o.updateQueue,
  3681. i === o)) {
  3682. var s = null
  3683. , c = null;
  3684. if (i = i.firstBaseUpdate,
  3685. i !== null) {
  3686. do {
  3687. var d = {
  3688. eventTime: i.eventTime,
  3689. lane: i.lane,
  3690. tag: i.tag,
  3691. payload: i.payload,
  3692. callback: i.callback,
  3693. next: null
  3694. };
  3695. c === null ? s = c = d : c = c.next = d,
  3696. i = i.next
  3697. } while (i !== null);
  3698. c === null ? s = c = e : c = c.next = e
  3699. } else
  3700. s = c = e;
  3701. i = {
  3702. baseState: o.baseState,
  3703. firstBaseUpdate: s,
  3704. lastBaseUpdate: c,
  3705. shared: o.shared,
  3706. effects: o.effects
  3707. },
  3708. a.updateQueue = i;
  3709. return
  3710. }
  3711. a = i.lastBaseUpdate,
  3712. a === null ? i.firstBaseUpdate = e : a.next = e,
  3713. i.lastBaseUpdate = e
  3714. }
  3715. function Cg(a, e, i, o) {
  3716. var s = a.updateQueue;
  3717. wg = !1;
  3718. var c = s.firstBaseUpdate
  3719. , d = s.lastBaseUpdate
  3720. , _ = s.shared.pending;
  3721. if (_ !== null) {
  3722. s.shared.pending = null;
  3723. var b = _
  3724. , k = b.next;
  3725. b.next = null,
  3726. d === null ? c = k : d.next = k,
  3727. d = b;
  3728. var j = a.alternate;
  3729. if (j !== null) {
  3730. j = j.updateQueue;
  3731. var $ = j.lastBaseUpdate;
  3732. $ !== d && ($ === null ? j.firstBaseUpdate = k : $.next = k,
  3733. j.lastBaseUpdate = b)
  3734. }
  3735. }
  3736. if (c !== null) {
  3737. $ = s.baseState,
  3738. d = 0,
  3739. j = k = b = null;
  3740. do {
  3741. _ = c.lane;
  3742. var _e = c.eventTime;
  3743. if ((o & _) === _) {
  3744. j !== null && (j = j.next = {
  3745. eventTime: _e,
  3746. lane: 0,
  3747. tag: c.tag,
  3748. payload: c.payload,
  3749. callback: c.callback,
  3750. next: null
  3751. });
  3752. e: {
  3753. var et = a
  3754. , tt = c;
  3755. switch (_ = e,
  3756. _e = i,
  3757. tt.tag) {
  3758. case 1:
  3759. if (et = tt.payload,
  3760. typeof et == "function") {
  3761. $ = et.call(_e, $, _);
  3762. break e
  3763. }
  3764. $ = et;
  3765. break e;
  3766. case 3:
  3767. et.flags = et.flags & -4097 | 64;
  3768. case 0:
  3769. if (et = tt.payload,
  3770. _ = typeof et == "function" ? et.call(_e, $, _) : et,
  3771. _ == null)
  3772. break e;
  3773. $ = m$1({}, $, _);
  3774. break e;
  3775. case 2:
  3776. wg = !0
  3777. }
  3778. }
  3779. c.callback !== null && (a.flags |= 32,
  3780. _ = s.effects,
  3781. _ === null ? s.effects = [c] : _.push(c))
  3782. } else
  3783. _e = {
  3784. eventTime: _e,
  3785. lane: _,
  3786. tag: c.tag,
  3787. payload: c.payload,
  3788. callback: c.callback,
  3789. next: null
  3790. },
  3791. j === null ? (k = j = _e,
  3792. b = $) : j = j.next = _e,
  3793. d |= _;
  3794. if (c = c.next,
  3795. c === null) {
  3796. if (_ = s.shared.pending,
  3797. _ === null)
  3798. break;
  3799. c = _.next,
  3800. _.next = null,
  3801. s.lastBaseUpdate = _,
  3802. s.shared.pending = null
  3803. }
  3804. } while (1);
  3805. j === null && (b = $),
  3806. s.baseState = b,
  3807. s.firstBaseUpdate = k,
  3808. s.lastBaseUpdate = j,
  3809. Dg |= d,
  3810. a.lanes = d,
  3811. a.memoizedState = $
  3812. }
  3813. }
  3814. function Eg(a, e, i) {
  3815. if (a = e.effects,
  3816. e.effects = null,
  3817. a !== null)
  3818. for (e = 0; e < a.length; e++) {
  3819. var o = a[e]
  3820. , s = o.callback;
  3821. if (s !== null) {
  3822. if (o.callback = null,
  3823. o = i,
  3824. typeof s != "function")
  3825. throw Error(y(191, s));
  3826. s.call(o)
  3827. }
  3828. }
  3829. }
  3830. var Fg = new aa.Component().refs;
  3831. function Gg(a, e, i, o) {
  3832. e = a.memoizedState,
  3833. i = i(o, e),
  3834. i = i == null ? e : m$1({}, e, i),
  3835. a.memoizedState = i,
  3836. a.lanes === 0 && (a.updateQueue.baseState = i)
  3837. }
  3838. var Kg = {
  3839. isMounted: function(a) {
  3840. return (a = a._reactInternals) ? Zb(a) === a : !1
  3841. },
  3842. enqueueSetState: function(a, e, i) {
  3843. a = a._reactInternals;
  3844. var o = Hg()
  3845. , s = Ig(a)
  3846. , c = zg(o, s);
  3847. c.payload = e,
  3848. i != null && (c.callback = i),
  3849. Ag(a, c),
  3850. Jg(a, s, o)
  3851. },
  3852. enqueueReplaceState: function(a, e, i) {
  3853. a = a._reactInternals;
  3854. var o = Hg()
  3855. , s = Ig(a)
  3856. , c = zg(o, s);
  3857. c.tag = 1,
  3858. c.payload = e,
  3859. i != null && (c.callback = i),
  3860. Ag(a, c),
  3861. Jg(a, s, o)
  3862. },
  3863. enqueueForceUpdate: function(a, e) {
  3864. a = a._reactInternals;
  3865. var i = Hg()
  3866. , o = Ig(a)
  3867. , s = zg(i, o);
  3868. s.tag = 2,
  3869. e != null && (s.callback = e),
  3870. Ag(a, s),
  3871. Jg(a, o, i)
  3872. }
  3873. };
  3874. function Lg(a, e, i, o, s, c, d) {
  3875. return a = a.stateNode,
  3876. typeof a.shouldComponentUpdate == "function" ? a.shouldComponentUpdate(o, c, d) : e.prototype && e.prototype.isPureReactComponent ? !Je(i, o) || !Je(s, c) : !0
  3877. }
  3878. function Mg(a, e, i) {
  3879. var o = !1
  3880. , s = Cf
  3881. , c = e.contextType;
  3882. return typeof c == "object" && c !== null ? c = vg(c) : (s = Ff(e) ? Df : M.current,
  3883. o = e.contextTypes,
  3884. c = (o = o != null) ? Ef(a, s) : Cf),
  3885. e = new e(i,c),
  3886. a.memoizedState = e.state !== null && e.state !== void 0 ? e.state : null,
  3887. e.updater = Kg,
  3888. a.stateNode = e,
  3889. e._reactInternals = a,
  3890. o && (a = a.stateNode,
  3891. a.__reactInternalMemoizedUnmaskedChildContext = s,
  3892. a.__reactInternalMemoizedMaskedChildContext = c),
  3893. e
  3894. }
  3895. function Ng(a, e, i, o) {
  3896. a = e.state,
  3897. typeof e.componentWillReceiveProps == "function" && e.componentWillReceiveProps(i, o),
  3898. typeof e.UNSAFE_componentWillReceiveProps == "function" && e.UNSAFE_componentWillReceiveProps(i, o),
  3899. e.state !== a && Kg.enqueueReplaceState(e, e.state, null)
  3900. }
  3901. function Og(a, e, i, o) {
  3902. var s = a.stateNode;
  3903. s.props = i,
  3904. s.state = a.memoizedState,
  3905. s.refs = Fg,
  3906. xg(a);
  3907. var c = e.contextType;
  3908. typeof c == "object" && c !== null ? s.context = vg(c) : (c = Ff(e) ? Df : M.current,
  3909. s.context = Ef(a, c)),
  3910. Cg(a, i, s, o),
  3911. s.state = a.memoizedState,
  3912. c = e.getDerivedStateFromProps,
  3913. typeof c == "function" && (Gg(a, e, c, i),
  3914. s.state = a.memoizedState),
  3915. typeof e.getDerivedStateFromProps == "function" || typeof s.getSnapshotBeforeUpdate == "function" || typeof s.UNSAFE_componentWillMount != "function" && typeof s.componentWillMount != "function" || (e = s.state,
  3916. typeof s.componentWillMount == "function" && s.componentWillMount(),
  3917. typeof s.UNSAFE_componentWillMount == "function" && s.UNSAFE_componentWillMount(),
  3918. e !== s.state && Kg.enqueueReplaceState(s, s.state, null),
  3919. Cg(a, i, s, o),
  3920. s.state = a.memoizedState),
  3921. typeof s.componentDidMount == "function" && (a.flags |= 4)
  3922. }
  3923. var Pg = Array.isArray;
  3924. function Qg(a, e, i) {
  3925. if (a = i.ref,
  3926. a !== null && typeof a != "function" && typeof a != "object") {
  3927. if (i._owner) {
  3928. if (i = i._owner,
  3929. i) {
  3930. if (i.tag !== 1)
  3931. throw Error(y(309));
  3932. var o = i.stateNode
  3933. }
  3934. if (!o)
  3935. throw Error(y(147, a));
  3936. var s = "" + a;
  3937. return e !== null && e.ref !== null && typeof e.ref == "function" && e.ref._stringRef === s ? e.ref : (e = function(c) {
  3938. var d = o.refs;
  3939. d === Fg && (d = o.refs = {}),
  3940. c === null ? delete d[s] : d[s] = c
  3941. }
  3942. ,
  3943. e._stringRef = s,
  3944. e)
  3945. }
  3946. if (typeof a != "string")
  3947. throw Error(y(284));
  3948. if (!i._owner)
  3949. throw Error(y(290, a))
  3950. }
  3951. return a
  3952. }
  3953. function Rg(a, e) {
  3954. if (a.type !== "textarea")
  3955. throw Error(y(31, Object.prototype.toString.call(e) === "[object Object]" ? "object with keys {" + Object.keys(e).join(", ") + "}" : e))
  3956. }
  3957. function Sg(a) {
  3958. function e(it, nt) {
  3959. if (a) {
  3960. var ot = it.lastEffect;
  3961. ot !== null ? (ot.nextEffect = nt,
  3962. it.lastEffect = nt) : it.firstEffect = it.lastEffect = nt,
  3963. nt.nextEffect = null,
  3964. nt.flags = 8
  3965. }
  3966. }
  3967. function i(it, nt) {
  3968. if (!a)
  3969. return null;
  3970. for (; nt !== null; )
  3971. e(it, nt),
  3972. nt = nt.sibling;
  3973. return null
  3974. }
  3975. function o(it, nt) {
  3976. for (it = new Map; nt !== null; )
  3977. nt.key !== null ? it.set(nt.key, nt) : it.set(nt.index, nt),
  3978. nt = nt.sibling;
  3979. return it
  3980. }
  3981. function s(it, nt) {
  3982. return it = Tg(it, nt),
  3983. it.index = 0,
  3984. it.sibling = null,
  3985. it
  3986. }
  3987. function c(it, nt, ot) {
  3988. return it.index = ot,
  3989. a ? (ot = it.alternate,
  3990. ot !== null ? (ot = ot.index,
  3991. ot < nt ? (it.flags = 2,
  3992. nt) : ot) : (it.flags = 2,
  3993. nt)) : nt
  3994. }
  3995. function d(it) {
  3996. return a && it.alternate === null && (it.flags = 2),
  3997. it
  3998. }
  3999. function _(it, nt, ot, at) {
  4000. return nt === null || nt.tag !== 6 ? (nt = Ug(ot, it.mode, at),
  4001. nt.return = it,
  4002. nt) : (nt = s(nt, ot),
  4003. nt.return = it,
  4004. nt)
  4005. }
  4006. function b(it, nt, ot, at) {
  4007. return nt !== null && nt.elementType === ot.type ? (at = s(nt, ot.props),
  4008. at.ref = Qg(it, nt, ot),
  4009. at.return = it,
  4010. at) : (at = Vg(ot.type, ot.key, ot.props, null, it.mode, at),
  4011. at.ref = Qg(it, nt, ot),
  4012. at.return = it,
  4013. at)
  4014. }
  4015. function k(it, nt, ot, at) {
  4016. return nt === null || nt.tag !== 4 || nt.stateNode.containerInfo !== ot.containerInfo || nt.stateNode.implementation !== ot.implementation ? (nt = Wg(ot, it.mode, at),
  4017. nt.return = it,
  4018. nt) : (nt = s(nt, ot.children || []),
  4019. nt.return = it,
  4020. nt)
  4021. }
  4022. function j(it, nt, ot, at, st) {
  4023. return nt === null || nt.tag !== 7 ? (nt = Xg(ot, it.mode, at, st),
  4024. nt.return = it,
  4025. nt) : (nt = s(nt, ot),
  4026. nt.return = it,
  4027. nt)
  4028. }
  4029. function $(it, nt, ot) {
  4030. if (typeof nt == "string" || typeof nt == "number")
  4031. return nt = Ug("" + nt, it.mode, ot),
  4032. nt.return = it,
  4033. nt;
  4034. if (typeof nt == "object" && nt !== null) {
  4035. switch (nt.$$typeof) {
  4036. case sa:
  4037. return ot = Vg(nt.type, nt.key, nt.props, null, it.mode, ot),
  4038. ot.ref = Qg(it, null, nt),
  4039. ot.return = it,
  4040. ot;
  4041. case ta:
  4042. return nt = Wg(nt, it.mode, ot),
  4043. nt.return = it,
  4044. nt
  4045. }
  4046. if (Pg(nt) || La(nt))
  4047. return nt = Xg(nt, it.mode, ot, null),
  4048. nt.return = it,
  4049. nt;
  4050. Rg(it, nt)
  4051. }
  4052. return null
  4053. }
  4054. function _e(it, nt, ot, at) {
  4055. var st = nt !== null ? nt.key : null;
  4056. if (typeof ot == "string" || typeof ot == "number")
  4057. return st !== null ? null : _(it, nt, "" + ot, at);
  4058. if (typeof ot == "object" && ot !== null) {
  4059. switch (ot.$$typeof) {
  4060. case sa:
  4061. return ot.key === st ? ot.type === ua ? j(it, nt, ot.props.children, at, st) : b(it, nt, ot, at) : null;
  4062. case ta:
  4063. return ot.key === st ? k(it, nt, ot, at) : null
  4064. }
  4065. if (Pg(ot) || La(ot))
  4066. return st !== null ? null : j(it, nt, ot, at, null);
  4067. Rg(it, ot)
  4068. }
  4069. return null
  4070. }
  4071. function et(it, nt, ot, at, st) {
  4072. if (typeof at == "string" || typeof at == "number")
  4073. return it = it.get(ot) || null,
  4074. _(nt, it, "" + at, st);
  4075. if (typeof at == "object" && at !== null) {
  4076. switch (at.$$typeof) {
  4077. case sa:
  4078. return it = it.get(at.key === null ? ot : at.key) || null,
  4079. at.type === ua ? j(nt, it, at.props.children, st, at.key) : b(nt, it, at, st);
  4080. case ta:
  4081. return it = it.get(at.key === null ? ot : at.key) || null,
  4082. k(nt, it, at, st)
  4083. }
  4084. if (Pg(at) || La(at))
  4085. return it = it.get(ot) || null,
  4086. j(nt, it, at, st, null);
  4087. Rg(nt, at)
  4088. }
  4089. return null
  4090. }
  4091. function tt(it, nt, ot, at) {
  4092. for (var st = null, ut = null, ct = nt, lt = nt = 0, ft = null; ct !== null && lt < ot.length; lt++) {
  4093. ct.index > lt ? (ft = ct,
  4094. ct = null) : ft = ct.sibling;
  4095. var ht = _e(it, ct, ot[lt], at);
  4096. if (ht === null) {
  4097. ct === null && (ct = ft);
  4098. break
  4099. }
  4100. a && ct && ht.alternate === null && e(it, ct),
  4101. nt = c(ht, nt, lt),
  4102. ut === null ? st = ht : ut.sibling = ht,
  4103. ut = ht,
  4104. ct = ft
  4105. }
  4106. if (lt === ot.length)
  4107. return i(it, ct),
  4108. st;
  4109. if (ct === null) {
  4110. for (; lt < ot.length; lt++)
  4111. ct = $(it, ot[lt], at),
  4112. ct !== null && (nt = c(ct, nt, lt),
  4113. ut === null ? st = ct : ut.sibling = ct,
  4114. ut = ct);
  4115. return st
  4116. }
  4117. for (ct = o(it, ct); lt < ot.length; lt++)
  4118. ft = et(ct, it, lt, ot[lt], at),
  4119. ft !== null && (a && ft.alternate !== null && ct.delete(ft.key === null ? lt : ft.key),
  4120. nt = c(ft, nt, lt),
  4121. ut === null ? st = ft : ut.sibling = ft,
  4122. ut = ft);
  4123. return a && ct.forEach(function(pt) {
  4124. return e(it, pt)
  4125. }),
  4126. st
  4127. }
  4128. function rt(it, nt, ot, at) {
  4129. var st = La(ot);
  4130. if (typeof st != "function")
  4131. throw Error(y(150));
  4132. if (ot = st.call(ot),
  4133. ot == null)
  4134. throw Error(y(151));
  4135. for (var ut = st = null, ct = nt, lt = nt = 0, ft = null, ht = ot.next(); ct !== null && !ht.done; lt++,
  4136. ht = ot.next()) {
  4137. ct.index > lt ? (ft = ct,
  4138. ct = null) : ft = ct.sibling;
  4139. var pt = _e(it, ct, ht.value, at);
  4140. if (pt === null) {
  4141. ct === null && (ct = ft);
  4142. break
  4143. }
  4144. a && ct && pt.alternate === null && e(it, ct),
  4145. nt = c(pt, nt, lt),
  4146. ut === null ? st = pt : ut.sibling = pt,
  4147. ut = pt,
  4148. ct = ft
  4149. }
  4150. if (ht.done)
  4151. return i(it, ct),
  4152. st;
  4153. if (ct === null) {
  4154. for (; !ht.done; lt++,
  4155. ht = ot.next())
  4156. ht = $(it, ht.value, at),
  4157. ht !== null && (nt = c(ht, nt, lt),
  4158. ut === null ? st = ht : ut.sibling = ht,
  4159. ut = ht);
  4160. return st
  4161. }
  4162. for (ct = o(it, ct); !ht.done; lt++,
  4163. ht = ot.next())
  4164. ht = et(ct, it, lt, ht.value, at),
  4165. ht !== null && (a && ht.alternate !== null && ct.delete(ht.key === null ? lt : ht.key),
  4166. nt = c(ht, nt, lt),
  4167. ut === null ? st = ht : ut.sibling = ht,
  4168. ut = ht);
  4169. return a && ct.forEach(function(dt) {
  4170. return e(it, dt)
  4171. }),
  4172. st
  4173. }
  4174. return function(it, nt, ot, at) {
  4175. var st = typeof ot == "object" && ot !== null && ot.type === ua && ot.key === null;
  4176. st && (ot = ot.props.children);
  4177. var ut = typeof ot == "object" && ot !== null;
  4178. if (ut)
  4179. switch (ot.$$typeof) {
  4180. case sa:
  4181. e: {
  4182. for (ut = ot.key,
  4183. st = nt; st !== null; ) {
  4184. if (st.key === ut) {
  4185. switch (st.tag) {
  4186. case 7:
  4187. if (ot.type === ua) {
  4188. i(it, st.sibling),
  4189. nt = s(st, ot.props.children),
  4190. nt.return = it,
  4191. it = nt;
  4192. break e
  4193. }
  4194. break;
  4195. default:
  4196. if (st.elementType === ot.type) {
  4197. i(it, st.sibling),
  4198. nt = s(st, ot.props),
  4199. nt.ref = Qg(it, st, ot),
  4200. nt.return = it,
  4201. it = nt;
  4202. break e
  4203. }
  4204. }
  4205. i(it, st);
  4206. break
  4207. } else
  4208. e(it, st);
  4209. st = st.sibling
  4210. }
  4211. ot.type === ua ? (nt = Xg(ot.props.children, it.mode, at, ot.key),
  4212. nt.return = it,
  4213. it = nt) : (at = Vg(ot.type, ot.key, ot.props, null, it.mode, at),
  4214. at.ref = Qg(it, nt, ot),
  4215. at.return = it,
  4216. it = at)
  4217. }
  4218. return d(it);
  4219. case ta:
  4220. e: {
  4221. for (st = ot.key; nt !== null; ) {
  4222. if (nt.key === st)
  4223. if (nt.tag === 4 && nt.stateNode.containerInfo === ot.containerInfo && nt.stateNode.implementation === ot.implementation) {
  4224. i(it, nt.sibling),
  4225. nt = s(nt, ot.children || []),
  4226. nt.return = it,
  4227. it = nt;
  4228. break e
  4229. } else {
  4230. i(it, nt);
  4231. break
  4232. }
  4233. else
  4234. e(it, nt);
  4235. nt = nt.sibling
  4236. }
  4237. nt = Wg(ot, it.mode, at),
  4238. nt.return = it,
  4239. it = nt
  4240. }
  4241. return d(it)
  4242. }
  4243. if (typeof ot == "string" || typeof ot == "number")
  4244. return ot = "" + ot,
  4245. nt !== null && nt.tag === 6 ? (i(it, nt.sibling),
  4246. nt = s(nt, ot),
  4247. nt.return = it,
  4248. it = nt) : (i(it, nt),
  4249. nt = Ug(ot, it.mode, at),
  4250. nt.return = it,
  4251. it = nt),
  4252. d(it);
  4253. if (Pg(ot))
  4254. return tt(it, nt, ot, at);
  4255. if (La(ot))
  4256. return rt(it, nt, ot, at);
  4257. if (ut && Rg(it, ot),
  4258. typeof ot == "undefined" && !st)
  4259. switch (it.tag) {
  4260. case 1:
  4261. case 22:
  4262. case 0:
  4263. case 11:
  4264. case 15:
  4265. throw Error(y(152, Ra(it.type) || "Component"))
  4266. }
  4267. return i(it, nt)
  4268. }
  4269. }
  4270. var Yg = Sg(!0)
  4271. , Zg = Sg(!1)
  4272. , $g = {}
  4273. , ah = Bf($g)
  4274. , bh = Bf($g)
  4275. , ch = Bf($g);
  4276. function dh(a) {
  4277. if (a === $g)
  4278. throw Error(y(174));
  4279. return a
  4280. }
  4281. function eh(a, e) {
  4282. switch (I(ch, e),
  4283. I(bh, a),
  4284. I(ah, $g),
  4285. a = e.nodeType,
  4286. a) {
  4287. case 9:
  4288. case 11:
  4289. e = (e = e.documentElement) ? e.namespaceURI : mb(null, "");
  4290. break;
  4291. default:
  4292. a = a === 8 ? e.parentNode : e,
  4293. e = a.namespaceURI || null,
  4294. a = a.tagName,
  4295. e = mb(e, a)
  4296. }
  4297. H(ah),
  4298. I(ah, e)
  4299. }
  4300. function fh() {
  4301. H(ah),
  4302. H(bh),
  4303. H(ch)
  4304. }
  4305. function gh(a) {
  4306. dh(ch.current);
  4307. var e = dh(ah.current)
  4308. , i = mb(e, a.type);
  4309. e !== i && (I(bh, a),
  4310. I(ah, i))
  4311. }
  4312. function hh(a) {
  4313. bh.current === a && (H(ah),
  4314. H(bh))
  4315. }
  4316. var P = Bf(0);
  4317. function ih(a) {
  4318. for (var e = a; e !== null; ) {
  4319. if (e.tag === 13) {
  4320. var i = e.memoizedState;
  4321. if (i !== null && (i = i.dehydrated,
  4322. i === null || i.data === "$?" || i.data === "$!"))
  4323. return e
  4324. } else if (e.tag === 19 && e.memoizedProps.revealOrder !== void 0) {
  4325. if ((e.flags & 64) !== 0)
  4326. return e
  4327. } else if (e.child !== null) {
  4328. e.child.return = e,
  4329. e = e.child;
  4330. continue
  4331. }
  4332. if (e === a)
  4333. break;
  4334. for (; e.sibling === null; ) {
  4335. if (e.return === null || e.return === a)
  4336. return null;
  4337. e = e.return
  4338. }
  4339. e.sibling.return = e.return,
  4340. e = e.sibling
  4341. }
  4342. return null
  4343. }
  4344. var jh = null
  4345. , kh = null
  4346. , lh = !1;
  4347. function mh(a, e) {
  4348. var i = nh(5, null, null, 0);
  4349. i.elementType = "DELETED",
  4350. i.type = "DELETED",
  4351. i.stateNode = e,
  4352. i.return = a,
  4353. i.flags = 8,
  4354. a.lastEffect !== null ? (a.lastEffect.nextEffect = i,
  4355. a.lastEffect = i) : a.firstEffect = a.lastEffect = i
  4356. }
  4357. function oh(a, e) {
  4358. switch (a.tag) {
  4359. case 5:
  4360. var i = a.type;
  4361. return e = e.nodeType !== 1 || i.toLowerCase() !== e.nodeName.toLowerCase() ? null : e,
  4362. e !== null ? (a.stateNode = e,
  4363. !0) : !1;
  4364. case 6:
  4365. return e = a.pendingProps === "" || e.nodeType !== 3 ? null : e,
  4366. e !== null ? (a.stateNode = e,
  4367. !0) : !1;
  4368. case 13:
  4369. return !1;
  4370. default:
  4371. return !1
  4372. }
  4373. }
  4374. function ph(a) {
  4375. if (lh) {
  4376. var e = kh;
  4377. if (e) {
  4378. var i = e;
  4379. if (!oh(a, e)) {
  4380. if (e = rf(i.nextSibling),
  4381. !e || !oh(a, e)) {
  4382. a.flags = a.flags & -1025 | 2,
  4383. lh = !1,
  4384. jh = a;
  4385. return
  4386. }
  4387. mh(jh, i)
  4388. }
  4389. jh = a,
  4390. kh = rf(e.firstChild)
  4391. } else
  4392. a.flags = a.flags & -1025 | 2,
  4393. lh = !1,
  4394. jh = a
  4395. }
  4396. }
  4397. function qh(a) {
  4398. for (a = a.return; a !== null && a.tag !== 5 && a.tag !== 3 && a.tag !== 13; )
  4399. a = a.return;
  4400. jh = a
  4401. }
  4402. function rh(a) {
  4403. if (a !== jh)
  4404. return !1;
  4405. if (!lh)
  4406. return qh(a),
  4407. lh = !0,
  4408. !1;
  4409. var e = a.type;
  4410. if (a.tag !== 5 || e !== "head" && e !== "body" && !nf(e, a.memoizedProps))
  4411. for (e = kh; e; )
  4412. mh(a, e),
  4413. e = rf(e.nextSibling);
  4414. if (qh(a),
  4415. a.tag === 13) {
  4416. if (a = a.memoizedState,
  4417. a = a !== null ? a.dehydrated : null,
  4418. !a)
  4419. throw Error(y(317));
  4420. e: {
  4421. for (a = a.nextSibling,
  4422. e = 0; a; ) {
  4423. if (a.nodeType === 8) {
  4424. var i = a.data;
  4425. if (i === "/$") {
  4426. if (e === 0) {
  4427. kh = rf(a.nextSibling);
  4428. break e
  4429. }
  4430. e--
  4431. } else
  4432. i !== "$" && i !== "$!" && i !== "$?" || e++
  4433. }
  4434. a = a.nextSibling
  4435. }
  4436. kh = null
  4437. }
  4438. } else
  4439. kh = jh ? rf(a.stateNode.nextSibling) : null;
  4440. return !0
  4441. }
  4442. function sh() {
  4443. kh = jh = null,
  4444. lh = !1
  4445. }
  4446. var th = [];
  4447. function uh() {
  4448. for (var a = 0; a < th.length; a++)
  4449. th[a]._workInProgressVersionPrimary = null;
  4450. th.length = 0
  4451. }
  4452. var vh = ra.ReactCurrentDispatcher
  4453. , wh = ra.ReactCurrentBatchConfig
  4454. , xh = 0
  4455. , R = null
  4456. , S = null
  4457. , T = null
  4458. , yh = !1
  4459. , zh = !1;
  4460. function Ah() {
  4461. throw Error(y(321))
  4462. }
  4463. function Bh(a, e) {
  4464. if (e === null)
  4465. return !1;
  4466. for (var i = 0; i < e.length && i < a.length; i++)
  4467. if (!He(a[i], e[i]))
  4468. return !1;
  4469. return !0
  4470. }
  4471. function Ch(a, e, i, o, s, c) {
  4472. if (xh = c,
  4473. R = e,
  4474. e.memoizedState = null,
  4475. e.updateQueue = null,
  4476. e.lanes = 0,
  4477. vh.current = a === null || a.memoizedState === null ? Dh : Eh,
  4478. a = i(o, s),
  4479. zh) {
  4480. c = 0;
  4481. do {
  4482. if (zh = !1,
  4483. !(25 > c))
  4484. throw Error(y(301));
  4485. c += 1,
  4486. T = S = null,
  4487. e.updateQueue = null,
  4488. vh.current = Fh,
  4489. a = i(o, s)
  4490. } while (zh)
  4491. }
  4492. if (vh.current = Gh,
  4493. e = S !== null && S.next !== null,
  4494. xh = 0,
  4495. T = S = R = null,
  4496. yh = !1,
  4497. e)
  4498. throw Error(y(300));
  4499. return a
  4500. }
  4501. function Hh() {
  4502. var a = {
  4503. memoizedState: null,
  4504. baseState: null,
  4505. baseQueue: null,
  4506. queue: null,
  4507. next: null
  4508. };
  4509. return T === null ? R.memoizedState = T = a : T = T.next = a,
  4510. T
  4511. }
  4512. function Ih() {
  4513. if (S === null) {
  4514. var a = R.alternate;
  4515. a = a !== null ? a.memoizedState : null
  4516. } else
  4517. a = S.next;
  4518. var e = T === null ? R.memoizedState : T.next;
  4519. if (e !== null)
  4520. T = e,
  4521. S = a;
  4522. else {
  4523. if (a === null)
  4524. throw Error(y(310));
  4525. S = a,
  4526. a = {
  4527. memoizedState: S.memoizedState,
  4528. baseState: S.baseState,
  4529. baseQueue: S.baseQueue,
  4530. queue: S.queue,
  4531. next: null
  4532. },
  4533. T === null ? R.memoizedState = T = a : T = T.next = a
  4534. }
  4535. return T
  4536. }
  4537. function Jh(a, e) {
  4538. return typeof e == "function" ? e(a) : e
  4539. }
  4540. function Kh(a) {
  4541. var e = Ih()
  4542. , i = e.queue;
  4543. if (i === null)
  4544. throw Error(y(311));
  4545. i.lastRenderedReducer = a;
  4546. var o = S
  4547. , s = o.baseQueue
  4548. , c = i.pending;
  4549. if (c !== null) {
  4550. if (s !== null) {
  4551. var d = s.next;
  4552. s.next = c.next,
  4553. c.next = d
  4554. }
  4555. o.baseQueue = s = c,
  4556. i.pending = null
  4557. }
  4558. if (s !== null) {
  4559. s = s.next,
  4560. o = o.baseState;
  4561. var _ = d = c = null
  4562. , b = s;
  4563. do {
  4564. var k = b.lane;
  4565. if ((xh & k) === k)
  4566. _ !== null && (_ = _.next = {
  4567. lane: 0,
  4568. action: b.action,
  4569. eagerReducer: b.eagerReducer,
  4570. eagerState: b.eagerState,
  4571. next: null
  4572. }),
  4573. o = b.eagerReducer === a ? b.eagerState : a(o, b.action);
  4574. else {
  4575. var j = {
  4576. lane: k,
  4577. action: b.action,
  4578. eagerReducer: b.eagerReducer,
  4579. eagerState: b.eagerState,
  4580. next: null
  4581. };
  4582. _ === null ? (d = _ = j,
  4583. c = o) : _ = _.next = j,
  4584. R.lanes |= k,
  4585. Dg |= k
  4586. }
  4587. b = b.next
  4588. } while (b !== null && b !== s);
  4589. _ === null ? c = o : _.next = d,
  4590. He(o, e.memoizedState) || (ug = !0),
  4591. e.memoizedState = o,
  4592. e.baseState = c,
  4593. e.baseQueue = _,
  4594. i.lastRenderedState = o
  4595. }
  4596. return [e.memoizedState, i.dispatch]
  4597. }
  4598. function Lh(a) {
  4599. var e = Ih()
  4600. , i = e.queue;
  4601. if (i === null)
  4602. throw Error(y(311));
  4603. i.lastRenderedReducer = a;
  4604. var o = i.dispatch
  4605. , s = i.pending
  4606. , c = e.memoizedState;
  4607. if (s !== null) {
  4608. i.pending = null;
  4609. var d = s = s.next;
  4610. do
  4611. c = a(c, d.action),
  4612. d = d.next;
  4613. while (d !== s);
  4614. He(c, e.memoizedState) || (ug = !0),
  4615. e.memoizedState = c,
  4616. e.baseQueue === null && (e.baseState = c),
  4617. i.lastRenderedState = c
  4618. }
  4619. return [c, o]
  4620. }
  4621. function Mh(a, e, i) {
  4622. var o = e._getVersion;
  4623. o = o(e._source);
  4624. var s = e._workInProgressVersionPrimary;
  4625. if (s !== null ? a = s === o : (a = a.mutableReadLanes,
  4626. (a = (xh & a) === a) && (e._workInProgressVersionPrimary = o,
  4627. th.push(e))),
  4628. a)
  4629. return i(e._source);
  4630. throw th.push(e),
  4631. Error(y(350))
  4632. }
  4633. function Nh(a, e, i, o) {
  4634. var s = U;
  4635. if (s === null)
  4636. throw Error(y(349));
  4637. var c = e._getVersion
  4638. , d = c(e._source)
  4639. , _ = vh.current
  4640. , b = _.useState(function() {
  4641. return Mh(s, e, i)
  4642. })
  4643. , k = b[1]
  4644. , j = b[0];
  4645. b = T;
  4646. var $ = a.memoizedState
  4647. , _e = $.refs
  4648. , et = _e.getSnapshot
  4649. , tt = $.source;
  4650. $ = $.subscribe;
  4651. var rt = R;
  4652. return a.memoizedState = {
  4653. refs: _e,
  4654. source: e,
  4655. subscribe: o
  4656. },
  4657. _.useEffect(function() {
  4658. _e.getSnapshot = i,
  4659. _e.setSnapshot = k;
  4660. var it = c(e._source);
  4661. if (!He(d, it)) {
  4662. it = i(e._source),
  4663. He(j, it) || (k(it),
  4664. it = Ig(rt),
  4665. s.mutableReadLanes |= it & s.pendingLanes),
  4666. it = s.mutableReadLanes,
  4667. s.entangledLanes |= it;
  4668. for (var nt = s.entanglements, ot = it; 0 < ot; ) {
  4669. var at = 31 - Vc(ot)
  4670. , st = 1 << at;
  4671. nt[at] |= it,
  4672. ot &= ~st
  4673. }
  4674. }
  4675. }, [i, e, o]),
  4676. _.useEffect(function() {
  4677. return o(e._source, function() {
  4678. var it = _e.getSnapshot
  4679. , nt = _e.setSnapshot;
  4680. try {
  4681. nt(it(e._source));
  4682. var ot = Ig(rt);
  4683. s.mutableReadLanes |= ot & s.pendingLanes
  4684. } catch (at) {
  4685. nt(function() {
  4686. throw at
  4687. })
  4688. }
  4689. })
  4690. }, [e, o]),
  4691. He(et, i) && He(tt, e) && He($, o) || (a = {
  4692. pending: null,
  4693. dispatch: null,
  4694. lastRenderedReducer: Jh,
  4695. lastRenderedState: j
  4696. },
  4697. a.dispatch = k = Oh.bind(null, R, a),
  4698. b.queue = a,
  4699. b.baseQueue = null,
  4700. j = Mh(s, e, i),
  4701. b.memoizedState = b.baseState = j),
  4702. j
  4703. }
  4704. function Ph(a, e, i) {
  4705. var o = Ih();
  4706. return Nh(o, a, e, i)
  4707. }
  4708. function Qh(a) {
  4709. var e = Hh();
  4710. return typeof a == "function" && (a = a()),
  4711. e.memoizedState = e.baseState = a,
  4712. a = e.queue = {
  4713. pending: null,
  4714. dispatch: null,
  4715. lastRenderedReducer: Jh,
  4716. lastRenderedState: a
  4717. },
  4718. a = a.dispatch = Oh.bind(null, R, a),
  4719. [e.memoizedState, a]
  4720. }
  4721. function Rh(a, e, i, o) {
  4722. return a = {
  4723. tag: a,
  4724. create: e,
  4725. destroy: i,
  4726. deps: o,
  4727. next: null
  4728. },
  4729. e = R.updateQueue,
  4730. e === null ? (e = {
  4731. lastEffect: null
  4732. },
  4733. R.updateQueue = e,
  4734. e.lastEffect = a.next = a) : (i = e.lastEffect,
  4735. i === null ? e.lastEffect = a.next = a : (o = i.next,
  4736. i.next = a,
  4737. a.next = o,
  4738. e.lastEffect = a)),
  4739. a
  4740. }
  4741. function Sh(a) {
  4742. var e = Hh();
  4743. return a = {
  4744. current: a
  4745. },
  4746. e.memoizedState = a
  4747. }
  4748. function Th() {
  4749. return Ih().memoizedState
  4750. }
  4751. function Uh(a, e, i, o) {
  4752. var s = Hh();
  4753. R.flags |= a,
  4754. s.memoizedState = Rh(1 | e, i, void 0, o === void 0 ? null : o)
  4755. }
  4756. function Vh(a, e, i, o) {
  4757. var s = Ih();
  4758. o = o === void 0 ? null : o;
  4759. var c = void 0;
  4760. if (S !== null) {
  4761. var d = S.memoizedState;
  4762. if (c = d.destroy,
  4763. o !== null && Bh(o, d.deps)) {
  4764. Rh(e, i, c, o);
  4765. return
  4766. }
  4767. }
  4768. R.flags |= a,
  4769. s.memoizedState = Rh(1 | e, i, c, o)
  4770. }
  4771. function Wh(a, e) {
  4772. return Uh(516, 4, a, e)
  4773. }
  4774. function Xh(a, e) {
  4775. return Vh(516, 4, a, e)
  4776. }
  4777. function Yh(a, e) {
  4778. return Vh(4, 2, a, e)
  4779. }
  4780. function Zh(a, e) {
  4781. if (typeof e == "function")
  4782. return a = a(),
  4783. e(a),
  4784. function() {
  4785. e(null)
  4786. }
  4787. ;
  4788. if (e != null)
  4789. return a = a(),
  4790. e.current = a,
  4791. function() {
  4792. e.current = null
  4793. }
  4794. }
  4795. function $h(a, e, i) {
  4796. return i = i != null ? i.concat([a]) : null,
  4797. Vh(4, 2, Zh.bind(null, e, a), i)
  4798. }
  4799. function ai() {}
  4800. function bi(a, e) {
  4801. var i = Ih();
  4802. e = e === void 0 ? null : e;
  4803. var o = i.memoizedState;
  4804. return o !== null && e !== null && Bh(e, o[1]) ? o[0] : (i.memoizedState = [a, e],
  4805. a)
  4806. }
  4807. function ci(a, e) {
  4808. var i = Ih();
  4809. e = e === void 0 ? null : e;
  4810. var o = i.memoizedState;
  4811. return o !== null && e !== null && Bh(e, o[1]) ? o[0] : (a = a(),
  4812. i.memoizedState = [a, e],
  4813. a)
  4814. }
  4815. function di(a, e) {
  4816. var i = eg();
  4817. gg(98 > i ? 98 : i, function() {
  4818. a(!0)
  4819. }),
  4820. gg(97 < i ? 97 : i, function() {
  4821. var o = wh.transition;
  4822. wh.transition = 1;
  4823. try {
  4824. a(!1),
  4825. e()
  4826. } finally {
  4827. wh.transition = o
  4828. }
  4829. })
  4830. }
  4831. function Oh(a, e, i) {
  4832. var o = Hg()
  4833. , s = Ig(a)
  4834. , c = {
  4835. lane: s,
  4836. action: i,
  4837. eagerReducer: null,
  4838. eagerState: null,
  4839. next: null
  4840. }
  4841. , d = e.pending;
  4842. if (d === null ? c.next = c : (c.next = d.next,
  4843. d.next = c),
  4844. e.pending = c,
  4845. d = a.alternate,
  4846. a === R || d !== null && d === R)
  4847. zh = yh = !0;
  4848. else {
  4849. if (a.lanes === 0 && (d === null || d.lanes === 0) && (d = e.lastRenderedReducer,
  4850. d !== null))
  4851. try {
  4852. var _ = e.lastRenderedState
  4853. , b = d(_, i);
  4854. if (c.eagerReducer = d,
  4855. c.eagerState = b,
  4856. He(b, _))
  4857. return
  4858. } catch {} finally {}
  4859. Jg(a, s, o)
  4860. }
  4861. }
  4862. var Gh = {
  4863. readContext: vg,
  4864. useCallback: Ah,
  4865. useContext: Ah,
  4866. useEffect: Ah,
  4867. useImperativeHandle: Ah,
  4868. useLayoutEffect: Ah,
  4869. useMemo: Ah,
  4870. useReducer: Ah,
  4871. useRef: Ah,
  4872. useState: Ah,
  4873. useDebugValue: Ah,
  4874. useDeferredValue: Ah,
  4875. useTransition: Ah,
  4876. useMutableSource: Ah,
  4877. useOpaqueIdentifier: Ah,
  4878. unstable_isNewReconciler: !1
  4879. }
  4880. , Dh = {
  4881. readContext: vg,
  4882. useCallback: function(a, e) {
  4883. return Hh().memoizedState = [a, e === void 0 ? null : e],
  4884. a
  4885. },
  4886. useContext: vg,
  4887. useEffect: Wh,
  4888. useImperativeHandle: function(a, e, i) {
  4889. return i = i != null ? i.concat([a]) : null,
  4890. Uh(4, 2, Zh.bind(null, e, a), i)
  4891. },
  4892. useLayoutEffect: function(a, e) {
  4893. return Uh(4, 2, a, e)
  4894. },
  4895. useMemo: function(a, e) {
  4896. var i = Hh();
  4897. return e = e === void 0 ? null : e,
  4898. a = a(),
  4899. i.memoizedState = [a, e],
  4900. a
  4901. },
  4902. useReducer: function(a, e, i) {
  4903. var o = Hh();
  4904. return e = i !== void 0 ? i(e) : e,
  4905. o.memoizedState = o.baseState = e,
  4906. a = o.queue = {
  4907. pending: null,
  4908. dispatch: null,
  4909. lastRenderedReducer: a,
  4910. lastRenderedState: e
  4911. },
  4912. a = a.dispatch = Oh.bind(null, R, a),
  4913. [o.memoizedState, a]
  4914. },
  4915. useRef: Sh,
  4916. useState: Qh,
  4917. useDebugValue: ai,
  4918. useDeferredValue: function(a) {
  4919. var e = Qh(a)
  4920. , i = e[0]
  4921. , o = e[1];
  4922. return Wh(function() {
  4923. var s = wh.transition;
  4924. wh.transition = 1;
  4925. try {
  4926. o(a)
  4927. } finally {
  4928. wh.transition = s
  4929. }
  4930. }, [a]),
  4931. i
  4932. },
  4933. useTransition: function() {
  4934. var a = Qh(!1)
  4935. , e = a[0];
  4936. return a = di.bind(null, a[1]),
  4937. Sh(a),
  4938. [a, e]
  4939. },
  4940. useMutableSource: function(a, e, i) {
  4941. var o = Hh();
  4942. return o.memoizedState = {
  4943. refs: {
  4944. getSnapshot: e,
  4945. setSnapshot: null
  4946. },
  4947. source: a,
  4948. subscribe: i
  4949. },
  4950. Nh(o, a, e, i)
  4951. },
  4952. useOpaqueIdentifier: function() {
  4953. if (lh) {
  4954. var a = !1
  4955. , e = uf(function() {
  4956. throw a || (a = !0,
  4957. i("r:" + (tf++).toString(36))),
  4958. Error(y(355))
  4959. })
  4960. , i = Qh(e)[1];
  4961. return (R.mode & 2) === 0 && (R.flags |= 516,
  4962. Rh(5, function() {
  4963. i("r:" + (tf++).toString(36))
  4964. }, void 0, null)),
  4965. e
  4966. }
  4967. return e = "r:" + (tf++).toString(36),
  4968. Qh(e),
  4969. e
  4970. },
  4971. unstable_isNewReconciler: !1
  4972. }
  4973. , Eh = {
  4974. readContext: vg,
  4975. useCallback: bi,
  4976. useContext: vg,
  4977. useEffect: Xh,
  4978. useImperativeHandle: $h,
  4979. useLayoutEffect: Yh,
  4980. useMemo: ci,
  4981. useReducer: Kh,
  4982. useRef: Th,
  4983. useState: function() {
  4984. return Kh(Jh)
  4985. },
  4986. useDebugValue: ai,
  4987. useDeferredValue: function(a) {
  4988. var e = Kh(Jh)
  4989. , i = e[0]
  4990. , o = e[1];
  4991. return Xh(function() {
  4992. var s = wh.transition;
  4993. wh.transition = 1;
  4994. try {
  4995. o(a)
  4996. } finally {
  4997. wh.transition = s
  4998. }
  4999. }, [a]),
  5000. i
  5001. },
  5002. useTransition: function() {
  5003. var a = Kh(Jh)[0];
  5004. return [Th().current, a]
  5005. },
  5006. useMutableSource: Ph,
  5007. useOpaqueIdentifier: function() {
  5008. return Kh(Jh)[0]
  5009. },
  5010. unstable_isNewReconciler: !1
  5011. }
  5012. , Fh = {
  5013. readContext: vg,
  5014. useCallback: bi,
  5015. useContext: vg,
  5016. useEffect: Xh,
  5017. useImperativeHandle: $h,
  5018. useLayoutEffect: Yh,
  5019. useMemo: ci,
  5020. useReducer: Lh,
  5021. useRef: Th,
  5022. useState: function() {
  5023. return Lh(Jh)
  5024. },
  5025. useDebugValue: ai,
  5026. useDeferredValue: function(a) {
  5027. var e = Lh(Jh)
  5028. , i = e[0]
  5029. , o = e[1];
  5030. return Xh(function() {
  5031. var s = wh.transition;
  5032. wh.transition = 1;
  5033. try {
  5034. o(a)
  5035. } finally {
  5036. wh.transition = s
  5037. }
  5038. }, [a]),
  5039. i
  5040. },
  5041. useTransition: function() {
  5042. var a = Lh(Jh)[0];
  5043. return [Th().current, a]
  5044. },
  5045. useMutableSource: Ph,
  5046. useOpaqueIdentifier: function() {
  5047. return Lh(Jh)[0]
  5048. },
  5049. unstable_isNewReconciler: !1
  5050. }
  5051. , ei = ra.ReactCurrentOwner
  5052. , ug = !1;
  5053. function fi(a, e, i, o) {
  5054. e.child = a === null ? Zg(e, null, i, o) : Yg(e, a.child, i, o)
  5055. }
  5056. function gi(a, e, i, o, s) {
  5057. i = i.render;
  5058. var c = e.ref;
  5059. return tg(e, s),
  5060. o = Ch(a, e, i, o, c, s),
  5061. a !== null && !ug ? (e.updateQueue = a.updateQueue,
  5062. e.flags &= -517,
  5063. a.lanes &= ~s,
  5064. hi(a, e, s)) : (e.flags |= 1,
  5065. fi(a, e, o, s),
  5066. e.child)
  5067. }
  5068. function ii(a, e, i, o, s, c) {
  5069. if (a === null) {
  5070. var d = i.type;
  5071. return typeof d == "function" && !ji(d) && d.defaultProps === void 0 && i.compare === null && i.defaultProps === void 0 ? (e.tag = 15,
  5072. e.type = d,
  5073. ki(a, e, d, o, s, c)) : (a = Vg(i.type, null, o, e, e.mode, c),
  5074. a.ref = e.ref,
  5075. a.return = e,
  5076. e.child = a)
  5077. }
  5078. return d = a.child,
  5079. (s & c) === 0 && (s = d.memoizedProps,
  5080. i = i.compare,
  5081. i = i !== null ? i : Je,
  5082. i(s, o) && a.ref === e.ref) ? hi(a, e, c) : (e.flags |= 1,
  5083. a = Tg(d, o),
  5084. a.ref = e.ref,
  5085. a.return = e,
  5086. e.child = a)
  5087. }
  5088. function ki(a, e, i, o, s, c) {
  5089. if (a !== null && Je(a.memoizedProps, o) && a.ref === e.ref)
  5090. if (ug = !1,
  5091. (c & s) !== 0)
  5092. (a.flags & 16384) !== 0 && (ug = !0);
  5093. else
  5094. return e.lanes = a.lanes,
  5095. hi(a, e, c);
  5096. return li(a, e, i, o, c)
  5097. }
  5098. function mi(a, e, i) {
  5099. var o = e.pendingProps
  5100. , s = o.children
  5101. , c = a !== null ? a.memoizedState : null;
  5102. if (o.mode === "hidden" || o.mode === "unstable-defer-without-hiding")
  5103. if ((e.mode & 4) === 0)
  5104. e.memoizedState = {
  5105. baseLanes: 0
  5106. },
  5107. ni(e, i);
  5108. else if ((i & 1073741824) !== 0)
  5109. e.memoizedState = {
  5110. baseLanes: 0
  5111. },
  5112. ni(e, c !== null ? c.baseLanes : i);
  5113. else
  5114. return a = c !== null ? c.baseLanes | i : i,
  5115. e.lanes = e.childLanes = 1073741824,
  5116. e.memoizedState = {
  5117. baseLanes: a
  5118. },
  5119. ni(e, a),
  5120. null;
  5121. else
  5122. c !== null ? (o = c.baseLanes | i,
  5123. e.memoizedState = null) : o = i,
  5124. ni(e, o);
  5125. return fi(a, e, s, i),
  5126. e.child
  5127. }
  5128. function oi(a, e) {
  5129. var i = e.ref;
  5130. (a === null && i !== null || a !== null && a.ref !== i) && (e.flags |= 128)
  5131. }
  5132. function li(a, e, i, o, s) {
  5133. var c = Ff(i) ? Df : M.current;
  5134. return c = Ef(e, c),
  5135. tg(e, s),
  5136. i = Ch(a, e, i, o, c, s),
  5137. a !== null && !ug ? (e.updateQueue = a.updateQueue,
  5138. e.flags &= -517,
  5139. a.lanes &= ~s,
  5140. hi(a, e, s)) : (e.flags |= 1,
  5141. fi(a, e, i, s),
  5142. e.child)
  5143. }
  5144. function pi(a, e, i, o, s) {
  5145. if (Ff(i)) {
  5146. var c = !0;
  5147. Jf(e)
  5148. } else
  5149. c = !1;
  5150. if (tg(e, s),
  5151. e.stateNode === null)
  5152. a !== null && (a.alternate = null,
  5153. e.alternate = null,
  5154. e.flags |= 2),
  5155. Mg(e, i, o),
  5156. Og(e, i, o, s),
  5157. o = !0;
  5158. else if (a === null) {
  5159. var d = e.stateNode
  5160. , _ = e.memoizedProps;
  5161. d.props = _;
  5162. var b = d.context
  5163. , k = i.contextType;
  5164. typeof k == "object" && k !== null ? k = vg(k) : (k = Ff(i) ? Df : M.current,
  5165. k = Ef(e, k));
  5166. var j = i.getDerivedStateFromProps
  5167. , $ = typeof j == "function" || typeof d.getSnapshotBeforeUpdate == "function";
  5168. $ || typeof d.UNSAFE_componentWillReceiveProps != "function" && typeof d.componentWillReceiveProps != "function" || (_ !== o || b !== k) && Ng(e, d, o, k),
  5169. wg = !1;
  5170. var _e = e.memoizedState;
  5171. d.state = _e,
  5172. Cg(e, o, d, s),
  5173. b = e.memoizedState,
  5174. _ !== o || _e !== b || N.current || wg ? (typeof j == "function" && (Gg(e, i, j, o),
  5175. b = e.memoizedState),
  5176. (_ = wg || Lg(e, i, _, o, _e, b, k)) ? ($ || typeof d.UNSAFE_componentWillMount != "function" && typeof d.componentWillMount != "function" || (typeof d.componentWillMount == "function" && d.componentWillMount(),
  5177. typeof d.UNSAFE_componentWillMount == "function" && d.UNSAFE_componentWillMount()),
  5178. typeof d.componentDidMount == "function" && (e.flags |= 4)) : (typeof d.componentDidMount == "function" && (e.flags |= 4),
  5179. e.memoizedProps = o,
  5180. e.memoizedState = b),
  5181. d.props = o,
  5182. d.state = b,
  5183. d.context = k,
  5184. o = _) : (typeof d.componentDidMount == "function" && (e.flags |= 4),
  5185. o = !1)
  5186. } else {
  5187. d = e.stateNode,
  5188. yg(a, e),
  5189. _ = e.memoizedProps,
  5190. k = e.type === e.elementType ? _ : lg(e.type, _),
  5191. d.props = k,
  5192. $ = e.pendingProps,
  5193. _e = d.context,
  5194. b = i.contextType,
  5195. typeof b == "object" && b !== null ? b = vg(b) : (b = Ff(i) ? Df : M.current,
  5196. b = Ef(e, b));
  5197. var et = i.getDerivedStateFromProps;
  5198. (j = typeof et == "function" || typeof d.getSnapshotBeforeUpdate == "function") || typeof d.UNSAFE_componentWillReceiveProps != "function" && typeof d.componentWillReceiveProps != "function" || (_ !== $ || _e !== b) && Ng(e, d, o, b),
  5199. wg = !1,
  5200. _e = e.memoizedState,
  5201. d.state = _e,
  5202. Cg(e, o, d, s);
  5203. var tt = e.memoizedState;
  5204. _ !== $ || _e !== tt || N.current || wg ? (typeof et == "function" && (Gg(e, i, et, o),
  5205. tt = e.memoizedState),
  5206. (k = wg || Lg(e, i, k, o, _e, tt, b)) ? (j || typeof d.UNSAFE_componentWillUpdate != "function" && typeof d.componentWillUpdate != "function" || (typeof d.componentWillUpdate == "function" && d.componentWillUpdate(o, tt, b),
  5207. typeof d.UNSAFE_componentWillUpdate == "function" && d.UNSAFE_componentWillUpdate(o, tt, b)),
  5208. typeof d.componentDidUpdate == "function" && (e.flags |= 4),
  5209. typeof d.getSnapshotBeforeUpdate == "function" && (e.flags |= 256)) : (typeof d.componentDidUpdate != "function" || _ === a.memoizedProps && _e === a.memoizedState || (e.flags |= 4),
  5210. typeof d.getSnapshotBeforeUpdate != "function" || _ === a.memoizedProps && _e === a.memoizedState || (e.flags |= 256),
  5211. e.memoizedProps = o,
  5212. e.memoizedState = tt),
  5213. d.props = o,
  5214. d.state = tt,
  5215. d.context = b,
  5216. o = k) : (typeof d.componentDidUpdate != "function" || _ === a.memoizedProps && _e === a.memoizedState || (e.flags |= 4),
  5217. typeof d.getSnapshotBeforeUpdate != "function" || _ === a.memoizedProps && _e === a.memoizedState || (e.flags |= 256),
  5218. o = !1)
  5219. }
  5220. return qi(a, e, i, o, c, s)
  5221. }
  5222. function qi(a, e, i, o, s, c) {
  5223. oi(a, e);
  5224. var d = (e.flags & 64) !== 0;
  5225. if (!o && !d)
  5226. return s && Kf(e, i, !1),
  5227. hi(a, e, c);
  5228. o = e.stateNode,
  5229. ei.current = e;
  5230. var _ = d && typeof i.getDerivedStateFromError != "function" ? null : o.render();
  5231. return e.flags |= 1,
  5232. a !== null && d ? (e.child = Yg(e, a.child, null, c),
  5233. e.child = Yg(e, null, _, c)) : fi(a, e, _, c),
  5234. e.memoizedState = o.state,
  5235. s && Kf(e, i, !0),
  5236. e.child
  5237. }
  5238. function ri(a) {
  5239. var e = a.stateNode;
  5240. e.pendingContext ? Hf(a, e.pendingContext, e.pendingContext !== e.context) : e.context && Hf(a, e.context, !1),
  5241. eh(a, e.containerInfo)
  5242. }
  5243. var si = {
  5244. dehydrated: null,
  5245. retryLane: 0
  5246. };
  5247. function ti(a, e, i) {
  5248. var o = e.pendingProps, s = P.current, c = !1, d;
  5249. return (d = (e.flags & 64) !== 0) || (d = a !== null && a.memoizedState === null ? !1 : (s & 2) !== 0),
  5250. d ? (c = !0,
  5251. e.flags &= -65) : a !== null && a.memoizedState === null || o.fallback === void 0 || o.unstable_avoidThisFallback === !0 || (s |= 1),
  5252. I(P, s & 1),
  5253. a === null ? (o.fallback !== void 0 && ph(e),
  5254. a = o.children,
  5255. s = o.fallback,
  5256. c ? (a = ui(e, a, s, i),
  5257. e.child.memoizedState = {
  5258. baseLanes: i
  5259. },
  5260. e.memoizedState = si,
  5261. a) : typeof o.unstable_expectedLoadTime == "number" ? (a = ui(e, a, s, i),
  5262. e.child.memoizedState = {
  5263. baseLanes: i
  5264. },
  5265. e.memoizedState = si,
  5266. e.lanes = 33554432,
  5267. a) : (i = vi({
  5268. mode: "visible",
  5269. children: a
  5270. }, e.mode, i, null),
  5271. i.return = e,
  5272. e.child = i)) : a.memoizedState !== null ? c ? (o = wi(a, e, o.children, o.fallback, i),
  5273. c = e.child,
  5274. s = a.child.memoizedState,
  5275. c.memoizedState = s === null ? {
  5276. baseLanes: i
  5277. } : {
  5278. baseLanes: s.baseLanes | i
  5279. },
  5280. c.childLanes = a.childLanes & ~i,
  5281. e.memoizedState = si,
  5282. o) : (i = xi(a, e, o.children, i),
  5283. e.memoizedState = null,
  5284. i) : c ? (o = wi(a, e, o.children, o.fallback, i),
  5285. c = e.child,
  5286. s = a.child.memoizedState,
  5287. c.memoizedState = s === null ? {
  5288. baseLanes: i
  5289. } : {
  5290. baseLanes: s.baseLanes | i
  5291. },
  5292. c.childLanes = a.childLanes & ~i,
  5293. e.memoizedState = si,
  5294. o) : (i = xi(a, e, o.children, i),
  5295. e.memoizedState = null,
  5296. i)
  5297. }
  5298. function ui(a, e, i, o) {
  5299. var s = a.mode
  5300. , c = a.child;
  5301. return e = {
  5302. mode: "hidden",
  5303. children: e
  5304. },
  5305. (s & 2) === 0 && c !== null ? (c.childLanes = 0,
  5306. c.pendingProps = e) : c = vi(e, s, 0, null),
  5307. i = Xg(i, s, o, null),
  5308. c.return = a,
  5309. i.return = a,
  5310. c.sibling = i,
  5311. a.child = c,
  5312. i
  5313. }
  5314. function xi(a, e, i, o) {
  5315. var s = a.child;
  5316. return a = s.sibling,
  5317. i = Tg(s, {
  5318. mode: "visible",
  5319. children: i
  5320. }),
  5321. (e.mode & 2) === 0 && (i.lanes = o),
  5322. i.return = e,
  5323. i.sibling = null,
  5324. a !== null && (a.nextEffect = null,
  5325. a.flags = 8,
  5326. e.firstEffect = e.lastEffect = a),
  5327. e.child = i
  5328. }
  5329. function wi(a, e, i, o, s) {
  5330. var c = e.mode
  5331. , d = a.child;
  5332. a = d.sibling;
  5333. var _ = {
  5334. mode: "hidden",
  5335. children: i
  5336. };
  5337. return (c & 2) === 0 && e.child !== d ? (i = e.child,
  5338. i.childLanes = 0,
  5339. i.pendingProps = _,
  5340. d = i.lastEffect,
  5341. d !== null ? (e.firstEffect = i.firstEffect,
  5342. e.lastEffect = d,
  5343. d.nextEffect = null) : e.firstEffect = e.lastEffect = null) : i = Tg(d, _),
  5344. a !== null ? o = Tg(a, o) : (o = Xg(o, c, s, null),
  5345. o.flags |= 2),
  5346. o.return = e,
  5347. i.return = e,
  5348. i.sibling = o,
  5349. e.child = i,
  5350. o
  5351. }
  5352. function yi(a, e) {
  5353. a.lanes |= e;
  5354. var i = a.alternate;
  5355. i !== null && (i.lanes |= e),
  5356. sg(a.return, e)
  5357. }
  5358. function zi(a, e, i, o, s, c) {
  5359. var d = a.memoizedState;
  5360. d === null ? a.memoizedState = {
  5361. isBackwards: e,
  5362. rendering: null,
  5363. renderingStartTime: 0,
  5364. last: o,
  5365. tail: i,
  5366. tailMode: s,
  5367. lastEffect: c
  5368. } : (d.isBackwards = e,
  5369. d.rendering = null,
  5370. d.renderingStartTime = 0,
  5371. d.last = o,
  5372. d.tail = i,
  5373. d.tailMode = s,
  5374. d.lastEffect = c)
  5375. }
  5376. function Ai(a, e, i) {
  5377. var o = e.pendingProps
  5378. , s = o.revealOrder
  5379. , c = o.tail;
  5380. if (fi(a, e, o.children, i),
  5381. o = P.current,
  5382. (o & 2) !== 0)
  5383. o = o & 1 | 2,
  5384. e.flags |= 64;
  5385. else {
  5386. if (a !== null && (a.flags & 64) !== 0)
  5387. e: for (a = e.child; a !== null; ) {
  5388. if (a.tag === 13)
  5389. a.memoizedState !== null && yi(a, i);
  5390. else if (a.tag === 19)
  5391. yi(a, i);
  5392. else if (a.child !== null) {
  5393. a.child.return = a,
  5394. a = a.child;
  5395. continue
  5396. }
  5397. if (a === e)
  5398. break e;
  5399. for (; a.sibling === null; ) {
  5400. if (a.return === null || a.return === e)
  5401. break e;
  5402. a = a.return
  5403. }
  5404. a.sibling.return = a.return,
  5405. a = a.sibling
  5406. }
  5407. o &= 1
  5408. }
  5409. if (I(P, o),
  5410. (e.mode & 2) === 0)
  5411. e.memoizedState = null;
  5412. else
  5413. switch (s) {
  5414. case "forwards":
  5415. for (i = e.child,
  5416. s = null; i !== null; )
  5417. a = i.alternate,
  5418. a !== null && ih(a) === null && (s = i),
  5419. i = i.sibling;
  5420. i = s,
  5421. i === null ? (s = e.child,
  5422. e.child = null) : (s = i.sibling,
  5423. i.sibling = null),
  5424. zi(e, !1, s, i, c, e.lastEffect);
  5425. break;
  5426. case "backwards":
  5427. for (i = null,
  5428. s = e.child,
  5429. e.child = null; s !== null; ) {
  5430. if (a = s.alternate,
  5431. a !== null && ih(a) === null) {
  5432. e.child = s;
  5433. break
  5434. }
  5435. a = s.sibling,
  5436. s.sibling = i,
  5437. i = s,
  5438. s = a
  5439. }
  5440. zi(e, !0, i, null, c, e.lastEffect);
  5441. break;
  5442. case "together":
  5443. zi(e, !1, null, null, void 0, e.lastEffect);
  5444. break;
  5445. default:
  5446. e.memoizedState = null
  5447. }
  5448. return e.child
  5449. }
  5450. function hi(a, e, i) {
  5451. if (a !== null && (e.dependencies = a.dependencies),
  5452. Dg |= e.lanes,
  5453. (i & e.childLanes) !== 0) {
  5454. if (a !== null && e.child !== a.child)
  5455. throw Error(y(153));
  5456. if (e.child !== null) {
  5457. for (a = e.child,
  5458. i = Tg(a, a.pendingProps),
  5459. e.child = i,
  5460. i.return = e; a.sibling !== null; )
  5461. a = a.sibling,
  5462. i = i.sibling = Tg(a, a.pendingProps),
  5463. i.return = e;
  5464. i.sibling = null
  5465. }
  5466. return e.child
  5467. }
  5468. return null
  5469. }
  5470. var Bi, Ci, Di, Ei;
  5471. Bi = function(a, e) {
  5472. for (var i = e.child; i !== null; ) {
  5473. if (i.tag === 5 || i.tag === 6)
  5474. a.appendChild(i.stateNode);
  5475. else if (i.tag !== 4 && i.child !== null) {
  5476. i.child.return = i,
  5477. i = i.child;
  5478. continue
  5479. }
  5480. if (i === e)
  5481. break;
  5482. for (; i.sibling === null; ) {
  5483. if (i.return === null || i.return === e)
  5484. return;
  5485. i = i.return
  5486. }
  5487. i.sibling.return = i.return,
  5488. i = i.sibling
  5489. }
  5490. }
  5491. ;
  5492. Ci = function() {}
  5493. ;
  5494. Di = function(a, e, i, o) {
  5495. var s = a.memoizedProps;
  5496. if (s !== o) {
  5497. a = e.stateNode,
  5498. dh(ah.current);
  5499. var c = null;
  5500. switch (i) {
  5501. case "input":
  5502. s = Ya(a, s),
  5503. o = Ya(a, o),
  5504. c = [];
  5505. break;
  5506. case "option":
  5507. s = eb(a, s),
  5508. o = eb(a, o),
  5509. c = [];
  5510. break;
  5511. case "select":
  5512. s = m$1({}, s, {
  5513. value: void 0
  5514. }),
  5515. o = m$1({}, o, {
  5516. value: void 0
  5517. }),
  5518. c = [];
  5519. break;
  5520. case "textarea":
  5521. s = gb(a, s),
  5522. o = gb(a, o),
  5523. c = [];
  5524. break;
  5525. default:
  5526. typeof s.onClick != "function" && typeof o.onClick == "function" && (a.onclick = jf)
  5527. }
  5528. vb(i, o);
  5529. var d;
  5530. i = null;
  5531. for (k in s)
  5532. if (!o.hasOwnProperty(k) && s.hasOwnProperty(k) && s[k] != null)
  5533. if (k === "style") {
  5534. var _ = s[k];
  5535. for (d in _)
  5536. _.hasOwnProperty(d) && (i || (i = {}),
  5537. i[d] = "")
  5538. } else
  5539. k !== "dangerouslySetInnerHTML" && k !== "children" && k !== "suppressContentEditableWarning" && k !== "suppressHydrationWarning" && k !== "autoFocus" && (ca.hasOwnProperty(k) ? c || (c = []) : (c = c || []).push(k, null));
  5540. for (k in o) {
  5541. var b = o[k];
  5542. if (_ = s != null ? s[k] : void 0,
  5543. o.hasOwnProperty(k) && b !== _ && (b != null || _ != null))
  5544. if (k === "style")
  5545. if (_) {
  5546. for (d in _)
  5547. !_.hasOwnProperty(d) || b && b.hasOwnProperty(d) || (i || (i = {}),
  5548. i[d] = "");
  5549. for (d in b)
  5550. b.hasOwnProperty(d) && _[d] !== b[d] && (i || (i = {}),
  5551. i[d] = b[d])
  5552. } else
  5553. i || (c || (c = []),
  5554. c.push(k, i)),
  5555. i = b;
  5556. else
  5557. k === "dangerouslySetInnerHTML" ? (b = b ? b.__html : void 0,
  5558. _ = _ ? _.__html : void 0,
  5559. b != null && _ !== b && (c = c || []).push(k, b)) : k === "children" ? typeof b != "string" && typeof b != "number" || (c = c || []).push(k, "" + b) : k !== "suppressContentEditableWarning" && k !== "suppressHydrationWarning" && (ca.hasOwnProperty(k) ? (b != null && k === "onScroll" && G("scroll", a),
  5560. c || _ === b || (c = [])) : typeof b == "object" && b !== null && b.$$typeof === Ga ? b.toString() : (c = c || []).push(k, b))
  5561. }
  5562. i && (c = c || []).push("style", i);
  5563. var k = c;
  5564. (e.updateQueue = k) && (e.flags |= 4)
  5565. }
  5566. }
  5567. ;
  5568. Ei = function(a, e, i, o) {
  5569. i !== o && (e.flags |= 4)
  5570. }
  5571. ;
  5572. function Fi(a, e) {
  5573. if (!lh)
  5574. switch (a.tailMode) {
  5575. case "hidden":
  5576. e = a.tail;
  5577. for (var i = null; e !== null; )
  5578. e.alternate !== null && (i = e),
  5579. e = e.sibling;
  5580. i === null ? a.tail = null : i.sibling = null;
  5581. break;
  5582. case "collapsed":
  5583. i = a.tail;
  5584. for (var o = null; i !== null; )
  5585. i.alternate !== null && (o = i),
  5586. i = i.sibling;
  5587. o === null ? e || a.tail === null ? a.tail = null : a.tail.sibling = null : o.sibling = null
  5588. }
  5589. }
  5590. function Gi(a, e, i) {
  5591. var o = e.pendingProps;
  5592. switch (e.tag) {
  5593. case 2:
  5594. case 16:
  5595. case 15:
  5596. case 0:
  5597. case 11:
  5598. case 7:
  5599. case 8:
  5600. case 12:
  5601. case 9:
  5602. case 14:
  5603. return null;
  5604. case 1:
  5605. return Ff(e.type) && Gf(),
  5606. null;
  5607. case 3:
  5608. return fh(),
  5609. H(N),
  5610. H(M),
  5611. uh(),
  5612. o = e.stateNode,
  5613. o.pendingContext && (o.context = o.pendingContext,
  5614. o.pendingContext = null),
  5615. (a === null || a.child === null) && (rh(e) ? e.flags |= 4 : o.hydrate || (e.flags |= 256)),
  5616. Ci(e),
  5617. null;
  5618. case 5:
  5619. hh(e);
  5620. var s = dh(ch.current);
  5621. if (i = e.type,
  5622. a !== null && e.stateNode != null)
  5623. Di(a, e, i, o, s),
  5624. a.ref !== e.ref && (e.flags |= 128);
  5625. else {
  5626. if (!o) {
  5627. if (e.stateNode === null)
  5628. throw Error(y(166));
  5629. return null
  5630. }
  5631. if (a = dh(ah.current),
  5632. rh(e)) {
  5633. o = e.stateNode,
  5634. i = e.type;
  5635. var c = e.memoizedProps;
  5636. switch (o[wf] = e,
  5637. o[xf] = c,
  5638. i) {
  5639. case "dialog":
  5640. G("cancel", o),
  5641. G("close", o);
  5642. break;
  5643. case "iframe":
  5644. case "object":
  5645. case "embed":
  5646. G("load", o);
  5647. break;
  5648. case "video":
  5649. case "audio":
  5650. for (a = 0; a < Xe.length; a++)
  5651. G(Xe[a], o);
  5652. break;
  5653. case "source":
  5654. G("error", o);
  5655. break;
  5656. case "img":
  5657. case "image":
  5658. case "link":
  5659. G("error", o),
  5660. G("load", o);
  5661. break;
  5662. case "details":
  5663. G("toggle", o);
  5664. break;
  5665. case "input":
  5666. Za(o, c),
  5667. G("invalid", o);
  5668. break;
  5669. case "select":
  5670. o._wrapperState = {
  5671. wasMultiple: !!c.multiple
  5672. },
  5673. G("invalid", o);
  5674. break;
  5675. case "textarea":
  5676. hb(o, c),
  5677. G("invalid", o)
  5678. }
  5679. vb(i, c),
  5680. a = null;
  5681. for (var d in c)
  5682. c.hasOwnProperty(d) && (s = c[d],
  5683. d === "children" ? typeof s == "string" ? o.textContent !== s && (a = ["children", s]) : typeof s == "number" && o.textContent !== "" + s && (a = ["children", "" + s]) : ca.hasOwnProperty(d) && s != null && d === "onScroll" && G("scroll", o));
  5684. switch (i) {
  5685. case "input":
  5686. Va(o),
  5687. cb(o, c, !0);
  5688. break;
  5689. case "textarea":
  5690. Va(o),
  5691. jb(o);
  5692. break;
  5693. case "select":
  5694. case "option":
  5695. break;
  5696. default:
  5697. typeof c.onClick == "function" && (o.onclick = jf)
  5698. }
  5699. o = a,
  5700. e.updateQueue = o,
  5701. o !== null && (e.flags |= 4)
  5702. } else {
  5703. switch (d = s.nodeType === 9 ? s : s.ownerDocument,
  5704. a === kb.html && (a = lb(i)),
  5705. a === kb.html ? i === "script" ? (a = d.createElement("div"),
  5706. a.innerHTML = "<script><\/script>",
  5707. a = a.removeChild(a.firstChild)) : typeof o.is == "string" ? a = d.createElement(i, {
  5708. is: o.is
  5709. }) : (a = d.createElement(i),
  5710. i === "select" && (d = a,
  5711. o.multiple ? d.multiple = !0 : o.size && (d.size = o.size))) : a = d.createElementNS(a, i),
  5712. a[wf] = e,
  5713. a[xf] = o,
  5714. Bi(a, e, !1, !1),
  5715. e.stateNode = a,
  5716. d = wb(i, o),
  5717. i) {
  5718. case "dialog":
  5719. G("cancel", a),
  5720. G("close", a),
  5721. s = o;
  5722. break;
  5723. case "iframe":
  5724. case "object":
  5725. case "embed":
  5726. G("load", a),
  5727. s = o;
  5728. break;
  5729. case "video":
  5730. case "audio":
  5731. for (s = 0; s < Xe.length; s++)
  5732. G(Xe[s], a);
  5733. s = o;
  5734. break;
  5735. case "source":
  5736. G("error", a),
  5737. s = o;
  5738. break;
  5739. case "img":
  5740. case "image":
  5741. case "link":
  5742. G("error", a),
  5743. G("load", a),
  5744. s = o;
  5745. break;
  5746. case "details":
  5747. G("toggle", a),
  5748. s = o;
  5749. break;
  5750. case "input":
  5751. Za(a, o),
  5752. s = Ya(a, o),
  5753. G("invalid", a);
  5754. break;
  5755. case "option":
  5756. s = eb(a, o);
  5757. break;
  5758. case "select":
  5759. a._wrapperState = {
  5760. wasMultiple: !!o.multiple
  5761. },
  5762. s = m$1({}, o, {
  5763. value: void 0
  5764. }),
  5765. G("invalid", a);
  5766. break;
  5767. case "textarea":
  5768. hb(a, o),
  5769. s = gb(a, o),
  5770. G("invalid", a);
  5771. break;
  5772. default:
  5773. s = o
  5774. }
  5775. vb(i, s);
  5776. var _ = s;
  5777. for (c in _)
  5778. if (_.hasOwnProperty(c)) {
  5779. var b = _[c];
  5780. c === "style" ? tb(a, b) : c === "dangerouslySetInnerHTML" ? (b = b ? b.__html : void 0,
  5781. b != null && ob(a, b)) : c === "children" ? typeof b == "string" ? (i !== "textarea" || b !== "") && pb(a, b) : typeof b == "number" && pb(a, "" + b) : c !== "suppressContentEditableWarning" && c !== "suppressHydrationWarning" && c !== "autoFocus" && (ca.hasOwnProperty(c) ? b != null && c === "onScroll" && G("scroll", a) : b != null && qa(a, c, b, d))
  5782. }
  5783. switch (i) {
  5784. case "input":
  5785. Va(a),
  5786. cb(a, o, !1);
  5787. break;
  5788. case "textarea":
  5789. Va(a),
  5790. jb(a);
  5791. break;
  5792. case "option":
  5793. o.value != null && a.setAttribute("value", "" + Sa(o.value));
  5794. break;
  5795. case "select":
  5796. a.multiple = !!o.multiple,
  5797. c = o.value,
  5798. c != null ? fb(a, !!o.multiple, c, !1) : o.defaultValue != null && fb(a, !!o.multiple, o.defaultValue, !0);
  5799. break;
  5800. default:
  5801. typeof s.onClick == "function" && (a.onclick = jf)
  5802. }
  5803. mf(i, o) && (e.flags |= 4)
  5804. }
  5805. e.ref !== null && (e.flags |= 128)
  5806. }
  5807. return null;
  5808. case 6:
  5809. if (a && e.stateNode != null)
  5810. Ei(a, e, a.memoizedProps, o);
  5811. else {
  5812. if (typeof o != "string" && e.stateNode === null)
  5813. throw Error(y(166));
  5814. i = dh(ch.current),
  5815. dh(ah.current),
  5816. rh(e) ? (o = e.stateNode,
  5817. i = e.memoizedProps,
  5818. o[wf] = e,
  5819. o.nodeValue !== i && (e.flags |= 4)) : (o = (i.nodeType === 9 ? i : i.ownerDocument).createTextNode(o),
  5820. o[wf] = e,
  5821. e.stateNode = o)
  5822. }
  5823. return null;
  5824. case 13:
  5825. return H(P),
  5826. o = e.memoizedState,
  5827. (e.flags & 64) !== 0 ? (e.lanes = i,
  5828. e) : (o = o !== null,
  5829. i = !1,
  5830. a === null ? e.memoizedProps.fallback !== void 0 && rh(e) : i = a.memoizedState !== null,
  5831. o && !i && (e.mode & 2) !== 0 && (a === null && e.memoizedProps.unstable_avoidThisFallback !== !0 || (P.current & 1) !== 0 ? V === 0 && (V = 3) : ((V === 0 || V === 3) && (V = 4),
  5832. U === null || (Dg & 134217727) === 0 && (Hi & 134217727) === 0 || Ii(U, W))),
  5833. (o || i) && (e.flags |= 4),
  5834. null);
  5835. case 4:
  5836. return fh(),
  5837. Ci(e),
  5838. a === null && cf(e.stateNode.containerInfo),
  5839. null;
  5840. case 10:
  5841. return rg(e),
  5842. null;
  5843. case 17:
  5844. return Ff(e.type) && Gf(),
  5845. null;
  5846. case 19:
  5847. if (H(P),
  5848. o = e.memoizedState,
  5849. o === null)
  5850. return null;
  5851. if (c = (e.flags & 64) !== 0,
  5852. d = o.rendering,
  5853. d === null)
  5854. if (c)
  5855. Fi(o, !1);
  5856. else {
  5857. if (V !== 0 || a !== null && (a.flags & 64) !== 0)
  5858. for (a = e.child; a !== null; ) {
  5859. if (d = ih(a),
  5860. d !== null) {
  5861. for (e.flags |= 64,
  5862. Fi(o, !1),
  5863. c = d.updateQueue,
  5864. c !== null && (e.updateQueue = c,
  5865. e.flags |= 4),
  5866. o.lastEffect === null && (e.firstEffect = null),
  5867. e.lastEffect = o.lastEffect,
  5868. o = i,
  5869. i = e.child; i !== null; )
  5870. c = i,
  5871. a = o,
  5872. c.flags &= 2,
  5873. c.nextEffect = null,
  5874. c.firstEffect = null,
  5875. c.lastEffect = null,
  5876. d = c.alternate,
  5877. d === null ? (c.childLanes = 0,
  5878. c.lanes = a,
  5879. c.child = null,
  5880. c.memoizedProps = null,
  5881. c.memoizedState = null,
  5882. c.updateQueue = null,
  5883. c.dependencies = null,
  5884. c.stateNode = null) : (c.childLanes = d.childLanes,
  5885. c.lanes = d.lanes,
  5886. c.child = d.child,
  5887. c.memoizedProps = d.memoizedProps,
  5888. c.memoizedState = d.memoizedState,
  5889. c.updateQueue = d.updateQueue,
  5890. c.type = d.type,
  5891. a = d.dependencies,
  5892. c.dependencies = a === null ? null : {
  5893. lanes: a.lanes,
  5894. firstContext: a.firstContext
  5895. }),
  5896. i = i.sibling;
  5897. return I(P, P.current & 1 | 2),
  5898. e.child
  5899. }
  5900. a = a.sibling
  5901. }
  5902. o.tail !== null && O() > Ji && (e.flags |= 64,
  5903. c = !0,
  5904. Fi(o, !1),
  5905. e.lanes = 33554432)
  5906. }
  5907. else {
  5908. if (!c)
  5909. if (a = ih(d),
  5910. a !== null) {
  5911. if (e.flags |= 64,
  5912. c = !0,
  5913. i = a.updateQueue,
  5914. i !== null && (e.updateQueue = i,
  5915. e.flags |= 4),
  5916. Fi(o, !0),
  5917. o.tail === null && o.tailMode === "hidden" && !d.alternate && !lh)
  5918. return e = e.lastEffect = o.lastEffect,
  5919. e !== null && (e.nextEffect = null),
  5920. null
  5921. } else
  5922. 2 * O() - o.renderingStartTime > Ji && i !== 1073741824 && (e.flags |= 64,
  5923. c = !0,
  5924. Fi(o, !1),
  5925. e.lanes = 33554432);
  5926. o.isBackwards ? (d.sibling = e.child,
  5927. e.child = d) : (i = o.last,
  5928. i !== null ? i.sibling = d : e.child = d,
  5929. o.last = d)
  5930. }
  5931. return o.tail !== null ? (i = o.tail,
  5932. o.rendering = i,
  5933. o.tail = i.sibling,
  5934. o.lastEffect = e.lastEffect,
  5935. o.renderingStartTime = O(),
  5936. i.sibling = null,
  5937. e = P.current,
  5938. I(P, c ? e & 1 | 2 : e & 1),
  5939. i) : null;
  5940. case 23:
  5941. case 24:
  5942. return Ki(),
  5943. a !== null && a.memoizedState !== null != (e.memoizedState !== null) && o.mode !== "unstable-defer-without-hiding" && (e.flags |= 4),
  5944. null
  5945. }
  5946. throw Error(y(156, e.tag))
  5947. }
  5948. function Li(a) {
  5949. switch (a.tag) {
  5950. case 1:
  5951. Ff(a.type) && Gf();
  5952. var e = a.flags;
  5953. return e & 4096 ? (a.flags = e & -4097 | 64,
  5954. a) : null;
  5955. case 3:
  5956. if (fh(),
  5957. H(N),
  5958. H(M),
  5959. uh(),
  5960. e = a.flags,
  5961. (e & 64) !== 0)
  5962. throw Error(y(285));
  5963. return a.flags = e & -4097 | 64,
  5964. a;
  5965. case 5:
  5966. return hh(a),
  5967. null;
  5968. case 13:
  5969. return H(P),
  5970. e = a.flags,
  5971. e & 4096 ? (a.flags = e & -4097 | 64,
  5972. a) : null;
  5973. case 19:
  5974. return H(P),
  5975. null;
  5976. case 4:
  5977. return fh(),
  5978. null;
  5979. case 10:
  5980. return rg(a),
  5981. null;
  5982. case 23:
  5983. case 24:
  5984. return Ki(),
  5985. null;
  5986. default:
  5987. return null
  5988. }
  5989. }
  5990. function Mi(a, e) {
  5991. try {
  5992. var i = ""
  5993. , o = e;
  5994. do
  5995. i += Qa(o),
  5996. o = o.return;
  5997. while (o);
  5998. var s = i
  5999. } catch (c) {
  6000. s = `
  6001. Error generating stack: ` + c.message + `
  6002. ` + c.stack
  6003. }
  6004. return {
  6005. value: a,
  6006. source: e,
  6007. stack: s
  6008. }
  6009. }
  6010. function Ni(a, e) {
  6011. try {
  6012. console.error(e.value)
  6013. } catch (i) {
  6014. setTimeout(function() {
  6015. throw i
  6016. })
  6017. }
  6018. }
  6019. var Oi = typeof WeakMap == "function" ? WeakMap : Map;
  6020. function Pi(a, e, i) {
  6021. i = zg(-1, i),
  6022. i.tag = 3,
  6023. i.payload = {
  6024. element: null
  6025. };
  6026. var o = e.value;
  6027. return i.callback = function() {
  6028. Qi || (Qi = !0,
  6029. Ri = o),
  6030. Ni(a, e)
  6031. }
  6032. ,
  6033. i
  6034. }
  6035. function Si(a, e, i) {
  6036. i = zg(-1, i),
  6037. i.tag = 3;
  6038. var o = a.type.getDerivedStateFromError;
  6039. if (typeof o == "function") {
  6040. var s = e.value;
  6041. i.payload = function() {
  6042. return Ni(a, e),
  6043. o(s)
  6044. }
  6045. }
  6046. var c = a.stateNode;
  6047. return c !== null && typeof c.componentDidCatch == "function" && (i.callback = function() {
  6048. typeof o != "function" && (Ti === null ? Ti = new Set([this]) : Ti.add(this),
  6049. Ni(a, e));
  6050. var d = e.stack;
  6051. this.componentDidCatch(e.value, {
  6052. componentStack: d !== null ? d : ""
  6053. })
  6054. }
  6055. ),
  6056. i
  6057. }
  6058. var Ui = typeof WeakSet == "function" ? WeakSet : Set;
  6059. function Vi(a) {
  6060. var e = a.ref;
  6061. if (e !== null)
  6062. if (typeof e == "function")
  6063. try {
  6064. e(null)
  6065. } catch (i) {
  6066. Wi(a, i)
  6067. }
  6068. else
  6069. e.current = null
  6070. }
  6071. function Xi(a, e) {
  6072. switch (e.tag) {
  6073. case 0:
  6074. case 11:
  6075. case 15:
  6076. case 22:
  6077. return;
  6078. case 1:
  6079. if (e.flags & 256 && a !== null) {
  6080. var i = a.memoizedProps
  6081. , o = a.memoizedState;
  6082. a = e.stateNode,
  6083. e = a.getSnapshotBeforeUpdate(e.elementType === e.type ? i : lg(e.type, i), o),
  6084. a.__reactInternalSnapshotBeforeUpdate = e
  6085. }
  6086. return;
  6087. case 3:
  6088. e.flags & 256 && qf(e.stateNode.containerInfo);
  6089. return;
  6090. case 5:
  6091. case 6:
  6092. case 4:
  6093. case 17:
  6094. return
  6095. }
  6096. throw Error(y(163))
  6097. }
  6098. function Yi(a, e, i) {
  6099. switch (i.tag) {
  6100. case 0:
  6101. case 11:
  6102. case 15:
  6103. case 22:
  6104. if (e = i.updateQueue,
  6105. e = e !== null ? e.lastEffect : null,
  6106. e !== null) {
  6107. a = e = e.next;
  6108. do {
  6109. if ((a.tag & 3) === 3) {
  6110. var o = a.create;
  6111. a.destroy = o()
  6112. }
  6113. a = a.next
  6114. } while (a !== e)
  6115. }
  6116. if (e = i.updateQueue,
  6117. e = e !== null ? e.lastEffect : null,
  6118. e !== null) {
  6119. a = e = e.next;
  6120. do {
  6121. var s = a;
  6122. o = s.next,
  6123. s = s.tag,
  6124. (s & 4) !== 0 && (s & 1) !== 0 && (Zi(i, a),
  6125. $i(i, a)),
  6126. a = o
  6127. } while (a !== e)
  6128. }
  6129. return;
  6130. case 1:
  6131. a = i.stateNode,
  6132. i.flags & 4 && (e === null ? a.componentDidMount() : (o = i.elementType === i.type ? e.memoizedProps : lg(i.type, e.memoizedProps),
  6133. a.componentDidUpdate(o, e.memoizedState, a.__reactInternalSnapshotBeforeUpdate))),
  6134. e = i.updateQueue,
  6135. e !== null && Eg(i, e, a);
  6136. return;
  6137. case 3:
  6138. if (e = i.updateQueue,
  6139. e !== null) {
  6140. if (a = null,
  6141. i.child !== null)
  6142. switch (i.child.tag) {
  6143. case 5:
  6144. a = i.child.stateNode;
  6145. break;
  6146. case 1:
  6147. a = i.child.stateNode
  6148. }
  6149. Eg(i, e, a)
  6150. }
  6151. return;
  6152. case 5:
  6153. a = i.stateNode,
  6154. e === null && i.flags & 4 && mf(i.type, i.memoizedProps) && a.focus();
  6155. return;
  6156. case 6:
  6157. return;
  6158. case 4:
  6159. return;
  6160. case 12:
  6161. return;
  6162. case 13:
  6163. i.memoizedState === null && (i = i.alternate,
  6164. i !== null && (i = i.memoizedState,
  6165. i !== null && (i = i.dehydrated,
  6166. i !== null && Cc(i))));
  6167. return;
  6168. case 19:
  6169. case 17:
  6170. case 20:
  6171. case 21:
  6172. case 23:
  6173. case 24:
  6174. return
  6175. }
  6176. throw Error(y(163))
  6177. }
  6178. function aj(a, e) {
  6179. for (var i = a; ; ) {
  6180. if (i.tag === 5) {
  6181. var o = i.stateNode;
  6182. if (e)
  6183. o = o.style,
  6184. typeof o.setProperty == "function" ? o.setProperty("display", "none", "important") : o.display = "none";
  6185. else {
  6186. o = i.stateNode;
  6187. var s = i.memoizedProps.style;
  6188. s = s != null && s.hasOwnProperty("display") ? s.display : null,
  6189. o.style.display = sb("display", s)
  6190. }
  6191. } else if (i.tag === 6)
  6192. i.stateNode.nodeValue = e ? "" : i.memoizedProps;
  6193. else if ((i.tag !== 23 && i.tag !== 24 || i.memoizedState === null || i === a) && i.child !== null) {
  6194. i.child.return = i,
  6195. i = i.child;
  6196. continue
  6197. }
  6198. if (i === a)
  6199. break;
  6200. for (; i.sibling === null; ) {
  6201. if (i.return === null || i.return === a)
  6202. return;
  6203. i = i.return
  6204. }
  6205. i.sibling.return = i.return,
  6206. i = i.sibling
  6207. }
  6208. }
  6209. function bj(a, e) {
  6210. if (Mf && typeof Mf.onCommitFiberUnmount == "function")
  6211. try {
  6212. Mf.onCommitFiberUnmount(Lf, e)
  6213. } catch {}
  6214. switch (e.tag) {
  6215. case 0:
  6216. case 11:
  6217. case 14:
  6218. case 15:
  6219. case 22:
  6220. if (a = e.updateQueue,
  6221. a !== null && (a = a.lastEffect,
  6222. a !== null)) {
  6223. var i = a = a.next;
  6224. do {
  6225. var o = i
  6226. , s = o.destroy;
  6227. if (o = o.tag,
  6228. s !== void 0)
  6229. if ((o & 4) !== 0)
  6230. Zi(e, i);
  6231. else {
  6232. o = e;
  6233. try {
  6234. s()
  6235. } catch (c) {
  6236. Wi(o, c)
  6237. }
  6238. }
  6239. i = i.next
  6240. } while (i !== a)
  6241. }
  6242. break;
  6243. case 1:
  6244. if (Vi(e),
  6245. a = e.stateNode,
  6246. typeof a.componentWillUnmount == "function")
  6247. try {
  6248. a.props = e.memoizedProps,
  6249. a.state = e.memoizedState,
  6250. a.componentWillUnmount()
  6251. } catch (c) {
  6252. Wi(e, c)
  6253. }
  6254. break;
  6255. case 5:
  6256. Vi(e);
  6257. break;
  6258. case 4:
  6259. cj(a, e)
  6260. }
  6261. }
  6262. function dj(a) {
  6263. a.alternate = null,
  6264. a.child = null,
  6265. a.dependencies = null,
  6266. a.firstEffect = null,
  6267. a.lastEffect = null,
  6268. a.memoizedProps = null,
  6269. a.memoizedState = null,
  6270. a.pendingProps = null,
  6271. a.return = null,
  6272. a.updateQueue = null
  6273. }
  6274. function ej(a) {
  6275. return a.tag === 5 || a.tag === 3 || a.tag === 4
  6276. }
  6277. function fj(a) {
  6278. e: {
  6279. for (var e = a.return; e !== null; ) {
  6280. if (ej(e))
  6281. break e;
  6282. e = e.return
  6283. }
  6284. throw Error(y(160))
  6285. }
  6286. var i = e;
  6287. switch (e = i.stateNode,
  6288. i.tag) {
  6289. case 5:
  6290. var o = !1;
  6291. break;
  6292. case 3:
  6293. e = e.containerInfo,
  6294. o = !0;
  6295. break;
  6296. case 4:
  6297. e = e.containerInfo,
  6298. o = !0;
  6299. break;
  6300. default:
  6301. throw Error(y(161))
  6302. }
  6303. i.flags & 16 && (pb(e, ""),
  6304. i.flags &= -17);
  6305. e: t: for (i = a; ; ) {
  6306. for (; i.sibling === null; ) {
  6307. if (i.return === null || ej(i.return)) {
  6308. i = null;
  6309. break e
  6310. }
  6311. i = i.return
  6312. }
  6313. for (i.sibling.return = i.return,
  6314. i = i.sibling; i.tag !== 5 && i.tag !== 6 && i.tag !== 18; ) {
  6315. if (i.flags & 2 || i.child === null || i.tag === 4)
  6316. continue t;
  6317. i.child.return = i,
  6318. i = i.child
  6319. }
  6320. if (!(i.flags & 2)) {
  6321. i = i.stateNode;
  6322. break e
  6323. }
  6324. }
  6325. o ? gj(a, i, e) : hj(a, i, e)
  6326. }
  6327. function gj(a, e, i) {
  6328. var o = a.tag
  6329. , s = o === 5 || o === 6;
  6330. if (s)
  6331. a = s ? a.stateNode : a.stateNode.instance,
  6332. e ? i.nodeType === 8 ? i.parentNode.insertBefore(a, e) : i.insertBefore(a, e) : (i.nodeType === 8 ? (e = i.parentNode,
  6333. e.insertBefore(a, i)) : (e = i,
  6334. e.appendChild(a)),
  6335. i = i._reactRootContainer,
  6336. i != null || e.onclick !== null || (e.onclick = jf));
  6337. else if (o !== 4 && (a = a.child,
  6338. a !== null))
  6339. for (gj(a, e, i),
  6340. a = a.sibling; a !== null; )
  6341. gj(a, e, i),
  6342. a = a.sibling
  6343. }
  6344. function hj(a, e, i) {
  6345. var o = a.tag
  6346. , s = o === 5 || o === 6;
  6347. if (s)
  6348. a = s ? a.stateNode : a.stateNode.instance,
  6349. e ? i.insertBefore(a, e) : i.appendChild(a);
  6350. else if (o !== 4 && (a = a.child,
  6351. a !== null))
  6352. for (hj(a, e, i),
  6353. a = a.sibling; a !== null; )
  6354. hj(a, e, i),
  6355. a = a.sibling
  6356. }
  6357. function cj(a, e) {
  6358. for (var i = e, o = !1, s, c; ; ) {
  6359. if (!o) {
  6360. o = i.return;
  6361. e: for (; ; ) {
  6362. if (o === null)
  6363. throw Error(y(160));
  6364. switch (s = o.stateNode,
  6365. o.tag) {
  6366. case 5:
  6367. c = !1;
  6368. break e;
  6369. case 3:
  6370. s = s.containerInfo,
  6371. c = !0;
  6372. break e;
  6373. case 4:
  6374. s = s.containerInfo,
  6375. c = !0;
  6376. break e
  6377. }
  6378. o = o.return
  6379. }
  6380. o = !0
  6381. }
  6382. if (i.tag === 5 || i.tag === 6) {
  6383. e: for (var d = a, _ = i, b = _; ; )
  6384. if (bj(d, b),
  6385. b.child !== null && b.tag !== 4)
  6386. b.child.return = b,
  6387. b = b.child;
  6388. else {
  6389. if (b === _)
  6390. break e;
  6391. for (; b.sibling === null; ) {
  6392. if (b.return === null || b.return === _)
  6393. break e;
  6394. b = b.return
  6395. }
  6396. b.sibling.return = b.return,
  6397. b = b.sibling
  6398. }
  6399. c ? (d = s,
  6400. _ = i.stateNode,
  6401. d.nodeType === 8 ? d.parentNode.removeChild(_) : d.removeChild(_)) : s.removeChild(i.stateNode)
  6402. } else if (i.tag === 4) {
  6403. if (i.child !== null) {
  6404. s = i.stateNode.containerInfo,
  6405. c = !0,
  6406. i.child.return = i,
  6407. i = i.child;
  6408. continue
  6409. }
  6410. } else if (bj(a, i),
  6411. i.child !== null) {
  6412. i.child.return = i,
  6413. i = i.child;
  6414. continue
  6415. }
  6416. if (i === e)
  6417. break;
  6418. for (; i.sibling === null; ) {
  6419. if (i.return === null || i.return === e)
  6420. return;
  6421. i = i.return,
  6422. i.tag === 4 && (o = !1)
  6423. }
  6424. i.sibling.return = i.return,
  6425. i = i.sibling
  6426. }
  6427. }
  6428. function ij(a, e) {
  6429. switch (e.tag) {
  6430. case 0:
  6431. case 11:
  6432. case 14:
  6433. case 15:
  6434. case 22:
  6435. var i = e.updateQueue;
  6436. if (i = i !== null ? i.lastEffect : null,
  6437. i !== null) {
  6438. var o = i = i.next;
  6439. do
  6440. (o.tag & 3) === 3 && (a = o.destroy,
  6441. o.destroy = void 0,
  6442. a !== void 0 && a()),
  6443. o = o.next;
  6444. while (o !== i)
  6445. }
  6446. return;
  6447. case 1:
  6448. return;
  6449. case 5:
  6450. if (i = e.stateNode,
  6451. i != null) {
  6452. o = e.memoizedProps;
  6453. var s = a !== null ? a.memoizedProps : o;
  6454. a = e.type;
  6455. var c = e.updateQueue;
  6456. if (e.updateQueue = null,
  6457. c !== null) {
  6458. for (i[xf] = o,
  6459. a === "input" && o.type === "radio" && o.name != null && $a(i, o),
  6460. wb(a, s),
  6461. e = wb(a, o),
  6462. s = 0; s < c.length; s += 2) {
  6463. var d = c[s]
  6464. , _ = c[s + 1];
  6465. d === "style" ? tb(i, _) : d === "dangerouslySetInnerHTML" ? ob(i, _) : d === "children" ? pb(i, _) : qa(i, d, _, e)
  6466. }
  6467. switch (a) {
  6468. case "input":
  6469. ab(i, o);
  6470. break;
  6471. case "textarea":
  6472. ib(i, o);
  6473. break;
  6474. case "select":
  6475. a = i._wrapperState.wasMultiple,
  6476. i._wrapperState.wasMultiple = !!o.multiple,
  6477. c = o.value,
  6478. c != null ? fb(i, !!o.multiple, c, !1) : a !== !!o.multiple && (o.defaultValue != null ? fb(i, !!o.multiple, o.defaultValue, !0) : fb(i, !!o.multiple, o.multiple ? [] : "", !1))
  6479. }
  6480. }
  6481. }
  6482. return;
  6483. case 6:
  6484. if (e.stateNode === null)
  6485. throw Error(y(162));
  6486. e.stateNode.nodeValue = e.memoizedProps;
  6487. return;
  6488. case 3:
  6489. i = e.stateNode,
  6490. i.hydrate && (i.hydrate = !1,
  6491. Cc(i.containerInfo));
  6492. return;
  6493. case 12:
  6494. return;
  6495. case 13:
  6496. e.memoizedState !== null && (jj = O(),
  6497. aj(e.child, !0)),
  6498. kj(e);
  6499. return;
  6500. case 19:
  6501. kj(e);
  6502. return;
  6503. case 17:
  6504. return;
  6505. case 23:
  6506. case 24:
  6507. aj(e, e.memoizedState !== null);
  6508. return
  6509. }
  6510. throw Error(y(163))
  6511. }
  6512. function kj(a) {
  6513. var e = a.updateQueue;
  6514. if (e !== null) {
  6515. a.updateQueue = null;
  6516. var i = a.stateNode;
  6517. i === null && (i = a.stateNode = new Ui),
  6518. e.forEach(function(o) {
  6519. var s = lj.bind(null, a, o);
  6520. i.has(o) || (i.add(o),
  6521. o.then(s, s))
  6522. })
  6523. }
  6524. }
  6525. function mj(a, e) {
  6526. return a !== null && (a = a.memoizedState,
  6527. a === null || a.dehydrated !== null) ? (e = e.memoizedState,
  6528. e !== null && e.dehydrated === null) : !1
  6529. }
  6530. var nj = Math.ceil
  6531. , oj = ra.ReactCurrentDispatcher
  6532. , pj = ra.ReactCurrentOwner
  6533. , X = 0
  6534. , U = null
  6535. , Y = null
  6536. , W = 0
  6537. , qj = 0
  6538. , rj = Bf(0)
  6539. , V = 0
  6540. , sj = null
  6541. , tj = 0
  6542. , Dg = 0
  6543. , Hi = 0
  6544. , uj = 0
  6545. , vj = null
  6546. , jj = 0
  6547. , Ji = 1 / 0;
  6548. function wj() {
  6549. Ji = O() + 500
  6550. }
  6551. var Z = null
  6552. , Qi = !1
  6553. , Ri = null
  6554. , Ti = null
  6555. , xj = !1
  6556. , yj = null
  6557. , zj = 90
  6558. , Aj = []
  6559. , Bj = []
  6560. , Cj = null
  6561. , Dj = 0
  6562. , Ej = null
  6563. , Fj = -1
  6564. , Gj = 0
  6565. , Hj = 0
  6566. , Ij = null
  6567. , Jj = !1;
  6568. function Hg() {
  6569. return (X & 48) !== 0 ? O() : Fj !== -1 ? Fj : Fj = O()
  6570. }
  6571. function Ig(a) {
  6572. if (a = a.mode,
  6573. (a & 2) === 0)
  6574. return 1;
  6575. if ((a & 4) === 0)
  6576. return eg() === 99 ? 1 : 2;
  6577. if (Gj === 0 && (Gj = tj),
  6578. kg.transition !== 0) {
  6579. Hj !== 0 && (Hj = vj !== null ? vj.pendingLanes : 0),
  6580. a = Gj;
  6581. var e = 4186112 & ~Hj;
  6582. return e &= -e,
  6583. e === 0 && (a = 4186112 & ~a,
  6584. e = a & -a,
  6585. e === 0 && (e = 8192)),
  6586. e
  6587. }
  6588. return a = eg(),
  6589. (X & 4) !== 0 && a === 98 ? a = Xc(12, Gj) : (a = Sc(a),
  6590. a = Xc(a, Gj)),
  6591. a
  6592. }
  6593. function Jg(a, e, i) {
  6594. if (50 < Dj)
  6595. throw Dj = 0,
  6596. Ej = null,
  6597. Error(y(185));
  6598. if (a = Kj(a, e),
  6599. a === null)
  6600. return null;
  6601. $c(a, e, i),
  6602. a === U && (Hi |= e,
  6603. V === 4 && Ii(a, W));
  6604. var o = eg();
  6605. e === 1 ? (X & 8) !== 0 && (X & 48) === 0 ? Lj(a) : (Mj(a, i),
  6606. X === 0 && (wj(),
  6607. ig())) : ((X & 4) === 0 || o !== 98 && o !== 99 || (Cj === null ? Cj = new Set([a]) : Cj.add(a)),
  6608. Mj(a, i)),
  6609. vj = a
  6610. }
  6611. function Kj(a, e) {
  6612. a.lanes |= e;
  6613. var i = a.alternate;
  6614. for (i !== null && (i.lanes |= e),
  6615. i = a,
  6616. a = a.return; a !== null; )
  6617. a.childLanes |= e,
  6618. i = a.alternate,
  6619. i !== null && (i.childLanes |= e),
  6620. i = a,
  6621. a = a.return;
  6622. return i.tag === 3 ? i.stateNode : null
  6623. }
  6624. function Mj(a, e) {
  6625. for (var i = a.callbackNode, o = a.suspendedLanes, s = a.pingedLanes, c = a.expirationTimes, d = a.pendingLanes; 0 < d; ) {
  6626. var _ = 31 - Vc(d)
  6627. , b = 1 << _
  6628. , k = c[_];
  6629. if (k === -1) {
  6630. if ((b & o) === 0 || (b & s) !== 0) {
  6631. k = e,
  6632. Rc(b);
  6633. var j = F;
  6634. c[_] = 10 <= j ? k + 250 : 6 <= j ? k + 5e3 : -1
  6635. }
  6636. } else
  6637. k <= e && (a.expiredLanes |= b);
  6638. d &= ~b
  6639. }
  6640. if (o = Uc(a, a === U ? W : 0),
  6641. e = F,
  6642. o === 0)
  6643. i !== null && (i !== Zf && Pf(i),
  6644. a.callbackNode = null,
  6645. a.callbackPriority = 0);
  6646. else {
  6647. if (i !== null) {
  6648. if (a.callbackPriority === e)
  6649. return;
  6650. i !== Zf && Pf(i)
  6651. }
  6652. e === 15 ? (i = Lj.bind(null, a),
  6653. ag === null ? (ag = [i],
  6654. bg = Of(Uf, jg)) : ag.push(i),
  6655. i = Zf) : e === 14 ? i = hg(99, Lj.bind(null, a)) : (i = Tc(e),
  6656. i = hg(i, Nj.bind(null, a))),
  6657. a.callbackPriority = e,
  6658. a.callbackNode = i
  6659. }
  6660. }
  6661. function Nj(a) {
  6662. if (Fj = -1,
  6663. Hj = Gj = 0,
  6664. (X & 48) !== 0)
  6665. throw Error(y(327));
  6666. var e = a.callbackNode;
  6667. if (Oj() && a.callbackNode !== e)
  6668. return null;
  6669. var i = Uc(a, a === U ? W : 0);
  6670. if (i === 0)
  6671. return null;
  6672. var o = i
  6673. , s = X;
  6674. X |= 16;
  6675. var c = Pj();
  6676. (U !== a || W !== o) && (wj(),
  6677. Qj(a, o));
  6678. do
  6679. try {
  6680. Rj();
  6681. break
  6682. } catch (_) {
  6683. Sj(a, _)
  6684. }
  6685. while (1);
  6686. if (qg(),
  6687. oj.current = c,
  6688. X = s,
  6689. Y !== null ? o = 0 : (U = null,
  6690. W = 0,
  6691. o = V),
  6692. (tj & Hi) !== 0)
  6693. Qj(a, 0);
  6694. else if (o !== 0) {
  6695. if (o === 2 && (X |= 64,
  6696. a.hydrate && (a.hydrate = !1,
  6697. qf(a.containerInfo)),
  6698. i = Wc(a),
  6699. i !== 0 && (o = Tj(a, i))),
  6700. o === 1)
  6701. throw e = sj,
  6702. Qj(a, 0),
  6703. Ii(a, i),
  6704. Mj(a, O()),
  6705. e;
  6706. switch (a.finishedWork = a.current.alternate,
  6707. a.finishedLanes = i,
  6708. o) {
  6709. case 0:
  6710. case 1:
  6711. throw Error(y(345));
  6712. case 2:
  6713. Uj(a);
  6714. break;
  6715. case 3:
  6716. if (Ii(a, i),
  6717. (i & 62914560) === i && (o = jj + 500 - O(),
  6718. 10 < o)) {
  6719. if (Uc(a, 0) !== 0)
  6720. break;
  6721. if (s = a.suspendedLanes,
  6722. (s & i) !== i) {
  6723. Hg(),
  6724. a.pingedLanes |= a.suspendedLanes & s;
  6725. break
  6726. }
  6727. a.timeoutHandle = of(Uj.bind(null, a), o);
  6728. break
  6729. }
  6730. Uj(a);
  6731. break;
  6732. case 4:
  6733. if (Ii(a, i),
  6734. (i & 4186112) === i)
  6735. break;
  6736. for (o = a.eventTimes,
  6737. s = -1; 0 < i; ) {
  6738. var d = 31 - Vc(i);
  6739. c = 1 << d,
  6740. d = o[d],
  6741. d > s && (s = d),
  6742. i &= ~c
  6743. }
  6744. if (i = s,
  6745. i = O() - i,
  6746. i = (120 > i ? 120 : 480 > i ? 480 : 1080 > i ? 1080 : 1920 > i ? 1920 : 3e3 > i ? 3e3 : 4320 > i ? 4320 : 1960 * nj(i / 1960)) - i,
  6747. 10 < i) {
  6748. a.timeoutHandle = of(Uj.bind(null, a), i);
  6749. break
  6750. }
  6751. Uj(a);
  6752. break;
  6753. case 5:
  6754. Uj(a);
  6755. break;
  6756. default:
  6757. throw Error(y(329))
  6758. }
  6759. }
  6760. return Mj(a, O()),
  6761. a.callbackNode === e ? Nj.bind(null, a) : null
  6762. }
  6763. function Ii(a, e) {
  6764. for (e &= ~uj,
  6765. e &= ~Hi,
  6766. a.suspendedLanes |= e,
  6767. a.pingedLanes &= ~e,
  6768. a = a.expirationTimes; 0 < e; ) {
  6769. var i = 31 - Vc(e)
  6770. , o = 1 << i;
  6771. a[i] = -1,
  6772. e &= ~o
  6773. }
  6774. }
  6775. function Lj(a) {
  6776. if ((X & 48) !== 0)
  6777. throw Error(y(327));
  6778. if (Oj(),
  6779. a === U && (a.expiredLanes & W) !== 0) {
  6780. var e = W
  6781. , i = Tj(a, e);
  6782. (tj & Hi) !== 0 && (e = Uc(a, e),
  6783. i = Tj(a, e))
  6784. } else
  6785. e = Uc(a, 0),
  6786. i = Tj(a, e);
  6787. if (a.tag !== 0 && i === 2 && (X |= 64,
  6788. a.hydrate && (a.hydrate = !1,
  6789. qf(a.containerInfo)),
  6790. e = Wc(a),
  6791. e !== 0 && (i = Tj(a, e))),
  6792. i === 1)
  6793. throw i = sj,
  6794. Qj(a, 0),
  6795. Ii(a, e),
  6796. Mj(a, O()),
  6797. i;
  6798. return a.finishedWork = a.current.alternate,
  6799. a.finishedLanes = e,
  6800. Uj(a),
  6801. Mj(a, O()),
  6802. null
  6803. }
  6804. function Vj() {
  6805. if (Cj !== null) {
  6806. var a = Cj;
  6807. Cj = null,
  6808. a.forEach(function(e) {
  6809. e.expiredLanes |= 24 & e.pendingLanes,
  6810. Mj(e, O())
  6811. })
  6812. }
  6813. ig()
  6814. }
  6815. function Wj(a, e) {
  6816. var i = X;
  6817. X |= 1;
  6818. try {
  6819. return a(e)
  6820. } finally {
  6821. X = i,
  6822. X === 0 && (wj(),
  6823. ig())
  6824. }
  6825. }
  6826. function Xj(a, e) {
  6827. var i = X;
  6828. X &= -2,
  6829. X |= 8;
  6830. try {
  6831. return a(e)
  6832. } finally {
  6833. X = i,
  6834. X === 0 && (wj(),
  6835. ig())
  6836. }
  6837. }
  6838. function ni(a, e) {
  6839. I(rj, qj),
  6840. qj |= e,
  6841. tj |= e
  6842. }
  6843. function Ki() {
  6844. qj = rj.current,
  6845. H(rj)
  6846. }
  6847. function Qj(a, e) {
  6848. a.finishedWork = null,
  6849. a.finishedLanes = 0;
  6850. var i = a.timeoutHandle;
  6851. if (i !== -1 && (a.timeoutHandle = -1,
  6852. pf(i)),
  6853. Y !== null)
  6854. for (i = Y.return; i !== null; ) {
  6855. var o = i;
  6856. switch (o.tag) {
  6857. case 1:
  6858. o = o.type.childContextTypes,
  6859. o != null && Gf();
  6860. break;
  6861. case 3:
  6862. fh(),
  6863. H(N),
  6864. H(M),
  6865. uh();
  6866. break;
  6867. case 5:
  6868. hh(o);
  6869. break;
  6870. case 4:
  6871. fh();
  6872. break;
  6873. case 13:
  6874. H(P);
  6875. break;
  6876. case 19:
  6877. H(P);
  6878. break;
  6879. case 10:
  6880. rg(o);
  6881. break;
  6882. case 23:
  6883. case 24:
  6884. Ki()
  6885. }
  6886. i = i.return
  6887. }
  6888. U = a,
  6889. Y = Tg(a.current, null),
  6890. W = qj = tj = e,
  6891. V = 0,
  6892. sj = null,
  6893. uj = Hi = Dg = 0
  6894. }
  6895. function Sj(a, e) {
  6896. do {
  6897. var i = Y;
  6898. try {
  6899. if (qg(),
  6900. vh.current = Gh,
  6901. yh) {
  6902. for (var o = R.memoizedState; o !== null; ) {
  6903. var s = o.queue;
  6904. s !== null && (s.pending = null),
  6905. o = o.next
  6906. }
  6907. yh = !1
  6908. }
  6909. if (xh = 0,
  6910. T = S = R = null,
  6911. zh = !1,
  6912. pj.current = null,
  6913. i === null || i.return === null) {
  6914. V = 1,
  6915. sj = e,
  6916. Y = null;
  6917. break
  6918. }
  6919. e: {
  6920. var c = a
  6921. , d = i.return
  6922. , _ = i
  6923. , b = e;
  6924. if (e = W,
  6925. _.flags |= 2048,
  6926. _.firstEffect = _.lastEffect = null,
  6927. b !== null && typeof b == "object" && typeof b.then == "function") {
  6928. var k = b;
  6929. if ((_.mode & 2) === 0) {
  6930. var j = _.alternate;
  6931. j ? (_.updateQueue = j.updateQueue,
  6932. _.memoizedState = j.memoizedState,
  6933. _.lanes = j.lanes) : (_.updateQueue = null,
  6934. _.memoizedState = null)
  6935. }
  6936. var $ = (P.current & 1) !== 0
  6937. , _e = d;
  6938. do {
  6939. var et;
  6940. if (et = _e.tag === 13) {
  6941. var tt = _e.memoizedState;
  6942. if (tt !== null)
  6943. et = tt.dehydrated !== null;
  6944. else {
  6945. var rt = _e.memoizedProps;
  6946. et = rt.fallback === void 0 ? !1 : rt.unstable_avoidThisFallback !== !0 ? !0 : !$
  6947. }
  6948. }
  6949. if (et) {
  6950. var it = _e.updateQueue;
  6951. if (it === null) {
  6952. var nt = new Set;
  6953. nt.add(k),
  6954. _e.updateQueue = nt
  6955. } else
  6956. it.add(k);
  6957. if ((_e.mode & 2) === 0) {
  6958. if (_e.flags |= 64,
  6959. _.flags |= 16384,
  6960. _.flags &= -2981,
  6961. _.tag === 1)
  6962. if (_.alternate === null)
  6963. _.tag = 17;
  6964. else {
  6965. var ot = zg(-1, 1);
  6966. ot.tag = 2,
  6967. Ag(_, ot)
  6968. }
  6969. _.lanes |= 1;
  6970. break e
  6971. }
  6972. b = void 0,
  6973. _ = e;
  6974. var at = c.pingCache;
  6975. if (at === null ? (at = c.pingCache = new Oi,
  6976. b = new Set,
  6977. at.set(k, b)) : (b = at.get(k),
  6978. b === void 0 && (b = new Set,
  6979. at.set(k, b))),
  6980. !b.has(_)) {
  6981. b.add(_);
  6982. var st = Yj.bind(null, c, k, _);
  6983. k.then(st, st)
  6984. }
  6985. _e.flags |= 4096,
  6986. _e.lanes = e;
  6987. break e
  6988. }
  6989. _e = _e.return
  6990. } while (_e !== null);
  6991. b = Error((Ra(_.type) || "A React component") + ` suspended while rendering, but no fallback UI was specified.
  6992. Add a <Suspense fallback=...> component higher in the tree to provide a loading indicator or placeholder to display.`)
  6993. }
  6994. V !== 5 && (V = 2),
  6995. b = Mi(b, _),
  6996. _e = d;
  6997. do {
  6998. switch (_e.tag) {
  6999. case 3:
  7000. c = b,
  7001. _e.flags |= 4096,
  7002. e &= -e,
  7003. _e.lanes |= e;
  7004. var ut = Pi(_e, c, e);
  7005. Bg(_e, ut);
  7006. break e;
  7007. case 1:
  7008. c = b;
  7009. var ct = _e.type
  7010. , lt = _e.stateNode;
  7011. if ((_e.flags & 64) === 0 && (typeof ct.getDerivedStateFromError == "function" || lt !== null && typeof lt.componentDidCatch == "function" && (Ti === null || !Ti.has(lt)))) {
  7012. _e.flags |= 4096,
  7013. e &= -e,
  7014. _e.lanes |= e;
  7015. var ft = Si(_e, c, e);
  7016. Bg(_e, ft);
  7017. break e
  7018. }
  7019. }
  7020. _e = _e.return
  7021. } while (_e !== null)
  7022. }
  7023. Zj(i)
  7024. } catch (ht) {
  7025. e = ht,
  7026. Y === i && i !== null && (Y = i = i.return);
  7027. continue
  7028. }
  7029. break
  7030. } while (1)
  7031. }
  7032. function Pj() {
  7033. var a = oj.current;
  7034. return oj.current = Gh,
  7035. a === null ? Gh : a
  7036. }
  7037. function Tj(a, e) {
  7038. var i = X;
  7039. X |= 16;
  7040. var o = Pj();
  7041. U === a && W === e || Qj(a, e);
  7042. do
  7043. try {
  7044. ak();
  7045. break
  7046. } catch (s) {
  7047. Sj(a, s)
  7048. }
  7049. while (1);
  7050. if (qg(),
  7051. X = i,
  7052. oj.current = o,
  7053. Y !== null)
  7054. throw Error(y(261));
  7055. return U = null,
  7056. W = 0,
  7057. V
  7058. }
  7059. function ak() {
  7060. for (; Y !== null; )
  7061. bk(Y)
  7062. }
  7063. function Rj() {
  7064. for (; Y !== null && !Qf(); )
  7065. bk(Y)
  7066. }
  7067. function bk(a) {
  7068. var e = ck(a.alternate, a, qj);
  7069. a.memoizedProps = a.pendingProps,
  7070. e === null ? Zj(a) : Y = e,
  7071. pj.current = null
  7072. }
  7073. function Zj(a) {
  7074. var e = a;
  7075. do {
  7076. var i = e.alternate;
  7077. if (a = e.return,
  7078. (e.flags & 2048) === 0) {
  7079. if (i = Gi(i, e, qj),
  7080. i !== null) {
  7081. Y = i;
  7082. return
  7083. }
  7084. if (i = e,
  7085. i.tag !== 24 && i.tag !== 23 || i.memoizedState === null || (qj & 1073741824) !== 0 || (i.mode & 4) === 0) {
  7086. for (var o = 0, s = i.child; s !== null; )
  7087. o |= s.lanes | s.childLanes,
  7088. s = s.sibling;
  7089. i.childLanes = o
  7090. }
  7091. a !== null && (a.flags & 2048) === 0 && (a.firstEffect === null && (a.firstEffect = e.firstEffect),
  7092. e.lastEffect !== null && (a.lastEffect !== null && (a.lastEffect.nextEffect = e.firstEffect),
  7093. a.lastEffect = e.lastEffect),
  7094. 1 < e.flags && (a.lastEffect !== null ? a.lastEffect.nextEffect = e : a.firstEffect = e,
  7095. a.lastEffect = e))
  7096. } else {
  7097. if (i = Li(e),
  7098. i !== null) {
  7099. i.flags &= 2047,
  7100. Y = i;
  7101. return
  7102. }
  7103. a !== null && (a.firstEffect = a.lastEffect = null,
  7104. a.flags |= 2048)
  7105. }
  7106. if (e = e.sibling,
  7107. e !== null) {
  7108. Y = e;
  7109. return
  7110. }
  7111. Y = e = a
  7112. } while (e !== null);
  7113. V === 0 && (V = 5)
  7114. }
  7115. function Uj(a) {
  7116. var e = eg();
  7117. return gg(99, dk.bind(null, a, e)),
  7118. null
  7119. }
  7120. function dk(a, e) {
  7121. do
  7122. Oj();
  7123. while (yj !== null);
  7124. if ((X & 48) !== 0)
  7125. throw Error(y(327));
  7126. var i = a.finishedWork;
  7127. if (i === null)
  7128. return null;
  7129. if (a.finishedWork = null,
  7130. a.finishedLanes = 0,
  7131. i === a.current)
  7132. throw Error(y(177));
  7133. a.callbackNode = null;
  7134. var o = i.lanes | i.childLanes
  7135. , s = o
  7136. , c = a.pendingLanes & ~s;
  7137. a.pendingLanes = s,
  7138. a.suspendedLanes = 0,
  7139. a.pingedLanes = 0,
  7140. a.expiredLanes &= s,
  7141. a.mutableReadLanes &= s,
  7142. a.entangledLanes &= s,
  7143. s = a.entanglements;
  7144. for (var d = a.eventTimes, _ = a.expirationTimes; 0 < c; ) {
  7145. var b = 31 - Vc(c)
  7146. , k = 1 << b;
  7147. s[b] = 0,
  7148. d[b] = -1,
  7149. _[b] = -1,
  7150. c &= ~k
  7151. }
  7152. if (Cj !== null && (o & 24) === 0 && Cj.has(a) && Cj.delete(a),
  7153. a === U && (Y = U = null,
  7154. W = 0),
  7155. 1 < i.flags ? i.lastEffect !== null ? (i.lastEffect.nextEffect = i,
  7156. o = i.firstEffect) : o = i : o = i.firstEffect,
  7157. o !== null) {
  7158. if (s = X,
  7159. X |= 32,
  7160. pj.current = null,
  7161. kf = fd,
  7162. d = Ne(),
  7163. Oe(d)) {
  7164. if ("selectionStart"in d)
  7165. _ = {
  7166. start: d.selectionStart,
  7167. end: d.selectionEnd
  7168. };
  7169. else
  7170. e: if (_ = (_ = d.ownerDocument) && _.defaultView || window,
  7171. (k = _.getSelection && _.getSelection()) && k.rangeCount !== 0) {
  7172. _ = k.anchorNode,
  7173. c = k.anchorOffset,
  7174. b = k.focusNode,
  7175. k = k.focusOffset;
  7176. try {
  7177. _.nodeType,
  7178. b.nodeType
  7179. } catch {
  7180. _ = null;
  7181. break e
  7182. }
  7183. var j = 0
  7184. , $ = -1
  7185. , _e = -1
  7186. , et = 0
  7187. , tt = 0
  7188. , rt = d
  7189. , it = null;
  7190. t: for (; ; ) {
  7191. for (var nt; rt !== _ || c !== 0 && rt.nodeType !== 3 || ($ = j + c),
  7192. rt !== b || k !== 0 && rt.nodeType !== 3 || (_e = j + k),
  7193. rt.nodeType === 3 && (j += rt.nodeValue.length),
  7194. (nt = rt.firstChild) !== null; )
  7195. it = rt,
  7196. rt = nt;
  7197. for (; ; ) {
  7198. if (rt === d)
  7199. break t;
  7200. if (it === _ && ++et === c && ($ = j),
  7201. it === b && ++tt === k && (_e = j),
  7202. (nt = rt.nextSibling) !== null)
  7203. break;
  7204. rt = it,
  7205. it = rt.parentNode
  7206. }
  7207. rt = nt
  7208. }
  7209. _ = $ === -1 || _e === -1 ? null : {
  7210. start: $,
  7211. end: _e
  7212. }
  7213. } else
  7214. _ = null;
  7215. _ = _ || {
  7216. start: 0,
  7217. end: 0
  7218. }
  7219. } else
  7220. _ = null;
  7221. lf = {
  7222. focusedElem: d,
  7223. selectionRange: _
  7224. },
  7225. fd = !1,
  7226. Ij = null,
  7227. Jj = !1,
  7228. Z = o;
  7229. do
  7230. try {
  7231. ek()
  7232. } catch (ht) {
  7233. if (Z === null)
  7234. throw Error(y(330));
  7235. Wi(Z, ht),
  7236. Z = Z.nextEffect
  7237. }
  7238. while (Z !== null);
  7239. Ij = null,
  7240. Z = o;
  7241. do
  7242. try {
  7243. for (d = a; Z !== null; ) {
  7244. var ot = Z.flags;
  7245. if (ot & 16 && pb(Z.stateNode, ""),
  7246. ot & 128) {
  7247. var at = Z.alternate;
  7248. if (at !== null) {
  7249. var st = at.ref;
  7250. st !== null && (typeof st == "function" ? st(null) : st.current = null)
  7251. }
  7252. }
  7253. switch (ot & 1038) {
  7254. case 2:
  7255. fj(Z),
  7256. Z.flags &= -3;
  7257. break;
  7258. case 6:
  7259. fj(Z),
  7260. Z.flags &= -3,
  7261. ij(Z.alternate, Z);
  7262. break;
  7263. case 1024:
  7264. Z.flags &= -1025;
  7265. break;
  7266. case 1028:
  7267. Z.flags &= -1025,
  7268. ij(Z.alternate, Z);
  7269. break;
  7270. case 4:
  7271. ij(Z.alternate, Z);
  7272. break;
  7273. case 8:
  7274. _ = Z,
  7275. cj(d, _);
  7276. var ut = _.alternate;
  7277. dj(_),
  7278. ut !== null && dj(ut)
  7279. }
  7280. Z = Z.nextEffect
  7281. }
  7282. } catch (ht) {
  7283. if (Z === null)
  7284. throw Error(y(330));
  7285. Wi(Z, ht),
  7286. Z = Z.nextEffect
  7287. }
  7288. while (Z !== null);
  7289. if (st = lf,
  7290. at = Ne(),
  7291. ot = st.focusedElem,
  7292. d = st.selectionRange,
  7293. at !== ot && ot && ot.ownerDocument && Me(ot.ownerDocument.documentElement, ot)) {
  7294. for (d !== null && Oe(ot) && (at = d.start,
  7295. st = d.end,
  7296. st === void 0 && (st = at),
  7297. "selectionStart"in ot ? (ot.selectionStart = at,
  7298. ot.selectionEnd = Math.min(st, ot.value.length)) : (st = (at = ot.ownerDocument || document) && at.defaultView || window,
  7299. st.getSelection && (st = st.getSelection(),
  7300. _ = ot.textContent.length,
  7301. ut = Math.min(d.start, _),
  7302. d = d.end === void 0 ? ut : Math.min(d.end, _),
  7303. !st.extend && ut > d && (_ = d,
  7304. d = ut,
  7305. ut = _),
  7306. _ = Le(ot, ut),
  7307. c = Le(ot, d),
  7308. _ && c && (st.rangeCount !== 1 || st.anchorNode !== _.node || st.anchorOffset !== _.offset || st.focusNode !== c.node || st.focusOffset !== c.offset) && (at = at.createRange(),
  7309. at.setStart(_.node, _.offset),
  7310. st.removeAllRanges(),
  7311. ut > d ? (st.addRange(at),
  7312. st.extend(c.node, c.offset)) : (at.setEnd(c.node, c.offset),
  7313. st.addRange(at)))))),
  7314. at = [],
  7315. st = ot; st = st.parentNode; )
  7316. st.nodeType === 1 && at.push({
  7317. element: st,
  7318. left: st.scrollLeft,
  7319. top: st.scrollTop
  7320. });
  7321. for (typeof ot.focus == "function" && ot.focus(),
  7322. ot = 0; ot < at.length; ot++)
  7323. st = at[ot],
  7324. st.element.scrollLeft = st.left,
  7325. st.element.scrollTop = st.top
  7326. }
  7327. fd = !!kf,
  7328. lf = kf = null,
  7329. a.current = i,
  7330. Z = o;
  7331. do
  7332. try {
  7333. for (ot = a; Z !== null; ) {
  7334. var ct = Z.flags;
  7335. if (ct & 36 && Yi(ot, Z.alternate, Z),
  7336. ct & 128) {
  7337. at = void 0;
  7338. var lt = Z.ref;
  7339. if (lt !== null) {
  7340. var ft = Z.stateNode;
  7341. switch (Z.tag) {
  7342. case 5:
  7343. at = ft;
  7344. break;
  7345. default:
  7346. at = ft
  7347. }
  7348. typeof lt == "function" ? lt(at) : lt.current = at
  7349. }
  7350. }
  7351. Z = Z.nextEffect
  7352. }
  7353. } catch (ht) {
  7354. if (Z === null)
  7355. throw Error(y(330));
  7356. Wi(Z, ht),
  7357. Z = Z.nextEffect
  7358. }
  7359. while (Z !== null);
  7360. Z = null,
  7361. $f(),
  7362. X = s
  7363. } else
  7364. a.current = i;
  7365. if (xj)
  7366. xj = !1,
  7367. yj = a,
  7368. zj = e;
  7369. else
  7370. for (Z = o; Z !== null; )
  7371. e = Z.nextEffect,
  7372. Z.nextEffect = null,
  7373. Z.flags & 8 && (ct = Z,
  7374. ct.sibling = null,
  7375. ct.stateNode = null),
  7376. Z = e;
  7377. if (o = a.pendingLanes,
  7378. o === 0 && (Ti = null),
  7379. o === 1 ? a === Ej ? Dj++ : (Dj = 0,
  7380. Ej = a) : Dj = 0,
  7381. i = i.stateNode,
  7382. Mf && typeof Mf.onCommitFiberRoot == "function")
  7383. try {
  7384. Mf.onCommitFiberRoot(Lf, i, void 0, (i.current.flags & 64) === 64)
  7385. } catch {}
  7386. if (Mj(a, O()),
  7387. Qi)
  7388. throw Qi = !1,
  7389. a = Ri,
  7390. Ri = null,
  7391. a;
  7392. return (X & 8) !== 0 || ig(),
  7393. null
  7394. }
  7395. function ek() {
  7396. for (; Z !== null; ) {
  7397. var a = Z.alternate;
  7398. Jj || Ij === null || ((Z.flags & 8) !== 0 ? dc(Z, Ij) && (Jj = !0) : Z.tag === 13 && mj(a, Z) && dc(Z, Ij) && (Jj = !0));
  7399. var e = Z.flags;
  7400. (e & 256) !== 0 && Xi(a, Z),
  7401. (e & 512) === 0 || xj || (xj = !0,
  7402. hg(97, function() {
  7403. return Oj(),
  7404. null
  7405. })),
  7406. Z = Z.nextEffect
  7407. }
  7408. }
  7409. function Oj() {
  7410. if (zj !== 90) {
  7411. var a = 97 < zj ? 97 : zj;
  7412. return zj = 90,
  7413. gg(a, fk)
  7414. }
  7415. return !1
  7416. }
  7417. function $i(a, e) {
  7418. Aj.push(e, a),
  7419. xj || (xj = !0,
  7420. hg(97, function() {
  7421. return Oj(),
  7422. null
  7423. }))
  7424. }
  7425. function Zi(a, e) {
  7426. Bj.push(e, a),
  7427. xj || (xj = !0,
  7428. hg(97, function() {
  7429. return Oj(),
  7430. null
  7431. }))
  7432. }
  7433. function fk() {
  7434. if (yj === null)
  7435. return !1;
  7436. var a = yj;
  7437. if (yj = null,
  7438. (X & 48) !== 0)
  7439. throw Error(y(331));
  7440. var e = X;
  7441. X |= 32;
  7442. var i = Bj;
  7443. Bj = [];
  7444. for (var o = 0; o < i.length; o += 2) {
  7445. var s = i[o]
  7446. , c = i[o + 1]
  7447. , d = s.destroy;
  7448. if (s.destroy = void 0,
  7449. typeof d == "function")
  7450. try {
  7451. d()
  7452. } catch (b) {
  7453. if (c === null)
  7454. throw Error(y(330));
  7455. Wi(c, b)
  7456. }
  7457. }
  7458. for (i = Aj,
  7459. Aj = [],
  7460. o = 0; o < i.length; o += 2) {
  7461. s = i[o],
  7462. c = i[o + 1];
  7463. try {
  7464. var _ = s.create;
  7465. s.destroy = _()
  7466. } catch (b) {
  7467. if (c === null)
  7468. throw Error(y(330));
  7469. Wi(c, b)
  7470. }
  7471. }
  7472. for (_ = a.current.firstEffect; _ !== null; )
  7473. a = _.nextEffect,
  7474. _.nextEffect = null,
  7475. _.flags & 8 && (_.sibling = null,
  7476. _.stateNode = null),
  7477. _ = a;
  7478. return X = e,
  7479. ig(),
  7480. !0
  7481. }
  7482. function gk(a, e, i) {
  7483. e = Mi(i, e),
  7484. e = Pi(a, e, 1),
  7485. Ag(a, e),
  7486. e = Hg(),
  7487. a = Kj(a, 1),
  7488. a !== null && ($c(a, 1, e),
  7489. Mj(a, e))
  7490. }
  7491. function Wi(a, e) {
  7492. if (a.tag === 3)
  7493. gk(a, a, e);
  7494. else
  7495. for (var i = a.return; i !== null; ) {
  7496. if (i.tag === 3) {
  7497. gk(i, a, e);
  7498. break
  7499. } else if (i.tag === 1) {
  7500. var o = i.stateNode;
  7501. if (typeof i.type.getDerivedStateFromError == "function" || typeof o.componentDidCatch == "function" && (Ti === null || !Ti.has(o))) {
  7502. a = Mi(e, a);
  7503. var s = Si(i, a, 1);
  7504. if (Ag(i, s),
  7505. s = Hg(),
  7506. i = Kj(i, 1),
  7507. i !== null)
  7508. $c(i, 1, s),
  7509. Mj(i, s);
  7510. else if (typeof o.componentDidCatch == "function" && (Ti === null || !Ti.has(o)))
  7511. try {
  7512. o.componentDidCatch(e, a)
  7513. } catch {}
  7514. break
  7515. }
  7516. }
  7517. i = i.return
  7518. }
  7519. }
  7520. function Yj(a, e, i) {
  7521. var o = a.pingCache;
  7522. o !== null && o.delete(e),
  7523. e = Hg(),
  7524. a.pingedLanes |= a.suspendedLanes & i,
  7525. U === a && (W & i) === i && (V === 4 || V === 3 && (W & 62914560) === W && 500 > O() - jj ? Qj(a, 0) : uj |= i),
  7526. Mj(a, e)
  7527. }
  7528. function lj(a, e) {
  7529. var i = a.stateNode;
  7530. i !== null && i.delete(e),
  7531. e = 0,
  7532. e === 0 && (e = a.mode,
  7533. (e & 2) === 0 ? e = 1 : (e & 4) === 0 ? e = eg() === 99 ? 1 : 2 : (Gj === 0 && (Gj = tj),
  7534. e = Yc(62914560 & ~Gj),
  7535. e === 0 && (e = 4194304))),
  7536. i = Hg(),
  7537. a = Kj(a, e),
  7538. a !== null && ($c(a, e, i),
  7539. Mj(a, i))
  7540. }
  7541. var ck;
  7542. ck = function(a, e, i) {
  7543. var o = e.lanes;
  7544. if (a !== null)
  7545. if (a.memoizedProps !== e.pendingProps || N.current)
  7546. ug = !0;
  7547. else if ((i & o) !== 0)
  7548. ug = (a.flags & 16384) !== 0;
  7549. else {
  7550. switch (ug = !1,
  7551. e.tag) {
  7552. case 3:
  7553. ri(e),
  7554. sh();
  7555. break;
  7556. case 5:
  7557. gh(e);
  7558. break;
  7559. case 1:
  7560. Ff(e.type) && Jf(e);
  7561. break;
  7562. case 4:
  7563. eh(e, e.stateNode.containerInfo);
  7564. break;
  7565. case 10:
  7566. o = e.memoizedProps.value;
  7567. var s = e.type._context;
  7568. I(mg, s._currentValue),
  7569. s._currentValue = o;
  7570. break;
  7571. case 13:
  7572. if (e.memoizedState !== null)
  7573. return (i & e.child.childLanes) !== 0 ? ti(a, e, i) : (I(P, P.current & 1),
  7574. e = hi(a, e, i),
  7575. e !== null ? e.sibling : null);
  7576. I(P, P.current & 1);
  7577. break;
  7578. case 19:
  7579. if (o = (i & e.childLanes) !== 0,
  7580. (a.flags & 64) !== 0) {
  7581. if (o)
  7582. return Ai(a, e, i);
  7583. e.flags |= 64
  7584. }
  7585. if (s = e.memoizedState,
  7586. s !== null && (s.rendering = null,
  7587. s.tail = null,
  7588. s.lastEffect = null),
  7589. I(P, P.current),
  7590. o)
  7591. break;
  7592. return null;
  7593. case 23:
  7594. case 24:
  7595. return e.lanes = 0,
  7596. mi(a, e, i)
  7597. }
  7598. return hi(a, e, i)
  7599. }
  7600. else
  7601. ug = !1;
  7602. switch (e.lanes = 0,
  7603. e.tag) {
  7604. case 2:
  7605. if (o = e.type,
  7606. a !== null && (a.alternate = null,
  7607. e.alternate = null,
  7608. e.flags |= 2),
  7609. a = e.pendingProps,
  7610. s = Ef(e, M.current),
  7611. tg(e, i),
  7612. s = Ch(null, e, o, a, s, i),
  7613. e.flags |= 1,
  7614. typeof s == "object" && s !== null && typeof s.render == "function" && s.$$typeof === void 0) {
  7615. if (e.tag = 1,
  7616. e.memoizedState = null,
  7617. e.updateQueue = null,
  7618. Ff(o)) {
  7619. var c = !0;
  7620. Jf(e)
  7621. } else
  7622. c = !1;
  7623. e.memoizedState = s.state !== null && s.state !== void 0 ? s.state : null,
  7624. xg(e);
  7625. var d = o.getDerivedStateFromProps;
  7626. typeof d == "function" && Gg(e, o, d, a),
  7627. s.updater = Kg,
  7628. e.stateNode = s,
  7629. s._reactInternals = e,
  7630. Og(e, o, a, i),
  7631. e = qi(null, e, o, !0, c, i)
  7632. } else
  7633. e.tag = 0,
  7634. fi(null, e, s, i),
  7635. e = e.child;
  7636. return e;
  7637. case 16:
  7638. s = e.elementType;
  7639. e: {
  7640. switch (a !== null && (a.alternate = null,
  7641. e.alternate = null,
  7642. e.flags |= 2),
  7643. a = e.pendingProps,
  7644. c = s._init,
  7645. s = c(s._payload),
  7646. e.type = s,
  7647. c = e.tag = hk(s),
  7648. a = lg(s, a),
  7649. c) {
  7650. case 0:
  7651. e = li(null, e, s, a, i);
  7652. break e;
  7653. case 1:
  7654. e = pi(null, e, s, a, i);
  7655. break e;
  7656. case 11:
  7657. e = gi(null, e, s, a, i);
  7658. break e;
  7659. case 14:
  7660. e = ii(null, e, s, lg(s.type, a), o, i);
  7661. break e
  7662. }
  7663. throw Error(y(306, s, ""))
  7664. }
  7665. return e;
  7666. case 0:
  7667. return o = e.type,
  7668. s = e.pendingProps,
  7669. s = e.elementType === o ? s : lg(o, s),
  7670. li(a, e, o, s, i);
  7671. case 1:
  7672. return o = e.type,
  7673. s = e.pendingProps,
  7674. s = e.elementType === o ? s : lg(o, s),
  7675. pi(a, e, o, s, i);
  7676. case 3:
  7677. if (ri(e),
  7678. o = e.updateQueue,
  7679. a === null || o === null)
  7680. throw Error(y(282));
  7681. if (o = e.pendingProps,
  7682. s = e.memoizedState,
  7683. s = s !== null ? s.element : null,
  7684. yg(a, e),
  7685. Cg(e, o, null, i),
  7686. o = e.memoizedState.element,
  7687. o === s)
  7688. sh(),
  7689. e = hi(a, e, i);
  7690. else {
  7691. if (s = e.stateNode,
  7692. (c = s.hydrate) && (kh = rf(e.stateNode.containerInfo.firstChild),
  7693. jh = e,
  7694. c = lh = !0),
  7695. c) {
  7696. if (a = s.mutableSourceEagerHydrationData,
  7697. a != null)
  7698. for (s = 0; s < a.length; s += 2)
  7699. c = a[s],
  7700. c._workInProgressVersionPrimary = a[s + 1],
  7701. th.push(c);
  7702. for (i = Zg(e, null, o, i),
  7703. e.child = i; i; )
  7704. i.flags = i.flags & -3 | 1024,
  7705. i = i.sibling
  7706. } else
  7707. fi(a, e, o, i),
  7708. sh();
  7709. e = e.child
  7710. }
  7711. return e;
  7712. case 5:
  7713. return gh(e),
  7714. a === null && ph(e),
  7715. o = e.type,
  7716. s = e.pendingProps,
  7717. c = a !== null ? a.memoizedProps : null,
  7718. d = s.children,
  7719. nf(o, s) ? d = null : c !== null && nf(o, c) && (e.flags |= 16),
  7720. oi(a, e),
  7721. fi(a, e, d, i),
  7722. e.child;
  7723. case 6:
  7724. return a === null && ph(e),
  7725. null;
  7726. case 13:
  7727. return ti(a, e, i);
  7728. case 4:
  7729. return eh(e, e.stateNode.containerInfo),
  7730. o = e.pendingProps,
  7731. a === null ? e.child = Yg(e, null, o, i) : fi(a, e, o, i),
  7732. e.child;
  7733. case 11:
  7734. return o = e.type,
  7735. s = e.pendingProps,
  7736. s = e.elementType === o ? s : lg(o, s),
  7737. gi(a, e, o, s, i);
  7738. case 7:
  7739. return fi(a, e, e.pendingProps, i),
  7740. e.child;
  7741. case 8:
  7742. return fi(a, e, e.pendingProps.children, i),
  7743. e.child;
  7744. case 12:
  7745. return fi(a, e, e.pendingProps.children, i),
  7746. e.child;
  7747. case 10:
  7748. e: {
  7749. o = e.type._context,
  7750. s = e.pendingProps,
  7751. d = e.memoizedProps,
  7752. c = s.value;
  7753. var _ = e.type._context;
  7754. if (I(mg, _._currentValue),
  7755. _._currentValue = c,
  7756. d !== null)
  7757. if (_ = d.value,
  7758. c = He(_, c) ? 0 : (typeof o._calculateChangedBits == "function" ? o._calculateChangedBits(_, c) : 1073741823) | 0,
  7759. c === 0) {
  7760. if (d.children === s.children && !N.current) {
  7761. e = hi(a, e, i);
  7762. break e
  7763. }
  7764. } else
  7765. for (_ = e.child,
  7766. _ !== null && (_.return = e); _ !== null; ) {
  7767. var b = _.dependencies;
  7768. if (b !== null) {
  7769. d = _.child;
  7770. for (var k = b.firstContext; k !== null; ) {
  7771. if (k.context === o && (k.observedBits & c) !== 0) {
  7772. _.tag === 1 && (k = zg(-1, i & -i),
  7773. k.tag = 2,
  7774. Ag(_, k)),
  7775. _.lanes |= i,
  7776. k = _.alternate,
  7777. k !== null && (k.lanes |= i),
  7778. sg(_.return, i),
  7779. b.lanes |= i;
  7780. break
  7781. }
  7782. k = k.next
  7783. }
  7784. } else
  7785. d = _.tag === 10 && _.type === e.type ? null : _.child;
  7786. if (d !== null)
  7787. d.return = _;
  7788. else
  7789. for (d = _; d !== null; ) {
  7790. if (d === e) {
  7791. d = null;
  7792. break
  7793. }
  7794. if (_ = d.sibling,
  7795. _ !== null) {
  7796. _.return = d.return,
  7797. d = _;
  7798. break
  7799. }
  7800. d = d.return
  7801. }
  7802. _ = d
  7803. }
  7804. fi(a, e, s.children, i),
  7805. e = e.child
  7806. }
  7807. return e;
  7808. case 9:
  7809. return s = e.type,
  7810. c = e.pendingProps,
  7811. o = c.children,
  7812. tg(e, i),
  7813. s = vg(s, c.unstable_observedBits),
  7814. o = o(s),
  7815. e.flags |= 1,
  7816. fi(a, e, o, i),
  7817. e.child;
  7818. case 14:
  7819. return s = e.type,
  7820. c = lg(s, e.pendingProps),
  7821. c = lg(s.type, c),
  7822. ii(a, e, s, c, o, i);
  7823. case 15:
  7824. return ki(a, e, e.type, e.pendingProps, o, i);
  7825. case 17:
  7826. return o = e.type,
  7827. s = e.pendingProps,
  7828. s = e.elementType === o ? s : lg(o, s),
  7829. a !== null && (a.alternate = null,
  7830. e.alternate = null,
  7831. e.flags |= 2),
  7832. e.tag = 1,
  7833. Ff(o) ? (a = !0,
  7834. Jf(e)) : a = !1,
  7835. tg(e, i),
  7836. Mg(e, o, s),
  7837. Og(e, o, s, i),
  7838. qi(null, e, o, !0, a, i);
  7839. case 19:
  7840. return Ai(a, e, i);
  7841. case 23:
  7842. return mi(a, e, i);
  7843. case 24:
  7844. return mi(a, e, i)
  7845. }
  7846. throw Error(y(156, e.tag))
  7847. }
  7848. ;
  7849. function ik(a, e, i, o) {
  7850. this.tag = a,
  7851. this.key = i,
  7852. this.sibling = this.child = this.return = this.stateNode = this.type = this.elementType = null,
  7853. this.index = 0,
  7854. this.ref = null,
  7855. this.pendingProps = e,
  7856. this.dependencies = this.memoizedState = this.updateQueue = this.memoizedProps = null,
  7857. this.mode = o,
  7858. this.flags = 0,
  7859. this.lastEffect = this.firstEffect = this.nextEffect = null,
  7860. this.childLanes = this.lanes = 0,
  7861. this.alternate = null
  7862. }
  7863. function nh(a, e, i, o) {
  7864. return new ik(a,e,i,o)
  7865. }
  7866. function ji(a) {
  7867. return a = a.prototype,
  7868. !(!a || !a.isReactComponent)
  7869. }
  7870. function hk(a) {
  7871. if (typeof a == "function")
  7872. return ji(a) ? 1 : 0;
  7873. if (a != null) {
  7874. if (a = a.$$typeof,
  7875. a === Aa)
  7876. return 11;
  7877. if (a === Da)
  7878. return 14
  7879. }
  7880. return 2
  7881. }
  7882. function Tg(a, e) {
  7883. var i = a.alternate;
  7884. return i === null ? (i = nh(a.tag, e, a.key, a.mode),
  7885. i.elementType = a.elementType,
  7886. i.type = a.type,
  7887. i.stateNode = a.stateNode,
  7888. i.alternate = a,
  7889. a.alternate = i) : (i.pendingProps = e,
  7890. i.type = a.type,
  7891. i.flags = 0,
  7892. i.nextEffect = null,
  7893. i.firstEffect = null,
  7894. i.lastEffect = null),
  7895. i.childLanes = a.childLanes,
  7896. i.lanes = a.lanes,
  7897. i.child = a.child,
  7898. i.memoizedProps = a.memoizedProps,
  7899. i.memoizedState = a.memoizedState,
  7900. i.updateQueue = a.updateQueue,
  7901. e = a.dependencies,
  7902. i.dependencies = e === null ? null : {
  7903. lanes: e.lanes,
  7904. firstContext: e.firstContext
  7905. },
  7906. i.sibling = a.sibling,
  7907. i.index = a.index,
  7908. i.ref = a.ref,
  7909. i
  7910. }
  7911. function Vg(a, e, i, o, s, c) {
  7912. var d = 2;
  7913. if (o = a,
  7914. typeof a == "function")
  7915. ji(a) && (d = 1);
  7916. else if (typeof a == "string")
  7917. d = 5;
  7918. else
  7919. e: switch (a) {
  7920. case ua:
  7921. return Xg(i.children, s, c, e);
  7922. case Ha:
  7923. d = 8,
  7924. s |= 16;
  7925. break;
  7926. case wa:
  7927. d = 8,
  7928. s |= 1;
  7929. break;
  7930. case xa:
  7931. return a = nh(12, i, e, s | 8),
  7932. a.elementType = xa,
  7933. a.type = xa,
  7934. a.lanes = c,
  7935. a;
  7936. case Ba:
  7937. return a = nh(13, i, e, s),
  7938. a.type = Ba,
  7939. a.elementType = Ba,
  7940. a.lanes = c,
  7941. a;
  7942. case Ca:
  7943. return a = nh(19, i, e, s),
  7944. a.elementType = Ca,
  7945. a.lanes = c,
  7946. a;
  7947. case Ia:
  7948. return vi(i, s, c, e);
  7949. case Ja:
  7950. return a = nh(24, i, e, s),
  7951. a.elementType = Ja,
  7952. a.lanes = c,
  7953. a;
  7954. default:
  7955. if (typeof a == "object" && a !== null)
  7956. switch (a.$$typeof) {
  7957. case ya:
  7958. d = 10;
  7959. break e;
  7960. case za:
  7961. d = 9;
  7962. break e;
  7963. case Aa:
  7964. d = 11;
  7965. break e;
  7966. case Da:
  7967. d = 14;
  7968. break e;
  7969. case Ea:
  7970. d = 16,
  7971. o = null;
  7972. break e;
  7973. case Fa:
  7974. d = 22;
  7975. break e
  7976. }
  7977. throw Error(y(130, a == null ? a : typeof a, ""))
  7978. }
  7979. return e = nh(d, i, e, s),
  7980. e.elementType = a,
  7981. e.type = o,
  7982. e.lanes = c,
  7983. e
  7984. }
  7985. function Xg(a, e, i, o) {
  7986. return a = nh(7, a, o, e),
  7987. a.lanes = i,
  7988. a
  7989. }
  7990. function vi(a, e, i, o) {
  7991. return a = nh(23, a, o, e),
  7992. a.elementType = Ia,
  7993. a.lanes = i,
  7994. a
  7995. }
  7996. function Ug(a, e, i) {
  7997. return a = nh(6, a, null, e),
  7998. a.lanes = i,
  7999. a
  8000. }
  8001. function Wg(a, e, i) {
  8002. return e = nh(4, a.children !== null ? a.children : [], a.key, e),
  8003. e.lanes = i,
  8004. e.stateNode = {
  8005. containerInfo: a.containerInfo,
  8006. pendingChildren: null,
  8007. implementation: a.implementation
  8008. },
  8009. e
  8010. }
  8011. function jk(a, e, i) {
  8012. this.tag = e,
  8013. this.containerInfo = a,
  8014. this.finishedWork = this.pingCache = this.current = this.pendingChildren = null,
  8015. this.timeoutHandle = -1,
  8016. this.pendingContext = this.context = null,
  8017. this.hydrate = i,
  8018. this.callbackNode = null,
  8019. this.callbackPriority = 0,
  8020. this.eventTimes = Zc(0),
  8021. this.expirationTimes = Zc(-1),
  8022. this.entangledLanes = this.finishedLanes = this.mutableReadLanes = this.expiredLanes = this.pingedLanes = this.suspendedLanes = this.pendingLanes = 0,
  8023. this.entanglements = Zc(0),
  8024. this.mutableSourceEagerHydrationData = null
  8025. }
  8026. function kk(a, e, i) {
  8027. var o = 3 < arguments.length && arguments[3] !== void 0 ? arguments[3] : null;
  8028. return {
  8029. $$typeof: ta,
  8030. key: o == null ? null : "" + o,
  8031. children: a,
  8032. containerInfo: e,
  8033. implementation: i
  8034. }
  8035. }
  8036. function lk(a, e, i, o) {
  8037. var s = e.current
  8038. , c = Hg()
  8039. , d = Ig(s);
  8040. e: if (i) {
  8041. i = i._reactInternals;
  8042. t: {
  8043. if (Zb(i) !== i || i.tag !== 1)
  8044. throw Error(y(170));
  8045. var _ = i;
  8046. do {
  8047. switch (_.tag) {
  8048. case 3:
  8049. _ = _.stateNode.context;
  8050. break t;
  8051. case 1:
  8052. if (Ff(_.type)) {
  8053. _ = _.stateNode.__reactInternalMemoizedMergedChildContext;
  8054. break t
  8055. }
  8056. }
  8057. _ = _.return
  8058. } while (_ !== null);
  8059. throw Error(y(171))
  8060. }
  8061. if (i.tag === 1) {
  8062. var b = i.type;
  8063. if (Ff(b)) {
  8064. i = If(i, b, _);
  8065. break e
  8066. }
  8067. }
  8068. i = _
  8069. } else
  8070. i = Cf;
  8071. return e.context === null ? e.context = i : e.pendingContext = i,
  8072. e = zg(c, d),
  8073. e.payload = {
  8074. element: a
  8075. },
  8076. o = o === void 0 ? null : o,
  8077. o !== null && (e.callback = o),
  8078. Ag(s, e),
  8079. Jg(s, d, c),
  8080. d
  8081. }
  8082. function mk(a) {
  8083. if (a = a.current,
  8084. !a.child)
  8085. return null;
  8086. switch (a.child.tag) {
  8087. case 5:
  8088. return a.child.stateNode;
  8089. default:
  8090. return a.child.stateNode
  8091. }
  8092. }
  8093. function nk(a, e) {
  8094. if (a = a.memoizedState,
  8095. a !== null && a.dehydrated !== null) {
  8096. var i = a.retryLane;
  8097. a.retryLane = i !== 0 && i < e ? i : e
  8098. }
  8099. }
  8100. function ok(a, e) {
  8101. nk(a, e),
  8102. (a = a.alternate) && nk(a, e)
  8103. }
  8104. function pk() {
  8105. return null
  8106. }
  8107. function qk(a, e, i) {
  8108. var o = i != null && i.hydrationOptions != null && i.hydrationOptions.mutableSources || null;
  8109. if (i = new jk(a,e,i != null && i.hydrate === !0),
  8110. e = nh(3, null, null, e === 2 ? 7 : e === 1 ? 3 : 0),
  8111. i.current = e,
  8112. e.stateNode = i,
  8113. xg(e),
  8114. a[ff] = i.current,
  8115. cf(a.nodeType === 8 ? a.parentNode : a),
  8116. o)
  8117. for (a = 0; a < o.length; a++) {
  8118. e = o[a];
  8119. var s = e._getVersion;
  8120. s = s(e._source),
  8121. i.mutableSourceEagerHydrationData == null ? i.mutableSourceEagerHydrationData = [e, s] : i.mutableSourceEagerHydrationData.push(e, s)
  8122. }
  8123. this._internalRoot = i
  8124. }
  8125. qk.prototype.render = function(a) {
  8126. lk(a, this._internalRoot, null, null)
  8127. }
  8128. ;
  8129. qk.prototype.unmount = function() {
  8130. var a = this._internalRoot
  8131. , e = a.containerInfo;
  8132. lk(null, a, null, function() {
  8133. e[ff] = null
  8134. })
  8135. }
  8136. ;
  8137. function rk(a) {
  8138. return !(!a || a.nodeType !== 1 && a.nodeType !== 9 && a.nodeType !== 11 && (a.nodeType !== 8 || a.nodeValue !== " react-mount-point-unstable "))
  8139. }
  8140. function sk(a, e) {
  8141. if (e || (e = a ? a.nodeType === 9 ? a.documentElement : a.firstChild : null,
  8142. e = !(!e || e.nodeType !== 1 || !e.hasAttribute("data-reactroot"))),
  8143. !e)
  8144. for (var i; i = a.lastChild; )
  8145. a.removeChild(i);
  8146. return new qk(a,0,e ? {
  8147. hydrate: !0
  8148. } : void 0)
  8149. }
  8150. function tk(a, e, i, o, s) {
  8151. var c = i._reactRootContainer;
  8152. if (c) {
  8153. var d = c._internalRoot;
  8154. if (typeof s == "function") {
  8155. var _ = s;
  8156. s = function() {
  8157. var k = mk(d);
  8158. _.call(k)
  8159. }
  8160. }
  8161. lk(e, d, a, s)
  8162. } else {
  8163. if (c = i._reactRootContainer = sk(i, o),
  8164. d = c._internalRoot,
  8165. typeof s == "function") {
  8166. var b = s;
  8167. s = function() {
  8168. var k = mk(d);
  8169. b.call(k)
  8170. }
  8171. }
  8172. Xj(function() {
  8173. lk(e, d, a, s)
  8174. })
  8175. }
  8176. return mk(d)
  8177. }
  8178. ec = function(a) {
  8179. if (a.tag === 13) {
  8180. var e = Hg();
  8181. Jg(a, 4, e),
  8182. ok(a, 4)
  8183. }
  8184. }
  8185. ;
  8186. fc = function(a) {
  8187. if (a.tag === 13) {
  8188. var e = Hg();
  8189. Jg(a, 67108864, e),
  8190. ok(a, 67108864)
  8191. }
  8192. }
  8193. ;
  8194. gc = function(a) {
  8195. if (a.tag === 13) {
  8196. var e = Hg()
  8197. , i = Ig(a);
  8198. Jg(a, i, e),
  8199. ok(a, i)
  8200. }
  8201. }
  8202. ;
  8203. hc = function(a, e) {
  8204. return e()
  8205. }
  8206. ;
  8207. yb = function(a, e, i) {
  8208. switch (e) {
  8209. case "input":
  8210. if (ab(a, i),
  8211. e = i.name,
  8212. i.type === "radio" && e != null) {
  8213. for (i = a; i.parentNode; )
  8214. i = i.parentNode;
  8215. for (i = i.querySelectorAll("input[name=" + JSON.stringify("" + e) + '][type="radio"]'),
  8216. e = 0; e < i.length; e++) {
  8217. var o = i[e];
  8218. if (o !== a && o.form === a.form) {
  8219. var s = Db(o);
  8220. if (!s)
  8221. throw Error(y(90));
  8222. Wa(o),
  8223. ab(o, s)
  8224. }
  8225. }
  8226. }
  8227. break;
  8228. case "textarea":
  8229. ib(a, i);
  8230. break;
  8231. case "select":
  8232. e = i.value,
  8233. e != null && fb(a, !!i.multiple, e, !1)
  8234. }
  8235. }
  8236. ;
  8237. Gb = Wj;
  8238. Hb = function(a, e, i, o, s) {
  8239. var c = X;
  8240. X |= 4;
  8241. try {
  8242. return gg(98, a.bind(null, e, i, o, s))
  8243. } finally {
  8244. X = c,
  8245. X === 0 && (wj(),
  8246. ig())
  8247. }
  8248. }
  8249. ;
  8250. Ib = function() {
  8251. (X & 49) === 0 && (Vj(),
  8252. Oj())
  8253. }
  8254. ;
  8255. Jb = function(a, e) {
  8256. var i = X;
  8257. X |= 2;
  8258. try {
  8259. return a(e)
  8260. } finally {
  8261. X = i,
  8262. X === 0 && (wj(),
  8263. ig())
  8264. }
  8265. }
  8266. ;
  8267. function uk(a, e) {
  8268. var i = 2 < arguments.length && arguments[2] !== void 0 ? arguments[2] : null;
  8269. if (!rk(e))
  8270. throw Error(y(200));
  8271. return kk(a, e, null, i)
  8272. }
  8273. var vk = {
  8274. Events: [Cb, ue, Db, Eb, Fb, Oj, {
  8275. current: !1
  8276. }]
  8277. }
  8278. , wk = {
  8279. findFiberByHostInstance: wc,
  8280. bundleType: 0,
  8281. version: "17.0.2",
  8282. rendererPackageName: "react-dom"
  8283. }
  8284. , xk = {
  8285. bundleType: wk.bundleType,
  8286. version: wk.version,
  8287. rendererPackageName: wk.rendererPackageName,
  8288. rendererConfig: wk.rendererConfig,
  8289. overrideHookState: null,
  8290. overrideHookStateDeletePath: null,
  8291. overrideHookStateRenamePath: null,
  8292. overrideProps: null,
  8293. overridePropsDeletePath: null,
  8294. overridePropsRenamePath: null,
  8295. setSuspenseHandler: null,
  8296. scheduleUpdate: null,
  8297. currentDispatcherRef: ra.ReactCurrentDispatcher,
  8298. findHostInstanceByFiber: function(a) {
  8299. return a = cc(a),
  8300. a === null ? null : a.stateNode
  8301. },
  8302. findFiberByHostInstance: wk.findFiberByHostInstance || pk,
  8303. findHostInstancesForRefresh: null,
  8304. scheduleRefresh: null,
  8305. scheduleRoot: null,
  8306. setRefreshHandler: null,
  8307. getCurrentFiber: null
  8308. };
  8309. if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ != "undefined") {
  8310. var yk = __REACT_DEVTOOLS_GLOBAL_HOOK__;
  8311. if (!yk.isDisabled && yk.supportsFiber)
  8312. try {
  8313. Lf = yk.inject(xk),
  8314. Mf = yk
  8315. } catch {}
  8316. }
  8317. reactDom_production_min.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = vk;
  8318. reactDom_production_min.createPortal = uk;
  8319. reactDom_production_min.findDOMNode = function(a) {
  8320. if (a == null)
  8321. return null;
  8322. if (a.nodeType === 1)
  8323. return a;
  8324. var e = a._reactInternals;
  8325. if (e === void 0)
  8326. throw typeof a.render == "function" ? Error(y(188)) : Error(y(268, Object.keys(a)));
  8327. return a = cc(e),
  8328. a = a === null ? null : a.stateNode,
  8329. a
  8330. }
  8331. ;
  8332. reactDom_production_min.flushSync = function(a, e) {
  8333. var i = X;
  8334. if ((i & 48) !== 0)
  8335. return a(e);
  8336. X |= 1;
  8337. try {
  8338. if (a)
  8339. return gg(99, a.bind(null, e))
  8340. } finally {
  8341. X = i,
  8342. ig()
  8343. }
  8344. }
  8345. ;
  8346. reactDom_production_min.hydrate = function(a, e, i) {
  8347. if (!rk(e))
  8348. throw Error(y(200));
  8349. return tk(null, a, e, !0, i)
  8350. }
  8351. ;
  8352. reactDom_production_min.render = function(a, e, i) {
  8353. if (!rk(e))
  8354. throw Error(y(200));
  8355. return tk(null, a, e, !1, i)
  8356. }
  8357. ;
  8358. reactDom_production_min.unmountComponentAtNode = function(a) {
  8359. if (!rk(a))
  8360. throw Error(y(40));
  8361. return a._reactRootContainer ? (Xj(function() {
  8362. tk(null, null, a, !1, function() {
  8363. a._reactRootContainer = null,
  8364. a[ff] = null
  8365. })
  8366. }),
  8367. !0) : !1
  8368. }
  8369. ;
  8370. reactDom_production_min.unstable_batchedUpdates = Wj;
  8371. reactDom_production_min.unstable_createPortal = function(a, e) {
  8372. return uk(a, e, 2 < arguments.length && arguments[2] !== void 0 ? arguments[2] : null)
  8373. }
  8374. ;
  8375. reactDom_production_min.unstable_renderSubtreeIntoContainer = function(a, e, i, o) {
  8376. if (!rk(i))
  8377. throw Error(y(200));
  8378. if (a == null || a._reactInternals === void 0)
  8379. throw Error(y(38));
  8380. return tk(a, e, i, !1, o)
  8381. }
  8382. ;
  8383. reactDom_production_min.version = "17.0.2";
  8384. function checkDCE() {
  8385. if (!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ == "undefined" || typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE != "function"))
  8386. try {
  8387. __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(checkDCE)
  8388. } catch (a) {
  8389. console.error(a)
  8390. }
  8391. }
  8392. checkDCE(),
  8393. reactDom.exports = reactDom_production_min;
  8394. var ReactDOM = reactDom.exports;
  8395. let logDisabled_ = !0
  8396. , deprecationWarnings_ = !0;
  8397. function extractVersion(a, e, i) {
  8398. const o = a.match(e);
  8399. return o && o.length >= i && parseInt(o[i], 10)
  8400. }
  8401. function wrapPeerConnectionEvent(a, e, i) {
  8402. if (!a.RTCPeerConnection)
  8403. return;
  8404. const o = a.RTCPeerConnection.prototype
  8405. , s = o.addEventListener;
  8406. o.addEventListener = function(d, _) {
  8407. if (d !== e)
  8408. return s.apply(this, arguments);
  8409. const b = k=>{
  8410. const j = i(k);
  8411. j && (_.handleEvent ? _.handleEvent(j) : _(j))
  8412. }
  8413. ;
  8414. return this._eventMap = this._eventMap || {},
  8415. this._eventMap[e] || (this._eventMap[e] = new Map),
  8416. this._eventMap[e].set(_, b),
  8417. s.apply(this, [d, b])
  8418. }
  8419. ;
  8420. const c = o.removeEventListener;
  8421. o.removeEventListener = function(d, _) {
  8422. if (d !== e || !this._eventMap || !this._eventMap[e])
  8423. return c.apply(this, arguments);
  8424. if (!this._eventMap[e].has(_))
  8425. return c.apply(this, arguments);
  8426. const b = this._eventMap[e].get(_);
  8427. return this._eventMap[e].delete(_),
  8428. this._eventMap[e].size === 0 && delete this._eventMap[e],
  8429. Object.keys(this._eventMap).length === 0 && delete this._eventMap,
  8430. c.apply(this, [d, b])
  8431. }
  8432. ,
  8433. Object.defineProperty(o, "on" + e, {
  8434. get() {
  8435. return this["_on" + e]
  8436. },
  8437. set(d) {
  8438. this["_on" + e] && (this.removeEventListener(e, this["_on" + e]),
  8439. delete this["_on" + e]),
  8440. d && this.addEventListener(e, this["_on" + e] = d)
  8441. },
  8442. enumerable: !0,
  8443. configurable: !0
  8444. })
  8445. }
  8446. function disableLog(a) {
  8447. return typeof a != "boolean" ? new Error("Argument type: " + typeof a + ". Please use a boolean.") : (logDisabled_ = a,
  8448. a ? "adapter.js logging disabled" : "adapter.js logging enabled")
  8449. }
  8450. function disableWarnings(a) {
  8451. return typeof a != "boolean" ? new Error("Argument type: " + typeof a + ". Please use a boolean.") : (deprecationWarnings_ = !a,
  8452. "adapter.js deprecation warnings " + (a ? "disabled" : "enabled"))
  8453. }
  8454. function log$L() {
  8455. if (typeof window == "object") {
  8456. if (logDisabled_)
  8457. return;
  8458. typeof console != "undefined" && typeof console.log == "function" && console.log.apply(console, arguments)
  8459. }
  8460. }
  8461. function deprecated(a, e) {
  8462. !deprecationWarnings_ || console.warn(a + " is deprecated, please use " + e + " instead.")
  8463. }
  8464. function detectBrowser(a) {
  8465. const e = {
  8466. browser: null,
  8467. version: null
  8468. };
  8469. if (typeof a == "undefined" || !a.navigator)
  8470. return e.browser = "Not a browser.",
  8471. e;
  8472. const {navigator: i} = a;
  8473. if (i.mozGetUserMedia)
  8474. e.browser = "firefox",
  8475. e.version = extractVersion(i.userAgent, /Firefox\/(\d+)\./, 1);
  8476. else if (i.webkitGetUserMedia || a.isSecureContext === !1 && a.webkitRTCPeerConnection && !a.RTCIceGatherer)
  8477. e.browser = "chrome",
  8478. e.version = extractVersion(i.userAgent, /Chrom(e|ium)\/(\d+)\./, 2);
  8479. else if (a.RTCPeerConnection && i.userAgent.match(/AppleWebKit\/(\d+)\./))
  8480. e.browser = "safari",
  8481. e.version = extractVersion(i.userAgent, /AppleWebKit\/(\d+)\./, 1),
  8482. e.supportsUnifiedPlan = a.RTCRtpTransceiver && "currentDirection"in a.RTCRtpTransceiver.prototype;
  8483. else
  8484. return e.browser = "Not a supported browser.",
  8485. e;
  8486. return e
  8487. }
  8488. function isObject$1(a) {
  8489. return Object.prototype.toString.call(a) === "[object Object]"
  8490. }
  8491. function compactObject(a) {
  8492. return isObject$1(a) ? Object.keys(a).reduce(function(e, i) {
  8493. const o = isObject$1(a[i])
  8494. , s = o ? compactObject(a[i]) : a[i]
  8495. , c = o && !Object.keys(s).length;
  8496. return s === void 0 || c ? e : Object.assign(e, {
  8497. [i]: s
  8498. })
  8499. }, {}) : a
  8500. }
  8501. function walkStats(a, e, i) {
  8502. !e || i.has(e.id) || (i.set(e.id, e),
  8503. Object.keys(e).forEach(o=>{
  8504. o.endsWith("Id") ? walkStats(a, a.get(e[o]), i) : o.endsWith("Ids") && e[o].forEach(s=>{
  8505. walkStats(a, a.get(s), i)
  8506. }
  8507. )
  8508. }
  8509. ))
  8510. }
  8511. function filterStats(a, e, i) {
  8512. const o = i ? "outbound-rtp" : "inbound-rtp"
  8513. , s = new Map;
  8514. if (e === null)
  8515. return s;
  8516. const c = [];
  8517. return a.forEach(d=>{
  8518. d.type === "track" && d.trackIdentifier === e.id && c.push(d)
  8519. }
  8520. ),
  8521. c.forEach(d=>{
  8522. a.forEach(_=>{
  8523. _.type === o && _.trackId === d.id && walkStats(a, _, s)
  8524. }
  8525. )
  8526. }
  8527. ),
  8528. s
  8529. }
  8530. const logging = log$L;
  8531. function shimGetUserMedia$2(a, e) {
  8532. const i = a && a.navigator;
  8533. if (!i.mediaDevices)
  8534. return;
  8535. const o = function(_) {
  8536. if (typeof _ != "object" || _.mandatory || _.optional)
  8537. return _;
  8538. const b = {};
  8539. return Object.keys(_).forEach(k=>{
  8540. if (k === "require" || k === "advanced" || k === "mediaSource")
  8541. return;
  8542. const j = typeof _[k] == "object" ? _[k] : {
  8543. ideal: _[k]
  8544. };
  8545. j.exact !== void 0 && typeof j.exact == "number" && (j.min = j.max = j.exact);
  8546. const $ = function(_e, et) {
  8547. return _e ? _e + et.charAt(0).toUpperCase() + et.slice(1) : et === "deviceId" ? "sourceId" : et
  8548. };
  8549. if (j.ideal !== void 0) {
  8550. b.optional = b.optional || [];
  8551. let _e = {};
  8552. typeof j.ideal == "number" ? (_e[$("min", k)] = j.ideal,
  8553. b.optional.push(_e),
  8554. _e = {},
  8555. _e[$("max", k)] = j.ideal,
  8556. b.optional.push(_e)) : (_e[$("", k)] = j.ideal,
  8557. b.optional.push(_e))
  8558. }
  8559. j.exact !== void 0 && typeof j.exact != "number" ? (b.mandatory = b.mandatory || {},
  8560. b.mandatory[$("", k)] = j.exact) : ["min", "max"].forEach(_e=>{
  8561. j[_e] !== void 0 && (b.mandatory = b.mandatory || {},
  8562. b.mandatory[$(_e, k)] = j[_e])
  8563. }
  8564. )
  8565. }
  8566. ),
  8567. _.advanced && (b.optional = (b.optional || []).concat(_.advanced)),
  8568. b
  8569. }
  8570. , s = function(_, b) {
  8571. if (e.version >= 61)
  8572. return b(_);
  8573. if (_ = JSON.parse(JSON.stringify(_)),
  8574. _ && typeof _.audio == "object") {
  8575. const k = function(j, $, _e) {
  8576. $in j && !(_e in j) && (j[_e] = j[$],
  8577. delete j[$])
  8578. };
  8579. _ = JSON.parse(JSON.stringify(_)),
  8580. k(_.audio, "autoGainControl", "googAutoGainControl"),
  8581. k(_.audio, "noiseSuppression", "googNoiseSuppression"),
  8582. _.audio = o(_.audio)
  8583. }
  8584. if (_ && typeof _.video == "object") {
  8585. let k = _.video.facingMode;
  8586. k = k && (typeof k == "object" ? k : {
  8587. ideal: k
  8588. });
  8589. const j = e.version < 66;
  8590. if (k && (k.exact === "user" || k.exact === "environment" || k.ideal === "user" || k.ideal === "environment") && !(i.mediaDevices.getSupportedConstraints && i.mediaDevices.getSupportedConstraints().facingMode && !j)) {
  8591. delete _.video.facingMode;
  8592. let$;
  8593. if (k.exact === "environment" || k.ideal === "environment" ? $ = ["back", "rear"] : (k.exact === "user" || k.ideal === "user") && ($ = ["front"]),
  8594. $)
  8595. return i.mediaDevices.enumerateDevices().then(_e=>{
  8596. _e = _e.filter(tt=>tt.kind === "videoinput");
  8597. let et = _e.find(tt=>$.some(rt=>tt.label.toLowerCase().includes(rt)));
  8598. return !et && _e.length && $.includes("back") && (et = _e[_e.length - 1]),
  8599. et && (_.video.deviceId = k.exact ? {
  8600. exact: et.deviceId
  8601. } : {
  8602. ideal: et.deviceId
  8603. }),
  8604. _.video = o(_.video),
  8605. logging("chrome: " + JSON.stringify(_)),
  8606. b(_)
  8607. }
  8608. )
  8609. }
  8610. _.video = o(_.video)
  8611. }
  8612. return logging("chrome: " + JSON.stringify(_)),
  8613. b(_)
  8614. }
  8615. , c = function(_) {
  8616. return e.version >= 64 ? _ : {
  8617. name: {
  8618. PermissionDeniedError: "NotAllowedError",
  8619. PermissionDismissedError: "NotAllowedError",
  8620. InvalidStateError: "NotAllowedError",
  8621. DevicesNotFoundError: "NotFoundError",
  8622. ConstraintNotSatisfiedError: "OverconstrainedError",
  8623. TrackStartError: "NotReadableError",
  8624. MediaDeviceFailedDueToShutdown: "NotAllowedError",
  8625. MediaDeviceKillSwitchOn: "NotAllowedError",
  8626. TabCaptureError: "AbortError",
  8627. ScreenCaptureError: "AbortError",
  8628. DeviceCaptureError: "AbortError"
  8629. }[_.name] || _.name,
  8630. message: _.message,
  8631. constraint: _.constraint || _.constraintName,
  8632. toString() {
  8633. return this.name + (this.message && ": ") + this.message
  8634. }
  8635. }
  8636. }
  8637. , d = function(_, b, k) {
  8638. s(_, j=>{
  8639. i.webkitGetUserMedia(j, b, $=>{
  8640. k && k(c($))
  8641. }
  8642. )
  8643. }
  8644. )
  8645. };
  8646. if (i.getUserMedia = d.bind(i),
  8647. i.mediaDevices.getUserMedia) {
  8648. const _ = i.mediaDevices.getUserMedia.bind(i.mediaDevices);
  8649. i.mediaDevices.getUserMedia = function(b) {
  8650. return s(b, k=>_(k).then(j=>{
  8651. if (k.audio && !j.getAudioTracks().length || k.video && !j.getVideoTracks().length)
  8652. throw j.getTracks().forEach($=>{
  8653. $.stop()
  8654. }
  8655. ),
  8656. new DOMException("","NotFoundError");
  8657. return j
  8658. }
  8659. , j=>Promise.reject(c(j))))
  8660. }
  8661. }
  8662. }
  8663. function shimGetDisplayMedia$1(a, e) {
  8664. if (!(a.navigator.mediaDevices && "getDisplayMedia"in a.navigator.mediaDevices) && !!a.navigator.mediaDevices) {
  8665. if (typeof e != "function") {
  8666. console.error("shimGetDisplayMedia: getSourceId argument is not a function");
  8667. return
  8668. }
  8669. a.navigator.mediaDevices.getDisplayMedia = function(o) {
  8670. return e(o).then(s=>{
  8671. const c = o.video && o.video.width
  8672. , d = o.video && o.video.height
  8673. , _ = o.video && o.video.frameRate;
  8674. return o.video = {
  8675. mandatory: {
  8676. chromeMediaSource: "desktop",
  8677. chromeMediaSourceId: s,
  8678. maxFrameRate: _ || 3
  8679. }
  8680. },
  8681. c && (o.video.mandatory.maxWidth = c),
  8682. d && (o.video.mandatory.maxHeight = d),
  8683. a.navigator.mediaDevices.getUserMedia(o)
  8684. }
  8685. )
  8686. }
  8687. }
  8688. }
  8689. function shimMediaStream(a) {
  8690. a.MediaStream = a.MediaStream || a.webkitMediaStream
  8691. }
  8692. function shimOnTrack$1(a) {
  8693. if (typeof a == "object" && a.RTCPeerConnection && !("ontrack"in a.RTCPeerConnection.prototype)) {
  8694. Object.defineProperty(a.RTCPeerConnection.prototype, "ontrack", {
  8695. get() {
  8696. return this._ontrack
  8697. },
  8698. set(i) {
  8699. this._ontrack && this.removeEventListener("track", this._ontrack),
  8700. this.addEventListener("track", this._ontrack = i)
  8701. },
  8702. enumerable: !0,
  8703. configurable: !0
  8704. });
  8705. const e = a.RTCPeerConnection.prototype.setRemoteDescription;
  8706. a.RTCPeerConnection.prototype.setRemoteDescription = function() {
  8707. return this._ontrackpoly || (this._ontrackpoly = o=>{
  8708. o.stream.addEventListener("addtrack", s=>{
  8709. let c;
  8710. a.RTCPeerConnection.prototype.getReceivers ? c = this.getReceivers().find(_=>_.track && _.track.id === s.track.id) : c = {
  8711. track: s.track
  8712. };
  8713. const d = new Event("track");
  8714. d.track = s.track,
  8715. d.receiver = c,
  8716. d.transceiver = {
  8717. receiver: c
  8718. },
  8719. d.streams = [o.stream],
  8720. this.dispatchEvent(d)
  8721. }
  8722. ),
  8723. o.stream.getTracks().forEach(s=>{
  8724. let c;
  8725. a.RTCPeerConnection.prototype.getReceivers ? c = this.getReceivers().find(_=>_.track && _.track.id === s.id) : c = {
  8726. track: s
  8727. };
  8728. const d = new Event("track");
  8729. d.track = s,
  8730. d.receiver = c,
  8731. d.transceiver = {
  8732. receiver: c
  8733. },
  8734. d.streams = [o.stream],
  8735. this.dispatchEvent(d)
  8736. }
  8737. )
  8738. }
  8739. ,
  8740. this.addEventListener("addstream", this._ontrackpoly)),
  8741. e.apply(this, arguments)
  8742. }
  8743. } else
  8744. wrapPeerConnectionEvent(a, "track", e=>(e.transceiver || Object.defineProperty(e, "transceiver", {
  8745. value: {
  8746. receiver: e.receiver
  8747. }
  8748. }),
  8749. e))
  8750. }
  8751. function shimGetSendersWithDtmf(a) {
  8752. if (typeof a == "object" && a.RTCPeerConnection && !("getSenders"in a.RTCPeerConnection.prototype) && "createDTMFSender"in a.RTCPeerConnection.prototype) {
  8753. const e = function(s, c) {
  8754. return {
  8755. track: c,
  8756. get dtmf() {
  8757. return this._dtmf === void 0 && (c.kind === "audio" ? this._dtmf = s.createDTMFSender(c) : this._dtmf = null),
  8758. this._dtmf
  8759. },
  8760. _pc: s
  8761. }
  8762. };
  8763. if (!a.RTCPeerConnection.prototype.getSenders) {
  8764. a.RTCPeerConnection.prototype.getSenders = function() {
  8765. return this._senders = this._senders || [],
  8766. this._senders.slice()
  8767. }
  8768. ;
  8769. const s = a.RTCPeerConnection.prototype.addTrack;
  8770. a.RTCPeerConnection.prototype.addTrack = function(_, b) {
  8771. let k = s.apply(this, arguments);
  8772. return k || (k = e(this, _),
  8773. this._senders.push(k)),
  8774. k
  8775. }
  8776. ;
  8777. const c = a.RTCPeerConnection.prototype.removeTrack;
  8778. a.RTCPeerConnection.prototype.removeTrack = function(_) {
  8779. c.apply(this, arguments);
  8780. const b = this._senders.indexOf(_);
  8781. b !== -1 && this._senders.splice(b, 1)
  8782. }
  8783. }
  8784. const i = a.RTCPeerConnection.prototype.addStream;
  8785. a.RTCPeerConnection.prototype.addStream = function(c) {
  8786. this._senders = this._senders || [],
  8787. i.apply(this, [c]),
  8788. c.getTracks().forEach(d=>{
  8789. this._senders.push(e(this, d))
  8790. }
  8791. )
  8792. }
  8793. ;
  8794. const o = a.RTCPeerConnection.prototype.removeStream;
  8795. a.RTCPeerConnection.prototype.removeStream = function(c) {
  8796. this._senders = this._senders || [],
  8797. o.apply(this, [c]),
  8798. c.getTracks().forEach(d=>{
  8799. const _ = this._senders.find(b=>b.track === d);
  8800. _ && this._senders.splice(this._senders.indexOf(_), 1)
  8801. }
  8802. )
  8803. }
  8804. } else if (typeof a == "object" && a.RTCPeerConnection && "getSenders"in a.RTCPeerConnection.prototype && "createDTMFSender"in a.RTCPeerConnection.prototype && a.RTCRtpSender && !("dtmf"in a.RTCRtpSender.prototype)) {
  8805. const e = a.RTCPeerConnection.prototype.getSenders;
  8806. a.RTCPeerConnection.prototype.getSenders = function() {
  8807. const o = e.apply(this, []);
  8808. return o.forEach(s=>s._pc = this),
  8809. o
  8810. }
  8811. ,
  8812. Object.defineProperty(a.RTCRtpSender.prototype, "dtmf", {
  8813. get() {
  8814. return this._dtmf === void 0 && (this.track.kind === "audio" ? this._dtmf = this._pc.createDTMFSender(this.track) : this._dtmf = null),
  8815. this._dtmf
  8816. }
  8817. })
  8818. }
  8819. }
  8820. function shimGetStats(a) {
  8821. if (!a.RTCPeerConnection)
  8822. return;
  8823. const e = a.RTCPeerConnection.prototype.getStats;
  8824. a.RTCPeerConnection.prototype.getStats = function() {
  8825. const [o,s,c] = arguments;
  8826. if (arguments.length > 0 && typeof o == "function")
  8827. return e.apply(this, arguments);
  8828. if (e.length === 0 && (arguments.length === 0 || typeof o != "function"))
  8829. return e.apply(this, []);
  8830. const d = function(b) {
  8831. const k = {};
  8832. return b.result().forEach($=>{
  8833. const _e = {
  8834. id: $.id,
  8835. timestamp: $.timestamp,
  8836. type: {
  8837. localcandidate: "local-candidate",
  8838. remotecandidate: "remote-candidate"
  8839. }[$.type] || $.type
  8840. };
  8841. $.names().forEach(et=>{
  8842. _e[et] = $.stat(et)
  8843. }
  8844. ),
  8845. k[_e.id] = _e
  8846. }
  8847. ),
  8848. k
  8849. }
  8850. , _ = function(b) {
  8851. return new Map(Object.keys(b).map(k=>[k, b[k]]))
  8852. };
  8853. if (arguments.length >= 2) {
  8854. const b = function(k) {
  8855. s(_(d(k)))
  8856. };
  8857. return e.apply(this, [b, o])
  8858. }
  8859. return new Promise((b,k)=>{
  8860. e.apply(this, [function(j) {
  8861. b(_(d(j)))
  8862. }
  8863. , k])
  8864. }
  8865. ).then(s, c)
  8866. }
  8867. }
  8868. function shimSenderReceiverGetStats(a) {
  8869. if (!(typeof a == "object" && a.RTCPeerConnection && a.RTCRtpSender && a.RTCRtpReceiver))
  8870. return;
  8871. if (!("getStats"in a.RTCRtpSender.prototype)) {
  8872. const i = a.RTCPeerConnection.prototype.getSenders;
  8873. i && (a.RTCPeerConnection.prototype.getSenders = function() {
  8874. const c = i.apply(this, []);
  8875. return c.forEach(d=>d._pc = this),
  8876. c
  8877. }
  8878. );
  8879. const o = a.RTCPeerConnection.prototype.addTrack;
  8880. o && (a.RTCPeerConnection.prototype.addTrack = function() {
  8881. const c = o.apply(this, arguments);
  8882. return c._pc = this,
  8883. c
  8884. }
  8885. ),
  8886. a.RTCRtpSender.prototype.getStats = function() {
  8887. const c = this;
  8888. return this._pc.getStats().then(d=>filterStats(d, c.track, !0))
  8889. }
  8890. }
  8891. if (!("getStats"in a.RTCRtpReceiver.prototype)) {
  8892. const i = a.RTCPeerConnection.prototype.getReceivers;
  8893. i && (a.RTCPeerConnection.prototype.getReceivers = function() {
  8894. const s = i.apply(this, []);
  8895. return s.forEach(c=>c._pc = this),
  8896. s
  8897. }
  8898. ),
  8899. wrapPeerConnectionEvent(a, "track", o=>(o.receiver._pc = o.srcElement,
  8900. o)),
  8901. a.RTCRtpReceiver.prototype.getStats = function() {
  8902. const s = this;
  8903. return this._pc.getStats().then(c=>filterStats(c, s.track, !1))
  8904. }
  8905. }
  8906. if (!("getStats"in a.RTCRtpSender.prototype && "getStats"in a.RTCRtpReceiver.prototype))
  8907. return;
  8908. const e = a.RTCPeerConnection.prototype.getStats;
  8909. a.RTCPeerConnection.prototype.getStats = function() {
  8910. if (arguments.length > 0 && arguments[0]instanceof a.MediaStreamTrack) {
  8911. const o = arguments[0];
  8912. let s, c, d;
  8913. return this.getSenders().forEach(_=>{
  8914. _.track === o && (s ? d = !0 : s = _)
  8915. }
  8916. ),
  8917. this.getReceivers().forEach(_=>(_.track === o && (c ? d = !0 : c = _),
  8918. _.track === o)),
  8919. d || s && c ? Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")) : s ? s.getStats() : c ? c.getStats() : Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))
  8920. }
  8921. return e.apply(this, arguments)
  8922. }
  8923. }
  8924. function shimAddTrackRemoveTrackWithNative(a) {
  8925. a.RTCPeerConnection.prototype.getLocalStreams = function() {
  8926. return this._shimmedLocalStreams = this._shimmedLocalStreams || {},
  8927. Object.keys(this._shimmedLocalStreams).map(d=>this._shimmedLocalStreams[d][0])
  8928. }
  8929. ;
  8930. const e = a.RTCPeerConnection.prototype.addTrack;
  8931. a.RTCPeerConnection.prototype.addTrack = function(d, _) {
  8932. if (!_)
  8933. return e.apply(this, arguments);
  8934. this._shimmedLocalStreams = this._shimmedLocalStreams || {};
  8935. const b = e.apply(this, arguments);
  8936. return this._shimmedLocalStreams[_.id] ? this._shimmedLocalStreams[_.id].indexOf(b) === -1 && this._shimmedLocalStreams[_.id].push(b) : this._shimmedLocalStreams[_.id] = [_, b],
  8937. b
  8938. }
  8939. ;
  8940. const i = a.RTCPeerConnection.prototype.addStream;
  8941. a.RTCPeerConnection.prototype.addStream = function(d) {
  8942. this._shimmedLocalStreams = this._shimmedLocalStreams || {},
  8943. d.getTracks().forEach(k=>{
  8944. if (this.getSenders().find($=>$.track === k))
  8945. throw new DOMException("Track already exists.","InvalidAccessError")
  8946. }
  8947. );
  8948. const _ = this.getSenders();
  8949. i.apply(this, arguments);
  8950. const b = this.getSenders().filter(k=>_.indexOf(k) === -1);
  8951. this._shimmedLocalStreams[d.id] = [d].concat(b)
  8952. }
  8953. ;
  8954. const o = a.RTCPeerConnection.prototype.removeStream;
  8955. a.RTCPeerConnection.prototype.removeStream = function(d) {
  8956. return this._shimmedLocalStreams = this._shimmedLocalStreams || {},
  8957. delete this._shimmedLocalStreams[d.id],
  8958. o.apply(this, arguments)
  8959. }
  8960. ;
  8961. const s = a.RTCPeerConnection.prototype.removeTrack;
  8962. a.RTCPeerConnection.prototype.removeTrack = function(d) {
  8963. return this._shimmedLocalStreams = this._shimmedLocalStreams || {},
  8964. d && Object.keys(this._shimmedLocalStreams).forEach(_=>{
  8965. const b = this._shimmedLocalStreams[_].indexOf(d);
  8966. b !== -1 && this._shimmedLocalStreams[_].splice(b, 1),
  8967. this._shimmedLocalStreams[_].length === 1 && delete this._shimmedLocalStreams[_]
  8968. }
  8969. ),
  8970. s.apply(this, arguments)
  8971. }
  8972. }
  8973. function shimAddTrackRemoveTrack(a, e) {
  8974. if (!a.RTCPeerConnection)
  8975. return;
  8976. if (a.RTCPeerConnection.prototype.addTrack && e.version >= 65)
  8977. return shimAddTrackRemoveTrackWithNative(a);
  8978. const i = a.RTCPeerConnection.prototype.getLocalStreams;
  8979. a.RTCPeerConnection.prototype.getLocalStreams = function() {
  8980. const j = i.apply(this);
  8981. return this._reverseStreams = this._reverseStreams || {},
  8982. j.map($=>this._reverseStreams[$.id])
  8983. }
  8984. ;
  8985. const o = a.RTCPeerConnection.prototype.addStream;
  8986. a.RTCPeerConnection.prototype.addStream = function(j) {
  8987. if (this._streams = this._streams || {},
  8988. this._reverseStreams = this._reverseStreams || {},
  8989. j.getTracks().forEach($=>{
  8990. if (this.getSenders().find(et=>et.track === $))
  8991. throw new DOMException("Track already exists.","InvalidAccessError")
  8992. }
  8993. ),
  8994. !this._reverseStreams[j.id]) {
  8995. const $ = new a.MediaStream(j.getTracks());
  8996. this._streams[j.id] = $,
  8997. this._reverseStreams[$.id] = j,
  8998. j = $
  8999. }
  9000. o.apply(this, [j])
  9001. }
  9002. ;
  9003. const s = a.RTCPeerConnection.prototype.removeStream;
  9004. a.RTCPeerConnection.prototype.removeStream = function(j) {
  9005. this._streams = this._streams || {},
  9006. this._reverseStreams = this._reverseStreams || {},
  9007. s.apply(this, [this._streams[j.id] || j]),
  9008. delete this._reverseStreams[this._streams[j.id] ? this._streams[j.id].id : j.id],
  9009. delete this._streams[j.id]
  9010. }
  9011. ,
  9012. a.RTCPeerConnection.prototype.addTrack = function(j, $) {
  9013. if (this.signalingState === "closed")
  9014. throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");
  9015. const _e = [].slice.call(arguments, 1);
  9016. if (_e.length !== 1 || !_e[0].getTracks().find(rt=>rt === j))
  9017. throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");
  9018. if (this.getSenders().find(rt=>rt.track === j))
  9019. throw new DOMException("Track already exists.","InvalidAccessError");
  9020. this._streams = this._streams || {},
  9021. this._reverseStreams = this._reverseStreams || {};
  9022. const tt = this._streams[$.id];
  9023. if (tt)
  9024. tt.addTrack(j),
  9025. Promise.resolve().then(()=>{
  9026. this.dispatchEvent(new Event("negotiationneeded"))
  9027. }
  9028. );
  9029. else {
  9030. const rt = new a.MediaStream([j]);
  9031. this._streams[$.id] = rt,
  9032. this._reverseStreams[rt.id] = $,
  9033. this.addStream(rt)
  9034. }
  9035. return this.getSenders().find(rt=>rt.track === j)
  9036. }
  9037. ;
  9038. function c(k, j) {
  9039. let$ = j.sdp;
  9040. return Object.keys(k._reverseStreams || []).forEach(_e=>{
  9041. const et = k._reverseStreams[_e]
  9042. , tt = k._streams[et.id];
  9043. $ = $.replace(new RegExp(tt.id,"g"), et.id)
  9044. }
  9045. ),
  9046. new RTCSessionDescription({
  9047. type: j.type,
  9048. sdp: $
  9049. })
  9050. }
  9051. function d(k, j) {
  9052. let$ = j.sdp;
  9053. return Object.keys(k._reverseStreams || []).forEach(_e=>{
  9054. const et = k._reverseStreams[_e]
  9055. , tt = k._streams[et.id];
  9056. $ = $.replace(new RegExp(et.id,"g"), tt.id)
  9057. }
  9058. ),
  9059. new RTCSessionDescription({
  9060. type: j.type,
  9061. sdp: $
  9062. })
  9063. }
  9064. ["createOffer", "createAnswer"].forEach(function(k) {
  9065. const j = a.RTCPeerConnection.prototype[k]
  9066. , $ = {
  9067. [k]() {
  9068. const _e = arguments;
  9069. return arguments.length && typeof arguments[0] == "function" ? j.apply(this, [tt=>{
  9070. const rt = c(this, tt);
  9071. _e[0].apply(null, [rt])
  9072. }
  9073. , tt=>{
  9074. _e[1] && _e[1].apply(null, tt)
  9075. }
  9076. , arguments[2]]) : j.apply(this, arguments).then(tt=>c(this, tt))
  9077. }
  9078. };
  9079. a.RTCPeerConnection.prototype[k] = $[k]
  9080. });
  9081. const _ = a.RTCPeerConnection.prototype.setLocalDescription;
  9082. a.RTCPeerConnection.prototype.setLocalDescription = function() {
  9083. return !arguments.length || !arguments[0].type ? _.apply(this, arguments) : (arguments[0] = d(this, arguments[0]),
  9084. _.apply(this, arguments))
  9085. }
  9086. ;
  9087. const b = Object.getOwnPropertyDescriptor(a.RTCPeerConnection.prototype, "localDescription");
  9088. Object.defineProperty(a.RTCPeerConnection.prototype, "localDescription", {
  9089. get() {
  9090. const k = b.get.apply(this);
  9091. return k.type === "" ? k : c(this, k)
  9092. }
  9093. }),
  9094. a.RTCPeerConnection.prototype.removeTrack = function(j) {
  9095. if (this.signalingState === "closed")
  9096. throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");
  9097. if (!j._pc)
  9098. throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");
  9099. if (!(j._pc === this))
  9100. throw new DOMException("Sender was not created by this connection.","InvalidAccessError");
  9101. this._streams = this._streams || {};
  9102. let _e;
  9103. Object.keys(this._streams).forEach(et=>{
  9104. this._streams[et].getTracks().find(rt=>j.track === rt) && (_e = this._streams[et])
  9105. }
  9106. ),
  9107. _e && (_e.getTracks().length === 1 ? this.removeStream(this._reverseStreams[_e.id]) : _e.removeTrack(j.track),
  9108. this.dispatchEvent(new Event("negotiationneeded")))
  9109. }
  9110. }
  9111. function shimPeerConnection$1(a, e) {
  9112. !a.RTCPeerConnection && a.webkitRTCPeerConnection && (a.RTCPeerConnection = a.webkitRTCPeerConnection),
  9113. !!a.RTCPeerConnection && e.version < 53 && ["setLocalDescription", "setRemoteDescription", "addIceCandidate"].forEach(function(i) {
  9114. const o = a.RTCPeerConnection.prototype[i]
  9115. , s = {
  9116. [i]() {
  9117. return arguments[0] = new (i === "addIceCandidate" ? a.RTCIceCandidate : a.RTCSessionDescription)(arguments[0]),
  9118. o.apply(this, arguments)
  9119. }
  9120. };
  9121. a.RTCPeerConnection.prototype[i] = s[i]
  9122. })
  9123. }
  9124. function fixNegotiationNeeded(a, e) {
  9125. wrapPeerConnectionEvent(a, "negotiationneeded", i=>{
  9126. const o = i.target;
  9127. if (!((e.version < 72 || o.getConfiguration && o.getConfiguration().sdpSemantics === "plan-b") && o.signalingState !== "stable"))
  9128. return i
  9129. }
  9130. )
  9131. }
  9132. var chromeShim = Object.freeze(Object.defineProperty({
  9133. __proto__: null,
  9134. shimMediaStream,
  9135. shimOnTrack: shimOnTrack$1,
  9136. shimGetSendersWithDtmf,
  9137. shimGetStats,
  9138. shimSenderReceiverGetStats,
  9139. shimAddTrackRemoveTrackWithNative,
  9140. shimAddTrackRemoveTrack,
  9141. shimPeerConnection: shimPeerConnection$1,
  9142. fixNegotiationNeeded,
  9143. shimGetUserMedia: shimGetUserMedia$2,
  9144. shimGetDisplayMedia: shimGetDisplayMedia$1
  9145. }, Symbol.toStringTag, {
  9146. value: "Module"
  9147. }));
  9148. function shimGetUserMedia$1(a, e) {
  9149. const i = a && a.navigator
  9150. , o = a && a.MediaStreamTrack;
  9151. if (i.getUserMedia = function(s, c, d) {
  9152. deprecated("navigator.getUserMedia", "navigator.mediaDevices.getUserMedia"),
  9153. i.mediaDevices.getUserMedia(s).then(c, d)
  9154. }
  9155. ,
  9156. !(e.version > 55 && "autoGainControl"in i.mediaDevices.getSupportedConstraints())) {
  9157. const s = function(d, _, b) {
  9158. _ in d && !(b in d) && (d[b] = d[_],
  9159. delete d[_])
  9160. }
  9161. , c = i.mediaDevices.getUserMedia.bind(i.mediaDevices);
  9162. if (i.mediaDevices.getUserMedia = function(d) {
  9163. return typeof d == "object" && typeof d.audio == "object" && (d = JSON.parse(JSON.stringify(d)),
  9164. s(d.audio, "autoGainControl", "mozAutoGainControl"),
  9165. s(d.audio, "noiseSuppression", "mozNoiseSuppression")),
  9166. c(d)
  9167. }
  9168. ,
  9169. o && o.prototype.getSettings) {
  9170. const d = o.prototype.getSettings;
  9171. o.prototype.getSettings = function() {
  9172. const _ = d.apply(this, arguments);
  9173. return s(_, "mozAutoGainControl", "autoGainControl"),
  9174. s(_, "mozNoiseSuppression", "noiseSuppression"),
  9175. _
  9176. }
  9177. }
  9178. if (o && o.prototype.applyConstraints) {
  9179. const d = o.prototype.applyConstraints;
  9180. o.prototype.applyConstraints = function(_) {
  9181. return this.kind === "audio" && typeof _ == "object" && (_ = JSON.parse(JSON.stringify(_)),
  9182. s(_, "autoGainControl", "mozAutoGainControl"),
  9183. s(_, "noiseSuppression", "mozNoiseSuppression")),
  9184. d.apply(this, [_])
  9185. }
  9186. }
  9187. }
  9188. }
  9189. function shimGetDisplayMedia(a, e) {
  9190. a.navigator.mediaDevices && "getDisplayMedia"in a.navigator.mediaDevices || !a.navigator.mediaDevices || (a.navigator.mediaDevices.getDisplayMedia = function(o) {
  9191. if (!(o && o.video)) {
  9192. const s = new DOMException("getDisplayMedia without video constraints is undefined");
  9193. return s.name = "NotFoundError",
  9194. s.code = 8,
  9195. Promise.reject(s)
  9196. }
  9197. return o.video === !0 ? o.video = {
  9198. mediaSource: e
  9199. } : o.video.mediaSource = e,
  9200. a.navigator.mediaDevices.getUserMedia(o)
  9201. }
  9202. )
  9203. }
  9204. function shimOnTrack(a) {
  9205. typeof a == "object" && a.RTCTrackEvent && "receiver"in a.RTCTrackEvent.prototype && !("transceiver"in a.RTCTrackEvent.prototype) && Object.defineProperty(a.RTCTrackEvent.prototype, "transceiver", {
  9206. get() {
  9207. return {
  9208. receiver: this.receiver
  9209. }
  9210. }
  9211. })
  9212. }
  9213. function shimPeerConnection(a, e) {
  9214. if (typeof a != "object" || !(a.RTCPeerConnection || a.mozRTCPeerConnection))
  9215. return;
  9216. !a.RTCPeerConnection && a.mozRTCPeerConnection && (a.RTCPeerConnection = a.mozRTCPeerConnection),
  9217. e.version < 53 && ["setLocalDescription", "setRemoteDescription", "addIceCandidate"].forEach(function(s) {
  9218. const c = a.RTCPeerConnection.prototype[s]
  9219. , d = {
  9220. [s]() {
  9221. return arguments[0] = new (s === "addIceCandidate" ? a.RTCIceCandidate : a.RTCSessionDescription)(arguments[0]),
  9222. c.apply(this, arguments)
  9223. }
  9224. };
  9225. a.RTCPeerConnection.prototype[s] = d[s]
  9226. });
  9227. const i = {
  9228. inboundrtp: "inbound-rtp",
  9229. outboundrtp: "outbound-rtp",
  9230. candidatepair: "candidate-pair",
  9231. localcandidate: "local-candidate",
  9232. remotecandidate: "remote-candidate"
  9233. }
  9234. , o = a.RTCPeerConnection.prototype.getStats;
  9235. a.RTCPeerConnection.prototype.getStats = function() {
  9236. const [c,d,_] = arguments;
  9237. return o.apply(this, [c || null]).then(b=>{
  9238. if (e.version < 53 && !d)
  9239. try {
  9240. b.forEach(k=>{
  9241. k.type = i[k.type] || k.type
  9242. }
  9243. )
  9244. } catch (k) {
  9245. if (k.name !== "TypeError")
  9246. throw k;
  9247. b.forEach((j,$)=>{
  9248. b.set($, Object.assign({}, j, {
  9249. type: i[j.type] || j.type
  9250. }))
  9251. }
  9252. )
  9253. }
  9254. return b
  9255. }
  9256. ).then(d, _)
  9257. }
  9258. }
  9259. function shimSenderGetStats(a) {
  9260. if (!(typeof a == "object" && a.RTCPeerConnection && a.RTCRtpSender) || a.RTCRtpSender && "getStats"in a.RTCRtpSender.prototype)
  9261. return;
  9262. const e = a.RTCPeerConnection.prototype.getSenders;
  9263. e && (a.RTCPeerConnection.prototype.getSenders = function() {
  9264. const s = e.apply(this, []);
  9265. return s.forEach(c=>c._pc = this),
  9266. s
  9267. }
  9268. );
  9269. const i = a.RTCPeerConnection.prototype.addTrack;
  9270. i && (a.RTCPeerConnection.prototype.addTrack = function() {
  9271. const s = i.apply(this, arguments);
  9272. return s._pc = this,
  9273. s
  9274. }
  9275. ),
  9276. a.RTCRtpSender.prototype.getStats = function() {
  9277. return this.track ? this._pc.getStats(this.track) : Promise.resolve(new Map)
  9278. }
  9279. }
  9280. function shimReceiverGetStats(a) {
  9281. if (!(typeof a == "object" && a.RTCPeerConnection && a.RTCRtpSender) || a.RTCRtpSender && "getStats"in a.RTCRtpReceiver.prototype)
  9282. return;
  9283. const e = a.RTCPeerConnection.prototype.getReceivers;
  9284. e && (a.RTCPeerConnection.prototype.getReceivers = function() {
  9285. const o = e.apply(this, []);
  9286. return o.forEach(s=>s._pc = this),
  9287. o
  9288. }
  9289. ),
  9290. wrapPeerConnectionEvent(a, "track", i=>(i.receiver._pc = i.srcElement,
  9291. i)),
  9292. a.RTCRtpReceiver.prototype.getStats = function() {
  9293. return this._pc.getStats(this.track)
  9294. }
  9295. }
  9296. function shimRemoveStream(a) {
  9297. !a.RTCPeerConnection || "removeStream"in a.RTCPeerConnection.prototype || (a.RTCPeerConnection.prototype.removeStream = function(i) {
  9298. deprecated("removeStream", "removeTrack"),
  9299. this.getSenders().forEach(o=>{
  9300. o.track && i.getTracks().includes(o.track) && this.removeTrack(o)
  9301. }
  9302. )
  9303. }
  9304. )
  9305. }
  9306. function shimRTCDataChannel(a) {
  9307. a.DataChannel && !a.RTCDataChannel && (a.RTCDataChannel = a.DataChannel)
  9308. }
  9309. function shimAddTransceiver(a) {
  9310. if (!(typeof a == "object" && a.RTCPeerConnection))
  9311. return;
  9312. const e = a.RTCPeerConnection.prototype.addTransceiver;
  9313. e && (a.RTCPeerConnection.prototype.addTransceiver = function() {
  9314. this.setParametersPromises = [];
  9315. const o = arguments[1]
  9316. , s = o && "sendEncodings"in o;
  9317. s && o.sendEncodings.forEach(d=>{
  9318. if ("rid"in d && !/^[a-z0-9]{0,16}$/i.test(d.rid))
  9319. throw new TypeError("Invalid RID value provided.");
  9320. if ("scaleResolutionDownBy"in d && !(parseFloat(d.scaleResolutionDownBy) >= 1))
  9321. throw new RangeError("scale_resolution_down_by must be >= 1.0");
  9322. if ("maxFramerate"in d && !(parseFloat(d.maxFramerate) >= 0))
  9323. throw new RangeError("max_framerate must be >= 0.0")
  9324. }
  9325. );
  9326. const c = e.apply(this, arguments);
  9327. if (s) {
  9328. const {sender: d} = c
  9329. , _ = d.getParameters();
  9330. (!("encodings"in _) || _.encodings.length === 1 && Object.keys(_.encodings[0]).length === 0) && (_.encodings = o.sendEncodings,
  9331. d.sendEncodings = o.sendEncodings,
  9332. this.setParametersPromises.push(d.setParameters(_).then(()=>{
  9333. delete d.sendEncodings
  9334. }
  9335. ).catch(()=>{
  9336. delete d.sendEncodings
  9337. }
  9338. )))
  9339. }
  9340. return c
  9341. }
  9342. )
  9343. }
  9344. function shimGetParameters(a) {
  9345. if (!(typeof a == "object" && a.RTCRtpSender))
  9346. return;
  9347. const e = a.RTCRtpSender.prototype.getParameters;
  9348. e && (a.RTCRtpSender.prototype.getParameters = function() {
  9349. const o = e.apply(this, arguments);
  9350. return "encodings"in o || (o.encodings = [].concat(this.sendEncodings || [{}])),
  9351. o
  9352. }
  9353. )
  9354. }
  9355. function shimCreateOffer(a) {
  9356. if (!(typeof a == "object" && a.RTCPeerConnection))
  9357. return;
  9358. const e = a.RTCPeerConnection.prototype.createOffer;
  9359. a.RTCPeerConnection.prototype.createOffer = function() {
  9360. return this.setParametersPromises && this.setParametersPromises.length ? Promise.all(this.setParametersPromises).then(()=>e.apply(this, arguments)).finally(()=>{
  9361. this.setParametersPromises = []
  9362. }
  9363. ) : e.apply(this, arguments)
  9364. }
  9365. }
  9366. function shimCreateAnswer(a) {
  9367. if (!(typeof a == "object" && a.RTCPeerConnection))
  9368. return;
  9369. const e = a.RTCPeerConnection.prototype.createAnswer;
  9370. a.RTCPeerConnection.prototype.createAnswer = function() {
  9371. return this.setParametersPromises && this.setParametersPromises.length ? Promise.all(this.setParametersPromises).then(()=>e.apply(this, arguments)).finally(()=>{
  9372. this.setParametersPromises = []
  9373. }
  9374. ) : e.apply(this, arguments)
  9375. }
  9376. }
  9377. var firefoxShim = Object.freeze(Object.defineProperty({
  9378. __proto__: null,
  9379. shimOnTrack,
  9380. shimPeerConnection,
  9381. shimSenderGetStats,
  9382. shimReceiverGetStats,
  9383. shimRemoveStream,
  9384. shimRTCDataChannel,
  9385. shimAddTransceiver,
  9386. shimGetParameters,
  9387. shimCreateOffer,
  9388. shimCreateAnswer,
  9389. shimGetUserMedia: shimGetUserMedia$1,
  9390. shimGetDisplayMedia
  9391. }, Symbol.toStringTag, {
  9392. value: "Module"
  9393. }));
  9394. function shimLocalStreamsAPI(a) {
  9395. if (!(typeof a != "object" || !a.RTCPeerConnection)) {
  9396. if ("getLocalStreams"in a.RTCPeerConnection.prototype || (a.RTCPeerConnection.prototype.getLocalStreams = function() {
  9397. return this._localStreams || (this._localStreams = []),
  9398. this._localStreams
  9399. }
  9400. ),
  9401. !("addStream"in a.RTCPeerConnection.prototype)) {
  9402. const e = a.RTCPeerConnection.prototype.addTrack;
  9403. a.RTCPeerConnection.prototype.addStream = function(o) {
  9404. this._localStreams || (this._localStreams = []),
  9405. this._localStreams.includes(o) || this._localStreams.push(o),
  9406. o.getAudioTracks().forEach(s=>e.call(this, s, o)),
  9407. o.getVideoTracks().forEach(s=>e.call(this, s, o))
  9408. }
  9409. ,
  9410. a.RTCPeerConnection.prototype.addTrack = function(o, ...s) {
  9411. return s && s.forEach(c=>{
  9412. this._localStreams ? this._localStreams.includes(c) || this._localStreams.push(c) : this._localStreams = [c]
  9413. }
  9414. ),
  9415. e.apply(this, arguments)
  9416. }
  9417. }
  9418. "removeStream"in a.RTCPeerConnection.prototype || (a.RTCPeerConnection.prototype.removeStream = function(i) {
  9419. this._localStreams || (this._localStreams = []);
  9420. const o = this._localStreams.indexOf(i);
  9421. if (o === -1)
  9422. return;
  9423. this._localStreams.splice(o, 1);
  9424. const s = i.getTracks();
  9425. this.getSenders().forEach(c=>{
  9426. s.includes(c.track) && this.removeTrack(c)
  9427. }
  9428. )
  9429. }
  9430. )
  9431. }
  9432. }
  9433. function shimRemoteStreamsAPI(a) {
  9434. if (!(typeof a != "object" || !a.RTCPeerConnection) && ("getRemoteStreams"in a.RTCPeerConnection.prototype || (a.RTCPeerConnection.prototype.getRemoteStreams = function() {
  9435. return this._remoteStreams ? this._remoteStreams : []
  9436. }
  9437. ),
  9438. !("onaddstream"in a.RTCPeerConnection.prototype))) {
  9439. Object.defineProperty(a.RTCPeerConnection.prototype, "onaddstream", {
  9440. get() {
  9441. return this._onaddstream
  9442. },
  9443. set(i) {
  9444. this._onaddstream && (this.removeEventListener("addstream", this._onaddstream),
  9445. this.removeEventListener("track", this._onaddstreampoly)),
  9446. this.addEventListener("addstream", this._onaddstream = i),
  9447. this.addEventListener("track", this._onaddstreampoly = o=>{
  9448. o.streams.forEach(s=>{
  9449. if (this._remoteStreams || (this._remoteStreams = []),
  9450. this._remoteStreams.includes(s))
  9451. return;
  9452. this._remoteStreams.push(s);
  9453. const c = new Event("addstream");
  9454. c.stream = s,
  9455. this.dispatchEvent(c)
  9456. }
  9457. )
  9458. }
  9459. )
  9460. }
  9461. });
  9462. const e = a.RTCPeerConnection.prototype.setRemoteDescription;
  9463. a.RTCPeerConnection.prototype.setRemoteDescription = function() {
  9464. const o = this;
  9465. return this._onaddstreampoly || this.addEventListener("track", this._onaddstreampoly = function(s) {
  9466. s.streams.forEach(c=>{
  9467. if (o._remoteStreams || (o._remoteStreams = []),
  9468. o._remoteStreams.indexOf(c) >= 0)
  9469. return;
  9470. o._remoteStreams.push(c);
  9471. const d = new Event("addstream");
  9472. d.stream = c,
  9473. o.dispatchEvent(d)
  9474. }
  9475. )
  9476. }
  9477. ),
  9478. e.apply(o, arguments)
  9479. }
  9480. }
  9481. }
  9482. function shimCallbacksAPI(a) {
  9483. if (typeof a != "object" || !a.RTCPeerConnection)
  9484. return;
  9485. const e = a.RTCPeerConnection.prototype
  9486. , i = e.createOffer
  9487. , o = e.createAnswer
  9488. , s = e.setLocalDescription
  9489. , c = e.setRemoteDescription
  9490. , d = e.addIceCandidate;
  9491. e.createOffer = function(k, j) {
  9492. const $ = arguments.length >= 2 ? arguments[2] : arguments[0]
  9493. , _e = i.apply(this, [$]);
  9494. return j ? (_e.then(k, j),
  9495. Promise.resolve()) : _e
  9496. }
  9497. ,
  9498. e.createAnswer = function(k, j) {
  9499. const $ = arguments.length >= 2 ? arguments[2] : arguments[0]
  9500. , _e = o.apply(this, [$]);
  9501. return j ? (_e.then(k, j),
  9502. Promise.resolve()) : _e
  9503. }
  9504. ;
  9505. let _ = function(b, k, j) {
  9506. const $ = s.apply(this, [b]);
  9507. return j ? ($.then(k, j),
  9508. Promise.resolve()) : $
  9509. };
  9510. e.setLocalDescription = _,
  9511. _ = function(b, k, j) {
  9512. const $ = c.apply(this, [b]);
  9513. return j ? ($.then(k, j),
  9514. Promise.resolve()) : $
  9515. }
  9516. ,
  9517. e.setRemoteDescription = _,
  9518. _ = function(b, k, j) {
  9519. const $ = d.apply(this, [b]);
  9520. return j ? ($.then(k, j),
  9521. Promise.resolve()) : $
  9522. }
  9523. ,
  9524. e.addIceCandidate = _
  9525. }
  9526. function shimGetUserMedia(a) {
  9527. const e = a && a.navigator;
  9528. if (e.mediaDevices && e.mediaDevices.getUserMedia) {
  9529. const i = e.mediaDevices
  9530. , o = i.getUserMedia.bind(i);
  9531. e.mediaDevices.getUserMedia = s=>o(shimConstraints(s))
  9532. }
  9533. !e.getUserMedia && e.mediaDevices && e.mediaDevices.getUserMedia && (e.getUserMedia = function(o, s, c) {
  9534. e.mediaDevices.getUserMedia(o).then(s, c)
  9535. }
  9536. .bind(e))
  9537. }
  9538. function shimConstraints(a) {
  9539. return a && a.video !== void 0 ? Object.assign({}, a, {
  9540. video: compactObject(a.video)
  9541. }) : a
  9542. }
  9543. function shimRTCIceServerUrls(a) {
  9544. if (!a.RTCPeerConnection)
  9545. return;
  9546. const e = a.RTCPeerConnection;
  9547. a.RTCPeerConnection = function(o, s) {
  9548. if (o && o.iceServers) {
  9549. const c = [];
  9550. for (let d = 0; d < o.iceServers.length; d++) {
  9551. let _ = o.iceServers[d];
  9552. !_.hasOwnProperty("urls") && _.hasOwnProperty("url") ? (deprecated("RTCIceServer.url", "RTCIceServer.urls"),
  9553. _ = JSON.parse(JSON.stringify(_)),
  9554. _.urls = _.url,
  9555. delete _.url,
  9556. c.push(_)) : c.push(o.iceServers[d])
  9557. }
  9558. o.iceServers = c
  9559. }
  9560. return new e(o,s)
  9561. }
  9562. ,
  9563. a.RTCPeerConnection.prototype = e.prototype,
  9564. "generateCertificate"in e && Object.defineProperty(a.RTCPeerConnection, "generateCertificate", {
  9565. get() {
  9566. return e.generateCertificate
  9567. }
  9568. })
  9569. }
  9570. function shimTrackEventTransceiver(a) {
  9571. typeof a == "object" && a.RTCTrackEvent && "receiver"in a.RTCTrackEvent.prototype && !("transceiver"in a.RTCTrackEvent.prototype) && Object.defineProperty(a.RTCTrackEvent.prototype, "transceiver", {
  9572. get() {
  9573. return {
  9574. receiver: this.receiver
  9575. }
  9576. }
  9577. })
  9578. }
  9579. function shimCreateOfferLegacy(a) {
  9580. const e = a.RTCPeerConnection.prototype.createOffer;
  9581. a.RTCPeerConnection.prototype.createOffer = function(o) {
  9582. if (o) {
  9583. typeof o.offerToReceiveAudio != "undefined" && (o.offerToReceiveAudio = !!o.offerToReceiveAudio);
  9584. const s = this.getTransceivers().find(d=>d.receiver.track.kind === "audio");
  9585. o.offerToReceiveAudio === !1 && s ? s.direction === "sendrecv" ? s.setDirection ? s.setDirection("sendonly") : s.direction = "sendonly" : s.direction === "recvonly" && (s.setDirection ? s.setDirection("inactive") : s.direction = "inactive") : o.offerToReceiveAudio === !0 && !s && this.addTransceiver("audio", {
  9586. direction: "recvonly"
  9587. }),
  9588. typeof o.offerToReceiveVideo != "undefined" && (o.offerToReceiveVideo = !!o.offerToReceiveVideo);
  9589. const c = this.getTransceivers().find(d=>d.receiver.track.kind === "video");
  9590. o.offerToReceiveVideo === !1 && c ? c.direction === "sendrecv" ? c.setDirection ? c.setDirection("sendonly") : c.direction = "sendonly" : c.direction === "recvonly" && (c.setDirection ? c.setDirection("inactive") : c.direction = "inactive") : o.offerToReceiveVideo === !0 && !c && this.addTransceiver("video", {
  9591. direction: "recvonly"
  9592. })
  9593. }
  9594. return e.apply(this, arguments)
  9595. }
  9596. }
  9597. function shimAudioContext(a) {
  9598. typeof a != "object" || a.AudioContext || (a.AudioContext = a.webkitAudioContext)
  9599. }
  9600. var safariShim = Object.freeze(Object.defineProperty({
  9601. __proto__: null,
  9602. shimLocalStreamsAPI,
  9603. shimRemoteStreamsAPI,
  9604. shimCallbacksAPI,
  9605. shimGetUserMedia,
  9606. shimConstraints,
  9607. shimRTCIceServerUrls,
  9608. shimTrackEventTransceiver,
  9609. shimCreateOfferLegacy,
  9610. shimAudioContext
  9611. }, Symbol.toStringTag, {
  9612. value: "Module"
  9613. }))
  9614. , sdp$1 = {
  9615. exports: {}
  9616. };
  9617. (function(a) {
  9618. const e = {};
  9619. e.generateIdentifier = function() {
  9620. return Math.random().toString(36).substr(2, 10)
  9621. }
  9622. ,
  9623. e.localCName = e.generateIdentifier(),
  9624. e.splitLines = function(i) {
  9625. return i.trim().split(`
  9626. `).map(o=>o.trim())
  9627. }
  9628. ,
  9629. e.splitSections = function(i) {
  9630. return i.split(`
  9631. m=`).map((s,c)=>(c > 0 ? "m=" + s : s).trim() + `\r
  9632. `)
  9633. }
  9634. ,
  9635. e.getDescription = function(i) {
  9636. const o = e.splitSections(i);
  9637. return o && o[0]
  9638. }
  9639. ,
  9640. e.getMediaSections = function(i) {
  9641. const o = e.splitSections(i);
  9642. return o.shift(),
  9643. o
  9644. }
  9645. ,
  9646. e.matchPrefix = function(i, o) {
  9647. return e.splitLines(i).filter(s=>s.indexOf(o) === 0)
  9648. }
  9649. ,
  9650. e.parseCandidate = function(i) {
  9651. let o;
  9652. i.indexOf("a=candidate:") === 0 ? o = i.substring(12).split(" ") : o = i.substring(10).split(" ");
  9653. const s = {
  9654. foundation: o[0],
  9655. component: {
  9656. 1: "rtp",
  9657. 2: "rtcp"
  9658. }[o[1]] || o[1],
  9659. protocol: o[2].toLowerCase(),
  9660. priority: parseInt(o[3], 10),
  9661. ip: o[4],
  9662. address: o[4],
  9663. port: parseInt(o[5], 10),
  9664. type: o[7]
  9665. };
  9666. for (let c = 8; c < o.length; c += 2)
  9667. switch (o[c]) {
  9668. case "raddr":
  9669. s.relatedAddress = o[c + 1];
  9670. break;
  9671. case "rport":
  9672. s.relatedPort = parseInt(o[c + 1], 10);
  9673. break;
  9674. case "tcptype":
  9675. s.tcpType = o[c + 1];
  9676. break;
  9677. case "ufrag":
  9678. s.ufrag = o[c + 1],
  9679. s.usernameFragment = o[c + 1];
  9680. break;
  9681. default:
  9682. s[o[c]] === void 0 && (s[o[c]] = o[c + 1]);
  9683. break
  9684. }
  9685. return s
  9686. }
  9687. ,
  9688. e.writeCandidate = function(i) {
  9689. const o = [];
  9690. o.push(i.foundation);
  9691. const s = i.component;
  9692. s === "rtp" ? o.push(1) : s === "rtcp" ? o.push(2) : o.push(s),
  9693. o.push(i.protocol.toUpperCase()),
  9694. o.push(i.priority),
  9695. o.push(i.address || i.ip),
  9696. o.push(i.port);
  9697. const c = i.type;
  9698. return o.push("typ"),
  9699. o.push(c),
  9700. c !== "host" && i.relatedAddress && i.relatedPort && (o.push("raddr"),
  9701. o.push(i.relatedAddress),
  9702. o.push("rport"),
  9703. o.push(i.relatedPort)),
  9704. i.tcpType && i.protocol.toLowerCase() === "tcp" && (o.push("tcptype"),
  9705. o.push(i.tcpType)),
  9706. (i.usernameFragment || i.ufrag) && (o.push("ufrag"),
  9707. o.push(i.usernameFragment || i.ufrag)),
  9708. "candidate:" + o.join(" ")
  9709. }
  9710. ,
  9711. e.parseIceOptions = function(i) {
  9712. return i.substr(14).split(" ")
  9713. }
  9714. ,
  9715. e.parseRtpMap = function(i) {
  9716. let o = i.substr(9).split(" ");
  9717. const s = {
  9718. payloadType: parseInt(o.shift(), 10)
  9719. };
  9720. return o = o[0].split("/"),
  9721. s.name = o[0],
  9722. s.clockRate = parseInt(o[1], 10),
  9723. s.channels = o.length === 3 ? parseInt(o[2], 10) : 1,
  9724. s.numChannels = s.channels,
  9725. s
  9726. }
  9727. ,
  9728. e.writeRtpMap = function(i) {
  9729. let o = i.payloadType;
  9730. i.preferredPayloadType !== void 0 && (o = i.preferredPayloadType);
  9731. const s = i.channels || i.numChannels || 1;
  9732. return "a=rtpmap:" + o + " " + i.name + "/" + i.clockRate + (s !== 1 ? "/" + s : "") + `\r
  9733. `
  9734. }
  9735. ,
  9736. e.parseExtmap = function(i) {
  9737. const o = i.substr(9).split(" ");
  9738. return {
  9739. id: parseInt(o[0], 10),
  9740. direction: o[0].indexOf("/") > 0 ? o[0].split("/")[1] : "sendrecv",
  9741. uri: o[1]
  9742. }
  9743. }
  9744. ,
  9745. e.writeExtmap = function(i) {
  9746. return "a=extmap:" + (i.id || i.preferredId) + (i.direction && i.direction !== "sendrecv" ? "/" + i.direction : "") + " " + i.uri + `\r
  9747. `
  9748. }
  9749. ,
  9750. e.parseFmtp = function(i) {
  9751. const o = {};
  9752. let s;
  9753. const c = i.substr(i.indexOf(" ") + 1).split(";");
  9754. for (let d = 0; d < c.length; d++)
  9755. s = c[d].trim().split("="),
  9756. o[s[0].trim()] = s[1];
  9757. return o
  9758. }
  9759. ,
  9760. e.writeFmtp = function(i) {
  9761. let o = ""
  9762. , s = i.payloadType;
  9763. if (i.preferredPayloadType !== void 0 && (s = i.preferredPayloadType),
  9764. i.parameters && Object.keys(i.parameters).length) {
  9765. const c = [];
  9766. Object.keys(i.parameters).forEach(d=>{
  9767. i.parameters[d] !== void 0 ? c.push(d + "=" + i.parameters[d]) : c.push(d)
  9768. }
  9769. ),
  9770. o += "a=fmtp:" + s + " " + c.join(";") + `\r
  9771. `
  9772. }
  9773. return o
  9774. }
  9775. ,
  9776. e.parseRtcpFb = function(i) {
  9777. const o = i.substr(i.indexOf(" ") + 1).split(" ");
  9778. return {
  9779. type: o.shift(),
  9780. parameter: o.join(" ")
  9781. }
  9782. }
  9783. ,
  9784. e.writeRtcpFb = function(i) {
  9785. let o = ""
  9786. , s = i.payloadType;
  9787. return i.preferredPayloadType !== void 0 && (s = i.preferredPayloadType),
  9788. i.rtcpFeedback && i.rtcpFeedback.length && i.rtcpFeedback.forEach(c=>{
  9789. o += "a=rtcp-fb:" + s + " " + c.type + (c.parameter && c.parameter.length ? " " + c.parameter : "") + `\r
  9790. `
  9791. }
  9792. ),
  9793. o
  9794. }
  9795. ,
  9796. e.parseSsrcMedia = function(i) {
  9797. const o = i.indexOf(" ")
  9798. , s = {
  9799. ssrc: parseInt(i.substr(7, o - 7), 10)
  9800. }
  9801. , c = i.indexOf(":", o);
  9802. return c > -1 ? (s.attribute = i.substr(o + 1, c - o - 1),
  9803. s.value = i.substr(c + 1)) : s.attribute = i.substr(o + 1),
  9804. s
  9805. }
  9806. ,
  9807. e.parseSsrcGroup = function(i) {
  9808. const o = i.substr(13).split(" ");
  9809. return {
  9810. semantics: o.shift(),
  9811. ssrcs: o.map(s=>parseInt(s, 10))
  9812. }
  9813. }
  9814. ,
  9815. e.getMid = function(i) {
  9816. const o = e.matchPrefix(i, "a=mid:")[0];
  9817. if (o)
  9818. return o.substr(6)
  9819. }
  9820. ,
  9821. e.parseFingerprint = function(i) {
  9822. const o = i.substr(14).split(" ");
  9823. return {
  9824. algorithm: o[0].toLowerCase(),
  9825. value: o[1].toUpperCase()
  9826. }
  9827. }
  9828. ,
  9829. e.getDtlsParameters = function(i, o) {
  9830. const s = e.matchPrefix(i + o, "a=fingerprint:");
  9831. return {
  9832. role: "auto",
  9833. fingerprints: s.map(e.parseFingerprint)
  9834. }
  9835. }
  9836. ,
  9837. e.writeDtlsParameters = function(i, o) {
  9838. let s = "a=setup:" + o + `\r
  9839. `;
  9840. return i.fingerprints.forEach(c=>{
  9841. s += "a=fingerprint:" + c.algorithm + " " + c.value + `\r
  9842. `
  9843. }
  9844. ),
  9845. s
  9846. }
  9847. ,
  9848. e.parseCryptoLine = function(i) {
  9849. const o = i.substr(9).split(" ");
  9850. return {
  9851. tag: parseInt(o[0], 10),
  9852. cryptoSuite: o[1],
  9853. keyParams: o[2],
  9854. sessionParams: o.slice(3)
  9855. }
  9856. }
  9857. ,
  9858. e.writeCryptoLine = function(i) {
  9859. return "a=crypto:" + i.tag + " " + i.cryptoSuite + " " + (typeof i.keyParams == "object" ? e.writeCryptoKeyParams(i.keyParams) : i.keyParams) + (i.sessionParams ? " " + i.sessionParams.join(" ") : "") + `\r
  9860. `
  9861. }
  9862. ,
  9863. e.parseCryptoKeyParams = function(i) {
  9864. if (i.indexOf("inline:") !== 0)
  9865. return null;
  9866. const o = i.substr(7).split("|");
  9867. return {
  9868. keyMethod: "inline",
  9869. keySalt: o[0],
  9870. lifeTime: o[1],
  9871. mkiValue: o[2] ? o[2].split(":")[0] : void 0,
  9872. mkiLength: o[2] ? o[2].split(":")[1] : void 0
  9873. }
  9874. }
  9875. ,
  9876. e.writeCryptoKeyParams = function(i) {
  9877. return i.keyMethod + ":" + i.keySalt + (i.lifeTime ? "|" + i.lifeTime : "") + (i.mkiValue && i.mkiLength ? "|" + i.mkiValue + ":" + i.mkiLength : "")
  9878. }
  9879. ,
  9880. e.getCryptoParameters = function(i, o) {
  9881. return e.matchPrefix(i + o, "a=crypto:").map(e.parseCryptoLine)
  9882. }
  9883. ,
  9884. e.getIceParameters = function(i, o) {
  9885. const s = e.matchPrefix(i + o, "a=ice-ufrag:")[0]
  9886. , c = e.matchPrefix(i + o, "a=ice-pwd:")[0];
  9887. return s && c ? {
  9888. usernameFragment: s.substr(12),
  9889. password: c.substr(10)
  9890. } : null
  9891. }
  9892. ,
  9893. e.writeIceParameters = function(i) {
  9894. let o = "a=ice-ufrag:" + i.usernameFragment + `\r
  9895. a=ice-pwd:` + i.password + `\r
  9896. `;
  9897. return i.iceLite && (o += `a=ice-lite\r
  9898. `),
  9899. o
  9900. }
  9901. ,
  9902. e.parseRtpParameters = function(i) {
  9903. const o = {
  9904. codecs: [],
  9905. headerExtensions: [],
  9906. fecMechanisms: [],
  9907. rtcp: []
  9908. }
  9909. , c = e.splitLines(i)[0].split(" ");
  9910. for (let d = 3; d < c.length; d++) {
  9911. const _ = c[d]
  9912. , b = e.matchPrefix(i, "a=rtpmap:" + _ + " ")[0];
  9913. if (b) {
  9914. const k = e.parseRtpMap(b)
  9915. , j = e.matchPrefix(i, "a=fmtp:" + _ + " ");
  9916. switch (k.parameters = j.length ? e.parseFmtp(j[0]) : {},
  9917. k.rtcpFeedback = e.matchPrefix(i, "a=rtcp-fb:" + _ + " ").map(e.parseRtcpFb),
  9918. o.codecs.push(k),
  9919. k.name.toUpperCase()) {
  9920. case "RED":
  9921. case "ULPFEC":
  9922. o.fecMechanisms.push(k.name.toUpperCase());
  9923. break
  9924. }
  9925. }
  9926. }
  9927. return e.matchPrefix(i, "a=extmap:").forEach(d=>{
  9928. o.headerExtensions.push(e.parseExtmap(d))
  9929. }
  9930. ),
  9931. o
  9932. }
  9933. ,
  9934. e.writeRtpDescription = function(i, o) {
  9935. let s = "";
  9936. s += "m=" + i + " ",
  9937. s += o.codecs.length > 0 ? "9" : "0",
  9938. s += " UDP/TLS/RTP/SAVPF ",
  9939. s += o.codecs.map(d=>d.preferredPayloadType !== void 0 ? d.preferredPayloadType : d.payloadType).join(" ") + `\r
  9940. `,
  9941. s += `c=IN IP4 0.0.0.0\r
  9942. `,
  9943. s += `a=rtcp:9 IN IP4 0.0.0.0\r
  9944. `,
  9945. o.codecs.forEach(d=>{
  9946. s += e.writeRtpMap(d),
  9947. s += e.writeFmtp(d),
  9948. s += e.writeRtcpFb(d)
  9949. }
  9950. );
  9951. let c = 0;
  9952. return o.codecs.forEach(d=>{
  9953. d.maxptime > c && (c = d.maxptime)
  9954. }
  9955. ),
  9956. c > 0 && (s += "a=maxptime:" + c + `\r
  9957. `),
  9958. o.headerExtensions && o.headerExtensions.forEach(d=>{
  9959. s += e.writeExtmap(d)
  9960. }
  9961. ),
  9962. s
  9963. }
  9964. ,
  9965. e.parseRtpEncodingParameters = function(i) {
  9966. const o = []
  9967. , s = e.parseRtpParameters(i)
  9968. , c = s.fecMechanisms.indexOf("RED") !== -1
  9969. , d = s.fecMechanisms.indexOf("ULPFEC") !== -1
  9970. , _ = e.matchPrefix(i, "a=ssrc:").map(_e=>e.parseSsrcMedia(_e)).filter(_e=>_e.attribute === "cname")
  9971. , b = _.length > 0 && _[0].ssrc;
  9972. let k;
  9973. const j = e.matchPrefix(i, "a=ssrc-group:FID").map(_e=>_e.substr(17).split(" ").map(tt=>parseInt(tt, 10)));
  9974. j.length > 0 && j[0].length > 1 && j[0][0] === b && (k = j[0][1]),
  9975. s.codecs.forEach(_e=>{
  9976. if (_e.name.toUpperCase() === "RTX" && _e.parameters.apt) {
  9977. let et = {
  9978. ssrc: b,
  9979. codecPayloadType: parseInt(_e.parameters.apt, 10)
  9980. };
  9981. b && k && (et.rtx = {
  9982. ssrc: k
  9983. }),
  9984. o.push(et),
  9985. c && (et = JSON.parse(JSON.stringify(et)),
  9986. et.fec = {
  9987. ssrc: b,
  9988. mechanism: d ? "red+ulpfec" : "red"
  9989. },
  9990. o.push(et))
  9991. }
  9992. }
  9993. ),
  9994. o.length === 0 && b && o.push({
  9995. ssrc: b
  9996. });
  9997. let$ = e.matchPrefix(i, "b=");
  9998. return $.length && ($[0].indexOf("b=TIAS:") === 0 ? $ = parseInt($[0].substr(7), 10) : $[0].indexOf("b=AS:") === 0 ? $ = parseInt($[0].substr(5), 10) * 1e3 * .95 - 50 * 40 * 8 : $ = void 0,
  9999. o.forEach(_e=>{
  10000. _e.maxBitrate = $
  10001. }
  10002. )),
  10003. o
  10004. }
  10005. ,
  10006. e.parseRtcpParameters = function(i) {
  10007. const o = {}
  10008. , s = e.matchPrefix(i, "a=ssrc:").map(_=>e.parseSsrcMedia(_)).filter(_=>_.attribute === "cname")[0];
  10009. s && (o.cname = s.value,
  10010. o.ssrc = s.ssrc);
  10011. const c = e.matchPrefix(i, "a=rtcp-rsize");
  10012. o.reducedSize = c.length > 0,
  10013. o.compound = c.length === 0;
  10014. const d = e.matchPrefix(i, "a=rtcp-mux");
  10015. return o.mux = d.length > 0,
  10016. o
  10017. }
  10018. ,
  10019. e.writeRtcpParameters = function(i) {
  10020. let o = "";
  10021. return i.reducedSize && (o += `a=rtcp-rsize\r
  10022. `),
  10023. i.mux && (o += `a=rtcp-mux\r
  10024. `),
  10025. i.ssrc !== void 0 && i.cname && (o += "a=ssrc:" + i.ssrc + " cname:" + i.cname + `\r
  10026. `),
  10027. o
  10028. }
  10029. ,
  10030. e.parseMsid = function(i) {
  10031. let o;
  10032. const s = e.matchPrefix(i, "a=msid:");
  10033. if (s.length === 1)
  10034. return o = s[0].substr(7).split(" "),
  10035. {
  10036. stream: o[0],
  10037. track: o[1]
  10038. };
  10039. const c = e.matchPrefix(i, "a=ssrc:").map(d=>e.parseSsrcMedia(d)).filter(d=>d.attribute === "msid");
  10040. if (c.length > 0)
  10041. return o = c[0].value.split(" "),
  10042. {
  10043. stream: o[0],
  10044. track: o[1]
  10045. }
  10046. }
  10047. ,
  10048. e.parseSctpDescription = function(i) {
  10049. const o = e.parseMLine(i)
  10050. , s = e.matchPrefix(i, "a=max-message-size:");
  10051. let c;
  10052. s.length > 0 && (c = parseInt(s[0].substr(19), 10)),
  10053. isNaN(c) && (c = 65536);
  10054. const d = e.matchPrefix(i, "a=sctp-port:");
  10055. if (d.length > 0)
  10056. return {
  10057. port: parseInt(d[0].substr(12), 10),
  10058. protocol: o.fmt,
  10059. maxMessageSize: c
  10060. };
  10061. const _ = e.matchPrefix(i, "a=sctpmap:");
  10062. if (_.length > 0) {
  10063. const b = _[0].substr(10).split(" ");
  10064. return {
  10065. port: parseInt(b[0], 10),
  10066. protocol: b[1],
  10067. maxMessageSize: c
  10068. }
  10069. }
  10070. }
  10071. ,
  10072. e.writeSctpDescription = function(i, o) {
  10073. let s = [];
  10074. return i.protocol !== "DTLS/SCTP" ? s = ["m=" + i.kind + " 9 " + i.protocol + " " + o.protocol + `\r
  10075. `, `c=IN IP4 0.0.0.0\r
  10076. `, "a=sctp-port:" + o.port + `\r
  10077. `] : s = ["m=" + i.kind + " 9 " + i.protocol + " " + o.port + `\r
  10078. `, `c=IN IP4 0.0.0.0\r
  10079. `, "a=sctpmap:" + o.port + " " + o.protocol + ` 65535\r
  10080. `],
  10081. o.maxMessageSize !== void 0 && s.push("a=max-message-size:" + o.maxMessageSize + `\r
  10082. `),
  10083. s.join("")
  10084. }
  10085. ,
  10086. e.generateSessionId = function() {
  10087. return Math.random().toString().substr(2, 21)
  10088. }
  10089. ,
  10090. e.writeSessionBoilerplate = function(i, o, s) {
  10091. let c;
  10092. const d = o !== void 0 ? o : 2;
  10093. return i ? c = i : c = e.generateSessionId(),
  10094. `v=0\r
  10095. o=` + (s || "thisisadapterortc") + " " + c + " " + d + ` IN IP4 127.0.0.1\r
  10096. s=-\r
  10097. t=0 0\r
  10098. `
  10099. }
  10100. ,
  10101. e.getDirection = function(i, o) {
  10102. const s = e.splitLines(i);
  10103. for (let c = 0; c < s.length; c++)
  10104. switch (s[c]) {
  10105. case "a=sendrecv":
  10106. case "a=sendonly":
  10107. case "a=recvonly":
  10108. case "a=inactive":
  10109. return s[c].substr(2)
  10110. }
  10111. return o ? e.getDirection(o) : "sendrecv"
  10112. }
  10113. ,
  10114. e.getKind = function(i) {
  10115. return e.splitLines(i)[0].split(" ")[0].substr(2)
  10116. }
  10117. ,
  10118. e.isRejected = function(i) {
  10119. return i.split(" ", 2)[1] === "0"
  10120. }
  10121. ,
  10122. e.parseMLine = function(i) {
  10123. const s = e.splitLines(i)[0].substr(2).split(" ");
  10124. return {
  10125. kind: s[0],
  10126. port: parseInt(s[1], 10),
  10127. protocol: s[2],
  10128. fmt: s.slice(3).join(" ")
  10129. }
  10130. }
  10131. ,
  10132. e.parseOLine = function(i) {
  10133. const s = e.matchPrefix(i, "o=")[0].substr(2).split(" ");
  10134. return {
  10135. username: s[0],
  10136. sessionId: s[1],
  10137. sessionVersion: parseInt(s[2], 10),
  10138. netType: s[3],
  10139. addressType: s[4],
  10140. address: s[5]
  10141. }
  10142. }
  10143. ,
  10144. e.isValidSDP = function(i) {
  10145. if (typeof i != "string" || i.length === 0)
  10146. return !1;
  10147. const o = e.splitLines(i);
  10148. for (let s = 0; s < o.length; s++)
  10149. if (o[s].length < 2 || o[s].charAt(1) !== "=")
  10150. return !1;
  10151. return !0
  10152. }
  10153. ,
  10154. a.exports = e
  10155. }
  10156. )(sdp$1);
  10157. var SDPUtils = sdp$1.exports
  10158. , sdp = _mergeNamespaces({
  10159. __proto__: null,
  10160. default: SDPUtils
  10161. }, [sdp$1.exports]);
  10162. function shimRTCIceCandidate(a) {
  10163. if (!a.RTCIceCandidate || a.RTCIceCandidate && "foundation"in a.RTCIceCandidate.prototype)
  10164. return;
  10165. const e = a.RTCIceCandidate;
  10166. a.RTCIceCandidate = function(o) {
  10167. if (typeof o == "object" && o.candidate && o.candidate.indexOf("a=") === 0 && (o = JSON.parse(JSON.stringify(o)),
  10168. o.candidate = o.candidate.substr(2)),
  10169. o.candidate && o.candidate.length) {
  10170. const s = new e(o)
  10171. , c = SDPUtils.parseCandidate(o.candidate)
  10172. , d = Object.assign(s, c);
  10173. return d.toJSON = function() {
  10174. return {
  10175. candidate: d.candidate,
  10176. sdpMid: d.sdpMid,
  10177. sdpMLineIndex: d.sdpMLineIndex,
  10178. usernameFragment: d.usernameFragment
  10179. }
  10180. }
  10181. ,
  10182. d
  10183. }
  10184. return new e(o)
  10185. }
  10186. ,
  10187. a.RTCIceCandidate.prototype = e.prototype,
  10188. wrapPeerConnectionEvent(a, "icecandidate", i=>(i.candidate && Object.defineProperty(i, "candidate", {
  10189. value: new a.RTCIceCandidate(i.candidate),
  10190. writable: "false"
  10191. }),
  10192. i))
  10193. }
  10194. function shimMaxMessageSize(a, e) {
  10195. if (!a.RTCPeerConnection)
  10196. return;
  10197. "sctp"in a.RTCPeerConnection.prototype || Object.defineProperty(a.RTCPeerConnection.prototype, "sctp", {
  10198. get() {
  10199. return typeof this._sctp == "undefined" ? null : this._sctp
  10200. }
  10201. });
  10202. const i = function(_) {
  10203. if (!_ || !_.sdp)
  10204. return !1;
  10205. const b = SDPUtils.splitSections(_.sdp);
  10206. return b.shift(),
  10207. b.some(k=>{
  10208. const j = SDPUtils.parseMLine(k);
  10209. return j && j.kind === "application" && j.protocol.indexOf("SCTP") !== -1
  10210. }
  10211. )
  10212. }
  10213. , o = function(_) {
  10214. const b = _.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);
  10215. if (b === null || b.length < 2)
  10216. return -1;
  10217. const k = parseInt(b[1], 10);
  10218. return k !== k ? -1 : k
  10219. }
  10220. , s = function(_) {
  10221. let b = 65536;
  10222. return e.browser === "firefox" && (e.version < 57 ? _ === -1 ? b = 16384 : b = 2147483637 : e.version < 60 ? b = e.version === 57 ? 65535 : 65536 : b = 2147483637),
  10223. b
  10224. }
  10225. , c = function(_, b) {
  10226. let k = 65536;
  10227. e.browser === "firefox" && e.version === 57 && (k = 65535);
  10228. const j = SDPUtils.matchPrefix(_.sdp, "a=max-message-size:");
  10229. return j.length > 0 ? k = parseInt(j[0].substr(19), 10) : e.browser === "firefox" && b !== -1 && (k = 2147483637),
  10230. k
  10231. }
  10232. , d = a.RTCPeerConnection.prototype.setRemoteDescription;
  10233. a.RTCPeerConnection.prototype.setRemoteDescription = function() {
  10234. if (this._sctp = null,
  10235. e.browser === "chrome" && e.version >= 76) {
  10236. const {sdpSemantics: b} = this.getConfiguration();
  10237. b === "plan-b" && Object.defineProperty(this, "sctp", {
  10238. get() {
  10239. return typeof this._sctp == "undefined" ? null : this._sctp
  10240. },
  10241. enumerable: !0,
  10242. configurable: !0
  10243. })
  10244. }
  10245. if (i(arguments[0])) {
  10246. const b = o(arguments[0])
  10247. , k = s(b)
  10248. , j = c(arguments[0], b);
  10249. let$;
  10250. k === 0 && j === 0 ? $ = Number.POSITIVE_INFINITY : k === 0 || j === 0 ? $ = Math.max(k, j) : $ = Math.min(k, j);
  10251. const _e = {};
  10252. Object.defineProperty(_e, "maxMessageSize", {
  10253. get() {
  10254. return $
  10255. }
  10256. }),
  10257. this._sctp = _e
  10258. }
  10259. return d.apply(this, arguments)
  10260. }
  10261. }
  10262. function shimSendThrowTypeError(a) {
  10263. if (!(a.RTCPeerConnection && "createDataChannel"in a.RTCPeerConnection.prototype))
  10264. return;
  10265. function e(o, s) {
  10266. const c = o.send;
  10267. o.send = function() {
  10268. const _ = arguments[0]
  10269. , b = _.length || _.size || _.byteLength;
  10270. if (o.readyState === "open" && s.sctp && b > s.sctp.maxMessageSize)
  10271. throw new TypeError("Message too large (can send a maximum of " + s.sctp.maxMessageSize + " bytes)");
  10272. return c.apply(o, arguments)
  10273. }
  10274. }
  10275. const i = a.RTCPeerConnection.prototype.createDataChannel;
  10276. a.RTCPeerConnection.prototype.createDataChannel = function() {
  10277. const s = i.apply(this, arguments);
  10278. return e(s, this),
  10279. s
  10280. }
  10281. ,
  10282. wrapPeerConnectionEvent(a, "datachannel", o=>(e(o.channel, o.target),
  10283. o))
  10284. }
  10285. function shimConnectionState(a) {
  10286. if (!a.RTCPeerConnection || "connectionState"in a.RTCPeerConnection.prototype)
  10287. return;
  10288. const e = a.RTCPeerConnection.prototype;
  10289. Object.defineProperty(e, "connectionState", {
  10290. get() {
  10291. return {
  10292. completed: "connected",
  10293. checking: "connecting"
  10294. }[this.iceConnectionState] || this.iceConnectionState
  10295. },
  10296. enumerable: !0,
  10297. configurable: !0
  10298. }),
  10299. Object.defineProperty(e, "onconnectionstatechange", {
  10300. get() {
  10301. return this._onconnectionstatechange || null
  10302. },
  10303. set(i) {
  10304. this._onconnectionstatechange && (this.removeEventListener("connectionstatechange", this._onconnectionstatechange),
  10305. delete this._onconnectionstatechange),
  10306. i && this.addEventListener("connectionstatechange", this._onconnectionstatechange = i)
  10307. },
  10308. enumerable: !0,
  10309. configurable: !0
  10310. }),
  10311. ["setLocalDescription", "setRemoteDescription"].forEach(i=>{
  10312. const o = e[i];
  10313. e[i] = function() {
  10314. return this._connectionstatechangepoly || (this._connectionstatechangepoly = s=>{
  10315. const c = s.target;
  10316. if (c._lastConnectionState !== c.connectionState) {
  10317. c._lastConnectionState = c.connectionState;
  10318. const d = new Event("connectionstatechange",s);
  10319. c.dispatchEvent(d)
  10320. }
  10321. return s
  10322. }
  10323. ,
  10324. this.addEventListener("iceconnectionstatechange", this._connectionstatechangepoly)),
  10325. o.apply(this, arguments)
  10326. }
  10327. }
  10328. )
  10329. }
  10330. function removeExtmapAllowMixed(a, e) {
  10331. if (!a.RTCPeerConnection || e.browser === "chrome" && e.version >= 71 || e.browser === "safari" && e.version >= 605)
  10332. return;
  10333. const i = a.RTCPeerConnection.prototype.setRemoteDescription;
  10334. a.RTCPeerConnection.prototype.setRemoteDescription = function(s) {
  10335. if (s && s.sdp && s.sdp.indexOf(`
  10336. a=extmap-allow-mixed`) !== -1) {
  10337. const c = s.sdp.split(`
  10338. `).filter(d=>d.trim() !== "a=extmap-allow-mixed").join(`
  10339. `);
  10340. a.RTCSessionDescription && s instanceof a.RTCSessionDescription ? arguments[0] = new a.RTCSessionDescription({
  10341. type: s.type,
  10342. sdp: c
  10343. }) : s.sdp = c
  10344. }
  10345. return i.apply(this, arguments)
  10346. }
  10347. }
  10348. function shimAddIceCandidateNullOrEmpty(a, e) {
  10349. if (!(a.RTCPeerConnection && a.RTCPeerConnection.prototype))
  10350. return;
  10351. const i = a.RTCPeerConnection.prototype.addIceCandidate;
  10352. !i || i.length === 0 || (a.RTCPeerConnection.prototype.addIceCandidate = function() {
  10353. return arguments[0] ? (e.browser === "chrome" && e.version < 78 || e.browser === "firefox" && e.version < 68 || e.browser === "safari") && arguments[0] && arguments[0].candidate === "" ? Promise.resolve() : i.apply(this, arguments) : (arguments[1] && arguments[1].apply(null),
  10354. Promise.resolve())
  10355. }
  10356. )
  10357. }
  10358. function shimParameterlessSetLocalDescription(a, e) {
  10359. if (!(a.RTCPeerConnection && a.RTCPeerConnection.prototype))
  10360. return;
  10361. const i = a.RTCPeerConnection.prototype.setLocalDescription;
  10362. !i || i.length === 0 || (a.RTCPeerConnection.prototype.setLocalDescription = function() {
  10363. let s = arguments[0] || {};
  10364. if (typeof s != "object" || s.type && s.sdp)
  10365. return i.apply(this, arguments);
  10366. if (s = {
  10367. type: s.type,
  10368. sdp: s.sdp
  10369. },
  10370. !s.type)
  10371. switch (this.signalingState) {
  10372. case "stable":
  10373. case "have-local-offer":
  10374. case "have-remote-pranswer":
  10375. s.type = "offer";
  10376. break;
  10377. default:
  10378. s.type = "answer";
  10379. break
  10380. }
  10381. return s.sdp || s.type !== "offer" && s.type !== "answer" ? i.apply(this, [s]) : (s.type === "offer" ? this.createOffer : this.createAnswer).apply(this).then(d=>i.apply(this, [d]))
  10382. }
  10383. )
  10384. }
  10385. var commonShim = Object.freeze(Object.defineProperty({
  10386. __proto__: null,
  10387. shimRTCIceCandidate,
  10388. shimMaxMessageSize,
  10389. shimSendThrowTypeError,
  10390. shimConnectionState,
  10391. removeExtmapAllowMixed,
  10392. shimAddIceCandidateNullOrEmpty,
  10393. shimParameterlessSetLocalDescription
  10394. }, Symbol.toStringTag, {
  10395. value: "Module"
  10396. }));
  10397. function adapterFactory({window: a}={}, e={
  10398. shimChrome: !0,
  10399. shimFirefox: !0,
  10400. shimSafari: !0
  10401. }) {
  10402. const i = log$L
  10403. , o = detectBrowser(a)
  10404. , s = {
  10405. browserDetails: o,
  10406. commonShim,
  10407. extractVersion,
  10408. disableLog,
  10409. disableWarnings,
  10410. sdp
  10411. };
  10412. switch (o.browser) {
  10413. case "chrome":
  10414. if (!chromeShim || !shimPeerConnection$1 || !e.shimChrome)
  10415. return i("Chrome shim is not included in this adapter release."),
  10416. s;
  10417. if (o.version === null)
  10418. return i("Chrome shim can not determine version, not shimming."),
  10419. s;
  10420. i("adapter.js shimming chrome."),
  10421. s.browserShim = chromeShim,
  10422. shimAddIceCandidateNullOrEmpty(a, o),
  10423. shimParameterlessSetLocalDescription(a),
  10424. shimGetUserMedia$2(a, o),
  10425. shimMediaStream(a),
  10426. shimPeerConnection$1(a, o),
  10427. shimOnTrack$1(a),
  10428. shimAddTrackRemoveTrack(a, o),
  10429. shimGetSendersWithDtmf(a),
  10430. shimGetStats(a),
  10431. shimSenderReceiverGetStats(a),
  10432. fixNegotiationNeeded(a, o),
  10433. shimRTCIceCandidate(a),
  10434. shimConnectionState(a),
  10435. shimMaxMessageSize(a, o),
  10436. shimSendThrowTypeError(a),
  10437. removeExtmapAllowMixed(a, o);
  10438. break;
  10439. case "firefox":
  10440. if (!firefoxShim || !shimPeerConnection || !e.shimFirefox)
  10441. return i("Firefox shim is not included in this adapter release."),
  10442. s;
  10443. i("adapter.js shimming firefox."),
  10444. s.browserShim = firefoxShim,
  10445. shimAddIceCandidateNullOrEmpty(a, o),
  10446. shimParameterlessSetLocalDescription(a),
  10447. shimGetUserMedia$1(a, o),
  10448. shimPeerConnection(a, o),
  10449. shimOnTrack(a),
  10450. shimRemoveStream(a),
  10451. shimSenderGetStats(a),
  10452. shimReceiverGetStats(a),
  10453. shimRTCDataChannel(a),
  10454. shimAddTransceiver(a),
  10455. shimGetParameters(a),
  10456. shimCreateOffer(a),
  10457. shimCreateAnswer(a),
  10458. shimRTCIceCandidate(a),
  10459. shimConnectionState(a),
  10460. shimMaxMessageSize(a, o),
  10461. shimSendThrowTypeError(a);
  10462. break;
  10463. case "safari":
  10464. if (!safariShim || !e.shimSafari)
  10465. return i("Safari shim is not included in this adapter release."),
  10466. s;
  10467. i("adapter.js shimming safari."),
  10468. s.browserShim = safariShim,
  10469. shimAddIceCandidateNullOrEmpty(a, o),
  10470. shimParameterlessSetLocalDescription(a),
  10471. shimRTCIceServerUrls(a),
  10472. shimCreateOfferLegacy(a),
  10473. shimCallbacksAPI(a),
  10474. shimLocalStreamsAPI(a),
  10475. shimRemoteStreamsAPI(a),
  10476. shimTrackEventTransceiver(a),
  10477. shimGetUserMedia(a),
  10478. shimAudioContext(a),
  10479. shimRTCIceCandidate(a),
  10480. shimMaxMessageSize(a, o),
  10481. shimSendThrowTypeError(a),
  10482. removeExtmapAllowMixed(a, o);
  10483. break;
  10484. default:
  10485. i("Unsupported browser!");
  10486. break
  10487. }
  10488. return s
  10489. }
  10490. adapterFactory({
  10491. window: typeof window == "undefined" ? void 0 : window
  10492. });
  10493. Promise.prototype._timeout = function(a, e) {
  10494. let i;
  10495. return new Promise((o,s)=>(i = window.setTimeout(()=>{
  10496. s(e)
  10497. }
  10498. , a),
  10499. this.then(c=>{
  10500. clearTimeout(i),
  10501. o(c)
  10502. }
  10503. , c=>{
  10504. clearTimeout(i),
  10505. s(c)
  10506. }
  10507. )))
  10508. }
  10509. ;
  10510. function clear() {
  10511. const a = console.log;
  10512. console.log = function(...e) {
  10513. typeof e[0] == "string" && e[0].indexOf("Babylon.js") == 0 || a(...e)
  10514. }
  10515. }
  10516. clear();
  10517. var Constants = function() {
  10518. function a() {}
  10519. return a.ALPHA_DISABLE = 0,
  10520. a.ALPHA_ADD = 1,
  10521. a.ALPHA_COMBINE = 2,
  10522. a.ALPHA_SUBTRACT = 3,
  10523. a.ALPHA_MULTIPLY = 4,
  10524. a.ALPHA_MAXIMIZED = 5,
  10525. a.ALPHA_ONEONE = 6,
  10526. a.ALPHA_PREMULTIPLIED = 7,
  10527. a.ALPHA_PREMULTIPLIED_PORTERDUFF = 8,
  10528. a.ALPHA_INTERPOLATE = 9,
  10529. a.ALPHA_SCREENMODE = 10,
  10530. a.ALPHA_ONEONE_ONEONE = 11,
  10531. a.ALPHA_ALPHATOCOLOR = 12,
  10532. a.ALPHA_REVERSEONEMINUS = 13,
  10533. a.ALPHA_SRC_DSTONEMINUSSRCALPHA = 14,
  10534. a.ALPHA_ONEONE_ONEZERO = 15,
  10535. a.ALPHA_EXCLUSION = 16,
  10536. a.ALPHA_LAYER_ACCUMULATE = 17,
  10537. a.ALPHA_EQUATION_ADD = 0,
  10538. a.ALPHA_EQUATION_SUBSTRACT = 1,
  10539. a.ALPHA_EQUATION_REVERSE_SUBTRACT = 2,
  10540. a.ALPHA_EQUATION_MAX = 3,
  10541. a.ALPHA_EQUATION_MIN = 4,
  10542. a.ALPHA_EQUATION_DARKEN = 5,
  10543. a.DELAYLOADSTATE_NONE = 0,
  10544. a.DELAYLOADSTATE_LOADED = 1,
  10545. a.DELAYLOADSTATE_LOADING = 2,
  10546. a.DELAYLOADSTATE_NOTLOADED = 4,
  10547. a.NEVER = 512,
  10548. a.ALWAYS = 519,
  10549. a.LESS = 513,
  10550. a.EQUAL = 514,
  10551. a.LEQUAL = 515,
  10552. a.GREATER = 516,
  10553. a.GEQUAL = 518,
  10554. a.NOTEQUAL = 517,
  10555. a.KEEP = 7680,
  10556. a.ZERO = 0,
  10557. a.REPLACE = 7681,
  10558. a.INCR = 7682,
  10559. a.DECR = 7683,
  10560. a.INVERT = 5386,
  10561. a.INCR_WRAP = 34055,
  10562. a.DECR_WRAP = 34056,
  10563. a.TEXTURE_CLAMP_ADDRESSMODE = 0,
  10564. a.TEXTURE_WRAP_ADDRESSMODE = 1,
  10565. a.TEXTURE_MIRROR_ADDRESSMODE = 2,
  10566. a.TEXTURE_CREATIONFLAG_STORAGE = 1,
  10567. a.TEXTUREFORMAT_ALPHA = 0,
  10568. a.TEXTUREFORMAT_LUMINANCE = 1,
  10569. a.TEXTUREFORMAT_LUMINANCE_ALPHA = 2,
  10570. a.TEXTUREFORMAT_RGB = 4,
  10571. a.TEXTUREFORMAT_RGBA = 5,
  10572. a.TEXTUREFORMAT_RED = 6,
  10573. a.TEXTUREFORMAT_R = 6,
  10574. a.TEXTUREFORMAT_RG = 7,
  10575. a.TEXTUREFORMAT_RED_INTEGER = 8,
  10576. a.TEXTUREFORMAT_R_INTEGER = 8,
  10577. a.TEXTUREFORMAT_RG_INTEGER = 9,
  10578. a.TEXTUREFORMAT_RGB_INTEGER = 10,
  10579. a.TEXTUREFORMAT_RGBA_INTEGER = 11,
  10580. a.TEXTUREFORMAT_BGRA = 12,
  10581. a.TEXTUREFORMAT_DEPTH24_STENCIL8 = 13,
  10582. a.TEXTUREFORMAT_DEPTH32_FLOAT = 14,
  10583. a.TEXTUREFORMAT_DEPTH16 = 15,
  10584. a.TEXTUREFORMAT_DEPTH24 = 16,
  10585. a.TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM = 36492,
  10586. a.TEXTUREFORMAT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT = 36495,
  10587. a.TEXTUREFORMAT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT = 36494,
  10588. a.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5 = 33779,
  10589. a.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3 = 33778,
  10590. a.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1 = 33777,
  10591. a.TEXTUREFORMAT_COMPRESSED_RGB_S3TC_DXT1 = 33776,
  10592. a.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_4x4 = 37808,
  10593. a.TEXTUREFORMAT_COMPRESSED_RGB_ETC1_WEBGL = 36196,
  10594. a.TEXTURETYPE_UNSIGNED_BYTE = 0,
  10595. a.TEXTURETYPE_UNSIGNED_INT = 0,
  10596. a.TEXTURETYPE_FLOAT = 1,
  10597. a.TEXTURETYPE_HALF_FLOAT = 2,
  10598. a.TEXTURETYPE_BYTE = 3,
  10599. a.TEXTURETYPE_SHORT = 4,
  10600. a.TEXTURETYPE_UNSIGNED_SHORT = 5,
  10601. a.TEXTURETYPE_INT = 6,
  10602. a.TEXTURETYPE_UNSIGNED_INTEGER = 7,
  10603. a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = 8,
  10604. a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = 9,
  10605. a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = 10,
  10606. a.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = 11,
  10607. a.TEXTURETYPE_UNSIGNED_INT_24_8 = 12,
  10608. a.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = 13,
  10609. a.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = 14,
  10610. a.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = 15,
  10611. a.TEXTURETYPE_UNDEFINED = 16,
  10612. a.TEXTURE_NEAREST_SAMPLINGMODE = 1,
  10613. a.TEXTURE_NEAREST_NEAREST = 1,
  10614. a.TEXTURE_BILINEAR_SAMPLINGMODE = 2,
  10615. a.TEXTURE_LINEAR_LINEAR = 2,
  10616. a.TEXTURE_TRILINEAR_SAMPLINGMODE = 3,
  10617. a.TEXTURE_LINEAR_LINEAR_MIPLINEAR = 3,
  10618. a.TEXTURE_NEAREST_NEAREST_MIPNEAREST = 4,
  10619. a.TEXTURE_NEAREST_LINEAR_MIPNEAREST = 5,
  10620. a.TEXTURE_NEAREST_LINEAR_MIPLINEAR = 6,
  10621. a.TEXTURE_NEAREST_LINEAR = 7,
  10622. a.TEXTURE_NEAREST_NEAREST_MIPLINEAR = 8,
  10623. a.TEXTURE_LINEAR_NEAREST_MIPNEAREST = 9,
  10624. a.TEXTURE_LINEAR_NEAREST_MIPLINEAR = 10,
  10625. a.TEXTURE_LINEAR_LINEAR_MIPNEAREST = 11,
  10626. a.TEXTURE_LINEAR_NEAREST = 12,
  10627. a.TEXTURE_EXPLICIT_MODE = 0,
  10628. a.TEXTURE_SPHERICAL_MODE = 1,
  10629. a.TEXTURE_PLANAR_MODE = 2,
  10630. a.TEXTURE_CUBIC_MODE = 3,
  10631. a.TEXTURE_PROJECTION_MODE = 4,
  10632. a.TEXTURE_SKYBOX_MODE = 5,
  10633. a.TEXTURE_INVCUBIC_MODE = 6,
  10634. a.TEXTURE_EQUIRECTANGULAR_MODE = 7,
  10635. a.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = 8,
  10636. a.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = 9,
  10637. a.TEXTURE_FILTERING_QUALITY_OFFLINE = 4096,
  10638. a.TEXTURE_FILTERING_QUALITY_HIGH = 64,
  10639. a.TEXTURE_FILTERING_QUALITY_MEDIUM = 16,
  10640. a.TEXTURE_FILTERING_QUALITY_LOW = 8,
  10641. a.SCALEMODE_FLOOR = 1,
  10642. a.SCALEMODE_NEAREST = 2,
  10643. a.SCALEMODE_CEILING = 3,
  10644. a.MATERIAL_TextureDirtyFlag = 1,
  10645. a.MATERIAL_LightDirtyFlag = 2,
  10646. a.MATERIAL_FresnelDirtyFlag = 4,
  10647. a.MATERIAL_AttributesDirtyFlag = 8,
  10648. a.MATERIAL_MiscDirtyFlag = 16,
  10649. a.MATERIAL_PrePassDirtyFlag = 32,
  10650. a.MATERIAL_AllDirtyFlag = 63,
  10651. a.MATERIAL_TriangleFillMode = 0,
  10652. a.MATERIAL_WireFrameFillMode = 1,
  10653. a.MATERIAL_PointFillMode = 2,
  10654. a.MATERIAL_PointListDrawMode = 3,
  10655. a.MATERIAL_LineListDrawMode = 4,
  10656. a.MATERIAL_LineLoopDrawMode = 5,
  10657. a.MATERIAL_LineStripDrawMode = 6,
  10658. a.MATERIAL_TriangleStripDrawMode = 7,
  10659. a.MATERIAL_TriangleFanDrawMode = 8,
  10660. a.MATERIAL_ClockWiseSideOrientation = 0,
  10661. a.MATERIAL_CounterClockWiseSideOrientation = 1,
  10662. a.ACTION_NothingTrigger = 0,
  10663. a.ACTION_OnPickTrigger = 1,
  10664. a.ACTION_OnLeftPickTrigger = 2,
  10665. a.ACTION_OnRightPickTrigger = 3,
  10666. a.ACTION_OnCenterPickTrigger = 4,
  10667. a.ACTION_OnPickDownTrigger = 5,
  10668. a.ACTION_OnDoublePickTrigger = 6,
  10669. a.ACTION_OnPickUpTrigger = 7,
  10670. a.ACTION_OnPickOutTrigger = 16,
  10671. a.ACTION_OnLongPressTrigger = 8,
  10672. a.ACTION_OnPointerOverTrigger = 9,
  10673. a.ACTION_OnPointerOutTrigger = 10,
  10674. a.ACTION_OnEveryFrameTrigger = 11,
  10675. a.ACTION_OnIntersectionEnterTrigger = 12,
  10676. a.ACTION_OnIntersectionExitTrigger = 13,
  10677. a.ACTION_OnKeyDownTrigger = 14,
  10678. a.ACTION_OnKeyUpTrigger = 15,
  10679. a.PARTICLES_BILLBOARDMODE_Y = 2,
  10680. a.PARTICLES_BILLBOARDMODE_ALL = 7,
  10681. a.PARTICLES_BILLBOARDMODE_STRETCHED = 8,
  10682. a.MESHES_CULLINGSTRATEGY_STANDARD = 0,
  10683. a.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = 1,
  10684. a.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = 2,
  10685. a.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = 3,
  10686. a.SCENELOADER_NO_LOGGING = 0,
  10687. a.SCENELOADER_MINIMAL_LOGGING = 1,
  10688. a.SCENELOADER_SUMMARY_LOGGING = 2,
  10689. a.SCENELOADER_DETAILED_LOGGING = 3,
  10690. a.PREPASS_IRRADIANCE_TEXTURE_TYPE = 0,
  10691. a.PREPASS_POSITION_TEXTURE_TYPE = 1,
  10692. a.PREPASS_VELOCITY_TEXTURE_TYPE = 2,
  10693. a.PREPASS_REFLECTIVITY_TEXTURE_TYPE = 3,
  10694. a.PREPASS_COLOR_TEXTURE_TYPE = 4,
  10695. a.PREPASS_DEPTH_TEXTURE_TYPE = 5,
  10696. a.PREPASS_NORMAL_TEXTURE_TYPE = 6,
  10697. a.PREPASS_ALBEDO_SQRT_TEXTURE_TYPE = 7,
  10698. a.BUFFER_CREATIONFLAG_READ = 1,
  10699. a.BUFFER_CREATIONFLAG_WRITE = 2,
  10700. a.BUFFER_CREATIONFLAG_READWRITE = 3,
  10701. a.BUFFER_CREATIONFLAG_UNIFORM = 4,
  10702. a.BUFFER_CREATIONFLAG_VERTEX = 8,
  10703. a.BUFFER_CREATIONFLAG_INDEX = 16,
  10704. a.BUFFER_CREATIONFLAG_STORAGE = 32,
  10705. a.RENDERPASS_MAIN = 0,
  10706. a.INPUT_ALT_KEY = 18,
  10707. a.INPUT_CTRL_KEY = 17,
  10708. a.INPUT_META_KEY1 = 91,
  10709. a.INPUT_META_KEY2 = 92,
  10710. a.INPUT_META_KEY3 = 93,
  10711. a.INPUT_SHIFT_KEY = 16,
  10712. a.SNAPSHOTRENDERING_STANDARD = 0,
  10713. a.SNAPSHOTRENDERING_FAST = 1,
  10714. a.PERSPECTIVE_CAMERA = 0,
  10715. a.ORTHOGRAPHIC_CAMERA = 1,
  10716. a.FOVMODE_VERTICAL_FIXED = 0,
  10717. a.FOVMODE_HORIZONTAL_FIXED = 1,
  10718. a.RIG_MODE_NONE = 0,
  10719. a.RIG_MODE_STEREOSCOPIC_ANAGLYPH = 10,
  10720. a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL = 11,
  10721. a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED = 12,
  10722. a.RIG_MODE_STEREOSCOPIC_OVERUNDER = 13,
  10723. a.RIG_MODE_STEREOSCOPIC_INTERLACED = 14,
  10724. a.RIG_MODE_VR = 20,
  10725. a.RIG_MODE_WEBVR = 21,
  10726. a.RIG_MODE_CUSTOM = 22,
  10727. a.MAX_SUPPORTED_UV_SETS = 6,
  10728. a.GL_ALPHA_EQUATION_ADD = 32774,
  10729. a.GL_ALPHA_EQUATION_MIN = 32775,
  10730. a.GL_ALPHA_EQUATION_MAX = 32776,
  10731. a.GL_ALPHA_EQUATION_SUBTRACT = 32778,
  10732. a.GL_ALPHA_EQUATION_REVERSE_SUBTRACT = 32779,
  10733. a.GL_ALPHA_FUNCTION_SRC = 768,
  10734. a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR = 769,
  10735. a.GL_ALPHA_FUNCTION_SRC_ALPHA = 770,
  10736. a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA = 771,
  10737. a.GL_ALPHA_FUNCTION_DST_ALPHA = 772,
  10738. a.GL_ALPHA_FUNCTION_ONE_MINUS_DST_ALPHA = 773,
  10739. a.GL_ALPHA_FUNCTION_DST_COLOR = 774,
  10740. a.GL_ALPHA_FUNCTION_ONE_MINUS_DST_COLOR = 775,
  10741. a.GL_ALPHA_FUNCTION_SRC_ALPHA_SATURATED = 776,
  10742. a.GL_ALPHA_FUNCTION_CONSTANT_COLOR = 32769,
  10743. a.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_COLOR = 32770,
  10744. a.GL_ALPHA_FUNCTION_CONSTANT_ALPHA = 32771,
  10745. a.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_ALPHA = 32772,
  10746. a
  10747. }();
  10748. /*! *****************************************************************************
  10749. Copyright (c) Microsoft Corporation.
  10750. Permission to use, copy, modify, and/or distribute this software for any
  10751. purpose with or without fee is hereby granted.
  10752. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  10753. REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  10754. AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  10755. INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  10756. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  10757. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  10758. PERFORMANCE OF THIS SOFTWARE.
  10759. ***************************************************************************** */
  10760. var extendStatics = function(a, e) {
  10761. return extendStatics = Object.setPrototypeOf || {
  10762. __proto__: []
  10763. }instanceof Array && function(i, o) {
  10764. i.__proto__ = o
  10765. }
  10766. || function(i, o) {
  10767. for (var s in o)
  10768. Object.prototype.hasOwnProperty.call(o, s) && (i[s] = o[s])
  10769. }
  10770. ,
  10771. extendStatics(a, e)
  10772. };
  10773. function __extends(a, e) {
  10774. if (typeof e != "function" && e !== null)
  10775. throw new TypeError("Class extends value " + String(e) + " is not a constructor or null");
  10776. extendStatics(a, e);
  10777. function i() {
  10778. this.constructor = a
  10779. }
  10780. a.prototype = e === null ? Object.create(e) : (i.prototype = e.prototype,
  10781. new i)
  10782. }
  10783. var __assign = function() {
  10784. return __assign = Object.assign || function(e) {
  10785. for (var i, o = 1, s = arguments.length; o < s; o++) {
  10786. i = arguments[o];
  10787. for (var c in i)
  10788. Object.prototype.hasOwnProperty.call(i, c) && (e[c] = i[c])
  10789. }
  10790. return e
  10791. }
  10792. ,
  10793. __assign.apply(this, arguments)
  10794. };
  10795. function __decorate(a, e, i, o) {
  10796. var s = arguments.length, c = s < 3 ? e : o === null ? o = Object.getOwnPropertyDescriptor(e, i) : o, d;
  10797. if (typeof Reflect == "object" && typeof Reflect.decorate == "function")
  10798. c = Reflect.decorate(a, e, i, o);
  10799. else
  10800. for (var _ = a.length - 1; _ >= 0; _--)
  10801. (d = a[_]) && (c = (s < 3 ? d(c) : s > 3 ? d(e, i, c) : d(e, i)) || c);
  10802. return s > 3 && c && Object.defineProperty(e, i, c),
  10803. c
  10804. }
  10805. function __awaiter(a, e, i, o) {
  10806. function s(c) {
  10807. return c instanceof i ? c : new i(function(d) {
  10808. d(c)
  10809. }
  10810. )
  10811. }
  10812. return new (i || (i = Promise))(function(c, d) {
  10813. function _(j) {
  10814. try {
  10815. k(o.next(j))
  10816. } catch ($) {
  10817. d($)
  10818. }
  10819. }
  10820. function b(j) {
  10821. try {
  10822. k(o.throw(j))
  10823. } catch ($) {
  10824. d($)
  10825. }
  10826. }
  10827. function k(j) {
  10828. j.done ? c(j.value) : s(j.value).then(_, b)
  10829. }
  10830. k((o = o.apply(a, e || [])).next())
  10831. }
  10832. )
  10833. }
  10834. function __generator(a, e) {
  10835. var i = {
  10836. label: 0,
  10837. sent: function() {
  10838. if (c[0] & 1)
  10839. throw c[1];
  10840. return c[1]
  10841. },
  10842. trys: [],
  10843. ops: []
  10844. }, o, s, c, d;
  10845. return d = {
  10846. next: _(0),
  10847. throw: _(1),
  10848. return: _(2)
  10849. },
  10850. typeof Symbol == "function" && (d[Symbol.iterator] = function() {
  10851. return this
  10852. }
  10853. ),
  10854. d;
  10855. function _(k) {
  10856. return function(j) {
  10857. return b([k, j])
  10858. }
  10859. }
  10860. function b(k) {
  10861. if (o)
  10862. throw new TypeError("Generator is already executing.");
  10863. for (; i; )
  10864. try {
  10865. if (o = 1,
  10866. s && (c = k[0] & 2 ? s.return : k[0] ? s.throw || ((c = s.return) && c.call(s),
  10867. 0) : s.next) && !(c = c.call(s, k[1])).done)
  10868. return c;
  10869. switch (s = 0,
  10870. c && (k = [k[0] & 2, c.value]),
  10871. k[0]) {
  10872. case 0:
  10873. case 1:
  10874. c = k;
  10875. break;
  10876. case 4:
  10877. return i.label++,
  10878. {
  10879. value: k[1],
  10880. done: !1
  10881. };
  10882. case 5:
  10883. i.label++,
  10884. s = k[1],
  10885. k = [0];
  10886. continue;
  10887. case 7:
  10888. k = i.ops.pop(),
  10889. i.trys.pop();
  10890. continue;
  10891. default:
  10892. if (c = i.trys,
  10893. !(c = c.length > 0 && c[c.length - 1]) && (k[0] === 6 || k[0] === 2)) {
  10894. i = 0;
  10895. continue
  10896. }
  10897. if (k[0] === 3 && (!c || k[1] > c[0] && k[1] < c[3])) {
  10898. i.label = k[1];
  10899. break
  10900. }
  10901. if (k[0] === 6 && i.label < c[1]) {
  10902. i.label = c[1],
  10903. c = k;
  10904. break
  10905. }
  10906. if (c && i.label < c[2]) {
  10907. i.label = c[2],
  10908. i.ops.push(k);
  10909. break
  10910. }
  10911. c[2] && i.ops.pop(),
  10912. i.trys.pop();
  10913. continue
  10914. }
  10915. k = e.call(a, i)
  10916. } catch (j) {
  10917. k = [6, j],
  10918. s = 0
  10919. } finally {
  10920. o = c = 0
  10921. }
  10922. if (k[0] & 5)
  10923. throw k[1];
  10924. return {
  10925. value: k[0] ? k[1] : void 0,
  10926. done: !0
  10927. }
  10928. }
  10929. }
  10930. function __spreadArray(a, e, i) {
  10931. if (i || arguments.length === 2)
  10932. for (var o = 0, s = e.length, c; o < s; o++)
  10933. (c || !(o in e)) && (c || (c = Array.prototype.slice.call(e, 0, o)),
  10934. c[o] = e[o]);
  10935. return a.concat(c || Array.prototype.slice.call(e))
  10936. }
  10937. var EngineStore = function() {
  10938. function a() {}
  10939. return Object.defineProperty(a, "LastCreatedEngine", {
  10940. get: function() {
  10941. return this.Instances.length === 0 ? null : this.Instances[this.Instances.length - 1]
  10942. },
  10943. enumerable: !1,
  10944. configurable: !0
  10945. }),
  10946. Object.defineProperty(a, "LastCreatedScene", {
  10947. get: function() {
  10948. return this._LastCreatedScene
  10949. },
  10950. enumerable: !1,
  10951. configurable: !0
  10952. }),
  10953. a.Instances = new Array,
  10954. a._LastCreatedScene = null,
  10955. a.UseFallbackTexture = !0,
  10956. a.FallbackTexture = "",
  10957. a
  10958. }()
  10959. , EventState = function() {
  10960. function a(e, i, o, s) {
  10961. i === void 0 && (i = !1),
  10962. this.initialize(e, i, o, s)
  10963. }
  10964. return a.prototype.initialize = function(e, i, o, s) {
  10965. return i === void 0 && (i = !1),
  10966. this.mask = e,
  10967. this.skipNextObservers = i,
  10968. this.target = o,
  10969. this.currentTarget = s,
  10970. this
  10971. }
  10972. ,
  10973. a
  10974. }()
  10975. , Observer = function() {
  10976. function a(e, i, o) {
  10977. o === void 0 && (o = null),
  10978. this.callback = e,
  10979. this.mask = i,
  10980. this.scope = o,
  10981. this._willBeUnregistered = !1,
  10982. this.unregisterOnNextCall = !1
  10983. }
  10984. return a
  10985. }()
  10986. , Observable = function() {
  10987. function a(e) {
  10988. this._observers = new Array,
  10989. this._eventState = new EventState(0),
  10990. e && (this._onObserverAdded = e)
  10991. }
  10992. return a.FromPromise = function(e, i) {
  10993. var o = new a;
  10994. return e.then(function(s) {
  10995. o.notifyObservers(s)
  10996. }).catch(function(s) {
  10997. if (i)
  10998. i.notifyObservers(s);
  10999. else
  11000. throw s
  11001. }),
  11002. o
  11003. }
  11004. ,
  11005. Object.defineProperty(a.prototype, "observers", {
  11006. get: function() {
  11007. return this._observers
  11008. },
  11009. enumerable: !1,
  11010. configurable: !0
  11011. }),
  11012. a.prototype.add = function(e, i, o, s, c) {
  11013. if (i === void 0 && (i = -1),
  11014. o === void 0 && (o = !1),
  11015. s === void 0 && (s = null),
  11016. c === void 0 && (c = !1),
  11017. !e)
  11018. return null;
  11019. var d = new Observer(e,i,s);
  11020. return d.unregisterOnNextCall = c,
  11021. o ? this._observers.unshift(d) : this._observers.push(d),
  11022. this._onObserverAdded && this._onObserverAdded(d),
  11023. d
  11024. }
  11025. ,
  11026. a.prototype.addOnce = function(e) {
  11027. return this.add(e, void 0, void 0, void 0, !0)
  11028. }
  11029. ,
  11030. a.prototype.remove = function(e) {
  11031. if (!e)
  11032. return !1;
  11033. var i = this._observers.indexOf(e);
  11034. return i !== -1 ? (this._deferUnregister(e),
  11035. !0) : !1
  11036. }
  11037. ,
  11038. a.prototype.removeCallback = function(e, i) {
  11039. for (var o = 0; o < this._observers.length; o++) {
  11040. var s = this._observers[o];
  11041. if (!s._willBeUnregistered && s.callback === e && (!i || i === s.scope))
  11042. return this._deferUnregister(s),
  11043. !0
  11044. }
  11045. return !1
  11046. }
  11047. ,
  11048. a.prototype._deferUnregister = function(e) {
  11049. var i = this;
  11050. e.unregisterOnNextCall = !1,
  11051. e._willBeUnregistered = !0,
  11052. setTimeout(function() {
  11053. i._remove(e)
  11054. }, 0)
  11055. }
  11056. ,
  11057. a.prototype._remove = function(e) {
  11058. if (!e)
  11059. return !1;
  11060. var i = this._observers.indexOf(e);
  11061. return i !== -1 ? (this._observers.splice(i, 1),
  11062. !0) : !1
  11063. }
  11064. ,
  11065. a.prototype.makeObserverTopPriority = function(e) {
  11066. this._remove(e),
  11067. this._observers.unshift(e)
  11068. }
  11069. ,
  11070. a.prototype.makeObserverBottomPriority = function(e) {
  11071. this._remove(e),
  11072. this._observers.push(e)
  11073. }
  11074. ,
  11075. a.prototype.notifyObservers = function(e, i, o, s, c) {
  11076. if (i === void 0 && (i = -1),
  11077. !this._observers.length)
  11078. return !0;
  11079. var d = this._eventState;
  11080. d.mask = i,
  11081. d.target = o,
  11082. d.currentTarget = s,
  11083. d.skipNextObservers = !1,
  11084. d.lastReturnValue = e,
  11085. d.userInfo = c;
  11086. for (var _ = 0, b = this._observers; _ < b.length; _++) {
  11087. var k = b[_];
  11088. if (!k._willBeUnregistered && (k.mask & i && (k.scope ? d.lastReturnValue = k.callback.apply(k.scope, [e, d]) : d.lastReturnValue = k.callback(e, d),
  11089. k.unregisterOnNextCall && this._deferUnregister(k)),
  11090. d.skipNextObservers))
  11091. return !1
  11092. }
  11093. return !0
  11094. }
  11095. ,
  11096. a.prototype.notifyObserversWithPromise = function(e, i, o, s, c) {
  11097. var d = this;
  11098. i === void 0 && (i = -1);
  11099. var _ = Promise.resolve(e);
  11100. if (!this._observers.length)
  11101. return _;
  11102. var b = this._eventState;
  11103. return b.mask = i,
  11104. b.target = o,
  11105. b.currentTarget = s,
  11106. b.skipNextObservers = !1,
  11107. b.userInfo = c,
  11108. this._observers.forEach(function(k) {
  11109. b.skipNextObservers || k._willBeUnregistered || k.mask & i && (k.scope ? _ = _.then(function(j) {
  11110. return b.lastReturnValue = j,
  11111. k.callback.apply(k.scope, [e, b])
  11112. }) : _ = _.then(function(j) {
  11113. return b.lastReturnValue = j,
  11114. k.callback(e, b)
  11115. }),
  11116. k.unregisterOnNextCall && d._deferUnregister(k))
  11117. }),
  11118. _.then(function() {
  11119. return e
  11120. })
  11121. }
  11122. ,
  11123. a.prototype.notifyObserver = function(e, i, o) {
  11124. if (o === void 0 && (o = -1),
  11125. !e._willBeUnregistered) {
  11126. var s = this._eventState;
  11127. s.mask = o,
  11128. s.skipNextObservers = !1,
  11129. e.callback(i, s),
  11130. e.unregisterOnNextCall && this._deferUnregister(e)
  11131. }
  11132. }
  11133. ,
  11134. a.prototype.hasObservers = function() {
  11135. return this._observers.length > 0
  11136. }
  11137. ,
  11138. a.prototype.clear = function() {
  11139. this._observers = new Array,
  11140. this._onObserverAdded = null
  11141. }
  11142. ,
  11143. a.prototype.clone = function() {
  11144. var e = new a;
  11145. return e._observers = this._observers.slice(0),
  11146. e
  11147. }
  11148. ,
  11149. a.prototype.hasSpecificMask = function(e) {
  11150. e === void 0 && (e = -1);
  11151. for (var i = 0, o = this._observers; i < o.length; i++) {
  11152. var s = o[i];
  11153. if (s.mask & e || s.mask === e)
  11154. return !0
  11155. }
  11156. return !1
  11157. }
  11158. ,
  11159. a
  11160. }();
  11161. function IsWindowObjectExist() {
  11162. return typeof window != "undefined"
  11163. }
  11164. function IsNavigatorAvailable() {
  11165. return typeof navigator != "undefined"
  11166. }
  11167. function IsDocumentAvailable() {
  11168. return typeof document != "undefined"
  11169. }
  11170. function GetDOMTextContent(a) {
  11171. for (var e = "", i = a.firstChild; i; )
  11172. i.nodeType === 3 && (e += i.textContent),
  11173. i = i.nextSibling;
  11174. return e
  11175. }
  11176. var DomManagement = {
  11177. IsWindowObjectExist,
  11178. IsNavigatorAvailable,
  11179. IsDocumentAvailable,
  11180. GetDOMTextContent
  11181. }
  11182. , Logger$2 = function() {
  11183. function a() {}
  11184. return a._CheckLimit = function(e, i) {
  11185. var o = a._LogLimitOutputs[e];
  11186. return o ? o.current++ : (o = {
  11187. limit: i,
  11188. current: 1
  11189. },
  11190. a._LogLimitOutputs[e] = o),
  11191. o.current <= o.limit
  11192. }
  11193. ,
  11194. a._GenerateLimitMessage = function(e, i) {
  11195. var o = a._LogLimitOutputs[e];
  11196. if (!(!o || !a.MessageLimitReached) && o.current === o.limit)
  11197. switch (i) {
  11198. case 0:
  11199. a.Log(a.MessageLimitReached.replace(/%LIMIT%/g, "" + o.limit).replace(/%TYPE%/g, "log"));
  11200. break;
  11201. case 1:
  11202. a.Warn(a.MessageLimitReached.replace(/%LIMIT%/g, "" + o.limit).replace(/%TYPE%/g, "warning"));
  11203. break;
  11204. case 2:
  11205. a.Error(a.MessageLimitReached.replace(/%LIMIT%/g, "" + o.limit).replace(/%TYPE%/g, "error"));
  11206. break
  11207. }
  11208. }
  11209. ,
  11210. a._AddLogEntry = function(e) {
  11211. a._LogCache = e + a._LogCache,
  11212. a.OnNewCacheEntry && a.OnNewCacheEntry(e)
  11213. }
  11214. ,
  11215. a._FormatMessage = function(e) {
  11216. var i = function(s) {
  11217. return s < 10 ? "0" + s : "" + s
  11218. }
  11219. , o = new Date;
  11220. return "[" + i(o.getHours()) + ":" + i(o.getMinutes()) + ":" + i(o.getSeconds()) + "]: " + e
  11221. }
  11222. ,
  11223. a._LogDisabled = function(e, i) {}
  11224. ,
  11225. a._LogEnabled = function(e, i) {
  11226. if (!(i !== void 0 && !a._CheckLimit(e, i))) {
  11227. var o = a._FormatMessage(e);
  11228. console.log("BJS - " + o);
  11229. var s = "<div style='color:white'>" + o + "</div><br>";
  11230. a._AddLogEntry(s),
  11231. a._GenerateLimitMessage(e, 0)
  11232. }
  11233. }
  11234. ,
  11235. a._WarnDisabled = function(e, i) {}
  11236. ,
  11237. a._WarnEnabled = function(e, i) {
  11238. if (!(i !== void 0 && !a._CheckLimit(e, i))) {
  11239. var o = a._FormatMessage(e);
  11240. console.warn("BJS - " + o);
  11241. var s = "<div style='color:orange'>" + e + "</div><br>";
  11242. a._AddLogEntry(s),
  11243. a._GenerateLimitMessage(e, 1)
  11244. }
  11245. }
  11246. ,
  11247. a._ErrorDisabled = function(e, i) {}
  11248. ,
  11249. a._ErrorEnabled = function(e, i) {
  11250. if (!(i !== void 0 && !a._CheckLimit(e, i))) {
  11251. var o = a._FormatMessage(e);
  11252. a.errorsCount++,
  11253. console.error("BJS - " + o);
  11254. var s = "<div style='color:red'>" + o + "</div><br>";
  11255. a._AddLogEntry(s),
  11256. a._GenerateLimitMessage(e, 2)
  11257. }
  11258. }
  11259. ,
  11260. Object.defineProperty(a, "LogCache", {
  11261. get: function() {
  11262. return a._LogCache
  11263. },
  11264. enumerable: !1,
  11265. configurable: !0
  11266. }),
  11267. a.ClearLogCache = function() {
  11268. a._LogCache = "",
  11269. a._LogLimitOutputs = {},
  11270. a.errorsCount = 0
  11271. }
  11272. ,
  11273. Object.defineProperty(a, "LogLevels", {
  11274. set: function(e) {
  11275. (e & a.MessageLogLevel) === a.MessageLogLevel ? a.Log = a._LogEnabled : a.Log = a._LogDisabled,
  11276. (e & a.WarningLogLevel) === a.WarningLogLevel ? a.Warn = a._WarnEnabled : a.Warn = a._WarnDisabled,
  11277. (e & a.ErrorLogLevel) === a.ErrorLogLevel ? a.Error = a._ErrorEnabled : a.Error = a._ErrorDisabled
  11278. },
  11279. enumerable: !1,
  11280. configurable: !0
  11281. }),
  11282. a.NoneLogLevel = 0,
  11283. a.MessageLogLevel = 1,
  11284. a.WarningLogLevel = 2,
  11285. a.ErrorLogLevel = 4,
  11286. a.AllLogLevel = 7,
  11287. a.MessageLimitReached = "Too many %TYPE%s (%LIMIT%), no more %TYPE%s will be reported for this message.",
  11288. a._LogCache = "",
  11289. a._LogLimitOutputs = {},
  11290. a.errorsCount = 0,
  11291. a.Log = a._LogEnabled,
  11292. a.Warn = a._WarnEnabled,
  11293. a.Error = a._ErrorEnabled,
  11294. a
  11295. }()
  11296. , EndsWith = function(a, e) {
  11297. return a.indexOf(e, a.length - e.length) !== -1
  11298. }
  11299. , StartsWith = function(a, e) {
  11300. return a ? a.indexOf(e) === 0 : !1
  11301. }
  11302. , Decode = function(a) {
  11303. if (typeof TextDecoder != "undefined")
  11304. return new TextDecoder().decode(a);
  11305. for (var e = "", i = 0; i < a.byteLength; i++)
  11306. e += String.fromCharCode(a[i]);
  11307. return e
  11308. }
  11309. , EncodeArrayBufferToBase64 = function(a) {
  11310. for (var e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", i = "", o, s, c, d, _, b, k, j = 0, $ = ArrayBuffer.isView(a) ? new Uint8Array(a.buffer,a.byteOffset,a.byteLength) : new Uint8Array(a); j < $.length; )
  11311. o = $[j++],
  11312. s = j < $.length ? $[j++] : Number.NaN,
  11313. c = j < $.length ? $[j++] : Number.NaN,
  11314. d = o >> 2,
  11315. _ = (o & 3) << 4 | s >> 4,
  11316. b = (s & 15) << 2 | c >> 6,
  11317. k = c & 63,
  11318. isNaN(s) ? b = k = 64 : isNaN(c) && (k = 64),
  11319. i += e.charAt(d) + e.charAt(_) + e.charAt(b) + e.charAt(k);
  11320. return i
  11321. }
  11322. , DecodeBase64ToString = function(a) {
  11323. return atob(a)
  11324. }
  11325. , DecodeBase64ToBinary = function(a) {
  11326. for (var e = DecodeBase64ToString(a), i = e.length, o = new Uint8Array(new ArrayBuffer(i)), s = 0; s < i; s++)
  11327. o[s] = e.charCodeAt(s);
  11328. return o.buffer
  11329. }
  11330. , PadNumber = function(a, e) {
  11331. for (var i = String(a); i.length < e; )
  11332. i = "0" + i;
  11333. return i
  11334. }
  11335. , StringTools = {
  11336. EndsWith,
  11337. StartsWith,
  11338. Decode,
  11339. EncodeArrayBufferToBase64,
  11340. DecodeBase64ToString,
  11341. DecodeBase64ToBinary,
  11342. PadNumber
  11343. }
  11344. , ShaderCodeNode = function() {
  11345. function a() {
  11346. this.children = []
  11347. }
  11348. return a.prototype.isValid = function(e) {
  11349. return !0
  11350. }
  11351. ,
  11352. a.prototype.process = function(e, i) {
  11353. var o = "";
  11354. if (this.line) {
  11355. var s = this.line
  11356. , c = i.processor;
  11357. if (c) {
  11358. if (c.lineProcessor && (s = c.lineProcessor(s, i.isFragment, i.processingContext)),
  11359. c.attributeProcessor && StartsWith(this.line, "attribute"))
  11360. s = c.attributeProcessor(this.line, e, i.processingContext);
  11361. else if (c.varyingProcessor && StartsWith(this.line, "varying"))
  11362. s = c.varyingProcessor(this.line, i.isFragment, e, i.processingContext);
  11363. else if (c.uniformProcessor && c.uniformRegexp && c.uniformRegexp.test(this.line))
  11364. i.lookForClosingBracketForUniformBuffer || (s = c.uniformProcessor(this.line, i.isFragment, e, i.processingContext));
  11365. else if (c.uniformBufferProcessor && c.uniformBufferRegexp && c.uniformBufferRegexp.test(this.line))
  11366. i.lookForClosingBracketForUniformBuffer || (s = c.uniformBufferProcessor(this.line, i.isFragment, i.processingContext),
  11367. i.lookForClosingBracketForUniformBuffer = !0);
  11368. else if (c.textureProcessor && c.textureRegexp && c.textureRegexp.test(this.line))
  11369. s = c.textureProcessor(this.line, i.isFragment, e, i.processingContext);
  11370. else if ((c.uniformProcessor || c.uniformBufferProcessor) && StartsWith(this.line, "uniform") && !i.lookForClosingBracketForUniformBuffer) {
  11371. var d = /uniform\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/;
  11372. d.test(this.line) ? c.uniformProcessor && (s = c.uniformProcessor(this.line, i.isFragment, e, i.processingContext)) : c.uniformBufferProcessor && (s = c.uniformBufferProcessor(this.line, i.isFragment, i.processingContext),
  11373. i.lookForClosingBracketForUniformBuffer = !0)
  11374. }
  11375. i.lookForClosingBracketForUniformBuffer && this.line.indexOf("}") !== -1 && (i.lookForClosingBracketForUniformBuffer = !1,
  11376. c.endOfUniformBufferProcessor && (s = c.endOfUniformBufferProcessor(this.line, i.isFragment, i.processingContext)))
  11377. }
  11378. o += s + `\r
  11379. `
  11380. }
  11381. return this.children.forEach(function(_) {
  11382. o += _.process(e, i)
  11383. }),
  11384. this.additionalDefineKey && (e[this.additionalDefineKey] = this.additionalDefineValue || "true"),
  11385. o
  11386. }
  11387. ,
  11388. a
  11389. }()
  11390. , ShaderCodeCursor = function() {
  11391. function a() {}
  11392. return Object.defineProperty(a.prototype, "currentLine", {
  11393. get: function() {
  11394. return this._lines[this.lineIndex]
  11395. },
  11396. enumerable: !1,
  11397. configurable: !0
  11398. }),
  11399. Object.defineProperty(a.prototype, "canRead", {
  11400. get: function() {
  11401. return this.lineIndex < this._lines.length - 1
  11402. },
  11403. enumerable: !1,
  11404. configurable: !0
  11405. }),
  11406. Object.defineProperty(a.prototype, "lines", {
  11407. set: function(e) {
  11408. this._lines = [];
  11409. for (var i = 0, o = e; i < o.length; i++) {
  11410. var s = o[i];
  11411. if (s[0] === "#") {
  11412. this._lines.push(s);
  11413. continue
  11414. }
  11415. for (var c = s.split(";"), d = 0; d < c.length; d++) {
  11416. var _ = c[d];
  11417. _ = _.trim(),
  11418. _ && this._lines.push(_ + (d !== c.length - 1 ? ";" : ""))
  11419. }
  11420. }
  11421. },
  11422. enumerable: !1,
  11423. configurable: !0
  11424. }),
  11425. a
  11426. }()
  11427. , ShaderCodeConditionNode = function(a) {
  11428. __extends(e, a);
  11429. function e() {
  11430. return a !== null && a.apply(this, arguments) || this
  11431. }
  11432. return e.prototype.process = function(i, o) {
  11433. for (var s = 0; s < this.children.length; s++) {
  11434. var c = this.children[s];
  11435. if (c.isValid(i))
  11436. return c.process(i, o)
  11437. }
  11438. return ""
  11439. }
  11440. ,
  11441. e
  11442. }(ShaderCodeNode)
  11443. , ShaderCodeTestNode = function(a) {
  11444. __extends(e, a);
  11445. function e() {
  11446. return a !== null && a.apply(this, arguments) || this
  11447. }
  11448. return e.prototype.isValid = function(i) {
  11449. return this.testExpression.isTrue(i)
  11450. }
  11451. ,
  11452. e
  11453. }(ShaderCodeNode)
  11454. , ShaderDefineExpression = function() {
  11455. function a() {}
  11456. return a.prototype.isTrue = function(e) {
  11457. return !0
  11458. }
  11459. ,
  11460. a.postfixToInfix = function(e) {
  11461. for (var i = [], o = 0, s = e; o < s.length; o++) {
  11462. var c = s[o];
  11463. if (a._OperatorPriority[c] === void 0)
  11464. i.push(c);
  11465. else {
  11466. var d = i[i.length - 1]
  11467. , _ = i[i.length - 2];
  11468. i.length -= 2,
  11469. i.push("(" + _ + c + d + ")")
  11470. }
  11471. }
  11472. return i[i.length - 1]
  11473. }
  11474. ,
  11475. a.infixToPostfix = function(e) {
  11476. for (var i = [], o = -1, s = function() {
  11477. k = k.trim(),
  11478. k !== "" && (i.push(k),
  11479. k = "")
  11480. }, c = function(_e) {
  11481. o < a._Stack.length - 1 && (a._Stack[++o] = _e)
  11482. }, d = function() {
  11483. return a._Stack[o]
  11484. }, _ = function() {
  11485. return o === -1 ? "!!INVALID EXPRESSION!!" : a._Stack[o--]
  11486. }, b = 0, k = ""; b < e.length; ) {
  11487. var j = e.charAt(b)
  11488. , $ = b < e.length - 1 ? e.substr(b, 2) : "";
  11489. if (j === "(")
  11490. k = "",
  11491. c(j);
  11492. else if (j === ")") {
  11493. for (s(); o !== -1 && d() !== "("; )
  11494. i.push(_());
  11495. _()
  11496. } else if (a._OperatorPriority[$] > 1) {
  11497. for (s(); o !== -1 && a._OperatorPriority[d()] >= a._OperatorPriority[$]; )
  11498. i.push(_());
  11499. c($),
  11500. b++
  11501. } else
  11502. k += j;
  11503. b++
  11504. }
  11505. for (s(); o !== -1; )
  11506. d() === "(" ? _() : i.push(_());
  11507. return i
  11508. }
  11509. ,
  11510. a._OperatorPriority = {
  11511. ")": 0,
  11512. "(": 1,
  11513. "||": 2,
  11514. "&&": 3
  11515. },
  11516. a._Stack = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""],
  11517. a
  11518. }()
  11519. , ShaderDefineIsDefinedOperator = function(a) {
  11520. __extends(e, a);
  11521. function e(i, o) {
  11522. o === void 0 && (o = !1);
  11523. var s = a.call(this) || this;
  11524. return s.define = i,
  11525. s.not = o,
  11526. s
  11527. }
  11528. return e.prototype.isTrue = function(i) {
  11529. var o = i[this.define] !== void 0;
  11530. return this.not && (o = !o),
  11531. o
  11532. }
  11533. ,
  11534. e
  11535. }(ShaderDefineExpression)
  11536. , ShaderDefineOrOperator = function(a) {
  11537. __extends(e, a);
  11538. function e() {
  11539. return a !== null && a.apply(this, arguments) || this
  11540. }
  11541. return e.prototype.isTrue = function(i) {
  11542. return this.leftOperand.isTrue(i) || this.rightOperand.isTrue(i)
  11543. }
  11544. ,
  11545. e
  11546. }(ShaderDefineExpression)
  11547. , ShaderDefineAndOperator = function(a) {
  11548. __extends(e, a);
  11549. function e() {
  11550. return a !== null && a.apply(this, arguments) || this
  11551. }
  11552. return e.prototype.isTrue = function(i) {
  11553. return this.leftOperand.isTrue(i) && this.rightOperand.isTrue(i)
  11554. }
  11555. ,
  11556. e
  11557. }(ShaderDefineExpression)
  11558. , ShaderDefineArithmeticOperator = function(a) {
  11559. __extends(e, a);
  11560. function e(i, o, s) {
  11561. var c = a.call(this) || this;
  11562. return c.define = i,
  11563. c.operand = o,
  11564. c.testValue = s,
  11565. c
  11566. }
  11567. return e.prototype.isTrue = function(i) {
  11568. var o = i[this.define];
  11569. o === void 0 && (o = this.define);
  11570. var s = !1
  11571. , c = parseInt(o)
  11572. , d = parseInt(this.testValue);
  11573. switch (this.operand) {
  11574. case ">":
  11575. s = c > d;
  11576. break;
  11577. case "<":
  11578. s = c < d;
  11579. break;
  11580. case "<=":
  11581. s = c <= d;
  11582. break;
  11583. case ">=":
  11584. s = c >= d;
  11585. break;
  11586. case "==":
  11587. s = c === d;
  11588. break
  11589. }
  11590. return s
  11591. }
  11592. ,
  11593. e
  11594. }(ShaderDefineExpression);
  11595. function _WarnImport(a) {
  11596. return a + " needs to be imported before as it contains a side-effect required by your code."
  11597. }
  11598. var ShaderLanguage;
  11599. (function(a) {
  11600. a[a.GLSL = 0] = "GLSL",
  11601. a[a.WGSL = 1] = "WGSL"
  11602. }
  11603. )(ShaderLanguage || (ShaderLanguage = {}));
  11604. var regexSE = /defined\s*?\((.+?)\)/g, regexSERevert = /defined\s*?\[(.+?)\]/g, ShaderProcessor = function() {
  11605. function a() {}
  11606. return a.Initialize = function(e) {
  11607. e.processor && e.processor.initializeShaders && e.processor.initializeShaders(e.processingContext)
  11608. }
  11609. ,
  11610. a.Process = function(e, i, o, s) {
  11611. var c = this, d;
  11612. !((d = i.processor) === null || d === void 0) && d.preProcessShaderCode && (e = i.processor.preProcessShaderCode(e)),
  11613. this._ProcessIncludes(e, i, function(_) {
  11614. var b = c._ProcessShaderConversion(_, i, s);
  11615. o(b)
  11616. })
  11617. }
  11618. ,
  11619. a.PreProcess = function(e, i, o, s) {
  11620. var c = this, d;
  11621. !((d = i.processor) === null || d === void 0) && d.preProcessShaderCode && (e = i.processor.preProcessShaderCode(e)),
  11622. this._ProcessIncludes(e, i, function(_) {
  11623. var b = c._ApplyPreProcessing(_, i, s);
  11624. o(b)
  11625. })
  11626. }
  11627. ,
  11628. a.Finalize = function(e, i, o) {
  11629. return !o.processor || !o.processor.finalizeShaders ? {
  11630. vertexCode: e,
  11631. fragmentCode: i
  11632. } : o.processor.finalizeShaders(e, i, o.processingContext)
  11633. }
  11634. ,
  11635. a._ProcessPrecision = function(e, i) {
  11636. var o;
  11637. if (!((o = i.processor) === null || o === void 0) && o.noPrecision)
  11638. return e;
  11639. var s = i.shouldUseHighPrecisionShader;
  11640. return e.indexOf("precision highp float") === -1 ? s ? e = `precision highp float;
  11641. ` + e : e = `precision mediump float;
  11642. ` + e : s || (e = e.replace("precision highp float", "precision mediump float")),
  11643. e
  11644. }
  11645. ,
  11646. a._ExtractOperation = function(e) {
  11647. var i = /defined\((.+)\)/
  11648. , o = i.exec(e);
  11649. if (o && o.length)
  11650. return new ShaderDefineIsDefinedOperator(o[1].trim(),e[0] === "!");
  11651. for (var s = ["==", ">=", "<=", "<", ">"], c = "", d = 0, _ = 0, b = s; _ < b.length && (c = b[_],
  11652. d = e.indexOf(c),
  11653. !(d > -1)); _++)
  11654. ;
  11655. if (d === -1)
  11656. return new ShaderDefineIsDefinedOperator(e);
  11657. var k = e.substring(0, d).trim()
  11658. , j = e.substring(d + c.length).trim();
  11659. return new ShaderDefineArithmeticOperator(k,c,j)
  11660. }
  11661. ,
  11662. a._BuildSubExpression = function(e) {
  11663. e = e.replace(regexSE, "defined[$1]");
  11664. for (var i = ShaderDefineExpression.infixToPostfix(e), o = [], s = 0, c = i; s < c.length; s++) {
  11665. var d = c[s];
  11666. if (d !== "||" && d !== "&&")
  11667. o.push(d);
  11668. else if (o.length >= 2) {
  11669. var _ = o[o.length - 1]
  11670. , b = o[o.length - 2];
  11671. o.length -= 2;
  11672. var k = d == "&&" ? new ShaderDefineAndOperator : new ShaderDefineOrOperator;
  11673. typeof _ == "string" && (_ = _.replace(regexSERevert, "defined($1)")),
  11674. typeof b == "string" && (b = b.replace(regexSERevert, "defined($1)")),
  11675. k.leftOperand = typeof b == "string" ? this._ExtractOperation(b) : b,
  11676. k.rightOperand = typeof _ == "string" ? this._ExtractOperation(_) : _,
  11677. o.push(k)
  11678. }
  11679. }
  11680. var j = o[o.length - 1];
  11681. return typeof j == "string" && (j = j.replace(regexSERevert, "defined($1)")),
  11682. typeof j == "string" ? this._ExtractOperation(j) : j
  11683. }
  11684. ,
  11685. a._BuildExpression = function(e, i) {
  11686. var o = new ShaderCodeTestNode
  11687. , s = e.substring(0, i)
  11688. , c = e.substring(i);
  11689. return c = c.substring(0, (c.indexOf("//") + 1 || c.length + 1) - 1).trim(),
  11690. s === "#ifdef" ? o.testExpression = new ShaderDefineIsDefinedOperator(c) : s === "#ifndef" ? o.testExpression = new ShaderDefineIsDefinedOperator(c,!0) : o.testExpression = this._BuildSubExpression(c),
  11691. o
  11692. }
  11693. ,
  11694. a._MoveCursorWithinIf = function(e, i, o) {
  11695. for (var s = e.currentLine; this._MoveCursor(e, o); ) {
  11696. s = e.currentLine;
  11697. var c = s.substring(0, 5).toLowerCase();
  11698. if (c === "#else") {
  11699. var d = new ShaderCodeNode;
  11700. i.children.push(d),
  11701. this._MoveCursor(e, d);
  11702. return
  11703. } else if (c === "#elif") {
  11704. var _ = this._BuildExpression(s, 5);
  11705. i.children.push(_),
  11706. o = _
  11707. }
  11708. }
  11709. }
  11710. ,
  11711. a._MoveCursor = function(e, i) {
  11712. for (; e.canRead; ) {
  11713. e.lineIndex++;
  11714. var o = e.currentLine
  11715. , s = /(#ifdef)|(#else)|(#elif)|(#endif)|(#ifndef)|(#if)/
  11716. , c = s.exec(o);
  11717. if (c && c.length) {
  11718. var d = c[0];
  11719. switch (d) {
  11720. case "#ifdef":
  11721. {
  11722. var _ = new ShaderCodeConditionNode;
  11723. i.children.push(_);
  11724. var b = this._BuildExpression(o, 6);
  11725. _.children.push(b),
  11726. this._MoveCursorWithinIf(e, _, b);
  11727. break
  11728. }
  11729. case "#else":
  11730. case "#elif":
  11731. return !0;
  11732. case "#endif":
  11733. return !1;
  11734. case "#ifndef":
  11735. {
  11736. var _ = new ShaderCodeConditionNode;
  11737. i.children.push(_);
  11738. var b = this._BuildExpression(o, 7);
  11739. _.children.push(b),
  11740. this._MoveCursorWithinIf(e, _, b);
  11741. break
  11742. }
  11743. case "#if":
  11744. {
  11745. var _ = new ShaderCodeConditionNode
  11746. , b = this._BuildExpression(o, 3);
  11747. i.children.push(_),
  11748. _.children.push(b),
  11749. this._MoveCursorWithinIf(e, _, b);
  11750. break
  11751. }
  11752. }
  11753. } else {
  11754. var k = new ShaderCodeNode;
  11755. if (k.line = o,
  11756. i.children.push(k),
  11757. o[0] === "#" && o[1] === "d") {
  11758. var j = o.replace(";", "").split(" ");
  11759. k.additionalDefineKey = j[1],
  11760. j.length === 3 && (k.additionalDefineValue = j[2])
  11761. }
  11762. }
  11763. }
  11764. return !1
  11765. }
  11766. ,
  11767. a._EvaluatePreProcessors = function(e, i, o) {
  11768. var s = new ShaderCodeNode
  11769. , c = new ShaderCodeCursor;
  11770. return c.lineIndex = -1,
  11771. c.lines = e.split(`
  11772. `),
  11773. this._MoveCursor(c, s),
  11774. s.process(i, o)
  11775. }
  11776. ,
  11777. a._PreparePreProcessors = function(e, i) {
  11778. for (var o, s = e.defines, c = {}, d = 0, _ = s; d < _.length; d++) {
  11779. var b = _[d]
  11780. , k = b.replace("#define", "").replace(";", "").trim()
  11781. , j = k.split(" ");
  11782. c[j[0]] = j.length > 1 ? j[1] : ""
  11783. }
  11784. return ((o = e.processor) === null || o === void 0 ? void 0 : o.shaderLanguage) === ShaderLanguage.GLSL && (c.GL_ES = "true"),
  11785. c.__VERSION__ = e.version,
  11786. c[e.platformName] = "true",
  11787. i._getGlobalDefines(c),
  11788. c
  11789. }
  11790. ,
  11791. a._ProcessShaderConversion = function(e, i, o) {
  11792. var s = this._ProcessPrecision(e, i);
  11793. if (!i.processor)
  11794. return s;
  11795. if (i.processor.shaderLanguage === ShaderLanguage.GLSL && s.indexOf("#version 3") !== -1)
  11796. return s.replace("#version 300 es", "");
  11797. var c = i.defines
  11798. , d = this._PreparePreProcessors(i, o);
  11799. return i.processor.preProcessor && (s = i.processor.preProcessor(s, c, i.isFragment, i.processingContext)),
  11800. s = this._EvaluatePreProcessors(s, d, i),
  11801. i.processor.postProcessor && (s = i.processor.postProcessor(s, c, i.isFragment, i.processingContext, o)),
  11802. o._features.needShaderCodeInlining && (s = o.inlineShaderCode(s)),
  11803. s
  11804. }
  11805. ,
  11806. a._ApplyPreProcessing = function(e, i, o) {
  11807. var s, c, d = e, _ = i.defines, b = this._PreparePreProcessors(i, o);
  11808. return !((s = i.processor) === null || s === void 0) && s.preProcessor && (d = i.processor.preProcessor(d, _, i.isFragment, i.processingContext)),
  11809. d = this._EvaluatePreProcessors(d, b, i),
  11810. !((c = i.processor) === null || c === void 0) && c.postProcessor && (d = i.processor.postProcessor(d, _, i.isFragment, i.processingContext, o)),
  11811. o._features.needShaderCodeInlining && (d = o.inlineShaderCode(d)),
  11812. d
  11813. }
  11814. ,
  11815. a._ProcessIncludes = function(e, i, o) {
  11816. for (var s = this, c = /#include\s?<(.+)>(\((.*)\))*(\[(.*)\])*/g, d = c.exec(e), _ = new String(e), b = !1; d != null; ) {
  11817. var k = d[1];
  11818. if (k.indexOf("__decl__") !== -1 && (k = k.replace(/__decl__/, ""),
  11819. i.supportsUniformBuffers && (k = k.replace(/Vertex/, "Ubo"),
  11820. k = k.replace(/Fragment/, "Ubo")),
  11821. k = k + "Declaration"),
  11822. i.includesShadersStore[k]) {
  11823. var j = i.includesShadersStore[k];
  11824. if (d[2])
  11825. for (var $ = d[3].split(","), _e = 0; _e < $.length; _e += 2) {
  11826. var et = new RegExp($[_e],"g")
  11827. , tt = $[_e + 1];
  11828. j = j.replace(et, tt)
  11829. }
  11830. if (d[4]) {
  11831. var rt = d[5];
  11832. if (rt.indexOf("..") !== -1) {
  11833. var it = rt.split("..")
  11834. , nt = parseInt(it[0])
  11835. , ot = parseInt(it[1])
  11836. , at = j.slice(0);
  11837. j = "",
  11838. isNaN(ot) && (ot = i.indexParameters[it[1]]);
  11839. for (var st = nt; st < ot; st++)
  11840. i.supportsUniformBuffers || (at = at.replace(/light\{X\}.(\w*)/g, function(ct, lt) {
  11841. return lt + "{X}"
  11842. })),
  11843. j += at.replace(/\{X\}/g, st.toString()) + `
  11844. `
  11845. } else
  11846. i.supportsUniformBuffers || (j = j.replace(/light\{X\}.(\w*)/g, function(ct, lt) {
  11847. return lt + "{X}"
  11848. })),
  11849. j = j.replace(/\{X\}/g, rt)
  11850. }
  11851. _ = _.replace(d[0], j),
  11852. b = b || j.indexOf("#include<") >= 0 || j.indexOf("#include <") >= 0
  11853. } else {
  11854. var ut = i.shadersRepository + "ShadersInclude/" + k + ".fx";
  11855. a._FileToolsLoadFile(ut, function(ct) {
  11856. i.includesShadersStore[k] = ct,
  11857. s._ProcessIncludes(_, i, o)
  11858. });
  11859. return
  11860. }
  11861. d = c.exec(e)
  11862. }
  11863. b ? this._ProcessIncludes(_.toString(), i, o) : o(_)
  11864. }
  11865. ,
  11866. a._FileToolsLoadFile = function(e, i, o, s, c, d) {
  11867. throw _WarnImport("FileTools")
  11868. }
  11869. ,
  11870. a
  11871. }(), ShaderStore = function() {
  11872. function a() {}
  11873. return a.GetShadersRepository = function(e) {
  11874. return e === void 0 && (e = ShaderLanguage.GLSL),
  11875. e === ShaderLanguage.GLSL ? a.ShadersRepository : a.ShadersRepositoryWGSL
  11876. }
  11877. ,
  11878. a.GetShadersStore = function(e) {
  11879. return e === void 0 && (e = ShaderLanguage.GLSL),
  11880. e === ShaderLanguage.GLSL ? a.ShadersStore : a.ShadersStoreWGSL
  11881. }
  11882. ,
  11883. a.GetIncludesShadersStore = function(e) {
  11884. return e === void 0 && (e = ShaderLanguage.GLSL),
  11885. e === ShaderLanguage.GLSL ? a.IncludesShadersStore : a.IncludesShadersStoreWGSL
  11886. }
  11887. ,
  11888. a.ShadersRepository = "src/Shaders/",
  11889. a.ShadersStore = {},
  11890. a.IncludesShadersStore = {},
  11891. a.ShadersRepositoryWGSL = "src/ShadersWGSL/",
  11892. a.ShadersStoreWGSL = {},
  11893. a.IncludesShadersStoreWGSL = {},
  11894. a
  11895. }(), Effect = function() {
  11896. function a(e, i, o, s, c, d, _, b, k, j, $, _e) {
  11897. var et = this;
  11898. s === void 0 && (s = null),
  11899. d === void 0 && (d = null),
  11900. _ === void 0 && (_ = null),
  11901. b === void 0 && (b = null),
  11902. k === void 0 && (k = null),
  11903. $ === void 0 && ($ = ""),
  11904. _e === void 0 && (_e = ShaderLanguage.GLSL);
  11905. var tt, rt;
  11906. this.name = null,
  11907. this.defines = "",
  11908. this.onCompiled = null,
  11909. this.onError = null,
  11910. this.onBind = null,
  11911. this.uniqueId = 0,
  11912. this.onCompileObservable = new Observable,
  11913. this.onErrorObservable = new Observable,
  11914. this._onBindObservable = null,
  11915. this._wasPreviouslyReady = !1,
  11916. this._bonesComputationForcedToCPU = !1,
  11917. this._uniformBuffersNames = {},
  11918. this._multiTarget = !1,
  11919. this._samplers = {},
  11920. this._isReady = !1,
  11921. this._compilationError = "",
  11922. this._allFallbacksProcessed = !1,
  11923. this._uniforms = {},
  11924. this._key = "",
  11925. this._fallbacks = null,
  11926. this._vertexSourceCodeOverride = "",
  11927. this._fragmentSourceCodeOverride = "",
  11928. this._transformFeedbackVaryings = null,
  11929. this._pipelineContext = null,
  11930. this._vertexSourceCode = "",
  11931. this._fragmentSourceCode = "",
  11932. this._rawVertexSourceCode = "",
  11933. this._rawFragmentSourceCode = "",
  11934. this.name = e,
  11935. this._key = $;
  11936. var it = null;
  11937. if (i.attributes) {
  11938. var nt = i;
  11939. if (this._engine = o,
  11940. this._attributesNames = nt.attributes,
  11941. this._uniformsNames = nt.uniformsNames.concat(nt.samplers),
  11942. this._samplerList = nt.samplers.slice(),
  11943. this.defines = nt.defines,
  11944. this.onError = nt.onError,
  11945. this.onCompiled = nt.onCompiled,
  11946. this._fallbacks = nt.fallbacks,
  11947. this._indexParameters = nt.indexParameters,
  11948. this._transformFeedbackVaryings = nt.transformFeedbackVaryings || null,
  11949. this._multiTarget = !!nt.multiTarget,
  11950. this._shaderLanguage = (tt = nt.shaderLanguage) !== null && tt !== void 0 ? tt : ShaderLanguage.GLSL,
  11951. nt.uniformBuffersNames) {
  11952. this._uniformBuffersNamesList = nt.uniformBuffersNames.slice();
  11953. for (var ot = 0; ot < nt.uniformBuffersNames.length; ot++)
  11954. this._uniformBuffersNames[nt.uniformBuffersNames[ot]] = ot
  11955. }
  11956. it = (rt = nt.processFinalCode) !== null && rt !== void 0 ? rt : null
  11957. } else
  11958. this._engine = c,
  11959. this.defines = d == null ? "" : d,
  11960. this._uniformsNames = o.concat(s),
  11961. this._samplerList = s ? s.slice() : [],
  11962. this._attributesNames = i,
  11963. this._uniformBuffersNamesList = [],
  11964. this._shaderLanguage = _e,
  11965. this.onError = k,
  11966. this.onCompiled = b,
  11967. this._indexParameters = j,
  11968. this._fallbacks = _;
  11969. this._attributeLocationByName = {},
  11970. this.uniqueId = a._uniqueIdSeed++;
  11971. var at, st, ut = IsWindowObjectExist() ? this._engine.getHostDocument() : null;
  11972. e.vertexSource ? at = "source:" + e.vertexSource : e.vertexElement ? (at = ut ? ut.getElementById(e.vertexElement) : null,
  11973. at || (at = e.vertexElement)) : at = e.vertex || e,
  11974. e.fragmentSource ? st = "source:" + e.fragmentSource : e.fragmentElement ? (st = ut ? ut.getElementById(e.fragmentElement) : null,
  11975. st || (st = e.fragmentElement)) : st = e.fragment || e,
  11976. this._processingContext = this._engine._getShaderProcessingContext(this._shaderLanguage);
  11977. var ct = {
  11978. defines: this.defines.split(`
  11979. `),
  11980. indexParameters: this._indexParameters,
  11981. isFragment: !1,
  11982. shouldUseHighPrecisionShader: this._engine._shouldUseHighPrecisionShader,
  11983. processor: this._engine._getShaderProcessor(this._shaderLanguage),
  11984. supportsUniformBuffers: this._engine.supportsUniformBuffers,
  11985. shadersRepository: ShaderStore.GetShadersRepository(this._shaderLanguage),
  11986. includesShadersStore: ShaderStore.GetIncludesShadersStore(this._shaderLanguage),
  11987. version: (this._engine.version * 100).toString(),
  11988. platformName: this._engine.shaderPlatformName,
  11989. processingContext: this._processingContext,
  11990. isNDCHalfZRange: this._engine.isNDCHalfZRange,
  11991. useReverseDepthBuffer: this._engine.useReverseDepthBuffer
  11992. }
  11993. , lt = [void 0, void 0]
  11994. , ft = function() {
  11995. if (lt[0] && lt[1]) {
  11996. ct.isFragment = !0;
  11997. var ht = lt[0]
  11998. , pt = lt[1];
  11999. ShaderProcessor.Process(pt, ct, function(dt) {
  12000. it && (dt = it("fragment", dt));
  12001. var _t = ShaderProcessor.Finalize(ht, dt, ct);
  12002. et._useFinalCode(_t.vertexCode, _t.fragmentCode, e)
  12003. }, et._engine)
  12004. }
  12005. };
  12006. this._loadShader(at, "Vertex", "", function(ht) {
  12007. ShaderProcessor.Initialize(ct),
  12008. ShaderProcessor.Process(ht, ct, function(pt) {
  12009. et._rawVertexSourceCode = ht,
  12010. it && (pt = it("vertex", pt)),
  12011. lt[0] = pt,
  12012. ft()
  12013. }, et._engine)
  12014. }),
  12015. this._loadShader(st, "Fragment", "Pixel", function(ht) {
  12016. et._rawFragmentSourceCode = ht,
  12017. lt[1] = ht,
  12018. ft()
  12019. })
  12020. }
  12021. return Object.defineProperty(a, "ShadersRepository", {
  12022. get: function() {
  12023. return ShaderStore.ShadersRepository
  12024. },
  12025. set: function(e) {
  12026. ShaderStore.ShadersRepository = e
  12027. },
  12028. enumerable: !1,
  12029. configurable: !0
  12030. }),
  12031. Object.defineProperty(a.prototype, "onBindObservable", {
  12032. get: function() {
  12033. return this._onBindObservable || (this._onBindObservable = new Observable),
  12034. this._onBindObservable
  12035. },
  12036. enumerable: !1,
  12037. configurable: !0
  12038. }),
  12039. a.prototype._useFinalCode = function(e, i, o) {
  12040. if (o) {
  12041. var s = o.vertexElement || o.vertex || o.spectorName || o
  12042. , c = o.fragmentElement || o.fragment || o.spectorName || o;
  12043. this._vertexSourceCode = (this._shaderLanguage === ShaderLanguage.WGSL ? "//" : "") + "#define SHADER_NAME vertex:" + s + `
  12044. ` + e,
  12045. this._fragmentSourceCode = (this._shaderLanguage === ShaderLanguage.WGSL ? "//" : "") + "#define SHADER_NAME fragment:" + c + `
  12046. ` + i
  12047. } else
  12048. this._vertexSourceCode = e,
  12049. this._fragmentSourceCode = i;
  12050. this._prepareEffect()
  12051. }
  12052. ,
  12053. Object.defineProperty(a.prototype, "key", {
  12054. get: function() {
  12055. return this._key
  12056. },
  12057. enumerable: !1,
  12058. configurable: !0
  12059. }),
  12060. a.prototype.isReady = function() {
  12061. try {
  12062. return this._isReadyInternal()
  12063. } catch {
  12064. return !1
  12065. }
  12066. }
  12067. ,
  12068. a.prototype._isReadyInternal = function() {
  12069. return this._isReady ? !0 : this._pipelineContext ? this._pipelineContext.isReady : !1
  12070. }
  12071. ,
  12072. a.prototype.getEngine = function() {
  12073. return this._engine
  12074. }
  12075. ,
  12076. a.prototype.getPipelineContext = function() {
  12077. return this._pipelineContext
  12078. }
  12079. ,
  12080. a.prototype.getAttributesNames = function() {
  12081. return this._attributesNames
  12082. }
  12083. ,
  12084. a.prototype.getAttributeLocation = function(e) {
  12085. return this._attributes[e]
  12086. }
  12087. ,
  12088. a.prototype.getAttributeLocationByName = function(e) {
  12089. return this._attributeLocationByName[e]
  12090. }
  12091. ,
  12092. a.prototype.getAttributesCount = function() {
  12093. return this._attributes.length
  12094. }
  12095. ,
  12096. a.prototype.getUniformIndex = function(e) {
  12097. return this._uniformsNames.indexOf(e)
  12098. }
  12099. ,
  12100. a.prototype.getUniform = function(e) {
  12101. return this._uniforms[e]
  12102. }
  12103. ,
  12104. a.prototype.getSamplers = function() {
  12105. return this._samplerList
  12106. }
  12107. ,
  12108. a.prototype.getUniformNames = function() {
  12109. return this._uniformsNames
  12110. }
  12111. ,
  12112. a.prototype.getUniformBuffersNames = function() {
  12113. return this._uniformBuffersNamesList
  12114. }
  12115. ,
  12116. a.prototype.getIndexParameters = function() {
  12117. return this._indexParameters
  12118. }
  12119. ,
  12120. a.prototype.getCompilationError = function() {
  12121. return this._compilationError
  12122. }
  12123. ,
  12124. a.prototype.allFallbacksProcessed = function() {
  12125. return this._allFallbacksProcessed
  12126. }
  12127. ,
  12128. a.prototype.executeWhenCompiled = function(e) {
  12129. var i = this;
  12130. if (this.isReady()) {
  12131. e(this);
  12132. return
  12133. }
  12134. this.onCompileObservable.add(function(o) {
  12135. e(o)
  12136. }),
  12137. (!this._pipelineContext || this._pipelineContext.isAsync) && setTimeout(function() {
  12138. i._checkIsReady(null)
  12139. }, 16)
  12140. }
  12141. ,
  12142. a.prototype._checkIsReady = function(e) {
  12143. var i = this;
  12144. try {
  12145. if (this._isReadyInternal())
  12146. return
  12147. } catch (o) {
  12148. this._processCompilationErrors(o, e);
  12149. return
  12150. }
  12151. setTimeout(function() {
  12152. i._checkIsReady(e)
  12153. }, 16)
  12154. }
  12155. ,
  12156. a.prototype._loadShader = function(e, i, o, s) {
  12157. if (typeof HTMLElement != "undefined" && e instanceof HTMLElement) {
  12158. var c = GetDOMTextContent(e);
  12159. s(c);
  12160. return
  12161. }
  12162. if (e.substr(0, 7) === "source:") {
  12163. s(e.substr(7));
  12164. return
  12165. }
  12166. if (e.substr(0, 7) === "base64:") {
  12167. var d = window.atob(e.substr(7));
  12168. s(d);
  12169. return
  12170. }
  12171. var _ = ShaderStore.GetShadersStore(this._shaderLanguage);
  12172. if (_[e + i + "Shader"]) {
  12173. s(_[e + i + "Shader"]);
  12174. return
  12175. }
  12176. if (o && _[e + o + "Shader"]) {
  12177. s(_[e + o + "Shader"]);
  12178. return
  12179. }
  12180. var b;
  12181. e[0] === "." || e[0] === "/" || e.indexOf("http") > -1 ? b = e : b = ShaderStore.GetShadersRepository(this._shaderLanguage) + e,
  12182. this._engine._loadFile(b + "." + i.toLowerCase() + ".fx", s)
  12183. }
  12184. ,
  12185. Object.defineProperty(a.prototype, "vertexSourceCode", {
  12186. get: function() {
  12187. var e, i;
  12188. return this._vertexSourceCodeOverride && this._fragmentSourceCodeOverride ? this._vertexSourceCodeOverride : (i = (e = this._pipelineContext) === null || e === void 0 ? void 0 : e._getVertexShaderCode()) !== null && i !== void 0 ? i : this._vertexSourceCode
  12189. },
  12190. enumerable: !1,
  12191. configurable: !0
  12192. }),
  12193. Object.defineProperty(a.prototype, "fragmentSourceCode", {
  12194. get: function() {
  12195. var e, i;
  12196. return this._vertexSourceCodeOverride && this._fragmentSourceCodeOverride ? this._fragmentSourceCodeOverride : (i = (e = this._pipelineContext) === null || e === void 0 ? void 0 : e._getFragmentShaderCode()) !== null && i !== void 0 ? i : this._fragmentSourceCode
  12197. },
  12198. enumerable: !1,
  12199. configurable: !0
  12200. }),
  12201. Object.defineProperty(a.prototype, "rawVertexSourceCode", {
  12202. get: function() {
  12203. return this._rawVertexSourceCode
  12204. },
  12205. enumerable: !1,
  12206. configurable: !0
  12207. }),
  12208. Object.defineProperty(a.prototype, "rawFragmentSourceCode", {
  12209. get: function() {
  12210. return this._rawFragmentSourceCode
  12211. },
  12212. enumerable: !1,
  12213. configurable: !0
  12214. }),
  12215. a.prototype._rebuildProgram = function(e, i, o, s) {
  12216. var c = this;
  12217. this._isReady = !1,
  12218. this._vertexSourceCodeOverride = e,
  12219. this._fragmentSourceCodeOverride = i,
  12220. this.onError = function(d, _) {
  12221. s && s(_)
  12222. }
  12223. ,
  12224. this.onCompiled = function() {
  12225. var d = c.getEngine().scenes;
  12226. if (d)
  12227. for (var _ = 0; _ < d.length; _++)
  12228. d[_].markAllMaterialsAsDirty(63);
  12229. c._pipelineContext._handlesSpectorRebuildCallback(o)
  12230. }
  12231. ,
  12232. this._fallbacks = null,
  12233. this._prepareEffect()
  12234. }
  12235. ,
  12236. a.prototype._prepareEffect = function() {
  12237. var e = this
  12238. , i = this._attributesNames
  12239. , o = this.defines
  12240. , s = this._pipelineContext;
  12241. this._isReady = !1;
  12242. try {
  12243. var c = this._engine;
  12244. this._pipelineContext = c.createPipelineContext(this._processingContext),
  12245. this._pipelineContext._name = this._key;
  12246. var d = this._rebuildProgram.bind(this);
  12247. this._vertexSourceCodeOverride && this._fragmentSourceCodeOverride ? c._preparePipelineContext(this._pipelineContext, this._vertexSourceCodeOverride, this._fragmentSourceCodeOverride, !0, this._rawVertexSourceCode, this._rawFragmentSourceCode, d, null, this._transformFeedbackVaryings, this._key) : c._preparePipelineContext(this._pipelineContext, this._vertexSourceCode, this._fragmentSourceCode, !1, this._rawVertexSourceCode, this._rawFragmentSourceCode, d, o, this._transformFeedbackVaryings, this._key),
  12248. c._executeWhenRenderingStateIsCompiled(this._pipelineContext, function() {
  12249. if (e._attributes = [],
  12250. e._pipelineContext._fillEffectInformation(e, e._uniformBuffersNames, e._uniformsNames, e._uniforms, e._samplerList, e._samplers, i, e._attributes),
  12251. i)
  12252. for (var _ = 0; _ < i.length; _++) {
  12253. var b = i[_];
  12254. e._attributeLocationByName[b] = e._attributes[_]
  12255. }
  12256. c.bindSamplers(e),
  12257. e._compilationError = "",
  12258. e._isReady = !0,
  12259. e.onCompiled && e.onCompiled(e),
  12260. e.onCompileObservable.notifyObservers(e),
  12261. e.onCompileObservable.clear(),
  12262. e._fallbacks && e._fallbacks.unBindMesh(),
  12263. s && e.getEngine()._deletePipelineContext(s)
  12264. }),
  12265. this._pipelineContext.isAsync && this._checkIsReady(s)
  12266. } catch (_) {
  12267. this._processCompilationErrors(_, s)
  12268. }
  12269. }
  12270. ,
  12271. a.prototype._getShaderCodeAndErrorLine = function(e, i, o) {
  12272. var s = o ? /FRAGMENT SHADER ERROR: 0:(\d+?):/ : /VERTEX SHADER ERROR: 0:(\d+?):/
  12273. , c = null;
  12274. if (i && e) {
  12275. var d = i.match(s);
  12276. if (d && d.length === 2) {
  12277. var _ = parseInt(d[1])
  12278. , b = e.split(`
  12279. `, -1);
  12280. b.length >= _ && (c = "Offending line [" + _ + "] in " + (o ? "fragment" : "vertex") + " code: " + b[_ - 1])
  12281. }
  12282. }
  12283. return [e, c]
  12284. }
  12285. ,
  12286. a.prototype._processCompilationErrors = function(e, i) {
  12287. var o, s, c, d, _;
  12288. i === void 0 && (i = null),
  12289. this._compilationError = e.message;
  12290. var b = this._attributesNames
  12291. , k = this._fallbacks;
  12292. if (Logger$2.Error("Unable to compile effect:"),
  12293. Logger$2.Error("Uniforms: " + this._uniformsNames.map(function(et) {
  12294. return " " + et
  12295. })),
  12296. Logger$2.Error("Attributes: " + b.map(function(et) {
  12297. return " " + et
  12298. })),
  12299. Logger$2.Error(`Defines:\r
  12300. ` + this.defines),
  12301. a.LogShaderCodeOnCompilationError) {
  12302. var j = null
  12303. , $ = null
  12304. , _e = null;
  12305. !((c = this._pipelineContext) === null || c === void 0) && c._getVertexShaderCode() && (o = this._getShaderCodeAndErrorLine(this._pipelineContext._getVertexShaderCode(), this._compilationError, !1),
  12306. _e = o[0],
  12307. j = o[1],
  12308. _e && (Logger$2.Error("Vertex code:"),
  12309. Logger$2.Error(_e))),
  12310. !((d = this._pipelineContext) === null || d === void 0) && d._getFragmentShaderCode() && (s = this._getShaderCodeAndErrorLine((_ = this._pipelineContext) === null || _ === void 0 ? void 0 : _._getFragmentShaderCode(), this._compilationError, !0),
  12311. _e = s[0],
  12312. $ = s[1],
  12313. _e && (Logger$2.Error("Fragment code:"),
  12314. Logger$2.Error(_e))),
  12315. j && Logger$2.Error(j),
  12316. $ && Logger$2.Error($)
  12317. }
  12318. Logger$2.Error("Error: " + this._compilationError),
  12319. i && (this._pipelineContext = i,
  12320. this._isReady = !0,
  12321. this.onError && this.onError(this, this._compilationError),
  12322. this.onErrorObservable.notifyObservers(this)),
  12323. k ? (this._pipelineContext = null,
  12324. k.hasMoreFallbacks ? (this._allFallbacksProcessed = !1,
  12325. Logger$2.Error("Trying next fallback."),
  12326. this.defines = k.reduce(this.defines, this),
  12327. this._prepareEffect()) : (this._allFallbacksProcessed = !0,
  12328. this.onError && this.onError(this, this._compilationError),
  12329. this.onErrorObservable.notifyObservers(this),
  12330. this.onErrorObservable.clear(),
  12331. this._fallbacks && this._fallbacks.unBindMesh())) : this._allFallbacksProcessed = !0
  12332. }
  12333. ,
  12334. Object.defineProperty(a.prototype, "isSupported", {
  12335. get: function() {
  12336. return this._compilationError === ""
  12337. },
  12338. enumerable: !1,
  12339. configurable: !0
  12340. }),
  12341. a.prototype._bindTexture = function(e, i) {
  12342. this._engine._bindTexture(this._samplers[e], i, e)
  12343. }
  12344. ,
  12345. a.prototype.setTexture = function(e, i) {
  12346. this._engine.setTexture(this._samplers[e], this._uniforms[e], i, e)
  12347. }
  12348. ,
  12349. a.prototype.setDepthStencilTexture = function(e, i) {
  12350. this._engine.setDepthStencilTexture(this._samplers[e], this._uniforms[e], i, e)
  12351. }
  12352. ,
  12353. a.prototype.setTextureArray = function(e, i) {
  12354. var o = e + "Ex";
  12355. if (this._samplerList.indexOf(o + "0") === -1) {
  12356. for (var s = this._samplerList.indexOf(e), c = 1; c < i.length; c++) {
  12357. var d = o + (c - 1).toString();
  12358. this._samplerList.splice(s + c, 0, d)
  12359. }
  12360. for (var _ = 0, b = 0, k = this._samplerList; b < k.length; b++) {
  12361. var j = k[b];
  12362. this._samplers[j] = _,
  12363. _ += 1
  12364. }
  12365. }
  12366. this._engine.setTextureArray(this._samplers[e], this._uniforms[e], i, e)
  12367. }
  12368. ,
  12369. a.prototype.setTextureFromPostProcess = function(e, i) {
  12370. this._engine.setTextureFromPostProcess(this._samplers[e], i, e)
  12371. }
  12372. ,
  12373. a.prototype.setTextureFromPostProcessOutput = function(e, i) {
  12374. this._engine.setTextureFromPostProcessOutput(this._samplers[e], i, e)
  12375. }
  12376. ,
  12377. a.prototype.bindUniformBuffer = function(e, i) {
  12378. var o = this._uniformBuffersNames[i];
  12379. o === void 0 || a._baseCache[o] === e && this._engine._features.useUBOBindingCache || (a._baseCache[o] = e,
  12380. this._engine.bindUniformBufferBase(e, o, i))
  12381. }
  12382. ,
  12383. a.prototype.bindUniformBlock = function(e, i) {
  12384. this._engine.bindUniformBlock(this._pipelineContext, e, i)
  12385. }
  12386. ,
  12387. a.prototype.setInt = function(e, i) {
  12388. return this._pipelineContext.setInt(e, i),
  12389. this
  12390. }
  12391. ,
  12392. a.prototype.setInt2 = function(e, i, o) {
  12393. return this._pipelineContext.setInt2(e, i, o),
  12394. this
  12395. }
  12396. ,
  12397. a.prototype.setInt3 = function(e, i, o, s) {
  12398. return this._pipelineContext.setInt3(e, i, o, s),
  12399. this
  12400. }
  12401. ,
  12402. a.prototype.setInt4 = function(e, i, o, s, c) {
  12403. return this._pipelineContext.setInt4(e, i, o, s, c),
  12404. this
  12405. }
  12406. ,
  12407. a.prototype.setIntArray = function(e, i) {
  12408. return this._pipelineContext.setIntArray(e, i),
  12409. this
  12410. }
  12411. ,
  12412. a.prototype.setIntArray2 = function(e, i) {
  12413. return this._pipelineContext.setIntArray2(e, i),
  12414. this
  12415. }
  12416. ,
  12417. a.prototype.setIntArray3 = function(e, i) {
  12418. return this._pipelineContext.setIntArray3(e, i),
  12419. this
  12420. }
  12421. ,
  12422. a.prototype.setIntArray4 = function(e, i) {
  12423. return this._pipelineContext.setIntArray4(e, i),
  12424. this
  12425. }
  12426. ,
  12427. a.prototype.setFloatArray = function(e, i) {
  12428. return this._pipelineContext.setArray(e, i),
  12429. this
  12430. }
  12431. ,
  12432. a.prototype.setFloatArray2 = function(e, i) {
  12433. return this._pipelineContext.setArray2(e, i),
  12434. this
  12435. }
  12436. ,
  12437. a.prototype.setFloatArray3 = function(e, i) {
  12438. return this._pipelineContext.setArray3(e, i),
  12439. this
  12440. }
  12441. ,
  12442. a.prototype.setFloatArray4 = function(e, i) {
  12443. return this._pipelineContext.setArray4(e, i),
  12444. this
  12445. }
  12446. ,
  12447. a.prototype.setArray = function(e, i) {
  12448. return this._pipelineContext.setArray(e, i),
  12449. this
  12450. }
  12451. ,
  12452. a.prototype.setArray2 = function(e, i) {
  12453. return this._pipelineContext.setArray2(e, i),
  12454. this
  12455. }
  12456. ,
  12457. a.prototype.setArray3 = function(e, i) {
  12458. return this._pipelineContext.setArray3(e, i),
  12459. this
  12460. }
  12461. ,
  12462. a.prototype.setArray4 = function(e, i) {
  12463. return this._pipelineContext.setArray4(e, i),
  12464. this
  12465. }
  12466. ,
  12467. a.prototype.setMatrices = function(e, i) {
  12468. return this._pipelineContext.setMatrices(e, i),
  12469. this
  12470. }
  12471. ,
  12472. a.prototype.setMatrix = function(e, i) {
  12473. return this._pipelineContext.setMatrix(e, i),
  12474. this
  12475. }
  12476. ,
  12477. a.prototype.setMatrix3x3 = function(e, i) {
  12478. return this._pipelineContext.setMatrix3x3(e, i),
  12479. this
  12480. }
  12481. ,
  12482. a.prototype.setMatrix2x2 = function(e, i) {
  12483. return this._pipelineContext.setMatrix2x2(e, i),
  12484. this
  12485. }
  12486. ,
  12487. a.prototype.setFloat = function(e, i) {
  12488. return this._pipelineContext.setFloat(e, i),
  12489. this
  12490. }
  12491. ,
  12492. a.prototype.setBool = function(e, i) {
  12493. return this._pipelineContext.setInt(e, i ? 1 : 0),
  12494. this
  12495. }
  12496. ,
  12497. a.prototype.setVector2 = function(e, i) {
  12498. return this._pipelineContext.setVector2(e, i),
  12499. this
  12500. }
  12501. ,
  12502. a.prototype.setFloat2 = function(e, i, o) {
  12503. return this._pipelineContext.setFloat2(e, i, o),
  12504. this
  12505. }
  12506. ,
  12507. a.prototype.setVector3 = function(e, i) {
  12508. return this._pipelineContext.setVector3(e, i),
  12509. this
  12510. }
  12511. ,
  12512. a.prototype.setFloat3 = function(e, i, o, s) {
  12513. return this._pipelineContext.setFloat3(e, i, o, s),
  12514. this
  12515. }
  12516. ,
  12517. a.prototype.setVector4 = function(e, i) {
  12518. return this._pipelineContext.setVector4(e, i),
  12519. this
  12520. }
  12521. ,
  12522. a.prototype.setFloat4 = function(e, i, o, s, c) {
  12523. return this._pipelineContext.setFloat4(e, i, o, s, c),
  12524. this
  12525. }
  12526. ,
  12527. a.prototype.setColor3 = function(e, i) {
  12528. return this._pipelineContext.setColor3(e, i),
  12529. this
  12530. }
  12531. ,
  12532. a.prototype.setColor4 = function(e, i, o) {
  12533. return this._pipelineContext.setColor4(e, i, o),
  12534. this
  12535. }
  12536. ,
  12537. a.prototype.setDirectColor4 = function(e, i) {
  12538. return this._pipelineContext.setDirectColor4(e, i),
  12539. this
  12540. }
  12541. ,
  12542. a.prototype.dispose = function() {
  12543. this._pipelineContext && this._pipelineContext.dispose(),
  12544. this._engine._releaseEffect(this)
  12545. }
  12546. ,
  12547. a.RegisterShader = function(e, i, o, s) {
  12548. s === void 0 && (s = ShaderLanguage.GLSL),
  12549. i && (ShaderStore.GetShadersStore(s)[e + "PixelShader"] = i),
  12550. o && (ShaderStore.GetShadersStore(s)[e + "VertexShader"] = o)
  12551. }
  12552. ,
  12553. a.ResetCache = function() {
  12554. a._baseCache = {}
  12555. }
  12556. ,
  12557. a.LogShaderCodeOnCompilationError = !0,
  12558. a._uniqueIdSeed = 0,
  12559. a._baseCache = {},
  12560. a.ShadersStore = ShaderStore.ShadersStore,
  12561. a.IncludesShadersStore = ShaderStore.IncludesShadersStore,
  12562. a
  12563. }(), DepthCullingState = function() {
  12564. function a(e) {
  12565. e === void 0 && (e = !0),
  12566. this._isDepthTestDirty = !1,
  12567. this._isDepthMaskDirty = !1,
  12568. this._isDepthFuncDirty = !1,
  12569. this._isCullFaceDirty = !1,
  12570. this._isCullDirty = !1,
  12571. this._isZOffsetDirty = !1,
  12572. this._isFrontFaceDirty = !1,
  12573. e && this.reset()
  12574. }
  12575. return Object.defineProperty(a.prototype, "isDirty", {
  12576. get: function() {
  12577. return this._isDepthFuncDirty || this._isDepthTestDirty || this._isDepthMaskDirty || this._isCullFaceDirty || this._isCullDirty || this._isZOffsetDirty || this._isFrontFaceDirty
  12578. },
  12579. enumerable: !1,
  12580. configurable: !0
  12581. }),
  12582. Object.defineProperty(a.prototype, "zOffset", {
  12583. get: function() {
  12584. return this._zOffset
  12585. },
  12586. set: function(e) {
  12587. this._zOffset !== e && (this._zOffset = e,
  12588. this._isZOffsetDirty = !0)
  12589. },
  12590. enumerable: !1,
  12591. configurable: !0
  12592. }),
  12593. Object.defineProperty(a.prototype, "zOffsetUnits", {
  12594. get: function() {
  12595. return this._zOffsetUnits
  12596. },
  12597. set: function(e) {
  12598. this._zOffsetUnits !== e && (this._zOffsetUnits = e,
  12599. this._isZOffsetDirty = !0)
  12600. },
  12601. enumerable: !1,
  12602. configurable: !0
  12603. }),
  12604. Object.defineProperty(a.prototype, "cullFace", {
  12605. get: function() {
  12606. return this._cullFace
  12607. },
  12608. set: function(e) {
  12609. this._cullFace !== e && (this._cullFace = e,
  12610. this._isCullFaceDirty = !0)
  12611. },
  12612. enumerable: !1,
  12613. configurable: !0
  12614. }),
  12615. Object.defineProperty(a.prototype, "cull", {
  12616. get: function() {
  12617. return this._cull
  12618. },
  12619. set: function(e) {
  12620. this._cull !== e && (this._cull = e,
  12621. this._isCullDirty = !0)
  12622. },
  12623. enumerable: !1,
  12624. configurable: !0
  12625. }),
  12626. Object.defineProperty(a.prototype, "depthFunc", {
  12627. get: function() {
  12628. return this._depthFunc
  12629. },
  12630. set: function(e) {
  12631. this._depthFunc !== e && (this._depthFunc = e,
  12632. this._isDepthFuncDirty = !0)
  12633. },
  12634. enumerable: !1,
  12635. configurable: !0
  12636. }),
  12637. Object.defineProperty(a.prototype, "depthMask", {
  12638. get: function() {
  12639. return this._depthMask
  12640. },
  12641. set: function(e) {
  12642. this._depthMask !== e && (this._depthMask = e,
  12643. this._isDepthMaskDirty = !0)
  12644. },
  12645. enumerable: !1,
  12646. configurable: !0
  12647. }),
  12648. Object.defineProperty(a.prototype, "depthTest", {
  12649. get: function() {
  12650. return this._depthTest
  12651. },
  12652. set: function(e) {
  12653. this._depthTest !== e && (this._depthTest = e,
  12654. this._isDepthTestDirty = !0)
  12655. },
  12656. enumerable: !1,
  12657. configurable: !0
  12658. }),
  12659. Object.defineProperty(a.prototype, "frontFace", {
  12660. get: function() {
  12661. return this._frontFace
  12662. },
  12663. set: function(e) {
  12664. this._frontFace !== e && (this._frontFace = e,
  12665. this._isFrontFaceDirty = !0)
  12666. },
  12667. enumerable: !1,
  12668. configurable: !0
  12669. }),
  12670. a.prototype.reset = function() {
  12671. this._depthMask = !0,
  12672. this._depthTest = !0,
  12673. this._depthFunc = null,
  12674. this._cullFace = null,
  12675. this._cull = null,
  12676. this._zOffset = 0,
  12677. this._zOffsetUnits = 0,
  12678. this._frontFace = null,
  12679. this._isDepthTestDirty = !0,
  12680. this._isDepthMaskDirty = !0,
  12681. this._isDepthFuncDirty = !1,
  12682. this._isCullFaceDirty = !1,
  12683. this._isCullDirty = !1,
  12684. this._isZOffsetDirty = !0,
  12685. this._isFrontFaceDirty = !1
  12686. }
  12687. ,
  12688. a.prototype.apply = function(e) {
  12689. !this.isDirty || (this._isCullDirty && (this.cull ? e.enable(e.CULL_FACE) : e.disable(e.CULL_FACE),
  12690. this._isCullDirty = !1),
  12691. this._isCullFaceDirty && (e.cullFace(this.cullFace),
  12692. this._isCullFaceDirty = !1),
  12693. this._isDepthMaskDirty && (e.depthMask(this.depthMask),
  12694. this._isDepthMaskDirty = !1),
  12695. this._isDepthTestDirty && (this.depthTest ? e.enable(e.DEPTH_TEST) : e.disable(e.DEPTH_TEST),
  12696. this._isDepthTestDirty = !1),
  12697. this._isDepthFuncDirty && (e.depthFunc(this.depthFunc),
  12698. this._isDepthFuncDirty = !1),
  12699. this._isZOffsetDirty && (this.zOffset || this.zOffsetUnits ? (e.enable(e.POLYGON_OFFSET_FILL),
  12700. e.polygonOffset(this.zOffset, this.zOffsetUnits)) : e.disable(e.POLYGON_OFFSET_FILL),
  12701. this._isZOffsetDirty = !1),
  12702. this._isFrontFaceDirty && (e.frontFace(this.frontFace),
  12703. this._isFrontFaceDirty = !1))
  12704. }
  12705. ,
  12706. a
  12707. }(), StencilState = function() {
  12708. function a() {
  12709. this.reset()
  12710. }
  12711. return a.prototype.reset = function() {
  12712. this.enabled = !1,
  12713. this.mask = 255,
  12714. this.func = a.ALWAYS,
  12715. this.funcRef = 1,
  12716. this.funcMask = 255,
  12717. this.opStencilFail = a.KEEP,
  12718. this.opDepthFail = a.KEEP,
  12719. this.opStencilDepthPass = a.REPLACE
  12720. }
  12721. ,
  12722. Object.defineProperty(a.prototype, "stencilFunc", {
  12723. get: function() {
  12724. return this.func
  12725. },
  12726. set: function(e) {
  12727. this.func = e
  12728. },
  12729. enumerable: !1,
  12730. configurable: !0
  12731. }),
  12732. Object.defineProperty(a.prototype, "stencilFuncRef", {
  12733. get: function() {
  12734. return this.funcRef
  12735. },
  12736. set: function(e) {
  12737. this.funcRef = e
  12738. },
  12739. enumerable: !1,
  12740. configurable: !0
  12741. }),
  12742. Object.defineProperty(a.prototype, "stencilFuncMask", {
  12743. get: function() {
  12744. return this.funcMask
  12745. },
  12746. set: function(e) {
  12747. this.funcMask = e
  12748. },
  12749. enumerable: !1,
  12750. configurable: !0
  12751. }),
  12752. Object.defineProperty(a.prototype, "stencilOpStencilFail", {
  12753. get: function() {
  12754. return this.opStencilFail
  12755. },
  12756. set: function(e) {
  12757. this.opStencilFail = e
  12758. },
  12759. enumerable: !1,
  12760. configurable: !0
  12761. }),
  12762. Object.defineProperty(a.prototype, "stencilOpDepthFail", {
  12763. get: function() {
  12764. return this.opDepthFail
  12765. },
  12766. set: function(e) {
  12767. this.opDepthFail = e
  12768. },
  12769. enumerable: !1,
  12770. configurable: !0
  12771. }),
  12772. Object.defineProperty(a.prototype, "stencilOpStencilDepthPass", {
  12773. get: function() {
  12774. return this.opStencilDepthPass
  12775. },
  12776. set: function(e) {
  12777. this.opStencilDepthPass = e
  12778. },
  12779. enumerable: !1,
  12780. configurable: !0
  12781. }),
  12782. Object.defineProperty(a.prototype, "stencilMask", {
  12783. get: function() {
  12784. return this.mask
  12785. },
  12786. set: function(e) {
  12787. this.mask = e
  12788. },
  12789. enumerable: !1,
  12790. configurable: !0
  12791. }),
  12792. Object.defineProperty(a.prototype, "stencilTest", {
  12793. get: function() {
  12794. return this.enabled
  12795. },
  12796. set: function(e) {
  12797. this.enabled = e
  12798. },
  12799. enumerable: !1,
  12800. configurable: !0
  12801. }),
  12802. a.ALWAYS = 519,
  12803. a.KEEP = 7680,
  12804. a.REPLACE = 7681,
  12805. a
  12806. }(), AlphaState = function() {
  12807. function a() {
  12808. this._blendFunctionParameters = new Array(4),
  12809. this._blendEquationParameters = new Array(2),
  12810. this._blendConstants = new Array(4),
  12811. this._isBlendConstantsDirty = !1,
  12812. this._alphaBlend = !1,
  12813. this._isAlphaBlendDirty = !1,
  12814. this._isBlendFunctionParametersDirty = !1,
  12815. this._isBlendEquationParametersDirty = !1,
  12816. this.reset()
  12817. }
  12818. return Object.defineProperty(a.prototype, "isDirty", {
  12819. get: function() {
  12820. return this._isAlphaBlendDirty || this._isBlendFunctionParametersDirty || this._isBlendEquationParametersDirty
  12821. },
  12822. enumerable: !1,
  12823. configurable: !0
  12824. }),
  12825. Object.defineProperty(a.prototype, "alphaBlend", {
  12826. get: function() {
  12827. return this._alphaBlend
  12828. },
  12829. set: function(e) {
  12830. this._alphaBlend !== e && (this._alphaBlend = e,
  12831. this._isAlphaBlendDirty = !0)
  12832. },
  12833. enumerable: !1,
  12834. configurable: !0
  12835. }),
  12836. a.prototype.setAlphaBlendConstants = function(e, i, o, s) {
  12837. this._blendConstants[0] === e && this._blendConstants[1] === i && this._blendConstants[2] === o && this._blendConstants[3] === s || (this._blendConstants[0] = e,
  12838. this._blendConstants[1] = i,
  12839. this._blendConstants[2] = o,
  12840. this._blendConstants[3] = s,
  12841. this._isBlendConstantsDirty = !0)
  12842. }
  12843. ,
  12844. a.prototype.setAlphaBlendFunctionParameters = function(e, i, o, s) {
  12845. this._blendFunctionParameters[0] === e && this._blendFunctionParameters[1] === i && this._blendFunctionParameters[2] === o && this._blendFunctionParameters[3] === s || (this._blendFunctionParameters[0] = e,
  12846. this._blendFunctionParameters[1] = i,
  12847. this._blendFunctionParameters[2] = o,
  12848. this._blendFunctionParameters[3] = s,
  12849. this._isBlendFunctionParametersDirty = !0)
  12850. }
  12851. ,
  12852. a.prototype.setAlphaEquationParameters = function(e, i) {
  12853. this._blendEquationParameters[0] === e && this._blendEquationParameters[1] === i || (this._blendEquationParameters[0] = e,
  12854. this._blendEquationParameters[1] = i,
  12855. this._isBlendEquationParametersDirty = !0)
  12856. }
  12857. ,
  12858. a.prototype.reset = function() {
  12859. this._alphaBlend = !1,
  12860. this._blendFunctionParameters[0] = null,
  12861. this._blendFunctionParameters[1] = null,
  12862. this._blendFunctionParameters[2] = null,
  12863. this._blendFunctionParameters[3] = null,
  12864. this._blendEquationParameters[0] = null,
  12865. this._blendEquationParameters[1] = null,
  12866. this._blendConstants[0] = null,
  12867. this._blendConstants[1] = null,
  12868. this._blendConstants[2] = null,
  12869. this._blendConstants[3] = null,
  12870. this._isAlphaBlendDirty = !0,
  12871. this._isBlendFunctionParametersDirty = !1,
  12872. this._isBlendEquationParametersDirty = !1,
  12873. this._isBlendConstantsDirty = !1
  12874. }
  12875. ,
  12876. a.prototype.apply = function(e) {
  12877. !this.isDirty || (this._isAlphaBlendDirty && (this._alphaBlend ? e.enable(e.BLEND) : e.disable(e.BLEND),
  12878. this._isAlphaBlendDirty = !1),
  12879. this._isBlendFunctionParametersDirty && (e.blendFuncSeparate(this._blendFunctionParameters[0], this._blendFunctionParameters[1], this._blendFunctionParameters[2], this._blendFunctionParameters[3]),
  12880. this._isBlendFunctionParametersDirty = !1),
  12881. this._isBlendEquationParametersDirty && (e.blendEquationSeparate(this._blendEquationParameters[0], this._blendEquationParameters[1]),
  12882. this._isBlendEquationParametersDirty = !1),
  12883. this._isBlendConstantsDirty && (e.blendColor(this._blendConstants[0], this._blendConstants[1], this._blendConstants[2], this._blendConstants[3]),
  12884. this._isBlendConstantsDirty = !1))
  12885. }
  12886. ,
  12887. a
  12888. }(), TextureSampler = function() {
  12889. function a() {
  12890. this.samplingMode = -1,
  12891. this._useMipMaps = !0,
  12892. this._cachedWrapU = null,
  12893. this._cachedWrapV = null,
  12894. this._cachedWrapR = null,
  12895. this._cachedAnisotropicFilteringLevel = null,
  12896. this._comparisonFunction = 0
  12897. }
  12898. return Object.defineProperty(a.prototype, "wrapU", {
  12899. get: function() {
  12900. return this._cachedWrapU
  12901. },
  12902. set: function(e) {
  12903. this._cachedWrapU = e
  12904. },
  12905. enumerable: !1,
  12906. configurable: !0
  12907. }),
  12908. Object.defineProperty(a.prototype, "wrapV", {
  12909. get: function() {
  12910. return this._cachedWrapV
  12911. },
  12912. set: function(e) {
  12913. this._cachedWrapV = e
  12914. },
  12915. enumerable: !1,
  12916. configurable: !0
  12917. }),
  12918. Object.defineProperty(a.prototype, "wrapR", {
  12919. get: function() {
  12920. return this._cachedWrapR
  12921. },
  12922. set: function(e) {
  12923. this._cachedWrapR = e
  12924. },
  12925. enumerable: !1,
  12926. configurable: !0
  12927. }),
  12928. Object.defineProperty(a.prototype, "anisotropicFilteringLevel", {
  12929. get: function() {
  12930. return this._cachedAnisotropicFilteringLevel
  12931. },
  12932. set: function(e) {
  12933. this._cachedAnisotropicFilteringLevel = e
  12934. },
  12935. enumerable: !1,
  12936. configurable: !0
  12937. }),
  12938. Object.defineProperty(a.prototype, "comparisonFunction", {
  12939. get: function() {
  12940. return this._comparisonFunction
  12941. },
  12942. set: function(e) {
  12943. this._comparisonFunction = e
  12944. },
  12945. enumerable: !1,
  12946. configurable: !0
  12947. }),
  12948. Object.defineProperty(a.prototype, "useMipMaps", {
  12949. get: function() {
  12950. return this._useMipMaps
  12951. },
  12952. set: function(e) {
  12953. this._useMipMaps = e
  12954. },
  12955. enumerable: !1,
  12956. configurable: !0
  12957. }),
  12958. a.prototype.setParameters = function(e, i, o, s, c, d) {
  12959. return e === void 0 && (e = 1),
  12960. i === void 0 && (i = 1),
  12961. o === void 0 && (o = 1),
  12962. s === void 0 && (s = 1),
  12963. c === void 0 && (c = 2),
  12964. d === void 0 && (d = 0),
  12965. this._cachedWrapU = e,
  12966. this._cachedWrapV = i,
  12967. this._cachedWrapR = o,
  12968. this._cachedAnisotropicFilteringLevel = s,
  12969. this.samplingMode = c,
  12970. this._comparisonFunction = d,
  12971. this
  12972. }
  12973. ,
  12974. a.prototype.compareSampler = function(e) {
  12975. return this._cachedWrapU === e._cachedWrapU && this._cachedWrapV === e._cachedWrapV && this._cachedWrapR === e._cachedWrapR && this._cachedAnisotropicFilteringLevel === e._cachedAnisotropicFilteringLevel && this.samplingMode === e.samplingMode && this._comparisonFunction === e._comparisonFunction && this._useMipMaps === e._useMipMaps
  12976. }
  12977. ,
  12978. a
  12979. }(), InternalTextureSource;
  12980. (function(a) {
  12981. a[a.Unknown = 0] = "Unknown",
  12982. a[a.Url = 1] = "Url",
  12983. a[a.Temp = 2] = "Temp",
  12984. a[a.Raw = 3] = "Raw",
  12985. a[a.Dynamic = 4] = "Dynamic",
  12986. a[a.RenderTarget = 5] = "RenderTarget",
  12987. a[a.MultiRenderTarget = 6] = "MultiRenderTarget",
  12988. a[a.Cube = 7] = "Cube",
  12989. a[a.CubeRaw = 8] = "CubeRaw",
  12990. a[a.CubePrefiltered = 9] = "CubePrefiltered",
  12991. a[a.Raw3D = 10] = "Raw3D",
  12992. a[a.Raw2DArray = 11] = "Raw2DArray",
  12993. a[a.DepthStencil = 12] = "DepthStencil",
  12994. a[a.CubeRawRGBD = 13] = "CubeRawRGBD",
  12995. a[a.Depth = 14] = "Depth"
  12996. }
  12997. )(InternalTextureSource || (InternalTextureSource = {}));
  12998. var InternalTexture = function(a) {
  12999. __extends(e, a);
  13000. function e(i, o, s) {
  13001. s === void 0 && (s = !1);
  13002. var c = a.call(this) || this;
  13003. return c.isReady = !1,
  13004. c.isCube = !1,
  13005. c.is3D = !1,
  13006. c.is2DArray = !1,
  13007. c.isMultiview = !1,
  13008. c.url = "",
  13009. c.generateMipMaps = !1,
  13010. c.samples = 0,
  13011. c.type = -1,
  13012. c.format = -1,
  13013. c.onLoadedObservable = new Observable,
  13014. c.onErrorObservable = new Observable,
  13015. c.onRebuildCallback = null,
  13016. c.width = 0,
  13017. c.height = 0,
  13018. c.depth = 0,
  13019. c.baseWidth = 0,
  13020. c.baseHeight = 0,
  13021. c.baseDepth = 0,
  13022. c.invertY = !1,
  13023. c._invertVScale = !1,
  13024. c._associatedChannel = -1,
  13025. c._source = InternalTextureSource.Unknown,
  13026. c._buffer = null,
  13027. c._bufferView = null,
  13028. c._bufferViewArray = null,
  13029. c._bufferViewArrayArray = null,
  13030. c._size = 0,
  13031. c._extension = "",
  13032. c._files = null,
  13033. c._workingCanvas = null,
  13034. c._workingContext = null,
  13035. c._cachedCoordinatesMode = null,
  13036. c._isDisabled = !1,
  13037. c._compression = null,
  13038. c._sphericalPolynomial = null,
  13039. c._sphericalPolynomialPromise = null,
  13040. c._sphericalPolynomialComputed = !1,
  13041. c._lodGenerationScale = 0,
  13042. c._lodGenerationOffset = 0,
  13043. c._useSRGBBuffer = !1,
  13044. c._lodTextureHigh = null,
  13045. c._lodTextureMid = null,
  13046. c._lodTextureLow = null,
  13047. c._isRGBD = !1,
  13048. c._linearSpecularLOD = !1,
  13049. c._irradianceTexture = null,
  13050. c._hardwareTexture = null,
  13051. c._references = 1,
  13052. c._gammaSpace = null,
  13053. c._engine = i,
  13054. c._source = o,
  13055. c._uniqueId = e._Counter++,
  13056. s || (c._hardwareTexture = i._createHardwareTexture()),
  13057. c
  13058. }
  13059. return Object.defineProperty(e.prototype, "useMipMaps", {
  13060. get: function() {
  13061. return this.generateMipMaps
  13062. },
  13063. set: function(i) {
  13064. this.generateMipMaps = i
  13065. },
  13066. enumerable: !1,
  13067. configurable: !0
  13068. }),
  13069. Object.defineProperty(e.prototype, "uniqueId", {
  13070. get: function() {
  13071. return this._uniqueId
  13072. },
  13073. enumerable: !1,
  13074. configurable: !0
  13075. }),
  13076. e.prototype.getEngine = function() {
  13077. return this._engine
  13078. }
  13079. ,
  13080. Object.defineProperty(e.prototype, "source", {
  13081. get: function() {
  13082. return this._source
  13083. },
  13084. enumerable: !1,
  13085. configurable: !0
  13086. }),
  13087. e.prototype.incrementReferences = function() {
  13088. this._references++
  13089. }
  13090. ,
  13091. e.prototype.updateSize = function(i, o, s) {
  13092. s === void 0 && (s = 1),
  13093. this._engine.updateTextureDimensions(this, i, o, s),
  13094. this.width = i,
  13095. this.height = o,
  13096. this.depth = s,
  13097. this.baseWidth = i,
  13098. this.baseHeight = o,
  13099. this.baseDepth = s,
  13100. this._size = i * o * s
  13101. }
  13102. ,
  13103. e.prototype._rebuild = function() {
  13104. var i = this, o;
  13105. if (this.isReady = !1,
  13106. this._cachedCoordinatesMode = null,
  13107. this._cachedWrapU = null,
  13108. this._cachedWrapV = null,
  13109. this._cachedWrapR = null,
  13110. this._cachedAnisotropicFilteringLevel = null,
  13111. this.onRebuildCallback) {
  13112. var s = this.onRebuildCallback(this)
  13113. , c = function(_) {
  13114. _._swapAndDie(i, !1),
  13115. i.isReady = s.isReady
  13116. };
  13117. s.isAsync ? s.proxy.then(c) : c(s.proxy);
  13118. return
  13119. }
  13120. var d;
  13121. switch (this.source) {
  13122. case InternalTextureSource.Temp:
  13123. break;
  13124. case InternalTextureSource.Url:
  13125. d = this._engine.createTexture((o = this._originalUrl) !== null && o !== void 0 ? o : this.url, !this.generateMipMaps, this.invertY, null, this.samplingMode, function() {
  13126. d._swapAndDie(i, !1),
  13127. i.isReady = !0
  13128. }, null, this._buffer, void 0, this.format, this._extension, void 0, void 0, void 0, this._useSRGBBuffer);
  13129. return;
  13130. case InternalTextureSource.Raw:
  13131. d = this._engine.createRawTexture(this._bufferView, this.baseWidth, this.baseHeight, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression, this.type),
  13132. d._swapAndDie(this, !1),
  13133. this.isReady = !0;
  13134. break;
  13135. case InternalTextureSource.Raw3D:
  13136. d = this._engine.createRawTexture3D(this._bufferView, this.baseWidth, this.baseHeight, this.baseDepth, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression, this.type),
  13137. d._swapAndDie(this, !1),
  13138. this.isReady = !0;
  13139. break;
  13140. case InternalTextureSource.Raw2DArray:
  13141. d = this._engine.createRawTexture2DArray(this._bufferView, this.baseWidth, this.baseHeight, this.baseDepth, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression, this.type),
  13142. d._swapAndDie(this, !1),
  13143. this.isReady = !0;
  13144. break;
  13145. case InternalTextureSource.Dynamic:
  13146. d = this._engine.createDynamicTexture(this.baseWidth, this.baseHeight, this.generateMipMaps, this.samplingMode),
  13147. d._swapAndDie(this, !1),
  13148. this._engine.updateDynamicTexture(this, this._engine.getRenderingCanvas(), this.invertY, void 0, void 0, !0);
  13149. break;
  13150. case InternalTextureSource.Cube:
  13151. d = this._engine.createCubeTexture(this.url, null, this._files, !this.generateMipMaps, function() {
  13152. d._swapAndDie(i, !1),
  13153. i.isReady = !0
  13154. }, null, this.format, this._extension, !1, 0, 0, null, void 0, this._useSRGBBuffer);
  13155. return;
  13156. case InternalTextureSource.CubeRaw:
  13157. d = this._engine.createRawCubeTexture(this._bufferViewArray, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression),
  13158. d._swapAndDie(this, !1),
  13159. this.isReady = !0;
  13160. break;
  13161. case InternalTextureSource.CubeRawRGBD:
  13162. return;
  13163. case InternalTextureSource.CubePrefiltered:
  13164. d = this._engine.createPrefilteredCubeTexture(this.url, null, this._lodGenerationScale, this._lodGenerationOffset, function(_) {
  13165. _ && _._swapAndDie(i, !1),
  13166. i.isReady = !0
  13167. }, null, this.format, this._extension),
  13168. d._sphericalPolynomial = this._sphericalPolynomial;
  13169. return
  13170. }
  13171. }
  13172. ,
  13173. e.prototype._swapAndDie = function(i, o) {
  13174. var s;
  13175. o === void 0 && (o = !0),
  13176. (s = this._hardwareTexture) === null || s === void 0 || s.setUsage(i._source, this.generateMipMaps, this.isCube, this.width, this.height),
  13177. i._hardwareTexture = this._hardwareTexture,
  13178. o && (i._isRGBD = this._isRGBD),
  13179. this._lodTextureHigh && (i._lodTextureHigh && i._lodTextureHigh.dispose(),
  13180. i._lodTextureHigh = this._lodTextureHigh),
  13181. this._lodTextureMid && (i._lodTextureMid && i._lodTextureMid.dispose(),
  13182. i._lodTextureMid = this._lodTextureMid),
  13183. this._lodTextureLow && (i._lodTextureLow && i._lodTextureLow.dispose(),
  13184. i._lodTextureLow = this._lodTextureLow),
  13185. this._irradianceTexture && (i._irradianceTexture && i._irradianceTexture.dispose(),
  13186. i._irradianceTexture = this._irradianceTexture);
  13187. var c = this._engine.getLoadedTexturesCache()
  13188. , d = c.indexOf(this);
  13189. d !== -1 && c.splice(d, 1);
  13190. var d = c.indexOf(i);
  13191. d === -1 && c.push(i)
  13192. }
  13193. ,
  13194. e.prototype.dispose = function() {
  13195. this._references--,
  13196. this.onLoadedObservable.clear(),
  13197. this.onErrorObservable.clear(),
  13198. this._references === 0 && (this._engine._releaseTexture(this),
  13199. this._hardwareTexture = null)
  13200. }
  13201. ,
  13202. e._Counter = 0,
  13203. e
  13204. }(TextureSampler)
  13205. , WebGLShaderProcessor = function() {
  13206. function a() {
  13207. this.shaderLanguage = ShaderLanguage.GLSL
  13208. }
  13209. return a.prototype.postProcessor = function(e, i, o, s, c) {
  13210. if (!c.getCaps().drawBuffersExtension) {
  13211. var d = /#extension.+GL_EXT_draw_buffers.+(enable|require)/g;
  13212. e = e.replace(d, "")
  13213. }
  13214. return e
  13215. }
  13216. ,
  13217. a
  13218. }()
  13219. , WebGL2ShaderProcessor = function() {
  13220. function a() {
  13221. this.shaderLanguage = ShaderLanguage.GLSL
  13222. }
  13223. return a.prototype.attributeProcessor = function(e) {
  13224. return e.replace("attribute", "in")
  13225. }
  13226. ,
  13227. a.prototype.varyingProcessor = function(e, i) {
  13228. return e.replace("varying", i ? "in" : "out")
  13229. }
  13230. ,
  13231. a.prototype.postProcessor = function(e, i, o, s, c) {
  13232. var d = e.search(/#extension.+GL_EXT_draw_buffers.+require/) !== -1
  13233. , _ = /#extension.+(GL_OVR_multiview2|GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g;
  13234. if (e = e.replace(_, ""),
  13235. e = e.replace(/texture2D\s*\(/g, "texture("),
  13236. o)
  13237. e = e.replace(/texture2DLodEXT\s*\(/g, "textureLod("),
  13238. e = e.replace(/textureCubeLodEXT\s*\(/g, "textureLod("),
  13239. e = e.replace(/textureCube\s*\(/g, "texture("),
  13240. e = e.replace(/gl_FragDepthEXT/g, "gl_FragDepth"),
  13241. e = e.replace(/gl_FragColor/g, "glFragColor"),
  13242. e = e.replace(/gl_FragData/g, "glFragData"),
  13243. e = e.replace(/void\s+?main\s*\(/g, (d ? "" : `out vec4 glFragColor;
  13244. `) + "void main(");
  13245. else {
  13246. var b = i.indexOf("#define MULTIVIEW") !== -1;
  13247. if (b)
  13248. return `#extension GL_OVR_multiview2 : require
  13249. layout (num_views = 2) in;
  13250. ` + e
  13251. }
  13252. return e
  13253. }
  13254. ,
  13255. a
  13256. }()
  13257. , DataBuffer = function() {
  13258. function a() {
  13259. this.references = 0,
  13260. this.capacity = 0,
  13261. this.is32Bits = !1,
  13262. this.uniqueId = a._Counter++
  13263. }
  13264. return Object.defineProperty(a.prototype, "underlyingResource", {
  13265. get: function() {
  13266. return null
  13267. },
  13268. enumerable: !1,
  13269. configurable: !0
  13270. }),
  13271. a._Counter = 0,
  13272. a
  13273. }()
  13274. , WebGLDataBuffer = function(a) {
  13275. __extends(e, a);
  13276. function e(i) {
  13277. var o = a.call(this) || this;
  13278. return o._buffer = i,
  13279. o
  13280. }
  13281. return Object.defineProperty(e.prototype, "underlyingResource", {
  13282. get: function() {
  13283. return this._buffer
  13284. },
  13285. enumerable: !1,
  13286. configurable: !0
  13287. }),
  13288. e
  13289. }(DataBuffer)
  13290. , WebGLPipelineContext = function() {
  13291. function a() {
  13292. this._valueCache = {},
  13293. this.vertexCompilationError = null,
  13294. this.fragmentCompilationError = null,
  13295. this.programLinkError = null,
  13296. this.programValidationError = null
  13297. }
  13298. return Object.defineProperty(a.prototype, "isAsync", {
  13299. get: function() {
  13300. return this.isParallelCompiled
  13301. },
  13302. enumerable: !1,
  13303. configurable: !0
  13304. }),
  13305. Object.defineProperty(a.prototype, "isReady", {
  13306. get: function() {
  13307. return this.program ? this.isParallelCompiled ? this.engine._isRenderingStateCompiled(this) : !0 : !1
  13308. },
  13309. enumerable: !1,
  13310. configurable: !0
  13311. }),
  13312. a.prototype._handlesSpectorRebuildCallback = function(e) {
  13313. e && this.program && e(this.program)
  13314. }
  13315. ,
  13316. a.prototype._fillEffectInformation = function(e, i, o, s, c, d, _, b) {
  13317. var k = this.engine;
  13318. if (k.supportsUniformBuffers)
  13319. for (var j in i)
  13320. e.bindUniformBlock(j, i[j]);
  13321. var $ = this.engine.getUniforms(this, o);
  13322. $.forEach(function(nt, ot) {
  13323. s[o[ot]] = nt
  13324. }),
  13325. this._uniforms = s;
  13326. var _e;
  13327. for (_e = 0; _e < c.length; _e++) {
  13328. var et = e.getUniform(c[_e]);
  13329. et == null && (c.splice(_e, 1),
  13330. _e--)
  13331. }
  13332. c.forEach(function(nt, ot) {
  13333. d[nt] = ot
  13334. });
  13335. for (var tt = 0, rt = k.getAttributes(this, _); tt < rt.length; tt++) {
  13336. var it = rt[tt];
  13337. b.push(it)
  13338. }
  13339. }
  13340. ,
  13341. a.prototype.dispose = function() {
  13342. this._uniforms = {}
  13343. }
  13344. ,
  13345. a.prototype._cacheMatrix = function(e, i) {
  13346. var o = this._valueCache[e]
  13347. , s = i.updateFlag;
  13348. return o !== void 0 && o === s ? !1 : (this._valueCache[e] = s,
  13349. !0)
  13350. }
  13351. ,
  13352. a.prototype._cacheFloat2 = function(e, i, o) {
  13353. var s = this._valueCache[e];
  13354. if (!s || s.length !== 2)
  13355. return s = [i, o],
  13356. this._valueCache[e] = s,
  13357. !0;
  13358. var c = !1;
  13359. return s[0] !== i && (s[0] = i,
  13360. c = !0),
  13361. s[1] !== o && (s[1] = o,
  13362. c = !0),
  13363. c
  13364. }
  13365. ,
  13366. a.prototype._cacheFloat3 = function(e, i, o, s) {
  13367. var c = this._valueCache[e];
  13368. if (!c || c.length !== 3)
  13369. return c = [i, o, s],
  13370. this._valueCache[e] = c,
  13371. !0;
  13372. var d = !1;
  13373. return c[0] !== i && (c[0] = i,
  13374. d = !0),
  13375. c[1] !== o && (c[1] = o,
  13376. d = !0),
  13377. c[2] !== s && (c[2] = s,
  13378. d = !0),
  13379. d
  13380. }
  13381. ,
  13382. a.prototype._cacheFloat4 = function(e, i, o, s, c) {
  13383. var d = this._valueCache[e];
  13384. if (!d || d.length !== 4)
  13385. return d = [i, o, s, c],
  13386. this._valueCache[e] = d,
  13387. !0;
  13388. var _ = !1;
  13389. return d[0] !== i && (d[0] = i,
  13390. _ = !0),
  13391. d[1] !== o && (d[1] = o,
  13392. _ = !0),
  13393. d[2] !== s && (d[2] = s,
  13394. _ = !0),
  13395. d[3] !== c && (d[3] = c,
  13396. _ = !0),
  13397. _
  13398. }
  13399. ,
  13400. a.prototype.setInt = function(e, i) {
  13401. var o = this._valueCache[e];
  13402. o !== void 0 && o === i || this.engine.setInt(this._uniforms[e], i) && (this._valueCache[e] = i)
  13403. }
  13404. ,
  13405. a.prototype.setInt2 = function(e, i, o) {
  13406. this._cacheFloat2(e, i, o) && (this.engine.setInt2(this._uniforms[e], i, o) || (this._valueCache[e] = null))
  13407. }
  13408. ,
  13409. a.prototype.setInt3 = function(e, i, o, s) {
  13410. this._cacheFloat3(e, i, o, s) && (this.engine.setInt3(this._uniforms[e], i, o, s) || (this._valueCache[e] = null))
  13411. }
  13412. ,
  13413. a.prototype.setInt4 = function(e, i, o, s, c) {
  13414. this._cacheFloat4(e, i, o, s, c) && (this.engine.setInt4(this._uniforms[e], i, o, s, c) || (this._valueCache[e] = null))
  13415. }
  13416. ,
  13417. a.prototype.setIntArray = function(e, i) {
  13418. this._valueCache[e] = null,
  13419. this.engine.setIntArray(this._uniforms[e], i)
  13420. }
  13421. ,
  13422. a.prototype.setIntArray2 = function(e, i) {
  13423. this._valueCache[e] = null,
  13424. this.engine.setIntArray2(this._uniforms[e], i)
  13425. }
  13426. ,
  13427. a.prototype.setIntArray3 = function(e, i) {
  13428. this._valueCache[e] = null,
  13429. this.engine.setIntArray3(this._uniforms[e], i)
  13430. }
  13431. ,
  13432. a.prototype.setIntArray4 = function(e, i) {
  13433. this._valueCache[e] = null,
  13434. this.engine.setIntArray4(this._uniforms[e], i)
  13435. }
  13436. ,
  13437. a.prototype.setArray = function(e, i) {
  13438. this._valueCache[e] = null,
  13439. this.engine.setArray(this._uniforms[e], i)
  13440. }
  13441. ,
  13442. a.prototype.setArray2 = function(e, i) {
  13443. this._valueCache[e] = null,
  13444. this.engine.setArray2(this._uniforms[e], i)
  13445. }
  13446. ,
  13447. a.prototype.setArray3 = function(e, i) {
  13448. this._valueCache[e] = null,
  13449. this.engine.setArray3(this._uniforms[e], i)
  13450. }
  13451. ,
  13452. a.prototype.setArray4 = function(e, i) {
  13453. this._valueCache[e] = null,
  13454. this.engine.setArray4(this._uniforms[e], i)
  13455. }
  13456. ,
  13457. a.prototype.setMatrices = function(e, i) {
  13458. !i || (this._valueCache[e] = null,
  13459. this.engine.setMatrices(this._uniforms[e], i))
  13460. }
  13461. ,
  13462. a.prototype.setMatrix = function(e, i) {
  13463. this._cacheMatrix(e, i) && (this.engine.setMatrices(this._uniforms[e], i.toArray()) || (this._valueCache[e] = null))
  13464. }
  13465. ,
  13466. a.prototype.setMatrix3x3 = function(e, i) {
  13467. this._valueCache[e] = null,
  13468. this.engine.setMatrix3x3(this._uniforms[e], i)
  13469. }
  13470. ,
  13471. a.prototype.setMatrix2x2 = function(e, i) {
  13472. this._valueCache[e] = null,
  13473. this.engine.setMatrix2x2(this._uniforms[e], i)
  13474. }
  13475. ,
  13476. a.prototype.setFloat = function(e, i) {
  13477. var o = this._valueCache[e];
  13478. o !== void 0 && o === i || this.engine.setFloat(this._uniforms[e], i) && (this._valueCache[e] = i)
  13479. }
  13480. ,
  13481. a.prototype.setVector2 = function(e, i) {
  13482. this._cacheFloat2(e, i.x, i.y) && (this.engine.setFloat2(this._uniforms[e], i.x, i.y) || (this._valueCache[e] = null))
  13483. }
  13484. ,
  13485. a.prototype.setFloat2 = function(e, i, o) {
  13486. this._cacheFloat2(e, i, o) && (this.engine.setFloat2(this._uniforms[e], i, o) || (this._valueCache[e] = null))
  13487. }
  13488. ,
  13489. a.prototype.setVector3 = function(e, i) {
  13490. this._cacheFloat3(e, i.x, i.y, i.z) && (this.engine.setFloat3(this._uniforms[e], i.x, i.y, i.z) || (this._valueCache[e] = null))
  13491. }
  13492. ,
  13493. a.prototype.setFloat3 = function(e, i, o, s) {
  13494. this._cacheFloat3(e, i, o, s) && (this.engine.setFloat3(this._uniforms[e], i, o, s) || (this._valueCache[e] = null))
  13495. }
  13496. ,
  13497. a.prototype.setVector4 = function(e, i) {
  13498. this._cacheFloat4(e, i.x, i.y, i.z, i.w) && (this.engine.setFloat4(this._uniforms[e], i.x, i.y, i.z, i.w) || (this._valueCache[e] = null))
  13499. }
  13500. ,
  13501. a.prototype.setFloat4 = function(e, i, o, s, c) {
  13502. this._cacheFloat4(e, i, o, s, c) && (this.engine.setFloat4(this._uniforms[e], i, o, s, c) || (this._valueCache[e] = null))
  13503. }
  13504. ,
  13505. a.prototype.setColor3 = function(e, i) {
  13506. this._cacheFloat3(e, i.r, i.g, i.b) && (this.engine.setFloat3(this._uniforms[e], i.r, i.g, i.b) || (this._valueCache[e] = null))
  13507. }
  13508. ,
  13509. a.prototype.setColor4 = function(e, i, o) {
  13510. this._cacheFloat4(e, i.r, i.g, i.b, o) && (this.engine.setFloat4(this._uniforms[e], i.r, i.g, i.b, o) || (this._valueCache[e] = null))
  13511. }
  13512. ,
  13513. a.prototype.setDirectColor4 = function(e, i) {
  13514. this._cacheFloat4(e, i.r, i.g, i.b, i.a) && (this.engine.setFloat4(this._uniforms[e], i.r, i.g, i.b, i.a) || (this._valueCache[e] = null))
  13515. }
  13516. ,
  13517. a.prototype._getVertexShaderCode = function() {
  13518. return this.vertexShader ? this.engine._getShaderSource(this.vertexShader) : null
  13519. }
  13520. ,
  13521. a.prototype._getFragmentShaderCode = function() {
  13522. return this.fragmentShader ? this.engine._getShaderSource(this.fragmentShader) : null
  13523. }
  13524. ,
  13525. a
  13526. }()
  13527. , PerformanceConfigurator = function() {
  13528. function a() {}
  13529. return a.SetMatrixPrecision = function(e) {
  13530. if (a.MatrixTrackPrecisionChange = !1,
  13531. e && !a.MatrixUse64Bits && a.MatrixTrackedMatrices)
  13532. for (var i = 0; i < a.MatrixTrackedMatrices.length; ++i) {
  13533. var o = a.MatrixTrackedMatrices[i]
  13534. , s = o._m;
  13535. o._m = new Array(16);
  13536. for (var c = 0; c < 16; ++c)
  13537. o._m[c] = s[c]
  13538. }
  13539. a.MatrixUse64Bits = e,
  13540. a.MatrixCurrentType = a.MatrixUse64Bits ? Array : Float32Array,
  13541. a.MatrixTrackedMatrices = null
  13542. }
  13543. ,
  13544. a.MatrixUse64Bits = !1,
  13545. a.MatrixTrackPrecisionChange = !0,
  13546. a.MatrixCurrentType = Float32Array,
  13547. a.MatrixTrackedMatrices = [],
  13548. a
  13549. }()
  13550. , WebGLHardwareTexture = function() {
  13551. function a(e, i) {
  13552. if (e === void 0 && (e = null),
  13553. this._MSAARenderBuffer = null,
  13554. this._context = i,
  13555. !e && (e = i.createTexture(),
  13556. !e))
  13557. throw new Error("Unable to create webGL texture");
  13558. this.set(e)
  13559. }
  13560. return Object.defineProperty(a.prototype, "underlyingResource", {
  13561. get: function() {
  13562. return this._webGLTexture
  13563. },
  13564. enumerable: !1,
  13565. configurable: !0
  13566. }),
  13567. a.prototype.setUsage = function(e, i, o, s, c) {}
  13568. ,
  13569. a.prototype.set = function(e) {
  13570. this._webGLTexture = e
  13571. }
  13572. ,
  13573. a.prototype.reset = function() {
  13574. this._webGLTexture = null,
  13575. this._MSAARenderBuffer = null
  13576. }
  13577. ,
  13578. a.prototype.release = function() {
  13579. this._MSAARenderBuffer && (this._context.deleteRenderbuffer(this._MSAARenderBuffer),
  13580. this._MSAARenderBuffer = null),
  13581. this._webGLTexture && this._context.deleteTexture(this._webGLTexture),
  13582. this.reset()
  13583. }
  13584. ,
  13585. a
  13586. }()
  13587. , DrawWrapper = function() {
  13588. function a(e, i) {
  13589. i === void 0 && (i = !0),
  13590. this.effect = null,
  13591. this.defines = null,
  13592. this.drawContext = e.createDrawContext(),
  13593. i && (this.materialContext = e.createMaterialContext())
  13594. }
  13595. return a.IsWrapper = function(e) {
  13596. return e.getPipelineContext === void 0
  13597. }
  13598. ,
  13599. a.GetEffect = function(e) {
  13600. return e.getPipelineContext === void 0 ? e.effect : e
  13601. }
  13602. ,
  13603. a.prototype.setEffect = function(e, i, o) {
  13604. var s;
  13605. o === void 0 && (o = !0),
  13606. this.effect = e,
  13607. i !== void 0 && (this.defines = i),
  13608. o && ((s = this.drawContext) === null || s === void 0 || s.reset())
  13609. }
  13610. ,
  13611. a.prototype.dispose = function() {
  13612. var e;
  13613. (e = this.drawContext) === null || e === void 0 || e.dispose()
  13614. }
  13615. ,
  13616. a
  13617. }()
  13618. , StencilStateComposer = function() {
  13619. function a(e) {
  13620. e === void 0 && (e = !0),
  13621. this._isStencilTestDirty = !1,
  13622. this._isStencilMaskDirty = !1,
  13623. this._isStencilFuncDirty = !1,
  13624. this._isStencilOpDirty = !1,
  13625. this.useStencilGlobalOnly = !1,
  13626. e && this.reset()
  13627. }
  13628. return Object.defineProperty(a.prototype, "isDirty", {
  13629. get: function() {
  13630. return this._isStencilTestDirty || this._isStencilMaskDirty || this._isStencilFuncDirty || this._isStencilOpDirty
  13631. },
  13632. enumerable: !1,
  13633. configurable: !0
  13634. }),
  13635. Object.defineProperty(a.prototype, "func", {
  13636. get: function() {
  13637. return this._func
  13638. },
  13639. set: function(e) {
  13640. this._func !== e && (this._func = e,
  13641. this._isStencilFuncDirty = !0)
  13642. },
  13643. enumerable: !1,
  13644. configurable: !0
  13645. }),
  13646. Object.defineProperty(a.prototype, "funcRef", {
  13647. get: function() {
  13648. return this._funcRef
  13649. },
  13650. set: function(e) {
  13651. this._funcRef !== e && (this._funcRef = e,
  13652. this._isStencilFuncDirty = !0)
  13653. },
  13654. enumerable: !1,
  13655. configurable: !0
  13656. }),
  13657. Object.defineProperty(a.prototype, "funcMask", {
  13658. get: function() {
  13659. return this._funcMask
  13660. },
  13661. set: function(e) {
  13662. this._funcMask !== e && (this._funcMask = e,
  13663. this._isStencilFuncDirty = !0)
  13664. },
  13665. enumerable: !1,
  13666. configurable: !0
  13667. }),
  13668. Object.defineProperty(a.prototype, "opStencilFail", {
  13669. get: function() {
  13670. return this._opStencilFail
  13671. },
  13672. set: function(e) {
  13673. this._opStencilFail !== e && (this._opStencilFail = e,
  13674. this._isStencilOpDirty = !0)
  13675. },
  13676. enumerable: !1,
  13677. configurable: !0
  13678. }),
  13679. Object.defineProperty(a.prototype, "opDepthFail", {
  13680. get: function() {
  13681. return this._opDepthFail
  13682. },
  13683. set: function(e) {
  13684. this._opDepthFail !== e && (this._opDepthFail = e,
  13685. this._isStencilOpDirty = !0)
  13686. },
  13687. enumerable: !1,
  13688. configurable: !0
  13689. }),
  13690. Object.defineProperty(a.prototype, "opStencilDepthPass", {
  13691. get: function() {
  13692. return this._opStencilDepthPass
  13693. },
  13694. set: function(e) {
  13695. this._opStencilDepthPass !== e && (this._opStencilDepthPass = e,
  13696. this._isStencilOpDirty = !0)
  13697. },
  13698. enumerable: !1,
  13699. configurable: !0
  13700. }),
  13701. Object.defineProperty(a.prototype, "mask", {
  13702. get: function() {
  13703. return this._mask
  13704. },
  13705. set: function(e) {
  13706. this._mask !== e && (this._mask = e,
  13707. this._isStencilMaskDirty = !0)
  13708. },
  13709. enumerable: !1,
  13710. configurable: !0
  13711. }),
  13712. Object.defineProperty(a.prototype, "enabled", {
  13713. get: function() {
  13714. return this._enabled
  13715. },
  13716. set: function(e) {
  13717. this._enabled !== e && (this._enabled = e,
  13718. this._isStencilTestDirty = !0)
  13719. },
  13720. enumerable: !1,
  13721. configurable: !0
  13722. }),
  13723. a.prototype.reset = function() {
  13724. var e;
  13725. this.stencilMaterial = void 0,
  13726. (e = this.stencilGlobal) === null || e === void 0 || e.reset(),
  13727. this._isStencilTestDirty = !0,
  13728. this._isStencilMaskDirty = !0,
  13729. this._isStencilFuncDirty = !0,
  13730. this._isStencilOpDirty = !0
  13731. }
  13732. ,
  13733. a.prototype.apply = function(e) {
  13734. var i;
  13735. if (!!e) {
  13736. var o = !this.useStencilGlobalOnly && !!(!((i = this.stencilMaterial) === null || i === void 0) && i.enabled);
  13737. this.enabled = o ? this.stencilMaterial.enabled : this.stencilGlobal.enabled,
  13738. this.func = o ? this.stencilMaterial.func : this.stencilGlobal.func,
  13739. this.funcRef = o ? this.stencilMaterial.funcRef : this.stencilGlobal.funcRef,
  13740. this.funcMask = o ? this.stencilMaterial.funcMask : this.stencilGlobal.funcMask,
  13741. this.opStencilFail = o ? this.stencilMaterial.opStencilFail : this.stencilGlobal.opStencilFail,
  13742. this.opDepthFail = o ? this.stencilMaterial.opDepthFail : this.stencilGlobal.opDepthFail,
  13743. this.opStencilDepthPass = o ? this.stencilMaterial.opStencilDepthPass : this.stencilGlobal.opStencilDepthPass,
  13744. this.mask = o ? this.stencilMaterial.mask : this.stencilGlobal.mask,
  13745. this.isDirty && (this._isStencilTestDirty && (this.enabled ? e.enable(e.STENCIL_TEST) : e.disable(e.STENCIL_TEST),
  13746. this._isStencilTestDirty = !1),
  13747. this._isStencilMaskDirty && (e.stencilMask(this.mask),
  13748. this._isStencilMaskDirty = !1),
  13749. this._isStencilFuncDirty && (e.stencilFunc(this.func, this.funcRef, this.funcMask),
  13750. this._isStencilFuncDirty = !1),
  13751. this._isStencilOpDirty && (e.stencilOp(this.opStencilFail, this.opDepthFail, this.opStencilDepthPass),
  13752. this._isStencilOpDirty = !1))
  13753. }
  13754. }
  13755. ,
  13756. a
  13757. }()
  13758. , BufferPointer = function() {
  13759. function a() {}
  13760. return a
  13761. }()
  13762. , ThinEngine = function() {
  13763. function a(e, i, o, s) {
  13764. var c = this;
  13765. this.forcePOTTextures = !1,
  13766. this.isFullscreen = !1,
  13767. this.cullBackFaces = null,
  13768. this.renderEvenInBackground = !0,
  13769. this.preventCacheWipeBetweenFrames = !1,
  13770. this.validateShaderPrograms = !1,
  13771. this._useReverseDepthBuffer = !1,
  13772. this.isNDCHalfZRange = !1,
  13773. this.hasOriginBottomLeft = !0,
  13774. this.disableUniformBuffers = !1,
  13775. this.onDisposeObservable = new Observable,
  13776. this._frameId = 0,
  13777. this._uniformBuffers = new Array,
  13778. this._storageBuffers = new Array,
  13779. this._webGLVersion = 1,
  13780. this._windowIsBackground = !1,
  13781. this._highPrecisionShadersAllowed = !0,
  13782. this._badOS = !1,
  13783. this._badDesktopOS = !1,
  13784. this._renderingQueueLaunched = !1,
  13785. this._activeRenderLoops = new Array,
  13786. this.onContextLostObservable = new Observable,
  13787. this.onContextRestoredObservable = new Observable,
  13788. this._contextWasLost = !1,
  13789. this._doNotHandleContextLost = !1,
  13790. this.disableVertexArrayObjects = !1,
  13791. this._colorWrite = !0,
  13792. this._colorWriteChanged = !0,
  13793. this._depthCullingState = new DepthCullingState,
  13794. this._stencilStateComposer = new StencilStateComposer,
  13795. this._stencilState = new StencilState,
  13796. this._alphaState = new AlphaState,
  13797. this._alphaMode = 1,
  13798. this._alphaEquation = 0,
  13799. this._internalTexturesCache = new Array,
  13800. this._renderTargetWrapperCache = new Array,
  13801. this._activeChannel = 0,
  13802. this._currentTextureChannel = -1,
  13803. this._boundTexturesCache = {},
  13804. this._compiledEffects = {},
  13805. this._vertexAttribArraysEnabled = [],
  13806. this._uintIndicesCurrentlySet = !1,
  13807. this._currentBoundBuffer = new Array,
  13808. this._currentFramebuffer = null,
  13809. this._dummyFramebuffer = null,
  13810. this._currentBufferPointers = new Array,
  13811. this._currentInstanceLocations = new Array,
  13812. this._currentInstanceBuffers = new Array,
  13813. this._vaoRecordInProgress = !1,
  13814. this._mustWipeVertexAttributes = !1,
  13815. this._nextFreeTextureSlots = new Array,
  13816. this._maxSimultaneousTextures = 0,
  13817. this._activeRequests = new Array,
  13818. this._transformTextureUrl = null,
  13819. this.hostInformation = {
  13820. isMobile: !1
  13821. },
  13822. this.premultipliedAlpha = !0,
  13823. this.onBeforeTextureInitObservable = new Observable,
  13824. this._isWebGPU = !1,
  13825. this._snapshotRenderingMode = 0,
  13826. this._viewportCached = {
  13827. x: 0,
  13828. y: 0,
  13829. z: 0,
  13830. w: 0
  13831. },
  13832. this._unpackFlipYCached = null,
  13833. this.enableUnpackFlipYCached = !0,
  13834. this._boundUniforms = {};
  13835. var d = null;
  13836. if (o = o || {},
  13837. this._stencilStateComposer.stencilGlobal = this._stencilState,
  13838. PerformanceConfigurator.SetMatrixPrecision(!!o.useHighPrecisionMatrix),
  13839. !!e) {
  13840. if (s = s || o.adaptToDeviceRatio || !1,
  13841. e.getContext) {
  13842. if (d = e,
  13843. this._renderingCanvas = d,
  13844. i !== void 0 && (o.antialias = i),
  13845. o.deterministicLockstep === void 0 && (o.deterministicLockstep = !1),
  13846. o.lockstepMaxSteps === void 0 && (o.lockstepMaxSteps = 4),
  13847. o.timeStep === void 0 && (o.timeStep = 1 / 60),
  13848. o.preserveDrawingBuffer === void 0 && (o.preserveDrawingBuffer = !1),
  13849. o.audioEngine === void 0 && (o.audioEngine = !0),
  13850. o.audioEngineOptions !== void 0 && o.audioEngineOptions.audioContext !== void 0 && (this._audioContext = o.audioEngineOptions.audioContext),
  13851. o.audioEngineOptions !== void 0 && o.audioEngineOptions.audioDestination !== void 0 && (this._audioDestination = o.audioEngineOptions.audioDestination),
  13852. o.stencil === void 0 && (o.stencil = !0),
  13853. o.premultipliedAlpha === !1 && (this.premultipliedAlpha = !1),
  13854. o.xrCompatible === void 0 && (o.xrCompatible = !0),
  13855. this._doNotHandleContextLost = !!o.doNotHandleContextLost,
  13856. navigator && navigator.userAgent) {
  13857. this._checkForMobile = function() {
  13858. var dt = navigator.userAgent;
  13859. c.hostInformation.isMobile = dt.indexOf("Mobile") !== -1 || dt.indexOf("Mac") !== -1 && IsDocumentAvailable() && "ontouchend"in document
  13860. }
  13861. ,
  13862. this._checkForMobile(),
  13863. IsWindowObjectExist() && window.addEventListener("resize", this._checkForMobile);
  13864. for (var _ = navigator.userAgent, b = 0, k = a.ExceptionList; b < k.length; b++) {
  13865. var j = k[b]
  13866. , $ = j.key
  13867. , _e = j.targets
  13868. , et = new RegExp($);
  13869. if (et.test(_)) {
  13870. if (j.capture && j.captureConstraint) {
  13871. var tt = j.capture
  13872. , rt = j.captureConstraint
  13873. , it = new RegExp(tt)
  13874. , nt = it.exec(_);
  13875. if (nt && nt.length > 0) {
  13876. var ot = parseInt(nt[nt.length - 1]);
  13877. if (ot >= rt)
  13878. continue
  13879. }
  13880. }
  13881. for (var at = 0, st = _e; at < st.length; at++) {
  13882. var ut = st[at];
  13883. switch (ut) {
  13884. case "uniformBuffer":
  13885. this.disableUniformBuffers = !0;
  13886. break;
  13887. case "vao":
  13888. this.disableVertexArrayObjects = !0;
  13889. break
  13890. }
  13891. }
  13892. }
  13893. }
  13894. }
  13895. if (this._doNotHandleContextLost || (this._onContextLost = function(dt) {
  13896. dt.preventDefault(),
  13897. c._contextWasLost = !0,
  13898. Logger$2.Warn("WebGL context lost."),
  13899. c.onContextLostObservable.notifyObservers(c)
  13900. }
  13901. ,
  13902. this._onContextRestored = function() {
  13903. c._restoreEngineAfterContextLost(c._initGLContext.bind(c))
  13904. }
  13905. ,
  13906. d.addEventListener("webglcontextlost", this._onContextLost, !1),
  13907. d.addEventListener("webglcontextrestored", this._onContextRestored, !1),
  13908. o.powerPreference = "high-performance"),
  13909. this._badDesktopOS = /^((?!chrome|android).)*safari/i.test(navigator.userAgent),
  13910. this._badDesktopOS && (o.xrCompatible = !1),
  13911. !o.disableWebGL2Support)
  13912. try {
  13913. this._gl = d.getContext("webgl2", o) || d.getContext("experimental-webgl2", o),
  13914. this._gl && (this._webGLVersion = 2,
  13915. this._shaderPlatformName = "WEBGL2",
  13916. this._gl.deleteQuery || (this._webGLVersion = 1,
  13917. this._shaderPlatformName = "WEBGL1"))
  13918. } catch {}
  13919. if (!this._gl) {
  13920. if (!d)
  13921. throw new Error("The provided canvas is null or undefined.");
  13922. try {
  13923. this._gl = d.getContext("webgl", o) || d.getContext("experimental-webgl", o)
  13924. } catch {
  13925. throw new Error("WebGL not supported")
  13926. }
  13927. }
  13928. if (!this._gl)
  13929. throw new Error("WebGL not supported")
  13930. } else {
  13931. this._gl = e,
  13932. this._renderingCanvas = this._gl.canvas,
  13933. this._gl.renderbufferStorageMultisample ? (this._webGLVersion = 2,
  13934. this._shaderPlatformName = "WEBGL2") : this._shaderPlatformName = "WEBGL1";
  13935. var ct = this._gl.getContextAttributes();
  13936. ct && (o.stencil = ct.stencil)
  13937. }
  13938. this._gl.pixelStorei(this._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, this._gl.NONE),
  13939. o.useHighPrecisionFloats !== void 0 && (this._highPrecisionShadersAllowed = o.useHighPrecisionFloats);
  13940. var lt = IsWindowObjectExist() && window.devicePixelRatio || 1
  13941. , ft = o.limitDeviceRatio || lt;
  13942. this._hardwareScalingLevel = s ? 1 / Math.min(ft, lt) : 1,
  13943. this.resize(),
  13944. this._isStencilEnable = !!o.stencil,
  13945. this._initGLContext(),
  13946. this._initFeatures();
  13947. for (var ht = 0; ht < this._caps.maxVertexAttribs; ht++)
  13948. this._currentBufferPointers[ht] = new BufferPointer;
  13949. this._shaderProcessor = this.webGLVersion > 1 ? new WebGL2ShaderProcessor : new WebGLShaderProcessor,
  13950. this._badOS = /iPad/i.test(navigator.userAgent) || /iPhone/i.test(navigator.userAgent),
  13951. this._creationOptions = o;
  13952. var pt = "Babylon.js v" + a.Version;
  13953. console.log(pt + (" - " + this.description)),
  13954. this._renderingCanvas && this._renderingCanvas.setAttribute && this._renderingCanvas.setAttribute("data-engine", pt)
  13955. }
  13956. }
  13957. return Object.defineProperty(a, "NpmPackage", {
  13958. get: function() {
  13959. return "babylonjs@5.0.0-alpha.63"
  13960. },
  13961. enumerable: !1,
  13962. configurable: !0
  13963. }),
  13964. Object.defineProperty(a, "Version", {
  13965. get: function() {
  13966. return "5.0.0-alpha.63"
  13967. },
  13968. enumerable: !1,
  13969. configurable: !0
  13970. }),
  13971. Object.defineProperty(a.prototype, "description", {
  13972. get: function() {
  13973. var e = this.name + this.webGLVersion;
  13974. return this._caps.parallelShaderCompile && (e += " - Parallel shader compilation"),
  13975. e
  13976. },
  13977. enumerable: !1,
  13978. configurable: !0
  13979. }),
  13980. Object.defineProperty(a.prototype, "name", {
  13981. get: function() {
  13982. return "WebGL"
  13983. },
  13984. enumerable: !1,
  13985. configurable: !0
  13986. }),
  13987. Object.defineProperty(a.prototype, "version", {
  13988. get: function() {
  13989. return this._webGLVersion
  13990. },
  13991. enumerable: !1,
  13992. configurable: !0
  13993. }),
  13994. Object.defineProperty(a, "ShadersRepository", {
  13995. get: function() {
  13996. return Effect.ShadersRepository
  13997. },
  13998. set: function(e) {
  13999. Effect.ShadersRepository = e
  14000. },
  14001. enumerable: !1,
  14002. configurable: !0
  14003. }),
  14004. a.prototype._getShaderProcessor = function(e) {
  14005. return this._shaderProcessor
  14006. }
  14007. ,
  14008. Object.defineProperty(a.prototype, "useReverseDepthBuffer", {
  14009. get: function() {
  14010. return this._useReverseDepthBuffer
  14011. },
  14012. set: function(e) {
  14013. e !== this._useReverseDepthBuffer && (this._useReverseDepthBuffer = e,
  14014. e ? this._depthCullingState.depthFunc = 518 : this._depthCullingState.depthFunc = 515)
  14015. },
  14016. enumerable: !1,
  14017. configurable: !0
  14018. }),
  14019. Object.defineProperty(a.prototype, "frameId", {
  14020. get: function() {
  14021. return this._frameId
  14022. },
  14023. enumerable: !1,
  14024. configurable: !0
  14025. }),
  14026. Object.defineProperty(a.prototype, "supportsUniformBuffers", {
  14027. get: function() {
  14028. return this.webGLVersion > 1 && !this.disableUniformBuffers
  14029. },
  14030. enumerable: !1,
  14031. configurable: !0
  14032. }),
  14033. Object.defineProperty(a.prototype, "_shouldUseHighPrecisionShader", {
  14034. get: function() {
  14035. return !!(this._caps.highPrecisionShaderSupported && this._highPrecisionShadersAllowed)
  14036. },
  14037. enumerable: !1,
  14038. configurable: !0
  14039. }),
  14040. Object.defineProperty(a.prototype, "needPOTTextures", {
  14041. get: function() {
  14042. return this._webGLVersion < 2 || this.forcePOTTextures
  14043. },
  14044. enumerable: !1,
  14045. configurable: !0
  14046. }),
  14047. Object.defineProperty(a.prototype, "activeRenderLoops", {
  14048. get: function() {
  14049. return this._activeRenderLoops
  14050. },
  14051. enumerable: !1,
  14052. configurable: !0
  14053. }),
  14054. Object.defineProperty(a.prototype, "doNotHandleContextLost", {
  14055. get: function() {
  14056. return this._doNotHandleContextLost
  14057. },
  14058. set: function(e) {
  14059. this._doNotHandleContextLost = e
  14060. },
  14061. enumerable: !1,
  14062. configurable: !0
  14063. }),
  14064. Object.defineProperty(a.prototype, "_supportsHardwareTextureRescaling", {
  14065. get: function() {
  14066. return !1
  14067. },
  14068. enumerable: !1,
  14069. configurable: !0
  14070. }),
  14071. Object.defineProperty(a.prototype, "framebufferDimensionsObject", {
  14072. set: function(e) {
  14073. this._framebufferDimensionsObject = e
  14074. },
  14075. enumerable: !1,
  14076. configurable: !0
  14077. }),
  14078. Object.defineProperty(a.prototype, "currentViewport", {
  14079. get: function() {
  14080. return this._cachedViewport
  14081. },
  14082. enumerable: !1,
  14083. configurable: !0
  14084. }),
  14085. Object.defineProperty(a.prototype, "emptyTexture", {
  14086. get: function() {
  14087. return this._emptyTexture || (this._emptyTexture = this.createRawTexture(new Uint8Array(4), 1, 1, 5, !1, !1, 1)),
  14088. this._emptyTexture
  14089. },
  14090. enumerable: !1,
  14091. configurable: !0
  14092. }),
  14093. Object.defineProperty(a.prototype, "emptyTexture3D", {
  14094. get: function() {
  14095. return this._emptyTexture3D || (this._emptyTexture3D = this.createRawTexture3D(new Uint8Array(4), 1, 1, 1, 5, !1, !1, 1)),
  14096. this._emptyTexture3D
  14097. },
  14098. enumerable: !1,
  14099. configurable: !0
  14100. }),
  14101. Object.defineProperty(a.prototype, "emptyTexture2DArray", {
  14102. get: function() {
  14103. return this._emptyTexture2DArray || (this._emptyTexture2DArray = this.createRawTexture2DArray(new Uint8Array(4), 1, 1, 1, 5, !1, !1, 1)),
  14104. this._emptyTexture2DArray
  14105. },
  14106. enumerable: !1,
  14107. configurable: !0
  14108. }),
  14109. Object.defineProperty(a.prototype, "emptyCubeTexture", {
  14110. get: function() {
  14111. if (!this._emptyCubeTexture) {
  14112. var e = new Uint8Array(4)
  14113. , i = [e, e, e, e, e, e];
  14114. this._emptyCubeTexture = this.createRawCubeTexture(i, 1, 5, 0, !1, !1, 1)
  14115. }
  14116. return this._emptyCubeTexture
  14117. },
  14118. enumerable: !1,
  14119. configurable: !0
  14120. }),
  14121. Object.defineProperty(a.prototype, "isWebGPU", {
  14122. get: function() {
  14123. return this._isWebGPU
  14124. },
  14125. enumerable: !1,
  14126. configurable: !0
  14127. }),
  14128. Object.defineProperty(a.prototype, "shaderPlatformName", {
  14129. get: function() {
  14130. return this._shaderPlatformName
  14131. },
  14132. enumerable: !1,
  14133. configurable: !0
  14134. }),
  14135. Object.defineProperty(a.prototype, "snapshotRendering", {
  14136. get: function() {
  14137. return !1
  14138. },
  14139. set: function(e) {},
  14140. enumerable: !1,
  14141. configurable: !0
  14142. }),
  14143. Object.defineProperty(a.prototype, "snapshotRenderingMode", {
  14144. get: function() {
  14145. return this._snapshotRenderingMode
  14146. },
  14147. set: function(e) {
  14148. this._snapshotRenderingMode = e
  14149. },
  14150. enumerable: !1,
  14151. configurable: !0
  14152. }),
  14153. a.prototype.snapshotRenderingReset = function() {
  14154. this.snapshotRendering = !1
  14155. }
  14156. ,
  14157. a._createCanvas = function(e, i) {
  14158. if (typeof document == "undefined")
  14159. return new OffscreenCanvas(e,i);
  14160. var o = document.createElement("canvas");
  14161. return o.width = e,
  14162. o.height = i,
  14163. o
  14164. }
  14165. ,
  14166. a.prototype.createCanvas = function(e, i) {
  14167. return a._createCanvas(e, i)
  14168. }
  14169. ,
  14170. a.prototype.createCanvasImage = function() {
  14171. return document.createElement("img")
  14172. }
  14173. ,
  14174. a.prototype._restoreEngineAfterContextLost = function(e) {
  14175. var i = this;
  14176. setTimeout(function() {
  14177. return __awaiter(i, void 0, void 0, function() {
  14178. var o, s, c, d, _;
  14179. return __generator(this, function(b) {
  14180. switch (b.label) {
  14181. case 0:
  14182. return this._dummyFramebuffer = null,
  14183. o = this._depthCullingState.depthTest,
  14184. s = this._depthCullingState.depthFunc,
  14185. c = this._depthCullingState.depthMask,
  14186. d = this._stencilState.stencilTest,
  14187. [4, e()];
  14188. case 1:
  14189. return b.sent(),
  14190. this._rebuildEffects(),
  14191. (_ = this._rebuildComputeEffects) === null || _ === void 0 || _.call(this),
  14192. this._rebuildInternalTextures(),
  14193. this._rebuildRenderTargetWrappers(),
  14194. this._rebuildBuffers(),
  14195. this.wipeCaches(!0),
  14196. this._depthCullingState.depthTest = o,
  14197. this._depthCullingState.depthFunc = s,
  14198. this._depthCullingState.depthMask = c,
  14199. this._stencilState.stencilTest = d,
  14200. Logger$2.Warn(this.name + " context successfully restored."),
  14201. this.onContextRestoredObservable.notifyObservers(this),
  14202. this._contextWasLost = !1,
  14203. [2]
  14204. }
  14205. })
  14206. })
  14207. }, 0)
  14208. }
  14209. ,
  14210. a.prototype._sharedInit = function(e, i, o) {
  14211. this._renderingCanvas = e
  14212. }
  14213. ,
  14214. a.prototype._getShaderProcessingContext = function(e) {
  14215. return null
  14216. }
  14217. ,
  14218. a.prototype._rebuildInternalTextures = function() {
  14219. for (var e = this._internalTexturesCache.slice(), i = 0, o = e; i < o.length; i++) {
  14220. var s = o[i];
  14221. s._rebuild()
  14222. }
  14223. }
  14224. ,
  14225. a.prototype._rebuildRenderTargetWrappers = function() {
  14226. for (var e = this._renderTargetWrapperCache.slice(), i = 0, o = e; i < o.length; i++) {
  14227. var s = o[i];
  14228. s._rebuild()
  14229. }
  14230. }
  14231. ,
  14232. a.prototype._rebuildEffects = function() {
  14233. for (var e in this._compiledEffects) {
  14234. var i = this._compiledEffects[e];
  14235. i._pipelineContext = null,
  14236. i._wasPreviouslyReady = !1,
  14237. i._prepareEffect()
  14238. }
  14239. Effect.ResetCache()
  14240. }
  14241. ,
  14242. a.prototype.areAllEffectsReady = function() {
  14243. for (var e in this._compiledEffects) {
  14244. var i = this._compiledEffects[e];
  14245. if (!i.isReady())
  14246. return !1
  14247. }
  14248. return !0
  14249. }
  14250. ,
  14251. a.prototype._rebuildBuffers = function() {
  14252. for (var e = 0, i = this._uniformBuffers; e < i.length; e++) {
  14253. var o = i[e];
  14254. o._rebuild()
  14255. }
  14256. for (var s = 0, c = this._storageBuffers; s < c.length; s++) {
  14257. var d = c[s];
  14258. d._rebuild()
  14259. }
  14260. }
  14261. ,
  14262. a.prototype._initGLContext = function() {
  14263. this._caps = {
  14264. maxTexturesImageUnits: this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS),
  14265. maxCombinedTexturesImageUnits: this._gl.getParameter(this._gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS),
  14266. maxVertexTextureImageUnits: this._gl.getParameter(this._gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS),
  14267. maxTextureSize: this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),
  14268. maxSamples: this._webGLVersion > 1 ? this._gl.getParameter(this._gl.MAX_SAMPLES) : 1,
  14269. maxCubemapTextureSize: this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE),
  14270. maxRenderTextureSize: this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE),
  14271. maxVertexAttribs: this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS),
  14272. maxVaryingVectors: this._gl.getParameter(this._gl.MAX_VARYING_VECTORS),
  14273. maxFragmentUniformVectors: this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS),
  14274. maxVertexUniformVectors: this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS),
  14275. parallelShaderCompile: this._gl.getExtension("KHR_parallel_shader_compile") || void 0,
  14276. standardDerivatives: this._webGLVersion > 1 || this._gl.getExtension("OES_standard_derivatives") !== null,
  14277. maxAnisotropy: 1,
  14278. astc: this._gl.getExtension("WEBGL_compressed_texture_astc") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_astc"),
  14279. bptc: this._gl.getExtension("EXT_texture_compression_bptc") || this._gl.getExtension("WEBKIT_EXT_texture_compression_bptc"),
  14280. s3tc: this._gl.getExtension("WEBGL_compressed_texture_s3tc") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc"),
  14281. s3tc_srgb: this._gl.getExtension("WEBGL_compressed_texture_s3tc_srgb") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc_srgb"),
  14282. pvrtc: this._gl.getExtension("WEBGL_compressed_texture_pvrtc") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),
  14283. etc1: this._gl.getExtension("WEBGL_compressed_texture_etc1") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc1"),
  14284. etc2: this._gl.getExtension("WEBGL_compressed_texture_etc") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc") || this._gl.getExtension("WEBGL_compressed_texture_es3_0"),
  14285. textureAnisotropicFilterExtension: this._gl.getExtension("EXT_texture_filter_anisotropic") || this._gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic") || this._gl.getExtension("MOZ_EXT_texture_filter_anisotropic"),
  14286. uintIndices: this._webGLVersion > 1 || this._gl.getExtension("OES_element_index_uint") !== null,
  14287. fragmentDepthSupported: this._webGLVersion > 1 || this._gl.getExtension("EXT_frag_depth") !== null,
  14288. highPrecisionShaderSupported: !1,
  14289. timerQuery: this._gl.getExtension("EXT_disjoint_timer_query_webgl2") || this._gl.getExtension("EXT_disjoint_timer_query"),
  14290. supportOcclusionQuery: this._webGLVersion > 1,
  14291. canUseTimestampForTimerQuery: !1,
  14292. drawBuffersExtension: !1,
  14293. maxMSAASamples: 1,
  14294. colorBufferFloat: !!(this._webGLVersion > 1 && this._gl.getExtension("EXT_color_buffer_float")),
  14295. textureFloat: !!(this._webGLVersion > 1 || this._gl.getExtension("OES_texture_float")),
  14296. textureHalfFloat: !!(this._webGLVersion > 1 || this._gl.getExtension("OES_texture_half_float")),
  14297. textureHalfFloatRender: !1,
  14298. textureFloatLinearFiltering: !1,
  14299. textureFloatRender: !1,
  14300. textureHalfFloatLinearFiltering: !1,
  14301. vertexArrayObject: !1,
  14302. instancedArrays: !1,
  14303. textureLOD: !!(this._webGLVersion > 1 || this._gl.getExtension("EXT_shader_texture_lod")),
  14304. blendMinMax: !1,
  14305. multiview: this._gl.getExtension("OVR_multiview2"),
  14306. oculusMultiview: this._gl.getExtension("OCULUS_multiview"),
  14307. depthTextureExtension: !1,
  14308. canUseGLInstanceID: this._webGLVersion > 1,
  14309. canUseGLVertexID: this._webGLVersion > 1,
  14310. supportComputeShaders: !1,
  14311. supportSRGBBuffers: !1
  14312. },
  14313. this._glVersion = this._gl.getParameter(this._gl.VERSION);
  14314. var e = this._gl.getExtension("WEBGL_debug_renderer_info");
  14315. if (e != null && (this._glRenderer = this._gl.getParameter(e.UNMASKED_RENDERER_WEBGL),
  14316. this._glVendor = this._gl.getParameter(e.UNMASKED_VENDOR_WEBGL)),
  14317. this._glVendor || (this._glVendor = "Unknown vendor"),
  14318. this._glRenderer || (this._glRenderer = "Unknown renderer"),
  14319. this._gl.HALF_FLOAT_OES !== 36193 && (this._gl.HALF_FLOAT_OES = 36193),
  14320. this._gl.RGBA16F !== 34842 && (this._gl.RGBA16F = 34842),
  14321. this._gl.RGBA32F !== 34836 && (this._gl.RGBA32F = 34836),
  14322. this._gl.DEPTH24_STENCIL8 !== 35056 && (this._gl.DEPTH24_STENCIL8 = 35056),
  14323. this._caps.timerQuery && (this._webGLVersion === 1 && (this._gl.getQuery = this._caps.timerQuery.getQueryEXT.bind(this._caps.timerQuery)),
  14324. this._caps.canUseTimestampForTimerQuery = this._gl.getQuery(this._caps.timerQuery.TIMESTAMP_EXT, this._caps.timerQuery.QUERY_COUNTER_BITS_EXT) > 0),
  14325. this._caps.maxAnisotropy = this._caps.textureAnisotropicFilterExtension ? this._gl.getParameter(this._caps.textureAnisotropicFilterExtension.MAX_TEXTURE_MAX_ANISOTROPY_EXT) : 0,
  14326. this._caps.textureFloatLinearFiltering = !!(this._caps.textureFloat && this._gl.getExtension("OES_texture_float_linear")),
  14327. this._caps.textureFloatRender = !!(this._caps.textureFloat && this._canRenderToFloatFramebuffer()),
  14328. this._caps.textureHalfFloatLinearFiltering = !!(this._webGLVersion > 1 || this._caps.textureHalfFloat && this._gl.getExtension("OES_texture_half_float_linear")),
  14329. this._caps.astc && (this._gl.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR = this._caps.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR),
  14330. this._caps.bptc && (this._gl.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT = this._caps.bptc.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT),
  14331. this._caps.s3tc_srgb && (this._gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT = this._caps.s3tc_srgb.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,
  14332. this._gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT = this._caps.s3tc_srgb.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT),
  14333. this._webGLVersion > 1 && this._gl.HALF_FLOAT_OES !== 5131 && (this._gl.HALF_FLOAT_OES = 5131),
  14334. this._caps.textureHalfFloatRender = this._caps.textureHalfFloat && this._canRenderToHalfFloatFramebuffer(),
  14335. this._webGLVersion > 1)
  14336. this._caps.drawBuffersExtension = !0,
  14337. this._caps.maxMSAASamples = this._gl.getParameter(this._gl.MAX_SAMPLES);
  14338. else {
  14339. var i = this._gl.getExtension("WEBGL_draw_buffers");
  14340. if (i !== null) {
  14341. this._caps.drawBuffersExtension = !0,
  14342. this._gl.drawBuffers = i.drawBuffersWEBGL.bind(i),
  14343. this._gl.DRAW_FRAMEBUFFER = this._gl.FRAMEBUFFER;
  14344. for (var o = 0; o < 16; o++)
  14345. this._gl["COLOR_ATTACHMENT" + o + "_WEBGL"] = i["COLOR_ATTACHMENT" + o + "_WEBGL"]
  14346. }
  14347. }
  14348. if (this._webGLVersion > 1)
  14349. this._caps.depthTextureExtension = !0;
  14350. else {
  14351. var s = this._gl.getExtension("WEBGL_depth_texture");
  14352. s != null && (this._caps.depthTextureExtension = !0,
  14353. this._gl.UNSIGNED_INT_24_8 = s.UNSIGNED_INT_24_8_WEBGL)
  14354. }
  14355. if (this.disableVertexArrayObjects)
  14356. this._caps.vertexArrayObject = !1;
  14357. else if (this._webGLVersion > 1)
  14358. this._caps.vertexArrayObject = !0;
  14359. else {
  14360. var c = this._gl.getExtension("OES_vertex_array_object");
  14361. c != null && (this._caps.vertexArrayObject = !0,
  14362. this._gl.createVertexArray = c.createVertexArrayOES.bind(c),
  14363. this._gl.bindVertexArray = c.bindVertexArrayOES.bind(c),
  14364. this._gl.deleteVertexArray = c.deleteVertexArrayOES.bind(c))
  14365. }
  14366. if (this._webGLVersion > 1)
  14367. this._caps.instancedArrays = !0;
  14368. else {
  14369. var d = this._gl.getExtension("ANGLE_instanced_arrays");
  14370. d != null ? (this._caps.instancedArrays = !0,
  14371. this._gl.drawArraysInstanced = d.drawArraysInstancedANGLE.bind(d),
  14372. this._gl.drawElementsInstanced = d.drawElementsInstancedANGLE.bind(d),
  14373. this._gl.vertexAttribDivisor = d.vertexAttribDivisorANGLE.bind(d)) : this._caps.instancedArrays = !1
  14374. }
  14375. if (this._gl.getShaderPrecisionFormat) {
  14376. var _ = this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER, this._gl.HIGH_FLOAT)
  14377. , b = this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER, this._gl.HIGH_FLOAT);
  14378. _ && b && (this._caps.highPrecisionShaderSupported = _.precision !== 0 && b.precision !== 0)
  14379. }
  14380. if (this._webGLVersion > 1)
  14381. this._caps.blendMinMax = !0;
  14382. else {
  14383. var k = this._gl.getExtension("EXT_blend_minmax");
  14384. k != null && (this._caps.blendMinMax = !0,
  14385. this._gl.MAX = k.MAX_EXT,
  14386. this._gl.MIN = k.MIN_EXT)
  14387. }
  14388. if (this._webGLVersion > 1)
  14389. this._caps.supportSRGBBuffers = !0;
  14390. else {
  14391. var j = this._gl.getExtension("EXT_sRGB");
  14392. j != null && (this._caps.supportSRGBBuffers = !0,
  14393. this._gl.SRGB = j.SRGB_EXT,
  14394. this._gl.SRGB8 = j.SRGB_ALPHA_EXT,
  14395. this._gl.SRGB8_ALPHA8 = j.SRGB_ALPHA_EXT)
  14396. }
  14397. this._depthCullingState.depthTest = !0,
  14398. this._depthCullingState.depthFunc = this._gl.LEQUAL,
  14399. this._depthCullingState.depthMask = !0,
  14400. this._maxSimultaneousTextures = this._caps.maxCombinedTexturesImageUnits;
  14401. for (var $ = 0; $ < this._maxSimultaneousTextures; $++)
  14402. this._nextFreeTextureSlots.push($)
  14403. }
  14404. ,
  14405. a.prototype._initFeatures = function() {
  14406. this._features = {
  14407. forceBitmapOverHTMLImageElement: !1,
  14408. supportRenderAndCopyToLodForFloatTextures: this._webGLVersion !== 1,
  14409. supportDepthStencilTexture: this._webGLVersion !== 1,
  14410. supportShadowSamplers: this._webGLVersion !== 1,
  14411. uniformBufferHardCheckMatrix: !1,
  14412. allowTexturePrefiltering: this._webGLVersion !== 1,
  14413. trackUbosInFrame: !1,
  14414. checkUbosContentBeforeUpload: !1,
  14415. supportCSM: this._webGLVersion !== 1,
  14416. basisNeedsPOT: this._webGLVersion === 1,
  14417. support3DTextures: this._webGLVersion !== 1,
  14418. needTypeSuffixInShaderConstants: this._webGLVersion !== 1,
  14419. supportMSAA: this._webGLVersion !== 1,
  14420. supportSSAO2: this._webGLVersion !== 1,
  14421. supportExtendedTextureFormats: this._webGLVersion !== 1,
  14422. supportSwitchCaseInShader: this._webGLVersion !== 1,
  14423. supportSyncTextureRead: !0,
  14424. needsInvertingBitmap: !0,
  14425. useUBOBindingCache: !0,
  14426. needShaderCodeInlining: !1,
  14427. needToAlwaysBindUniformBuffers: !1,
  14428. supportRenderPasses: !1,
  14429. _collectUbosUpdatedInFrame: !1
  14430. }
  14431. }
  14432. ,
  14433. Object.defineProperty(a.prototype, "webGLVersion", {
  14434. get: function() {
  14435. return this._webGLVersion
  14436. },
  14437. enumerable: !1,
  14438. configurable: !0
  14439. }),
  14440. a.prototype.getClassName = function() {
  14441. return "ThinEngine"
  14442. }
  14443. ,
  14444. Object.defineProperty(a.prototype, "isStencilEnable", {
  14445. get: function() {
  14446. return this._isStencilEnable
  14447. },
  14448. enumerable: !1,
  14449. configurable: !0
  14450. }),
  14451. a.prototype._prepareWorkingCanvas = function() {
  14452. if (!this._workingCanvas) {
  14453. this._workingCanvas = this.createCanvas(1, 1);
  14454. var e = this._workingCanvas.getContext("2d");
  14455. e && (this._workingContext = e)
  14456. }
  14457. }
  14458. ,
  14459. a.prototype.resetTextureCache = function() {
  14460. for (var e in this._boundTexturesCache)
  14461. !this._boundTexturesCache.hasOwnProperty(e) || (this._boundTexturesCache[e] = null);
  14462. this._currentTextureChannel = -1
  14463. }
  14464. ,
  14465. a.prototype.getInfo = function() {
  14466. return this.getGlInfo()
  14467. }
  14468. ,
  14469. a.prototype.getGlInfo = function() {
  14470. return {
  14471. vendor: this._glVendor,
  14472. renderer: this._glRenderer,
  14473. version: this._glVersion
  14474. }
  14475. }
  14476. ,
  14477. a.prototype.setHardwareScalingLevel = function(e) {
  14478. this._hardwareScalingLevel = e,
  14479. this.resize()
  14480. }
  14481. ,
  14482. a.prototype.getHardwareScalingLevel = function() {
  14483. return this._hardwareScalingLevel
  14484. }
  14485. ,
  14486. a.prototype.getLoadedTexturesCache = function() {
  14487. return this._internalTexturesCache
  14488. }
  14489. ,
  14490. a.prototype.getCaps = function() {
  14491. return this._caps
  14492. }
  14493. ,
  14494. a.prototype.stopRenderLoop = function(e) {
  14495. if (!e) {
  14496. this._activeRenderLoops = [];
  14497. return
  14498. }
  14499. var i = this._activeRenderLoops.indexOf(e);
  14500. i >= 0 && this._activeRenderLoops.splice(i, 1)
  14501. }
  14502. ,
  14503. a.prototype._renderLoop = function() {
  14504. if (!this._contextWasLost) {
  14505. var e = !0;
  14506. if (!this.renderEvenInBackground && this._windowIsBackground && (e = !1),
  14507. e) {
  14508. this.beginFrame();
  14509. for (var i = 0; i < this._activeRenderLoops.length; i++) {
  14510. var o = this._activeRenderLoops[i];
  14511. o()
  14512. }
  14513. this.endFrame()
  14514. }
  14515. }
  14516. this._activeRenderLoops.length > 0 ? this._frameHandler = this._queueNewFrame(this._boundRenderFunction, this.getHostWindow()) : this._renderingQueueLaunched = !1
  14517. }
  14518. ,
  14519. a.prototype.getRenderingCanvas = function() {
  14520. return this._renderingCanvas
  14521. }
  14522. ,
  14523. a.prototype.getAudioContext = function() {
  14524. return this._audioContext
  14525. }
  14526. ,
  14527. a.prototype.getAudioDestination = function() {
  14528. return this._audioDestination
  14529. }
  14530. ,
  14531. a.prototype.getHostWindow = function() {
  14532. return IsWindowObjectExist() ? this._renderingCanvas && this._renderingCanvas.ownerDocument && this._renderingCanvas.ownerDocument.defaultView ? this._renderingCanvas.ownerDocument.defaultView : window : null
  14533. }
  14534. ,
  14535. a.prototype.getRenderWidth = function(e) {
  14536. return e === void 0 && (e = !1),
  14537. !e && this._currentRenderTarget ? this._currentRenderTarget.width : this._framebufferDimensionsObject ? this._framebufferDimensionsObject.framebufferWidth : this._gl.drawingBufferWidth
  14538. }
  14539. ,
  14540. a.prototype.getRenderHeight = function(e) {
  14541. return e === void 0 && (e = !1),
  14542. !e && this._currentRenderTarget ? this._currentRenderTarget.height : this._framebufferDimensionsObject ? this._framebufferDimensionsObject.framebufferHeight : this._gl.drawingBufferHeight
  14543. }
  14544. ,
  14545. a.prototype._queueNewFrame = function(e, i) {
  14546. return a.QueueNewFrame(e, i)
  14547. }
  14548. ,
  14549. a.prototype.runRenderLoop = function(e) {
  14550. this._activeRenderLoops.indexOf(e) === -1 && (this._activeRenderLoops.push(e),
  14551. this._renderingQueueLaunched || (this._renderingQueueLaunched = !0,
  14552. this._boundRenderFunction = this._renderLoop.bind(this),
  14553. this._frameHandler = this._queueNewFrame(this._boundRenderFunction, this.getHostWindow())))
  14554. }
  14555. ,
  14556. a.prototype.clear = function(e, i, o, s) {
  14557. s === void 0 && (s = !1);
  14558. var c = this.stencilStateComposer.useStencilGlobalOnly;
  14559. this.stencilStateComposer.useStencilGlobalOnly = !0,
  14560. this.applyStates(),
  14561. this.stencilStateComposer.useStencilGlobalOnly = c;
  14562. var d = 0;
  14563. i && e && (this._gl.clearColor(e.r, e.g, e.b, e.a !== void 0 ? e.a : 1),
  14564. d |= this._gl.COLOR_BUFFER_BIT),
  14565. o && (this.useReverseDepthBuffer ? (this._depthCullingState.depthFunc = this._gl.GEQUAL,
  14566. this._gl.clearDepth(0)) : this._gl.clearDepth(1),
  14567. d |= this._gl.DEPTH_BUFFER_BIT),
  14568. s && (this._gl.clearStencil(0),
  14569. d |= this._gl.STENCIL_BUFFER_BIT),
  14570. this._gl.clear(d)
  14571. }
  14572. ,
  14573. a.prototype._viewport = function(e, i, o, s) {
  14574. (e !== this._viewportCached.x || i !== this._viewportCached.y || o !== this._viewportCached.z || s !== this._viewportCached.w) && (this._viewportCached.x = e,
  14575. this._viewportCached.y = i,
  14576. this._viewportCached.z = o,
  14577. this._viewportCached.w = s,
  14578. this._gl.viewport(e, i, o, s))
  14579. }
  14580. ,
  14581. a.prototype.setViewport = function(e, i, o) {
  14582. var s = i || this.getRenderWidth()
  14583. , c = o || this.getRenderHeight()
  14584. , d = e.x || 0
  14585. , _ = e.y || 0;
  14586. this._cachedViewport = e,
  14587. this._viewport(d * s, _ * c, s * e.width, c * e.height)
  14588. }
  14589. ,
  14590. a.prototype.beginFrame = function() {}
  14591. ,
  14592. a.prototype.endFrame = function() {
  14593. this._badOS && this.flushFramebuffer(),
  14594. this._frameId++
  14595. }
  14596. ,
  14597. a.prototype.resize = function(e) {
  14598. e === void 0 && (e = !1);
  14599. var i, o;
  14600. IsWindowObjectExist() ? (i = this._renderingCanvas ? this._renderingCanvas.clientWidth || this._renderingCanvas.width : window.innerWidth,
  14601. o = this._renderingCanvas ? this._renderingCanvas.clientHeight || this._renderingCanvas.height : window.innerHeight) : (i = this._renderingCanvas ? this._renderingCanvas.width : 100,
  14602. o = this._renderingCanvas ? this._renderingCanvas.height : 100),
  14603. this.setSize(i / this._hardwareScalingLevel, o / this._hardwareScalingLevel, e)
  14604. }
  14605. ,
  14606. a.prototype.setSize = function(e, i, o) {
  14607. return o === void 0 && (o = !1),
  14608. !this._renderingCanvas || (e = e | 0,
  14609. i = i | 0,
  14610. !o && this._renderingCanvas.width === e && this._renderingCanvas.height === i) ? !1 : (this._renderingCanvas.width = e,
  14611. this._renderingCanvas.height = i,
  14612. !0)
  14613. }
  14614. ,
  14615. a.prototype.bindFramebuffer = function(e, i, o, s, c, d, _) {
  14616. var b, k, j, $, _e;
  14617. i === void 0 && (i = 0),
  14618. d === void 0 && (d = 0),
  14619. _ === void 0 && (_ = 0);
  14620. var et = e;
  14621. this._currentRenderTarget && this.unBindFramebuffer(this._currentRenderTarget),
  14622. this._currentRenderTarget = e,
  14623. this._bindUnboundFramebuffer(et._MSAAFramebuffer ? et._MSAAFramebuffer : et._framebuffer);
  14624. var tt = this._gl;
  14625. e.is2DArray ? tt.framebufferTextureLayer(tt.FRAMEBUFFER, tt.COLOR_ATTACHMENT0, (b = e.texture._hardwareTexture) === null || b === void 0 ? void 0 : b.underlyingResource, d, _) : e.isCube && tt.framebufferTexture2D(tt.FRAMEBUFFER, tt.COLOR_ATTACHMENT0, tt.TEXTURE_CUBE_MAP_POSITIVE_X + i, (k = e.texture._hardwareTexture) === null || k === void 0 ? void 0 : k.underlyingResource, d);
  14626. var rt = e._depthStencilTexture;
  14627. if (rt) {
  14628. var it = e._depthStencilTextureWithStencil ? tt.DEPTH_STENCIL_ATTACHMENT : tt.DEPTH_ATTACHMENT;
  14629. e.is2DArray ? tt.framebufferTextureLayer(tt.FRAMEBUFFER, it, (j = rt._hardwareTexture) === null || j === void 0 ? void 0 : j.underlyingResource, d, _) : e.isCube ? tt.framebufferTexture2D(tt.FRAMEBUFFER, it, tt.TEXTURE_CUBE_MAP_POSITIVE_X + i, ($ = rt._hardwareTexture) === null || $ === void 0 ? void 0 : $.underlyingResource, d) : tt.framebufferTexture2D(tt.FRAMEBUFFER, it, tt.TEXTURE_2D, (_e = rt._hardwareTexture) === null || _e === void 0 ? void 0 : _e.underlyingResource, d)
  14630. }
  14631. this._cachedViewport && !c ? this.setViewport(this._cachedViewport, o, s) : (o || (o = e.width,
  14632. d && (o = o / Math.pow(2, d))),
  14633. s || (s = e.height,
  14634. d && (s = s / Math.pow(2, d))),
  14635. this._viewport(0, 0, o, s)),
  14636. this.wipeCaches()
  14637. }
  14638. ,
  14639. a.prototype.setState = function(e, i, o, s, c, d, _) {
  14640. var b, k;
  14641. i === void 0 && (i = 0),
  14642. s === void 0 && (s = !1),
  14643. _ === void 0 && (_ = 0),
  14644. (this._depthCullingState.cull !== e || o) && (this._depthCullingState.cull = e);
  14645. var j = !((k = (b = this.cullBackFaces) !== null && b !== void 0 ? b : c) !== null && k !== void 0) || k ? this._gl.BACK : this._gl.FRONT;
  14646. (this._depthCullingState.cullFace !== j || o) && (this._depthCullingState.cullFace = j),
  14647. this.setZOffset(i),
  14648. this.setZOffsetUnits(_);
  14649. var $ = s ? this._gl.CW : this._gl.CCW;
  14650. (this._depthCullingState.frontFace !== $ || o) && (this._depthCullingState.frontFace = $),
  14651. this._stencilStateComposer.stencilMaterial = d
  14652. }
  14653. ,
  14654. a.prototype.setZOffset = function(e) {
  14655. this._depthCullingState.zOffset = this.useReverseDepthBuffer ? -e : e
  14656. }
  14657. ,
  14658. a.prototype.getZOffset = function() {
  14659. var e = this._depthCullingState.zOffset;
  14660. return this.useReverseDepthBuffer ? -e : e
  14661. }
  14662. ,
  14663. a.prototype.setZOffsetUnits = function(e) {
  14664. this._depthCullingState.zOffsetUnits = this.useReverseDepthBuffer ? -e : e
  14665. }
  14666. ,
  14667. a.prototype.getZOffsetUnits = function() {
  14668. var e = this._depthCullingState.zOffsetUnits;
  14669. return this.useReverseDepthBuffer ? -e : e
  14670. }
  14671. ,
  14672. a.prototype._bindUnboundFramebuffer = function(e) {
  14673. this._currentFramebuffer !== e && (this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, e),
  14674. this._currentFramebuffer = e)
  14675. }
  14676. ,
  14677. a.prototype._currentFrameBufferIsDefaultFrameBuffer = function() {
  14678. return this._currentFramebuffer === null
  14679. }
  14680. ,
  14681. a.prototype.generateMipmaps = function(e) {
  14682. this._bindTextureDirectly(this._gl.TEXTURE_2D, e, !0),
  14683. this._gl.generateMipmap(this._gl.TEXTURE_2D),
  14684. this._bindTextureDirectly(this._gl.TEXTURE_2D, null)
  14685. }
  14686. ,
  14687. a.prototype.unBindFramebuffer = function(e, i, o) {
  14688. var s;
  14689. i === void 0 && (i = !1);
  14690. var c = e;
  14691. this._currentRenderTarget = null;
  14692. var d = this._gl;
  14693. if (c._MSAAFramebuffer) {
  14694. if (e.isMulti) {
  14695. this.unBindMultiColorAttachmentFramebuffer(e, i, o);
  14696. return
  14697. }
  14698. d.bindFramebuffer(d.READ_FRAMEBUFFER, c._MSAAFramebuffer),
  14699. d.bindFramebuffer(d.DRAW_FRAMEBUFFER, c._framebuffer),
  14700. d.blitFramebuffer(0, 0, e.width, e.height, 0, 0, e.width, e.height, d.COLOR_BUFFER_BIT, d.NEAREST)
  14701. }
  14702. ((s = e.texture) === null || s === void 0 ? void 0 : s.generateMipMaps) && !i && !e.isCube && this.generateMipmaps(e.texture),
  14703. o && (c._MSAAFramebuffer && this._bindUnboundFramebuffer(c._framebuffer),
  14704. o()),
  14705. this._bindUnboundFramebuffer(null)
  14706. }
  14707. ,
  14708. a.prototype.flushFramebuffer = function() {
  14709. this._gl.flush()
  14710. }
  14711. ,
  14712. a.prototype.restoreDefaultFramebuffer = function() {
  14713. this._currentRenderTarget ? this.unBindFramebuffer(this._currentRenderTarget) : this._bindUnboundFramebuffer(null),
  14714. this._cachedViewport && this.setViewport(this._cachedViewport),
  14715. this.wipeCaches()
  14716. }
  14717. ,
  14718. a.prototype._resetVertexBufferBinding = function() {
  14719. this.bindArrayBuffer(null),
  14720. this._cachedVertexBuffers = null
  14721. }
  14722. ,
  14723. a.prototype.createVertexBuffer = function(e) {
  14724. return this._createVertexBuffer(e, this._gl.STATIC_DRAW)
  14725. }
  14726. ,
  14727. a.prototype._createVertexBuffer = function(e, i) {
  14728. var o = this._gl.createBuffer();
  14729. if (!o)
  14730. throw new Error("Unable to create vertex buffer");
  14731. var s = new WebGLDataBuffer(o);
  14732. return this.bindArrayBuffer(s),
  14733. e instanceof Array ? this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(e), i) : this._gl.bufferData(this._gl.ARRAY_BUFFER, e, i),
  14734. this._resetVertexBufferBinding(),
  14735. s.references = 1,
  14736. s
  14737. }
  14738. ,
  14739. a.prototype.createDynamicVertexBuffer = function(e) {
  14740. return this._createVertexBuffer(e, this._gl.DYNAMIC_DRAW)
  14741. }
  14742. ,
  14743. a.prototype._resetIndexBufferBinding = function() {
  14744. this.bindIndexBuffer(null),
  14745. this._cachedIndexBuffer = null
  14746. }
  14747. ,
  14748. a.prototype.createIndexBuffer = function(e, i) {
  14749. var o = this._gl.createBuffer()
  14750. , s = new WebGLDataBuffer(o);
  14751. if (!o)
  14752. throw new Error("Unable to create index buffer");
  14753. this.bindIndexBuffer(s);
  14754. var c = this._normalizeIndexData(e);
  14755. return this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, c, i ? this._gl.DYNAMIC_DRAW : this._gl.STATIC_DRAW),
  14756. this._resetIndexBufferBinding(),
  14757. s.references = 1,
  14758. s.is32Bits = c.BYTES_PER_ELEMENT === 4,
  14759. s
  14760. }
  14761. ,
  14762. a.prototype._normalizeIndexData = function(e) {
  14763. var i = e.BYTES_PER_ELEMENT;
  14764. if (i === 2)
  14765. return e;
  14766. if (this._caps.uintIndices) {
  14767. if (e instanceof Uint32Array)
  14768. return e;
  14769. for (var o = 0; o < e.length; o++)
  14770. if (e[o] >= 65535)
  14771. return new Uint32Array(e);
  14772. return new Uint16Array(e)
  14773. }
  14774. return new Uint16Array(e)
  14775. }
  14776. ,
  14777. a.prototype.bindArrayBuffer = function(e) {
  14778. this._vaoRecordInProgress || this._unbindVertexArrayObject(),
  14779. this.bindBuffer(e, this._gl.ARRAY_BUFFER)
  14780. }
  14781. ,
  14782. a.prototype.bindUniformBlock = function(e, i, o) {
  14783. var s = e.program
  14784. , c = this._gl.getUniformBlockIndex(s, i);
  14785. this._gl.uniformBlockBinding(s, c, o)
  14786. }
  14787. ,
  14788. a.prototype.bindIndexBuffer = function(e) {
  14789. this._vaoRecordInProgress || this._unbindVertexArrayObject(),
  14790. this.bindBuffer(e, this._gl.ELEMENT_ARRAY_BUFFER)
  14791. }
  14792. ,
  14793. a.prototype.bindBuffer = function(e, i) {
  14794. (this._vaoRecordInProgress || this._currentBoundBuffer[i] !== e) && (this._gl.bindBuffer(i, e ? e.underlyingResource : null),
  14795. this._currentBoundBuffer[i] = e)
  14796. }
  14797. ,
  14798. a.prototype.updateArrayBuffer = function(e) {
  14799. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, e)
  14800. }
  14801. ,
  14802. a.prototype._vertexAttribPointer = function(e, i, o, s, c, d, _) {
  14803. var b = this._currentBufferPointers[i];
  14804. if (!!b) {
  14805. var k = !1;
  14806. b.active ? (b.buffer !== e && (b.buffer = e,
  14807. k = !0),
  14808. b.size !== o && (b.size = o,
  14809. k = !0),
  14810. b.type !== s && (b.type = s,
  14811. k = !0),
  14812. b.normalized !== c && (b.normalized = c,
  14813. k = !0),
  14814. b.stride !== d && (b.stride = d,
  14815. k = !0),
  14816. b.offset !== _ && (b.offset = _,
  14817. k = !0)) : (k = !0,
  14818. b.active = !0,
  14819. b.index = i,
  14820. b.size = o,
  14821. b.type = s,
  14822. b.normalized = c,
  14823. b.stride = d,
  14824. b.offset = _,
  14825. b.buffer = e),
  14826. (k || this._vaoRecordInProgress) && (this.bindArrayBuffer(e),
  14827. this._gl.vertexAttribPointer(i, o, s, c, d, _))
  14828. }
  14829. }
  14830. ,
  14831. a.prototype._bindIndexBufferWithCache = function(e) {
  14832. e != null && this._cachedIndexBuffer !== e && (this._cachedIndexBuffer = e,
  14833. this.bindIndexBuffer(e),
  14834. this._uintIndicesCurrentlySet = e.is32Bits)
  14835. }
  14836. ,
  14837. a.prototype._bindVertexBuffersAttributes = function(e, i, o) {
  14838. var s = i.getAttributesNames();
  14839. this._vaoRecordInProgress || this._unbindVertexArrayObject(),
  14840. this.unbindAllAttributes();
  14841. for (var c = 0; c < s.length; c++) {
  14842. var d = i.getAttributeLocation(c);
  14843. if (d >= 0) {
  14844. var _ = s[c]
  14845. , b = null;
  14846. if (o && (b = o[_]),
  14847. b || (b = e[_]),
  14848. !b)
  14849. continue;
  14850. this._gl.enableVertexAttribArray(d),
  14851. this._vaoRecordInProgress || (this._vertexAttribArraysEnabled[d] = !0);
  14852. var k = b.getBuffer();
  14853. k && (this._vertexAttribPointer(k, d, b.getSize(), b.type, b.normalized, b.byteStride, b.byteOffset),
  14854. b.getIsInstanced() && (this._gl.vertexAttribDivisor(d, b.getInstanceDivisor()),
  14855. this._vaoRecordInProgress || (this._currentInstanceLocations.push(d),
  14856. this._currentInstanceBuffers.push(k))))
  14857. }
  14858. }
  14859. }
  14860. ,
  14861. a.prototype.recordVertexArrayObject = function(e, i, o, s) {
  14862. var c = this._gl.createVertexArray();
  14863. return this._vaoRecordInProgress = !0,
  14864. this._gl.bindVertexArray(c),
  14865. this._mustWipeVertexAttributes = !0,
  14866. this._bindVertexBuffersAttributes(e, o, s),
  14867. this.bindIndexBuffer(i),
  14868. this._vaoRecordInProgress = !1,
  14869. this._gl.bindVertexArray(null),
  14870. c
  14871. }
  14872. ,
  14873. a.prototype.bindVertexArrayObject = function(e, i) {
  14874. this._cachedVertexArrayObject !== e && (this._cachedVertexArrayObject = e,
  14875. this._gl.bindVertexArray(e),
  14876. this._cachedVertexBuffers = null,
  14877. this._cachedIndexBuffer = null,
  14878. this._uintIndicesCurrentlySet = i != null && i.is32Bits,
  14879. this._mustWipeVertexAttributes = !0)
  14880. }
  14881. ,
  14882. a.prototype.bindBuffersDirectly = function(e, i, o, s, c) {
  14883. if (this._cachedVertexBuffers !== e || this._cachedEffectForVertexBuffers !== c) {
  14884. this._cachedVertexBuffers = e,
  14885. this._cachedEffectForVertexBuffers = c;
  14886. var d = c.getAttributesCount();
  14887. this._unbindVertexArrayObject(),
  14888. this.unbindAllAttributes();
  14889. for (var _ = 0, b = 0; b < d; b++)
  14890. if (b < o.length) {
  14891. var k = c.getAttributeLocation(b);
  14892. k >= 0 && (this._gl.enableVertexAttribArray(k),
  14893. this._vertexAttribArraysEnabled[k] = !0,
  14894. this._vertexAttribPointer(e, k, o[b], this._gl.FLOAT, !1, s, _)),
  14895. _ += o[b] * 4
  14896. }
  14897. }
  14898. this._bindIndexBufferWithCache(i)
  14899. }
  14900. ,
  14901. a.prototype._unbindVertexArrayObject = function() {
  14902. !this._cachedVertexArrayObject || (this._cachedVertexArrayObject = null,
  14903. this._gl.bindVertexArray(null))
  14904. }
  14905. ,
  14906. a.prototype.bindBuffers = function(e, i, o, s) {
  14907. (this._cachedVertexBuffers !== e || this._cachedEffectForVertexBuffers !== o) && (this._cachedVertexBuffers = e,
  14908. this._cachedEffectForVertexBuffers = o,
  14909. this._bindVertexBuffersAttributes(e, o, s)),
  14910. this._bindIndexBufferWithCache(i)
  14911. }
  14912. ,
  14913. a.prototype.unbindInstanceAttributes = function() {
  14914. for (var e, i = 0, o = this._currentInstanceLocations.length; i < o; i++) {
  14915. var s = this._currentInstanceBuffers[i];
  14916. e != s && s.references && (e = s,
  14917. this.bindArrayBuffer(s));
  14918. var c = this._currentInstanceLocations[i];
  14919. this._gl.vertexAttribDivisor(c, 0)
  14920. }
  14921. this._currentInstanceBuffers.length = 0,
  14922. this._currentInstanceLocations.length = 0
  14923. }
  14924. ,
  14925. a.prototype.releaseVertexArrayObject = function(e) {
  14926. this._gl.deleteVertexArray(e)
  14927. }
  14928. ,
  14929. a.prototype._releaseBuffer = function(e) {
  14930. return e.references--,
  14931. e.references === 0 ? (this._deleteBuffer(e),
  14932. !0) : !1
  14933. }
  14934. ,
  14935. a.prototype._deleteBuffer = function(e) {
  14936. this._gl.deleteBuffer(e.underlyingResource)
  14937. }
  14938. ,
  14939. a.prototype.updateAndBindInstancesBuffer = function(e, i, o) {
  14940. if (this.bindArrayBuffer(e),
  14941. i && this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, i),
  14942. o[0].index !== void 0)
  14943. this.bindInstancesBuffer(e, o, !0);
  14944. else
  14945. for (var s = 0; s < 4; s++) {
  14946. var c = o[s];
  14947. this._vertexAttribArraysEnabled[c] || (this._gl.enableVertexAttribArray(c),
  14948. this._vertexAttribArraysEnabled[c] = !0),
  14949. this._vertexAttribPointer(e, c, 4, this._gl.FLOAT, !1, 64, s * 16),
  14950. this._gl.vertexAttribDivisor(c, 1),
  14951. this._currentInstanceLocations.push(c),
  14952. this._currentInstanceBuffers.push(e)
  14953. }
  14954. }
  14955. ,
  14956. a.prototype.bindInstancesBuffer = function(e, i, o) {
  14957. o === void 0 && (o = !0),
  14958. this.bindArrayBuffer(e);
  14959. var s = 0;
  14960. if (o)
  14961. for (var c = 0; c < i.length; c++) {
  14962. var d = i[c];
  14963. s += d.attributeSize * 4
  14964. }
  14965. for (var c = 0; c < i.length; c++) {
  14966. var d = i[c];
  14967. d.index === void 0 && (d.index = this._currentEffect.getAttributeLocationByName(d.attributeName)),
  14968. !(d.index < 0) && (this._vertexAttribArraysEnabled[d.index] || (this._gl.enableVertexAttribArray(d.index),
  14969. this._vertexAttribArraysEnabled[d.index] = !0),
  14970. this._vertexAttribPointer(e, d.index, d.attributeSize, d.attributeType || this._gl.FLOAT, d.normalized || !1, s, d.offset),
  14971. this._gl.vertexAttribDivisor(d.index, d.divisor === void 0 ? 1 : d.divisor),
  14972. this._currentInstanceLocations.push(d.index),
  14973. this._currentInstanceBuffers.push(e))
  14974. }
  14975. }
  14976. ,
  14977. a.prototype.disableInstanceAttributeByName = function(e) {
  14978. if (!!this._currentEffect) {
  14979. var i = this._currentEffect.getAttributeLocationByName(e);
  14980. this.disableInstanceAttribute(i)
  14981. }
  14982. }
  14983. ,
  14984. a.prototype.disableInstanceAttribute = function(e) {
  14985. for (var i = !1, o; (o = this._currentInstanceLocations.indexOf(e)) !== -1; )
  14986. this._currentInstanceLocations.splice(o, 1),
  14987. this._currentInstanceBuffers.splice(o, 1),
  14988. i = !0,
  14989. o = this._currentInstanceLocations.indexOf(e);
  14990. i && (this._gl.vertexAttribDivisor(e, 0),
  14991. this.disableAttributeByIndex(e))
  14992. }
  14993. ,
  14994. a.prototype.disableAttributeByIndex = function(e) {
  14995. this._gl.disableVertexAttribArray(e),
  14996. this._vertexAttribArraysEnabled[e] = !1,
  14997. this._currentBufferPointers[e].active = !1
  14998. }
  14999. ,
  15000. a.prototype.draw = function(e, i, o, s) {
  15001. this.drawElementsType(e ? 0 : 1, i, o, s)
  15002. }
  15003. ,
  15004. a.prototype.drawPointClouds = function(e, i, o) {
  15005. this.drawArraysType(2, e, i, o)
  15006. }
  15007. ,
  15008. a.prototype.drawUnIndexed = function(e, i, o, s) {
  15009. this.drawArraysType(e ? 0 : 1, i, o, s)
  15010. }
  15011. ,
  15012. a.prototype.drawElementsType = function(e, i, o, s) {
  15013. this.applyStates(),
  15014. this._reportDrawCall();
  15015. var c = this._drawMode(e)
  15016. , d = this._uintIndicesCurrentlySet ? this._gl.UNSIGNED_INT : this._gl.UNSIGNED_SHORT
  15017. , _ = this._uintIndicesCurrentlySet ? 4 : 2;
  15018. s ? this._gl.drawElementsInstanced(c, o, d, i * _, s) : this._gl.drawElements(c, o, d, i * _)
  15019. }
  15020. ,
  15021. a.prototype.drawArraysType = function(e, i, o, s) {
  15022. this.applyStates(),
  15023. this._reportDrawCall();
  15024. var c = this._drawMode(e);
  15025. s ? this._gl.drawArraysInstanced(c, i, o, s) : this._gl.drawArrays(c, i, o)
  15026. }
  15027. ,
  15028. a.prototype._drawMode = function(e) {
  15029. switch (e) {
  15030. case 0:
  15031. return this._gl.TRIANGLES;
  15032. case 2:
  15033. return this._gl.POINTS;
  15034. case 1:
  15035. return this._gl.LINES;
  15036. case 3:
  15037. return this._gl.POINTS;
  15038. case 4:
  15039. return this._gl.LINES;
  15040. case 5:
  15041. return this._gl.LINE_LOOP;
  15042. case 6:
  15043. return this._gl.LINE_STRIP;
  15044. case 7:
  15045. return this._gl.TRIANGLE_STRIP;
  15046. case 8:
  15047. return this._gl.TRIANGLE_FAN;
  15048. default:
  15049. return this._gl.TRIANGLES
  15050. }
  15051. }
  15052. ,
  15053. a.prototype._reportDrawCall = function() {}
  15054. ,
  15055. a.prototype._releaseEffect = function(e) {
  15056. if (this._compiledEffects[e._key]) {
  15057. delete this._compiledEffects[e._key];
  15058. var i = e.getPipelineContext();
  15059. i && this._deletePipelineContext(i)
  15060. }
  15061. }
  15062. ,
  15063. a.prototype._deletePipelineContext = function(e) {
  15064. var i = e;
  15065. i && i.program && (i.program.__SPECTOR_rebuildProgram = null,
  15066. this._gl.deleteProgram(i.program))
  15067. }
  15068. ,
  15069. a.prototype._getGlobalDefines = function(e) {
  15070. if (e) {
  15071. this.isNDCHalfZRange ? e.IS_NDC_HALF_ZRANGE = "" : delete e.IS_NDC_HALF_ZRANGE,
  15072. this.useReverseDepthBuffer ? e.USE_REVERSE_DEPTHBUFFER = "" : delete e.USE_REVERSE_DEPTHBUFFER;
  15073. return
  15074. } else {
  15075. var i = "";
  15076. return this.isNDCHalfZRange && (i += "#define IS_NDC_HALF_ZRANGE"),
  15077. this.useReverseDepthBuffer && (i && (i += `
  15078. `),
  15079. i += "#define USE_REVERSE_DEPTHBUFFER"),
  15080. i
  15081. }
  15082. }
  15083. ,
  15084. a.prototype.createEffect = function(e, i, o, s, c, d, _, b, k, j) {
  15085. var $;
  15086. j === void 0 && (j = ShaderLanguage.GLSL);
  15087. var _e = e.vertexElement || e.vertex || e.vertexToken || e.vertexSource || e
  15088. , et = e.fragmentElement || e.fragment || e.fragmentToken || e.fragmentSource || e
  15089. , tt = this._getGlobalDefines()
  15090. , rt = ($ = c != null ? c : i.defines) !== null && $ !== void 0 ? $ : "";
  15091. tt && (rt += tt);
  15092. var it = _e + "+" + et + "@" + rt;
  15093. if (this._compiledEffects[it]) {
  15094. var nt = this._compiledEffects[it];
  15095. return _ && nt.isReady() && _(nt),
  15096. nt
  15097. }
  15098. var ot = new Effect(e,i,o,s,this,c,d,_,b,k,it,j);
  15099. return this._compiledEffects[it] = ot,
  15100. ot
  15101. }
  15102. ,
  15103. a._ConcatenateShader = function(e, i, o) {
  15104. return o === void 0 && (o = ""),
  15105. o + (i ? i + `
  15106. ` : "") + e
  15107. }
  15108. ,
  15109. a.prototype._compileShader = function(e, i, o, s) {
  15110. return this._compileRawShader(a._ConcatenateShader(e, o, s), i)
  15111. }
  15112. ,
  15113. a.prototype._compileRawShader = function(e, i) {
  15114. for (var o = this._gl; o.getError() != o.NO_ERROR; )
  15115. ;
  15116. var s = o.createShader(i === "vertex" ? o.VERTEX_SHADER : o.FRAGMENT_SHADER);
  15117. if (!s)
  15118. throw new Error("Something went wrong while creating a gl " + i + " shader object. gl error=" + o.getError() + ", gl isContextLost=" + o.isContextLost() + ", _contextWasLost=" + this._contextWasLost);
  15119. return o.shaderSource(s, e),
  15120. o.compileShader(s),
  15121. s
  15122. }
  15123. ,
  15124. a.prototype._getShaderSource = function(e) {
  15125. return this._gl.getShaderSource(e)
  15126. }
  15127. ,
  15128. a.prototype.createRawShaderProgram = function(e, i, o, s, c) {
  15129. c === void 0 && (c = null),
  15130. s = s || this._gl;
  15131. var d = this._compileRawShader(i, "vertex")
  15132. , _ = this._compileRawShader(o, "fragment");
  15133. return this._createShaderProgram(e, d, _, s, c)
  15134. }
  15135. ,
  15136. a.prototype.createShaderProgram = function(e, i, o, s, c, d) {
  15137. d === void 0 && (d = null),
  15138. c = c || this._gl;
  15139. var _ = this._webGLVersion > 1 ? `#version 300 es
  15140. #define WEBGL2
  15141. ` : ""
  15142. , b = this._compileShader(i, "vertex", s, _)
  15143. , k = this._compileShader(o, "fragment", s, _);
  15144. return this._createShaderProgram(e, b, k, c, d)
  15145. }
  15146. ,
  15147. a.prototype.inlineShaderCode = function(e) {
  15148. return e
  15149. }
  15150. ,
  15151. a.prototype.createPipelineContext = function(e) {
  15152. var i = new WebGLPipelineContext;
  15153. return i.engine = this,
  15154. this._caps.parallelShaderCompile && (i.isParallelCompiled = !0),
  15155. i
  15156. }
  15157. ,
  15158. a.prototype.createMaterialContext = function() {}
  15159. ,
  15160. a.prototype.createDrawContext = function() {}
  15161. ,
  15162. a.prototype._createShaderProgram = function(e, i, o, s, c) {
  15163. var d = s.createProgram();
  15164. if (e.program = d,
  15165. !d)
  15166. throw new Error("Unable to create program");
  15167. return s.attachShader(d, i),
  15168. s.attachShader(d, o),
  15169. s.linkProgram(d),
  15170. e.context = s,
  15171. e.vertexShader = i,
  15172. e.fragmentShader = o,
  15173. e.isParallelCompiled || this._finalizePipelineContext(e),
  15174. d
  15175. }
  15176. ,
  15177. a.prototype._finalizePipelineContext = function(e) {
  15178. var i = e.context
  15179. , o = e.vertexShader
  15180. , s = e.fragmentShader
  15181. , c = e.program
  15182. , d = i.getProgramParameter(c, i.LINK_STATUS);
  15183. if (!d) {
  15184. if (!this._gl.getShaderParameter(o, this._gl.COMPILE_STATUS)) {
  15185. var _ = this._gl.getShaderInfoLog(o);
  15186. if (_)
  15187. throw e.vertexCompilationError = _,
  15188. new Error("VERTEX SHADER " + _)
  15189. }
  15190. if (!this._gl.getShaderParameter(s, this._gl.COMPILE_STATUS)) {
  15191. var _ = this._gl.getShaderInfoLog(s);
  15192. if (_)
  15193. throw e.fragmentCompilationError = _,
  15194. new Error("FRAGMENT SHADER " + _)
  15195. }
  15196. var b = i.getProgramInfoLog(c);
  15197. if (b)
  15198. throw e.programLinkError = b,
  15199. new Error(b)
  15200. }
  15201. if (this.validateShaderPrograms) {
  15202. i.validateProgram(c);
  15203. var k = i.getProgramParameter(c, i.VALIDATE_STATUS);
  15204. if (!k) {
  15205. var b = i.getProgramInfoLog(c);
  15206. if (b)
  15207. throw e.programValidationError = b,
  15208. new Error(b)
  15209. }
  15210. }
  15211. i.deleteShader(o),
  15212. i.deleteShader(s),
  15213. e.vertexShader = void 0,
  15214. e.fragmentShader = void 0,
  15215. e.onCompiled && (e.onCompiled(),
  15216. e.onCompiled = void 0)
  15217. }
  15218. ,
  15219. a.prototype._preparePipelineContext = function(e, i, o, s, c, d, _, b, k, j) {
  15220. var $ = e;
  15221. s ? $.program = this.createRawShaderProgram($, i, o, void 0, k) : $.program = this.createShaderProgram($, i, o, b, void 0, k),
  15222. $.program.__SPECTOR_rebuildProgram = _
  15223. }
  15224. ,
  15225. a.prototype._isRenderingStateCompiled = function(e) {
  15226. var i = e;
  15227. return this._gl.getProgramParameter(i.program, this._caps.parallelShaderCompile.COMPLETION_STATUS_KHR) ? (this._finalizePipelineContext(i),
  15228. !0) : !1
  15229. }
  15230. ,
  15231. a.prototype._executeWhenRenderingStateIsCompiled = function(e, i) {
  15232. var o = e;
  15233. if (!o.isParallelCompiled) {
  15234. i();
  15235. return
  15236. }
  15237. var s = o.onCompiled;
  15238. s ? o.onCompiled = function() {
  15239. s(),
  15240. i()
  15241. }
  15242. : o.onCompiled = i
  15243. }
  15244. ,
  15245. a.prototype.getUniforms = function(e, i) {
  15246. for (var o = new Array, s = e, c = 0; c < i.length; c++)
  15247. o.push(this._gl.getUniformLocation(s.program, i[c]));
  15248. return o
  15249. }
  15250. ,
  15251. a.prototype.getAttributes = function(e, i) {
  15252. for (var o = [], s = e, c = 0; c < i.length; c++)
  15253. try {
  15254. o.push(this._gl.getAttribLocation(s.program, i[c]))
  15255. } catch {
  15256. o.push(-1)
  15257. }
  15258. return o
  15259. }
  15260. ,
  15261. a.prototype.enableEffect = function(e) {
  15262. e = e !== null && DrawWrapper.IsWrapper(e) ? e.effect : e,
  15263. !(!e || e === this._currentEffect) && (this._stencilStateComposer.stencilMaterial = void 0,
  15264. e = e,
  15265. this.bindSamplers(e),
  15266. this._currentEffect = e,
  15267. e.onBind && e.onBind(e),
  15268. e._onBindObservable && e._onBindObservable.notifyObservers(e))
  15269. }
  15270. ,
  15271. a.prototype.setInt = function(e, i) {
  15272. return e ? (this._gl.uniform1i(e, i),
  15273. !0) : !1
  15274. }
  15275. ,
  15276. a.prototype.setInt2 = function(e, i, o) {
  15277. return e ? (this._gl.uniform2i(e, i, o),
  15278. !0) : !1
  15279. }
  15280. ,
  15281. a.prototype.setInt3 = function(e, i, o, s) {
  15282. return e ? (this._gl.uniform3i(e, i, o, s),
  15283. !0) : !1
  15284. }
  15285. ,
  15286. a.prototype.setInt4 = function(e, i, o, s, c) {
  15287. return e ? (this._gl.uniform4i(e, i, o, s, c),
  15288. !0) : !1
  15289. }
  15290. ,
  15291. a.prototype.setIntArray = function(e, i) {
  15292. return e ? (this._gl.uniform1iv(e, i),
  15293. !0) : !1
  15294. }
  15295. ,
  15296. a.prototype.setIntArray2 = function(e, i) {
  15297. return !e || i.length % 2 !== 0 ? !1 : (this._gl.uniform2iv(e, i),
  15298. !0)
  15299. }
  15300. ,
  15301. a.prototype.setIntArray3 = function(e, i) {
  15302. return !e || i.length % 3 !== 0 ? !1 : (this._gl.uniform3iv(e, i),
  15303. !0)
  15304. }
  15305. ,
  15306. a.prototype.setIntArray4 = function(e, i) {
  15307. return !e || i.length % 4 !== 0 ? !1 : (this._gl.uniform4iv(e, i),
  15308. !0)
  15309. }
  15310. ,
  15311. a.prototype.setArray = function(e, i) {
  15312. return !e || i.length < 1 ? !1 : (this._gl.uniform1fv(e, i),
  15313. !0)
  15314. }
  15315. ,
  15316. a.prototype.setArray2 = function(e, i) {
  15317. return !e || i.length % 2 !== 0 ? !1 : (this._gl.uniform2fv(e, i),
  15318. !0)
  15319. }
  15320. ,
  15321. a.prototype.setArray3 = function(e, i) {
  15322. return !e || i.length % 3 !== 0 ? !1 : (this._gl.uniform3fv(e, i),
  15323. !0)
  15324. }
  15325. ,
  15326. a.prototype.setArray4 = function(e, i) {
  15327. return !e || i.length % 4 !== 0 ? !1 : (this._gl.uniform4fv(e, i),
  15328. !0)
  15329. }
  15330. ,
  15331. a.prototype.setMatrices = function(e, i) {
  15332. return e ? (this._gl.uniformMatrix4fv(e, !1, i),
  15333. !0) : !1
  15334. }
  15335. ,
  15336. a.prototype.setMatrix3x3 = function(e, i) {
  15337. return e ? (this._gl.uniformMatrix3fv(e, !1, i),
  15338. !0) : !1
  15339. }
  15340. ,
  15341. a.prototype.setMatrix2x2 = function(e, i) {
  15342. return e ? (this._gl.uniformMatrix2fv(e, !1, i),
  15343. !0) : !1
  15344. }
  15345. ,
  15346. a.prototype.setFloat = function(e, i) {
  15347. return e ? (this._gl.uniform1f(e, i),
  15348. !0) : !1
  15349. }
  15350. ,
  15351. a.prototype.setFloat2 = function(e, i, o) {
  15352. return e ? (this._gl.uniform2f(e, i, o),
  15353. !0) : !1
  15354. }
  15355. ,
  15356. a.prototype.setFloat3 = function(e, i, o, s) {
  15357. return e ? (this._gl.uniform3f(e, i, o, s),
  15358. !0) : !1
  15359. }
  15360. ,
  15361. a.prototype.setFloat4 = function(e, i, o, s, c) {
  15362. return e ? (this._gl.uniform4f(e, i, o, s, c),
  15363. !0) : !1
  15364. }
  15365. ,
  15366. a.prototype.applyStates = function() {
  15367. if (this._depthCullingState.apply(this._gl),
  15368. this._stencilStateComposer.apply(this._gl),
  15369. this._alphaState.apply(this._gl),
  15370. this._colorWriteChanged) {
  15371. this._colorWriteChanged = !1;
  15372. var e = this._colorWrite;
  15373. this._gl.colorMask(e, e, e, e)
  15374. }
  15375. }
  15376. ,
  15377. a.prototype.setColorWrite = function(e) {
  15378. e !== this._colorWrite && (this._colorWriteChanged = !0,
  15379. this._colorWrite = e)
  15380. }
  15381. ,
  15382. a.prototype.getColorWrite = function() {
  15383. return this._colorWrite
  15384. }
  15385. ,
  15386. Object.defineProperty(a.prototype, "depthCullingState", {
  15387. get: function() {
  15388. return this._depthCullingState
  15389. },
  15390. enumerable: !1,
  15391. configurable: !0
  15392. }),
  15393. Object.defineProperty(a.prototype, "alphaState", {
  15394. get: function() {
  15395. return this._alphaState
  15396. },
  15397. enumerable: !1,
  15398. configurable: !0
  15399. }),
  15400. Object.defineProperty(a.prototype, "stencilState", {
  15401. get: function() {
  15402. return this._stencilState
  15403. },
  15404. enumerable: !1,
  15405. configurable: !0
  15406. }),
  15407. Object.defineProperty(a.prototype, "stencilStateComposer", {
  15408. get: function() {
  15409. return this._stencilStateComposer
  15410. },
  15411. enumerable: !1,
  15412. configurable: !0
  15413. }),
  15414. a.prototype.clearInternalTexturesCache = function() {
  15415. this._internalTexturesCache = []
  15416. }
  15417. ,
  15418. a.prototype.wipeCaches = function(e) {
  15419. this.preventCacheWipeBetweenFrames && !e || (this._currentEffect = null,
  15420. this._viewportCached.x = 0,
  15421. this._viewportCached.y = 0,
  15422. this._viewportCached.z = 0,
  15423. this._viewportCached.w = 0,
  15424. this._unbindVertexArrayObject(),
  15425. e && (this._currentProgram = null,
  15426. this.resetTextureCache(),
  15427. this._stencilStateComposer.reset(),
  15428. this._depthCullingState.reset(),
  15429. this._depthCullingState.depthFunc = this._gl.LEQUAL,
  15430. this._alphaState.reset(),
  15431. this._alphaMode = 1,
  15432. this._alphaEquation = 0,
  15433. this._colorWrite = !0,
  15434. this._colorWriteChanged = !0,
  15435. this._unpackFlipYCached = null,
  15436. this._gl.pixelStorei(this._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, this._gl.NONE),
  15437. this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0),
  15438. this._mustWipeVertexAttributes = !0,
  15439. this.unbindAllAttributes()),
  15440. this._resetVertexBufferBinding(),
  15441. this._cachedIndexBuffer = null,
  15442. this._cachedEffectForVertexBuffers = null,
  15443. this.bindIndexBuffer(null))
  15444. }
  15445. ,
  15446. a.prototype._getSamplingParameters = function(e, i) {
  15447. var o = this._gl
  15448. , s = o.NEAREST
  15449. , c = o.NEAREST;
  15450. switch (e) {
  15451. case 11:
  15452. s = o.LINEAR,
  15453. i ? c = o.LINEAR_MIPMAP_NEAREST : c = o.LINEAR;
  15454. break;
  15455. case 3:
  15456. s = o.LINEAR,
  15457. i ? c = o.LINEAR_MIPMAP_LINEAR : c = o.LINEAR;
  15458. break;
  15459. case 8:
  15460. s = o.NEAREST,
  15461. i ? c = o.NEAREST_MIPMAP_LINEAR : c = o.NEAREST;
  15462. break;
  15463. case 4:
  15464. s = o.NEAREST,
  15465. i ? c = o.NEAREST_MIPMAP_NEAREST : c = o.NEAREST;
  15466. break;
  15467. case 5:
  15468. s = o.NEAREST,
  15469. i ? c = o.LINEAR_MIPMAP_NEAREST : c = o.LINEAR;
  15470. break;
  15471. case 6:
  15472. s = o.NEAREST,
  15473. i ? c = o.LINEAR_MIPMAP_LINEAR : c = o.LINEAR;
  15474. break;
  15475. case 7:
  15476. s = o.NEAREST,
  15477. c = o.LINEAR;
  15478. break;
  15479. case 1:
  15480. s = o.NEAREST,
  15481. c = o.NEAREST;
  15482. break;
  15483. case 9:
  15484. s = o.LINEAR,
  15485. i ? c = o.NEAREST_MIPMAP_NEAREST : c = o.NEAREST;
  15486. break;
  15487. case 10:
  15488. s = o.LINEAR,
  15489. i ? c = o.NEAREST_MIPMAP_LINEAR : c = o.NEAREST;
  15490. break;
  15491. case 2:
  15492. s = o.LINEAR,
  15493. c = o.LINEAR;
  15494. break;
  15495. case 12:
  15496. s = o.LINEAR,
  15497. c = o.NEAREST;
  15498. break
  15499. }
  15500. return {
  15501. min: c,
  15502. mag: s
  15503. }
  15504. }
  15505. ,
  15506. a.prototype._createTexture = function() {
  15507. var e = this._gl.createTexture();
  15508. if (!e)
  15509. throw new Error("Unable to create texture");
  15510. return e
  15511. }
  15512. ,
  15513. a.prototype._createHardwareTexture = function() {
  15514. return new WebGLHardwareTexture(this._createTexture(),this._gl)
  15515. }
  15516. ,
  15517. a.prototype._createInternalTexture = function(e, i, o, s) {
  15518. s === void 0 && (s = InternalTextureSource.Unknown);
  15519. var c = {};
  15520. i !== void 0 && typeof i == "object" ? (c.generateMipMaps = i.generateMipMaps,
  15521. c.type = i.type === void 0 ? 0 : i.type,
  15522. c.samplingMode = i.samplingMode === void 0 ? 3 : i.samplingMode,
  15523. c.format = i.format === void 0 ? 5 : i.format) : (c.generateMipMaps = i,
  15524. c.type = 0,
  15525. c.samplingMode = 3,
  15526. c.format = 5),
  15527. (c.type === 1 && !this._caps.textureFloatLinearFiltering || c.type === 2 && !this._caps.textureHalfFloatLinearFiltering) && (c.samplingMode = 1),
  15528. c.type === 1 && !this._caps.textureFloat && (c.type = 0,
  15529. Logger$2.Warn("Float textures are not supported. Type forced to TEXTURETYPE_UNSIGNED_BYTE"));
  15530. var d = this._gl
  15531. , _ = new InternalTexture(this,s)
  15532. , b = e.width || e
  15533. , k = e.height || e
  15534. , j = e.layers || 0
  15535. , $ = this._getSamplingParameters(c.samplingMode, !!c.generateMipMaps)
  15536. , _e = j !== 0 ? d.TEXTURE_2D_ARRAY : d.TEXTURE_2D
  15537. , et = this._getRGBABufferInternalSizedFormat(c.type, c.format)
  15538. , tt = this._getInternalFormat(c.format)
  15539. , rt = this._getWebGLTextureType(c.type);
  15540. return this._bindTextureDirectly(_e, _),
  15541. j !== 0 ? (_.is2DArray = !0,
  15542. d.texImage3D(_e, 0, et, b, k, j, 0, tt, rt, null)) : d.texImage2D(_e, 0, et, b, k, 0, tt, rt, null),
  15543. d.texParameteri(_e, d.TEXTURE_MAG_FILTER, $.mag),
  15544. d.texParameteri(_e, d.TEXTURE_MIN_FILTER, $.min),
  15545. d.texParameteri(_e, d.TEXTURE_WRAP_S, d.CLAMP_TO_EDGE),
  15546. d.texParameteri(_e, d.TEXTURE_WRAP_T, d.CLAMP_TO_EDGE),
  15547. c.generateMipMaps && this._gl.generateMipmap(_e),
  15548. this._bindTextureDirectly(_e, null),
  15549. _.baseWidth = b,
  15550. _.baseHeight = k,
  15551. _.width = b,
  15552. _.height = k,
  15553. _.depth = j,
  15554. _.isReady = !0,
  15555. _.samples = 1,
  15556. _.generateMipMaps = !!c.generateMipMaps,
  15557. _.samplingMode = c.samplingMode,
  15558. _.type = c.type,
  15559. _.format = c.format,
  15560. this._internalTexturesCache.push(_),
  15561. _
  15562. }
  15563. ,
  15564. a.prototype._getUseSRGBBuffer = function(e, i) {
  15565. return e && this._caps.supportSRGBBuffers && (this.webGLVersion > 1 || this.isWebGPU || i)
  15566. }
  15567. ,
  15568. a.prototype._createTextureBase = function(e, i, o, s, c, d, _, b, k, j, $, _e, et, tt, rt, it) {
  15569. var nt = this;
  15570. c === void 0 && (c = 3),
  15571. d === void 0 && (d = null),
  15572. _ === void 0 && (_ = null),
  15573. j === void 0 && (j = null),
  15574. $ === void 0 && ($ = null),
  15575. _e === void 0 && (_e = null),
  15576. et === void 0 && (et = null),
  15577. e = e || "";
  15578. var ot = e.substr(0, 5) === "data:"
  15579. , at = e.substr(0, 5) === "blob:"
  15580. , st = ot && e.indexOf(";base64,") !== -1
  15581. , ut = $ || new InternalTexture(this,InternalTextureSource.Url)
  15582. , ct = e;
  15583. this._transformTextureUrl && !st && !$ && !j && (e = this._transformTextureUrl(e)),
  15584. ct !== e && (ut._originalUrl = ct);
  15585. var lt = e.lastIndexOf(".")
  15586. , ft = et || (lt > -1 ? e.substring(lt).toLowerCase() : "")
  15587. , ht = null
  15588. , pt = ft.indexOf("?");
  15589. pt > -1 && (ft = ft.split("?")[0]);
  15590. for (var dt = 0, _t = a._TextureLoaders; dt < _t.length; dt++) {
  15591. var mt = _t[dt];
  15592. if (mt.canLoad(ft, tt)) {
  15593. ht = mt;
  15594. break
  15595. }
  15596. }
  15597. s && s._addPendingData(ut),
  15598. ut.url = e,
  15599. ut.generateMipMaps = !i,
  15600. ut.samplingMode = c,
  15601. ut.invertY = o,
  15602. ut._useSRGBBuffer = this._getUseSRGBBuffer(!!it, i),
  15603. this._doNotHandleContextLost || (ut._buffer = j);
  15604. var vt = null;
  15605. d && !$ && (vt = ut.onLoadedObservable.add(d)),
  15606. $ || this._internalTexturesCache.push(ut);
  15607. var yt = function(gt, St) {
  15608. s && s._removePendingData(ut),
  15609. e === ct ? (vt && ut.onLoadedObservable.remove(vt),
  15610. EngineStore.UseFallbackTexture && nt._createTextureBase(EngineStore.FallbackTexture, i, ut.invertY, s, c, null, _, b, k, j, ut),
  15611. gt = (gt || "Unknown error") + (EngineStore.UseFallbackTexture ? " - Fallback texture was used" : ""),
  15612. ut.onErrorObservable.notifyObservers({
  15613. message: gt,
  15614. exception: St
  15615. }),
  15616. _ && _(gt, St)) : (Logger$2.Warn("Failed to load " + e + ", falling back to " + ct),
  15617. nt._createTextureBase(ct, i, ut.invertY, s, c, d, _, b, k, j, ut, _e, et, tt, rt, it))
  15618. };
  15619. if (ht) {
  15620. var Et = function(gt) {
  15621. ht.loadData(gt, ut, function(St, xt, bt, Rt, Mt, Pt) {
  15622. Pt ? yt("TextureLoader failed to load data") : b(ut, ft, s, {
  15623. width: St,
  15624. height: xt
  15625. }, ut.invertY, !bt, Rt, function() {
  15626. return Mt(),
  15627. !1
  15628. }, c)
  15629. }, rt)
  15630. };
  15631. j ? j instanceof ArrayBuffer ? Et(new Uint8Array(j)) : ArrayBuffer.isView(j) ? Et(j) : _ && _("Unable to load: only ArrayBuffer or ArrayBufferView is supported", null) : this._loadFile(e, function(gt) {
  15632. return Et(new Uint8Array(gt))
  15633. }, void 0, s ? s.offlineProvider : void 0, !0, function(gt, St) {
  15634. yt("Unable to load " + (gt && gt.responseURL,
  15635. St))
  15636. })
  15637. } else {
  15638. var At = function(gt) {
  15639. at && !nt._doNotHandleContextLost && (ut._buffer = gt),
  15640. b(ut, ft, s, gt, ut.invertY, i, !1, k, c)
  15641. };
  15642. !ot || st ? j && (typeof j.decoding == "string" || j.close) ? At(j) : a._FileToolsLoadImage(e, At, yt, s ? s.offlineProvider : null, tt, ut.invertY && this._features.needsInvertingBitmap ? {
  15643. imageOrientation: "flipY"
  15644. } : void 0) : typeof j == "string" || j instanceof ArrayBuffer || ArrayBuffer.isView(j) || j instanceof Blob ? a._FileToolsLoadImage(j, At, yt, s ? s.offlineProvider : null, tt, ut.invertY && this._features.needsInvertingBitmap ? {
  15645. imageOrientation: "flipY"
  15646. } : void 0) : j && At(j)
  15647. }
  15648. return ut
  15649. }
  15650. ,
  15651. a.prototype.createTexture = function(e, i, o, s, c, d, _, b, k, j, $, _e, et, tt, rt) {
  15652. var it = this;
  15653. return c === void 0 && (c = 3),
  15654. d === void 0 && (d = null),
  15655. _ === void 0 && (_ = null),
  15656. b === void 0 && (b = null),
  15657. k === void 0 && (k = null),
  15658. j === void 0 && (j = null),
  15659. $ === void 0 && ($ = null),
  15660. this._createTextureBase(e, i, o, s, c, d, _, this._prepareWebGLTexture.bind(this), function(nt, ot, at, st, ut, ct) {
  15661. var lt = it._gl
  15662. , ft = at.width === nt && at.height === ot
  15663. , ht = j ? it._getInternalFormat(j, ut._useSRGBBuffer) : st === ".jpg" && !ut._useSRGBBuffer ? lt.RGB : ut._useSRGBBuffer ? lt.SRGB8_ALPHA8 : lt.RGBA
  15664. , pt = j ? it._getInternalFormat(j) : st === ".jpg" && !ut._useSRGBBuffer ? lt.RGB : lt.RGBA;
  15665. if (ut._useSRGBBuffer && it.webGLVersion === 1 && (pt = ht),
  15666. ft)
  15667. return lt.texImage2D(lt.TEXTURE_2D, 0, ht, pt, lt.UNSIGNED_BYTE, at),
  15668. !1;
  15669. var dt = it._caps.maxTextureSize;
  15670. if (at.width > dt || at.height > dt || !it._supportsHardwareTextureRescaling)
  15671. return it._prepareWorkingCanvas(),
  15672. !it._workingCanvas || !it._workingContext || (it._workingCanvas.width = nt,
  15673. it._workingCanvas.height = ot,
  15674. it._workingContext.drawImage(at, 0, 0, at.width, at.height, 0, 0, nt, ot),
  15675. lt.texImage2D(lt.TEXTURE_2D, 0, ht, pt, lt.UNSIGNED_BYTE, it._workingCanvas),
  15676. ut.width = nt,
  15677. ut.height = ot),
  15678. !1;
  15679. var _t = new InternalTexture(it,InternalTextureSource.Temp);
  15680. return it._bindTextureDirectly(lt.TEXTURE_2D, _t, !0),
  15681. lt.texImage2D(lt.TEXTURE_2D, 0, ht, pt, lt.UNSIGNED_BYTE, at),
  15682. it._rescaleTexture(_t, ut, s, ht, function() {
  15683. it._releaseTexture(_t),
  15684. it._bindTextureDirectly(lt.TEXTURE_2D, ut, !0),
  15685. ct()
  15686. }),
  15687. !0
  15688. }, b, k, j, $, _e, et, rt)
  15689. }
  15690. ,
  15691. a._FileToolsLoadImage = function(e, i, o, s, c, d) {
  15692. throw _WarnImport("FileTools")
  15693. }
  15694. ,
  15695. a.prototype._rescaleTexture = function(e, i, o, s, c) {}
  15696. ,
  15697. a.prototype.createRawTexture = function(e, i, o, s, c, d, _, b, k) {
  15698. throw _WarnImport("Engine.RawTexture")
  15699. }
  15700. ,
  15701. a.prototype.createRawCubeTexture = function(e, i, o, s, c, d, _, b) {
  15702. throw _WarnImport("Engine.RawTexture")
  15703. }
  15704. ,
  15705. a.prototype.createRawTexture3D = function(e, i, o, s, c, d, _, b, k, j) {
  15706. throw _WarnImport("Engine.RawTexture")
  15707. }
  15708. ,
  15709. a.prototype.createRawTexture2DArray = function(e, i, o, s, c, d, _, b, k, j) {
  15710. throw _WarnImport("Engine.RawTexture")
  15711. }
  15712. ,
  15713. a.prototype._unpackFlipY = function(e) {
  15714. this._unpackFlipYCached !== e && (this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL, e ? 1 : 0),
  15715. this.enableUnpackFlipYCached && (this._unpackFlipYCached = e))
  15716. }
  15717. ,
  15718. a.prototype._getUnpackAlignement = function() {
  15719. return this._gl.getParameter(this._gl.UNPACK_ALIGNMENT)
  15720. }
  15721. ,
  15722. a.prototype._getTextureTarget = function(e) {
  15723. return e.isCube ? this._gl.TEXTURE_CUBE_MAP : e.is3D ? this._gl.TEXTURE_3D : e.is2DArray || e.isMultiview ? this._gl.TEXTURE_2D_ARRAY : this._gl.TEXTURE_2D
  15724. }
  15725. ,
  15726. a.prototype.updateTextureSamplingMode = function(e, i, o) {
  15727. o === void 0 && (o = !1);
  15728. var s = this._getTextureTarget(i)
  15729. , c = this._getSamplingParameters(e, i.generateMipMaps || o);
  15730. this._setTextureParameterInteger(s, this._gl.TEXTURE_MAG_FILTER, c.mag, i),
  15731. this._setTextureParameterInteger(s, this._gl.TEXTURE_MIN_FILTER, c.min),
  15732. o && (i.generateMipMaps = !0,
  15733. this._gl.generateMipmap(s)),
  15734. this._bindTextureDirectly(s, null),
  15735. i.samplingMode = e
  15736. }
  15737. ,
  15738. a.prototype.updateTextureDimensions = function(e, i, o, s) {}
  15739. ,
  15740. a.prototype.updateTextureWrappingMode = function(e, i, o, s) {
  15741. o === void 0 && (o = null),
  15742. s === void 0 && (s = null);
  15743. var c = this._getTextureTarget(e);
  15744. i !== null && (this._setTextureParameterInteger(c, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(i), e),
  15745. e._cachedWrapU = i),
  15746. o !== null && (this._setTextureParameterInteger(c, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(o), e),
  15747. e._cachedWrapV = o),
  15748. (e.is2DArray || e.is3D) && s !== null && (this._setTextureParameterInteger(c, this._gl.TEXTURE_WRAP_R, this._getTextureWrapMode(s), e),
  15749. e._cachedWrapR = s),
  15750. this._bindTextureDirectly(c, null)
  15751. }
  15752. ,
  15753. a.prototype._setupDepthStencilTexture = function(e, i, o, s, c, d) {
  15754. d === void 0 && (d = 1);
  15755. var _ = i.width || i
  15756. , b = i.height || i
  15757. , k = i.layers || 0;
  15758. e.baseWidth = _,
  15759. e.baseHeight = b,
  15760. e.width = _,
  15761. e.height = b,
  15762. e.is2DArray = k > 0,
  15763. e.depth = k,
  15764. e.isReady = !0,
  15765. e.samples = d,
  15766. e.generateMipMaps = !1,
  15767. e.samplingMode = s ? 2 : 1,
  15768. e.type = 0,
  15769. e._comparisonFunction = c;
  15770. var j = this._gl
  15771. , $ = this._getTextureTarget(e)
  15772. , _e = this._getSamplingParameters(e.samplingMode, !1);
  15773. j.texParameteri($, j.TEXTURE_MAG_FILTER, _e.mag),
  15774. j.texParameteri($, j.TEXTURE_MIN_FILTER, _e.min),
  15775. j.texParameteri($, j.TEXTURE_WRAP_S, j.CLAMP_TO_EDGE),
  15776. j.texParameteri($, j.TEXTURE_WRAP_T, j.CLAMP_TO_EDGE),
  15777. c === 0 ? (j.texParameteri($, j.TEXTURE_COMPARE_FUNC, 515),
  15778. j.texParameteri($, j.TEXTURE_COMPARE_MODE, j.NONE)) : (j.texParameteri($, j.TEXTURE_COMPARE_FUNC, c),
  15779. j.texParameteri($, j.TEXTURE_COMPARE_MODE, j.COMPARE_REF_TO_TEXTURE))
  15780. }
  15781. ,
  15782. a.prototype._uploadCompressedDataToTextureDirectly = function(e, i, o, s, c, d, _) {
  15783. d === void 0 && (d = 0),
  15784. _ === void 0 && (_ = 0);
  15785. var b = this._gl
  15786. , k = b.TEXTURE_2D;
  15787. if (e.isCube && (k = b.TEXTURE_CUBE_MAP_POSITIVE_X + d),
  15788. e._useSRGBBuffer)
  15789. switch (i) {
  15790. case 36492:
  15791. i = b.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT;
  15792. break;
  15793. case 37808:
  15794. i = b.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR;
  15795. break;
  15796. case 33776:
  15797. this._caps.s3tc_srgb ? i = b.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT : e._useSRGBBuffer = !1;
  15798. break;
  15799. case 33779:
  15800. this._caps.s3tc_srgb ? i = b.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT : e._useSRGBBuffer = !1;
  15801. break;
  15802. default:
  15803. e._useSRGBBuffer = !1;
  15804. break
  15805. }
  15806. this._gl.compressedTexImage2D(k, _, i, o, s, 0, c)
  15807. }
  15808. ,
  15809. a.prototype._uploadDataToTextureDirectly = function(e, i, o, s, c, d) {
  15810. o === void 0 && (o = 0),
  15811. s === void 0 && (s = 0),
  15812. d === void 0 && (d = !1);
  15813. var _ = this._gl
  15814. , b = this._getWebGLTextureType(e.type)
  15815. , k = this._getInternalFormat(e.format)
  15816. , j = c === void 0 ? this._getRGBABufferInternalSizedFormat(e.type, e.format, e._useSRGBBuffer) : this._getInternalFormat(c, e._useSRGBBuffer);
  15817. this._unpackFlipY(e.invertY);
  15818. var $ = _.TEXTURE_2D;
  15819. e.isCube && ($ = _.TEXTURE_CUBE_MAP_POSITIVE_X + o);
  15820. var _e = Math.round(Math.log(e.width) * Math.LOG2E)
  15821. , et = Math.round(Math.log(e.height) * Math.LOG2E)
  15822. , tt = d ? e.width : Math.pow(2, Math.max(_e - s, 0))
  15823. , rt = d ? e.height : Math.pow(2, Math.max(et - s, 0));
  15824. _.texImage2D($, s, j, tt, rt, 0, k, b, i)
  15825. }
  15826. ,
  15827. a.prototype.updateTextureData = function(e, i, o, s, c, d, _, b) {
  15828. _ === void 0 && (_ = 0),
  15829. b === void 0 && (b = 0);
  15830. var k = this._gl
  15831. , j = this._getWebGLTextureType(e.type)
  15832. , $ = this._getInternalFormat(e.format);
  15833. this._unpackFlipY(e.invertY);
  15834. var _e = k.TEXTURE_2D;
  15835. e.isCube && (_e = k.TEXTURE_CUBE_MAP_POSITIVE_X + _),
  15836. k.texSubImage2D(_e, b, o, s, c, d, $, j, i)
  15837. }
  15838. ,
  15839. a.prototype._uploadArrayBufferViewToTexture = function(e, i, o, s) {
  15840. o === void 0 && (o = 0),
  15841. s === void 0 && (s = 0);
  15842. var c = this._gl
  15843. , d = e.isCube ? c.TEXTURE_CUBE_MAP : c.TEXTURE_2D;
  15844. this._bindTextureDirectly(d, e, !0),
  15845. this._uploadDataToTextureDirectly(e, i, o, s),
  15846. this._bindTextureDirectly(d, null, !0)
  15847. }
  15848. ,
  15849. a.prototype._prepareWebGLTextureContinuation = function(e, i, o, s, c) {
  15850. var d = this._gl;
  15851. if (!!d) {
  15852. var _ = this._getSamplingParameters(c, !o);
  15853. d.texParameteri(d.TEXTURE_2D, d.TEXTURE_MAG_FILTER, _.mag),
  15854. d.texParameteri(d.TEXTURE_2D, d.TEXTURE_MIN_FILTER, _.min),
  15855. !o && !s && d.generateMipmap(d.TEXTURE_2D),
  15856. this._bindTextureDirectly(d.TEXTURE_2D, null),
  15857. i && i._removePendingData(e),
  15858. e.onLoadedObservable.notifyObservers(e),
  15859. e.onLoadedObservable.clear()
  15860. }
  15861. }
  15862. ,
  15863. a.prototype._prepareWebGLTexture = function(e, i, o, s, c, d, _, b, k) {
  15864. var j = this;
  15865. k === void 0 && (k = 3);
  15866. var $ = this.getCaps().maxTextureSize
  15867. , _e = Math.min($, this.needPOTTextures ? a.GetExponentOfTwo(s.width, $) : s.width)
  15868. , et = Math.min($, this.needPOTTextures ? a.GetExponentOfTwo(s.height, $) : s.height)
  15869. , tt = this._gl;
  15870. if (!!tt) {
  15871. if (!e._hardwareTexture) {
  15872. o && o._removePendingData(e);
  15873. return
  15874. }
  15875. this._bindTextureDirectly(tt.TEXTURE_2D, e, !0),
  15876. this._unpackFlipY(c === void 0 ? !0 : !!c),
  15877. e.baseWidth = s.width,
  15878. e.baseHeight = s.height,
  15879. e.width = _e,
  15880. e.height = et,
  15881. e.isReady = !0,
  15882. !b(_e, et, s, i, e, function() {
  15883. j._prepareWebGLTextureContinuation(e, o, d, _, k)
  15884. }) && this._prepareWebGLTextureContinuation(e, o, d, _, k)
  15885. }
  15886. }
  15887. ,
  15888. a.prototype._setupFramebufferDepthAttachments = function(e, i, o, s, c) {
  15889. c === void 0 && (c = 1);
  15890. var d = this._gl;
  15891. if (e && i)
  15892. return this._createRenderBuffer(o, s, c, d.DEPTH_STENCIL, d.DEPTH24_STENCIL8, d.DEPTH_STENCIL_ATTACHMENT);
  15893. if (i) {
  15894. var _ = d.DEPTH_COMPONENT16;
  15895. return this._webGLVersion > 1 && (_ = d.DEPTH_COMPONENT32F),
  15896. this._createRenderBuffer(o, s, c, _, _, d.DEPTH_ATTACHMENT)
  15897. }
  15898. return e ? this._createRenderBuffer(o, s, c, d.STENCIL_INDEX8, d.STENCIL_INDEX8, d.STENCIL_ATTACHMENT) : null
  15899. }
  15900. ,
  15901. a.prototype._createRenderBuffer = function(e, i, o, s, c, d, _) {
  15902. _ === void 0 && (_ = !0);
  15903. var b = this._gl
  15904. , k = b.createRenderbuffer();
  15905. return b.bindRenderbuffer(b.RENDERBUFFER, k),
  15906. o > 1 && b.renderbufferStorageMultisample ? b.renderbufferStorageMultisample(b.RENDERBUFFER, o, c, e, i) : b.renderbufferStorage(b.RENDERBUFFER, s, e, i),
  15907. b.framebufferRenderbuffer(b.FRAMEBUFFER, d, b.RENDERBUFFER, k),
  15908. _ && b.bindRenderbuffer(b.RENDERBUFFER, null),
  15909. k
  15910. }
  15911. ,
  15912. a.prototype._releaseTexture = function(e) {
  15913. var i;
  15914. this._deleteTexture((i = e._hardwareTexture) === null || i === void 0 ? void 0 : i.underlyingResource),
  15915. this.unbindAllTextures();
  15916. var o = this._internalTexturesCache.indexOf(e);
  15917. o !== -1 && this._internalTexturesCache.splice(o, 1),
  15918. e._lodTextureHigh && e._lodTextureHigh.dispose(),
  15919. e._lodTextureMid && e._lodTextureMid.dispose(),
  15920. e._lodTextureLow && e._lodTextureLow.dispose(),
  15921. e._irradianceTexture && e._irradianceTexture.dispose()
  15922. }
  15923. ,
  15924. a.prototype._releaseRenderTargetWrapper = function(e) {
  15925. var i = this._renderTargetWrapperCache.indexOf(e);
  15926. i !== -1 && this._renderTargetWrapperCache.splice(i, 1)
  15927. }
  15928. ,
  15929. a.prototype._deleteTexture = function(e) {
  15930. e && this._gl.deleteTexture(e)
  15931. }
  15932. ,
  15933. a.prototype._setProgram = function(e) {
  15934. this._currentProgram !== e && (this._gl.useProgram(e),
  15935. this._currentProgram = e)
  15936. }
  15937. ,
  15938. a.prototype.bindSamplers = function(e) {
  15939. var i = e.getPipelineContext();
  15940. this._setProgram(i.program);
  15941. for (var o = e.getSamplers(), s = 0; s < o.length; s++) {
  15942. var c = e.getUniform(o[s]);
  15943. c && (this._boundUniforms[s] = c)
  15944. }
  15945. this._currentEffect = null
  15946. }
  15947. ,
  15948. a.prototype._activateCurrentTexture = function() {
  15949. this._currentTextureChannel !== this._activeChannel && (this._gl.activeTexture(this._gl.TEXTURE0 + this._activeChannel),
  15950. this._currentTextureChannel = this._activeChannel)
  15951. }
  15952. ,
  15953. a.prototype._bindTextureDirectly = function(e, i, o, s) {
  15954. var c, d;
  15955. o === void 0 && (o = !1),
  15956. s === void 0 && (s = !1);
  15957. var _ = !1
  15958. , b = i && i._associatedChannel > -1;
  15959. o && b && (this._activeChannel = i._associatedChannel);
  15960. var k = this._boundTexturesCache[this._activeChannel];
  15961. if (k !== i || s) {
  15962. if (this._activateCurrentTexture(),
  15963. i && i.isMultiview)
  15964. throw console.error(e, i),
  15965. "_bindTextureDirectly called with a multiview texture!";
  15966. this._gl.bindTexture(e, (d = (c = i == null ? void 0 : i._hardwareTexture) === null || c === void 0 ? void 0 : c.underlyingResource) !== null && d !== void 0 ? d : null),
  15967. this._boundTexturesCache[this._activeChannel] = i,
  15968. i && (i._associatedChannel = this._activeChannel)
  15969. } else
  15970. o && (_ = !0,
  15971. this._activateCurrentTexture());
  15972. return b && !o && this._bindSamplerUniformToChannel(i._associatedChannel, this._activeChannel),
  15973. _
  15974. }
  15975. ,
  15976. a.prototype._bindTexture = function(e, i, o) {
  15977. if (e !== void 0) {
  15978. i && (i._associatedChannel = e),
  15979. this._activeChannel = e;
  15980. var s = i ? this._getTextureTarget(i) : this._gl.TEXTURE_2D;
  15981. this._bindTextureDirectly(s, i)
  15982. }
  15983. }
  15984. ,
  15985. a.prototype.unbindAllTextures = function() {
  15986. for (var e = 0; e < this._maxSimultaneousTextures; e++)
  15987. this._activeChannel = e,
  15988. this._bindTextureDirectly(this._gl.TEXTURE_2D, null),
  15989. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null),
  15990. this.webGLVersion > 1 && (this._bindTextureDirectly(this._gl.TEXTURE_3D, null),
  15991. this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY, null))
  15992. }
  15993. ,
  15994. a.prototype.setTexture = function(e, i, o, s) {
  15995. e !== void 0 && (i && (this._boundUniforms[e] = i),
  15996. this._setTexture(e, o))
  15997. }
  15998. ,
  15999. a.prototype._bindSamplerUniformToChannel = function(e, i) {
  16000. var o = this._boundUniforms[e];
  16001. !o || o._currentState === i || (this._gl.uniform1i(o, i),
  16002. o._currentState = i)
  16003. }
  16004. ,
  16005. a.prototype._getTextureWrapMode = function(e) {
  16006. switch (e) {
  16007. case 1:
  16008. return this._gl.REPEAT;
  16009. case 0:
  16010. return this._gl.CLAMP_TO_EDGE;
  16011. case 2:
  16012. return this._gl.MIRRORED_REPEAT
  16013. }
  16014. return this._gl.REPEAT
  16015. }
  16016. ,
  16017. a.prototype._setTexture = function(e, i, o, s, c) {
  16018. if (o === void 0 && (o = !1),
  16019. s === void 0 && (s = !1),
  16020. !i)
  16021. return this._boundTexturesCache[e] != null && (this._activeChannel = e,
  16022. this._bindTextureDirectly(this._gl.TEXTURE_2D, null),
  16023. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null),
  16024. this.webGLVersion > 1 && (this._bindTextureDirectly(this._gl.TEXTURE_3D, null),
  16025. this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY, null))),
  16026. !1;
  16027. if (i.video)
  16028. this._activeChannel = e,
  16029. i.update();
  16030. else if (i.delayLoadState === 4)
  16031. return i.delayLoad(),
  16032. !1;
  16033. var d;
  16034. s ? d = i.depthStencilTexture : i.isReady() ? d = i.getInternalTexture() : i.isCube ? d = this.emptyCubeTexture : i.is3D ? d = this.emptyTexture3D : i.is2DArray ? d = this.emptyTexture2DArray : d = this.emptyTexture,
  16035. !o && d && (d._associatedChannel = e);
  16036. var _ = !0;
  16037. this._boundTexturesCache[e] === d && (o || this._bindSamplerUniformToChannel(d._associatedChannel, e),
  16038. _ = !1),
  16039. this._activeChannel = e;
  16040. var b = this._getTextureTarget(d);
  16041. if (_ && this._bindTextureDirectly(b, d, o),
  16042. d && !d.isMultiview) {
  16043. if (d.isCube && d._cachedCoordinatesMode !== i.coordinatesMode) {
  16044. d._cachedCoordinatesMode = i.coordinatesMode;
  16045. var k = i.coordinatesMode !== 3 && i.coordinatesMode !== 5 ? 1 : 0;
  16046. i.wrapU = k,
  16047. i.wrapV = k
  16048. }
  16049. d._cachedWrapU !== i.wrapU && (d._cachedWrapU = i.wrapU,
  16050. this._setTextureParameterInteger(b, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(i.wrapU), d)),
  16051. d._cachedWrapV !== i.wrapV && (d._cachedWrapV = i.wrapV,
  16052. this._setTextureParameterInteger(b, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(i.wrapV), d)),
  16053. d.is3D && d._cachedWrapR !== i.wrapR && (d._cachedWrapR = i.wrapR,
  16054. this._setTextureParameterInteger(b, this._gl.TEXTURE_WRAP_R, this._getTextureWrapMode(i.wrapR), d)),
  16055. this._setAnisotropicLevel(b, d, i.anisotropicFilteringLevel)
  16056. }
  16057. return !0
  16058. }
  16059. ,
  16060. a.prototype.setTextureArray = function(e, i, o, s) {
  16061. if (!(e === void 0 || !i)) {
  16062. (!this._textureUnits || this._textureUnits.length !== o.length) && (this._textureUnits = new Int32Array(o.length));
  16063. for (var c = 0; c < o.length; c++) {
  16064. var d = o[c].getInternalTexture();
  16065. d ? (this._textureUnits[c] = e + c,
  16066. d._associatedChannel = e + c) : this._textureUnits[c] = -1
  16067. }
  16068. this._gl.uniform1iv(i, this._textureUnits);
  16069. for (var _ = 0; _ < o.length; _++)
  16070. this._setTexture(this._textureUnits[_], o[_], !0)
  16071. }
  16072. }
  16073. ,
  16074. a.prototype._setAnisotropicLevel = function(e, i, o) {
  16075. var s = this._caps.textureAnisotropicFilterExtension;
  16076. i.samplingMode !== 11 && i.samplingMode !== 3 && i.samplingMode !== 2 && (o = 1),
  16077. s && i._cachedAnisotropicFilteringLevel !== o && (this._setTextureParameterFloat(e, s.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(o, this._caps.maxAnisotropy), i),
  16078. i._cachedAnisotropicFilteringLevel = o)
  16079. }
  16080. ,
  16081. a.prototype._setTextureParameterFloat = function(e, i, o, s) {
  16082. this._bindTextureDirectly(e, s, !0, !0),
  16083. this._gl.texParameterf(e, i, o)
  16084. }
  16085. ,
  16086. a.prototype._setTextureParameterInteger = function(e, i, o, s) {
  16087. s && this._bindTextureDirectly(e, s, !0, !0),
  16088. this._gl.texParameteri(e, i, o)
  16089. }
  16090. ,
  16091. a.prototype.unbindAllAttributes = function() {
  16092. if (this._mustWipeVertexAttributes) {
  16093. this._mustWipeVertexAttributes = !1;
  16094. for (var e = 0; e < this._caps.maxVertexAttribs; e++)
  16095. this.disableAttributeByIndex(e);
  16096. return
  16097. }
  16098. for (var e = 0, i = this._vertexAttribArraysEnabled.length; e < i; e++)
  16099. e >= this._caps.maxVertexAttribs || !this._vertexAttribArraysEnabled[e] || this.disableAttributeByIndex(e)
  16100. }
  16101. ,
  16102. a.prototype.releaseEffects = function() {
  16103. for (var e in this._compiledEffects) {
  16104. var i = this._compiledEffects[e].getPipelineContext();
  16105. this._deletePipelineContext(i)
  16106. }
  16107. this._compiledEffects = {}
  16108. }
  16109. ,
  16110. a.prototype.dispose = function() {
  16111. var e;
  16112. this.stopRenderLoop(),
  16113. this.onBeforeTextureInitObservable && this.onBeforeTextureInitObservable.clear(),
  16114. this._emptyTexture && (this._releaseTexture(this._emptyTexture),
  16115. this._emptyTexture = null),
  16116. this._emptyCubeTexture && (this._releaseTexture(this._emptyCubeTexture),
  16117. this._emptyCubeTexture = null),
  16118. this._dummyFramebuffer && this._gl.deleteFramebuffer(this._dummyFramebuffer),
  16119. this.releaseEffects(),
  16120. (e = this.releaseComputeEffects) === null || e === void 0 || e.call(this),
  16121. this.unbindAllAttributes(),
  16122. this._boundUniforms = [],
  16123. IsWindowObjectExist() && this._renderingCanvas && (this._doNotHandleContextLost || (this._renderingCanvas.removeEventListener("webglcontextlost", this._onContextLost),
  16124. this._renderingCanvas.removeEventListener("webglcontextrestored", this._onContextRestored)),
  16125. window.removeEventListener("resize", this._checkForMobile)),
  16126. this._workingCanvas = null,
  16127. this._workingContext = null,
  16128. this._currentBufferPointers = [],
  16129. this._renderingCanvas = null,
  16130. this._currentProgram = null,
  16131. this._boundRenderFunction = null,
  16132. Effect.ResetCache();
  16133. for (var i = 0, o = this._activeRequests; i < o.length; i++) {
  16134. var s = o[i];
  16135. s.abort()
  16136. }
  16137. this.onDisposeObservable.notifyObservers(this),
  16138. this.onDisposeObservable.clear()
  16139. }
  16140. ,
  16141. a.prototype.attachContextLostEvent = function(e) {
  16142. this._renderingCanvas && this._renderingCanvas.addEventListener("webglcontextlost", e, !1)
  16143. }
  16144. ,
  16145. a.prototype.attachContextRestoredEvent = function(e) {
  16146. this._renderingCanvas && this._renderingCanvas.addEventListener("webglcontextrestored", e, !1)
  16147. }
  16148. ,
  16149. a.prototype.getError = function() {
  16150. return this._gl.getError()
  16151. }
  16152. ,
  16153. a.prototype._canRenderToFloatFramebuffer = function() {
  16154. return this._webGLVersion > 1 ? this._caps.colorBufferFloat : this._canRenderToFramebuffer(1)
  16155. }
  16156. ,
  16157. a.prototype._canRenderToHalfFloatFramebuffer = function() {
  16158. return this._webGLVersion > 1 ? this._caps.colorBufferFloat : this._canRenderToFramebuffer(2)
  16159. }
  16160. ,
  16161. a.prototype._canRenderToFramebuffer = function(e) {
  16162. for (var i = this._gl; i.getError() !== i.NO_ERROR; )
  16163. ;
  16164. var o = !0
  16165. , s = i.createTexture();
  16166. i.bindTexture(i.TEXTURE_2D, s),
  16167. i.texImage2D(i.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(e), 1, 1, 0, i.RGBA, this._getWebGLTextureType(e), null),
  16168. i.texParameteri(i.TEXTURE_2D, i.TEXTURE_MIN_FILTER, i.NEAREST),
  16169. i.texParameteri(i.TEXTURE_2D, i.TEXTURE_MAG_FILTER, i.NEAREST);
  16170. var c = i.createFramebuffer();
  16171. i.bindFramebuffer(i.FRAMEBUFFER, c),
  16172. i.framebufferTexture2D(i.FRAMEBUFFER, i.COLOR_ATTACHMENT0, i.TEXTURE_2D, s, 0);
  16173. var d = i.checkFramebufferStatus(i.FRAMEBUFFER);
  16174. if (o = o && d === i.FRAMEBUFFER_COMPLETE,
  16175. o = o && i.getError() === i.NO_ERROR,
  16176. o && (i.clear(i.COLOR_BUFFER_BIT),
  16177. o = o && i.getError() === i.NO_ERROR),
  16178. o) {
  16179. i.bindFramebuffer(i.FRAMEBUFFER, null);
  16180. var _ = i.RGBA
  16181. , b = i.UNSIGNED_BYTE
  16182. , k = new Uint8Array(4);
  16183. i.readPixels(0, 0, 1, 1, _, b, k),
  16184. o = o && i.getError() === i.NO_ERROR
  16185. }
  16186. for (i.deleteTexture(s),
  16187. i.deleteFramebuffer(c),
  16188. i.bindFramebuffer(i.FRAMEBUFFER, null); !o && i.getError() !== i.NO_ERROR; )
  16189. ;
  16190. return o
  16191. }
  16192. ,
  16193. a.prototype._getWebGLTextureType = function(e) {
  16194. if (this._webGLVersion === 1) {
  16195. switch (e) {
  16196. case 1:
  16197. return this._gl.FLOAT;
  16198. case 2:
  16199. return this._gl.HALF_FLOAT_OES;
  16200. case 0:
  16201. return this._gl.UNSIGNED_BYTE;
  16202. case 8:
  16203. return this._gl.UNSIGNED_SHORT_4_4_4_4;
  16204. case 9:
  16205. return this._gl.UNSIGNED_SHORT_5_5_5_1;
  16206. case 10:
  16207. return this._gl.UNSIGNED_SHORT_5_6_5
  16208. }
  16209. return this._gl.UNSIGNED_BYTE
  16210. }
  16211. switch (e) {
  16212. case 3:
  16213. return this._gl.BYTE;
  16214. case 0:
  16215. return this._gl.UNSIGNED_BYTE;
  16216. case 4:
  16217. return this._gl.SHORT;
  16218. case 5:
  16219. return this._gl.UNSIGNED_SHORT;
  16220. case 6:
  16221. return this._gl.INT;
  16222. case 7:
  16223. return this._gl.UNSIGNED_INT;
  16224. case 1:
  16225. return this._gl.FLOAT;
  16226. case 2:
  16227. return this._gl.HALF_FLOAT;
  16228. case 8:
  16229. return this._gl.UNSIGNED_SHORT_4_4_4_4;
  16230. case 9:
  16231. return this._gl.UNSIGNED_SHORT_5_5_5_1;
  16232. case 10:
  16233. return this._gl.UNSIGNED_SHORT_5_6_5;
  16234. case 11:
  16235. return this._gl.UNSIGNED_INT_2_10_10_10_REV;
  16236. case 12:
  16237. return this._gl.UNSIGNED_INT_24_8;
  16238. case 13:
  16239. return this._gl.UNSIGNED_INT_10F_11F_11F_REV;
  16240. case 14:
  16241. return this._gl.UNSIGNED_INT_5_9_9_9_REV;
  16242. case 15:
  16243. return this._gl.FLOAT_32_UNSIGNED_INT_24_8_REV
  16244. }
  16245. return this._gl.UNSIGNED_BYTE
  16246. }
  16247. ,
  16248. a.prototype._getInternalFormat = function(e, i) {
  16249. i === void 0 && (i = !1);
  16250. var o = i ? this._gl.SRGB8_ALPHA8 : this._gl.RGBA;
  16251. switch (e) {
  16252. case 0:
  16253. o = this._gl.ALPHA;
  16254. break;
  16255. case 1:
  16256. o = this._gl.LUMINANCE;
  16257. break;
  16258. case 2:
  16259. o = this._gl.LUMINANCE_ALPHA;
  16260. break;
  16261. case 6:
  16262. o = this._gl.RED;
  16263. break;
  16264. case 7:
  16265. o = this._gl.RG;
  16266. break;
  16267. case 4:
  16268. o = i ? this._gl.SRGB : this._gl.RGB;
  16269. break;
  16270. case 5:
  16271. o = i ? this._gl.SRGB8_ALPHA8 : this._gl.RGBA;
  16272. break
  16273. }
  16274. if (this._webGLVersion > 1)
  16275. switch (e) {
  16276. case 8:
  16277. o = this._gl.RED_INTEGER;
  16278. break;
  16279. case 9:
  16280. o = this._gl.RG_INTEGER;
  16281. break;
  16282. case 10:
  16283. o = this._gl.RGB_INTEGER;
  16284. break;
  16285. case 11:
  16286. o = this._gl.RGBA_INTEGER;
  16287. break
  16288. }
  16289. return o
  16290. }
  16291. ,
  16292. a.prototype._getRGBABufferInternalSizedFormat = function(e, i, o) {
  16293. if (o === void 0 && (o = !1),
  16294. this._webGLVersion === 1) {
  16295. if (i !== void 0)
  16296. switch (i) {
  16297. case 0:
  16298. return this._gl.ALPHA;
  16299. case 1:
  16300. return this._gl.LUMINANCE;
  16301. case 2:
  16302. return this._gl.LUMINANCE_ALPHA;
  16303. case 4:
  16304. return o ? this._gl.SRGB : this._gl.RGB
  16305. }
  16306. return this._gl.RGBA
  16307. }
  16308. switch (e) {
  16309. case 3:
  16310. switch (i) {
  16311. case 6:
  16312. return this._gl.R8_SNORM;
  16313. case 7:
  16314. return this._gl.RG8_SNORM;
  16315. case 4:
  16316. return this._gl.RGB8_SNORM;
  16317. case 8:
  16318. return this._gl.R8I;
  16319. case 9:
  16320. return this._gl.RG8I;
  16321. case 10:
  16322. return this._gl.RGB8I;
  16323. case 11:
  16324. return this._gl.RGBA8I;
  16325. default:
  16326. return this._gl.RGBA8_SNORM
  16327. }
  16328. case 0:
  16329. switch (i) {
  16330. case 6:
  16331. return this._gl.R8;
  16332. case 7:
  16333. return this._gl.RG8;
  16334. case 4:
  16335. return o ? this._gl.SRGB8 : this._gl.RGB8;
  16336. case 5:
  16337. return o ? this._gl.SRGB8_ALPHA8 : this._gl.RGBA8;
  16338. case 8:
  16339. return this._gl.R8UI;
  16340. case 9:
  16341. return this._gl.RG8UI;
  16342. case 10:
  16343. return this._gl.RGB8UI;
  16344. case 11:
  16345. return this._gl.RGBA8UI;
  16346. case 0:
  16347. return this._gl.ALPHA;
  16348. case 1:
  16349. return this._gl.LUMINANCE;
  16350. case 2:
  16351. return this._gl.LUMINANCE_ALPHA;
  16352. default:
  16353. return this._gl.RGBA8
  16354. }
  16355. case 4:
  16356. switch (i) {
  16357. case 8:
  16358. return this._gl.R16I;
  16359. case 9:
  16360. return this._gl.RG16I;
  16361. case 10:
  16362. return this._gl.RGB16I;
  16363. case 11:
  16364. return this._gl.RGBA16I;
  16365. default:
  16366. return this._gl.RGBA16I
  16367. }
  16368. case 5:
  16369. switch (i) {
  16370. case 8:
  16371. return this._gl.R16UI;
  16372. case 9:
  16373. return this._gl.RG16UI;
  16374. case 10:
  16375. return this._gl.RGB16UI;
  16376. case 11:
  16377. return this._gl.RGBA16UI;
  16378. default:
  16379. return this._gl.RGBA16UI
  16380. }
  16381. case 6:
  16382. switch (i) {
  16383. case 8:
  16384. return this._gl.R32I;
  16385. case 9:
  16386. return this._gl.RG32I;
  16387. case 10:
  16388. return this._gl.RGB32I;
  16389. case 11:
  16390. return this._gl.RGBA32I;
  16391. default:
  16392. return this._gl.RGBA32I
  16393. }
  16394. case 7:
  16395. switch (i) {
  16396. case 8:
  16397. return this._gl.R32UI;
  16398. case 9:
  16399. return this._gl.RG32UI;
  16400. case 10:
  16401. return this._gl.RGB32UI;
  16402. case 11:
  16403. return this._gl.RGBA32UI;
  16404. default:
  16405. return this._gl.RGBA32UI
  16406. }
  16407. case 1:
  16408. switch (i) {
  16409. case 6:
  16410. return this._gl.R32F;
  16411. case 7:
  16412. return this._gl.RG32F;
  16413. case 4:
  16414. return this._gl.RGB32F;
  16415. case 5:
  16416. return this._gl.RGBA32F;
  16417. default:
  16418. return this._gl.RGBA32F
  16419. }
  16420. case 2:
  16421. switch (i) {
  16422. case 6:
  16423. return this._gl.R16F;
  16424. case 7:
  16425. return this._gl.RG16F;
  16426. case 4:
  16427. return this._gl.RGB16F;
  16428. case 5:
  16429. return this._gl.RGBA16F;
  16430. default:
  16431. return this._gl.RGBA16F
  16432. }
  16433. case 10:
  16434. return this._gl.RGB565;
  16435. case 13:
  16436. return this._gl.R11F_G11F_B10F;
  16437. case 14:
  16438. return this._gl.RGB9_E5;
  16439. case 8:
  16440. return this._gl.RGBA4;
  16441. case 9:
  16442. return this._gl.RGB5_A1;
  16443. case 11:
  16444. switch (i) {
  16445. case 5:
  16446. return this._gl.RGB10_A2;
  16447. case 11:
  16448. return this._gl.RGB10_A2UI;
  16449. default:
  16450. return this._gl.RGB10_A2
  16451. }
  16452. }
  16453. return o ? this._gl.SRGB8_ALPHA8 : this._gl.RGBA8
  16454. }
  16455. ,
  16456. a.prototype._getRGBAMultiSampleBufferFormat = function(e) {
  16457. return e === 1 ? this._gl.RGBA32F : e === 2 ? this._gl.RGBA16F : this._gl.RGBA8
  16458. }
  16459. ,
  16460. a.prototype._loadFile = function(e, i, o, s, c, d) {
  16461. var _ = this
  16462. , b = a._FileToolsLoadFile(e, i, o, s, c, d);
  16463. return this._activeRequests.push(b),
  16464. b.onCompleteObservable.add(function(k) {
  16465. _._activeRequests.splice(_._activeRequests.indexOf(k), 1)
  16466. }),
  16467. b
  16468. }
  16469. ,
  16470. a._FileToolsLoadFile = function(e, i, o, s, c, d) {
  16471. throw _WarnImport("FileTools")
  16472. }
  16473. ,
  16474. a.prototype.readPixels = function(e, i, o, s, c, d) {
  16475. c === void 0 && (c = !0),
  16476. d === void 0 && (d = !0);
  16477. var _ = c ? 4 : 3
  16478. , b = c ? this._gl.RGBA : this._gl.RGB
  16479. , k = new Uint8Array(s * o * _);
  16480. return d && this.flushFramebuffer(),
  16481. this._gl.readPixels(e, i, o, s, b, this._gl.UNSIGNED_BYTE, k),
  16482. Promise.resolve(k)
  16483. }
  16484. ,
  16485. Object.defineProperty(a, "IsSupportedAsync", {
  16486. get: function() {
  16487. return Promise.resolve(this.isSupported())
  16488. },
  16489. enumerable: !1,
  16490. configurable: !0
  16491. }),
  16492. Object.defineProperty(a, "IsSupported", {
  16493. get: function() {
  16494. return this.isSupported()
  16495. },
  16496. enumerable: !1,
  16497. configurable: !0
  16498. }),
  16499. a.isSupported = function() {
  16500. if (this._HasMajorPerformanceCaveat !== null)
  16501. return !this._HasMajorPerformanceCaveat;
  16502. if (this._IsSupported === null)
  16503. try {
  16504. var e = this._createCanvas(1, 1)
  16505. , i = e.getContext("webgl") || e.getContext("experimental-webgl");
  16506. this._IsSupported = i != null && !!window.WebGLRenderingContext
  16507. } catch {
  16508. this._IsSupported = !1
  16509. }
  16510. return this._IsSupported
  16511. }
  16512. ,
  16513. Object.defineProperty(a, "HasMajorPerformanceCaveat", {
  16514. get: function() {
  16515. if (this._HasMajorPerformanceCaveat === null)
  16516. try {
  16517. var e = this._createCanvas(1, 1)
  16518. , i = e.getContext("webgl", {
  16519. failIfMajorPerformanceCaveat: !0
  16520. }) || e.getContext("experimental-webgl", {
  16521. failIfMajorPerformanceCaveat: !0
  16522. });
  16523. this._HasMajorPerformanceCaveat = !i
  16524. } catch {
  16525. this._HasMajorPerformanceCaveat = !1
  16526. }
  16527. return this._HasMajorPerformanceCaveat
  16528. },
  16529. enumerable: !1,
  16530. configurable: !0
  16531. }),
  16532. a.CeilingPOT = function(e) {
  16533. return e--,
  16534. e |= e >> 1,
  16535. e |= e >> 2,
  16536. e |= e >> 4,
  16537. e |= e >> 8,
  16538. e |= e >> 16,
  16539. e++,
  16540. e
  16541. }
  16542. ,
  16543. a.FloorPOT = function(e) {
  16544. return e = e | e >> 1,
  16545. e = e | e >> 2,
  16546. e = e | e >> 4,
  16547. e = e | e >> 8,
  16548. e = e | e >> 16,
  16549. e - (e >> 1)
  16550. }
  16551. ,
  16552. a.NearestPOT = function(e) {
  16553. var i = a.CeilingPOT(e)
  16554. , o = a.FloorPOT(e);
  16555. return i - e > e - o ? o : i
  16556. }
  16557. ,
  16558. a.GetExponentOfTwo = function(e, i, o) {
  16559. o === void 0 && (o = 2);
  16560. var s;
  16561. switch (o) {
  16562. case 1:
  16563. s = a.FloorPOT(e);
  16564. break;
  16565. case 2:
  16566. s = a.NearestPOT(e);
  16567. break;
  16568. case 3:
  16569. default:
  16570. s = a.CeilingPOT(e);
  16571. break
  16572. }
  16573. return Math.min(s, i)
  16574. }
  16575. ,
  16576. a.QueueNewFrame = function(e, i) {
  16577. return IsWindowObjectExist() ? (i || (i = window),
  16578. i.requestPostAnimationFrame ? i.requestPostAnimationFrame(e) : i.requestAnimationFrame ? i.requestAnimationFrame(e) : i.msRequestAnimationFrame ? i.msRequestAnimationFrame(e) : i.webkitRequestAnimationFrame ? i.webkitRequestAnimationFrame(e) : i.mozRequestAnimationFrame ? i.mozRequestAnimationFrame(e) : i.oRequestAnimationFrame ? i.oRequestAnimationFrame(e) : window.setTimeout(e, 16)) : typeof requestAnimationFrame != "undefined" ? requestAnimationFrame(e) : setTimeout(e, 16)
  16579. }
  16580. ,
  16581. a.prototype.getHostDocument = function() {
  16582. return this._renderingCanvas && this._renderingCanvas.ownerDocument ? this._renderingCanvas.ownerDocument : document
  16583. }
  16584. ,
  16585. a.ExceptionList = [{
  16586. key: "Chrome/63.0",
  16587. capture: "63\\.0\\.3239\\.(\\d+)",
  16588. captureConstraint: 108,
  16589. targets: ["uniformBuffer"]
  16590. }, {
  16591. key: "Firefox/58",
  16592. capture: null,
  16593. captureConstraint: null,
  16594. targets: ["uniformBuffer"]
  16595. }, {
  16596. key: "Firefox/59",
  16597. capture: null,
  16598. captureConstraint: null,
  16599. targets: ["uniformBuffer"]
  16600. }, {
  16601. key: "Chrome/72.+?Mobile",
  16602. capture: null,
  16603. captureConstraint: null,
  16604. targets: ["vao"]
  16605. }, {
  16606. key: "Chrome/73.+?Mobile",
  16607. capture: null,
  16608. captureConstraint: null,
  16609. targets: ["vao"]
  16610. }, {
  16611. key: "Chrome/74.+?Mobile",
  16612. capture: null,
  16613. captureConstraint: null,
  16614. targets: ["vao"]
  16615. }, {
  16616. key: "Mac OS.+Chrome/71",
  16617. capture: null,
  16618. captureConstraint: null,
  16619. targets: ["vao"]
  16620. }, {
  16621. key: "Mac OS.+Chrome/72",
  16622. capture: null,
  16623. captureConstraint: null,
  16624. targets: ["vao"]
  16625. }],
  16626. a._TextureLoaders = [],
  16627. a.CollisionsEpsilon = .001,
  16628. a._IsSupported = null,
  16629. a._HasMajorPerformanceCaveat = null,
  16630. a
  16631. }()
  16632. , PrecisionDate = function() {
  16633. function a() {}
  16634. return Object.defineProperty(a, "Now", {
  16635. get: function() {
  16636. return DomManagement.IsWindowObjectExist() && window.performance && window.performance.now ? window.performance.now() : Date.now()
  16637. },
  16638. enumerable: !1,
  16639. configurable: !0
  16640. }),
  16641. a
  16642. }()
  16643. , PerformanceMonitor = function() {
  16644. function a(e) {
  16645. e === void 0 && (e = 30),
  16646. this._enabled = !0,
  16647. this._rollingFrameTime = new RollingAverage(e)
  16648. }
  16649. return a.prototype.sampleFrame = function(e) {
  16650. if (e === void 0 && (e = PrecisionDate.Now),
  16651. !!this._enabled) {
  16652. if (this._lastFrameTimeMs != null) {
  16653. var i = e - this._lastFrameTimeMs;
  16654. this._rollingFrameTime.add(i)
  16655. }
  16656. this._lastFrameTimeMs = e
  16657. }
  16658. }
  16659. ,
  16660. Object.defineProperty(a.prototype, "averageFrameTime", {
  16661. get: function() {
  16662. return this._rollingFrameTime.average
  16663. },
  16664. enumerable: !1,
  16665. configurable: !0
  16666. }),
  16667. Object.defineProperty(a.prototype, "averageFrameTimeVariance", {
  16668. get: function() {
  16669. return this._rollingFrameTime.variance
  16670. },
  16671. enumerable: !1,
  16672. configurable: !0
  16673. }),
  16674. Object.defineProperty(a.prototype, "instantaneousFrameTime", {
  16675. get: function() {
  16676. return this._rollingFrameTime.history(0)
  16677. },
  16678. enumerable: !1,
  16679. configurable: !0
  16680. }),
  16681. Object.defineProperty(a.prototype, "averageFPS", {
  16682. get: function() {
  16683. return 1e3 / this._rollingFrameTime.average
  16684. },
  16685. enumerable: !1,
  16686. configurable: !0
  16687. }),
  16688. Object.defineProperty(a.prototype, "instantaneousFPS", {
  16689. get: function() {
  16690. var e = this._rollingFrameTime.history(0);
  16691. return e === 0 ? 0 : 1e3 / e
  16692. },
  16693. enumerable: !1,
  16694. configurable: !0
  16695. }),
  16696. Object.defineProperty(a.prototype, "isSaturated", {
  16697. get: function() {
  16698. return this._rollingFrameTime.isSaturated()
  16699. },
  16700. enumerable: !1,
  16701. configurable: !0
  16702. }),
  16703. a.prototype.enable = function() {
  16704. this._enabled = !0
  16705. }
  16706. ,
  16707. a.prototype.disable = function() {
  16708. this._enabled = !1,
  16709. this._lastFrameTimeMs = null
  16710. }
  16711. ,
  16712. Object.defineProperty(a.prototype, "isEnabled", {
  16713. get: function() {
  16714. return this._enabled
  16715. },
  16716. enumerable: !1,
  16717. configurable: !0
  16718. }),
  16719. a.prototype.reset = function() {
  16720. this._lastFrameTimeMs = null,
  16721. this._rollingFrameTime.reset()
  16722. }
  16723. ,
  16724. a
  16725. }()
  16726. , RollingAverage = function() {
  16727. function a(e) {
  16728. this._samples = new Array(e),
  16729. this.reset()
  16730. }
  16731. return a.prototype.add = function(e) {
  16732. var i;
  16733. if (this.isSaturated()) {
  16734. var o = this._samples[this._pos];
  16735. i = o - this.average,
  16736. this.average -= i / (this._sampleCount - 1),
  16737. this._m2 -= i * (o - this.average)
  16738. } else
  16739. this._sampleCount++;
  16740. i = e - this.average,
  16741. this.average += i / this._sampleCount,
  16742. this._m2 += i * (e - this.average),
  16743. this.variance = this._m2 / (this._sampleCount - 1),
  16744. this._samples[this._pos] = e,
  16745. this._pos++,
  16746. this._pos %= this._samples.length
  16747. }
  16748. ,
  16749. a.prototype.history = function(e) {
  16750. if (e >= this._sampleCount || e >= this._samples.length)
  16751. return 0;
  16752. var i = this._wrapPosition(this._pos - 1);
  16753. return this._samples[this._wrapPosition(i - e)]
  16754. }
  16755. ,
  16756. a.prototype.isSaturated = function() {
  16757. return this._sampleCount >= this._samples.length
  16758. }
  16759. ,
  16760. a.prototype.reset = function() {
  16761. this.average = 0,
  16762. this.variance = 0,
  16763. this._sampleCount = 0,
  16764. this._pos = 0,
  16765. this._m2 = 0
  16766. }
  16767. ,
  16768. a.prototype._wrapPosition = function(e) {
  16769. var i = this._samples.length;
  16770. return (e % i + i) % i
  16771. }
  16772. ,
  16773. a
  16774. }()
  16775. , PerfCounter = function() {
  16776. function a() {
  16777. this._startMonitoringTime = 0,
  16778. this._min = 0,
  16779. this._max = 0,
  16780. this._average = 0,
  16781. this._lastSecAverage = 0,
  16782. this._current = 0,
  16783. this._totalValueCount = 0,
  16784. this._totalAccumulated = 0,
  16785. this._lastSecAccumulated = 0,
  16786. this._lastSecTime = 0,
  16787. this._lastSecValueCount = 0
  16788. }
  16789. return Object.defineProperty(a.prototype, "min", {
  16790. get: function() {
  16791. return this._min
  16792. },
  16793. enumerable: !1,
  16794. configurable: !0
  16795. }),
  16796. Object.defineProperty(a.prototype, "max", {
  16797. get: function() {
  16798. return this._max
  16799. },
  16800. enumerable: !1,
  16801. configurable: !0
  16802. }),
  16803. Object.defineProperty(a.prototype, "average", {
  16804. get: function() {
  16805. return this._average
  16806. },
  16807. enumerable: !1,
  16808. configurable: !0
  16809. }),
  16810. Object.defineProperty(a.prototype, "lastSecAverage", {
  16811. get: function() {
  16812. return this._lastSecAverage
  16813. },
  16814. enumerable: !1,
  16815. configurable: !0
  16816. }),
  16817. Object.defineProperty(a.prototype, "current", {
  16818. get: function() {
  16819. return this._current
  16820. },
  16821. enumerable: !1,
  16822. configurable: !0
  16823. }),
  16824. Object.defineProperty(a.prototype, "total", {
  16825. get: function() {
  16826. return this._totalAccumulated
  16827. },
  16828. enumerable: !1,
  16829. configurable: !0
  16830. }),
  16831. Object.defineProperty(a.prototype, "count", {
  16832. get: function() {
  16833. return this._totalValueCount
  16834. },
  16835. enumerable: !1,
  16836. configurable: !0
  16837. }),
  16838. a.prototype.fetchNewFrame = function() {
  16839. this._totalValueCount++,
  16840. this._current = 0,
  16841. this._lastSecValueCount++
  16842. }
  16843. ,
  16844. a.prototype.addCount = function(e, i) {
  16845. !a.Enabled || (this._current += e,
  16846. i && this._fetchResult())
  16847. }
  16848. ,
  16849. a.prototype.beginMonitoring = function() {
  16850. !a.Enabled || (this._startMonitoringTime = PrecisionDate.Now)
  16851. }
  16852. ,
  16853. a.prototype.endMonitoring = function(e) {
  16854. if (e === void 0 && (e = !0),
  16855. !!a.Enabled) {
  16856. e && this.fetchNewFrame();
  16857. var i = PrecisionDate.Now;
  16858. this._current = i - this._startMonitoringTime,
  16859. e && this._fetchResult()
  16860. }
  16861. }
  16862. ,
  16863. a.prototype._fetchResult = function() {
  16864. this._totalAccumulated += this._current,
  16865. this._lastSecAccumulated += this._current,
  16866. this._min = Math.min(this._min, this._current),
  16867. this._max = Math.max(this._max, this._current),
  16868. this._average = this._totalAccumulated / this._totalValueCount;
  16869. var e = PrecisionDate.Now;
  16870. e - this._lastSecTime > 1e3 && (this._lastSecAverage = this._lastSecAccumulated / this._lastSecValueCount,
  16871. this._lastSecTime = e,
  16872. this._lastSecAccumulated = 0,
  16873. this._lastSecValueCount = 0)
  16874. }
  16875. ,
  16876. a.Enabled = !0,
  16877. a
  16878. }();
  16879. ThinEngine.prototype.setAlphaConstants = function(a, e, i, o) {
  16880. this._alphaState.setAlphaBlendConstants(a, e, i, o)
  16881. }
  16882. ;
  16883. ThinEngine.prototype.setAlphaMode = function(a, e) {
  16884. if (e === void 0 && (e = !1),
  16885. this._alphaMode !== a) {
  16886. switch (a) {
  16887. case 0:
  16888. this._alphaState.alphaBlend = !1;
  16889. break;
  16890. case 7:
  16891. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE),
  16892. this._alphaState.alphaBlend = !0;
  16893. break;
  16894. case 8:
  16895. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA),
  16896. this._alphaState.alphaBlend = !0;
  16897. break;
  16898. case 2:
  16899. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE),
  16900. this._alphaState.alphaBlend = !0;
  16901. break;
  16902. case 6:
  16903. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE, this._gl.ZERO, this._gl.ONE),
  16904. this._alphaState.alphaBlend = !0;
  16905. break;
  16906. case 1:
  16907. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE, this._gl.ZERO, this._gl.ONE),
  16908. this._alphaState.alphaBlend = !0;
  16909. break;
  16910. case 3:
  16911. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ZERO, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE),
  16912. this._alphaState.alphaBlend = !0;
  16913. break;
  16914. case 4:
  16915. this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_COLOR, this._gl.ZERO, this._gl.ONE, this._gl.ONE),
  16916. this._alphaState.alphaBlend = !0;
  16917. break;
  16918. case 5:
  16919. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE),
  16920. this._alphaState.alphaBlend = !0;
  16921. break;
  16922. case 9:
  16923. this._alphaState.setAlphaBlendFunctionParameters(this._gl.CONSTANT_COLOR, this._gl.ONE_MINUS_CONSTANT_COLOR, this._gl.CONSTANT_ALPHA, this._gl.ONE_MINUS_CONSTANT_ALPHA),
  16924. this._alphaState.alphaBlend = !0;
  16925. break;
  16926. case 10:
  16927. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA),
  16928. this._alphaState.alphaBlend = !0;
  16929. break;
  16930. case 11:
  16931. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE, this._gl.ONE, this._gl.ONE),
  16932. this._alphaState.alphaBlend = !0;
  16933. break;
  16934. case 12:
  16935. this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_ALPHA, this._gl.ONE, this._gl.ZERO, this._gl.ZERO),
  16936. this._alphaState.alphaBlend = !0;
  16937. break;
  16938. case 13:
  16939. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE_MINUS_DST_COLOR, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE_MINUS_DST_ALPHA, this._gl.ONE_MINUS_SRC_ALPHA),
  16940. this._alphaState.alphaBlend = !0;
  16941. break;
  16942. case 14:
  16943. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA),
  16944. this._alphaState.alphaBlend = !0;
  16945. break;
  16946. case 15:
  16947. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE, this._gl.ONE, this._gl.ZERO),
  16948. this._alphaState.alphaBlend = !0;
  16949. break;
  16950. case 16:
  16951. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE_MINUS_DST_COLOR, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ZERO, this._gl.ONE),
  16952. this._alphaState.alphaBlend = !0;
  16953. break;
  16954. case 17:
  16955. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA),
  16956. this._alphaState.alphaBlend = !0;
  16957. break
  16958. }
  16959. e || (this.depthCullingState.depthMask = a === 0),
  16960. this._alphaMode = a
  16961. }
  16962. }
  16963. ;
  16964. ThinEngine.prototype.getAlphaMode = function() {
  16965. return this._alphaMode
  16966. }
  16967. ;
  16968. ThinEngine.prototype.setAlphaEquation = function(a) {
  16969. if (this._alphaEquation !== a) {
  16970. switch (a) {
  16971. case 0:
  16972. this._alphaState.setAlphaEquationParameters(32774, 32774);
  16973. break;
  16974. case 1:
  16975. this._alphaState.setAlphaEquationParameters(32778, 32778);
  16976. break;
  16977. case 2:
  16978. this._alphaState.setAlphaEquationParameters(32779, 32779);
  16979. break;
  16980. case 3:
  16981. this._alphaState.setAlphaEquationParameters(32776, 32776);
  16982. break;
  16983. case 4:
  16984. this._alphaState.setAlphaEquationParameters(32775, 32775);
  16985. break;
  16986. case 5:
  16987. this._alphaState.setAlphaEquationParameters(32775, 32774);
  16988. break
  16989. }
  16990. this._alphaEquation = a
  16991. }
  16992. }
  16993. ;
  16994. ThinEngine.prototype.getAlphaEquation = function() {
  16995. return this._alphaEquation
  16996. }
  16997. ;
  16998. function allocateAndCopyTypedBuffer(a, e, i, o) {
  16999. switch (i === void 0 && (i = !1),
  17000. a) {
  17001. case 3:
  17002. {
  17003. var s = e instanceof ArrayBuffer ? new Int8Array(e) : new Int8Array(e);
  17004. return o && s.set(new Int8Array(o)),
  17005. s
  17006. }
  17007. case 0:
  17008. {
  17009. var c = e instanceof ArrayBuffer ? new Uint8Array(e) : new Uint8Array(e);
  17010. return o && c.set(new Uint8Array(o)),
  17011. c
  17012. }
  17013. case 4:
  17014. {
  17015. var d = e instanceof ArrayBuffer ? new Int16Array(e) : new Int16Array(i ? e / 2 : e);
  17016. return o && d.set(new Int16Array(o)),
  17017. d
  17018. }
  17019. case 5:
  17020. case 8:
  17021. case 9:
  17022. case 10:
  17023. case 2:
  17024. {
  17025. var _ = e instanceof ArrayBuffer ? new Uint16Array(e) : new Uint16Array(i ? e / 2 : e);
  17026. return o && _.set(new Uint16Array(o)),
  17027. _
  17028. }
  17029. case 6:
  17030. {
  17031. var b = e instanceof ArrayBuffer ? new Int32Array(e) : new Int32Array(i ? e / 4 : e);
  17032. return o && b.set(new Int32Array(o)),
  17033. b
  17034. }
  17035. case 7:
  17036. case 11:
  17037. case 12:
  17038. case 13:
  17039. case 14:
  17040. case 15:
  17041. {
  17042. var k = e instanceof ArrayBuffer ? new Uint32Array(e) : new Uint32Array(i ? e / 4 : e);
  17043. return o && k.set(new Uint32Array(o)),
  17044. k
  17045. }
  17046. case 1:
  17047. {
  17048. var j = e instanceof ArrayBuffer ? new Float32Array(e) : new Float32Array(i ? e / 4 : e);
  17049. return o && j.set(new Float32Array(o)),
  17050. j
  17051. }
  17052. }
  17053. var $ = e instanceof ArrayBuffer ? new Uint8Array(e) : new Uint8Array(e);
  17054. return o && $.set(new Uint8Array(o)),
  17055. $
  17056. }
  17057. ThinEngine.prototype._readTexturePixelsSync = function(a, e, i, o, s, c, d, _) {
  17058. var b, k;
  17059. o === void 0 && (o = -1),
  17060. s === void 0 && (s = 0),
  17061. c === void 0 && (c = null),
  17062. d === void 0 && (d = !0),
  17063. _ === void 0 && (_ = !1);
  17064. var j = this._gl;
  17065. if (!j)
  17066. throw new Error("Engine does not have gl rendering context.");
  17067. if (!this._dummyFramebuffer) {
  17068. var $ = j.createFramebuffer();
  17069. if (!$)
  17070. throw new Error("Unable to create dummy framebuffer");
  17071. this._dummyFramebuffer = $
  17072. }
  17073. j.bindFramebuffer(j.FRAMEBUFFER, this._dummyFramebuffer),
  17074. o > -1 ? j.framebufferTexture2D(j.FRAMEBUFFER, j.COLOR_ATTACHMENT0, j.TEXTURE_CUBE_MAP_POSITIVE_X + o, (b = a._hardwareTexture) === null || b === void 0 ? void 0 : b.underlyingResource, s) : j.framebufferTexture2D(j.FRAMEBUFFER, j.COLOR_ATTACHMENT0, j.TEXTURE_2D, (k = a._hardwareTexture) === null || k === void 0 ? void 0 : k.underlyingResource, s);
  17075. var _e = a.type !== void 0 ? this._getWebGLTextureType(a.type) : j.UNSIGNED_BYTE;
  17076. if (_)
  17077. c || (c = allocateAndCopyTypedBuffer(a.type, 4 * e * i));
  17078. else
  17079. switch (_e) {
  17080. case j.UNSIGNED_BYTE:
  17081. c || (c = new Uint8Array(4 * e * i)),
  17082. _e = j.UNSIGNED_BYTE;
  17083. break;
  17084. default:
  17085. c || (c = new Float32Array(4 * e * i)),
  17086. _e = j.FLOAT;
  17087. break
  17088. }
  17089. return d && this.flushFramebuffer(),
  17090. j.readPixels(0, 0, e, i, j.RGBA, _e, c),
  17091. j.bindFramebuffer(j.FRAMEBUFFER, this._currentFramebuffer),
  17092. c
  17093. }
  17094. ;
  17095. ThinEngine.prototype._readTexturePixels = function(a, e, i, o, s, c, d, _) {
  17096. return o === void 0 && (o = -1),
  17097. s === void 0 && (s = 0),
  17098. c === void 0 && (c = null),
  17099. d === void 0 && (d = !0),
  17100. _ === void 0 && (_ = !1),
  17101. Promise.resolve(this._readTexturePixelsSync(a, e, i, o, s, c, d, _))
  17102. }
  17103. ;
  17104. ThinEngine.prototype.updateDynamicIndexBuffer = function(a, e, i) {
  17105. this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER] = null,
  17106. this.bindIndexBuffer(a);
  17107. var o;
  17108. e instanceof Uint16Array || e instanceof Uint32Array ? o = e : o = a.is32Bits ? new Uint32Array(e) : new Uint16Array(e),
  17109. this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, o, this._gl.DYNAMIC_DRAW),
  17110. this._resetIndexBufferBinding()
  17111. }
  17112. ;
  17113. ThinEngine.prototype.updateDynamicVertexBuffer = function(a, e, i, o) {
  17114. this.bindArrayBuffer(a),
  17115. i === void 0 && (i = 0);
  17116. var s = e.length || e.byteLength;
  17117. o === void 0 || o >= s && i === 0 ? e instanceof Array ? this._gl.bufferSubData(this._gl.ARRAY_BUFFER, i, new Float32Array(e)) : this._gl.bufferSubData(this._gl.ARRAY_BUFFER, i, e) : e instanceof Array ? this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, new Float32Array(e).subarray(i, i + o)) : (e instanceof ArrayBuffer ? e = new Uint8Array(e,i,o) : e = new Uint8Array(e.buffer,e.byteOffset + i,o),
  17118. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, e)),
  17119. this._resetVertexBufferBinding()
  17120. }
  17121. ;
  17122. var Engine = function(a) {
  17123. __extends(e, a);
  17124. function e(i, o, s, c) {
  17125. c === void 0 && (c = !1);
  17126. var d = a.call(this, i, o, s, c) || this;
  17127. if (d.enableOfflineSupport = !1,
  17128. d.disableManifestCheck = !1,
  17129. d.scenes = new Array,
  17130. d._virtualScenes = new Array,
  17131. d.onNewSceneAddedObservable = new Observable,
  17132. d.postProcesses = new Array,
  17133. d.isPointerLock = !1,
  17134. d.onResizeObservable = new Observable,
  17135. d.onCanvasBlurObservable = new Observable,
  17136. d.onCanvasFocusObservable = new Observable,
  17137. d.onCanvasPointerOutObservable = new Observable,
  17138. d.onBeginFrameObservable = new Observable,
  17139. d.customAnimationFrameRequester = null,
  17140. d.onEndFrameObservable = new Observable,
  17141. d.onBeforeShaderCompilationObservable = new Observable,
  17142. d.onAfterShaderCompilationObservable = new Observable,
  17143. d._deterministicLockstep = !1,
  17144. d._lockstepMaxSteps = 4,
  17145. d._timeStep = 1 / 60,
  17146. d._fps = 60,
  17147. d._deltaTime = 0,
  17148. d._drawCalls = new PerfCounter,
  17149. d.canvasTabIndex = 1,
  17150. d.disablePerformanceMonitorInBackground = !1,
  17151. d._performanceMonitor = new PerformanceMonitor,
  17152. d._compatibilityMode = !0,
  17153. d.currentRenderPassId = 0,
  17154. d._renderPassNames = ["main"],
  17155. e.Instances.push(d),
  17156. !i)
  17157. return d;
  17158. if (d._features.supportRenderPasses = !0,
  17159. s = d._creationOptions,
  17160. i.getContext) {
  17161. var _ = i;
  17162. if (d._sharedInit(_, !!s.doNotHandleTouchAction, s.audioEngine),
  17163. IsWindowObjectExist()) {
  17164. var b = document;
  17165. d._onFullscreenChange = function() {
  17166. b.fullscreen !== void 0 ? d.isFullscreen = b.fullscreen : b.mozFullScreen !== void 0 ? d.isFullscreen = b.mozFullScreen : b.webkitIsFullScreen !== void 0 ? d.isFullscreen = b.webkitIsFullScreen : b.msIsFullScreen !== void 0 && (d.isFullscreen = b.msIsFullScreen),
  17167. d.isFullscreen && d._pointerLockRequested && _ && e._RequestPointerlock(_)
  17168. }
  17169. ,
  17170. document.addEventListener("fullscreenchange", d._onFullscreenChange, !1),
  17171. document.addEventListener("mozfullscreenchange", d._onFullscreenChange, !1),
  17172. document.addEventListener("webkitfullscreenchange", d._onFullscreenChange, !1),
  17173. document.addEventListener("msfullscreenchange", d._onFullscreenChange, !1),
  17174. d._onPointerLockChange = function() {
  17175. d.isPointerLock = b.mozPointerLockElement === _ || b.webkitPointerLockElement === _ || b.msPointerLockElement === _ || b.pointerLockElement === _
  17176. }
  17177. ,
  17178. document.addEventListener("pointerlockchange", d._onPointerLockChange, !1),
  17179. document.addEventListener("mspointerlockchange", d._onPointerLockChange, !1),
  17180. document.addEventListener("mozpointerlockchange", d._onPointerLockChange, !1),
  17181. document.addEventListener("webkitpointerlockchange", d._onPointerLockChange, !1),
  17182. !e.audioEngine && s.audioEngine && e.AudioEngineFactory && (e.audioEngine = e.AudioEngineFactory(d.getRenderingCanvas(), d.getAudioContext(), d.getAudioDestination()))
  17183. }
  17184. d._connectVREvents(),
  17185. d.enableOfflineSupport = e.OfflineProviderFactory !== void 0,
  17186. d._deterministicLockstep = !!s.deterministicLockstep,
  17187. d._lockstepMaxSteps = s.lockstepMaxSteps || 0,
  17188. d._timeStep = s.timeStep || 1 / 60
  17189. }
  17190. return d._prepareVRComponent(),
  17191. s.autoEnableWebVR && d.initWebVR(),
  17192. d
  17193. }
  17194. return Object.defineProperty(e, "NpmPackage", {
  17195. get: function() {
  17196. return ThinEngine.NpmPackage
  17197. },
  17198. enumerable: !1,
  17199. configurable: !0
  17200. }),
  17201. Object.defineProperty(e, "Version", {
  17202. get: function() {
  17203. return ThinEngine.Version
  17204. },
  17205. enumerable: !1,
  17206. configurable: !0
  17207. }),
  17208. Object.defineProperty(e, "Instances", {
  17209. get: function() {
  17210. return EngineStore.Instances
  17211. },
  17212. enumerable: !1,
  17213. configurable: !0
  17214. }),
  17215. Object.defineProperty(e, "LastCreatedEngine", {
  17216. get: function() {
  17217. return EngineStore.LastCreatedEngine
  17218. },
  17219. enumerable: !1,
  17220. configurable: !0
  17221. }),
  17222. Object.defineProperty(e, "LastCreatedScene", {
  17223. get: function() {
  17224. return EngineStore.LastCreatedScene
  17225. },
  17226. enumerable: !1,
  17227. configurable: !0
  17228. }),
  17229. e.prototype.createImageBitmap = function(i, o) {
  17230. return createImageBitmap(i, o)
  17231. }
  17232. ,
  17233. e.prototype.resizeImageBitmap = function(i, o, s) {
  17234. var c = this.createCanvas(o, s)
  17235. , d = c.getContext("2d");
  17236. if (!d)
  17237. throw new Error("Unable to get 2d context for resizeImageBitmap");
  17238. d.drawImage(i, 0, 0);
  17239. var _ = d.getImageData(0, 0, o, s).data;
  17240. return _
  17241. }
  17242. ,
  17243. e.MarkAllMaterialsAsDirty = function(i, o) {
  17244. for (var s = 0; s < e.Instances.length; s++)
  17245. for (var c = e.Instances[s], d = 0; d < c.scenes.length; d++)
  17246. c.scenes[d].markAllMaterialsAsDirty(i, o)
  17247. }
  17248. ,
  17249. e.DefaultLoadingScreenFactory = function(i) {
  17250. throw _WarnImport("LoadingScreen")
  17251. }
  17252. ,
  17253. Object.defineProperty(e.prototype, "_supportsHardwareTextureRescaling", {
  17254. get: function() {
  17255. return !!e._RescalePostProcessFactory
  17256. },
  17257. enumerable: !1,
  17258. configurable: !0
  17259. }),
  17260. Object.defineProperty(e.prototype, "performanceMonitor", {
  17261. get: function() {
  17262. return this._performanceMonitor
  17263. },
  17264. enumerable: !1,
  17265. configurable: !0
  17266. }),
  17267. Object.defineProperty(e.prototype, "compatibilityMode", {
  17268. get: function() {
  17269. return this._compatibilityMode
  17270. },
  17271. set: function(i) {
  17272. this._compatibilityMode = !0
  17273. },
  17274. enumerable: !1,
  17275. configurable: !0
  17276. }),
  17277. e.prototype.getInputElement = function() {
  17278. return this._renderingCanvas
  17279. }
  17280. ,
  17281. e.prototype._sharedInit = function(i, o, s) {
  17282. var c = this;
  17283. if (a.prototype._sharedInit.call(this, i, o, s),
  17284. this._onCanvasFocus = function() {
  17285. c.onCanvasFocusObservable.notifyObservers(c)
  17286. }
  17287. ,
  17288. this._onCanvasBlur = function() {
  17289. c.onCanvasBlurObservable.notifyObservers(c)
  17290. }
  17291. ,
  17292. i.addEventListener("focus", this._onCanvasFocus),
  17293. i.addEventListener("blur", this._onCanvasBlur),
  17294. this._onBlur = function() {
  17295. c.disablePerformanceMonitorInBackground && c._performanceMonitor.disable(),
  17296. c._windowIsBackground = !0
  17297. }
  17298. ,
  17299. this._onFocus = function() {
  17300. c.disablePerformanceMonitorInBackground && c._performanceMonitor.enable(),
  17301. c._windowIsBackground = !1
  17302. }
  17303. ,
  17304. this._onCanvasPointerOut = function(_) {
  17305. document.elementFromPoint(_.clientX, _.clientY) !== i && c.onCanvasPointerOutObservable.notifyObservers(_)
  17306. }
  17307. ,
  17308. IsWindowObjectExist()) {
  17309. var d = this.getHostWindow();
  17310. d && (d.addEventListener("blur", this._onBlur),
  17311. d.addEventListener("focus", this._onFocus))
  17312. }
  17313. i.addEventListener("pointerout", this._onCanvasPointerOut),
  17314. o || this._disableTouchAction(),
  17315. !e.audioEngine && s && e.AudioEngineFactory && (e.audioEngine = e.AudioEngineFactory(this.getRenderingCanvas(), this.getAudioContext(), this.getAudioDestination()))
  17316. }
  17317. ,
  17318. e.prototype.getAspectRatio = function(i, o) {
  17319. o === void 0 && (o = !1);
  17320. var s = i.viewport;
  17321. return this.getRenderWidth(o) * s.width / (this.getRenderHeight(o) * s.height)
  17322. }
  17323. ,
  17324. e.prototype.getScreenAspectRatio = function() {
  17325. return this.getRenderWidth(!0) / this.getRenderHeight(!0)
  17326. }
  17327. ,
  17328. e.prototype.getRenderingCanvasClientRect = function() {
  17329. return this._renderingCanvas ? this._renderingCanvas.getBoundingClientRect() : null
  17330. }
  17331. ,
  17332. e.prototype.getInputElementClientRect = function() {
  17333. return this._renderingCanvas ? this.getInputElement().getBoundingClientRect() : null
  17334. }
  17335. ,
  17336. e.prototype.isDeterministicLockStep = function() {
  17337. return this._deterministicLockstep
  17338. }
  17339. ,
  17340. e.prototype.getLockstepMaxSteps = function() {
  17341. return this._lockstepMaxSteps
  17342. }
  17343. ,
  17344. e.prototype.getTimeStep = function() {
  17345. return this._timeStep * 1e3
  17346. }
  17347. ,
  17348. e.prototype.generateMipMapsForCubemap = function(i, o) {
  17349. if (o === void 0 && (o = !0),
  17350. i.generateMipMaps) {
  17351. var s = this._gl;
  17352. this._bindTextureDirectly(s.TEXTURE_CUBE_MAP, i, !0),
  17353. s.generateMipmap(s.TEXTURE_CUBE_MAP),
  17354. o && this._bindTextureDirectly(s.TEXTURE_CUBE_MAP, null)
  17355. }
  17356. }
  17357. ,
  17358. e.prototype.getDepthBuffer = function() {
  17359. return this._depthCullingState.depthTest
  17360. }
  17361. ,
  17362. e.prototype.setDepthBuffer = function(i) {
  17363. this._depthCullingState.depthTest = i
  17364. }
  17365. ,
  17366. e.prototype.getDepthWrite = function() {
  17367. return this._depthCullingState.depthMask
  17368. }
  17369. ,
  17370. e.prototype.setDepthWrite = function(i) {
  17371. this._depthCullingState.depthMask = i
  17372. }
  17373. ,
  17374. e.prototype.getStencilBuffer = function() {
  17375. return this._stencilState.stencilTest
  17376. }
  17377. ,
  17378. e.prototype.setStencilBuffer = function(i) {
  17379. this._stencilState.stencilTest = i
  17380. }
  17381. ,
  17382. e.prototype.getStencilMask = function() {
  17383. return this._stencilState.stencilMask
  17384. }
  17385. ,
  17386. e.prototype.setStencilMask = function(i) {
  17387. this._stencilState.stencilMask = i
  17388. }
  17389. ,
  17390. e.prototype.getStencilFunction = function() {
  17391. return this._stencilState.stencilFunc
  17392. }
  17393. ,
  17394. e.prototype.getStencilFunctionReference = function() {
  17395. return this._stencilState.stencilFuncRef
  17396. }
  17397. ,
  17398. e.prototype.getStencilFunctionMask = function() {
  17399. return this._stencilState.stencilFuncMask
  17400. }
  17401. ,
  17402. e.prototype.setStencilFunction = function(i) {
  17403. this._stencilState.stencilFunc = i
  17404. }
  17405. ,
  17406. e.prototype.setStencilFunctionReference = function(i) {
  17407. this._stencilState.stencilFuncRef = i
  17408. }
  17409. ,
  17410. e.prototype.setStencilFunctionMask = function(i) {
  17411. this._stencilState.stencilFuncMask = i
  17412. }
  17413. ,
  17414. e.prototype.getStencilOperationFail = function() {
  17415. return this._stencilState.stencilOpStencilFail
  17416. }
  17417. ,
  17418. e.prototype.getStencilOperationDepthFail = function() {
  17419. return this._stencilState.stencilOpDepthFail
  17420. }
  17421. ,
  17422. e.prototype.getStencilOperationPass = function() {
  17423. return this._stencilState.stencilOpStencilDepthPass
  17424. }
  17425. ,
  17426. e.prototype.setStencilOperationFail = function(i) {
  17427. this._stencilState.stencilOpStencilFail = i
  17428. }
  17429. ,
  17430. e.prototype.setStencilOperationDepthFail = function(i) {
  17431. this._stencilState.stencilOpDepthFail = i
  17432. }
  17433. ,
  17434. e.prototype.setStencilOperationPass = function(i) {
  17435. this._stencilState.stencilOpStencilDepthPass = i
  17436. }
  17437. ,
  17438. e.prototype.setDitheringState = function(i) {
  17439. i ? this._gl.enable(this._gl.DITHER) : this._gl.disable(this._gl.DITHER)
  17440. }
  17441. ,
  17442. e.prototype.setRasterizerState = function(i) {
  17443. i ? this._gl.disable(this._gl.RASTERIZER_DISCARD) : this._gl.enable(this._gl.RASTERIZER_DISCARD)
  17444. }
  17445. ,
  17446. e.prototype.getDepthFunction = function() {
  17447. return this._depthCullingState.depthFunc
  17448. }
  17449. ,
  17450. e.prototype.setDepthFunction = function(i) {
  17451. this._depthCullingState.depthFunc = i
  17452. }
  17453. ,
  17454. e.prototype.setDepthFunctionToGreater = function() {
  17455. this.setDepthFunction(516)
  17456. }
  17457. ,
  17458. e.prototype.setDepthFunctionToGreaterOrEqual = function() {
  17459. this.setDepthFunction(518)
  17460. }
  17461. ,
  17462. e.prototype.setDepthFunctionToLess = function() {
  17463. this.setDepthFunction(513)
  17464. }
  17465. ,
  17466. e.prototype.setDepthFunctionToLessOrEqual = function() {
  17467. this.setDepthFunction(515)
  17468. }
  17469. ,
  17470. e.prototype.cacheStencilState = function() {
  17471. this._cachedStencilBuffer = this.getStencilBuffer(),
  17472. this._cachedStencilFunction = this.getStencilFunction(),
  17473. this._cachedStencilMask = this.getStencilMask(),
  17474. this._cachedStencilOperationPass = this.getStencilOperationPass(),
  17475. this._cachedStencilOperationFail = this.getStencilOperationFail(),
  17476. this._cachedStencilOperationDepthFail = this.getStencilOperationDepthFail(),
  17477. this._cachedStencilReference = this.getStencilFunctionReference()
  17478. }
  17479. ,
  17480. e.prototype.restoreStencilState = function() {
  17481. this.setStencilFunction(this._cachedStencilFunction),
  17482. this.setStencilMask(this._cachedStencilMask),
  17483. this.setStencilBuffer(this._cachedStencilBuffer),
  17484. this.setStencilOperationPass(this._cachedStencilOperationPass),
  17485. this.setStencilOperationFail(this._cachedStencilOperationFail),
  17486. this.setStencilOperationDepthFail(this._cachedStencilOperationDepthFail),
  17487. this.setStencilFunctionReference(this._cachedStencilReference)
  17488. }
  17489. ,
  17490. e.prototype.setDirectViewport = function(i, o, s, c) {
  17491. var d = this._cachedViewport;
  17492. return this._cachedViewport = null,
  17493. this._viewport(i, o, s, c),
  17494. d
  17495. }
  17496. ,
  17497. e.prototype.scissorClear = function(i, o, s, c, d) {
  17498. this.enableScissor(i, o, s, c),
  17499. this.clear(d, !0, !0, !0),
  17500. this.disableScissor()
  17501. }
  17502. ,
  17503. e.prototype.enableScissor = function(i, o, s, c) {
  17504. var d = this._gl;
  17505. d.enable(d.SCISSOR_TEST),
  17506. d.scissor(i, o, s, c)
  17507. }
  17508. ,
  17509. e.prototype.disableScissor = function() {
  17510. var i = this._gl;
  17511. i.disable(i.SCISSOR_TEST)
  17512. }
  17513. ,
  17514. e.prototype._reportDrawCall = function(i) {
  17515. i === void 0 && (i = 1),
  17516. this._drawCalls.addCount(i, !1)
  17517. }
  17518. ,
  17519. e.prototype.initWebVR = function() {
  17520. throw _WarnImport("WebVRCamera")
  17521. }
  17522. ,
  17523. e.prototype._prepareVRComponent = function() {}
  17524. ,
  17525. e.prototype._connectVREvents = function(i, o) {}
  17526. ,
  17527. e.prototype._submitVRFrame = function() {}
  17528. ,
  17529. e.prototype.disableVR = function() {}
  17530. ,
  17531. e.prototype.isVRPresenting = function() {
  17532. return !1
  17533. }
  17534. ,
  17535. e.prototype._requestVRFrame = function() {}
  17536. ,
  17537. e.prototype._loadFileAsync = function(i, o, s) {
  17538. var c = this;
  17539. return new Promise(function(d, _) {
  17540. c._loadFile(i, function(b) {
  17541. d(b)
  17542. }, void 0, o, s, function(b, k) {
  17543. _(k)
  17544. })
  17545. }
  17546. )
  17547. }
  17548. ,
  17549. e.prototype.getVertexShaderSource = function(i) {
  17550. var o = this._gl.getAttachedShaders(i);
  17551. return o ? this._gl.getShaderSource(o[0]) : null
  17552. }
  17553. ,
  17554. e.prototype.getFragmentShaderSource = function(i) {
  17555. var o = this._gl.getAttachedShaders(i);
  17556. return o ? this._gl.getShaderSource(o[1]) : null
  17557. }
  17558. ,
  17559. e.prototype.setDepthStencilTexture = function(i, o, s, c) {
  17560. i !== void 0 && (o && (this._boundUniforms[i] = o),
  17561. !s || !s.depthStencilTexture ? this._setTexture(i, null, void 0, void 0, c) : this._setTexture(i, s, !1, !0, c))
  17562. }
  17563. ,
  17564. e.prototype.setTextureFromPostProcess = function(i, o, s) {
  17565. var c, d = null;
  17566. o && (o._textures.data[o._currentRenderTextureInd] ? d = o._textures.data[o._currentRenderTextureInd] : o._forcedOutputTexture && (d = o._forcedOutputTexture)),
  17567. this._bindTexture(i, (c = d == null ? void 0 : d.texture) !== null && c !== void 0 ? c : null, s)
  17568. }
  17569. ,
  17570. e.prototype.setTextureFromPostProcessOutput = function(i, o, s) {
  17571. var c, d;
  17572. this._bindTexture(i, (d = (c = o == null ? void 0 : o._outputTexture) === null || c === void 0 ? void 0 : c.texture) !== null && d !== void 0 ? d : null, s)
  17573. }
  17574. ,
  17575. e.prototype._rebuildBuffers = function() {
  17576. for (var i = 0, o = this.scenes; i < o.length; i++) {
  17577. var s = o[i];
  17578. s.resetCachedMaterial(),
  17579. s._rebuildGeometries(),
  17580. s._rebuildTextures()
  17581. }
  17582. for (var c = 0, d = this._virtualScenes; c < d.length; c++) {
  17583. var s = d[c];
  17584. s.resetCachedMaterial(),
  17585. s._rebuildGeometries(),
  17586. s._rebuildTextures()
  17587. }
  17588. a.prototype._rebuildBuffers.call(this)
  17589. }
  17590. ,
  17591. e.prototype._renderFrame = function() {
  17592. for (var i = 0; i < this._activeRenderLoops.length; i++) {
  17593. var o = this._activeRenderLoops[i];
  17594. o()
  17595. }
  17596. }
  17597. ,
  17598. e.prototype._renderLoop = function() {
  17599. if (!this._contextWasLost) {
  17600. var i = !0;
  17601. !this.renderEvenInBackground && this._windowIsBackground && (i = !1),
  17602. i && (this.beginFrame(),
  17603. this._renderViews() || this._renderFrame(),
  17604. this.endFrame())
  17605. }
  17606. this._activeRenderLoops.length > 0 ? this.customAnimationFrameRequester ? (this.customAnimationFrameRequester.requestID = this._queueNewFrame(this.customAnimationFrameRequester.renderFunction || this._boundRenderFunction, this.customAnimationFrameRequester),
  17607. this._frameHandler = this.customAnimationFrameRequester.requestID) : this.isVRPresenting() ? this._requestVRFrame() : this._frameHandler = this._queueNewFrame(this._boundRenderFunction, this.getHostWindow()) : this._renderingQueueLaunched = !1
  17608. }
  17609. ,
  17610. e.prototype._renderViews = function() {
  17611. return !1
  17612. }
  17613. ,
  17614. e.prototype.switchFullscreen = function(i) {
  17615. this.isFullscreen ? this.exitFullscreen() : this.enterFullscreen(i)
  17616. }
  17617. ,
  17618. e.prototype.enterFullscreen = function(i) {
  17619. this.isFullscreen || (this._pointerLockRequested = i,
  17620. this._renderingCanvas && e._RequestFullscreen(this._renderingCanvas))
  17621. }
  17622. ,
  17623. e.prototype.exitFullscreen = function() {
  17624. this.isFullscreen && e._ExitFullscreen()
  17625. }
  17626. ,
  17627. e.prototype.enterPointerlock = function() {
  17628. this._renderingCanvas && e._RequestPointerlock(this._renderingCanvas)
  17629. }
  17630. ,
  17631. e.prototype.exitPointerlock = function() {
  17632. e._ExitPointerlock()
  17633. }
  17634. ,
  17635. e.prototype.beginFrame = function() {
  17636. this._measureFps(),
  17637. this.onBeginFrameObservable.notifyObservers(this),
  17638. a.prototype.beginFrame.call(this)
  17639. }
  17640. ,
  17641. e.prototype.endFrame = function() {
  17642. a.prototype.endFrame.call(this),
  17643. this._submitVRFrame(),
  17644. this.onEndFrameObservable.notifyObservers(this)
  17645. }
  17646. ,
  17647. e.prototype.resize = function(i) {
  17648. i === void 0 && (i = !1),
  17649. !this.isVRPresenting() && a.prototype.resize.call(this, i)
  17650. }
  17651. ,
  17652. e.prototype.setSize = function(i, o, s) {
  17653. if (s === void 0 && (s = !1),
  17654. !this._renderingCanvas || !a.prototype.setSize.call(this, i, o, s))
  17655. return !1;
  17656. if (this.scenes) {
  17657. for (var c = 0; c < this.scenes.length; c++)
  17658. for (var d = this.scenes[c], _ = 0; _ < d.cameras.length; _++) {
  17659. var b = d.cameras[_];
  17660. b._currentRenderId = 0
  17661. }
  17662. this.onResizeObservable.hasObservers() && this.onResizeObservable.notifyObservers(this)
  17663. }
  17664. return !0
  17665. }
  17666. ,
  17667. e.prototype._deletePipelineContext = function(i) {
  17668. var o = i;
  17669. o && o.program && o.transformFeedback && (this.deleteTransformFeedback(o.transformFeedback),
  17670. o.transformFeedback = null),
  17671. a.prototype._deletePipelineContext.call(this, i)
  17672. }
  17673. ,
  17674. e.prototype.createShaderProgram = function(i, o, s, c, d, _) {
  17675. _ === void 0 && (_ = null),
  17676. d = d || this._gl,
  17677. this.onBeforeShaderCompilationObservable.notifyObservers(this);
  17678. var b = a.prototype.createShaderProgram.call(this, i, o, s, c, d, _);
  17679. return this.onAfterShaderCompilationObservable.notifyObservers(this),
  17680. b
  17681. }
  17682. ,
  17683. e.prototype._createShaderProgram = function(i, o, s, c, d) {
  17684. d === void 0 && (d = null);
  17685. var _ = c.createProgram();
  17686. if (i.program = _,
  17687. !_)
  17688. throw new Error("Unable to create program");
  17689. if (c.attachShader(_, o),
  17690. c.attachShader(_, s),
  17691. this.webGLVersion > 1 && d) {
  17692. var b = this.createTransformFeedback();
  17693. this.bindTransformFeedback(b),
  17694. this.setTranformFeedbackVaryings(_, d),
  17695. i.transformFeedback = b
  17696. }
  17697. return c.linkProgram(_),
  17698. this.webGLVersion > 1 && d && this.bindTransformFeedback(null),
  17699. i.context = c,
  17700. i.vertexShader = o,
  17701. i.fragmentShader = s,
  17702. i.isParallelCompiled || this._finalizePipelineContext(i),
  17703. _
  17704. }
  17705. ,
  17706. e.prototype._releaseTexture = function(i) {
  17707. a.prototype._releaseTexture.call(this, i)
  17708. }
  17709. ,
  17710. e.prototype._releaseRenderTargetWrapper = function(i) {
  17711. a.prototype._releaseRenderTargetWrapper.call(this, i),
  17712. this.scenes.forEach(function(o) {
  17713. o.postProcesses.forEach(function(s) {
  17714. s._outputTexture === i && (s._outputTexture = null)
  17715. }),
  17716. o.cameras.forEach(function(s) {
  17717. s._postProcesses.forEach(function(c) {
  17718. c && c._outputTexture === i && (c._outputTexture = null)
  17719. })
  17720. })
  17721. })
  17722. }
  17723. ,
  17724. e.prototype.getRenderPassNames = function() {
  17725. return this._renderPassNames
  17726. }
  17727. ,
  17728. e.prototype.getCurrentRenderPassName = function() {
  17729. return this._renderPassNames[this.currentRenderPassId]
  17730. }
  17731. ,
  17732. e.prototype.createRenderPassId = function(i) {
  17733. var o = ++e._RenderPassIdCounter;
  17734. return this._renderPassNames[o] = i != null ? i : "NONAME",
  17735. o
  17736. }
  17737. ,
  17738. e.prototype.releaseRenderPassId = function(i) {
  17739. this._renderPassNames[i] = void 0;
  17740. for (var o = 0; o < this.scenes.length; ++o)
  17741. for (var s = this.scenes[o], c = 0; c < s.meshes.length; ++c) {
  17742. var d = s.meshes[c];
  17743. if (d.subMeshes)
  17744. for (var _ = 0; _ < d.subMeshes.length; ++_) {
  17745. var b = d.subMeshes[_];
  17746. b._removeDrawWrapper(i)
  17747. }
  17748. }
  17749. }
  17750. ,
  17751. e.prototype._rescaleTexture = function(i, o, s, c, d) {
  17752. var _ = this;
  17753. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, this._gl.LINEAR),
  17754. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, this._gl.LINEAR),
  17755. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_S, this._gl.CLAMP_TO_EDGE),
  17756. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_T, this._gl.CLAMP_TO_EDGE);
  17757. var b = this.createRenderTargetTexture({
  17758. width: o.width,
  17759. height: o.height
  17760. }, {
  17761. generateMipMaps: !1,
  17762. type: 0,
  17763. samplingMode: 2,
  17764. generateDepthBuffer: !1,
  17765. generateStencilBuffer: !1
  17766. });
  17767. !this._rescalePostProcess && e._RescalePostProcessFactory && (this._rescalePostProcess = e._RescalePostProcessFactory(this)),
  17768. this._rescalePostProcess.externalTextureSamplerBinding = !0,
  17769. this._rescalePostProcess.getEffect().executeWhenCompiled(function() {
  17770. _._rescalePostProcess.onApply = function(j) {
  17771. j._bindTexture("textureSampler", i)
  17772. }
  17773. ;
  17774. var k = s;
  17775. k || (k = _.scenes[_.scenes.length - 1]),
  17776. k.postProcessManager.directRender([_._rescalePostProcess], b, !0),
  17777. _._bindTextureDirectly(_._gl.TEXTURE_2D, o, !0),
  17778. _._gl.copyTexImage2D(_._gl.TEXTURE_2D, 0, c, 0, 0, o.width, o.height, 0),
  17779. _.unBindFramebuffer(b),
  17780. b.dispose(),
  17781. d && d()
  17782. })
  17783. }
  17784. ,
  17785. e.prototype.getFps = function() {
  17786. return this._fps
  17787. }
  17788. ,
  17789. e.prototype.getDeltaTime = function() {
  17790. return this._deltaTime
  17791. }
  17792. ,
  17793. e.prototype._measureFps = function() {
  17794. this._performanceMonitor.sampleFrame(),
  17795. this._fps = this._performanceMonitor.averageFPS,
  17796. this._deltaTime = this._performanceMonitor.instantaneousFrameTime || 0
  17797. }
  17798. ,
  17799. e.prototype._uploadImageToTexture = function(i, o, s, c) {
  17800. s === void 0 && (s = 0),
  17801. c === void 0 && (c = 0);
  17802. var d = this._gl
  17803. , _ = this._getWebGLTextureType(i.type)
  17804. , b = this._getInternalFormat(i.format)
  17805. , k = this._getRGBABufferInternalSizedFormat(i.type, b)
  17806. , j = i.isCube ? d.TEXTURE_CUBE_MAP : d.TEXTURE_2D;
  17807. this._bindTextureDirectly(j, i, !0),
  17808. this._unpackFlipY(i.invertY);
  17809. var $ = d.TEXTURE_2D;
  17810. i.isCube && ($ = d.TEXTURE_CUBE_MAP_POSITIVE_X + s),
  17811. d.texImage2D($, c, k, b, _, o),
  17812. this._bindTextureDirectly(j, null, !0)
  17813. }
  17814. ,
  17815. e.prototype.updateTextureComparisonFunction = function(i, o) {
  17816. if (this.webGLVersion === 1) {
  17817. Logger$2.Error("WebGL 1 does not support texture comparison.");
  17818. return
  17819. }
  17820. var s = this._gl;
  17821. i.isCube ? (this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, i, !0),
  17822. o === 0 ? (s.texParameteri(s.TEXTURE_CUBE_MAP, s.TEXTURE_COMPARE_FUNC, 515),
  17823. s.texParameteri(s.TEXTURE_CUBE_MAP, s.TEXTURE_COMPARE_MODE, s.NONE)) : (s.texParameteri(s.TEXTURE_CUBE_MAP, s.TEXTURE_COMPARE_FUNC, o),
  17824. s.texParameteri(s.TEXTURE_CUBE_MAP, s.TEXTURE_COMPARE_MODE, s.COMPARE_REF_TO_TEXTURE)),
  17825. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null)) : (this._bindTextureDirectly(this._gl.TEXTURE_2D, i, !0),
  17826. o === 0 ? (s.texParameteri(s.TEXTURE_2D, s.TEXTURE_COMPARE_FUNC, 515),
  17827. s.texParameteri(s.TEXTURE_2D, s.TEXTURE_COMPARE_MODE, s.NONE)) : (s.texParameteri(s.TEXTURE_2D, s.TEXTURE_COMPARE_FUNC, o),
  17828. s.texParameteri(s.TEXTURE_2D, s.TEXTURE_COMPARE_MODE, s.COMPARE_REF_TO_TEXTURE)),
  17829. this._bindTextureDirectly(this._gl.TEXTURE_2D, null)),
  17830. i._comparisonFunction = o
  17831. }
  17832. ,
  17833. e.prototype.createInstancesBuffer = function(i) {
  17834. var o = this._gl.createBuffer();
  17835. if (!o)
  17836. throw new Error("Unable to create instance buffer");
  17837. var s = new WebGLDataBuffer(o);
  17838. return s.capacity = i,
  17839. this.bindArrayBuffer(s),
  17840. this._gl.bufferData(this._gl.ARRAY_BUFFER, i, this._gl.DYNAMIC_DRAW),
  17841. s.references = 1,
  17842. s
  17843. }
  17844. ,
  17845. e.prototype.deleteInstancesBuffer = function(i) {
  17846. this._gl.deleteBuffer(i)
  17847. }
  17848. ,
  17849. e.prototype._clientWaitAsync = function(i, o, s) {
  17850. o === void 0 && (o = 0),
  17851. s === void 0 && (s = 10);
  17852. var c = this._gl;
  17853. return new Promise(function(d, _) {
  17854. var b = function() {
  17855. var k = c.clientWaitSync(i, o, 0);
  17856. if (k == c.WAIT_FAILED) {
  17857. _();
  17858. return
  17859. }
  17860. if (k == c.TIMEOUT_EXPIRED) {
  17861. setTimeout(b, s);
  17862. return
  17863. }
  17864. d()
  17865. };
  17866. b()
  17867. }
  17868. )
  17869. }
  17870. ,
  17871. e.prototype._readPixelsAsync = function(i, o, s, c, d, _, b) {
  17872. if (this._webGLVersion < 2)
  17873. throw new Error("_readPixelsAsync only work on WebGL2+");
  17874. var k = this._gl
  17875. , j = k.createBuffer();
  17876. k.bindBuffer(k.PIXEL_PACK_BUFFER, j),
  17877. k.bufferData(k.PIXEL_PACK_BUFFER, b.byteLength, k.STREAM_READ),
  17878. k.readPixels(i, o, s, c, d, _, 0),
  17879. k.bindBuffer(k.PIXEL_PACK_BUFFER, null);
  17880. var $ = k.fenceSync(k.SYNC_GPU_COMMANDS_COMPLETE, 0);
  17881. return $ ? (k.flush(),
  17882. this._clientWaitAsync($, 0, 10).then(function() {
  17883. return k.deleteSync($),
  17884. k.bindBuffer(k.PIXEL_PACK_BUFFER, j),
  17885. k.getBufferSubData(k.PIXEL_PACK_BUFFER, 0, b),
  17886. k.bindBuffer(k.PIXEL_PACK_BUFFER, null),
  17887. k.deleteBuffer(j),
  17888. b
  17889. })) : null
  17890. }
  17891. ,
  17892. e.prototype.dispose = function() {
  17893. for (this.hideLoadingUI(),
  17894. this.onNewSceneAddedObservable.clear(); this.postProcesses.length; )
  17895. this.postProcesses[0].dispose();
  17896. for (this._rescalePostProcess && this._rescalePostProcess.dispose(); this.scenes.length; )
  17897. this.scenes[0].dispose();
  17898. for (; this._virtualScenes.length; )
  17899. this._virtualScenes[0].dispose();
  17900. e.Instances.length === 1 && e.audioEngine && (e.audioEngine.dispose(),
  17901. e.audioEngine = null),
  17902. this.disableVR(),
  17903. this.deviceInputSystem && this.deviceInputSystem.dispose(),
  17904. IsWindowObjectExist() && (window.removeEventListener("blur", this._onBlur),
  17905. window.removeEventListener("focus", this._onFocus),
  17906. this._renderingCanvas && (this._renderingCanvas.removeEventListener("focus", this._onCanvasFocus),
  17907. this._renderingCanvas.removeEventListener("blur", this._onCanvasBlur),
  17908. this._renderingCanvas.removeEventListener("pointerout", this._onCanvasPointerOut)),
  17909. IsDocumentAvailable() && (document.removeEventListener("fullscreenchange", this._onFullscreenChange),
  17910. document.removeEventListener("mozfullscreenchange", this._onFullscreenChange),
  17911. document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange),
  17912. document.removeEventListener("msfullscreenchange", this._onFullscreenChange),
  17913. document.removeEventListener("pointerlockchange", this._onPointerLockChange),
  17914. document.removeEventListener("mspointerlockchange", this._onPointerLockChange),
  17915. document.removeEventListener("mozpointerlockchange", this._onPointerLockChange),
  17916. document.removeEventListener("webkitpointerlockchange", this._onPointerLockChange))),
  17917. a.prototype.dispose.call(this);
  17918. var i = e.Instances.indexOf(this);
  17919. i >= 0 && e.Instances.splice(i, 1),
  17920. this.onResizeObservable.clear(),
  17921. this.onCanvasBlurObservable.clear(),
  17922. this.onCanvasFocusObservable.clear(),
  17923. this.onCanvasPointerOutObservable.clear(),
  17924. this.onBeginFrameObservable.clear(),
  17925. this.onEndFrameObservable.clear()
  17926. }
  17927. ,
  17928. e.prototype._disableTouchAction = function() {
  17929. !this._renderingCanvas || !this._renderingCanvas.setAttribute || (this._renderingCanvas.setAttribute("touch-action", "none"),
  17930. this._renderingCanvas.style.touchAction = "none",
  17931. this._renderingCanvas.style.msTouchAction = "none")
  17932. }
  17933. ,
  17934. e.prototype.displayLoadingUI = function() {
  17935. if (!!IsWindowObjectExist()) {
  17936. var i = this.loadingScreen;
  17937. i && i.displayLoadingUI()
  17938. }
  17939. }
  17940. ,
  17941. e.prototype.hideLoadingUI = function() {
  17942. if (!!IsWindowObjectExist()) {
  17943. var i = this._loadingScreen;
  17944. i && i.hideLoadingUI()
  17945. }
  17946. }
  17947. ,
  17948. Object.defineProperty(e.prototype, "loadingScreen", {
  17949. get: function() {
  17950. return !this._loadingScreen && this._renderingCanvas && (this._loadingScreen = e.DefaultLoadingScreenFactory(this._renderingCanvas)),
  17951. this._loadingScreen
  17952. },
  17953. set: function(i) {
  17954. this._loadingScreen = i
  17955. },
  17956. enumerable: !1,
  17957. configurable: !0
  17958. }),
  17959. Object.defineProperty(e.prototype, "loadingUIText", {
  17960. set: function(i) {
  17961. this.loadingScreen.loadingUIText = i
  17962. },
  17963. enumerable: !1,
  17964. configurable: !0
  17965. }),
  17966. Object.defineProperty(e.prototype, "loadingUIBackgroundColor", {
  17967. set: function(i) {
  17968. this.loadingScreen.loadingUIBackgroundColor = i
  17969. },
  17970. enumerable: !1,
  17971. configurable: !0
  17972. }),
  17973. e.prototype.createVideoElement = function(i) {
  17974. return document.createElement("video")
  17975. }
  17976. ,
  17977. e._RequestPointerlock = function(i) {
  17978. i.requestPointerLock = i.requestPointerLock || i.msRequestPointerLock || i.mozRequestPointerLock || i.webkitRequestPointerLock,
  17979. i.requestPointerLock && i.requestPointerLock()
  17980. }
  17981. ,
  17982. e._ExitPointerlock = function() {
  17983. var i = document;
  17984. document.exitPointerLock = document.exitPointerLock || i.msExitPointerLock || i.mozExitPointerLock || i.webkitExitPointerLock,
  17985. document.exitPointerLock && document.exitPointerLock()
  17986. }
  17987. ,
  17988. e._RequestFullscreen = function(i) {
  17989. var o = i.requestFullscreen || i.msRequestFullscreen || i.webkitRequestFullscreen || i.mozRequestFullScreen;
  17990. !o || o.call(i)
  17991. }
  17992. ,
  17993. e._ExitFullscreen = function() {
  17994. var i = document;
  17995. document.exitFullscreen ? document.exitFullscreen() : i.mozCancelFullScreen ? i.mozCancelFullScreen() : i.webkitCancelFullScreen ? i.webkitCancelFullScreen() : i.msCancelFullScreen && i.msCancelFullScreen()
  17996. }
  17997. ,
  17998. e.prototype.getFontOffset = function(i) {
  17999. var o = document.createElement("span");
  18000. o.innerHTML = "Hg",
  18001. o.setAttribute("style", "font: " + i + " !important");
  18002. var s = document.createElement("div");
  18003. s.style.display = "inline-block",
  18004. s.style.width = "1px",
  18005. s.style.height = "0px",
  18006. s.style.verticalAlign = "bottom";
  18007. var c = document.createElement("div");
  18008. c.style.whiteSpace = "nowrap",
  18009. c.appendChild(o),
  18010. c.appendChild(s),
  18011. document.body.appendChild(c);
  18012. var d = 0
  18013. , _ = 0;
  18014. try {
  18015. _ = s.getBoundingClientRect().top - o.getBoundingClientRect().top,
  18016. s.style.verticalAlign = "baseline",
  18017. d = s.getBoundingClientRect().top - o.getBoundingClientRect().top
  18018. } finally {
  18019. document.body.removeChild(c)
  18020. }
  18021. return {
  18022. ascent: d,
  18023. height: _,
  18024. descent: _ - d
  18025. }
  18026. }
  18027. ,
  18028. e.ALPHA_DISABLE = 0,
  18029. e.ALPHA_ADD = 1,
  18030. e.ALPHA_COMBINE = 2,
  18031. e.ALPHA_SUBTRACT = 3,
  18032. e.ALPHA_MULTIPLY = 4,
  18033. e.ALPHA_MAXIMIZED = 5,
  18034. e.ALPHA_ONEONE = 6,
  18035. e.ALPHA_PREMULTIPLIED = 7,
  18036. e.ALPHA_PREMULTIPLIED_PORTERDUFF = 8,
  18037. e.ALPHA_INTERPOLATE = 9,
  18038. e.ALPHA_SCREENMODE = 10,
  18039. e.DELAYLOADSTATE_NONE = 0,
  18040. e.DELAYLOADSTATE_LOADED = 1,
  18041. e.DELAYLOADSTATE_LOADING = 2,
  18042. e.DELAYLOADSTATE_NOTLOADED = 4,
  18043. e.NEVER = 512,
  18044. e.ALWAYS = 519,
  18045. e.LESS = 513,
  18046. e.EQUAL = 514,
  18047. e.LEQUAL = 515,
  18048. e.GREATER = 516,
  18049. e.GEQUAL = 518,
  18050. e.NOTEQUAL = 517,
  18051. e.KEEP = 7680,
  18052. e.REPLACE = 7681,
  18053. e.INCR = 7682,
  18054. e.DECR = 7683,
  18055. e.INVERT = 5386,
  18056. e.INCR_WRAP = 34055,
  18057. e.DECR_WRAP = 34056,
  18058. e.TEXTURE_CLAMP_ADDRESSMODE = 0,
  18059. e.TEXTURE_WRAP_ADDRESSMODE = 1,
  18060. e.TEXTURE_MIRROR_ADDRESSMODE = 2,
  18061. e.TEXTUREFORMAT_ALPHA = 0,
  18062. e.TEXTUREFORMAT_LUMINANCE = 1,
  18063. e.TEXTUREFORMAT_LUMINANCE_ALPHA = 2,
  18064. e.TEXTUREFORMAT_RGB = 4,
  18065. e.TEXTUREFORMAT_RGBA = 5,
  18066. e.TEXTUREFORMAT_RED = 6,
  18067. e.TEXTUREFORMAT_R = 6,
  18068. e.TEXTUREFORMAT_RG = 7,
  18069. e.TEXTUREFORMAT_RED_INTEGER = 8,
  18070. e.TEXTUREFORMAT_R_INTEGER = 8,
  18071. e.TEXTUREFORMAT_RG_INTEGER = 9,
  18072. e.TEXTUREFORMAT_RGB_INTEGER = 10,
  18073. e.TEXTUREFORMAT_RGBA_INTEGER = 11,
  18074. e.TEXTURETYPE_UNSIGNED_BYTE = 0,
  18075. e.TEXTURETYPE_UNSIGNED_INT = 0,
  18076. e.TEXTURETYPE_FLOAT = 1,
  18077. e.TEXTURETYPE_HALF_FLOAT = 2,
  18078. e.TEXTURETYPE_BYTE = 3,
  18079. e.TEXTURETYPE_SHORT = 4,
  18080. e.TEXTURETYPE_UNSIGNED_SHORT = 5,
  18081. e.TEXTURETYPE_INT = 6,
  18082. e.TEXTURETYPE_UNSIGNED_INTEGER = 7,
  18083. e.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = 8,
  18084. e.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = 9,
  18085. e.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = 10,
  18086. e.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = 11,
  18087. e.TEXTURETYPE_UNSIGNED_INT_24_8 = 12,
  18088. e.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = 13,
  18089. e.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = 14,
  18090. e.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = 15,
  18091. e.TEXTURE_NEAREST_SAMPLINGMODE = 1,
  18092. e.TEXTURE_BILINEAR_SAMPLINGMODE = 2,
  18093. e.TEXTURE_TRILINEAR_SAMPLINGMODE = 3,
  18094. e.TEXTURE_NEAREST_NEAREST_MIPLINEAR = 8,
  18095. e.TEXTURE_LINEAR_LINEAR_MIPNEAREST = 11,
  18096. e.TEXTURE_LINEAR_LINEAR_MIPLINEAR = 3,
  18097. e.TEXTURE_NEAREST_NEAREST_MIPNEAREST = 4,
  18098. e.TEXTURE_NEAREST_LINEAR_MIPNEAREST = 5,
  18099. e.TEXTURE_NEAREST_LINEAR_MIPLINEAR = 6,
  18100. e.TEXTURE_NEAREST_LINEAR = 7,
  18101. e.TEXTURE_NEAREST_NEAREST = 1,
  18102. e.TEXTURE_LINEAR_NEAREST_MIPNEAREST = 9,
  18103. e.TEXTURE_LINEAR_NEAREST_MIPLINEAR = 10,
  18104. e.TEXTURE_LINEAR_LINEAR = 2,
  18105. e.TEXTURE_LINEAR_NEAREST = 12,
  18106. e.TEXTURE_EXPLICIT_MODE = 0,
  18107. e.TEXTURE_SPHERICAL_MODE = 1,
  18108. e.TEXTURE_PLANAR_MODE = 2,
  18109. e.TEXTURE_CUBIC_MODE = 3,
  18110. e.TEXTURE_PROJECTION_MODE = 4,
  18111. e.TEXTURE_SKYBOX_MODE = 5,
  18112. e.TEXTURE_INVCUBIC_MODE = 6,
  18113. e.TEXTURE_EQUIRECTANGULAR_MODE = 7,
  18114. e.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = 8,
  18115. e.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = 9,
  18116. e.SCALEMODE_FLOOR = 1,
  18117. e.SCALEMODE_NEAREST = 2,
  18118. e.SCALEMODE_CEILING = 3,
  18119. e._RescalePostProcessFactory = null,
  18120. e._RenderPassIdCounter = 0,
  18121. e
  18122. }(ThinEngine)
  18123. , RenderTargetWrapper = function() {
  18124. function a(e, i, o, s) {
  18125. this._textures = null,
  18126. this._attachments = null,
  18127. this._generateStencilBuffer = !1,
  18128. this._generateDepthBuffer = !1,
  18129. this._depthStencilTextureWithStencil = !1,
  18130. this._isMulti = e,
  18131. this._isCube = i,
  18132. this._size = o,
  18133. this._engine = s,
  18134. this._depthStencilTexture = null
  18135. }
  18136. return Object.defineProperty(a.prototype, "isCube", {
  18137. get: function() {
  18138. return this._isCube
  18139. },
  18140. enumerable: !1,
  18141. configurable: !0
  18142. }),
  18143. Object.defineProperty(a.prototype, "isMulti", {
  18144. get: function() {
  18145. return this._isMulti
  18146. },
  18147. enumerable: !1,
  18148. configurable: !0
  18149. }),
  18150. Object.defineProperty(a.prototype, "is2DArray", {
  18151. get: function() {
  18152. return this.layers > 0
  18153. },
  18154. enumerable: !1,
  18155. configurable: !0
  18156. }),
  18157. Object.defineProperty(a.prototype, "size", {
  18158. get: function() {
  18159. return this.width
  18160. },
  18161. enumerable: !1,
  18162. configurable: !0
  18163. }),
  18164. Object.defineProperty(a.prototype, "width", {
  18165. get: function() {
  18166. return this._size.width || this._size
  18167. },
  18168. enumerable: !1,
  18169. configurable: !0
  18170. }),
  18171. Object.defineProperty(a.prototype, "height", {
  18172. get: function() {
  18173. return this._size.height || this._size
  18174. },
  18175. enumerable: !1,
  18176. configurable: !0
  18177. }),
  18178. Object.defineProperty(a.prototype, "layers", {
  18179. get: function() {
  18180. return this._size.layers || 0
  18181. },
  18182. enumerable: !1,
  18183. configurable: !0
  18184. }),
  18185. Object.defineProperty(a.prototype, "texture", {
  18186. get: function() {
  18187. var e, i;
  18188. return (i = (e = this._textures) === null || e === void 0 ? void 0 : e[0]) !== null && i !== void 0 ? i : null
  18189. },
  18190. enumerable: !1,
  18191. configurable: !0
  18192. }),
  18193. Object.defineProperty(a.prototype, "textures", {
  18194. get: function() {
  18195. return this._textures
  18196. },
  18197. enumerable: !1,
  18198. configurable: !0
  18199. }),
  18200. Object.defineProperty(a.prototype, "samples", {
  18201. get: function() {
  18202. var e, i;
  18203. return (i = (e = this.texture) === null || e === void 0 ? void 0 : e.samples) !== null && i !== void 0 ? i : 1
  18204. },
  18205. enumerable: !1,
  18206. configurable: !0
  18207. }),
  18208. a.prototype.setSamples = function(e, i, o) {
  18209. return i === void 0 && (i = !0),
  18210. o === void 0 && (o = !1),
  18211. this.samples === e && !o ? e : this._isMulti ? this._engine.updateMultipleRenderTargetTextureSampleCount(this, e, i) : this._engine.updateRenderTargetTextureSampleCount(this, e)
  18212. }
  18213. ,
  18214. a.prototype.setTextures = function(e) {
  18215. Array.isArray(e) ? this._textures = e : e ? this._textures = [e] : this._textures = null
  18216. }
  18217. ,
  18218. a.prototype.setTexture = function(e, i, o) {
  18219. i === void 0 && (i = 0),
  18220. o === void 0 && (o = !0),
  18221. this._textures || (this._textures = []),
  18222. this._textures[i] && o && this._textures[i].dispose(),
  18223. this._textures[i] = e
  18224. }
  18225. ,
  18226. a.prototype.createDepthStencilTexture = function(e, i, o, s, c) {
  18227. var d;
  18228. return e === void 0 && (e = 0),
  18229. i === void 0 && (i = !0),
  18230. o === void 0 && (o = !1),
  18231. s === void 0 && (s = 1),
  18232. c === void 0 && (c = 15),
  18233. (d = this._depthStencilTexture) === null || d === void 0 || d.dispose(),
  18234. this._depthStencilTextureWithStencil = o,
  18235. this._depthStencilTexture = this._engine.createDepthStencilTexture(this._size, {
  18236. bilinearFiltering: i,
  18237. comparisonFunction: e,
  18238. generateStencil: o,
  18239. isCube: this._isCube,
  18240. samples: s,
  18241. depthTextureFormat: c
  18242. }, this),
  18243. this._depthStencilTexture
  18244. }
  18245. ,
  18246. a.prototype._shareDepth = function(e) {
  18247. this._depthStencilTexture && (e._depthStencilTexture && e._depthStencilTexture.dispose(),
  18248. e._depthStencilTexture = this._depthStencilTexture,
  18249. this._depthStencilTexture.incrementReferences())
  18250. }
  18251. ,
  18252. a.prototype._swapAndDie = function(e) {
  18253. this.texture && this.texture._swapAndDie(e),
  18254. this._textures = null,
  18255. this.dispose(!0)
  18256. }
  18257. ,
  18258. a.prototype._cloneRenderTargetWrapper = function() {
  18259. var e, i, o, s, c, d, _ = null;
  18260. if (this._isMulti) {
  18261. var b = this.textures;
  18262. if (b && b.length > 0) {
  18263. var k = !1
  18264. , j = b.length
  18265. , $ = b[b.length - 1]._source;
  18266. ($ === InternalTextureSource.Depth || $ === InternalTextureSource.DepthStencil) && (k = !0,
  18267. j--);
  18268. for (var _e = [], et = [], tt = 0; tt < j; ++tt) {
  18269. var rt = b[tt];
  18270. _e.push(rt.samplingMode),
  18271. et.push(rt.type)
  18272. }
  18273. var it = {
  18274. samplingModes: _e,
  18275. generateMipMaps: b[0].generateMipMaps,
  18276. generateDepthBuffer: this._generateDepthBuffer,
  18277. generateStencilBuffer: this._generateStencilBuffer,
  18278. generateDepthTexture: k,
  18279. types: et,
  18280. textureCount: j
  18281. }
  18282. , nt = {
  18283. width: this.width,
  18284. height: this.height
  18285. };
  18286. _ = this._engine.createMultipleRenderTarget(nt, it)
  18287. }
  18288. } else {
  18289. var ot = {};
  18290. if (ot.generateDepthBuffer = this._generateDepthBuffer,
  18291. ot.generateMipMaps = (i = (e = this.texture) === null || e === void 0 ? void 0 : e.generateMipMaps) !== null && i !== void 0 ? i : !1,
  18292. ot.generateStencilBuffer = this._generateStencilBuffer,
  18293. ot.samplingMode = (o = this.texture) === null || o === void 0 ? void 0 : o.samplingMode,
  18294. ot.type = (s = this.texture) === null || s === void 0 ? void 0 : s.type,
  18295. ot.format = (c = this.texture) === null || c === void 0 ? void 0 : c.format,
  18296. this.isCube)
  18297. _ = this._engine.createRenderTargetCubeTexture(this.width, ot);
  18298. else {
  18299. var nt = {
  18300. width: this.width,
  18301. height: this.height,
  18302. layers: this.is2DArray ? (d = this.texture) === null || d === void 0 ? void 0 : d.depth : void 0
  18303. };
  18304. _ = this._engine.createRenderTargetTexture(nt, ot)
  18305. }
  18306. _.texture.isReady = !0
  18307. }
  18308. return _
  18309. }
  18310. ,
  18311. a.prototype._swapRenderTargetWrapper = function(e) {
  18312. if (this._textures && e._textures)
  18313. for (var i = 0; i < this._textures.length; ++i)
  18314. this._textures[i]._swapAndDie(e._textures[i], !1),
  18315. e._textures[i].isReady = !0;
  18316. this._depthStencilTexture && e._depthStencilTexture && (this._depthStencilTexture._swapAndDie(e._depthStencilTexture),
  18317. e._depthStencilTexture.isReady = !0),
  18318. this._textures = null,
  18319. this._depthStencilTexture = null
  18320. }
  18321. ,
  18322. a.prototype._rebuild = function() {
  18323. var e = this._cloneRenderTargetWrapper();
  18324. if (!!e) {
  18325. if (this._depthStencilTexture) {
  18326. var i = this._depthStencilTexture.samplingMode
  18327. , o = i === 2 || i === 3 || i === 11;
  18328. e.createDepthStencilTexture(this._depthStencilTexture._comparisonFunction, o, this._depthStencilTextureWithStencil, this._depthStencilTexture.samples)
  18329. }
  18330. this.samples > 1 && e.setSamples(this.samples),
  18331. e._swapRenderTargetWrapper(this),
  18332. e.dispose()
  18333. }
  18334. }
  18335. ,
  18336. a.prototype.releaseTextures = function() {
  18337. var e, i;
  18338. if (this._textures)
  18339. for (var o = 0; (i = o < ((e = this._textures) === null || e === void 0 ? void 0 : e.length)) !== null && i !== void 0 && i; ++o)
  18340. this._textures[o].dispose();
  18341. this._textures = null
  18342. }
  18343. ,
  18344. a.prototype.dispose = function(e) {
  18345. var i;
  18346. e === void 0 && (e = !1),
  18347. e || ((i = this._depthStencilTexture) === null || i === void 0 || i.dispose(),
  18348. this._depthStencilTexture = null,
  18349. this.releaseTextures()),
  18350. this._engine._releaseRenderTargetWrapper(this)
  18351. }
  18352. ,
  18353. a
  18354. }()
  18355. , NullEngineOptions = function() {
  18356. function a() {
  18357. this.renderWidth = 512,
  18358. this.renderHeight = 256,
  18359. this.textureSize = 512,
  18360. this.deterministicLockstep = !1,
  18361. this.lockstepMaxSteps = 4
  18362. }
  18363. return a
  18364. }();
  18365. (function(a) {
  18366. __extends(e, a);
  18367. function e(i) {
  18368. i === void 0 && (i = new NullEngineOptions);
  18369. var o = a.call(this, null) || this;
  18370. Engine.Instances.push(o),
  18371. i.deterministicLockstep === void 0 && (i.deterministicLockstep = !1),
  18372. i.lockstepMaxSteps === void 0 && (i.lockstepMaxSteps = 4),
  18373. o._options = i,
  18374. PerformanceConfigurator.SetMatrixPrecision(!!i.useHighPrecisionMatrix),
  18375. o._caps = {
  18376. maxTexturesImageUnits: 16,
  18377. maxVertexTextureImageUnits: 16,
  18378. maxCombinedTexturesImageUnits: 32,
  18379. maxTextureSize: 512,
  18380. maxCubemapTextureSize: 512,
  18381. maxRenderTextureSize: 512,
  18382. maxVertexAttribs: 16,
  18383. maxVaryingVectors: 16,
  18384. maxFragmentUniformVectors: 16,
  18385. maxVertexUniformVectors: 16,
  18386. standardDerivatives: !1,
  18387. astc: null,
  18388. pvrtc: null,
  18389. etc1: null,
  18390. etc2: null,
  18391. bptc: null,
  18392. maxAnisotropy: 0,
  18393. uintIndices: !1,
  18394. fragmentDepthSupported: !1,
  18395. highPrecisionShaderSupported: !0,
  18396. colorBufferFloat: !1,
  18397. textureFloat: !1,
  18398. textureFloatLinearFiltering: !1,
  18399. textureFloatRender: !1,
  18400. textureHalfFloat: !1,
  18401. textureHalfFloatLinearFiltering: !1,
  18402. textureHalfFloatRender: !1,
  18403. textureLOD: !1,
  18404. drawBuffersExtension: !1,
  18405. depthTextureExtension: !1,
  18406. vertexArrayObject: !1,
  18407. instancedArrays: !1,
  18408. supportOcclusionQuery: !1,
  18409. canUseTimestampForTimerQuery: !1,
  18410. maxMSAASamples: 1,
  18411. blendMinMax: !1,
  18412. canUseGLInstanceID: !1,
  18413. canUseGLVertexID: !1,
  18414. supportComputeShaders: !1,
  18415. supportSRGBBuffers: !1
  18416. },
  18417. o._features = {
  18418. forceBitmapOverHTMLImageElement: !1,
  18419. supportRenderAndCopyToLodForFloatTextures: !1,
  18420. supportDepthStencilTexture: !1,
  18421. supportShadowSamplers: !1,
  18422. uniformBufferHardCheckMatrix: !1,
  18423. allowTexturePrefiltering: !1,
  18424. trackUbosInFrame: !1,
  18425. checkUbosContentBeforeUpload: !1,
  18426. supportCSM: !1,
  18427. basisNeedsPOT: !1,
  18428. support3DTextures: !1,
  18429. needTypeSuffixInShaderConstants: !1,
  18430. supportMSAA: !1,
  18431. supportSSAO2: !1,
  18432. supportExtendedTextureFormats: !1,
  18433. supportSwitchCaseInShader: !1,
  18434. supportSyncTextureRead: !1,
  18435. needsInvertingBitmap: !1,
  18436. useUBOBindingCache: !1,
  18437. needShaderCodeInlining: !1,
  18438. needToAlwaysBindUniformBuffers: !1,
  18439. supportRenderPasses: !0,
  18440. _collectUbosUpdatedInFrame: !1
  18441. },
  18442. Logger$2.Log("Babylon.js v" + Engine.Version + " - Null engine");
  18443. var s = typeof self != "undefined" ? self : typeof global != "undefined" ? global : window;
  18444. return typeof URL == "undefined" && (s.URL = {
  18445. createObjectURL: function() {},
  18446. revokeObjectURL: function() {}
  18447. }),
  18448. typeof Blob == "undefined" && (s.Blob = function() {}
  18449. ),
  18450. o
  18451. }
  18452. return e.prototype.isDeterministicLockStep = function() {
  18453. return this._options.deterministicLockstep
  18454. }
  18455. ,
  18456. e.prototype.getLockstepMaxSteps = function() {
  18457. return this._options.lockstepMaxSteps
  18458. }
  18459. ,
  18460. e.prototype.getHardwareScalingLevel = function() {
  18461. return 1
  18462. }
  18463. ,
  18464. e.prototype.createVertexBuffer = function(i) {
  18465. var o = new DataBuffer;
  18466. return o.references = 1,
  18467. o
  18468. }
  18469. ,
  18470. e.prototype.createIndexBuffer = function(i) {
  18471. var o = new DataBuffer;
  18472. return o.references = 1,
  18473. o
  18474. }
  18475. ,
  18476. e.prototype.clear = function(i, o, s, c) {}
  18477. ,
  18478. e.prototype.getRenderWidth = function(i) {
  18479. return i === void 0 && (i = !1),
  18480. !i && this._currentRenderTarget ? this._currentRenderTarget.width : this._options.renderWidth
  18481. }
  18482. ,
  18483. e.prototype.getRenderHeight = function(i) {
  18484. return i === void 0 && (i = !1),
  18485. !i && this._currentRenderTarget ? this._currentRenderTarget.height : this._options.renderHeight
  18486. }
  18487. ,
  18488. e.prototype.setViewport = function(i, o, s) {
  18489. this._cachedViewport = i
  18490. }
  18491. ,
  18492. e.prototype.createShaderProgram = function(i, o, s, c, d) {
  18493. return {
  18494. __SPECTOR_rebuildProgram: null
  18495. }
  18496. }
  18497. ,
  18498. e.prototype.getUniforms = function(i, o) {
  18499. return []
  18500. }
  18501. ,
  18502. e.prototype.getAttributes = function(i, o) {
  18503. return []
  18504. }
  18505. ,
  18506. e.prototype.bindSamplers = function(i) {
  18507. this._currentEffect = null
  18508. }
  18509. ,
  18510. e.prototype.enableEffect = function(i) {
  18511. i = i !== null && DrawWrapper.IsWrapper(i) ? i.effect : i,
  18512. this._currentEffect = i,
  18513. i && (i.onBind && i.onBind(i),
  18514. i._onBindObservable && i._onBindObservable.notifyObservers(i))
  18515. }
  18516. ,
  18517. e.prototype.setState = function(i, o, s, c, d, _, b) {}
  18518. ,
  18519. e.prototype.setIntArray = function(i, o) {
  18520. return !0
  18521. }
  18522. ,
  18523. e.prototype.setIntArray2 = function(i, o) {
  18524. return !0
  18525. }
  18526. ,
  18527. e.prototype.setIntArray3 = function(i, o) {
  18528. return !0
  18529. }
  18530. ,
  18531. e.prototype.setIntArray4 = function(i, o) {
  18532. return !0
  18533. }
  18534. ,
  18535. e.prototype.setFloatArray = function(i, o) {
  18536. return !0
  18537. }
  18538. ,
  18539. e.prototype.setFloatArray2 = function(i, o) {
  18540. return !0
  18541. }
  18542. ,
  18543. e.prototype.setFloatArray3 = function(i, o) {
  18544. return !0
  18545. }
  18546. ,
  18547. e.prototype.setFloatArray4 = function(i, o) {
  18548. return !0
  18549. }
  18550. ,
  18551. e.prototype.setArray = function(i, o) {
  18552. return !0
  18553. }
  18554. ,
  18555. e.prototype.setArray2 = function(i, o) {
  18556. return !0
  18557. }
  18558. ,
  18559. e.prototype.setArray3 = function(i, o) {
  18560. return !0
  18561. }
  18562. ,
  18563. e.prototype.setArray4 = function(i, o) {
  18564. return !0
  18565. }
  18566. ,
  18567. e.prototype.setMatrices = function(i, o) {
  18568. return !0
  18569. }
  18570. ,
  18571. e.prototype.setMatrix3x3 = function(i, o) {
  18572. return !0
  18573. }
  18574. ,
  18575. e.prototype.setMatrix2x2 = function(i, o) {
  18576. return !0
  18577. }
  18578. ,
  18579. e.prototype.setFloat = function(i, o) {
  18580. return !0
  18581. }
  18582. ,
  18583. e.prototype.setFloat2 = function(i, o, s) {
  18584. return !0
  18585. }
  18586. ,
  18587. e.prototype.setFloat3 = function(i, o, s, c) {
  18588. return !0
  18589. }
  18590. ,
  18591. e.prototype.setBool = function(i, o) {
  18592. return !0
  18593. }
  18594. ,
  18595. e.prototype.setFloat4 = function(i, o, s, c, d) {
  18596. return !0
  18597. }
  18598. ,
  18599. e.prototype.setAlphaMode = function(i, o) {
  18600. o === void 0 && (o = !1),
  18601. this._alphaMode !== i && (this.alphaState.alphaBlend = i !== 0,
  18602. o || this.setDepthWrite(i === 0),
  18603. this._alphaMode = i)
  18604. }
  18605. ,
  18606. e.prototype.bindBuffers = function(i, o, s) {}
  18607. ,
  18608. e.prototype.wipeCaches = function(i) {
  18609. this.preventCacheWipeBetweenFrames || (this.resetTextureCache(),
  18610. this._currentEffect = null,
  18611. i && (this._currentProgram = null,
  18612. this._stencilStateComposer.reset(),
  18613. this.depthCullingState.reset(),
  18614. this.alphaState.reset()),
  18615. this._cachedVertexBuffers = null,
  18616. this._cachedIndexBuffer = null,
  18617. this._cachedEffectForVertexBuffers = null)
  18618. }
  18619. ,
  18620. e.prototype.draw = function(i, o, s, c) {}
  18621. ,
  18622. e.prototype.drawElementsType = function(i, o, s, c) {}
  18623. ,
  18624. e.prototype.drawArraysType = function(i, o, s, c) {}
  18625. ,
  18626. e.prototype._createTexture = function() {
  18627. return {}
  18628. }
  18629. ,
  18630. e.prototype._releaseTexture = function(i) {}
  18631. ,
  18632. e.prototype.createTexture = function(i, o, s, c, d, _, b, k, j, $, _e, et) {
  18633. d === void 0 && (d = 3),
  18634. _ === void 0 && (_ = null),
  18635. $ === void 0 && ($ = null);
  18636. var tt = new InternalTexture(this,InternalTextureSource.Url)
  18637. , rt = String(i);
  18638. return tt.url = rt,
  18639. tt.generateMipMaps = !o,
  18640. tt.samplingMode = d,
  18641. tt.invertY = s,
  18642. tt.baseWidth = this._options.textureSize,
  18643. tt.baseHeight = this._options.textureSize,
  18644. tt.width = this._options.textureSize,
  18645. tt.height = this._options.textureSize,
  18646. $ && (tt.format = $),
  18647. tt.isReady = !0,
  18648. _ && _(),
  18649. this._internalTexturesCache.push(tt),
  18650. tt
  18651. }
  18652. ,
  18653. e.prototype._createHardwareRenderTargetWrapper = function(i, o, s) {
  18654. var c = new RenderTargetWrapper(i,o,s,this);
  18655. return this._renderTargetWrapperCache.push(c),
  18656. c
  18657. }
  18658. ,
  18659. e.prototype.createRenderTargetTexture = function(i, o) {
  18660. var s = this._createHardwareRenderTargetWrapper(!1, !1, i)
  18661. , c = {};
  18662. o !== void 0 && typeof o == "object" ? (c.generateMipMaps = o.generateMipMaps,
  18663. c.generateDepthBuffer = o.generateDepthBuffer === void 0 ? !0 : o.generateDepthBuffer,
  18664. c.generateStencilBuffer = c.generateDepthBuffer && o.generateStencilBuffer,
  18665. c.type = o.type === void 0 ? 0 : o.type,
  18666. c.samplingMode = o.samplingMode === void 0 ? 3 : o.samplingMode) : (c.generateMipMaps = o,
  18667. c.generateDepthBuffer = !0,
  18668. c.generateStencilBuffer = !1,
  18669. c.type = 0,
  18670. c.samplingMode = 3);
  18671. var d = new InternalTexture(this,InternalTextureSource.RenderTarget)
  18672. , _ = i.width || i
  18673. , b = i.height || i;
  18674. return s._generateDepthBuffer = c.generateDepthBuffer,
  18675. s._generateStencilBuffer = !!c.generateStencilBuffer,
  18676. d.baseWidth = _,
  18677. d.baseHeight = b,
  18678. d.width = _,
  18679. d.height = b,
  18680. d.isReady = !0,
  18681. d.samples = 1,
  18682. d.generateMipMaps = !!c.generateMipMaps,
  18683. d.samplingMode = c.samplingMode,
  18684. d.type = c.type,
  18685. this._internalTexturesCache.push(d),
  18686. s
  18687. }
  18688. ,
  18689. e.prototype.updateTextureSamplingMode = function(i, o) {
  18690. o.samplingMode = i
  18691. }
  18692. ,
  18693. e.prototype.createRawTexture = function(i, o, s, c, d, _, b, k, j, $) {
  18694. k === void 0 && (k = null),
  18695. j === void 0 && (j = 0);
  18696. var _e = new InternalTexture(this,InternalTextureSource.Raw);
  18697. return _e.baseWidth = o,
  18698. _e.baseHeight = s,
  18699. _e.width = o,
  18700. _e.height = s,
  18701. _e.format = c,
  18702. _e.generateMipMaps = d,
  18703. _e.samplingMode = b,
  18704. _e.invertY = _,
  18705. _e._compression = k,
  18706. _e.type = j,
  18707. this._doNotHandleContextLost || (_e._bufferView = i),
  18708. _e
  18709. }
  18710. ,
  18711. e.prototype.updateRawTexture = function(i, o, s, c, d, _) {
  18712. d === void 0 && (d = null),
  18713. _ === void 0 && (_ = 0),
  18714. i && (i._bufferView = o,
  18715. i.format = s,
  18716. i.invertY = c,
  18717. i._compression = d,
  18718. i.type = _)
  18719. }
  18720. ,
  18721. e.prototype.bindFramebuffer = function(i, o, s, c, d) {
  18722. this._currentRenderTarget && this.unBindFramebuffer(this._currentRenderTarget),
  18723. this._currentRenderTarget = i,
  18724. this._currentFramebuffer = null,
  18725. this._cachedViewport && !d && this.setViewport(this._cachedViewport, s, c)
  18726. }
  18727. ,
  18728. e.prototype.unBindFramebuffer = function(i, o, s) {
  18729. this._currentRenderTarget = null,
  18730. s && s(),
  18731. this._currentFramebuffer = null
  18732. }
  18733. ,
  18734. e.prototype.createDynamicVertexBuffer = function(i) {
  18735. var o = new DataBuffer;
  18736. return o.references = 1,
  18737. o.capacity = 1,
  18738. o
  18739. }
  18740. ,
  18741. e.prototype.updateDynamicTexture = function(i, o, s, c, d) {}
  18742. ,
  18743. e.prototype.areAllEffectsReady = function() {
  18744. return !0
  18745. }
  18746. ,
  18747. e.prototype.getError = function() {
  18748. return 0
  18749. }
  18750. ,
  18751. e.prototype._getUnpackAlignement = function() {
  18752. return 1
  18753. }
  18754. ,
  18755. e.prototype._unpackFlipY = function(i) {}
  18756. ,
  18757. e.prototype.updateDynamicIndexBuffer = function(i, o, s) {}
  18758. ,
  18759. e.prototype.updateDynamicVertexBuffer = function(i, o, s, c) {}
  18760. ,
  18761. e.prototype._bindTextureDirectly = function(i, o) {
  18762. return this._boundTexturesCache[this._activeChannel] !== o ? (this._boundTexturesCache[this._activeChannel] = o,
  18763. !0) : !1
  18764. }
  18765. ,
  18766. e.prototype._bindTexture = function(i, o) {
  18767. i < 0 || this._bindTextureDirectly(0, o)
  18768. }
  18769. ,
  18770. e.prototype._deleteBuffer = function(i) {}
  18771. ,
  18772. e.prototype.releaseEffects = function() {}
  18773. ,
  18774. e.prototype.displayLoadingUI = function() {}
  18775. ,
  18776. e.prototype.hideLoadingUI = function() {}
  18777. ,
  18778. e.prototype._uploadCompressedDataToTextureDirectly = function(i, o, s, c, d, _, b) {}
  18779. ,
  18780. e.prototype._uploadDataToTextureDirectly = function(i, o, s, c) {}
  18781. ,
  18782. e.prototype._uploadArrayBufferViewToTexture = function(i, o, s, c) {}
  18783. ,
  18784. e.prototype._uploadImageToTexture = function(i, o, s, c) {}
  18785. ,
  18786. e
  18787. }
  18788. )(Engine);
  18789. ThinEngine.prototype._debugPushGroup = function(a, e) {}
  18790. ;
  18791. ThinEngine.prototype._debugPopGroup = function(a) {}
  18792. ;
  18793. ThinEngine.prototype._debugInsertMarker = function(a, e) {}
  18794. ;
  18795. ThinEngine.prototype._debugFlushPendingCommands = function() {}
  18796. ;
  18797. var cloneValue = function(a, e) {
  18798. return !a || a.getClassName && a.getClassName() === "Mesh" ? null : a.getClassName && a.getClassName() === "SubMesh" ? a.clone(e) : a.clone ? a.clone() : null
  18799. };
  18800. function getAllPropertyNames(a) {
  18801. var e = [];
  18802. do
  18803. Object.getOwnPropertyNames(a).forEach(function(i) {
  18804. e.indexOf(i) === -1 && e.push(i)
  18805. });
  18806. while (a = Object.getPrototypeOf(a));
  18807. return e
  18808. }
  18809. var DeepCopier = function() {
  18810. function a() {}
  18811. return a.DeepCopy = function(e, i, o, s) {
  18812. for (var c = getAllPropertyNames(e), d = 0, _ = c; d < _.length; d++) {
  18813. var b = _[d];
  18814. if (!(b[0] === "_" && (!s || s.indexOf(b) === -1)) && !EndsWith(b, "Observable") && !(o && o.indexOf(b) !== -1)) {
  18815. var k = e[b]
  18816. , j = typeof k;
  18817. if (j !== "function")
  18818. try {
  18819. if (j === "object")
  18820. if (k instanceof Array) {
  18821. if (i[b] = [],
  18822. k.length > 0)
  18823. if (typeof k[0] == "object")
  18824. for (var $ = 0; $ < k.length; $++) {
  18825. var _e = cloneValue(k[$], i);
  18826. i[b].indexOf(_e) === -1 && i[b].push(_e)
  18827. }
  18828. else
  18829. i[b] = k.slice(0)
  18830. } else
  18831. i[b] = cloneValue(k, i);
  18832. else
  18833. i[b] = k
  18834. } catch (et) {
  18835. Logger$2.Warn(et.message)
  18836. }
  18837. }
  18838. }
  18839. }
  18840. ,
  18841. a
  18842. }();
  18843. function createXMLHttpRequest() {
  18844. return typeof _native != "undefined" && _native.XMLHttpRequest ? new _native.XMLHttpRequest : new XMLHttpRequest
  18845. }
  18846. var WebRequest = function() {
  18847. function a() {
  18848. this._xhr = createXMLHttpRequest()
  18849. }
  18850. return a.prototype._injectCustomRequestHeaders = function() {
  18851. for (var e in a.CustomRequestHeaders) {
  18852. var i = a.CustomRequestHeaders[e];
  18853. i && this._xhr.setRequestHeader(e, i)
  18854. }
  18855. }
  18856. ,
  18857. Object.defineProperty(a.prototype, "onprogress", {
  18858. get: function() {
  18859. return this._xhr.onprogress
  18860. },
  18861. set: function(e) {
  18862. this._xhr.onprogress = e
  18863. },
  18864. enumerable: !1,
  18865. configurable: !0
  18866. }),
  18867. Object.defineProperty(a.prototype, "readyState", {
  18868. get: function() {
  18869. return this._xhr.readyState
  18870. },
  18871. enumerable: !1,
  18872. configurable: !0
  18873. }),
  18874. Object.defineProperty(a.prototype, "status", {
  18875. get: function() {
  18876. return this._xhr.status
  18877. },
  18878. enumerable: !1,
  18879. configurable: !0
  18880. }),
  18881. Object.defineProperty(a.prototype, "statusText", {
  18882. get: function() {
  18883. return this._xhr.statusText
  18884. },
  18885. enumerable: !1,
  18886. configurable: !0
  18887. }),
  18888. Object.defineProperty(a.prototype, "response", {
  18889. get: function() {
  18890. return this._xhr.response
  18891. },
  18892. enumerable: !1,
  18893. configurable: !0
  18894. }),
  18895. Object.defineProperty(a.prototype, "responseURL", {
  18896. get: function() {
  18897. return this._xhr.responseURL
  18898. },
  18899. enumerable: !1,
  18900. configurable: !0
  18901. }),
  18902. Object.defineProperty(a.prototype, "responseText", {
  18903. get: function() {
  18904. return this._xhr.responseText
  18905. },
  18906. enumerable: !1,
  18907. configurable: !0
  18908. }),
  18909. Object.defineProperty(a.prototype, "responseType", {
  18910. get: function() {
  18911. return this._xhr.responseType
  18912. },
  18913. set: function(e) {
  18914. this._xhr.responseType = e
  18915. },
  18916. enumerable: !1,
  18917. configurable: !0
  18918. }),
  18919. Object.defineProperty(a.prototype, "timeout", {
  18920. get: function() {
  18921. return this._xhr.timeout
  18922. },
  18923. set: function(e) {
  18924. this._xhr.timeout = e
  18925. },
  18926. enumerable: !1,
  18927. configurable: !0
  18928. }),
  18929. a.prototype.addEventListener = function(e, i, o) {
  18930. this._xhr.addEventListener(e, i, o)
  18931. }
  18932. ,
  18933. a.prototype.removeEventListener = function(e, i, o) {
  18934. this._xhr.removeEventListener(e, i, o)
  18935. }
  18936. ,
  18937. a.prototype.abort = function() {
  18938. this._xhr.abort()
  18939. }
  18940. ,
  18941. a.prototype.send = function(e) {
  18942. a.CustomRequestHeaders && this._injectCustomRequestHeaders(),
  18943. this._xhr.send(e)
  18944. }
  18945. ,
  18946. a.prototype.open = function(e, i) {
  18947. for (var o = 0, s = a.CustomRequestModifiers; o < s.length; o++) {
  18948. var c = s[o];
  18949. c(this._xhr, i)
  18950. }
  18951. return i = i.replace("file:http:", "http:"),
  18952. i = i.replace("file:https:", "https:"),
  18953. this._xhr.open(e, i, !0)
  18954. }
  18955. ,
  18956. a.prototype.setRequestHeader = function(e, i) {
  18957. this._xhr.setRequestHeader(e, i)
  18958. }
  18959. ,
  18960. a.prototype.getResponseHeader = function(e) {
  18961. return this._xhr.getResponseHeader(e)
  18962. }
  18963. ,
  18964. a.CustomRequestHeaders = {},
  18965. a.CustomRequestModifiers = new Array,
  18966. a
  18967. }(), FilesInputStore = function() {
  18968. function a() {}
  18969. return a.FilesToLoad = {},
  18970. a
  18971. }(), RetryStrategy = function() {
  18972. function a() {}
  18973. return a.ExponentialBackoff = function(e, i) {
  18974. return e === void 0 && (e = 3),
  18975. i === void 0 && (i = 500),
  18976. function(o, s, c) {
  18977. return s.status !== 0 || c >= e || o.indexOf("file:") !== -1 ? -1 : Math.pow(2, c) * i
  18978. }
  18979. }
  18980. ,
  18981. a
  18982. }(), BaseError = function(a) {
  18983. __extends(e, a);
  18984. function e() {
  18985. return a !== null && a.apply(this, arguments) || this
  18986. }
  18987. return e._setPrototypeOf = Object.setPrototypeOf || function(i, o) {
  18988. return i.__proto__ = o,
  18989. i
  18990. }
  18991. ,
  18992. e
  18993. }(Error), TimingTools = function() {
  18994. function a() {}
  18995. return a.SetImmediate = function(e) {
  18996. IsWindowObjectExist() && window.setImmediate ? window.setImmediate(e) : setTimeout(e, 1)
  18997. }
  18998. ,
  18999. a
  19000. }(), FileTools, _injectLTSFileTools = function(a, e, i, o, s, c, d, _, b, k) {
  19001. FileTools = {
  19002. DecodeBase64UrlToBinary: a,
  19003. DecodeBase64UrlToString: e,
  19004. DefaultRetryStrategy: i.DefaultRetryStrategy,
  19005. BaseUrl: i.BaseUrl,
  19006. CorsBehavior: i.CorsBehavior,
  19007. PreprocessUrl: i.PreprocessUrl,
  19008. IsBase64DataUrl: o,
  19009. IsFileURL: s,
  19010. LoadFile: c,
  19011. LoadImage: d,
  19012. ReadFile: _,
  19013. RequestFile: b,
  19014. SetCorsBehavior: k
  19015. },
  19016. Object.defineProperty(FileTools, "DefaultRetryStrategy", {
  19017. get: function() {
  19018. return i.DefaultRetryStrategy
  19019. },
  19020. set: function(j) {
  19021. i.DefaultRetryStrategy = j
  19022. }
  19023. }),
  19024. Object.defineProperty(FileTools, "BaseUrl", {
  19025. get: function() {
  19026. return i.BaseUrl
  19027. },
  19028. set: function(j) {
  19029. i.BaseUrl = j
  19030. }
  19031. }),
  19032. Object.defineProperty(FileTools, "PreprocessUrl", {
  19033. get: function() {
  19034. return i.PreprocessUrl
  19035. },
  19036. set: function(j) {
  19037. i.PreprocessUrl = j
  19038. }
  19039. }),
  19040. Object.defineProperty(FileTools, "CorsBehavior", {
  19041. get: function() {
  19042. return i.CorsBehavior
  19043. },
  19044. set: function(j) {
  19045. i.CorsBehavior = j
  19046. }
  19047. })
  19048. }, base64DataUrlRegEx = new RegExp(/^data:([^,]+\/[^,]+)?;base64,/i), LoadFileError = function(a) {
  19049. __extends(e, a);
  19050. function e(i, o) {
  19051. var s = a.call(this, i) || this;
  19052. return s.name = "LoadFileError",
  19053. BaseError._setPrototypeOf(s, e.prototype),
  19054. o instanceof WebRequest ? s.request = o : s.file = o,
  19055. s
  19056. }
  19057. return e
  19058. }(BaseError), RequestFileError = function(a) {
  19059. __extends(e, a);
  19060. function e(i, o) {
  19061. var s = a.call(this, i) || this;
  19062. return s.request = o,
  19063. s.name = "RequestFileError",
  19064. BaseError._setPrototypeOf(s, e.prototype),
  19065. s
  19066. }
  19067. return e
  19068. }(BaseError), ReadFileError = function(a) {
  19069. __extends(e, a);
  19070. function e(i, o) {
  19071. var s = a.call(this, i) || this;
  19072. return s.file = o,
  19073. s.name = "ReadFileError",
  19074. BaseError._setPrototypeOf(s, e.prototype),
  19075. s
  19076. }
  19077. return e
  19078. }(BaseError), FileToolsOptions = {
  19079. DefaultRetryStrategy: RetryStrategy.ExponentialBackoff(),
  19080. BaseUrl: "",
  19081. CorsBehavior: "anonymous",
  19082. PreprocessUrl: function(a) {
  19083. return a
  19084. }
  19085. }, _CleanUrl = function(a) {
  19086. return a = a.replace(/#/mg, "%23"),
  19087. a
  19088. }, SetCorsBehavior = function(a, e) {
  19089. if (!(a && a.indexOf("data:") === 0) && FileToolsOptions.CorsBehavior)
  19090. if (typeof FileToolsOptions.CorsBehavior == "string" || FileToolsOptions.CorsBehavior instanceof String)
  19091. e.crossOrigin = FileToolsOptions.CorsBehavior;
  19092. else {
  19093. var i = FileToolsOptions.CorsBehavior(a);
  19094. i && (e.crossOrigin = i)
  19095. }
  19096. }, LoadImage = function(a, e, i, o, s, c) {
  19097. var d;
  19098. s === void 0 && (s = "");
  19099. var _, b = !1;
  19100. a instanceof ArrayBuffer || ArrayBuffer.isView(a) ? typeof Blob != "undefined" ? (_ = URL.createObjectURL(new Blob([a],{
  19101. type: s
  19102. })),
  19103. b = !0) : _ = "data:" + s + ";base64," + EncodeArrayBufferToBase64(a) : a instanceof Blob ? (_ = URL.createObjectURL(a),
  19104. b = !0) : (_ = _CleanUrl(a),
  19105. _ = FileToolsOptions.PreprocessUrl(a));
  19106. var k = EngineStore.LastCreatedEngine
  19107. , j = function(ot) {
  19108. if (i) {
  19109. var at = _ || a.toString();
  19110. i("Error while trying to load image: " + (at.indexOf("http") === 0 || at.length <= 128 ? at : at.slice(0, 128) + "..."), ot)
  19111. }
  19112. };
  19113. if (typeof Image == "undefined" || ((d = k == null ? void 0 : k._features.forceBitmapOverHTMLImageElement) !== null && d !== void 0 ? d : !1))
  19114. return LoadFile(_, function(ot) {
  19115. k.createImageBitmap(new Blob([ot],{
  19116. type: s
  19117. }), __assign({
  19118. premultiplyAlpha: "none"
  19119. }, c)).then(function(at) {
  19120. e(at),
  19121. b && URL.revokeObjectURL(_)
  19122. }).catch(function(at) {
  19123. i && i("Error while trying to load image: " + a, at)
  19124. })
  19125. }, void 0, o || void 0, !0, function(ot, at) {
  19126. j(at)
  19127. }),
  19128. null;
  19129. var $ = new Image;
  19130. SetCorsBehavior(_, $);
  19131. var _e = function() {
  19132. $.removeEventListener("load", _e),
  19133. $.removeEventListener("error", et),
  19134. e($),
  19135. b && $.src && URL.revokeObjectURL($.src)
  19136. }
  19137. , et = function(ot) {
  19138. $.removeEventListener("load", _e),
  19139. $.removeEventListener("error", et),
  19140. j(ot),
  19141. b && $.src && URL.revokeObjectURL($.src)
  19142. };
  19143. $.addEventListener("load", _e),
  19144. $.addEventListener("error", et);
  19145. var tt = function() {
  19146. $.src = _
  19147. }
  19148. , rt = function() {
  19149. o && o.loadImage(_, $)
  19150. };
  19151. if (_.substr(0, 5) !== "data:" && o && o.enableTexturesOffline)
  19152. o.open(rt, tt);
  19153. else {
  19154. if (_.indexOf("file:") !== -1) {
  19155. var it = decodeURIComponent(_.substring(5).toLowerCase());
  19156. if (FilesInputStore.FilesToLoad[it]) {
  19157. try {
  19158. var nt;
  19159. try {
  19160. nt = URL.createObjectURL(FilesInputStore.FilesToLoad[it])
  19161. } catch {
  19162. nt = URL.createObjectURL(FilesInputStore.FilesToLoad[it])
  19163. }
  19164. $.src = nt,
  19165. b = !0
  19166. } catch {
  19167. $.src = ""
  19168. }
  19169. return $
  19170. }
  19171. }
  19172. tt()
  19173. }
  19174. return $
  19175. }, ReadFile = function(a, e, i, o, s) {
  19176. var c = new FileReader
  19177. , d = {
  19178. onCompleteObservable: new Observable,
  19179. abort: function() {
  19180. return c.abort()
  19181. }
  19182. };
  19183. return c.onloadend = function(_) {
  19184. return d.onCompleteObservable.notifyObservers(d)
  19185. }
  19186. ,
  19187. s && (c.onerror = function(_) {
  19188. s(new ReadFileError("Unable to read " + a.name,a))
  19189. }
  19190. ),
  19191. c.onload = function(_) {
  19192. e(_.target.result)
  19193. }
  19194. ,
  19195. i && (c.onprogress = i),
  19196. o ? c.readAsArrayBuffer(a) : c.readAsText(a),
  19197. d
  19198. }, LoadFile = function(a, e, i, o, s, c, d) {
  19199. if (a.name)
  19200. return ReadFile(a, e, i, s, c ? function($) {
  19201. c(void 0, $)
  19202. }
  19203. : void 0);
  19204. var _ = a;
  19205. if (_.indexOf("file:") !== -1) {
  19206. var b = decodeURIComponent(_.substring(5).toLowerCase());
  19207. b.indexOf("./") === 0 && (b = b.substring(2));
  19208. var k = FilesInputStore.FilesToLoad[b];
  19209. if (k)
  19210. return ReadFile(k, e, i, s, c ? function($) {
  19211. return c(void 0, new LoadFileError($.message,$.file))
  19212. }
  19213. : void 0)
  19214. }
  19215. if (IsBase64DataUrl(_)) {
  19216. var j = {
  19217. onCompleteObservable: new Observable,
  19218. abort: function() {
  19219. return function() {}
  19220. }
  19221. };
  19222. try {
  19223. e(s ? DecodeBase64UrlToBinary(_) : DecodeBase64UrlToString(_))
  19224. } catch ($) {
  19225. c ? c(void 0, $) : Logger$2.Error($.message || "Failed to parse the Data URL")
  19226. }
  19227. return TimingTools.SetImmediate(function() {
  19228. j.onCompleteObservable.notifyObservers(j)
  19229. }),
  19230. j
  19231. }
  19232. return RequestFile(_, function($, _e) {
  19233. e($, _e ? _e.responseURL : void 0)
  19234. }, i, o, s, c ? function($) {
  19235. c($.request, new LoadFileError($.message,$.request))
  19236. }
  19237. : void 0, d)
  19238. }, RequestFile = function(a, e, i, o, s, c, d) {
  19239. a = _CleanUrl(a),
  19240. a = FileToolsOptions.PreprocessUrl(a);
  19241. var _ = FileToolsOptions.BaseUrl + a
  19242. , b = !1
  19243. , k = {
  19244. onCompleteObservable: new Observable,
  19245. abort: function() {
  19246. return b = !0
  19247. }
  19248. }
  19249. , j = function() {
  19250. var et = new WebRequest
  19251. , tt = null;
  19252. k.abort = function() {
  19253. b = !0,
  19254. et.readyState !== (XMLHttpRequest.DONE || 4) && et.abort(),
  19255. tt !== null && (clearTimeout(tt),
  19256. tt = null)
  19257. }
  19258. ;
  19259. var rt = function(nt) {
  19260. var ot = nt.message || "Unknown error";
  19261. c ? c(new RequestFileError(ot,et)) : Logger$2.Error(ot)
  19262. }
  19263. , it = function(nt) {
  19264. if (et.open("GET", _),
  19265. d)
  19266. try {
  19267. d(et)
  19268. } catch (st) {
  19269. rt(st);
  19270. return
  19271. }
  19272. s && (et.responseType = "arraybuffer"),
  19273. i && et.addEventListener("progress", i);
  19274. var ot = function() {
  19275. et.removeEventListener("loadend", ot),
  19276. k.onCompleteObservable.notifyObservers(k),
  19277. k.onCompleteObservable.clear()
  19278. };
  19279. et.addEventListener("loadend", ot);
  19280. var at = function() {
  19281. if (!b && et.readyState === (XMLHttpRequest.DONE || 4)) {
  19282. if (et.removeEventListener("readystatechange", at),
  19283. et.status >= 200 && et.status < 300 || et.status === 0 && (!IsWindowObjectExist() || IsFileURL())) {
  19284. try {
  19285. e(s ? et.response : et.responseText, et)
  19286. } catch (lt) {
  19287. rt(lt)
  19288. }
  19289. return
  19290. }
  19291. var st = FileToolsOptions.DefaultRetryStrategy;
  19292. if (st) {
  19293. var ut = st(_, et, nt);
  19294. if (ut !== -1) {
  19295. et.removeEventListener("loadend", ot),
  19296. et = new WebRequest,
  19297. tt = setTimeout(function() {
  19298. return it(nt + 1)
  19299. }, ut);
  19300. return
  19301. }
  19302. }
  19303. var ct = new RequestFileError("Error status: " + et.status + " " + et.statusText + " - Unable to load " + _,et);
  19304. c && c(ct)
  19305. }
  19306. };
  19307. et.addEventListener("readystatechange", at),
  19308. et.send()
  19309. };
  19310. it(0)
  19311. };
  19312. if (o && o.enableSceneOffline) {
  19313. var $ = function(et) {
  19314. et && et.status > 400 ? c && c(et) : j()
  19315. }
  19316. , _e = function() {
  19317. o && o.loadFile(FileToolsOptions.BaseUrl + a, function(et) {
  19318. b || e(et),
  19319. k.onCompleteObservable.notifyObservers(k)
  19320. }, i ? function(et) {
  19321. b || i(et)
  19322. }
  19323. : void 0, $, s)
  19324. };
  19325. o.open(_e, $)
  19326. } else
  19327. j();
  19328. return k
  19329. }, IsFileURL = function() {
  19330. return typeof location != "undefined" && location.protocol === "file:"
  19331. }, IsBase64DataUrl = function(a) {
  19332. return base64DataUrlRegEx.test(a)
  19333. };
  19334. function DecodeBase64UrlToBinary(a) {
  19335. return DecodeBase64ToBinary(a.split(",")[1])
  19336. }
  19337. var DecodeBase64UrlToString = function(a) {
  19338. return DecodeBase64ToString(a.split(",")[1])
  19339. }
  19340. , initSideEffects$1 = function() {
  19341. ThinEngine._FileToolsLoadImage = LoadImage,
  19342. ThinEngine._FileToolsLoadFile = LoadFile,
  19343. ShaderProcessor._FileToolsLoadFile = LoadFile
  19344. };
  19345. initSideEffects$1();
  19346. _injectLTSFileTools(DecodeBase64UrlToBinary, DecodeBase64UrlToString, FileToolsOptions, IsBase64DataUrl, IsFileURL, LoadFile, LoadImage, ReadFile, RequestFile, SetCorsBehavior);
  19347. var PromiseStates;
  19348. (function(a) {
  19349. a[a.Pending = 0] = "Pending",
  19350. a[a.Fulfilled = 1] = "Fulfilled",
  19351. a[a.Rejected = 2] = "Rejected"
  19352. }
  19353. )(PromiseStates || (PromiseStates = {}));
  19354. var FulFillmentAgregator = function() {
  19355. function a() {
  19356. this.count = 0,
  19357. this.target = 0,
  19358. this.results = []
  19359. }
  19360. return a
  19361. }()
  19362. , InternalPromise = function() {
  19363. function a(e) {
  19364. var i = this;
  19365. if (this._state = PromiseStates.Pending,
  19366. this._children = new Array,
  19367. this._rejectWasConsumed = !1,
  19368. !!e)
  19369. try {
  19370. e(function(o) {
  19371. i._resolve(o)
  19372. }, function(o) {
  19373. i._reject(o)
  19374. })
  19375. } catch (o) {
  19376. this._reject(o)
  19377. }
  19378. }
  19379. return Object.defineProperty(a.prototype, "_result", {
  19380. get: function() {
  19381. return this._resultValue
  19382. },
  19383. set: function(e) {
  19384. this._resultValue = e,
  19385. this._parent && this._parent._result === void 0 && (this._parent._result = e)
  19386. },
  19387. enumerable: !1,
  19388. configurable: !0
  19389. }),
  19390. a.prototype.catch = function(e) {
  19391. return this.then(void 0, e)
  19392. }
  19393. ,
  19394. a.prototype.then = function(e, i) {
  19395. var o = this
  19396. , s = new a;
  19397. return s._onFulfilled = e,
  19398. s._onRejected = i,
  19399. this._children.push(s),
  19400. s._parent = this,
  19401. this._state !== PromiseStates.Pending && setTimeout(function() {
  19402. o._state === PromiseStates.Fulfilled || o._rejectWasConsumed ? s._resolve(o._result) : s._reject(o._reason)
  19403. }),
  19404. s
  19405. }
  19406. ,
  19407. a.prototype._moveChildren = function(e) {
  19408. var i, o = this;
  19409. if ((i = this._children).push.apply(i, e.splice(0, e.length)),
  19410. this._children.forEach(function(k) {
  19411. k._parent = o
  19412. }),
  19413. this._state === PromiseStates.Fulfilled)
  19414. for (var s = 0, c = this._children; s < c.length; s++) {
  19415. var d = c[s];
  19416. d._resolve(this._result)
  19417. }
  19418. else if (this._state === PromiseStates.Rejected)
  19419. for (var _ = 0, b = this._children; _ < b.length; _++) {
  19420. var d = b[_];
  19421. d._reject(this._reason)
  19422. }
  19423. }
  19424. ,
  19425. a.prototype._resolve = function(e) {
  19426. try {
  19427. this._state = PromiseStates.Fulfilled;
  19428. var i = null;
  19429. if (this._onFulfilled && (i = this._onFulfilled(e)),
  19430. i != null)
  19431. if (i._state !== void 0) {
  19432. var o = i;
  19433. o._parent = this,
  19434. o._moveChildren(this._children),
  19435. e = o._result
  19436. } else
  19437. e = i;
  19438. this._result = e;
  19439. for (var s = 0, c = this._children; s < c.length; s++) {
  19440. var d = c[s];
  19441. d._resolve(e)
  19442. }
  19443. this._children.length = 0,
  19444. delete this._onFulfilled,
  19445. delete this._onRejected
  19446. } catch (_) {
  19447. this._reject(_, !0)
  19448. }
  19449. }
  19450. ,
  19451. a.prototype._reject = function(e, i) {
  19452. if (i === void 0 && (i = !1),
  19453. this._state = PromiseStates.Rejected,
  19454. this._reason = e,
  19455. this._onRejected && !i)
  19456. try {
  19457. this._onRejected(e),
  19458. this._rejectWasConsumed = !0
  19459. } catch (d) {
  19460. e = d
  19461. }
  19462. for (var o = 0, s = this._children; o < s.length; o++) {
  19463. var c = s[o];
  19464. this._rejectWasConsumed ? c._resolve(null) : c._reject(e)
  19465. }
  19466. this._children.length = 0,
  19467. delete this._onFulfilled,
  19468. delete this._onRejected
  19469. }
  19470. ,
  19471. a.resolve = function(e) {
  19472. var i = new a;
  19473. return i._resolve(e),
  19474. i
  19475. }
  19476. ,
  19477. a._RegisterForFulfillment = function(e, i, o) {
  19478. e.then(function(s) {
  19479. return i.results[o] = s,
  19480. i.count++,
  19481. i.count === i.target && i.rootPromise._resolve(i.results),
  19482. null
  19483. }, function(s) {
  19484. i.rootPromise._state !== PromiseStates.Rejected && i.rootPromise._reject(s)
  19485. })
  19486. }
  19487. ,
  19488. a.all = function(e) {
  19489. var i = new a
  19490. , o = new FulFillmentAgregator;
  19491. if (o.target = e.length,
  19492. o.rootPromise = i,
  19493. e.length)
  19494. for (var s = 0; s < e.length; s++)
  19495. a._RegisterForFulfillment(e[s], o, s);
  19496. else
  19497. i._resolve([]);
  19498. return i
  19499. }
  19500. ,
  19501. a.race = function(e) {
  19502. var i = new a;
  19503. if (e.length)
  19504. for (var o = 0, s = e; o < s.length; o++) {
  19505. var c = s[o];
  19506. c.then(function(d) {
  19507. return i && (i._resolve(d),
  19508. i = null),
  19509. null
  19510. }, function(d) {
  19511. i && (i._reject(d),
  19512. i = null)
  19513. })
  19514. }
  19515. return i
  19516. }
  19517. ,
  19518. a
  19519. }()
  19520. , PromisePolyfill = function() {
  19521. function a() {}
  19522. return a.Apply = function(e) {
  19523. if (e === void 0 && (e = !1),
  19524. e || typeof Promise == "undefined") {
  19525. var i = window;
  19526. i.Promise = InternalPromise
  19527. }
  19528. }
  19529. ,
  19530. a
  19531. }()
  19532. , _RegisteredTypes = {};
  19533. function RegisterClass(a, e) {
  19534. _RegisteredTypes[a] = e
  19535. }
  19536. function GetClass(a) {
  19537. return _RegisteredTypes[a]
  19538. }
  19539. var InstantiationTools = function() {
  19540. function a() {}
  19541. return a.Instantiate = function(e) {
  19542. if (this.RegisteredExternalClasses && this.RegisteredExternalClasses[e])
  19543. return this.RegisteredExternalClasses[e];
  19544. var i = GetClass(e);
  19545. if (i)
  19546. return i;
  19547. Logger$2.Warn(e + " not found, you may have missed an import.");
  19548. for (var o = e.split("."), s = window || this, c = 0, d = o.length; c < d; c++)
  19549. s = s[o[c]];
  19550. return typeof s != "function" ? null : s
  19551. }
  19552. ,
  19553. a.RegisteredExternalClasses = {},
  19554. a
  19555. }();
  19556. function RandomGUID() {
  19557. return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(a) {
  19558. var e = Math.random() * 16 | 0
  19559. , i = a === "x" ? e : e & 3 | 8;
  19560. return i.toString(16)
  19561. })
  19562. }
  19563. var SliceTools = function() {
  19564. function a() {}
  19565. return a.Slice = function(e, i, o) {
  19566. return e.slice ? e.slice(i, o) : Array.prototype.slice.call(e, i, o)
  19567. }
  19568. ,
  19569. a.SliceToArray = function(e, i, o) {
  19570. return Array.isArray(e) ? e.slice(i, o) : Array.prototype.slice.call(e, i, o)
  19571. }
  19572. ,
  19573. a
  19574. }()
  19575. , Tools = function() {
  19576. function a() {}
  19577. return Object.defineProperty(a, "BaseUrl", {
  19578. get: function() {
  19579. return FileToolsOptions.BaseUrl
  19580. },
  19581. set: function(e) {
  19582. FileToolsOptions.BaseUrl = e
  19583. },
  19584. enumerable: !1,
  19585. configurable: !0
  19586. }),
  19587. Object.defineProperty(a, "DefaultRetryStrategy", {
  19588. get: function() {
  19589. return FileToolsOptions.DefaultRetryStrategy
  19590. },
  19591. set: function(e) {
  19592. FileToolsOptions.DefaultRetryStrategy = e
  19593. },
  19594. enumerable: !1,
  19595. configurable: !0
  19596. }),
  19597. Object.defineProperty(a, "CorsBehavior", {
  19598. get: function() {
  19599. return FileToolsOptions.CorsBehavior
  19600. },
  19601. set: function(e) {
  19602. FileToolsOptions.CorsBehavior = e
  19603. },
  19604. enumerable: !1,
  19605. configurable: !0
  19606. }),
  19607. Object.defineProperty(a, "UseFallbackTexture", {
  19608. get: function() {
  19609. return EngineStore.UseFallbackTexture
  19610. },
  19611. set: function(e) {
  19612. EngineStore.UseFallbackTexture = e
  19613. },
  19614. enumerable: !1,
  19615. configurable: !0
  19616. }),
  19617. Object.defineProperty(a, "RegisteredExternalClasses", {
  19618. get: function() {
  19619. return InstantiationTools.RegisteredExternalClasses
  19620. },
  19621. set: function(e) {
  19622. InstantiationTools.RegisteredExternalClasses = e
  19623. },
  19624. enumerable: !1,
  19625. configurable: !0
  19626. }),
  19627. Object.defineProperty(a, "fallbackTexture", {
  19628. get: function() {
  19629. return EngineStore.FallbackTexture
  19630. },
  19631. set: function(e) {
  19632. EngineStore.FallbackTexture = e
  19633. },
  19634. enumerable: !1,
  19635. configurable: !0
  19636. }),
  19637. a.FetchToRef = function(e, i, o, s, c, d) {
  19638. var _ = Math.abs(e) * o % o | 0
  19639. , b = Math.abs(i) * s % s | 0
  19640. , k = (_ + b * o) * 4;
  19641. d.r = c[k] / 255,
  19642. d.g = c[k + 1] / 255,
  19643. d.b = c[k + 2] / 255,
  19644. d.a = c[k + 3] / 255
  19645. }
  19646. ,
  19647. a.Mix = function(e, i, o) {
  19648. return e * (1 - o) + i * o
  19649. }
  19650. ,
  19651. a.Instantiate = function(e) {
  19652. return InstantiationTools.Instantiate(e)
  19653. }
  19654. ,
  19655. a.Slice = function(e, i, o) {
  19656. return SliceTools.Slice(e, i, o)
  19657. }
  19658. ,
  19659. a.SliceToArray = function(e, i, o) {
  19660. return SliceTools.SliceToArray(e, i, o)
  19661. }
  19662. ,
  19663. a.SetImmediate = function(e) {
  19664. TimingTools.SetImmediate(e)
  19665. }
  19666. ,
  19667. a.IsExponentOfTwo = function(e) {
  19668. var i = 1;
  19669. do
  19670. i *= 2;
  19671. while (i < e);
  19672. return i === e
  19673. }
  19674. ,
  19675. a.FloatRound = function(e) {
  19676. return Math.fround ? Math.fround(e) : (a._tmpFloatArray[0] = e,
  19677. a._tmpFloatArray[0])
  19678. }
  19679. ,
  19680. a.GetFilename = function(e) {
  19681. var i = e.lastIndexOf("/");
  19682. return i < 0 ? e : e.substring(i + 1)
  19683. }
  19684. ,
  19685. a.GetFolderPath = function(e, i) {
  19686. i === void 0 && (i = !1);
  19687. var o = e.lastIndexOf("/");
  19688. return o < 0 ? i ? e : "" : e.substring(0, o + 1)
  19689. }
  19690. ,
  19691. a.ToDegrees = function(e) {
  19692. return e * 180 / Math.PI
  19693. }
  19694. ,
  19695. a.ToRadians = function(e) {
  19696. return e * Math.PI / 180
  19697. }
  19698. ,
  19699. a.MakeArray = function(e, i) {
  19700. return i !== !0 && (e === void 0 || e == null) ? null : Array.isArray(e) ? e : [e]
  19701. }
  19702. ,
  19703. a.GetPointerPrefix = function(e) {
  19704. var i = "pointer";
  19705. return IsWindowObjectExist() && !window.PointerEvent && IsNavigatorAvailable() && !navigator.pointerEnabled && (i = "mouse"),
  19706. e._badDesktopOS && !e._badOS && !(document && "ontouchend"in document) && (i = "mouse"),
  19707. i
  19708. }
  19709. ,
  19710. a.SetCorsBehavior = function(e, i) {
  19711. SetCorsBehavior(e, i)
  19712. }
  19713. ,
  19714. a.CleanUrl = function(e) {
  19715. return e = e.replace(/#/gm, "%23"),
  19716. e
  19717. }
  19718. ,
  19719. Object.defineProperty(a, "PreprocessUrl", {
  19720. get: function() {
  19721. return FileToolsOptions.PreprocessUrl
  19722. },
  19723. set: function(e) {
  19724. FileToolsOptions.PreprocessUrl = e
  19725. },
  19726. enumerable: !1,
  19727. configurable: !0
  19728. }),
  19729. a.LoadImage = function(e, i, o, s, c, d) {
  19730. return LoadImage(e, i, o, s, c, d)
  19731. }
  19732. ,
  19733. a.LoadFile = function(e, i, o, s, c, d) {
  19734. return LoadFile(e, i, o, s, c, d)
  19735. }
  19736. ,
  19737. a.LoadFileAsync = function(e, i) {
  19738. return i === void 0 && (i = !0),
  19739. new Promise(function(o, s) {
  19740. LoadFile(e, function(c) {
  19741. o(c)
  19742. }, void 0, void 0, i, function(c, d) {
  19743. s(d)
  19744. })
  19745. }
  19746. )
  19747. }
  19748. ,
  19749. a.LoadScript = function(e, i, o, s) {
  19750. if (!!IsWindowObjectExist()) {
  19751. var c = document.getElementsByTagName("head")[0]
  19752. , d = document.createElement("script");
  19753. d.setAttribute("type", "text/javascript"),
  19754. d.setAttribute("src", e),
  19755. s && (d.id = s),
  19756. d.onload = function() {
  19757. i && i()
  19758. }
  19759. ,
  19760. d.onerror = function(_) {
  19761. o && o("Unable to load script '" + e + "'", _)
  19762. }
  19763. ,
  19764. c.appendChild(d)
  19765. }
  19766. }
  19767. ,
  19768. a.LoadScriptAsync = function(e, i) {
  19769. var o = this;
  19770. return new Promise(function(s, c) {
  19771. o.LoadScript(e, function() {
  19772. s()
  19773. }, function(d, _) {
  19774. c(_)
  19775. })
  19776. }
  19777. )
  19778. }
  19779. ,
  19780. a.ReadFileAsDataURL = function(e, i, o) {
  19781. var s = new FileReader
  19782. , c = {
  19783. onCompleteObservable: new Observable,
  19784. abort: function() {
  19785. return s.abort()
  19786. }
  19787. };
  19788. return s.onloadend = function(d) {
  19789. c.onCompleteObservable.notifyObservers(c)
  19790. }
  19791. ,
  19792. s.onload = function(d) {
  19793. i(d.target.result)
  19794. }
  19795. ,
  19796. s.onprogress = o,
  19797. s.readAsDataURL(e),
  19798. c
  19799. }
  19800. ,
  19801. a.ReadFile = function(e, i, o, s, c) {
  19802. return ReadFile(e, i, o, s, c)
  19803. }
  19804. ,
  19805. a.FileAsURL = function(e) {
  19806. var i = new Blob([e])
  19807. , o = window.URL || window.webkitURL
  19808. , s = o.createObjectURL(i);
  19809. return s
  19810. }
  19811. ,
  19812. a.Format = function(e, i) {
  19813. return i === void 0 && (i = 2),
  19814. e.toFixed(i)
  19815. }
  19816. ,
  19817. a.DeepCopy = function(e, i, o, s) {
  19818. DeepCopier.DeepCopy(e, i, o, s)
  19819. }
  19820. ,
  19821. a.IsEmpty = function(e) {
  19822. for (var i in e)
  19823. if (e.hasOwnProperty(i))
  19824. return !1;
  19825. return !0
  19826. }
  19827. ,
  19828. a.RegisterTopRootEvents = function(e, i) {
  19829. for (var o = 0; o < i.length; o++) {
  19830. var s = i[o];
  19831. e.addEventListener(s.name, s.handler, !1);
  19832. try {
  19833. window.parent && window.parent.addEventListener(s.name, s.handler, !1)
  19834. } catch {}
  19835. }
  19836. }
  19837. ,
  19838. a.UnregisterTopRootEvents = function(e, i) {
  19839. for (var o = 0; o < i.length; o++) {
  19840. var s = i[o];
  19841. e.removeEventListener(s.name, s.handler);
  19842. try {
  19843. e.parent && e.parent.removeEventListener(s.name, s.handler)
  19844. } catch {}
  19845. }
  19846. }
  19847. ,
  19848. a.DumpFramebuffer = function(e, i, o, s, c, d) {
  19849. return c === void 0 && (c = "image/png"),
  19850. __awaiter(this, void 0, void 0, function() {
  19851. var _, b;
  19852. return __generator(this, function(k) {
  19853. switch (k.label) {
  19854. case 0:
  19855. return [4, o.readPixels(0, 0, e, i)];
  19856. case 1:
  19857. return _ = k.sent(),
  19858. b = new Uint8Array(_.buffer),
  19859. a.DumpData(e, i, b, s, c, d, !0),
  19860. [2]
  19861. }
  19862. })
  19863. })
  19864. }
  19865. ,
  19866. a.DumpData = function(e, i, o, s, c, d, _, b, k) {
  19867. c === void 0 && (c = "image/png"),
  19868. _ === void 0 && (_ = !1),
  19869. b === void 0 && (b = !1),
  19870. a._ScreenshotCanvas || (a._ScreenshotCanvas = document.createElement("canvas")),
  19871. a._ScreenshotCanvas.width = e,
  19872. a._ScreenshotCanvas.height = i;
  19873. var j = a._ScreenshotCanvas.getContext("2d");
  19874. if (j) {
  19875. if (o instanceof Float32Array) {
  19876. for (var $ = new Uint8Array(o.length), _e = o.length; _e--; ) {
  19877. var et = o[_e];
  19878. $[_e] = et < 0 ? 0 : et > 1 ? 1 : Math.round(et * 255)
  19879. }
  19880. o = $
  19881. }
  19882. var tt = j.createImageData(e, i)
  19883. , rt = tt.data;
  19884. rt.set(o),
  19885. j.putImageData(tt, 0, 0);
  19886. var it = a._ScreenshotCanvas;
  19887. if (_) {
  19888. var nt = document.createElement("canvas");
  19889. nt.width = e,
  19890. nt.height = i;
  19891. var ot = nt.getContext("2d");
  19892. if (!ot)
  19893. return;
  19894. ot.translate(0, i),
  19895. ot.scale(1, -1),
  19896. ot.drawImage(a._ScreenshotCanvas, 0, 0),
  19897. it = nt
  19898. }
  19899. b ? a.ToBlob(it, function(at) {
  19900. var st = new FileReader;
  19901. st.onload = function(ut) {
  19902. var ct = ut.target.result;
  19903. s && s(ct)
  19904. }
  19905. ,
  19906. st.readAsArrayBuffer(at)
  19907. }, c, k) : a.EncodeScreenshotCanvasData(s, c, d, it, k)
  19908. }
  19909. }
  19910. ,
  19911. a.DumpDataAsync = function(e, i, o, s, c, d, _, b) {
  19912. return s === void 0 && (s = "image/png"),
  19913. d === void 0 && (d = !1),
  19914. _ === void 0 && (_ = !1),
  19915. new Promise(function(k) {
  19916. a.DumpData(e, i, o, function(j) {
  19917. return k(j)
  19918. }, s, c, d, _, b)
  19919. }
  19920. )
  19921. }
  19922. ,
  19923. a.ToBlob = function(e, i, o, s) {
  19924. o === void 0 && (o = "image/png"),
  19925. e.toBlob || (e.toBlob = function(c, d, _) {
  19926. var b = this;
  19927. setTimeout(function() {
  19928. for (var k = atob(b.toDataURL(d, _).split(",")[1]), j = k.length, $ = new Uint8Array(j), _e = 0; _e < j; _e++)
  19929. $[_e] = k.charCodeAt(_e);
  19930. c(new Blob([$]))
  19931. })
  19932. }
  19933. ),
  19934. e.toBlob(function(c) {
  19935. i(c)
  19936. }, o, s)
  19937. }
  19938. ,
  19939. a.EncodeScreenshotCanvasData = function(e, i, o, s, c) {
  19940. if (i === void 0 && (i = "image/png"),
  19941. e) {
  19942. var d = (s != null ? s : a._ScreenshotCanvas).toDataURL(i, c);
  19943. e(d)
  19944. } else
  19945. this.ToBlob(s != null ? s : a._ScreenshotCanvas, function(_) {
  19946. if ("download"in document.createElement("a")) {
  19947. if (!o) {
  19948. var b = new Date
  19949. , k = (b.getFullYear() + "-" + (b.getMonth() + 1)).slice(2) + "-" + b.getDate() + "_" + b.getHours() + "-" + ("0" + b.getMinutes()).slice(-2);
  19950. o = "screenshot_" + k + ".png"
  19951. }
  19952. a.Download(_, o)
  19953. } else {
  19954. var j = URL.createObjectURL(_)
  19955. , $ = window.open("");
  19956. if (!$)
  19957. return;
  19958. var _e = $.document.createElement("img");
  19959. _e.onload = function() {
  19960. URL.revokeObjectURL(j)
  19961. }
  19962. ,
  19963. _e.src = j,
  19964. $.document.body.appendChild(_e)
  19965. }
  19966. }, i, c)
  19967. }
  19968. ,
  19969. a.Download = function(e, i) {
  19970. if (navigator && navigator.msSaveBlob) {
  19971. navigator.msSaveBlob(e, i);
  19972. return
  19973. }
  19974. var o = window.URL.createObjectURL(e)
  19975. , s = document.createElement("a");
  19976. document.body.appendChild(s),
  19977. s.style.display = "none",
  19978. s.href = o,
  19979. s.download = i,
  19980. s.addEventListener("click", function() {
  19981. s.parentElement && s.parentElement.removeChild(s)
  19982. }),
  19983. s.click(),
  19984. window.URL.revokeObjectURL(o)
  19985. }
  19986. ,
  19987. a.BackCompatCameraNoPreventDefault = function(e) {
  19988. return typeof e[0] == "boolean" ? e[0] : typeof e[1] == "boolean" ? e[1] : !1
  19989. }
  19990. ,
  19991. a.CreateScreenshot = function(e, i, o, s, c) {
  19992. throw _WarnImport("ScreenshotTools")
  19993. }
  19994. ,
  19995. a.CreateScreenshotAsync = function(e, i, o, s) {
  19996. throw _WarnImport("ScreenshotTools")
  19997. }
  19998. ,
  19999. a.CreateScreenshotUsingRenderTarget = function(e, i, o, s, c, d, _, b) {
  20000. throw _WarnImport("ScreenshotTools")
  20001. }
  20002. ,
  20003. a.CreateScreenshotUsingRenderTargetAsync = function(e, i, o, s, c, d, _) {
  20004. throw _WarnImport("ScreenshotTools")
  20005. }
  20006. ,
  20007. a.RandomId = function() {
  20008. return RandomGUID()
  20009. }
  20010. ,
  20011. a.IsBase64 = function(e) {
  20012. return IsBase64DataUrl(e)
  20013. }
  20014. ,
  20015. a.DecodeBase64 = function(e) {
  20016. return DecodeBase64UrlToBinary(e)
  20017. }
  20018. ,
  20019. Object.defineProperty(a, "errorsCount", {
  20020. get: function() {
  20021. return Logger$2.errorsCount
  20022. },
  20023. enumerable: !1,
  20024. configurable: !0
  20025. }),
  20026. a.Log = function(e) {
  20027. Logger$2.Log(e)
  20028. }
  20029. ,
  20030. a.Warn = function(e) {
  20031. Logger$2.Warn(e)
  20032. }
  20033. ,
  20034. a.Error = function(e) {
  20035. Logger$2.Error(e)
  20036. }
  20037. ,
  20038. Object.defineProperty(a, "LogCache", {
  20039. get: function() {
  20040. return Logger$2.LogCache
  20041. },
  20042. enumerable: !1,
  20043. configurable: !0
  20044. }),
  20045. a.ClearLogCache = function() {
  20046. Logger$2.ClearLogCache()
  20047. }
  20048. ,
  20049. Object.defineProperty(a, "LogLevels", {
  20050. set: function(e) {
  20051. Logger$2.LogLevels = e
  20052. },
  20053. enumerable: !1,
  20054. configurable: !0
  20055. }),
  20056. Object.defineProperty(a, "PerformanceLogLevel", {
  20057. set: function(e) {
  20058. if ((e & a.PerformanceUserMarkLogLevel) === a.PerformanceUserMarkLogLevel) {
  20059. a.StartPerformanceCounter = a._StartUserMark,
  20060. a.EndPerformanceCounter = a._EndUserMark;
  20061. return
  20062. }
  20063. if ((e & a.PerformanceConsoleLogLevel) === a.PerformanceConsoleLogLevel) {
  20064. a.StartPerformanceCounter = a._StartPerformanceConsole,
  20065. a.EndPerformanceCounter = a._EndPerformanceConsole;
  20066. return
  20067. }
  20068. a.StartPerformanceCounter = a._StartPerformanceCounterDisabled,
  20069. a.EndPerformanceCounter = a._EndPerformanceCounterDisabled
  20070. },
  20071. enumerable: !1,
  20072. configurable: !0
  20073. }),
  20074. a._StartPerformanceCounterDisabled = function(e, i) {}
  20075. ,
  20076. a._EndPerformanceCounterDisabled = function(e, i) {}
  20077. ,
  20078. a._StartUserMark = function(e, i) {
  20079. if (i === void 0 && (i = !0),
  20080. !a._performance) {
  20081. if (!IsWindowObjectExist())
  20082. return;
  20083. a._performance = window.performance
  20084. }
  20085. !i || !a._performance.mark || a._performance.mark(e + "-Begin")
  20086. }
  20087. ,
  20088. a._EndUserMark = function(e, i) {
  20089. i === void 0 && (i = !0),
  20090. !(!i || !a._performance.mark) && (a._performance.mark(e + "-End"),
  20091. a._performance.measure(e, e + "-Begin", e + "-End"))
  20092. }
  20093. ,
  20094. a._StartPerformanceConsole = function(e, i) {
  20095. i === void 0 && (i = !0),
  20096. i && (a._StartUserMark(e, i),
  20097. console.time && console.time(e))
  20098. }
  20099. ,
  20100. a._EndPerformanceConsole = function(e, i) {
  20101. i === void 0 && (i = !0),
  20102. i && (a._EndUserMark(e, i),
  20103. console.timeEnd(e))
  20104. }
  20105. ,
  20106. Object.defineProperty(a, "Now", {
  20107. get: function() {
  20108. return PrecisionDate.Now
  20109. },
  20110. enumerable: !1,
  20111. configurable: !0
  20112. }),
  20113. a.GetClassName = function(e, i) {
  20114. i === void 0 && (i = !1);
  20115. var o = null;
  20116. if (!i && e.getClassName)
  20117. o = e.getClassName();
  20118. else {
  20119. if (e instanceof Object) {
  20120. var s = i ? e : Object.getPrototypeOf(e);
  20121. o = s.constructor.__bjsclassName__
  20122. }
  20123. o || (o = typeof e)
  20124. }
  20125. return o
  20126. }
  20127. ,
  20128. a.First = function(e, i) {
  20129. for (var o = 0, s = e; o < s.length; o++) {
  20130. var c = s[o];
  20131. if (i(c))
  20132. return c
  20133. }
  20134. return null
  20135. }
  20136. ,
  20137. a.getFullClassName = function(e, i) {
  20138. i === void 0 && (i = !1);
  20139. var o = null
  20140. , s = null;
  20141. if (!i && e.getClassName)
  20142. o = e.getClassName();
  20143. else {
  20144. if (e instanceof Object) {
  20145. var c = i ? e : Object.getPrototypeOf(e);
  20146. o = c.constructor.__bjsclassName__,
  20147. s = c.constructor.__bjsmoduleName__
  20148. }
  20149. o || (o = typeof e)
  20150. }
  20151. return o ? (s != null ? s + "." : "") + o : null
  20152. }
  20153. ,
  20154. a.DelayAsync = function(e) {
  20155. return new Promise(function(i) {
  20156. setTimeout(function() {
  20157. i()
  20158. }, e)
  20159. }
  20160. )
  20161. }
  20162. ,
  20163. a.IsSafari = function() {
  20164. return IsNavigatorAvailable() ? /^((?!chrome|android).)*safari/i.test(navigator.userAgent) : !1
  20165. }
  20166. ,
  20167. a.UseCustomRequestHeaders = !1,
  20168. a.CustomRequestHeaders = WebRequest.CustomRequestHeaders,
  20169. a._tmpFloatArray = new Float32Array(1),
  20170. a.GetDOMTextContent = GetDOMTextContent,
  20171. a.GetAbsoluteUrl = typeof document == "object" ? function(e) {
  20172. var i = document.createElement("a");
  20173. return i.href = e,
  20174. i.href
  20175. }
  20176. : typeof URL == "function" && typeof location == "object" ? function(e) {
  20177. return new URL(e,location.origin).href
  20178. }
  20179. : function(e) {
  20180. throw new Error("Unable to get absolute URL. Override BABYLON.Tools.GetAbsoluteUrl to a custom implementation for the current context.")
  20181. }
  20182. ,
  20183. a.NoneLogLevel = Logger$2.NoneLogLevel,
  20184. a.MessageLogLevel = Logger$2.MessageLogLevel,
  20185. a.WarningLogLevel = Logger$2.WarningLogLevel,
  20186. a.ErrorLogLevel = Logger$2.ErrorLogLevel,
  20187. a.AllLogLevel = Logger$2.AllLogLevel,
  20188. a.IsWindowObjectExist = IsWindowObjectExist,
  20189. a.PerformanceNoneLogLevel = 0,
  20190. a.PerformanceUserMarkLogLevel = 1,
  20191. a.PerformanceConsoleLogLevel = 2,
  20192. a.StartPerformanceCounter = a._StartPerformanceCounterDisabled,
  20193. a.EndPerformanceCounter = a._EndPerformanceCounterDisabled,
  20194. a
  20195. }()
  20196. , AsyncLoop = function() {
  20197. function a(e, i, o, s) {
  20198. s === void 0 && (s = 0),
  20199. this.iterations = e,
  20200. this.index = s - 1,
  20201. this._done = !1,
  20202. this._fn = i,
  20203. this._successCallback = o
  20204. }
  20205. return a.prototype.executeNext = function() {
  20206. this._done || (this.index + 1 < this.iterations ? (++this.index,
  20207. this._fn(this)) : this.breakLoop())
  20208. }
  20209. ,
  20210. a.prototype.breakLoop = function() {
  20211. this._done = !0,
  20212. this._successCallback()
  20213. }
  20214. ,
  20215. a.Run = function(e, i, o, s) {
  20216. s === void 0 && (s = 0);
  20217. var c = new a(e,i,o,s);
  20218. return c.executeNext(),
  20219. c
  20220. }
  20221. ,
  20222. a.SyncAsyncForLoop = function(e, i, o, s, c, d) {
  20223. return d === void 0 && (d = 0),
  20224. a.Run(Math.ceil(e / i), function(_) {
  20225. c && c() ? _.breakLoop() : setTimeout(function() {
  20226. for (var b = 0; b < i; ++b) {
  20227. var k = _.index * i + b;
  20228. if (k >= e)
  20229. break;
  20230. if (o(k),
  20231. c && c()) {
  20232. _.breakLoop();
  20233. break
  20234. }
  20235. }
  20236. _.executeNext()
  20237. }, d)
  20238. }, s)
  20239. }
  20240. ,
  20241. a
  20242. }();
  20243. EngineStore.FallbackTexture = "data:image/jpg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/4QBmRXhpZgAATU0AKgAAAAgABAEaAAUAAAABAAAAPgEbAAUAAAABAAAARgEoAAMAAAABAAIAAAExAAIAAAAQAAAATgAAAAAAAABgAAAAAQAAAGAAAAABcGFpbnQubmV0IDQuMC41AP/bAEMABAIDAwMCBAMDAwQEBAQFCQYFBQUFCwgIBgkNCw0NDQsMDA4QFBEODxMPDAwSGBITFRYXFxcOERkbGRYaFBYXFv/bAEMBBAQEBQUFCgYGChYPDA8WFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFv/AABEIAQABAAMBIgACEQEDEQH/xAAfAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgv/xAC1EAACAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4eLj5OXm5+jp6vHy8/T19vf4+fr/xAAfAQADAQEBAQEBAQEBAAAAAAAAAQIDBAUGBwgJCgv/xAC1EQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2gAMAwEAAhEDEQA/APH6KKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76CiiigD5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BQooooA+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/voKKKKAPl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76CiiigD5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BQooooA+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/voKKKKAPl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76P//Z";
  20244. PromisePolyfill.Apply();
  20245. var Scalar = function() {
  20246. function a() {}
  20247. return a.WithinEpsilon = function(e, i, o) {
  20248. return o === void 0 && (o = 1401298e-51),
  20249. Math.abs(e - i) <= o
  20250. }
  20251. ,
  20252. a.ToHex = function(e) {
  20253. var i = e.toString(16);
  20254. return e <= 15 ? ("0" + i).toUpperCase() : i.toUpperCase()
  20255. }
  20256. ,
  20257. a.Sign = function(e) {
  20258. return e = +e,
  20259. e === 0 || isNaN(e) ? e : e > 0 ? 1 : -1
  20260. }
  20261. ,
  20262. a.Clamp = function(e, i, o) {
  20263. return i === void 0 && (i = 0),
  20264. o === void 0 && (o = 1),
  20265. Math.min(o, Math.max(i, e))
  20266. }
  20267. ,
  20268. a.Log2 = function(e) {
  20269. return Math.log(e) * Math.LOG2E
  20270. }
  20271. ,
  20272. a.ILog2 = function(e) {
  20273. if (Math.log2)
  20274. return Math.floor(Math.log2(e));
  20275. if (e < 0)
  20276. return NaN;
  20277. if (e === 0)
  20278. return -1 / 0;
  20279. var i = 0;
  20280. if (e < 1) {
  20281. for (; e < 1; )
  20282. i++,
  20283. e = e * 2;
  20284. i = -i
  20285. } else if (e > 1)
  20286. for (; e > 1; )
  20287. i++,
  20288. e = Math.floor(e / 2);
  20289. return i
  20290. }
  20291. ,
  20292. a.Repeat = function(e, i) {
  20293. return e - Math.floor(e / i) * i
  20294. }
  20295. ,
  20296. a.Normalize = function(e, i, o) {
  20297. return (e - i) / (o - i)
  20298. }
  20299. ,
  20300. a.Denormalize = function(e, i, o) {
  20301. return e * (o - i) + i
  20302. }
  20303. ,
  20304. a.DeltaAngle = function(e, i) {
  20305. var o = a.Repeat(i - e, 360);
  20306. return o > 180 && (o -= 360),
  20307. o
  20308. }
  20309. ,
  20310. a.PingPong = function(e, i) {
  20311. var o = a.Repeat(e, i * 2);
  20312. return i - Math.abs(o - i)
  20313. }
  20314. ,
  20315. a.SmoothStep = function(e, i, o) {
  20316. var s = a.Clamp(o);
  20317. return s = -2 * s * s * s + 3 * s * s,
  20318. i * s + e * (1 - s)
  20319. }
  20320. ,
  20321. a.MoveTowards = function(e, i, o) {
  20322. var s = 0;
  20323. return Math.abs(i - e) <= o ? s = i : s = e + a.Sign(i - e) * o,
  20324. s
  20325. }
  20326. ,
  20327. a.MoveTowardsAngle = function(e, i, o) {
  20328. var s = a.DeltaAngle(e, i)
  20329. , c = 0;
  20330. return -o < s && s < o ? c = i : (i = e + s,
  20331. c = a.MoveTowards(e, i, o)),
  20332. c
  20333. }
  20334. ,
  20335. a.Lerp = function(e, i, o) {
  20336. return e + (i - e) * o
  20337. }
  20338. ,
  20339. a.LerpAngle = function(e, i, o) {
  20340. var s = a.Repeat(i - e, 360);
  20341. return s > 180 && (s -= 360),
  20342. e + s * a.Clamp(o)
  20343. }
  20344. ,
  20345. a.InverseLerp = function(e, i, o) {
  20346. var s = 0;
  20347. return e != i ? s = a.Clamp((o - e) / (i - e)) : s = 0,
  20348. s
  20349. }
  20350. ,
  20351. a.Hermite = function(e, i, o, s, c) {
  20352. var d = c * c
  20353. , _ = c * d
  20354. , b = 2 * _ - 3 * d + 1
  20355. , k = -2 * _ + 3 * d
  20356. , j = _ - 2 * d + c
  20357. , $ = _ - d;
  20358. return e * b + o * k + i * j + s * $
  20359. }
  20360. ,
  20361. a.Hermite1stDerivative = function(e, i, o, s, c) {
  20362. var d = c * c;
  20363. return (d - c) * 6 * e + (3 * d - 4 * c + 1) * i + (-d + c) * 6 * o + (3 * d - 2 * c) * s
  20364. }
  20365. ,
  20366. a.RandomRange = function(e, i) {
  20367. return e === i ? e : Math.random() * (i - e) + e
  20368. }
  20369. ,
  20370. a.RangeToPercent = function(e, i, o) {
  20371. return (e - i) / (o - i)
  20372. }
  20373. ,
  20374. a.PercentToRange = function(e, i, o) {
  20375. return (o - i) * e + i
  20376. }
  20377. ,
  20378. a.NormalizeRadians = function(e) {
  20379. return e -= a.TwoPi * Math.floor((e + Math.PI) / a.TwoPi),
  20380. e
  20381. }
  20382. ,
  20383. a.HCF = function(e, i) {
  20384. var o = e % i;
  20385. return o === 0 ? i : a.HCF(i, o)
  20386. }
  20387. ,
  20388. a.TwoPi = Math.PI * 2,
  20389. a
  20390. }()
  20391. , ToGammaSpace = 1 / 2.2
  20392. , ToLinearSpace = 2.2
  20393. , PHI = (1 + Math.sqrt(5)) / 2
  20394. , Epsilon = .001
  20395. , ArrayTools = function() {
  20396. function a() {}
  20397. return a.BuildArray = function(e, i) {
  20398. for (var o = [], s = 0; s < e; ++s)
  20399. o.push(i());
  20400. return o
  20401. }
  20402. ,
  20403. a.BuildTuple = function(e, i) {
  20404. return a.BuildArray(e, i)
  20405. }
  20406. ,
  20407. a
  20408. }()
  20409. , Vector2 = function() {
  20410. function a(e, i) {
  20411. e === void 0 && (e = 0),
  20412. i === void 0 && (i = 0),
  20413. this.x = e,
  20414. this.y = i
  20415. }
  20416. return a.prototype.toString = function() {
  20417. return "{X: " + this.x + " Y: " + this.y + "}"
  20418. }
  20419. ,
  20420. a.prototype.getClassName = function() {
  20421. return "Vector2"
  20422. }
  20423. ,
  20424. a.prototype.getHashCode = function() {
  20425. var e = this.x | 0;
  20426. return e = e * 397 ^ (this.y | 0),
  20427. e
  20428. }
  20429. ,
  20430. a.prototype.toArray = function(e, i) {
  20431. return i === void 0 && (i = 0),
  20432. e[i] = this.x,
  20433. e[i + 1] = this.y,
  20434. this
  20435. }
  20436. ,
  20437. a.prototype.fromArray = function(e, i) {
  20438. return i === void 0 && (i = 0),
  20439. a.FromArrayToRef(e, i, this),
  20440. this
  20441. }
  20442. ,
  20443. a.prototype.asArray = function() {
  20444. var e = new Array;
  20445. return this.toArray(e, 0),
  20446. e
  20447. }
  20448. ,
  20449. a.prototype.copyFrom = function(e) {
  20450. return this.x = e.x,
  20451. this.y = e.y,
  20452. this
  20453. }
  20454. ,
  20455. a.prototype.copyFromFloats = function(e, i) {
  20456. return this.x = e,
  20457. this.y = i,
  20458. this
  20459. }
  20460. ,
  20461. a.prototype.set = function(e, i) {
  20462. return this.copyFromFloats(e, i)
  20463. }
  20464. ,
  20465. a.prototype.add = function(e) {
  20466. return new a(this.x + e.x,this.y + e.y)
  20467. }
  20468. ,
  20469. a.prototype.addToRef = function(e, i) {
  20470. return i.x = this.x + e.x,
  20471. i.y = this.y + e.y,
  20472. this
  20473. }
  20474. ,
  20475. a.prototype.addInPlace = function(e) {
  20476. return this.x += e.x,
  20477. this.y += e.y,
  20478. this
  20479. }
  20480. ,
  20481. a.prototype.addVector3 = function(e) {
  20482. return new a(this.x + e.x,this.y + e.y)
  20483. }
  20484. ,
  20485. a.prototype.subtract = function(e) {
  20486. return new a(this.x - e.x,this.y - e.y)
  20487. }
  20488. ,
  20489. a.prototype.subtractToRef = function(e, i) {
  20490. return i.x = this.x - e.x,
  20491. i.y = this.y - e.y,
  20492. this
  20493. }
  20494. ,
  20495. a.prototype.subtractInPlace = function(e) {
  20496. return this.x -= e.x,
  20497. this.y -= e.y,
  20498. this
  20499. }
  20500. ,
  20501. a.prototype.multiplyInPlace = function(e) {
  20502. return this.x *= e.x,
  20503. this.y *= e.y,
  20504. this
  20505. }
  20506. ,
  20507. a.prototype.multiply = function(e) {
  20508. return new a(this.x * e.x,this.y * e.y)
  20509. }
  20510. ,
  20511. a.prototype.multiplyToRef = function(e, i) {
  20512. return i.x = this.x * e.x,
  20513. i.y = this.y * e.y,
  20514. this
  20515. }
  20516. ,
  20517. a.prototype.multiplyByFloats = function(e, i) {
  20518. return new a(this.x * e,this.y * i)
  20519. }
  20520. ,
  20521. a.prototype.divide = function(e) {
  20522. return new a(this.x / e.x,this.y / e.y)
  20523. }
  20524. ,
  20525. a.prototype.divideToRef = function(e, i) {
  20526. return i.x = this.x / e.x,
  20527. i.y = this.y / e.y,
  20528. this
  20529. }
  20530. ,
  20531. a.prototype.divideInPlace = function(e) {
  20532. return this.divideToRef(e, this)
  20533. }
  20534. ,
  20535. a.prototype.negate = function() {
  20536. return new a(-this.x,-this.y)
  20537. }
  20538. ,
  20539. a.prototype.negateInPlace = function() {
  20540. return this.x *= -1,
  20541. this.y *= -1,
  20542. this
  20543. }
  20544. ,
  20545. a.prototype.negateToRef = function(e) {
  20546. return e.copyFromFloats(this.x * -1, this.y * -1)
  20547. }
  20548. ,
  20549. a.prototype.scaleInPlace = function(e) {
  20550. return this.x *= e,
  20551. this.y *= e,
  20552. this
  20553. }
  20554. ,
  20555. a.prototype.scale = function(e) {
  20556. var i = new a(0,0);
  20557. return this.scaleToRef(e, i),
  20558. i
  20559. }
  20560. ,
  20561. a.prototype.scaleToRef = function(e, i) {
  20562. return i.x = this.x * e,
  20563. i.y = this.y * e,
  20564. this
  20565. }
  20566. ,
  20567. a.prototype.scaleAndAddToRef = function(e, i) {
  20568. return i.x += this.x * e,
  20569. i.y += this.y * e,
  20570. this
  20571. }
  20572. ,
  20573. a.prototype.equals = function(e) {
  20574. return e && this.x === e.x && this.y === e.y
  20575. }
  20576. ,
  20577. a.prototype.equalsWithEpsilon = function(e, i) {
  20578. return i === void 0 && (i = Epsilon),
  20579. e && Scalar.WithinEpsilon(this.x, e.x, i) && Scalar.WithinEpsilon(this.y, e.y, i)
  20580. }
  20581. ,
  20582. a.prototype.floor = function() {
  20583. return new a(Math.floor(this.x),Math.floor(this.y))
  20584. }
  20585. ,
  20586. a.prototype.fract = function() {
  20587. return new a(this.x - Math.floor(this.x),this.y - Math.floor(this.y))
  20588. }
  20589. ,
  20590. a.prototype.rotateToRef = function(e, i) {
  20591. var o = Math.cos(e)
  20592. , s = Math.sin(e);
  20593. return i.x = o * this.x - s * this.y,
  20594. i.y = s * this.x + o * this.y,
  20595. this
  20596. }
  20597. ,
  20598. a.prototype.length = function() {
  20599. return Math.sqrt(this.x * this.x + this.y * this.y)
  20600. }
  20601. ,
  20602. a.prototype.lengthSquared = function() {
  20603. return this.x * this.x + this.y * this.y
  20604. }
  20605. ,
  20606. a.prototype.normalize = function() {
  20607. return a.NormalizeToRef(this, this),
  20608. this
  20609. }
  20610. ,
  20611. a.prototype.clone = function() {
  20612. return new a(this.x,this.y)
  20613. }
  20614. ,
  20615. a.Zero = function() {
  20616. return new a(0,0)
  20617. }
  20618. ,
  20619. a.One = function() {
  20620. return new a(1,1)
  20621. }
  20622. ,
  20623. a.FromArray = function(e, i) {
  20624. return i === void 0 && (i = 0),
  20625. new a(e[i],e[i + 1])
  20626. }
  20627. ,
  20628. a.FromArrayToRef = function(e, i, o) {
  20629. o.x = e[i],
  20630. o.y = e[i + 1]
  20631. }
  20632. ,
  20633. a.CatmullRom = function(e, i, o, s, c) {
  20634. var d = c * c
  20635. , _ = c * d
  20636. , b = .5 * (2 * i.x + (-e.x + o.x) * c + (2 * e.x - 5 * i.x + 4 * o.x - s.x) * d + (-e.x + 3 * i.x - 3 * o.x + s.x) * _)
  20637. , k = .5 * (2 * i.y + (-e.y + o.y) * c + (2 * e.y - 5 * i.y + 4 * o.y - s.y) * d + (-e.y + 3 * i.y - 3 * o.y + s.y) * _);
  20638. return new a(b,k)
  20639. }
  20640. ,
  20641. a.Clamp = function(e, i, o) {
  20642. var s = e.x;
  20643. s = s > o.x ? o.x : s,
  20644. s = s < i.x ? i.x : s;
  20645. var c = e.y;
  20646. return c = c > o.y ? o.y : c,
  20647. c = c < i.y ? i.y : c,
  20648. new a(s,c)
  20649. }
  20650. ,
  20651. a.Hermite = function(e, i, o, s, c) {
  20652. var d = c * c
  20653. , _ = c * d
  20654. , b = 2 * _ - 3 * d + 1
  20655. , k = -2 * _ + 3 * d
  20656. , j = _ - 2 * d + c
  20657. , $ = _ - d
  20658. , _e = e.x * b + o.x * k + i.x * j + s.x * $
  20659. , et = e.y * b + o.y * k + i.y * j + s.y * $;
  20660. return new a(_e,et)
  20661. }
  20662. ,
  20663. a.Hermite1stDerivative = function(e, i, o, s, c) {
  20664. var d = a.Zero();
  20665. return this.Hermite1stDerivativeToRef(e, i, o, s, c, d),
  20666. d
  20667. }
  20668. ,
  20669. a.Hermite1stDerivativeToRef = function(e, i, o, s, c, d) {
  20670. var _ = c * c;
  20671. d.x = (_ - c) * 6 * e.x + (3 * _ - 4 * c + 1) * i.x + (-_ + c) * 6 * o.x + (3 * _ - 2 * c) * s.x,
  20672. d.y = (_ - c) * 6 * e.y + (3 * _ - 4 * c + 1) * i.y + (-_ + c) * 6 * o.y + (3 * _ - 2 * c) * s.y
  20673. }
  20674. ,
  20675. a.Lerp = function(e, i, o) {
  20676. var s = e.x + (i.x - e.x) * o
  20677. , c = e.y + (i.y - e.y) * o;
  20678. return new a(s,c)
  20679. }
  20680. ,
  20681. a.Dot = function(e, i) {
  20682. return e.x * i.x + e.y * i.y
  20683. }
  20684. ,
  20685. a.Normalize = function(e) {
  20686. var i = a.Zero();
  20687. return this.NormalizeToRef(e, i),
  20688. i
  20689. }
  20690. ,
  20691. a.NormalizeToRef = function(e, i) {
  20692. var o = e.length();
  20693. o !== 0 && (i.x = e.x / o,
  20694. i.y = e.y / o)
  20695. }
  20696. ,
  20697. a.Minimize = function(e, i) {
  20698. var o = e.x < i.x ? e.x : i.x
  20699. , s = e.y < i.y ? e.y : i.y;
  20700. return new a(o,s)
  20701. }
  20702. ,
  20703. a.Maximize = function(e, i) {
  20704. var o = e.x > i.x ? e.x : i.x
  20705. , s = e.y > i.y ? e.y : i.y;
  20706. return new a(o,s)
  20707. }
  20708. ,
  20709. a.Transform = function(e, i) {
  20710. var o = a.Zero();
  20711. return a.TransformToRef(e, i, o),
  20712. o
  20713. }
  20714. ,
  20715. a.TransformToRef = function(e, i, o) {
  20716. var s = i.m
  20717. , c = e.x * s[0] + e.y * s[4] + s[12]
  20718. , d = e.x * s[1] + e.y * s[5] + s[13];
  20719. o.x = c,
  20720. o.y = d
  20721. }
  20722. ,
  20723. a.PointInTriangle = function(e, i, o, s) {
  20724. var c = .5 * (-o.y * s.x + i.y * (-o.x + s.x) + i.x * (o.y - s.y) + o.x * s.y)
  20725. , d = c < 0 ? -1 : 1
  20726. , _ = (i.y * s.x - i.x * s.y + (s.y - i.y) * e.x + (i.x - s.x) * e.y) * d
  20727. , b = (i.x * o.y - i.y * o.x + (i.y - o.y) * e.x + (o.x - i.x) * e.y) * d;
  20728. return _ > 0 && b > 0 && _ + b < 2 * c * d
  20729. }
  20730. ,
  20731. a.Distance = function(e, i) {
  20732. return Math.sqrt(a.DistanceSquared(e, i))
  20733. }
  20734. ,
  20735. a.DistanceSquared = function(e, i) {
  20736. var o = e.x - i.x
  20737. , s = e.y - i.y;
  20738. return o * o + s * s
  20739. }
  20740. ,
  20741. a.Center = function(e, i) {
  20742. return a.CenterToRef(e, i, a.Zero())
  20743. }
  20744. ,
  20745. a.CenterToRef = function(e, i, o) {
  20746. return o.copyFromFloats((e.x + i.x) / 2, (e.y + i.y) / 2)
  20747. }
  20748. ,
  20749. a.DistanceOfPointFromSegment = function(e, i, o) {
  20750. var s = a.DistanceSquared(i, o);
  20751. if (s === 0)
  20752. return a.Distance(e, i);
  20753. var c = o.subtract(i)
  20754. , d = Math.max(0, Math.min(1, a.Dot(e.subtract(i), c) / s))
  20755. , _ = i.add(c.multiplyByFloats(d, d));
  20756. return a.Distance(e, _)
  20757. }
  20758. ,
  20759. a
  20760. }()
  20761. , Vector3 = function() {
  20762. function a(e, i, o) {
  20763. e === void 0 && (e = 0),
  20764. i === void 0 && (i = 0),
  20765. o === void 0 && (o = 0),
  20766. this._isDirty = !0,
  20767. this._x = e,
  20768. this._y = i,
  20769. this._z = o
  20770. }
  20771. return Object.defineProperty(a.prototype, "x", {
  20772. get: function() {
  20773. return this._x
  20774. },
  20775. set: function(e) {
  20776. this._x = e,
  20777. this._isDirty = !0
  20778. },
  20779. enumerable: !1,
  20780. configurable: !0
  20781. }),
  20782. Object.defineProperty(a.prototype, "y", {
  20783. get: function() {
  20784. return this._y
  20785. },
  20786. set: function(e) {
  20787. this._y = e,
  20788. this._isDirty = !0
  20789. },
  20790. enumerable: !1,
  20791. configurable: !0
  20792. }),
  20793. Object.defineProperty(a.prototype, "z", {
  20794. get: function() {
  20795. return this._z
  20796. },
  20797. set: function(e) {
  20798. this._z = e,
  20799. this._isDirty = !0
  20800. },
  20801. enumerable: !1,
  20802. configurable: !0
  20803. }),
  20804. a.prototype.toString = function() {
  20805. return "{X: " + this._x + " Y: " + this._y + " Z: " + this._z + "}"
  20806. }
  20807. ,
  20808. a.prototype.getClassName = function() {
  20809. return "Vector3"
  20810. }
  20811. ,
  20812. a.prototype.getHashCode = function() {
  20813. var e = this._x | 0;
  20814. return e = e * 397 ^ (this._y | 0),
  20815. e = e * 397 ^ (this._z | 0),
  20816. e
  20817. }
  20818. ,
  20819. a.prototype.asArray = function() {
  20820. var e = [];
  20821. return this.toArray(e, 0),
  20822. e
  20823. }
  20824. ,
  20825. a.prototype.toArray = function(e, i) {
  20826. return i === void 0 && (i = 0),
  20827. e[i] = this._x,
  20828. e[i + 1] = this._y,
  20829. e[i + 2] = this._z,
  20830. this
  20831. }
  20832. ,
  20833. a.prototype.fromArray = function(e, i) {
  20834. return i === void 0 && (i = 0),
  20835. a.FromArrayToRef(e, i, this),
  20836. this
  20837. }
  20838. ,
  20839. a.prototype.toQuaternion = function() {
  20840. return Quaternion.RotationYawPitchRoll(this._y, this._x, this._z)
  20841. }
  20842. ,
  20843. a.prototype.addInPlace = function(e) {
  20844. return this.addInPlaceFromFloats(e._x, e._y, e._z)
  20845. }
  20846. ,
  20847. a.prototype.addInPlaceFromFloats = function(e, i, o) {
  20848. return this.x += e,
  20849. this.y += i,
  20850. this.z += o,
  20851. this
  20852. }
  20853. ,
  20854. a.prototype.add = function(e) {
  20855. return new a(this._x + e._x,this._y + e._y,this._z + e._z)
  20856. }
  20857. ,
  20858. a.prototype.addToRef = function(e, i) {
  20859. return i.copyFromFloats(this._x + e._x, this._y + e._y, this._z + e._z)
  20860. }
  20861. ,
  20862. a.prototype.subtractInPlace = function(e) {
  20863. return this.x -= e._x,
  20864. this.y -= e._y,
  20865. this.z -= e._z,
  20866. this
  20867. }
  20868. ,
  20869. a.prototype.subtract = function(e) {
  20870. return new a(this._x - e._x,this._y - e._y,this._z - e._z)
  20871. }
  20872. ,
  20873. a.prototype.subtractToRef = function(e, i) {
  20874. return this.subtractFromFloatsToRef(e._x, e._y, e._z, i)
  20875. }
  20876. ,
  20877. a.prototype.subtractFromFloats = function(e, i, o) {
  20878. return new a(this._x - e,this._y - i,this._z - o)
  20879. }
  20880. ,
  20881. a.prototype.subtractFromFloatsToRef = function(e, i, o, s) {
  20882. return s.copyFromFloats(this._x - e, this._y - i, this._z - o)
  20883. }
  20884. ,
  20885. a.prototype.negate = function() {
  20886. return new a(-this._x,-this._y,-this._z)
  20887. }
  20888. ,
  20889. a.prototype.negateInPlace = function() {
  20890. return this.x *= -1,
  20891. this.y *= -1,
  20892. this.z *= -1,
  20893. this
  20894. }
  20895. ,
  20896. a.prototype.negateToRef = function(e) {
  20897. return e.copyFromFloats(this._x * -1, this._y * -1, this._z * -1)
  20898. }
  20899. ,
  20900. a.prototype.scaleInPlace = function(e) {
  20901. return this.x *= e,
  20902. this.y *= e,
  20903. this.z *= e,
  20904. this
  20905. }
  20906. ,
  20907. a.prototype.scale = function(e) {
  20908. return new a(this._x * e,this._y * e,this._z * e)
  20909. }
  20910. ,
  20911. a.prototype.scaleToRef = function(e, i) {
  20912. return i.copyFromFloats(this._x * e, this._y * e, this._z * e)
  20913. }
  20914. ,
  20915. a.prototype.scaleAndAddToRef = function(e, i) {
  20916. return i.addInPlaceFromFloats(this._x * e, this._y * e, this._z * e)
  20917. }
  20918. ,
  20919. a.prototype.projectOnPlane = function(e, i) {
  20920. var o = a.Zero();
  20921. return this.projectOnPlaneToRef(e, i, o),
  20922. o
  20923. }
  20924. ,
  20925. a.prototype.projectOnPlaneToRef = function(e, i, o) {
  20926. var s = e.normal
  20927. , c = e.d
  20928. , d = MathTmp.Vector3[0];
  20929. this.subtractToRef(i, d),
  20930. d.normalize();
  20931. var _ = a.Dot(d, s)
  20932. , b = -(a.Dot(i, s) + c) / _
  20933. , k = d.scaleInPlace(b);
  20934. i.addToRef(k, o)
  20935. }
  20936. ,
  20937. a.prototype.equals = function(e) {
  20938. return e && this._x === e._x && this._y === e._y && this._z === e._z
  20939. }
  20940. ,
  20941. a.prototype.equalsWithEpsilon = function(e, i) {
  20942. return i === void 0 && (i = Epsilon),
  20943. e && Scalar.WithinEpsilon(this._x, e._x, i) && Scalar.WithinEpsilon(this._y, e._y, i) && Scalar.WithinEpsilon(this._z, e._z, i)
  20944. }
  20945. ,
  20946. a.prototype.equalsToFloats = function(e, i, o) {
  20947. return this._x === e && this._y === i && this._z === o
  20948. }
  20949. ,
  20950. a.prototype.multiplyInPlace = function(e) {
  20951. return this.x *= e._x,
  20952. this.y *= e._y,
  20953. this.z *= e._z,
  20954. this
  20955. }
  20956. ,
  20957. a.prototype.multiply = function(e) {
  20958. return this.multiplyByFloats(e._x, e._y, e._z)
  20959. }
  20960. ,
  20961. a.prototype.multiplyToRef = function(e, i) {
  20962. return i.copyFromFloats(this._x * e._x, this._y * e._y, this._z * e._z)
  20963. }
  20964. ,
  20965. a.prototype.multiplyByFloats = function(e, i, o) {
  20966. return new a(this._x * e,this._y * i,this._z * o)
  20967. }
  20968. ,
  20969. a.prototype.divide = function(e) {
  20970. return new a(this._x / e._x,this._y / e._y,this._z / e._z)
  20971. }
  20972. ,
  20973. a.prototype.divideToRef = function(e, i) {
  20974. return i.copyFromFloats(this._x / e._x, this._y / e._y, this._z / e._z)
  20975. }
  20976. ,
  20977. a.prototype.divideInPlace = function(e) {
  20978. return this.divideToRef(e, this)
  20979. }
  20980. ,
  20981. a.prototype.minimizeInPlace = function(e) {
  20982. return this.minimizeInPlaceFromFloats(e._x, e._y, e._z)
  20983. }
  20984. ,
  20985. a.prototype.maximizeInPlace = function(e) {
  20986. return this.maximizeInPlaceFromFloats(e._x, e._y, e._z)
  20987. }
  20988. ,
  20989. a.prototype.minimizeInPlaceFromFloats = function(e, i, o) {
  20990. return e < this._x && (this.x = e),
  20991. i < this._y && (this.y = i),
  20992. o < this._z && (this.z = o),
  20993. this
  20994. }
  20995. ,
  20996. a.prototype.maximizeInPlaceFromFloats = function(e, i, o) {
  20997. return e > this._x && (this.x = e),
  20998. i > this._y && (this.y = i),
  20999. o > this._z && (this.z = o),
  21000. this
  21001. }
  21002. ,
  21003. a.prototype.isNonUniformWithinEpsilon = function(e) {
  21004. var i = Math.abs(this._x)
  21005. , o = Math.abs(this._y);
  21006. if (!Scalar.WithinEpsilon(i, o, e))
  21007. return !0;
  21008. var s = Math.abs(this._z);
  21009. return !Scalar.WithinEpsilon(i, s, e) || !Scalar.WithinEpsilon(o, s, e)
  21010. }
  21011. ,
  21012. Object.defineProperty(a.prototype, "isNonUniform", {
  21013. get: function() {
  21014. var e = Math.abs(this._x)
  21015. , i = Math.abs(this._y);
  21016. if (e !== i)
  21017. return !0;
  21018. var o = Math.abs(this._z);
  21019. return e !== o
  21020. },
  21021. enumerable: !1,
  21022. configurable: !0
  21023. }),
  21024. a.prototype.floor = function() {
  21025. return new a(Math.floor(this._x),Math.floor(this._y),Math.floor(this._z))
  21026. }
  21027. ,
  21028. a.prototype.fract = function() {
  21029. return new a(this._x - Math.floor(this._x),this._y - Math.floor(this._y),this._z - Math.floor(this._z))
  21030. }
  21031. ,
  21032. a.prototype.length = function() {
  21033. return Math.sqrt(this._x * this._x + this._y * this._y + this._z * this._z)
  21034. }
  21035. ,
  21036. a.prototype.lengthSquared = function() {
  21037. return this._x * this._x + this._y * this._y + this._z * this._z
  21038. }
  21039. ,
  21040. a.prototype.normalize = function() {
  21041. return this.normalizeFromLength(this.length())
  21042. }
  21043. ,
  21044. a.prototype.reorderInPlace = function(e) {
  21045. var i = this;
  21046. return e = e.toLowerCase(),
  21047. e === "xyz" ? this : (MathTmp.Vector3[0].copyFrom(this),
  21048. ["x", "y", "z"].forEach(function(o, s) {
  21049. i[o] = MathTmp.Vector3[0][e[s]]
  21050. }),
  21051. this)
  21052. }
  21053. ,
  21054. a.prototype.rotateByQuaternionToRef = function(e, i) {
  21055. return e.toRotationMatrix(MathTmp.Matrix[0]),
  21056. a.TransformCoordinatesToRef(this, MathTmp.Matrix[0], i),
  21057. i
  21058. }
  21059. ,
  21060. a.prototype.rotateByQuaternionAroundPointToRef = function(e, i, o) {
  21061. return this.subtractToRef(i, MathTmp.Vector3[0]),
  21062. MathTmp.Vector3[0].rotateByQuaternionToRef(e, MathTmp.Vector3[0]),
  21063. i.addToRef(MathTmp.Vector3[0], o),
  21064. o
  21065. }
  21066. ,
  21067. a.prototype.cross = function(e) {
  21068. return a.Cross(this, e)
  21069. }
  21070. ,
  21071. a.prototype.normalizeFromLength = function(e) {
  21072. return e === 0 || e === 1 ? this : this.scaleInPlace(1 / e)
  21073. }
  21074. ,
  21075. a.prototype.normalizeToNew = function() {
  21076. var e = new a(0,0,0);
  21077. return this.normalizeToRef(e),
  21078. e
  21079. }
  21080. ,
  21081. a.prototype.normalizeToRef = function(e) {
  21082. var i = this.length();
  21083. return i === 0 || i === 1 ? e.copyFromFloats(this._x, this._y, this._z) : this.scaleToRef(1 / i, e)
  21084. }
  21085. ,
  21086. a.prototype.clone = function() {
  21087. return new a(this._x,this._y,this._z)
  21088. }
  21089. ,
  21090. a.prototype.copyFrom = function(e) {
  21091. return this.copyFromFloats(e._x, e._y, e._z)
  21092. }
  21093. ,
  21094. a.prototype.copyFromFloats = function(e, i, o) {
  21095. return this.x = e,
  21096. this.y = i,
  21097. this.z = o,
  21098. this
  21099. }
  21100. ,
  21101. a.prototype.set = function(e, i, o) {
  21102. return this.copyFromFloats(e, i, o)
  21103. }
  21104. ,
  21105. a.prototype.setAll = function(e) {
  21106. return this.x = this.y = this.z = e,
  21107. this
  21108. }
  21109. ,
  21110. a.GetClipFactor = function(e, i, o, s) {
  21111. var c = a.Dot(e, o) - s
  21112. , d = a.Dot(i, o) - s
  21113. , _ = c / (c - d);
  21114. return _
  21115. }
  21116. ,
  21117. a.GetAngleBetweenVectors = function(e, i, o) {
  21118. var s = e.normalizeToRef(MathTmp.Vector3[1])
  21119. , c = i.normalizeToRef(MathTmp.Vector3[2])
  21120. , d = a.Dot(s, c)
  21121. , _ = Math.acos(d)
  21122. , b = MathTmp.Vector3[3];
  21123. return a.CrossToRef(s, c, b),
  21124. a.Dot(b, o) > 0 ? isNaN(_) ? 0 : _ : isNaN(_) ? -Math.PI : -Math.acos(d)
  21125. }
  21126. ,
  21127. a.GetAngleBetweenVectorsOnPlane = function(e, i, o) {
  21128. MathTmp.Vector3[0].copyFrom(e);
  21129. var s = MathTmp.Vector3[0];
  21130. MathTmp.Vector3[1].copyFrom(i);
  21131. var c = MathTmp.Vector3[1];
  21132. MathTmp.Vector3[2].copyFrom(o);
  21133. var d = MathTmp.Vector3[2]
  21134. , _ = MathTmp.Vector3[3]
  21135. , b = MathTmp.Vector3[4];
  21136. s.normalize(),
  21137. c.normalize(),
  21138. d.normalize(),
  21139. a.CrossToRef(d, s, _),
  21140. a.CrossToRef(_, d, b);
  21141. var k = Math.atan2(a.Dot(c, _), a.Dot(c, b));
  21142. return Scalar.NormalizeRadians(k)
  21143. }
  21144. ,
  21145. a.SlerpToRef = function(e, i, o, s) {
  21146. o = Scalar.Clamp(o, 0, 1);
  21147. var c = MathTmp.Vector3[0], d = MathTmp.Vector3[1], _, b;
  21148. c.copyFrom(e),
  21149. _ = c.length(),
  21150. c.normalizeFromLength(_),
  21151. d.copyFrom(i),
  21152. b = d.length(),
  21153. d.normalizeFromLength(b);
  21154. var k = a.Dot(c, d), j, $;
  21155. if (k < 1 - Epsilon) {
  21156. var _e = Math.acos(k)
  21157. , et = 1 / Math.sin(_e);
  21158. j = Math.sin((1 - o) * _e) * et,
  21159. $ = Math.sin(o * _e) * et
  21160. } else
  21161. j = 1 - o,
  21162. $ = o;
  21163. c.scaleInPlace(j),
  21164. d.scaleInPlace($),
  21165. s.copyFrom(c).addInPlace(d),
  21166. s.scaleInPlace(Scalar.Lerp(_, b, o))
  21167. }
  21168. ,
  21169. a.SmoothToRef = function(e, i, o, s, c) {
  21170. a.SlerpToRef(e, i, s === 0 ? 1 : o / s, c)
  21171. }
  21172. ,
  21173. a.FromArray = function(e, i) {
  21174. return i === void 0 && (i = 0),
  21175. new a(e[i],e[i + 1],e[i + 2])
  21176. }
  21177. ,
  21178. a.FromFloatArray = function(e, i) {
  21179. return a.FromArray(e, i)
  21180. }
  21181. ,
  21182. a.FromArrayToRef = function(e, i, o) {
  21183. o.x = e[i],
  21184. o.y = e[i + 1],
  21185. o.z = e[i + 2]
  21186. }
  21187. ,
  21188. a.FromFloatArrayToRef = function(e, i, o) {
  21189. return a.FromArrayToRef(e, i, o)
  21190. }
  21191. ,
  21192. a.FromFloatsToRef = function(e, i, o, s) {
  21193. s.copyFromFloats(e, i, o)
  21194. }
  21195. ,
  21196. a.Zero = function() {
  21197. return new a(0,0,0)
  21198. }
  21199. ,
  21200. a.One = function() {
  21201. return new a(1,1,1)
  21202. }
  21203. ,
  21204. a.Up = function() {
  21205. return new a(0,1,0)
  21206. }
  21207. ,
  21208. Object.defineProperty(a, "UpReadOnly", {
  21209. get: function() {
  21210. return a._UpReadOnly
  21211. },
  21212. enumerable: !1,
  21213. configurable: !0
  21214. }),
  21215. Object.defineProperty(a, "RightReadOnly", {
  21216. get: function() {
  21217. return a._RightReadOnly
  21218. },
  21219. enumerable: !1,
  21220. configurable: !0
  21221. }),
  21222. Object.defineProperty(a, "LeftHandedForwardReadOnly", {
  21223. get: function() {
  21224. return a._LeftHandedForwardReadOnly
  21225. },
  21226. enumerable: !1,
  21227. configurable: !0
  21228. }),
  21229. Object.defineProperty(a, "RightHandedForwardReadOnly", {
  21230. get: function() {
  21231. return a._RightHandedForwardReadOnly
  21232. },
  21233. enumerable: !1,
  21234. configurable: !0
  21235. }),
  21236. Object.defineProperty(a, "ZeroReadOnly", {
  21237. get: function() {
  21238. return a._ZeroReadOnly
  21239. },
  21240. enumerable: !1,
  21241. configurable: !0
  21242. }),
  21243. a.Down = function() {
  21244. return new a(0,-1,0)
  21245. }
  21246. ,
  21247. a.Forward = function(e) {
  21248. return e === void 0 && (e = !1),
  21249. new a(0,0,e ? -1 : 1)
  21250. }
  21251. ,
  21252. a.Backward = function(e) {
  21253. return e === void 0 && (e = !1),
  21254. new a(0,0,e ? 1 : -1)
  21255. }
  21256. ,
  21257. a.Right = function() {
  21258. return new a(1,0,0)
  21259. }
  21260. ,
  21261. a.Left = function() {
  21262. return new a(-1,0,0)
  21263. }
  21264. ,
  21265. a.TransformCoordinates = function(e, i) {
  21266. var o = a.Zero();
  21267. return a.TransformCoordinatesToRef(e, i, o),
  21268. o
  21269. }
  21270. ,
  21271. a.TransformCoordinatesToRef = function(e, i, o) {
  21272. a.TransformCoordinatesFromFloatsToRef(e._x, e._y, e._z, i, o)
  21273. }
  21274. ,
  21275. a.TransformCoordinatesFromFloatsToRef = function(e, i, o, s, c) {
  21276. var d = s.m
  21277. , _ = e * d[0] + i * d[4] + o * d[8] + d[12]
  21278. , b = e * d[1] + i * d[5] + o * d[9] + d[13]
  21279. , k = e * d[2] + i * d[6] + o * d[10] + d[14]
  21280. , j = 1 / (e * d[3] + i * d[7] + o * d[11] + d[15]);
  21281. c.x = _ * j,
  21282. c.y = b * j,
  21283. c.z = k * j
  21284. }
  21285. ,
  21286. a.TransformNormal = function(e, i) {
  21287. var o = a.Zero();
  21288. return a.TransformNormalToRef(e, i, o),
  21289. o
  21290. }
  21291. ,
  21292. a.TransformNormalToRef = function(e, i, o) {
  21293. this.TransformNormalFromFloatsToRef(e._x, e._y, e._z, i, o)
  21294. }
  21295. ,
  21296. a.TransformNormalFromFloatsToRef = function(e, i, o, s, c) {
  21297. var d = s.m;
  21298. c.x = e * d[0] + i * d[4] + o * d[8],
  21299. c.y = e * d[1] + i * d[5] + o * d[9],
  21300. c.z = e * d[2] + i * d[6] + o * d[10]
  21301. }
  21302. ,
  21303. a.CatmullRom = function(e, i, o, s, c) {
  21304. var d = c * c
  21305. , _ = c * d
  21306. , b = .5 * (2 * i._x + (-e._x + o._x) * c + (2 * e._x - 5 * i._x + 4 * o._x - s._x) * d + (-e._x + 3 * i._x - 3 * o._x + s._x) * _)
  21307. , k = .5 * (2 * i._y + (-e._y + o._y) * c + (2 * e._y - 5 * i._y + 4 * o._y - s._y) * d + (-e._y + 3 * i._y - 3 * o._y + s._y) * _)
  21308. , j = .5 * (2 * i._z + (-e._z + o._z) * c + (2 * e._z - 5 * i._z + 4 * o._z - s._z) * d + (-e._z + 3 * i._z - 3 * o._z + s._z) * _);
  21309. return new a(b,k,j)
  21310. }
  21311. ,
  21312. a.Clamp = function(e, i, o) {
  21313. var s = new a;
  21314. return a.ClampToRef(e, i, o, s),
  21315. s
  21316. }
  21317. ,
  21318. a.ClampToRef = function(e, i, o, s) {
  21319. var c = e._x;
  21320. c = c > o._x ? o._x : c,
  21321. c = c < i._x ? i._x : c;
  21322. var d = e._y;
  21323. d = d > o._y ? o._y : d,
  21324. d = d < i._y ? i._y : d;
  21325. var _ = e._z;
  21326. _ = _ > o._z ? o._z : _,
  21327. _ = _ < i._z ? i._z : _,
  21328. s.copyFromFloats(c, d, _)
  21329. }
  21330. ,
  21331. a.CheckExtends = function(e, i, o) {
  21332. i.minimizeInPlace(e),
  21333. o.maximizeInPlace(e)
  21334. }
  21335. ,
  21336. a.Hermite = function(e, i, o, s, c) {
  21337. var d = c * c
  21338. , _ = c * d
  21339. , b = 2 * _ - 3 * d + 1
  21340. , k = -2 * _ + 3 * d
  21341. , j = _ - 2 * d + c
  21342. , $ = _ - d
  21343. , _e = e._x * b + o._x * k + i._x * j + s._x * $
  21344. , et = e._y * b + o._y * k + i._y * j + s._y * $
  21345. , tt = e._z * b + o._z * k + i._z * j + s._z * $;
  21346. return new a(_e,et,tt)
  21347. }
  21348. ,
  21349. a.Hermite1stDerivative = function(e, i, o, s, c) {
  21350. var d = a.Zero();
  21351. return this.Hermite1stDerivativeToRef(e, i, o, s, c, d),
  21352. d
  21353. }
  21354. ,
  21355. a.Hermite1stDerivativeToRef = function(e, i, o, s, c, d) {
  21356. var _ = c * c;
  21357. d.x = (_ - c) * 6 * e.x + (3 * _ - 4 * c + 1) * i.x + (-_ + c) * 6 * o.x + (3 * _ - 2 * c) * s.x,
  21358. d.y = (_ - c) * 6 * e.y + (3 * _ - 4 * c + 1) * i.y + (-_ + c) * 6 * o.y + (3 * _ - 2 * c) * s.y,
  21359. d.z = (_ - c) * 6 * e.z + (3 * _ - 4 * c + 1) * i.z + (-_ + c) * 6 * o.z + (3 * _ - 2 * c) * s.z
  21360. }
  21361. ,
  21362. a.Lerp = function(e, i, o) {
  21363. var s = new a(0,0,0);
  21364. return a.LerpToRef(e, i, o, s),
  21365. s
  21366. }
  21367. ,
  21368. a.LerpToRef = function(e, i, o, s) {
  21369. s.x = e._x + (i._x - e._x) * o,
  21370. s.y = e._y + (i._y - e._y) * o,
  21371. s.z = e._z + (i._z - e._z) * o
  21372. }
  21373. ,
  21374. a.Dot = function(e, i) {
  21375. return e._x * i._x + e._y * i._y + e._z * i._z
  21376. }
  21377. ,
  21378. a.Cross = function(e, i) {
  21379. var o = a.Zero();
  21380. return a.CrossToRef(e, i, o),
  21381. o
  21382. }
  21383. ,
  21384. a.CrossToRef = function(e, i, o) {
  21385. var s = e._y * i._z - e._z * i._y
  21386. , c = e._z * i._x - e._x * i._z
  21387. , d = e._x * i._y - e._y * i._x;
  21388. o.copyFromFloats(s, c, d)
  21389. }
  21390. ,
  21391. a.Normalize = function(e) {
  21392. var i = a.Zero();
  21393. return a.NormalizeToRef(e, i),
  21394. i
  21395. }
  21396. ,
  21397. a.NormalizeToRef = function(e, i) {
  21398. e.normalizeToRef(i)
  21399. }
  21400. ,
  21401. a.Project = function(e, i, o, s) {
  21402. var c = new a;
  21403. return a.ProjectToRef(e, i, o, s, c),
  21404. c
  21405. }
  21406. ,
  21407. a.ProjectToRef = function(e, i, o, s, c) {
  21408. var d = s.width
  21409. , _ = s.height
  21410. , b = s.x
  21411. , k = s.y
  21412. , j = MathTmp.Matrix[1];
  21413. Matrix.FromValuesToRef(d / 2, 0, 0, 0, 0, -_ / 2, 0, 0, 0, 0, .5, 0, b + d / 2, _ / 2 + k, .5, 1, j);
  21414. var $ = MathTmp.Matrix[0];
  21415. return i.multiplyToRef(o, $),
  21416. $.multiplyToRef(j, $),
  21417. a.TransformCoordinatesToRef(e, $, c),
  21418. c
  21419. }
  21420. ,
  21421. a._UnprojectFromInvertedMatrixToRef = function(e, i, o) {
  21422. a.TransformCoordinatesToRef(e, i, o);
  21423. var s = i.m
  21424. , c = e._x * s[3] + e._y * s[7] + e._z * s[11] + s[15];
  21425. Scalar.WithinEpsilon(c, 1) && o.scaleInPlace(1 / c)
  21426. }
  21427. ,
  21428. a.UnprojectFromTransform = function(e, i, o, s, c) {
  21429. var d = MathTmp.Matrix[0];
  21430. s.multiplyToRef(c, d),
  21431. d.invert(),
  21432. e.x = e._x / i * 2 - 1,
  21433. e.y = -(e._y / o * 2 - 1);
  21434. var _ = new a;
  21435. return a._UnprojectFromInvertedMatrixToRef(e, d, _),
  21436. _
  21437. }
  21438. ,
  21439. a.Unproject = function(e, i, o, s, c, d) {
  21440. var _ = a.Zero();
  21441. return a.UnprojectToRef(e, i, o, s, c, d, _),
  21442. _
  21443. }
  21444. ,
  21445. a.UnprojectToRef = function(e, i, o, s, c, d, _) {
  21446. a.UnprojectFloatsToRef(e._x, e._y, e._z, i, o, s, c, d, _)
  21447. }
  21448. ,
  21449. a.UnprojectFloatsToRef = function(e, i, o, s, c, d, _, b, k) {
  21450. var j = MathTmp.Matrix[0];
  21451. d.multiplyToRef(_, j),
  21452. j.multiplyToRef(b, j),
  21453. j.invert();
  21454. var $ = MathTmp.Vector3[0];
  21455. $.x = e / s * 2 - 1,
  21456. $.y = -(i / c * 2 - 1),
  21457. $.z = 2 * o - 1,
  21458. a._UnprojectFromInvertedMatrixToRef($, j, k)
  21459. }
  21460. ,
  21461. a.Minimize = function(e, i) {
  21462. var o = e.clone();
  21463. return o.minimizeInPlace(i),
  21464. o
  21465. }
  21466. ,
  21467. a.Maximize = function(e, i) {
  21468. var o = e.clone();
  21469. return o.maximizeInPlace(i),
  21470. o
  21471. }
  21472. ,
  21473. a.Distance = function(e, i) {
  21474. return Math.sqrt(a.DistanceSquared(e, i))
  21475. }
  21476. ,
  21477. a.DistanceSquared = function(e, i) {
  21478. var o = e._x - i._x
  21479. , s = e._y - i._y
  21480. , c = e._z - i._z;
  21481. return o * o + s * s + c * c
  21482. }
  21483. ,
  21484. a.ProjectOnTriangleToRef = function(e, i, o, s, c) {
  21485. var d = MathTmp.Vector3[0]
  21486. , _ = MathTmp.Vector3[1]
  21487. , b = MathTmp.Vector3[2]
  21488. , k = MathTmp.Vector3[3]
  21489. , j = MathTmp.Vector3[4];
  21490. o.subtractToRef(i, d),
  21491. s.subtractToRef(i, _),
  21492. s.subtractToRef(o, b);
  21493. var $ = d.length()
  21494. , _e = _.length()
  21495. , et = b.length();
  21496. if ($ < Epsilon || _e < Epsilon || et < Epsilon)
  21497. return c.copyFrom(i),
  21498. a.Distance(e, i);
  21499. e.subtractToRef(i, j),
  21500. a.CrossToRef(d, _, k);
  21501. var tt = k.length();
  21502. if (tt < Epsilon)
  21503. return c.copyFrom(i),
  21504. a.Distance(e, i);
  21505. k.normalizeFromLength(tt);
  21506. var rt = j.length();
  21507. if (rt < Epsilon)
  21508. return c.copyFrom(i),
  21509. 0;
  21510. j.normalizeFromLength(rt);
  21511. var it = a.Dot(k, j)
  21512. , nt = MathTmp.Vector3[5]
  21513. , ot = MathTmp.Vector3[6];
  21514. nt.copyFrom(k).scaleInPlace(-rt * it),
  21515. ot.copyFrom(e).addInPlace(nt);
  21516. var at = MathTmp.Vector3[4]
  21517. , st = MathTmp.Vector3[5]
  21518. , ut = MathTmp.Vector3[7]
  21519. , ct = MathTmp.Vector3[8];
  21520. at.copyFrom(d).scaleInPlace(1 / $),
  21521. ct.copyFrom(_).scaleInPlace(1 / _e),
  21522. at.addInPlace(ct).scaleInPlace(-1),
  21523. st.copyFrom(d).scaleInPlace(-1 / $),
  21524. ct.copyFrom(b).scaleInPlace(1 / et),
  21525. st.addInPlace(ct).scaleInPlace(-1),
  21526. ut.copyFrom(b).scaleInPlace(-1 / et),
  21527. ct.copyFrom(_).scaleInPlace(-1 / _e),
  21528. ut.addInPlace(ct).scaleInPlace(-1);
  21529. var lt = MathTmp.Vector3[9], ft, ht, pt, dt;
  21530. lt.copyFrom(ot).subtractInPlace(i),
  21531. a.CrossToRef(at, lt, ct),
  21532. ft = a.Dot(ct, k),
  21533. ht = ft,
  21534. lt.copyFrom(ot).subtractInPlace(o),
  21535. a.CrossToRef(st, lt, ct),
  21536. ft = a.Dot(ct, k),
  21537. pt = ft,
  21538. lt.copyFrom(ot).subtractInPlace(s),
  21539. a.CrossToRef(ut, lt, ct),
  21540. ft = a.Dot(ct, k),
  21541. dt = ft;
  21542. var _t = MathTmp.Vector3[10], mt, vt;
  21543. ht > 0 && pt < 0 ? (_t.copyFrom(d),
  21544. mt = i,
  21545. vt = o) : pt > 0 && dt < 0 ? (_t.copyFrom(b),
  21546. mt = o,
  21547. vt = s) : (_t.copyFrom(_).scaleInPlace(-1),
  21548. mt = s,
  21549. vt = i);
  21550. var yt = MathTmp.Vector3[9]
  21551. , Et = MathTmp.Vector3[4];
  21552. mt.subtractToRef(ot, ct),
  21553. vt.subtractToRef(ot, yt),
  21554. a.CrossToRef(ct, yt, Et);
  21555. var At = a.Dot(Et, k) < 0;
  21556. if (!At)
  21557. return c.copyFrom(ot),
  21558. Math.abs(rt * it);
  21559. var gt = MathTmp.Vector3[5];
  21560. a.CrossToRef(_t, Et, gt),
  21561. gt.normalize();
  21562. var St = MathTmp.Vector3[9];
  21563. St.copyFrom(mt).subtractInPlace(ot);
  21564. var xt = St.length();
  21565. if (xt < Epsilon)
  21566. return c.copyFrom(mt),
  21567. a.Distance(e, mt);
  21568. St.normalizeFromLength(xt);
  21569. var bt = a.Dot(gt, St)
  21570. , Rt = MathTmp.Vector3[7];
  21571. Rt.copyFrom(ot).addInPlace(gt.scaleInPlace(xt * bt)),
  21572. ct.copyFrom(Rt).subtractInPlace(mt),
  21573. rt = _t.length(),
  21574. _t.normalizeFromLength(rt);
  21575. var Mt = a.Dot(ct, _t) / Math.max(rt, Epsilon);
  21576. return Mt = Scalar.Clamp(Mt, 0, 1),
  21577. Rt.copyFrom(mt).addInPlace(_t.scaleInPlace(Mt * rt)),
  21578. c.copyFrom(Rt),
  21579. a.Distance(e, Rt)
  21580. }
  21581. ,
  21582. a.Center = function(e, i) {
  21583. return a.CenterToRef(e, i, a.Zero())
  21584. }
  21585. ,
  21586. a.CenterToRef = function(e, i, o) {
  21587. return o.copyFromFloats((e._x + i._x) / 2, (e._y + i._y) / 2, (e._z + i._z) / 2)
  21588. }
  21589. ,
  21590. a.RotationFromAxis = function(e, i, o) {
  21591. var s = a.Zero();
  21592. return a.RotationFromAxisToRef(e, i, o, s),
  21593. s
  21594. }
  21595. ,
  21596. a.RotationFromAxisToRef = function(e, i, o, s) {
  21597. var c = MathTmp.Quaternion[0];
  21598. Quaternion.RotationQuaternionFromAxisToRef(e, i, o, c),
  21599. c.toEulerAnglesToRef(s)
  21600. }
  21601. ,
  21602. a._UpReadOnly = a.Up(),
  21603. a._LeftHandedForwardReadOnly = a.Forward(!1),
  21604. a._RightHandedForwardReadOnly = a.Forward(!0),
  21605. a._RightReadOnly = a.Right(),
  21606. a._ZeroReadOnly = a.Zero(),
  21607. a
  21608. }()
  21609. , Vector4 = function() {
  21610. function a(e, i, o, s) {
  21611. this.x = e,
  21612. this.y = i,
  21613. this.z = o,
  21614. this.w = s
  21615. }
  21616. return a.prototype.toString = function() {
  21617. return "{X: " + this.x + " Y: " + this.y + " Z: " + this.z + " W: " + this.w + "}"
  21618. }
  21619. ,
  21620. a.prototype.getClassName = function() {
  21621. return "Vector4"
  21622. }
  21623. ,
  21624. a.prototype.getHashCode = function() {
  21625. var e = this.x | 0;
  21626. return e = e * 397 ^ (this.y | 0),
  21627. e = e * 397 ^ (this.z | 0),
  21628. e = e * 397 ^ (this.w | 0),
  21629. e
  21630. }
  21631. ,
  21632. a.prototype.asArray = function() {
  21633. var e = new Array;
  21634. return this.toArray(e, 0),
  21635. e
  21636. }
  21637. ,
  21638. a.prototype.toArray = function(e, i) {
  21639. return i === void 0 && (i = 0),
  21640. e[i] = this.x,
  21641. e[i + 1] = this.y,
  21642. e[i + 2] = this.z,
  21643. e[i + 3] = this.w,
  21644. this
  21645. }
  21646. ,
  21647. a.prototype.fromArray = function(e, i) {
  21648. return i === void 0 && (i = 0),
  21649. a.FromArrayToRef(e, i, this),
  21650. this
  21651. }
  21652. ,
  21653. a.prototype.addInPlace = function(e) {
  21654. return this.x += e.x,
  21655. this.y += e.y,
  21656. this.z += e.z,
  21657. this.w += e.w,
  21658. this
  21659. }
  21660. ,
  21661. a.prototype.add = function(e) {
  21662. return new a(this.x + e.x,this.y + e.y,this.z + e.z,this.w + e.w)
  21663. }
  21664. ,
  21665. a.prototype.addToRef = function(e, i) {
  21666. return i.x = this.x + e.x,
  21667. i.y = this.y + e.y,
  21668. i.z = this.z + e.z,
  21669. i.w = this.w + e.w,
  21670. this
  21671. }
  21672. ,
  21673. a.prototype.subtractInPlace = function(e) {
  21674. return this.x -= e.x,
  21675. this.y -= e.y,
  21676. this.z -= e.z,
  21677. this.w -= e.w,
  21678. this
  21679. }
  21680. ,
  21681. a.prototype.subtract = function(e) {
  21682. return new a(this.x - e.x,this.y - e.y,this.z - e.z,this.w - e.w)
  21683. }
  21684. ,
  21685. a.prototype.subtractToRef = function(e, i) {
  21686. return i.x = this.x - e.x,
  21687. i.y = this.y - e.y,
  21688. i.z = this.z - e.z,
  21689. i.w = this.w - e.w,
  21690. this
  21691. }
  21692. ,
  21693. a.prototype.subtractFromFloats = function(e, i, o, s) {
  21694. return new a(this.x - e,this.y - i,this.z - o,this.w - s)
  21695. }
  21696. ,
  21697. a.prototype.subtractFromFloatsToRef = function(e, i, o, s, c) {
  21698. return c.x = this.x - e,
  21699. c.y = this.y - i,
  21700. c.z = this.z - o,
  21701. c.w = this.w - s,
  21702. this
  21703. }
  21704. ,
  21705. a.prototype.negate = function() {
  21706. return new a(-this.x,-this.y,-this.z,-this.w)
  21707. }
  21708. ,
  21709. a.prototype.negateInPlace = function() {
  21710. return this.x *= -1,
  21711. this.y *= -1,
  21712. this.z *= -1,
  21713. this.w *= -1,
  21714. this
  21715. }
  21716. ,
  21717. a.prototype.negateToRef = function(e) {
  21718. return e.copyFromFloats(this.x * -1, this.y * -1, this.z * -1, this.w * -1)
  21719. }
  21720. ,
  21721. a.prototype.scaleInPlace = function(e) {
  21722. return this.x *= e,
  21723. this.y *= e,
  21724. this.z *= e,
  21725. this.w *= e,
  21726. this
  21727. }
  21728. ,
  21729. a.prototype.scale = function(e) {
  21730. return new a(this.x * e,this.y * e,this.z * e,this.w * e)
  21731. }
  21732. ,
  21733. a.prototype.scaleToRef = function(e, i) {
  21734. return i.x = this.x * e,
  21735. i.y = this.y * e,
  21736. i.z = this.z * e,
  21737. i.w = this.w * e,
  21738. this
  21739. }
  21740. ,
  21741. a.prototype.scaleAndAddToRef = function(e, i) {
  21742. return i.x += this.x * e,
  21743. i.y += this.y * e,
  21744. i.z += this.z * e,
  21745. i.w += this.w * e,
  21746. this
  21747. }
  21748. ,
  21749. a.prototype.equals = function(e) {
  21750. return e && this.x === e.x && this.y === e.y && this.z === e.z && this.w === e.w
  21751. }
  21752. ,
  21753. a.prototype.equalsWithEpsilon = function(e, i) {
  21754. return i === void 0 && (i = Epsilon),
  21755. e && Scalar.WithinEpsilon(this.x, e.x, i) && Scalar.WithinEpsilon(this.y, e.y, i) && Scalar.WithinEpsilon(this.z, e.z, i) && Scalar.WithinEpsilon(this.w, e.w, i)
  21756. }
  21757. ,
  21758. a.prototype.equalsToFloats = function(e, i, o, s) {
  21759. return this.x === e && this.y === i && this.z === o && this.w === s
  21760. }
  21761. ,
  21762. a.prototype.multiplyInPlace = function(e) {
  21763. return this.x *= e.x,
  21764. this.y *= e.y,
  21765. this.z *= e.z,
  21766. this.w *= e.w,
  21767. this
  21768. }
  21769. ,
  21770. a.prototype.multiply = function(e) {
  21771. return new a(this.x * e.x,this.y * e.y,this.z * e.z,this.w * e.w)
  21772. }
  21773. ,
  21774. a.prototype.multiplyToRef = function(e, i) {
  21775. return i.x = this.x * e.x,
  21776. i.y = this.y * e.y,
  21777. i.z = this.z * e.z,
  21778. i.w = this.w * e.w,
  21779. this
  21780. }
  21781. ,
  21782. a.prototype.multiplyByFloats = function(e, i, o, s) {
  21783. return new a(this.x * e,this.y * i,this.z * o,this.w * s)
  21784. }
  21785. ,
  21786. a.prototype.divide = function(e) {
  21787. return new a(this.x / e.x,this.y / e.y,this.z / e.z,this.w / e.w)
  21788. }
  21789. ,
  21790. a.prototype.divideToRef = function(e, i) {
  21791. return i.x = this.x / e.x,
  21792. i.y = this.y / e.y,
  21793. i.z = this.z / e.z,
  21794. i.w = this.w / e.w,
  21795. this
  21796. }
  21797. ,
  21798. a.prototype.divideInPlace = function(e) {
  21799. return this.divideToRef(e, this)
  21800. }
  21801. ,
  21802. a.prototype.minimizeInPlace = function(e) {
  21803. return e.x < this.x && (this.x = e.x),
  21804. e.y < this.y && (this.y = e.y),
  21805. e.z < this.z && (this.z = e.z),
  21806. e.w < this.w && (this.w = e.w),
  21807. this
  21808. }
  21809. ,
  21810. a.prototype.maximizeInPlace = function(e) {
  21811. return e.x > this.x && (this.x = e.x),
  21812. e.y > this.y && (this.y = e.y),
  21813. e.z > this.z && (this.z = e.z),
  21814. e.w > this.w && (this.w = e.w),
  21815. this
  21816. }
  21817. ,
  21818. a.prototype.floor = function() {
  21819. return new a(Math.floor(this.x),Math.floor(this.y),Math.floor(this.z),Math.floor(this.w))
  21820. }
  21821. ,
  21822. a.prototype.fract = function() {
  21823. return new a(this.x - Math.floor(this.x),this.y - Math.floor(this.y),this.z - Math.floor(this.z),this.w - Math.floor(this.w))
  21824. }
  21825. ,
  21826. a.prototype.length = function() {
  21827. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w)
  21828. }
  21829. ,
  21830. a.prototype.lengthSquared = function() {
  21831. return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w
  21832. }
  21833. ,
  21834. a.prototype.normalize = function() {
  21835. var e = this.length();
  21836. return e === 0 ? this : this.scaleInPlace(1 / e)
  21837. }
  21838. ,
  21839. a.prototype.toVector3 = function() {
  21840. return new Vector3(this.x,this.y,this.z)
  21841. }
  21842. ,
  21843. a.prototype.clone = function() {
  21844. return new a(this.x,this.y,this.z,this.w)
  21845. }
  21846. ,
  21847. a.prototype.copyFrom = function(e) {
  21848. return this.x = e.x,
  21849. this.y = e.y,
  21850. this.z = e.z,
  21851. this.w = e.w,
  21852. this
  21853. }
  21854. ,
  21855. a.prototype.copyFromFloats = function(e, i, o, s) {
  21856. return this.x = e,
  21857. this.y = i,
  21858. this.z = o,
  21859. this.w = s,
  21860. this
  21861. }
  21862. ,
  21863. a.prototype.set = function(e, i, o, s) {
  21864. return this.copyFromFloats(e, i, o, s)
  21865. }
  21866. ,
  21867. a.prototype.setAll = function(e) {
  21868. return this.x = this.y = this.z = this.w = e,
  21869. this
  21870. }
  21871. ,
  21872. a.FromArray = function(e, i) {
  21873. return i || (i = 0),
  21874. new a(e[i],e[i + 1],e[i + 2],e[i + 3])
  21875. }
  21876. ,
  21877. a.FromArrayToRef = function(e, i, o) {
  21878. o.x = e[i],
  21879. o.y = e[i + 1],
  21880. o.z = e[i + 2],
  21881. o.w = e[i + 3]
  21882. }
  21883. ,
  21884. a.FromFloatArrayToRef = function(e, i, o) {
  21885. a.FromArrayToRef(e, i, o)
  21886. }
  21887. ,
  21888. a.FromFloatsToRef = function(e, i, o, s, c) {
  21889. c.x = e,
  21890. c.y = i,
  21891. c.z = o,
  21892. c.w = s
  21893. }
  21894. ,
  21895. a.Zero = function() {
  21896. return new a(0,0,0,0)
  21897. }
  21898. ,
  21899. a.One = function() {
  21900. return new a(1,1,1,1)
  21901. }
  21902. ,
  21903. a.Normalize = function(e) {
  21904. var i = a.Zero();
  21905. return a.NormalizeToRef(e, i),
  21906. i
  21907. }
  21908. ,
  21909. a.NormalizeToRef = function(e, i) {
  21910. i.copyFrom(e),
  21911. i.normalize()
  21912. }
  21913. ,
  21914. a.Minimize = function(e, i) {
  21915. var o = e.clone();
  21916. return o.minimizeInPlace(i),
  21917. o
  21918. }
  21919. ,
  21920. a.Maximize = function(e, i) {
  21921. var o = e.clone();
  21922. return o.maximizeInPlace(i),
  21923. o
  21924. }
  21925. ,
  21926. a.Distance = function(e, i) {
  21927. return Math.sqrt(a.DistanceSquared(e, i))
  21928. }
  21929. ,
  21930. a.DistanceSquared = function(e, i) {
  21931. var o = e.x - i.x
  21932. , s = e.y - i.y
  21933. , c = e.z - i.z
  21934. , d = e.w - i.w;
  21935. return o * o + s * s + c * c + d * d
  21936. }
  21937. ,
  21938. a.Center = function(e, i) {
  21939. return a.CenterToRef(e, i, a.Zero())
  21940. }
  21941. ,
  21942. a.CenterToRef = function(e, i, o) {
  21943. return o.copyFromFloats((e.x + i.x) / 2, (e.y + i.y) / 2, (e.z + i.z) / 2, (e.w + i.w) / 2)
  21944. }
  21945. ,
  21946. a.TransformCoordinates = function(e, i) {
  21947. var o = a.Zero();
  21948. return a.TransformCoordinatesToRef(e, i, o),
  21949. o
  21950. }
  21951. ,
  21952. a.TransformCoordinatesToRef = function(e, i, o) {
  21953. a.TransformCoordinatesFromFloatsToRef(e._x, e._y, e._z, i, o)
  21954. }
  21955. ,
  21956. a.TransformCoordinatesFromFloatsToRef = function(e, i, o, s, c) {
  21957. var d = s.m
  21958. , _ = e * d[0] + i * d[4] + o * d[8] + d[12]
  21959. , b = e * d[1] + i * d[5] + o * d[9] + d[13]
  21960. , k = e * d[2] + i * d[6] + o * d[10] + d[14]
  21961. , j = e * d[3] + i * d[7] + o * d[11] + d[15];
  21962. c.x = _,
  21963. c.y = b,
  21964. c.z = k,
  21965. c.w = j
  21966. }
  21967. ,
  21968. a.TransformNormal = function(e, i) {
  21969. var o = a.Zero();
  21970. return a.TransformNormalToRef(e, i, o),
  21971. o
  21972. }
  21973. ,
  21974. a.TransformNormalToRef = function(e, i, o) {
  21975. var s = i.m
  21976. , c = e.x * s[0] + e.y * s[4] + e.z * s[8]
  21977. , d = e.x * s[1] + e.y * s[5] + e.z * s[9]
  21978. , _ = e.x * s[2] + e.y * s[6] + e.z * s[10];
  21979. o.x = c,
  21980. o.y = d,
  21981. o.z = _,
  21982. o.w = e.w
  21983. }
  21984. ,
  21985. a.TransformNormalFromFloatsToRef = function(e, i, o, s, c, d) {
  21986. var _ = c.m;
  21987. d.x = e * _[0] + i * _[4] + o * _[8],
  21988. d.y = e * _[1] + i * _[5] + o * _[9],
  21989. d.z = e * _[2] + i * _[6] + o * _[10],
  21990. d.w = s
  21991. }
  21992. ,
  21993. a.FromVector3 = function(e, i) {
  21994. return i === void 0 && (i = 0),
  21995. new a(e._x,e._y,e._z,i)
  21996. }
  21997. ,
  21998. a
  21999. }()
  22000. , Quaternion = function() {
  22001. function a(e, i, o, s) {
  22002. e === void 0 && (e = 0),
  22003. i === void 0 && (i = 0),
  22004. o === void 0 && (o = 0),
  22005. s === void 0 && (s = 1),
  22006. this._isDirty = !0,
  22007. this._x = e,
  22008. this._y = i,
  22009. this._z = o,
  22010. this._w = s
  22011. }
  22012. return Object.defineProperty(a.prototype, "x", {
  22013. get: function() {
  22014. return this._x
  22015. },
  22016. set: function(e) {
  22017. this._x = e,
  22018. this._isDirty = !0
  22019. },
  22020. enumerable: !1,
  22021. configurable: !0
  22022. }),
  22023. Object.defineProperty(a.prototype, "y", {
  22024. get: function() {
  22025. return this._y
  22026. },
  22027. set: function(e) {
  22028. this._y = e,
  22029. this._isDirty = !0
  22030. },
  22031. enumerable: !1,
  22032. configurable: !0
  22033. }),
  22034. Object.defineProperty(a.prototype, "z", {
  22035. get: function() {
  22036. return this._z
  22037. },
  22038. set: function(e) {
  22039. this._z = e,
  22040. this._isDirty = !0
  22041. },
  22042. enumerable: !1,
  22043. configurable: !0
  22044. }),
  22045. Object.defineProperty(a.prototype, "w", {
  22046. get: function() {
  22047. return this._w
  22048. },
  22049. set: function(e) {
  22050. this._w = e,
  22051. this._isDirty = !0
  22052. },
  22053. enumerable: !1,
  22054. configurable: !0
  22055. }),
  22056. a.prototype.toString = function() {
  22057. return "{X: " + this._x + " Y: " + this._y + " Z: " + this._z + " W: " + this._w + "}"
  22058. }
  22059. ,
  22060. a.prototype.getClassName = function() {
  22061. return "Quaternion"
  22062. }
  22063. ,
  22064. a.prototype.getHashCode = function() {
  22065. var e = this._x | 0;
  22066. return e = e * 397 ^ (this._y | 0),
  22067. e = e * 397 ^ (this._z | 0),
  22068. e = e * 397 ^ (this._w | 0),
  22069. e
  22070. }
  22071. ,
  22072. a.prototype.asArray = function() {
  22073. return [this._x, this._y, this._z, this._w]
  22074. }
  22075. ,
  22076. a.prototype.equals = function(e) {
  22077. return e && this._x === e._x && this._y === e._y && this._z === e._z && this._w === e._w
  22078. }
  22079. ,
  22080. a.prototype.equalsWithEpsilon = function(e, i) {
  22081. return i === void 0 && (i = Epsilon),
  22082. e && Scalar.WithinEpsilon(this._x, e._x, i) && Scalar.WithinEpsilon(this._y, e._y, i) && Scalar.WithinEpsilon(this._z, e._z, i) && Scalar.WithinEpsilon(this._w, e._w, i)
  22083. }
  22084. ,
  22085. a.prototype.clone = function() {
  22086. return new a(this._x,this._y,this._z,this._w)
  22087. }
  22088. ,
  22089. a.prototype.copyFrom = function(e) {
  22090. return this.x = e._x,
  22091. this.y = e._y,
  22092. this.z = e._z,
  22093. this.w = e._w,
  22094. this
  22095. }
  22096. ,
  22097. a.prototype.copyFromFloats = function(e, i, o, s) {
  22098. return this.x = e,
  22099. this.y = i,
  22100. this.z = o,
  22101. this.w = s,
  22102. this
  22103. }
  22104. ,
  22105. a.prototype.set = function(e, i, o, s) {
  22106. return this.copyFromFloats(e, i, o, s)
  22107. }
  22108. ,
  22109. a.prototype.add = function(e) {
  22110. return new a(this._x + e._x,this._y + e._y,this._z + e._z,this._w + e._w)
  22111. }
  22112. ,
  22113. a.prototype.addInPlace = function(e) {
  22114. return this._x += e._x,
  22115. this._y += e._y,
  22116. this._z += e._z,
  22117. this._w += e._w,
  22118. this
  22119. }
  22120. ,
  22121. a.prototype.subtract = function(e) {
  22122. return new a(this._x - e._x,this._y - e._y,this._z - e._z,this._w - e._w)
  22123. }
  22124. ,
  22125. a.prototype.scale = function(e) {
  22126. return new a(this._x * e,this._y * e,this._z * e,this._w * e)
  22127. }
  22128. ,
  22129. a.prototype.scaleToRef = function(e, i) {
  22130. return i.x = this._x * e,
  22131. i.y = this._y * e,
  22132. i.z = this._z * e,
  22133. i.w = this._w * e,
  22134. this
  22135. }
  22136. ,
  22137. a.prototype.scaleInPlace = function(e) {
  22138. return this.x *= e,
  22139. this.y *= e,
  22140. this.z *= e,
  22141. this.w *= e,
  22142. this
  22143. }
  22144. ,
  22145. a.prototype.scaleAndAddToRef = function(e, i) {
  22146. return i.x += this._x * e,
  22147. i.y += this._y * e,
  22148. i.z += this._z * e,
  22149. i.w += this._w * e,
  22150. this
  22151. }
  22152. ,
  22153. a.prototype.multiply = function(e) {
  22154. var i = new a(0,0,0,1);
  22155. return this.multiplyToRef(e, i),
  22156. i
  22157. }
  22158. ,
  22159. a.prototype.multiplyToRef = function(e, i) {
  22160. var o = this._x * e._w + this._y * e._z - this._z * e._y + this._w * e._x
  22161. , s = -this._x * e._z + this._y * e._w + this._z * e._x + this._w * e._y
  22162. , c = this._x * e._y - this._y * e._x + this._z * e._w + this._w * e._z
  22163. , d = -this._x * e._x - this._y * e._y - this._z * e._z + this._w * e._w;
  22164. return i.copyFromFloats(o, s, c, d),
  22165. this
  22166. }
  22167. ,
  22168. a.prototype.multiplyInPlace = function(e) {
  22169. return this.multiplyToRef(e, this),
  22170. this
  22171. }
  22172. ,
  22173. a.prototype.conjugateToRef = function(e) {
  22174. return e.copyFromFloats(-this._x, -this._y, -this._z, this._w),
  22175. this
  22176. }
  22177. ,
  22178. a.prototype.conjugateInPlace = function() {
  22179. return this.x *= -1,
  22180. this.y *= -1,
  22181. this.z *= -1,
  22182. this
  22183. }
  22184. ,
  22185. a.prototype.conjugate = function() {
  22186. var e = new a(-this._x,-this._y,-this._z,this._w);
  22187. return e
  22188. }
  22189. ,
  22190. a.prototype.length = function() {
  22191. return Math.sqrt(this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w)
  22192. }
  22193. ,
  22194. a.prototype.normalize = function() {
  22195. var e = this.length();
  22196. if (e === 0)
  22197. return this;
  22198. var i = 1 / e;
  22199. return this.x *= i,
  22200. this.y *= i,
  22201. this.z *= i,
  22202. this.w *= i,
  22203. this
  22204. }
  22205. ,
  22206. a.prototype.toEulerAngles = function() {
  22207. var e = Vector3.Zero();
  22208. return this.toEulerAnglesToRef(e),
  22209. e
  22210. }
  22211. ,
  22212. a.prototype.toEulerAnglesToRef = function(e) {
  22213. var i = this._z
  22214. , o = this._x
  22215. , s = this._y
  22216. , c = this._w
  22217. , d = c * c
  22218. , _ = i * i
  22219. , b = o * o
  22220. , k = s * s
  22221. , j = s * i - o * c
  22222. , $ = .4999999;
  22223. return j < -$ ? (e.y = 2 * Math.atan2(s, c),
  22224. e.x = Math.PI / 2,
  22225. e.z = 0) : j > $ ? (e.y = 2 * Math.atan2(s, c),
  22226. e.x = -Math.PI / 2,
  22227. e.z = 0) : (e.z = Math.atan2(2 * (o * s + i * c), -_ - b + k + d),
  22228. e.x = Math.asin(-2 * (i * s - o * c)),
  22229. e.y = Math.atan2(2 * (i * o + s * c), _ - b - k + d)),
  22230. this
  22231. }
  22232. ,
  22233. a.prototype.toRotationMatrix = function(e) {
  22234. return Matrix.FromQuaternionToRef(this, e),
  22235. this
  22236. }
  22237. ,
  22238. a.prototype.fromRotationMatrix = function(e) {
  22239. return a.FromRotationMatrixToRef(e, this),
  22240. this
  22241. }
  22242. ,
  22243. a.FromRotationMatrix = function(e) {
  22244. var i = new a;
  22245. return a.FromRotationMatrixToRef(e, i),
  22246. i
  22247. }
  22248. ,
  22249. a.FromRotationMatrixToRef = function(e, i) {
  22250. var o = e.m, s = o[0], c = o[4], d = o[8], _ = o[1], b = o[5], k = o[9], j = o[2], $ = o[6], _e = o[10], et = s + b + _e, tt;
  22251. et > 0 ? (tt = .5 / Math.sqrt(et + 1),
  22252. i.w = .25 / tt,
  22253. i.x = ($ - k) * tt,
  22254. i.y = (d - j) * tt,
  22255. i.z = (_ - c) * tt) : s > b && s > _e ? (tt = 2 * Math.sqrt(1 + s - b - _e),
  22256. i.w = ($ - k) / tt,
  22257. i.x = .25 * tt,
  22258. i.y = (c + _) / tt,
  22259. i.z = (d + j) / tt) : b > _e ? (tt = 2 * Math.sqrt(1 + b - s - _e),
  22260. i.w = (d - j) / tt,
  22261. i.x = (c + _) / tt,
  22262. i.y = .25 * tt,
  22263. i.z = (k + $) / tt) : (tt = 2 * Math.sqrt(1 + _e - s - b),
  22264. i.w = (_ - c) / tt,
  22265. i.x = (d + j) / tt,
  22266. i.y = (k + $) / tt,
  22267. i.z = .25 * tt)
  22268. }
  22269. ,
  22270. a.Dot = function(e, i) {
  22271. return e._x * i._x + e._y * i._y + e._z * i._z + e._w * i._w
  22272. }
  22273. ,
  22274. a.AreClose = function(e, i) {
  22275. var o = a.Dot(e, i);
  22276. return o >= 0
  22277. }
  22278. ,
  22279. a.SmoothToRef = function(e, i, o, s, c) {
  22280. var d = s === 0 ? 1 : o / s;
  22281. d = Scalar.Clamp(d, 0, 1),
  22282. a.SlerpToRef(e, i, d, c)
  22283. }
  22284. ,
  22285. a.Zero = function() {
  22286. return new a(0,0,0,0)
  22287. }
  22288. ,
  22289. a.Inverse = function(e) {
  22290. return new a(-e._x,-e._y,-e._z,e._w)
  22291. }
  22292. ,
  22293. a.InverseToRef = function(e, i) {
  22294. return i.set(-e._x, -e._y, -e._z, e._w),
  22295. i
  22296. }
  22297. ,
  22298. a.Identity = function() {
  22299. return new a(0,0,0,1)
  22300. }
  22301. ,
  22302. a.IsIdentity = function(e) {
  22303. return e && e._x === 0 && e._y === 0 && e._z === 0 && e._w === 1
  22304. }
  22305. ,
  22306. a.RotationAxis = function(e, i) {
  22307. return a.RotationAxisToRef(e, i, new a)
  22308. }
  22309. ,
  22310. a.RotationAxisToRef = function(e, i, o) {
  22311. var s = Math.sin(i / 2);
  22312. return e.normalize(),
  22313. o.w = Math.cos(i / 2),
  22314. o.x = e._x * s,
  22315. o.y = e._y * s,
  22316. o.z = e._z * s,
  22317. o
  22318. }
  22319. ,
  22320. a.FromArray = function(e, i) {
  22321. return i || (i = 0),
  22322. new a(e[i],e[i + 1],e[i + 2],e[i + 3])
  22323. }
  22324. ,
  22325. a.FromArrayToRef = function(e, i, o) {
  22326. o.x = e[i],
  22327. o.y = e[i + 1],
  22328. o.z = e[i + 2],
  22329. o.w = e[i + 3]
  22330. }
  22331. ,
  22332. a.FromEulerAngles = function(e, i, o) {
  22333. var s = new a;
  22334. return a.RotationYawPitchRollToRef(i, e, o, s),
  22335. s
  22336. }
  22337. ,
  22338. a.FromEulerAnglesToRef = function(e, i, o, s) {
  22339. return a.RotationYawPitchRollToRef(i, e, o, s),
  22340. s
  22341. }
  22342. ,
  22343. a.FromEulerVector = function(e) {
  22344. var i = new a;
  22345. return a.RotationYawPitchRollToRef(e._y, e._x, e._z, i),
  22346. i
  22347. }
  22348. ,
  22349. a.FromEulerVectorToRef = function(e, i) {
  22350. return a.RotationYawPitchRollToRef(e._y, e._x, e._z, i),
  22351. i
  22352. }
  22353. ,
  22354. a.FromUnitVectorsToRef = function(e, i, o) {
  22355. var s = Vector3.Dot(e, i) + 1;
  22356. return s < Epsilon ? Math.abs(e.x) > Math.abs(e.z) ? o.set(-e.y, e.x, 0, 0) : o.set(0, -e.z, e.y, 0) : (Vector3.CrossToRef(e, i, TmpVectors.Vector3[0]),
  22357. o.set(TmpVectors.Vector3[0].x, TmpVectors.Vector3[0].y, TmpVectors.Vector3[0].z, s)),
  22358. o.normalize()
  22359. }
  22360. ,
  22361. a.RotationYawPitchRoll = function(e, i, o) {
  22362. var s = new a;
  22363. return a.RotationYawPitchRollToRef(e, i, o, s),
  22364. s
  22365. }
  22366. ,
  22367. a.RotationYawPitchRollToRef = function(e, i, o, s) {
  22368. var c = o * .5
  22369. , d = i * .5
  22370. , _ = e * .5
  22371. , b = Math.sin(c)
  22372. , k = Math.cos(c)
  22373. , j = Math.sin(d)
  22374. , $ = Math.cos(d)
  22375. , _e = Math.sin(_)
  22376. , et = Math.cos(_);
  22377. s.x = et * j * k + _e * $ * b,
  22378. s.y = _e * $ * k - et * j * b,
  22379. s.z = et * $ * b - _e * j * k,
  22380. s.w = et * $ * k + _e * j * b
  22381. }
  22382. ,
  22383. a.RotationAlphaBetaGamma = function(e, i, o) {
  22384. var s = new a;
  22385. return a.RotationAlphaBetaGammaToRef(e, i, o, s),
  22386. s
  22387. }
  22388. ,
  22389. a.RotationAlphaBetaGammaToRef = function(e, i, o, s) {
  22390. var c = (o + e) * .5
  22391. , d = (o - e) * .5
  22392. , _ = i * .5;
  22393. s.x = Math.cos(d) * Math.sin(_),
  22394. s.y = Math.sin(d) * Math.sin(_),
  22395. s.z = Math.sin(c) * Math.cos(_),
  22396. s.w = Math.cos(c) * Math.cos(_)
  22397. }
  22398. ,
  22399. a.RotationQuaternionFromAxis = function(e, i, o) {
  22400. var s = new a(0,0,0,0);
  22401. return a.RotationQuaternionFromAxisToRef(e, i, o, s),
  22402. s
  22403. }
  22404. ,
  22405. a.RotationQuaternionFromAxisToRef = function(e, i, o, s) {
  22406. var c = MathTmp.Matrix[0];
  22407. Matrix.FromXYZAxesToRef(e.normalize(), i.normalize(), o.normalize(), c),
  22408. a.FromRotationMatrixToRef(c, s)
  22409. }
  22410. ,
  22411. a.FromLookDirectionLH = function(e, i) {
  22412. var o = new a;
  22413. return a.FromLookDirectionLHToRef(e, i, o),
  22414. o
  22415. }
  22416. ,
  22417. a.FromLookDirectionLHToRef = function(e, i, o) {
  22418. var s = MathTmp.Matrix[0];
  22419. Matrix.LookDirectionLHToRef(e, i, s),
  22420. a.FromRotationMatrixToRef(s, o)
  22421. }
  22422. ,
  22423. a.FromLookDirectionRH = function(e, i) {
  22424. var o = new a;
  22425. return a.FromLookDirectionRHToRef(e, i, o),
  22426. o
  22427. }
  22428. ,
  22429. a.FromLookDirectionRHToRef = function(e, i, o) {
  22430. var s = MathTmp.Matrix[0];
  22431. return Matrix.LookDirectionRHToRef(e, i, s),
  22432. a.FromRotationMatrixToRef(s, o)
  22433. }
  22434. ,
  22435. a.Slerp = function(e, i, o) {
  22436. var s = a.Identity();
  22437. return a.SlerpToRef(e, i, o, s),
  22438. s
  22439. }
  22440. ,
  22441. a.SlerpToRef = function(e, i, o, s) {
  22442. var c, d, _ = e._x * i._x + e._y * i._y + e._z * i._z + e._w * i._w, b = !1;
  22443. if (_ < 0 && (b = !0,
  22444. _ = -_),
  22445. _ > .999999)
  22446. d = 1 - o,
  22447. c = b ? -o : o;
  22448. else {
  22449. var k = Math.acos(_)
  22450. , j = 1 / Math.sin(k);
  22451. d = Math.sin((1 - o) * k) * j,
  22452. c = b ? -Math.sin(o * k) * j : Math.sin(o * k) * j
  22453. }
  22454. s.x = d * e._x + c * i._x,
  22455. s.y = d * e._y + c * i._y,
  22456. s.z = d * e._z + c * i._z,
  22457. s.w = d * e._w + c * i._w
  22458. }
  22459. ,
  22460. a.Hermite = function(e, i, o, s, c) {
  22461. var d = c * c
  22462. , _ = c * d
  22463. , b = 2 * _ - 3 * d + 1
  22464. , k = -2 * _ + 3 * d
  22465. , j = _ - 2 * d + c
  22466. , $ = _ - d
  22467. , _e = e._x * b + o._x * k + i._x * j + s._x * $
  22468. , et = e._y * b + o._y * k + i._y * j + s._y * $
  22469. , tt = e._z * b + o._z * k + i._z * j + s._z * $
  22470. , rt = e._w * b + o._w * k + i._w * j + s._w * $;
  22471. return new a(_e,et,tt,rt)
  22472. }
  22473. ,
  22474. a.Hermite1stDerivative = function(e, i, o, s, c) {
  22475. var d = a.Zero();
  22476. return this.Hermite1stDerivativeToRef(e, i, o, s, c, d),
  22477. d
  22478. }
  22479. ,
  22480. a.Hermite1stDerivativeToRef = function(e, i, o, s, c, d) {
  22481. var _ = c * c;
  22482. d.x = (_ - c) * 6 * e.x + (3 * _ - 4 * c + 1) * i.x + (-_ + c) * 6 * o.x + (3 * _ - 2 * c) * s.x,
  22483. d.y = (_ - c) * 6 * e.y + (3 * _ - 4 * c + 1) * i.y + (-_ + c) * 6 * o.y + (3 * _ - 2 * c) * s.y,
  22484. d.z = (_ - c) * 6 * e.z + (3 * _ - 4 * c + 1) * i.z + (-_ + c) * 6 * o.z + (3 * _ - 2 * c) * s.z,
  22485. d.w = (_ - c) * 6 * e.w + (3 * _ - 4 * c + 1) * i.w + (-_ + c) * 6 * o.w + (3 * _ - 2 * c) * s.w
  22486. }
  22487. ,
  22488. a
  22489. }()
  22490. , Matrix = function() {
  22491. function a() {
  22492. this._isIdentity = !1,
  22493. this._isIdentityDirty = !0,
  22494. this._isIdentity3x2 = !0,
  22495. this._isIdentity3x2Dirty = !0,
  22496. this.updateFlag = -1,
  22497. PerformanceConfigurator.MatrixTrackPrecisionChange && PerformanceConfigurator.MatrixTrackedMatrices.push(this),
  22498. this._m = new PerformanceConfigurator.MatrixCurrentType(16),
  22499. this._markAsUpdated()
  22500. }
  22501. return Object.defineProperty(a, "Use64Bits", {
  22502. get: function() {
  22503. return PerformanceConfigurator.MatrixUse64Bits
  22504. },
  22505. enumerable: !1,
  22506. configurable: !0
  22507. }),
  22508. Object.defineProperty(a.prototype, "m", {
  22509. get: function() {
  22510. return this._m
  22511. },
  22512. enumerable: !1,
  22513. configurable: !0
  22514. }),
  22515. a.prototype._markAsUpdated = function() {
  22516. this.updateFlag = a._updateFlagSeed++,
  22517. this._isIdentity = !1,
  22518. this._isIdentity3x2 = !1,
  22519. this._isIdentityDirty = !0,
  22520. this._isIdentity3x2Dirty = !0
  22521. }
  22522. ,
  22523. a.prototype._updateIdentityStatus = function(e, i, o, s) {
  22524. i === void 0 && (i = !1),
  22525. o === void 0 && (o = !1),
  22526. s === void 0 && (s = !0),
  22527. this._isIdentity = e,
  22528. this._isIdentity3x2 = e || o,
  22529. this._isIdentityDirty = this._isIdentity ? !1 : i,
  22530. this._isIdentity3x2Dirty = this._isIdentity3x2 ? !1 : s
  22531. }
  22532. ,
  22533. a.prototype.isIdentity = function() {
  22534. if (this._isIdentityDirty) {
  22535. this._isIdentityDirty = !1;
  22536. var e = this._m;
  22537. this._isIdentity = e[0] === 1 && e[1] === 0 && e[2] === 0 && e[3] === 0 && e[4] === 0 && e[5] === 1 && e[6] === 0 && e[7] === 0 && e[8] === 0 && e[9] === 0 && e[10] === 1 && e[11] === 0 && e[12] === 0 && e[13] === 0 && e[14] === 0 && e[15] === 1
  22538. }
  22539. return this._isIdentity
  22540. }
  22541. ,
  22542. a.prototype.isIdentityAs3x2 = function() {
  22543. return this._isIdentity3x2Dirty && (this._isIdentity3x2Dirty = !1,
  22544. this._m[0] !== 1 || this._m[5] !== 1 || this._m[15] !== 1 ? this._isIdentity3x2 = !1 : this._m[1] !== 0 || this._m[2] !== 0 || this._m[3] !== 0 || this._m[4] !== 0 || this._m[6] !== 0 || this._m[7] !== 0 || this._m[8] !== 0 || this._m[9] !== 0 || this._m[10] !== 0 || this._m[11] !== 0 || this._m[12] !== 0 || this._m[13] !== 0 || this._m[14] !== 0 ? this._isIdentity3x2 = !1 : this._isIdentity3x2 = !0),
  22545. this._isIdentity3x2
  22546. }
  22547. ,
  22548. a.prototype.determinant = function() {
  22549. if (this._isIdentity === !0)
  22550. return 1;
  22551. var e = this._m
  22552. , i = e[0]
  22553. , o = e[1]
  22554. , s = e[2]
  22555. , c = e[3]
  22556. , d = e[4]
  22557. , _ = e[5]
  22558. , b = e[6]
  22559. , k = e[7]
  22560. , j = e[8]
  22561. , $ = e[9]
  22562. , _e = e[10]
  22563. , et = e[11]
  22564. , tt = e[12]
  22565. , rt = e[13]
  22566. , it = e[14]
  22567. , nt = e[15]
  22568. , ot = _e * nt - it * et
  22569. , at = $ * nt - rt * et
  22570. , st = $ * it - rt * _e
  22571. , ut = j * nt - tt * et
  22572. , ct = j * it - _e * tt
  22573. , lt = j * rt - tt * $
  22574. , ft = +(_ * ot - b * at + k * st)
  22575. , ht = -(d * ot - b * ut + k * ct)
  22576. , pt = +(d * at - _ * ut + k * lt)
  22577. , dt = -(d * st - _ * ct + b * lt);
  22578. return i * ft + o * ht + s * pt + c * dt
  22579. }
  22580. ,
  22581. a.prototype.toArray = function() {
  22582. return this._m
  22583. }
  22584. ,
  22585. a.prototype.asArray = function() {
  22586. return this._m
  22587. }
  22588. ,
  22589. a.prototype.invert = function() {
  22590. return this.invertToRef(this),
  22591. this
  22592. }
  22593. ,
  22594. a.prototype.reset = function() {
  22595. return a.FromValuesToRef(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, this),
  22596. this._updateIdentityStatus(!1),
  22597. this
  22598. }
  22599. ,
  22600. a.prototype.add = function(e) {
  22601. var i = new a;
  22602. return this.addToRef(e, i),
  22603. i
  22604. }
  22605. ,
  22606. a.prototype.addToRef = function(e, i) {
  22607. for (var o = this._m, s = i._m, c = e.m, d = 0; d < 16; d++)
  22608. s[d] = o[d] + c[d];
  22609. return i._markAsUpdated(),
  22610. this
  22611. }
  22612. ,
  22613. a.prototype.addToSelf = function(e) {
  22614. for (var i = this._m, o = e.m, s = 0; s < 16; s++)
  22615. i[s] += o[s];
  22616. return this._markAsUpdated(),
  22617. this
  22618. }
  22619. ,
  22620. a.prototype.invertToRef = function(e) {
  22621. if (this._isIdentity === !0)
  22622. return a.IdentityToRef(e),
  22623. this;
  22624. var i = this._m
  22625. , o = i[0]
  22626. , s = i[1]
  22627. , c = i[2]
  22628. , d = i[3]
  22629. , _ = i[4]
  22630. , b = i[5]
  22631. , k = i[6]
  22632. , j = i[7]
  22633. , $ = i[8]
  22634. , _e = i[9]
  22635. , et = i[10]
  22636. , tt = i[11]
  22637. , rt = i[12]
  22638. , it = i[13]
  22639. , nt = i[14]
  22640. , ot = i[15]
  22641. , at = et * ot - nt * tt
  22642. , st = _e * ot - it * tt
  22643. , ut = _e * nt - it * et
  22644. , ct = $ * ot - rt * tt
  22645. , lt = $ * nt - et * rt
  22646. , ft = $ * it - rt * _e
  22647. , ht = +(b * at - k * st + j * ut)
  22648. , pt = -(_ * at - k * ct + j * lt)
  22649. , dt = +(_ * st - b * ct + j * ft)
  22650. , _t = -(_ * ut - b * lt + k * ft)
  22651. , mt = o * ht + s * pt + c * dt + d * _t;
  22652. if (mt === 0)
  22653. return e.copyFrom(this),
  22654. this;
  22655. var vt = 1 / mt
  22656. , yt = k * ot - nt * j
  22657. , Et = b * ot - it * j
  22658. , At = b * nt - it * k
  22659. , gt = _ * ot - rt * j
  22660. , St = _ * nt - rt * k
  22661. , xt = _ * it - rt * b
  22662. , bt = k * tt - et * j
  22663. , Rt = b * tt - _e * j
  22664. , Mt = b * et - _e * k
  22665. , Pt = _ * tt - $ * j
  22666. , It = _ * et - $ * k
  22667. , Dt = _ * _e - $ * b
  22668. , Ct = -(s * at - c * st + d * ut)
  22669. , Ot = +(o * at - c * ct + d * lt)
  22670. , wt = -(o * st - s * ct + d * ft)
  22671. , Nt = +(o * ut - s * lt + c * ft)
  22672. , Ft = +(s * yt - c * Et + d * At)
  22673. , Vt = -(o * yt - c * gt + d * St)
  22674. , Lt = +(o * Et - s * gt + d * xt)
  22675. , kt = -(o * At - s * St + c * xt)
  22676. , Bt = -(s * bt - c * Rt + d * Mt)
  22677. , Ut = +(o * bt - c * Pt + d * It)
  22678. , Gt = -(o * Rt - s * Pt + d * Dt)
  22679. , Ht = +(o * Mt - s * It + c * Dt);
  22680. return a.FromValuesToRef(ht * vt, Ct * vt, Ft * vt, Bt * vt, pt * vt, Ot * vt, Vt * vt, Ut * vt, dt * vt, wt * vt, Lt * vt, Gt * vt, _t * vt, Nt * vt, kt * vt, Ht * vt, e),
  22681. this
  22682. }
  22683. ,
  22684. a.prototype.addAtIndex = function(e, i) {
  22685. return this._m[e] += i,
  22686. this._markAsUpdated(),
  22687. this
  22688. }
  22689. ,
  22690. a.prototype.multiplyAtIndex = function(e, i) {
  22691. return this._m[e] *= i,
  22692. this._markAsUpdated(),
  22693. this
  22694. }
  22695. ,
  22696. a.prototype.setTranslationFromFloats = function(e, i, o) {
  22697. return this._m[12] = e,
  22698. this._m[13] = i,
  22699. this._m[14] = o,
  22700. this._markAsUpdated(),
  22701. this
  22702. }
  22703. ,
  22704. a.prototype.addTranslationFromFloats = function(e, i, o) {
  22705. return this._m[12] += e,
  22706. this._m[13] += i,
  22707. this._m[14] += o,
  22708. this._markAsUpdated(),
  22709. this
  22710. }
  22711. ,
  22712. a.prototype.setTranslation = function(e) {
  22713. return this.setTranslationFromFloats(e._x, e._y, e._z)
  22714. }
  22715. ,
  22716. a.prototype.getTranslation = function() {
  22717. return new Vector3(this._m[12],this._m[13],this._m[14])
  22718. }
  22719. ,
  22720. a.prototype.getTranslationToRef = function(e) {
  22721. return e.x = this._m[12],
  22722. e.y = this._m[13],
  22723. e.z = this._m[14],
  22724. this
  22725. }
  22726. ,
  22727. a.prototype.removeRotationAndScaling = function() {
  22728. var e = this.m;
  22729. return a.FromValuesToRef(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, e[12], e[13], e[14], e[15], this),
  22730. this._updateIdentityStatus(e[12] === 0 && e[13] === 0 && e[14] === 0 && e[15] === 1),
  22731. this
  22732. }
  22733. ,
  22734. a.prototype.multiply = function(e) {
  22735. var i = new a;
  22736. return this.multiplyToRef(e, i),
  22737. i
  22738. }
  22739. ,
  22740. a.prototype.copyFrom = function(e) {
  22741. e.copyToArray(this._m);
  22742. var i = e;
  22743. return this.updateFlag = i.updateFlag,
  22744. this._updateIdentityStatus(i._isIdentity, i._isIdentityDirty, i._isIdentity3x2, i._isIdentity3x2Dirty),
  22745. this
  22746. }
  22747. ,
  22748. a.prototype.copyToArray = function(e, i) {
  22749. i === void 0 && (i = 0);
  22750. var o = this._m;
  22751. return e[i] = o[0],
  22752. e[i + 1] = o[1],
  22753. e[i + 2] = o[2],
  22754. e[i + 3] = o[3],
  22755. e[i + 4] = o[4],
  22756. e[i + 5] = o[5],
  22757. e[i + 6] = o[6],
  22758. e[i + 7] = o[7],
  22759. e[i + 8] = o[8],
  22760. e[i + 9] = o[9],
  22761. e[i + 10] = o[10],
  22762. e[i + 11] = o[11],
  22763. e[i + 12] = o[12],
  22764. e[i + 13] = o[13],
  22765. e[i + 14] = o[14],
  22766. e[i + 15] = o[15],
  22767. this
  22768. }
  22769. ,
  22770. a.prototype.multiplyToRef = function(e, i) {
  22771. return this._isIdentity ? (i.copyFrom(e),
  22772. this) : e._isIdentity ? (i.copyFrom(this),
  22773. this) : (this.multiplyToArray(e, i._m, 0),
  22774. i._markAsUpdated(),
  22775. this)
  22776. }
  22777. ,
  22778. a.prototype.multiplyToArray = function(e, i, o) {
  22779. var s = this._m
  22780. , c = e.m
  22781. , d = s[0]
  22782. , _ = s[1]
  22783. , b = s[2]
  22784. , k = s[3]
  22785. , j = s[4]
  22786. , $ = s[5]
  22787. , _e = s[6]
  22788. , et = s[7]
  22789. , tt = s[8]
  22790. , rt = s[9]
  22791. , it = s[10]
  22792. , nt = s[11]
  22793. , ot = s[12]
  22794. , at = s[13]
  22795. , st = s[14]
  22796. , ut = s[15]
  22797. , ct = c[0]
  22798. , lt = c[1]
  22799. , ft = c[2]
  22800. , ht = c[3]
  22801. , pt = c[4]
  22802. , dt = c[5]
  22803. , _t = c[6]
  22804. , mt = c[7]
  22805. , vt = c[8]
  22806. , yt = c[9]
  22807. , Et = c[10]
  22808. , At = c[11]
  22809. , gt = c[12]
  22810. , St = c[13]
  22811. , xt = c[14]
  22812. , bt = c[15];
  22813. return i[o] = d * ct + _ * pt + b * vt + k * gt,
  22814. i[o + 1] = d * lt + _ * dt + b * yt + k * St,
  22815. i[o + 2] = d * ft + _ * _t + b * Et + k * xt,
  22816. i[o + 3] = d * ht + _ * mt + b * At + k * bt,
  22817. i[o + 4] = j * ct + $ * pt + _e * vt + et * gt,
  22818. i[o + 5] = j * lt + $ * dt + _e * yt + et * St,
  22819. i[o + 6] = j * ft + $ * _t + _e * Et + et * xt,
  22820. i[o + 7] = j * ht + $ * mt + _e * At + et * bt,
  22821. i[o + 8] = tt * ct + rt * pt + it * vt + nt * gt,
  22822. i[o + 9] = tt * lt + rt * dt + it * yt + nt * St,
  22823. i[o + 10] = tt * ft + rt * _t + it * Et + nt * xt,
  22824. i[o + 11] = tt * ht + rt * mt + it * At + nt * bt,
  22825. i[o + 12] = ot * ct + at * pt + st * vt + ut * gt,
  22826. i[o + 13] = ot * lt + at * dt + st * yt + ut * St,
  22827. i[o + 14] = ot * ft + at * _t + st * Et + ut * xt,
  22828. i[o + 15] = ot * ht + at * mt + st * At + ut * bt,
  22829. this
  22830. }
  22831. ,
  22832. a.prototype.equals = function(e) {
  22833. var i = e;
  22834. if (!i)
  22835. return !1;
  22836. if ((this._isIdentity || i._isIdentity) && !this._isIdentityDirty && !i._isIdentityDirty)
  22837. return this._isIdentity && i._isIdentity;
  22838. var o = this.m
  22839. , s = i.m;
  22840. return o[0] === s[0] && o[1] === s[1] && o[2] === s[2] && o[3] === s[3] && o[4] === s[4] && o[5] === s[5] && o[6] === s[6] && o[7] === s[7] && o[8] === s[8] && o[9] === s[9] && o[10] === s[10] && o[11] === s[11] && o[12] === s[12] && o[13] === s[13] && o[14] === s[14] && o[15] === s[15]
  22841. }
  22842. ,
  22843. a.prototype.clone = function() {
  22844. var e = new a;
  22845. return e.copyFrom(this),
  22846. e
  22847. }
  22848. ,
  22849. a.prototype.getClassName = function() {
  22850. return "Matrix"
  22851. }
  22852. ,
  22853. a.prototype.getHashCode = function() {
  22854. for (var e = this._m[0] | 0, i = 1; i < 16; i++)
  22855. e = e * 397 ^ (this._m[i] | 0);
  22856. return e
  22857. }
  22858. ,
  22859. a.prototype.decomposeToTransformNode = function(e) {
  22860. return e.rotationQuaternion = e.rotationQuaternion || new Quaternion,
  22861. this.decompose(e.scaling, e.rotationQuaternion, e.position)
  22862. }
  22863. ,
  22864. a.prototype.decompose = function(e, i, o, s) {
  22865. if (this._isIdentity)
  22866. return o && o.setAll(0),
  22867. e && e.setAll(1),
  22868. i && i.copyFromFloats(0, 0, 0, 1),
  22869. !0;
  22870. var c = this._m;
  22871. if (o && o.copyFromFloats(c[12], c[13], c[14]),
  22872. e = e || MathTmp.Vector3[0],
  22873. e.x = Math.sqrt(c[0] * c[0] + c[1] * c[1] + c[2] * c[2]),
  22874. e.y = Math.sqrt(c[4] * c[4] + c[5] * c[5] + c[6] * c[6]),
  22875. e.z = Math.sqrt(c[8] * c[8] + c[9] * c[9] + c[10] * c[10]),
  22876. s) {
  22877. var d = s.scaling.x < 0 ? -1 : 1
  22878. , _ = s.scaling.y < 0 ? -1 : 1
  22879. , b = s.scaling.z < 0 ? -1 : 1;
  22880. e.x *= d,
  22881. e.y *= _,
  22882. e.z *= b
  22883. } else
  22884. this.determinant() <= 0 && (e.y *= -1);
  22885. if (e._x === 0 || e._y === 0 || e._z === 0)
  22886. return i && i.copyFromFloats(0, 0, 0, 1),
  22887. !1;
  22888. if (i) {
  22889. var k = 1 / e._x
  22890. , j = 1 / e._y
  22891. , $ = 1 / e._z;
  22892. a.FromValuesToRef(c[0] * k, c[1] * k, c[2] * k, 0, c[4] * j, c[5] * j, c[6] * j, 0, c[8] * $, c[9] * $, c[10] * $, 0, 0, 0, 0, 1, MathTmp.Matrix[0]),
  22893. Quaternion.FromRotationMatrixToRef(MathTmp.Matrix[0], i)
  22894. }
  22895. return !0
  22896. }
  22897. ,
  22898. a.prototype.getRow = function(e) {
  22899. if (e < 0 || e > 3)
  22900. return null;
  22901. var i = e * 4;
  22902. return new Vector4(this._m[i + 0],this._m[i + 1],this._m[i + 2],this._m[i + 3])
  22903. }
  22904. ,
  22905. a.prototype.setRow = function(e, i) {
  22906. return this.setRowFromFloats(e, i.x, i.y, i.z, i.w)
  22907. }
  22908. ,
  22909. a.prototype.transpose = function() {
  22910. return a.Transpose(this)
  22911. }
  22912. ,
  22913. a.prototype.transposeToRef = function(e) {
  22914. return a.TransposeToRef(this, e),
  22915. this
  22916. }
  22917. ,
  22918. a.prototype.setRowFromFloats = function(e, i, o, s, c) {
  22919. if (e < 0 || e > 3)
  22920. return this;
  22921. var d = e * 4;
  22922. return this._m[d + 0] = i,
  22923. this._m[d + 1] = o,
  22924. this._m[d + 2] = s,
  22925. this._m[d + 3] = c,
  22926. this._markAsUpdated(),
  22927. this
  22928. }
  22929. ,
  22930. a.prototype.scale = function(e) {
  22931. var i = new a;
  22932. return this.scaleToRef(e, i),
  22933. i
  22934. }
  22935. ,
  22936. a.prototype.scaleToRef = function(e, i) {
  22937. for (var o = 0; o < 16; o++)
  22938. i._m[o] = this._m[o] * e;
  22939. return i._markAsUpdated(),
  22940. this
  22941. }
  22942. ,
  22943. a.prototype.scaleAndAddToRef = function(e, i) {
  22944. for (var o = 0; o < 16; o++)
  22945. i._m[o] += this._m[o] * e;
  22946. return i._markAsUpdated(),
  22947. this
  22948. }
  22949. ,
  22950. a.prototype.toNormalMatrix = function(e) {
  22951. var i = MathTmp.Matrix[0];
  22952. this.invertToRef(i),
  22953. i.transposeToRef(e);
  22954. var o = e._m;
  22955. a.FromValuesToRef(o[0], o[1], o[2], 0, o[4], o[5], o[6], 0, o[8], o[9], o[10], 0, 0, 0, 0, 1, e)
  22956. }
  22957. ,
  22958. a.prototype.getRotationMatrix = function() {
  22959. var e = new a;
  22960. return this.getRotationMatrixToRef(e),
  22961. e
  22962. }
  22963. ,
  22964. a.prototype.getRotationMatrixToRef = function(e) {
  22965. var i = MathTmp.Vector3[0];
  22966. if (!this.decompose(i))
  22967. return a.IdentityToRef(e),
  22968. this;
  22969. var o = this._m
  22970. , s = 1 / i._x
  22971. , c = 1 / i._y
  22972. , d = 1 / i._z;
  22973. return a.FromValuesToRef(o[0] * s, o[1] * s, o[2] * s, 0, o[4] * c, o[5] * c, o[6] * c, 0, o[8] * d, o[9] * d, o[10] * d, 0, 0, 0, 0, 1, e),
  22974. this
  22975. }
  22976. ,
  22977. a.prototype.toggleModelMatrixHandInPlace = function() {
  22978. var e = this._m;
  22979. e[2] *= -1,
  22980. e[6] *= -1,
  22981. e[8] *= -1,
  22982. e[9] *= -1,
  22983. e[14] *= -1,
  22984. this._markAsUpdated()
  22985. }
  22986. ,
  22987. a.prototype.toggleProjectionMatrixHandInPlace = function() {
  22988. var e = this._m;
  22989. e[8] *= -1,
  22990. e[9] *= -1,
  22991. e[10] *= -1,
  22992. e[11] *= -1,
  22993. this._markAsUpdated()
  22994. }
  22995. ,
  22996. a.FromArray = function(e, i) {
  22997. i === void 0 && (i = 0);
  22998. var o = new a;
  22999. return a.FromArrayToRef(e, i, o),
  23000. o
  23001. }
  23002. ,
  23003. a.FromArrayToRef = function(e, i, o) {
  23004. for (var s = 0; s < 16; s++)
  23005. o._m[s] = e[s + i];
  23006. o._markAsUpdated()
  23007. }
  23008. ,
  23009. a.FromFloat32ArrayToRefScaled = function(e, i, o, s) {
  23010. for (var c = 0; c < 16; c++)
  23011. s._m[c] = e[c + i] * o;
  23012. s._markAsUpdated()
  23013. }
  23014. ,
  23015. Object.defineProperty(a, "IdentityReadOnly", {
  23016. get: function() {
  23017. return a._identityReadOnly
  23018. },
  23019. enumerable: !1,
  23020. configurable: !0
  23021. }),
  23022. a.FromValuesToRef = function(e, i, o, s, c, d, _, b, k, j, $, _e, et, tt, rt, it, nt) {
  23023. var ot = nt._m;
  23024. ot[0] = e,
  23025. ot[1] = i,
  23026. ot[2] = o,
  23027. ot[3] = s,
  23028. ot[4] = c,
  23029. ot[5] = d,
  23030. ot[6] = _,
  23031. ot[7] = b,
  23032. ot[8] = k,
  23033. ot[9] = j,
  23034. ot[10] = $,
  23035. ot[11] = _e,
  23036. ot[12] = et,
  23037. ot[13] = tt,
  23038. ot[14] = rt,
  23039. ot[15] = it,
  23040. nt._markAsUpdated()
  23041. }
  23042. ,
  23043. a.FromValues = function(e, i, o, s, c, d, _, b, k, j, $, _e, et, tt, rt, it) {
  23044. var nt = new a
  23045. , ot = nt._m;
  23046. return ot[0] = e,
  23047. ot[1] = i,
  23048. ot[2] = o,
  23049. ot[3] = s,
  23050. ot[4] = c,
  23051. ot[5] = d,
  23052. ot[6] = _,
  23053. ot[7] = b,
  23054. ot[8] = k,
  23055. ot[9] = j,
  23056. ot[10] = $,
  23057. ot[11] = _e,
  23058. ot[12] = et,
  23059. ot[13] = tt,
  23060. ot[14] = rt,
  23061. ot[15] = it,
  23062. nt._markAsUpdated(),
  23063. nt
  23064. }
  23065. ,
  23066. a.Compose = function(e, i, o) {
  23067. var s = new a;
  23068. return a.ComposeToRef(e, i, o, s),
  23069. s
  23070. }
  23071. ,
  23072. a.ComposeToRef = function(e, i, o, s) {
  23073. var c = s._m
  23074. , d = i._x
  23075. , _ = i._y
  23076. , b = i._z
  23077. , k = i._w
  23078. , j = d + d
  23079. , $ = _ + _
  23080. , _e = b + b
  23081. , et = d * j
  23082. , tt = d * $
  23083. , rt = d * _e
  23084. , it = _ * $
  23085. , nt = _ * _e
  23086. , ot = b * _e
  23087. , at = k * j
  23088. , st = k * $
  23089. , ut = k * _e
  23090. , ct = e._x
  23091. , lt = e._y
  23092. , ft = e._z;
  23093. c[0] = (1 - (it + ot)) * ct,
  23094. c[1] = (tt + ut) * ct,
  23095. c[2] = (rt - st) * ct,
  23096. c[3] = 0,
  23097. c[4] = (tt - ut) * lt,
  23098. c[5] = (1 - (et + ot)) * lt,
  23099. c[6] = (nt + at) * lt,
  23100. c[7] = 0,
  23101. c[8] = (rt + st) * ft,
  23102. c[9] = (nt - at) * ft,
  23103. c[10] = (1 - (et + it)) * ft,
  23104. c[11] = 0,
  23105. c[12] = o._x,
  23106. c[13] = o._y,
  23107. c[14] = o._z,
  23108. c[15] = 1,
  23109. s._markAsUpdated()
  23110. }
  23111. ,
  23112. a.Identity = function() {
  23113. var e = a.FromValues(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
  23114. return e._updateIdentityStatus(!0),
  23115. e
  23116. }
  23117. ,
  23118. a.IdentityToRef = function(e) {
  23119. a.FromValuesToRef(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, e),
  23120. e._updateIdentityStatus(!0)
  23121. }
  23122. ,
  23123. a.Zero = function() {
  23124. var e = a.FromValues(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
  23125. return e._updateIdentityStatus(!1),
  23126. e
  23127. }
  23128. ,
  23129. a.RotationX = function(e) {
  23130. var i = new a;
  23131. return a.RotationXToRef(e, i),
  23132. i
  23133. }
  23134. ,
  23135. a.Invert = function(e) {
  23136. var i = new a;
  23137. return e.invertToRef(i),
  23138. i
  23139. }
  23140. ,
  23141. a.RotationXToRef = function(e, i) {
  23142. var o = Math.sin(e)
  23143. , s = Math.cos(e);
  23144. a.FromValuesToRef(1, 0, 0, 0, 0, s, o, 0, 0, -o, s, 0, 0, 0, 0, 1, i),
  23145. i._updateIdentityStatus(s === 1 && o === 0)
  23146. }
  23147. ,
  23148. a.RotationY = function(e) {
  23149. var i = new a;
  23150. return a.RotationYToRef(e, i),
  23151. i
  23152. }
  23153. ,
  23154. a.RotationYToRef = function(e, i) {
  23155. var o = Math.sin(e)
  23156. , s = Math.cos(e);
  23157. a.FromValuesToRef(s, 0, -o, 0, 0, 1, 0, 0, o, 0, s, 0, 0, 0, 0, 1, i),
  23158. i._updateIdentityStatus(s === 1 && o === 0)
  23159. }
  23160. ,
  23161. a.RotationZ = function(e) {
  23162. var i = new a;
  23163. return a.RotationZToRef(e, i),
  23164. i
  23165. }
  23166. ,
  23167. a.RotationZToRef = function(e, i) {
  23168. var o = Math.sin(e)
  23169. , s = Math.cos(e);
  23170. a.FromValuesToRef(s, o, 0, 0, -o, s, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, i),
  23171. i._updateIdentityStatus(s === 1 && o === 0)
  23172. }
  23173. ,
  23174. a.RotationAxis = function(e, i) {
  23175. var o = new a;
  23176. return a.RotationAxisToRef(e, i, o),
  23177. o
  23178. }
  23179. ,
  23180. a.RotationAxisToRef = function(e, i, o) {
  23181. var s = Math.sin(-i)
  23182. , c = Math.cos(-i)
  23183. , d = 1 - c;
  23184. e.normalize();
  23185. var _ = o._m;
  23186. _[0] = e._x * e._x * d + c,
  23187. _[1] = e._x * e._y * d - e._z * s,
  23188. _[2] = e._x * e._z * d + e._y * s,
  23189. _[3] = 0,
  23190. _[4] = e._y * e._x * d + e._z * s,
  23191. _[5] = e._y * e._y * d + c,
  23192. _[6] = e._y * e._z * d - e._x * s,
  23193. _[7] = 0,
  23194. _[8] = e._z * e._x * d - e._y * s,
  23195. _[9] = e._z * e._y * d + e._x * s,
  23196. _[10] = e._z * e._z * d + c,
  23197. _[11] = 0,
  23198. _[12] = 0,
  23199. _[13] = 0,
  23200. _[14] = 0,
  23201. _[15] = 1,
  23202. o._markAsUpdated()
  23203. }
  23204. ,
  23205. a.RotationAlignToRef = function(e, i, o) {
  23206. var s = Vector3.Dot(i, e)
  23207. , c = o._m;
  23208. if (s < -1 + Epsilon)
  23209. c[0] = -1,
  23210. c[1] = 0,
  23211. c[2] = 0,
  23212. c[3] = 0,
  23213. c[4] = 0,
  23214. c[5] = -1,
  23215. c[6] = 0,
  23216. c[7] = 0,
  23217. c[8] = 0,
  23218. c[9] = 0,
  23219. c[10] = 1,
  23220. c[11] = 0;
  23221. else {
  23222. var d = Vector3.Cross(i, e)
  23223. , _ = 1 / (1 + s);
  23224. c[0] = d._x * d._x * _ + s,
  23225. c[1] = d._y * d._x * _ - d._z,
  23226. c[2] = d._z * d._x * _ + d._y,
  23227. c[3] = 0,
  23228. c[4] = d._x * d._y * _ + d._z,
  23229. c[5] = d._y * d._y * _ + s,
  23230. c[6] = d._z * d._y * _ - d._x,
  23231. c[7] = 0,
  23232. c[8] = d._x * d._z * _ - d._y,
  23233. c[9] = d._y * d._z * _ + d._x,
  23234. c[10] = d._z * d._z * _ + s,
  23235. c[11] = 0
  23236. }
  23237. c[12] = 0,
  23238. c[13] = 0,
  23239. c[14] = 0,
  23240. c[15] = 1,
  23241. o._markAsUpdated()
  23242. }
  23243. ,
  23244. a.RotationYawPitchRoll = function(e, i, o) {
  23245. var s = new a;
  23246. return a.RotationYawPitchRollToRef(e, i, o, s),
  23247. s
  23248. }
  23249. ,
  23250. a.RotationYawPitchRollToRef = function(e, i, o, s) {
  23251. Quaternion.RotationYawPitchRollToRef(e, i, o, MathTmp.Quaternion[0]),
  23252. MathTmp.Quaternion[0].toRotationMatrix(s)
  23253. }
  23254. ,
  23255. a.Scaling = function(e, i, o) {
  23256. var s = new a;
  23257. return a.ScalingToRef(e, i, o, s),
  23258. s
  23259. }
  23260. ,
  23261. a.ScalingToRef = function(e, i, o, s) {
  23262. a.FromValuesToRef(e, 0, 0, 0, 0, i, 0, 0, 0, 0, o, 0, 0, 0, 0, 1, s),
  23263. s._updateIdentityStatus(e === 1 && i === 1 && o === 1)
  23264. }
  23265. ,
  23266. a.Translation = function(e, i, o) {
  23267. var s = new a;
  23268. return a.TranslationToRef(e, i, o, s),
  23269. s
  23270. }
  23271. ,
  23272. a.TranslationToRef = function(e, i, o, s) {
  23273. a.FromValuesToRef(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, e, i, o, 1, s),
  23274. s._updateIdentityStatus(e === 0 && i === 0 && o === 0)
  23275. }
  23276. ,
  23277. a.Lerp = function(e, i, o) {
  23278. var s = new a;
  23279. return a.LerpToRef(e, i, o, s),
  23280. s
  23281. }
  23282. ,
  23283. a.LerpToRef = function(e, i, o, s) {
  23284. for (var c = s._m, d = e.m, _ = i.m, b = 0; b < 16; b++)
  23285. c[b] = d[b] * (1 - o) + _[b] * o;
  23286. s._markAsUpdated()
  23287. }
  23288. ,
  23289. a.DecomposeLerp = function(e, i, o) {
  23290. var s = new a;
  23291. return a.DecomposeLerpToRef(e, i, o, s),
  23292. s
  23293. }
  23294. ,
  23295. a.DecomposeLerpToRef = function(e, i, o, s) {
  23296. var c = MathTmp.Vector3[0]
  23297. , d = MathTmp.Quaternion[0]
  23298. , _ = MathTmp.Vector3[1];
  23299. e.decompose(c, d, _);
  23300. var b = MathTmp.Vector3[2]
  23301. , k = MathTmp.Quaternion[1]
  23302. , j = MathTmp.Vector3[3];
  23303. i.decompose(b, k, j);
  23304. var $ = MathTmp.Vector3[4];
  23305. Vector3.LerpToRef(c, b, o, $);
  23306. var _e = MathTmp.Quaternion[2];
  23307. Quaternion.SlerpToRef(d, k, o, _e);
  23308. var et = MathTmp.Vector3[5];
  23309. Vector3.LerpToRef(_, j, o, et),
  23310. a.ComposeToRef($, _e, et, s)
  23311. }
  23312. ,
  23313. a.LookAtLH = function(e, i, o) {
  23314. var s = new a;
  23315. return a.LookAtLHToRef(e, i, o, s),
  23316. s
  23317. }
  23318. ,
  23319. a.LookAtLHToRef = function(e, i, o, s) {
  23320. var c = MathTmp.Vector3[0]
  23321. , d = MathTmp.Vector3[1]
  23322. , _ = MathTmp.Vector3[2];
  23323. i.subtractToRef(e, _),
  23324. _.normalize(),
  23325. Vector3.CrossToRef(o, _, c);
  23326. var b = c.lengthSquared();
  23327. b === 0 ? c.x = 1 : c.normalizeFromLength(Math.sqrt(b)),
  23328. Vector3.CrossToRef(_, c, d),
  23329. d.normalize();
  23330. var k = -Vector3.Dot(c, e)
  23331. , j = -Vector3.Dot(d, e)
  23332. , $ = -Vector3.Dot(_, e);
  23333. a.FromValuesToRef(c._x, d._x, _._x, 0, c._y, d._y, _._y, 0, c._z, d._z, _._z, 0, k, j, $, 1, s)
  23334. }
  23335. ,
  23336. a.LookAtRH = function(e, i, o) {
  23337. var s = new a;
  23338. return a.LookAtRHToRef(e, i, o, s),
  23339. s
  23340. }
  23341. ,
  23342. a.LookAtRHToRef = function(e, i, o, s) {
  23343. var c = MathTmp.Vector3[0]
  23344. , d = MathTmp.Vector3[1]
  23345. , _ = MathTmp.Vector3[2];
  23346. e.subtractToRef(i, _),
  23347. _.normalize(),
  23348. Vector3.CrossToRef(o, _, c);
  23349. var b = c.lengthSquared();
  23350. b === 0 ? c.x = 1 : c.normalizeFromLength(Math.sqrt(b)),
  23351. Vector3.CrossToRef(_, c, d),
  23352. d.normalize();
  23353. var k = -Vector3.Dot(c, e)
  23354. , j = -Vector3.Dot(d, e)
  23355. , $ = -Vector3.Dot(_, e);
  23356. a.FromValuesToRef(c._x, d._x, _._x, 0, c._y, d._y, _._y, 0, c._z, d._z, _._z, 0, k, j, $, 1, s)
  23357. }
  23358. ,
  23359. a.LookDirectionLH = function(e, i) {
  23360. var o = new a;
  23361. return a.LookDirectionLHToRef(e, i, o),
  23362. o
  23363. }
  23364. ,
  23365. a.LookDirectionLHToRef = function(e, i, o) {
  23366. var s = MathTmp.Vector3[0];
  23367. s.copyFrom(e),
  23368. s.scaleInPlace(-1);
  23369. var c = MathTmp.Vector3[1];
  23370. Vector3.CrossToRef(i, s, c),
  23371. a.FromValuesToRef(c._x, c._y, c._z, 0, i._x, i._y, i._z, 0, s._x, s._y, s._z, 0, 0, 0, 0, 1, o)
  23372. }
  23373. ,
  23374. a.LookDirectionRH = function(e, i) {
  23375. var o = new a;
  23376. return a.LookDirectionRHToRef(e, i, o),
  23377. o
  23378. }
  23379. ,
  23380. a.LookDirectionRHToRef = function(e, i, o) {
  23381. var s = MathTmp.Vector3[2];
  23382. Vector3.CrossToRef(i, e, s),
  23383. a.FromValuesToRef(s._x, s._y, s._z, 0, i._x, i._y, i._z, 0, e._x, e._y, e._z, 0, 0, 0, 0, 1, o)
  23384. }
  23385. ,
  23386. a.OrthoLH = function(e, i, o, s, c) {
  23387. var d = new a;
  23388. return a.OrthoLHToRef(e, i, o, s, d, c),
  23389. d
  23390. }
  23391. ,
  23392. a.OrthoLHToRef = function(e, i, o, s, c, d) {
  23393. var _ = o
  23394. , b = s
  23395. , k = 2 / e
  23396. , j = 2 / i
  23397. , $ = 2 / (b - _)
  23398. , _e = -(b + _) / (b - _);
  23399. a.FromValuesToRef(k, 0, 0, 0, 0, j, 0, 0, 0, 0, $, 0, 0, 0, _e, 1, c),
  23400. d && c.multiplyToRef(mtxConvertNDCToHalfZRange, c),
  23401. c._updateIdentityStatus(k === 1 && j === 1 && $ === 1 && _e === 0)
  23402. }
  23403. ,
  23404. a.OrthoOffCenterLH = function(e, i, o, s, c, d, _) {
  23405. var b = new a;
  23406. return a.OrthoOffCenterLHToRef(e, i, o, s, c, d, b, _),
  23407. b
  23408. }
  23409. ,
  23410. a.OrthoOffCenterLHToRef = function(e, i, o, s, c, d, _, b) {
  23411. var k = c
  23412. , j = d
  23413. , $ = 2 / (i - e)
  23414. , _e = 2 / (s - o)
  23415. , et = 2 / (j - k)
  23416. , tt = -(j + k) / (j - k)
  23417. , rt = (e + i) / (e - i)
  23418. , it = (s + o) / (o - s);
  23419. a.FromValuesToRef($, 0, 0, 0, 0, _e, 0, 0, 0, 0, et, 0, rt, it, tt, 1, _),
  23420. b && _.multiplyToRef(mtxConvertNDCToHalfZRange, _),
  23421. _._markAsUpdated()
  23422. }
  23423. ,
  23424. a.OrthoOffCenterRH = function(e, i, o, s, c, d, _) {
  23425. var b = new a;
  23426. return a.OrthoOffCenterRHToRef(e, i, o, s, c, d, b, _),
  23427. b
  23428. }
  23429. ,
  23430. a.OrthoOffCenterRHToRef = function(e, i, o, s, c, d, _, b) {
  23431. a.OrthoOffCenterLHToRef(e, i, o, s, c, d, _, b),
  23432. _._m[10] *= -1
  23433. }
  23434. ,
  23435. a.PerspectiveLH = function(e, i, o, s, c, d) {
  23436. d === void 0 && (d = 0);
  23437. var _ = new a
  23438. , b = o
  23439. , k = s
  23440. , j = 2 * b / e
  23441. , $ = 2 * b / i
  23442. , _e = (k + b) / (k - b)
  23443. , et = -2 * k * b / (k - b)
  23444. , tt = Math.tan(d);
  23445. return a.FromValuesToRef(j, 0, 0, 0, 0, $, 0, tt, 0, 0, _e, 1, 0, 0, et, 0, _),
  23446. c && _.multiplyToRef(mtxConvertNDCToHalfZRange, _),
  23447. _._updateIdentityStatus(!1),
  23448. _
  23449. }
  23450. ,
  23451. a.PerspectiveFovLH = function(e, i, o, s, c, d, _) {
  23452. d === void 0 && (d = 0),
  23453. _ === void 0 && (_ = !1);
  23454. var b = new a;
  23455. return a.PerspectiveFovLHToRef(e, i, o, s, b, !0, c, d, _),
  23456. b
  23457. }
  23458. ,
  23459. a.PerspectiveFovLHToRef = function(e, i, o, s, c, d, _, b, k) {
  23460. d === void 0 && (d = !0),
  23461. b === void 0 && (b = 0),
  23462. k === void 0 && (k = !1);
  23463. var j = o
  23464. , $ = s
  23465. , _e = 1 / Math.tan(e * .5)
  23466. , et = d ? _e / i : _e
  23467. , tt = d ? _e : _e * i
  23468. , rt = k && j === 0 ? -1 : $ !== 0 ? ($ + j) / ($ - j) : 1
  23469. , it = k && j === 0 ? 2 * $ : $ !== 0 ? -2 * $ * j / ($ - j) : -2 * j
  23470. , nt = Math.tan(b);
  23471. a.FromValuesToRef(et, 0, 0, 0, 0, tt, 0, nt, 0, 0, rt, 1, 0, 0, it, 0, c),
  23472. _ && c.multiplyToRef(mtxConvertNDCToHalfZRange, c),
  23473. c._updateIdentityStatus(!1)
  23474. }
  23475. ,
  23476. a.PerspectiveFovReverseLHToRef = function(e, i, o, s, c, d, _, b) {
  23477. d === void 0 && (d = !0),
  23478. b === void 0 && (b = 0);
  23479. var k = 1 / Math.tan(e * .5)
  23480. , j = d ? k / i : k
  23481. , $ = d ? k : k * i
  23482. , _e = Math.tan(b);
  23483. a.FromValuesToRef(j, 0, 0, 0, 0, $, 0, _e, 0, 0, -o, 1, 0, 0, 1, 0, c),
  23484. _ && c.multiplyToRef(mtxConvertNDCToHalfZRange, c),
  23485. c._updateIdentityStatus(!1)
  23486. }
  23487. ,
  23488. a.PerspectiveFovRH = function(e, i, o, s, c, d, _) {
  23489. d === void 0 && (d = 0),
  23490. _ === void 0 && (_ = !1);
  23491. var b = new a;
  23492. return a.PerspectiveFovRHToRef(e, i, o, s, b, !0, c, d, _),
  23493. b
  23494. }
  23495. ,
  23496. a.PerspectiveFovRHToRef = function(e, i, o, s, c, d, _, b, k) {
  23497. d === void 0 && (d = !0),
  23498. b === void 0 && (b = 0),
  23499. k === void 0 && (k = !1);
  23500. var j = o
  23501. , $ = s
  23502. , _e = 1 / Math.tan(e * .5)
  23503. , et = d ? _e / i : _e
  23504. , tt = d ? _e : _e * i
  23505. , rt = k && j === 0 ? 1 : $ !== 0 ? -($ + j) / ($ - j) : -1
  23506. , it = k && j === 0 ? 2 * $ : $ !== 0 ? -2 * $ * j / ($ - j) : -2 * j
  23507. , nt = Math.tan(b);
  23508. a.FromValuesToRef(et, 0, 0, 0, 0, tt, 0, nt, 0, 0, rt, -1, 0, 0, it, 0, c),
  23509. _ && c.multiplyToRef(mtxConvertNDCToHalfZRange, c),
  23510. c._updateIdentityStatus(!1)
  23511. }
  23512. ,
  23513. a.PerspectiveFovReverseRHToRef = function(e, i, o, s, c, d, _, b) {
  23514. d === void 0 && (d = !0),
  23515. b === void 0 && (b = 0);
  23516. var k = 1 / Math.tan(e * .5)
  23517. , j = d ? k / i : k
  23518. , $ = d ? k : k * i
  23519. , _e = Math.tan(b);
  23520. a.FromValuesToRef(j, 0, 0, 0, 0, $, 0, _e, 0, 0, -o, -1, 0, 0, -1, 0, c),
  23521. _ && c.multiplyToRef(mtxConvertNDCToHalfZRange, c),
  23522. c._updateIdentityStatus(!1)
  23523. }
  23524. ,
  23525. a.PerspectiveFovWebVRToRef = function(e, i, o, s, c, d, _) {
  23526. c === void 0 && (c = !1),
  23527. _ === void 0 && (_ = 0);
  23528. var b = c ? -1 : 1
  23529. , k = Math.tan(e.upDegrees * Math.PI / 180)
  23530. , j = Math.tan(e.downDegrees * Math.PI / 180)
  23531. , $ = Math.tan(e.leftDegrees * Math.PI / 180)
  23532. , _e = Math.tan(e.rightDegrees * Math.PI / 180)
  23533. , et = 2 / ($ + _e)
  23534. , tt = 2 / (k + j)
  23535. , rt = Math.tan(_)
  23536. , it = s._m;
  23537. it[0] = et,
  23538. it[1] = it[2] = it[3] = it[4] = 0,
  23539. it[5] = tt,
  23540. it[6] = 0,
  23541. it[7] = rt,
  23542. it[8] = ($ - _e) * et * .5,
  23543. it[9] = -((k - j) * tt * .5),
  23544. it[10] = -o / (i - o),
  23545. it[11] = 1 * b,
  23546. it[12] = it[13] = it[15] = 0,
  23547. it[14] = -(2 * o * i) / (o - i),
  23548. d && s.multiplyToRef(mtxConvertNDCToHalfZRange, s),
  23549. s._markAsUpdated()
  23550. }
  23551. ,
  23552. a.GetFinalMatrix = function(e, i, o, s, c, d) {
  23553. var _ = e.width
  23554. , b = e.height
  23555. , k = e.x
  23556. , j = e.y
  23557. , $ = a.FromValues(_ / 2, 0, 0, 0, 0, -b / 2, 0, 0, 0, 0, d - c, 0, k + _ / 2, b / 2 + j, c, 1)
  23558. , _e = MathTmp.Matrix[0];
  23559. return i.multiplyToRef(o, _e),
  23560. _e.multiplyToRef(s, _e),
  23561. _e.multiply($)
  23562. }
  23563. ,
  23564. a.GetAsMatrix2x2 = function(e) {
  23565. var i = e.m
  23566. , o = [i[0], i[1], i[4], i[5]];
  23567. return PerformanceConfigurator.MatrixUse64Bits ? o : new Float32Array(o)
  23568. }
  23569. ,
  23570. a.GetAsMatrix3x3 = function(e) {
  23571. var i = e.m
  23572. , o = [i[0], i[1], i[2], i[4], i[5], i[6], i[8], i[9], i[10]];
  23573. return PerformanceConfigurator.MatrixUse64Bits ? o : new Float32Array(o)
  23574. }
  23575. ,
  23576. a.Transpose = function(e) {
  23577. var i = new a;
  23578. return a.TransposeToRef(e, i),
  23579. i
  23580. }
  23581. ,
  23582. a.TransposeToRef = function(e, i) {
  23583. var o = i._m
  23584. , s = e.m;
  23585. o[0] = s[0],
  23586. o[1] = s[4],
  23587. o[2] = s[8],
  23588. o[3] = s[12],
  23589. o[4] = s[1],
  23590. o[5] = s[5],
  23591. o[6] = s[9],
  23592. o[7] = s[13],
  23593. o[8] = s[2],
  23594. o[9] = s[6],
  23595. o[10] = s[10],
  23596. o[11] = s[14],
  23597. o[12] = s[3],
  23598. o[13] = s[7],
  23599. o[14] = s[11],
  23600. o[15] = s[15],
  23601. i._markAsUpdated(),
  23602. i._updateIdentityStatus(e._isIdentity, e._isIdentityDirty)
  23603. }
  23604. ,
  23605. a.Reflection = function(e) {
  23606. var i = new a;
  23607. return a.ReflectionToRef(e, i),
  23608. i
  23609. }
  23610. ,
  23611. a.ReflectionToRef = function(e, i) {
  23612. e.normalize();
  23613. var o = e.normal.x
  23614. , s = e.normal.y
  23615. , c = e.normal.z
  23616. , d = -2 * o
  23617. , _ = -2 * s
  23618. , b = -2 * c;
  23619. a.FromValuesToRef(d * o + 1, _ * o, b * o, 0, d * s, _ * s + 1, b * s, 0, d * c, _ * c, b * c + 1, 0, d * e.d, _ * e.d, b * e.d, 1, i)
  23620. }
  23621. ,
  23622. a.FromXYZAxesToRef = function(e, i, o, s) {
  23623. a.FromValuesToRef(e._x, e._y, e._z, 0, i._x, i._y, i._z, 0, o._x, o._y, o._z, 0, 0, 0, 0, 1, s)
  23624. }
  23625. ,
  23626. a.FromQuaternionToRef = function(e, i) {
  23627. var o = e._x * e._x
  23628. , s = e._y * e._y
  23629. , c = e._z * e._z
  23630. , d = e._x * e._y
  23631. , _ = e._z * e._w
  23632. , b = e._z * e._x
  23633. , k = e._y * e._w
  23634. , j = e._y * e._z
  23635. , $ = e._x * e._w;
  23636. i._m[0] = 1 - 2 * (s + c),
  23637. i._m[1] = 2 * (d + _),
  23638. i._m[2] = 2 * (b - k),
  23639. i._m[3] = 0,
  23640. i._m[4] = 2 * (d - _),
  23641. i._m[5] = 1 - 2 * (c + o),
  23642. i._m[6] = 2 * (j + $),
  23643. i._m[7] = 0,
  23644. i._m[8] = 2 * (b + k),
  23645. i._m[9] = 2 * (j - $),
  23646. i._m[10] = 1 - 2 * (s + o),
  23647. i._m[11] = 0,
  23648. i._m[12] = 0,
  23649. i._m[13] = 0,
  23650. i._m[14] = 0,
  23651. i._m[15] = 1,
  23652. i._markAsUpdated()
  23653. }
  23654. ,
  23655. a._updateFlagSeed = 0,
  23656. a._identityReadOnly = a.Identity(),
  23657. a
  23658. }()
  23659. , MathTmp = function() {
  23660. function a() {}
  23661. return a.Vector3 = ArrayTools.BuildTuple(11, Vector3.Zero),
  23662. a.Matrix = ArrayTools.BuildTuple(2, Matrix.Identity),
  23663. a.Quaternion = ArrayTools.BuildTuple(3, Quaternion.Zero),
  23664. a
  23665. }()
  23666. , TmpVectors = function() {
  23667. function a() {}
  23668. return a.Vector2 = ArrayTools.BuildTuple(3, Vector2.Zero),
  23669. a.Vector3 = ArrayTools.BuildTuple(13, Vector3.Zero),
  23670. a.Vector4 = ArrayTools.BuildTuple(3, Vector4.Zero),
  23671. a.Quaternion = ArrayTools.BuildTuple(2, Quaternion.Zero),
  23672. a.Matrix = ArrayTools.BuildTuple(8, Matrix.Identity),
  23673. a
  23674. }();
  23675. RegisterClass("BABYLON.Vector2", Vector2);
  23676. RegisterClass("BABYLON.Vector3", Vector3);
  23677. RegisterClass("BABYLON.Vector4", Vector4);
  23678. RegisterClass("BABYLON.Matrix", Matrix);
  23679. var mtxConvertNDCToHalfZRange = Matrix.FromValues(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, .5, 0, 0, 0, .5, 1)
  23680. , Buffer = function() {
  23681. function a(e, i, o, s, c, d, _, b) {
  23682. s === void 0 && (s = 0),
  23683. c === void 0 && (c = !1),
  23684. d === void 0 && (d = !1),
  23685. _ === void 0 && (_ = !1),
  23686. this._isAlreadyOwned = !1,
  23687. e.getScene ? this._engine = e.getScene().getEngine() : this._engine = e,
  23688. this._updatable = o,
  23689. this._instanced = d,
  23690. this._divisor = b || 1,
  23691. i instanceof DataBuffer ? (this._data = null,
  23692. this._buffer = i) : (this._data = i,
  23693. this._buffer = null),
  23694. this.byteStride = _ ? s : s * Float32Array.BYTES_PER_ELEMENT,
  23695. c || this.create()
  23696. }
  23697. return a.prototype.createVertexBuffer = function(e, i, o, s, c, d, _) {
  23698. d === void 0 && (d = !1);
  23699. var b = d ? i : i * Float32Array.BYTES_PER_ELEMENT
  23700. , k = s ? d ? s : s * Float32Array.BYTES_PER_ELEMENT : this.byteStride;
  23701. return new VertexBuffer(this._engine,this,e,this._updatable,!0,k,c === void 0 ? this._instanced : c,b,o,void 0,void 0,!0,this._divisor || _)
  23702. }
  23703. ,
  23704. a.prototype.isUpdatable = function() {
  23705. return this._updatable
  23706. }
  23707. ,
  23708. a.prototype.getData = function() {
  23709. return this._data
  23710. }
  23711. ,
  23712. a.prototype.getBuffer = function() {
  23713. return this._buffer
  23714. }
  23715. ,
  23716. a.prototype.getStrideSize = function() {
  23717. return this.byteStride / Float32Array.BYTES_PER_ELEMENT
  23718. }
  23719. ,
  23720. a.prototype.create = function(e) {
  23721. e === void 0 && (e = null),
  23722. !(!e && this._buffer) && (e = e || this._data,
  23723. e && (this._buffer ? this._updatable && (this._engine.updateDynamicVertexBuffer(this._buffer, e),
  23724. this._data = e) : this._updatable ? (this._buffer = this._engine.createDynamicVertexBuffer(e),
  23725. this._data = e) : this._buffer = this._engine.createVertexBuffer(e)))
  23726. }
  23727. ,
  23728. a.prototype._rebuild = function() {
  23729. this._buffer = null,
  23730. this.create(this._data)
  23731. }
  23732. ,
  23733. a.prototype.update = function(e) {
  23734. this.create(e)
  23735. }
  23736. ,
  23737. a.prototype.updateDirectly = function(e, i, o, s) {
  23738. s === void 0 && (s = !1),
  23739. !!this._buffer && this._updatable && (this._engine.updateDynamicVertexBuffer(this._buffer, e, s ? i : i * Float32Array.BYTES_PER_ELEMENT, o ? o * this.byteStride : void 0),
  23740. this._data = null)
  23741. }
  23742. ,
  23743. a.prototype._increaseReferences = function() {
  23744. if (!!this._buffer) {
  23745. if (!this._isAlreadyOwned) {
  23746. this._isAlreadyOwned = !0;
  23747. return
  23748. }
  23749. this._buffer.references++
  23750. }
  23751. }
  23752. ,
  23753. a.prototype.dispose = function() {
  23754. !this._buffer || this._engine._releaseBuffer(this._buffer) && (this._buffer = null,
  23755. this._data = null)
  23756. }
  23757. ,
  23758. a
  23759. }()
  23760. , VertexBuffer = function() {
  23761. function a(e, i, o, s, c, d, _, b, k, j, $, _e, et, tt) {
  23762. if ($ === void 0 && ($ = !1),
  23763. _e === void 0 && (_e = !1),
  23764. et === void 0 && (et = 1),
  23765. tt === void 0 && (tt = !1),
  23766. i instanceof Buffer ? (this._buffer = i,
  23767. this._ownsBuffer = tt) : (this._buffer = new Buffer(e,i,s,d,c,_,_e),
  23768. this._ownsBuffer = !0),
  23769. this.uniqueId = a._Counter++,
  23770. this._kind = o,
  23771. j == null) {
  23772. var rt = this.getData();
  23773. this.type = a.FLOAT,
  23774. rt instanceof Int8Array ? this.type = a.BYTE : rt instanceof Uint8Array ? this.type = a.UNSIGNED_BYTE : rt instanceof Int16Array ? this.type = a.SHORT : rt instanceof Uint16Array ? this.type = a.UNSIGNED_SHORT : rt instanceof Int32Array ? this.type = a.INT : rt instanceof Uint32Array && (this.type = a.UNSIGNED_INT)
  23775. } else
  23776. this.type = j;
  23777. var it = a.GetTypeByteLength(this.type);
  23778. _e ? (this._size = k || (d ? d / it : a.DeduceStride(o)),
  23779. this.byteStride = d || this._buffer.byteStride || this._size * it,
  23780. this.byteOffset = b || 0) : (this._size = k || d || a.DeduceStride(o),
  23781. this.byteStride = d ? d * it : this._buffer.byteStride || this._size * it,
  23782. this.byteOffset = (b || 0) * it),
  23783. this.normalized = $,
  23784. this._instanced = _ !== void 0 ? _ : !1,
  23785. this._instanceDivisor = _ ? et : 0,
  23786. this._computeHashCode()
  23787. }
  23788. return Object.defineProperty(a.prototype, "instanceDivisor", {
  23789. get: function() {
  23790. return this._instanceDivisor
  23791. },
  23792. set: function(e) {
  23793. this._instanceDivisor = e,
  23794. e == 0 ? this._instanced = !1 : this._instanced = !0,
  23795. this._computeHashCode()
  23796. },
  23797. enumerable: !1,
  23798. configurable: !0
  23799. }),
  23800. a.prototype._computeHashCode = function() {
  23801. this.hashCode = (this.type - 5120 << 0) + ((this.normalized ? 1 : 0) << 3) + (this._size << 4) + ((this._instanced ? 1 : 0) << 6) + (this.byteStride << 12)
  23802. }
  23803. ,
  23804. a.prototype._rebuild = function() {
  23805. !this._buffer || this._buffer._rebuild()
  23806. }
  23807. ,
  23808. a.prototype.getKind = function() {
  23809. return this._kind
  23810. }
  23811. ,
  23812. a.prototype.isUpdatable = function() {
  23813. return this._buffer.isUpdatable()
  23814. }
  23815. ,
  23816. a.prototype.getData = function() {
  23817. return this._buffer.getData()
  23818. }
  23819. ,
  23820. a.prototype.getFloatData = function(e, i) {
  23821. var o = this.getData();
  23822. if (!o)
  23823. return null;
  23824. var s = this.getSize() * a.GetTypeByteLength(this.type)
  23825. , c = e * this.getSize();
  23826. if (this.type !== a.FLOAT || this.byteStride !== s) {
  23827. var d = new Float32Array(c);
  23828. return this.forEach(c, function($, _e) {
  23829. return d[_e] = $
  23830. }),
  23831. d
  23832. }
  23833. if (!(o instanceof Array || o instanceof Float32Array) || this.byteOffset !== 0 || o.length !== c)
  23834. if (o instanceof Array) {
  23835. var _ = this.byteOffset / 4;
  23836. return SliceTools.Slice(o, _, _ + c)
  23837. } else {
  23838. if (o instanceof ArrayBuffer)
  23839. return new Float32Array(o,this.byteOffset,c);
  23840. var _ = o.byteOffset + this.byteOffset;
  23841. if (i) {
  23842. var b = new Float32Array(c)
  23843. , k = new Float32Array(o.buffer,_,c);
  23844. return b.set(k),
  23845. b
  23846. }
  23847. var j = _ % 4;
  23848. return j && (_ = Math.max(0, _ - j)),
  23849. new Float32Array(o.buffer,_,c)
  23850. }
  23851. return i ? SliceTools.Slice(o) : o
  23852. }
  23853. ,
  23854. a.prototype.getBuffer = function() {
  23855. return this._buffer.getBuffer()
  23856. }
  23857. ,
  23858. a.prototype.getStrideSize = function() {
  23859. return this.byteStride / a.GetTypeByteLength(this.type)
  23860. }
  23861. ,
  23862. a.prototype.getOffset = function() {
  23863. return this.byteOffset / a.GetTypeByteLength(this.type)
  23864. }
  23865. ,
  23866. a.prototype.getSize = function(e) {
  23867. return e === void 0 && (e = !1),
  23868. e ? this._size * a.GetTypeByteLength(this.type) : this._size
  23869. }
  23870. ,
  23871. a.prototype.getIsInstanced = function() {
  23872. return this._instanced
  23873. }
  23874. ,
  23875. a.prototype.getInstanceDivisor = function() {
  23876. return this._instanceDivisor
  23877. }
  23878. ,
  23879. a.prototype.create = function(e) {
  23880. this._buffer.create(e)
  23881. }
  23882. ,
  23883. a.prototype.update = function(e) {
  23884. this._buffer.update(e)
  23885. }
  23886. ,
  23887. a.prototype.updateDirectly = function(e, i, o) {
  23888. o === void 0 && (o = !1),
  23889. this._buffer.updateDirectly(e, i, void 0, o)
  23890. }
  23891. ,
  23892. a.prototype.dispose = function() {
  23893. this._ownsBuffer && this._buffer.dispose()
  23894. }
  23895. ,
  23896. a.prototype.forEach = function(e, i) {
  23897. a.ForEach(this._buffer.getData(), this.byteOffset, this.byteStride, this._size, this.type, e, this.normalized, i)
  23898. }
  23899. ,
  23900. a.DeduceStride = function(e) {
  23901. switch (e) {
  23902. case a.UVKind:
  23903. case a.UV2Kind:
  23904. case a.UV3Kind:
  23905. case a.UV4Kind:
  23906. case a.UV5Kind:
  23907. case a.UV6Kind:
  23908. return 2;
  23909. case a.NormalKind:
  23910. case a.PositionKind:
  23911. return 3;
  23912. case a.ColorKind:
  23913. case a.MatricesIndicesKind:
  23914. case a.MatricesIndicesExtraKind:
  23915. case a.MatricesWeightsKind:
  23916. case a.MatricesWeightsExtraKind:
  23917. case a.TangentKind:
  23918. return 4;
  23919. default:
  23920. throw new Error("Invalid kind '" + e + "'")
  23921. }
  23922. }
  23923. ,
  23924. a.GetTypeByteLength = function(e) {
  23925. switch (e) {
  23926. case a.BYTE:
  23927. case a.UNSIGNED_BYTE:
  23928. return 1;
  23929. case a.SHORT:
  23930. case a.UNSIGNED_SHORT:
  23931. return 2;
  23932. case a.INT:
  23933. case a.UNSIGNED_INT:
  23934. case a.FLOAT:
  23935. return 4;
  23936. default:
  23937. throw new Error("Invalid type '" + e + "'")
  23938. }
  23939. }
  23940. ,
  23941. a.ForEach = function(e, i, o, s, c, d, _, b) {
  23942. if (e instanceof Array)
  23943. for (var k = i / 4, j = o / 4, $ = 0; $ < d; $ += s) {
  23944. for (var _e = 0; _e < s; _e++)
  23945. b(e[k + _e], $ + _e);
  23946. k += j
  23947. }
  23948. else
  23949. for (var et = e instanceof ArrayBuffer ? new DataView(e) : new DataView(e.buffer,e.byteOffset,e.byteLength), tt = a.GetTypeByteLength(c), $ = 0; $ < d; $ += s) {
  23950. for (var rt = i, _e = 0; _e < s; _e++) {
  23951. var it = a._GetFloatValue(et, c, rt, _);
  23952. b(it, $ + _e),
  23953. rt += tt
  23954. }
  23955. i += o
  23956. }
  23957. }
  23958. ,
  23959. a._GetFloatValue = function(e, i, o, s) {
  23960. switch (i) {
  23961. case a.BYTE:
  23962. {
  23963. var c = e.getInt8(o);
  23964. return s && (c = Math.max(c / 127, -1)),
  23965. c
  23966. }
  23967. case a.UNSIGNED_BYTE:
  23968. {
  23969. var c = e.getUint8(o);
  23970. return s && (c = c / 255),
  23971. c
  23972. }
  23973. case a.SHORT:
  23974. {
  23975. var c = e.getInt16(o, !0);
  23976. return s && (c = Math.max(c / 32767, -1)),
  23977. c
  23978. }
  23979. case a.UNSIGNED_SHORT:
  23980. {
  23981. var c = e.getUint16(o, !0);
  23982. return s && (c = c / 65535),
  23983. c
  23984. }
  23985. case a.INT:
  23986. return e.getInt32(o, !0);
  23987. case a.UNSIGNED_INT:
  23988. return e.getUint32(o, !0);
  23989. case a.FLOAT:
  23990. return e.getFloat32(o, !0);
  23991. default:
  23992. throw new Error("Invalid component type " + i)
  23993. }
  23994. }
  23995. ,
  23996. a._Counter = 0,
  23997. a.BYTE = 5120,
  23998. a.UNSIGNED_BYTE = 5121,
  23999. a.SHORT = 5122,
  24000. a.UNSIGNED_SHORT = 5123,
  24001. a.INT = 5124,
  24002. a.UNSIGNED_INT = 5125,
  24003. a.FLOAT = 5126,
  24004. a.PositionKind = "position",
  24005. a.NormalKind = "normal",
  24006. a.TangentKind = "tangent",
  24007. a.UVKind = "uv",
  24008. a.UV2Kind = "uv2",
  24009. a.UV3Kind = "uv3",
  24010. a.UV4Kind = "uv4",
  24011. a.UV5Kind = "uv5",
  24012. a.UV6Kind = "uv6",
  24013. a.ColorKind = "color",
  24014. a.MatricesIndicesKind = "matricesIndices",
  24015. a.MatricesWeightsKind = "matricesWeights",
  24016. a.MatricesIndicesExtraKind = "matricesIndicesExtra",
  24017. a.MatricesWeightsExtraKind = "matricesWeightsExtra",
  24018. a
  24019. }()
  24020. , Color3 = function() {
  24021. function a(e, i, o) {
  24022. e === void 0 && (e = 0),
  24023. i === void 0 && (i = 0),
  24024. o === void 0 && (o = 0),
  24025. this.r = e,
  24026. this.g = i,
  24027. this.b = o
  24028. }
  24029. return a.prototype.toString = function() {
  24030. return "{R: " + this.r + " G:" + this.g + " B:" + this.b + "}"
  24031. }
  24032. ,
  24033. a.prototype.getClassName = function() {
  24034. return "Color3"
  24035. }
  24036. ,
  24037. a.prototype.getHashCode = function() {
  24038. var e = this.r * 255 | 0;
  24039. return e = e * 397 ^ (this.g * 255 | 0),
  24040. e = e * 397 ^ (this.b * 255 | 0),
  24041. e
  24042. }
  24043. ,
  24044. a.prototype.toArray = function(e, i) {
  24045. return i === void 0 && (i = 0),
  24046. e[i] = this.r,
  24047. e[i + 1] = this.g,
  24048. e[i + 2] = this.b,
  24049. this
  24050. }
  24051. ,
  24052. a.prototype.fromArray = function(e, i) {
  24053. return i === void 0 && (i = 0),
  24054. a.FromArrayToRef(e, i, this),
  24055. this
  24056. }
  24057. ,
  24058. a.prototype.toColor4 = function(e) {
  24059. return e === void 0 && (e = 1),
  24060. new Color4(this.r,this.g,this.b,e)
  24061. }
  24062. ,
  24063. a.prototype.asArray = function() {
  24064. var e = new Array;
  24065. return this.toArray(e, 0),
  24066. e
  24067. }
  24068. ,
  24069. a.prototype.toLuminance = function() {
  24070. return this.r * .3 + this.g * .59 + this.b * .11
  24071. }
  24072. ,
  24073. a.prototype.multiply = function(e) {
  24074. return new a(this.r * e.r,this.g * e.g,this.b * e.b)
  24075. }
  24076. ,
  24077. a.prototype.multiplyToRef = function(e, i) {
  24078. return i.r = this.r * e.r,
  24079. i.g = this.g * e.g,
  24080. i.b = this.b * e.b,
  24081. this
  24082. }
  24083. ,
  24084. a.prototype.equals = function(e) {
  24085. return e && this.r === e.r && this.g === e.g && this.b === e.b
  24086. }
  24087. ,
  24088. a.prototype.equalsFloats = function(e, i, o) {
  24089. return this.r === e && this.g === i && this.b === o
  24090. }
  24091. ,
  24092. a.prototype.scale = function(e) {
  24093. return new a(this.r * e,this.g * e,this.b * e)
  24094. }
  24095. ,
  24096. a.prototype.scaleToRef = function(e, i) {
  24097. return i.r = this.r * e,
  24098. i.g = this.g * e,
  24099. i.b = this.b * e,
  24100. this
  24101. }
  24102. ,
  24103. a.prototype.scaleAndAddToRef = function(e, i) {
  24104. return i.r += this.r * e,
  24105. i.g += this.g * e,
  24106. i.b += this.b * e,
  24107. this
  24108. }
  24109. ,
  24110. a.prototype.clampToRef = function(e, i, o) {
  24111. return e === void 0 && (e = 0),
  24112. i === void 0 && (i = 1),
  24113. o.r = Scalar.Clamp(this.r, e, i),
  24114. o.g = Scalar.Clamp(this.g, e, i),
  24115. o.b = Scalar.Clamp(this.b, e, i),
  24116. this
  24117. }
  24118. ,
  24119. a.prototype.add = function(e) {
  24120. return new a(this.r + e.r,this.g + e.g,this.b + e.b)
  24121. }
  24122. ,
  24123. a.prototype.addToRef = function(e, i) {
  24124. return i.r = this.r + e.r,
  24125. i.g = this.g + e.g,
  24126. i.b = this.b + e.b,
  24127. this
  24128. }
  24129. ,
  24130. a.prototype.subtract = function(e) {
  24131. return new a(this.r - e.r,this.g - e.g,this.b - e.b)
  24132. }
  24133. ,
  24134. a.prototype.subtractToRef = function(e, i) {
  24135. return i.r = this.r - e.r,
  24136. i.g = this.g - e.g,
  24137. i.b = this.b - e.b,
  24138. this
  24139. }
  24140. ,
  24141. a.prototype.clone = function() {
  24142. return new a(this.r,this.g,this.b)
  24143. }
  24144. ,
  24145. a.prototype.copyFrom = function(e) {
  24146. return this.r = e.r,
  24147. this.g = e.g,
  24148. this.b = e.b,
  24149. this
  24150. }
  24151. ,
  24152. a.prototype.copyFromFloats = function(e, i, o) {
  24153. return this.r = e,
  24154. this.g = i,
  24155. this.b = o,
  24156. this
  24157. }
  24158. ,
  24159. a.prototype.set = function(e, i, o) {
  24160. return this.copyFromFloats(e, i, o)
  24161. }
  24162. ,
  24163. a.prototype.toHexString = function() {
  24164. var e = Math.round(this.r * 255)
  24165. , i = Math.round(this.g * 255)
  24166. , o = Math.round(this.b * 255);
  24167. return "#" + Scalar.ToHex(e) + Scalar.ToHex(i) + Scalar.ToHex(o)
  24168. }
  24169. ,
  24170. a.prototype.toLinearSpace = function() {
  24171. var e = new a;
  24172. return this.toLinearSpaceToRef(e),
  24173. e
  24174. }
  24175. ,
  24176. a.prototype.toHSV = function() {
  24177. var e = new a;
  24178. return this.toHSVToRef(e),
  24179. e
  24180. }
  24181. ,
  24182. a.prototype.toHSVToRef = function(e) {
  24183. var i = this.r
  24184. , o = this.g
  24185. , s = this.b
  24186. , c = Math.max(i, o, s)
  24187. , d = Math.min(i, o, s)
  24188. , _ = 0
  24189. , b = 0
  24190. , k = c
  24191. , j = c - d;
  24192. c !== 0 && (b = j / c),
  24193. c != d && (c == i ? (_ = (o - s) / j,
  24194. o < s && (_ += 6)) : c == o ? _ = (s - i) / j + 2 : c == s && (_ = (i - o) / j + 4),
  24195. _ *= 60),
  24196. e.r = _,
  24197. e.g = b,
  24198. e.b = k
  24199. }
  24200. ,
  24201. a.prototype.toLinearSpaceToRef = function(e) {
  24202. return e.r = Math.pow(this.r, ToLinearSpace),
  24203. e.g = Math.pow(this.g, ToLinearSpace),
  24204. e.b = Math.pow(this.b, ToLinearSpace),
  24205. this
  24206. }
  24207. ,
  24208. a.prototype.toGammaSpace = function() {
  24209. var e = new a;
  24210. return this.toGammaSpaceToRef(e),
  24211. e
  24212. }
  24213. ,
  24214. a.prototype.toGammaSpaceToRef = function(e) {
  24215. return e.r = Math.pow(this.r, ToGammaSpace),
  24216. e.g = Math.pow(this.g, ToGammaSpace),
  24217. e.b = Math.pow(this.b, ToGammaSpace),
  24218. this
  24219. }
  24220. ,
  24221. a.HSVtoRGBToRef = function(e, i, o, s) {
  24222. var c = o * i
  24223. , d = e / 60
  24224. , _ = c * (1 - Math.abs(d % 2 - 1))
  24225. , b = 0
  24226. , k = 0
  24227. , j = 0;
  24228. d >= 0 && d <= 1 ? (b = c,
  24229. k = _) : d >= 1 && d <= 2 ? (b = _,
  24230. k = c) : d >= 2 && d <= 3 ? (k = c,
  24231. j = _) : d >= 3 && d <= 4 ? (k = _,
  24232. j = c) : d >= 4 && d <= 5 ? (b = _,
  24233. j = c) : d >= 5 && d <= 6 && (b = c,
  24234. j = _);
  24235. var $ = o - c;
  24236. s.set(b + $, k + $, j + $)
  24237. }
  24238. ,
  24239. a.FromHexString = function(e) {
  24240. if (e.substring(0, 1) !== "#" || e.length !== 7)
  24241. return new a(0,0,0);
  24242. var i = parseInt(e.substring(1, 3), 16)
  24243. , o = parseInt(e.substring(3, 5), 16)
  24244. , s = parseInt(e.substring(5, 7), 16);
  24245. return a.FromInts(i, o, s)
  24246. }
  24247. ,
  24248. a.FromArray = function(e, i) {
  24249. return i === void 0 && (i = 0),
  24250. new a(e[i],e[i + 1],e[i + 2])
  24251. }
  24252. ,
  24253. a.FromArrayToRef = function(e, i, o) {
  24254. i === void 0 && (i = 0),
  24255. o.r = e[i],
  24256. o.g = e[i + 1],
  24257. o.b = e[i + 2]
  24258. }
  24259. ,
  24260. a.FromInts = function(e, i, o) {
  24261. return new a(e / 255,i / 255,o / 255)
  24262. }
  24263. ,
  24264. a.Lerp = function(e, i, o) {
  24265. var s = new a(0,0,0);
  24266. return a.LerpToRef(e, i, o, s),
  24267. s
  24268. }
  24269. ,
  24270. a.LerpToRef = function(e, i, o, s) {
  24271. s.r = e.r + (i.r - e.r) * o,
  24272. s.g = e.g + (i.g - e.g) * o,
  24273. s.b = e.b + (i.b - e.b) * o
  24274. }
  24275. ,
  24276. a.Hermite = function(e, i, o, s, c) {
  24277. var d = c * c
  24278. , _ = c * d
  24279. , b = 2 * _ - 3 * d + 1
  24280. , k = -2 * _ + 3 * d
  24281. , j = _ - 2 * d + c
  24282. , $ = _ - d
  24283. , _e = e.r * b + o.r * k + i.r * j + s.r * $
  24284. , et = e.g * b + o.g * k + i.g * j + s.g * $
  24285. , tt = e.b * b + o.b * k + i.b * j + s.b * $;
  24286. return new a(_e,et,tt)
  24287. }
  24288. ,
  24289. a.Hermite1stDerivative = function(e, i, o, s, c) {
  24290. var d = a.Black();
  24291. return this.Hermite1stDerivativeToRef(e, i, o, s, c, d),
  24292. d
  24293. }
  24294. ,
  24295. a.Hermite1stDerivativeToRef = function(e, i, o, s, c, d) {
  24296. var _ = c * c;
  24297. d.r = (_ - c) * 6 * e.r + (3 * _ - 4 * c + 1) * i.r + (-_ + c) * 6 * o.r + (3 * _ - 2 * c) * s.r,
  24298. d.g = (_ - c) * 6 * e.g + (3 * _ - 4 * c + 1) * i.g + (-_ + c) * 6 * o.g + (3 * _ - 2 * c) * s.g,
  24299. d.b = (_ - c) * 6 * e.b + (3 * _ - 4 * c + 1) * i.b + (-_ + c) * 6 * o.b + (3 * _ - 2 * c) * s.b
  24300. }
  24301. ,
  24302. a.Red = function() {
  24303. return new a(1,0,0)
  24304. }
  24305. ,
  24306. a.Green = function() {
  24307. return new a(0,1,0)
  24308. }
  24309. ,
  24310. a.Blue = function() {
  24311. return new a(0,0,1)
  24312. }
  24313. ,
  24314. a.Black = function() {
  24315. return new a(0,0,0)
  24316. }
  24317. ,
  24318. Object.defineProperty(a, "BlackReadOnly", {
  24319. get: function() {
  24320. return a._BlackReadOnly
  24321. },
  24322. enumerable: !1,
  24323. configurable: !0
  24324. }),
  24325. a.White = function() {
  24326. return new a(1,1,1)
  24327. }
  24328. ,
  24329. a.Purple = function() {
  24330. return new a(.5,0,.5)
  24331. }
  24332. ,
  24333. a.Magenta = function() {
  24334. return new a(1,0,1)
  24335. }
  24336. ,
  24337. a.Yellow = function() {
  24338. return new a(1,1,0)
  24339. }
  24340. ,
  24341. a.Gray = function() {
  24342. return new a(.5,.5,.5)
  24343. }
  24344. ,
  24345. a.Teal = function() {
  24346. return new a(0,1,1)
  24347. }
  24348. ,
  24349. a.Random = function() {
  24350. return new a(Math.random(),Math.random(),Math.random())
  24351. }
  24352. ,
  24353. a._BlackReadOnly = a.Black(),
  24354. a
  24355. }()
  24356. , Color4 = function() {
  24357. function a(e, i, o, s) {
  24358. e === void 0 && (e = 0),
  24359. i === void 0 && (i = 0),
  24360. o === void 0 && (o = 0),
  24361. s === void 0 && (s = 1),
  24362. this.r = e,
  24363. this.g = i,
  24364. this.b = o,
  24365. this.a = s
  24366. }
  24367. return a.prototype.addInPlace = function(e) {
  24368. return this.r += e.r,
  24369. this.g += e.g,
  24370. this.b += e.b,
  24371. this.a += e.a,
  24372. this
  24373. }
  24374. ,
  24375. a.prototype.asArray = function() {
  24376. var e = new Array;
  24377. return this.toArray(e, 0),
  24378. e
  24379. }
  24380. ,
  24381. a.prototype.toArray = function(e, i) {
  24382. return i === void 0 && (i = 0),
  24383. e[i] = this.r,
  24384. e[i + 1] = this.g,
  24385. e[i + 2] = this.b,
  24386. e[i + 3] = this.a,
  24387. this
  24388. }
  24389. ,
  24390. a.prototype.fromArray = function(e, i) {
  24391. return i === void 0 && (i = 0),
  24392. a.FromArrayToRef(e, i, this),
  24393. this
  24394. }
  24395. ,
  24396. a.prototype.equals = function(e) {
  24397. return e && this.r === e.r && this.g === e.g && this.b === e.b && this.a === e.a
  24398. }
  24399. ,
  24400. a.prototype.add = function(e) {
  24401. return new a(this.r + e.r,this.g + e.g,this.b + e.b,this.a + e.a)
  24402. }
  24403. ,
  24404. a.prototype.subtract = function(e) {
  24405. return new a(this.r - e.r,this.g - e.g,this.b - e.b,this.a - e.a)
  24406. }
  24407. ,
  24408. a.prototype.subtractToRef = function(e, i) {
  24409. return i.r = this.r - e.r,
  24410. i.g = this.g - e.g,
  24411. i.b = this.b - e.b,
  24412. i.a = this.a - e.a,
  24413. this
  24414. }
  24415. ,
  24416. a.prototype.scale = function(e) {
  24417. return new a(this.r * e,this.g * e,this.b * e,this.a * e)
  24418. }
  24419. ,
  24420. a.prototype.scaleToRef = function(e, i) {
  24421. return i.r = this.r * e,
  24422. i.g = this.g * e,
  24423. i.b = this.b * e,
  24424. i.a = this.a * e,
  24425. this
  24426. }
  24427. ,
  24428. a.prototype.scaleAndAddToRef = function(e, i) {
  24429. return i.r += this.r * e,
  24430. i.g += this.g * e,
  24431. i.b += this.b * e,
  24432. i.a += this.a * e,
  24433. this
  24434. }
  24435. ,
  24436. a.prototype.clampToRef = function(e, i, o) {
  24437. return e === void 0 && (e = 0),
  24438. i === void 0 && (i = 1),
  24439. o.r = Scalar.Clamp(this.r, e, i),
  24440. o.g = Scalar.Clamp(this.g, e, i),
  24441. o.b = Scalar.Clamp(this.b, e, i),
  24442. o.a = Scalar.Clamp(this.a, e, i),
  24443. this
  24444. }
  24445. ,
  24446. a.prototype.multiply = function(e) {
  24447. return new a(this.r * e.r,this.g * e.g,this.b * e.b,this.a * e.a)
  24448. }
  24449. ,
  24450. a.prototype.multiplyToRef = function(e, i) {
  24451. return i.r = this.r * e.r,
  24452. i.g = this.g * e.g,
  24453. i.b = this.b * e.b,
  24454. i.a = this.a * e.a,
  24455. i
  24456. }
  24457. ,
  24458. a.prototype.toString = function() {
  24459. return "{R: " + this.r + " G:" + this.g + " B:" + this.b + " A:" + this.a + "}"
  24460. }
  24461. ,
  24462. a.prototype.getClassName = function() {
  24463. return "Color4"
  24464. }
  24465. ,
  24466. a.prototype.getHashCode = function() {
  24467. var e = this.r * 255 | 0;
  24468. return e = e * 397 ^ (this.g * 255 | 0),
  24469. e = e * 397 ^ (this.b * 255 | 0),
  24470. e = e * 397 ^ (this.a * 255 | 0),
  24471. e
  24472. }
  24473. ,
  24474. a.prototype.clone = function() {
  24475. return new a(this.r,this.g,this.b,this.a)
  24476. }
  24477. ,
  24478. a.prototype.copyFrom = function(e) {
  24479. return this.r = e.r,
  24480. this.g = e.g,
  24481. this.b = e.b,
  24482. this.a = e.a,
  24483. this
  24484. }
  24485. ,
  24486. a.prototype.copyFromFloats = function(e, i, o, s) {
  24487. return this.r = e,
  24488. this.g = i,
  24489. this.b = o,
  24490. this.a = s,
  24491. this
  24492. }
  24493. ,
  24494. a.prototype.set = function(e, i, o, s) {
  24495. return this.copyFromFloats(e, i, o, s)
  24496. }
  24497. ,
  24498. a.prototype.toHexString = function(e) {
  24499. e === void 0 && (e = !1);
  24500. var i = Math.round(this.r * 255)
  24501. , o = Math.round(this.g * 255)
  24502. , s = Math.round(this.b * 255);
  24503. if (e)
  24504. return "#" + Scalar.ToHex(i) + Scalar.ToHex(o) + Scalar.ToHex(s);
  24505. var c = Math.round(this.a * 255);
  24506. return "#" + Scalar.ToHex(i) + Scalar.ToHex(o) + Scalar.ToHex(s) + Scalar.ToHex(c)
  24507. }
  24508. ,
  24509. a.prototype.toLinearSpace = function() {
  24510. var e = new a;
  24511. return this.toLinearSpaceToRef(e),
  24512. e
  24513. }
  24514. ,
  24515. a.prototype.toLinearSpaceToRef = function(e) {
  24516. return e.r = Math.pow(this.r, ToLinearSpace),
  24517. e.g = Math.pow(this.g, ToLinearSpace),
  24518. e.b = Math.pow(this.b, ToLinearSpace),
  24519. e.a = this.a,
  24520. this
  24521. }
  24522. ,
  24523. a.prototype.toGammaSpace = function() {
  24524. var e = new a;
  24525. return this.toGammaSpaceToRef(e),
  24526. e
  24527. }
  24528. ,
  24529. a.prototype.toGammaSpaceToRef = function(e) {
  24530. return e.r = Math.pow(this.r, ToGammaSpace),
  24531. e.g = Math.pow(this.g, ToGammaSpace),
  24532. e.b = Math.pow(this.b, ToGammaSpace),
  24533. e.a = this.a,
  24534. this
  24535. }
  24536. ,
  24537. a.FromHexString = function(e) {
  24538. if (e.substring(0, 1) !== "#" || e.length !== 9 && e.length !== 7)
  24539. return new a(0,0,0,0);
  24540. var i = parseInt(e.substring(1, 3), 16)
  24541. , o = parseInt(e.substring(3, 5), 16)
  24542. , s = parseInt(e.substring(5, 7), 16)
  24543. , c = e.length === 9 ? parseInt(e.substring(7, 9), 16) : 255;
  24544. return a.FromInts(i, o, s, c)
  24545. }
  24546. ,
  24547. a.Lerp = function(e, i, o) {
  24548. var s = new a(0,0,0,0);
  24549. return a.LerpToRef(e, i, o, s),
  24550. s
  24551. }
  24552. ,
  24553. a.LerpToRef = function(e, i, o, s) {
  24554. s.r = e.r + (i.r - e.r) * o,
  24555. s.g = e.g + (i.g - e.g) * o,
  24556. s.b = e.b + (i.b - e.b) * o,
  24557. s.a = e.a + (i.a - e.a) * o
  24558. }
  24559. ,
  24560. a.Hermite = function(e, i, o, s, c) {
  24561. var d = c * c
  24562. , _ = c * d
  24563. , b = 2 * _ - 3 * d + 1
  24564. , k = -2 * _ + 3 * d
  24565. , j = _ - 2 * d + c
  24566. , $ = _ - d
  24567. , _e = e.r * b + o.r * k + i.r * j + s.r * $
  24568. , et = e.g * b + o.g * k + i.g * j + s.g * $
  24569. , tt = e.b * b + o.b * k + i.b * j + s.b * $
  24570. , rt = e.a * b + o.a * k + i.a * j + s.a * $;
  24571. return new a(_e,et,tt,rt)
  24572. }
  24573. ,
  24574. a.Hermite1stDerivative = function(e, i, o, s, c) {
  24575. var d = new a;
  24576. return this.Hermite1stDerivativeToRef(e, i, o, s, c, d),
  24577. d
  24578. }
  24579. ,
  24580. a.Hermite1stDerivativeToRef = function(e, i, o, s, c, d) {
  24581. var _ = c * c;
  24582. d.r = (_ - c) * 6 * e.r + (3 * _ - 4 * c + 1) * i.r + (-_ + c) * 6 * o.r + (3 * _ - 2 * c) * s.r,
  24583. d.g = (_ - c) * 6 * e.g + (3 * _ - 4 * c + 1) * i.g + (-_ + c) * 6 * o.g + (3 * _ - 2 * c) * s.g,
  24584. d.b = (_ - c) * 6 * e.b + (3 * _ - 4 * c + 1) * i.b + (-_ + c) * 6 * o.b + (3 * _ - 2 * c) * s.b,
  24585. d.a = (_ - c) * 6 * e.a + (3 * _ - 4 * c + 1) * i.a + (-_ + c) * 6 * o.a + (3 * _ - 2 * c) * s.a
  24586. }
  24587. ,
  24588. a.FromColor3 = function(e, i) {
  24589. return i === void 0 && (i = 1),
  24590. new a(e.r,e.g,e.b,i)
  24591. }
  24592. ,
  24593. a.FromArray = function(e, i) {
  24594. return i === void 0 && (i = 0),
  24595. new a(e[i],e[i + 1],e[i + 2],e[i + 3])
  24596. }
  24597. ,
  24598. a.FromArrayToRef = function(e, i, o) {
  24599. i === void 0 && (i = 0),
  24600. o.r = e[i],
  24601. o.g = e[i + 1],
  24602. o.b = e[i + 2],
  24603. o.a = e[i + 3]
  24604. }
  24605. ,
  24606. a.FromInts = function(e, i, o, s) {
  24607. return new a(e / 255,i / 255,o / 255,s / 255)
  24608. }
  24609. ,
  24610. a.CheckColors4 = function(e, i) {
  24611. if (e.length === i * 3) {
  24612. for (var o = [], s = 0; s < e.length; s += 3) {
  24613. var c = s / 3 * 4;
  24614. o[c] = e[s],
  24615. o[c + 1] = e[s + 1],
  24616. o[c + 2] = e[s + 2],
  24617. o[c + 3] = 1
  24618. }
  24619. return o
  24620. }
  24621. return e
  24622. }
  24623. ,
  24624. a
  24625. }()
  24626. , TmpColors = function() {
  24627. function a() {}
  24628. return a.Color3 = ArrayTools.BuildArray(3, Color3.Black),
  24629. a.Color4 = ArrayTools.BuildArray(3, function() {
  24630. return new Color4(0,0,0,0)
  24631. }),
  24632. a
  24633. }();
  24634. RegisterClass("BABYLON.Color3", Color3);
  24635. RegisterClass("BABYLON.Color4", Color4);
  24636. var AndOrNotEvaluator = function() {
  24637. function a() {}
  24638. return a.Eval = function(e, i) {
  24639. return e.match(/\([^\(\)]*\)/g) ? e = e.replace(/\([^\(\)]*\)/g, function(o) {
  24640. return o = o.slice(1, o.length - 1),
  24641. a._HandleParenthesisContent(o, i)
  24642. }) : e = a._HandleParenthesisContent(e, i),
  24643. e === "true" ? !0 : e === "false" ? !1 : a.Eval(e, i)
  24644. }
  24645. ,
  24646. a._HandleParenthesisContent = function(e, i) {
  24647. i = i || function(j) {
  24648. return j === "true"
  24649. }
  24650. ;
  24651. var o, s = e.split("||");
  24652. for (var c in s)
  24653. if (s.hasOwnProperty(c)) {
  24654. var d = a._SimplifyNegation(s[c].trim())
  24655. , _ = d.split("&&");
  24656. if (_.length > 1)
  24657. for (var b = 0; b < _.length; ++b) {
  24658. var k = a._SimplifyNegation(_[b].trim());
  24659. if (k !== "true" && k !== "false" ? k[0] === "!" ? o = !i(k.substring(1)) : o = i(k) : o = k === "true",
  24660. !o) {
  24661. d = "false";
  24662. break
  24663. }
  24664. }
  24665. if (o || d === "true") {
  24666. o = !0;
  24667. break
  24668. }
  24669. d !== "true" && d !== "false" ? d[0] === "!" ? o = !i(d.substring(1)) : o = i(d) : o = d === "true"
  24670. }
  24671. return o ? "true" : "false"
  24672. }
  24673. ,
  24674. a._SimplifyNegation = function(e) {
  24675. return e = e.replace(/^[\s!]+/, function(i) {
  24676. return i = i.replace(/[\s]/g, function() {
  24677. return ""
  24678. }),
  24679. i.length % 2 ? "!" : ""
  24680. }),
  24681. e = e.trim(),
  24682. e === "!true" ? e = "false" : e === "!false" && (e = "true"),
  24683. e
  24684. }
  24685. ,
  24686. a
  24687. }()
  24688. , Tags = function() {
  24689. function a() {}
  24690. return a.EnableFor = function(e) {
  24691. e._tags = e._tags || {},
  24692. e.hasTags = function() {
  24693. return a.HasTags(e)
  24694. }
  24695. ,
  24696. e.addTags = function(i) {
  24697. return a.AddTagsTo(e, i)
  24698. }
  24699. ,
  24700. e.removeTags = function(i) {
  24701. return a.RemoveTagsFrom(e, i)
  24702. }
  24703. ,
  24704. e.matchesTagsQuery = function(i) {
  24705. return a.MatchesQuery(e, i)
  24706. }
  24707. }
  24708. ,
  24709. a.DisableFor = function(e) {
  24710. delete e._tags,
  24711. delete e.hasTags,
  24712. delete e.addTags,
  24713. delete e.removeTags,
  24714. delete e.matchesTagsQuery
  24715. }
  24716. ,
  24717. a.HasTags = function(e) {
  24718. if (!e._tags)
  24719. return !1;
  24720. var i = e._tags;
  24721. for (var o in i)
  24722. if (i.hasOwnProperty(o))
  24723. return !0;
  24724. return !1
  24725. }
  24726. ,
  24727. a.GetTags = function(e, i) {
  24728. if (i === void 0 && (i = !0),
  24729. !e._tags)
  24730. return null;
  24731. if (i) {
  24732. var o = [];
  24733. for (var s in e._tags)
  24734. e._tags.hasOwnProperty(s) && e._tags[s] === !0 && o.push(s);
  24735. return o.join(" ")
  24736. } else
  24737. return e._tags
  24738. }
  24739. ,
  24740. a.AddTagsTo = function(e, i) {
  24741. if (!!i && typeof i == "string") {
  24742. var o = i.split(" ");
  24743. o.forEach(function(s, c, d) {
  24744. a._AddTagTo(e, s)
  24745. })
  24746. }
  24747. }
  24748. ,
  24749. a._AddTagTo = function(e, i) {
  24750. i = i.trim(),
  24751. !(i === "" || i === "true" || i === "false") && (i.match(/[\s]/) || i.match(/^([!]|([|]|[&]){2})/) || (a.EnableFor(e),
  24752. e._tags[i] = !0))
  24753. }
  24754. ,
  24755. a.RemoveTagsFrom = function(e, i) {
  24756. if (!!a.HasTags(e)) {
  24757. var o = i.split(" ");
  24758. for (var s in o)
  24759. a._RemoveTagFrom(e, o[s])
  24760. }
  24761. }
  24762. ,
  24763. a._RemoveTagFrom = function(e, i) {
  24764. delete e._tags[i]
  24765. }
  24766. ,
  24767. a.MatchesQuery = function(e, i) {
  24768. return i === void 0 ? !0 : i === "" ? a.HasTags(e) : AndOrNotEvaluator.Eval(i, function(o) {
  24769. return a.HasTags(e) && e._tags[o]
  24770. })
  24771. }
  24772. ,
  24773. a
  24774. }()
  24775. , __decoratorInitialStore$1 = {}
  24776. , __mergedStore$1 = {}
  24777. , _copySource$1 = function(a, e, i) {
  24778. var o = a();
  24779. Tags && Tags.AddTagsTo(o, e.tags);
  24780. var s = getMergedStore(o);
  24781. for (var c in s) {
  24782. var d = s[c]
  24783. , _ = e[c]
  24784. , b = d.type;
  24785. if (_ != null && (c !== "uniqueId" || SerializationHelper.AllowLoadingUniqueId))
  24786. switch (b) {
  24787. case 0:
  24788. case 6:
  24789. case 11:
  24790. o[c] = _;
  24791. break;
  24792. case 1:
  24793. o[c] = i || _.isRenderTarget ? _ : _.clone();
  24794. break;
  24795. case 2:
  24796. case 3:
  24797. case 4:
  24798. case 5:
  24799. case 7:
  24800. case 10:
  24801. case 12:
  24802. o[c] = i ? _ : _.clone();
  24803. break
  24804. }
  24805. }
  24806. return o
  24807. };
  24808. function getDirectStore$1(a) {
  24809. var e = a.getClassName();
  24810. return __decoratorInitialStore$1[e] || (__decoratorInitialStore$1[e] = {}),
  24811. __decoratorInitialStore$1[e]
  24812. }
  24813. function getMergedStore(a) {
  24814. var e = a.getClassName();
  24815. if (__mergedStore$1[e])
  24816. return __mergedStore$1[e];
  24817. __mergedStore$1[e] = {};
  24818. for (var i = __mergedStore$1[e], o = a, s = e; s; ) {
  24819. var c = __decoratorInitialStore$1[s];
  24820. for (var d in c)
  24821. i[d] = c[d];
  24822. var _ = void 0
  24823. , b = !1;
  24824. do {
  24825. if (_ = Object.getPrototypeOf(o),
  24826. !_.getClassName) {
  24827. b = !0;
  24828. break
  24829. }
  24830. if (_.getClassName() !== s)
  24831. break;
  24832. o = _
  24833. } while (_);
  24834. if (b)
  24835. break;
  24836. s = _.getClassName(),
  24837. o = _
  24838. }
  24839. return i
  24840. }
  24841. function generateSerializableMember$1(a, e) {
  24842. return function(i, o) {
  24843. var s = getDirectStore$1(i);
  24844. s[o] || (s[o] = {
  24845. type: a,
  24846. sourceName: e
  24847. })
  24848. }
  24849. }
  24850. function generateExpandMember(a, e) {
  24851. return e === void 0 && (e = null),
  24852. function(i, o) {
  24853. var s = e || "_" + o;
  24854. Object.defineProperty(i, o, {
  24855. get: function() {
  24856. return this[s]
  24857. },
  24858. set: function(c) {
  24859. this[s] !== c && (this[s] = c,
  24860. i[a].apply(this))
  24861. },
  24862. enumerable: !0,
  24863. configurable: !0
  24864. })
  24865. }
  24866. }
  24867. function expandToProperty(a, e) {
  24868. return e === void 0 && (e = null),
  24869. generateExpandMember(a, e)
  24870. }
  24871. function serialize(a) {
  24872. return generateSerializableMember$1(0, a)
  24873. }
  24874. function serializeAsTexture(a) {
  24875. return generateSerializableMember$1(1, a)
  24876. }
  24877. function serializeAsColor3(a) {
  24878. return generateSerializableMember$1(2, a)
  24879. }
  24880. function serializeAsFresnelParameters(a) {
  24881. return generateSerializableMember$1(3, a)
  24882. }
  24883. function serializeAsVector2(a) {
  24884. return generateSerializableMember$1(4, a)
  24885. }
  24886. function serializeAsVector3(a) {
  24887. return generateSerializableMember$1(5, a)
  24888. }
  24889. function serializeAsMeshReference(a) {
  24890. return generateSerializableMember$1(6, a)
  24891. }
  24892. function serializeAsColorCurves(a) {
  24893. return generateSerializableMember$1(7, a)
  24894. }
  24895. function serializeAsColor4(a) {
  24896. return generateSerializableMember$1(8, a)
  24897. }
  24898. function serializeAsImageProcessingConfiguration(a) {
  24899. return generateSerializableMember$1(9, a)
  24900. }
  24901. function serializeAsQuaternion(a) {
  24902. return generateSerializableMember$1(10, a)
  24903. }
  24904. function serializeAsMatrix(a) {
  24905. return generateSerializableMember$1(12, a)
  24906. }
  24907. function serializeAsCameraReference(a) {
  24908. return generateSerializableMember$1(11, a)
  24909. }
  24910. var SerializationHelper = function() {
  24911. function a() {}
  24912. return a.AppendSerializedAnimations = function(e, i) {
  24913. if (e.animations) {
  24914. i.animations = [];
  24915. for (var o = 0; o < e.animations.length; o++) {
  24916. var s = e.animations[o];
  24917. i.animations.push(s.serialize())
  24918. }
  24919. }
  24920. }
  24921. ,
  24922. a.Serialize = function(e, i) {
  24923. i || (i = {}),
  24924. Tags && (i.tags = Tags.GetTags(e));
  24925. var o = getMergedStore(e);
  24926. for (var s in o) {
  24927. var c = o[s]
  24928. , d = c.sourceName || s
  24929. , _ = c.type
  24930. , b = e[s];
  24931. if (b != null && (s !== "uniqueId" || a.AllowLoadingUniqueId))
  24932. switch (_) {
  24933. case 0:
  24934. i[d] = b;
  24935. break;
  24936. case 1:
  24937. i[d] = b.serialize();
  24938. break;
  24939. case 2:
  24940. i[d] = b.asArray();
  24941. break;
  24942. case 3:
  24943. i[d] = b.serialize();
  24944. break;
  24945. case 4:
  24946. i[d] = b.asArray();
  24947. break;
  24948. case 5:
  24949. i[d] = b.asArray();
  24950. break;
  24951. case 6:
  24952. i[d] = b.id;
  24953. break;
  24954. case 7:
  24955. i[d] = b.serialize();
  24956. break;
  24957. case 8:
  24958. i[d] = b.asArray();
  24959. break;
  24960. case 9:
  24961. i[d] = b.serialize();
  24962. break;
  24963. case 10:
  24964. i[d] = b.asArray();
  24965. break;
  24966. case 11:
  24967. i[d] = b.id;
  24968. break;
  24969. case 12:
  24970. i[d] = b.asArray();
  24971. break
  24972. }
  24973. }
  24974. return i
  24975. }
  24976. ,
  24977. a.Parse = function(e, i, o, s) {
  24978. s === void 0 && (s = null);
  24979. var c = e();
  24980. s || (s = ""),
  24981. Tags && Tags.AddTagsTo(c, i.tags);
  24982. var d = getMergedStore(c);
  24983. for (var _ in d) {
  24984. var b = d[_]
  24985. , k = i[b.sourceName || _]
  24986. , j = b.type;
  24987. if (k != null && (_ !== "uniqueId" || a.AllowLoadingUniqueId)) {
  24988. var $ = c;
  24989. switch (j) {
  24990. case 0:
  24991. $[_] = k;
  24992. break;
  24993. case 1:
  24994. o && ($[_] = a._TextureParser(k, o, s));
  24995. break;
  24996. case 2:
  24997. $[_] = Color3.FromArray(k);
  24998. break;
  24999. case 3:
  25000. $[_] = a._FresnelParametersParser(k);
  25001. break;
  25002. case 4:
  25003. $[_] = Vector2.FromArray(k);
  25004. break;
  25005. case 5:
  25006. $[_] = Vector3.FromArray(k);
  25007. break;
  25008. case 6:
  25009. o && ($[_] = o.getLastMeshById(k));
  25010. break;
  25011. case 7:
  25012. $[_] = a._ColorCurvesParser(k);
  25013. break;
  25014. case 8:
  25015. $[_] = Color4.FromArray(k);
  25016. break;
  25017. case 9:
  25018. $[_] = a._ImageProcessingConfigurationParser(k);
  25019. break;
  25020. case 10:
  25021. $[_] = Quaternion.FromArray(k);
  25022. break;
  25023. case 11:
  25024. o && ($[_] = o.getCameraById(k));
  25025. case 12:
  25026. $[_] = Matrix.FromArray(k);
  25027. break
  25028. }
  25029. }
  25030. }
  25031. return c
  25032. }
  25033. ,
  25034. a.Clone = function(e, i) {
  25035. return _copySource$1(e, i, !1)
  25036. }
  25037. ,
  25038. a.Instanciate = function(e, i) {
  25039. return _copySource$1(e, i, !0)
  25040. }
  25041. ,
  25042. a.AllowLoadingUniqueId = !1,
  25043. a._ImageProcessingConfigurationParser = function(e) {
  25044. throw _WarnImport("ImageProcessingConfiguration")
  25045. }
  25046. ,
  25047. a._FresnelParametersParser = function(e) {
  25048. throw _WarnImport("FresnelParameters")
  25049. }
  25050. ,
  25051. a._ColorCurvesParser = function(e) {
  25052. throw _WarnImport("ColorCurves")
  25053. }
  25054. ,
  25055. a._TextureParser = function(e, i, o) {
  25056. throw _WarnImport("Texture")
  25057. }
  25058. ,
  25059. a
  25060. }();
  25061. function nativeOverride(a, e, i, o) {
  25062. var s = i.value;
  25063. i.value = function() {
  25064. for (var c = [], d = 0; d < arguments.length; d++)
  25065. c[d] = arguments[d];
  25066. var _ = s;
  25067. if (typeof _native != "undefined" && _native[e]) {
  25068. var b = _native[e];
  25069. o ? _ = function() {
  25070. for (var k = [], j = 0; j < arguments.length; j++)
  25071. k[j] = arguments[j];
  25072. return o.apply(void 0, k) ? b.apply(void 0, k) : s.apply(void 0, k)
  25073. }
  25074. : _ = b
  25075. }
  25076. return a[e] = _,
  25077. _.apply(void 0, c)
  25078. }
  25079. }
  25080. nativeOverride.filter = function(a) {
  25081. return function(e, i, o) {
  25082. return nativeOverride(e, i, o, a)
  25083. }
  25084. }
  25085. ;
  25086. function inlineScheduler(a, e, i) {
  25087. try {
  25088. var o = a.next();
  25089. o.done ? e(o) : o.value ? o.value.then(function() {
  25090. o.value = void 0,
  25091. e(o)
  25092. }, i) : e(o)
  25093. } catch (s) {
  25094. i(s)
  25095. }
  25096. }
  25097. function createYieldingScheduler(a) {
  25098. a === void 0 && (a = 25);
  25099. var e;
  25100. return function(i, o, s) {
  25101. var c = performance.now();
  25102. e === void 0 || c - e > a ? (e = c,
  25103. setTimeout(function() {
  25104. inlineScheduler(i, o, s)
  25105. }, 0)) : inlineScheduler(i, o, s)
  25106. }
  25107. }
  25108. function runCoroutine(a, e, i, o, s) {
  25109. var c = function() {
  25110. var d, _ = function(b) {
  25111. b.done ? i(b.value) : d === void 0 ? d = !0 : c()
  25112. };
  25113. do
  25114. d = void 0,
  25115. !s || !s.aborted ? e(a, _, o) : o(new Error("Aborted")),
  25116. d === void 0 && (d = !1);
  25117. while (d)
  25118. };
  25119. c()
  25120. }
  25121. function runCoroutineSync(a, e) {
  25122. var i;
  25123. return runCoroutine(a, inlineScheduler, function(o) {
  25124. return i = o
  25125. }, function(o) {
  25126. throw o
  25127. }, e),
  25128. i
  25129. }
  25130. function runCoroutineAsync(a, e, i) {
  25131. return new Promise(function(o, s) {
  25132. runCoroutine(a, e, o, s, i)
  25133. }
  25134. )
  25135. }
  25136. function makeSyncFunction(a, e) {
  25137. return function() {
  25138. for (var i = [], o = 0; o < arguments.length; o++)
  25139. i[o] = arguments[o];
  25140. return runCoroutineSync(a.apply(void 0, i), e)
  25141. }
  25142. }
  25143. var VertexData = function() {
  25144. function a() {
  25145. this._applyTo = makeSyncFunction(this._applyToCoroutine.bind(this))
  25146. }
  25147. return a.prototype.set = function(e, i) {
  25148. switch (e.length || Logger$2.Warn("Setting vertex data kind '" + i + "' with an empty array"),
  25149. i) {
  25150. case VertexBuffer.PositionKind:
  25151. this.positions = e;
  25152. break;
  25153. case VertexBuffer.NormalKind:
  25154. this.normals = e;
  25155. break;
  25156. case VertexBuffer.TangentKind:
  25157. this.tangents = e;
  25158. break;
  25159. case VertexBuffer.UVKind:
  25160. this.uvs = e;
  25161. break;
  25162. case VertexBuffer.UV2Kind:
  25163. this.uvs2 = e;
  25164. break;
  25165. case VertexBuffer.UV3Kind:
  25166. this.uvs3 = e;
  25167. break;
  25168. case VertexBuffer.UV4Kind:
  25169. this.uvs4 = e;
  25170. break;
  25171. case VertexBuffer.UV5Kind:
  25172. this.uvs5 = e;
  25173. break;
  25174. case VertexBuffer.UV6Kind:
  25175. this.uvs6 = e;
  25176. break;
  25177. case VertexBuffer.ColorKind:
  25178. this.colors = e;
  25179. break;
  25180. case VertexBuffer.MatricesIndicesKind:
  25181. this.matricesIndices = e;
  25182. break;
  25183. case VertexBuffer.MatricesWeightsKind:
  25184. this.matricesWeights = e;
  25185. break;
  25186. case VertexBuffer.MatricesIndicesExtraKind:
  25187. this.matricesIndicesExtra = e;
  25188. break;
  25189. case VertexBuffer.MatricesWeightsExtraKind:
  25190. this.matricesWeightsExtra = e;
  25191. break
  25192. }
  25193. }
  25194. ,
  25195. a.prototype.applyToMesh = function(e, i) {
  25196. return this._applyTo(e, i, !1),
  25197. this
  25198. }
  25199. ,
  25200. a.prototype.applyToGeometry = function(e, i) {
  25201. return this._applyTo(e, i, !1),
  25202. this
  25203. }
  25204. ,
  25205. a.prototype.updateMesh = function(e) {
  25206. return this._update(e),
  25207. this
  25208. }
  25209. ,
  25210. a.prototype.updateGeometry = function(e) {
  25211. return this._update(e),
  25212. this
  25213. }
  25214. ,
  25215. a.prototype._applyToCoroutine = function(e, i, o) {
  25216. return i === void 0 && (i = !1),
  25217. __generator(this, function(s) {
  25218. switch (s.label) {
  25219. case 0:
  25220. return this.positions ? (e.setVerticesData(VertexBuffer.PositionKind, this.positions, i),
  25221. o ? [4] : [3, 2]) : [3, 2];
  25222. case 1:
  25223. s.sent(),
  25224. s.label = 2;
  25225. case 2:
  25226. return this.normals ? (e.setVerticesData(VertexBuffer.NormalKind, this.normals, i),
  25227. o ? [4] : [3, 4]) : [3, 4];
  25228. case 3:
  25229. s.sent(),
  25230. s.label = 4;
  25231. case 4:
  25232. return this.tangents ? (e.setVerticesData(VertexBuffer.TangentKind, this.tangents, i),
  25233. o ? [4] : [3, 6]) : [3, 6];
  25234. case 5:
  25235. s.sent(),
  25236. s.label = 6;
  25237. case 6:
  25238. return this.uvs ? (e.setVerticesData(VertexBuffer.UVKind, this.uvs, i),
  25239. o ? [4] : [3, 8]) : [3, 8];
  25240. case 7:
  25241. s.sent(),
  25242. s.label = 8;
  25243. case 8:
  25244. return this.uvs2 ? (e.setVerticesData(VertexBuffer.UV2Kind, this.uvs2, i),
  25245. o ? [4] : [3, 10]) : [3, 10];
  25246. case 9:
  25247. s.sent(),
  25248. s.label = 10;
  25249. case 10:
  25250. return this.uvs3 ? (e.setVerticesData(VertexBuffer.UV3Kind, this.uvs3, i),
  25251. o ? [4] : [3, 12]) : [3, 12];
  25252. case 11:
  25253. s.sent(),
  25254. s.label = 12;
  25255. case 12:
  25256. return this.uvs4 ? (e.setVerticesData(VertexBuffer.UV4Kind, this.uvs4, i),
  25257. o ? [4] : [3, 14]) : [3, 14];
  25258. case 13:
  25259. s.sent(),
  25260. s.label = 14;
  25261. case 14:
  25262. return this.uvs5 ? (e.setVerticesData(VertexBuffer.UV5Kind, this.uvs5, i),
  25263. o ? [4] : [3, 16]) : [3, 16];
  25264. case 15:
  25265. s.sent(),
  25266. s.label = 16;
  25267. case 16:
  25268. return this.uvs6 ? (e.setVerticesData(VertexBuffer.UV6Kind, this.uvs6, i),
  25269. o ? [4] : [3, 18]) : [3, 18];
  25270. case 17:
  25271. s.sent(),
  25272. s.label = 18;
  25273. case 18:
  25274. return this.colors ? (e.setVerticesData(VertexBuffer.ColorKind, this.colors, i),
  25275. o ? [4] : [3, 20]) : [3, 20];
  25276. case 19:
  25277. s.sent(),
  25278. s.label = 20;
  25279. case 20:
  25280. return this.matricesIndices ? (e.setVerticesData(VertexBuffer.MatricesIndicesKind, this.matricesIndices, i),
  25281. o ? [4] : [3, 22]) : [3, 22];
  25282. case 21:
  25283. s.sent(),
  25284. s.label = 22;
  25285. case 22:
  25286. return this.matricesWeights ? (e.setVerticesData(VertexBuffer.MatricesWeightsKind, this.matricesWeights, i),
  25287. o ? [4] : [3, 24]) : [3, 24];
  25288. case 23:
  25289. s.sent(),
  25290. s.label = 24;
  25291. case 24:
  25292. return this.matricesIndicesExtra ? (e.setVerticesData(VertexBuffer.MatricesIndicesExtraKind, this.matricesIndicesExtra, i),
  25293. o ? [4] : [3, 26]) : [3, 26];
  25294. case 25:
  25295. s.sent(),
  25296. s.label = 26;
  25297. case 26:
  25298. return this.matricesWeightsExtra ? (e.setVerticesData(VertexBuffer.MatricesWeightsExtraKind, this.matricesWeightsExtra, i),
  25299. o ? [4] : [3, 28]) : [3, 28];
  25300. case 27:
  25301. s.sent(),
  25302. s.label = 28;
  25303. case 28:
  25304. return this.indices ? (e.setIndices(this.indices, null, i),
  25305. o ? [4] : [3, 30]) : [3, 31];
  25306. case 29:
  25307. s.sent(),
  25308. s.label = 30;
  25309. case 30:
  25310. return [3, 32];
  25311. case 31:
  25312. e.setIndices([], null),
  25313. s.label = 32;
  25314. case 32:
  25315. return [2, this]
  25316. }
  25317. })
  25318. }
  25319. ,
  25320. a.prototype._update = function(e, i, o) {
  25321. return this.positions && e.updateVerticesData(VertexBuffer.PositionKind, this.positions, i, o),
  25322. this.normals && e.updateVerticesData(VertexBuffer.NormalKind, this.normals, i, o),
  25323. this.tangents && e.updateVerticesData(VertexBuffer.TangentKind, this.tangents, i, o),
  25324. this.uvs && e.updateVerticesData(VertexBuffer.UVKind, this.uvs, i, o),
  25325. this.uvs2 && e.updateVerticesData(VertexBuffer.UV2Kind, this.uvs2, i, o),
  25326. this.uvs3 && e.updateVerticesData(VertexBuffer.UV3Kind, this.uvs3, i, o),
  25327. this.uvs4 && e.updateVerticesData(VertexBuffer.UV4Kind, this.uvs4, i, o),
  25328. this.uvs5 && e.updateVerticesData(VertexBuffer.UV5Kind, this.uvs5, i, o),
  25329. this.uvs6 && e.updateVerticesData(VertexBuffer.UV6Kind, this.uvs6, i, o),
  25330. this.colors && e.updateVerticesData(VertexBuffer.ColorKind, this.colors, i, o),
  25331. this.matricesIndices && e.updateVerticesData(VertexBuffer.MatricesIndicesKind, this.matricesIndices, i, o),
  25332. this.matricesWeights && e.updateVerticesData(VertexBuffer.MatricesWeightsKind, this.matricesWeights, i, o),
  25333. this.matricesIndicesExtra && e.updateVerticesData(VertexBuffer.MatricesIndicesExtraKind, this.matricesIndicesExtra, i, o),
  25334. this.matricesWeightsExtra && e.updateVerticesData(VertexBuffer.MatricesWeightsExtraKind, this.matricesWeightsExtra, i, o),
  25335. this.indices && e.setIndices(this.indices, null),
  25336. this
  25337. }
  25338. ,
  25339. a._TransformVector3Coordinates = function(e, i) {
  25340. for (var o = TmpVectors.Vector3[0], s = TmpVectors.Vector3[1], c = 0; c < e.length; c += 3)
  25341. Vector3.FromArrayToRef(e, c, o),
  25342. Vector3.TransformCoordinatesToRef(o, i, s),
  25343. e[c] = s.x,
  25344. e[c + 1] = s.y,
  25345. e[c + 2] = s.z
  25346. }
  25347. ,
  25348. a._TransformVector3Normals = function(e, i) {
  25349. for (var o = TmpVectors.Vector3[0], s = TmpVectors.Vector3[1], c = 0; c < e.length; c += 3)
  25350. Vector3.FromArrayToRef(e, c, o),
  25351. Vector3.TransformNormalToRef(o, i, s),
  25352. e[c] = s.x,
  25353. e[c + 1] = s.y,
  25354. e[c + 2] = s.z
  25355. }
  25356. ,
  25357. a._TransformVector4Normals = function(e, i) {
  25358. for (var o = TmpVectors.Vector4[0], s = TmpVectors.Vector4[1], c = 0; c < e.length; c += 4)
  25359. Vector4.FromArrayToRef(e, c, o),
  25360. Vector4.TransformNormalToRef(o, i, s),
  25361. e[c] = s.x,
  25362. e[c + 1] = s.y,
  25363. e[c + 2] = s.z,
  25364. e[c + 3] = s.w
  25365. }
  25366. ,
  25367. a._FlipFaces = function(e) {
  25368. for (var i = 0; i < e.length; i += 3) {
  25369. var o = e[i + 1];
  25370. e[i + 1] = e[i + 2],
  25371. e[i + 2] = o
  25372. }
  25373. }
  25374. ,
  25375. a.prototype.transform = function(e) {
  25376. var i = e.determinant() < 0;
  25377. return this.positions && a._TransformVector3Coordinates(this.positions, e),
  25378. this.normals && a._TransformVector3Normals(this.normals, e),
  25379. this.tangents && a._TransformVector4Normals(this.tangents, e),
  25380. i && this.indices && a._FlipFaces(this.indices),
  25381. this
  25382. }
  25383. ,
  25384. a.prototype.merge = function(e, i) {
  25385. return i === void 0 && (i = !1),
  25386. runCoroutineSync(this._mergeCoroutine(e, i, !1))
  25387. }
  25388. ,
  25389. a.prototype._mergeCoroutine = function(e, i, o) {
  25390. var s, c, _e, d, _, b, k, j, $, _e, et, tt, rt, it, nt;
  25391. return i === void 0 && (i = !1),
  25392. __generator(this, function(ot) {
  25393. switch (ot.label) {
  25394. case 0:
  25395. for (this._validate(),
  25396. e = Array.isArray(e) ? e : [e],
  25397. s = 0,
  25398. c = e; s < c.length; s++)
  25399. if (_e = c[s],
  25400. _e._validate(),
  25401. !this.normals != !_e.normals || !this.tangents != !_e.tangents || !this.uvs != !_e.uvs || !this.uvs2 != !_e.uvs2 || !this.uvs3 != !_e.uvs3 || !this.uvs4 != !_e.uvs4 || !this.uvs5 != !_e.uvs5 || !this.uvs6 != !_e.uvs6 || !this.colors != !_e.colors || !this.matricesIndices != !_e.matricesIndices || !this.matricesWeights != !_e.matricesWeights || !this.matricesIndicesExtra != !_e.matricesIndicesExtra || !this.matricesWeightsExtra != !_e.matricesWeightsExtra)
  25402. throw new Error("Cannot merge vertex data that do not have the same set of attributes");
  25403. if (d = e.reduce(function(at, st) {
  25404. var ut, ct;
  25405. return at + ((ct = (ut = st.indices) === null || ut === void 0 ? void 0 : ut.length) !== null && ct !== void 0 ? ct : 0)
  25406. }, (rt = (tt = this.indices) === null || tt === void 0 ? void 0 : tt.length) !== null && rt !== void 0 ? rt : 0),
  25407. !(d > 0))
  25408. return [3, 4];
  25409. _ = (nt = (it = this.indices) === null || it === void 0 ? void 0 : it.length) !== null && nt !== void 0 ? nt : 0,
  25410. this.indices || (this.indices = new Array(d)),
  25411. this.indices.length !== d && (Array.isArray(this.indices) ? this.indices.length = d : (b = i || this.indices instanceof Uint32Array ? new Uint32Array(d) : new Uint16Array(d),
  25412. b.set(this.indices),
  25413. this.indices = b)),
  25414. k = this.positions ? this.positions.length / 3 : 0,
  25415. j = 0,
  25416. $ = e,
  25417. ot.label = 1;
  25418. case 1:
  25419. if (!(j < $.length))
  25420. return [3, 4];
  25421. if (_e = $[j],
  25422. !_e.indices)
  25423. return [3, 3];
  25424. for (et = 0; et < _e.indices.length; et++)
  25425. this.indices[_ + et] = _e.indices[et] + k;
  25426. return k += _e.positions.length / 3,
  25427. _ += _e.indices.length,
  25428. o ? [4] : [3, 3];
  25429. case 2:
  25430. ot.sent(),
  25431. ot.label = 3;
  25432. case 3:
  25433. return j++,
  25434. [3, 1];
  25435. case 4:
  25436. return this.positions = a._mergeElement(this.positions, e.map(function(at) {
  25437. return at.positions
  25438. })),
  25439. o ? [4] : [3, 6];
  25440. case 5:
  25441. ot.sent(),
  25442. ot.label = 6;
  25443. case 6:
  25444. return this.normals = a._mergeElement(this.normals, e.map(function(at) {
  25445. return at.normals
  25446. })),
  25447. o ? [4] : [3, 8];
  25448. case 7:
  25449. ot.sent(),
  25450. ot.label = 8;
  25451. case 8:
  25452. return this.tangents = a._mergeElement(this.tangents, e.map(function(at) {
  25453. return at.tangents
  25454. })),
  25455. o ? [4] : [3, 10];
  25456. case 9:
  25457. ot.sent(),
  25458. ot.label = 10;
  25459. case 10:
  25460. return this.uvs = a._mergeElement(this.uvs, e.map(function(at) {
  25461. return at.uvs
  25462. })),
  25463. o ? [4] : [3, 12];
  25464. case 11:
  25465. ot.sent(),
  25466. ot.label = 12;
  25467. case 12:
  25468. return this.uvs2 = a._mergeElement(this.uvs2, e.map(function(at) {
  25469. return at.uvs2
  25470. })),
  25471. o ? [4] : [3, 14];
  25472. case 13:
  25473. ot.sent(),
  25474. ot.label = 14;
  25475. case 14:
  25476. return this.uvs3 = a._mergeElement(this.uvs3, e.map(function(at) {
  25477. return at.uvs3
  25478. })),
  25479. o ? [4] : [3, 16];
  25480. case 15:
  25481. ot.sent(),
  25482. ot.label = 16;
  25483. case 16:
  25484. return this.uvs4 = a._mergeElement(this.uvs4, e.map(function(at) {
  25485. return at.uvs4
  25486. })),
  25487. o ? [4] : [3, 18];
  25488. case 17:
  25489. ot.sent(),
  25490. ot.label = 18;
  25491. case 18:
  25492. return this.uvs5 = a._mergeElement(this.uvs5, e.map(function(at) {
  25493. return at.uvs5
  25494. })),
  25495. o ? [4] : [3, 20];
  25496. case 19:
  25497. ot.sent(),
  25498. ot.label = 20;
  25499. case 20:
  25500. return this.uvs6 = a._mergeElement(this.uvs6, e.map(function(at) {
  25501. return at.uvs6
  25502. })),
  25503. o ? [4] : [3, 22];
  25504. case 21:
  25505. ot.sent(),
  25506. ot.label = 22;
  25507. case 22:
  25508. return this.colors = a._mergeElement(this.colors, e.map(function(at) {
  25509. return at.colors
  25510. })),
  25511. o ? [4] : [3, 24];
  25512. case 23:
  25513. ot.sent(),
  25514. ot.label = 24;
  25515. case 24:
  25516. return this.matricesIndices = a._mergeElement(this.matricesIndices, e.map(function(at) {
  25517. return at.matricesIndices
  25518. })),
  25519. o ? [4] : [3, 26];
  25520. case 25:
  25521. ot.sent(),
  25522. ot.label = 26;
  25523. case 26:
  25524. return this.matricesWeights = a._mergeElement(this.matricesWeights, e.map(function(at) {
  25525. return at.matricesWeights
  25526. })),
  25527. o ? [4] : [3, 28];
  25528. case 27:
  25529. ot.sent(),
  25530. ot.label = 28;
  25531. case 28:
  25532. return this.matricesIndicesExtra = a._mergeElement(this.matricesIndicesExtra, e.map(function(at) {
  25533. return at.matricesIndicesExtra
  25534. })),
  25535. o ? [4] : [3, 30];
  25536. case 29:
  25537. ot.sent(),
  25538. ot.label = 30;
  25539. case 30:
  25540. return this.matricesWeightsExtra = a._mergeElement(this.matricesWeightsExtra, e.map(function(at) {
  25541. return at.matricesWeightsExtra
  25542. })),
  25543. [2, this]
  25544. }
  25545. })
  25546. }
  25547. ,
  25548. a._mergeElement = function(e, i) {
  25549. var o = i.filter(function(tt) {
  25550. return tt != null
  25551. });
  25552. if (o.length === 0)
  25553. return e;
  25554. if (!e)
  25555. return this._mergeElement(o[0], o.slice(1));
  25556. var s = o.reduce(function(tt, rt) {
  25557. return tt + rt.length
  25558. }, e.length);
  25559. if (e instanceof Float32Array) {
  25560. var c = new Float32Array(s);
  25561. c.set(e);
  25562. for (var d = e.length, _ = 0, b = o; _ < b.length; _++) {
  25563. var k = b[_];
  25564. c.set(k, d),
  25565. d += k.length
  25566. }
  25567. return c
  25568. } else {
  25569. for (var j = new Array(s), $ = 0; $ < e.length; $++)
  25570. j[$] = e[$];
  25571. for (var d = e.length, _e = 0, et = o; _e < et.length; _e++) {
  25572. for (var k = et[_e], $ = 0; $ < k.length; $++)
  25573. j[d + $] = k[$];
  25574. d += k.length
  25575. }
  25576. return j
  25577. }
  25578. }
  25579. ,
  25580. a.prototype._validate = function() {
  25581. if (!this.positions)
  25582. throw new Error("Positions are required");
  25583. var e = function(s, c) {
  25584. var d = VertexBuffer.DeduceStride(s);
  25585. if (c.length % d !== 0)
  25586. throw new Error("The " + s + "s array count must be a multiple of " + d);
  25587. return c.length / d
  25588. }
  25589. , i = e(VertexBuffer.PositionKind, this.positions)
  25590. , o = function(s, c) {
  25591. var d = e(s, c);
  25592. if (d !== i)
  25593. throw new Error("The " + s + "s element count (" + d + ") does not match the positions count (" + i + ")")
  25594. };
  25595. this.normals && o(VertexBuffer.NormalKind, this.normals),
  25596. this.tangents && o(VertexBuffer.TangentKind, this.tangents),
  25597. this.uvs && o(VertexBuffer.UVKind, this.uvs),
  25598. this.uvs2 && o(VertexBuffer.UV2Kind, this.uvs2),
  25599. this.uvs3 && o(VertexBuffer.UV3Kind, this.uvs3),
  25600. this.uvs4 && o(VertexBuffer.UV4Kind, this.uvs4),
  25601. this.uvs5 && o(VertexBuffer.UV5Kind, this.uvs5),
  25602. this.uvs6 && o(VertexBuffer.UV6Kind, this.uvs6),
  25603. this.colors && o(VertexBuffer.ColorKind, this.colors),
  25604. this.matricesIndices && o(VertexBuffer.MatricesIndicesKind, this.matricesIndices),
  25605. this.matricesWeights && o(VertexBuffer.MatricesWeightsKind, this.matricesWeights),
  25606. this.matricesIndicesExtra && o(VertexBuffer.MatricesIndicesExtraKind, this.matricesIndicesExtra),
  25607. this.matricesWeightsExtra && o(VertexBuffer.MatricesWeightsExtraKind, this.matricesWeightsExtra)
  25608. }
  25609. ,
  25610. a.prototype.serialize = function() {
  25611. var e = {};
  25612. return this.positions && (e.positions = this.positions),
  25613. this.normals && (e.normals = this.normals),
  25614. this.tangents && (e.tangents = this.tangents),
  25615. this.uvs && (e.uvs = this.uvs),
  25616. this.uvs2 && (e.uvs2 = this.uvs2),
  25617. this.uvs3 && (e.uvs3 = this.uvs3),
  25618. this.uvs4 && (e.uvs4 = this.uvs4),
  25619. this.uvs5 && (e.uvs5 = this.uvs5),
  25620. this.uvs6 && (e.uvs6 = this.uvs6),
  25621. this.colors && (e.colors = this.colors),
  25622. this.matricesIndices && (e.matricesIndices = this.matricesIndices,
  25623. e.matricesIndices._isExpanded = !0),
  25624. this.matricesWeights && (e.matricesWeights = this.matricesWeights),
  25625. this.matricesIndicesExtra && (e.matricesIndicesExtra = this.matricesIndicesExtra,
  25626. e.matricesIndicesExtra._isExpanded = !0),
  25627. this.matricesWeightsExtra && (e.matricesWeightsExtra = this.matricesWeightsExtra),
  25628. e.indices = this.indices,
  25629. e
  25630. }
  25631. ,
  25632. a.ExtractFromMesh = function(e, i, o) {
  25633. return a._ExtractFrom(e, i, o)
  25634. }
  25635. ,
  25636. a.ExtractFromGeometry = function(e, i, o) {
  25637. return a._ExtractFrom(e, i, o)
  25638. }
  25639. ,
  25640. a._ExtractFrom = function(e, i, o) {
  25641. var s = new a;
  25642. return e.isVerticesDataPresent(VertexBuffer.PositionKind) && (s.positions = e.getVerticesData(VertexBuffer.PositionKind, i, o)),
  25643. e.isVerticesDataPresent(VertexBuffer.NormalKind) && (s.normals = e.getVerticesData(VertexBuffer.NormalKind, i, o)),
  25644. e.isVerticesDataPresent(VertexBuffer.TangentKind) && (s.tangents = e.getVerticesData(VertexBuffer.TangentKind, i, o)),
  25645. e.isVerticesDataPresent(VertexBuffer.UVKind) && (s.uvs = e.getVerticesData(VertexBuffer.UVKind, i, o)),
  25646. e.isVerticesDataPresent(VertexBuffer.UV2Kind) && (s.uvs2 = e.getVerticesData(VertexBuffer.UV2Kind, i, o)),
  25647. e.isVerticesDataPresent(VertexBuffer.UV3Kind) && (s.uvs3 = e.getVerticesData(VertexBuffer.UV3Kind, i, o)),
  25648. e.isVerticesDataPresent(VertexBuffer.UV4Kind) && (s.uvs4 = e.getVerticesData(VertexBuffer.UV4Kind, i, o)),
  25649. e.isVerticesDataPresent(VertexBuffer.UV5Kind) && (s.uvs5 = e.getVerticesData(VertexBuffer.UV5Kind, i, o)),
  25650. e.isVerticesDataPresent(VertexBuffer.UV6Kind) && (s.uvs6 = e.getVerticesData(VertexBuffer.UV6Kind, i, o)),
  25651. e.isVerticesDataPresent(VertexBuffer.ColorKind) && (s.colors = e.getVerticesData(VertexBuffer.ColorKind, i, o)),
  25652. e.isVerticesDataPresent(VertexBuffer.MatricesIndicesKind) && (s.matricesIndices = e.getVerticesData(VertexBuffer.MatricesIndicesKind, i, o)),
  25653. e.isVerticesDataPresent(VertexBuffer.MatricesWeightsKind) && (s.matricesWeights = e.getVerticesData(VertexBuffer.MatricesWeightsKind, i, o)),
  25654. e.isVerticesDataPresent(VertexBuffer.MatricesIndicesExtraKind) && (s.matricesIndicesExtra = e.getVerticesData(VertexBuffer.MatricesIndicesExtraKind, i, o)),
  25655. e.isVerticesDataPresent(VertexBuffer.MatricesWeightsExtraKind) && (s.matricesWeightsExtra = e.getVerticesData(VertexBuffer.MatricesWeightsExtraKind, i, o)),
  25656. s.indices = e.getIndices(i, o),
  25657. s
  25658. }
  25659. ,
  25660. a.CreateRibbon = function(e) {
  25661. throw _WarnImport("ribbonBuilder")
  25662. }
  25663. ,
  25664. a.CreateBox = function(e) {
  25665. throw _WarnImport("boxBuilder")
  25666. }
  25667. ,
  25668. a.CreateTiledBox = function(e) {
  25669. throw _WarnImport("tiledBoxBuilder")
  25670. }
  25671. ,
  25672. a.CreateTiledPlane = function(e) {
  25673. throw _WarnImport("tiledPlaneBuilder")
  25674. }
  25675. ,
  25676. a.CreateSphere = function(e) {
  25677. throw _WarnImport("sphereBuilder")
  25678. }
  25679. ,
  25680. a.CreateCylinder = function(e) {
  25681. throw _WarnImport("cylinderBuilder")
  25682. }
  25683. ,
  25684. a.CreateTorus = function(e) {
  25685. throw _WarnImport("torusBuilder")
  25686. }
  25687. ,
  25688. a.CreateLineSystem = function(e) {
  25689. throw _WarnImport("linesBuilder")
  25690. }
  25691. ,
  25692. a.CreateDashedLines = function(e) {
  25693. throw _WarnImport("linesBuilder")
  25694. }
  25695. ,
  25696. a.CreateGround = function(e) {
  25697. throw _WarnImport("groundBuilder")
  25698. }
  25699. ,
  25700. a.CreateTiledGround = function(e) {
  25701. throw _WarnImport("groundBuilder")
  25702. }
  25703. ,
  25704. a.CreateGroundFromHeightMap = function(e) {
  25705. throw _WarnImport("groundBuilder")
  25706. }
  25707. ,
  25708. a.CreatePlane = function(e) {
  25709. throw _WarnImport("planeBuilder")
  25710. }
  25711. ,
  25712. a.CreateDisc = function(e) {
  25713. throw _WarnImport("discBuilder")
  25714. }
  25715. ,
  25716. a.CreatePolygon = function(e, i, o, s, c, d, _) {
  25717. throw _WarnImport("polygonBuilder")
  25718. }
  25719. ,
  25720. a.CreateIcoSphere = function(e) {
  25721. throw _WarnImport("icoSphereBuilder")
  25722. }
  25723. ,
  25724. a.CreatePolyhedron = function(e) {
  25725. throw _WarnImport("polyhedronBuilder")
  25726. }
  25727. ,
  25728. a.CreateCapsule = function(e) {
  25729. throw e === void 0 && (e = {
  25730. orientation: Vector3.Up(),
  25731. subdivisions: 2,
  25732. tessellation: 16,
  25733. height: 1,
  25734. radius: .25,
  25735. capSubdivisions: 6
  25736. }),
  25737. _WarnImport("capsuleBuilder")
  25738. }
  25739. ,
  25740. a.CreateTorusKnot = function(e) {
  25741. throw _WarnImport("torusKnotBuilder")
  25742. }
  25743. ,
  25744. a.ComputeNormals = function(e, i, o, s) {
  25745. var c = 0
  25746. , d = 0
  25747. , _ = 0
  25748. , b = 0
  25749. , k = 0
  25750. , j = 0
  25751. , $ = 0
  25752. , _e = 0
  25753. , et = 0
  25754. , tt = 0
  25755. , rt = 0
  25756. , it = 0
  25757. , nt = 0
  25758. , ot = 0
  25759. , at = 0
  25760. , st = 0
  25761. , ut = 0
  25762. , ct = 0
  25763. , lt = 0
  25764. , ft = 0
  25765. , ht = !1
  25766. , pt = !1
  25767. , dt = !1
  25768. , _t = !1
  25769. , mt = 1
  25770. , vt = 0
  25771. , yt = null;
  25772. if (s && (ht = !!s.facetNormals,
  25773. pt = !!s.facetPositions,
  25774. dt = !!s.facetPartitioning,
  25775. mt = s.useRightHandedSystem === !0 ? -1 : 1,
  25776. vt = s.ratio || 0,
  25777. _t = !!s.depthSort,
  25778. yt = s.distanceTo,
  25779. _t)) {
  25780. yt === void 0 && (yt = Vector3.Zero());
  25781. var Et = s.depthSortedFacets
  25782. }
  25783. var At = 0
  25784. , gt = 0
  25785. , St = 0
  25786. , xt = 0;
  25787. if (dt && s && s.bbSize) {
  25788. var bt = 0
  25789. , Rt = 0
  25790. , Mt = 0
  25791. , Pt = 0
  25792. , It = 0
  25793. , Dt = 0
  25794. , Ct = 0
  25795. , Ot = 0
  25796. , wt = 0
  25797. , Nt = 0
  25798. , Ft = 0
  25799. , Vt = 0
  25800. , Lt = 0
  25801. , kt = 0
  25802. , Bt = 0
  25803. , Ut = 0
  25804. , Gt = s.bbSize.x > s.bbSize.y ? s.bbSize.x : s.bbSize.y;
  25805. Gt = Gt > s.bbSize.z ? Gt : s.bbSize.z,
  25806. At = s.subDiv.X * vt / s.bbSize.x,
  25807. gt = s.subDiv.Y * vt / s.bbSize.y,
  25808. St = s.subDiv.Z * vt / s.bbSize.z,
  25809. xt = s.subDiv.max * s.subDiv.max,
  25810. s.facetPartitioning.length = 0
  25811. }
  25812. for (c = 0; c < e.length; c++)
  25813. o[c] = 0;
  25814. var Ht = i.length / 3 | 0;
  25815. for (c = 0; c < Ht; c++) {
  25816. if (it = i[c * 3] * 3,
  25817. nt = it + 1,
  25818. ot = it + 2,
  25819. at = i[c * 3 + 1] * 3,
  25820. st = at + 1,
  25821. ut = at + 2,
  25822. ct = i[c * 3 + 2] * 3,
  25823. lt = ct + 1,
  25824. ft = ct + 2,
  25825. d = e[it] - e[at],
  25826. _ = e[nt] - e[st],
  25827. b = e[ot] - e[ut],
  25828. k = e[ct] - e[at],
  25829. j = e[lt] - e[st],
  25830. $ = e[ft] - e[ut],
  25831. _e = mt * (_ * $ - b * j),
  25832. et = mt * (b * k - d * $),
  25833. tt = mt * (d * j - _ * k),
  25834. rt = Math.sqrt(_e * _e + et * et + tt * tt),
  25835. rt = rt === 0 ? 1 : rt,
  25836. _e /= rt,
  25837. et /= rt,
  25838. tt /= rt,
  25839. ht && s && (s.facetNormals[c].x = _e,
  25840. s.facetNormals[c].y = et,
  25841. s.facetNormals[c].z = tt),
  25842. pt && s && (s.facetPositions[c].x = (e[it] + e[at] + e[ct]) / 3,
  25843. s.facetPositions[c].y = (e[nt] + e[st] + e[lt]) / 3,
  25844. s.facetPositions[c].z = (e[ot] + e[ut] + e[ft]) / 3),
  25845. dt && s && (bt = Math.floor((s.facetPositions[c].x - s.bInfo.minimum.x * vt) * At),
  25846. Rt = Math.floor((s.facetPositions[c].y - s.bInfo.minimum.y * vt) * gt),
  25847. Mt = Math.floor((s.facetPositions[c].z - s.bInfo.minimum.z * vt) * St),
  25848. Pt = Math.floor((e[it] - s.bInfo.minimum.x * vt) * At),
  25849. It = Math.floor((e[nt] - s.bInfo.minimum.y * vt) * gt),
  25850. Dt = Math.floor((e[ot] - s.bInfo.minimum.z * vt) * St),
  25851. Ct = Math.floor((e[at] - s.bInfo.minimum.x * vt) * At),
  25852. Ot = Math.floor((e[st] - s.bInfo.minimum.y * vt) * gt),
  25853. wt = Math.floor((e[ut] - s.bInfo.minimum.z * vt) * St),
  25854. Nt = Math.floor((e[ct] - s.bInfo.minimum.x * vt) * At),
  25855. Ft = Math.floor((e[lt] - s.bInfo.minimum.y * vt) * gt),
  25856. Vt = Math.floor((e[ft] - s.bInfo.minimum.z * vt) * St),
  25857. kt = Pt + s.subDiv.max * It + xt * Dt,
  25858. Bt = Ct + s.subDiv.max * Ot + xt * wt,
  25859. Ut = Nt + s.subDiv.max * Ft + xt * Vt,
  25860. Lt = bt + s.subDiv.max * Rt + xt * Mt,
  25861. s.facetPartitioning[Lt] = s.facetPartitioning[Lt] ? s.facetPartitioning[Lt] : new Array,
  25862. s.facetPartitioning[kt] = s.facetPartitioning[kt] ? s.facetPartitioning[kt] : new Array,
  25863. s.facetPartitioning[Bt] = s.facetPartitioning[Bt] ? s.facetPartitioning[Bt] : new Array,
  25864. s.facetPartitioning[Ut] = s.facetPartitioning[Ut] ? s.facetPartitioning[Ut] : new Array,
  25865. s.facetPartitioning[kt].push(c),
  25866. Bt != kt && s.facetPartitioning[Bt].push(c),
  25867. Ut == Bt || Ut == kt || s.facetPartitioning[Ut].push(c),
  25868. Lt == kt || Lt == Bt || Lt == Ut || s.facetPartitioning[Lt].push(c)),
  25869. _t && s && s.facetPositions) {
  25870. var zt = Et[c];
  25871. zt.ind = c * 3,
  25872. zt.sqDistance = Vector3.DistanceSquared(s.facetPositions[c], yt)
  25873. }
  25874. o[it] += _e,
  25875. o[nt] += et,
  25876. o[ot] += tt,
  25877. o[at] += _e,
  25878. o[st] += et,
  25879. o[ut] += tt,
  25880. o[ct] += _e,
  25881. o[lt] += et,
  25882. o[ft] += tt
  25883. }
  25884. for (c = 0; c < o.length / 3; c++)
  25885. _e = o[c * 3],
  25886. et = o[c * 3 + 1],
  25887. tt = o[c * 3 + 2],
  25888. rt = Math.sqrt(_e * _e + et * et + tt * tt),
  25889. rt = rt === 0 ? 1 : rt,
  25890. _e /= rt,
  25891. et /= rt,
  25892. tt /= rt,
  25893. o[c * 3] = _e,
  25894. o[c * 3 + 1] = et,
  25895. o[c * 3 + 2] = tt
  25896. }
  25897. ,
  25898. a._ComputeSides = function(e, i, o, s, c, d, _) {
  25899. var b = o.length, k = s.length, j, $;
  25900. switch (e = e || a.DEFAULTSIDE,
  25901. e) {
  25902. case a.FRONTSIDE:
  25903. break;
  25904. case a.BACKSIDE:
  25905. var _e;
  25906. for (j = 0; j < b; j += 3)
  25907. _e = o[j],
  25908. o[j] = o[j + 2],
  25909. o[j + 2] = _e;
  25910. for ($ = 0; $ < k; $++)
  25911. s[$] = -s[$];
  25912. break;
  25913. case a.DOUBLESIDE:
  25914. for (var et = i.length, tt = et / 3, rt = 0; rt < et; rt++)
  25915. i[et + rt] = i[rt];
  25916. for (j = 0; j < b; j += 3)
  25917. o[j + b] = o[j + 2] + tt,
  25918. o[j + 1 + b] = o[j + 1] + tt,
  25919. o[j + 2 + b] = o[j] + tt;
  25920. for ($ = 0; $ < k; $++)
  25921. s[k + $] = -s[$];
  25922. var it = c.length
  25923. , nt = 0;
  25924. for (nt = 0; nt < it; nt++)
  25925. c[nt + it] = c[nt];
  25926. for (d = d || new Vector4(0,0,1,1),
  25927. _ = _ || new Vector4(0,0,1,1),
  25928. nt = 0,
  25929. j = 0; j < it / 2; j++)
  25930. c[nt] = d.x + (d.z - d.x) * c[nt],
  25931. c[nt + 1] = d.y + (d.w - d.y) * c[nt + 1],
  25932. c[nt + it] = _.x + (_.z - _.x) * c[nt + it],
  25933. c[nt + it + 1] = _.y + (_.w - _.y) * c[nt + it + 1],
  25934. nt += 2;
  25935. break
  25936. }
  25937. }
  25938. ,
  25939. a.ImportVertexData = function(e, i) {
  25940. var o = new a
  25941. , s = e.positions;
  25942. s && o.set(s, VertexBuffer.PositionKind);
  25943. var c = e.normals;
  25944. c && o.set(c, VertexBuffer.NormalKind);
  25945. var d = e.tangents;
  25946. d && o.set(d, VertexBuffer.TangentKind);
  25947. var _ = e.uvs;
  25948. _ && o.set(_, VertexBuffer.UVKind);
  25949. var b = e.uv2s;
  25950. b && o.set(b, VertexBuffer.UV2Kind);
  25951. var k = e.uv3s;
  25952. k && o.set(k, VertexBuffer.UV3Kind);
  25953. var j = e.uv4s;
  25954. j && o.set(j, VertexBuffer.UV4Kind);
  25955. var $ = e.uv5s;
  25956. $ && o.set($, VertexBuffer.UV5Kind);
  25957. var _e = e.uv6s;
  25958. _e && o.set(_e, VertexBuffer.UV6Kind);
  25959. var et = e.colors;
  25960. et && o.set(Color4.CheckColors4(et, s.length / 3), VertexBuffer.ColorKind);
  25961. var tt = e.matricesIndices;
  25962. tt && o.set(tt, VertexBuffer.MatricesIndicesKind);
  25963. var rt = e.matricesWeights;
  25964. rt && o.set(rt, VertexBuffer.MatricesWeightsKind);
  25965. var it = e.indices;
  25966. it && (o.indices = it),
  25967. i.setAllVerticesData(o, e.updatable)
  25968. }
  25969. ,
  25970. a.FRONTSIDE = 0,
  25971. a.BACKSIDE = 1,
  25972. a.DOUBLESIDE = 2,
  25973. a.DEFAULTSIDE = 0,
  25974. __decorate([nativeOverride.filter(function() {
  25975. for (var e = [], i = 0; i < arguments.length; i++)
  25976. e[i] = arguments[i];
  25977. var o = e[0];
  25978. return !Array.isArray(o)
  25979. })], a, "_TransformVector3Coordinates", null),
  25980. __decorate([nativeOverride.filter(function() {
  25981. for (var e = [], i = 0; i < arguments.length; i++)
  25982. e[i] = arguments[i];
  25983. var o = e[0];
  25984. return !Array.isArray(o)
  25985. })], a, "_TransformVector3Normals", null),
  25986. __decorate([nativeOverride.filter(function() {
  25987. for (var e = [], i = 0; i < arguments.length; i++)
  25988. e[i] = arguments[i];
  25989. var o = e[0];
  25990. return !Array.isArray(o)
  25991. })], a, "_TransformVector4Normals", null),
  25992. __decorate([nativeOverride.filter(function() {
  25993. for (var e = [], i = 0; i < arguments.length; i++)
  25994. e[i] = arguments[i];
  25995. var o = e[0];
  25996. return !Array.isArray(o)
  25997. })], a, "_FlipFaces", null),
  25998. a
  25999. }(), _InternalNodeDataInfo = function() {
  26000. function a() {
  26001. this._doNotSerialize = !1,
  26002. this._isDisposed = !1,
  26003. this._sceneRootNodesIndex = -1,
  26004. this._isEnabled = !0,
  26005. this._isParentEnabled = !0,
  26006. this._isReady = !0,
  26007. this._onEnabledStateChangedObservable = new Observable,
  26008. this._onClonedObservable = new Observable
  26009. }
  26010. return a
  26011. }(), Node$2 = function() {
  26012. function a(e, i) {
  26013. i === void 0 && (i = null),
  26014. this._isDirty = !1,
  26015. this._nodeDataStorage = new _InternalNodeDataInfo,
  26016. this.state = "",
  26017. this.metadata = null,
  26018. this.reservedDataStore = null,
  26019. this._parentContainer = null,
  26020. this.animations = new Array,
  26021. this._ranges = {},
  26022. this.onReady = null,
  26023. this._currentRenderId = -1,
  26024. this._parentUpdateId = -1,
  26025. this._childUpdateId = -1,
  26026. this._waitingParentId = null,
  26027. this._cache = {},
  26028. this._parentNode = null,
  26029. this._children = null,
  26030. this._worldMatrix = Matrix.Identity(),
  26031. this._worldMatrixDeterminant = 0,
  26032. this._worldMatrixDeterminantIsDirty = !0,
  26033. this._animationPropertiesOverride = null,
  26034. this._isNode = !0,
  26035. this.onDisposeObservable = new Observable,
  26036. this._onDisposeObserver = null,
  26037. this._behaviors = new Array,
  26038. this.name = e,
  26039. this.id = e,
  26040. this._scene = i || EngineStore.LastCreatedScene,
  26041. this.uniqueId = this._scene.getUniqueId(),
  26042. this._initCache()
  26043. }
  26044. return a.AddNodeConstructor = function(e, i) {
  26045. this._NodeConstructors[e] = i
  26046. }
  26047. ,
  26048. a.Construct = function(e, i, o, s) {
  26049. var c = this._NodeConstructors[e];
  26050. return c ? c(i, o, s) : null
  26051. }
  26052. ,
  26053. Object.defineProperty(a.prototype, "doNotSerialize", {
  26054. get: function() {
  26055. return this._nodeDataStorage._doNotSerialize ? !0 : this._parentNode ? this._parentNode.doNotSerialize : !1
  26056. },
  26057. set: function(e) {
  26058. this._nodeDataStorage._doNotSerialize = e
  26059. },
  26060. enumerable: !1,
  26061. configurable: !0
  26062. }),
  26063. a.prototype.isDisposed = function() {
  26064. return this._nodeDataStorage._isDisposed
  26065. }
  26066. ,
  26067. Object.defineProperty(a.prototype, "parent", {
  26068. get: function() {
  26069. return this._parentNode
  26070. },
  26071. set: function(e) {
  26072. if (this._parentNode !== e) {
  26073. var i = this._parentNode;
  26074. if (this._parentNode && this._parentNode._children !== void 0 && this._parentNode._children !== null) {
  26075. var o = this._parentNode._children.indexOf(this);
  26076. o !== -1 && this._parentNode._children.splice(o, 1),
  26077. !e && !this._nodeDataStorage._isDisposed && this._addToSceneRootNodes()
  26078. }
  26079. this._parentNode = e,
  26080. this._parentNode && ((this._parentNode._children === void 0 || this._parentNode._children === null) && (this._parentNode._children = new Array),
  26081. this._parentNode._children.push(this),
  26082. i || this._removeFromSceneRootNodes()),
  26083. this._syncParentEnabledState()
  26084. }
  26085. },
  26086. enumerable: !1,
  26087. configurable: !0
  26088. }),
  26089. a.prototype._addToSceneRootNodes = function() {
  26090. this._nodeDataStorage._sceneRootNodesIndex === -1 && (this._nodeDataStorage._sceneRootNodesIndex = this._scene.rootNodes.length,
  26091. this._scene.rootNodes.push(this))
  26092. }
  26093. ,
  26094. a.prototype._removeFromSceneRootNodes = function() {
  26095. if (this._nodeDataStorage._sceneRootNodesIndex !== -1) {
  26096. var e = this._scene.rootNodes
  26097. , i = e.length - 1;
  26098. e[this._nodeDataStorage._sceneRootNodesIndex] = e[i],
  26099. e[this._nodeDataStorage._sceneRootNodesIndex]._nodeDataStorage._sceneRootNodesIndex = this._nodeDataStorage._sceneRootNodesIndex,
  26100. this._scene.rootNodes.pop(),
  26101. this._nodeDataStorage._sceneRootNodesIndex = -1
  26102. }
  26103. }
  26104. ,
  26105. Object.defineProperty(a.prototype, "animationPropertiesOverride", {
  26106. get: function() {
  26107. return this._animationPropertiesOverride ? this._animationPropertiesOverride : this._scene.animationPropertiesOverride
  26108. },
  26109. set: function(e) {
  26110. this._animationPropertiesOverride = e
  26111. },
  26112. enumerable: !1,
  26113. configurable: !0
  26114. }),
  26115. a.prototype.getClassName = function() {
  26116. return "Node"
  26117. }
  26118. ,
  26119. Object.defineProperty(a.prototype, "onDispose", {
  26120. set: function(e) {
  26121. this._onDisposeObserver && this.onDisposeObservable.remove(this._onDisposeObserver),
  26122. this._onDisposeObserver = this.onDisposeObservable.add(e)
  26123. },
  26124. enumerable: !1,
  26125. configurable: !0
  26126. }),
  26127. Object.defineProperty(a.prototype, "onEnabledStateChangedObservable", {
  26128. get: function() {
  26129. return this._nodeDataStorage._onEnabledStateChangedObservable
  26130. },
  26131. enumerable: !1,
  26132. configurable: !0
  26133. }),
  26134. Object.defineProperty(a.prototype, "onClonedObservable", {
  26135. get: function() {
  26136. return this._nodeDataStorage._onClonedObservable
  26137. },
  26138. enumerable: !1,
  26139. configurable: !0
  26140. }),
  26141. a.prototype.getScene = function() {
  26142. return this._scene
  26143. }
  26144. ,
  26145. a.prototype.getEngine = function() {
  26146. return this._scene.getEngine()
  26147. }
  26148. ,
  26149. a.prototype.addBehavior = function(e, i) {
  26150. var o = this;
  26151. i === void 0 && (i = !1);
  26152. var s = this._behaviors.indexOf(e);
  26153. return s !== -1 ? this : (e.init(),
  26154. this._scene.isLoading && !i ? this._scene.onDataLoadedObservable.addOnce(function() {
  26155. e.attach(o)
  26156. }) : e.attach(this),
  26157. this._behaviors.push(e),
  26158. this)
  26159. }
  26160. ,
  26161. a.prototype.removeBehavior = function(e) {
  26162. var i = this._behaviors.indexOf(e);
  26163. return i === -1 ? this : (this._behaviors[i].detach(),
  26164. this._behaviors.splice(i, 1),
  26165. this)
  26166. }
  26167. ,
  26168. Object.defineProperty(a.prototype, "behaviors", {
  26169. get: function() {
  26170. return this._behaviors
  26171. },
  26172. enumerable: !1,
  26173. configurable: !0
  26174. }),
  26175. a.prototype.getBehaviorByName = function(e) {
  26176. for (var i = 0, o = this._behaviors; i < o.length; i++) {
  26177. var s = o[i];
  26178. if (s.name === e)
  26179. return s
  26180. }
  26181. return null
  26182. }
  26183. ,
  26184. a.prototype.getWorldMatrix = function() {
  26185. return this._currentRenderId !== this._scene.getRenderId() && this.computeWorldMatrix(),
  26186. this._worldMatrix
  26187. }
  26188. ,
  26189. a.prototype._getWorldMatrixDeterminant = function() {
  26190. return this._worldMatrixDeterminantIsDirty && (this._worldMatrixDeterminantIsDirty = !1,
  26191. this._worldMatrixDeterminant = this._worldMatrix.determinant()),
  26192. this._worldMatrixDeterminant
  26193. }
  26194. ,
  26195. Object.defineProperty(a.prototype, "worldMatrixFromCache", {
  26196. get: function() {
  26197. return this._worldMatrix
  26198. },
  26199. enumerable: !1,
  26200. configurable: !0
  26201. }),
  26202. a.prototype._initCache = function() {
  26203. this._cache = {},
  26204. this._cache.parent = void 0
  26205. }
  26206. ,
  26207. a.prototype.updateCache = function(e) {
  26208. !e && this.isSynchronized() || (this._cache.parent = this.parent,
  26209. this._updateCache())
  26210. }
  26211. ,
  26212. a.prototype._getActionManagerForTrigger = function(e, i) {
  26213. return this.parent ? this.parent._getActionManagerForTrigger(e, !1) : null
  26214. }
  26215. ,
  26216. a.prototype._updateCache = function(e) {}
  26217. ,
  26218. a.prototype._isSynchronized = function() {
  26219. return !0
  26220. }
  26221. ,
  26222. a.prototype._markSyncedWithParent = function() {
  26223. this._parentNode && (this._parentUpdateId = this._parentNode._childUpdateId)
  26224. }
  26225. ,
  26226. a.prototype.isSynchronizedWithParent = function() {
  26227. return this._parentNode ? this._parentUpdateId !== this._parentNode._childUpdateId ? !1 : this._parentNode.isSynchronized() : !0
  26228. }
  26229. ,
  26230. a.prototype.isSynchronized = function() {
  26231. return this._cache.parent != this._parentNode ? (this._cache.parent = this._parentNode,
  26232. !1) : this._parentNode && !this.isSynchronizedWithParent() ? !1 : this._isSynchronized()
  26233. }
  26234. ,
  26235. a.prototype.isReady = function(e) {
  26236. return this._nodeDataStorage._isReady
  26237. }
  26238. ,
  26239. a.prototype.markAsDirty = function(e) {
  26240. return this._currentRenderId = Number.MAX_VALUE,
  26241. this._isDirty = !0,
  26242. this
  26243. }
  26244. ,
  26245. a.prototype.isEnabled = function(e) {
  26246. return e === void 0 && (e = !0),
  26247. e === !1 ? this._nodeDataStorage._isEnabled : this._nodeDataStorage._isEnabled ? this._nodeDataStorage._isParentEnabled : !1
  26248. }
  26249. ,
  26250. a.prototype._syncParentEnabledState = function() {
  26251. this._nodeDataStorage._isParentEnabled = this._parentNode ? this._parentNode.isEnabled() : !0,
  26252. this._children && this._children.forEach(function(e) {
  26253. e._syncParentEnabledState()
  26254. })
  26255. }
  26256. ,
  26257. a.prototype.setEnabled = function(e) {
  26258. this._nodeDataStorage._isEnabled !== e && (this._nodeDataStorage._isEnabled = e,
  26259. this._nodeDataStorage._onEnabledStateChangedObservable.notifyObservers(e),
  26260. this._syncParentEnabledState())
  26261. }
  26262. ,
  26263. a.prototype.isDescendantOf = function(e) {
  26264. return this.parent ? this.parent === e ? !0 : this.parent.isDescendantOf(e) : !1
  26265. }
  26266. ,
  26267. a.prototype._getDescendants = function(e, i, o) {
  26268. if (i === void 0 && (i = !1),
  26269. !!this._children)
  26270. for (var s = 0; s < this._children.length; s++) {
  26271. var c = this._children[s];
  26272. (!o || o(c)) && e.push(c),
  26273. i || c._getDescendants(e, !1, o)
  26274. }
  26275. }
  26276. ,
  26277. a.prototype.getDescendants = function(e, i) {
  26278. var o = new Array;
  26279. return this._getDescendants(o, e, i),
  26280. o
  26281. }
  26282. ,
  26283. a.prototype.getChildMeshes = function(e, i) {
  26284. var o = [];
  26285. return this._getDescendants(o, e, function(s) {
  26286. return (!i || i(s)) && s.cullingStrategy !== void 0
  26287. }),
  26288. o
  26289. }
  26290. ,
  26291. a.prototype.getChildren = function(e, i) {
  26292. return i === void 0 && (i = !0),
  26293. this.getDescendants(i, e)
  26294. }
  26295. ,
  26296. a.prototype._setReady = function(e) {
  26297. if (e !== this._nodeDataStorage._isReady) {
  26298. if (!e) {
  26299. this._nodeDataStorage._isReady = !1;
  26300. return
  26301. }
  26302. this.onReady && this.onReady(this),
  26303. this._nodeDataStorage._isReady = !0
  26304. }
  26305. }
  26306. ,
  26307. a.prototype.getAnimationByName = function(e) {
  26308. for (var i = 0; i < this.animations.length; i++) {
  26309. var o = this.animations[i];
  26310. if (o.name === e)
  26311. return o
  26312. }
  26313. return null
  26314. }
  26315. ,
  26316. a.prototype.createAnimationRange = function(e, i, o) {
  26317. if (!this._ranges[e]) {
  26318. this._ranges[e] = a._AnimationRangeFactory(e, i, o);
  26319. for (var s = 0, c = this.animations.length; s < c; s++)
  26320. this.animations[s] && this.animations[s].createRange(e, i, o)
  26321. }
  26322. }
  26323. ,
  26324. a.prototype.deleteAnimationRange = function(e, i) {
  26325. i === void 0 && (i = !0);
  26326. for (var o = 0, s = this.animations.length; o < s; o++)
  26327. this.animations[o] && this.animations[o].deleteRange(e, i);
  26328. this._ranges[e] = null
  26329. }
  26330. ,
  26331. a.prototype.getAnimationRange = function(e) {
  26332. return this._ranges[e] || null
  26333. }
  26334. ,
  26335. a.prototype.getAnimationRanges = function() {
  26336. var e = [], i;
  26337. for (i in this._ranges)
  26338. e.push(this._ranges[i]);
  26339. return e
  26340. }
  26341. ,
  26342. a.prototype.beginAnimation = function(e, i, o, s) {
  26343. var c = this.getAnimationRange(e);
  26344. return c ? this._scene.beginAnimation(this, c.from, c.to, i, o, s) : null
  26345. }
  26346. ,
  26347. a.prototype.serializeAnimationRanges = function() {
  26348. var e = [];
  26349. for (var i in this._ranges) {
  26350. var o = this._ranges[i];
  26351. if (!!o) {
  26352. var s = {};
  26353. s.name = i,
  26354. s.from = o.from,
  26355. s.to = o.to,
  26356. e.push(s)
  26357. }
  26358. }
  26359. return e
  26360. }
  26361. ,
  26362. a.prototype.computeWorldMatrix = function(e) {
  26363. return this._worldMatrix || (this._worldMatrix = Matrix.Identity()),
  26364. this._worldMatrix
  26365. }
  26366. ,
  26367. a.prototype.dispose = function(e, i) {
  26368. if (i === void 0 && (i = !1),
  26369. this._nodeDataStorage._isDisposed = !0,
  26370. !e)
  26371. for (var o = this.getDescendants(!0), s = 0, c = o; s < c.length; s++) {
  26372. var d = c[s];
  26373. d.dispose(e, i)
  26374. }
  26375. this.parent ? this.parent = null : this._removeFromSceneRootNodes(),
  26376. this.onDisposeObservable.notifyObservers(this),
  26377. this.onDisposeObservable.clear(),
  26378. this.onEnabledStateChangedObservable.clear(),
  26379. this.onClonedObservable.clear();
  26380. for (var _ = 0, b = this._behaviors; _ < b.length; _++) {
  26381. var k = b[_];
  26382. k.detach()
  26383. }
  26384. this._behaviors = [],
  26385. this.metadata = null
  26386. }
  26387. ,
  26388. a.ParseAnimationRanges = function(e, i, o) {
  26389. if (i.ranges)
  26390. for (var s = 0; s < i.ranges.length; s++) {
  26391. var c = i.ranges[s];
  26392. e.createAnimationRange(c.name, c.from, c.to)
  26393. }
  26394. }
  26395. ,
  26396. a.prototype.getHierarchyBoundingVectors = function(e, i) {
  26397. e === void 0 && (e = !0),
  26398. i === void 0 && (i = null),
  26399. this.getScene().incrementRenderId(),
  26400. this.computeWorldMatrix(!0);
  26401. var o, s, c = this;
  26402. if (c.getBoundingInfo && c.subMeshes) {
  26403. var d = c.getBoundingInfo();
  26404. o = d.boundingBox.minimumWorld.clone(),
  26405. s = d.boundingBox.maximumWorld.clone()
  26406. } else
  26407. o = new Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),
  26408. s = new Vector3(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);
  26409. if (e)
  26410. for (var _ = this.getDescendants(!1), b = 0, k = _; b < k.length; b++) {
  26411. var j = k[b]
  26412. , $ = j;
  26413. if ($.computeWorldMatrix(!0),
  26414. !(i && !i($)) && !(!$.getBoundingInfo || $.getTotalVertices() === 0)) {
  26415. var _e = $.getBoundingInfo()
  26416. , et = _e.boundingBox
  26417. , tt = et.minimumWorld
  26418. , rt = et.maximumWorld;
  26419. Vector3.CheckExtends(tt, o, s),
  26420. Vector3.CheckExtends(rt, o, s)
  26421. }
  26422. }
  26423. return {
  26424. min: o,
  26425. max: s
  26426. }
  26427. }
  26428. ,
  26429. a._AnimationRangeFactory = function(e, i, o) {
  26430. throw _WarnImport("AnimationRange")
  26431. }
  26432. ,
  26433. a._NodeConstructors = {},
  26434. __decorate([serialize()], a.prototype, "name", void 0),
  26435. __decorate([serialize()], a.prototype, "id", void 0),
  26436. __decorate([serialize()], a.prototype, "uniqueId", void 0),
  26437. __decorate([serialize()], a.prototype, "state", void 0),
  26438. __decorate([serialize()], a.prototype, "metadata", void 0),
  26439. a
  26440. }(), Space;
  26441. (function(a) {
  26442. a[a.LOCAL = 0] = "LOCAL",
  26443. a[a.WORLD = 1] = "WORLD",
  26444. a[a.BONE = 2] = "BONE"
  26445. }
  26446. )(Space || (Space = {}));
  26447. var Axis = function() {
  26448. function a() {}
  26449. return a.X = new Vector3(1,0,0),
  26450. a.Y = new Vector3(0,1,0),
  26451. a.Z = new Vector3(0,0,1),
  26452. a
  26453. }(), Coordinate;
  26454. (function(a) {
  26455. a[a.X = 0] = "X",
  26456. a[a.Y = 1] = "Y",
  26457. a[a.Z = 2] = "Z"
  26458. }
  26459. )(Coordinate || (Coordinate = {}));
  26460. var TransformNode = function(a) {
  26461. __extends(e, a);
  26462. function e(i, o, s) {
  26463. o === void 0 && (o = null),
  26464. s === void 0 && (s = !0);
  26465. var c = a.call(this, i, o) || this;
  26466. return c._forward = new Vector3(0,0,1),
  26467. c._forwardInverted = new Vector3(0,0,-1),
  26468. c._up = new Vector3(0,1,0),
  26469. c._right = new Vector3(1,0,0),
  26470. c._rightInverted = new Vector3(-1,0,0),
  26471. c._position = Vector3.Zero(),
  26472. c._rotation = Vector3.Zero(),
  26473. c._rotationQuaternion = null,
  26474. c._scaling = Vector3.One(),
  26475. c._transformToBoneReferal = null,
  26476. c._isAbsoluteSynced = !1,
  26477. c._billboardMode = e.BILLBOARDMODE_NONE,
  26478. c._preserveParentRotationForBillboard = !1,
  26479. c.scalingDeterminant = 1,
  26480. c._infiniteDistance = !1,
  26481. c.ignoreNonUniformScaling = !1,
  26482. c.reIntegrateRotationIntoRotationQuaternion = !1,
  26483. c._poseMatrix = null,
  26484. c._localMatrix = Matrix.Zero(),
  26485. c._usePivotMatrix = !1,
  26486. c._absolutePosition = Vector3.Zero(),
  26487. c._absoluteScaling = Vector3.Zero(),
  26488. c._absoluteRotationQuaternion = Quaternion.Identity(),
  26489. c._pivotMatrix = Matrix.Identity(),
  26490. c._postMultiplyPivotMatrix = !1,
  26491. c._isWorldMatrixFrozen = !1,
  26492. c._indexInSceneTransformNodesArray = -1,
  26493. c.onAfterWorldMatrixUpdateObservable = new Observable,
  26494. c._nonUniformScaling = !1,
  26495. s && c.getScene().addTransformNode(c),
  26496. c
  26497. }
  26498. return Object.defineProperty(e.prototype, "billboardMode", {
  26499. get: function() {
  26500. return this._billboardMode
  26501. },
  26502. set: function(i) {
  26503. this._billboardMode !== i && (this._billboardMode = i)
  26504. },
  26505. enumerable: !1,
  26506. configurable: !0
  26507. }),
  26508. Object.defineProperty(e.prototype, "preserveParentRotationForBillboard", {
  26509. get: function() {
  26510. return this._preserveParentRotationForBillboard
  26511. },
  26512. set: function(i) {
  26513. i !== this._preserveParentRotationForBillboard && (this._preserveParentRotationForBillboard = i)
  26514. },
  26515. enumerable: !1,
  26516. configurable: !0
  26517. }),
  26518. Object.defineProperty(e.prototype, "infiniteDistance", {
  26519. get: function() {
  26520. return this._infiniteDistance
  26521. },
  26522. set: function(i) {
  26523. this._infiniteDistance !== i && (this._infiniteDistance = i)
  26524. },
  26525. enumerable: !1,
  26526. configurable: !0
  26527. }),
  26528. e.prototype.getClassName = function() {
  26529. return "TransformNode"
  26530. }
  26531. ,
  26532. Object.defineProperty(e.prototype, "position", {
  26533. get: function() {
  26534. return this._position
  26535. },
  26536. set: function(i) {
  26537. this._position = i,
  26538. this._isDirty = !0
  26539. },
  26540. enumerable: !1,
  26541. configurable: !0
  26542. }),
  26543. e.prototype.isUsingPivotMatrix = function() {
  26544. return this._usePivotMatrix
  26545. }
  26546. ,
  26547. Object.defineProperty(e.prototype, "rotation", {
  26548. get: function() {
  26549. return this._rotation
  26550. },
  26551. set: function(i) {
  26552. this._rotation = i,
  26553. this._rotationQuaternion = null,
  26554. this._isDirty = !0
  26555. },
  26556. enumerable: !1,
  26557. configurable: !0
  26558. }),
  26559. Object.defineProperty(e.prototype, "scaling", {
  26560. get: function() {
  26561. return this._scaling
  26562. },
  26563. set: function(i) {
  26564. this._scaling = i,
  26565. this._isDirty = !0
  26566. },
  26567. enumerable: !1,
  26568. configurable: !0
  26569. }),
  26570. Object.defineProperty(e.prototype, "rotationQuaternion", {
  26571. get: function() {
  26572. return this._rotationQuaternion
  26573. },
  26574. set: function(i) {
  26575. this._rotationQuaternion = i,
  26576. i && this._rotation.setAll(0),
  26577. this._isDirty = !0
  26578. },
  26579. enumerable: !1,
  26580. configurable: !0
  26581. }),
  26582. Object.defineProperty(e.prototype, "forward", {
  26583. get: function() {
  26584. return Vector3.Normalize(Vector3.TransformNormal(this.getScene().useRightHandedSystem ? this._forwardInverted : this._forward, this.getWorldMatrix()))
  26585. },
  26586. enumerable: !1,
  26587. configurable: !0
  26588. }),
  26589. Object.defineProperty(e.prototype, "up", {
  26590. get: function() {
  26591. return Vector3.Normalize(Vector3.TransformNormal(this._up, this.getWorldMatrix()))
  26592. },
  26593. enumerable: !1,
  26594. configurable: !0
  26595. }),
  26596. Object.defineProperty(e.prototype, "right", {
  26597. get: function() {
  26598. return Vector3.Normalize(Vector3.TransformNormal(this.getScene().useRightHandedSystem ? this._rightInverted : this._right, this.getWorldMatrix()))
  26599. },
  26600. enumerable: !1,
  26601. configurable: !0
  26602. }),
  26603. e.prototype.updatePoseMatrix = function(i) {
  26604. return this._poseMatrix ? (this._poseMatrix.copyFrom(i),
  26605. this) : (this._poseMatrix = i.clone(),
  26606. this)
  26607. }
  26608. ,
  26609. e.prototype.getPoseMatrix = function() {
  26610. return this._poseMatrix || (this._poseMatrix = Matrix.Identity()),
  26611. this._poseMatrix
  26612. }
  26613. ,
  26614. e.prototype._isSynchronized = function() {
  26615. var i = this._cache;
  26616. return !(this.billboardMode !== i.billboardMode || this.billboardMode !== e.BILLBOARDMODE_NONE || i.pivotMatrixUpdated || this.infiniteDistance || this.position._isDirty || this.scaling._isDirty || this._rotationQuaternion && this._rotationQuaternion._isDirty || this.rotation._isDirty)
  26617. }
  26618. ,
  26619. e.prototype._initCache = function() {
  26620. a.prototype._initCache.call(this);
  26621. var i = this._cache;
  26622. i.localMatrixUpdated = !1,
  26623. i.billboardMode = -1,
  26624. i.infiniteDistance = !1
  26625. }
  26626. ,
  26627. Object.defineProperty(e.prototype, "absolutePosition", {
  26628. get: function() {
  26629. return this.getAbsolutePosition()
  26630. },
  26631. enumerable: !1,
  26632. configurable: !0
  26633. }),
  26634. Object.defineProperty(e.prototype, "absoluteScaling", {
  26635. get: function() {
  26636. return this._syncAbsoluteScalingAndRotation(),
  26637. this._absoluteScaling
  26638. },
  26639. enumerable: !1,
  26640. configurable: !0
  26641. }),
  26642. Object.defineProperty(e.prototype, "absoluteRotationQuaternion", {
  26643. get: function() {
  26644. return this._syncAbsoluteScalingAndRotation(),
  26645. this._absoluteRotationQuaternion
  26646. },
  26647. enumerable: !1,
  26648. configurable: !0
  26649. }),
  26650. e.prototype.setPreTransformMatrix = function(i) {
  26651. return this.setPivotMatrix(i, !1)
  26652. }
  26653. ,
  26654. e.prototype.setPivotMatrix = function(i, o) {
  26655. return o === void 0 && (o = !0),
  26656. this._pivotMatrix.copyFrom(i),
  26657. this._usePivotMatrix = !this._pivotMatrix.isIdentity(),
  26658. this._cache.pivotMatrixUpdated = !0,
  26659. this._postMultiplyPivotMatrix = o,
  26660. this._postMultiplyPivotMatrix && (this._pivotMatrixInverse ? this._pivotMatrix.invertToRef(this._pivotMatrixInverse) : this._pivotMatrixInverse = Matrix.Invert(this._pivotMatrix)),
  26661. this
  26662. }
  26663. ,
  26664. e.prototype.getPivotMatrix = function() {
  26665. return this._pivotMatrix
  26666. }
  26667. ,
  26668. e.prototype.instantiateHierarchy = function(i, o, s) {
  26669. i === void 0 && (i = null);
  26670. var c = this.clone("Clone of " + (this.name || this.id), i || this.parent, !0);
  26671. c && s && s(this, c);
  26672. for (var d = 0, _ = this.getChildTransformNodes(!0); d < _.length; d++) {
  26673. var b = _[d];
  26674. b.instantiateHierarchy(c, o, s)
  26675. }
  26676. return c
  26677. }
  26678. ,
  26679. e.prototype.freezeWorldMatrix = function(i, o) {
  26680. return i === void 0 && (i = null),
  26681. o === void 0 && (o = !1),
  26682. i ? o ? (this._rotation.setAll(0),
  26683. this._rotationQuaternion = this._rotationQuaternion || Quaternion.Identity(),
  26684. i.decompose(this._scaling, this._rotationQuaternion, this._position),
  26685. this.computeWorldMatrix(!0)) : (this._worldMatrix = i,
  26686. this._absolutePosition.copyFromFloats(this._worldMatrix.m[12], this._worldMatrix.m[13], this._worldMatrix.m[14]),
  26687. this._afterComputeWorldMatrix()) : (this._isWorldMatrixFrozen = !1,
  26688. this.computeWorldMatrix(!0)),
  26689. this._isDirty = !1,
  26690. this._isWorldMatrixFrozen = !0,
  26691. this
  26692. }
  26693. ,
  26694. e.prototype.unfreezeWorldMatrix = function() {
  26695. return this._isWorldMatrixFrozen = !1,
  26696. this.computeWorldMatrix(!0),
  26697. this
  26698. }
  26699. ,
  26700. Object.defineProperty(e.prototype, "isWorldMatrixFrozen", {
  26701. get: function() {
  26702. return this._isWorldMatrixFrozen
  26703. },
  26704. enumerable: !1,
  26705. configurable: !0
  26706. }),
  26707. e.prototype.getAbsolutePosition = function() {
  26708. return this.computeWorldMatrix(),
  26709. this._absolutePosition
  26710. }
  26711. ,
  26712. e.prototype.setAbsolutePosition = function(i) {
  26713. if (!i)
  26714. return this;
  26715. var o, s, c;
  26716. if (i.x === void 0) {
  26717. if (arguments.length < 3)
  26718. return this;
  26719. o = arguments[0],
  26720. s = arguments[1],
  26721. c = arguments[2]
  26722. } else
  26723. o = i.x,
  26724. s = i.y,
  26725. c = i.z;
  26726. if (this.parent) {
  26727. var d = TmpVectors.Matrix[0];
  26728. this.parent.getWorldMatrix().invertToRef(d),
  26729. Vector3.TransformCoordinatesFromFloatsToRef(o, s, c, d, this.position)
  26730. } else
  26731. this.position.x = o,
  26732. this.position.y = s,
  26733. this.position.z = c;
  26734. return this._absolutePosition.copyFrom(i),
  26735. this
  26736. }
  26737. ,
  26738. e.prototype.setPositionWithLocalVector = function(i) {
  26739. return this.computeWorldMatrix(),
  26740. this.position = Vector3.TransformNormal(i, this._localMatrix),
  26741. this
  26742. }
  26743. ,
  26744. e.prototype.getPositionExpressedInLocalSpace = function() {
  26745. this.computeWorldMatrix();
  26746. var i = TmpVectors.Matrix[0];
  26747. return this._localMatrix.invertToRef(i),
  26748. Vector3.TransformNormal(this.position, i)
  26749. }
  26750. ,
  26751. e.prototype.locallyTranslate = function(i) {
  26752. return this.computeWorldMatrix(!0),
  26753. this.position = Vector3.TransformCoordinates(i, this._localMatrix),
  26754. this
  26755. }
  26756. ,
  26757. e.prototype.lookAt = function(i, o, s, c, d) {
  26758. o === void 0 && (o = 0),
  26759. s === void 0 && (s = 0),
  26760. c === void 0 && (c = 0),
  26761. d === void 0 && (d = Space.LOCAL);
  26762. var _ = e._lookAtVectorCache
  26763. , b = d === Space.LOCAL ? this.position : this.getAbsolutePosition();
  26764. if (i.subtractToRef(b, _),
  26765. this.setDirection(_, o, s, c),
  26766. d === Space.WORLD && this.parent)
  26767. if (this.rotationQuaternion) {
  26768. var k = TmpVectors.Matrix[0];
  26769. this.rotationQuaternion.toRotationMatrix(k);
  26770. var j = TmpVectors.Matrix[1];
  26771. this.parent.getWorldMatrix().getRotationMatrixToRef(j),
  26772. j.invert(),
  26773. k.multiplyToRef(j, k),
  26774. this.rotationQuaternion.fromRotationMatrix(k)
  26775. } else {
  26776. var $ = TmpVectors.Quaternion[0];
  26777. Quaternion.FromEulerVectorToRef(this.rotation, $);
  26778. var k = TmpVectors.Matrix[0];
  26779. $.toRotationMatrix(k);
  26780. var j = TmpVectors.Matrix[1];
  26781. this.parent.getWorldMatrix().getRotationMatrixToRef(j),
  26782. j.invert(),
  26783. k.multiplyToRef(j, k),
  26784. $.fromRotationMatrix(k),
  26785. $.toEulerAnglesToRef(this.rotation)
  26786. }
  26787. return this
  26788. }
  26789. ,
  26790. e.prototype.getDirection = function(i) {
  26791. var o = Vector3.Zero();
  26792. return this.getDirectionToRef(i, o),
  26793. o
  26794. }
  26795. ,
  26796. e.prototype.getDirectionToRef = function(i, o) {
  26797. return Vector3.TransformNormalToRef(i, this.getWorldMatrix(), o),
  26798. this
  26799. }
  26800. ,
  26801. e.prototype.setDirection = function(i, o, s, c) {
  26802. o === void 0 && (o = 0),
  26803. s === void 0 && (s = 0),
  26804. c === void 0 && (c = 0);
  26805. var d = -Math.atan2(i.z, i.x) + Math.PI / 2
  26806. , _ = Math.sqrt(i.x * i.x + i.z * i.z)
  26807. , b = -Math.atan2(i.y, _);
  26808. return this.rotationQuaternion ? Quaternion.RotationYawPitchRollToRef(d + o, b + s, c, this.rotationQuaternion) : (this.rotation.x = b + s,
  26809. this.rotation.y = d + o,
  26810. this.rotation.z = c),
  26811. this
  26812. }
  26813. ,
  26814. e.prototype.setPivotPoint = function(i, o) {
  26815. o === void 0 && (o = Space.LOCAL),
  26816. this.getScene().getRenderId() == 0 && this.computeWorldMatrix(!0);
  26817. var s = this.getWorldMatrix();
  26818. if (o == Space.WORLD) {
  26819. var c = TmpVectors.Matrix[0];
  26820. s.invertToRef(c),
  26821. i = Vector3.TransformCoordinates(i, c)
  26822. }
  26823. return this.setPivotMatrix(Matrix.Translation(-i.x, -i.y, -i.z), !0)
  26824. }
  26825. ,
  26826. e.prototype.getPivotPoint = function() {
  26827. var i = Vector3.Zero();
  26828. return this.getPivotPointToRef(i),
  26829. i
  26830. }
  26831. ,
  26832. e.prototype.getPivotPointToRef = function(i) {
  26833. return i.x = -this._pivotMatrix.m[12],
  26834. i.y = -this._pivotMatrix.m[13],
  26835. i.z = -this._pivotMatrix.m[14],
  26836. this
  26837. }
  26838. ,
  26839. e.prototype.getAbsolutePivotPoint = function() {
  26840. var i = Vector3.Zero();
  26841. return this.getAbsolutePivotPointToRef(i),
  26842. i
  26843. }
  26844. ,
  26845. e.prototype.getAbsolutePivotPointToRef = function(i) {
  26846. return this.getPivotPointToRef(i),
  26847. Vector3.TransformCoordinatesToRef(i, this.getWorldMatrix(), i),
  26848. this
  26849. }
  26850. ,
  26851. e.prototype.markAsDirty = function(i) {
  26852. if (this._children)
  26853. for (var o = 0, s = this._children; o < s.length; o++) {
  26854. var c = s[o];
  26855. c.markAsDirty(i)
  26856. }
  26857. return a.prototype.markAsDirty.call(this, i)
  26858. }
  26859. ,
  26860. e.prototype.setParent = function(i, o) {
  26861. if (o === void 0 && (o = !1),
  26862. !i && !this.parent)
  26863. return this;
  26864. var s = TmpVectors.Quaternion[0]
  26865. , c = TmpVectors.Vector3[0]
  26866. , d = TmpVectors.Vector3[1]
  26867. , _ = TmpVectors.Matrix[1];
  26868. Matrix.IdentityToRef(_);
  26869. var b = TmpVectors.Matrix[0];
  26870. this.computeWorldMatrix(!0);
  26871. var k = this.rotationQuaternion;
  26872. return k || (k = e._TmpRotation,
  26873. Quaternion.RotationYawPitchRollToRef(this._rotation.y, this._rotation.x, this._rotation.z, k)),
  26874. Matrix.ComposeToRef(this.scaling, k, this.position, b),
  26875. this.parent && b.multiplyToRef(this.parent.computeWorldMatrix(!0), b),
  26876. i && (i.computeWorldMatrix(!0).invertToRef(_),
  26877. b.multiplyToRef(_, b)),
  26878. b.decompose(d, s, c, o ? this : void 0),
  26879. this.rotationQuaternion ? this.rotationQuaternion.copyFrom(s) : s.toEulerAnglesToRef(this.rotation),
  26880. this.scaling.copyFrom(d),
  26881. this.position.copyFrom(c),
  26882. this.parent = i,
  26883. this
  26884. }
  26885. ,
  26886. Object.defineProperty(e.prototype, "nonUniformScaling", {
  26887. get: function() {
  26888. return this._nonUniformScaling
  26889. },
  26890. enumerable: !1,
  26891. configurable: !0
  26892. }),
  26893. e.prototype._updateNonUniformScalingState = function(i) {
  26894. return this._nonUniformScaling === i ? !1 : (this._nonUniformScaling = i,
  26895. !0)
  26896. }
  26897. ,
  26898. e.prototype.attachToBone = function(i, o) {
  26899. return this._currentParentWhenAttachingToBone = this.parent,
  26900. this._transformToBoneReferal = o,
  26901. this.parent = i,
  26902. i.getSkeleton().prepare(),
  26903. i.getWorldMatrix().determinant() < 0 && (this.scalingDeterminant *= -1),
  26904. this
  26905. }
  26906. ,
  26907. e.prototype.detachFromBone = function(i) {
  26908. return i === void 0 && (i = !1),
  26909. this.parent ? (this.parent.getWorldMatrix().determinant() < 0 && (this.scalingDeterminant *= -1),
  26910. this._transformToBoneReferal = null,
  26911. i ? this.parent = this._currentParentWhenAttachingToBone : this.parent = null,
  26912. this) : (i && (this.parent = this._currentParentWhenAttachingToBone),
  26913. this)
  26914. }
  26915. ,
  26916. e.prototype.rotate = function(i, o, s) {
  26917. i.normalize(),
  26918. this.rotationQuaternion || (this.rotationQuaternion = this.rotation.toQuaternion(),
  26919. this.rotation.setAll(0));
  26920. var c;
  26921. if (!s || s === Space.LOCAL)
  26922. c = Quaternion.RotationAxisToRef(i, o, e._rotationAxisCache),
  26923. this.rotationQuaternion.multiplyToRef(c, this.rotationQuaternion);
  26924. else {
  26925. if (this.parent) {
  26926. var d = TmpVectors.Matrix[0];
  26927. this.parent.getWorldMatrix().invertToRef(d),
  26928. i = Vector3.TransformNormal(i, d)
  26929. }
  26930. c = Quaternion.RotationAxisToRef(i, o, e._rotationAxisCache),
  26931. c.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion)
  26932. }
  26933. return this
  26934. }
  26935. ,
  26936. e.prototype.rotateAround = function(i, o, s) {
  26937. o.normalize(),
  26938. this.rotationQuaternion || (this.rotationQuaternion = Quaternion.RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z),
  26939. this.rotation.setAll(0));
  26940. var c = TmpVectors.Vector3[0]
  26941. , d = TmpVectors.Vector3[1]
  26942. , _ = TmpVectors.Vector3[2]
  26943. , b = TmpVectors.Quaternion[0]
  26944. , k = TmpVectors.Matrix[0]
  26945. , j = TmpVectors.Matrix[1]
  26946. , $ = TmpVectors.Matrix[2]
  26947. , _e = TmpVectors.Matrix[3];
  26948. return i.subtractToRef(this.position, c),
  26949. Matrix.TranslationToRef(c.x, c.y, c.z, k),
  26950. Matrix.TranslationToRef(-c.x, -c.y, -c.z, j),
  26951. Matrix.RotationAxisToRef(o, s, $),
  26952. j.multiplyToRef($, _e),
  26953. _e.multiplyToRef(k, _e),
  26954. _e.decompose(d, b, _),
  26955. this.position.addInPlace(_),
  26956. b.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion),
  26957. this
  26958. }
  26959. ,
  26960. e.prototype.translate = function(i, o, s) {
  26961. var c = i.scale(o);
  26962. if (!s || s === Space.LOCAL) {
  26963. var d = this.getPositionExpressedInLocalSpace().add(c);
  26964. this.setPositionWithLocalVector(d)
  26965. } else
  26966. this.setAbsolutePosition(this.getAbsolutePosition().add(c));
  26967. return this
  26968. }
  26969. ,
  26970. e.prototype.addRotation = function(i, o, s) {
  26971. var c;
  26972. this.rotationQuaternion ? c = this.rotationQuaternion : (c = TmpVectors.Quaternion[1],
  26973. Quaternion.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, c));
  26974. var d = TmpVectors.Quaternion[0];
  26975. return Quaternion.RotationYawPitchRollToRef(o, i, s, d),
  26976. c.multiplyInPlace(d),
  26977. this.rotationQuaternion || c.toEulerAnglesToRef(this.rotation),
  26978. this
  26979. }
  26980. ,
  26981. e.prototype._getEffectiveParent = function() {
  26982. return this.parent
  26983. }
  26984. ,
  26985. e.prototype.computeWorldMatrix = function(i) {
  26986. if (this._isWorldMatrixFrozen && !this._isDirty)
  26987. return this._worldMatrix;
  26988. var o = this.getScene().getRenderId();
  26989. if (!this._isDirty && !i && this.isSynchronized())
  26990. return this._currentRenderId = o,
  26991. this._worldMatrix;
  26992. var s = this.getScene().activeCamera
  26993. , c = (this._billboardMode & e.BILLBOARDMODE_USE_POSITION) !== 0
  26994. , d = this._billboardMode !== e.BILLBOARDMODE_NONE && !this.preserveParentRotationForBillboard;
  26995. d && s && c && (this.lookAt(s.position),
  26996. (this.billboardMode & e.BILLBOARDMODE_X) !== e.BILLBOARDMODE_X && (this.rotation.x = 0),
  26997. (this.billboardMode & e.BILLBOARDMODE_Y) !== e.BILLBOARDMODE_Y && (this.rotation.y = 0),
  26998. (this.billboardMode & e.BILLBOARDMODE_Z) !== e.BILLBOARDMODE_Z && (this.rotation.z = 0)),
  26999. this._updateCache();
  27000. var _ = this._cache;
  27001. _.pivotMatrixUpdated = !1,
  27002. _.billboardMode = this.billboardMode,
  27003. _.infiniteDistance = this.infiniteDistance,
  27004. this._currentRenderId = o,
  27005. this._childUpdateId += 1,
  27006. this._isDirty = !1,
  27007. this._position._isDirty = !1,
  27008. this._rotation._isDirty = !1,
  27009. this._scaling._isDirty = !1;
  27010. var b = this._getEffectiveParent()
  27011. , k = e._TmpScaling
  27012. , j = this._position;
  27013. if (this._infiniteDistance && !this.parent && s) {
  27014. var $ = s.getWorldMatrix()
  27015. , _e = new Vector3($.m[12],$.m[13],$.m[14]);
  27016. j = e._TmpTranslation,
  27017. j.copyFromFloats(this._position.x + _e.x, this._position.y + _e.y, this._position.z + _e.z)
  27018. }
  27019. k.copyFromFloats(this._scaling.x * this.scalingDeterminant, this._scaling.y * this.scalingDeterminant, this._scaling.z * this.scalingDeterminant);
  27020. var et;
  27021. if (this._rotationQuaternion) {
  27022. if (this._rotationQuaternion._isDirty = !1,
  27023. et = this._rotationQuaternion,
  27024. this.reIntegrateRotationIntoRotationQuaternion) {
  27025. var tt = this.rotation.lengthSquared();
  27026. tt && (this._rotationQuaternion.multiplyInPlace(Quaternion.RotationYawPitchRoll(this._rotation.y, this._rotation.x, this._rotation.z)),
  27027. this._rotation.copyFromFloats(0, 0, 0))
  27028. }
  27029. } else
  27030. et = e._TmpRotation,
  27031. Quaternion.RotationYawPitchRollToRef(this._rotation.y, this._rotation.x, this._rotation.z, et);
  27032. if (this._usePivotMatrix) {
  27033. var rt = TmpVectors.Matrix[1];
  27034. Matrix.ScalingToRef(k.x, k.y, k.z, rt);
  27035. var it = TmpVectors.Matrix[0];
  27036. et.toRotationMatrix(it),
  27037. this._pivotMatrix.multiplyToRef(rt, TmpVectors.Matrix[4]),
  27038. TmpVectors.Matrix[4].multiplyToRef(it, this._localMatrix),
  27039. this._postMultiplyPivotMatrix && this._localMatrix.multiplyToRef(this._pivotMatrixInverse, this._localMatrix),
  27040. this._localMatrix.addTranslationFromFloats(j.x, j.y, j.z)
  27041. } else
  27042. Matrix.ComposeToRef(k, et, j, this._localMatrix);
  27043. if (b && b.getWorldMatrix) {
  27044. if (i && b.computeWorldMatrix(i),
  27045. d) {
  27046. this._transformToBoneReferal ? b.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), TmpVectors.Matrix[7]) : TmpVectors.Matrix[7].copyFrom(b.getWorldMatrix());
  27047. var nt = TmpVectors.Vector3[5]
  27048. , ot = TmpVectors.Vector3[6];
  27049. TmpVectors.Matrix[7].decompose(ot, void 0, nt),
  27050. Matrix.ScalingToRef(ot.x, ot.y, ot.z, TmpVectors.Matrix[7]),
  27051. TmpVectors.Matrix[7].setTranslation(nt),
  27052. this._localMatrix.multiplyToRef(TmpVectors.Matrix[7], this._worldMatrix)
  27053. } else
  27054. this._transformToBoneReferal ? (this._localMatrix.multiplyToRef(b.getWorldMatrix(), TmpVectors.Matrix[6]),
  27055. TmpVectors.Matrix[6].multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), this._worldMatrix)) : this._localMatrix.multiplyToRef(b.getWorldMatrix(), this._worldMatrix);
  27056. this._markSyncedWithParent()
  27057. } else
  27058. this._worldMatrix.copyFrom(this._localMatrix);
  27059. if (d && s && this.billboardMode && !c) {
  27060. var at = TmpVectors.Vector3[0];
  27061. if (this._worldMatrix.getTranslationToRef(at),
  27062. TmpVectors.Matrix[1].copyFrom(s.getViewMatrix()),
  27063. TmpVectors.Matrix[1].setTranslationFromFloats(0, 0, 0),
  27064. TmpVectors.Matrix[1].invertToRef(TmpVectors.Matrix[0]),
  27065. (this.billboardMode & e.BILLBOARDMODE_ALL) !== e.BILLBOARDMODE_ALL) {
  27066. TmpVectors.Matrix[0].decompose(void 0, TmpVectors.Quaternion[0], void 0);
  27067. var st = TmpVectors.Vector3[1];
  27068. TmpVectors.Quaternion[0].toEulerAnglesToRef(st),
  27069. (this.billboardMode & e.BILLBOARDMODE_X) !== e.BILLBOARDMODE_X && (st.x = 0),
  27070. (this.billboardMode & e.BILLBOARDMODE_Y) !== e.BILLBOARDMODE_Y && (st.y = 0),
  27071. (this.billboardMode & e.BILLBOARDMODE_Z) !== e.BILLBOARDMODE_Z && (st.z = 0),
  27072. Matrix.RotationYawPitchRollToRef(st.y, st.x, st.z, TmpVectors.Matrix[0])
  27073. }
  27074. this._worldMatrix.setTranslationFromFloats(0, 0, 0),
  27075. this._worldMatrix.multiplyToRef(TmpVectors.Matrix[0], this._worldMatrix),
  27076. this._worldMatrix.setTranslation(TmpVectors.Vector3[0])
  27077. }
  27078. return this.ignoreNonUniformScaling ? this._updateNonUniformScalingState(!1) : this._scaling.isNonUniformWithinEpsilon(1e-6) ? this._updateNonUniformScalingState(!0) : b && b._nonUniformScaling ? this._updateNonUniformScalingState(b._nonUniformScaling) : this._updateNonUniformScalingState(!1),
  27079. this._afterComputeWorldMatrix(),
  27080. this._absolutePosition.copyFromFloats(this._worldMatrix.m[12], this._worldMatrix.m[13], this._worldMatrix.m[14]),
  27081. this._isAbsoluteSynced = !1,
  27082. this.onAfterWorldMatrixUpdateObservable.notifyObservers(this),
  27083. this._poseMatrix || (this._poseMatrix = Matrix.Invert(this._worldMatrix)),
  27084. this._worldMatrixDeterminantIsDirty = !0,
  27085. this._worldMatrix
  27086. }
  27087. ,
  27088. e.prototype.resetLocalMatrix = function(i) {
  27089. if (i === void 0 && (i = !0),
  27090. this.computeWorldMatrix(),
  27091. i)
  27092. for (var o = this.getChildren(), s = 0; s < o.length; ++s) {
  27093. var c = o[s];
  27094. if (c) {
  27095. c.computeWorldMatrix();
  27096. var d = TmpVectors.Matrix[0];
  27097. c._localMatrix.multiplyToRef(this._localMatrix, d);
  27098. var _ = TmpVectors.Quaternion[0];
  27099. d.decompose(c.scaling, _, c.position),
  27100. c.rotationQuaternion ? c.rotationQuaternion.copyFrom(_) : _.toEulerAnglesToRef(c.rotation)
  27101. }
  27102. }
  27103. this.scaling.copyFromFloats(1, 1, 1),
  27104. this.position.copyFromFloats(0, 0, 0),
  27105. this.rotation.copyFromFloats(0, 0, 0),
  27106. this.rotationQuaternion && (this.rotationQuaternion = Quaternion.Identity()),
  27107. this._worldMatrix = Matrix.Identity()
  27108. }
  27109. ,
  27110. e.prototype._afterComputeWorldMatrix = function() {}
  27111. ,
  27112. e.prototype.registerAfterWorldMatrixUpdate = function(i) {
  27113. return this.onAfterWorldMatrixUpdateObservable.add(i),
  27114. this
  27115. }
  27116. ,
  27117. e.prototype.unregisterAfterWorldMatrixUpdate = function(i) {
  27118. return this.onAfterWorldMatrixUpdateObservable.removeCallback(i),
  27119. this
  27120. }
  27121. ,
  27122. e.prototype.getPositionInCameraSpace = function(i) {
  27123. return i === void 0 && (i = null),
  27124. i || (i = this.getScene().activeCamera),
  27125. Vector3.TransformCoordinates(this.getAbsolutePosition(), i.getViewMatrix())
  27126. }
  27127. ,
  27128. e.prototype.getDistanceToCamera = function(i) {
  27129. return i === void 0 && (i = null),
  27130. i || (i = this.getScene().activeCamera),
  27131. this.getAbsolutePosition().subtract(i.globalPosition).length()
  27132. }
  27133. ,
  27134. e.prototype.clone = function(i, o, s) {
  27135. var c = this
  27136. , d = SerializationHelper.Clone(function() {
  27137. return new e(i,c.getScene())
  27138. }, this);
  27139. if (d.name = i,
  27140. d.id = i,
  27141. o && (d.parent = o),
  27142. !s)
  27143. for (var _ = this.getDescendants(!0), b = 0; b < _.length; b++) {
  27144. var k = _[b];
  27145. k.clone && k.clone(i + "." + k.name, d)
  27146. }
  27147. return d
  27148. }
  27149. ,
  27150. e.prototype.serialize = function(i) {
  27151. var o = SerializationHelper.Serialize(this, i);
  27152. return o.type = this.getClassName(),
  27153. o.uniqueId = this.uniqueId,
  27154. this.parent && (o.parentId = this.parent.uniqueId),
  27155. o.localMatrix = this.getPivotMatrix().asArray(),
  27156. o.isEnabled = this.isEnabled(),
  27157. this.parent && (o.parentId = this.parent.uniqueId),
  27158. o
  27159. }
  27160. ,
  27161. e.Parse = function(i, o, s) {
  27162. var c = SerializationHelper.Parse(function() {
  27163. return new e(i.name,o)
  27164. }, i, o, s);
  27165. return i.localMatrix ? c.setPreTransformMatrix(Matrix.FromArray(i.localMatrix)) : i.pivotMatrix && c.setPivotMatrix(Matrix.FromArray(i.pivotMatrix)),
  27166. c.setEnabled(i.isEnabled),
  27167. i.parentId && (c._waitingParentId = i.parentId),
  27168. c
  27169. }
  27170. ,
  27171. e.prototype.getChildTransformNodes = function(i, o) {
  27172. var s = [];
  27173. return this._getDescendants(s, i, function(c) {
  27174. return (!o || o(c)) && c instanceof e
  27175. }),
  27176. s
  27177. }
  27178. ,
  27179. e.prototype.dispose = function(i, o) {
  27180. if (o === void 0 && (o = !1),
  27181. this.getScene().stopAnimation(this),
  27182. this.getScene().removeTransformNode(this),
  27183. this._parentContainer) {
  27184. var s = this._parentContainer.transformNodes.indexOf(this);
  27185. s > -1 && this._parentContainer.transformNodes.splice(s, 1),
  27186. this._parentContainer = null
  27187. }
  27188. if (this.onAfterWorldMatrixUpdateObservable.clear(),
  27189. i)
  27190. for (var c = this.getChildTransformNodes(!0), d = 0, _ = c; d < _.length; d++) {
  27191. var b = _[d];
  27192. b.parent = null,
  27193. b.computeWorldMatrix(!0)
  27194. }
  27195. a.prototype.dispose.call(this, i, o)
  27196. }
  27197. ,
  27198. e.prototype.normalizeToUnitCube = function(i, o, s) {
  27199. i === void 0 && (i = !0),
  27200. o === void 0 && (o = !1);
  27201. var c = null
  27202. , d = null;
  27203. o && (this.rotationQuaternion ? (d = this.rotationQuaternion.clone(),
  27204. this.rotationQuaternion.copyFromFloats(0, 0, 0, 1)) : this.rotation && (c = this.rotation.clone(),
  27205. this.rotation.copyFromFloats(0, 0, 0)));
  27206. var _ = this.getHierarchyBoundingVectors(i, s)
  27207. , b = _.max.subtract(_.min)
  27208. , k = Math.max(b.x, b.y, b.z);
  27209. if (k === 0)
  27210. return this;
  27211. var j = 1 / k;
  27212. return this.scaling.scaleInPlace(j),
  27213. o && (this.rotationQuaternion && d ? this.rotationQuaternion.copyFrom(d) : this.rotation && c && this.rotation.copyFrom(c)),
  27214. this
  27215. }
  27216. ,
  27217. e.prototype._syncAbsoluteScalingAndRotation = function() {
  27218. this._isAbsoluteSynced || (this._worldMatrix.decompose(this._absoluteScaling, this._absoluteRotationQuaternion),
  27219. this._isAbsoluteSynced = !0)
  27220. }
  27221. ,
  27222. e.BILLBOARDMODE_NONE = 0,
  27223. e.BILLBOARDMODE_X = 1,
  27224. e.BILLBOARDMODE_Y = 2,
  27225. e.BILLBOARDMODE_Z = 4,
  27226. e.BILLBOARDMODE_ALL = 7,
  27227. e.BILLBOARDMODE_USE_POSITION = 128,
  27228. e._TmpRotation = Quaternion.Zero(),
  27229. e._TmpScaling = Vector3.Zero(),
  27230. e._TmpTranslation = Vector3.Zero(),
  27231. e._lookAtVectorCache = new Vector3(0,0,0),
  27232. e._rotationAxisCache = new Quaternion,
  27233. __decorate([serializeAsVector3("position")], e.prototype, "_position", void 0),
  27234. __decorate([serializeAsVector3("rotation")], e.prototype, "_rotation", void 0),
  27235. __decorate([serializeAsQuaternion("rotationQuaternion")], e.prototype, "_rotationQuaternion", void 0),
  27236. __decorate([serializeAsVector3("scaling")], e.prototype, "_scaling", void 0),
  27237. __decorate([serialize("billboardMode")], e.prototype, "_billboardMode", void 0),
  27238. __decorate([serialize()], e.prototype, "scalingDeterminant", void 0),
  27239. __decorate([serialize("infiniteDistance")], e.prototype, "_infiniteDistance", void 0),
  27240. __decorate([serialize()], e.prototype, "ignoreNonUniformScaling", void 0),
  27241. __decorate([serialize()], e.prototype, "reIntegrateRotationIntoRotationQuaternion", void 0),
  27242. e
  27243. }(Node$2)
  27244. , PickingInfo = function() {
  27245. function a() {
  27246. this._pickingUnavailable = !1,
  27247. this.hit = !1,
  27248. this.distance = 0,
  27249. this.pickedPoint = null,
  27250. this.pickedMesh = null,
  27251. this.bu = 0,
  27252. this.bv = 0,
  27253. this.faceId = -1,
  27254. this.subMeshFaceId = -1,
  27255. this.subMeshId = 0,
  27256. this.pickedSprite = null,
  27257. this.thinInstanceIndex = -1,
  27258. this.ray = null,
  27259. this.originMesh = null,
  27260. this.aimTransform = null,
  27261. this.gripTransform = null
  27262. }
  27263. return a.prototype.getNormal = function(e, i) {
  27264. if (e === void 0 && (e = !1),
  27265. i === void 0 && (i = !0),
  27266. !this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(VertexBuffer.NormalKind))
  27267. return null;
  27268. var o = this.pickedMesh.getIndices();
  27269. if (!o)
  27270. return null;
  27271. var s;
  27272. if (i) {
  27273. var c = this.pickedMesh.getVerticesData(VertexBuffer.NormalKind)
  27274. , d = Vector3.FromArray(c, o[this.faceId * 3] * 3)
  27275. , _ = Vector3.FromArray(c, o[this.faceId * 3 + 1] * 3)
  27276. , b = Vector3.FromArray(c, o[this.faceId * 3 + 2] * 3);
  27277. d = d.scale(this.bu),
  27278. _ = _.scale(this.bv),
  27279. b = b.scale(1 - this.bu - this.bv),
  27280. s = new Vector3(d.x + _.x + b.x,d.y + _.y + b.y,d.z + _.z + b.z)
  27281. } else {
  27282. var k = this.pickedMesh.getVerticesData(VertexBuffer.PositionKind)
  27283. , j = Vector3.FromArray(k, o[this.faceId * 3] * 3)
  27284. , $ = Vector3.FromArray(k, o[this.faceId * 3 + 1] * 3)
  27285. , _e = Vector3.FromArray(k, o[this.faceId * 3 + 2] * 3)
  27286. , et = j.subtract($)
  27287. , tt = _e.subtract($);
  27288. s = Vector3.Cross(et, tt)
  27289. }
  27290. if (e) {
  27291. var rt = this.pickedMesh.getWorldMatrix();
  27292. this.pickedMesh.nonUniformScaling && (TmpVectors.Matrix[0].copyFrom(rt),
  27293. rt = TmpVectors.Matrix[0],
  27294. rt.setTranslationFromFloats(0, 0, 0),
  27295. rt.invert(),
  27296. rt.transposeToRef(TmpVectors.Matrix[1]),
  27297. rt = TmpVectors.Matrix[1]),
  27298. s = Vector3.TransformNormal(s, rt)
  27299. }
  27300. return s.normalize(),
  27301. s
  27302. }
  27303. ,
  27304. a.prototype.getTextureCoordinates = function() {
  27305. if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(VertexBuffer.UVKind))
  27306. return null;
  27307. var e = this.pickedMesh.getIndices();
  27308. if (!e)
  27309. return null;
  27310. var i = this.pickedMesh.getVerticesData(VertexBuffer.UVKind);
  27311. if (!i)
  27312. return null;
  27313. var o = Vector2.FromArray(i, e[this.faceId * 3] * 2)
  27314. , s = Vector2.FromArray(i, e[this.faceId * 3 + 1] * 2)
  27315. , c = Vector2.FromArray(i, e[this.faceId * 3 + 2] * 2);
  27316. return o = o.scale(this.bu),
  27317. s = s.scale(this.bv),
  27318. c = c.scale(1 - this.bu - this.bv),
  27319. new Vector2(o.x + s.x + c.x,o.y + s.y + c.y)
  27320. }
  27321. ,
  27322. a
  27323. }()
  27324. , BoundingBox = function() {
  27325. function a(e, i, o) {
  27326. this.vectors = ArrayTools.BuildArray(8, Vector3.Zero),
  27327. this.center = Vector3.Zero(),
  27328. this.centerWorld = Vector3.Zero(),
  27329. this.extendSize = Vector3.Zero(),
  27330. this.extendSizeWorld = Vector3.Zero(),
  27331. this.directions = ArrayTools.BuildArray(3, Vector3.Zero),
  27332. this.vectorsWorld = ArrayTools.BuildArray(8, Vector3.Zero),
  27333. this.minimumWorld = Vector3.Zero(),
  27334. this.maximumWorld = Vector3.Zero(),
  27335. this.minimum = Vector3.Zero(),
  27336. this.maximum = Vector3.Zero(),
  27337. this._drawWrapperFront = null,
  27338. this._drawWrapperBack = null,
  27339. this.reConstruct(e, i, o)
  27340. }
  27341. return a.prototype.reConstruct = function(e, i, o) {
  27342. var s = e.x
  27343. , c = e.y
  27344. , d = e.z
  27345. , _ = i.x
  27346. , b = i.y
  27347. , k = i.z
  27348. , j = this.vectors;
  27349. this.minimum.copyFromFloats(s, c, d),
  27350. this.maximum.copyFromFloats(_, b, k),
  27351. j[0].copyFromFloats(s, c, d),
  27352. j[1].copyFromFloats(_, b, k),
  27353. j[2].copyFromFloats(_, c, d),
  27354. j[3].copyFromFloats(s, b, d),
  27355. j[4].copyFromFloats(s, c, k),
  27356. j[5].copyFromFloats(_, b, d),
  27357. j[6].copyFromFloats(s, b, k),
  27358. j[7].copyFromFloats(_, c, k),
  27359. i.addToRef(e, this.center).scaleInPlace(.5),
  27360. i.subtractToRef(e, this.extendSize).scaleInPlace(.5),
  27361. this._worldMatrix = o || Matrix.IdentityReadOnly,
  27362. this._update(this._worldMatrix)
  27363. }
  27364. ,
  27365. a.prototype.scale = function(e) {
  27366. var i = a.TmpVector3
  27367. , o = this.maximum.subtractToRef(this.minimum, i[0])
  27368. , s = o.length();
  27369. o.normalizeFromLength(s);
  27370. var c = s * e
  27371. , d = o.scaleInPlace(c * .5)
  27372. , _ = this.center.subtractToRef(d, i[1])
  27373. , b = this.center.addToRef(d, i[2]);
  27374. return this.reConstruct(_, b, this._worldMatrix),
  27375. this
  27376. }
  27377. ,
  27378. a.prototype.getWorldMatrix = function() {
  27379. return this._worldMatrix
  27380. }
  27381. ,
  27382. a.prototype._update = function(e) {
  27383. var i = this.minimumWorld
  27384. , o = this.maximumWorld
  27385. , s = this.directions
  27386. , c = this.vectorsWorld
  27387. , d = this.vectors;
  27388. if (e.isIdentity()) {
  27389. i.copyFrom(this.minimum),
  27390. o.copyFrom(this.maximum);
  27391. for (var _ = 0; _ < 8; ++_)
  27392. c[_].copyFrom(d[_]);
  27393. this.extendSizeWorld.copyFrom(this.extendSize),
  27394. this.centerWorld.copyFrom(this.center)
  27395. } else {
  27396. i.setAll(Number.MAX_VALUE),
  27397. o.setAll(-Number.MAX_VALUE);
  27398. for (var _ = 0; _ < 8; ++_) {
  27399. var b = c[_];
  27400. Vector3.TransformCoordinatesToRef(d[_], e, b),
  27401. i.minimizeInPlace(b),
  27402. o.maximizeInPlace(b)
  27403. }
  27404. o.subtractToRef(i, this.extendSizeWorld).scaleInPlace(.5),
  27405. o.addToRef(i, this.centerWorld).scaleInPlace(.5)
  27406. }
  27407. Vector3.FromArrayToRef(e.m, 0, s[0]),
  27408. Vector3.FromArrayToRef(e.m, 4, s[1]),
  27409. Vector3.FromArrayToRef(e.m, 8, s[2]),
  27410. this._worldMatrix = e
  27411. }
  27412. ,
  27413. a.prototype.isInFrustum = function(e) {
  27414. return a.IsInFrustum(this.vectorsWorld, e)
  27415. }
  27416. ,
  27417. a.prototype.isCompletelyInFrustum = function(e) {
  27418. return a.IsCompletelyInFrustum(this.vectorsWorld, e)
  27419. }
  27420. ,
  27421. a.prototype.intersectsPoint = function(e) {
  27422. var i = this.minimumWorld
  27423. , o = this.maximumWorld
  27424. , s = i.x
  27425. , c = i.y
  27426. , d = i.z
  27427. , _ = o.x
  27428. , b = o.y
  27429. , k = o.z
  27430. , j = e.x
  27431. , $ = e.y
  27432. , _e = e.z
  27433. , et = -Epsilon;
  27434. return !(_ - j < et || et > j - s || b - $ < et || et > $ - c || k - _e < et || et > _e - d)
  27435. }
  27436. ,
  27437. a.prototype.intersectsSphere = function(e) {
  27438. return a.IntersectsSphere(this.minimumWorld, this.maximumWorld, e.centerWorld, e.radiusWorld)
  27439. }
  27440. ,
  27441. a.prototype.intersectsMinMax = function(e, i) {
  27442. var o = this.minimumWorld
  27443. , s = this.maximumWorld
  27444. , c = o.x
  27445. , d = o.y
  27446. , _ = o.z
  27447. , b = s.x
  27448. , k = s.y
  27449. , j = s.z
  27450. , $ = e.x
  27451. , _e = e.y
  27452. , et = e.z
  27453. , tt = i.x
  27454. , rt = i.y
  27455. , it = i.z;
  27456. return !(b < $ || c > tt || k < _e || d > rt || j < et || _ > it)
  27457. }
  27458. ,
  27459. a.prototype.dispose = function() {
  27460. var e, i;
  27461. (e = this._drawWrapperFront) === null || e === void 0 || e.dispose(),
  27462. (i = this._drawWrapperBack) === null || i === void 0 || i.dispose()
  27463. }
  27464. ,
  27465. a.Intersects = function(e, i) {
  27466. return e.intersectsMinMax(i.minimumWorld, i.maximumWorld)
  27467. }
  27468. ,
  27469. a.IntersectsSphere = function(e, i, o, s) {
  27470. var c = a.TmpVector3[0];
  27471. Vector3.ClampToRef(o, e, i, c);
  27472. var d = Vector3.DistanceSquared(o, c);
  27473. return d <= s * s
  27474. }
  27475. ,
  27476. a.IsCompletelyInFrustum = function(e, i) {
  27477. for (var o = 0; o < 6; ++o)
  27478. for (var s = i[o], c = 0; c < 8; ++c)
  27479. if (s.dotCoordinate(e[c]) < 0)
  27480. return !1;
  27481. return !0
  27482. }
  27483. ,
  27484. a.IsInFrustum = function(e, i) {
  27485. for (var o = 0; o < 6; ++o) {
  27486. for (var s = !0, c = i[o], d = 0; d < 8; ++d)
  27487. if (c.dotCoordinate(e[d]) >= 0) {
  27488. s = !1;
  27489. break
  27490. }
  27491. if (s)
  27492. return !1
  27493. }
  27494. return !0
  27495. }
  27496. ,
  27497. a.TmpVector3 = ArrayTools.BuildArray(3, Vector3.Zero),
  27498. a
  27499. }()
  27500. , BoundingSphere = function() {
  27501. function a(e, i, o) {
  27502. this.center = Vector3.Zero(),
  27503. this.centerWorld = Vector3.Zero(),
  27504. this.minimum = Vector3.Zero(),
  27505. this.maximum = Vector3.Zero(),
  27506. this.reConstruct(e, i, o)
  27507. }
  27508. return a.prototype.reConstruct = function(e, i, o) {
  27509. this.minimum.copyFrom(e),
  27510. this.maximum.copyFrom(i);
  27511. var s = Vector3.Distance(e, i);
  27512. i.addToRef(e, this.center).scaleInPlace(.5),
  27513. this.radius = s * .5,
  27514. this._update(o || Matrix.IdentityReadOnly)
  27515. }
  27516. ,
  27517. a.prototype.scale = function(e) {
  27518. var i = this.radius * e
  27519. , o = a.TmpVector3
  27520. , s = o[0].setAll(i)
  27521. , c = this.center.subtractToRef(s, o[1])
  27522. , d = this.center.addToRef(s, o[2]);
  27523. return this.reConstruct(c, d, this._worldMatrix),
  27524. this
  27525. }
  27526. ,
  27527. a.prototype.getWorldMatrix = function() {
  27528. return this._worldMatrix
  27529. }
  27530. ,
  27531. a.prototype._update = function(e) {
  27532. if (e.isIdentity())
  27533. this.centerWorld.copyFrom(this.center),
  27534. this.radiusWorld = this.radius;
  27535. else {
  27536. Vector3.TransformCoordinatesToRef(this.center, e, this.centerWorld);
  27537. var i = a.TmpVector3[0];
  27538. Vector3.TransformNormalFromFloatsToRef(1, 1, 1, e, i),
  27539. this.radiusWorld = Math.max(Math.abs(i.x), Math.abs(i.y), Math.abs(i.z)) * this.radius
  27540. }
  27541. }
  27542. ,
  27543. a.prototype.isInFrustum = function(e) {
  27544. for (var i = this.centerWorld, o = this.radiusWorld, s = 0; s < 6; s++)
  27545. if (e[s].dotCoordinate(i) <= -o)
  27546. return !1;
  27547. return !0
  27548. }
  27549. ,
  27550. a.prototype.isCenterInFrustum = function(e) {
  27551. for (var i = this.centerWorld, o = 0; o < 6; o++)
  27552. if (e[o].dotCoordinate(i) < 0)
  27553. return !1;
  27554. return !0
  27555. }
  27556. ,
  27557. a.prototype.intersectsPoint = function(e) {
  27558. var i = Vector3.DistanceSquared(this.centerWorld, e);
  27559. return !(this.radiusWorld * this.radiusWorld < i)
  27560. }
  27561. ,
  27562. a.Intersects = function(e, i) {
  27563. var o = Vector3.DistanceSquared(e.centerWorld, i.centerWorld)
  27564. , s = e.radiusWorld + i.radiusWorld;
  27565. return !(s * s < o)
  27566. }
  27567. ,
  27568. a.CreateFromCenterAndRadius = function(e, i, o) {
  27569. this.TmpVector3[0].copyFrom(e),
  27570. this.TmpVector3[1].copyFromFloats(0, 0, i),
  27571. this.TmpVector3[2].copyFrom(e),
  27572. this.TmpVector3[0].addInPlace(this.TmpVector3[1]),
  27573. this.TmpVector3[2].subtractInPlace(this.TmpVector3[1]);
  27574. var s = new a(this.TmpVector3[0],this.TmpVector3[2]);
  27575. return o ? s._worldMatrix = o : s._worldMatrix = Matrix.Identity(),
  27576. s
  27577. }
  27578. ,
  27579. a.TmpVector3 = ArrayTools.BuildArray(3, Vector3.Zero),
  27580. a
  27581. }()
  27582. , _result0 = {
  27583. min: 0,
  27584. max: 0
  27585. }
  27586. , _result1 = {
  27587. min: 0,
  27588. max: 0
  27589. }
  27590. , computeBoxExtents = function(a, e, i) {
  27591. var o = Vector3.Dot(e.centerWorld, a)
  27592. , s = Math.abs(Vector3.Dot(e.directions[0], a)) * e.extendSize.x
  27593. , c = Math.abs(Vector3.Dot(e.directions[1], a)) * e.extendSize.y
  27594. , d = Math.abs(Vector3.Dot(e.directions[2], a)) * e.extendSize.z
  27595. , _ = s + c + d;
  27596. i.min = o - _,
  27597. i.max = o + _
  27598. }
  27599. , axisOverlap = function(a, e, i) {
  27600. return computeBoxExtents(a, e, _result0),
  27601. computeBoxExtents(a, i, _result1),
  27602. !(_result0.min > _result1.max || _result1.min > _result0.max)
  27603. }
  27604. , BoundingInfo = function() {
  27605. function a(e, i, o) {
  27606. this._isLocked = !1,
  27607. this.boundingBox = new BoundingBox(e,i,o),
  27608. this.boundingSphere = new BoundingSphere(e,i,o)
  27609. }
  27610. return a.prototype.reConstruct = function(e, i, o) {
  27611. this.boundingBox.reConstruct(e, i, o),
  27612. this.boundingSphere.reConstruct(e, i, o)
  27613. }
  27614. ,
  27615. Object.defineProperty(a.prototype, "minimum", {
  27616. get: function() {
  27617. return this.boundingBox.minimum
  27618. },
  27619. enumerable: !1,
  27620. configurable: !0
  27621. }),
  27622. Object.defineProperty(a.prototype, "maximum", {
  27623. get: function() {
  27624. return this.boundingBox.maximum
  27625. },
  27626. enumerable: !1,
  27627. configurable: !0
  27628. }),
  27629. Object.defineProperty(a.prototype, "isLocked", {
  27630. get: function() {
  27631. return this._isLocked
  27632. },
  27633. set: function(e) {
  27634. this._isLocked = e
  27635. },
  27636. enumerable: !1,
  27637. configurable: !0
  27638. }),
  27639. a.prototype.update = function(e) {
  27640. this._isLocked || (this.boundingBox._update(e),
  27641. this.boundingSphere._update(e))
  27642. }
  27643. ,
  27644. a.prototype.centerOn = function(e, i) {
  27645. var o = a.TmpVector3[0].copyFrom(e).subtractInPlace(i)
  27646. , s = a.TmpVector3[1].copyFrom(e).addInPlace(i);
  27647. return this.boundingBox.reConstruct(o, s, this.boundingBox.getWorldMatrix()),
  27648. this.boundingSphere.reConstruct(o, s, this.boundingBox.getWorldMatrix()),
  27649. this
  27650. }
  27651. ,
  27652. a.prototype.encapsulate = function(e) {
  27653. var i = Vector3.Minimize(this.minimum, e)
  27654. , o = Vector3.Maximize(this.maximum, e);
  27655. return this.reConstruct(i, o, this.boundingBox.getWorldMatrix()),
  27656. this
  27657. }
  27658. ,
  27659. a.prototype.encapsulateBoundingInfo = function(e) {
  27660. return this.encapsulate(e.boundingBox.centerWorld.subtract(e.boundingBox.extendSizeWorld)),
  27661. this.encapsulate(e.boundingBox.centerWorld.add(e.boundingBox.extendSizeWorld)),
  27662. this
  27663. }
  27664. ,
  27665. a.prototype.scale = function(e) {
  27666. return this.boundingBox.scale(e),
  27667. this.boundingSphere.scale(e),
  27668. this
  27669. }
  27670. ,
  27671. a.prototype.isInFrustum = function(e, i) {
  27672. i === void 0 && (i = 0);
  27673. var o = i === 2 || i === 3;
  27674. if (o && this.boundingSphere.isCenterInFrustum(e))
  27675. return !0;
  27676. if (!this.boundingSphere.isInFrustum(e))
  27677. return !1;
  27678. var s = i === 1 || i === 3;
  27679. return s ? !0 : this.boundingBox.isInFrustum(e)
  27680. }
  27681. ,
  27682. Object.defineProperty(a.prototype, "diagonalLength", {
  27683. get: function() {
  27684. var e = this.boundingBox
  27685. , i = e.maximumWorld.subtractToRef(e.minimumWorld, a.TmpVector3[0]);
  27686. return i.length()
  27687. },
  27688. enumerable: !1,
  27689. configurable: !0
  27690. }),
  27691. a.prototype.isCompletelyInFrustum = function(e) {
  27692. return this.boundingBox.isCompletelyInFrustum(e)
  27693. }
  27694. ,
  27695. a.prototype._checkCollision = function(e) {
  27696. return e._canDoCollision(this.boundingSphere.centerWorld, this.boundingSphere.radiusWorld, this.boundingBox.minimumWorld, this.boundingBox.maximumWorld)
  27697. }
  27698. ,
  27699. a.prototype.intersectsPoint = function(e) {
  27700. return !(!this.boundingSphere.centerWorld || !this.boundingSphere.intersectsPoint(e) || !this.boundingBox.intersectsPoint(e))
  27701. }
  27702. ,
  27703. a.prototype.intersects = function(e, i) {
  27704. if (!BoundingSphere.Intersects(this.boundingSphere, e.boundingSphere) || !BoundingBox.Intersects(this.boundingBox, e.boundingBox))
  27705. return !1;
  27706. if (!i)
  27707. return !0;
  27708. var o = this.boundingBox
  27709. , s = e.boundingBox;
  27710. return !(!axisOverlap(o.directions[0], o, s) || !axisOverlap(o.directions[1], o, s) || !axisOverlap(o.directions[2], o, s) || !axisOverlap(s.directions[0], o, s) || !axisOverlap(s.directions[1], o, s) || !axisOverlap(s.directions[2], o, s) || !axisOverlap(Vector3.Cross(o.directions[0], s.directions[0]), o, s) || !axisOverlap(Vector3.Cross(o.directions[0], s.directions[1]), o, s) || !axisOverlap(Vector3.Cross(o.directions[0], s.directions[2]), o, s) || !axisOverlap(Vector3.Cross(o.directions[1], s.directions[0]), o, s) || !axisOverlap(Vector3.Cross(o.directions[1], s.directions[1]), o, s) || !axisOverlap(Vector3.Cross(o.directions[1], s.directions[2]), o, s) || !axisOverlap(Vector3.Cross(o.directions[2], s.directions[0]), o, s) || !axisOverlap(Vector3.Cross(o.directions[2], s.directions[1]), o, s) || !axisOverlap(Vector3.Cross(o.directions[2], s.directions[2]), o, s))
  27711. }
  27712. ,
  27713. a.TmpVector3 = ArrayTools.BuildArray(2, Vector3.Zero),
  27714. a
  27715. }();
  27716. ThinEngine.prototype.createUniformBuffer = function(a) {
  27717. var e = this._gl.createBuffer();
  27718. if (!e)
  27719. throw new Error("Unable to create uniform buffer");
  27720. var i = new WebGLDataBuffer(e);
  27721. return this.bindUniformBuffer(i),
  27722. a instanceof Float32Array ? this._gl.bufferData(this._gl.UNIFORM_BUFFER, a, this._gl.STATIC_DRAW) : this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(a), this._gl.STATIC_DRAW),
  27723. this.bindUniformBuffer(null),
  27724. i.references = 1,
  27725. i
  27726. }
  27727. ;
  27728. ThinEngine.prototype.createDynamicUniformBuffer = function(a) {
  27729. var e = this._gl.createBuffer();
  27730. if (!e)
  27731. throw new Error("Unable to create dynamic uniform buffer");
  27732. var i = new WebGLDataBuffer(e);
  27733. return this.bindUniformBuffer(i),
  27734. a instanceof Float32Array ? this._gl.bufferData(this._gl.UNIFORM_BUFFER, a, this._gl.DYNAMIC_DRAW) : this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(a), this._gl.DYNAMIC_DRAW),
  27735. this.bindUniformBuffer(null),
  27736. i.references = 1,
  27737. i
  27738. }
  27739. ;
  27740. ThinEngine.prototype.updateUniformBuffer = function(a, e, i, o) {
  27741. this.bindUniformBuffer(a),
  27742. i === void 0 && (i = 0),
  27743. o === void 0 ? e instanceof Float32Array ? this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, i, e) : this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, i, new Float32Array(e)) : e instanceof Float32Array ? this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, e.subarray(i, i + o)) : this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, new Float32Array(e).subarray(i, i + o)),
  27744. this.bindUniformBuffer(null)
  27745. }
  27746. ;
  27747. ThinEngine.prototype.bindUniformBuffer = function(a) {
  27748. this._gl.bindBuffer(this._gl.UNIFORM_BUFFER, a ? a.underlyingResource : null)
  27749. }
  27750. ;
  27751. ThinEngine.prototype.bindUniformBufferBase = function(a, e, i) {
  27752. this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER, e, a ? a.underlyingResource : null)
  27753. }
  27754. ;
  27755. ThinEngine.prototype.bindUniformBlock = function(a, e, i) {
  27756. var o = a.program
  27757. , s = this._gl.getUniformBlockIndex(o, e);
  27758. this._gl.uniformBlockBinding(o, s, i)
  27759. }
  27760. ;
  27761. var UniformBuffer = function() {
  27762. function a(e, i, o, s) {
  27763. this._valueCache = {},
  27764. this._engine = e,
  27765. this._noUBO = !e.supportsUniformBuffers,
  27766. this._dynamic = o,
  27767. this._name = s != null ? s : "no-name",
  27768. this._data = i || [],
  27769. this._uniformLocations = {},
  27770. this._uniformSizes = {},
  27771. this._uniformArraySizes = {},
  27772. this._uniformLocationPointer = 0,
  27773. this._needSync = !1,
  27774. this._engine._features.trackUbosInFrame && (this._buffers = [],
  27775. this._bufferIndex = -1,
  27776. this._createBufferOnWrite = !1,
  27777. this._currentFrameId = 0),
  27778. this._noUBO ? (this.updateMatrix3x3 = this._updateMatrix3x3ForEffect,
  27779. this.updateMatrix2x2 = this._updateMatrix2x2ForEffect,
  27780. this.updateFloat = this._updateFloatForEffect,
  27781. this.updateFloat2 = this._updateFloat2ForEffect,
  27782. this.updateFloat3 = this._updateFloat3ForEffect,
  27783. this.updateFloat4 = this._updateFloat4ForEffect,
  27784. this.updateFloatArray = this._updateFloatArrayForEffect,
  27785. this.updateArray = this._updateArrayForEffect,
  27786. this.updateIntArray = this._updateIntArrayForEffect,
  27787. this.updateMatrix = this._updateMatrixForEffect,
  27788. this.updateMatrices = this._updateMatricesForEffect,
  27789. this.updateVector3 = this._updateVector3ForEffect,
  27790. this.updateVector4 = this._updateVector4ForEffect,
  27791. this.updateColor3 = this._updateColor3ForEffect,
  27792. this.updateColor4 = this._updateColor4ForEffect,
  27793. this.updateDirectColor4 = this._updateDirectColor4ForEffect,
  27794. this.updateInt = this._updateIntForEffect,
  27795. this.updateInt2 = this._updateInt2ForEffect,
  27796. this.updateInt3 = this._updateInt3ForEffect,
  27797. this.updateInt4 = this._updateInt4ForEffect) : (this._engine._uniformBuffers.push(this),
  27798. this.updateMatrix3x3 = this._updateMatrix3x3ForUniform,
  27799. this.updateMatrix2x2 = this._updateMatrix2x2ForUniform,
  27800. this.updateFloat = this._updateFloatForUniform,
  27801. this.updateFloat2 = this._updateFloat2ForUniform,
  27802. this.updateFloat3 = this._updateFloat3ForUniform,
  27803. this.updateFloat4 = this._updateFloat4ForUniform,
  27804. this.updateFloatArray = this._updateFloatArrayForUniform,
  27805. this.updateArray = this._updateArrayForUniform,
  27806. this.updateIntArray = this._updateIntArrayForUniform,
  27807. this.updateMatrix = this._updateMatrixForUniform,
  27808. this.updateMatrices = this._updateMatricesForUniform,
  27809. this.updateVector3 = this._updateVector3ForUniform,
  27810. this.updateVector4 = this._updateVector4ForUniform,
  27811. this.updateColor3 = this._updateColor3ForUniform,
  27812. this.updateColor4 = this._updateColor4ForUniform,
  27813. this.updateDirectColor4 = this._updateDirectColor4ForUniform,
  27814. this.updateInt = this._updateIntForUniform,
  27815. this.updateInt2 = this._updateInt2ForUniform,
  27816. this.updateInt3 = this._updateInt3ForUniform,
  27817. this.updateInt4 = this._updateInt4ForUniform)
  27818. }
  27819. return Object.defineProperty(a.prototype, "useUbo", {
  27820. get: function() {
  27821. return !this._noUBO
  27822. },
  27823. enumerable: !1,
  27824. configurable: !0
  27825. }),
  27826. Object.defineProperty(a.prototype, "isSync", {
  27827. get: function() {
  27828. return !this._needSync
  27829. },
  27830. enumerable: !1,
  27831. configurable: !0
  27832. }),
  27833. a.prototype.isDynamic = function() {
  27834. return this._dynamic !== void 0
  27835. }
  27836. ,
  27837. a.prototype.getData = function() {
  27838. return this._bufferData
  27839. }
  27840. ,
  27841. a.prototype.getBuffer = function() {
  27842. return this._buffer
  27843. }
  27844. ,
  27845. a.prototype._fillAlignment = function(e) {
  27846. var i;
  27847. if (e <= 2 ? i = e : i = 4,
  27848. this._uniformLocationPointer % i !== 0) {
  27849. var o = this._uniformLocationPointer;
  27850. this._uniformLocationPointer += i - this._uniformLocationPointer % i;
  27851. for (var s = this._uniformLocationPointer - o, c = 0; c < s; c++)
  27852. this._data.push(0)
  27853. }
  27854. }
  27855. ,
  27856. a.prototype.addUniform = function(e, i, o) {
  27857. if (o === void 0 && (o = 0),
  27858. !this._noUBO && this._uniformLocations[e] === void 0) {
  27859. var s;
  27860. if (o > 0) {
  27861. if (i instanceof Array)
  27862. throw "addUniform should not be use with Array in UBO: " + e;
  27863. if (this._fillAlignment(4),
  27864. this._uniformArraySizes[e] = {
  27865. strideSize: i,
  27866. arraySize: o
  27867. },
  27868. i == 16)
  27869. i = i * o;
  27870. else {
  27871. var c = 4 - i
  27872. , d = c * o;
  27873. i = i * o + d
  27874. }
  27875. s = [];
  27876. for (var _ = 0; _ < i; _++)
  27877. s.push(0)
  27878. } else {
  27879. if (i instanceof Array)
  27880. s = i,
  27881. i = s.length;
  27882. else {
  27883. i = i,
  27884. s = [];
  27885. for (var _ = 0; _ < i; _++)
  27886. s.push(0)
  27887. }
  27888. this._fillAlignment(i)
  27889. }
  27890. this._uniformSizes[e] = i,
  27891. this._uniformLocations[e] = this._uniformLocationPointer,
  27892. this._uniformLocationPointer += i;
  27893. for (var _ = 0; _ < i; _++)
  27894. this._data.push(s[_]);
  27895. this._needSync = !0
  27896. }
  27897. }
  27898. ,
  27899. a.prototype.addMatrix = function(e, i) {
  27900. this.addUniform(e, Array.prototype.slice.call(i.toArray()))
  27901. }
  27902. ,
  27903. a.prototype.addFloat2 = function(e, i, o) {
  27904. var s = [i, o];
  27905. this.addUniform(e, s)
  27906. }
  27907. ,
  27908. a.prototype.addFloat3 = function(e, i, o, s) {
  27909. var c = [i, o, s];
  27910. this.addUniform(e, c)
  27911. }
  27912. ,
  27913. a.prototype.addColor3 = function(e, i) {
  27914. var o = [i.r, i.g, i.b];
  27915. this.addUniform(e, o)
  27916. }
  27917. ,
  27918. a.prototype.addColor4 = function(e, i, o) {
  27919. var s = [i.r, i.g, i.b, o];
  27920. this.addUniform(e, s)
  27921. }
  27922. ,
  27923. a.prototype.addVector3 = function(e, i) {
  27924. var o = [i.x, i.y, i.z];
  27925. this.addUniform(e, o)
  27926. }
  27927. ,
  27928. a.prototype.addMatrix3x3 = function(e) {
  27929. this.addUniform(e, 12)
  27930. }
  27931. ,
  27932. a.prototype.addMatrix2x2 = function(e) {
  27933. this.addUniform(e, 8)
  27934. }
  27935. ,
  27936. a.prototype.create = function() {
  27937. this._noUBO || this._buffer || (this._fillAlignment(4),
  27938. this._bufferData = new Float32Array(this._data),
  27939. this._rebuild(),
  27940. this._needSync = !0)
  27941. }
  27942. ,
  27943. a.prototype._rebuild = function() {
  27944. this._noUBO || !this._bufferData || (this._dynamic ? this._buffer = this._engine.createDynamicUniformBuffer(this._bufferData) : this._buffer = this._engine.createUniformBuffer(this._bufferData),
  27945. this._engine._features.trackUbosInFrame && (this._buffers.push([this._buffer, this._engine._features.checkUbosContentBeforeUpload ? this._bufferData.slice() : void 0]),
  27946. this._bufferIndex = this._buffers.length - 1,
  27947. this._createBufferOnWrite = !1))
  27948. }
  27949. ,
  27950. Object.defineProperty(a.prototype, "_numBuffers", {
  27951. get: function() {
  27952. return this._buffers.length
  27953. },
  27954. enumerable: !1,
  27955. configurable: !0
  27956. }),
  27957. Object.defineProperty(a.prototype, "_indexBuffer", {
  27958. get: function() {
  27959. return this._bufferIndex
  27960. },
  27961. enumerable: !1,
  27962. configurable: !0
  27963. }),
  27964. Object.defineProperty(a.prototype, "name", {
  27965. get: function() {
  27966. return this._name
  27967. },
  27968. enumerable: !1,
  27969. configurable: !0
  27970. }),
  27971. a.prototype._buffersEqual = function(e, i) {
  27972. for (var o = 0; o < e.length; ++o)
  27973. if (e[o] !== i[o])
  27974. return !1;
  27975. return !0
  27976. }
  27977. ,
  27978. a.prototype._copyBuffer = function(e, i) {
  27979. for (var o = 0; o < e.length; ++o)
  27980. i[o] = e[o]
  27981. }
  27982. ,
  27983. a.prototype.update = function() {
  27984. if (this.bindUniformBuffer(),
  27985. !this._buffer) {
  27986. this.create();
  27987. return
  27988. }
  27989. if (!this._dynamic && !this._needSync) {
  27990. this._createBufferOnWrite = this._engine._features.trackUbosInFrame;
  27991. return
  27992. }
  27993. if (this._buffers && this._buffers.length > 1 && this._buffers[this._bufferIndex][1])
  27994. if (this._buffersEqual(this._bufferData, this._buffers[this._bufferIndex][1])) {
  27995. this._needSync = !1,
  27996. this._createBufferOnWrite = this._engine._features.trackUbosInFrame;
  27997. return
  27998. } else
  27999. this._copyBuffer(this._bufferData, this._buffers[this._bufferIndex][1]);
  28000. this._engine.updateUniformBuffer(this._buffer, this._bufferData),
  28001. this._engine._features._collectUbosUpdatedInFrame && (a._updatedUbosInFrame[this._name] || (a._updatedUbosInFrame[this._name] = 0),
  28002. a._updatedUbosInFrame[this._name]++),
  28003. this._needSync = !1,
  28004. this._createBufferOnWrite = this._engine._features.trackUbosInFrame
  28005. }
  28006. ,
  28007. a.prototype._createNewBuffer = function() {
  28008. this._bufferIndex + 1 < this._buffers.length ? (this._bufferIndex++,
  28009. this._buffer = this._buffers[this._bufferIndex][0],
  28010. this._createBufferOnWrite = !1,
  28011. this._needSync = !0) : this._rebuild()
  28012. }
  28013. ,
  28014. a.prototype._checkNewFrame = function() {
  28015. this._engine._features.trackUbosInFrame && this._currentFrameId !== this._engine.frameId && (this._currentFrameId = this._engine.frameId,
  28016. this._createBufferOnWrite = !1,
  28017. this._buffers && this._buffers.length > 0 ? (this._needSync = this._bufferIndex !== 0,
  28018. this._bufferIndex = 0,
  28019. this._buffer = this._buffers[this._bufferIndex][0]) : this._bufferIndex = -1)
  28020. }
  28021. ,
  28022. a.prototype.updateUniform = function(e, i, o) {
  28023. this._checkNewFrame();
  28024. var s = this._uniformLocations[e];
  28025. if (s === void 0) {
  28026. if (this._buffer) {
  28027. Logger$2.Error("Cannot add an uniform after UBO has been created.");
  28028. return
  28029. }
  28030. this.addUniform(e, o),
  28031. s = this._uniformLocations[e]
  28032. }
  28033. if (this._buffer || this.create(),
  28034. this._dynamic)
  28035. for (var d = 0; d < o; d++)
  28036. this._bufferData[s + d] = i[d];
  28037. else {
  28038. for (var c = !1, d = 0; d < o; d++)
  28039. (o === 16 && !this._engine._features.uniformBufferHardCheckMatrix || this._bufferData[s + d] !== Tools.FloatRound(i[d])) && (c = !0,
  28040. this._createBufferOnWrite && this._createNewBuffer(),
  28041. this._bufferData[s + d] = i[d]);
  28042. this._needSync = this._needSync || c
  28043. }
  28044. }
  28045. ,
  28046. a.prototype.updateUniformArray = function(e, i, o) {
  28047. this._checkNewFrame();
  28048. var s = this._uniformLocations[e];
  28049. if (s === void 0) {
  28050. Logger$2.Error("Cannot add an uniform Array dynamically. Please, add it using addUniform.");
  28051. return
  28052. }
  28053. this._buffer || this.create();
  28054. var c = this._uniformArraySizes[e];
  28055. if (this._dynamic)
  28056. for (var k = 0; k < o; k++)
  28057. this._bufferData[s + k] = i[k];
  28058. else {
  28059. for (var d = !1, _ = 0, b = 0, k = 0; k < o; k++)
  28060. if (this._bufferData[s + b * 4 + _] !== Tools.FloatRound(i[k]) && (d = !0,
  28061. this._createBufferOnWrite && this._createNewBuffer(),
  28062. this._bufferData[s + b * 4 + _] = i[k]),
  28063. _++,
  28064. _ === c.strideSize) {
  28065. for (; _ < 4; _++)
  28066. this._bufferData[s + b * 4 + _] = 0;
  28067. _ = 0,
  28068. b++
  28069. }
  28070. this._needSync = this._needSync || d
  28071. }
  28072. }
  28073. ,
  28074. a.prototype._cacheMatrix = function(e, i) {
  28075. this._checkNewFrame();
  28076. var o = this._valueCache[e]
  28077. , s = i.updateFlag;
  28078. return o !== void 0 && o === s ? !1 : (this._valueCache[e] = s,
  28079. !0)
  28080. }
  28081. ,
  28082. a.prototype._updateMatrix3x3ForUniform = function(e, i) {
  28083. for (var o = 0; o < 3; o++)
  28084. a._tempBuffer[o * 4] = i[o * 3],
  28085. a._tempBuffer[o * 4 + 1] = i[o * 3 + 1],
  28086. a._tempBuffer[o * 4 + 2] = i[o * 3 + 2],
  28087. a._tempBuffer[o * 4 + 3] = 0;
  28088. this.updateUniform(e, a._tempBuffer, 12)
  28089. }
  28090. ,
  28091. a.prototype._updateMatrix3x3ForEffect = function(e, i) {
  28092. this._currentEffect.setMatrix3x3(e, i)
  28093. }
  28094. ,
  28095. a.prototype._updateMatrix2x2ForEffect = function(e, i) {
  28096. this._currentEffect.setMatrix2x2(e, i)
  28097. }
  28098. ,
  28099. a.prototype._updateMatrix2x2ForUniform = function(e, i) {
  28100. for (var o = 0; o < 2; o++)
  28101. a._tempBuffer[o * 4] = i[o * 2],
  28102. a._tempBuffer[o * 4 + 1] = i[o * 2 + 1],
  28103. a._tempBuffer[o * 4 + 2] = 0,
  28104. a._tempBuffer[o * 4 + 3] = 0;
  28105. this.updateUniform(e, a._tempBuffer, 8)
  28106. }
  28107. ,
  28108. a.prototype._updateFloatForEffect = function(e, i) {
  28109. this._currentEffect.setFloat(e, i)
  28110. }
  28111. ,
  28112. a.prototype._updateFloatForUniform = function(e, i) {
  28113. a._tempBuffer[0] = i,
  28114. this.updateUniform(e, a._tempBuffer, 1)
  28115. }
  28116. ,
  28117. a.prototype._updateFloat2ForEffect = function(e, i, o, s) {
  28118. s === void 0 && (s = ""),
  28119. this._currentEffect.setFloat2(e + s, i, o)
  28120. }
  28121. ,
  28122. a.prototype._updateFloat2ForUniform = function(e, i, o) {
  28123. a._tempBuffer[0] = i,
  28124. a._tempBuffer[1] = o,
  28125. this.updateUniform(e, a._tempBuffer, 2)
  28126. }
  28127. ,
  28128. a.prototype._updateFloat3ForEffect = function(e, i, o, s, c) {
  28129. c === void 0 && (c = ""),
  28130. this._currentEffect.setFloat3(e + c, i, o, s)
  28131. }
  28132. ,
  28133. a.prototype._updateFloat3ForUniform = function(e, i, o, s) {
  28134. a._tempBuffer[0] = i,
  28135. a._tempBuffer[1] = o,
  28136. a._tempBuffer[2] = s,
  28137. this.updateUniform(e, a._tempBuffer, 3)
  28138. }
  28139. ,
  28140. a.prototype._updateFloat4ForEffect = function(e, i, o, s, c, d) {
  28141. d === void 0 && (d = ""),
  28142. this._currentEffect.setFloat4(e + d, i, o, s, c)
  28143. }
  28144. ,
  28145. a.prototype._updateFloat4ForUniform = function(e, i, o, s, c) {
  28146. a._tempBuffer[0] = i,
  28147. a._tempBuffer[1] = o,
  28148. a._tempBuffer[2] = s,
  28149. a._tempBuffer[3] = c,
  28150. this.updateUniform(e, a._tempBuffer, 4)
  28151. }
  28152. ,
  28153. a.prototype._updateFloatArrayForEffect = function(e, i) {
  28154. this._currentEffect.setFloatArray(e, i)
  28155. }
  28156. ,
  28157. a.prototype._updateFloatArrayForUniform = function(e, i) {
  28158. this.updateUniformArray(e, i, i.length)
  28159. }
  28160. ,
  28161. a.prototype._updateArrayForEffect = function(e, i) {
  28162. this._currentEffect.setArray(e, i)
  28163. }
  28164. ,
  28165. a.prototype._updateArrayForUniform = function(e, i) {
  28166. this.updateUniformArray(e, i, i.length)
  28167. }
  28168. ,
  28169. a.prototype._updateIntArrayForEffect = function(e, i) {
  28170. this._currentEffect.setIntArray(e, i)
  28171. }
  28172. ,
  28173. a.prototype._updateIntArrayForUniform = function(e, i) {
  28174. a._tempBufferInt32View.set(i),
  28175. this.updateUniformArray(e, a._tempBuffer, i.length)
  28176. }
  28177. ,
  28178. a.prototype._updateMatrixForEffect = function(e, i) {
  28179. this._currentEffect.setMatrix(e, i)
  28180. }
  28181. ,
  28182. a.prototype._updateMatrixForUniform = function(e, i) {
  28183. this._cacheMatrix(e, i) && this.updateUniform(e, i.toArray(), 16)
  28184. }
  28185. ,
  28186. a.prototype._updateMatricesForEffect = function(e, i) {
  28187. this._currentEffect.setMatrices(e, i)
  28188. }
  28189. ,
  28190. a.prototype._updateMatricesForUniform = function(e, i) {
  28191. this.updateUniform(e, i, i.length)
  28192. }
  28193. ,
  28194. a.prototype._updateVector3ForEffect = function(e, i) {
  28195. this._currentEffect.setVector3(e, i)
  28196. }
  28197. ,
  28198. a.prototype._updateVector3ForUniform = function(e, i) {
  28199. a._tempBuffer[0] = i.x,
  28200. a._tempBuffer[1] = i.y,
  28201. a._tempBuffer[2] = i.z,
  28202. this.updateUniform(e, a._tempBuffer, 3)
  28203. }
  28204. ,
  28205. a.prototype._updateVector4ForEffect = function(e, i) {
  28206. this._currentEffect.setVector4(e, i)
  28207. }
  28208. ,
  28209. a.prototype._updateVector4ForUniform = function(e, i) {
  28210. a._tempBuffer[0] = i.x,
  28211. a._tempBuffer[1] = i.y,
  28212. a._tempBuffer[2] = i.z,
  28213. a._tempBuffer[3] = i.w,
  28214. this.updateUniform(e, a._tempBuffer, 4)
  28215. }
  28216. ,
  28217. a.prototype._updateColor3ForEffect = function(e, i, o) {
  28218. o === void 0 && (o = ""),
  28219. this._currentEffect.setColor3(e + o, i)
  28220. }
  28221. ,
  28222. a.prototype._updateColor3ForUniform = function(e, i) {
  28223. a._tempBuffer[0] = i.r,
  28224. a._tempBuffer[1] = i.g,
  28225. a._tempBuffer[2] = i.b,
  28226. this.updateUniform(e, a._tempBuffer, 3)
  28227. }
  28228. ,
  28229. a.prototype._updateColor4ForEffect = function(e, i, o, s) {
  28230. s === void 0 && (s = ""),
  28231. this._currentEffect.setColor4(e + s, i, o)
  28232. }
  28233. ,
  28234. a.prototype._updateDirectColor4ForEffect = function(e, i, o) {
  28235. o === void 0 && (o = ""),
  28236. this._currentEffect.setDirectColor4(e + o, i)
  28237. }
  28238. ,
  28239. a.prototype._updateColor4ForUniform = function(e, i, o) {
  28240. a._tempBuffer[0] = i.r,
  28241. a._tempBuffer[1] = i.g,
  28242. a._tempBuffer[2] = i.b,
  28243. a._tempBuffer[3] = o,
  28244. this.updateUniform(e, a._tempBuffer, 4)
  28245. }
  28246. ,
  28247. a.prototype._updateDirectColor4ForUniform = function(e, i) {
  28248. a._tempBuffer[0] = i.r,
  28249. a._tempBuffer[1] = i.g,
  28250. a._tempBuffer[2] = i.b,
  28251. a._tempBuffer[3] = i.a,
  28252. this.updateUniform(e, a._tempBuffer, 4)
  28253. }
  28254. ,
  28255. a.prototype._updateIntForEffect = function(e, i, o) {
  28256. o === void 0 && (o = ""),
  28257. this._currentEffect.setInt(e + o, i)
  28258. }
  28259. ,
  28260. a.prototype._updateIntForUniform = function(e, i) {
  28261. a._tempBufferInt32View[0] = i,
  28262. this.updateUniform(e, a._tempBuffer, 1)
  28263. }
  28264. ,
  28265. a.prototype._updateInt2ForEffect = function(e, i, o, s) {
  28266. s === void 0 && (s = ""),
  28267. this._currentEffect.setInt2(e + s, i, o)
  28268. }
  28269. ,
  28270. a.prototype._updateInt2ForUniform = function(e, i, o) {
  28271. a._tempBufferInt32View[0] = i,
  28272. a._tempBufferInt32View[1] = o,
  28273. this.updateUniform(e, a._tempBuffer, 2)
  28274. }
  28275. ,
  28276. a.prototype._updateInt3ForEffect = function(e, i, o, s, c) {
  28277. c === void 0 && (c = ""),
  28278. this._currentEffect.setInt3(e + c, i, o, s)
  28279. }
  28280. ,
  28281. a.prototype._updateInt3ForUniform = function(e, i, o, s) {
  28282. a._tempBufferInt32View[0] = i,
  28283. a._tempBufferInt32View[1] = o,
  28284. a._tempBufferInt32View[2] = s,
  28285. this.updateUniform(e, a._tempBuffer, 3)
  28286. }
  28287. ,
  28288. a.prototype._updateInt4ForEffect = function(e, i, o, s, c, d) {
  28289. d === void 0 && (d = ""),
  28290. this._currentEffect.setInt4(e + d, i, o, s, c)
  28291. }
  28292. ,
  28293. a.prototype._updateInt4ForUniform = function(e, i, o, s, c) {
  28294. a._tempBufferInt32View[0] = i,
  28295. a._tempBufferInt32View[1] = o,
  28296. a._tempBufferInt32View[2] = s,
  28297. a._tempBufferInt32View[3] = c,
  28298. this.updateUniform(e, a._tempBuffer, 4)
  28299. }
  28300. ,
  28301. a.prototype.setTexture = function(e, i) {
  28302. this._currentEffect.setTexture(e, i)
  28303. }
  28304. ,
  28305. a.prototype.updateUniformDirectly = function(e, i) {
  28306. this.updateUniform(e, i, i.length),
  28307. this.update()
  28308. }
  28309. ,
  28310. a.prototype.bindToEffect = function(e, i) {
  28311. this._currentEffect = e,
  28312. this._currentEffectName = i
  28313. }
  28314. ,
  28315. a.prototype.bindUniformBuffer = function() {
  28316. !this._noUBO && this._buffer && this._currentEffect && this._currentEffect.bindUniformBuffer(this._buffer, this._currentEffectName)
  28317. }
  28318. ,
  28319. a.prototype.unbindEffect = function() {
  28320. this._currentEffect = void 0,
  28321. this._currentEffectName = void 0
  28322. }
  28323. ,
  28324. a.prototype.dispose = function() {
  28325. if (!this._noUBO) {
  28326. var e = this._engine._uniformBuffers
  28327. , i = e.indexOf(this);
  28328. if (i !== -1 && (e[i] = e[e.length - 1],
  28329. e.pop()),
  28330. this._engine._features.trackUbosInFrame && this._buffers)
  28331. for (var o = 0; o < this._buffers.length; ++o) {
  28332. var s = this._buffers[o][0];
  28333. this._engine._releaseBuffer(s)
  28334. }
  28335. else
  28336. this._buffer && this._engine._releaseBuffer(this._buffer) && (this._buffer = null)
  28337. }
  28338. }
  28339. ,
  28340. a._updatedUbosInFrame = {},
  28341. a._MAX_UNIFORM_SIZE = 256,
  28342. a._tempBuffer = new Float32Array(a._MAX_UNIFORM_SIZE),
  28343. a._tempBufferInt32View = new Uint32Array(a._tempBuffer.buffer),
  28344. a
  28345. }()
  28346. , _MeshCollisionData = function() {
  28347. function a() {
  28348. this._checkCollisions = !1,
  28349. this._collisionMask = -1,
  28350. this._collisionGroup = -1,
  28351. this._surroundingMeshes = null,
  28352. this._collider = null,
  28353. this._oldPositionForCollisions = new Vector3(0,0,0),
  28354. this._diffPositionForCollisions = new Vector3(0,0,0),
  28355. this._collisionResponse = !0
  28356. }
  28357. return a
  28358. }()
  28359. , MathHelpers = function() {
  28360. function a() {}
  28361. return a.extractMinAndMaxIndexed = function(e, i, o, s, c, d) {
  28362. for (var _ = o; _ < o + s; _++) {
  28363. var b = i[_] * 3
  28364. , k = e[b]
  28365. , j = e[b + 1]
  28366. , $ = e[b + 2];
  28367. c.minimizeInPlaceFromFloats(k, j, $),
  28368. d.maximizeInPlaceFromFloats(k, j, $)
  28369. }
  28370. }
  28371. ,
  28372. a.extractMinAndMax = function(e, i, o, s, c, d) {
  28373. for (var _ = i, b = i * s; _ < i + o; _++,
  28374. b += s) {
  28375. var k = e[b]
  28376. , j = e[b + 1]
  28377. , $ = e[b + 2];
  28378. c.minimizeInPlaceFromFloats(k, j, $),
  28379. d.maximizeInPlaceFromFloats(k, j, $)
  28380. }
  28381. }
  28382. ,
  28383. __decorate([nativeOverride.filter(function() {
  28384. for (var e = [], i = 0; i < arguments.length; i++)
  28385. e[i] = arguments[i];
  28386. var o = e[0]
  28387. , s = e[1];
  28388. return !Array.isArray(o) && !Array.isArray(s)
  28389. })], a, "extractMinAndMaxIndexed", null),
  28390. __decorate([nativeOverride.filter(function() {
  28391. for (var e = [], i = 0; i < arguments.length; i++)
  28392. e[i] = arguments[i];
  28393. var o = e[0];
  28394. return !Array.isArray(o)
  28395. })], a, "extractMinAndMax", null),
  28396. a
  28397. }();
  28398. function extractMinAndMaxIndexed(a, e, i, o, s) {
  28399. s === void 0 && (s = null);
  28400. var c = new Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)
  28401. , d = new Vector3(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);
  28402. return MathHelpers.extractMinAndMaxIndexed(a, e, i, o, c, d),
  28403. s && (c.x -= c.x * s.x + s.y,
  28404. c.y -= c.y * s.x + s.y,
  28405. c.z -= c.z * s.x + s.y,
  28406. d.x += d.x * s.x + s.y,
  28407. d.y += d.y * s.x + s.y,
  28408. d.z += d.z * s.x + s.y),
  28409. {
  28410. minimum: c,
  28411. maximum: d
  28412. }
  28413. }
  28414. function extractMinAndMax(a, e, i, o, s) {
  28415. o === void 0 && (o = null);
  28416. var c = new Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)
  28417. , d = new Vector3(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);
  28418. return s || (s = 3),
  28419. MathHelpers.extractMinAndMax(a, e, i, s, c, d),
  28420. o && (c.x -= c.x * o.x + o.y,
  28421. c.y -= c.y * o.x + o.y,
  28422. c.z -= c.z * o.x + o.y,
  28423. d.x += d.x * o.x + o.y,
  28424. d.y += d.y * o.x + o.y,
  28425. d.z += d.z * o.x + o.y),
  28426. {
  28427. minimum: c,
  28428. maximum: d
  28429. }
  28430. }
  28431. var _FacetDataStorage = function() {
  28432. function a() {
  28433. this.facetNb = 0,
  28434. this.partitioningSubdivisions = 10,
  28435. this.partitioningBBoxRatio = 1.01,
  28436. this.facetDataEnabled = !1,
  28437. this.facetParameters = {},
  28438. this.bbSize = Vector3.Zero(),
  28439. this.subDiv = {
  28440. max: 1,
  28441. X: 1,
  28442. Y: 1,
  28443. Z: 1
  28444. },
  28445. this.facetDepthSort = !1,
  28446. this.facetDepthSortEnabled = !1
  28447. }
  28448. return a
  28449. }()
  28450. , _InternalAbstractMeshDataInfo = function() {
  28451. function a() {
  28452. this._hasVertexAlpha = !1,
  28453. this._useVertexColors = !0,
  28454. this._numBoneInfluencers = 4,
  28455. this._applyFog = !0,
  28456. this._receiveShadows = !1,
  28457. this._facetData = new _FacetDataStorage,
  28458. this._visibility = 1,
  28459. this._skeleton = null,
  28460. this._layerMask = 268435455,
  28461. this._computeBonesUsingShaders = !0,
  28462. this._isActive = !1,
  28463. this._onlyForInstances = !1,
  28464. this._isActiveIntermediate = !1,
  28465. this._onlyForInstancesIntermediate = !1,
  28466. this._actAsRegularMesh = !1,
  28467. this._currentLOD = null,
  28468. this._currentLODIsUpToDate = !1,
  28469. this._collisionRetryCount = 3,
  28470. this._morphTargetManager = null,
  28471. this._renderingGroupId = 0,
  28472. this._bakedVertexAnimationManager = null,
  28473. this._material = null,
  28474. this._positions = null,
  28475. this._meshCollisionData = new _MeshCollisionData
  28476. }
  28477. return a
  28478. }()
  28479. , AbstractMesh = function(a) {
  28480. __extends(e, a);
  28481. function e(i, o) {
  28482. o === void 0 && (o = null);
  28483. var s = a.call(this, i, o, !1) || this;
  28484. return s._internalAbstractMeshDataInfo = new _InternalAbstractMeshDataInfo,
  28485. s.cullingStrategy = e.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY,
  28486. s.onCollideObservable = new Observable,
  28487. s.onCollisionPositionChangeObservable = new Observable,
  28488. s.onMaterialChangedObservable = new Observable,
  28489. s.definedFacingForward = !0,
  28490. s._occlusionQuery = null,
  28491. s._renderingGroup = null,
  28492. s.alphaIndex = Number.MAX_VALUE,
  28493. s.isVisible = !0,
  28494. s.isPickable = !0,
  28495. s.isNearPickable = !1,
  28496. s.isNearGrabbable = !1,
  28497. s.showSubMeshesBoundingBox = !1,
  28498. s.isBlocker = !1,
  28499. s.enablePointerMoveEvents = !1,
  28500. s.outlineColor = Color3.Red(),
  28501. s.outlineWidth = .02,
  28502. s.overlayColor = Color3.Red(),
  28503. s.overlayAlpha = .5,
  28504. s.useOctreeForRenderingSelection = !0,
  28505. s.useOctreeForPicking = !0,
  28506. s.useOctreeForCollisions = !0,
  28507. s.alwaysSelectAsActiveMesh = !1,
  28508. s.doNotSyncBoundingInfo = !1,
  28509. s.actionManager = null,
  28510. s.ellipsoid = new Vector3(.5,1,.5),
  28511. s.ellipsoidOffset = new Vector3(0,0,0),
  28512. s.edgesWidth = 1,
  28513. s.edgesColor = new Color4(1,0,0,1),
  28514. s._edgesRenderer = null,
  28515. s._masterMesh = null,
  28516. s._boundingInfo = null,
  28517. s._boundingInfoIsDirty = !0,
  28518. s._renderId = 0,
  28519. s._intersectionsInProgress = new Array,
  28520. s._unIndexed = !1,
  28521. s._lightSources = new Array,
  28522. s._waitingData = {
  28523. lods: null,
  28524. actions: null,
  28525. freezeWorldMatrix: null
  28526. },
  28527. s._bonesTransformMatrices = null,
  28528. s._transformMatrixTexture = null,
  28529. s.onRebuildObservable = new Observable,
  28530. s._onCollisionPositionChange = function(c, d, _) {
  28531. _ === void 0 && (_ = null),
  28532. d.subtractToRef(s._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions, s._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions),
  28533. s._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions.length() > Engine.CollisionsEpsilon && s.position.addInPlace(s._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions),
  28534. _ && s.onCollideObservable.notifyObservers(_),
  28535. s.onCollisionPositionChangeObservable.notifyObservers(s.position)
  28536. }
  28537. ,
  28538. s.getScene().addMesh(s),
  28539. s._resyncLightSources(),
  28540. s._uniformBuffer = new UniformBuffer(s.getScene().getEngine(),void 0,void 0,i),
  28541. s._buildUniformLayout(),
  28542. s
  28543. }
  28544. return Object.defineProperty(e, "BILLBOARDMODE_NONE", {
  28545. get: function() {
  28546. return TransformNode.BILLBOARDMODE_NONE
  28547. },
  28548. enumerable: !1,
  28549. configurable: !0
  28550. }),
  28551. Object.defineProperty(e, "BILLBOARDMODE_X", {
  28552. get: function() {
  28553. return TransformNode.BILLBOARDMODE_X
  28554. },
  28555. enumerable: !1,
  28556. configurable: !0
  28557. }),
  28558. Object.defineProperty(e, "BILLBOARDMODE_Y", {
  28559. get: function() {
  28560. return TransformNode.BILLBOARDMODE_Y
  28561. },
  28562. enumerable: !1,
  28563. configurable: !0
  28564. }),
  28565. Object.defineProperty(e, "BILLBOARDMODE_Z", {
  28566. get: function() {
  28567. return TransformNode.BILLBOARDMODE_Z
  28568. },
  28569. enumerable: !1,
  28570. configurable: !0
  28571. }),
  28572. Object.defineProperty(e, "BILLBOARDMODE_ALL", {
  28573. get: function() {
  28574. return TransformNode.BILLBOARDMODE_ALL
  28575. },
  28576. enumerable: !1,
  28577. configurable: !0
  28578. }),
  28579. Object.defineProperty(e, "BILLBOARDMODE_USE_POSITION", {
  28580. get: function() {
  28581. return TransformNode.BILLBOARDMODE_USE_POSITION
  28582. },
  28583. enumerable: !1,
  28584. configurable: !0
  28585. }),
  28586. Object.defineProperty(e.prototype, "facetNb", {
  28587. get: function() {
  28588. return this._internalAbstractMeshDataInfo._facetData.facetNb
  28589. },
  28590. enumerable: !1,
  28591. configurable: !0
  28592. }),
  28593. Object.defineProperty(e.prototype, "partitioningSubdivisions", {
  28594. get: function() {
  28595. return this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions
  28596. },
  28597. set: function(i) {
  28598. this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions = i
  28599. },
  28600. enumerable: !1,
  28601. configurable: !0
  28602. }),
  28603. Object.defineProperty(e.prototype, "partitioningBBoxRatio", {
  28604. get: function() {
  28605. return this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio
  28606. },
  28607. set: function(i) {
  28608. this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio = i
  28609. },
  28610. enumerable: !1,
  28611. configurable: !0
  28612. }),
  28613. Object.defineProperty(e.prototype, "mustDepthSortFacets", {
  28614. get: function() {
  28615. return this._internalAbstractMeshDataInfo._facetData.facetDepthSort
  28616. },
  28617. set: function(i) {
  28618. this._internalAbstractMeshDataInfo._facetData.facetDepthSort = i
  28619. },
  28620. enumerable: !1,
  28621. configurable: !0
  28622. }),
  28623. Object.defineProperty(e.prototype, "facetDepthSortFrom", {
  28624. get: function() {
  28625. return this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom
  28626. },
  28627. set: function(i) {
  28628. this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom = i
  28629. },
  28630. enumerable: !1,
  28631. configurable: !0
  28632. }),
  28633. Object.defineProperty(e.prototype, "collisionRetryCount", {
  28634. get: function() {
  28635. return this._internalAbstractMeshDataInfo._collisionRetryCount
  28636. },
  28637. set: function(i) {
  28638. this._internalAbstractMeshDataInfo._collisionRetryCount = i
  28639. },
  28640. enumerable: !1,
  28641. configurable: !0
  28642. }),
  28643. Object.defineProperty(e.prototype, "isFacetDataEnabled", {
  28644. get: function() {
  28645. return this._internalAbstractMeshDataInfo._facetData.facetDataEnabled
  28646. },
  28647. enumerable: !1,
  28648. configurable: !0
  28649. }),
  28650. Object.defineProperty(e.prototype, "morphTargetManager", {
  28651. get: function() {
  28652. return this._internalAbstractMeshDataInfo._morphTargetManager
  28653. },
  28654. set: function(i) {
  28655. this._internalAbstractMeshDataInfo._morphTargetManager !== i && (this._internalAbstractMeshDataInfo._morphTargetManager = i,
  28656. this._syncGeometryWithMorphTargetManager())
  28657. },
  28658. enumerable: !1,
  28659. configurable: !0
  28660. }),
  28661. Object.defineProperty(e.prototype, "bakedVertexAnimationManager", {
  28662. get: function() {
  28663. return this._internalAbstractMeshDataInfo._bakedVertexAnimationManager
  28664. },
  28665. set: function(i) {
  28666. this._internalAbstractMeshDataInfo._bakedVertexAnimationManager !== i && (this._internalAbstractMeshDataInfo._bakedVertexAnimationManager = i,
  28667. this._markSubMeshesAsAttributesDirty())
  28668. },
  28669. enumerable: !1,
  28670. configurable: !0
  28671. }),
  28672. e.prototype._syncGeometryWithMorphTargetManager = function() {}
  28673. ,
  28674. e.prototype._updateNonUniformScalingState = function(i) {
  28675. return a.prototype._updateNonUniformScalingState.call(this, i) ? (this._markSubMeshesAsMiscDirty(),
  28676. !0) : !1
  28677. }
  28678. ,
  28679. Object.defineProperty(e.prototype, "onCollide", {
  28680. set: function(i) {
  28681. this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver && this.onCollideObservable.remove(this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver),
  28682. this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver = this.onCollideObservable.add(i)
  28683. },
  28684. enumerable: !1,
  28685. configurable: !0
  28686. }),
  28687. Object.defineProperty(e.prototype, "onCollisionPositionChange", {
  28688. set: function(i) {
  28689. this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver && this.onCollisionPositionChangeObservable.remove(this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver),
  28690. this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver = this.onCollisionPositionChangeObservable.add(i)
  28691. },
  28692. enumerable: !1,
  28693. configurable: !0
  28694. }),
  28695. Object.defineProperty(e.prototype, "visibility", {
  28696. get: function() {
  28697. return this._internalAbstractMeshDataInfo._visibility
  28698. },
  28699. set: function(i) {
  28700. if (this._internalAbstractMeshDataInfo._visibility !== i) {
  28701. var o = this._internalAbstractMeshDataInfo._visibility;
  28702. this._internalAbstractMeshDataInfo._visibility = i,
  28703. (o === 1 && i !== 1 || o !== 1 && i === 1) && this._markSubMeshesAsMiscDirty()
  28704. }
  28705. },
  28706. enumerable: !1,
  28707. configurable: !0
  28708. }),
  28709. Object.defineProperty(e.prototype, "renderingGroupId", {
  28710. get: function() {
  28711. return this._internalAbstractMeshDataInfo._renderingGroupId
  28712. },
  28713. set: function(i) {
  28714. this._internalAbstractMeshDataInfo._renderingGroupId = i
  28715. },
  28716. enumerable: !1,
  28717. configurable: !0
  28718. }),
  28719. Object.defineProperty(e.prototype, "material", {
  28720. get: function() {
  28721. return this._internalAbstractMeshDataInfo._material
  28722. },
  28723. set: function(i) {
  28724. this._internalAbstractMeshDataInfo._material !== i && (this._internalAbstractMeshDataInfo._material && this._internalAbstractMeshDataInfo._material.meshMap && (this._internalAbstractMeshDataInfo._material.meshMap[this.uniqueId] = void 0),
  28725. this._internalAbstractMeshDataInfo._material = i,
  28726. i && i.meshMap && (i.meshMap[this.uniqueId] = this),
  28727. this.onMaterialChangedObservable.hasObservers() && this.onMaterialChangedObservable.notifyObservers(this),
  28728. this.subMeshes && (this.resetDrawCache(),
  28729. this._unBindEffect()))
  28730. },
  28731. enumerable: !1,
  28732. configurable: !0
  28733. }),
  28734. e.prototype.getMaterialForRenderPass = function(i) {
  28735. var o;
  28736. return (o = this._internalAbstractMeshDataInfo._materialForRenderPass) === null || o === void 0 ? void 0 : o[i]
  28737. }
  28738. ,
  28739. e.prototype.setMaterialForRenderPass = function(i, o) {
  28740. this._internalAbstractMeshDataInfo._materialForRenderPass || (this._internalAbstractMeshDataInfo._materialForRenderPass = []),
  28741. this._internalAbstractMeshDataInfo._materialForRenderPass[i] = o
  28742. }
  28743. ,
  28744. Object.defineProperty(e.prototype, "receiveShadows", {
  28745. get: function() {
  28746. return this._internalAbstractMeshDataInfo._receiveShadows
  28747. },
  28748. set: function(i) {
  28749. this._internalAbstractMeshDataInfo._receiveShadows !== i && (this._internalAbstractMeshDataInfo._receiveShadows = i,
  28750. this._markSubMeshesAsLightDirty())
  28751. },
  28752. enumerable: !1,
  28753. configurable: !0
  28754. }),
  28755. Object.defineProperty(e.prototype, "hasVertexAlpha", {
  28756. get: function() {
  28757. return this._internalAbstractMeshDataInfo._hasVertexAlpha
  28758. },
  28759. set: function(i) {
  28760. this._internalAbstractMeshDataInfo._hasVertexAlpha !== i && (this._internalAbstractMeshDataInfo._hasVertexAlpha = i,
  28761. this._markSubMeshesAsAttributesDirty(),
  28762. this._markSubMeshesAsMiscDirty())
  28763. },
  28764. enumerable: !1,
  28765. configurable: !0
  28766. }),
  28767. Object.defineProperty(e.prototype, "useVertexColors", {
  28768. get: function() {
  28769. return this._internalAbstractMeshDataInfo._useVertexColors
  28770. },
  28771. set: function(i) {
  28772. this._internalAbstractMeshDataInfo._useVertexColors !== i && (this._internalAbstractMeshDataInfo._useVertexColors = i,
  28773. this._markSubMeshesAsAttributesDirty())
  28774. },
  28775. enumerable: !1,
  28776. configurable: !0
  28777. }),
  28778. Object.defineProperty(e.prototype, "computeBonesUsingShaders", {
  28779. get: function() {
  28780. return this._internalAbstractMeshDataInfo._computeBonesUsingShaders
  28781. },
  28782. set: function(i) {
  28783. this._internalAbstractMeshDataInfo._computeBonesUsingShaders !== i && (this._internalAbstractMeshDataInfo._computeBonesUsingShaders = i,
  28784. this._markSubMeshesAsAttributesDirty())
  28785. },
  28786. enumerable: !1,
  28787. configurable: !0
  28788. }),
  28789. Object.defineProperty(e.prototype, "numBoneInfluencers", {
  28790. get: function() {
  28791. return this._internalAbstractMeshDataInfo._numBoneInfluencers
  28792. },
  28793. set: function(i) {
  28794. this._internalAbstractMeshDataInfo._numBoneInfluencers !== i && (this._internalAbstractMeshDataInfo._numBoneInfluencers = i,
  28795. this._markSubMeshesAsAttributesDirty())
  28796. },
  28797. enumerable: !1,
  28798. configurable: !0
  28799. }),
  28800. Object.defineProperty(e.prototype, "applyFog", {
  28801. get: function() {
  28802. return this._internalAbstractMeshDataInfo._applyFog
  28803. },
  28804. set: function(i) {
  28805. this._internalAbstractMeshDataInfo._applyFog !== i && (this._internalAbstractMeshDataInfo._applyFog = i,
  28806. this._markSubMeshesAsMiscDirty())
  28807. },
  28808. enumerable: !1,
  28809. configurable: !0
  28810. }),
  28811. Object.defineProperty(e.prototype, "layerMask", {
  28812. get: function() {
  28813. return this._internalAbstractMeshDataInfo._layerMask
  28814. },
  28815. set: function(i) {
  28816. i !== this._internalAbstractMeshDataInfo._layerMask && (this._internalAbstractMeshDataInfo._layerMask = i,
  28817. this._resyncLightSources())
  28818. },
  28819. enumerable: !1,
  28820. configurable: !0
  28821. }),
  28822. Object.defineProperty(e.prototype, "collisionMask", {
  28823. get: function() {
  28824. return this._internalAbstractMeshDataInfo._meshCollisionData._collisionMask
  28825. },
  28826. set: function(i) {
  28827. this._internalAbstractMeshDataInfo._meshCollisionData._collisionMask = isNaN(i) ? -1 : i
  28828. },
  28829. enumerable: !1,
  28830. configurable: !0
  28831. }),
  28832. Object.defineProperty(e.prototype, "collisionResponse", {
  28833. get: function() {
  28834. return this._internalAbstractMeshDataInfo._meshCollisionData._collisionResponse
  28835. },
  28836. set: function(i) {
  28837. this._internalAbstractMeshDataInfo._meshCollisionData._collisionResponse = i
  28838. },
  28839. enumerable: !1,
  28840. configurable: !0
  28841. }),
  28842. Object.defineProperty(e.prototype, "collisionGroup", {
  28843. get: function() {
  28844. return this._internalAbstractMeshDataInfo._meshCollisionData._collisionGroup
  28845. },
  28846. set: function(i) {
  28847. this._internalAbstractMeshDataInfo._meshCollisionData._collisionGroup = isNaN(i) ? -1 : i
  28848. },
  28849. enumerable: !1,
  28850. configurable: !0
  28851. }),
  28852. Object.defineProperty(e.prototype, "surroundingMeshes", {
  28853. get: function() {
  28854. return this._internalAbstractMeshDataInfo._meshCollisionData._surroundingMeshes
  28855. },
  28856. set: function(i) {
  28857. this._internalAbstractMeshDataInfo._meshCollisionData._surroundingMeshes = i
  28858. },
  28859. enumerable: !1,
  28860. configurable: !0
  28861. }),
  28862. Object.defineProperty(e.prototype, "lightSources", {
  28863. get: function() {
  28864. return this._lightSources
  28865. },
  28866. enumerable: !1,
  28867. configurable: !0
  28868. }),
  28869. Object.defineProperty(e.prototype, "_positions", {
  28870. get: function() {
  28871. return null
  28872. },
  28873. enumerable: !1,
  28874. configurable: !0
  28875. }),
  28876. Object.defineProperty(e.prototype, "skeleton", {
  28877. get: function() {
  28878. return this._internalAbstractMeshDataInfo._skeleton
  28879. },
  28880. set: function(i) {
  28881. var o = this._internalAbstractMeshDataInfo._skeleton;
  28882. o && o.needInitialSkinMatrix && o._unregisterMeshWithPoseMatrix(this),
  28883. i && i.needInitialSkinMatrix && i._registerMeshWithPoseMatrix(this),
  28884. this._internalAbstractMeshDataInfo._skeleton = i,
  28885. this._internalAbstractMeshDataInfo._skeleton || (this._bonesTransformMatrices = null),
  28886. this._markSubMeshesAsAttributesDirty()
  28887. },
  28888. enumerable: !1,
  28889. configurable: !0
  28890. }),
  28891. e.prototype._buildUniformLayout = function() {
  28892. this._uniformBuffer.addUniform("world", 16),
  28893. this._uniformBuffer.addUniform("visibility", 1),
  28894. this._uniformBuffer.create()
  28895. }
  28896. ,
  28897. e.prototype.transferToEffect = function(i) {
  28898. var o = this._uniformBuffer;
  28899. o.updateMatrix("world", i),
  28900. o.updateFloat("visibility", this._internalAbstractMeshDataInfo._visibility),
  28901. o.update()
  28902. }
  28903. ,
  28904. e.prototype.getMeshUniformBuffer = function() {
  28905. return this._uniformBuffer
  28906. }
  28907. ,
  28908. e.prototype.getClassName = function() {
  28909. return "AbstractMesh"
  28910. }
  28911. ,
  28912. e.prototype.toString = function(i) {
  28913. var o = "Name: " + this.name + ", isInstance: " + (this.getClassName() !== "InstancedMesh" ? "YES" : "NO");
  28914. o += ", # of submeshes: " + (this.subMeshes ? this.subMeshes.length : 0);
  28915. var s = this._internalAbstractMeshDataInfo._skeleton;
  28916. return s && (o += ", skeleton: " + s.name),
  28917. i && (o += ", billboard mode: " + ["NONE", "X", "Y", null, "Z", null, null, "ALL"][this.billboardMode],
  28918. o += ", freeze wrld mat: " + (this._isWorldMatrixFrozen || this._waitingData.freezeWorldMatrix ? "YES" : "NO")),
  28919. o
  28920. }
  28921. ,
  28922. e.prototype._getEffectiveParent = function() {
  28923. return this._masterMesh && this.billboardMode !== TransformNode.BILLBOARDMODE_NONE ? this._masterMesh : a.prototype._getEffectiveParent.call(this)
  28924. }
  28925. ,
  28926. e.prototype._getActionManagerForTrigger = function(i, o) {
  28927. if (o === void 0 && (o = !0),
  28928. this.actionManager && (o || this.actionManager.isRecursive))
  28929. if (i) {
  28930. if (this.actionManager.hasSpecificTrigger(i))
  28931. return this.actionManager
  28932. } else
  28933. return this.actionManager;
  28934. return this.parent ? this.parent._getActionManagerForTrigger(i, !1) : null
  28935. }
  28936. ,
  28937. e.prototype._rebuild = function(i) {
  28938. if (this.onRebuildObservable.notifyObservers(this),
  28939. this._occlusionQuery !== null && (this._occlusionQuery = null),
  28940. !!this.subMeshes)
  28941. for (var o = 0, s = this.subMeshes; o < s.length; o++) {
  28942. var c = s[o];
  28943. c._rebuild()
  28944. }
  28945. }
  28946. ,
  28947. e.prototype._resyncLightSources = function() {
  28948. this._lightSources.length = 0;
  28949. for (var i = 0, o = this.getScene().lights; i < o.length; i++) {
  28950. var s = o[i];
  28951. !s.isEnabled() || s.canAffectMesh(this) && this._lightSources.push(s)
  28952. }
  28953. this._markSubMeshesAsLightDirty()
  28954. }
  28955. ,
  28956. e.prototype._resyncLightSource = function(i) {
  28957. var o = i.isEnabled() && i.canAffectMesh(this)
  28958. , s = this._lightSources.indexOf(i)
  28959. , c = !1;
  28960. if (s === -1) {
  28961. if (!o)
  28962. return;
  28963. this._lightSources.push(i)
  28964. } else {
  28965. if (o)
  28966. return;
  28967. c = !0,
  28968. this._lightSources.splice(s, 1)
  28969. }
  28970. this._markSubMeshesAsLightDirty(c)
  28971. }
  28972. ,
  28973. e.prototype._unBindEffect = function() {
  28974. for (var i = 0, o = this.subMeshes; i < o.length; i++) {
  28975. var s = o[i];
  28976. s.setEffect(null)
  28977. }
  28978. }
  28979. ,
  28980. e.prototype._removeLightSource = function(i, o) {
  28981. var s = this._lightSources.indexOf(i);
  28982. s !== -1 && (this._lightSources.splice(s, 1),
  28983. this._markSubMeshesAsLightDirty(o))
  28984. }
  28985. ,
  28986. e.prototype._markSubMeshesAsDirty = function(i) {
  28987. if (!!this.subMeshes)
  28988. for (var o = 0, s = this.subMeshes; o < s.length; o++)
  28989. for (var c = s[o], d = 0; d < c._drawWrappers.length; ++d) {
  28990. var _ = c._drawWrappers[d];
  28991. !_ || !_.defines || !_.defines.markAllAsDirty || i(_.defines)
  28992. }
  28993. }
  28994. ,
  28995. e.prototype._markSubMeshesAsLightDirty = function(i) {
  28996. i === void 0 && (i = !1),
  28997. this._markSubMeshesAsDirty(function(o) {
  28998. return o.markAsLightDirty(i)
  28999. })
  29000. }
  29001. ,
  29002. e.prototype._markSubMeshesAsAttributesDirty = function() {
  29003. this._markSubMeshesAsDirty(function(i) {
  29004. return i.markAsAttributesDirty()
  29005. })
  29006. }
  29007. ,
  29008. e.prototype._markSubMeshesAsMiscDirty = function() {
  29009. this._markSubMeshesAsDirty(function(i) {
  29010. return i.markAsMiscDirty()
  29011. })
  29012. }
  29013. ,
  29014. e.prototype.markAsDirty = function(i) {
  29015. return this._currentRenderId = Number.MAX_VALUE,
  29016. this._isDirty = !0,
  29017. this
  29018. }
  29019. ,
  29020. e.prototype.resetDrawCache = function() {
  29021. if (!!this.subMeshes)
  29022. for (var i = 0, o = this.subMeshes; i < o.length; i++) {
  29023. var s = o[i];
  29024. s.resetDrawCache()
  29025. }
  29026. }
  29027. ,
  29028. Object.defineProperty(e.prototype, "scaling", {
  29029. get: function() {
  29030. return this._scaling
  29031. },
  29032. set: function(i) {
  29033. this._scaling = i
  29034. },
  29035. enumerable: !1,
  29036. configurable: !0
  29037. }),
  29038. Object.defineProperty(e.prototype, "isBlocked", {
  29039. get: function() {
  29040. return !1
  29041. },
  29042. enumerable: !1,
  29043. configurable: !0
  29044. }),
  29045. e.prototype.getLOD = function(i) {
  29046. return this
  29047. }
  29048. ,
  29049. e.prototype.getTotalVertices = function() {
  29050. return 0
  29051. }
  29052. ,
  29053. e.prototype.getTotalIndices = function() {
  29054. return 0
  29055. }
  29056. ,
  29057. e.prototype.getIndices = function() {
  29058. return null
  29059. }
  29060. ,
  29061. e.prototype.getVerticesData = function(i) {
  29062. return null
  29063. }
  29064. ,
  29065. e.prototype.setVerticesData = function(i, o, s, c) {
  29066. return this
  29067. }
  29068. ,
  29069. e.prototype.updateVerticesData = function(i, o, s, c) {
  29070. return this
  29071. }
  29072. ,
  29073. e.prototype.setIndices = function(i, o) {
  29074. return this
  29075. }
  29076. ,
  29077. e.prototype.isVerticesDataPresent = function(i) {
  29078. return !1
  29079. }
  29080. ,
  29081. e.prototype.getBoundingInfo = function() {
  29082. return this._masterMesh ? this._masterMesh.getBoundingInfo() : (this._boundingInfoIsDirty && (this._boundingInfoIsDirty = !1,
  29083. this._updateBoundingInfo()),
  29084. this._boundingInfo)
  29085. }
  29086. ,
  29087. e.prototype.setBoundingInfo = function(i) {
  29088. return this._boundingInfo = i,
  29089. this
  29090. }
  29091. ,
  29092. Object.defineProperty(e.prototype, "hasBoundingInfo", {
  29093. get: function() {
  29094. return this._boundingInfo !== null
  29095. },
  29096. enumerable: !1,
  29097. configurable: !0
  29098. }),
  29099. e.prototype.buildBoundingInfo = function(i, o, s) {
  29100. return this._boundingInfo = new BoundingInfo(i,o,s),
  29101. this._boundingInfo
  29102. }
  29103. ,
  29104. e.prototype.normalizeToUnitCube = function(i, o, s) {
  29105. return i === void 0 && (i = !0),
  29106. o === void 0 && (o = !1),
  29107. a.prototype.normalizeToUnitCube.call(this, i, o, s)
  29108. }
  29109. ,
  29110. Object.defineProperty(e.prototype, "useBones", {
  29111. get: function() {
  29112. return this.skeleton && this.getScene().skeletonsEnabled && this.isVerticesDataPresent(VertexBuffer.MatricesIndicesKind) && this.isVerticesDataPresent(VertexBuffer.MatricesWeightsKind)
  29113. },
  29114. enumerable: !1,
  29115. configurable: !0
  29116. }),
  29117. e.prototype._preActivate = function() {}
  29118. ,
  29119. e.prototype._preActivateForIntermediateRendering = function(i) {}
  29120. ,
  29121. e.prototype._activate = function(i, o) {
  29122. return this._renderId = i,
  29123. !0
  29124. }
  29125. ,
  29126. e.prototype._postActivate = function() {}
  29127. ,
  29128. e.prototype._freeze = function() {}
  29129. ,
  29130. e.prototype._unFreeze = function() {}
  29131. ,
  29132. e.prototype.getWorldMatrix = function() {
  29133. return this._masterMesh && this.billboardMode === TransformNode.BILLBOARDMODE_NONE ? this._masterMesh.getWorldMatrix() : a.prototype.getWorldMatrix.call(this)
  29134. }
  29135. ,
  29136. e.prototype._getWorldMatrixDeterminant = function() {
  29137. return this._masterMesh ? this._masterMesh._getWorldMatrixDeterminant() : a.prototype._getWorldMatrixDeterminant.call(this)
  29138. }
  29139. ,
  29140. Object.defineProperty(e.prototype, "isAnInstance", {
  29141. get: function() {
  29142. return !1
  29143. },
  29144. enumerable: !1,
  29145. configurable: !0
  29146. }),
  29147. Object.defineProperty(e.prototype, "hasInstances", {
  29148. get: function() {
  29149. return !1
  29150. },
  29151. enumerable: !1,
  29152. configurable: !0
  29153. }),
  29154. Object.defineProperty(e.prototype, "hasThinInstances", {
  29155. get: function() {
  29156. return !1
  29157. },
  29158. enumerable: !1,
  29159. configurable: !0
  29160. }),
  29161. e.prototype.movePOV = function(i, o, s) {
  29162. return this.position.addInPlace(this.calcMovePOV(i, o, s)),
  29163. this
  29164. }
  29165. ,
  29166. e.prototype.calcMovePOV = function(i, o, s) {
  29167. var c = new Matrix
  29168. , d = this.rotationQuaternion ? this.rotationQuaternion : Quaternion.RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
  29169. d.toRotationMatrix(c);
  29170. var _ = Vector3.Zero()
  29171. , b = this.definedFacingForward ? -1 : 1;
  29172. return Vector3.TransformCoordinatesFromFloatsToRef(i * b, o, s * b, c, _),
  29173. _
  29174. }
  29175. ,
  29176. e.prototype.rotatePOV = function(i, o, s) {
  29177. return this.rotation.addInPlace(this.calcRotatePOV(i, o, s)),
  29178. this
  29179. }
  29180. ,
  29181. e.prototype.calcRotatePOV = function(i, o, s) {
  29182. var c = this.definedFacingForward ? 1 : -1;
  29183. return new Vector3(i * c,o,s * c)
  29184. }
  29185. ,
  29186. e.prototype.refreshBoundingInfo = function(i, o) {
  29187. return i === void 0 && (i = !1),
  29188. o === void 0 && (o = !1),
  29189. this._boundingInfo && this._boundingInfo.isLocked ? this : (this._refreshBoundingInfo(this._getPositionData(i, o), null),
  29190. this)
  29191. }
  29192. ,
  29193. e.prototype._refreshBoundingInfo = function(i, o) {
  29194. if (i) {
  29195. var s = extractMinAndMax(i, 0, this.getTotalVertices(), o);
  29196. this._boundingInfo ? this._boundingInfo.reConstruct(s.minimum, s.maximum) : this._boundingInfo = new BoundingInfo(s.minimum,s.maximum)
  29197. }
  29198. if (this.subMeshes)
  29199. for (var c = 0; c < this.subMeshes.length; c++)
  29200. this.subMeshes[c].refreshBoundingInfo(i);
  29201. this._updateBoundingInfo()
  29202. }
  29203. ,
  29204. e.prototype._getPositionData = function(i, o) {
  29205. var s, c = this.getVerticesData(VertexBuffer.PositionKind);
  29206. if (this._internalAbstractMeshDataInfo._positions && (this._internalAbstractMeshDataInfo._positions = null),
  29207. c && (i && this.skeleton || o && this.morphTargetManager) && (c = Tools.Slice(c),
  29208. this._generatePointsArray(),
  29209. this._positions)) {
  29210. var d = this._positions;
  29211. this._internalAbstractMeshDataInfo._positions = new Array(d.length);
  29212. for (var _ = 0; _ < d.length; _++)
  29213. this._internalAbstractMeshDataInfo._positions[_] = ((s = d[_]) === null || s === void 0 ? void 0 : s.clone()) || new Vector3
  29214. }
  29215. if (c && o && this.morphTargetManager)
  29216. for (var b = 0, k = 0, j = 0; j < c.length; j++) {
  29217. for (var $ = 0; $ < this.morphTargetManager.numTargets; $++) {
  29218. var _e = this.morphTargetManager.getTarget($)
  29219. , et = _e.influence;
  29220. if (et > 0) {
  29221. var tt = _e.getPositions();
  29222. tt && (c[j] += (tt[j] - c[j]) * et)
  29223. }
  29224. }
  29225. if (b++,
  29226. this._positions && b === 3) {
  29227. b = 0;
  29228. var rt = k * 3;
  29229. this._positions[k++].copyFromFloats(c[rt], c[rt + 1], c[rt + 2])
  29230. }
  29231. }
  29232. if (c && i && this.skeleton) {
  29233. var it = this.getVerticesData(VertexBuffer.MatricesIndicesKind)
  29234. , nt = this.getVerticesData(VertexBuffer.MatricesWeightsKind);
  29235. if (nt && it) {
  29236. var ot = this.numBoneInfluencers > 4
  29237. , at = ot ? this.getVerticesData(VertexBuffer.MatricesIndicesExtraKind) : null
  29238. , st = ot ? this.getVerticesData(VertexBuffer.MatricesWeightsExtraKind) : null;
  29239. this.skeleton.prepare();
  29240. for (var ut = this.skeleton.getTransformMatrices(this), ct = TmpVectors.Vector3[0], lt = TmpVectors.Matrix[0], ft = TmpVectors.Matrix[1], ht = 0, pt = 0; pt < c.length; pt += 3,
  29241. ht += 4) {
  29242. lt.reset();
  29243. var dt, _t;
  29244. for (dt = 0; dt < 4; dt++)
  29245. _t = nt[ht + dt],
  29246. _t > 0 && (Matrix.FromFloat32ArrayToRefScaled(ut, Math.floor(it[ht + dt] * 16), _t, ft),
  29247. lt.addToSelf(ft));
  29248. if (ot)
  29249. for (dt = 0; dt < 4; dt++)
  29250. _t = st[ht + dt],
  29251. _t > 0 && (Matrix.FromFloat32ArrayToRefScaled(ut, Math.floor(at[ht + dt] * 16), _t, ft),
  29252. lt.addToSelf(ft));
  29253. Vector3.TransformCoordinatesFromFloatsToRef(c[pt], c[pt + 1], c[pt + 2], lt, ct),
  29254. ct.toArray(c, pt),
  29255. this._positions && this._positions[pt / 3].copyFrom(ct)
  29256. }
  29257. }
  29258. }
  29259. return c
  29260. }
  29261. ,
  29262. e.prototype._updateBoundingInfo = function() {
  29263. var i = this._effectiveMesh;
  29264. return this._boundingInfo ? this._boundingInfo.update(i.worldMatrixFromCache) : this._boundingInfo = new BoundingInfo(this.position,this.position,i.worldMatrixFromCache),
  29265. this._updateSubMeshesBoundingInfo(i.worldMatrixFromCache),
  29266. this
  29267. }
  29268. ,
  29269. e.prototype._updateSubMeshesBoundingInfo = function(i) {
  29270. if (!this.subMeshes)
  29271. return this;
  29272. for (var o = this.subMeshes.length, s = 0; s < o; s++) {
  29273. var c = this.subMeshes[s];
  29274. (o > 1 || !c.IsGlobal) && c.updateBoundingInfo(i)
  29275. }
  29276. return this
  29277. }
  29278. ,
  29279. e.prototype._afterComputeWorldMatrix = function() {
  29280. this.doNotSyncBoundingInfo || (this._boundingInfoIsDirty = !0)
  29281. }
  29282. ,
  29283. Object.defineProperty(e.prototype, "_effectiveMesh", {
  29284. get: function() {
  29285. return this.skeleton && this.skeleton.overrideMesh || this
  29286. },
  29287. enumerable: !1,
  29288. configurable: !0
  29289. }),
  29290. e.prototype.isInFrustum = function(i) {
  29291. return this.getBoundingInfo().isInFrustum(i, this.cullingStrategy)
  29292. }
  29293. ,
  29294. e.prototype.isCompletelyInFrustum = function(i) {
  29295. return this.getBoundingInfo().isCompletelyInFrustum(i)
  29296. }
  29297. ,
  29298. e.prototype.intersectsMesh = function(i, o, s) {
  29299. o === void 0 && (o = !1);
  29300. var c = this.getBoundingInfo()
  29301. , d = i.getBoundingInfo();
  29302. if (c.intersects(d, o))
  29303. return !0;
  29304. if (s)
  29305. for (var _ = 0, b = this.getChildMeshes(); _ < b.length; _++) {
  29306. var k = b[_];
  29307. if (k.intersectsMesh(i, o, !0))
  29308. return !0
  29309. }
  29310. return !1
  29311. }
  29312. ,
  29313. e.prototype.intersectsPoint = function(i) {
  29314. return this.getBoundingInfo().intersectsPoint(i)
  29315. }
  29316. ,
  29317. Object.defineProperty(e.prototype, "checkCollisions", {
  29318. get: function() {
  29319. return this._internalAbstractMeshDataInfo._meshCollisionData._checkCollisions
  29320. },
  29321. set: function(i) {
  29322. this._internalAbstractMeshDataInfo._meshCollisionData._checkCollisions = i
  29323. },
  29324. enumerable: !1,
  29325. configurable: !0
  29326. }),
  29327. Object.defineProperty(e.prototype, "collider", {
  29328. get: function() {
  29329. return this._internalAbstractMeshDataInfo._meshCollisionData._collider
  29330. },
  29331. enumerable: !1,
  29332. configurable: !0
  29333. }),
  29334. e.prototype.moveWithCollisions = function(i) {
  29335. var o = this.getAbsolutePosition();
  29336. o.addToRef(this.ellipsoidOffset, this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions);
  29337. var s = this.getScene().collisionCoordinator;
  29338. return this._internalAbstractMeshDataInfo._meshCollisionData._collider || (this._internalAbstractMeshDataInfo._meshCollisionData._collider = s.createCollider()),
  29339. this._internalAbstractMeshDataInfo._meshCollisionData._collider._radius = this.ellipsoid,
  29340. s.getNewPosition(this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions, i, this._internalAbstractMeshDataInfo._meshCollisionData._collider, this.collisionRetryCount, this, this._onCollisionPositionChange, this.uniqueId),
  29341. this
  29342. }
  29343. ,
  29344. e.prototype._collideForSubMesh = function(i, o, s) {
  29345. if (this._generatePointsArray(),
  29346. !this._positions)
  29347. return this;
  29348. if (!i._lastColliderWorldVertices || !i._lastColliderTransformMatrix.equals(o)) {
  29349. i._lastColliderTransformMatrix = o.clone(),
  29350. i._lastColliderWorldVertices = [],
  29351. i._trianglePlanes = [];
  29352. for (var c = i.verticesStart, d = i.verticesStart + i.verticesCount, _ = c; _ < d; _++)
  29353. i._lastColliderWorldVertices.push(Vector3.TransformCoordinates(this._positions[_], o))
  29354. }
  29355. return s._collide(i._trianglePlanes, i._lastColliderWorldVertices, this.getIndices(), i.indexStart, i.indexStart + i.indexCount, i.verticesStart, !!i.getMaterial(), this),
  29356. this
  29357. }
  29358. ,
  29359. e.prototype._processCollisionsForSubMeshes = function(i, o) {
  29360. for (var s = this._scene.getCollidingSubMeshCandidates(this, i), c = s.length, d = 0; d < c; d++) {
  29361. var _ = s.data[d];
  29362. c > 1 && !_._checkCollision(i) || this._collideForSubMesh(_, o, i)
  29363. }
  29364. return this
  29365. }
  29366. ,
  29367. e.prototype._checkCollision = function(i) {
  29368. if (!this.getBoundingInfo()._checkCollision(i))
  29369. return this;
  29370. var o = TmpVectors.Matrix[0]
  29371. , s = TmpVectors.Matrix[1];
  29372. return Matrix.ScalingToRef(1 / i._radius.x, 1 / i._radius.y, 1 / i._radius.z, o),
  29373. this.worldMatrixFromCache.multiplyToRef(o, s),
  29374. this._processCollisionsForSubMeshes(i, s),
  29375. this
  29376. }
  29377. ,
  29378. e.prototype._generatePointsArray = function() {
  29379. return !1
  29380. }
  29381. ,
  29382. e.prototype.intersects = function(i, o, s, c, d, _) {
  29383. c === void 0 && (c = !1),
  29384. _ === void 0 && (_ = !1);
  29385. var b = new PickingInfo
  29386. , k = this.getClassName() === "InstancedLinesMesh" || this.getClassName() === "LinesMesh" ? this.intersectionThreshold : 0
  29387. , j = this.getBoundingInfo();
  29388. if (!this.subMeshes || !_ && (!i.intersectsSphere(j.boundingSphere, k) || !i.intersectsBox(j.boundingBox, k)))
  29389. return b;
  29390. if (c)
  29391. return b.hit = !_,
  29392. b.pickedMesh = _ ? null : this,
  29393. b.distance = _ ? 0 : Vector3.Distance(i.origin, j.boundingSphere.center),
  29394. b.subMeshId = 0,
  29395. b;
  29396. if (!this._generatePointsArray())
  29397. return b;
  29398. for (var $ = null, _e = this._scene.getIntersectingSubMeshCandidates(this, i), et = _e.length, tt = !1, rt = 0; rt < et; rt++) {
  29399. var it = _e.data[rt]
  29400. , nt = it.getMaterial();
  29401. if (!!nt && (nt.fillMode == 7 || nt.fillMode == 0 || nt.fillMode == 1 || nt.fillMode == 2)) {
  29402. tt = !0;
  29403. break
  29404. }
  29405. }
  29406. if (!tt)
  29407. return b.hit = !0,
  29408. b.pickedMesh = this,
  29409. b.distance = Vector3.Distance(i.origin, j.boundingSphere.center),
  29410. b.subMeshId = -1,
  29411. b;
  29412. for (var rt = 0; rt < et; rt++) {
  29413. var it = _e.data[rt];
  29414. if (!(et > 1 && !it.canIntersects(i))) {
  29415. var ot = it.intersects(i, this._positions, this.getIndices(), o, s);
  29416. if (ot && (o || !$ || ot.distance < $.distance) && ($ = ot,
  29417. $.subMeshId = rt,
  29418. o))
  29419. break
  29420. }
  29421. }
  29422. if ($) {
  29423. var at = d != null ? d : this.skeleton && this.skeleton.overrideMesh ? this.skeleton.overrideMesh.getWorldMatrix() : this.getWorldMatrix()
  29424. , st = TmpVectors.Vector3[0]
  29425. , ut = TmpVectors.Vector3[1];
  29426. Vector3.TransformCoordinatesToRef(i.origin, at, st),
  29427. i.direction.scaleToRef($.distance, ut);
  29428. var ct = Vector3.TransformNormal(ut, at)
  29429. , lt = ct.addInPlace(st);
  29430. return b.hit = !0,
  29431. b.distance = Vector3.Distance(st, lt),
  29432. b.pickedPoint = lt,
  29433. b.pickedMesh = this,
  29434. b.bu = $.bu || 0,
  29435. b.bv = $.bv || 0,
  29436. b.subMeshFaceId = $.faceId,
  29437. b.faceId = $.faceId + _e.data[$.subMeshId].indexStart / (this.getClassName().indexOf("LinesMesh") !== -1 ? 2 : 3),
  29438. b.subMeshId = $.subMeshId,
  29439. b
  29440. }
  29441. return b
  29442. }
  29443. ,
  29444. e.prototype.clone = function(i, o, s) {
  29445. return null
  29446. }
  29447. ,
  29448. e.prototype.releaseSubMeshes = function() {
  29449. if (this.subMeshes)
  29450. for (; this.subMeshes.length; )
  29451. this.subMeshes[0].dispose();
  29452. else
  29453. this.subMeshes = new Array;
  29454. return this
  29455. }
  29456. ,
  29457. e.prototype.dispose = function(i, o) {
  29458. var s = this;
  29459. o === void 0 && (o = !1);
  29460. var c;
  29461. for (this._scene.useMaterialMeshMap && this._internalAbstractMeshDataInfo._material && this._internalAbstractMeshDataInfo._material.meshMap && (this._internalAbstractMeshDataInfo._material.meshMap[this.uniqueId] = void 0),
  29462. this.getScene().freeActiveMeshes(),
  29463. this.getScene().freeRenderingGroups(),
  29464. this.actionManager !== void 0 && this.actionManager !== null && (this.actionManager.dispose(),
  29465. this.actionManager = null),
  29466. this._internalAbstractMeshDataInfo._skeleton = null,
  29467. this._transformMatrixTexture && (this._transformMatrixTexture.dispose(),
  29468. this._transformMatrixTexture = null),
  29469. c = 0; c < this._intersectionsInProgress.length; c++) {
  29470. var d = this._intersectionsInProgress[c]
  29471. , _ = d._intersectionsInProgress.indexOf(this);
  29472. d._intersectionsInProgress.splice(_, 1)
  29473. }
  29474. this._intersectionsInProgress = [];
  29475. var b = this.getScene().lights;
  29476. b.forEach(function($) {
  29477. var _e = $.includedOnlyMeshes.indexOf(s);
  29478. _e !== -1 && $.includedOnlyMeshes.splice(_e, 1),
  29479. _e = $.excludedMeshes.indexOf(s),
  29480. _e !== -1 && $.excludedMeshes.splice(_e, 1);
  29481. var et = $.getShadowGenerator();
  29482. if (et) {
  29483. var tt = et.getShadowMap();
  29484. tt && tt.renderList && (_e = tt.renderList.indexOf(s),
  29485. _e !== -1 && tt.renderList.splice(_e, 1))
  29486. }
  29487. }),
  29488. (this.getClassName() !== "InstancedMesh" || this.getClassName() !== "InstancedLinesMesh") && this.releaseSubMeshes();
  29489. var k = this.getScene().getEngine();
  29490. if (this._occlusionQuery !== null && (this.isOcclusionQueryInProgress = !1,
  29491. k.deleteQuery(this._occlusionQuery),
  29492. this._occlusionQuery = null),
  29493. k.wipeCaches(),
  29494. this.getScene().removeMesh(this),
  29495. this._parentContainer) {
  29496. var j = this._parentContainer.meshes.indexOf(this);
  29497. j > -1 && this._parentContainer.meshes.splice(j, 1),
  29498. this._parentContainer = null
  29499. }
  29500. if (o && this.material && (this.material.getClassName() === "MultiMaterial" ? this.material.dispose(!1, !0, !0) : this.material.dispose(!1, !0)),
  29501. !i)
  29502. for (c = 0; c < this.getScene().particleSystems.length; c++)
  29503. this.getScene().particleSystems[c].emitter === this && (this.getScene().particleSystems[c].dispose(),
  29504. c--);
  29505. this._internalAbstractMeshDataInfo._facetData.facetDataEnabled && this.disableFacetData(),
  29506. this._uniformBuffer.dispose(),
  29507. this.onAfterWorldMatrixUpdateObservable.clear(),
  29508. this.onCollideObservable.clear(),
  29509. this.onCollisionPositionChangeObservable.clear(),
  29510. this.onRebuildObservable.clear(),
  29511. a.prototype.dispose.call(this, i, o)
  29512. }
  29513. ,
  29514. e.prototype.addChild = function(i, o) {
  29515. return o === void 0 && (o = !1),
  29516. i.setParent(this, o),
  29517. this
  29518. }
  29519. ,
  29520. e.prototype.removeChild = function(i, o) {
  29521. return o === void 0 && (o = !1),
  29522. i.setParent(null, o),
  29523. this
  29524. }
  29525. ,
  29526. e.prototype._initFacetData = function() {
  29527. var i = this._internalAbstractMeshDataInfo._facetData;
  29528. i.facetNormals || (i.facetNormals = new Array),
  29529. i.facetPositions || (i.facetPositions = new Array),
  29530. i.facetPartitioning || (i.facetPartitioning = new Array),
  29531. i.facetNb = this.getIndices().length / 3 | 0,
  29532. i.partitioningSubdivisions = i.partitioningSubdivisions ? i.partitioningSubdivisions : 10,
  29533. i.partitioningBBoxRatio = i.partitioningBBoxRatio ? i.partitioningBBoxRatio : 1.01;
  29534. for (var o = 0; o < i.facetNb; o++)
  29535. i.facetNormals[o] = Vector3.Zero(),
  29536. i.facetPositions[o] = Vector3.Zero();
  29537. return i.facetDataEnabled = !0,
  29538. this
  29539. }
  29540. ,
  29541. e.prototype.updateFacetData = function() {
  29542. var i = this._internalAbstractMeshDataInfo._facetData;
  29543. i.facetDataEnabled || this._initFacetData();
  29544. var o = this.getVerticesData(VertexBuffer.PositionKind)
  29545. , s = this.getIndices()
  29546. , c = this.getVerticesData(VertexBuffer.NormalKind)
  29547. , d = this.getBoundingInfo();
  29548. if (i.facetDepthSort && !i.facetDepthSortEnabled) {
  29549. if (i.facetDepthSortEnabled = !0,
  29550. s instanceof Uint16Array)
  29551. i.depthSortedIndices = new Uint16Array(s);
  29552. else if (s instanceof Uint32Array)
  29553. i.depthSortedIndices = new Uint32Array(s);
  29554. else {
  29555. for (var _ = !1, b = 0; b < s.length; b++)
  29556. if (s[b] > 65535) {
  29557. _ = !0;
  29558. break
  29559. }
  29560. _ ? i.depthSortedIndices = new Uint32Array(s) : i.depthSortedIndices = new Uint16Array(s)
  29561. }
  29562. if (i.facetDepthSortFunction = function(rt, it) {
  29563. return it.sqDistance - rt.sqDistance
  29564. }
  29565. ,
  29566. !i.facetDepthSortFrom) {
  29567. var k = this.getScene().activeCamera;
  29568. i.facetDepthSortFrom = k ? k.position : Vector3.Zero()
  29569. }
  29570. i.depthSortedFacets = [];
  29571. for (var j = 0; j < i.facetNb; j++) {
  29572. var $ = {
  29573. ind: j * 3,
  29574. sqDistance: 0
  29575. };
  29576. i.depthSortedFacets.push($)
  29577. }
  29578. i.invertedMatrix = Matrix.Identity(),
  29579. i.facetDepthSortOrigin = Vector3.Zero()
  29580. }
  29581. i.bbSize.x = d.maximum.x - d.minimum.x > Epsilon ? d.maximum.x - d.minimum.x : Epsilon,
  29582. i.bbSize.y = d.maximum.y - d.minimum.y > Epsilon ? d.maximum.y - d.minimum.y : Epsilon,
  29583. i.bbSize.z = d.maximum.z - d.minimum.z > Epsilon ? d.maximum.z - d.minimum.z : Epsilon;
  29584. var _e = i.bbSize.x > i.bbSize.y ? i.bbSize.x : i.bbSize.y;
  29585. if (_e = _e > i.bbSize.z ? _e : i.bbSize.z,
  29586. i.subDiv.max = i.partitioningSubdivisions,
  29587. i.subDiv.X = Math.floor(i.subDiv.max * i.bbSize.x / _e),
  29588. i.subDiv.Y = Math.floor(i.subDiv.max * i.bbSize.y / _e),
  29589. i.subDiv.Z = Math.floor(i.subDiv.max * i.bbSize.z / _e),
  29590. i.subDiv.X = i.subDiv.X < 1 ? 1 : i.subDiv.X,
  29591. i.subDiv.Y = i.subDiv.Y < 1 ? 1 : i.subDiv.Y,
  29592. i.subDiv.Z = i.subDiv.Z < 1 ? 1 : i.subDiv.Z,
  29593. i.facetParameters.facetNormals = this.getFacetLocalNormals(),
  29594. i.facetParameters.facetPositions = this.getFacetLocalPositions(),
  29595. i.facetParameters.facetPartitioning = this.getFacetLocalPartitioning(),
  29596. i.facetParameters.bInfo = d,
  29597. i.facetParameters.bbSize = i.bbSize,
  29598. i.facetParameters.subDiv = i.subDiv,
  29599. i.facetParameters.ratio = this.partitioningBBoxRatio,
  29600. i.facetParameters.depthSort = i.facetDepthSort,
  29601. i.facetDepthSort && i.facetDepthSortEnabled && (this.computeWorldMatrix(!0),
  29602. this._worldMatrix.invertToRef(i.invertedMatrix),
  29603. Vector3.TransformCoordinatesToRef(i.facetDepthSortFrom, i.invertedMatrix, i.facetDepthSortOrigin),
  29604. i.facetParameters.distanceTo = i.facetDepthSortOrigin),
  29605. i.facetParameters.depthSortedFacets = i.depthSortedFacets,
  29606. c && VertexData.ComputeNormals(o, s, c, i.facetParameters),
  29607. i.facetDepthSort && i.facetDepthSortEnabled) {
  29608. i.depthSortedFacets.sort(i.facetDepthSortFunction);
  29609. for (var et = i.depthSortedIndices.length / 3 | 0, j = 0; j < et; j++) {
  29610. var tt = i.depthSortedFacets[j].ind;
  29611. i.depthSortedIndices[j * 3] = s[tt],
  29612. i.depthSortedIndices[j * 3 + 1] = s[tt + 1],
  29613. i.depthSortedIndices[j * 3 + 2] = s[tt + 2]
  29614. }
  29615. this.updateIndices(i.depthSortedIndices, void 0, !0)
  29616. }
  29617. return this
  29618. }
  29619. ,
  29620. e.prototype.getFacetLocalNormals = function() {
  29621. var i = this._internalAbstractMeshDataInfo._facetData;
  29622. return i.facetNormals || this.updateFacetData(),
  29623. i.facetNormals
  29624. }
  29625. ,
  29626. e.prototype.getFacetLocalPositions = function() {
  29627. var i = this._internalAbstractMeshDataInfo._facetData;
  29628. return i.facetPositions || this.updateFacetData(),
  29629. i.facetPositions
  29630. }
  29631. ,
  29632. e.prototype.getFacetLocalPartitioning = function() {
  29633. var i = this._internalAbstractMeshDataInfo._facetData;
  29634. return i.facetPartitioning || this.updateFacetData(),
  29635. i.facetPartitioning
  29636. }
  29637. ,
  29638. e.prototype.getFacetPosition = function(i) {
  29639. var o = Vector3.Zero();
  29640. return this.getFacetPositionToRef(i, o),
  29641. o
  29642. }
  29643. ,
  29644. e.prototype.getFacetPositionToRef = function(i, o) {
  29645. var s = this.getFacetLocalPositions()[i]
  29646. , c = this.getWorldMatrix();
  29647. return Vector3.TransformCoordinatesToRef(s, c, o),
  29648. this
  29649. }
  29650. ,
  29651. e.prototype.getFacetNormal = function(i) {
  29652. var o = Vector3.Zero();
  29653. return this.getFacetNormalToRef(i, o),
  29654. o
  29655. }
  29656. ,
  29657. e.prototype.getFacetNormalToRef = function(i, o) {
  29658. var s = this.getFacetLocalNormals()[i];
  29659. return Vector3.TransformNormalToRef(s, this.getWorldMatrix(), o),
  29660. this
  29661. }
  29662. ,
  29663. e.prototype.getFacetsAtLocalCoordinates = function(i, o, s) {
  29664. var c = this.getBoundingInfo()
  29665. , d = this._internalAbstractMeshDataInfo._facetData
  29666. , _ = Math.floor((i - c.minimum.x * d.partitioningBBoxRatio) * d.subDiv.X * d.partitioningBBoxRatio / d.bbSize.x)
  29667. , b = Math.floor((o - c.minimum.y * d.partitioningBBoxRatio) * d.subDiv.Y * d.partitioningBBoxRatio / d.bbSize.y)
  29668. , k = Math.floor((s - c.minimum.z * d.partitioningBBoxRatio) * d.subDiv.Z * d.partitioningBBoxRatio / d.bbSize.z);
  29669. return _ < 0 || _ > d.subDiv.max || b < 0 || b > d.subDiv.max || k < 0 || k > d.subDiv.max ? null : d.facetPartitioning[_ + d.subDiv.max * b + d.subDiv.max * d.subDiv.max * k]
  29670. }
  29671. ,
  29672. e.prototype.getClosestFacetAtCoordinates = function(i, o, s, c, d, _) {
  29673. d === void 0 && (d = !1),
  29674. _ === void 0 && (_ = !0);
  29675. var b = this.getWorldMatrix()
  29676. , k = TmpVectors.Matrix[5];
  29677. b.invertToRef(k);
  29678. var j = TmpVectors.Vector3[8];
  29679. Vector3.TransformCoordinatesFromFloatsToRef(i, o, s, k, j);
  29680. var $ = this.getClosestFacetAtLocalCoordinates(j.x, j.y, j.z, c, d, _);
  29681. return c && Vector3.TransformCoordinatesFromFloatsToRef(c.x, c.y, c.z, b, c),
  29682. $
  29683. }
  29684. ,
  29685. e.prototype.getClosestFacetAtLocalCoordinates = function(i, o, s, c, d, _) {
  29686. d === void 0 && (d = !1),
  29687. _ === void 0 && (_ = !0);
  29688. var b = null
  29689. , k = 0
  29690. , j = 0
  29691. , $ = 0
  29692. , _e = 0
  29693. , et = 0
  29694. , tt = 0
  29695. , rt = 0
  29696. , it = 0
  29697. , nt = this.getFacetLocalPositions()
  29698. , ot = this.getFacetLocalNormals()
  29699. , at = this.getFacetsAtLocalCoordinates(i, o, s);
  29700. if (!at)
  29701. return null;
  29702. for (var st = Number.MAX_VALUE, ut = st, ct, lt, ft, ht = 0; ht < at.length; ht++)
  29703. ct = at[ht],
  29704. lt = ot[ct],
  29705. ft = nt[ct],
  29706. _e = (i - ft.x) * lt.x + (o - ft.y) * lt.y + (s - ft.z) * lt.z,
  29707. (!d || d && _ && _e >= 0 || d && !_ && _e <= 0) && (_e = lt.x * ft.x + lt.y * ft.y + lt.z * ft.z,
  29708. et = -(lt.x * i + lt.y * o + lt.z * s - _e) / (lt.x * lt.x + lt.y * lt.y + lt.z * lt.z),
  29709. tt = i + lt.x * et,
  29710. rt = o + lt.y * et,
  29711. it = s + lt.z * et,
  29712. k = tt - i,
  29713. j = rt - o,
  29714. $ = it - s,
  29715. ut = k * k + j * j + $ * $,
  29716. ut < st && (st = ut,
  29717. b = ct,
  29718. c && (c.x = tt,
  29719. c.y = rt,
  29720. c.z = it)));
  29721. return b
  29722. }
  29723. ,
  29724. e.prototype.getFacetDataParameters = function() {
  29725. return this._internalAbstractMeshDataInfo._facetData.facetParameters
  29726. }
  29727. ,
  29728. e.prototype.disableFacetData = function() {
  29729. var i = this._internalAbstractMeshDataInfo._facetData;
  29730. return i.facetDataEnabled && (i.facetDataEnabled = !1,
  29731. i.facetPositions = new Array,
  29732. i.facetNormals = new Array,
  29733. i.facetPartitioning = new Array,
  29734. i.facetParameters = null,
  29735. i.depthSortedIndices = new Uint32Array(0)),
  29736. this
  29737. }
  29738. ,
  29739. e.prototype.updateIndices = function(i, o, s) {
  29740. return this
  29741. }
  29742. ,
  29743. e.prototype.createNormals = function(i) {
  29744. var o = this.getVerticesData(VertexBuffer.PositionKind), s = this.getIndices(), c;
  29745. return this.isVerticesDataPresent(VertexBuffer.NormalKind) ? c = this.getVerticesData(VertexBuffer.NormalKind) : c = [],
  29746. VertexData.ComputeNormals(o, s, c, {
  29747. useRightHandedSystem: this.getScene().useRightHandedSystem
  29748. }),
  29749. this.setVerticesData(VertexBuffer.NormalKind, c, i),
  29750. this
  29751. }
  29752. ,
  29753. e.prototype.alignWithNormal = function(i, o) {
  29754. o || (o = Axis.Y);
  29755. var s = TmpVectors.Vector3[0]
  29756. , c = TmpVectors.Vector3[1];
  29757. return Vector3.CrossToRef(o, i, c),
  29758. Vector3.CrossToRef(i, c, s),
  29759. this.rotationQuaternion ? Quaternion.RotationQuaternionFromAxisToRef(s, i, c, this.rotationQuaternion) : Vector3.RotationFromAxisToRef(s, i, c, this.rotation),
  29760. this
  29761. }
  29762. ,
  29763. e.prototype._checkOcclusionQuery = function() {
  29764. return !1
  29765. }
  29766. ,
  29767. e.prototype.disableEdgesRendering = function() {
  29768. throw _WarnImport("EdgesRenderer")
  29769. }
  29770. ,
  29771. e.prototype.enableEdgesRendering = function(i, o, s) {
  29772. throw _WarnImport("EdgesRenderer")
  29773. }
  29774. ,
  29775. e.prototype.getConnectedParticleSystems = function() {
  29776. var i = this;
  29777. return this._scene.particleSystems.filter(function(o) {
  29778. return o.emitter === i
  29779. })
  29780. }
  29781. ,
  29782. e.OCCLUSION_TYPE_NONE = 0,
  29783. e.OCCLUSION_TYPE_OPTIMISTIC = 1,
  29784. e.OCCLUSION_TYPE_STRICT = 2,
  29785. e.OCCLUSION_ALGORITHM_TYPE_ACCURATE = 0,
  29786. e.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE = 1,
  29787. e.CULLINGSTRATEGY_STANDARD = 0,
  29788. e.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = 1,
  29789. e.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = 2,
  29790. e.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = 3,
  29791. e
  29792. }(TransformNode);
  29793. RegisterClass("BABYLON.AbstractMesh", AbstractMesh);
  29794. var _TimeToken = function() {
  29795. function a() {
  29796. this._timeElapsedQueryEnded = !1
  29797. }
  29798. return a
  29799. }()
  29800. , _OcclusionDataStorage = function() {
  29801. function a() {
  29802. this.occlusionInternalRetryCounter = 0,
  29803. this.isOcclusionQueryInProgress = !1,
  29804. this.isOccluded = !1,
  29805. this.occlusionRetryCount = -1,
  29806. this.occlusionType = AbstractMesh.OCCLUSION_TYPE_NONE,
  29807. this.occlusionQueryAlgorithmType = AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE
  29808. }
  29809. return a
  29810. }();
  29811. Engine.prototype.createQuery = function() {
  29812. return this._gl.createQuery()
  29813. }
  29814. ;
  29815. Engine.prototype.deleteQuery = function(a) {
  29816. return this._gl.deleteQuery(a),
  29817. this
  29818. }
  29819. ;
  29820. Engine.prototype.isQueryResultAvailable = function(a) {
  29821. return this._gl.getQueryParameter(a, this._gl.QUERY_RESULT_AVAILABLE)
  29822. }
  29823. ;
  29824. Engine.prototype.getQueryResult = function(a) {
  29825. return this._gl.getQueryParameter(a, this._gl.QUERY_RESULT)
  29826. }
  29827. ;
  29828. Engine.prototype.beginOcclusionQuery = function(a, e) {
  29829. var i = this._getGlAlgorithmType(a);
  29830. return this._gl.beginQuery(i, e),
  29831. !0
  29832. }
  29833. ;
  29834. Engine.prototype.endOcclusionQuery = function(a) {
  29835. var e = this._getGlAlgorithmType(a);
  29836. return this._gl.endQuery(e),
  29837. this
  29838. }
  29839. ;
  29840. Engine.prototype._createTimeQuery = function() {
  29841. var a = this.getCaps().timerQuery;
  29842. return a.createQueryEXT ? a.createQueryEXT() : this.createQuery()
  29843. }
  29844. ;
  29845. Engine.prototype._deleteTimeQuery = function(a) {
  29846. var e = this.getCaps().timerQuery;
  29847. if (e.deleteQueryEXT) {
  29848. e.deleteQueryEXT(a);
  29849. return
  29850. }
  29851. this.deleteQuery(a)
  29852. }
  29853. ;
  29854. Engine.prototype._getTimeQueryResult = function(a) {
  29855. var e = this.getCaps().timerQuery;
  29856. return e.getQueryObjectEXT ? e.getQueryObjectEXT(a, e.QUERY_RESULT_EXT) : this.getQueryResult(a)
  29857. }
  29858. ;
  29859. Engine.prototype._getTimeQueryAvailability = function(a) {
  29860. var e = this.getCaps().timerQuery;
  29861. return e.getQueryObjectEXT ? e.getQueryObjectEXT(a, e.QUERY_RESULT_AVAILABLE_EXT) : this.isQueryResultAvailable(a)
  29862. }
  29863. ;
  29864. Engine.prototype.startTimeQuery = function() {
  29865. var a = this.getCaps()
  29866. , e = a.timerQuery;
  29867. if (!e)
  29868. return null;
  29869. var i = new _TimeToken;
  29870. if (this._gl.getParameter(e.GPU_DISJOINT_EXT),
  29871. a.canUseTimestampForTimerQuery)
  29872. i._startTimeQuery = this._createTimeQuery(),
  29873. e.queryCounterEXT(i._startTimeQuery, e.TIMESTAMP_EXT);
  29874. else {
  29875. if (this._currentNonTimestampToken)
  29876. return this._currentNonTimestampToken;
  29877. i._timeElapsedQuery = this._createTimeQuery(),
  29878. e.beginQueryEXT ? e.beginQueryEXT(e.TIME_ELAPSED_EXT, i._timeElapsedQuery) : this._gl.beginQuery(e.TIME_ELAPSED_EXT, i._timeElapsedQuery),
  29879. this._currentNonTimestampToken = i
  29880. }
  29881. return i
  29882. }
  29883. ;
  29884. Engine.prototype.endTimeQuery = function(a) {
  29885. var e = this.getCaps()
  29886. , i = e.timerQuery;
  29887. if (!i || !a)
  29888. return -1;
  29889. if (e.canUseTimestampForTimerQuery) {
  29890. if (!a._startTimeQuery)
  29891. return -1;
  29892. a._endTimeQuery || (a._endTimeQuery = this._createTimeQuery(),
  29893. i.queryCounterEXT(a._endTimeQuery, i.TIMESTAMP_EXT))
  29894. } else if (!a._timeElapsedQueryEnded) {
  29895. if (!a._timeElapsedQuery)
  29896. return -1;
  29897. i.endQueryEXT ? i.endQueryEXT(i.TIME_ELAPSED_EXT) : this._gl.endQuery(i.TIME_ELAPSED_EXT),
  29898. a._timeElapsedQueryEnded = !0
  29899. }
  29900. var o = this._gl.getParameter(i.GPU_DISJOINT_EXT)
  29901. , s = !1;
  29902. if (a._endTimeQuery ? s = this._getTimeQueryAvailability(a._endTimeQuery) : a._timeElapsedQuery && (s = this._getTimeQueryAvailability(a._timeElapsedQuery)),
  29903. s && !o) {
  29904. var c = 0;
  29905. if (e.canUseTimestampForTimerQuery) {
  29906. if (!a._startTimeQuery || !a._endTimeQuery)
  29907. return -1;
  29908. var d = this._getTimeQueryResult(a._startTimeQuery)
  29909. , _ = this._getTimeQueryResult(a._endTimeQuery);
  29910. c = _ - d,
  29911. this._deleteTimeQuery(a._startTimeQuery),
  29912. this._deleteTimeQuery(a._endTimeQuery),
  29913. a._startTimeQuery = null,
  29914. a._endTimeQuery = null
  29915. } else {
  29916. if (!a._timeElapsedQuery)
  29917. return -1;
  29918. c = this._getTimeQueryResult(a._timeElapsedQuery),
  29919. this._deleteTimeQuery(a._timeElapsedQuery),
  29920. a._timeElapsedQuery = null,
  29921. a._timeElapsedQueryEnded = !1,
  29922. this._currentNonTimestampToken = null
  29923. }
  29924. return c
  29925. }
  29926. return -1
  29927. }
  29928. ;
  29929. Engine.prototype._captureGPUFrameTime = !1;
  29930. Engine.prototype._gpuFrameTime = new PerfCounter;
  29931. Engine.prototype.getGPUFrameTimeCounter = function() {
  29932. return this._gpuFrameTime
  29933. }
  29934. ;
  29935. Engine.prototype.captureGPUFrameTime = function(a) {
  29936. var e = this;
  29937. a !== this._captureGPUFrameTime && (this._captureGPUFrameTime = a,
  29938. a ? (this._onBeginFrameObserver = this.onBeginFrameObservable.add(function() {
  29939. e._gpuFrameTimeToken || (e._gpuFrameTimeToken = e.startTimeQuery())
  29940. }),
  29941. this._onEndFrameObserver = this.onEndFrameObservable.add(function() {
  29942. if (!!e._gpuFrameTimeToken) {
  29943. var i = e.endTimeQuery(e._gpuFrameTimeToken);
  29944. i > -1 && (e._gpuFrameTimeToken = null,
  29945. e._gpuFrameTime.fetchNewFrame(),
  29946. e._gpuFrameTime.addCount(i, !0))
  29947. }
  29948. })) : (this.onBeginFrameObservable.remove(this._onBeginFrameObserver),
  29949. this._onBeginFrameObserver = null,
  29950. this.onEndFrameObservable.remove(this._onEndFrameObserver),
  29951. this._onEndFrameObserver = null))
  29952. }
  29953. ;
  29954. Engine.prototype._getGlAlgorithmType = function(a) {
  29955. return a === AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE ? this._gl.ANY_SAMPLES_PASSED_CONSERVATIVE : this._gl.ANY_SAMPLES_PASSED
  29956. }
  29957. ;
  29958. Object.defineProperty(AbstractMesh.prototype, "isOcclusionQueryInProgress", {
  29959. get: function() {
  29960. return this._occlusionDataStorage.isOcclusionQueryInProgress
  29961. },
  29962. set: function(a) {
  29963. this._occlusionDataStorage.isOcclusionQueryInProgress = a
  29964. },
  29965. enumerable: !1,
  29966. configurable: !0
  29967. });
  29968. Object.defineProperty(AbstractMesh.prototype, "_occlusionDataStorage", {
  29969. get: function() {
  29970. return this.__occlusionDataStorage || (this.__occlusionDataStorage = new _OcclusionDataStorage),
  29971. this.__occlusionDataStorage
  29972. },
  29973. enumerable: !1,
  29974. configurable: !0
  29975. });
  29976. Object.defineProperty(AbstractMesh.prototype, "isOccluded", {
  29977. get: function() {
  29978. return this._occlusionDataStorage.isOccluded
  29979. },
  29980. set: function(a) {
  29981. this._occlusionDataStorage.isOccluded = a
  29982. },
  29983. enumerable: !0,
  29984. configurable: !0
  29985. });
  29986. Object.defineProperty(AbstractMesh.prototype, "occlusionQueryAlgorithmType", {
  29987. get: function() {
  29988. return this._occlusionDataStorage.occlusionQueryAlgorithmType
  29989. },
  29990. set: function(a) {
  29991. this._occlusionDataStorage.occlusionQueryAlgorithmType = a
  29992. },
  29993. enumerable: !0,
  29994. configurable: !0
  29995. });
  29996. Object.defineProperty(AbstractMesh.prototype, "occlusionType", {
  29997. get: function() {
  29998. return this._occlusionDataStorage.occlusionType
  29999. },
  30000. set: function(a) {
  30001. this._occlusionDataStorage.occlusionType = a
  30002. },
  30003. enumerable: !0,
  30004. configurable: !0
  30005. });
  30006. Object.defineProperty(AbstractMesh.prototype, "occlusionRetryCount", {
  30007. get: function() {
  30008. return this._occlusionDataStorage.occlusionRetryCount
  30009. },
  30010. set: function(a) {
  30011. this._occlusionDataStorage.occlusionRetryCount = a
  30012. },
  30013. enumerable: !0,
  30014. configurable: !0
  30015. });
  30016. AbstractMesh.prototype._checkOcclusionQuery = function() {
  30017. var a = this._occlusionDataStorage;
  30018. if (a.occlusionType === AbstractMesh.OCCLUSION_TYPE_NONE)
  30019. return a.isOccluded = !1,
  30020. !1;
  30021. var e = this.getEngine();
  30022. if (!e.getCaps().supportOcclusionQuery || !e.isQueryResultAvailable)
  30023. return a.isOccluded = !1,
  30024. !1;
  30025. if (this.isOcclusionQueryInProgress && this._occlusionQuery) {
  30026. var i = e.isQueryResultAvailable(this._occlusionQuery);
  30027. if (i) {
  30028. var o = e.getQueryResult(this._occlusionQuery);
  30029. a.isOcclusionQueryInProgress = !1,
  30030. a.occlusionInternalRetryCounter = 0,
  30031. a.isOccluded = !(o > 0)
  30032. } else if (a.occlusionInternalRetryCounter++,
  30033. a.occlusionRetryCount !== -1 && a.occlusionInternalRetryCounter > a.occlusionRetryCount)
  30034. a.isOcclusionQueryInProgress = !1,
  30035. a.occlusionInternalRetryCounter = 0,
  30036. a.isOccluded = a.occlusionType === AbstractMesh.OCCLUSION_TYPE_OPTIMISTIC ? !1 : a.isOccluded;
  30037. else
  30038. return a.occlusionType === AbstractMesh.OCCLUSION_TYPE_OPTIMISTIC ? !1 : a.isOccluded
  30039. }
  30040. var s = this.getScene();
  30041. if (s.getBoundingBoxRenderer) {
  30042. var c = s.getBoundingBoxRenderer();
  30043. this._occlusionQuery === null && (this._occlusionQuery = e.createQuery()),
  30044. e.beginOcclusionQuery(a.occlusionQueryAlgorithmType, this._occlusionQuery) && (c.renderOcclusionBoundingBox(this),
  30045. e.endOcclusionQuery(a.occlusionQueryAlgorithmType),
  30046. this._occlusionDataStorage.isOcclusionQueryInProgress = !0)
  30047. }
  30048. return a.isOccluded
  30049. }
  30050. ;
  30051. Engine.prototype.createTransformFeedback = function() {
  30052. return this._gl.createTransformFeedback()
  30053. }
  30054. ;
  30055. Engine.prototype.deleteTransformFeedback = function(a) {
  30056. this._gl.deleteTransformFeedback(a)
  30057. }
  30058. ;
  30059. Engine.prototype.bindTransformFeedback = function(a) {
  30060. this._gl.bindTransformFeedback(this._gl.TRANSFORM_FEEDBACK, a)
  30061. }
  30062. ;
  30063. Engine.prototype.beginTransformFeedback = function(a) {
  30064. a === void 0 && (a = !0),
  30065. this._gl.beginTransformFeedback(a ? this._gl.POINTS : this._gl.TRIANGLES)
  30066. }
  30067. ;
  30068. Engine.prototype.endTransformFeedback = function() {
  30069. this._gl.endTransformFeedback()
  30070. }
  30071. ;
  30072. Engine.prototype.setTranformFeedbackVaryings = function(a, e) {
  30073. this._gl.transformFeedbackVaryings(a, e, this._gl.INTERLEAVED_ATTRIBS)
  30074. }
  30075. ;
  30076. Engine.prototype.bindTransformFeedbackBuffer = function(a) {
  30077. this._gl.bindBufferBase(this._gl.TRANSFORM_FEEDBACK_BUFFER, 0, a ? a.underlyingResource : null)
  30078. }
  30079. ;
  30080. var SmartArray = function() {
  30081. function a(e) {
  30082. this.length = 0,
  30083. this.data = new Array(e),
  30084. this._id = a._GlobalId++
  30085. }
  30086. return a.prototype.push = function(e) {
  30087. this.data[this.length++] = e,
  30088. this.length > this.data.length && (this.data.length *= 2)
  30089. }
  30090. ,
  30091. a.prototype.forEach = function(e) {
  30092. for (var i = 0; i < this.length; i++)
  30093. e(this.data[i])
  30094. }
  30095. ,
  30096. a.prototype.sort = function(e) {
  30097. this.data.sort(e)
  30098. }
  30099. ,
  30100. a.prototype.reset = function() {
  30101. this.length = 0
  30102. }
  30103. ,
  30104. a.prototype.dispose = function() {
  30105. this.reset(),
  30106. this.data && (this.data.length = 0,
  30107. this.data = [])
  30108. }
  30109. ,
  30110. a.prototype.concat = function(e) {
  30111. if (e.length !== 0) {
  30112. this.length + e.length > this.data.length && (this.data.length = (this.length + e.length) * 2);
  30113. for (var i = 0; i < e.length; i++)
  30114. this.data[this.length++] = (e.data || e)[i]
  30115. }
  30116. }
  30117. ,
  30118. a.prototype.indexOf = function(e) {
  30119. var i = this.data.indexOf(e);
  30120. return i >= this.length ? -1 : i
  30121. }
  30122. ,
  30123. a.prototype.contains = function(e) {
  30124. return this.indexOf(e) !== -1
  30125. }
  30126. ,
  30127. a._GlobalId = 0,
  30128. a
  30129. }()
  30130. , SmartArrayNoDuplicate = function(a) {
  30131. __extends(e, a);
  30132. function e() {
  30133. var i = a !== null && a.apply(this, arguments) || this;
  30134. return i._duplicateId = 0,
  30135. i
  30136. }
  30137. return e.prototype.push = function(i) {
  30138. a.prototype.push.call(this, i),
  30139. i.__smartArrayFlags || (i.__smartArrayFlags = {}),
  30140. i.__smartArrayFlags[this._id] = this._duplicateId
  30141. }
  30142. ,
  30143. e.prototype.pushNoDuplicate = function(i) {
  30144. return i.__smartArrayFlags && i.__smartArrayFlags[this._id] === this._duplicateId ? !1 : (this.push(i),
  30145. !0)
  30146. }
  30147. ,
  30148. e.prototype.reset = function() {
  30149. a.prototype.reset.call(this),
  30150. this._duplicateId++
  30151. }
  30152. ,
  30153. e.prototype.concatWithNoDuplicate = function(i) {
  30154. if (i.length !== 0) {
  30155. this.length + i.length > this.data.length && (this.data.length = (this.length + i.length) * 2);
  30156. for (var o = 0; o < i.length; o++) {
  30157. var s = (i.data || i)[o];
  30158. this.pushNoDuplicate(s)
  30159. }
  30160. }
  30161. }
  30162. ,
  30163. e
  30164. }(SmartArray)
  30165. , Viewport = function() {
  30166. function a(e, i, o, s) {
  30167. this.x = e,
  30168. this.y = i,
  30169. this.width = o,
  30170. this.height = s
  30171. }
  30172. return a.prototype.toGlobal = function(e, i) {
  30173. return new a(this.x * e,this.y * i,this.width * e,this.height * i)
  30174. }
  30175. ,
  30176. a.prototype.toGlobalToRef = function(e, i, o) {
  30177. return o.x = this.x * e,
  30178. o.y = this.y * i,
  30179. o.width = this.width * e,
  30180. o.height = this.height * i,
  30181. this
  30182. }
  30183. ,
  30184. a.prototype.clone = function() {
  30185. return new a(this.x,this.y,this.width,this.height)
  30186. }
  30187. ,
  30188. a
  30189. }()
  30190. , Plane = function() {
  30191. function a(e, i, o, s) {
  30192. this.normal = new Vector3(e,i,o),
  30193. this.d = s
  30194. }
  30195. return a.prototype.asArray = function() {
  30196. return [this.normal.x, this.normal.y, this.normal.z, this.d]
  30197. }
  30198. ,
  30199. a.prototype.clone = function() {
  30200. return new a(this.normal.x,this.normal.y,this.normal.z,this.d)
  30201. }
  30202. ,
  30203. a.prototype.getClassName = function() {
  30204. return "Plane"
  30205. }
  30206. ,
  30207. a.prototype.getHashCode = function() {
  30208. var e = this.normal.getHashCode();
  30209. return e = e * 397 ^ (this.d | 0),
  30210. e
  30211. }
  30212. ,
  30213. a.prototype.normalize = function() {
  30214. var e = Math.sqrt(this.normal.x * this.normal.x + this.normal.y * this.normal.y + this.normal.z * this.normal.z)
  30215. , i = 0;
  30216. return e !== 0 && (i = 1 / e),
  30217. this.normal.x *= i,
  30218. this.normal.y *= i,
  30219. this.normal.z *= i,
  30220. this.d *= i,
  30221. this
  30222. }
  30223. ,
  30224. a.prototype.transform = function(e) {
  30225. var i = a._TmpMatrix;
  30226. e.invertToRef(i);
  30227. var o = i.m
  30228. , s = this.normal.x
  30229. , c = this.normal.y
  30230. , d = this.normal.z
  30231. , _ = this.d
  30232. , b = s * o[0] + c * o[1] + d * o[2] + _ * o[3]
  30233. , k = s * o[4] + c * o[5] + d * o[6] + _ * o[7]
  30234. , j = s * o[8] + c * o[9] + d * o[10] + _ * o[11]
  30235. , $ = s * o[12] + c * o[13] + d * o[14] + _ * o[15];
  30236. return new a(b,k,j,$)
  30237. }
  30238. ,
  30239. a.prototype.dotCoordinate = function(e) {
  30240. return this.normal.x * e.x + this.normal.y * e.y + this.normal.z * e.z + this.d
  30241. }
  30242. ,
  30243. a.prototype.copyFromPoints = function(e, i, o) {
  30244. var s = i.x - e.x, c = i.y - e.y, d = i.z - e.z, _ = o.x - e.x, b = o.y - e.y, k = o.z - e.z, j = c * k - d * b, $ = d * _ - s * k, _e = s * b - c * _, et = Math.sqrt(j * j + $ * $ + _e * _e), tt;
  30245. return et !== 0 ? tt = 1 / et : tt = 0,
  30246. this.normal.x = j * tt,
  30247. this.normal.y = $ * tt,
  30248. this.normal.z = _e * tt,
  30249. this.d = -(this.normal.x * e.x + this.normal.y * e.y + this.normal.z * e.z),
  30250. this
  30251. }
  30252. ,
  30253. a.prototype.isFrontFacingTo = function(e, i) {
  30254. var o = Vector3.Dot(this.normal, e);
  30255. return o <= i
  30256. }
  30257. ,
  30258. a.prototype.signedDistanceTo = function(e) {
  30259. return Vector3.Dot(e, this.normal) + this.d
  30260. }
  30261. ,
  30262. a.FromArray = function(e) {
  30263. return new a(e[0],e[1],e[2],e[3])
  30264. }
  30265. ,
  30266. a.FromPoints = function(e, i, o) {
  30267. var s = new a(0,0,0,0);
  30268. return s.copyFromPoints(e, i, o),
  30269. s
  30270. }
  30271. ,
  30272. a.FromPositionAndNormal = function(e, i) {
  30273. var o = new a(0,0,0,0);
  30274. return i.normalize(),
  30275. o.normal = i,
  30276. o.d = -(i.x * e.x + i.y * e.y + i.z * e.z),
  30277. o
  30278. }
  30279. ,
  30280. a.SignedDistanceToPlaneFromPositionAndNormal = function(e, i, o) {
  30281. var s = -(i.x * e.x + i.y * e.y + i.z * e.z);
  30282. return Vector3.Dot(o, i) + s
  30283. }
  30284. ,
  30285. a._TmpMatrix = Matrix.Identity(),
  30286. a
  30287. }()
  30288. , Frustum = function() {
  30289. function a() {}
  30290. return a.GetPlanes = function(e) {
  30291. for (var i = [], o = 0; o < 6; o++)
  30292. i.push(new Plane(0,0,0,0));
  30293. return a.GetPlanesToRef(e, i),
  30294. i
  30295. }
  30296. ,
  30297. a.GetNearPlaneToRef = function(e, i) {
  30298. var o = e.m;
  30299. i.normal.x = o[3] + o[2],
  30300. i.normal.y = o[7] + o[6],
  30301. i.normal.z = o[11] + o[10],
  30302. i.d = o[15] + o[14],
  30303. i.normalize()
  30304. }
  30305. ,
  30306. a.GetFarPlaneToRef = function(e, i) {
  30307. var o = e.m;
  30308. i.normal.x = o[3] - o[2],
  30309. i.normal.y = o[7] - o[6],
  30310. i.normal.z = o[11] - o[10],
  30311. i.d = o[15] - o[14],
  30312. i.normalize()
  30313. }
  30314. ,
  30315. a.GetLeftPlaneToRef = function(e, i) {
  30316. var o = e.m;
  30317. i.normal.x = o[3] + o[0],
  30318. i.normal.y = o[7] + o[4],
  30319. i.normal.z = o[11] + o[8],
  30320. i.d = o[15] + o[12],
  30321. i.normalize()
  30322. }
  30323. ,
  30324. a.GetRightPlaneToRef = function(e, i) {
  30325. var o = e.m;
  30326. i.normal.x = o[3] - o[0],
  30327. i.normal.y = o[7] - o[4],
  30328. i.normal.z = o[11] - o[8],
  30329. i.d = o[15] - o[12],
  30330. i.normalize()
  30331. }
  30332. ,
  30333. a.GetTopPlaneToRef = function(e, i) {
  30334. var o = e.m;
  30335. i.normal.x = o[3] - o[1],
  30336. i.normal.y = o[7] - o[5],
  30337. i.normal.z = o[11] - o[9],
  30338. i.d = o[15] - o[13],
  30339. i.normalize()
  30340. }
  30341. ,
  30342. a.GetBottomPlaneToRef = function(e, i) {
  30343. var o = e.m;
  30344. i.normal.x = o[3] + o[1],
  30345. i.normal.y = o[7] + o[5],
  30346. i.normal.z = o[11] + o[9],
  30347. i.d = o[15] + o[13],
  30348. i.normalize()
  30349. }
  30350. ,
  30351. a.GetPlanesToRef = function(e, i) {
  30352. a.GetNearPlaneToRef(e, i[0]),
  30353. a.GetFarPlaneToRef(e, i[1]),
  30354. a.GetLeftPlaneToRef(e, i[2]),
  30355. a.GetRightPlaneToRef(e, i[3]),
  30356. a.GetTopPlaneToRef(e, i[4]),
  30357. a.GetBottomPlaneToRef(e, i[5])
  30358. }
  30359. ,
  30360. a
  30361. }()
  30362. , Camera$1 = function(a) {
  30363. __extends(e, a);
  30364. function e(i, o, s, c) {
  30365. c === void 0 && (c = !0);
  30366. var d = a.call(this, i, s) || this;
  30367. return d._position = Vector3.Zero(),
  30368. d._upVector = Vector3.Up(),
  30369. d.orthoLeft = null,
  30370. d.orthoRight = null,
  30371. d.orthoBottom = null,
  30372. d.orthoTop = null,
  30373. d.fov = .8,
  30374. d.projectionPlaneTilt = 0,
  30375. d.minZ = 1,
  30376. d.maxZ = 1e4,
  30377. d.inertia = .9,
  30378. d.mode = e.PERSPECTIVE_CAMERA,
  30379. d.isIntermediate = !1,
  30380. d.viewport = new Viewport(0,0,1,1),
  30381. d.layerMask = 268435455,
  30382. d.fovMode = e.FOVMODE_VERTICAL_FIXED,
  30383. d.cameraRigMode = e.RIG_MODE_NONE,
  30384. d.customRenderTargets = new Array,
  30385. d.outputRenderTarget = null,
  30386. d.onViewMatrixChangedObservable = new Observable,
  30387. d.onProjectionMatrixChangedObservable = new Observable,
  30388. d.onAfterCheckInputsObservable = new Observable,
  30389. d.onRestoreStateObservable = new Observable,
  30390. d.isRigCamera = !1,
  30391. d._rigCameras = new Array,
  30392. d._webvrViewMatrix = Matrix.Identity(),
  30393. d._skipRendering = !1,
  30394. d._projectionMatrix = new Matrix,
  30395. d._postProcesses = new Array,
  30396. d._activeMeshes = new SmartArray(256),
  30397. d._globalPosition = Vector3.Zero(),
  30398. d._computedViewMatrix = Matrix.Identity(),
  30399. d._doNotComputeProjectionMatrix = !1,
  30400. d._transformMatrix = Matrix.Zero(),
  30401. d._refreshFrustumPlanes = !0,
  30402. d._absoluteRotation = Quaternion.Identity(),
  30403. d._isCamera = !0,
  30404. d._isLeftCamera = !1,
  30405. d._isRightCamera = !1,
  30406. d.getScene().addCamera(d),
  30407. c && !d.getScene().activeCamera && (d.getScene().activeCamera = d),
  30408. d.position = o,
  30409. d.renderPassId = d.getScene().getEngine().createRenderPassId("Camera " + i),
  30410. d
  30411. }
  30412. return Object.defineProperty(e.prototype, "position", {
  30413. get: function() {
  30414. return this._position
  30415. },
  30416. set: function(i) {
  30417. this._position = i
  30418. },
  30419. enumerable: !1,
  30420. configurable: !0
  30421. }),
  30422. Object.defineProperty(e.prototype, "upVector", {
  30423. get: function() {
  30424. return this._upVector
  30425. },
  30426. set: function(i) {
  30427. this._upVector = i
  30428. },
  30429. enumerable: !1,
  30430. configurable: !0
  30431. }),
  30432. Object.defineProperty(e.prototype, "screenArea", {
  30433. get: function() {
  30434. var i, o, s, c, d = 0, _ = 0;
  30435. if (this.mode === e.PERSPECTIVE_CAMERA)
  30436. this.fovMode === e.FOVMODE_VERTICAL_FIXED ? (_ = this.minZ * 2 * Math.tan(this.fov / 2),
  30437. d = this.getEngine().getAspectRatio(this) * _) : (d = this.minZ * 2 * Math.tan(this.fov / 2),
  30438. _ = d / this.getEngine().getAspectRatio(this));
  30439. else {
  30440. var b = this.getEngine().getRenderWidth() / 2
  30441. , k = this.getEngine().getRenderHeight() / 2;
  30442. d = ((i = this.orthoRight) !== null && i !== void 0 ? i : b) - ((o = this.orthoLeft) !== null && o !== void 0 ? o : -b),
  30443. _ = ((s = this.orthoTop) !== null && s !== void 0 ? s : k) - ((c = this.orthoBottom) !== null && c !== void 0 ? c : -k)
  30444. }
  30445. return d * _
  30446. },
  30447. enumerable: !1,
  30448. configurable: !0
  30449. }),
  30450. e.prototype.storeState = function() {
  30451. return this._stateStored = !0,
  30452. this._storedFov = this.fov,
  30453. this
  30454. }
  30455. ,
  30456. e.prototype._restoreStateValues = function() {
  30457. return this._stateStored ? (this.fov = this._storedFov,
  30458. !0) : !1
  30459. }
  30460. ,
  30461. e.prototype.restoreState = function() {
  30462. return this._restoreStateValues() ? (this.onRestoreStateObservable.notifyObservers(this),
  30463. !0) : !1
  30464. }
  30465. ,
  30466. e.prototype.getClassName = function() {
  30467. return "Camera"
  30468. }
  30469. ,
  30470. e.prototype.toString = function(i) {
  30471. var o = "Name: " + this.name;
  30472. if (o += ", type: " + this.getClassName(),
  30473. this.animations)
  30474. for (var s = 0; s < this.animations.length; s++)
  30475. o += ", animation[0]: " + this.animations[s].toString(i);
  30476. return o
  30477. }
  30478. ,
  30479. e.prototype.applyVerticalCorrection = function() {
  30480. var i = this.absoluteRotation.toEulerAngles();
  30481. this.projectionPlaneTilt = this._scene.useRightHandedSystem ? -i.x : i.x
  30482. }
  30483. ,
  30484. Object.defineProperty(e.prototype, "globalPosition", {
  30485. get: function() {
  30486. return this._globalPosition
  30487. },
  30488. enumerable: !1,
  30489. configurable: !0
  30490. }),
  30491. e.prototype.getActiveMeshes = function() {
  30492. return this._activeMeshes
  30493. }
  30494. ,
  30495. e.prototype.isActiveMesh = function(i) {
  30496. return this._activeMeshes.indexOf(i) !== -1
  30497. }
  30498. ,
  30499. e.prototype.isReady = function(i) {
  30500. if (i === void 0 && (i = !1),
  30501. i)
  30502. for (var o = 0, s = this._postProcesses; o < s.length; o++) {
  30503. var c = s[o];
  30504. if (c && !c.isReady())
  30505. return !1
  30506. }
  30507. return a.prototype.isReady.call(this, i)
  30508. }
  30509. ,
  30510. e.prototype._initCache = function() {
  30511. a.prototype._initCache.call(this),
  30512. this._cache.position = new Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),
  30513. this._cache.upVector = new Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),
  30514. this._cache.mode = void 0,
  30515. this._cache.minZ = void 0,
  30516. this._cache.maxZ = void 0,
  30517. this._cache.fov = void 0,
  30518. this._cache.fovMode = void 0,
  30519. this._cache.aspectRatio = void 0,
  30520. this._cache.orthoLeft = void 0,
  30521. this._cache.orthoRight = void 0,
  30522. this._cache.orthoBottom = void 0,
  30523. this._cache.orthoTop = void 0,
  30524. this._cache.renderWidth = void 0,
  30525. this._cache.renderHeight = void 0
  30526. }
  30527. ,
  30528. e.prototype._updateCache = function(i) {
  30529. i || a.prototype._updateCache.call(this),
  30530. this._cache.position.copyFrom(this.position),
  30531. this._cache.upVector.copyFrom(this.upVector)
  30532. }
  30533. ,
  30534. e.prototype._isSynchronized = function() {
  30535. return this._isSynchronizedViewMatrix() && this._isSynchronizedProjectionMatrix()
  30536. }
  30537. ,
  30538. e.prototype._isSynchronizedViewMatrix = function() {
  30539. return a.prototype._isSynchronized.call(this) ? this._cache.position.equals(this.position) && this._cache.upVector.equals(this.upVector) && this.isSynchronizedWithParent() : !1
  30540. }
  30541. ,
  30542. e.prototype._isSynchronizedProjectionMatrix = function() {
  30543. var i = this._cache.mode === this.mode && this._cache.minZ === this.minZ && this._cache.maxZ === this.maxZ;
  30544. if (!i)
  30545. return !1;
  30546. var o = this.getEngine();
  30547. return this.mode === e.PERSPECTIVE_CAMERA ? i = this._cache.fov === this.fov && this._cache.fovMode === this.fovMode && this._cache.aspectRatio === o.getAspectRatio(this) && this._cache.projectionPlaneTilt === this.projectionPlaneTilt : i = this._cache.orthoLeft === this.orthoLeft && this._cache.orthoRight === this.orthoRight && this._cache.orthoBottom === this.orthoBottom && this._cache.orthoTop === this.orthoTop && this._cache.renderWidth === o.getRenderWidth() && this._cache.renderHeight === o.getRenderHeight(),
  30548. i
  30549. }
  30550. ,
  30551. e.prototype.attachControl = function(i, o) {}
  30552. ,
  30553. e.prototype.detachControl = function(i) {}
  30554. ,
  30555. e.prototype.update = function() {
  30556. this._checkInputs(),
  30557. this.cameraRigMode !== e.RIG_MODE_NONE && this._updateRigCameras()
  30558. }
  30559. ,
  30560. e.prototype._checkInputs = function() {
  30561. this.onAfterCheckInputsObservable.notifyObservers(this)
  30562. }
  30563. ,
  30564. Object.defineProperty(e.prototype, "rigCameras", {
  30565. get: function() {
  30566. return this._rigCameras
  30567. },
  30568. enumerable: !1,
  30569. configurable: !0
  30570. }),
  30571. Object.defineProperty(e.prototype, "rigPostProcess", {
  30572. get: function() {
  30573. return this._rigPostProcess
  30574. },
  30575. enumerable: !1,
  30576. configurable: !0
  30577. }),
  30578. e.prototype._getFirstPostProcess = function() {
  30579. for (var i = 0; i < this._postProcesses.length; i++)
  30580. if (this._postProcesses[i] !== null)
  30581. return this._postProcesses[i];
  30582. return null
  30583. }
  30584. ,
  30585. e.prototype._cascadePostProcessesToRigCams = function() {
  30586. var i = this._getFirstPostProcess();
  30587. i && i.markTextureDirty();
  30588. for (var o = 0, s = this._rigCameras.length; o < s; o++) {
  30589. var c = this._rigCameras[o]
  30590. , d = c._rigPostProcess;
  30591. if (d) {
  30592. var _ = d.getEffectName() === "pass";
  30593. _ && (c.isIntermediate = this._postProcesses.length === 0),
  30594. c._postProcesses = this._postProcesses.slice(0).concat(d),
  30595. d.markTextureDirty()
  30596. } else
  30597. c._postProcesses = this._postProcesses.slice(0)
  30598. }
  30599. }
  30600. ,
  30601. e.prototype.attachPostProcess = function(i, o) {
  30602. return o === void 0 && (o = null),
  30603. !i.isReusable() && this._postProcesses.indexOf(i) > -1 ? (Logger$2.Error("You're trying to reuse a post process not defined as reusable."),
  30604. 0) : (o == null || o < 0 ? this._postProcesses.push(i) : this._postProcesses[o] === null ? this._postProcesses[o] = i : this._postProcesses.splice(o, 0, i),
  30605. this._cascadePostProcessesToRigCams(),
  30606. this._scene.prePassRenderer && this._scene.prePassRenderer.markAsDirty(),
  30607. this._postProcesses.indexOf(i))
  30608. }
  30609. ,
  30610. e.prototype.detachPostProcess = function(i) {
  30611. var o = this._postProcesses.indexOf(i);
  30612. o !== -1 && (this._postProcesses[o] = null),
  30613. this._scene.prePassRenderer && this._scene.prePassRenderer.markAsDirty(),
  30614. this._cascadePostProcessesToRigCams()
  30615. }
  30616. ,
  30617. e.prototype.getWorldMatrix = function() {
  30618. return this._isSynchronizedViewMatrix() ? this._worldMatrix : (this.getViewMatrix(),
  30619. this._worldMatrix)
  30620. }
  30621. ,
  30622. e.prototype._getViewMatrix = function() {
  30623. return Matrix.Identity()
  30624. }
  30625. ,
  30626. e.prototype.getViewMatrix = function(i) {
  30627. return !i && this._isSynchronizedViewMatrix() ? this._computedViewMatrix : (this.updateCache(),
  30628. this._computedViewMatrix = this._getViewMatrix(),
  30629. this._currentRenderId = this.getScene().getRenderId(),
  30630. this._childUpdateId++,
  30631. this._refreshFrustumPlanes = !0,
  30632. this._cameraRigParams && this._cameraRigParams.vrPreViewMatrix && this._computedViewMatrix.multiplyToRef(this._cameraRigParams.vrPreViewMatrix, this._computedViewMatrix),
  30633. this.parent && this.parent.onViewMatrixChangedObservable && this.parent.onViewMatrixChangedObservable.notifyObservers(this.parent),
  30634. this.onViewMatrixChangedObservable.notifyObservers(this),
  30635. this._computedViewMatrix.invertToRef(this._worldMatrix),
  30636. this._computedViewMatrix)
  30637. }
  30638. ,
  30639. e.prototype.freezeProjectionMatrix = function(i) {
  30640. this._doNotComputeProjectionMatrix = !0,
  30641. i !== void 0 && (this._projectionMatrix = i)
  30642. }
  30643. ,
  30644. e.prototype.unfreezeProjectionMatrix = function() {
  30645. this._doNotComputeProjectionMatrix = !1
  30646. }
  30647. ,
  30648. e.prototype.getProjectionMatrix = function(i) {
  30649. var o, s, c, d, _, b, k, j;
  30650. if (this._doNotComputeProjectionMatrix || !i && this._isSynchronizedProjectionMatrix())
  30651. return this._projectionMatrix;
  30652. this._cache.mode = this.mode,
  30653. this._cache.minZ = this.minZ,
  30654. this._cache.maxZ = this.maxZ,
  30655. this._refreshFrustumPlanes = !0;
  30656. var $ = this.getEngine()
  30657. , _e = this.getScene();
  30658. if (this.mode === e.PERSPECTIVE_CAMERA) {
  30659. this._cache.fov = this.fov,
  30660. this._cache.fovMode = this.fovMode,
  30661. this._cache.aspectRatio = $.getAspectRatio(this),
  30662. this._cache.projectionPlaneTilt = this.projectionPlaneTilt,
  30663. this.minZ <= 0 && (this.minZ = .1);
  30664. var et = $.useReverseDepthBuffer
  30665. , tt = void 0;
  30666. _e.useRightHandedSystem ? tt = Matrix.PerspectiveFovRHToRef : tt = Matrix.PerspectiveFovLHToRef,
  30667. tt(this.fov, $.getAspectRatio(this), et ? this.maxZ : this.minZ, et ? this.minZ : this.maxZ, this._projectionMatrix, this.fovMode === e.FOVMODE_VERTICAL_FIXED, $.isNDCHalfZRange, this.projectionPlaneTilt, $.useReverseDepthBuffer)
  30668. } else {
  30669. var rt = $.getRenderWidth() / 2
  30670. , it = $.getRenderHeight() / 2;
  30671. _e.useRightHandedSystem ? Matrix.OrthoOffCenterRHToRef((o = this.orthoLeft) !== null && o !== void 0 ? o : -rt, (s = this.orthoRight) !== null && s !== void 0 ? s : rt, (c = this.orthoBottom) !== null && c !== void 0 ? c : -it, (d = this.orthoTop) !== null && d !== void 0 ? d : it, this.minZ, this.maxZ, this._projectionMatrix, $.isNDCHalfZRange) : Matrix.OrthoOffCenterLHToRef((_ = this.orthoLeft) !== null && _ !== void 0 ? _ : -rt, (b = this.orthoRight) !== null && b !== void 0 ? b : rt, (k = this.orthoBottom) !== null && k !== void 0 ? k : -it, (j = this.orthoTop) !== null && j !== void 0 ? j : it, this.minZ, this.maxZ, this._projectionMatrix, $.isNDCHalfZRange),
  30672. this._cache.orthoLeft = this.orthoLeft,
  30673. this._cache.orthoRight = this.orthoRight,
  30674. this._cache.orthoBottom = this.orthoBottom,
  30675. this._cache.orthoTop = this.orthoTop,
  30676. this._cache.renderWidth = $.getRenderWidth(),
  30677. this._cache.renderHeight = $.getRenderHeight()
  30678. }
  30679. return this.onProjectionMatrixChangedObservable.notifyObservers(this),
  30680. this._projectionMatrix
  30681. }
  30682. ,
  30683. e.prototype.getTransformationMatrix = function() {
  30684. return this._computedViewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix),
  30685. this._transformMatrix
  30686. }
  30687. ,
  30688. e.prototype._updateFrustumPlanes = function() {
  30689. !this._refreshFrustumPlanes || (this.getTransformationMatrix(),
  30690. this._frustumPlanes ? Frustum.GetPlanesToRef(this._transformMatrix, this._frustumPlanes) : this._frustumPlanes = Frustum.GetPlanes(this._transformMatrix),
  30691. this._refreshFrustumPlanes = !1)
  30692. }
  30693. ,
  30694. e.prototype.isInFrustum = function(i, o) {
  30695. if (o === void 0 && (o = !1),
  30696. this._updateFrustumPlanes(),
  30697. o && this.rigCameras.length > 0) {
  30698. var s = !1;
  30699. return this.rigCameras.forEach(function(c) {
  30700. c._updateFrustumPlanes(),
  30701. s = s || i.isInFrustum(c._frustumPlanes)
  30702. }),
  30703. s
  30704. } else
  30705. return i.isInFrustum(this._frustumPlanes)
  30706. }
  30707. ,
  30708. e.prototype.isCompletelyInFrustum = function(i) {
  30709. return this._updateFrustumPlanes(),
  30710. i.isCompletelyInFrustum(this._frustumPlanes)
  30711. }
  30712. ,
  30713. e.prototype.getForwardRay = function(i, o, s) {
  30714. throw _WarnImport("Ray")
  30715. }
  30716. ,
  30717. e.prototype.getForwardRayToRef = function(i, o, s, c) {
  30718. throw _WarnImport("Ray")
  30719. }
  30720. ,
  30721. e.prototype.dispose = function(i, o) {
  30722. for (o === void 0 && (o = !1),
  30723. this.onViewMatrixChangedObservable.clear(),
  30724. this.onProjectionMatrixChangedObservable.clear(),
  30725. this.onAfterCheckInputsObservable.clear(),
  30726. this.onRestoreStateObservable.clear(),
  30727. this.inputs && this.inputs.clear(),
  30728. this.getScene().stopAnimation(this),
  30729. this.getScene().removeCamera(this); this._rigCameras.length > 0; ) {
  30730. var s = this._rigCameras.pop();
  30731. s && s.dispose()
  30732. }
  30733. if (this._parentContainer) {
  30734. var c = this._parentContainer.cameras.indexOf(this);
  30735. c > -1 && this._parentContainer.cameras.splice(c, 1),
  30736. this._parentContainer = null
  30737. }
  30738. if (this._rigPostProcess)
  30739. this._rigPostProcess.dispose(this),
  30740. this._rigPostProcess = null,
  30741. this._postProcesses = [];
  30742. else if (this.cameraRigMode !== e.RIG_MODE_NONE)
  30743. this._rigPostProcess = null,
  30744. this._postProcesses = [];
  30745. else
  30746. for (var _ = this._postProcesses.length; --_ >= 0; ) {
  30747. var d = this._postProcesses[_];
  30748. d && d.dispose(this)
  30749. }
  30750. for (var _ = this.customRenderTargets.length; --_ >= 0; )
  30751. this.customRenderTargets[_].dispose();
  30752. this.customRenderTargets = [],
  30753. this._activeMeshes.dispose(),
  30754. this.getScene().getEngine().releaseRenderPassId(this.renderPassId),
  30755. a.prototype.dispose.call(this, i, o)
  30756. }
  30757. ,
  30758. Object.defineProperty(e.prototype, "isLeftCamera", {
  30759. get: function() {
  30760. return this._isLeftCamera
  30761. },
  30762. enumerable: !1,
  30763. configurable: !0
  30764. }),
  30765. Object.defineProperty(e.prototype, "isRightCamera", {
  30766. get: function() {
  30767. return this._isRightCamera
  30768. },
  30769. enumerable: !1,
  30770. configurable: !0
  30771. }),
  30772. Object.defineProperty(e.prototype, "leftCamera", {
  30773. get: function() {
  30774. return this._rigCameras.length < 1 ? null : this._rigCameras[0]
  30775. },
  30776. enumerable: !1,
  30777. configurable: !0
  30778. }),
  30779. Object.defineProperty(e.prototype, "rightCamera", {
  30780. get: function() {
  30781. return this._rigCameras.length < 2 ? null : this._rigCameras[1]
  30782. },
  30783. enumerable: !1,
  30784. configurable: !0
  30785. }),
  30786. e.prototype.getLeftTarget = function() {
  30787. return this._rigCameras.length < 1 ? null : this._rigCameras[0].getTarget()
  30788. }
  30789. ,
  30790. e.prototype.getRightTarget = function() {
  30791. return this._rigCameras.length < 2 ? null : this._rigCameras[1].getTarget()
  30792. }
  30793. ,
  30794. e.prototype.setCameraRigMode = function(i, o) {
  30795. if (this.cameraRigMode !== i) {
  30796. for (; this._rigCameras.length > 0; ) {
  30797. var s = this._rigCameras.pop();
  30798. s && s.dispose()
  30799. }
  30800. if (this.cameraRigMode = i,
  30801. this._cameraRigParams = {},
  30802. this._cameraRigParams.interaxialDistance = o.interaxialDistance || .0637,
  30803. this._cameraRigParams.stereoHalfAngle = Tools.ToRadians(this._cameraRigParams.interaxialDistance / .0637),
  30804. this.cameraRigMode !== e.RIG_MODE_NONE) {
  30805. var c = this.createRigCamera(this.name + "_L", 0);
  30806. c && (c._isLeftCamera = !0);
  30807. var d = this.createRigCamera(this.name + "_R", 1);
  30808. d && (d._isRightCamera = !0),
  30809. c && d && (this._rigCameras.push(c),
  30810. this._rigCameras.push(d))
  30811. }
  30812. this._setRigMode(o),
  30813. this._cascadePostProcessesToRigCams(),
  30814. this.update()
  30815. }
  30816. }
  30817. ,
  30818. e.prototype._setRigMode = function(i) {}
  30819. ,
  30820. e.prototype._getVRProjectionMatrix = function() {
  30821. return Matrix.PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov, this._cameraRigParams.vrMetrics.aspectRatio, this.minZ, this.maxZ, this._cameraRigParams.vrWorkMatrix, !0, this.getEngine().isNDCHalfZRange),
  30822. this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrHMatrix, this._projectionMatrix),
  30823. this._projectionMatrix
  30824. }
  30825. ,
  30826. e.prototype._updateCameraRotationMatrix = function() {}
  30827. ,
  30828. e.prototype._updateWebVRCameraRotationMatrix = function() {}
  30829. ,
  30830. e.prototype._getWebVRProjectionMatrix = function() {
  30831. return Matrix.Identity()
  30832. }
  30833. ,
  30834. e.prototype._getWebVRViewMatrix = function() {
  30835. return Matrix.Identity()
  30836. }
  30837. ,
  30838. e.prototype.setCameraRigParameter = function(i, o) {
  30839. this._cameraRigParams || (this._cameraRigParams = {}),
  30840. this._cameraRigParams[i] = o,
  30841. i === "interaxialDistance" && (this._cameraRigParams.stereoHalfAngle = Tools.ToRadians(o / .0637))
  30842. }
  30843. ,
  30844. e.prototype.createRigCamera = function(i, o) {
  30845. return null
  30846. }
  30847. ,
  30848. e.prototype._updateRigCameras = function() {
  30849. for (var i = 0; i < this._rigCameras.length; i++)
  30850. this._rigCameras[i].minZ = this.minZ,
  30851. this._rigCameras[i].maxZ = this.maxZ,
  30852. this._rigCameras[i].fov = this.fov,
  30853. this._rigCameras[i].upVector.copyFrom(this.upVector);
  30854. this.cameraRigMode === e.RIG_MODE_STEREOSCOPIC_ANAGLYPH && (this._rigCameras[0].viewport = this._rigCameras[1].viewport = this.viewport)
  30855. }
  30856. ,
  30857. e.prototype._setupInputs = function() {}
  30858. ,
  30859. e.prototype.serialize = function() {
  30860. var i = SerializationHelper.Serialize(this);
  30861. return i.uniqueId = this.uniqueId,
  30862. i.type = this.getClassName(),
  30863. this.parent && (i.parentId = this.parent.uniqueId),
  30864. this.inputs && this.inputs.serialize(i),
  30865. SerializationHelper.AppendSerializedAnimations(this, i),
  30866. i.ranges = this.serializeAnimationRanges(),
  30867. i.isEnabled = this.isEnabled(),
  30868. i
  30869. }
  30870. ,
  30871. e.prototype.clone = function(i) {
  30872. var o = SerializationHelper.Clone(e.GetConstructorFromName(this.getClassName(), i, this.getScene(), this.interaxialDistance, this.isStereoscopicSideBySide), this);
  30873. return o.name = i,
  30874. this.onClonedObservable.notifyObservers(o),
  30875. o
  30876. }
  30877. ,
  30878. e.prototype.getDirection = function(i) {
  30879. var o = Vector3.Zero();
  30880. return this.getDirectionToRef(i, o),
  30881. o
  30882. }
  30883. ,
  30884. Object.defineProperty(e.prototype, "absoluteRotation", {
  30885. get: function() {
  30886. return this.getWorldMatrix().decompose(void 0, this._absoluteRotation),
  30887. this._absoluteRotation
  30888. },
  30889. enumerable: !1,
  30890. configurable: !0
  30891. }),
  30892. e.prototype.getDirectionToRef = function(i, o) {
  30893. Vector3.TransformNormalToRef(i, this.getWorldMatrix(), o)
  30894. }
  30895. ,
  30896. e.GetConstructorFromName = function(i, o, s, c, d) {
  30897. c === void 0 && (c = 0),
  30898. d === void 0 && (d = !0);
  30899. var _ = Node$2.Construct(i, o, s, {
  30900. interaxial_distance: c,
  30901. isStereoscopicSideBySide: d
  30902. });
  30903. return _ || function() {
  30904. return e._createDefaultParsedCamera(o, s)
  30905. }
  30906. }
  30907. ,
  30908. e.prototype.computeWorldMatrix = function() {
  30909. return this.getWorldMatrix()
  30910. }
  30911. ,
  30912. e.Parse = function(i, o) {
  30913. var s = i.type
  30914. , c = e.GetConstructorFromName(s, i.name, o, i.interaxial_distance, i.isStereoscopicSideBySide)
  30915. , d = SerializationHelper.Parse(c, i, o);
  30916. if (i.parentId && (d._waitingParentId = i.parentId),
  30917. d.inputs && (d.inputs.parse(i),
  30918. d._setupInputs()),
  30919. i.upVector && (d.upVector = Vector3.FromArray(i.upVector)),
  30920. d.setPosition && (d.position.copyFromFloats(0, 0, 0),
  30921. d.setPosition(Vector3.FromArray(i.position))),
  30922. i.target && d.setTarget && d.setTarget(Vector3.FromArray(i.target)),
  30923. i.cameraRigMode) {
  30924. var _ = i.interaxial_distance ? {
  30925. interaxialDistance: i.interaxial_distance
  30926. } : {};
  30927. d.setCameraRigMode(i.cameraRigMode, _)
  30928. }
  30929. if (i.animations) {
  30930. for (var b = 0; b < i.animations.length; b++) {
  30931. var k = i.animations[b]
  30932. , j = GetClass("BABYLON.Animation");
  30933. j && d.animations.push(j.Parse(k))
  30934. }
  30935. Node$2.ParseAnimationRanges(d, i, o)
  30936. }
  30937. return i.autoAnimate && o.beginAnimation(d, i.autoAnimateFrom, i.autoAnimateTo, i.autoAnimateLoop, i.autoAnimateSpeed || 1),
  30938. i.isEnabled !== void 0 && d.setEnabled(i.isEnabled),
  30939. d
  30940. }
  30941. ,
  30942. e._createDefaultParsedCamera = function(i, o) {
  30943. throw _WarnImport("UniversalCamera")
  30944. }
  30945. ,
  30946. e.PERSPECTIVE_CAMERA = 0,
  30947. e.ORTHOGRAPHIC_CAMERA = 1,
  30948. e.FOVMODE_VERTICAL_FIXED = 0,
  30949. e.FOVMODE_HORIZONTAL_FIXED = 1,
  30950. e.RIG_MODE_NONE = 0,
  30951. e.RIG_MODE_STEREOSCOPIC_ANAGLYPH = 10,
  30952. e.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL = 11,
  30953. e.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED = 12,
  30954. e.RIG_MODE_STEREOSCOPIC_OVERUNDER = 13,
  30955. e.RIG_MODE_STEREOSCOPIC_INTERLACED = 14,
  30956. e.RIG_MODE_VR = 20,
  30957. e.RIG_MODE_WEBVR = 21,
  30958. e.RIG_MODE_CUSTOM = 22,
  30959. e.ForceAttachControlToAlwaysPreventDefault = !1,
  30960. __decorate([serializeAsVector3("position")], e.prototype, "_position", void 0),
  30961. __decorate([serializeAsVector3("upVector")], e.prototype, "_upVector", void 0),
  30962. __decorate([serialize()], e.prototype, "orthoLeft", void 0),
  30963. __decorate([serialize()], e.prototype, "orthoRight", void 0),
  30964. __decorate([serialize()], e.prototype, "orthoBottom", void 0),
  30965. __decorate([serialize()], e.prototype, "orthoTop", void 0),
  30966. __decorate([serialize()], e.prototype, "fov", void 0),
  30967. __decorate([serialize()], e.prototype, "projectionPlaneTilt", void 0),
  30968. __decorate([serialize()], e.prototype, "minZ", void 0),
  30969. __decorate([serialize()], e.prototype, "maxZ", void 0),
  30970. __decorate([serialize()], e.prototype, "inertia", void 0),
  30971. __decorate([serialize()], e.prototype, "mode", void 0),
  30972. __decorate([serialize()], e.prototype, "layerMask", void 0),
  30973. __decorate([serialize()], e.prototype, "fovMode", void 0),
  30974. __decorate([serialize()], e.prototype, "cameraRigMode", void 0),
  30975. __decorate([serialize()], e.prototype, "interaxialDistance", void 0),
  30976. __decorate([serialize()], e.prototype, "isStereoscopicSideBySide", void 0),
  30977. e
  30978. }(Node$2)
  30979. , StringDictionary = function() {
  30980. function a() {
  30981. this._count = 0,
  30982. this._data = {}
  30983. }
  30984. return a.prototype.copyFrom = function(e) {
  30985. var i = this;
  30986. this.clear(),
  30987. e.forEach(function(o, s) {
  30988. return i.add(o, s)
  30989. })
  30990. }
  30991. ,
  30992. a.prototype.get = function(e) {
  30993. var i = this._data[e];
  30994. if (i !== void 0)
  30995. return i
  30996. }
  30997. ,
  30998. a.prototype.getOrAddWithFactory = function(e, i) {
  30999. var o = this.get(e);
  31000. return o !== void 0 || (o = i(e),
  31001. o && this.add(e, o)),
  31002. o
  31003. }
  31004. ,
  31005. a.prototype.getOrAdd = function(e, i) {
  31006. var o = this.get(e);
  31007. return o !== void 0 ? o : (this.add(e, i),
  31008. i)
  31009. }
  31010. ,
  31011. a.prototype.contains = function(e) {
  31012. return this._data[e] !== void 0
  31013. }
  31014. ,
  31015. a.prototype.add = function(e, i) {
  31016. return this._data[e] !== void 0 ? !1 : (this._data[e] = i,
  31017. ++this._count,
  31018. !0)
  31019. }
  31020. ,
  31021. a.prototype.set = function(e, i) {
  31022. return this._data[e] === void 0 ? !1 : (this._data[e] = i,
  31023. !0)
  31024. }
  31025. ,
  31026. a.prototype.getAndRemove = function(e) {
  31027. var i = this.get(e);
  31028. return i !== void 0 ? (delete this._data[e],
  31029. --this._count,
  31030. i) : null
  31031. }
  31032. ,
  31033. a.prototype.remove = function(e) {
  31034. return this.contains(e) ? (delete this._data[e],
  31035. --this._count,
  31036. !0) : !1
  31037. }
  31038. ,
  31039. a.prototype.clear = function() {
  31040. this._data = {},
  31041. this._count = 0
  31042. }
  31043. ,
  31044. Object.defineProperty(a.prototype, "count", {
  31045. get: function() {
  31046. return this._count
  31047. },
  31048. enumerable: !1,
  31049. configurable: !0
  31050. }),
  31051. a.prototype.forEach = function(e) {
  31052. for (var i in this._data) {
  31053. var o = this._data[i];
  31054. e(i, o)
  31055. }
  31056. }
  31057. ,
  31058. a.prototype.first = function(e) {
  31059. for (var i in this._data) {
  31060. var o = this._data[i]
  31061. , s = e(i, o);
  31062. if (s)
  31063. return s
  31064. }
  31065. return null
  31066. }
  31067. ,
  31068. a
  31069. }()
  31070. , AbstractScene = function() {
  31071. function a() {
  31072. this.rootNodes = new Array,
  31073. this.cameras = new Array,
  31074. this.lights = new Array,
  31075. this.meshes = new Array,
  31076. this.skeletons = new Array,
  31077. this.particleSystems = new Array,
  31078. this.animations = [],
  31079. this.animationGroups = new Array,
  31080. this.multiMaterials = new Array,
  31081. this.materials = new Array,
  31082. this.morphTargetManagers = new Array,
  31083. this.geometries = new Array,
  31084. this.transformNodes = new Array,
  31085. this.actionManagers = new Array,
  31086. this.textures = new Array,
  31087. this._environmentTexture = null,
  31088. this.postProcesses = new Array
  31089. }
  31090. return a.AddParser = function(e, i) {
  31091. this._BabylonFileParsers[e] = i
  31092. }
  31093. ,
  31094. a.GetParser = function(e) {
  31095. return this._BabylonFileParsers[e] ? this._BabylonFileParsers[e] : null
  31096. }
  31097. ,
  31098. a.AddIndividualParser = function(e, i) {
  31099. this._IndividualBabylonFileParsers[e] = i
  31100. }
  31101. ,
  31102. a.GetIndividualParser = function(e) {
  31103. return this._IndividualBabylonFileParsers[e] ? this._IndividualBabylonFileParsers[e] : null
  31104. }
  31105. ,
  31106. a.Parse = function(e, i, o, s) {
  31107. for (var c in this._BabylonFileParsers)
  31108. this._BabylonFileParsers.hasOwnProperty(c) && this._BabylonFileParsers[c](e, i, o, s)
  31109. }
  31110. ,
  31111. Object.defineProperty(a.prototype, "environmentTexture", {
  31112. get: function() {
  31113. return this._environmentTexture
  31114. },
  31115. set: function(e) {
  31116. this._environmentTexture = e
  31117. },
  31118. enumerable: !1,
  31119. configurable: !0
  31120. }),
  31121. a.prototype.getNodes = function() {
  31122. var e = new Array;
  31123. return e = e.concat(this.meshes),
  31124. e = e.concat(this.lights),
  31125. e = e.concat(this.cameras),
  31126. e = e.concat(this.transformNodes),
  31127. this.skeletons.forEach(function(i) {
  31128. return e = e.concat(i.bones)
  31129. }),
  31130. e
  31131. }
  31132. ,
  31133. a._BabylonFileParsers = {},
  31134. a._IndividualBabylonFileParsers = {},
  31135. a
  31136. }()
  31137. , MaterialDefines = function() {
  31138. function a() {
  31139. this._isDirty = !0,
  31140. this._areLightsDirty = !0,
  31141. this._areLightsDisposed = !1,
  31142. this._areAttributesDirty = !0,
  31143. this._areTexturesDirty = !0,
  31144. this._areFresnelDirty = !0,
  31145. this._areMiscDirty = !0,
  31146. this._arePrePassDirty = !0,
  31147. this._areImageProcessingDirty = !0,
  31148. this._normals = !1,
  31149. this._uvs = !1,
  31150. this._needNormals = !1,
  31151. this._needUVs = !1
  31152. }
  31153. return Object.defineProperty(a.prototype, "isDirty", {
  31154. get: function() {
  31155. return this._isDirty
  31156. },
  31157. enumerable: !1,
  31158. configurable: !0
  31159. }),
  31160. a.prototype.markAsProcessed = function() {
  31161. this._isDirty = !1,
  31162. this._areAttributesDirty = !1,
  31163. this._areTexturesDirty = !1,
  31164. this._areFresnelDirty = !1,
  31165. this._areLightsDirty = !1,
  31166. this._areLightsDisposed = !1,
  31167. this._areMiscDirty = !1,
  31168. this._arePrePassDirty = !1,
  31169. this._areImageProcessingDirty = !1
  31170. }
  31171. ,
  31172. a.prototype.markAsUnprocessed = function() {
  31173. this._isDirty = !0
  31174. }
  31175. ,
  31176. a.prototype.markAllAsDirty = function() {
  31177. this._areTexturesDirty = !0,
  31178. this._areAttributesDirty = !0,
  31179. this._areLightsDirty = !0,
  31180. this._areFresnelDirty = !0,
  31181. this._areMiscDirty = !0,
  31182. this._areImageProcessingDirty = !0,
  31183. this._isDirty = !0
  31184. }
  31185. ,
  31186. a.prototype.markAsImageProcessingDirty = function() {
  31187. this._areImageProcessingDirty = !0,
  31188. this._isDirty = !0
  31189. }
  31190. ,
  31191. a.prototype.markAsLightDirty = function(e) {
  31192. e === void 0 && (e = !1),
  31193. this._areLightsDirty = !0,
  31194. this._areLightsDisposed = this._areLightsDisposed || e,
  31195. this._isDirty = !0
  31196. }
  31197. ,
  31198. a.prototype.markAsAttributesDirty = function() {
  31199. this._areAttributesDirty = !0,
  31200. this._isDirty = !0
  31201. }
  31202. ,
  31203. a.prototype.markAsTexturesDirty = function() {
  31204. this._areTexturesDirty = !0,
  31205. this._isDirty = !0
  31206. }
  31207. ,
  31208. a.prototype.markAsFresnelDirty = function() {
  31209. this._areFresnelDirty = !0,
  31210. this._isDirty = !0
  31211. }
  31212. ,
  31213. a.prototype.markAsMiscDirty = function() {
  31214. this._areMiscDirty = !0,
  31215. this._isDirty = !0
  31216. }
  31217. ,
  31218. a.prototype.markAsPrePassDirty = function() {
  31219. this._arePrePassDirty = !0,
  31220. this._isDirty = !0
  31221. }
  31222. ,
  31223. a.prototype.rebuild = function() {
  31224. this._keys = [];
  31225. for (var e = 0, i = Object.keys(this); e < i.length; e++) {
  31226. var o = i[e];
  31227. o[0] !== "_" && this._keys.push(o)
  31228. }
  31229. }
  31230. ,
  31231. a.prototype.isEqual = function(e) {
  31232. if (this._keys.length !== e._keys.length)
  31233. return !1;
  31234. for (var i = 0; i < this._keys.length; i++) {
  31235. var o = this._keys[i];
  31236. if (this[o] !== e[o])
  31237. return !1
  31238. }
  31239. return !0
  31240. }
  31241. ,
  31242. a.prototype.cloneTo = function(e) {
  31243. this._keys.length !== e._keys.length && (e._keys = this._keys.slice(0));
  31244. for (var i = 0; i < this._keys.length; i++) {
  31245. var o = this._keys[i];
  31246. e[o] = this[o]
  31247. }
  31248. }
  31249. ,
  31250. a.prototype.reset = function() {
  31251. for (var e = 0; e < this._keys.length; e++) {
  31252. var i = this._keys[e]
  31253. , o = typeof this[i];
  31254. switch (o) {
  31255. case "number":
  31256. this[i] = 0;
  31257. break;
  31258. case "string":
  31259. this[i] = "";
  31260. break;
  31261. default:
  31262. this[i] = !1;
  31263. break
  31264. }
  31265. }
  31266. }
  31267. ,
  31268. a.prototype.toString = function() {
  31269. for (var e = "", i = 0; i < this._keys.length; i++) {
  31270. var o = this._keys[i]
  31271. , s = this[o]
  31272. , c = typeof s;
  31273. switch (c) {
  31274. case "number":
  31275. case "string":
  31276. e += "#define " + o + " " + s + `
  31277. `;
  31278. break;
  31279. default:
  31280. s && (e += "#define " + o + `
  31281. `);
  31282. break
  31283. }
  31284. }
  31285. return e
  31286. }
  31287. ,
  31288. a
  31289. }()
  31290. , ColorCurves = function() {
  31291. function a() {
  31292. this._dirty = !0,
  31293. this._tempColor = new Color4(0,0,0,0),
  31294. this._globalCurve = new Color4(0,0,0,0),
  31295. this._highlightsCurve = new Color4(0,0,0,0),
  31296. this._midtonesCurve = new Color4(0,0,0,0),
  31297. this._shadowsCurve = new Color4(0,0,0,0),
  31298. this._positiveCurve = new Color4(0,0,0,0),
  31299. this._negativeCurve = new Color4(0,0,0,0),
  31300. this._globalHue = 30,
  31301. this._globalDensity = 0,
  31302. this._globalSaturation = 0,
  31303. this._globalExposure = 0,
  31304. this._highlightsHue = 30,
  31305. this._highlightsDensity = 0,
  31306. this._highlightsSaturation = 0,
  31307. this._highlightsExposure = 0,
  31308. this._midtonesHue = 30,
  31309. this._midtonesDensity = 0,
  31310. this._midtonesSaturation = 0,
  31311. this._midtonesExposure = 0,
  31312. this._shadowsHue = 30,
  31313. this._shadowsDensity = 0,
  31314. this._shadowsSaturation = 0,
  31315. this._shadowsExposure = 0
  31316. }
  31317. return Object.defineProperty(a.prototype, "globalHue", {
  31318. get: function() {
  31319. return this._globalHue
  31320. },
  31321. set: function(e) {
  31322. this._globalHue = e,
  31323. this._dirty = !0
  31324. },
  31325. enumerable: !1,
  31326. configurable: !0
  31327. }),
  31328. Object.defineProperty(a.prototype, "globalDensity", {
  31329. get: function() {
  31330. return this._globalDensity
  31331. },
  31332. set: function(e) {
  31333. this._globalDensity = e,
  31334. this._dirty = !0
  31335. },
  31336. enumerable: !1,
  31337. configurable: !0
  31338. }),
  31339. Object.defineProperty(a.prototype, "globalSaturation", {
  31340. get: function() {
  31341. return this._globalSaturation
  31342. },
  31343. set: function(e) {
  31344. this._globalSaturation = e,
  31345. this._dirty = !0
  31346. },
  31347. enumerable: !1,
  31348. configurable: !0
  31349. }),
  31350. Object.defineProperty(a.prototype, "globalExposure", {
  31351. get: function() {
  31352. return this._globalExposure
  31353. },
  31354. set: function(e) {
  31355. this._globalExposure = e,
  31356. this._dirty = !0
  31357. },
  31358. enumerable: !1,
  31359. configurable: !0
  31360. }),
  31361. Object.defineProperty(a.prototype, "highlightsHue", {
  31362. get: function() {
  31363. return this._highlightsHue
  31364. },
  31365. set: function(e) {
  31366. this._highlightsHue = e,
  31367. this._dirty = !0
  31368. },
  31369. enumerable: !1,
  31370. configurable: !0
  31371. }),
  31372. Object.defineProperty(a.prototype, "highlightsDensity", {
  31373. get: function() {
  31374. return this._highlightsDensity
  31375. },
  31376. set: function(e) {
  31377. this._highlightsDensity = e,
  31378. this._dirty = !0
  31379. },
  31380. enumerable: !1,
  31381. configurable: !0
  31382. }),
  31383. Object.defineProperty(a.prototype, "highlightsSaturation", {
  31384. get: function() {
  31385. return this._highlightsSaturation
  31386. },
  31387. set: function(e) {
  31388. this._highlightsSaturation = e,
  31389. this._dirty = !0
  31390. },
  31391. enumerable: !1,
  31392. configurable: !0
  31393. }),
  31394. Object.defineProperty(a.prototype, "highlightsExposure", {
  31395. get: function() {
  31396. return this._highlightsExposure
  31397. },
  31398. set: function(e) {
  31399. this._highlightsExposure = e,
  31400. this._dirty = !0
  31401. },
  31402. enumerable: !1,
  31403. configurable: !0
  31404. }),
  31405. Object.defineProperty(a.prototype, "midtonesHue", {
  31406. get: function() {
  31407. return this._midtonesHue
  31408. },
  31409. set: function(e) {
  31410. this._midtonesHue = e,
  31411. this._dirty = !0
  31412. },
  31413. enumerable: !1,
  31414. configurable: !0
  31415. }),
  31416. Object.defineProperty(a.prototype, "midtonesDensity", {
  31417. get: function() {
  31418. return this._midtonesDensity
  31419. },
  31420. set: function(e) {
  31421. this._midtonesDensity = e,
  31422. this._dirty = !0
  31423. },
  31424. enumerable: !1,
  31425. configurable: !0
  31426. }),
  31427. Object.defineProperty(a.prototype, "midtonesSaturation", {
  31428. get: function() {
  31429. return this._midtonesSaturation
  31430. },
  31431. set: function(e) {
  31432. this._midtonesSaturation = e,
  31433. this._dirty = !0
  31434. },
  31435. enumerable: !1,
  31436. configurable: !0
  31437. }),
  31438. Object.defineProperty(a.prototype, "midtonesExposure", {
  31439. get: function() {
  31440. return this._midtonesExposure
  31441. },
  31442. set: function(e) {
  31443. this._midtonesExposure = e,
  31444. this._dirty = !0
  31445. },
  31446. enumerable: !1,
  31447. configurable: !0
  31448. }),
  31449. Object.defineProperty(a.prototype, "shadowsHue", {
  31450. get: function() {
  31451. return this._shadowsHue
  31452. },
  31453. set: function(e) {
  31454. this._shadowsHue = e,
  31455. this._dirty = !0
  31456. },
  31457. enumerable: !1,
  31458. configurable: !0
  31459. }),
  31460. Object.defineProperty(a.prototype, "shadowsDensity", {
  31461. get: function() {
  31462. return this._shadowsDensity
  31463. },
  31464. set: function(e) {
  31465. this._shadowsDensity = e,
  31466. this._dirty = !0
  31467. },
  31468. enumerable: !1,
  31469. configurable: !0
  31470. }),
  31471. Object.defineProperty(a.prototype, "shadowsSaturation", {
  31472. get: function() {
  31473. return this._shadowsSaturation
  31474. },
  31475. set: function(e) {
  31476. this._shadowsSaturation = e,
  31477. this._dirty = !0
  31478. },
  31479. enumerable: !1,
  31480. configurable: !0
  31481. }),
  31482. Object.defineProperty(a.prototype, "shadowsExposure", {
  31483. get: function() {
  31484. return this._shadowsExposure
  31485. },
  31486. set: function(e) {
  31487. this._shadowsExposure = e,
  31488. this._dirty = !0
  31489. },
  31490. enumerable: !1,
  31491. configurable: !0
  31492. }),
  31493. a.prototype.getClassName = function() {
  31494. return "ColorCurves"
  31495. }
  31496. ,
  31497. a.Bind = function(e, i, o, s, c) {
  31498. o === void 0 && (o = "vCameraColorCurvePositive"),
  31499. s === void 0 && (s = "vCameraColorCurveNeutral"),
  31500. c === void 0 && (c = "vCameraColorCurveNegative"),
  31501. e._dirty && (e._dirty = !1,
  31502. e.getColorGradingDataToRef(e._globalHue, e._globalDensity, e._globalSaturation, e._globalExposure, e._globalCurve),
  31503. e.getColorGradingDataToRef(e._highlightsHue, e._highlightsDensity, e._highlightsSaturation, e._highlightsExposure, e._tempColor),
  31504. e._tempColor.multiplyToRef(e._globalCurve, e._highlightsCurve),
  31505. e.getColorGradingDataToRef(e._midtonesHue, e._midtonesDensity, e._midtonesSaturation, e._midtonesExposure, e._tempColor),
  31506. e._tempColor.multiplyToRef(e._globalCurve, e._midtonesCurve),
  31507. e.getColorGradingDataToRef(e._shadowsHue, e._shadowsDensity, e._shadowsSaturation, e._shadowsExposure, e._tempColor),
  31508. e._tempColor.multiplyToRef(e._globalCurve, e._shadowsCurve),
  31509. e._highlightsCurve.subtractToRef(e._midtonesCurve, e._positiveCurve),
  31510. e._midtonesCurve.subtractToRef(e._shadowsCurve, e._negativeCurve)),
  31511. i && (i.setFloat4(o, e._positiveCurve.r, e._positiveCurve.g, e._positiveCurve.b, e._positiveCurve.a),
  31512. i.setFloat4(s, e._midtonesCurve.r, e._midtonesCurve.g, e._midtonesCurve.b, e._midtonesCurve.a),
  31513. i.setFloat4(c, e._negativeCurve.r, e._negativeCurve.g, e._negativeCurve.b, e._negativeCurve.a))
  31514. }
  31515. ,
  31516. a.PrepareUniforms = function(e) {
  31517. e.push("vCameraColorCurveNeutral", "vCameraColorCurvePositive", "vCameraColorCurveNegative")
  31518. }
  31519. ,
  31520. a.prototype.getColorGradingDataToRef = function(e, i, o, s, c) {
  31521. e != null && (e = a.clamp(e, 0, 360),
  31522. i = a.clamp(i, -100, 100),
  31523. o = a.clamp(o, -100, 100),
  31524. s = a.clamp(s, -100, 100),
  31525. i = a.applyColorGradingSliderNonlinear(i),
  31526. i *= .5,
  31527. s = a.applyColorGradingSliderNonlinear(s),
  31528. i < 0 && (i *= -1,
  31529. e = (e + 180) % 360),
  31530. a.fromHSBToRef(e, i, 50 + .25 * s, c),
  31531. c.scaleToRef(2, c),
  31532. c.a = 1 + .01 * o)
  31533. }
  31534. ,
  31535. a.applyColorGradingSliderNonlinear = function(e) {
  31536. e /= 100;
  31537. var i = Math.abs(e);
  31538. return i = Math.pow(i, 2),
  31539. e < 0 && (i *= -1),
  31540. i *= 100,
  31541. i
  31542. }
  31543. ,
  31544. a.fromHSBToRef = function(e, i, o, s) {
  31545. var c = a.clamp(e, 0, 360)
  31546. , d = a.clamp(i / 100, 0, 1)
  31547. , _ = a.clamp(o / 100, 0, 1);
  31548. if (d === 0)
  31549. s.r = _,
  31550. s.g = _,
  31551. s.b = _;
  31552. else {
  31553. c /= 60;
  31554. var b = Math.floor(c)
  31555. , k = c - b
  31556. , j = _ * (1 - d)
  31557. , $ = _ * (1 - d * k)
  31558. , _e = _ * (1 - d * (1 - k));
  31559. switch (b) {
  31560. case 0:
  31561. s.r = _,
  31562. s.g = _e,
  31563. s.b = j;
  31564. break;
  31565. case 1:
  31566. s.r = $,
  31567. s.g = _,
  31568. s.b = j;
  31569. break;
  31570. case 2:
  31571. s.r = j,
  31572. s.g = _,
  31573. s.b = _e;
  31574. break;
  31575. case 3:
  31576. s.r = j,
  31577. s.g = $,
  31578. s.b = _;
  31579. break;
  31580. case 4:
  31581. s.r = _e,
  31582. s.g = j,
  31583. s.b = _;
  31584. break;
  31585. default:
  31586. s.r = _,
  31587. s.g = j,
  31588. s.b = $;
  31589. break
  31590. }
  31591. }
  31592. s.a = 1
  31593. }
  31594. ,
  31595. a.clamp = function(e, i, o) {
  31596. return Math.min(Math.max(e, i), o)
  31597. }
  31598. ,
  31599. a.prototype.clone = function() {
  31600. return SerializationHelper.Clone(function() {
  31601. return new a
  31602. }, this)
  31603. }
  31604. ,
  31605. a.prototype.serialize = function() {
  31606. return SerializationHelper.Serialize(this)
  31607. }
  31608. ,
  31609. a.Parse = function(e) {
  31610. return SerializationHelper.Parse(function() {
  31611. return new a
  31612. }, e, null, null)
  31613. }
  31614. ,
  31615. __decorate([serialize()], a.prototype, "_globalHue", void 0),
  31616. __decorate([serialize()], a.prototype, "_globalDensity", void 0),
  31617. __decorate([serialize()], a.prototype, "_globalSaturation", void 0),
  31618. __decorate([serialize()], a.prototype, "_globalExposure", void 0),
  31619. __decorate([serialize()], a.prototype, "_highlightsHue", void 0),
  31620. __decorate([serialize()], a.prototype, "_highlightsDensity", void 0),
  31621. __decorate([serialize()], a.prototype, "_highlightsSaturation", void 0),
  31622. __decorate([serialize()], a.prototype, "_highlightsExposure", void 0),
  31623. __decorate([serialize()], a.prototype, "_midtonesHue", void 0),
  31624. __decorate([serialize()], a.prototype, "_midtonesDensity", void 0),
  31625. __decorate([serialize()], a.prototype, "_midtonesSaturation", void 0),
  31626. __decorate([serialize()], a.prototype, "_midtonesExposure", void 0),
  31627. a
  31628. }();
  31629. SerializationHelper._ColorCurvesParser = ColorCurves.Parse;
  31630. var ImageProcessingConfigurationDefines = function(a) {
  31631. __extends(e, a);
  31632. function e() {
  31633. var i = a.call(this) || this;
  31634. return i.IMAGEPROCESSING = !1,
  31635. i.VIGNETTE = !1,
  31636. i.VIGNETTEBLENDMODEMULTIPLY = !1,
  31637. i.VIGNETTEBLENDMODEOPAQUE = !1,
  31638. i.TONEMAPPING = !1,
  31639. i.TONEMAPPING_ACES = !1,
  31640. i.CONTRAST = !1,
  31641. i.COLORCURVES = !1,
  31642. i.COLORGRADING = !1,
  31643. i.COLORGRADING3D = !1,
  31644. i.SAMPLER3DGREENDEPTH = !1,
  31645. i.SAMPLER3DBGRMAP = !1,
  31646. i.IMAGEPROCESSINGPOSTPROCESS = !1,
  31647. i.EXPOSURE = !1,
  31648. i.SKIPFINALCOLORCLAMP = !1,
  31649. i.rebuild(),
  31650. i
  31651. }
  31652. return e
  31653. }(MaterialDefines)
  31654. , ImageProcessingConfiguration = function() {
  31655. function a() {
  31656. this.colorCurves = new ColorCurves,
  31657. this._colorCurvesEnabled = !1,
  31658. this._colorGradingEnabled = !1,
  31659. this._colorGradingWithGreenDepth = !0,
  31660. this._colorGradingBGR = !0,
  31661. this._exposure = 1,
  31662. this._toneMappingEnabled = !1,
  31663. this._toneMappingType = a.TONEMAPPING_STANDARD,
  31664. this._contrast = 1,
  31665. this.vignetteStretch = 0,
  31666. this.vignetteCentreX = 0,
  31667. this.vignetteCentreY = 0,
  31668. this.vignetteWeight = 1.5,
  31669. this.vignetteColor = new Color4(0,0,0,0),
  31670. this.vignetteCameraFov = .5,
  31671. this._vignetteBlendMode = a.VIGNETTEMODE_MULTIPLY,
  31672. this._vignetteEnabled = !1,
  31673. this._skipFinalColorClamp = !1,
  31674. this._applyByPostProcess = !1,
  31675. this._isEnabled = !0,
  31676. this.onUpdateParameters = new Observable
  31677. }
  31678. return Object.defineProperty(a.prototype, "colorCurvesEnabled", {
  31679. get: function() {
  31680. return this._colorCurvesEnabled
  31681. },
  31682. set: function(e) {
  31683. this._colorCurvesEnabled !== e && (this._colorCurvesEnabled = e,
  31684. this._updateParameters())
  31685. },
  31686. enumerable: !1,
  31687. configurable: !0
  31688. }),
  31689. Object.defineProperty(a.prototype, "colorGradingTexture", {
  31690. get: function() {
  31691. return this._colorGradingTexture
  31692. },
  31693. set: function(e) {
  31694. this._colorGradingTexture !== e && (this._colorGradingTexture = e,
  31695. this._updateParameters())
  31696. },
  31697. enumerable: !1,
  31698. configurable: !0
  31699. }),
  31700. Object.defineProperty(a.prototype, "colorGradingEnabled", {
  31701. get: function() {
  31702. return this._colorGradingEnabled
  31703. },
  31704. set: function(e) {
  31705. this._colorGradingEnabled !== e && (this._colorGradingEnabled = e,
  31706. this._updateParameters())
  31707. },
  31708. enumerable: !1,
  31709. configurable: !0
  31710. }),
  31711. Object.defineProperty(a.prototype, "colorGradingWithGreenDepth", {
  31712. get: function() {
  31713. return this._colorGradingWithGreenDepth
  31714. },
  31715. set: function(e) {
  31716. this._colorGradingWithGreenDepth !== e && (this._colorGradingWithGreenDepth = e,
  31717. this._updateParameters())
  31718. },
  31719. enumerable: !1,
  31720. configurable: !0
  31721. }),
  31722. Object.defineProperty(a.prototype, "colorGradingBGR", {
  31723. get: function() {
  31724. return this._colorGradingBGR
  31725. },
  31726. set: function(e) {
  31727. this._colorGradingBGR !== e && (this._colorGradingBGR = e,
  31728. this._updateParameters())
  31729. },
  31730. enumerable: !1,
  31731. configurable: !0
  31732. }),
  31733. Object.defineProperty(a.prototype, "exposure", {
  31734. get: function() {
  31735. return this._exposure
  31736. },
  31737. set: function(e) {
  31738. this._exposure !== e && (this._exposure = e,
  31739. this._updateParameters())
  31740. },
  31741. enumerable: !1,
  31742. configurable: !0
  31743. }),
  31744. Object.defineProperty(a.prototype, "toneMappingEnabled", {
  31745. get: function() {
  31746. return this._toneMappingEnabled
  31747. },
  31748. set: function(e) {
  31749. this._toneMappingEnabled !== e && (this._toneMappingEnabled = e,
  31750. this._updateParameters())
  31751. },
  31752. enumerable: !1,
  31753. configurable: !0
  31754. }),
  31755. Object.defineProperty(a.prototype, "toneMappingType", {
  31756. get: function() {
  31757. return this._toneMappingType
  31758. },
  31759. set: function(e) {
  31760. this._toneMappingType !== e && (this._toneMappingType = e,
  31761. this._updateParameters())
  31762. },
  31763. enumerable: !1,
  31764. configurable: !0
  31765. }),
  31766. Object.defineProperty(a.prototype, "contrast", {
  31767. get: function() {
  31768. return this._contrast
  31769. },
  31770. set: function(e) {
  31771. this._contrast !== e && (this._contrast = e,
  31772. this._updateParameters())
  31773. },
  31774. enumerable: !1,
  31775. configurable: !0
  31776. }),
  31777. Object.defineProperty(a.prototype, "vignetteBlendMode", {
  31778. get: function() {
  31779. return this._vignetteBlendMode
  31780. },
  31781. set: function(e) {
  31782. this._vignetteBlendMode !== e && (this._vignetteBlendMode = e,
  31783. this._updateParameters())
  31784. },
  31785. enumerable: !1,
  31786. configurable: !0
  31787. }),
  31788. Object.defineProperty(a.prototype, "vignetteEnabled", {
  31789. get: function() {
  31790. return this._vignetteEnabled
  31791. },
  31792. set: function(e) {
  31793. this._vignetteEnabled !== e && (this._vignetteEnabled = e,
  31794. this._updateParameters())
  31795. },
  31796. enumerable: !1,
  31797. configurable: !0
  31798. }),
  31799. Object.defineProperty(a.prototype, "skipFinalColorClamp", {
  31800. get: function() {
  31801. return this._skipFinalColorClamp
  31802. },
  31803. set: function(e) {
  31804. this._skipFinalColorClamp !== e && (this._skipFinalColorClamp = e,
  31805. this._updateParameters())
  31806. },
  31807. enumerable: !1,
  31808. configurable: !0
  31809. }),
  31810. Object.defineProperty(a.prototype, "applyByPostProcess", {
  31811. get: function() {
  31812. return this._applyByPostProcess
  31813. },
  31814. set: function(e) {
  31815. this._applyByPostProcess !== e && (this._applyByPostProcess = e,
  31816. this._updateParameters())
  31817. },
  31818. enumerable: !1,
  31819. configurable: !0
  31820. }),
  31821. Object.defineProperty(a.prototype, "isEnabled", {
  31822. get: function() {
  31823. return this._isEnabled
  31824. },
  31825. set: function(e) {
  31826. this._isEnabled !== e && (this._isEnabled = e,
  31827. this._updateParameters())
  31828. },
  31829. enumerable: !1,
  31830. configurable: !0
  31831. }),
  31832. a.prototype._updateParameters = function() {
  31833. this.onUpdateParameters.notifyObservers(this)
  31834. }
  31835. ,
  31836. a.prototype.getClassName = function() {
  31837. return "ImageProcessingConfiguration"
  31838. }
  31839. ,
  31840. a.PrepareUniforms = function(e, i) {
  31841. i.EXPOSURE && e.push("exposureLinear"),
  31842. i.CONTRAST && e.push("contrast"),
  31843. i.COLORGRADING && e.push("colorTransformSettings"),
  31844. i.VIGNETTE && (e.push("vInverseScreenSize"),
  31845. e.push("vignetteSettings1"),
  31846. e.push("vignetteSettings2")),
  31847. i.COLORCURVES && ColorCurves.PrepareUniforms(e)
  31848. }
  31849. ,
  31850. a.PrepareSamplers = function(e, i) {
  31851. i.COLORGRADING && e.push("txColorTransform")
  31852. }
  31853. ,
  31854. a.prototype.prepareDefines = function(e, i) {
  31855. if (i === void 0 && (i = !1),
  31856. i !== this.applyByPostProcess || !this._isEnabled) {
  31857. e.VIGNETTE = !1,
  31858. e.TONEMAPPING = !1,
  31859. e.TONEMAPPING_ACES = !1,
  31860. e.CONTRAST = !1,
  31861. e.EXPOSURE = !1,
  31862. e.COLORCURVES = !1,
  31863. e.COLORGRADING = !1,
  31864. e.COLORGRADING3D = !1,
  31865. e.IMAGEPROCESSING = !1,
  31866. e.SKIPFINALCOLORCLAMP = this.skipFinalColorClamp,
  31867. e.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess && this._isEnabled;
  31868. return
  31869. }
  31870. switch (e.VIGNETTE = this.vignetteEnabled,
  31871. e.VIGNETTEBLENDMODEMULTIPLY = this.vignetteBlendMode === a._VIGNETTEMODE_MULTIPLY,
  31872. e.VIGNETTEBLENDMODEOPAQUE = !e.VIGNETTEBLENDMODEMULTIPLY,
  31873. e.TONEMAPPING = this.toneMappingEnabled,
  31874. this._toneMappingType) {
  31875. case a.TONEMAPPING_ACES:
  31876. e.TONEMAPPING_ACES = !0;
  31877. break;
  31878. default:
  31879. e.TONEMAPPING_ACES = !1;
  31880. break
  31881. }
  31882. e.CONTRAST = this.contrast !== 1,
  31883. e.EXPOSURE = this.exposure !== 1,
  31884. e.COLORCURVES = this.colorCurvesEnabled && !!this.colorCurves,
  31885. e.COLORGRADING = this.colorGradingEnabled && !!this.colorGradingTexture,
  31886. e.COLORGRADING ? e.COLORGRADING3D = this.colorGradingTexture.is3D : e.COLORGRADING3D = !1,
  31887. e.SAMPLER3DGREENDEPTH = this.colorGradingWithGreenDepth,
  31888. e.SAMPLER3DBGRMAP = this.colorGradingBGR,
  31889. e.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess,
  31890. e.SKIPFINALCOLORCLAMP = this.skipFinalColorClamp,
  31891. e.IMAGEPROCESSING = e.VIGNETTE || e.TONEMAPPING || e.CONTRAST || e.EXPOSURE || e.COLORCURVES || e.COLORGRADING
  31892. }
  31893. ,
  31894. a.prototype.isReady = function() {
  31895. return !this.colorGradingEnabled || !this.colorGradingTexture || this.colorGradingTexture.isReady()
  31896. }
  31897. ,
  31898. a.prototype.bind = function(e, i) {
  31899. if (this._colorCurvesEnabled && this.colorCurves && ColorCurves.Bind(this.colorCurves, e),
  31900. this._vignetteEnabled) {
  31901. var o = 1 / e.getEngine().getRenderWidth()
  31902. , s = 1 / e.getEngine().getRenderHeight();
  31903. e.setFloat2("vInverseScreenSize", o, s);
  31904. var c = i != null ? i : s / o
  31905. , d = Math.tan(this.vignetteCameraFov * .5)
  31906. , _ = d * c
  31907. , b = Math.sqrt(_ * d);
  31908. _ = Tools.Mix(_, b, this.vignetteStretch),
  31909. d = Tools.Mix(d, b, this.vignetteStretch),
  31910. e.setFloat4("vignetteSettings1", _, d, -_ * this.vignetteCentreX, -d * this.vignetteCentreY);
  31911. var k = -2 * this.vignetteWeight;
  31912. e.setFloat4("vignetteSettings2", this.vignetteColor.r, this.vignetteColor.g, this.vignetteColor.b, k)
  31913. }
  31914. if (e.setFloat("exposureLinear", this.exposure),
  31915. e.setFloat("contrast", this.contrast),
  31916. this.colorGradingTexture) {
  31917. e.setTexture("txColorTransform", this.colorGradingTexture);
  31918. var j = this.colorGradingTexture.getSize().height;
  31919. e.setFloat4("colorTransformSettings", (j - 1) / j, .5 / j, j, this.colorGradingTexture.level)
  31920. }
  31921. }
  31922. ,
  31923. a.prototype.clone = function() {
  31924. return SerializationHelper.Clone(function() {
  31925. return new a
  31926. }, this)
  31927. }
  31928. ,
  31929. a.prototype.serialize = function() {
  31930. return SerializationHelper.Serialize(this)
  31931. }
  31932. ,
  31933. a.Parse = function(e) {
  31934. return SerializationHelper.Parse(function() {
  31935. return new a
  31936. }, e, null, null)
  31937. }
  31938. ,
  31939. Object.defineProperty(a, "VIGNETTEMODE_MULTIPLY", {
  31940. get: function() {
  31941. return this._VIGNETTEMODE_MULTIPLY
  31942. },
  31943. enumerable: !1,
  31944. configurable: !0
  31945. }),
  31946. Object.defineProperty(a, "VIGNETTEMODE_OPAQUE", {
  31947. get: function() {
  31948. return this._VIGNETTEMODE_OPAQUE
  31949. },
  31950. enumerable: !1,
  31951. configurable: !0
  31952. }),
  31953. a.TONEMAPPING_STANDARD = 0,
  31954. a.TONEMAPPING_ACES = 1,
  31955. a._VIGNETTEMODE_MULTIPLY = 0,
  31956. a._VIGNETTEMODE_OPAQUE = 1,
  31957. __decorate([serializeAsColorCurves()], a.prototype, "colorCurves", void 0),
  31958. __decorate([serialize()], a.prototype, "_colorCurvesEnabled", void 0),
  31959. __decorate([serializeAsTexture("colorGradingTexture")], a.prototype, "_colorGradingTexture", void 0),
  31960. __decorate([serialize()], a.prototype, "_colorGradingEnabled", void 0),
  31961. __decorate([serialize()], a.prototype, "_colorGradingWithGreenDepth", void 0),
  31962. __decorate([serialize()], a.prototype, "_colorGradingBGR", void 0),
  31963. __decorate([serialize()], a.prototype, "_exposure", void 0),
  31964. __decorate([serialize()], a.prototype, "_toneMappingEnabled", void 0),
  31965. __decorate([serialize()], a.prototype, "_toneMappingType", void 0),
  31966. __decorate([serialize()], a.prototype, "_contrast", void 0),
  31967. __decorate([serialize()], a.prototype, "vignetteStretch", void 0),
  31968. __decorate([serialize()], a.prototype, "vignetteCentreX", void 0),
  31969. __decorate([serialize()], a.prototype, "vignetteCentreY", void 0),
  31970. __decorate([serialize()], a.prototype, "vignetteWeight", void 0),
  31971. __decorate([serializeAsColor4()], a.prototype, "vignetteColor", void 0),
  31972. __decorate([serialize()], a.prototype, "vignetteCameraFov", void 0),
  31973. __decorate([serialize()], a.prototype, "_vignetteBlendMode", void 0),
  31974. __decorate([serialize()], a.prototype, "_vignetteEnabled", void 0),
  31975. __decorate([serialize()], a.prototype, "_skipFinalColorClamp", void 0),
  31976. __decorate([serialize()], a.prototype, "_applyByPostProcess", void 0),
  31977. __decorate([serialize()], a.prototype, "_isEnabled", void 0),
  31978. a
  31979. }();
  31980. SerializationHelper._ImageProcessingConfigurationParser = ImageProcessingConfiguration.Parse;
  31981. var ActionEvent = function() {
  31982. function a(e, i, o, s, c, d) {
  31983. this.source = e,
  31984. this.pointerX = i,
  31985. this.pointerY = o,
  31986. this.meshUnderPointer = s,
  31987. this.sourceEvent = c,
  31988. this.additionalData = d
  31989. }
  31990. return a.CreateNew = function(e, i, o) {
  31991. var s = e.getScene();
  31992. return new a(e,s.pointerX,s.pointerY,s.meshUnderPointer || e,i,o)
  31993. }
  31994. ,
  31995. a.CreateNewFromSprite = function(e, i, o, s) {
  31996. return new a(e,i.pointerX,i.pointerY,i.meshUnderPointer,o,s)
  31997. }
  31998. ,
  31999. a.CreateNewFromScene = function(e, i) {
  32000. return new a(null,e.pointerX,e.pointerY,e.meshUnderPointer,i)
  32001. }
  32002. ,
  32003. a.CreateNewFromPrimitive = function(e, i, o, s) {
  32004. return new a(e,i.x,i.y,null,o,s)
  32005. }
  32006. ,
  32007. a
  32008. }(), PostProcessManager = function() {
  32009. function a(e) {
  32010. this._vertexBuffers = {},
  32011. this._scene = e
  32012. }
  32013. return a.prototype._prepareBuffers = function() {
  32014. if (!this._vertexBuffers[VertexBuffer.PositionKind]) {
  32015. var e = [];
  32016. e.push(1, 1),
  32017. e.push(-1, 1),
  32018. e.push(-1, -1),
  32019. e.push(1, -1),
  32020. this._vertexBuffers[VertexBuffer.PositionKind] = new VertexBuffer(this._scene.getEngine(),e,VertexBuffer.PositionKind,!1,!1,2),
  32021. this._buildIndexBuffer()
  32022. }
  32023. }
  32024. ,
  32025. a.prototype._buildIndexBuffer = function() {
  32026. var e = [];
  32027. e.push(0),
  32028. e.push(1),
  32029. e.push(2),
  32030. e.push(0),
  32031. e.push(2),
  32032. e.push(3),
  32033. this._indexBuffer = this._scene.getEngine().createIndexBuffer(e)
  32034. }
  32035. ,
  32036. a.prototype._rebuild = function() {
  32037. var e = this._vertexBuffers[VertexBuffer.PositionKind];
  32038. !e || (e._rebuild(),
  32039. this._buildIndexBuffer())
  32040. }
  32041. ,
  32042. a.prototype._prepareFrame = function(e, i) {
  32043. e === void 0 && (e = null),
  32044. i === void 0 && (i = null);
  32045. var o = this._scene.activeCamera;
  32046. return !o || (i = i || o._postProcesses.filter(function(s) {
  32047. return s != null
  32048. }),
  32049. !i || i.length === 0 || !this._scene.postProcessesEnabled) ? !1 : (i[0].activate(o, e, i != null),
  32050. !0)
  32051. }
  32052. ,
  32053. a.prototype.directRender = function(e, i, o, s, c, d) {
  32054. var _;
  32055. i === void 0 && (i = null),
  32056. o === void 0 && (o = !1),
  32057. s === void 0 && (s = 0),
  32058. c === void 0 && (c = 0),
  32059. d === void 0 && (d = !1);
  32060. for (var b = this._scene.getEngine(), k = 0; k < e.length; k++) {
  32061. k < e.length - 1 ? e[k + 1].activate(this._scene.activeCamera, i == null ? void 0 : i.texture) : (i ? b.bindFramebuffer(i, s, void 0, void 0, o, c) : d || b.restoreDefaultFramebuffer(),
  32062. (_ = b._debugInsertMarker) === null || _ === void 0 || _.call(b, "post process " + e[k].name + " output"));
  32063. var j = e[k]
  32064. , $ = j.apply();
  32065. $ && (j.onBeforeRenderObservable.notifyObservers($),
  32066. this._prepareBuffers(),
  32067. b.bindBuffers(this._vertexBuffers, this._indexBuffer, $),
  32068. b.drawElementsType(0, 0, 6),
  32069. j.onAfterRenderObservable.notifyObservers($))
  32070. }
  32071. b.setDepthBuffer(!0),
  32072. b.setDepthWrite(!0)
  32073. }
  32074. ,
  32075. a.prototype._finalizeFrame = function(e, i, o, s, c) {
  32076. var d;
  32077. c === void 0 && (c = !1);
  32078. var _ = this._scene.activeCamera;
  32079. if (!!_ && (s = s || _._postProcesses.filter(function(et) {
  32080. return et != null
  32081. }),
  32082. !(s.length === 0 || !this._scene.postProcessesEnabled))) {
  32083. for (var b = this._scene.getEngine(), k = 0, j = s.length; k < j; k++) {
  32084. var $ = s[k];
  32085. if (k < j - 1 ? $._outputTexture = s[k + 1].activate(_, i == null ? void 0 : i.texture) : (i ? (b.bindFramebuffer(i, o, void 0, void 0, c),
  32086. $._outputTexture = i) : (b.restoreDefaultFramebuffer(),
  32087. $._outputTexture = null),
  32088. (d = b._debugInsertMarker) === null || d === void 0 || d.call(b, "post process " + s[k].name + " output")),
  32089. e)
  32090. break;
  32091. var _e = $.apply();
  32092. _e && ($.onBeforeRenderObservable.notifyObservers(_e),
  32093. this._prepareBuffers(),
  32094. b.bindBuffers(this._vertexBuffers, this._indexBuffer, _e),
  32095. b.drawElementsType(0, 0, 6),
  32096. $.onAfterRenderObservable.notifyObservers(_e))
  32097. }
  32098. b.setDepthBuffer(!0),
  32099. b.setDepthWrite(!0),
  32100. b.setAlphaMode(0)
  32101. }
  32102. }
  32103. ,
  32104. a.prototype.dispose = function() {
  32105. var e = this._vertexBuffers[VertexBuffer.PositionKind];
  32106. e && (e.dispose(),
  32107. this._vertexBuffers[VertexBuffer.PositionKind] = null),
  32108. this._indexBuffer && (this._scene.getEngine()._releaseBuffer(this._indexBuffer),
  32109. this._indexBuffer = null)
  32110. }
  32111. ,
  32112. a
  32113. }(), RenderingGroup = function() {
  32114. function a(e, i, o, s, c) {
  32115. o === void 0 && (o = null),
  32116. s === void 0 && (s = null),
  32117. c === void 0 && (c = null),
  32118. this.index = e,
  32119. this._opaqueSubMeshes = new SmartArray(256),
  32120. this._transparentSubMeshes = new SmartArray(256),
  32121. this._alphaTestSubMeshes = new SmartArray(256),
  32122. this._depthOnlySubMeshes = new SmartArray(256),
  32123. this._particleSystems = new SmartArray(256),
  32124. this._spriteManagers = new SmartArray(256),
  32125. this._edgesRenderers = new SmartArrayNoDuplicate(16),
  32126. this._scene = i,
  32127. this.opaqueSortCompareFn = o,
  32128. this.alphaTestSortCompareFn = s,
  32129. this.transparentSortCompareFn = c
  32130. }
  32131. return Object.defineProperty(a.prototype, "opaqueSortCompareFn", {
  32132. set: function(e) {
  32133. this._opaqueSortCompareFn = e,
  32134. e ? this._renderOpaque = this.renderOpaqueSorted : this._renderOpaque = a.renderUnsorted
  32135. },
  32136. enumerable: !1,
  32137. configurable: !0
  32138. }),
  32139. Object.defineProperty(a.prototype, "alphaTestSortCompareFn", {
  32140. set: function(e) {
  32141. this._alphaTestSortCompareFn = e,
  32142. e ? this._renderAlphaTest = this.renderAlphaTestSorted : this._renderAlphaTest = a.renderUnsorted
  32143. },
  32144. enumerable: !1,
  32145. configurable: !0
  32146. }),
  32147. Object.defineProperty(a.prototype, "transparentSortCompareFn", {
  32148. set: function(e) {
  32149. e ? this._transparentSortCompareFn = e : this._transparentSortCompareFn = a.defaultTransparentSortCompare,
  32150. this._renderTransparent = this.renderTransparentSorted
  32151. },
  32152. enumerable: !1,
  32153. configurable: !0
  32154. }),
  32155. a.prototype.render = function(e, i, o, s) {
  32156. if (e) {
  32157. e(this._opaqueSubMeshes, this._alphaTestSubMeshes, this._transparentSubMeshes, this._depthOnlySubMeshes);
  32158. return
  32159. }
  32160. var c = this._scene.getEngine();
  32161. this._depthOnlySubMeshes.length !== 0 && (c.setColorWrite(!1),
  32162. this._renderAlphaTest(this._depthOnlySubMeshes),
  32163. c.setColorWrite(!0)),
  32164. this._opaqueSubMeshes.length !== 0 && this._renderOpaque(this._opaqueSubMeshes),
  32165. this._alphaTestSubMeshes.length !== 0 && this._renderAlphaTest(this._alphaTestSubMeshes);
  32166. var d = c.getStencilBuffer();
  32167. if (c.setStencilBuffer(!1),
  32168. i && this._renderSprites(),
  32169. o && this._renderParticles(s),
  32170. this.onBeforeTransparentRendering && this.onBeforeTransparentRendering(),
  32171. (this._transparentSubMeshes.length !== 0 || this._scene.useOrderIndependentTransparency) && (c.setStencilBuffer(d),
  32172. this._scene.useOrderIndependentTransparency ? this._scene.depthPeelingRenderer.render(this._transparentSubMeshes) : this._renderTransparent(this._transparentSubMeshes),
  32173. c.setAlphaMode(0)),
  32174. c.setStencilBuffer(!1),
  32175. this._edgesRenderers.length) {
  32176. for (var _ = 0; _ < this._edgesRenderers.length; _++)
  32177. this._edgesRenderers.data[_].render();
  32178. c.setAlphaMode(0)
  32179. }
  32180. c.setStencilBuffer(d)
  32181. }
  32182. ,
  32183. a.prototype.renderOpaqueSorted = function(e) {
  32184. return a.renderSorted(e, this._opaqueSortCompareFn, this._scene.activeCamera, !1)
  32185. }
  32186. ,
  32187. a.prototype.renderAlphaTestSorted = function(e) {
  32188. return a.renderSorted(e, this._alphaTestSortCompareFn, this._scene.activeCamera, !1)
  32189. }
  32190. ,
  32191. a.prototype.renderTransparentSorted = function(e) {
  32192. return a.renderSorted(e, this._transparentSortCompareFn, this._scene.activeCamera, !0)
  32193. }
  32194. ,
  32195. a.renderSorted = function(e, i, o, s) {
  32196. for (var c = 0, d, _ = o ? o.globalPosition : a._zeroVector; c < e.length; c++)
  32197. d = e.data[c],
  32198. d._alphaIndex = d.getMesh().alphaIndex,
  32199. d._distanceToCamera = Vector3.Distance(d.getBoundingInfo().boundingSphere.centerWorld, _);
  32200. var b = e.data.slice(0, e.length);
  32201. for (i && b.sort(i),
  32202. c = 0; c < b.length; c++) {
  32203. if (d = b[c],
  32204. s) {
  32205. var k = d.getMaterial();
  32206. if (k && k.needDepthPrePass) {
  32207. var j = k.getScene().getEngine();
  32208. j.setColorWrite(!1),
  32209. j.setAlphaMode(0),
  32210. d.render(!1),
  32211. j.setColorWrite(!0)
  32212. }
  32213. }
  32214. d.render(s)
  32215. }
  32216. }
  32217. ,
  32218. a.renderUnsorted = function(e) {
  32219. for (var i = 0; i < e.length; i++) {
  32220. var o = e.data[i];
  32221. o.render(!1)
  32222. }
  32223. }
  32224. ,
  32225. a.defaultTransparentSortCompare = function(e, i) {
  32226. return e._alphaIndex > i._alphaIndex ? 1 : e._alphaIndex < i._alphaIndex ? -1 : a.backToFrontSortCompare(e, i)
  32227. }
  32228. ,
  32229. a.backToFrontSortCompare = function(e, i) {
  32230. return e._distanceToCamera < i._distanceToCamera ? 1 : e._distanceToCamera > i._distanceToCamera ? -1 : 0
  32231. }
  32232. ,
  32233. a.frontToBackSortCompare = function(e, i) {
  32234. return e._distanceToCamera < i._distanceToCamera ? -1 : e._distanceToCamera > i._distanceToCamera ? 1 : 0
  32235. }
  32236. ,
  32237. a.prototype.prepare = function() {
  32238. this._opaqueSubMeshes.reset(),
  32239. this._transparentSubMeshes.reset(),
  32240. this._alphaTestSubMeshes.reset(),
  32241. this._depthOnlySubMeshes.reset(),
  32242. this._particleSystems.reset(),
  32243. this._spriteManagers.reset(),
  32244. this._edgesRenderers.reset()
  32245. }
  32246. ,
  32247. a.prototype.dispose = function() {
  32248. this._opaqueSubMeshes.dispose(),
  32249. this._transparentSubMeshes.dispose(),
  32250. this._alphaTestSubMeshes.dispose(),
  32251. this._depthOnlySubMeshes.dispose(),
  32252. this._particleSystems.dispose(),
  32253. this._spriteManagers.dispose(),
  32254. this._edgesRenderers.dispose()
  32255. }
  32256. ,
  32257. a.prototype.dispatch = function(e, i, o) {
  32258. i === void 0 && (i = e.getMesh()),
  32259. o === void 0 && (o = e.getMaterial()),
  32260. o != null && (o.needAlphaBlendingForMesh(i) ? this._transparentSubMeshes.push(e) : o.needAlphaTesting() ? (o.needDepthPrePass && this._depthOnlySubMeshes.push(e),
  32261. this._alphaTestSubMeshes.push(e)) : (o.needDepthPrePass && this._depthOnlySubMeshes.push(e),
  32262. this._opaqueSubMeshes.push(e)),
  32263. i._renderingGroup = this,
  32264. i._edgesRenderer && i._edgesRenderer.isEnabled && this._edgesRenderers.pushNoDuplicate(i._edgesRenderer))
  32265. }
  32266. ,
  32267. a.prototype.dispatchSprites = function(e) {
  32268. this._spriteManagers.push(e)
  32269. }
  32270. ,
  32271. a.prototype.dispatchParticles = function(e) {
  32272. this._particleSystems.push(e)
  32273. }
  32274. ,
  32275. a.prototype._renderParticles = function(e) {
  32276. if (this._particleSystems.length !== 0) {
  32277. var i = this._scene.activeCamera;
  32278. this._scene.onBeforeParticlesRenderingObservable.notifyObservers(this._scene);
  32279. for (var o = 0; o < this._particleSystems.length; o++) {
  32280. var s = this._particleSystems.data[o];
  32281. if ((i && i.layerMask & s.layerMask) !== 0) {
  32282. var c = s.emitter;
  32283. (!c.position || !e || e.indexOf(c) !== -1) && this._scene._activeParticles.addCount(s.render(), !1)
  32284. }
  32285. }
  32286. this._scene.onAfterParticlesRenderingObservable.notifyObservers(this._scene)
  32287. }
  32288. }
  32289. ,
  32290. a.prototype._renderSprites = function() {
  32291. if (!(!this._scene.spritesEnabled || this._spriteManagers.length === 0)) {
  32292. var e = this._scene.activeCamera;
  32293. this._scene.onBeforeSpritesRenderingObservable.notifyObservers(this._scene);
  32294. for (var i = 0; i < this._spriteManagers.length; i++) {
  32295. var o = this._spriteManagers.data[i];
  32296. (e && e.layerMask & o.layerMask) !== 0 && o.render()
  32297. }
  32298. this._scene.onAfterSpritesRenderingObservable.notifyObservers(this._scene)
  32299. }
  32300. }
  32301. ,
  32302. a._zeroVector = Vector3.Zero(),
  32303. a
  32304. }(), RenderingGroupInfo = function() {
  32305. function a() {}
  32306. return a
  32307. }(), RenderingManager = function() {
  32308. function a(e) {
  32309. this._useSceneAutoClearSetup = !1,
  32310. this._renderingGroups = new Array,
  32311. this._autoClearDepthStencil = {},
  32312. this._customOpaqueSortCompareFn = {},
  32313. this._customAlphaTestSortCompareFn = {},
  32314. this._customTransparentSortCompareFn = {},
  32315. this._renderingGroupInfo = new RenderingGroupInfo,
  32316. this._scene = e;
  32317. for (var i = a.MIN_RENDERINGGROUPS; i < a.MAX_RENDERINGGROUPS; i++)
  32318. this._autoClearDepthStencil[i] = {
  32319. autoClear: !0,
  32320. depth: !0,
  32321. stencil: !0
  32322. }
  32323. }
  32324. return a.prototype._clearDepthStencilBuffer = function(e, i) {
  32325. e === void 0 && (e = !0),
  32326. i === void 0 && (i = !0),
  32327. !this._depthStencilBufferAlreadyCleaned && (this._scene.getEngine().clear(null, !1, e, i),
  32328. this._depthStencilBufferAlreadyCleaned = !0)
  32329. }
  32330. ,
  32331. a.prototype.render = function(e, i, o, s) {
  32332. var c = this._renderingGroupInfo;
  32333. if (c.scene = this._scene,
  32334. c.camera = this._scene.activeCamera,
  32335. this._scene.spriteManagers && s)
  32336. for (var d = 0; d < this._scene.spriteManagers.length; d++) {
  32337. var _ = this._scene.spriteManagers[d];
  32338. this.dispatchSprites(_)
  32339. }
  32340. for (var d = a.MIN_RENDERINGGROUPS; d < a.MAX_RENDERINGGROUPS; d++) {
  32341. this._depthStencilBufferAlreadyCleaned = d === a.MIN_RENDERINGGROUPS;
  32342. var b = this._renderingGroups[d];
  32343. if (!!b) {
  32344. var k = Math.pow(2, d);
  32345. if (c.renderingGroupId = d,
  32346. this._scene.onBeforeRenderingGroupObservable.notifyObservers(c, k),
  32347. a.AUTOCLEAR) {
  32348. var j = this._useSceneAutoClearSetup ? this._scene.getAutoClearDepthStencilSetup(d) : this._autoClearDepthStencil[d];
  32349. j && j.autoClear && this._clearDepthStencilBuffer(j.depth, j.stencil)
  32350. }
  32351. for (var $ = 0, _e = this._scene._beforeRenderingGroupDrawStage; $ < _e.length; $++) {
  32352. var et = _e[$];
  32353. et.action(d)
  32354. }
  32355. b.render(e, s, o, i);
  32356. for (var tt = 0, rt = this._scene._afterRenderingGroupDrawStage; tt < rt.length; tt++) {
  32357. var et = rt[tt];
  32358. et.action(d)
  32359. }
  32360. this._scene.onAfterRenderingGroupObservable.notifyObservers(c, k)
  32361. }
  32362. }
  32363. }
  32364. ,
  32365. a.prototype.reset = function() {
  32366. for (var e = a.MIN_RENDERINGGROUPS; e < a.MAX_RENDERINGGROUPS; e++) {
  32367. var i = this._renderingGroups[e];
  32368. i && i.prepare()
  32369. }
  32370. }
  32371. ,
  32372. a.prototype.dispose = function() {
  32373. this.freeRenderingGroups(),
  32374. this._renderingGroups.length = 0,
  32375. this._renderingGroupInfo = null
  32376. }
  32377. ,
  32378. a.prototype.freeRenderingGroups = function() {
  32379. for (var e = a.MIN_RENDERINGGROUPS; e < a.MAX_RENDERINGGROUPS; e++) {
  32380. var i = this._renderingGroups[e];
  32381. i && i.dispose()
  32382. }
  32383. }
  32384. ,
  32385. a.prototype._prepareRenderingGroup = function(e) {
  32386. this._renderingGroups[e] === void 0 && (this._renderingGroups[e] = new RenderingGroup(e,this._scene,this._customOpaqueSortCompareFn[e],this._customAlphaTestSortCompareFn[e],this._customTransparentSortCompareFn[e]))
  32387. }
  32388. ,
  32389. a.prototype.dispatchSprites = function(e) {
  32390. var i = e.renderingGroupId || 0;
  32391. this._prepareRenderingGroup(i),
  32392. this._renderingGroups[i].dispatchSprites(e)
  32393. }
  32394. ,
  32395. a.prototype.dispatchParticles = function(e) {
  32396. var i = e.renderingGroupId || 0;
  32397. this._prepareRenderingGroup(i),
  32398. this._renderingGroups[i].dispatchParticles(e)
  32399. }
  32400. ,
  32401. a.prototype.dispatch = function(e, i, o) {
  32402. i === void 0 && (i = e.getMesh());
  32403. var s = i.renderingGroupId || 0;
  32404. this._prepareRenderingGroup(s),
  32405. this._renderingGroups[s].dispatch(e, i, o)
  32406. }
  32407. ,
  32408. a.prototype.setRenderingOrder = function(e, i, o, s) {
  32409. if (i === void 0 && (i = null),
  32410. o === void 0 && (o = null),
  32411. s === void 0 && (s = null),
  32412. this._customOpaqueSortCompareFn[e] = i,
  32413. this._customAlphaTestSortCompareFn[e] = o,
  32414. this._customTransparentSortCompareFn[e] = s,
  32415. this._renderingGroups[e]) {
  32416. var c = this._renderingGroups[e];
  32417. c.opaqueSortCompareFn = this._customOpaqueSortCompareFn[e],
  32418. c.alphaTestSortCompareFn = this._customAlphaTestSortCompareFn[e],
  32419. c.transparentSortCompareFn = this._customTransparentSortCompareFn[e]
  32420. }
  32421. }
  32422. ,
  32423. a.prototype.setRenderingAutoClearDepthStencil = function(e, i, o, s) {
  32424. o === void 0 && (o = !0),
  32425. s === void 0 && (s = !0),
  32426. this._autoClearDepthStencil[e] = {
  32427. autoClear: i,
  32428. depth: o,
  32429. stencil: s
  32430. }
  32431. }
  32432. ,
  32433. a.prototype.getAutoClearDepthStencilSetup = function(e) {
  32434. return this._autoClearDepthStencil[e]
  32435. }
  32436. ,
  32437. a.MAX_RENDERINGGROUPS = 4,
  32438. a.MIN_RENDERINGGROUPS = 0,
  32439. a.AUTOCLEAR = !0,
  32440. a
  32441. }(), SceneComponentConstants = function() {
  32442. function a() {}
  32443. return a.NAME_EFFECTLAYER = "EffectLayer",
  32444. a.NAME_LAYER = "Layer",
  32445. a.NAME_LENSFLARESYSTEM = "LensFlareSystem",
  32446. a.NAME_BOUNDINGBOXRENDERER = "BoundingBoxRenderer",
  32447. a.NAME_PARTICLESYSTEM = "ParticleSystem",
  32448. a.NAME_GAMEPAD = "Gamepad",
  32449. a.NAME_SIMPLIFICATIONQUEUE = "SimplificationQueue",
  32450. a.NAME_GEOMETRYBUFFERRENDERER = "GeometryBufferRenderer",
  32451. a.NAME_PREPASSRENDERER = "PrePassRenderer",
  32452. a.NAME_DEPTHRENDERER = "DepthRenderer",
  32453. a.NAME_DEPTHPEELINGRENDERER = "DepthPeelingRenderer",
  32454. a.NAME_POSTPROCESSRENDERPIPELINEMANAGER = "PostProcessRenderPipelineManager",
  32455. a.NAME_SPRITE = "Sprite",
  32456. a.NAME_SUBSURFACE = "SubSurface",
  32457. a.NAME_OUTLINERENDERER = "Outline",
  32458. a.NAME_PROCEDURALTEXTURE = "ProceduralTexture",
  32459. a.NAME_SHADOWGENERATOR = "ShadowGenerator",
  32460. a.NAME_OCTREE = "Octree",
  32461. a.NAME_PHYSICSENGINE = "PhysicsEngine",
  32462. a.NAME_AUDIO = "Audio",
  32463. a.STEP_ISREADYFORMESH_EFFECTLAYER = 0,
  32464. a.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER = 0,
  32465. a.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER = 0,
  32466. a.STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER = 0,
  32467. a.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER = 1,
  32468. a.STEP_BEFORECAMERADRAW_PREPASS = 0,
  32469. a.STEP_BEFORECAMERADRAW_EFFECTLAYER = 1,
  32470. a.STEP_BEFORECAMERADRAW_LAYER = 2,
  32471. a.STEP_BEFORERENDERTARGETDRAW_PREPASS = 0,
  32472. a.STEP_BEFORERENDERTARGETDRAW_LAYER = 1,
  32473. a.STEP_BEFORERENDERINGMESH_PREPASS = 0,
  32474. a.STEP_BEFORERENDERINGMESH_OUTLINE = 1,
  32475. a.STEP_AFTERRENDERINGMESH_PREPASS = 0,
  32476. a.STEP_AFTERRENDERINGMESH_OUTLINE = 1,
  32477. a.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW = 0,
  32478. a.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER = 1,
  32479. a.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE = 0,
  32480. a.STEP_BEFORECAMERAUPDATE_GAMEPAD = 1,
  32481. a.STEP_BEFORECLEAR_PROCEDURALTEXTURE = 0,
  32482. a.STEP_AFTERRENDERTARGETDRAW_PREPASS = 0,
  32483. a.STEP_AFTERRENDERTARGETDRAW_LAYER = 1,
  32484. a.STEP_AFTERCAMERADRAW_PREPASS = 0,
  32485. a.STEP_AFTERCAMERADRAW_EFFECTLAYER = 1,
  32486. a.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM = 2,
  32487. a.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW = 3,
  32488. a.STEP_AFTERCAMERADRAW_LAYER = 4,
  32489. a.STEP_AFTERRENDER_AUDIO = 0,
  32490. a.STEP_GATHERRENDERTARGETS_DEPTHRENDERER = 0,
  32491. a.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER = 1,
  32492. a.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR = 2,
  32493. a.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER = 3,
  32494. a.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER = 0,
  32495. a.STEP_BEFORECLEARSTAGE_PREPASS = 0,
  32496. a.STEP_BEFORERENDERTARGETCLEARSTAGE_PREPASS = 0,
  32497. a.STEP_POINTERMOVE_SPRITE = 0,
  32498. a.STEP_POINTERDOWN_SPRITE = 0,
  32499. a.STEP_POINTERUP_SPRITE = 0,
  32500. a
  32501. }(), Stage = function(a) {
  32502. __extends(e, a);
  32503. function e(i) {
  32504. return a.apply(this, i) || this
  32505. }
  32506. return e.Create = function() {
  32507. return Object.create(e.prototype)
  32508. }
  32509. ,
  32510. e.prototype.registerStep = function(i, o, s) {
  32511. for (var c = 0, d = Number.MAX_VALUE; c < this.length; c++) {
  32512. var _ = this[c];
  32513. if (d = _.index,
  32514. i < d)
  32515. break
  32516. }
  32517. this.splice(c, 0, {
  32518. index: i,
  32519. component: o,
  32520. action: s.bind(o)
  32521. })
  32522. }
  32523. ,
  32524. e.prototype.clear = function() {
  32525. this.length = 0
  32526. }
  32527. ,
  32528. e
  32529. }(Array), PointerEventTypes = function() {
  32530. function a() {}
  32531. return a.POINTERDOWN = 1,
  32532. a.POINTERUP = 2,
  32533. a.POINTERMOVE = 4,
  32534. a.POINTERWHEEL = 8,
  32535. a.POINTERPICK = 16,
  32536. a.POINTERTAP = 32,
  32537. a.POINTERDOUBLETAP = 64,
  32538. a
  32539. }(), PointerInfoBase = function() {
  32540. function a(e, i) {
  32541. this.type = e,
  32542. this.event = i
  32543. }
  32544. return a
  32545. }(), PointerInfoPre = function(a) {
  32546. __extends(e, a);
  32547. function e(i, o, s, c) {
  32548. var d = a.call(this, i, o) || this;
  32549. return d.ray = null,
  32550. d.skipOnPointerObservable = !1,
  32551. d.localPosition = new Vector2(s,c),
  32552. d
  32553. }
  32554. return e
  32555. }(PointerInfoBase), PointerInfo = function(a) {
  32556. __extends(e, a);
  32557. function e(i, o, s) {
  32558. var c = a.call(this, i, o) || this;
  32559. return c.pickInfo = s,
  32560. c
  32561. }
  32562. return e
  32563. }(PointerInfoBase), AbstractActionManager = function() {
  32564. function a() {
  32565. this.hoverCursor = "",
  32566. this.actions = new Array,
  32567. this.isRecursive = !1
  32568. }
  32569. return Object.defineProperty(a, "HasTriggers", {
  32570. get: function() {
  32571. for (var e in a.Triggers)
  32572. if (a.Triggers.hasOwnProperty(e))
  32573. return !0;
  32574. return !1
  32575. },
  32576. enumerable: !1,
  32577. configurable: !0
  32578. }),
  32579. Object.defineProperty(a, "HasPickTriggers", {
  32580. get: function() {
  32581. for (var e in a.Triggers)
  32582. if (a.Triggers.hasOwnProperty(e)) {
  32583. var i = parseInt(e);
  32584. if (i >= 1 && i <= 7)
  32585. return !0
  32586. }
  32587. return !1
  32588. },
  32589. enumerable: !1,
  32590. configurable: !0
  32591. }),
  32592. a.HasSpecificTrigger = function(e) {
  32593. for (var i in a.Triggers)
  32594. if (a.Triggers.hasOwnProperty(i)) {
  32595. var o = parseInt(i);
  32596. if (o === e)
  32597. return !0
  32598. }
  32599. return !1
  32600. }
  32601. ,
  32602. a.Triggers = {},
  32603. a
  32604. }(), KeyboardEventTypes = function() {
  32605. function a() {}
  32606. return a.KEYDOWN = 1,
  32607. a.KEYUP = 2,
  32608. a
  32609. }(), KeyboardInfo = function() {
  32610. function a(e, i) {
  32611. this.type = e,
  32612. this.event = i
  32613. }
  32614. return a
  32615. }(), KeyboardInfoPre = function(a) {
  32616. __extends(e, a);
  32617. function e(i, o) {
  32618. var s = a.call(this, i, o) || this;
  32619. return s.type = i,
  32620. s.event = o,
  32621. s.skipOnPointerObservable = !1,
  32622. s
  32623. }
  32624. return e
  32625. }(KeyboardInfo), DeviceType;
  32626. (function(a) {
  32627. a[a.Generic = 0] = "Generic",
  32628. a[a.Keyboard = 1] = "Keyboard",
  32629. a[a.Mouse = 2] = "Mouse",
  32630. a[a.Touch = 3] = "Touch",
  32631. a[a.DualShock = 4] = "DualShock",
  32632. a[a.Xbox = 5] = "Xbox",
  32633. a[a.Switch = 6] = "Switch"
  32634. }
  32635. )(DeviceType || (DeviceType = {}));
  32636. var PointerInput;
  32637. (function(a) {
  32638. a[a.Horizontal = 0] = "Horizontal",
  32639. a[a.Vertical = 1] = "Vertical",
  32640. a[a.LeftClick = 2] = "LeftClick",
  32641. a[a.MiddleClick = 3] = "MiddleClick",
  32642. a[a.RightClick = 4] = "RightClick",
  32643. a[a.BrowserBack = 5] = "BrowserBack",
  32644. a[a.BrowserForward = 6] = "BrowserForward",
  32645. a[a.MouseWheelX = 7] = "MouseWheelX",
  32646. a[a.MouseWheelY = 8] = "MouseWheelY",
  32647. a[a.MouseWheelZ = 9] = "MouseWheelZ",
  32648. a[a.DeltaHorizontal = 10] = "DeltaHorizontal",
  32649. a[a.DeltaVertical = 11] = "DeltaVertical"
  32650. }
  32651. )(PointerInput || (PointerInput = {}));
  32652. var DualShockInput;
  32653. (function(a) {
  32654. a[a.Cross = 0] = "Cross",
  32655. a[a.Circle = 1] = "Circle",
  32656. a[a.Square = 2] = "Square",
  32657. a[a.Triangle = 3] = "Triangle",
  32658. a[a.L1 = 4] = "L1",
  32659. a[a.R1 = 5] = "R1",
  32660. a[a.L2 = 6] = "L2",
  32661. a[a.R2 = 7] = "R2",
  32662. a[a.Share = 8] = "Share",
  32663. a[a.Options = 9] = "Options",
  32664. a[a.L3 = 10] = "L3",
  32665. a[a.R3 = 11] = "R3",
  32666. a[a.DPadUp = 12] = "DPadUp",
  32667. a[a.DPadDown = 13] = "DPadDown",
  32668. a[a.DPadLeft = 14] = "DPadLeft",
  32669. a[a.DPadRight = 15] = "DPadRight",
  32670. a[a.Home = 16] = "Home",
  32671. a[a.TouchPad = 17] = "TouchPad",
  32672. a[a.LStickXAxis = 18] = "LStickXAxis",
  32673. a[a.LStickYAxis = 19] = "LStickYAxis",
  32674. a[a.RStickXAxis = 20] = "RStickXAxis",
  32675. a[a.RStickYAxis = 21] = "RStickYAxis"
  32676. }
  32677. )(DualShockInput || (DualShockInput = {}));
  32678. var XboxInput;
  32679. (function(a) {
  32680. a[a.A = 0] = "A",
  32681. a[a.B = 1] = "B",
  32682. a[a.X = 2] = "X",
  32683. a[a.Y = 3] = "Y",
  32684. a[a.LB = 4] = "LB",
  32685. a[a.RB = 5] = "RB",
  32686. a[a.LT = 6] = "LT",
  32687. a[a.RT = 7] = "RT",
  32688. a[a.Back = 8] = "Back",
  32689. a[a.Start = 9] = "Start",
  32690. a[a.LS = 10] = "LS",
  32691. a[a.RS = 11] = "RS",
  32692. a[a.DPadUp = 12] = "DPadUp",
  32693. a[a.DPadDown = 13] = "DPadDown",
  32694. a[a.DPadLeft = 14] = "DPadLeft",
  32695. a[a.DPadRight = 15] = "DPadRight",
  32696. a[a.Home = 16] = "Home",
  32697. a[a.LStickXAxis = 17] = "LStickXAxis",
  32698. a[a.LStickYAxis = 18] = "LStickYAxis",
  32699. a[a.RStickXAxis = 19] = "RStickXAxis",
  32700. a[a.RStickYAxis = 20] = "RStickYAxis"
  32701. }
  32702. )(XboxInput || (XboxInput = {}));
  32703. var SwitchInput;
  32704. (function(a) {
  32705. a[a.B = 0] = "B",
  32706. a[a.A = 1] = "A",
  32707. a[a.Y = 2] = "Y",
  32708. a[a.X = 3] = "X",
  32709. a[a.L = 4] = "L",
  32710. a[a.R = 5] = "R",
  32711. a[a.ZL = 6] = "ZL",
  32712. a[a.ZR = 7] = "ZR",
  32713. a[a.Minus = 8] = "Minus",
  32714. a[a.Plus = 9] = "Plus",
  32715. a[a.LS = 10] = "LS",
  32716. a[a.RS = 11] = "RS",
  32717. a[a.DPadUp = 12] = "DPadUp",
  32718. a[a.DPadDown = 13] = "DPadDown",
  32719. a[a.DPadLeft = 14] = "DPadLeft",
  32720. a[a.DPadRight = 15] = "DPadRight",
  32721. a[a.Home = 16] = "Home",
  32722. a[a.Capture = 17] = "Capture",
  32723. a[a.LStickXAxis = 18] = "LStickXAxis",
  32724. a[a.LStickYAxis = 19] = "LStickYAxis",
  32725. a[a.RStickXAxis = 20] = "RStickXAxis",
  32726. a[a.RStickYAxis = 21] = "RStickYAxis"
  32727. }
  32728. )(SwitchInput || (SwitchInput = {}));
  32729. var DeviceInputEventType;
  32730. (function(a) {
  32731. a[a.PointerMove = 0] = "PointerMove",
  32732. a[a.PointerDown = 1] = "PointerDown",
  32733. a[a.PointerUp = 2] = "PointerUp"
  32734. }
  32735. )(DeviceInputEventType || (DeviceInputEventType = {}));
  32736. var EventConstants = function() {
  32737. function a() {}
  32738. return a.DOM_DELTA_PIXEL = 0,
  32739. a.DOM_DELTA_LINE = 1,
  32740. a.DOM_DELTA_PAGE = 2,
  32741. a
  32742. }()
  32743. , DeviceEventFactory = function() {
  32744. function a() {}
  32745. return a.CreateDeviceEvent = function(e, i, o, s, c, d) {
  32746. switch (e) {
  32747. case DeviceType.Keyboard:
  32748. return this._createKeyboardEvent(o, s, c, d);
  32749. case DeviceType.Mouse:
  32750. if (o === PointerInput.MouseWheelX || o === PointerInput.MouseWheelY || o === PointerInput.MouseWheelZ)
  32751. return this._createWheelEvent(e, i, o, s, c, d);
  32752. case DeviceType.Touch:
  32753. return this._createPointerEvent(e, i, o, s, c, d);
  32754. default:
  32755. throw "Unable to generate event for device " + DeviceType[e]
  32756. }
  32757. }
  32758. ,
  32759. a._createPointerEvent = function(e, i, o, s, c, d) {
  32760. var _ = this._createMouseEvent(e, i, o, s, c, d);
  32761. return _.pointerId = e === DeviceType.Mouse ? 1 : i,
  32762. o === PointerInput.Horizontal || o === PointerInput.Vertical || o === PointerInput.DeltaHorizontal || o === PointerInput.DeltaVertical ? _.type = "pointermove" : o >= PointerInput.LeftClick && o <= PointerInput.RightClick && (_.type = s === 1 ? "pointerdown" : "pointerup",
  32763. _.button = o - 2),
  32764. _
  32765. }
  32766. ,
  32767. a._createWheelEvent = function(e, i, o, s, c, d) {
  32768. var _ = this._createMouseEvent(e, i, o, s, c, d);
  32769. return _.type = "wheel",
  32770. _.deltaMode = EventConstants.DOM_DELTA_PIXEL,
  32771. _.deltaX = o === PointerInput.MouseWheelX ? s : c.pollInput(e, i, PointerInput.MouseWheelX),
  32772. _.deltaY = o === PointerInput.MouseWheelY ? s : c.pollInput(e, i, PointerInput.MouseWheelY),
  32773. _.deltaZ = o === PointerInput.MouseWheelZ ? s : c.pollInput(e, i, PointerInput.MouseWheelZ),
  32774. _
  32775. }
  32776. ,
  32777. a._createMouseEvent = function(e, i, o, s, c, d) {
  32778. var _ = this._createEvent(d)
  32779. , b = c.pollInput(e, i, PointerInput.Horizontal)
  32780. , k = c.pollInput(e, i, PointerInput.Vertical)
  32781. , j = o === PointerInput.DeltaHorizontal ? s : 0
  32782. , $ = o === PointerInput.DeltaVertical ? s : 0
  32783. , _e = o === PointerInput.DeltaHorizontal && d ? j - d.getBoundingClientRect().x : 0
  32784. , et = o === PointerInput.DeltaVertical && d ? $ - d.getBoundingClientRect().y : 0;
  32785. return this._checkNonCharacterKeys(_, c),
  32786. _.clientX = b,
  32787. _.clientY = k,
  32788. _.movementX = j,
  32789. _.movementY = $,
  32790. _.offsetX = _e,
  32791. _.offsetY = et,
  32792. _.x = b,
  32793. _.y = k,
  32794. _
  32795. }
  32796. ,
  32797. a._createKeyboardEvent = function(e, i, o, s) {
  32798. var c = this._createEvent(s);
  32799. return this._checkNonCharacterKeys(c, o),
  32800. c.type = i === 1 ? "keydown" : "keyup",
  32801. c.key = String.fromCharCode(e),
  32802. c.keyCode = e,
  32803. c
  32804. }
  32805. ,
  32806. a._checkNonCharacterKeys = function(e, i) {
  32807. var o = i.isDeviceAvailable(DeviceType.Keyboard)
  32808. , s = o && i.pollInput(DeviceType.Keyboard, 0, 18) === 1
  32809. , c = o && i.pollInput(DeviceType.Keyboard, 0, 17) === 1
  32810. , d = o && (i.pollInput(DeviceType.Keyboard, 0, 91) === 1 || i.pollInput(DeviceType.Keyboard, 0, 92) === 1 || i.pollInput(DeviceType.Keyboard, 0, 93) === 1)
  32811. , _ = o && i.pollInput(DeviceType.Keyboard, 0, 16) === 1;
  32812. e.altKey = s,
  32813. e.ctrlKey = c,
  32814. e.metaKey = d,
  32815. e.shiftKey = _
  32816. }
  32817. ,
  32818. a._createEvent = function(e) {
  32819. var i = {};
  32820. return i.preventDefault = function() {}
  32821. ,
  32822. i.target = e,
  32823. i
  32824. }
  32825. ,
  32826. a
  32827. }()
  32828. , NativeDeviceInputSystemImpl = function() {
  32829. function a(e) {
  32830. var i = this;
  32831. this.onDeviceConnected = function(o, s) {}
  32832. ,
  32833. this.onDeviceDisconnected = function(o, s) {}
  32834. ,
  32835. this.onInputChanged = function(o) {}
  32836. ,
  32837. this._nativeInput = e || this._createDummyNativeInput(),
  32838. this._nativeInput.onDeviceConnected = function(o, s) {
  32839. i.onDeviceConnected(o, s)
  32840. }
  32841. ,
  32842. this._nativeInput.onDeviceDisconnected = function(o, s) {
  32843. i.onDeviceDisconnected(o, s)
  32844. }
  32845. ,
  32846. this._nativeInput.onInputChanged = function(o, s, c, d, _, b) {
  32847. var k = DeviceEventFactory.CreateDeviceEvent(o, s, c, _, i)
  32848. , j = k;
  32849. j.deviceType = o,
  32850. j.deviceSlot = s,
  32851. j.inputIndex = c,
  32852. j.previousState = d,
  32853. j.currentState = _,
  32854. i.onInputChanged(j)
  32855. }
  32856. }
  32857. return a.prototype.configureEvents = function() {}
  32858. ,
  32859. a.prototype.pollInput = function(e, i, o) {
  32860. return this._nativeInput.pollInput(e, i, o)
  32861. }
  32862. ,
  32863. a.prototype.isDeviceAvailable = function(e) {
  32864. return e === DeviceType.Mouse || e === DeviceType.Touch
  32865. }
  32866. ,
  32867. a.prototype.dispose = function() {
  32868. this.onDeviceConnected = function() {}
  32869. ,
  32870. this.onDeviceDisconnected = function() {}
  32871. ,
  32872. this.onInputChanged = function() {}
  32873. }
  32874. ,
  32875. a.prototype._createDummyNativeInput = function() {
  32876. var e = {
  32877. onDeviceConnected: function(i, o) {},
  32878. onDeviceDisconnected: function(i, o) {},
  32879. onInputChanged: function(i, o, s, c, d, _) {},
  32880. pollInput: function() {
  32881. return 0
  32882. },
  32883. isDeviceAvailable: function() {
  32884. return !1
  32885. },
  32886. dispose: function() {}
  32887. };
  32888. return e
  32889. }
  32890. ,
  32891. a
  32892. }()
  32893. , WebDeviceInputSystemImpl = function() {
  32894. function a(e) {
  32895. this._inputs = [],
  32896. this._keyboardActive = !1,
  32897. this._pointerActive = !1,
  32898. this._usingSafari = Tools.IsSafari(),
  32899. this._keyboardDownEvent = function(i) {}
  32900. ,
  32901. this._keyboardUpEvent = function(i) {}
  32902. ,
  32903. this._keyboardBlurEvent = function(i) {}
  32904. ,
  32905. this._pointerMoveEvent = function(i) {}
  32906. ,
  32907. this._pointerDownEvent = function(i) {}
  32908. ,
  32909. this._pointerUpEvent = function(i) {}
  32910. ,
  32911. this._pointerWheelEvent = function(i) {}
  32912. ,
  32913. this._pointerBlurEvent = function(i) {}
  32914. ,
  32915. this._mouseId = -1,
  32916. this._isUsingFirefox = navigator && navigator.userAgent && navigator.userAgent.indexOf("Firefox") !== -1,
  32917. this._activeTouchIds = [],
  32918. this._rollingTouchId = 0,
  32919. this._pointerInputClearObserver = null,
  32920. this._gamepadConnectedEvent = function(i) {}
  32921. ,
  32922. this._gamepadDisconnectedEvent = function(i) {}
  32923. ,
  32924. this._eventPrefix = Tools.GetPointerPrefix(e),
  32925. this._engine = e,
  32926. this.onDeviceConnected = function(i, o) {}
  32927. ,
  32928. this.onDeviceDisconnected = function(i, o) {}
  32929. ,
  32930. this.onInputChanged = function(i) {}
  32931. ,
  32932. this.configureEvents()
  32933. }
  32934. return Object.defineProperty(a.prototype, "onDeviceConnected", {
  32935. get: function() {
  32936. return this._onDeviceConnected
  32937. },
  32938. set: function(e) {
  32939. this._onDeviceConnected = e;
  32940. for (var i = 0; i < this._inputs.length; i++) {
  32941. var o = this._inputs[i];
  32942. if (o)
  32943. for (var s in o) {
  32944. var c = +s;
  32945. this._inputs[i][c] && this._onDeviceConnected(i, c)
  32946. }
  32947. }
  32948. },
  32949. enumerable: !1,
  32950. configurable: !0
  32951. }),
  32952. a.prototype.configureEvents = function() {
  32953. var e = this._engine.getInputElement();
  32954. e && this._elementToAttachTo !== e && (this._elementToAttachTo && this._removeEvents(),
  32955. this._elementToAttachTo = e,
  32956. this._elementToAttachTo.tabIndex = this._elementToAttachTo.tabIndex !== -1 ? this._elementToAttachTo.tabIndex : this._engine.canvasTabIndex,
  32957. this._handleKeyActions(),
  32958. this._handlePointerActions(),
  32959. this._handleGamepadActions(),
  32960. this._checkForConnectedDevices())
  32961. }
  32962. ,
  32963. a.prototype.pollInput = function(e, i, o) {
  32964. var s = this._inputs[e][i];
  32965. if (!s)
  32966. throw "Unable to find device " + DeviceType[e];
  32967. e >= DeviceType.Xbox && e <= DeviceType.Switch && navigator.getGamepads && this._updateDevice(e, i, o);
  32968. var c = s[o];
  32969. if (c === void 0)
  32970. throw "Unable to find input " + o + " for device " + DeviceType[e] + " in slot " + i;
  32971. return c
  32972. }
  32973. ,
  32974. a.prototype.isDeviceAvailable = function(e) {
  32975. return this._inputs[e] !== void 0
  32976. }
  32977. ,
  32978. a.prototype.dispose = function() {
  32979. this.onDeviceConnected = function() {}
  32980. ,
  32981. this.onDeviceDisconnected = function() {}
  32982. ,
  32983. this.onInputChanged = function() {}
  32984. ,
  32985. this._elementToAttachTo && (this._removeEvents(),
  32986. window.removeEventListener("gamepadconnected", this._gamepadConnectedEvent),
  32987. window.removeEventListener("gamepaddisconnected", this._gamepadDisconnectedEvent))
  32988. }
  32989. ,
  32990. a.prototype._checkForConnectedDevices = function() {
  32991. if (navigator.getGamepads)
  32992. for (var e = navigator.getGamepads(), i = 0, o = e; i < o.length; i++) {
  32993. var s = o[i];
  32994. s && this._addGamePad(s)
  32995. }
  32996. matchMedia("(pointer:fine)").matches && this._addPointerDevice(DeviceType.Mouse, 0, 0, 0)
  32997. }
  32998. ,
  32999. a.prototype._addGamePad = function(e) {
  33000. var i = this._getGamepadDeviceType(e.id)
  33001. , o = e.index;
  33002. this._registerDevice(i, o, e.buttons.length + e.axes.length),
  33003. this._gamepads = this._gamepads || new Array(e.index + 1),
  33004. this._gamepads[o] = i
  33005. }
  33006. ,
  33007. a.prototype._addPointerDevice = function(e, i, o, s) {
  33008. this._pointerActive = !0,
  33009. this._registerDevice(e, i, a.MAX_POINTER_INPUTS);
  33010. var c = this._inputs[e][i];
  33011. c[0] = o,
  33012. c[1] = s
  33013. }
  33014. ,
  33015. a.prototype._registerDevice = function(e, i, o) {
  33016. if (i === void 0)
  33017. throw "Unable to register device " + DeviceType[e] + " to undefined slot.";
  33018. if (this._inputs[e] || (this._inputs[e] = {}),
  33019. !this._inputs[e][i]) {
  33020. for (var s = new Array(o), c = 0; c < o; c++)
  33021. s[c] = 0;
  33022. this._inputs[e][i] = s,
  33023. this.onDeviceConnected(e, i)
  33024. }
  33025. }
  33026. ,
  33027. a.prototype._unregisterDevice = function(e, i) {
  33028. this._inputs[e][i] && (delete this._inputs[e][i],
  33029. this.onDeviceDisconnected(e, i))
  33030. }
  33031. ,
  33032. a.prototype._handleKeyActions = function() {
  33033. var e = this;
  33034. this._keyboardDownEvent = function(i) {
  33035. e._keyboardActive || (e._keyboardActive = !0,
  33036. e._registerDevice(DeviceType.Keyboard, 0, a.MAX_KEYCODES));
  33037. var o = e._inputs[DeviceType.Keyboard][0];
  33038. if (o) {
  33039. o[i.keyCode] = 1;
  33040. var s = i;
  33041. s.deviceType = DeviceType.Keyboard,
  33042. s.deviceSlot = 0,
  33043. s.inputIndex = i.keyCode,
  33044. s.previousState = 0,
  33045. s.currentState = o[i.keyCode],
  33046. e.onInputChanged(s)
  33047. }
  33048. }
  33049. ,
  33050. this._keyboardUpEvent = function(i) {
  33051. e._keyboardActive || (e._keyboardActive = !0,
  33052. e._registerDevice(DeviceType.Keyboard, 0, a.MAX_KEYCODES));
  33053. var o = e._inputs[DeviceType.Keyboard][0];
  33054. if (o) {
  33055. o[i.keyCode] = 0;
  33056. var s = i;
  33057. s.deviceType = DeviceType.Keyboard,
  33058. s.deviceSlot = 0,
  33059. s.inputIndex = i.keyCode,
  33060. s.previousState = 1,
  33061. s.currentState = o[i.keyCode],
  33062. e.onInputChanged(s)
  33063. }
  33064. }
  33065. ,
  33066. this._keyboardBlurEvent = function(i) {
  33067. if (e._keyboardActive) {
  33068. for (var o = e._inputs[DeviceType.Keyboard][0], s = 0; s < o.length; s++)
  33069. if (o[s] !== 0) {
  33070. o[s] = 0;
  33071. var c = DeviceEventFactory.CreateDeviceEvent(DeviceType.Keyboard, 0, s, 1, e, e._elementToAttachTo)
  33072. , d = c;
  33073. d.deviceType = DeviceType.Keyboard,
  33074. d.deviceSlot = 0,
  33075. d.inputIndex = s,
  33076. d.currentState = 0,
  33077. d.previousState = 1,
  33078. e.onInputChanged(d)
  33079. }
  33080. }
  33081. }
  33082. ,
  33083. this._elementToAttachTo.addEventListener("keydown", this._keyboardDownEvent),
  33084. this._elementToAttachTo.addEventListener("keyup", this._keyboardUpEvent),
  33085. this._elementToAttachTo.addEventListener("blur", this._keyboardBlurEvent)
  33086. }
  33087. ,
  33088. a.prototype._handlePointerActions = function() {
  33089. var e = this;
  33090. this._pointerMoveEvent = function(c) {
  33091. var d = e._getPointerType(c)
  33092. , _ = d === DeviceType.Mouse ? 0 : e._activeTouchIds.indexOf(c.pointerId);
  33093. e._inputs[d] || (e._inputs[d] = {}),
  33094. e._inputs[d][_] || e._addPointerDevice(d, _, c.clientX, c.clientY);
  33095. var b = e._inputs[d][_];
  33096. if (b) {
  33097. var k = b[PointerInput.Horizontal]
  33098. , j = b[PointerInput.Vertical]
  33099. , $ = b[PointerInput.DeltaHorizontal]
  33100. , _e = b[PointerInput.DeltaVertical];
  33101. b[PointerInput.Horizontal] = c.clientX,
  33102. b[PointerInput.Vertical] = c.clientY,
  33103. b[PointerInput.DeltaHorizontal] = c.movementX,
  33104. b[PointerInput.DeltaVertical] = c.movementY;
  33105. var et = c;
  33106. et.deviceType = d,
  33107. et.deviceSlot = _,
  33108. k !== c.clientX && (et.inputIndex = PointerInput.Horizontal,
  33109. et.previousState = k,
  33110. et.currentState = b[PointerInput.Horizontal],
  33111. e.onInputChanged(et)),
  33112. j !== c.clientY && (et.inputIndex = PointerInput.Vertical,
  33113. et.previousState = j,
  33114. et.currentState = b[PointerInput.Vertical],
  33115. e.onInputChanged(et)),
  33116. b[PointerInput.DeltaHorizontal] !== 0 && (et.inputIndex = PointerInput.DeltaHorizontal,
  33117. et.previousState = $,
  33118. et.currentState = b[PointerInput.DeltaHorizontal],
  33119. e.onInputChanged(et)),
  33120. b[PointerInput.DeltaVertical] !== 0 && (et.inputIndex = PointerInput.DeltaVertical,
  33121. et.previousState = _e,
  33122. et.currentState = b[PointerInput.DeltaVertical],
  33123. e.onInputChanged(et)),
  33124. !e._usingSafari && c.button !== -1 && (et.inputIndex = c.button + 2,
  33125. et.previousState = b[c.button + 2],
  33126. b[c.button + 2] = b[c.button + 2] ? 0 : 1,
  33127. et.currentState = b[c.button + 2],
  33128. e.onInputChanged(et))
  33129. }
  33130. }
  33131. ,
  33132. this._pointerDownEvent = function(c) {
  33133. var d = e._getPointerType(c)
  33134. , _ = d === DeviceType.Mouse ? 0 : c.pointerId;
  33135. d === DeviceType.Touch && (_ = e._rollingTouchId++,
  33136. e._activeTouchIds[_] = c.pointerId),
  33137. e._inputs[d] || (e._inputs[d] = {}),
  33138. e._inputs[d][_] || e._addPointerDevice(d, _, c.clientX, c.clientY);
  33139. var b = e._inputs[d][_];
  33140. if (b) {
  33141. var k = b[PointerInput.Horizontal]
  33142. , j = b[PointerInput.Vertical]
  33143. , $ = b[c.button + 2];
  33144. if (d === DeviceType.Mouse) {
  33145. if (e._mouseId === -1 && (c.pointerId === void 0 ? e._mouseId = e._isUsingFirefox ? 0 : 1 : e._mouseId = c.pointerId),
  33146. !document.pointerLockElement && e._elementToAttachTo.hasPointerCapture)
  33147. try {
  33148. e._elementToAttachTo.setPointerCapture(e._mouseId)
  33149. } catch {}
  33150. } else if (c.pointerId && !document.pointerLockElement && e._elementToAttachTo.hasPointerCapture)
  33151. try {
  33152. e._elementToAttachTo.setPointerCapture(c.pointerId)
  33153. } catch {}
  33154. b[PointerInput.Horizontal] = c.clientX,
  33155. b[PointerInput.Vertical] = c.clientY,
  33156. b[c.button + 2] = 1;
  33157. var _e = c;
  33158. _e.deviceType = d,
  33159. _e.deviceSlot = _,
  33160. k !== c.clientX && (_e.inputIndex = PointerInput.Horizontal,
  33161. _e.previousState = k,
  33162. _e.currentState = b[PointerInput.Horizontal],
  33163. e.onInputChanged(_e)),
  33164. j !== c.clientY && (_e.inputIndex = PointerInput.Vertical,
  33165. _e.previousState = j,
  33166. _e.currentState = b[PointerInput.Vertical],
  33167. e.onInputChanged(_e)),
  33168. _e.inputIndex = c.button + 2,
  33169. _e.previousState = $,
  33170. _e.currentState = b[c.button + 2],
  33171. e.onInputChanged(_e)
  33172. }
  33173. }
  33174. ,
  33175. this._pointerUpEvent = function(c) {
  33176. var d, _, b, k, j, $ = e._getPointerType(c), _e = $ === DeviceType.Mouse ? 0 : e._activeTouchIds.indexOf(c.pointerId), et = (d = e._inputs[$]) === null || d === void 0 ? void 0 : d[_e];
  33177. if (et && et[c.button + 2] !== 0) {
  33178. var tt = et[PointerInput.Horizontal]
  33179. , rt = et[PointerInput.Vertical]
  33180. , it = et[c.button + 2];
  33181. et[PointerInput.Horizontal] = c.clientX,
  33182. et[PointerInput.Vertical] = c.clientY,
  33183. et[c.button + 2] = 0;
  33184. var nt = c;
  33185. if (nt.deviceType = $,
  33186. nt.deviceSlot = _e,
  33187. tt !== c.clientX && (nt.inputIndex = PointerInput.Horizontal,
  33188. nt.previousState = tt,
  33189. nt.currentState = et[PointerInput.Horizontal],
  33190. e.onInputChanged(nt)),
  33191. rt !== c.clientY && (nt.inputIndex = PointerInput.Vertical,
  33192. nt.previousState = rt,
  33193. nt.currentState = et[PointerInput.Vertical],
  33194. e.onInputChanged(nt)),
  33195. nt.inputIndex = c.button + 2,
  33196. nt.previousState = it,
  33197. nt.currentState = et[c.button + 2],
  33198. $ === DeviceType.Mouse && e._mouseId >= 0 && ((b = (_ = e._elementToAttachTo).hasPointerCapture) === null || b === void 0 ? void 0 : b.call(_, e._mouseId)) ? e._elementToAttachTo.releasePointerCapture(e._mouseId) : c.pointerId && ((j = (k = e._elementToAttachTo).hasPointerCapture) === null || j === void 0 ? void 0 : j.call(k, c.pointerId)) && e._elementToAttachTo.releasePointerCapture(c.pointerId),
  33199. e.onInputChanged(nt),
  33200. $ !== DeviceType.Mouse) {
  33201. var ot = e._activeTouchIds.indexOf(c.pointerId);
  33202. delete e._activeTouchIds[ot],
  33203. e._unregisterDevice($, _e)
  33204. }
  33205. }
  33206. }
  33207. ,
  33208. this._wheelEventName = "onwheel"in document.createElement("div") ? "wheel" : document.onmousewheel !== void 0 ? "mousewheel" : "DOMMouseScroll";
  33209. var i = !1
  33210. , o = function() {};
  33211. try {
  33212. var s = {
  33213. passive: {
  33214. get: function() {
  33215. i = !0
  33216. }
  33217. }
  33218. };
  33219. this._elementToAttachTo.addEventListener("test", o, s),
  33220. this._elementToAttachTo.removeEventListener("test", o, s)
  33221. } catch {}
  33222. this._pointerBlurEvent = function(c) {
  33223. var d, _, b, k, j;
  33224. if (e.isDeviceAvailable(DeviceType.Mouse)) {
  33225. var $ = e._inputs[DeviceType.Mouse][0];
  33226. e._mouseId >= 0 && ((_ = (d = e._elementToAttachTo).hasPointerCapture) === null || _ === void 0 ? void 0 : _.call(d, e._mouseId)) && e._elementToAttachTo.releasePointerCapture(e._mouseId);
  33227. for (var _e = 0; _e <= PointerInput.BrowserForward; _e++)
  33228. if ($[_e + 2] === 1) {
  33229. $[_e + 2] = 0;
  33230. var et = DeviceEventFactory.CreateDeviceEvent(DeviceType.Mouse, 0, _e + 2, 1, e, e._elementToAttachTo)
  33231. , tt = et;
  33232. tt.deviceType = DeviceType.Mouse,
  33233. tt.deviceSlot = 0,
  33234. tt.inputIndex = _e + 2,
  33235. tt.currentState = $[_e + 2],
  33236. tt.previousState = 1,
  33237. e.onInputChanged(tt)
  33238. }
  33239. }
  33240. if (e.isDeviceAvailable(DeviceType.Touch)) {
  33241. var $ = e._inputs[DeviceType.Touch];
  33242. for (var rt in Object.keys(e._activeTouchIds)) {
  33243. var it = +rt
  33244. , nt = e._activeTouchIds[it];
  33245. if (!((k = (b = e._elementToAttachTo).hasPointerCapture) === null || k === void 0) && k.call(b, nt) && e._elementToAttachTo.releasePointerCapture(nt),
  33246. ((j = $[it]) === null || j === void 0 ? void 0 : j[PointerInput.LeftClick]) === 1) {
  33247. $[it][PointerInput.LeftClick] = 0;
  33248. var ot = DeviceEventFactory.CreateDeviceEvent(DeviceType.Touch, nt, PointerInput.LeftClick, 1, e, e._elementToAttachTo)
  33249. , tt = ot;
  33250. tt.deviceType = DeviceType.Mouse,
  33251. tt.deviceSlot = it,
  33252. tt.inputIndex = PointerInput.LeftClick,
  33253. tt.currentState = $[it][PointerInput.LeftClick],
  33254. tt.previousState = 1,
  33255. e.onInputChanged(tt),
  33256. e._unregisterDevice(DeviceType.Touch, it)
  33257. }
  33258. }
  33259. for (; e._activeTouchIds.pop() !== void 0; )
  33260. ;
  33261. }
  33262. }
  33263. ,
  33264. this._pointerWheelEvent = function(c) {
  33265. var d = DeviceType.Mouse
  33266. , _ = 0;
  33267. e._inputs[d] || (e._inputs[d] = []),
  33268. e._inputs[d][_] || (e._pointerActive = !0,
  33269. e._registerDevice(d, _, a.MAX_POINTER_INPUTS));
  33270. var b = e._inputs[d][_];
  33271. if (b) {
  33272. var k = b[PointerInput.MouseWheelX]
  33273. , j = b[PointerInput.MouseWheelY]
  33274. , $ = b[PointerInput.MouseWheelZ];
  33275. b[PointerInput.MouseWheelX] = c.deltaX || 0,
  33276. b[PointerInput.MouseWheelY] = c.deltaY || c.wheelDelta || 0,
  33277. b[PointerInput.MouseWheelZ] = c.deltaZ || 0;
  33278. var _e = c;
  33279. _e.deviceType = d,
  33280. _e.deviceSlot = _,
  33281. b[PointerInput.MouseWheelX] !== 0 && (_e.inputIndex = PointerInput.MouseWheelX,
  33282. _e.previousState = k,
  33283. _e.currentState = b[PointerInput.MouseWheelX],
  33284. e.onInputChanged(_e)),
  33285. b[PointerInput.MouseWheelY] !== 0 && (_e.inputIndex = PointerInput.MouseWheelY,
  33286. _e.previousState = j,
  33287. _e.currentState = b[PointerInput.MouseWheelY],
  33288. e.onInputChanged(_e)),
  33289. b[PointerInput.MouseWheelZ] !== 0 && (_e.inputIndex = PointerInput.MouseWheelZ,
  33290. _e.previousState = $,
  33291. _e.currentState = b[PointerInput.MouseWheelZ],
  33292. e.onInputChanged(_e))
  33293. }
  33294. }
  33295. ,
  33296. this._elementToAttachTo.addEventListener(this._eventPrefix + "move", this._pointerMoveEvent),
  33297. this._elementToAttachTo.addEventListener(this._eventPrefix + "down", this._pointerDownEvent),
  33298. this._elementToAttachTo.addEventListener(this._eventPrefix + "up", this._pointerUpEvent),
  33299. this._elementToAttachTo.addEventListener("blur", this._pointerBlurEvent),
  33300. this._elementToAttachTo.addEventListener(this._wheelEventName, this._pointerWheelEvent, i ? {
  33301. passive: !1
  33302. } : !1),
  33303. this._pointerInputClearObserver = this._engine.onEndFrameObservable.add(function() {
  33304. if (e.isDeviceAvailable(DeviceType.Mouse)) {
  33305. var c = e._inputs[DeviceType.Mouse][0];
  33306. c[PointerInput.MouseWheelX] = 0,
  33307. c[PointerInput.MouseWheelY] = 0,
  33308. c[PointerInput.MouseWheelZ] = 0,
  33309. c[PointerInput.DeltaHorizontal] = 0,
  33310. c[PointerInput.DeltaVertical] = 0
  33311. }
  33312. })
  33313. }
  33314. ,
  33315. a.prototype._handleGamepadActions = function() {
  33316. var e = this;
  33317. this._gamepadConnectedEvent = function(i) {
  33318. e._addGamePad(i.gamepad)
  33319. }
  33320. ,
  33321. this._gamepadDisconnectedEvent = function(i) {
  33322. if (e._gamepads) {
  33323. var o = e._getGamepadDeviceType(i.gamepad.id)
  33324. , s = i.gamepad.index;
  33325. e._unregisterDevice(o, s),
  33326. delete e._gamepads[s]
  33327. }
  33328. }
  33329. ,
  33330. window.addEventListener("gamepadconnected", this._gamepadConnectedEvent),
  33331. window.addEventListener("gamepaddisconnected", this._gamepadDisconnectedEvent)
  33332. }
  33333. ,
  33334. a.prototype._updateDevice = function(e, i, o) {
  33335. var s = navigator.getGamepads()[i];
  33336. if (s && e === this._gamepads[i]) {
  33337. var c = this._inputs[e][i];
  33338. o >= s.buttons.length ? c[o] = s.axes[o - s.buttons.length].valueOf() : c[o] = s.buttons[o].value
  33339. }
  33340. }
  33341. ,
  33342. a.prototype._getGamepadDeviceType = function(e) {
  33343. return e.indexOf("054c") !== -1 && e.indexOf("0ce6") === -1 ? DeviceType.DualShock : e.indexOf("Xbox One") !== -1 || e.search("Xbox 360") !== -1 || e.search("xinput") !== -1 ? DeviceType.Xbox : e.indexOf("057e") !== -1 ? DeviceType.Switch : DeviceType.Generic
  33344. }
  33345. ,
  33346. a.prototype._getPointerType = function(e) {
  33347. var i = DeviceType.Mouse;
  33348. return (e.pointerType === "touch" || e.pointerType === "pen" || e.touches) && (i = DeviceType.Touch),
  33349. i
  33350. }
  33351. ,
  33352. a.prototype._removeEvents = function() {
  33353. this._elementToAttachTo.removeEventListener("blur", this._keyboardBlurEvent),
  33354. this._elementToAttachTo.removeEventListener("blur", this._pointerBlurEvent),
  33355. this._keyboardActive && (this._elementToAttachTo.removeEventListener("keydown", this._keyboardDownEvent),
  33356. this._elementToAttachTo.removeEventListener("keyup", this._keyboardUpEvent)),
  33357. this._pointerActive && (this._elementToAttachTo.removeEventListener(this._eventPrefix + "move", this._pointerMoveEvent),
  33358. this._elementToAttachTo.removeEventListener(this._eventPrefix + "down", this._pointerDownEvent),
  33359. this._elementToAttachTo.removeEventListener(this._eventPrefix + "up", this._pointerUpEvent),
  33360. this._elementToAttachTo.removeEventListener(this._wheelEventName, this._pointerWheelEvent),
  33361. this._pointerInputClearObserver && this._engine.onEndFrameObservable.remove(this._pointerInputClearObserver))
  33362. }
  33363. ,
  33364. a.MAX_KEYCODES = 255,
  33365. a.MAX_POINTER_INPUTS = Object.keys(PointerInput).length / 2,
  33366. a
  33367. }()
  33368. , DeviceInputSystem = function() {
  33369. function a(e) {
  33370. var i = this;
  33371. this._deviceInputSystem = e,
  33372. this.onDeviceConnectedObservable = new Observable,
  33373. this.onDeviceDisconnectedObservable = new Observable,
  33374. this.onInputChangedObservable = new Observable,
  33375. this._deviceInputSystem.onDeviceConnected = function(o, s) {
  33376. i.onDeviceConnectedObservable.notifyObservers({
  33377. deviceType: o,
  33378. deviceSlot: s
  33379. })
  33380. }
  33381. ,
  33382. this._deviceInputSystem.onDeviceDisconnected = function(o, s) {
  33383. i.onDeviceDisconnectedObservable.notifyObservers({
  33384. deviceType: o,
  33385. deviceSlot: s
  33386. })
  33387. }
  33388. ,
  33389. this._deviceInputSystem.onInputChanged = function(o) {
  33390. i.onInputChangedObservable.notifyObservers(o)
  33391. }
  33392. }
  33393. return a._Create = function(e) {
  33394. if (!e.deviceInputSystem) {
  33395. var i = void 0;
  33396. typeof _native != "undefined" ? i = _native.DeviceInputSystem ? new NativeDeviceInputSystemImpl(new _native.DeviceInputSystem) : new NativeDeviceInputSystemImpl : i = new WebDeviceInputSystemImpl(e),
  33397. i && (e.deviceInputSystem = new a(i))
  33398. }
  33399. return e.deviceInputSystem
  33400. }
  33401. ,
  33402. a.prototype.configureEvents = function() {
  33403. this._deviceInputSystem.configureEvents()
  33404. }
  33405. ,
  33406. a.prototype.pollInput = function(e, i, o) {
  33407. return this._deviceInputSystem.pollInput(e, i, o)
  33408. }
  33409. ,
  33410. a.prototype.isDeviceAvailable = function(e) {
  33411. return this._deviceInputSystem.isDeviceAvailable(e)
  33412. }
  33413. ,
  33414. a.prototype.dispose = function() {
  33415. this.onDeviceConnectedObservable.clear(),
  33416. this.onDeviceDisconnectedObservable.clear(),
  33417. this.onInputChangedObservable.clear(),
  33418. this._deviceInputSystem.dispose()
  33419. }
  33420. ,
  33421. a
  33422. }()
  33423. , _ClickInfo = function() {
  33424. function a() {
  33425. this._singleClick = !1,
  33426. this._doubleClick = !1,
  33427. this._hasSwiped = !1,
  33428. this._ignore = !1
  33429. }
  33430. return Object.defineProperty(a.prototype, "singleClick", {
  33431. get: function() {
  33432. return this._singleClick
  33433. },
  33434. set: function(e) {
  33435. this._singleClick = e
  33436. },
  33437. enumerable: !1,
  33438. configurable: !0
  33439. }),
  33440. Object.defineProperty(a.prototype, "doubleClick", {
  33441. get: function() {
  33442. return this._doubleClick
  33443. },
  33444. set: function(e) {
  33445. this._doubleClick = e
  33446. },
  33447. enumerable: !1,
  33448. configurable: !0
  33449. }),
  33450. Object.defineProperty(a.prototype, "hasSwiped", {
  33451. get: function() {
  33452. return this._hasSwiped
  33453. },
  33454. set: function(e) {
  33455. this._hasSwiped = e
  33456. },
  33457. enumerable: !1,
  33458. configurable: !0
  33459. }),
  33460. Object.defineProperty(a.prototype, "ignore", {
  33461. get: function() {
  33462. return this._ignore
  33463. },
  33464. set: function(e) {
  33465. this._ignore = e
  33466. },
  33467. enumerable: !1,
  33468. configurable: !0
  33469. }),
  33470. a
  33471. }()
  33472. , InputManager = function() {
  33473. function a(e) {
  33474. this._alreadyAttached = !1,
  33475. this._meshPickProceed = !1,
  33476. this._currentPickResult = null,
  33477. this._previousPickResult = null,
  33478. this._totalPointersPressed = 0,
  33479. this._doubleClickOccured = !1,
  33480. this._pointerX = 0,
  33481. this._pointerY = 0,
  33482. this._startingPointerPosition = new Vector2(0,0),
  33483. this._previousStartingPointerPosition = new Vector2(0,0),
  33484. this._startingPointerTime = 0,
  33485. this._previousStartingPointerTime = 0,
  33486. this._pointerCaptures = {},
  33487. this._meshUnderPointerId = {},
  33488. this._scene = e
  33489. }
  33490. return Object.defineProperty(a.prototype, "meshUnderPointer", {
  33491. get: function() {
  33492. return this._pointerOverMesh
  33493. },
  33494. enumerable: !1,
  33495. configurable: !0
  33496. }),
  33497. a.prototype.getMeshUnderPointerByPointerId = function(e) {
  33498. return this._meshUnderPointerId[e] || null
  33499. }
  33500. ,
  33501. Object.defineProperty(a.prototype, "unTranslatedPointer", {
  33502. get: function() {
  33503. return new Vector2(this._unTranslatedPointerX,this._unTranslatedPointerY)
  33504. },
  33505. enumerable: !1,
  33506. configurable: !0
  33507. }),
  33508. Object.defineProperty(a.prototype, "pointerX", {
  33509. get: function() {
  33510. return this._pointerX
  33511. },
  33512. set: function(e) {
  33513. this._pointerX = e
  33514. },
  33515. enumerable: !1,
  33516. configurable: !0
  33517. }),
  33518. Object.defineProperty(a.prototype, "pointerY", {
  33519. get: function() {
  33520. return this._pointerY
  33521. },
  33522. set: function(e) {
  33523. this._pointerY = e
  33524. },
  33525. enumerable: !1,
  33526. configurable: !0
  33527. }),
  33528. a.prototype._updatePointerPosition = function(e) {
  33529. var i = this._scene.getEngine().getInputElementClientRect();
  33530. !i || (this._pointerX = e.clientX - i.left,
  33531. this._pointerY = e.clientY - i.top,
  33532. this._unTranslatedPointerX = this._pointerX,
  33533. this._unTranslatedPointerY = this._pointerY)
  33534. }
  33535. ,
  33536. a.prototype._processPointerMove = function(e, i) {
  33537. var o = this._scene
  33538. , s = o.getEngine()
  33539. , c = s.getInputElement();
  33540. c && (c.tabIndex = s.canvasTabIndex,
  33541. o.doNotHandleCursors || (c.style.cursor = o.defaultCursor));
  33542. var d = !!(e && e.hit && e.pickedMesh);
  33543. d ? (o.setPointerOverMesh(e.pickedMesh, i.pointerId, e),
  33544. this._pointerOverMesh && this._pointerOverMesh.actionManager && this._pointerOverMesh.actionManager.hasPointerTriggers && !o.doNotHandleCursors && c && (this._pointerOverMesh.actionManager.hoverCursor ? c.style.cursor = this._pointerOverMesh.actionManager.hoverCursor : c.style.cursor = o.hoverCursor)) : o.setPointerOverMesh(null, i.pointerId, e);
  33545. for (var _ = 0, b = o._pointerMoveStage; _ < b.length; _++) {
  33546. var k = b[_];
  33547. e = k.action(this._unTranslatedPointerX, this._unTranslatedPointerY, e, d, c)
  33548. }
  33549. if (e) {
  33550. var j = i.type === "wheel" || i.type === "mousewheel" || i.type === "DOMMouseScroll" ? PointerEventTypes.POINTERWHEEL : PointerEventTypes.POINTERMOVE;
  33551. if (o.onPointerMove && o.onPointerMove(i, e, j),
  33552. o.onPointerObservable.hasObservers()) {
  33553. var $ = new PointerInfo(j,i,e);
  33554. this._setRayOnPointerInfo($),
  33555. o.onPointerObservable.notifyObservers($, j)
  33556. }
  33557. }
  33558. }
  33559. ,
  33560. a.prototype._setRayOnPointerInfo = function(e) {
  33561. var i = this._scene;
  33562. e.pickInfo && !e.pickInfo._pickingUnavailable && (e.pickInfo.ray || (e.pickInfo.ray = i.createPickingRay(e.event.offsetX, e.event.offsetY, Matrix.Identity(), i.activeCamera)))
  33563. }
  33564. ,
  33565. a.prototype._checkPrePointerObservable = function(e, i, o) {
  33566. var s = this._scene
  33567. , c = new PointerInfoPre(o,i,this._unTranslatedPointerX,this._unTranslatedPointerY);
  33568. return e && (c.ray = e.ray,
  33569. e.originMesh && (c.nearInteractionPickingInfo = e)),
  33570. s.onPrePointerObservable.notifyObservers(c, o),
  33571. !!c.skipOnPointerObservable
  33572. }
  33573. ,
  33574. a.prototype.simulatePointerMove = function(e, i) {
  33575. var o = new PointerEvent("pointermove",i);
  33576. this._checkPrePointerObservable(e, o, PointerEventTypes.POINTERMOVE) || this._processPointerMove(e, o)
  33577. }
  33578. ,
  33579. a.prototype.simulatePointerDown = function(e, i) {
  33580. var o = new PointerEvent("pointerdown",i);
  33581. this._checkPrePointerObservable(e, o, PointerEventTypes.POINTERDOWN) || this._processPointerDown(e, o)
  33582. }
  33583. ,
  33584. a.prototype._processPointerDown = function(e, i) {
  33585. var o = this
  33586. , s = this._scene;
  33587. if (e && e.hit && e.pickedMesh) {
  33588. this._pickedDownMesh = e.pickedMesh;
  33589. var c = e.pickedMesh._getActionManagerForTrigger();
  33590. if (c) {
  33591. if (c.hasPickTriggers)
  33592. switch (c.processTrigger(5, ActionEvent.CreateNew(e.pickedMesh, i)),
  33593. i.button) {
  33594. case 0:
  33595. c.processTrigger(2, ActionEvent.CreateNew(e.pickedMesh, i));
  33596. break;
  33597. case 1:
  33598. c.processTrigger(4, ActionEvent.CreateNew(e.pickedMesh, i));
  33599. break;
  33600. case 2:
  33601. c.processTrigger(3, ActionEvent.CreateNew(e.pickedMesh, i));
  33602. break
  33603. }
  33604. c.hasSpecificTrigger(8) && window.setTimeout(function() {
  33605. var $ = s.pick(o._unTranslatedPointerX, o._unTranslatedPointerY, function(_e) {
  33606. return _e.isPickable && _e.isVisible && _e.isReady() && _e.actionManager && _e.actionManager.hasSpecificTrigger(8) && _e === o._pickedDownMesh
  33607. }, !1, s.cameraToUseForPointers);
  33608. $ && $.hit && $.pickedMesh && c && o._totalPointersPressed !== 0 && Date.now() - o._startingPointerTime > a.LongPressDelay && !o._isPointerSwiping() && (o._startingPointerTime = 0,
  33609. c.processTrigger(8, ActionEvent.CreateNew($.pickedMesh, i)))
  33610. }, a.LongPressDelay)
  33611. }
  33612. } else
  33613. for (var d = 0, _ = s._pointerDownStage; d < _.length; d++) {
  33614. var b = _[d];
  33615. e = b.action(this._unTranslatedPointerX, this._unTranslatedPointerY, e, i)
  33616. }
  33617. if (e) {
  33618. var k = PointerEventTypes.POINTERDOWN;
  33619. if (s.onPointerDown && s.onPointerDown(i, e, k),
  33620. s.onPointerObservable.hasObservers()) {
  33621. var j = new PointerInfo(k,i,e);
  33622. this._setRayOnPointerInfo(j),
  33623. s.onPointerObservable.notifyObservers(j, k)
  33624. }
  33625. }
  33626. }
  33627. ,
  33628. a.prototype._isPointerSwiping = function() {
  33629. return Math.abs(this._startingPointerPosition.x - this._pointerX) > a.DragMovementThreshold || Math.abs(this._startingPointerPosition.y - this._pointerY) > a.DragMovementThreshold
  33630. }
  33631. ,
  33632. a.prototype.simulatePointerUp = function(e, i, o) {
  33633. var s = new PointerEvent("pointerup",i)
  33634. , c = new _ClickInfo;
  33635. o ? c.doubleClick = !0 : c.singleClick = !0,
  33636. !this._checkPrePointerObservable(e, s, PointerEventTypes.POINTERUP) && this._processPointerUp(e, s, c)
  33637. }
  33638. ,
  33639. a.prototype._processPointerUp = function(e, i, o) {
  33640. var s = this._scene;
  33641. if (e && e && e.pickedMesh) {
  33642. if (this._pickedUpMesh = e.pickedMesh,
  33643. this._pickedDownMesh === this._pickedUpMesh && (s.onPointerPick && s.onPointerPick(i, e),
  33644. o.singleClick && !o.ignore && s.onPointerObservable.hasObservers())) {
  33645. var c = PointerEventTypes.POINTERPICK
  33646. , d = new PointerInfo(c,i,e);
  33647. this._setRayOnPointerInfo(d),
  33648. s.onPointerObservable.notifyObservers(d, c)
  33649. }
  33650. var _ = e.pickedMesh._getActionManagerForTrigger();
  33651. if (_ && !o.ignore) {
  33652. _.processTrigger(7, ActionEvent.CreateNew(e.pickedMesh, i, e)),
  33653. !o.hasSwiped && o.singleClick && _.processTrigger(1, ActionEvent.CreateNew(e.pickedMesh, i, e));
  33654. var b = e.pickedMesh._getActionManagerForTrigger(6);
  33655. o.doubleClick && b && b.processTrigger(6, ActionEvent.CreateNew(e.pickedMesh, i, e))
  33656. }
  33657. } else if (!o.ignore)
  33658. for (var k = 0, j = s._pointerUpStage; k < j.length; k++) {
  33659. var $ = j[k];
  33660. e = $.action(this._unTranslatedPointerX, this._unTranslatedPointerY, e, i)
  33661. }
  33662. if (this._pickedDownMesh && this._pickedDownMesh !== this._pickedUpMesh) {
  33663. var _e = this._pickedDownMesh._getActionManagerForTrigger(16);
  33664. _e && _e.processTrigger(16, ActionEvent.CreateNew(this._pickedDownMesh, i))
  33665. }
  33666. var et = 0;
  33667. if (s.onPointerObservable.hasObservers()) {
  33668. if (!o.ignore && !o.hasSwiped && (o.singleClick && s.onPointerObservable.hasSpecificMask(PointerEventTypes.POINTERTAP) ? et = PointerEventTypes.POINTERTAP : o.doubleClick && s.onPointerObservable.hasSpecificMask(PointerEventTypes.POINTERDOUBLETAP) && (et = PointerEventTypes.POINTERDOUBLETAP),
  33669. et)) {
  33670. var d = new PointerInfo(et,i,e);
  33671. this._setRayOnPointerInfo(d),
  33672. s.onPointerObservable.notifyObservers(d, et)
  33673. }
  33674. if (!o.ignore) {
  33675. et = PointerEventTypes.POINTERUP;
  33676. var d = new PointerInfo(et,i,e);
  33677. this._setRayOnPointerInfo(d),
  33678. s.onPointerObservable.notifyObservers(d, et)
  33679. }
  33680. }
  33681. s.onPointerUp && !o.ignore && s.onPointerUp(i, e, et)
  33682. }
  33683. ,
  33684. a.prototype.isPointerCaptured = function(e) {
  33685. return e === void 0 && (e = 0),
  33686. this._pointerCaptures[e]
  33687. }
  33688. ,
  33689. a.prototype.attachControl = function(e, i, o, s) {
  33690. var c = this;
  33691. e === void 0 && (e = !0),
  33692. i === void 0 && (i = !0),
  33693. o === void 0 && (o = !0),
  33694. s === void 0 && (s = null);
  33695. var d = this._scene
  33696. , _ = d.getEngine();
  33697. s || (s = _.getInputElement()),
  33698. this._alreadyAttached && this.detachControl(),
  33699. s && (this._alreadyAttachedTo = s),
  33700. this._deviceInputSystem ? this._deviceInputSystem.configureEvents() : this._deviceInputSystem = DeviceInputSystem._Create(_),
  33701. this._initActionManager = function(b, k) {
  33702. if (!c._meshPickProceed) {
  33703. var j = d.pick(c._unTranslatedPointerX, c._unTranslatedPointerY, d.pointerDownPredicate, !1, d.cameraToUseForPointers);
  33704. c._currentPickResult = j,
  33705. j && (b = j.hit && j.pickedMesh ? j.pickedMesh._getActionManagerForTrigger() : null),
  33706. c._meshPickProceed = !0
  33707. }
  33708. return b
  33709. }
  33710. ,
  33711. this._delayedSimpleClick = function(b, k, j) {
  33712. (Date.now() - c._previousStartingPointerTime > a.DoubleClickDelay && !c._doubleClickOccured || b !== c._previousButtonPressed) && (c._doubleClickOccured = !1,
  33713. k.singleClick = !0,
  33714. k.ignore = !1,
  33715. j(k, c._currentPickResult))
  33716. }
  33717. ,
  33718. this._initClickEvent = function(b, k, j, $) {
  33719. var _e = new _ClickInfo;
  33720. c._currentPickResult = null;
  33721. var et = null
  33722. , tt = b.hasSpecificMask(PointerEventTypes.POINTERPICK) || k.hasSpecificMask(PointerEventTypes.POINTERPICK) || b.hasSpecificMask(PointerEventTypes.POINTERTAP) || k.hasSpecificMask(PointerEventTypes.POINTERTAP) || b.hasSpecificMask(PointerEventTypes.POINTERDOUBLETAP) || k.hasSpecificMask(PointerEventTypes.POINTERDOUBLETAP);
  33723. !tt && AbstractActionManager && (et = c._initActionManager(et, _e),
  33724. et && (tt = et.hasPickTriggers));
  33725. var rt = !1;
  33726. if (tt) {
  33727. var it = j.button;
  33728. if (_e.hasSwiped = c._isPointerSwiping(),
  33729. !_e.hasSwiped) {
  33730. var nt = !a.ExclusiveDoubleClickMode;
  33731. nt || (nt = !b.hasSpecificMask(PointerEventTypes.POINTERDOUBLETAP) && !k.hasSpecificMask(PointerEventTypes.POINTERDOUBLETAP),
  33732. nt && !AbstractActionManager.HasSpecificTrigger(6) && (et = c._initActionManager(et, _e),
  33733. et && (nt = !et.hasSpecificTrigger(6)))),
  33734. nt ? (Date.now() - c._previousStartingPointerTime > a.DoubleClickDelay || it !== c._previousButtonPressed) && (_e.singleClick = !0,
  33735. $(_e, c._currentPickResult),
  33736. rt = !0) : (c._previousDelayedSimpleClickTimeout = c._delayedSimpleClickTimeout,
  33737. c._delayedSimpleClickTimeout = window.setTimeout(c._delayedSimpleClick.bind(c, it, _e, $), a.DoubleClickDelay));
  33738. var ot = b.hasSpecificMask(PointerEventTypes.POINTERDOUBLETAP) || k.hasSpecificMask(PointerEventTypes.POINTERDOUBLETAP);
  33739. !ot && AbstractActionManager.HasSpecificTrigger(6) && (et = c._initActionManager(et, _e),
  33740. et && (ot = et.hasSpecificTrigger(6))),
  33741. ot && (it === c._previousButtonPressed && Date.now() - c._previousStartingPointerTime < a.DoubleClickDelay && !c._doubleClickOccured ? (!_e.hasSwiped && !c._isPointerSwiping() ? (c._previousStartingPointerTime = 0,
  33742. c._doubleClickOccured = !0,
  33743. _e.doubleClick = !0,
  33744. _e.ignore = !1,
  33745. a.ExclusiveDoubleClickMode && c._previousDelayedSimpleClickTimeout && clearTimeout(c._previousDelayedSimpleClickTimeout),
  33746. c._previousDelayedSimpleClickTimeout = c._delayedSimpleClickTimeout,
  33747. $(_e, c._currentPickResult)) : (c._doubleClickOccured = !1,
  33748. c._previousStartingPointerTime = c._startingPointerTime,
  33749. c._previousStartingPointerPosition.x = c._startingPointerPosition.x,
  33750. c._previousStartingPointerPosition.y = c._startingPointerPosition.y,
  33751. c._previousButtonPressed = it,
  33752. a.ExclusiveDoubleClickMode ? (c._previousDelayedSimpleClickTimeout && clearTimeout(c._previousDelayedSimpleClickTimeout),
  33753. c._previousDelayedSimpleClickTimeout = c._delayedSimpleClickTimeout,
  33754. $(_e, c._previousPickResult)) : $(_e, c._currentPickResult)),
  33755. rt = !0) : (c._doubleClickOccured = !1,
  33756. c._previousStartingPointerTime = c._startingPointerTime,
  33757. c._previousStartingPointerPosition.x = c._startingPointerPosition.x,
  33758. c._previousStartingPointerPosition.y = c._startingPointerPosition.y,
  33759. c._previousButtonPressed = it))
  33760. }
  33761. }
  33762. rt || $(_e, c._currentPickResult)
  33763. }
  33764. ,
  33765. this._onPointerMove = function(b) {
  33766. if (b.pointerId === void 0 && (b.pointerId = 0),
  33767. c._updatePointerPosition(b),
  33768. !c._checkPrePointerObservable(null, b, b.type === "wheel" || b.type === "mousewheel" || b.type === "DOMMouseScroll" ? PointerEventTypes.POINTERWHEEL : PointerEventTypes.POINTERMOVE) && !(!d.cameraToUseForPointers && !d.activeCamera)) {
  33769. if (d.skipPointerMovePicking) {
  33770. c._processPointerMove(new PickingInfo, b);
  33771. return
  33772. }
  33773. d.pointerMovePredicate || (d.pointerMovePredicate = function(j) {
  33774. return j.isPickable && j.isVisible && j.isReady() && j.isEnabled() && (j.enablePointerMoveEvents || d.constantlyUpdateMeshUnderPointer || j._getActionManagerForTrigger() !== null) && (!d.cameraToUseForPointers || (d.cameraToUseForPointers.layerMask & j.layerMask) !== 0)
  33775. }
  33776. );
  33777. var k = d.pick(c._unTranslatedPointerX, c._unTranslatedPointerY, d.pointerMovePredicate, !1, d.cameraToUseForPointers, d.pointerMoveTrianglePredicate);
  33778. c._processPointerMove(k, b)
  33779. }
  33780. }
  33781. ,
  33782. this._onPointerDown = function(b) {
  33783. if (c._totalPointersPressed++,
  33784. c._pickedDownMesh = null,
  33785. c._meshPickProceed = !1,
  33786. b.pointerId === void 0 && (b.pointerId = 0),
  33787. c._updatePointerPosition(b),
  33788. d.preventDefaultOnPointerDown && s && (b.preventDefault(),
  33789. s.focus()),
  33790. c._startingPointerPosition.x = c._pointerX,
  33791. c._startingPointerPosition.y = c._pointerY,
  33792. c._startingPointerTime = Date.now(),
  33793. !c._checkPrePointerObservable(null, b, PointerEventTypes.POINTERDOWN) && !(!d.cameraToUseForPointers && !d.activeCamera)) {
  33794. c._pointerCaptures[b.pointerId] = !0,
  33795. d.pointerDownPredicate || (d.pointerDownPredicate = function(j) {
  33796. return j.isPickable && j.isVisible && j.isReady() && j.isEnabled() && (!d.cameraToUseForPointers || (d.cameraToUseForPointers.layerMask & j.layerMask) !== 0)
  33797. }
  33798. ),
  33799. c._pickedDownMesh = null;
  33800. var k = d.pick(c._unTranslatedPointerX, c._unTranslatedPointerY, d.pointerDownPredicate, !1, d.cameraToUseForPointers);
  33801. c._processPointerDown(k, b)
  33802. }
  33803. }
  33804. ,
  33805. this._onPointerUp = function(b) {
  33806. c._totalPointersPressed !== 0 && (c._totalPointersPressed--,
  33807. c._pickedUpMesh = null,
  33808. c._meshPickProceed = !1,
  33809. b.pointerId === void 0 && (b.pointerId = 0),
  33810. c._updatePointerPosition(b),
  33811. d.preventDefaultOnPointerUp && s && (b.preventDefault(),
  33812. s.focus()),
  33813. c._initClickEvent(d.onPrePointerObservable, d.onPointerObservable, b, function(k, j) {
  33814. d.onPrePointerObservable.hasObservers() && !k.ignore && (!k.hasSwiped && (k.singleClick && d.onPrePointerObservable.hasSpecificMask(PointerEventTypes.POINTERTAP) && c._checkPrePointerObservable(null, b, PointerEventTypes.POINTERTAP) || k.doubleClick && d.onPrePointerObservable.hasSpecificMask(PointerEventTypes.POINTERDOUBLETAP) && c._checkPrePointerObservable(null, b, PointerEventTypes.POINTERDOUBLETAP)) || c._checkPrePointerObservable(null, b, PointerEventTypes.POINTERUP)) || !c._pointerCaptures[b.pointerId] && b.buttons > 0 || (c._pointerCaptures[b.pointerId] = !1,
  33815. !(!d.cameraToUseForPointers && !d.activeCamera) && (d.pointerUpPredicate || (d.pointerUpPredicate = function($) {
  33816. return $.isPickable && $.isVisible && $.isReady() && $.isEnabled() && (!d.cameraToUseForPointers || (d.cameraToUseForPointers.layerMask & $.layerMask) !== 0)
  33817. }
  33818. ),
  33819. !c._meshPickProceed && (AbstractActionManager && AbstractActionManager.HasTriggers || d.onPointerObservable.hasObservers()) && c._initActionManager(null, k),
  33820. j || (j = c._currentPickResult),
  33821. c._processPointerUp(j, b, k),
  33822. c._previousPickResult = c._currentPickResult))
  33823. }))
  33824. }
  33825. ,
  33826. this._onKeyDown = function(b) {
  33827. var k = KeyboardEventTypes.KEYDOWN;
  33828. if (d.onPreKeyboardObservable.hasObservers()) {
  33829. var j = new KeyboardInfoPre(k,b);
  33830. if (d.onPreKeyboardObservable.notifyObservers(j, k),
  33831. j.skipOnPointerObservable)
  33832. return
  33833. }
  33834. if (d.onKeyboardObservable.hasObservers()) {
  33835. var j = new KeyboardInfo(k,b);
  33836. d.onKeyboardObservable.notifyObservers(j, k)
  33837. }
  33838. d.actionManager && d.actionManager.processTrigger(14, ActionEvent.CreateNewFromScene(d, b))
  33839. }
  33840. ,
  33841. this._onKeyUp = function(b) {
  33842. var k = KeyboardEventTypes.KEYUP;
  33843. if (d.onPreKeyboardObservable.hasObservers()) {
  33844. var j = new KeyboardInfoPre(k,b);
  33845. if (d.onPreKeyboardObservable.notifyObservers(j, k),
  33846. j.skipOnPointerObservable)
  33847. return
  33848. }
  33849. if (d.onKeyboardObservable.hasObservers()) {
  33850. var j = new KeyboardInfo(k,b);
  33851. d.onKeyboardObservable.notifyObservers(j, k)
  33852. }
  33853. d.actionManager && d.actionManager.processTrigger(15, ActionEvent.CreateNewFromScene(d, b))
  33854. }
  33855. ,
  33856. this._onInputObserver = this._deviceInputSystem.onInputChangedObservable.add(function(b) {
  33857. var k = b;
  33858. b.deviceType === DeviceType.Keyboard && (b.currentState === 1 && c._onKeyDown(k),
  33859. b.currentState === 0 && c._onKeyUp(k)),
  33860. (b.deviceType === DeviceType.Mouse || b.deviceType === DeviceType.Touch) && (i && b.inputIndex >= PointerInput.LeftClick && b.inputIndex <= PointerInput.RightClick && b.currentState === 1 && c._onPointerDown(k),
  33861. e && b.inputIndex >= PointerInput.LeftClick && b.inputIndex <= PointerInput.RightClick && b.currentState === 0 && c._onPointerUp(k),
  33862. o && (b.inputIndex === PointerInput.Horizontal || b.inputIndex === PointerInput.Vertical || b.inputIndex === PointerInput.DeltaHorizontal || b.inputIndex === PointerInput.DeltaVertical || b.inputIndex === PointerInput.MouseWheelX || b.inputIndex === PointerInput.MouseWheelY || b.inputIndex === PointerInput.MouseWheelZ) && c._onPointerMove(k))
  33863. }),
  33864. this._alreadyAttached = !0
  33865. }
  33866. ,
  33867. a.prototype.detachControl = function() {
  33868. this._alreadyAttached && (this._deviceInputSystem.onInputChangedObservable.remove(this._onInputObserver),
  33869. this._alreadyAttachedTo && !this._scene.doNotHandleCursors && (this._alreadyAttachedTo.style.cursor = this._scene.defaultCursor),
  33870. this._alreadyAttached = !1)
  33871. }
  33872. ,
  33873. a.prototype.setPointerOverMesh = function(e, i, o) {
  33874. if (i === void 0 && (i = 0),
  33875. this._meshUnderPointerId[i] !== e) {
  33876. var s = this._meshUnderPointerId[i], c;
  33877. s && (c = s._getActionManagerForTrigger(10),
  33878. c && c.processTrigger(10, ActionEvent.CreateNew(s, void 0, {
  33879. pointerId: i
  33880. }))),
  33881. e ? (this._meshUnderPointerId[i] = e,
  33882. this._pointerOverMesh = e,
  33883. c = e._getActionManagerForTrigger(9),
  33884. c && c.processTrigger(9, ActionEvent.CreateNew(e, void 0, {
  33885. pointerId: i,
  33886. pickResult: o
  33887. }))) : (delete this._meshUnderPointerId[i],
  33888. this._pointerOverMesh = null)
  33889. }
  33890. }
  33891. ,
  33892. a.prototype.getPointerOverMesh = function() {
  33893. return this._pointerOverMesh
  33894. }
  33895. ,
  33896. a.prototype._invalidateMesh = function(e) {
  33897. this._pointerOverMesh === e && (this._pointerOverMesh = null),
  33898. this._pickedDownMesh === e && (this._pickedDownMesh = null),
  33899. this._pickedUpMesh === e && (this._pickedUpMesh = null);
  33900. for (var i in this._meshUnderPointerId)
  33901. this._meshUnderPointerId[i] === e && delete this._meshUnderPointerId[i]
  33902. }
  33903. ,
  33904. a.DragMovementThreshold = 10,
  33905. a.LongPressDelay = 500,
  33906. a.DoubleClickDelay = 300,
  33907. a.ExclusiveDoubleClickMode = !1,
  33908. a
  33909. }()
  33910. , UniqueIdGenerator = function() {
  33911. function a() {}
  33912. return Object.defineProperty(a, "UniqueId", {
  33913. get: function() {
  33914. var e = this._UniqueIdCounter;
  33915. return this._UniqueIdCounter++,
  33916. e
  33917. },
  33918. enumerable: !1,
  33919. configurable: !0
  33920. }),
  33921. a._UniqueIdCounter = 0,
  33922. a
  33923. }()
  33924. , LightConstants = function() {
  33925. function a() {}
  33926. return a.CompareLightsPriority = function(e, i) {
  33927. return e.shadowEnabled !== i.shadowEnabled ? (i.shadowEnabled ? 1 : 0) - (e.shadowEnabled ? 1 : 0) : i.renderPriority - e.renderPriority
  33928. }
  33929. ,
  33930. a.FALLOFF_DEFAULT = 0,
  33931. a.FALLOFF_PHYSICAL = 1,
  33932. a.FALLOFF_GLTF = 2,
  33933. a.FALLOFF_STANDARD = 3,
  33934. a.LIGHTMAP_DEFAULT = 0,
  33935. a.LIGHTMAP_SPECULAR = 1,
  33936. a.LIGHTMAP_SHADOWSONLY = 2,
  33937. a.INTENSITYMODE_AUTOMATIC = 0,
  33938. a.INTENSITYMODE_LUMINOUSPOWER = 1,
  33939. a.INTENSITYMODE_LUMINOUSINTENSITY = 2,
  33940. a.INTENSITYMODE_ILLUMINANCE = 3,
  33941. a.INTENSITYMODE_LUMINANCE = 4,
  33942. a.LIGHTTYPEID_POINTLIGHT = 0,
  33943. a.LIGHTTYPEID_DIRECTIONALLIGHT = 1,
  33944. a.LIGHTTYPEID_SPOTLIGHT = 2,
  33945. a.LIGHTTYPEID_HEMISPHERICLIGHT = 3,
  33946. a
  33947. }()
  33948. , ComputePressureObserverWrapper = function() {
  33949. function a(e, i) {
  33950. a.IsAvailable && (this._observer = new window.ComputePressureObserver(e,i))
  33951. }
  33952. return Object.defineProperty(a, "IsAvailable", {
  33953. get: function() {
  33954. return IsWindowObjectExist() && "ComputePressureObserver"in window
  33955. },
  33956. enumerable: !1,
  33957. configurable: !0
  33958. }),
  33959. a.prototype.observe = function() {
  33960. var e, i;
  33961. !((e = this._observer) === null || e === void 0) && e.observe && ((i = this._observer) === null || i === void 0 || i.observe())
  33962. }
  33963. ,
  33964. a.prototype.unobserve = function() {
  33965. var e, i;
  33966. !((e = this._observer) === null || e === void 0) && e.unobserve && ((i = this._observer) === null || i === void 0 || i.unobserve())
  33967. }
  33968. ,
  33969. a
  33970. }()
  33971. , _injectLTSScene = function(a) {
  33972. a.prototype.setActiveCameraByID = function(e) {
  33973. return this.setActiveCameraById(e)
  33974. }
  33975. ,
  33976. a.prototype.getLastMaterialByID = function(e) {
  33977. return this.getLastMaterialById(e)
  33978. }
  33979. ,
  33980. a.prototype.getMaterialByID = function(e) {
  33981. return this.getMaterialById(e)
  33982. }
  33983. ,
  33984. a.prototype.getTextureByUniqueID = function(e) {
  33985. return this.getTextureByUniqueId(e)
  33986. }
  33987. ,
  33988. a.prototype.getCameraByID = function(e) {
  33989. return this.getCameraById(e)
  33990. }
  33991. ,
  33992. a.prototype.getCameraByUniqueID = function(e) {
  33993. return this.getCameraByUniqueId(e)
  33994. }
  33995. ,
  33996. a.prototype.getBoneByID = function(e) {
  33997. return this.getBoneById(e)
  33998. }
  33999. ,
  34000. a.prototype.getLightByID = function(e) {
  34001. return this.getLightById(e)
  34002. }
  34003. ,
  34004. a.prototype.getLightByUniqueID = function(e) {
  34005. return this.getLightByUniqueId(e)
  34006. }
  34007. ,
  34008. a.prototype.getParticleSystemByID = function(e) {
  34009. return this.getParticleSystemById(e)
  34010. }
  34011. ,
  34012. a.prototype.getGeometryByID = function(e) {
  34013. return this.getGeometryById(e)
  34014. }
  34015. ,
  34016. a.prototype.getMeshByID = function(e) {
  34017. return this.getMeshById(e)
  34018. }
  34019. ,
  34020. a.prototype.getMeshesByID = function(e) {
  34021. return this.getMeshesById(e)
  34022. }
  34023. ,
  34024. a.prototype.getTransformNodeByID = function(e) {
  34025. return this.getTransformNodeById(e)
  34026. }
  34027. ,
  34028. a.prototype.getTransformNodeByUniqueID = function(e) {
  34029. return this.getTransformNodeByUniqueId(e)
  34030. }
  34031. ,
  34032. a.prototype.getTransformNodesByID = function(e) {
  34033. return this.getTransformNodesById(e)
  34034. }
  34035. ,
  34036. a.prototype.getMeshByUniqueID = function(e) {
  34037. return this.getMeshByUniqueId(e)
  34038. }
  34039. ,
  34040. a.prototype.getLastMeshByID = function(e) {
  34041. return this.getLastMeshById(e)
  34042. }
  34043. ,
  34044. a.prototype.getLastEntryByID = function(e) {
  34045. return this.getLastEntryById(e)
  34046. }
  34047. ,
  34048. a.prototype.getNodeByID = function(e) {
  34049. return this.getNodeById(e)
  34050. }
  34051. ,
  34052. a.prototype.getLastSkeletonByID = function(e) {
  34053. return this.getLastSkeletonById(e)
  34054. }
  34055. }
  34056. , Scene = function(a) {
  34057. __extends(e, a);
  34058. function e(i, o) {
  34059. var s = a.call(this) || this;
  34060. s._inputManager = new InputManager(s),
  34061. s.cameraToUseForPointers = null,
  34062. s._isScene = !0,
  34063. s._blockEntityCollection = !1,
  34064. s.autoClear = !0,
  34065. s.autoClearDepthAndStencil = !0,
  34066. s.clearColor = new Color4(.2,.2,.3,1),
  34067. s.ambientColor = new Color3(0,0,0),
  34068. s._environmentIntensity = 1,
  34069. s._forceWireframe = !1,
  34070. s._skipFrustumClipping = !1,
  34071. s._forcePointsCloud = !1,
  34072. s.animationsEnabled = !0,
  34073. s._animationPropertiesOverride = null,
  34074. s.useConstantAnimationDeltaTime = !1,
  34075. s.constantlyUpdateMeshUnderPointer = !1,
  34076. s.hoverCursor = "pointer",
  34077. s.defaultCursor = "",
  34078. s.doNotHandleCursors = !1,
  34079. s.preventDefaultOnPointerDown = !0,
  34080. s.preventDefaultOnPointerUp = !0,
  34081. s.metadata = null,
  34082. s.reservedDataStore = null,
  34083. s.disableOfflineSupportExceptionRules = new Array,
  34084. s.onDisposeObservable = new Observable,
  34085. s._onDisposeObserver = null,
  34086. s.onBeforeRenderObservable = new Observable,
  34087. s._onBeforeRenderObserver = null,
  34088. s.onAfterRenderObservable = new Observable,
  34089. s.onBeforeRunRegisterBeforeRenderObservable = new Observable,
  34090. s.onAfterRunRegisterBeforeRenderObservable = new Observable,
  34091. s.onBeforeRunRegisterAfterRenderObservable = new Observable,
  34092. s.onAfterRunRegisterAfterRenderObservable = new Observable,
  34093. s.onBeforeRTT1Observable = new Observable,
  34094. s.onAfterRTT1Observable = new Observable,
  34095. s.onAfterRenderCameraObservable = new Observable,
  34096. s._onAfterRenderObserver = null,
  34097. s.onBeforeAnimationsObservable = new Observable,
  34098. s.onAfterAnimationsObservable = new Observable,
  34099. s.onBeforeDrawPhaseObservable = new Observable,
  34100. s.onAfterDrawPhaseObservable = new Observable,
  34101. s.onReadyObservable = new Observable,
  34102. s.onBeforeCameraRenderObservable = new Observable,
  34103. s._onBeforeCameraRenderObserver = null,
  34104. s.onAfterCameraRenderObservable = new Observable,
  34105. s._onAfterCameraRenderObserver = null,
  34106. s.onBeforeActiveMeshesEvaluationObservable = new Observable,
  34107. s.onAfterActiveMeshesEvaluationObservable = new Observable,
  34108. s.onBeforeParticlesRenderingObservable = new Observable,
  34109. s.onAfterParticlesRenderingObservable = new Observable,
  34110. s.onDataLoadedObservable = new Observable,
  34111. s.onNewCameraAddedObservable = new Observable,
  34112. s.onCameraRemovedObservable = new Observable,
  34113. s.onNewLightAddedObservable = new Observable,
  34114. s.onLightRemovedObservable = new Observable,
  34115. s.onNewGeometryAddedObservable = new Observable,
  34116. s.onGeometryRemovedObservable = new Observable,
  34117. s.onNewTransformNodeAddedObservable = new Observable,
  34118. s.onTransformNodeRemovedObservable = new Observable,
  34119. s.onNewMeshAddedObservable = new Observable,
  34120. s.onMeshRemovedObservable = new Observable,
  34121. s.onNewSkeletonAddedObservable = new Observable,
  34122. s.onSkeletonRemovedObservable = new Observable,
  34123. s.onNewMaterialAddedObservable = new Observable,
  34124. s.onNewMultiMaterialAddedObservable = new Observable,
  34125. s.onMaterialRemovedObservable = new Observable,
  34126. s.onMultiMaterialRemovedObservable = new Observable,
  34127. s.onNewTextureAddedObservable = new Observable,
  34128. s.onTextureRemovedObservable = new Observable,
  34129. s.onBeforeRenderTargetsRenderObservable = new Observable,
  34130. s.onAfterRenderTargetsRenderObservable = new Observable,
  34131. s.onBeforeStepObservable = new Observable,
  34132. s.onAfterStepObservable = new Observable,
  34133. s.onActiveCameraChanged = new Observable,
  34134. s.onBeforeRenderingGroupObservable = new Observable,
  34135. s.onAfterRenderingGroupObservable = new Observable,
  34136. s.onMeshImportedObservable = new Observable,
  34137. s.onAnimationFileImportedObservable = new Observable,
  34138. s._registeredForLateAnimationBindings = new SmartArrayNoDuplicate(256),
  34139. s.skipPointerMovePicking = !1,
  34140. s.onPrePointerObservable = new Observable,
  34141. s.onPointerObservable = new Observable,
  34142. s.onPreKeyboardObservable = new Observable,
  34143. s.onKeyboardObservable = new Observable,
  34144. s._useRightHandedSystem = !1,
  34145. s._timeAccumulator = 0,
  34146. s._currentStepId = 0,
  34147. s._currentInternalStep = 0,
  34148. s._fogEnabled = !0,
  34149. s._fogMode = e.FOGMODE_NONE,
  34150. s.fogColor = new Color3(.2,.2,.3),
  34151. s.fogDensity = .1,
  34152. s.fogStart = 0,
  34153. s.fogEnd = 1e3,
  34154. s.needsPreviousWorldMatrices = !1,
  34155. s._shadowsEnabled = !0,
  34156. s._lightsEnabled = !0,
  34157. s.activeCameras = new Array,
  34158. s._texturesEnabled = !0,
  34159. s.physicsEnabled = !0,
  34160. s.particlesEnabled = !0,
  34161. s.spritesEnabled = !0,
  34162. s._skeletonsEnabled = !0,
  34163. s.lensFlaresEnabled = !0,
  34164. s.collisionsEnabled = !0,
  34165. s.gravity = new Vector3(0,-9.807,0),
  34166. s.postProcessesEnabled = !0,
  34167. s.renderTargetsEnabled = !0,
  34168. s.dumpNextRenderTargets = !1,
  34169. s.customRenderTargets = new Array,
  34170. s.importedMeshesFiles = new Array,
  34171. s.probesEnabled = !0,
  34172. s._meshesForIntersections = new SmartArrayNoDuplicate(256),
  34173. s.proceduralTexturesEnabled = !0,
  34174. s._totalVertices = new PerfCounter,
  34175. s._activeIndices = new PerfCounter,
  34176. s._activeParticles = new PerfCounter,
  34177. s._activeBones = new PerfCounter,
  34178. s._animationTime = 0,
  34179. s.animationTimeScale = 1,
  34180. s._renderId = 0,
  34181. s._frameId = 0,
  34182. s._executeWhenReadyTimeoutId = -1,
  34183. s._intermediateRendering = !1,
  34184. s._defaultFrameBufferCleared = !1,
  34185. s._viewUpdateFlag = -1,
  34186. s._projectionUpdateFlag = -1,
  34187. s._toBeDisposed = new Array(256),
  34188. s._activeRequests = new Array,
  34189. s._pendingData = new Array,
  34190. s._isDisposed = !1,
  34191. s.dispatchAllSubMeshesOfActiveMeshes = !1,
  34192. s._activeMeshes = new SmartArray(256),
  34193. s._processedMaterials = new SmartArray(256),
  34194. s._renderTargets = new SmartArrayNoDuplicate(256),
  34195. s._activeParticleSystems = new SmartArray(256),
  34196. s._activeSkeletons = new SmartArrayNoDuplicate(32),
  34197. s._softwareSkinnedMeshes = new SmartArrayNoDuplicate(32),
  34198. s._activeAnimatables = new Array,
  34199. s._transformMatrix = Matrix.Zero(),
  34200. s.requireLightSorting = !1,
  34201. s._components = [],
  34202. s._serializableComponents = [],
  34203. s._transientComponents = [],
  34204. s._beforeCameraUpdateStage = Stage.Create(),
  34205. s._beforeClearStage = Stage.Create(),
  34206. s._beforeRenderTargetClearStage = Stage.Create(),
  34207. s._gatherRenderTargetsStage = Stage.Create(),
  34208. s._gatherActiveCameraRenderTargetsStage = Stage.Create(),
  34209. s._isReadyForMeshStage = Stage.Create(),
  34210. s._beforeEvaluateActiveMeshStage = Stage.Create(),
  34211. s._evaluateSubMeshStage = Stage.Create(),
  34212. s._preActiveMeshStage = Stage.Create(),
  34213. s._cameraDrawRenderTargetStage = Stage.Create(),
  34214. s._beforeCameraDrawStage = Stage.Create(),
  34215. s._beforeRenderTargetDrawStage = Stage.Create(),
  34216. s._beforeRenderingGroupDrawStage = Stage.Create(),
  34217. s._beforeRenderingMeshStage = Stage.Create(),
  34218. s._afterRenderingMeshStage = Stage.Create(),
  34219. s._afterRenderingGroupDrawStage = Stage.Create(),
  34220. s._afterCameraDrawStage = Stage.Create(),
  34221. s._afterRenderTargetDrawStage = Stage.Create(),
  34222. s._afterRenderStage = Stage.Create(),
  34223. s._pointerMoveStage = Stage.Create(),
  34224. s._pointerDownStage = Stage.Create(),
  34225. s._pointerUpStage = Stage.Create(),
  34226. s.geometriesByUniqueId = null,
  34227. s._defaultMeshCandidates = {
  34228. data: [],
  34229. length: 0
  34230. },
  34231. s._defaultSubMeshCandidates = {
  34232. data: [],
  34233. length: 0
  34234. },
  34235. s._preventFreeActiveMeshesAndRenderingGroups = !1,
  34236. s._activeMeshesFrozen = !1,
  34237. s._skipEvaluateActiveMeshesCompletely = !1,
  34238. s._allowPostProcessClearColor = !0,
  34239. s.getDeterministicFrameTime = function() {
  34240. return s._engine.getTimeStep()
  34241. }
  34242. ,
  34243. s._blockMaterialDirtyMechanism = !1,
  34244. s._perfCollector = null,
  34245. s.onComputePressureChanged = new Observable;
  34246. var c = __assign({
  34247. useGeometryUniqueIdsMap: !0,
  34248. useMaterialMeshMap: !0,
  34249. useClonedMeshMap: !0,
  34250. virtual: !1
  34251. }, o);
  34252. return s._engine = i || EngineStore.LastCreatedEngine,
  34253. c.virtual ? s._engine._virtualScenes.push(s) : (EngineStore._LastCreatedScene = s,
  34254. s._engine.scenes.push(s)),
  34255. s._uid = null,
  34256. s._renderingManager = new RenderingManager(s),
  34257. PostProcessManager && (s.postProcessManager = new PostProcessManager(s)),
  34258. IsWindowObjectExist() && s.attachControl(),
  34259. s._createUbo(),
  34260. ImageProcessingConfiguration && (s._imageProcessingConfiguration = new ImageProcessingConfiguration),
  34261. s.setDefaultCandidateProviders(),
  34262. c.useGeometryUniqueIdsMap && (s.geometriesByUniqueId = {}),
  34263. s.useMaterialMeshMap = c.useMaterialMeshMap,
  34264. s.useClonedMeshMap = c.useClonedMeshMap,
  34265. (!o || !o.virtual) && s._engine.onNewSceneAddedObservable.notifyObservers(s),
  34266. ComputePressureObserverWrapper.IsAvailable && (s._computePressureObserver = new ComputePressureObserverWrapper(function(d) {
  34267. s.onComputePressureChanged.notifyObservers(d)
  34268. }
  34269. ,{
  34270. cpuUtilizationThresholds: [.25, .5, .75, .9],
  34271. cpuSpeedThresholds: [.5]
  34272. }),
  34273. s._computePressureObserver.observe()),
  34274. s
  34275. }
  34276. return e.DefaultMaterialFactory = function(i) {
  34277. throw _WarnImport("StandardMaterial")
  34278. }
  34279. ,
  34280. e.CollisionCoordinatorFactory = function() {
  34281. throw _WarnImport("DefaultCollisionCoordinator")
  34282. }
  34283. ,
  34284. Object.defineProperty(e.prototype, "environmentTexture", {
  34285. get: function() {
  34286. return this._environmentTexture
  34287. },
  34288. set: function(i) {
  34289. this._environmentTexture !== i && (this._environmentTexture = i,
  34290. this.markAllMaterialsAsDirty(1))
  34291. },
  34292. enumerable: !1,
  34293. configurable: !0
  34294. }),
  34295. Object.defineProperty(e.prototype, "environmentIntensity", {
  34296. get: function() {
  34297. return this._environmentIntensity
  34298. },
  34299. set: function(i) {
  34300. this._environmentIntensity !== i && (this._environmentIntensity = i,
  34301. this.markAllMaterialsAsDirty(1))
  34302. },
  34303. enumerable: !1,
  34304. configurable: !0
  34305. }),
  34306. Object.defineProperty(e.prototype, "imageProcessingConfiguration", {
  34307. get: function() {
  34308. return this._imageProcessingConfiguration
  34309. },
  34310. enumerable: !1,
  34311. configurable: !0
  34312. }),
  34313. Object.defineProperty(e.prototype, "forceWireframe", {
  34314. get: function() {
  34315. return this._forceWireframe
  34316. },
  34317. set: function(i) {
  34318. this._forceWireframe !== i && (this._forceWireframe = i,
  34319. this.markAllMaterialsAsDirty(16))
  34320. },
  34321. enumerable: !1,
  34322. configurable: !0
  34323. }),
  34324. Object.defineProperty(e.prototype, "skipFrustumClipping", {
  34325. get: function() {
  34326. return this._skipFrustumClipping
  34327. },
  34328. set: function(i) {
  34329. this._skipFrustumClipping !== i && (this._skipFrustumClipping = i)
  34330. },
  34331. enumerable: !1,
  34332. configurable: !0
  34333. }),
  34334. Object.defineProperty(e.prototype, "forcePointsCloud", {
  34335. get: function() {
  34336. return this._forcePointsCloud
  34337. },
  34338. set: function(i) {
  34339. this._forcePointsCloud !== i && (this._forcePointsCloud = i,
  34340. this.markAllMaterialsAsDirty(16))
  34341. },
  34342. enumerable: !1,
  34343. configurable: !0
  34344. }),
  34345. Object.defineProperty(e.prototype, "animationPropertiesOverride", {
  34346. get: function() {
  34347. return this._animationPropertiesOverride
  34348. },
  34349. set: function(i) {
  34350. this._animationPropertiesOverride = i
  34351. },
  34352. enumerable: !1,
  34353. configurable: !0
  34354. }),
  34355. Object.defineProperty(e.prototype, "onDispose", {
  34356. set: function(i) {
  34357. this._onDisposeObserver && this.onDisposeObservable.remove(this._onDisposeObserver),
  34358. this._onDisposeObserver = this.onDisposeObservable.add(i)
  34359. },
  34360. enumerable: !1,
  34361. configurable: !0
  34362. }),
  34363. Object.defineProperty(e.prototype, "beforeRender", {
  34364. set: function(i) {
  34365. this._onBeforeRenderObserver && this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),
  34366. i && (this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(i))
  34367. },
  34368. enumerable: !1,
  34369. configurable: !0
  34370. }),
  34371. Object.defineProperty(e.prototype, "afterRender", {
  34372. set: function(i) {
  34373. this._onAfterRenderObserver && this.onAfterRenderObservable.remove(this._onAfterRenderObserver),
  34374. i && (this._onAfterRenderObserver = this.onAfterRenderObservable.add(i))
  34375. },
  34376. enumerable: !1,
  34377. configurable: !0
  34378. }),
  34379. Object.defineProperty(e.prototype, "beforeCameraRender", {
  34380. set: function(i) {
  34381. this._onBeforeCameraRenderObserver && this.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),
  34382. this._onBeforeCameraRenderObserver = this.onBeforeCameraRenderObservable.add(i)
  34383. },
  34384. enumerable: !1,
  34385. configurable: !0
  34386. }),
  34387. Object.defineProperty(e.prototype, "afterCameraRender", {
  34388. set: function(i) {
  34389. this._onAfterCameraRenderObserver && this.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver),
  34390. this._onAfterCameraRenderObserver = this.onAfterCameraRenderObservable.add(i)
  34391. },
  34392. enumerable: !1,
  34393. configurable: !0
  34394. }),
  34395. Object.defineProperty(e.prototype, "unTranslatedPointer", {
  34396. get: function() {
  34397. return this._inputManager.unTranslatedPointer
  34398. },
  34399. enumerable: !1,
  34400. configurable: !0
  34401. }),
  34402. Object.defineProperty(e, "DragMovementThreshold", {
  34403. get: function() {
  34404. return InputManager.DragMovementThreshold
  34405. },
  34406. set: function(i) {
  34407. InputManager.DragMovementThreshold = i
  34408. },
  34409. enumerable: !1,
  34410. configurable: !0
  34411. }),
  34412. Object.defineProperty(e, "LongPressDelay", {
  34413. get: function() {
  34414. return InputManager.LongPressDelay
  34415. },
  34416. set: function(i) {
  34417. InputManager.LongPressDelay = i
  34418. },
  34419. enumerable: !1,
  34420. configurable: !0
  34421. }),
  34422. Object.defineProperty(e, "DoubleClickDelay", {
  34423. get: function() {
  34424. return InputManager.DoubleClickDelay
  34425. },
  34426. set: function(i) {
  34427. InputManager.DoubleClickDelay = i
  34428. },
  34429. enumerable: !1,
  34430. configurable: !0
  34431. }),
  34432. Object.defineProperty(e, "ExclusiveDoubleClickMode", {
  34433. get: function() {
  34434. return InputManager.ExclusiveDoubleClickMode
  34435. },
  34436. set: function(i) {
  34437. InputManager.ExclusiveDoubleClickMode = i
  34438. },
  34439. enumerable: !1,
  34440. configurable: !0
  34441. }),
  34442. e.prototype.bindEyePosition = function(i, o, s) {
  34443. var c;
  34444. o === void 0 && (o = "vEyePosition"),
  34445. s === void 0 && (s = !1);
  34446. var d = this._forcedViewPosition ? this._forcedViewPosition : this._mirroredCameraPosition ? this._mirroredCameraPosition : (c = this.activeCamera.globalPosition) !== null && c !== void 0 ? c : this.activeCamera.devicePosition
  34447. , _ = this.useRightHandedSystem === (this._mirroredCameraPosition != null);
  34448. return TmpVectors.Vector4[0].set(d.x, d.y, d.z, _ ? -1 : 1),
  34449. i && (s ? i.setFloat3(o, TmpVectors.Vector4[0].x, TmpVectors.Vector4[0].y, TmpVectors.Vector4[0].z) : i.setVector4(o, TmpVectors.Vector4[0])),
  34450. TmpVectors.Vector4[0]
  34451. }
  34452. ,
  34453. e.prototype.finalizeSceneUbo = function() {
  34454. var i = this.getSceneUniformBuffer()
  34455. , o = this.bindEyePosition(null);
  34456. return i.updateFloat4("vEyePosition", o.x, o.y, o.z, o.w),
  34457. i.update(),
  34458. i
  34459. }
  34460. ,
  34461. Object.defineProperty(e.prototype, "useRightHandedSystem", {
  34462. get: function() {
  34463. return this._useRightHandedSystem
  34464. },
  34465. set: function(i) {
  34466. this._useRightHandedSystem !== i && (this._useRightHandedSystem = i,
  34467. this.markAllMaterialsAsDirty(16))
  34468. },
  34469. enumerable: !1,
  34470. configurable: !0
  34471. }),
  34472. e.prototype.setStepId = function(i) {
  34473. this._currentStepId = i
  34474. }
  34475. ,
  34476. e.prototype.getStepId = function() {
  34477. return this._currentStepId
  34478. }
  34479. ,
  34480. e.prototype.getInternalStep = function() {
  34481. return this._currentInternalStep
  34482. }
  34483. ,
  34484. Object.defineProperty(e.prototype, "fogEnabled", {
  34485. get: function() {
  34486. return this._fogEnabled
  34487. },
  34488. set: function(i) {
  34489. this._fogEnabled !== i && (this._fogEnabled = i,
  34490. this.markAllMaterialsAsDirty(16))
  34491. },
  34492. enumerable: !1,
  34493. configurable: !0
  34494. }),
  34495. Object.defineProperty(e.prototype, "fogMode", {
  34496. get: function() {
  34497. return this._fogMode
  34498. },
  34499. set: function(i) {
  34500. this._fogMode !== i && (this._fogMode = i,
  34501. this.markAllMaterialsAsDirty(16))
  34502. },
  34503. enumerable: !1,
  34504. configurable: !0
  34505. }),
  34506. Object.defineProperty(e.prototype, "prePass", {
  34507. get: function() {
  34508. return !!this.prePassRenderer && this.prePassRenderer.defaultRT.enabled
  34509. },
  34510. enumerable: !1,
  34511. configurable: !0
  34512. }),
  34513. Object.defineProperty(e.prototype, "shadowsEnabled", {
  34514. get: function() {
  34515. return this._shadowsEnabled
  34516. },
  34517. set: function(i) {
  34518. this._shadowsEnabled !== i && (this._shadowsEnabled = i,
  34519. this.markAllMaterialsAsDirty(2))
  34520. },
  34521. enumerable: !1,
  34522. configurable: !0
  34523. }),
  34524. Object.defineProperty(e.prototype, "lightsEnabled", {
  34525. get: function() {
  34526. return this._lightsEnabled
  34527. },
  34528. set: function(i) {
  34529. this._lightsEnabled !== i && (this._lightsEnabled = i,
  34530. this.markAllMaterialsAsDirty(2))
  34531. },
  34532. enumerable: !1,
  34533. configurable: !0
  34534. }),
  34535. Object.defineProperty(e.prototype, "activeCamera", {
  34536. get: function() {
  34537. return this._activeCamera
  34538. },
  34539. set: function(i) {
  34540. i !== this._activeCamera && (this._activeCamera = i,
  34541. this.onActiveCameraChanged.notifyObservers(this))
  34542. },
  34543. enumerable: !1,
  34544. configurable: !0
  34545. }),
  34546. Object.defineProperty(e.prototype, "defaultMaterial", {
  34547. get: function() {
  34548. return this._defaultMaterial || (this._defaultMaterial = e.DefaultMaterialFactory(this)),
  34549. this._defaultMaterial
  34550. },
  34551. set: function(i) {
  34552. this._defaultMaterial = i
  34553. },
  34554. enumerable: !1,
  34555. configurable: !0
  34556. }),
  34557. Object.defineProperty(e.prototype, "texturesEnabled", {
  34558. get: function() {
  34559. return this._texturesEnabled
  34560. },
  34561. set: function(i) {
  34562. this._texturesEnabled !== i && (this._texturesEnabled = i,
  34563. this.markAllMaterialsAsDirty(1))
  34564. },
  34565. enumerable: !1,
  34566. configurable: !0
  34567. }),
  34568. Object.defineProperty(e.prototype, "skeletonsEnabled", {
  34569. get: function() {
  34570. return this._skeletonsEnabled
  34571. },
  34572. set: function(i) {
  34573. this._skeletonsEnabled !== i && (this._skeletonsEnabled = i,
  34574. this.markAllMaterialsAsDirty(8))
  34575. },
  34576. enumerable: !1,
  34577. configurable: !0
  34578. }),
  34579. Object.defineProperty(e.prototype, "collisionCoordinator", {
  34580. get: function() {
  34581. return this._collisionCoordinator || (this._collisionCoordinator = e.CollisionCoordinatorFactory(),
  34582. this._collisionCoordinator.init(this)),
  34583. this._collisionCoordinator
  34584. },
  34585. enumerable: !1,
  34586. configurable: !0
  34587. }),
  34588. Object.defineProperty(e.prototype, "frustumPlanes", {
  34589. get: function() {
  34590. return this._frustumPlanes
  34591. },
  34592. enumerable: !1,
  34593. configurable: !0
  34594. }),
  34595. e.prototype._registerTransientComponents = function() {
  34596. if (this._transientComponents.length > 0) {
  34597. for (var i = 0, o = this._transientComponents; i < o.length; i++) {
  34598. var s = o[i];
  34599. s.register()
  34600. }
  34601. this._transientComponents = []
  34602. }
  34603. }
  34604. ,
  34605. e.prototype._addComponent = function(i) {
  34606. this._components.push(i),
  34607. this._transientComponents.push(i);
  34608. var o = i;
  34609. o.addFromContainer && o.serialize && this._serializableComponents.push(o)
  34610. }
  34611. ,
  34612. e.prototype._getComponent = function(i) {
  34613. for (var o = 0, s = this._components; o < s.length; o++) {
  34614. var c = s[o];
  34615. if (c.name === i)
  34616. return c
  34617. }
  34618. return null
  34619. }
  34620. ,
  34621. e.prototype.getClassName = function() {
  34622. return "Scene"
  34623. }
  34624. ,
  34625. e.prototype._getDefaultMeshCandidates = function() {
  34626. return this._defaultMeshCandidates.data = this.meshes,
  34627. this._defaultMeshCandidates.length = this.meshes.length,
  34628. this._defaultMeshCandidates
  34629. }
  34630. ,
  34631. e.prototype._getDefaultSubMeshCandidates = function(i) {
  34632. return this._defaultSubMeshCandidates.data = i.subMeshes,
  34633. this._defaultSubMeshCandidates.length = i.subMeshes.length,
  34634. this._defaultSubMeshCandidates
  34635. }
  34636. ,
  34637. e.prototype.setDefaultCandidateProviders = function() {
  34638. this.getActiveMeshCandidates = this._getDefaultMeshCandidates.bind(this),
  34639. this.getActiveSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this),
  34640. this.getIntersectingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this),
  34641. this.getCollidingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this)
  34642. }
  34643. ,
  34644. Object.defineProperty(e.prototype, "meshUnderPointer", {
  34645. get: function() {
  34646. return this._inputManager.meshUnderPointer
  34647. },
  34648. enumerable: !1,
  34649. configurable: !0
  34650. }),
  34651. Object.defineProperty(e.prototype, "pointerX", {
  34652. get: function() {
  34653. return this._inputManager.pointerX
  34654. },
  34655. set: function(i) {
  34656. this._inputManager.pointerX = i
  34657. },
  34658. enumerable: !1,
  34659. configurable: !0
  34660. }),
  34661. Object.defineProperty(e.prototype, "pointerY", {
  34662. get: function() {
  34663. return this._inputManager.pointerY
  34664. },
  34665. set: function(i) {
  34666. this._inputManager.pointerY = i
  34667. },
  34668. enumerable: !1,
  34669. configurable: !0
  34670. }),
  34671. e.prototype.getCachedMaterial = function() {
  34672. return this._cachedMaterial
  34673. }
  34674. ,
  34675. e.prototype.getCachedEffect = function() {
  34676. return this._cachedEffect
  34677. }
  34678. ,
  34679. e.prototype.getCachedVisibility = function() {
  34680. return this._cachedVisibility
  34681. }
  34682. ,
  34683. e.prototype.isCachedMaterialInvalid = function(i, o, s) {
  34684. return s === void 0 && (s = 1),
  34685. this._cachedEffect !== o || this._cachedMaterial !== i || this._cachedVisibility !== s
  34686. }
  34687. ,
  34688. e.prototype.getEngine = function() {
  34689. return this._engine
  34690. }
  34691. ,
  34692. e.prototype.getTotalVertices = function() {
  34693. return this._totalVertices.current
  34694. }
  34695. ,
  34696. Object.defineProperty(e.prototype, "totalVerticesPerfCounter", {
  34697. get: function() {
  34698. return this._totalVertices
  34699. },
  34700. enumerable: !1,
  34701. configurable: !0
  34702. }),
  34703. e.prototype.getActiveIndices = function() {
  34704. return this._activeIndices.current
  34705. }
  34706. ,
  34707. Object.defineProperty(e.prototype, "totalActiveIndicesPerfCounter", {
  34708. get: function() {
  34709. return this._activeIndices
  34710. },
  34711. enumerable: !1,
  34712. configurable: !0
  34713. }),
  34714. e.prototype.getActiveParticles = function() {
  34715. return this._activeParticles.current
  34716. }
  34717. ,
  34718. Object.defineProperty(e.prototype, "activeParticlesPerfCounter", {
  34719. get: function() {
  34720. return this._activeParticles
  34721. },
  34722. enumerable: !1,
  34723. configurable: !0
  34724. }),
  34725. e.prototype.getActiveBones = function() {
  34726. return this._activeBones.current
  34727. }
  34728. ,
  34729. Object.defineProperty(e.prototype, "activeBonesPerfCounter", {
  34730. get: function() {
  34731. return this._activeBones
  34732. },
  34733. enumerable: !1,
  34734. configurable: !0
  34735. }),
  34736. e.prototype.getActiveMeshes = function() {
  34737. return this._activeMeshes
  34738. }
  34739. ,
  34740. e.prototype.getAnimationRatio = function() {
  34741. return this._animationRatio !== void 0 ? this._animationRatio : 1
  34742. }
  34743. ,
  34744. e.prototype.getRenderId = function() {
  34745. return this._renderId
  34746. }
  34747. ,
  34748. e.prototype.getFrameId = function() {
  34749. return this._frameId
  34750. }
  34751. ,
  34752. e.prototype.incrementRenderId = function() {
  34753. this._renderId++
  34754. }
  34755. ,
  34756. e.prototype._createUbo = function() {
  34757. this.setSceneUniformBuffer(this.createSceneUniformBuffer())
  34758. }
  34759. ,
  34760. e.prototype.simulatePointerMove = function(i, o) {
  34761. return this._inputManager.simulatePointerMove(i, o),
  34762. this
  34763. }
  34764. ,
  34765. e.prototype.simulatePointerDown = function(i, o) {
  34766. return this._inputManager.simulatePointerDown(i, o),
  34767. this
  34768. }
  34769. ,
  34770. e.prototype.simulatePointerUp = function(i, o, s) {
  34771. return this._inputManager.simulatePointerUp(i, o, s),
  34772. this
  34773. }
  34774. ,
  34775. e.prototype.isPointerCaptured = function(i) {
  34776. return i === void 0 && (i = 0),
  34777. this._inputManager.isPointerCaptured(i)
  34778. }
  34779. ,
  34780. e.prototype.attachControl = function(i, o, s) {
  34781. i === void 0 && (i = !0),
  34782. o === void 0 && (o = !0),
  34783. s === void 0 && (s = !0),
  34784. this._inputManager.attachControl(i, o, s)
  34785. }
  34786. ,
  34787. e.prototype.detachControl = function() {
  34788. this._inputManager.detachControl()
  34789. }
  34790. ,
  34791. e.prototype.isReady = function(i) {
  34792. if (i === void 0 && (i = !0),
  34793. this._isDisposed)
  34794. return !1;
  34795. var o, s = this.getEngine();
  34796. if (!s.areAllEffectsReady() || this._pendingData.length > 0)
  34797. return !1;
  34798. for (i && (this._processedMaterials.reset(),
  34799. this._renderTargets.reset()),
  34800. o = 0; o < this.meshes.length; o++) {
  34801. var c = this.meshes[o];
  34802. if (!!c.isEnabled() && !(!c.subMeshes || c.subMeshes.length === 0)) {
  34803. if (!c.isReady(!0))
  34804. return !1;
  34805. for (var d = c.hasThinInstances || c.getClassName() === "InstancedMesh" || c.getClassName() === "InstancedLinesMesh" || s.getCaps().instancedArrays && c.instances.length > 0, _ = 0, b = this._isReadyForMeshStage; _ < b.length; _++) {
  34806. var k = b[_];
  34807. if (!k.action(c, d))
  34808. return !1
  34809. }
  34810. if (!!i) {
  34811. var j = c.material || this.defaultMaterial;
  34812. if (j)
  34813. if (j._storeEffectOnSubMeshes)
  34814. for (var $ = 0, _e = c.subMeshes; $ < _e.length; $++) {
  34815. var et = _e[$]
  34816. , tt = et.getMaterial();
  34817. tt && tt.hasRenderTargetTextures && tt.getRenderTargetTextures != null && this._processedMaterials.indexOf(tt) === -1 && (this._processedMaterials.push(tt),
  34818. this._renderTargets.concatWithNoDuplicate(tt.getRenderTargetTextures()))
  34819. }
  34820. else
  34821. j.hasRenderTargetTextures && j.getRenderTargetTextures != null && this._processedMaterials.indexOf(j) === -1 && (this._processedMaterials.push(j),
  34822. this._renderTargets.concatWithNoDuplicate(j.getRenderTargetTextures()))
  34823. }
  34824. }
  34825. }
  34826. if (i)
  34827. for (o = 0; o < this._renderTargets.length; ++o) {
  34828. var rt = this._renderTargets.data[o];
  34829. if (!rt.isReadyForRendering())
  34830. return !1
  34831. }
  34832. for (o = 0; o < this.geometries.length; o++) {
  34833. var it = this.geometries[o];
  34834. if (it.delayLoadState === 2)
  34835. return !1
  34836. }
  34837. if (this.activeCameras && this.activeCameras.length > 0)
  34838. for (var nt = 0, ot = this.activeCameras; nt < ot.length; nt++) {
  34839. var at = ot[nt];
  34840. if (!at.isReady(!0))
  34841. return !1
  34842. }
  34843. else if (this.activeCamera && !this.activeCamera.isReady(!0))
  34844. return !1;
  34845. for (var st = 0, ut = this.particleSystems; st < ut.length; st++) {
  34846. var ct = ut[st];
  34847. if (!ct.isReady())
  34848. return !1
  34849. }
  34850. return !0
  34851. }
  34852. ,
  34853. e.prototype.resetCachedMaterial = function() {
  34854. this._cachedMaterial = null,
  34855. this._cachedEffect = null,
  34856. this._cachedVisibility = null
  34857. }
  34858. ,
  34859. e.prototype.registerBeforeRender = function(i) {
  34860. this.onBeforeRenderObservable.add(i)
  34861. }
  34862. ,
  34863. e.prototype.unregisterBeforeRender = function(i) {
  34864. this.onBeforeRenderObservable.removeCallback(i)
  34865. }
  34866. ,
  34867. e.prototype.registerAfterRender = function(i) {
  34868. this.onAfterRenderObservable.add(i)
  34869. }
  34870. ,
  34871. e.prototype.unregisterAfterRender = function(i) {
  34872. this.onAfterRenderObservable.removeCallback(i)
  34873. }
  34874. ,
  34875. e.prototype._executeOnceBeforeRender = function(i) {
  34876. var o = this
  34877. , s = function() {
  34878. i(),
  34879. setTimeout(function() {
  34880. o.unregisterBeforeRender(s)
  34881. })
  34882. };
  34883. this.registerBeforeRender(s)
  34884. }
  34885. ,
  34886. e.prototype.executeOnceBeforeRender = function(i, o) {
  34887. var s = this;
  34888. o !== void 0 ? setTimeout(function() {
  34889. s._executeOnceBeforeRender(i)
  34890. }, o) : this._executeOnceBeforeRender(i)
  34891. }
  34892. ,
  34893. e.prototype._addPendingData = function(i) {
  34894. this._pendingData.push(i)
  34895. }
  34896. ,
  34897. e.prototype._removePendingData = function(i) {
  34898. var o = this.isLoading
  34899. , s = this._pendingData.indexOf(i);
  34900. s !== -1 && this._pendingData.splice(s, 1),
  34901. o && !this.isLoading && this.onDataLoadedObservable.notifyObservers(this)
  34902. }
  34903. ,
  34904. e.prototype.getWaitingItemsCount = function() {
  34905. return this._pendingData.length
  34906. }
  34907. ,
  34908. Object.defineProperty(e.prototype, "isLoading", {
  34909. get: function() {
  34910. return this._pendingData.length > 0
  34911. },
  34912. enumerable: !1,
  34913. configurable: !0
  34914. }),
  34915. e.prototype.executeWhenReady = function(i, o) {
  34916. var s = this;
  34917. o === void 0 && (o = !1),
  34918. this.onReadyObservable.add(i),
  34919. this._executeWhenReadyTimeoutId === -1 && (this._executeWhenReadyTimeoutId = setTimeout(function() {
  34920. s._checkIsReady(o)
  34921. }, 150))
  34922. }
  34923. ,
  34924. e.prototype.whenReadyAsync = function(i) {
  34925. var o = this;
  34926. return i === void 0 && (i = !1),
  34927. new Promise(function(s) {
  34928. o.executeWhenReady(function() {
  34929. s()
  34930. }, i)
  34931. }
  34932. )
  34933. }
  34934. ,
  34935. e.prototype._checkIsReady = function(i) {
  34936. var o = this;
  34937. if (i === void 0 && (i = !1),
  34938. this._registerTransientComponents(),
  34939. this.isReady(i)) {
  34940. this.onReadyObservable.notifyObservers(this),
  34941. this.onReadyObservable.clear(),
  34942. this._executeWhenReadyTimeoutId = -1;
  34943. return
  34944. }
  34945. if (this._isDisposed) {
  34946. this.onReadyObservable.clear(),
  34947. this._executeWhenReadyTimeoutId = -1;
  34948. return
  34949. }
  34950. this._executeWhenReadyTimeoutId = setTimeout(function() {
  34951. o._checkIsReady(i)
  34952. }, 150)
  34953. }
  34954. ,
  34955. Object.defineProperty(e.prototype, "animatables", {
  34956. get: function() {
  34957. return this._activeAnimatables
  34958. },
  34959. enumerable: !1,
  34960. configurable: !0
  34961. }),
  34962. e.prototype.resetLastAnimationTimeFrame = function() {
  34963. this._animationTimeLast = PrecisionDate.Now
  34964. }
  34965. ,
  34966. e.prototype.getViewMatrix = function() {
  34967. return this._viewMatrix
  34968. }
  34969. ,
  34970. e.prototype.getProjectionMatrix = function() {
  34971. return this._projectionMatrix
  34972. }
  34973. ,
  34974. e.prototype.getTransformMatrix = function() {
  34975. return this._transformMatrix
  34976. }
  34977. ,
  34978. e.prototype.setTransformMatrix = function(i, o, s, c) {
  34979. this._viewUpdateFlag === i.updateFlag && this._projectionUpdateFlag === o.updateFlag || (this._viewUpdateFlag = i.updateFlag,
  34980. this._projectionUpdateFlag = o.updateFlag,
  34981. this._viewMatrix = i,
  34982. this._projectionMatrix = o,
  34983. this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix),
  34984. this._frustumPlanes ? Frustum.GetPlanesToRef(this._transformMatrix, this._frustumPlanes) : this._frustumPlanes = Frustum.GetPlanes(this._transformMatrix),
  34985. this._multiviewSceneUbo && this._multiviewSceneUbo.useUbo ? this._updateMultiviewUbo(s, c) : this._sceneUbo.useUbo && (this._sceneUbo.updateMatrix("viewProjection", this._transformMatrix),
  34986. this._sceneUbo.updateMatrix("view", this._viewMatrix),
  34987. this._sceneUbo.updateMatrix("projection", this._projectionMatrix)))
  34988. }
  34989. ,
  34990. e.prototype.getSceneUniformBuffer = function() {
  34991. return this._multiviewSceneUbo ? this._multiviewSceneUbo : this._sceneUbo
  34992. }
  34993. ,
  34994. e.prototype.createSceneUniformBuffer = function(i) {
  34995. var o = new UniformBuffer(this._engine,void 0,!1,i != null ? i : "scene");
  34996. return o.addUniform("viewProjection", 16),
  34997. o.addUniform("view", 16),
  34998. o.addUniform("projection", 16),
  34999. o.addUniform("vEyePosition", 4),
  35000. o
  35001. }
  35002. ,
  35003. e.prototype.setSceneUniformBuffer = function(i) {
  35004. this._sceneUbo = i,
  35005. this._viewUpdateFlag = -1,
  35006. this._projectionUpdateFlag = -1
  35007. }
  35008. ,
  35009. e.prototype.getUniqueId = function() {
  35010. return UniqueIdGenerator.UniqueId
  35011. }
  35012. ,
  35013. e.prototype.addMesh = function(i, o) {
  35014. var s = this;
  35015. o === void 0 && (o = !1),
  35016. !this._blockEntityCollection && (this.meshes.push(i),
  35017. i._resyncLightSources(),
  35018. i.parent || i._addToSceneRootNodes(),
  35019. this.onNewMeshAddedObservable.notifyObservers(i),
  35020. o && i.getChildMeshes().forEach(function(c) {
  35021. s.addMesh(c)
  35022. }))
  35023. }
  35024. ,
  35025. e.prototype.removeMesh = function(i, o) {
  35026. var s = this;
  35027. o === void 0 && (o = !1);
  35028. var c = this.meshes.indexOf(i);
  35029. return c !== -1 && (this.meshes[c] = this.meshes[this.meshes.length - 1],
  35030. this.meshes.pop(),
  35031. i.parent || i._removeFromSceneRootNodes()),
  35032. this._inputManager._invalidateMesh(i),
  35033. this.onMeshRemovedObservable.notifyObservers(i),
  35034. o && i.getChildMeshes().forEach(function(d) {
  35035. s.removeMesh(d)
  35036. }),
  35037. c
  35038. }
  35039. ,
  35040. e.prototype.addTransformNode = function(i) {
  35041. this._blockEntityCollection || (i._indexInSceneTransformNodesArray = this.transformNodes.length,
  35042. this.transformNodes.push(i),
  35043. i.parent || i._addToSceneRootNodes(),
  35044. this.onNewTransformNodeAddedObservable.notifyObservers(i))
  35045. }
  35046. ,
  35047. e.prototype.removeTransformNode = function(i) {
  35048. var o = i._indexInSceneTransformNodesArray;
  35049. if (o !== -1) {
  35050. if (o !== this.transformNodes.length - 1) {
  35051. var s = this.transformNodes[this.transformNodes.length - 1];
  35052. this.transformNodes[o] = s,
  35053. s._indexInSceneTransformNodesArray = o
  35054. }
  35055. i._indexInSceneTransformNodesArray = -1,
  35056. this.transformNodes.pop(),
  35057. i.parent || i._removeFromSceneRootNodes()
  35058. }
  35059. return this.onTransformNodeRemovedObservable.notifyObservers(i),
  35060. o
  35061. }
  35062. ,
  35063. e.prototype.removeSkeleton = function(i) {
  35064. var o = this.skeletons.indexOf(i);
  35065. return o !== -1 && (this.skeletons.splice(o, 1),
  35066. this.onSkeletonRemovedObservable.notifyObservers(i)),
  35067. o
  35068. }
  35069. ,
  35070. e.prototype.removeMorphTargetManager = function(i) {
  35071. var o = this.morphTargetManagers.indexOf(i);
  35072. return o !== -1 && this.morphTargetManagers.splice(o, 1),
  35073. o
  35074. }
  35075. ,
  35076. e.prototype.removeLight = function(i) {
  35077. var o = this.lights.indexOf(i);
  35078. if (o !== -1) {
  35079. for (var s = 0, c = this.meshes; s < c.length; s++) {
  35080. var d = c[s];
  35081. d._removeLightSource(i, !1)
  35082. }
  35083. this.lights.splice(o, 1),
  35084. this.sortLightsByPriority(),
  35085. i.parent || i._removeFromSceneRootNodes()
  35086. }
  35087. return this.onLightRemovedObservable.notifyObservers(i),
  35088. o
  35089. }
  35090. ,
  35091. e.prototype.removeCamera = function(i) {
  35092. var o = this.cameras.indexOf(i);
  35093. if (o !== -1 && (this.cameras.splice(o, 1),
  35094. i.parent || i._removeFromSceneRootNodes()),
  35095. this.activeCameras) {
  35096. var s = this.activeCameras.indexOf(i);
  35097. s !== -1 && this.activeCameras.splice(s, 1)
  35098. }
  35099. return this.activeCamera === i && (this.cameras.length > 0 ? this.activeCamera = this.cameras[0] : this.activeCamera = null),
  35100. this.onCameraRemovedObservable.notifyObservers(i),
  35101. o
  35102. }
  35103. ,
  35104. e.prototype.removeParticleSystem = function(i) {
  35105. var o = this.particleSystems.indexOf(i);
  35106. return o !== -1 && this.particleSystems.splice(o, 1),
  35107. o
  35108. }
  35109. ,
  35110. e.prototype.removeAnimation = function(i) {
  35111. var o = this.animations.indexOf(i);
  35112. return o !== -1 && this.animations.splice(o, 1),
  35113. o
  35114. }
  35115. ,
  35116. e.prototype.stopAnimation = function(i, o, s) {}
  35117. ,
  35118. e.prototype.removeAnimationGroup = function(i) {
  35119. var o = this.animationGroups.indexOf(i);
  35120. return o !== -1 && this.animationGroups.splice(o, 1),
  35121. o
  35122. }
  35123. ,
  35124. e.prototype.removeMultiMaterial = function(i) {
  35125. var o = this.multiMaterials.indexOf(i);
  35126. return o !== -1 && this.multiMaterials.splice(o, 1),
  35127. this.onMultiMaterialRemovedObservable.notifyObservers(i),
  35128. o
  35129. }
  35130. ,
  35131. e.prototype.removeMaterial = function(i) {
  35132. var o = i._indexInSceneMaterialArray;
  35133. if (o !== -1 && o < this.materials.length) {
  35134. if (o !== this.materials.length - 1) {
  35135. var s = this.materials[this.materials.length - 1];
  35136. this.materials[o] = s,
  35137. s._indexInSceneMaterialArray = o
  35138. }
  35139. i._indexInSceneMaterialArray = -1,
  35140. this.materials.pop()
  35141. }
  35142. return this.onMaterialRemovedObservable.notifyObservers(i),
  35143. o
  35144. }
  35145. ,
  35146. e.prototype.removeActionManager = function(i) {
  35147. var o = this.actionManagers.indexOf(i);
  35148. return o !== -1 && this.actionManagers.splice(o, 1),
  35149. o
  35150. }
  35151. ,
  35152. e.prototype.removeTexture = function(i) {
  35153. var o = this.textures.indexOf(i);
  35154. return o !== -1 && this.textures.splice(o, 1),
  35155. this.onTextureRemovedObservable.notifyObservers(i),
  35156. o
  35157. }
  35158. ,
  35159. e.prototype.addLight = function(i) {
  35160. if (!this._blockEntityCollection) {
  35161. this.lights.push(i),
  35162. this.sortLightsByPriority(),
  35163. i.parent || i._addToSceneRootNodes();
  35164. for (var o = 0, s = this.meshes; o < s.length; o++) {
  35165. var c = s[o];
  35166. c.lightSources.indexOf(i) === -1 && (c.lightSources.push(i),
  35167. c._resyncLightSources())
  35168. }
  35169. this.onNewLightAddedObservable.notifyObservers(i)
  35170. }
  35171. }
  35172. ,
  35173. e.prototype.sortLightsByPriority = function() {
  35174. this.requireLightSorting && this.lights.sort(LightConstants.CompareLightsPriority)
  35175. }
  35176. ,
  35177. e.prototype.addCamera = function(i) {
  35178. this._blockEntityCollection || (this.cameras.push(i),
  35179. this.onNewCameraAddedObservable.notifyObservers(i),
  35180. i.parent || i._addToSceneRootNodes())
  35181. }
  35182. ,
  35183. e.prototype.addSkeleton = function(i) {
  35184. this._blockEntityCollection || (this.skeletons.push(i),
  35185. this.onNewSkeletonAddedObservable.notifyObservers(i))
  35186. }
  35187. ,
  35188. e.prototype.addParticleSystem = function(i) {
  35189. this._blockEntityCollection || this.particleSystems.push(i)
  35190. }
  35191. ,
  35192. e.prototype.addAnimation = function(i) {
  35193. this._blockEntityCollection || this.animations.push(i)
  35194. }
  35195. ,
  35196. e.prototype.addAnimationGroup = function(i) {
  35197. this._blockEntityCollection || this.animationGroups.push(i)
  35198. }
  35199. ,
  35200. e.prototype.addMultiMaterial = function(i) {
  35201. this._blockEntityCollection || (this.multiMaterials.push(i),
  35202. this.onNewMultiMaterialAddedObservable.notifyObservers(i))
  35203. }
  35204. ,
  35205. e.prototype.addMaterial = function(i) {
  35206. this._blockEntityCollection || (i._indexInSceneMaterialArray = this.materials.length,
  35207. this.materials.push(i),
  35208. this.onNewMaterialAddedObservable.notifyObservers(i))
  35209. }
  35210. ,
  35211. e.prototype.addMorphTargetManager = function(i) {
  35212. this._blockEntityCollection || this.morphTargetManagers.push(i)
  35213. }
  35214. ,
  35215. e.prototype.addGeometry = function(i) {
  35216. this._blockEntityCollection || (this.geometriesByUniqueId && (this.geometriesByUniqueId[i.uniqueId] = this.geometries.length),
  35217. this.geometries.push(i))
  35218. }
  35219. ,
  35220. e.prototype.addActionManager = function(i) {
  35221. this.actionManagers.push(i)
  35222. }
  35223. ,
  35224. e.prototype.addTexture = function(i) {
  35225. this._blockEntityCollection || (this.textures.push(i),
  35226. this.onNewTextureAddedObservable.notifyObservers(i))
  35227. }
  35228. ,
  35229. e.prototype.switchActiveCamera = function(i, o) {
  35230. o === void 0 && (o = !0);
  35231. var s = this._engine.getInputElement();
  35232. !s || (this.activeCamera && this.activeCamera.detachControl(),
  35233. this.activeCamera = i,
  35234. o && i.attachControl())
  35235. }
  35236. ,
  35237. e.prototype.setActiveCameraById = function(i) {
  35238. var o = this.getCameraById(i);
  35239. return o ? (this.activeCamera = o,
  35240. o) : null
  35241. }
  35242. ,
  35243. e.prototype.setActiveCameraByName = function(i) {
  35244. var o = this.getCameraByName(i);
  35245. return o ? (this.activeCamera = o,
  35246. o) : null
  35247. }
  35248. ,
  35249. e.prototype.getAnimationGroupByName = function(i) {
  35250. for (var o = 0; o < this.animationGroups.length; o++)
  35251. if (this.animationGroups[o].name === i)
  35252. return this.animationGroups[o];
  35253. return null
  35254. }
  35255. ,
  35256. e.prototype.getMaterialByUniqueID = function(i) {
  35257. for (var o = 0; o < this.materials.length; o++)
  35258. if (this.materials[o].uniqueId === i)
  35259. return this.materials[o];
  35260. return null
  35261. }
  35262. ,
  35263. e.prototype.getMaterialById = function(i) {
  35264. for (var o = 0; o < this.materials.length; o++)
  35265. if (this.materials[o].id === i)
  35266. return this.materials[o];
  35267. return null
  35268. }
  35269. ,
  35270. e.prototype.getLastMaterialById = function(i) {
  35271. for (var o = this.materials.length - 1; o >= 0; o--)
  35272. if (this.materials[o].id === i)
  35273. return this.materials[o];
  35274. return null
  35275. }
  35276. ,
  35277. e.prototype.getMaterialByName = function(i) {
  35278. for (var o = 0; o < this.materials.length; o++)
  35279. if (this.materials[o].name === i)
  35280. return this.materials[o];
  35281. return null
  35282. }
  35283. ,
  35284. e.prototype.getTextureByUniqueId = function(i) {
  35285. for (var o = 0; o < this.textures.length; o++)
  35286. if (this.textures[o].uniqueId === i)
  35287. return this.textures[o];
  35288. return null
  35289. }
  35290. ,
  35291. e.prototype.getTextureByName = function(i) {
  35292. for (var o = 0; o < this.textures.length; o++)
  35293. if (this.textures[o].name === i)
  35294. return this.textures[o];
  35295. return null
  35296. }
  35297. ,
  35298. e.prototype.getCameraById = function(i) {
  35299. for (var o = 0; o < this.cameras.length; o++)
  35300. if (this.cameras[o].id === i)
  35301. return this.cameras[o];
  35302. return null
  35303. }
  35304. ,
  35305. e.prototype.getCameraByUniqueId = function(i) {
  35306. for (var o = 0; o < this.cameras.length; o++)
  35307. if (this.cameras[o].uniqueId === i)
  35308. return this.cameras[o];
  35309. return null
  35310. }
  35311. ,
  35312. e.prototype.getCameraByName = function(i) {
  35313. for (var o = 0; o < this.cameras.length; o++)
  35314. if (this.cameras[o].name === i)
  35315. return this.cameras[o];
  35316. return null
  35317. }
  35318. ,
  35319. e.prototype.getBoneById = function(i) {
  35320. for (var o = 0; o < this.skeletons.length; o++)
  35321. for (var s = this.skeletons[o], c = 0; c < s.bones.length; c++)
  35322. if (s.bones[c].id === i)
  35323. return s.bones[c];
  35324. return null
  35325. }
  35326. ,
  35327. e.prototype.getBoneByName = function(i) {
  35328. for (var o = 0; o < this.skeletons.length; o++)
  35329. for (var s = this.skeletons[o], c = 0; c < s.bones.length; c++)
  35330. if (s.bones[c].name === i)
  35331. return s.bones[c];
  35332. return null
  35333. }
  35334. ,
  35335. e.prototype.getLightByName = function(i) {
  35336. for (var o = 0; o < this.lights.length; o++)
  35337. if (this.lights[o].name === i)
  35338. return this.lights[o];
  35339. return null
  35340. }
  35341. ,
  35342. e.prototype.getLightById = function(i) {
  35343. for (var o = 0; o < this.lights.length; o++)
  35344. if (this.lights[o].id === i)
  35345. return this.lights[o];
  35346. return null
  35347. }
  35348. ,
  35349. e.prototype.getLightByUniqueId = function(i) {
  35350. for (var o = 0; o < this.lights.length; o++)
  35351. if (this.lights[o].uniqueId === i)
  35352. return this.lights[o];
  35353. return null
  35354. }
  35355. ,
  35356. e.prototype.getParticleSystemById = function(i) {
  35357. for (var o = 0; o < this.particleSystems.length; o++)
  35358. if (this.particleSystems[o].id === i)
  35359. return this.particleSystems[o];
  35360. return null
  35361. }
  35362. ,
  35363. e.prototype.getGeometryById = function(i) {
  35364. for (var o = 0; o < this.geometries.length; o++)
  35365. if (this.geometries[o].id === i)
  35366. return this.geometries[o];
  35367. return null
  35368. }
  35369. ,
  35370. e.prototype._getGeometryByUniqueId = function(i) {
  35371. if (this.geometriesByUniqueId) {
  35372. var o = this.geometriesByUniqueId[i];
  35373. if (o !== void 0)
  35374. return this.geometries[o]
  35375. } else
  35376. for (var s = 0; s < this.geometries.length; s++)
  35377. if (this.geometries[s].uniqueId === i)
  35378. return this.geometries[s];
  35379. return null
  35380. }
  35381. ,
  35382. e.prototype.pushGeometry = function(i, o) {
  35383. return !o && this._getGeometryByUniqueId(i.uniqueId) ? !1 : (this.addGeometry(i),
  35384. this.onNewGeometryAddedObservable.notifyObservers(i),
  35385. !0)
  35386. }
  35387. ,
  35388. e.prototype.removeGeometry = function(i) {
  35389. var o;
  35390. if (this.geometriesByUniqueId) {
  35391. if (o = this.geometriesByUniqueId[i.uniqueId],
  35392. o === void 0)
  35393. return !1
  35394. } else if (o = this.geometries.indexOf(i),
  35395. o < 0)
  35396. return !1;
  35397. if (o !== this.geometries.length - 1) {
  35398. var s = this.geometries[this.geometries.length - 1];
  35399. s && (this.geometries[o] = s,
  35400. this.geometriesByUniqueId && (this.geometriesByUniqueId[s.uniqueId] = o,
  35401. this.geometriesByUniqueId[i.uniqueId] = void 0))
  35402. }
  35403. return this.geometries.pop(),
  35404. this.onGeometryRemovedObservable.notifyObservers(i),
  35405. !0
  35406. }
  35407. ,
  35408. e.prototype.getGeometries = function() {
  35409. return this.geometries
  35410. }
  35411. ,
  35412. e.prototype.getMeshById = function(i) {
  35413. for (var o = 0; o < this.meshes.length; o++)
  35414. if (this.meshes[o].id === i)
  35415. return this.meshes[o];
  35416. return null
  35417. }
  35418. ,
  35419. e.prototype.getMeshesById = function(i) {
  35420. return this.meshes.filter(function(o) {
  35421. return o.id === i
  35422. })
  35423. }
  35424. ,
  35425. e.prototype.getTransformNodeById = function(i) {
  35426. for (var o = 0; o < this.transformNodes.length; o++)
  35427. if (this.transformNodes[o].id === i)
  35428. return this.transformNodes[o];
  35429. return null
  35430. }
  35431. ,
  35432. e.prototype.getTransformNodeByUniqueId = function(i) {
  35433. for (var o = 0; o < this.transformNodes.length; o++)
  35434. if (this.transformNodes[o].uniqueId === i)
  35435. return this.transformNodes[o];
  35436. return null
  35437. }
  35438. ,
  35439. e.prototype.getTransformNodesById = function(i) {
  35440. return this.transformNodes.filter(function(o) {
  35441. return o.id === i
  35442. })
  35443. }
  35444. ,
  35445. e.prototype.getMeshByUniqueId = function(i) {
  35446. for (var o = 0; o < this.meshes.length; o++)
  35447. if (this.meshes[o].uniqueId === i)
  35448. return this.meshes[o];
  35449. return null
  35450. }
  35451. ,
  35452. e.prototype.getLastMeshById = function(i) {
  35453. for (var o = this.meshes.length - 1; o >= 0; o--)
  35454. if (this.meshes[o].id === i)
  35455. return this.meshes[o];
  35456. return null
  35457. }
  35458. ,
  35459. e.prototype.getLastEntryById = function(i) {
  35460. var o;
  35461. for (o = this.meshes.length - 1; o >= 0; o--)
  35462. if (this.meshes[o].id === i)
  35463. return this.meshes[o];
  35464. for (o = this.transformNodes.length - 1; o >= 0; o--)
  35465. if (this.transformNodes[o].id === i)
  35466. return this.transformNodes[o];
  35467. for (o = this.cameras.length - 1; o >= 0; o--)
  35468. if (this.cameras[o].id === i)
  35469. return this.cameras[o];
  35470. for (o = this.lights.length - 1; o >= 0; o--)
  35471. if (this.lights[o].id === i)
  35472. return this.lights[o];
  35473. return null
  35474. }
  35475. ,
  35476. e.prototype.getNodeById = function(i) {
  35477. var o = this.getMeshById(i);
  35478. if (o)
  35479. return o;
  35480. var s = this.getTransformNodeById(i);
  35481. if (s)
  35482. return s;
  35483. var c = this.getLightById(i);
  35484. if (c)
  35485. return c;
  35486. var d = this.getCameraById(i);
  35487. if (d)
  35488. return d;
  35489. var _ = this.getBoneById(i);
  35490. return _ || null
  35491. }
  35492. ,
  35493. e.prototype.getNodeByName = function(i) {
  35494. var o = this.getMeshByName(i);
  35495. if (o)
  35496. return o;
  35497. var s = this.getTransformNodeByName(i);
  35498. if (s)
  35499. return s;
  35500. var c = this.getLightByName(i);
  35501. if (c)
  35502. return c;
  35503. var d = this.getCameraByName(i);
  35504. if (d)
  35505. return d;
  35506. var _ = this.getBoneByName(i);
  35507. return _ || null
  35508. }
  35509. ,
  35510. e.prototype.getMeshByName = function(i) {
  35511. for (var o = 0; o < this.meshes.length; o++)
  35512. if (this.meshes[o].name === i)
  35513. return this.meshes[o];
  35514. return null
  35515. }
  35516. ,
  35517. e.prototype.getTransformNodeByName = function(i) {
  35518. for (var o = 0; o < this.transformNodes.length; o++)
  35519. if (this.transformNodes[o].name === i)
  35520. return this.transformNodes[o];
  35521. return null
  35522. }
  35523. ,
  35524. e.prototype.getLastSkeletonById = function(i) {
  35525. for (var o = this.skeletons.length - 1; o >= 0; o--)
  35526. if (this.skeletons[o].id === i)
  35527. return this.skeletons[o];
  35528. return null
  35529. }
  35530. ,
  35531. e.prototype.getSkeletonByUniqueId = function(i) {
  35532. for (var o = 0; o < this.skeletons.length; o++)
  35533. if (this.skeletons[o].uniqueId === i)
  35534. return this.skeletons[o];
  35535. return null
  35536. }
  35537. ,
  35538. e.prototype.getSkeletonById = function(i) {
  35539. for (var o = 0; o < this.skeletons.length; o++)
  35540. if (this.skeletons[o].id === i)
  35541. return this.skeletons[o];
  35542. return null
  35543. }
  35544. ,
  35545. e.prototype.getSkeletonByName = function(i) {
  35546. for (var o = 0; o < this.skeletons.length; o++)
  35547. if (this.skeletons[o].name === i)
  35548. return this.skeletons[o];
  35549. return null
  35550. }
  35551. ,
  35552. e.prototype.getMorphTargetManagerById = function(i) {
  35553. for (var o = 0; o < this.morphTargetManagers.length; o++)
  35554. if (this.morphTargetManagers[o].uniqueId === i)
  35555. return this.morphTargetManagers[o];
  35556. return null
  35557. }
  35558. ,
  35559. e.prototype.getMorphTargetById = function(i) {
  35560. for (var o = 0; o < this.morphTargetManagers.length; ++o)
  35561. for (var s = this.morphTargetManagers[o], c = 0; c < s.numTargets; ++c) {
  35562. var d = s.getTarget(c);
  35563. if (d.id === i)
  35564. return d
  35565. }
  35566. return null
  35567. }
  35568. ,
  35569. e.prototype.getMorphTargetByName = function(i) {
  35570. for (var o = 0; o < this.morphTargetManagers.length; ++o)
  35571. for (var s = this.morphTargetManagers[o], c = 0; c < s.numTargets; ++c) {
  35572. var d = s.getTarget(c);
  35573. if (d.name === i)
  35574. return d
  35575. }
  35576. return null
  35577. }
  35578. ,
  35579. e.prototype.getPostProcessByName = function(i) {
  35580. for (var o = 0; o < this.postProcesses.length; ++o) {
  35581. var s = this.postProcesses[o];
  35582. if (s.name === i)
  35583. return s
  35584. }
  35585. return null
  35586. }
  35587. ,
  35588. e.prototype.isActiveMesh = function(i) {
  35589. return this._activeMeshes.indexOf(i) !== -1
  35590. }
  35591. ,
  35592. Object.defineProperty(e.prototype, "uid", {
  35593. get: function() {
  35594. return this._uid || (this._uid = Tools.RandomId()),
  35595. this._uid
  35596. },
  35597. enumerable: !1,
  35598. configurable: !0
  35599. }),
  35600. e.prototype.addExternalData = function(i, o) {
  35601. return this._externalData || (this._externalData = new StringDictionary),
  35602. this._externalData.add(i, o)
  35603. }
  35604. ,
  35605. e.prototype.getExternalData = function(i) {
  35606. return this._externalData ? this._externalData.get(i) : null
  35607. }
  35608. ,
  35609. e.prototype.getOrAddExternalDataWithFactory = function(i, o) {
  35610. return this._externalData || (this._externalData = new StringDictionary),
  35611. this._externalData.getOrAddWithFactory(i, o)
  35612. }
  35613. ,
  35614. e.prototype.removeExternalData = function(i) {
  35615. return this._externalData.remove(i)
  35616. }
  35617. ,
  35618. e.prototype._evaluateSubMesh = function(i, o, s) {
  35619. if (s.hasInstances || s.isAnInstance || this.dispatchAllSubMeshesOfActiveMeshes || this._skipFrustumClipping || o.alwaysSelectAsActiveMesh || o.subMeshes.length === 1 || i.isInFrustum(this._frustumPlanes)) {
  35620. for (var c = 0, d = this._evaluateSubMeshStage; c < d.length; c++) {
  35621. var _ = d[c];
  35622. _.action(o, i)
  35623. }
  35624. var b = i.getMaterial();
  35625. b != null && (b.hasRenderTargetTextures && b.getRenderTargetTextures != null && this._processedMaterials.indexOf(b) === -1 && (this._processedMaterials.push(b),
  35626. this._renderTargets.concatWithNoDuplicate(b.getRenderTargetTextures())),
  35627. this._renderingManager.dispatch(i, o, b))
  35628. }
  35629. }
  35630. ,
  35631. e.prototype.freeProcessedMaterials = function() {
  35632. this._processedMaterials.dispose()
  35633. }
  35634. ,
  35635. Object.defineProperty(e.prototype, "blockfreeActiveMeshesAndRenderingGroups", {
  35636. get: function() {
  35637. return this._preventFreeActiveMeshesAndRenderingGroups
  35638. },
  35639. set: function(i) {
  35640. this._preventFreeActiveMeshesAndRenderingGroups !== i && (i && (this.freeActiveMeshes(),
  35641. this.freeRenderingGroups()),
  35642. this._preventFreeActiveMeshesAndRenderingGroups = i)
  35643. },
  35644. enumerable: !1,
  35645. configurable: !0
  35646. }),
  35647. e.prototype.freeActiveMeshes = function() {
  35648. if (!this.blockfreeActiveMeshesAndRenderingGroups && (this._activeMeshes.dispose(),
  35649. this.activeCamera && this.activeCamera._activeMeshes && this.activeCamera._activeMeshes.dispose(),
  35650. this.activeCameras))
  35651. for (var i = 0; i < this.activeCameras.length; i++) {
  35652. var o = this.activeCameras[i];
  35653. o && o._activeMeshes && o._activeMeshes.dispose()
  35654. }
  35655. }
  35656. ,
  35657. e.prototype.freeRenderingGroups = function() {
  35658. if (!this.blockfreeActiveMeshesAndRenderingGroups && (this._renderingManager && this._renderingManager.freeRenderingGroups(),
  35659. this.textures))
  35660. for (var i = 0; i < this.textures.length; i++) {
  35661. var o = this.textures[i];
  35662. o && o.renderList && o.freeRenderingGroups()
  35663. }
  35664. }
  35665. ,
  35666. e.prototype._isInIntermediateRendering = function() {
  35667. return this._intermediateRendering
  35668. }
  35669. ,
  35670. e.prototype.freezeActiveMeshes = function(i, o, s, c) {
  35671. var d = this;
  35672. return i === void 0 && (i = !1),
  35673. c === void 0 && (c = !0),
  35674. this.executeWhenReady(function() {
  35675. if (!d.activeCamera) {
  35676. s && s("No active camera found");
  35677. return
  35678. }
  35679. if (d._frustumPlanes || d.setTransformMatrix(d.activeCamera.getViewMatrix(), d.activeCamera.getProjectionMatrix()),
  35680. d._evaluateActiveMeshes(),
  35681. d._activeMeshesFrozen = !0,
  35682. d._skipEvaluateActiveMeshesCompletely = i,
  35683. c)
  35684. for (var _ = 0; _ < d._activeMeshes.length; _++)
  35685. d._activeMeshes.data[_]._freeze();
  35686. o && o()
  35687. }),
  35688. this
  35689. }
  35690. ,
  35691. e.prototype.unfreezeActiveMeshes = function() {
  35692. for (var i = 0; i < this.meshes.length; i++) {
  35693. var o = this.meshes[i];
  35694. o._internalAbstractMeshDataInfo && (o._internalAbstractMeshDataInfo._isActive = !1)
  35695. }
  35696. for (var i = 0; i < this._activeMeshes.length; i++)
  35697. this._activeMeshes.data[i]._unFreeze();
  35698. return this._activeMeshesFrozen = !1,
  35699. this
  35700. }
  35701. ,
  35702. e.prototype._evaluateActiveMeshes = function() {
  35703. var i;
  35704. if (this._engine.snapshotRendering && this._engine.snapshotRenderingMode === 1) {
  35705. this._activeMeshes.length > 0 && ((i = this.activeCamera) === null || i === void 0 || i._activeMeshes.reset(),
  35706. this._activeMeshes.reset(),
  35707. this._renderingManager.reset(),
  35708. this._processedMaterials.reset(),
  35709. this._activeParticleSystems.reset(),
  35710. this._activeSkeletons.reset(),
  35711. this._softwareSkinnedMeshes.reset());
  35712. return
  35713. }
  35714. if (this._activeMeshesFrozen && this._activeMeshes.length) {
  35715. if (!this._skipEvaluateActiveMeshesCompletely)
  35716. for (var o = this._activeMeshes.length, s = 0; s < o; s++) {
  35717. var c = this._activeMeshes.data[s];
  35718. c.computeWorldMatrix()
  35719. }
  35720. if (this._activeParticleSystems)
  35721. for (var d = this._activeParticleSystems.length, s = 0; s < d; s++)
  35722. this._activeParticleSystems.data[s].animate();
  35723. return
  35724. }
  35725. if (!!this.activeCamera) {
  35726. this.onBeforeActiveMeshesEvaluationObservable.notifyObservers(this),
  35727. this.activeCamera._activeMeshes.reset(),
  35728. this._activeMeshes.reset(),
  35729. this._renderingManager.reset(),
  35730. this._processedMaterials.reset(),
  35731. this._activeParticleSystems.reset(),
  35732. this._activeSkeletons.reset(),
  35733. this._softwareSkinnedMeshes.reset();
  35734. for (var _ = 0, b = this._beforeEvaluateActiveMeshStage; _ < b.length; _++) {
  35735. var k = b[_];
  35736. k.action()
  35737. }
  35738. for (var j = this.getActiveMeshCandidates(), $ = j.length, s = 0; s < $; s++) {
  35739. var c = j.data[s];
  35740. if (c._internalAbstractMeshDataInfo._currentLODIsUpToDate = !1,
  35741. !c.isBlocked && (this._totalVertices.addCount(c.getTotalVertices(), !1),
  35742. !(!c.isReady() || !c.isEnabled() || c.scaling.lengthSquared() === 0))) {
  35743. c.computeWorldMatrix(),
  35744. c.actionManager && c.actionManager.hasSpecificTriggers2(12, 13) && this._meshesForIntersections.pushNoDuplicate(c);
  35745. var _e = this.customLODSelector ? this.customLODSelector(c, this.activeCamera) : c.getLOD(this.activeCamera);
  35746. if (c._internalAbstractMeshDataInfo._currentLOD = _e,
  35747. c._internalAbstractMeshDataInfo._currentLODIsUpToDate = !0,
  35748. _e != null && (_e !== c && _e.billboardMode !== 0 && _e.computeWorldMatrix(),
  35749. c._preActivate(),
  35750. c.isVisible && c.visibility > 0 && (c.layerMask & this.activeCamera.layerMask) !== 0 && (this._skipFrustumClipping || c.alwaysSelectAsActiveMesh || c.isInFrustum(this._frustumPlanes)))) {
  35751. this._activeMeshes.push(c),
  35752. this.activeCamera._activeMeshes.push(c),
  35753. _e !== c && _e._activate(this._renderId, !1);
  35754. for (var et = 0, tt = this._preActiveMeshStage; et < tt.length; et++) {
  35755. var k = tt[et];
  35756. k.action(c)
  35757. }
  35758. c._activate(this._renderId, !1) && (c.isAnInstance ? c._internalAbstractMeshDataInfo._actAsRegularMesh && (_e = c) : _e._internalAbstractMeshDataInfo._onlyForInstances = !1,
  35759. _e._internalAbstractMeshDataInfo._isActive = !0,
  35760. this._activeMesh(c, _e)),
  35761. c._postActivate()
  35762. }
  35763. }
  35764. }
  35765. if (this.onAfterActiveMeshesEvaluationObservable.notifyObservers(this),
  35766. this.particlesEnabled) {
  35767. this.onBeforeParticlesRenderingObservable.notifyObservers(this);
  35768. for (var rt = 0; rt < this.particleSystems.length; rt++) {
  35769. var it = this.particleSystems[rt];
  35770. if (!(!it.isStarted() || !it.emitter)) {
  35771. var nt = it.emitter;
  35772. (!nt.position || nt.isEnabled()) && (this._activeParticleSystems.push(it),
  35773. it.animate(),
  35774. this._renderingManager.dispatchParticles(it))
  35775. }
  35776. }
  35777. this.onAfterParticlesRenderingObservable.notifyObservers(this)
  35778. }
  35779. }
  35780. }
  35781. ,
  35782. e.prototype._activeMesh = function(i, o) {
  35783. if (this._skeletonsEnabled && o.skeleton !== null && o.skeleton !== void 0 && (this._activeSkeletons.pushNoDuplicate(o.skeleton) && o.skeleton.prepare(),
  35784. o.computeBonesUsingShaders || this._softwareSkinnedMeshes.pushNoDuplicate(o)),
  35785. o != null && o.subMeshes !== void 0 && o.subMeshes !== null && o.subMeshes.length > 0)
  35786. for (var s = this.getActiveSubMeshCandidates(o), c = s.length, d = 0; d < c; d++) {
  35787. var _ = s.data[d];
  35788. this._evaluateSubMesh(_, o, i)
  35789. }
  35790. }
  35791. ,
  35792. e.prototype.updateTransformMatrix = function(i) {
  35793. !this.activeCamera || this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(i))
  35794. }
  35795. ,
  35796. e.prototype._bindFrameBuffer = function(i, o) {
  35797. o === void 0 && (o = !0),
  35798. i && i._multiviewTexture ? i._multiviewTexture._bindFrameBuffer() : i && i.outputRenderTarget ? i.outputRenderTarget._bindFrameBuffer() : this._engine._currentFrameBufferIsDefaultFrameBuffer() || this._engine.restoreDefaultFramebuffer(),
  35799. o && this._clearFrameBuffer(i)
  35800. }
  35801. ,
  35802. e.prototype._clearFrameBuffer = function(i) {
  35803. if (!(i && i._multiviewTexture))
  35804. if (i && i.outputRenderTarget) {
  35805. var o = i.outputRenderTarget;
  35806. o.onClearObservable.hasObservers() ? o.onClearObservable.notifyObservers(this._engine) : o.skipInitialClear || (this._engine.clear(o.clearColor || this.clearColor, !o._cleared, !0, !0),
  35807. o._cleared = !0)
  35808. } else
  35809. this._defaultFrameBufferCleared ? this._engine.clear(null, !1, !0, !0) : (this._defaultFrameBufferCleared = !0,
  35810. this._clear())
  35811. }
  35812. ,
  35813. e.prototype._renderForCamera = function(i, o, s) {
  35814. var c, d, _;
  35815. if (s === void 0 && (s = !0),
  35816. !(i && i._skipRendering)) {
  35817. var b = this._engine;
  35818. if (this._activeCamera = i,
  35819. !this.activeCamera)
  35820. throw new Error("Active camera not set");
  35821. b.setViewport(this.activeCamera.viewport),
  35822. this.resetCachedMaterial(),
  35823. this._renderId++,
  35824. !this.prePass && s && this._bindFrameBuffer(this._activeCamera);
  35825. var k = this.getEngine().getCaps().multiview && i.outputRenderTarget && i.outputRenderTarget.getViewCount() > 1;
  35826. k ? this.setTransformMatrix(i._rigCameras[0].getViewMatrix(), i._rigCameras[0].getProjectionMatrix(), i._rigCameras[1].getViewMatrix(), i._rigCameras[1].getProjectionMatrix()) : this.updateTransformMatrix(),
  35827. this.onBeforeCameraRenderObservable.notifyObservers(this.activeCamera),
  35828. this._evaluateActiveMeshes();
  35829. for (var j = 0; j < this._softwareSkinnedMeshes.length; j++) {
  35830. var $ = this._softwareSkinnedMeshes.data[j];
  35831. $.applySkeleton($.skeleton)
  35832. }
  35833. this.onBeforeRenderTargetsRenderObservable.notifyObservers(this),
  35834. i.customRenderTargets && i.customRenderTargets.length > 0 && this._renderTargets.concatWithNoDuplicate(i.customRenderTargets),
  35835. o && o.customRenderTargets && o.customRenderTargets.length > 0 && this._renderTargets.concatWithNoDuplicate(o.customRenderTargets),
  35836. this.environmentTexture && this.environmentTexture.isRenderTarget && this._renderTargets.pushNoDuplicate(this.environmentTexture);
  35837. for (var _e = 0, et = this._gatherActiveCameraRenderTargetsStage; _e < et.length; _e++) {
  35838. var tt = et[_e];
  35839. tt.action(this._renderTargets)
  35840. }
  35841. var rt = !1;
  35842. if (this.renderTargetsEnabled) {
  35843. if (this._intermediateRendering = !0,
  35844. this._renderTargets.length > 0) {
  35845. Tools.StartPerformanceCounter("Render targets", this._renderTargets.length > 0);
  35846. for (var it = 0; it < this._renderTargets.length; it++) {
  35847. var nt = this._renderTargets.data[it];
  35848. if (nt._shouldRender()) {
  35849. this._renderId++;
  35850. var ot = nt.activeCamera && nt.activeCamera !== this.activeCamera;
  35851. nt.render(ot, this.dumpNextRenderTargets),
  35852. rt = !0
  35853. }
  35854. }
  35855. Tools.EndPerformanceCounter("Render targets", this._renderTargets.length > 0),
  35856. this._renderId++
  35857. }
  35858. for (var at = 0, st = this._cameraDrawRenderTargetStage; at < st.length; at++) {
  35859. var tt = st[at];
  35860. rt = tt.action(this.activeCamera) || rt
  35861. }
  35862. this._intermediateRendering = !1
  35863. }
  35864. this._engine.currentRenderPassId = (_ = (d = (c = i.outputRenderTarget) === null || c === void 0 ? void 0 : c.renderPassId) !== null && d !== void 0 ? d : i.renderPassId) !== null && _ !== void 0 ? _ : 0,
  35865. rt && !this.prePass && this._bindFrameBuffer(this._activeCamera, !1),
  35866. this.onAfterRenderTargetsRenderObservable.notifyObservers(this),
  35867. this.postProcessManager && !i._multiviewTexture && !this.prePass && this.postProcessManager._prepareFrame();
  35868. for (var ut = 0, ct = this._beforeCameraDrawStage; ut < ct.length; ut++) {
  35869. var tt = ct[ut];
  35870. tt.action(this.activeCamera)
  35871. }
  35872. this.onBeforeDrawPhaseObservable.notifyObservers(this),
  35873. b.snapshotRendering && b.snapshotRenderingMode === 1 && this.finalizeSceneUbo(),
  35874. this._renderingManager.render(null, null, !0, !0),
  35875. this.onAfterDrawPhaseObservable.notifyObservers(this);
  35876. for (var lt = 0, ft = this._afterCameraDrawStage; lt < ft.length; lt++) {
  35877. var tt = ft[lt];
  35878. tt.action(this.activeCamera)
  35879. }
  35880. if (this.postProcessManager && !i._multiviewTexture) {
  35881. var ht = i.outputRenderTarget ? i.outputRenderTarget.renderTarget : void 0;
  35882. this.postProcessManager._finalizeFrame(i.isIntermediate, ht)
  35883. }
  35884. this._renderTargets.reset(),
  35885. this.onAfterCameraRenderObservable.notifyObservers(this.activeCamera)
  35886. }
  35887. }
  35888. ,
  35889. e.prototype._processSubCameras = function(i, o) {
  35890. if (o === void 0 && (o = !0),
  35891. i.cameraRigMode === 0 || i.outputRenderTarget && i.outputRenderTarget.getViewCount() > 1 && this.getEngine().getCaps().multiview) {
  35892. this._renderForCamera(i, void 0, o),
  35893. this.onAfterRenderCameraObservable.notifyObservers(i);
  35894. return
  35895. }
  35896. if (i._useMultiviewToSingleView)
  35897. this._renderMultiviewToSingleView(i);
  35898. else {
  35899. this.onBeforeCameraRenderObservable.notifyObservers(i);
  35900. for (var s = 0; s < i._rigCameras.length; s++)
  35901. this._renderForCamera(i._rigCameras[s], i)
  35902. }
  35903. this._activeCamera = i,
  35904. this.setTransformMatrix(this._activeCamera.getViewMatrix(), this._activeCamera.getProjectionMatrix()),
  35905. this.onAfterRenderCameraObservable.notifyObservers(i)
  35906. }
  35907. ,
  35908. e.prototype._checkIntersections = function() {
  35909. for (var i = 0; i < this._meshesForIntersections.length; i++) {
  35910. var o = this._meshesForIntersections.data[i];
  35911. if (!!o.actionManager)
  35912. for (var s = 0; o.actionManager && s < o.actionManager.actions.length; s++) {
  35913. var c = o.actionManager.actions[s];
  35914. if (c.trigger === 12 || c.trigger === 13) {
  35915. var d = c.getTriggerParameter()
  35916. , _ = d.mesh ? d.mesh : d
  35917. , b = _.intersectsMesh(o, d.usePreciseIntersection)
  35918. , k = o._intersectionsInProgress.indexOf(_);
  35919. b && k === -1 ? c.trigger === 12 ? (c._executeCurrent(ActionEvent.CreateNew(o, void 0, _)),
  35920. o._intersectionsInProgress.push(_)) : c.trigger === 13 && o._intersectionsInProgress.push(_) : !b && k > -1 && (c.trigger === 13 && c._executeCurrent(ActionEvent.CreateNew(o, void 0, _)),
  35921. (!o.actionManager.hasSpecificTrigger(13, function(j) {
  35922. var $ = j.mesh ? j.mesh : j;
  35923. return _ === $
  35924. }) || c.trigger === 13) && o._intersectionsInProgress.splice(k, 1))
  35925. }
  35926. }
  35927. }
  35928. }
  35929. ,
  35930. e.prototype._advancePhysicsEngineStep = function(i) {}
  35931. ,
  35932. e.prototype._animate = function() {}
  35933. ,
  35934. e.prototype.animate = function() {
  35935. if (this._engine.isDeterministicLockStep()) {
  35936. var i = Math.max(e.MinDeltaTime, Math.min(this._engine.getDeltaTime(), e.MaxDeltaTime)) + this._timeAccumulator
  35937. , o = this._engine.getTimeStep()
  35938. , s = 1e3 / o / 1e3
  35939. , c = 0
  35940. , d = this._engine.getLockstepMaxSteps()
  35941. , _ = Math.floor(i / o);
  35942. for (_ = Math.min(_, d); i > 0 && c < _; )
  35943. this.onBeforeStepObservable.notifyObservers(this),
  35944. this._animationRatio = o * s,
  35945. this._animate(),
  35946. this.onAfterAnimationsObservable.notifyObservers(this),
  35947. this.physicsEnabled && this._advancePhysicsEngineStep(o),
  35948. this.onAfterStepObservable.notifyObservers(this),
  35949. this._currentStepId++,
  35950. c++,
  35951. i -= o;
  35952. this._timeAccumulator = i < 0 ? 0 : i
  35953. } else {
  35954. var i = this.useConstantAnimationDeltaTime ? 16 : Math.max(e.MinDeltaTime, Math.min(this._engine.getDeltaTime(), e.MaxDeltaTime));
  35955. this._animationRatio = i * (60 / 1e3),
  35956. this._animate(),
  35957. this.onAfterAnimationsObservable.notifyObservers(this),
  35958. this.physicsEnabled && this._advancePhysicsEngineStep(i)
  35959. }
  35960. }
  35961. ,
  35962. e.prototype._clear = function() {
  35963. (this.autoClearDepthAndStencil || this.autoClear) && this._engine.clear(this.clearColor, this.autoClear || this.forceWireframe || this.forcePointsCloud, this.autoClearDepthAndStencil, this.autoClearDepthAndStencil)
  35964. }
  35965. ,
  35966. e.prototype.checkCameraRenderTarget = function(i) {
  35967. var o;
  35968. if ((i == null ? void 0 : i.outputRenderTarget) && !(i != null && i.isRigCamera) && (i.outputRenderTarget._cleared = !1),
  35969. !((o = i == null ? void 0 : i.rigCameras) === null || o === void 0) && o.length)
  35970. for (var s = 0; s < i.rigCameras.length; ++s) {
  35971. var c = i.rigCameras[s].outputRenderTarget;
  35972. c && (c._cleared = !1)
  35973. }
  35974. }
  35975. ,
  35976. e.prototype.resetDrawCache = function() {
  35977. if (!!this.meshes)
  35978. for (var i = 0, o = this.meshes; i < o.length; i++) {
  35979. var s = o[i];
  35980. s.resetDrawCache()
  35981. }
  35982. }
  35983. ,
  35984. e.prototype.render = function(i, o) {
  35985. var s, c, d;
  35986. if (i === void 0 && (i = !0),
  35987. o === void 0 && (o = !1),
  35988. !this.isDisposed) {
  35989. this.onReadyObservable.hasObservers() && this._executeWhenReadyTimeoutId === -1 && this._checkIsReady(),
  35990. this._frameId++,
  35991. this._defaultFrameBufferCleared = !1,
  35992. this.checkCameraRenderTarget(this.activeCamera),
  35993. !((s = this.activeCameras) === null || s === void 0) && s.length && this.activeCameras.forEach(this.checkCameraRenderTarget),
  35994. this._registerTransientComponents(),
  35995. this._activeParticles.fetchNewFrame(),
  35996. this._totalVertices.fetchNewFrame(),
  35997. this._activeIndices.fetchNewFrame(),
  35998. this._activeBones.fetchNewFrame(),
  35999. this._meshesForIntersections.reset(),
  36000. this.resetCachedMaterial(),
  36001. this.onBeforeAnimationsObservable.notifyObservers(this),
  36002. this.actionManager && this.actionManager.processTrigger(11),
  36003. o || this.animate();
  36004. for (var _ = 0, b = this._beforeCameraUpdateStage; _ < b.length; _++) {
  36005. var k = b[_];
  36006. k.action()
  36007. }
  36008. if (i) {
  36009. if (this.activeCameras && this.activeCameras.length > 0)
  36010. for (var j = 0; j < this.activeCameras.length; j++) {
  36011. var $ = this.activeCameras[j];
  36012. if ($.update(),
  36013. $.cameraRigMode !== 0)
  36014. for (var _e = 0; _e < $._rigCameras.length; _e++)
  36015. $._rigCameras[_e].update()
  36016. }
  36017. else if (this.activeCamera && (this.activeCamera.update(),
  36018. this.activeCamera.cameraRigMode !== 0))
  36019. for (var _e = 0; _e < this.activeCamera._rigCameras.length; _e++)
  36020. this.activeCamera._rigCameras[_e].update()
  36021. }
  36022. this.onBeforeRunRegisterBeforeRenderObservable.notifyObservers(this),
  36023. this.onBeforeRenderObservable.notifyObservers(this),
  36024. this.onAfterRunRegisterBeforeRenderObservable.notifyObservers(this),
  36025. this.onBeforeRTT1Observable.notifyObservers(this);
  36026. var et = this.getEngine();
  36027. this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
  36028. var tt = !((c = this.activeCameras) === null || c === void 0) && c.length ? this.activeCameras[0] : this.activeCamera;
  36029. if (this.renderTargetsEnabled) {
  36030. Tools.StartPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0),
  36031. this._intermediateRendering = !0;
  36032. for (var rt = 0; rt < this.customRenderTargets.length; rt++) {
  36033. var it = this.customRenderTargets[rt];
  36034. if (it._shouldRender()) {
  36035. if (this._renderId++,
  36036. this.activeCamera = it.activeCamera || this.activeCamera,
  36037. !this.activeCamera)
  36038. throw new Error("Active camera not set");
  36039. et.setViewport(this.activeCamera.viewport),
  36040. this.updateTransformMatrix(),
  36041. it.render(tt !== this.activeCamera, this.dumpNextRenderTargets)
  36042. }
  36043. }
  36044. Tools.EndPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0),
  36045. this._intermediateRendering = !1,
  36046. this._renderId++
  36047. }
  36048. this._engine.currentRenderPassId = (d = tt == null ? void 0 : tt.renderPassId) !== null && d !== void 0 ? d : 0,
  36049. this.activeCamera = tt,
  36050. this._activeCamera && this._activeCamera.cameraRigMode !== 22 && !this.prePass && this._bindFrameBuffer(this._activeCamera, !1),
  36051. this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
  36052. for (var nt = 0, ot = this._beforeClearStage; nt < ot.length; nt++) {
  36053. var k = ot[nt];
  36054. k.action()
  36055. }
  36056. this._clearFrameBuffer(this.activeCamera);
  36057. for (var at = 0, st = this._gatherRenderTargetsStage; at < st.length; at++) {
  36058. var k = st[at];
  36059. k.action(this._renderTargets)
  36060. }
  36061. if (this.onAfterRTT1Observable.notifyObservers(this),
  36062. this.activeCameras && this.activeCameras.length > 0)
  36063. for (var j = 0; j < this.activeCameras.length; j++)
  36064. this._processSubCameras(this.activeCameras[j], j > 0);
  36065. else {
  36066. if (!this.activeCamera)
  36067. throw new Error("No camera defined");
  36068. this._processSubCameras(this.activeCamera, !1)
  36069. }
  36070. this.onBeforeRunRegisterAfterRenderObservable.notifyObservers(this),
  36071. this._checkIntersections();
  36072. for (var ut = 0, ct = this._afterRenderStage; ut < ct.length; ut++) {
  36073. var k = ct[ut];
  36074. k.action()
  36075. }
  36076. if (this.afterRender && this.afterRender(),
  36077. this.onAfterRenderObservable.notifyObservers(this),
  36078. this.onAfterRunRegisterAfterRenderObservable.notifyObservers(this),
  36079. this._toBeDisposed.length) {
  36080. for (var _e = 0; _e < this._toBeDisposed.length; _e++) {
  36081. var lt = this._toBeDisposed[_e];
  36082. lt && lt.dispose()
  36083. }
  36084. this._toBeDisposed = []
  36085. }
  36086. this.dumpNextRenderTargets && (this.dumpNextRenderTargets = !1),
  36087. this._activeBones.addCount(0, !0),
  36088. this._activeIndices.addCount(0, !0),
  36089. this._activeParticles.addCount(0, !0),
  36090. this._engine.restoreDefaultFramebuffer()
  36091. }
  36092. }
  36093. ,
  36094. e.prototype.freezeMaterials = function() {
  36095. for (var i = 0; i < this.materials.length; i++)
  36096. this.materials[i].freeze()
  36097. }
  36098. ,
  36099. e.prototype.unfreezeMaterials = function() {
  36100. for (var i = 0; i < this.materials.length; i++)
  36101. this.materials[i].unfreeze()
  36102. }
  36103. ,
  36104. e.prototype.dispose = function() {
  36105. var i;
  36106. if (!this.isDisposed) {
  36107. this.beforeRender = null,
  36108. this.afterRender = null,
  36109. this.metadata = null,
  36110. this.skeletons = [],
  36111. this.morphTargetManagers = [],
  36112. this._transientComponents = [],
  36113. this._isReadyForMeshStage.clear(),
  36114. this._beforeEvaluateActiveMeshStage.clear(),
  36115. this._evaluateSubMeshStage.clear(),
  36116. this._preActiveMeshStage.clear(),
  36117. this._cameraDrawRenderTargetStage.clear(),
  36118. this._beforeCameraDrawStage.clear(),
  36119. this._beforeRenderTargetDrawStage.clear(),
  36120. this._beforeRenderingGroupDrawStage.clear(),
  36121. this._beforeRenderingMeshStage.clear(),
  36122. this._afterRenderingMeshStage.clear(),
  36123. this._afterRenderingGroupDrawStage.clear(),
  36124. this._afterCameraDrawStage.clear(),
  36125. this._afterRenderTargetDrawStage.clear(),
  36126. this._afterRenderStage.clear(),
  36127. this._beforeCameraUpdateStage.clear(),
  36128. this._beforeClearStage.clear(),
  36129. this._gatherRenderTargetsStage.clear(),
  36130. this._gatherActiveCameraRenderTargetsStage.clear(),
  36131. this._pointerMoveStage.clear(),
  36132. this._pointerDownStage.clear(),
  36133. this._pointerUpStage.clear();
  36134. for (var o = 0, s = this._components; o < s.length; o++) {
  36135. var c = s[o];
  36136. c.dispose()
  36137. }
  36138. this.importedMeshesFiles = new Array,
  36139. this.stopAllAnimations && this.stopAllAnimations(),
  36140. this.resetCachedMaterial(),
  36141. this.activeCamera && (this.activeCamera._activeMeshes.dispose(),
  36142. this.activeCamera = null),
  36143. this._activeMeshes.dispose(),
  36144. this._renderingManager.dispose(),
  36145. this._processedMaterials.dispose(),
  36146. this._activeParticleSystems.dispose(),
  36147. this._activeSkeletons.dispose(),
  36148. this._softwareSkinnedMeshes.dispose(),
  36149. this._renderTargets.dispose(),
  36150. this._registeredForLateAnimationBindings.dispose(),
  36151. this._meshesForIntersections.dispose(),
  36152. this._toBeDisposed = [];
  36153. for (var d = 0, _ = this._activeRequests; d < _.length; d++) {
  36154. var b = _[d];
  36155. b.abort()
  36156. }
  36157. this.onBeforeRunRegisterBeforeRenderObservable.clear(),
  36158. this.onAfterRunRegisterBeforeRenderObservable.clear(),
  36159. this.onBeforeRTT1Observable.clear(),
  36160. this.onAfterRTT1Observable.clear(),
  36161. this.onBeforeRunRegisterAfterRenderObservable.clear(),
  36162. this.onAfterRunRegisterAfterRenderObservable.clear(),
  36163. this.onDisposeObservable.notifyObservers(this),
  36164. this.onDisposeObservable.clear(),
  36165. this.onBeforeRenderObservable.clear(),
  36166. this.onAfterRenderObservable.clear(),
  36167. this.onBeforeRenderTargetsRenderObservable.clear(),
  36168. this.onAfterRenderTargetsRenderObservable.clear(),
  36169. this.onAfterStepObservable.clear(),
  36170. this.onBeforeStepObservable.clear(),
  36171. this.onBeforeActiveMeshesEvaluationObservable.clear(),
  36172. this.onAfterActiveMeshesEvaluationObservable.clear(),
  36173. this.onBeforeParticlesRenderingObservable.clear(),
  36174. this.onAfterParticlesRenderingObservable.clear(),
  36175. this.onBeforeDrawPhaseObservable.clear(),
  36176. this.onAfterDrawPhaseObservable.clear(),
  36177. this.onBeforeAnimationsObservable.clear(),
  36178. this.onAfterAnimationsObservable.clear(),
  36179. this.onDataLoadedObservable.clear(),
  36180. this.onBeforeRenderingGroupObservable.clear(),
  36181. this.onAfterRenderingGroupObservable.clear(),
  36182. this.onMeshImportedObservable.clear(),
  36183. this.onBeforeCameraRenderObservable.clear(),
  36184. this.onAfterCameraRenderObservable.clear(),
  36185. this.onReadyObservable.clear(),
  36186. this.onNewCameraAddedObservable.clear(),
  36187. this.onCameraRemovedObservable.clear(),
  36188. this.onNewLightAddedObservable.clear(),
  36189. this.onLightRemovedObservable.clear(),
  36190. this.onNewGeometryAddedObservable.clear(),
  36191. this.onGeometryRemovedObservable.clear(),
  36192. this.onNewTransformNodeAddedObservable.clear(),
  36193. this.onTransformNodeRemovedObservable.clear(),
  36194. this.onNewMeshAddedObservable.clear(),
  36195. this.onMeshRemovedObservable.clear(),
  36196. this.onNewSkeletonAddedObservable.clear(),
  36197. this.onSkeletonRemovedObservable.clear(),
  36198. this.onNewMaterialAddedObservable.clear(),
  36199. this.onNewMultiMaterialAddedObservable.clear(),
  36200. this.onMaterialRemovedObservable.clear(),
  36201. this.onMultiMaterialRemovedObservable.clear(),
  36202. this.onNewTextureAddedObservable.clear(),
  36203. this.onTextureRemovedObservable.clear(),
  36204. this.onPrePointerObservable.clear(),
  36205. this.onPointerObservable.clear(),
  36206. this.onPreKeyboardObservable.clear(),
  36207. this.onKeyboardObservable.clear(),
  36208. this.onActiveCameraChanged.clear(),
  36209. this.onComputePressureChanged.clear(),
  36210. (i = this._computePressureObserver) === null || i === void 0 || i.unobserve(),
  36211. this._computePressureObserver = void 0,
  36212. this.detachControl();
  36213. var k = this._engine.getInputElement();
  36214. if (k) {
  36215. var j;
  36216. for (j = 0; j < this.cameras.length; j++)
  36217. this.cameras[j].detachControl()
  36218. }
  36219. for (; this.animationGroups.length; )
  36220. this.animationGroups[0].dispose();
  36221. for (; this.lights.length; )
  36222. this.lights[0].dispose();
  36223. for (; this.meshes.length; )
  36224. this.meshes[0].dispose(!0);
  36225. for (; this.transformNodes.length; )
  36226. this.transformNodes[0].dispose(!0);
  36227. for (; this.cameras.length; )
  36228. this.cameras[0].dispose();
  36229. for (this._defaultMaterial && this._defaultMaterial.dispose(); this.multiMaterials.length; )
  36230. this.multiMaterials[0].dispose();
  36231. for (; this.materials.length; )
  36232. this.materials[0].dispose();
  36233. for (; this.particleSystems.length; )
  36234. this.particleSystems[0].dispose();
  36235. for (; this.postProcesses.length; )
  36236. this.postProcesses[0].dispose();
  36237. for (; this.textures.length; )
  36238. this.textures[0].dispose();
  36239. for (; this.morphTargetManagers.length; )
  36240. this.morphTargetManagers[0].dispose();
  36241. this._sceneUbo.dispose(),
  36242. this._multiviewSceneUbo && this._multiviewSceneUbo.dispose(),
  36243. this.postProcessManager.dispose(),
  36244. j = this._engine.scenes.indexOf(this),
  36245. j > -1 && this._engine.scenes.splice(j, 1),
  36246. EngineStore._LastCreatedScene === this && (this._engine.scenes.length > 0 ? EngineStore._LastCreatedScene = this._engine.scenes[this._engine.scenes.length - 1] : EngineStore._LastCreatedScene = null),
  36247. j = this._engine._virtualScenes.indexOf(this),
  36248. j > -1 && this._engine._virtualScenes.splice(j, 1),
  36249. this._engine.wipeCaches(!0),
  36250. this._isDisposed = !0
  36251. }
  36252. }
  36253. ,
  36254. Object.defineProperty(e.prototype, "isDisposed", {
  36255. get: function() {
  36256. return this._isDisposed
  36257. },
  36258. enumerable: !1,
  36259. configurable: !0
  36260. }),
  36261. e.prototype.clearCachedVertexData = function() {
  36262. for (var i = 0; i < this.meshes.length; i++) {
  36263. var o = this.meshes[i]
  36264. , s = o.geometry;
  36265. s && s.clearCachedData()
  36266. }
  36267. }
  36268. ,
  36269. e.prototype.cleanCachedTextureBuffer = function() {
  36270. for (var i = 0, o = this.textures; i < o.length; i++) {
  36271. var s = o[i]
  36272. , c = s._buffer;
  36273. c && (s._buffer = null)
  36274. }
  36275. }
  36276. ,
  36277. e.prototype.getWorldExtends = function(i) {
  36278. var o = new Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)
  36279. , s = new Vector3(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);
  36280. return i = i || function() {
  36281. return !0
  36282. }
  36283. ,
  36284. this.meshes.filter(i).forEach(function(c) {
  36285. if (c.computeWorldMatrix(!0),
  36286. !(!c.subMeshes || c.subMeshes.length === 0 || c.infiniteDistance)) {
  36287. var d = c.getBoundingInfo()
  36288. , _ = d.boundingBox.minimumWorld
  36289. , b = d.boundingBox.maximumWorld;
  36290. Vector3.CheckExtends(_, o, s),
  36291. Vector3.CheckExtends(b, o, s)
  36292. }
  36293. }),
  36294. {
  36295. min: o,
  36296. max: s
  36297. }
  36298. }
  36299. ,
  36300. e.prototype.createPickingRay = function(i, o, s, c, d) {
  36301. throw _WarnImport("Ray")
  36302. }
  36303. ,
  36304. e.prototype.createPickingRayToRef = function(i, o, s, c, d, _) {
  36305. throw _WarnImport("Ray")
  36306. }
  36307. ,
  36308. e.prototype.createPickingRayInCameraSpace = function(i, o, s) {
  36309. throw _WarnImport("Ray")
  36310. }
  36311. ,
  36312. e.prototype.createPickingRayInCameraSpaceToRef = function(i, o, s, c) {
  36313. throw _WarnImport("Ray")
  36314. }
  36315. ,
  36316. e.prototype.pick = function(i, o, s, c, d, _) {
  36317. var b = new PickingInfo;
  36318. return b._pickingUnavailable = !0,
  36319. b
  36320. }
  36321. ,
  36322. e.prototype.pickWithBoundingInfo = function(i, o, s, c, d) {
  36323. var _ = new PickingInfo;
  36324. return _._pickingUnavailable = !0,
  36325. _
  36326. }
  36327. ,
  36328. e.prototype.pickWithRay = function(i, o, s, c) {
  36329. throw _WarnImport("Ray")
  36330. }
  36331. ,
  36332. e.prototype.multiPick = function(i, o, s, c, d) {
  36333. throw _WarnImport("Ray")
  36334. }
  36335. ,
  36336. e.prototype.multiPickWithRay = function(i, o, s) {
  36337. throw _WarnImport("Ray")
  36338. }
  36339. ,
  36340. e.prototype.setPointerOverMesh = function(i, o, s) {
  36341. this._inputManager.setPointerOverMesh(i, o, s)
  36342. }
  36343. ,
  36344. e.prototype.getPointerOverMesh = function() {
  36345. return this._inputManager.getPointerOverMesh()
  36346. }
  36347. ,
  36348. e.prototype._rebuildGeometries = function() {
  36349. for (var i = 0, o = this.geometries; i < o.length; i++) {
  36350. var s = o[i];
  36351. s._rebuild()
  36352. }
  36353. for (var c = 0, d = this.meshes; c < d.length; c++) {
  36354. var _ = d[c];
  36355. _._rebuild()
  36356. }
  36357. this.postProcessManager && this.postProcessManager._rebuild();
  36358. for (var b = 0, k = this._components; b < k.length; b++) {
  36359. var j = k[b];
  36360. j.rebuild()
  36361. }
  36362. for (var $ = 0, _e = this.particleSystems; $ < _e.length; $++) {
  36363. var et = _e[$];
  36364. et.rebuild()
  36365. }
  36366. if (this.spriteManagers)
  36367. for (var tt = 0, rt = this.spriteManagers; tt < rt.length; tt++) {
  36368. var it = rt[tt];
  36369. it.rebuild()
  36370. }
  36371. }
  36372. ,
  36373. e.prototype._rebuildTextures = function() {
  36374. for (var i = 0, o = this.textures; i < o.length; i++) {
  36375. var s = o[i];
  36376. s._rebuild()
  36377. }
  36378. this.markAllMaterialsAsDirty(1)
  36379. }
  36380. ,
  36381. e.prototype._getByTags = function(i, o, s) {
  36382. if (o === void 0)
  36383. return i;
  36384. var c = [];
  36385. s = s || function(b) {}
  36386. ;
  36387. for (var d in i) {
  36388. var _ = i[d];
  36389. Tags && Tags.MatchesQuery(_, o) && (c.push(_),
  36390. s(_))
  36391. }
  36392. return c
  36393. }
  36394. ,
  36395. e.prototype.getMeshesByTags = function(i, o) {
  36396. return this._getByTags(this.meshes, i, o)
  36397. }
  36398. ,
  36399. e.prototype.getCamerasByTags = function(i, o) {
  36400. return this._getByTags(this.cameras, i, o)
  36401. }
  36402. ,
  36403. e.prototype.getLightsByTags = function(i, o) {
  36404. return this._getByTags(this.lights, i, o)
  36405. }
  36406. ,
  36407. e.prototype.getMaterialByTags = function(i, o) {
  36408. return this._getByTags(this.materials, i, o).concat(this._getByTags(this.multiMaterials, i, o))
  36409. }
  36410. ,
  36411. e.prototype.getTransformNodesByTags = function(i, o) {
  36412. return this._getByTags(this.transformNodes, i, o)
  36413. }
  36414. ,
  36415. e.prototype.setRenderingOrder = function(i, o, s, c) {
  36416. o === void 0 && (o = null),
  36417. s === void 0 && (s = null),
  36418. c === void 0 && (c = null),
  36419. this._renderingManager.setRenderingOrder(i, o, s, c)
  36420. }
  36421. ,
  36422. e.prototype.setRenderingAutoClearDepthStencil = function(i, o, s, c) {
  36423. s === void 0 && (s = !0),
  36424. c === void 0 && (c = !0),
  36425. this._renderingManager.setRenderingAutoClearDepthStencil(i, o, s, c)
  36426. }
  36427. ,
  36428. e.prototype.getAutoClearDepthStencilSetup = function(i) {
  36429. return this._renderingManager.getAutoClearDepthStencilSetup(i)
  36430. }
  36431. ,
  36432. Object.defineProperty(e.prototype, "blockMaterialDirtyMechanism", {
  36433. get: function() {
  36434. return this._blockMaterialDirtyMechanism
  36435. },
  36436. set: function(i) {
  36437. this._blockMaterialDirtyMechanism !== i && (this._blockMaterialDirtyMechanism = i,
  36438. i || this.markAllMaterialsAsDirty(63))
  36439. },
  36440. enumerable: !1,
  36441. configurable: !0
  36442. }),
  36443. e.prototype.markAllMaterialsAsDirty = function(i, o) {
  36444. if (!this._blockMaterialDirtyMechanism)
  36445. for (var s = 0, c = this.materials; s < c.length; s++) {
  36446. var d = c[s];
  36447. o && !o(d) || d.markAsDirty(i)
  36448. }
  36449. }
  36450. ,
  36451. e.prototype._loadFile = function(i, o, s, c, d, _, b) {
  36452. var k = this
  36453. , j = LoadFile(i, o, s, c ? this.offlineProvider : void 0, d, _, b);
  36454. return this._activeRequests.push(j),
  36455. j.onCompleteObservable.add(function($) {
  36456. k._activeRequests.splice(k._activeRequests.indexOf($), 1)
  36457. }),
  36458. j
  36459. }
  36460. ,
  36461. e.prototype._loadFileAsync = function(i, o, s, c, d) {
  36462. var _ = this;
  36463. return new Promise(function(b, k) {
  36464. _._loadFile(i, function(j) {
  36465. b(j)
  36466. }, o, s, c, function(j, $) {
  36467. k($)
  36468. }, d)
  36469. }
  36470. )
  36471. }
  36472. ,
  36473. e.prototype._requestFile = function(i, o, s, c, d, _, b) {
  36474. var k = this
  36475. , j = RequestFile(i, o, s, c ? this.offlineProvider : void 0, d, _, b);
  36476. return this._activeRequests.push(j),
  36477. j.onCompleteObservable.add(function($) {
  36478. k._activeRequests.splice(k._activeRequests.indexOf($), 1)
  36479. }),
  36480. j
  36481. }
  36482. ,
  36483. e.prototype._requestFileAsync = function(i, o, s, c, d) {
  36484. var _ = this;
  36485. return new Promise(function(b, k) {
  36486. _._requestFile(i, function(j) {
  36487. b(j)
  36488. }, o, s, c, function(j) {
  36489. k(j)
  36490. }, d)
  36491. }
  36492. )
  36493. }
  36494. ,
  36495. e.prototype._readFile = function(i, o, s, c, d) {
  36496. var _ = this
  36497. , b = ReadFile(i, o, s, c, d);
  36498. return this._activeRequests.push(b),
  36499. b.onCompleteObservable.add(function(k) {
  36500. _._activeRequests.splice(_._activeRequests.indexOf(k), 1)
  36501. }),
  36502. b
  36503. }
  36504. ,
  36505. e.prototype._readFileAsync = function(i, o, s) {
  36506. var c = this;
  36507. return new Promise(function(d, _) {
  36508. c._readFile(i, function(b) {
  36509. d(b)
  36510. }, o, s, function(b) {
  36511. _(b)
  36512. })
  36513. }
  36514. )
  36515. }
  36516. ,
  36517. e.prototype.getPerfCollector = function() {
  36518. throw _WarnImport("performanceViewerSceneExtension")
  36519. }
  36520. ,
  36521. e.FOGMODE_NONE = 0,
  36522. e.FOGMODE_EXP = 1,
  36523. e.FOGMODE_EXP2 = 2,
  36524. e.FOGMODE_LINEAR = 3,
  36525. e.MinDeltaTime = 1,
  36526. e.MaxDeltaTime = 1e3,
  36527. e
  36528. }(AbstractScene);
  36529. _injectLTSScene(Scene);
  36530. var Size = function() {
  36531. function a(e, i) {
  36532. this.width = e,
  36533. this.height = i
  36534. }
  36535. return a.prototype.toString = function() {
  36536. return "{W: " + this.width + ", H: " + this.height + "}"
  36537. }
  36538. ,
  36539. a.prototype.getClassName = function() {
  36540. return "Size"
  36541. }
  36542. ,
  36543. a.prototype.getHashCode = function() {
  36544. var e = this.width | 0;
  36545. return e = e * 397 ^ (this.height | 0),
  36546. e
  36547. }
  36548. ,
  36549. a.prototype.copyFrom = function(e) {
  36550. this.width = e.width,
  36551. this.height = e.height
  36552. }
  36553. ,
  36554. a.prototype.copyFromFloats = function(e, i) {
  36555. return this.width = e,
  36556. this.height = i,
  36557. this
  36558. }
  36559. ,
  36560. a.prototype.set = function(e, i) {
  36561. return this.copyFromFloats(e, i)
  36562. }
  36563. ,
  36564. a.prototype.multiplyByFloats = function(e, i) {
  36565. return new a(this.width * e,this.height * i)
  36566. }
  36567. ,
  36568. a.prototype.clone = function() {
  36569. return new a(this.width,this.height)
  36570. }
  36571. ,
  36572. a.prototype.equals = function(e) {
  36573. return e ? this.width === e.width && this.height === e.height : !1
  36574. }
  36575. ,
  36576. Object.defineProperty(a.prototype, "surface", {
  36577. get: function() {
  36578. return this.width * this.height
  36579. },
  36580. enumerable: !1,
  36581. configurable: !0
  36582. }),
  36583. a.Zero = function() {
  36584. return new a(0,0)
  36585. }
  36586. ,
  36587. a.prototype.add = function(e) {
  36588. var i = new a(this.width + e.width,this.height + e.height);
  36589. return i
  36590. }
  36591. ,
  36592. a.prototype.subtract = function(e) {
  36593. var i = new a(this.width - e.width,this.height - e.height);
  36594. return i
  36595. }
  36596. ,
  36597. a.Lerp = function(e, i, o) {
  36598. var s = e.width + (i.width - e.width) * o
  36599. , c = e.height + (i.height - e.height) * o;
  36600. return new a(s,c)
  36601. }
  36602. ,
  36603. a
  36604. }()
  36605. , ThinTexture = function() {
  36606. function a(e) {
  36607. this._wrapU = 1,
  36608. this._wrapV = 1,
  36609. this.wrapR = 1,
  36610. this.anisotropicFilteringLevel = 4,
  36611. this.delayLoadState = 0,
  36612. this._texture = null,
  36613. this._engine = null,
  36614. this._cachedSize = Size.Zero(),
  36615. this._cachedBaseSize = Size.Zero(),
  36616. this._initialSamplingMode = 2,
  36617. this._texture = e,
  36618. this._texture && (this._engine = this._texture.getEngine())
  36619. }
  36620. return Object.defineProperty(a.prototype, "wrapU", {
  36621. get: function() {
  36622. return this._wrapU
  36623. },
  36624. set: function(e) {
  36625. this._wrapU = e
  36626. },
  36627. enumerable: !1,
  36628. configurable: !0
  36629. }),
  36630. Object.defineProperty(a.prototype, "wrapV", {
  36631. get: function() {
  36632. return this._wrapV
  36633. },
  36634. set: function(e) {
  36635. this._wrapV = e
  36636. },
  36637. enumerable: !1,
  36638. configurable: !0
  36639. }),
  36640. Object.defineProperty(a.prototype, "coordinatesMode", {
  36641. get: function() {
  36642. return 0
  36643. },
  36644. enumerable: !1,
  36645. configurable: !0
  36646. }),
  36647. Object.defineProperty(a.prototype, "isCube", {
  36648. get: function() {
  36649. return this._texture ? this._texture.isCube : !1
  36650. },
  36651. set: function(e) {
  36652. !this._texture || (this._texture.isCube = e)
  36653. },
  36654. enumerable: !1,
  36655. configurable: !0
  36656. }),
  36657. Object.defineProperty(a.prototype, "is3D", {
  36658. get: function() {
  36659. return this._texture ? this._texture.is3D : !1
  36660. },
  36661. set: function(e) {
  36662. !this._texture || (this._texture.is3D = e)
  36663. },
  36664. enumerable: !1,
  36665. configurable: !0
  36666. }),
  36667. Object.defineProperty(a.prototype, "is2DArray", {
  36668. get: function() {
  36669. return this._texture ? this._texture.is2DArray : !1
  36670. },
  36671. set: function(e) {
  36672. !this._texture || (this._texture.is2DArray = e)
  36673. },
  36674. enumerable: !1,
  36675. configurable: !0
  36676. }),
  36677. a.prototype.getClassName = function() {
  36678. return "ThinTexture"
  36679. }
  36680. ,
  36681. a.prototype.isReady = function() {
  36682. return this.delayLoadState === 4 ? (this.delayLoad(),
  36683. !1) : this._texture ? this._texture.isReady : !1
  36684. }
  36685. ,
  36686. a.prototype.delayLoad = function() {}
  36687. ,
  36688. a.prototype.getInternalTexture = function() {
  36689. return this._texture
  36690. }
  36691. ,
  36692. a.prototype.getSize = function() {
  36693. if (this._texture) {
  36694. if (this._texture.width)
  36695. return this._cachedSize.width = this._texture.width,
  36696. this._cachedSize.height = this._texture.height,
  36697. this._cachedSize;
  36698. if (this._texture._size)
  36699. return this._cachedSize.width = this._texture._size,
  36700. this._cachedSize.height = this._texture._size,
  36701. this._cachedSize
  36702. }
  36703. return this._cachedSize
  36704. }
  36705. ,
  36706. a.prototype.getBaseSize = function() {
  36707. return !this.isReady() || !this._texture ? (this._cachedBaseSize.width = 0,
  36708. this._cachedBaseSize.height = 0,
  36709. this._cachedBaseSize) : this._texture._size ? (this._cachedBaseSize.width = this._texture._size,
  36710. this._cachedBaseSize.height = this._texture._size,
  36711. this._cachedBaseSize) : (this._cachedBaseSize.width = this._texture.baseWidth,
  36712. this._cachedBaseSize.height = this._texture.baseHeight,
  36713. this._cachedBaseSize)
  36714. }
  36715. ,
  36716. Object.defineProperty(a.prototype, "samplingMode", {
  36717. get: function() {
  36718. return this._texture ? this._texture.samplingMode : this._initialSamplingMode
  36719. },
  36720. enumerable: !1,
  36721. configurable: !0
  36722. }),
  36723. a.prototype.updateSamplingMode = function(e) {
  36724. this._texture && this._engine && this._engine.updateTextureSamplingMode(e, this._texture)
  36725. }
  36726. ,
  36727. a.prototype.releaseInternalTexture = function() {
  36728. this._texture && (this._texture.dispose(),
  36729. this._texture = null)
  36730. }
  36731. ,
  36732. a.prototype.dispose = function() {
  36733. this._texture && (this.releaseInternalTexture(),
  36734. this._engine = null)
  36735. }
  36736. ,
  36737. a
  36738. }()
  36739. , BaseTexture = function(a) {
  36740. __extends(e, a);
  36741. function e(i) {
  36742. var o = a.call(this, null) || this;
  36743. return o.metadata = null,
  36744. o.reservedDataStore = null,
  36745. o._hasAlpha = !1,
  36746. o.getAlphaFromRGB = !1,
  36747. o.level = 1,
  36748. o.coordinatesIndex = 0,
  36749. o._coordinatesMode = 0,
  36750. o.wrapR = 1,
  36751. o.anisotropicFilteringLevel = e.DEFAULT_ANISOTROPIC_FILTERING_LEVEL,
  36752. o._isCube = !1,
  36753. o._gammaSpace = !0,
  36754. o.invertZ = !1,
  36755. o.lodLevelInAlpha = !1,
  36756. o.isRenderTarget = !1,
  36757. o._prefiltered = !1,
  36758. o._forceSerialize = !1,
  36759. o.animations = new Array,
  36760. o.onDisposeObservable = new Observable,
  36761. o._onDisposeObserver = null,
  36762. o._scene = null,
  36763. o._uid = null,
  36764. o._parentContainer = null,
  36765. o._loadingError = !1,
  36766. i ? e._isScene(i) ? o._scene = i : o._engine = i : o._scene = EngineStore.LastCreatedScene,
  36767. o._scene && (o.uniqueId = o._scene.getUniqueId(),
  36768. o._scene.addTexture(o),
  36769. o._engine = o._scene.getEngine()),
  36770. o._uid = null,
  36771. o
  36772. }
  36773. return Object.defineProperty(e.prototype, "hasAlpha", {
  36774. get: function() {
  36775. return this._hasAlpha
  36776. },
  36777. set: function(i) {
  36778. this._hasAlpha !== i && (this._hasAlpha = i,
  36779. this._scene && this._scene.markAllMaterialsAsDirty(17))
  36780. },
  36781. enumerable: !1,
  36782. configurable: !0
  36783. }),
  36784. Object.defineProperty(e.prototype, "coordinatesMode", {
  36785. get: function() {
  36786. return this._coordinatesMode
  36787. },
  36788. set: function(i) {
  36789. this._coordinatesMode !== i && (this._coordinatesMode = i,
  36790. this._scene && this._scene.markAllMaterialsAsDirty(1))
  36791. },
  36792. enumerable: !1,
  36793. configurable: !0
  36794. }),
  36795. Object.defineProperty(e.prototype, "wrapU", {
  36796. get: function() {
  36797. return this._wrapU
  36798. },
  36799. set: function(i) {
  36800. this._wrapU = i
  36801. },
  36802. enumerable: !1,
  36803. configurable: !0
  36804. }),
  36805. Object.defineProperty(e.prototype, "wrapV", {
  36806. get: function() {
  36807. return this._wrapV
  36808. },
  36809. set: function(i) {
  36810. this._wrapV = i
  36811. },
  36812. enumerable: !1,
  36813. configurable: !0
  36814. }),
  36815. Object.defineProperty(e.prototype, "isCube", {
  36816. get: function() {
  36817. return this._texture ? this._texture.isCube : this._isCube
  36818. },
  36819. set: function(i) {
  36820. this._texture ? this._texture.isCube = i : this._isCube = i
  36821. },
  36822. enumerable: !1,
  36823. configurable: !0
  36824. }),
  36825. Object.defineProperty(e.prototype, "is3D", {
  36826. get: function() {
  36827. return this._texture ? this._texture.is3D : !1
  36828. },
  36829. set: function(i) {
  36830. !this._texture || (this._texture.is3D = i)
  36831. },
  36832. enumerable: !1,
  36833. configurable: !0
  36834. }),
  36835. Object.defineProperty(e.prototype, "is2DArray", {
  36836. get: function() {
  36837. return this._texture ? this._texture.is2DArray : !1
  36838. },
  36839. set: function(i) {
  36840. !this._texture || (this._texture.is2DArray = i)
  36841. },
  36842. enumerable: !1,
  36843. configurable: !0
  36844. }),
  36845. Object.defineProperty(e.prototype, "gammaSpace", {
  36846. get: function() {
  36847. if (this._texture)
  36848. this._texture._gammaSpace === null && (this._texture._gammaSpace = this._gammaSpace);
  36849. else
  36850. return this._gammaSpace;
  36851. return this._texture._gammaSpace && !this._texture._useSRGBBuffer
  36852. },
  36853. set: function(i) {
  36854. if (this._texture) {
  36855. if (this._texture._gammaSpace === i)
  36856. return;
  36857. this._texture._gammaSpace = i
  36858. } else {
  36859. if (this._gammaSpace === i)
  36860. return;
  36861. this._gammaSpace = i
  36862. }
  36863. this._markAllSubMeshesAsTexturesDirty()
  36864. },
  36865. enumerable: !1,
  36866. configurable: !0
  36867. }),
  36868. Object.defineProperty(e.prototype, "isRGBD", {
  36869. get: function() {
  36870. return this._texture != null && this._texture._isRGBD
  36871. },
  36872. set: function(i) {
  36873. this._texture && (this._texture._isRGBD = i)
  36874. },
  36875. enumerable: !1,
  36876. configurable: !0
  36877. }),
  36878. Object.defineProperty(e.prototype, "noMipmap", {
  36879. get: function() {
  36880. return !1
  36881. },
  36882. enumerable: !1,
  36883. configurable: !0
  36884. }),
  36885. Object.defineProperty(e.prototype, "lodGenerationOffset", {
  36886. get: function() {
  36887. return this._texture ? this._texture._lodGenerationOffset : 0
  36888. },
  36889. set: function(i) {
  36890. this._texture && (this._texture._lodGenerationOffset = i)
  36891. },
  36892. enumerable: !1,
  36893. configurable: !0
  36894. }),
  36895. Object.defineProperty(e.prototype, "lodGenerationScale", {
  36896. get: function() {
  36897. return this._texture ? this._texture._lodGenerationScale : 0
  36898. },
  36899. set: function(i) {
  36900. this._texture && (this._texture._lodGenerationScale = i)
  36901. },
  36902. enumerable: !1,
  36903. configurable: !0
  36904. }),
  36905. Object.defineProperty(e.prototype, "linearSpecularLOD", {
  36906. get: function() {
  36907. return this._texture ? this._texture._linearSpecularLOD : !1
  36908. },
  36909. set: function(i) {
  36910. this._texture && (this._texture._linearSpecularLOD = i)
  36911. },
  36912. enumerable: !1,
  36913. configurable: !0
  36914. }),
  36915. Object.defineProperty(e.prototype, "irradianceTexture", {
  36916. get: function() {
  36917. return this._texture ? this._texture._irradianceTexture : null
  36918. },
  36919. set: function(i) {
  36920. this._texture && (this._texture._irradianceTexture = i)
  36921. },
  36922. enumerable: !1,
  36923. configurable: !0
  36924. }),
  36925. Object.defineProperty(e.prototype, "uid", {
  36926. get: function() {
  36927. return this._uid || (this._uid = RandomGUID()),
  36928. this._uid
  36929. },
  36930. enumerable: !1,
  36931. configurable: !0
  36932. }),
  36933. e.prototype.toString = function() {
  36934. return this.name
  36935. }
  36936. ,
  36937. e.prototype.getClassName = function() {
  36938. return "BaseTexture"
  36939. }
  36940. ,
  36941. Object.defineProperty(e.prototype, "onDispose", {
  36942. set: function(i) {
  36943. this._onDisposeObserver && this.onDisposeObservable.remove(this._onDisposeObserver),
  36944. this._onDisposeObserver = this.onDisposeObservable.add(i)
  36945. },
  36946. enumerable: !1,
  36947. configurable: !0
  36948. }),
  36949. Object.defineProperty(e.prototype, "isBlocking", {
  36950. get: function() {
  36951. return !0
  36952. },
  36953. enumerable: !1,
  36954. configurable: !0
  36955. }),
  36956. Object.defineProperty(e.prototype, "loadingError", {
  36957. get: function() {
  36958. return this._loadingError
  36959. },
  36960. enumerable: !1,
  36961. configurable: !0
  36962. }),
  36963. Object.defineProperty(e.prototype, "errorObject", {
  36964. get: function() {
  36965. return this._errorObject
  36966. },
  36967. enumerable: !1,
  36968. configurable: !0
  36969. }),
  36970. e.prototype.getScene = function() {
  36971. return this._scene
  36972. }
  36973. ,
  36974. e.prototype._getEngine = function() {
  36975. return this._engine
  36976. }
  36977. ,
  36978. e.prototype.checkTransformsAreIdentical = function(i) {
  36979. return i !== null
  36980. }
  36981. ,
  36982. e.prototype.getTextureMatrix = function() {
  36983. return Matrix.IdentityReadOnly
  36984. }
  36985. ,
  36986. e.prototype.getReflectionTextureMatrix = function() {
  36987. return Matrix.IdentityReadOnly
  36988. }
  36989. ,
  36990. e.prototype.isReadyOrNotBlocking = function() {
  36991. return !this.isBlocking || this.isReady() || this.loadingError
  36992. }
  36993. ,
  36994. e.prototype.scale = function(i) {}
  36995. ,
  36996. Object.defineProperty(e.prototype, "canRescale", {
  36997. get: function() {
  36998. return !1
  36999. },
  37000. enumerable: !1,
  37001. configurable: !0
  37002. }),
  37003. e.prototype._getFromCache = function(i, o, s, c, d) {
  37004. var _ = this._getEngine();
  37005. if (!_)
  37006. return null;
  37007. for (var b = _._getUseSRGBBuffer(!!d, o), k = _.getLoadedTexturesCache(), j = 0; j < k.length; j++) {
  37008. var $ = k[j];
  37009. if ((d === void 0 || b === $._useSRGBBuffer) && (c === void 0 || c === $.invertY) && $.url === i && $.generateMipMaps === !o && (!s || s === $.samplingMode))
  37010. return $.incrementReferences(),
  37011. $
  37012. }
  37013. return null
  37014. }
  37015. ,
  37016. e.prototype._rebuild = function() {}
  37017. ,
  37018. e.prototype.clone = function() {
  37019. return null
  37020. }
  37021. ,
  37022. Object.defineProperty(e.prototype, "textureType", {
  37023. get: function() {
  37024. return this._texture && this._texture.type !== void 0 ? this._texture.type : 0
  37025. },
  37026. enumerable: !1,
  37027. configurable: !0
  37028. }),
  37029. Object.defineProperty(e.prototype, "textureFormat", {
  37030. get: function() {
  37031. return this._texture && this._texture.format !== void 0 ? this._texture.format : 5
  37032. },
  37033. enumerable: !1,
  37034. configurable: !0
  37035. }),
  37036. e.prototype._markAllSubMeshesAsTexturesDirty = function() {
  37037. var i = this.getScene();
  37038. !i || i.markAllMaterialsAsDirty(1)
  37039. }
  37040. ,
  37041. e.prototype.readPixels = function(i, o, s, c, d) {
  37042. if (i === void 0 && (i = 0),
  37043. o === void 0 && (o = 0),
  37044. s === void 0 && (s = null),
  37045. c === void 0 && (c = !0),
  37046. d === void 0 && (d = !1),
  37047. !this._texture)
  37048. return null;
  37049. var _ = this.getSize()
  37050. , b = _.width
  37051. , k = _.height
  37052. , j = this._getEngine();
  37053. if (!j)
  37054. return null;
  37055. o != 0 && (b = b / Math.pow(2, o),
  37056. k = k / Math.pow(2, o),
  37057. b = Math.round(b),
  37058. k = Math.round(k));
  37059. try {
  37060. return this._texture.isCube ? j._readTexturePixels(this._texture, b, k, i, o, s, c, d) : j._readTexturePixels(this._texture, b, k, -1, o, s, c, d)
  37061. } catch {
  37062. return null
  37063. }
  37064. }
  37065. ,
  37066. e.prototype._readPixelsSync = function(i, o, s, c, d) {
  37067. if (i === void 0 && (i = 0),
  37068. o === void 0 && (o = 0),
  37069. s === void 0 && (s = null),
  37070. c === void 0 && (c = !0),
  37071. d === void 0 && (d = !1),
  37072. !this._texture)
  37073. return null;
  37074. var _ = this.getSize()
  37075. , b = _.width
  37076. , k = _.height
  37077. , j = this._getEngine();
  37078. if (!j)
  37079. return null;
  37080. o != 0 && (b = b / Math.pow(2, o),
  37081. k = k / Math.pow(2, o),
  37082. b = Math.round(b),
  37083. k = Math.round(k));
  37084. try {
  37085. return this._texture.isCube ? j._readTexturePixelsSync(this._texture, b, k, i, o, s, c, d) : j._readTexturePixelsSync(this._texture, b, k, -1, o, s, c, d)
  37086. } catch {
  37087. return null
  37088. }
  37089. }
  37090. ,
  37091. Object.defineProperty(e.prototype, "_lodTextureHigh", {
  37092. get: function() {
  37093. return this._texture ? this._texture._lodTextureHigh : null
  37094. },
  37095. enumerable: !1,
  37096. configurable: !0
  37097. }),
  37098. Object.defineProperty(e.prototype, "_lodTextureMid", {
  37099. get: function() {
  37100. return this._texture ? this._texture._lodTextureMid : null
  37101. },
  37102. enumerable: !1,
  37103. configurable: !0
  37104. }),
  37105. Object.defineProperty(e.prototype, "_lodTextureLow", {
  37106. get: function() {
  37107. return this._texture ? this._texture._lodTextureLow : null
  37108. },
  37109. enumerable: !1,
  37110. configurable: !0
  37111. }),
  37112. e.prototype.dispose = function() {
  37113. if (this._scene) {
  37114. this._scene.stopAnimation && this._scene.stopAnimation(this),
  37115. this._scene._removePendingData(this);
  37116. var i = this._scene.textures.indexOf(this);
  37117. if (i >= 0 && this._scene.textures.splice(i, 1),
  37118. this._scene.onTextureRemovedObservable.notifyObservers(this),
  37119. this._scene = null,
  37120. this._parentContainer) {
  37121. var o = this._parentContainer.textures.indexOf(this);
  37122. o > -1 && this._parentContainer.textures.splice(o, 1),
  37123. this._parentContainer = null
  37124. }
  37125. }
  37126. this.onDisposeObservable.notifyObservers(this),
  37127. this.onDisposeObservable.clear(),
  37128. this.metadata = null,
  37129. a.prototype.dispose.call(this)
  37130. }
  37131. ,
  37132. e.prototype.serialize = function() {
  37133. if (!this.name)
  37134. return null;
  37135. var i = SerializationHelper.Serialize(this);
  37136. return SerializationHelper.AppendSerializedAnimations(this, i),
  37137. i
  37138. }
  37139. ,
  37140. e.WhenAllReady = function(i, o) {
  37141. var s = i.length;
  37142. if (s === 0) {
  37143. o();
  37144. return
  37145. }
  37146. for (var c = 0; c < i.length; c++) {
  37147. var d = i[c];
  37148. if (d.isReady())
  37149. --s === 0 && o();
  37150. else {
  37151. var _ = d.onLoadObservable;
  37152. _ && _.addOnce(function() {
  37153. --s === 0 && o()
  37154. })
  37155. }
  37156. }
  37157. }
  37158. ,
  37159. e._isScene = function(i) {
  37160. return i.getClassName() === "Scene"
  37161. }
  37162. ,
  37163. e.DEFAULT_ANISOTROPIC_FILTERING_LEVEL = 4,
  37164. __decorate([serialize()], e.prototype, "uniqueId", void 0),
  37165. __decorate([serialize()], e.prototype, "name", void 0),
  37166. __decorate([serialize()], e.prototype, "metadata", void 0),
  37167. __decorate([serialize("hasAlpha")], e.prototype, "_hasAlpha", void 0),
  37168. __decorate([serialize()], e.prototype, "getAlphaFromRGB", void 0),
  37169. __decorate([serialize()], e.prototype, "level", void 0),
  37170. __decorate([serialize()], e.prototype, "coordinatesIndex", void 0),
  37171. __decorate([serialize("coordinatesMode")], e.prototype, "_coordinatesMode", void 0),
  37172. __decorate([serialize()], e.prototype, "wrapU", null),
  37173. __decorate([serialize()], e.prototype, "wrapV", null),
  37174. __decorate([serialize()], e.prototype, "wrapR", void 0),
  37175. __decorate([serialize()], e.prototype, "anisotropicFilteringLevel", void 0),
  37176. __decorate([serialize()], e.prototype, "isCube", null),
  37177. __decorate([serialize()], e.prototype, "is3D", null),
  37178. __decorate([serialize()], e.prototype, "is2DArray", null),
  37179. __decorate([serialize()], e.prototype, "gammaSpace", null),
  37180. __decorate([serialize()], e.prototype, "invertZ", void 0),
  37181. __decorate([serialize()], e.prototype, "lodLevelInAlpha", void 0),
  37182. __decorate([serialize()], e.prototype, "lodGenerationOffset", null),
  37183. __decorate([serialize()], e.prototype, "lodGenerationScale", null),
  37184. __decorate([serialize()], e.prototype, "linearSpecularLOD", null),
  37185. __decorate([serializeAsTexture()], e.prototype, "irradianceTexture", null),
  37186. __decorate([serialize()], e.prototype, "isRenderTarget", void 0),
  37187. e
  37188. }(ThinTexture);
  37189. function GenerateBase64StringFromPixelData(a, e, i) {
  37190. i === void 0 && (i = !1);
  37191. var o = e.width
  37192. , s = e.height;
  37193. if (a instanceof Float32Array) {
  37194. for (var c = a.byteLength / a.BYTES_PER_ELEMENT, d = new Uint8Array(c); --c >= 0; ) {
  37195. var _ = a[c];
  37196. _ < 0 ? _ = 0 : _ > 1 && (_ = 1),
  37197. d[c] = _ * 255
  37198. }
  37199. a = d
  37200. }
  37201. var b = document.createElement("canvas");
  37202. b.width = o,
  37203. b.height = s;
  37204. var k = b.getContext("2d");
  37205. if (!k)
  37206. return null;
  37207. var j = k.createImageData(o, s)
  37208. , $ = j.data;
  37209. if ($.set(a),
  37210. k.putImageData(j, 0, 0),
  37211. i) {
  37212. var _e = document.createElement("canvas");
  37213. _e.width = o,
  37214. _e.height = s;
  37215. var et = _e.getContext("2d");
  37216. return et ? (et.translate(0, s),
  37217. et.scale(1, -1),
  37218. et.drawImage(b, 0, 0),
  37219. _e.toDataURL("image/png")) : null
  37220. }
  37221. return b.toDataURL("image/png")
  37222. }
  37223. function GenerateBase64StringFromTexture(a, e, i) {
  37224. e === void 0 && (e = 0),
  37225. i === void 0 && (i = 0);
  37226. var o = a.getInternalTexture();
  37227. if (!o)
  37228. return null;
  37229. var s = a._readPixelsSync(e, i);
  37230. return s ? GenerateBase64StringFromPixelData(s, a.getSize(), o.invertY) : null
  37231. }
  37232. function GenerateBase64StringFromTextureAsync(a, e, i) {
  37233. return e === void 0 && (e = 0),
  37234. i === void 0 && (i = 0),
  37235. __awaiter(this, void 0, void 0, function() {
  37236. var o, s;
  37237. return __generator(this, function(c) {
  37238. switch (c.label) {
  37239. case 0:
  37240. return o = a.getInternalTexture(),
  37241. o ? [4, a.readPixels(e, i)] : [2, null];
  37242. case 1:
  37243. return s = c.sent(),
  37244. s ? [2, GenerateBase64StringFromPixelData(s, a.getSize(), o.invertY)] : [2, null]
  37245. }
  37246. })
  37247. })
  37248. }
  37249. var Texture = function(a) {
  37250. __extends(e, a);
  37251. function e(i, o, s, c, d, _, b, k, j, $, _e, et, tt) {
  37252. c === void 0 && (c = !0),
  37253. d === void 0 && (d = e.TRILINEAR_SAMPLINGMODE),
  37254. _ === void 0 && (_ = null),
  37255. b === void 0 && (b = null),
  37256. k === void 0 && (k = null),
  37257. j === void 0 && (j = !1);
  37258. var rt, it, nt, ot, at, st, ut, ct, lt = a.call(this, o) || this;
  37259. lt.url = null,
  37260. lt.uOffset = 0,
  37261. lt.vOffset = 0,
  37262. lt.uScale = 1,
  37263. lt.vScale = 1,
  37264. lt.uAng = 0,
  37265. lt.vAng = 0,
  37266. lt.wAng = 0,
  37267. lt.uRotationCenter = .5,
  37268. lt.vRotationCenter = .5,
  37269. lt.wRotationCenter = .5,
  37270. lt.homogeneousRotationInUVTransform = !1,
  37271. lt.inspectableCustomProperties = null,
  37272. lt._noMipmap = !1,
  37273. lt._invertY = !1,
  37274. lt._rowGenerationMatrix = null,
  37275. lt._cachedTextureMatrix = null,
  37276. lt._projectionModeMatrix = null,
  37277. lt._t0 = null,
  37278. lt._t1 = null,
  37279. lt._t2 = null,
  37280. lt._cachedUOffset = -1,
  37281. lt._cachedVOffset = -1,
  37282. lt._cachedUScale = 0,
  37283. lt._cachedVScale = 0,
  37284. lt._cachedUAng = -1,
  37285. lt._cachedVAng = -1,
  37286. lt._cachedWAng = -1,
  37287. lt._cachedProjectionMatrixId = -1,
  37288. lt._cachedURotationCenter = -1,
  37289. lt._cachedVRotationCenter = -1,
  37290. lt._cachedWRotationCenter = -1,
  37291. lt._cachedHomogeneousRotationInUVTransform = !1,
  37292. lt._cachedCoordinatesMode = -1,
  37293. lt._buffer = null,
  37294. lt._deleteBuffer = !1,
  37295. lt._format = null,
  37296. lt._delayedOnLoad = null,
  37297. lt._delayedOnError = null,
  37298. lt.onLoadObservable = new Observable,
  37299. lt._isBlocking = !0,
  37300. lt.name = i || "",
  37301. lt.url = i;
  37302. var ft, ht = !1;
  37303. typeof s == "object" && s !== null ? (ft = (rt = s.noMipmap) !== null && rt !== void 0 ? rt : !1,
  37304. c = (it = s.invertY) !== null && it !== void 0 ? it : !0,
  37305. d = (nt = s.samplingMode) !== null && nt !== void 0 ? nt : e.TRILINEAR_SAMPLINGMODE,
  37306. _ = (ot = s.onLoad) !== null && ot !== void 0 ? ot : null,
  37307. b = (at = s.onError) !== null && at !== void 0 ? at : null,
  37308. k = (st = s.buffer) !== null && st !== void 0 ? st : null,
  37309. j = (ut = s.deleteBuffer) !== null && ut !== void 0 ? ut : !1,
  37310. $ = s.format,
  37311. _e = s.mimeType,
  37312. et = s.loaderOptions,
  37313. tt = s.creationFlags,
  37314. ht = (ct = s.useSRGBBuffer) !== null && ct !== void 0 ? ct : !1) : ft = !!s,
  37315. lt._noMipmap = ft,
  37316. lt._invertY = c,
  37317. lt._initialSamplingMode = d,
  37318. lt._buffer = k,
  37319. lt._deleteBuffer = j,
  37320. lt._mimeType = _e,
  37321. lt._loaderOptions = et,
  37322. lt._creationFlags = tt,
  37323. lt._useSRGBBuffer = ht,
  37324. $ && (lt._format = $);
  37325. var pt = lt.getScene()
  37326. , dt = lt._getEngine();
  37327. if (!dt)
  37328. return lt;
  37329. dt.onBeforeTextureInitObservable.notifyObservers(lt);
  37330. var _t = function() {
  37331. lt._texture && (lt._texture._invertVScale && (lt.vScale *= -1,
  37332. lt.vOffset += 1),
  37333. lt._texture._cachedWrapU !== null && (lt.wrapU = lt._texture._cachedWrapU,
  37334. lt._texture._cachedWrapU = null),
  37335. lt._texture._cachedWrapV !== null && (lt.wrapV = lt._texture._cachedWrapV,
  37336. lt._texture._cachedWrapV = null),
  37337. lt._texture._cachedWrapR !== null && (lt.wrapR = lt._texture._cachedWrapR,
  37338. lt._texture._cachedWrapR = null)),
  37339. lt.onLoadObservable.hasObservers() && lt.onLoadObservable.notifyObservers(lt),
  37340. _ && _(),
  37341. !lt.isBlocking && pt && pt.resetCachedMaterial()
  37342. }
  37343. , mt = function(yt, Et) {
  37344. lt._loadingError = !0,
  37345. lt._errorObject = {
  37346. message: yt,
  37347. exception: Et
  37348. },
  37349. b && b(yt, Et),
  37350. e.OnTextureLoadErrorObservable.notifyObservers(lt)
  37351. };
  37352. if (!lt.url)
  37353. return lt._delayedOnLoad = _t,
  37354. lt._delayedOnError = mt,
  37355. lt;
  37356. if (lt._texture = lt._getFromCache(lt.url, ft, d, c, ht),
  37357. lt._texture)
  37358. if (lt._texture.isReady)
  37359. TimingTools.SetImmediate(function() {
  37360. return _t()
  37361. });
  37362. else {
  37363. var vt = lt._texture.onLoadedObservable.add(_t);
  37364. lt._texture.onErrorObservable.add(function(yt) {
  37365. var Et;
  37366. mt(yt.message, yt.exception),
  37367. (Et = lt._texture) === null || Et === void 0 || Et.onLoadedObservable.remove(vt)
  37368. })
  37369. }
  37370. else if (!pt || !pt.useDelayedTextureLoading) {
  37371. try {
  37372. lt._texture = dt.createTexture(lt.url, ft, c, pt, d, _t, mt, lt._buffer, void 0, lt._format, null, _e, et, tt, ht)
  37373. } catch (yt) {
  37374. throw mt("error loading", yt),
  37375. yt
  37376. }
  37377. j && (lt._buffer = null)
  37378. } else
  37379. lt.delayLoadState = 4,
  37380. lt._delayedOnLoad = _t,
  37381. lt._delayedOnError = mt;
  37382. return lt
  37383. }
  37384. return Object.defineProperty(e.prototype, "noMipmap", {
  37385. get: function() {
  37386. return this._noMipmap
  37387. },
  37388. enumerable: !1,
  37389. configurable: !0
  37390. }),
  37391. Object.defineProperty(e.prototype, "mimeType", {
  37392. get: function() {
  37393. return this._mimeType
  37394. },
  37395. enumerable: !1,
  37396. configurable: !0
  37397. }),
  37398. Object.defineProperty(e.prototype, "isBlocking", {
  37399. get: function() {
  37400. return this._isBlocking
  37401. },
  37402. set: function(i) {
  37403. this._isBlocking = i
  37404. },
  37405. enumerable: !1,
  37406. configurable: !0
  37407. }),
  37408. Object.defineProperty(e.prototype, "invertY", {
  37409. get: function() {
  37410. return this._invertY
  37411. },
  37412. enumerable: !1,
  37413. configurable: !0
  37414. }),
  37415. e.prototype.updateURL = function(i, o, s) {
  37416. o === void 0 && (o = null),
  37417. this.url && (this.releaseInternalTexture(),
  37418. this.getScene().markAllMaterialsAsDirty(1)),
  37419. (!this.name || StartsWith(this.name, "data:")) && (this.name = i),
  37420. this.url = i,
  37421. this._buffer = o,
  37422. this.delayLoadState = 4,
  37423. s && (this._delayedOnLoad = s),
  37424. this.delayLoad()
  37425. }
  37426. ,
  37427. e.prototype.delayLoad = function() {
  37428. if (this.delayLoadState === 4) {
  37429. var i = this.getScene();
  37430. !i || (this.delayLoadState = 1,
  37431. this._texture = this._getFromCache(this.url, this._noMipmap, this.samplingMode, this._invertY, this._useSRGBBuffer),
  37432. this._texture ? this._delayedOnLoad && (this._texture.isReady ? TimingTools.SetImmediate(this._delayedOnLoad) : this._texture.onLoadedObservable.add(this._delayedOnLoad)) : (this._texture = i.getEngine().createTexture(this.url, this._noMipmap, this._invertY, i, this.samplingMode, this._delayedOnLoad, this._delayedOnError, this._buffer, null, this._format, null, this._mimeType, this._loaderOptions, this._creationFlags, this._useSRGBBuffer),
  37433. this._deleteBuffer && (this._buffer = null)),
  37434. this._delayedOnLoad = null,
  37435. this._delayedOnError = null)
  37436. }
  37437. }
  37438. ,
  37439. e.prototype._prepareRowForTextureGeneration = function(i, o, s, c) {
  37440. i *= this._cachedUScale,
  37441. o *= this._cachedVScale,
  37442. i -= this.uRotationCenter * this._cachedUScale,
  37443. o -= this.vRotationCenter * this._cachedVScale,
  37444. s -= this.wRotationCenter,
  37445. Vector3.TransformCoordinatesFromFloatsToRef(i, o, s, this._rowGenerationMatrix, c),
  37446. c.x += this.uRotationCenter * this._cachedUScale + this._cachedUOffset,
  37447. c.y += this.vRotationCenter * this._cachedVScale + this._cachedVOffset,
  37448. c.z += this.wRotationCenter
  37449. }
  37450. ,
  37451. e.prototype.checkTransformsAreIdentical = function(i) {
  37452. return i !== null && this.uOffset === i.uOffset && this.vOffset === i.vOffset && this.uScale === i.uScale && this.vScale === i.vScale && this.uAng === i.uAng && this.vAng === i.vAng && this.wAng === i.wAng
  37453. }
  37454. ,
  37455. e.prototype.getTextureMatrix = function(i) {
  37456. var o = this;
  37457. if (i === void 0 && (i = 1),
  37458. this.uOffset === this._cachedUOffset && this.vOffset === this._cachedVOffset && this.uScale * i === this._cachedUScale && this.vScale === this._cachedVScale && this.uAng === this._cachedUAng && this.vAng === this._cachedVAng && this.wAng === this._cachedWAng && this.uRotationCenter === this._cachedURotationCenter && this.vRotationCenter === this._cachedVRotationCenter && this.wRotationCenter === this._cachedWRotationCenter && this.homogeneousRotationInUVTransform === this._cachedHomogeneousRotationInUVTransform)
  37459. return this._cachedTextureMatrix;
  37460. this._cachedUOffset = this.uOffset,
  37461. this._cachedVOffset = this.vOffset,
  37462. this._cachedUScale = this.uScale * i,
  37463. this._cachedVScale = this.vScale,
  37464. this._cachedUAng = this.uAng,
  37465. this._cachedVAng = this.vAng,
  37466. this._cachedWAng = this.wAng,
  37467. this._cachedURotationCenter = this.uRotationCenter,
  37468. this._cachedVRotationCenter = this.vRotationCenter,
  37469. this._cachedWRotationCenter = this.wRotationCenter,
  37470. this._cachedHomogeneousRotationInUVTransform = this.homogeneousRotationInUVTransform,
  37471. (!this._cachedTextureMatrix || !this._rowGenerationMatrix) && (this._cachedTextureMatrix = Matrix.Zero(),
  37472. this._rowGenerationMatrix = new Matrix,
  37473. this._t0 = Vector3.Zero(),
  37474. this._t1 = Vector3.Zero(),
  37475. this._t2 = Vector3.Zero()),
  37476. Matrix.RotationYawPitchRollToRef(this.vAng, this.uAng, this.wAng, this._rowGenerationMatrix),
  37477. this.homogeneousRotationInUVTransform ? (Matrix.TranslationToRef(-this._cachedURotationCenter, -this._cachedVRotationCenter, -this._cachedWRotationCenter, TmpVectors.Matrix[0]),
  37478. Matrix.TranslationToRef(this._cachedURotationCenter, this._cachedVRotationCenter, this._cachedWRotationCenter, TmpVectors.Matrix[1]),
  37479. Matrix.ScalingToRef(this._cachedUScale, this._cachedVScale, 0, TmpVectors.Matrix[2]),
  37480. Matrix.TranslationToRef(this._cachedUOffset, this._cachedVOffset, 0, TmpVectors.Matrix[3]),
  37481. TmpVectors.Matrix[0].multiplyToRef(this._rowGenerationMatrix, this._cachedTextureMatrix),
  37482. this._cachedTextureMatrix.multiplyToRef(TmpVectors.Matrix[1], this._cachedTextureMatrix),
  37483. this._cachedTextureMatrix.multiplyToRef(TmpVectors.Matrix[2], this._cachedTextureMatrix),
  37484. this._cachedTextureMatrix.multiplyToRef(TmpVectors.Matrix[3], this._cachedTextureMatrix),
  37485. this._cachedTextureMatrix.setRowFromFloats(2, this._cachedTextureMatrix.m[12], this._cachedTextureMatrix.m[13], this._cachedTextureMatrix.m[14], 1)) : (this._prepareRowForTextureGeneration(0, 0, 0, this._t0),
  37486. this._prepareRowForTextureGeneration(1, 0, 0, this._t1),
  37487. this._prepareRowForTextureGeneration(0, 1, 0, this._t2),
  37488. this._t1.subtractInPlace(this._t0),
  37489. this._t2.subtractInPlace(this._t0),
  37490. Matrix.FromValuesToRef(this._t1.x, this._t1.y, this._t1.z, 0, this._t2.x, this._t2.y, this._t2.z, 0, this._t0.x, this._t0.y, this._t0.z, 0, 0, 0, 0, 1, this._cachedTextureMatrix));
  37491. var s = this.getScene();
  37492. return s ? (s.markAllMaterialsAsDirty(1, function(c) {
  37493. return c.hasTexture(o)
  37494. }),
  37495. this._cachedTextureMatrix) : this._cachedTextureMatrix
  37496. }
  37497. ,
  37498. e.prototype.getReflectionTextureMatrix = function() {
  37499. var i = this
  37500. , o = this.getScene();
  37501. if (!o)
  37502. return this._cachedTextureMatrix;
  37503. if (this.uOffset === this._cachedUOffset && this.vOffset === this._cachedVOffset && this.uScale === this._cachedUScale && this.vScale === this._cachedVScale && this.coordinatesMode === this._cachedCoordinatesMode)
  37504. if (this.coordinatesMode === e.PROJECTION_MODE) {
  37505. if (this._cachedProjectionMatrixId === o.getProjectionMatrix().updateFlag)
  37506. return this._cachedTextureMatrix
  37507. } else
  37508. return this._cachedTextureMatrix;
  37509. this._cachedTextureMatrix || (this._cachedTextureMatrix = Matrix.Zero()),
  37510. this._projectionModeMatrix || (this._projectionModeMatrix = Matrix.Zero());
  37511. var s = this._cachedCoordinatesMode !== this.coordinatesMode;
  37512. switch (this._cachedUOffset = this.uOffset,
  37513. this._cachedVOffset = this.vOffset,
  37514. this._cachedUScale = this.uScale,
  37515. this._cachedVScale = this.vScale,
  37516. this._cachedCoordinatesMode = this.coordinatesMode,
  37517. this.coordinatesMode) {
  37518. case e.PLANAR_MODE:
  37519. Matrix.IdentityToRef(this._cachedTextureMatrix),
  37520. this._cachedTextureMatrix[0] = this.uScale,
  37521. this._cachedTextureMatrix[5] = this.vScale,
  37522. this._cachedTextureMatrix[12] = this.uOffset,
  37523. this._cachedTextureMatrix[13] = this.vOffset;
  37524. break;
  37525. case e.PROJECTION_MODE:
  37526. Matrix.FromValuesToRef(.5, 0, 0, 0, 0, -.5, 0, 0, 0, 0, 0, 0, .5, .5, 1, 1, this._projectionModeMatrix);
  37527. var c = o.getProjectionMatrix();
  37528. this._cachedProjectionMatrixId = c.updateFlag,
  37529. c.multiplyToRef(this._projectionModeMatrix, this._cachedTextureMatrix);
  37530. break;
  37531. default:
  37532. Matrix.IdentityToRef(this._cachedTextureMatrix);
  37533. break
  37534. }
  37535. return s && o.markAllMaterialsAsDirty(1, function(d) {
  37536. return d.getActiveTextures().indexOf(i) !== -1
  37537. }),
  37538. this._cachedTextureMatrix
  37539. }
  37540. ,
  37541. e.prototype.clone = function() {
  37542. var i = this
  37543. , o = {
  37544. noMipmap: this._noMipmap,
  37545. invertY: this._invertY,
  37546. samplingMode: this.samplingMode,
  37547. onLoad: void 0,
  37548. onError: void 0,
  37549. buffer: this._texture ? this._texture._buffer : void 0,
  37550. deleteBuffer: this._deleteBuffer,
  37551. format: this.textureFormat,
  37552. mimeType: this.mimeType,
  37553. loaderOptions: this._loaderOptions,
  37554. creationFlags: this._creationFlags,
  37555. useSRGBBuffer: this._useSRGBBuffer
  37556. };
  37557. return SerializationHelper.Clone(function() {
  37558. return new e(i._texture ? i._texture.url : null,i.getScene(),o)
  37559. }, this)
  37560. }
  37561. ,
  37562. e.prototype.serialize = function() {
  37563. var i = this.name;
  37564. e.SerializeBuffers || StartsWith(this.name, "data:") && (this.name = ""),
  37565. StartsWith(this.name, "data:") && this.url === this.name && (this.url = "");
  37566. var o = a.prototype.serialize.call(this);
  37567. return o ? ((e.SerializeBuffers || e.ForceSerializeBuffers) && (typeof this._buffer == "string" && this._buffer.substr(0, 5) === "data:" ? (o.base64String = this._buffer,
  37568. o.name = o.name.replace("data:", "")) : this.url && StartsWith(this.url, "data:") && this._buffer instanceof Uint8Array ? o.base64String = "data:image/png;base64," + EncodeArrayBufferToBase64(this._buffer) : (e.ForceSerializeBuffers || this.url && StartsWith(this.url, "blob:") || this._forceSerialize) && (o.base64String = !this._engine || this._engine._features.supportSyncTextureRead ? GenerateBase64StringFromTexture(this) : GenerateBase64StringFromTextureAsync(this))),
  37569. o.invertY = this._invertY,
  37570. o.samplingMode = this.samplingMode,
  37571. o._creationFlags = this._creationFlags,
  37572. o._useSRGBBuffer = this._useSRGBBuffer,
  37573. this.name = i,
  37574. o) : null
  37575. }
  37576. ,
  37577. e.prototype.getClassName = function() {
  37578. return "Texture"
  37579. }
  37580. ,
  37581. e.prototype.dispose = function() {
  37582. a.prototype.dispose.call(this),
  37583. this.onLoadObservable.clear(),
  37584. this._delayedOnLoad = null,
  37585. this._delayedOnError = null
  37586. }
  37587. ,
  37588. e.Parse = function(i, o, s) {
  37589. if (i.customType) {
  37590. var c = InstantiationTools.Instantiate(i.customType)
  37591. , d = c.Parse(i, o, s);
  37592. return i.samplingMode && d.updateSamplingMode && d._samplingMode && d._samplingMode !== i.samplingMode && d.updateSamplingMode(i.samplingMode),
  37593. d
  37594. }
  37595. if (i.isCube && !i.isRenderTarget)
  37596. return e._CubeTextureParser(i, o, s);
  37597. if (!i.name && !i.isRenderTarget)
  37598. return null;
  37599. var _ = function() {
  37600. if (b && b._texture && (b._texture._cachedWrapU = null,
  37601. b._texture._cachedWrapV = null,
  37602. b._texture._cachedWrapR = null),
  37603. i.samplingMode) {
  37604. var k = i.samplingMode;
  37605. b && b.samplingMode !== k && b.updateSamplingMode(k)
  37606. }
  37607. if (b && i.animations)
  37608. for (var j = 0; j < i.animations.length; j++) {
  37609. var $ = i.animations[j]
  37610. , _e = GetClass("BABYLON.Animation");
  37611. _e && b.animations.push(_e.Parse($))
  37612. }
  37613. }
  37614. , b = SerializationHelper.Parse(function() {
  37615. var k, j, $, _e = !0;
  37616. if (i.noMipmap && (_e = !1),
  37617. i.mirrorPlane) {
  37618. var et = e._CreateMirror(i.name, i.renderTargetSize, o, _e);
  37619. return et._waitingRenderList = i.renderList,
  37620. et.mirrorPlane = Plane.FromArray(i.mirrorPlane),
  37621. _(),
  37622. et
  37623. } else if (i.isRenderTarget) {
  37624. var tt = null;
  37625. if (i.isCube) {
  37626. if (o.reflectionProbes)
  37627. for (var rt = 0; rt < o.reflectionProbes.length; rt++) {
  37628. var it = o.reflectionProbes[rt];
  37629. if (it.name === i.name)
  37630. return it.cubeTexture
  37631. }
  37632. } else
  37633. tt = e._CreateRenderTargetTexture(i.name, i.renderTargetSize, o, _e, (k = i._creationFlags) !== null && k !== void 0 ? k : 0),
  37634. tt._waitingRenderList = i.renderList;
  37635. return _(),
  37636. tt
  37637. } else {
  37638. var nt;
  37639. if (i.base64String)
  37640. nt = e.CreateFromBase64String(i.base64String, i.name, o, !_e, i.invertY, i.samplingMode, _, (j = i._creationFlags) !== null && j !== void 0 ? j : 0, ($ = i._useSRGBBuffer) !== null && $ !== void 0 ? $ : !1);
  37641. else {
  37642. var ot = void 0;
  37643. i.name && i.name.indexOf("://") > 0 ? ot = i.name : ot = s + i.name,
  37644. (StartsWith(i.url, "data:") || e.UseSerializedUrlIfAny && i.url) && (ot = i.url),
  37645. nt = new e(ot,o,!_e,i.invertY,i.samplingMode,_)
  37646. }
  37647. return nt
  37648. }
  37649. }, i, o);
  37650. return b
  37651. }
  37652. ,
  37653. e.CreateFromBase64String = function(i, o, s, c, d, _, b, k, j, $) {
  37654. return _ === void 0 && (_ = e.TRILINEAR_SAMPLINGMODE),
  37655. b === void 0 && (b = null),
  37656. k === void 0 && (k = null),
  37657. j === void 0 && (j = 5),
  37658. new e("data:" + o,s,c,d,_,b,k,i,!1,j,void 0,void 0,$)
  37659. }
  37660. ,
  37661. e.LoadFromDataString = function(i, o, s, c, d, _, b, k, j, $, _e) {
  37662. return c === void 0 && (c = !1),
  37663. _ === void 0 && (_ = !0),
  37664. b === void 0 && (b = e.TRILINEAR_SAMPLINGMODE),
  37665. k === void 0 && (k = null),
  37666. j === void 0 && (j = null),
  37667. $ === void 0 && ($ = 5),
  37668. i.substr(0, 5) !== "data:" && (i = "data:" + i),
  37669. new e(i,s,d,_,b,k,j,o,c,$,void 0,void 0,_e)
  37670. }
  37671. ,
  37672. e.SerializeBuffers = !0,
  37673. e.ForceSerializeBuffers = !1,
  37674. e.OnTextureLoadErrorObservable = new Observable,
  37675. e._CubeTextureParser = function(i, o, s) {
  37676. throw _WarnImport("CubeTexture")
  37677. }
  37678. ,
  37679. e._CreateMirror = function(i, o, s, c) {
  37680. throw _WarnImport("MirrorTexture")
  37681. }
  37682. ,
  37683. e._CreateRenderTargetTexture = function(i, o, s, c, d) {
  37684. throw _WarnImport("RenderTargetTexture")
  37685. }
  37686. ,
  37687. e.NEAREST_SAMPLINGMODE = 1,
  37688. e.NEAREST_NEAREST_MIPLINEAR = 8,
  37689. e.BILINEAR_SAMPLINGMODE = 2,
  37690. e.LINEAR_LINEAR_MIPNEAREST = 11,
  37691. e.TRILINEAR_SAMPLINGMODE = 3,
  37692. e.LINEAR_LINEAR_MIPLINEAR = 3,
  37693. e.NEAREST_NEAREST_MIPNEAREST = 4,
  37694. e.NEAREST_LINEAR_MIPNEAREST = 5,
  37695. e.NEAREST_LINEAR_MIPLINEAR = 6,
  37696. e.NEAREST_LINEAR = 7,
  37697. e.NEAREST_NEAREST = 1,
  37698. e.LINEAR_NEAREST_MIPNEAREST = 9,
  37699. e.LINEAR_NEAREST_MIPLINEAR = 10,
  37700. e.LINEAR_LINEAR = 2,
  37701. e.LINEAR_NEAREST = 12,
  37702. e.EXPLICIT_MODE = 0,
  37703. e.SPHERICAL_MODE = 1,
  37704. e.PLANAR_MODE = 2,
  37705. e.CUBIC_MODE = 3,
  37706. e.PROJECTION_MODE = 4,
  37707. e.SKYBOX_MODE = 5,
  37708. e.INVCUBIC_MODE = 6,
  37709. e.EQUIRECTANGULAR_MODE = 7,
  37710. e.FIXED_EQUIRECTANGULAR_MODE = 8,
  37711. e.FIXED_EQUIRECTANGULAR_MIRRORED_MODE = 9,
  37712. e.CLAMP_ADDRESSMODE = 0,
  37713. e.WRAP_ADDRESSMODE = 1,
  37714. e.MIRROR_ADDRESSMODE = 2,
  37715. e.UseSerializedUrlIfAny = !1,
  37716. __decorate([serialize()], e.prototype, "url", void 0),
  37717. __decorate([serialize()], e.prototype, "uOffset", void 0),
  37718. __decorate([serialize()], e.prototype, "vOffset", void 0),
  37719. __decorate([serialize()], e.prototype, "uScale", void 0),
  37720. __decorate([serialize()], e.prototype, "vScale", void 0),
  37721. __decorate([serialize()], e.prototype, "uAng", void 0),
  37722. __decorate([serialize()], e.prototype, "vAng", void 0),
  37723. __decorate([serialize()], e.prototype, "wAng", void 0),
  37724. __decorate([serialize()], e.prototype, "uRotationCenter", void 0),
  37725. __decorate([serialize()], e.prototype, "vRotationCenter", void 0),
  37726. __decorate([serialize()], e.prototype, "wRotationCenter", void 0),
  37727. __decorate([serialize()], e.prototype, "homogeneousRotationInUVTransform", void 0),
  37728. __decorate([serialize()], e.prototype, "isBlocking", null),
  37729. e
  37730. }(BaseTexture);
  37731. RegisterClass("BABYLON.Texture", Texture);
  37732. SerializationHelper._TextureParser = Texture.Parse;
  37733. var WebGLRenderTargetWrapper = function(a) {
  37734. __extends(e, a);
  37735. function e(i, o, s, c, d) {
  37736. var _ = a.call(this, i, o, s, c) || this;
  37737. return _._framebuffer = null,
  37738. _._depthStencilBuffer = null,
  37739. _._MSAAFramebuffer = null,
  37740. _._colorTextureArray = null,
  37741. _._depthStencilTextureArray = null,
  37742. _._context = d,
  37743. _
  37744. }
  37745. return e.prototype._cloneRenderTargetWrapper = function() {
  37746. var i = null;
  37747. return this._colorTextureArray && this._depthStencilTextureArray ? (i = this._engine.createMultiviewRenderTargetTexture(this.width, this.height),
  37748. i.texture.isReady = !0) : i = a.prototype._cloneRenderTargetWrapper.call(this),
  37749. i
  37750. }
  37751. ,
  37752. e.prototype._swapRenderTargetWrapper = function(i) {
  37753. a.prototype._swapRenderTargetWrapper.call(this, i),
  37754. i._framebuffer = this._framebuffer,
  37755. i._depthStencilBuffer = this._depthStencilBuffer,
  37756. i._MSAAFramebuffer = this._MSAAFramebuffer,
  37757. i._colorTextureArray = this._colorTextureArray,
  37758. i._depthStencilTextureArray = this._depthStencilTextureArray,
  37759. this._framebuffer = this._depthStencilBuffer = this._MSAAFramebuffer = this._colorTextureArray = this._depthStencilTextureArray = null
  37760. }
  37761. ,
  37762. e.prototype._shareDepth = function(i) {
  37763. a.prototype._shareDepth.call(this, i);
  37764. var o = this._context
  37765. , s = this._depthStencilBuffer
  37766. , c = i._framebuffer;
  37767. i._depthStencilBuffer && o.deleteRenderbuffer(i._depthStencilBuffer),
  37768. i._depthStencilBuffer = this._depthStencilBuffer,
  37769. this._engine._bindUnboundFramebuffer(c),
  37770. o.framebufferRenderbuffer(o.FRAMEBUFFER, o.DEPTH_ATTACHMENT, o.RENDERBUFFER, s),
  37771. this._engine._bindUnboundFramebuffer(null)
  37772. }
  37773. ,
  37774. e.prototype._bindTextureRenderTarget = function(i, o, s, c) {
  37775. if (o === void 0 && (o = 0),
  37776. s === void 0 && (s = -1),
  37777. c === void 0 && (c = 0),
  37778. !!i._hardwareTexture) {
  37779. var d = this._context
  37780. , _ = this._framebuffer
  37781. , b = this._engine._currentFramebuffer;
  37782. this._engine._bindUnboundFramebuffer(_);
  37783. var k = d[this._engine.webGLVersion > 1 ? "COLOR_ATTACHMENT" + o : "COLOR_ATTACHMENT" + o + "_WEBGL"]
  37784. , j = s !== -1 ? d.TEXTURE_CUBE_MAP_POSITIVE_X + s : d.TEXTURE_2D;
  37785. d.framebufferTexture2D(d.FRAMEBUFFER, k, j, i._hardwareTexture.underlyingResource, c),
  37786. this._engine._bindUnboundFramebuffer(b)
  37787. }
  37788. }
  37789. ,
  37790. e.prototype.setTexture = function(i, o, s) {
  37791. o === void 0 && (o = 0),
  37792. s === void 0 && (s = !0),
  37793. a.prototype.setTexture.call(this, i, o, s),
  37794. this._bindTextureRenderTarget(i, o)
  37795. }
  37796. ,
  37797. e.prototype.dispose = function(i) {
  37798. i === void 0 && (i = !1);
  37799. var o = this._context;
  37800. i || (this._colorTextureArray && (this._context.deleteTexture(this._colorTextureArray),
  37801. this._colorTextureArray = null),
  37802. this._depthStencilTextureArray && (this._context.deleteTexture(this._depthStencilTextureArray),
  37803. this._depthStencilTextureArray = null)),
  37804. this._framebuffer && (o.deleteFramebuffer(this._framebuffer),
  37805. this._framebuffer = null),
  37806. this._depthStencilBuffer && (o.deleteRenderbuffer(this._depthStencilBuffer),
  37807. this._depthStencilBuffer = null),
  37808. this._MSAAFramebuffer && (o.deleteFramebuffer(this._MSAAFramebuffer),
  37809. this._MSAAFramebuffer = null),
  37810. a.prototype.dispose.call(this, i)
  37811. }
  37812. ,
  37813. e
  37814. }(RenderTargetWrapper);
  37815. ThinEngine.prototype._createHardwareRenderTargetWrapper = function(a, e, i) {
  37816. var o = new WebGLRenderTargetWrapper(a,e,i,this,this._gl);
  37817. return this._renderTargetWrapperCache.push(o),
  37818. o
  37819. }
  37820. ;
  37821. ThinEngine.prototype.createRenderTargetTexture = function(a, e) {
  37822. var i = this._createHardwareRenderTargetWrapper(!1, !1, a)
  37823. , o = {};
  37824. e !== void 0 && typeof e == "object" ? (o.generateDepthBuffer = !!e.generateDepthBuffer,
  37825. o.generateStencilBuffer = !!e.generateStencilBuffer) : (o.generateDepthBuffer = !0,
  37826. o.generateStencilBuffer = !1);
  37827. var s = this._createInternalTexture(a, e, !0, InternalTextureSource.RenderTarget)
  37828. , c = a.width || a
  37829. , d = a.height || a
  37830. , _ = this._currentFramebuffer
  37831. , b = this._gl
  37832. , k = b.createFramebuffer();
  37833. return this._bindUnboundFramebuffer(k),
  37834. i._depthStencilBuffer = this._setupFramebufferDepthAttachments(!!o.generateStencilBuffer, o.generateDepthBuffer, c, d),
  37835. s.is2DArray || b.framebufferTexture2D(b.FRAMEBUFFER, b.COLOR_ATTACHMENT0, b.TEXTURE_2D, s._hardwareTexture.underlyingResource, 0),
  37836. this._bindUnboundFramebuffer(_),
  37837. i._framebuffer = k,
  37838. i._generateDepthBuffer = o.generateDepthBuffer,
  37839. i._generateStencilBuffer = !!o.generateStencilBuffer,
  37840. i.setTextures(s),
  37841. i
  37842. }
  37843. ;
  37844. ThinEngine.prototype.createDepthStencilTexture = function(a, e, i) {
  37845. if (e.isCube) {
  37846. var o = a.width || a;
  37847. return this._createDepthStencilCubeTexture(o, e, i)
  37848. } else
  37849. return this._createDepthStencilTexture(a, e, i)
  37850. }
  37851. ;
  37852. ThinEngine.prototype._createDepthStencilTexture = function(a, e, i) {
  37853. var o = this._gl
  37854. , s = a.layers || 0
  37855. , c = s !== 0 ? o.TEXTURE_2D_ARRAY : o.TEXTURE_2D
  37856. , d = new InternalTexture(this,InternalTextureSource.DepthStencil);
  37857. if (!this._caps.depthTextureExtension)
  37858. return Logger$2.Error("Depth texture is not supported by your browser or hardware."),
  37859. d;
  37860. var _ = __assign({
  37861. bilinearFiltering: !1,
  37862. comparisonFunction: 0,
  37863. generateStencil: !1
  37864. }, e);
  37865. this._bindTextureDirectly(c, d, !0),
  37866. this._setupDepthStencilTexture(d, a, _.generateStencil, _.comparisonFunction === 0 ? !1 : _.bilinearFiltering, _.comparisonFunction),
  37867. i._depthStencilTexture = d,
  37868. i._depthStencilTextureWithStencil = _.generateStencil;
  37869. var b = _.generateStencil ? o.UNSIGNED_INT_24_8 : o.UNSIGNED_INT
  37870. , k = _.generateStencil ? o.DEPTH_STENCIL : o.DEPTH_COMPONENT
  37871. , j = k;
  37872. return this.webGLVersion > 1 && (j = _.generateStencil ? o.DEPTH24_STENCIL8 : o.DEPTH_COMPONENT24),
  37873. d.is2DArray ? o.texImage3D(c, 0, j, d.width, d.height, s, 0, k, b, null) : o.texImage2D(c, 0, j, d.width, d.height, 0, k, b, null),
  37874. this._bindTextureDirectly(c, null),
  37875. this._internalTexturesCache.push(d),
  37876. d
  37877. }
  37878. ;
  37879. ThinEngine.prototype.updateRenderTargetTextureSampleCount = function(a, e) {
  37880. if (this.webGLVersion < 2 || !a || !a.texture)
  37881. return 1;
  37882. if (a.samples === e)
  37883. return e;
  37884. var i = this._gl;
  37885. e = Math.min(e, this.getCaps().maxMSAASamples),
  37886. a._depthStencilBuffer && (i.deleteRenderbuffer(a._depthStencilBuffer),
  37887. a._depthStencilBuffer = null),
  37888. a._MSAAFramebuffer && (i.deleteFramebuffer(a._MSAAFramebuffer),
  37889. a._MSAAFramebuffer = null);
  37890. var o = a.texture._hardwareTexture;
  37891. if (o._MSAARenderBuffer && (i.deleteRenderbuffer(o._MSAARenderBuffer),
  37892. o._MSAARenderBuffer = null),
  37893. e > 1 && i.renderbufferStorageMultisample) {
  37894. var s = i.createFramebuffer();
  37895. if (!s)
  37896. throw new Error("Unable to create multi sampled framebuffer");
  37897. a._MSAAFramebuffer = s,
  37898. this._bindUnboundFramebuffer(a._MSAAFramebuffer);
  37899. var c = this._createRenderBuffer(a.texture.width, a.texture.height, e, -1, this._getRGBAMultiSampleBufferFormat(a.texture.type), i.COLOR_ATTACHMENT0, !1);
  37900. if (!c)
  37901. throw new Error("Unable to create multi sampled framebuffer");
  37902. o._MSAARenderBuffer = c
  37903. } else
  37904. this._bindUnboundFramebuffer(a._framebuffer);
  37905. return a.texture.samples = e,
  37906. a._depthStencilBuffer = this._setupFramebufferDepthAttachments(a._generateStencilBuffer, a._generateDepthBuffer, a.texture.width, a.texture.height, e),
  37907. this._bindUnboundFramebuffer(null),
  37908. e
  37909. }
  37910. ;
  37911. ThinEngine.prototype.createRenderTargetCubeTexture = function(a, e) {
  37912. var i = this._createHardwareRenderTargetWrapper(!1, !0, a)
  37913. , o = __assign({
  37914. generateMipMaps: !0,
  37915. generateDepthBuffer: !0,
  37916. generateStencilBuffer: !1,
  37917. type: 0,
  37918. samplingMode: 3,
  37919. format: 5
  37920. }, e);
  37921. o.generateStencilBuffer = o.generateDepthBuffer && o.generateStencilBuffer,
  37922. (o.type === 1 && !this._caps.textureFloatLinearFiltering || o.type === 2 && !this._caps.textureHalfFloatLinearFiltering) && (o.samplingMode = 1);
  37923. var s = this._gl
  37924. , c = new InternalTexture(this,InternalTextureSource.RenderTarget);
  37925. this._bindTextureDirectly(s.TEXTURE_CUBE_MAP, c, !0);
  37926. var d = this._getSamplingParameters(o.samplingMode, o.generateMipMaps);
  37927. o.type === 1 && !this._caps.textureFloat && (o.type = 0,
  37928. Logger$2.Warn("Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type")),
  37929. s.texParameteri(s.TEXTURE_CUBE_MAP, s.TEXTURE_MAG_FILTER, d.mag),
  37930. s.texParameteri(s.TEXTURE_CUBE_MAP, s.TEXTURE_MIN_FILTER, d.min),
  37931. s.texParameteri(s.TEXTURE_CUBE_MAP, s.TEXTURE_WRAP_S, s.CLAMP_TO_EDGE),
  37932. s.texParameteri(s.TEXTURE_CUBE_MAP, s.TEXTURE_WRAP_T, s.CLAMP_TO_EDGE);
  37933. for (var _ = 0; _ < 6; _++)
  37934. s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X + _, 0, this._getRGBABufferInternalSizedFormat(o.type, o.format), a, a, 0, this._getInternalFormat(o.format), this._getWebGLTextureType(o.type), null);
  37935. var b = s.createFramebuffer();
  37936. return this._bindUnboundFramebuffer(b),
  37937. i._depthStencilBuffer = this._setupFramebufferDepthAttachments(o.generateStencilBuffer, o.generateDepthBuffer, a, a),
  37938. o.generateMipMaps && s.generateMipmap(s.TEXTURE_CUBE_MAP),
  37939. this._bindTextureDirectly(s.TEXTURE_CUBE_MAP, null),
  37940. this._bindUnboundFramebuffer(null),
  37941. i._framebuffer = b,
  37942. i._generateDepthBuffer = o.generateDepthBuffer,
  37943. i._generateStencilBuffer = o.generateStencilBuffer,
  37944. c.width = a,
  37945. c.height = a,
  37946. c.isReady = !0,
  37947. c.isCube = !0,
  37948. c.samples = 1,
  37949. c.generateMipMaps = o.generateMipMaps,
  37950. c.samplingMode = o.samplingMode,
  37951. c.type = o.type,
  37952. c.format = o.format,
  37953. this._internalTexturesCache.push(c),
  37954. i.setTextures(c),
  37955. i
  37956. }
  37957. ;
  37958. var RenderTargetTexture = function(a) {
  37959. __extends(e, a);
  37960. function e(i, o, s, c, d, _, b, k, j, $, _e, et, tt, rt, it) {
  37961. d === void 0 && (d = !0),
  37962. _ === void 0 && (_ = 0),
  37963. b === void 0 && (b = !1),
  37964. k === void 0 && (k = Texture.TRILINEAR_SAMPLINGMODE),
  37965. j === void 0 && (j = !0),
  37966. $ === void 0 && ($ = !1),
  37967. _e === void 0 && (_e = !1),
  37968. et === void 0 && (et = 5),
  37969. tt === void 0 && (tt = !1);
  37970. var nt, ot = a.call(this, null, s, !c, void 0, k, void 0, void 0, void 0, void 0, et) || this;
  37971. if (ot.renderParticles = !0,
  37972. ot.renderSprites = !1,
  37973. ot.ignoreCameraViewport = !1,
  37974. ot.onBeforeBindObservable = new Observable,
  37975. ot.onAfterUnbindObservable = new Observable,
  37976. ot.onBeforeRenderObservable = new Observable,
  37977. ot.onAfterRenderObservable = new Observable,
  37978. ot.onClearObservable = new Observable,
  37979. ot.onResizeObservable = new Observable,
  37980. ot._cleared = !1,
  37981. ot.skipInitialClear = !1,
  37982. ot._currentRefreshId = -1,
  37983. ot._refreshRate = 1,
  37984. ot._samples = 1,
  37985. ot._canRescale = !0,
  37986. ot._renderTarget = null,
  37987. ot.boundingBoxPosition = Vector3.Zero(),
  37988. s = ot.getScene(),
  37989. !s)
  37990. return ot;
  37991. var at = ot.getScene().getEngine();
  37992. return ot._coordinatesMode = Texture.PROJECTION_MODE,
  37993. ot.renderList = new Array,
  37994. ot.name = i,
  37995. ot.isRenderTarget = !0,
  37996. ot._initialSizeParameter = o,
  37997. ot._renderPassIds = [],
  37998. ot.__isCube = b,
  37999. ot._processSizeParameter(o),
  38000. ot.renderPassId = ot._renderPassIds[0],
  38001. ot._resizeObserver = at.onResizeObservable.add(function() {}),
  38002. ot._generateMipMaps = !!c,
  38003. ot._doNotChangeAspectRatio = d,
  38004. ot._renderingManager = new RenderingManager(s),
  38005. ot._renderingManager._useSceneAutoClearSetup = !0,
  38006. _e || (ot._renderTargetOptions = {
  38007. generateMipMaps: c,
  38008. type: _,
  38009. format: (nt = ot._format) !== null && nt !== void 0 ? nt : void 0,
  38010. samplingMode: ot.samplingMode,
  38011. generateDepthBuffer: j,
  38012. generateStencilBuffer: $,
  38013. samples: rt,
  38014. creationFlags: it
  38015. },
  38016. ot.samplingMode === Texture.NEAREST_SAMPLINGMODE && (ot.wrapU = Texture.CLAMP_ADDRESSMODE,
  38017. ot.wrapV = Texture.CLAMP_ADDRESSMODE),
  38018. tt || (b ? (ot._renderTarget = s.getEngine().createRenderTargetCubeTexture(ot.getRenderSize(), ot._renderTargetOptions),
  38019. ot.coordinatesMode = Texture.INVCUBIC_MODE,
  38020. ot._textureMatrix = Matrix.Identity()) : ot._renderTarget = s.getEngine().createRenderTargetTexture(ot._size, ot._renderTargetOptions),
  38021. ot._texture = ot._renderTarget.texture,
  38022. rt !== void 0 && (ot.samples = rt))),
  38023. ot
  38024. }
  38025. return Object.defineProperty(e.prototype, "renderList", {
  38026. get: function() {
  38027. return this._renderList
  38028. },
  38029. set: function(i) {
  38030. this._renderList = i,
  38031. this._renderList && this._hookArray(this._renderList)
  38032. },
  38033. enumerable: !1,
  38034. configurable: !0
  38035. }),
  38036. e.prototype._hookArray = function(i) {
  38037. var o = this
  38038. , s = i.push;
  38039. i.push = function() {
  38040. for (var d, _ = [], b = 0; b < arguments.length; b++)
  38041. _[b] = arguments[b];
  38042. var k = i.length === 0
  38043. , j = s.apply(i, _);
  38044. return k && ((d = o.getScene()) === null || d === void 0 || d.meshes.forEach(function($) {
  38045. $._markSubMeshesAsLightDirty()
  38046. })),
  38047. j
  38048. }
  38049. ;
  38050. var c = i.splice;
  38051. i.splice = function(d, _) {
  38052. var b, k = c.apply(i, [d, _]);
  38053. return i.length === 0 && ((b = o.getScene()) === null || b === void 0 || b.meshes.forEach(function(j) {
  38054. j._markSubMeshesAsLightDirty()
  38055. })),
  38056. k
  38057. }
  38058. }
  38059. ,
  38060. Object.defineProperty(e.prototype, "postProcesses", {
  38061. get: function() {
  38062. return this._postProcesses
  38063. },
  38064. enumerable: !1,
  38065. configurable: !0
  38066. }),
  38067. Object.defineProperty(e.prototype, "_prePassEnabled", {
  38068. get: function() {
  38069. return !!this._prePassRenderTarget && this._prePassRenderTarget.enabled
  38070. },
  38071. enumerable: !1,
  38072. configurable: !0
  38073. }),
  38074. Object.defineProperty(e.prototype, "onAfterUnbind", {
  38075. set: function(i) {
  38076. this._onAfterUnbindObserver && this.onAfterUnbindObservable.remove(this._onAfterUnbindObserver),
  38077. this._onAfterUnbindObserver = this.onAfterUnbindObservable.add(i)
  38078. },
  38079. enumerable: !1,
  38080. configurable: !0
  38081. }),
  38082. Object.defineProperty(e.prototype, "onBeforeRender", {
  38083. set: function(i) {
  38084. this._onBeforeRenderObserver && this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),
  38085. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(i)
  38086. },
  38087. enumerable: !1,
  38088. configurable: !0
  38089. }),
  38090. Object.defineProperty(e.prototype, "onAfterRender", {
  38091. set: function(i) {
  38092. this._onAfterRenderObserver && this.onAfterRenderObservable.remove(this._onAfterRenderObserver),
  38093. this._onAfterRenderObserver = this.onAfterRenderObservable.add(i)
  38094. },
  38095. enumerable: !1,
  38096. configurable: !0
  38097. }),
  38098. Object.defineProperty(e.prototype, "onClear", {
  38099. set: function(i) {
  38100. this._onClearObserver && this.onClearObservable.remove(this._onClearObserver),
  38101. this._onClearObserver = this.onClearObservable.add(i)
  38102. },
  38103. enumerable: !1,
  38104. configurable: !0
  38105. }),
  38106. Object.defineProperty(e.prototype, "renderPassIds", {
  38107. get: function() {
  38108. return this._renderPassIds
  38109. },
  38110. enumerable: !1,
  38111. configurable: !0
  38112. }),
  38113. e.prototype.setMaterialForRendering = function(i, o) {
  38114. var s;
  38115. Array.isArray(i) ? s = i : s = [i];
  38116. for (var c = 0; c < s.length; ++c)
  38117. for (var d = 0; d < this._renderPassIds.length; ++d)
  38118. s[c].setMaterialForRenderPass(this._renderPassIds[d], o !== void 0 ? Array.isArray(o) ? o[d] : o : void 0)
  38119. }
  38120. ,
  38121. Object.defineProperty(e.prototype, "renderTargetOptions", {
  38122. get: function() {
  38123. return this._renderTargetOptions
  38124. },
  38125. enumerable: !1,
  38126. configurable: !0
  38127. }),
  38128. Object.defineProperty(e.prototype, "renderTarget", {
  38129. get: function() {
  38130. return this._renderTarget
  38131. },
  38132. enumerable: !1,
  38133. configurable: !0
  38134. }),
  38135. e.prototype._onRatioRescale = function() {
  38136. this._sizeRatio && this.resize(this._initialSizeParameter)
  38137. }
  38138. ,
  38139. Object.defineProperty(e.prototype, "boundingBoxSize", {
  38140. get: function() {
  38141. return this._boundingBoxSize
  38142. },
  38143. set: function(i) {
  38144. if (!(this._boundingBoxSize && this._boundingBoxSize.equals(i))) {
  38145. this._boundingBoxSize = i;
  38146. var o = this.getScene();
  38147. o && o.markAllMaterialsAsDirty(1)
  38148. }
  38149. },
  38150. enumerable: !1,
  38151. configurable: !0
  38152. }),
  38153. Object.defineProperty(e.prototype, "depthStencilTexture", {
  38154. get: function() {
  38155. var i, o;
  38156. return (o = (i = this._renderTarget) === null || i === void 0 ? void 0 : i._depthStencilTexture) !== null && o !== void 0 ? o : null
  38157. },
  38158. enumerable: !1,
  38159. configurable: !0
  38160. }),
  38161. e.prototype.createDepthStencilTexture = function(i, o, s, c) {
  38162. var d;
  38163. i === void 0 && (i = 0),
  38164. o === void 0 && (o = !0),
  38165. s === void 0 && (s = !1),
  38166. c === void 0 && (c = 1),
  38167. (d = this._renderTarget) === null || d === void 0 || d.createDepthStencilTexture(i, o, s, c)
  38168. }
  38169. ,
  38170. e.prototype._releaseRenderPassId = function() {
  38171. if (this._scene)
  38172. for (var i = this._scene.getEngine(), o = 0; o < this._renderPassIds.length; ++o)
  38173. i.releaseRenderPassId(this._renderPassIds[o]);
  38174. this._renderPassIds = []
  38175. }
  38176. ,
  38177. e.prototype._createRenderPassId = function() {
  38178. this._releaseRenderPassId();
  38179. for (var i = this._scene.getEngine(), o = this.__isCube ? 6 : this.getRenderLayers() || 1, s = 0; s < o; ++s)
  38180. this._renderPassIds[s] = i.createRenderPassId("RenderTargetTexture - " + this.name + "#" + s)
  38181. }
  38182. ,
  38183. e.prototype._processSizeParameter = function(i) {
  38184. if (i.ratio) {
  38185. this._sizeRatio = i.ratio;
  38186. var o = this._getEngine();
  38187. this._size = {
  38188. width: this._bestReflectionRenderTargetDimension(o.getRenderWidth(), this._sizeRatio),
  38189. height: this._bestReflectionRenderTargetDimension(o.getRenderHeight(), this._sizeRatio)
  38190. }
  38191. } else
  38192. this._size = i;
  38193. this._createRenderPassId()
  38194. }
  38195. ,
  38196. Object.defineProperty(e.prototype, "samples", {
  38197. get: function() {
  38198. var i, o;
  38199. return (o = (i = this._renderTarget) === null || i === void 0 ? void 0 : i.samples) !== null && o !== void 0 ? o : this._samples
  38200. },
  38201. set: function(i) {
  38202. this._renderTarget && (this._samples = this._renderTarget.setSamples(i))
  38203. },
  38204. enumerable: !1,
  38205. configurable: !0
  38206. }),
  38207. e.prototype.resetRefreshCounter = function() {
  38208. this._currentRefreshId = -1
  38209. }
  38210. ,
  38211. Object.defineProperty(e.prototype, "refreshRate", {
  38212. get: function() {
  38213. return this._refreshRate
  38214. },
  38215. set: function(i) {
  38216. this._refreshRate = i,
  38217. this.resetRefreshCounter()
  38218. },
  38219. enumerable: !1,
  38220. configurable: !0
  38221. }),
  38222. e.prototype.addPostProcess = function(i) {
  38223. if (!this._postProcessManager) {
  38224. var o = this.getScene();
  38225. if (!o)
  38226. return;
  38227. this._postProcessManager = new PostProcessManager(o),
  38228. this._postProcesses = new Array
  38229. }
  38230. this._postProcesses.push(i),
  38231. this._postProcesses[0].autoClear = !1
  38232. }
  38233. ,
  38234. e.prototype.clearPostProcesses = function(i) {
  38235. if (i === void 0 && (i = !1),
  38236. !!this._postProcesses) {
  38237. if (i)
  38238. for (var o = 0, s = this._postProcesses; o < s.length; o++) {
  38239. var c = s[o];
  38240. c.dispose()
  38241. }
  38242. this._postProcesses = []
  38243. }
  38244. }
  38245. ,
  38246. e.prototype.removePostProcess = function(i) {
  38247. if (!!this._postProcesses) {
  38248. var o = this._postProcesses.indexOf(i);
  38249. o !== -1 && (this._postProcesses.splice(o, 1),
  38250. this._postProcesses.length > 0 && (this._postProcesses[0].autoClear = !1))
  38251. }
  38252. }
  38253. ,
  38254. e.prototype._shouldRender = function() {
  38255. return this._currentRefreshId === -1 ? (this._currentRefreshId = 1,
  38256. !0) : this.refreshRate === this._currentRefreshId ? (this._currentRefreshId = 1,
  38257. !0) : (this._currentRefreshId++,
  38258. !1)
  38259. }
  38260. ,
  38261. e.prototype.getRenderSize = function() {
  38262. return this.getRenderWidth()
  38263. }
  38264. ,
  38265. e.prototype.getRenderWidth = function() {
  38266. return this._size.width ? this._size.width : this._size
  38267. }
  38268. ,
  38269. e.prototype.getRenderHeight = function() {
  38270. return this._size.width ? this._size.height : this._size
  38271. }
  38272. ,
  38273. e.prototype.getRenderLayers = function() {
  38274. var i = this._size.layers;
  38275. return i || 0
  38276. }
  38277. ,
  38278. e.prototype.disableRescaling = function() {
  38279. this._canRescale = !1
  38280. }
  38281. ,
  38282. Object.defineProperty(e.prototype, "canRescale", {
  38283. get: function() {
  38284. return this._canRescale
  38285. },
  38286. enumerable: !1,
  38287. configurable: !0
  38288. }),
  38289. e.prototype.scale = function(i) {
  38290. var o = Math.max(1, this.getRenderSize() * i);
  38291. this.resize(o)
  38292. }
  38293. ,
  38294. e.prototype.getReflectionTextureMatrix = function() {
  38295. return this.isCube ? this._textureMatrix : a.prototype.getReflectionTextureMatrix.call(this)
  38296. }
  38297. ,
  38298. e.prototype.resize = function(i) {
  38299. var o, s = this.isCube;
  38300. (o = this._renderTarget) === null || o === void 0 || o.dispose(),
  38301. this._renderTarget = null;
  38302. var c = this.getScene();
  38303. !c || (this._processSizeParameter(i),
  38304. s ? this._renderTarget = c.getEngine().createRenderTargetCubeTexture(this.getRenderSize(), this._renderTargetOptions) : this._renderTarget = c.getEngine().createRenderTargetTexture(this._size, this._renderTargetOptions),
  38305. this._texture = this._renderTarget.texture,
  38306. this._renderTargetOptions.samples !== void 0 && (this.samples = this._renderTargetOptions.samples),
  38307. this.onResizeObservable.hasObservers() && this.onResizeObservable.notifyObservers(this))
  38308. }
  38309. ,
  38310. e.prototype.render = function(i, o) {
  38311. i === void 0 && (i = !1),
  38312. o === void 0 && (o = !1),
  38313. this._render(i, o)
  38314. }
  38315. ,
  38316. e.prototype.isReadyForRendering = function() {
  38317. return this._render(!1, !1, !0)
  38318. }
  38319. ,
  38320. e.prototype._render = function(i, o, s) {
  38321. var c;
  38322. i === void 0 && (i = !1),
  38323. o === void 0 && (o = !1),
  38324. s === void 0 && (s = !1);
  38325. var d = this.getScene();
  38326. if (!d)
  38327. return s;
  38328. var _ = d.getEngine();
  38329. if (this.useCameraPostProcesses !== void 0 && (i = this.useCameraPostProcesses),
  38330. this._waitingRenderList) {
  38331. this.renderList = [];
  38332. for (var b = 0; b < this._waitingRenderList.length; b++) {
  38333. var k = this._waitingRenderList[b]
  38334. , j = d.getMeshById(k);
  38335. j && this.renderList.push(j)
  38336. }
  38337. this._waitingRenderList = void 0
  38338. }
  38339. if (this.renderListPredicate) {
  38340. this.renderList ? this.renderList.length = 0 : this.renderList = [];
  38341. var d = this.getScene();
  38342. if (!d)
  38343. return s;
  38344. for (var $ = d.meshes, b = 0; b < $.length; b++) {
  38345. var _e = $[b];
  38346. this.renderListPredicate(_e) && this.renderList.push(_e)
  38347. }
  38348. }
  38349. var et = _.currentRenderPassId;
  38350. this.onBeforeBindObservable.notifyObservers(this);
  38351. var tt = (c = this.activeCamera) !== null && c !== void 0 ? c : d.activeCamera;
  38352. tt && (tt !== d.activeCamera && d.setTransformMatrix(tt.getViewMatrix(), tt.getProjectionMatrix(!0)),
  38353. _.setViewport(tt.viewport, this.getRenderWidth(), this.getRenderHeight())),
  38354. this._defaultRenderListPrepared = !1;
  38355. var rt = s;
  38356. if (s) {
  38357. d.getViewMatrix() || d.updateTransformMatrix();
  38358. for (var ot = this.is2DArray ? this.getRenderLayers() : this.isCube ? 6 : 1, it = 0; it < ot && rt; it++) {
  38359. var at = null
  38360. , st = this.renderList ? this.renderList : d.getActiveMeshes().data
  38361. , ut = this.renderList ? this.renderList.length : d.getActiveMeshes().length;
  38362. _.currentRenderPassId = this._renderPassIds[it],
  38363. this.onBeforeRenderObservable.notifyObservers(it),
  38364. this.getCustomRenderList && (at = this.getCustomRenderList(it, st, ut)),
  38365. at || (at = st),
  38366. this._doNotChangeAspectRatio || d.updateTransformMatrix(!0);
  38367. for (var ct = 0; ct < at.length && rt; ++ct) {
  38368. var lt = at[ct];
  38369. if (!(!lt.isEnabled() || lt.isBlocked || !lt.isVisible || !lt.subMeshes)) {
  38370. if (this.customIsReadyFunction) {
  38371. if (!this.customIsReadyFunction(lt, this.refreshRate)) {
  38372. rt = !1;
  38373. break
  38374. }
  38375. } else if (!lt.isReady(!0)) {
  38376. rt = !1;
  38377. break
  38378. }
  38379. }
  38380. }
  38381. this.onAfterRenderObservable.notifyObservers(it)
  38382. }
  38383. } else if (this.is2DArray)
  38384. for (var it = 0; it < this.getRenderLayers(); it++)
  38385. this.renderToTarget(0, i, o, it, tt),
  38386. d.incrementRenderId(),
  38387. d.resetCachedMaterial();
  38388. else if (this.isCube)
  38389. for (var nt = 0; nt < 6; nt++)
  38390. this.renderToTarget(nt, i, o, void 0, tt),
  38391. d.incrementRenderId(),
  38392. d.resetCachedMaterial();
  38393. else
  38394. this.renderToTarget(0, i, o, void 0, tt);
  38395. return this.onAfterUnbindObservable.notifyObservers(this),
  38396. _.currentRenderPassId = et,
  38397. d.activeCamera && ((d.getEngine().scenes.length > 1 || this.activeCamera && this.activeCamera !== d.activeCamera) && d.setTransformMatrix(d.activeCamera.getViewMatrix(), d.activeCamera.getProjectionMatrix(!0)),
  38398. _.setViewport(d.activeCamera.viewport)),
  38399. d.resetCachedMaterial(),
  38400. rt
  38401. }
  38402. ,
  38403. e.prototype._bestReflectionRenderTargetDimension = function(i, o) {
  38404. var s = 128
  38405. , c = i * o
  38406. , d = Engine.NearestPOT(c + s * s / (s + c));
  38407. return Math.min(Engine.FloorPOT(i), d)
  38408. }
  38409. ,
  38410. e.prototype._prepareRenderingManager = function(i, o, s, c) {
  38411. var d = this.getScene();
  38412. if (!!d) {
  38413. this._renderingManager.reset();
  38414. for (var _ = d.getRenderId(), b = 0; b < o; b++) {
  38415. var k = i[b];
  38416. if (k && !k.isBlocked) {
  38417. if (this.customIsReadyFunction) {
  38418. if (!this.customIsReadyFunction(k, this.refreshRate)) {
  38419. this.resetRefreshCounter();
  38420. continue
  38421. }
  38422. } else if (!k.isReady(this.refreshRate === 0)) {
  38423. this.resetRefreshCounter();
  38424. continue
  38425. }
  38426. if (!k._internalAbstractMeshDataInfo._currentLODIsUpToDate && d.activeCamera && (k._internalAbstractMeshDataInfo._currentLOD = d.customLODSelector ? d.customLODSelector(k, this.activeCamera || d.activeCamera) : k.getLOD(this.activeCamera || d.activeCamera),
  38427. k._internalAbstractMeshDataInfo._currentLODIsUpToDate = !0),
  38428. !k._internalAbstractMeshDataInfo._currentLOD)
  38429. continue;
  38430. var j = k._internalAbstractMeshDataInfo._currentLOD;
  38431. j._preActivateForIntermediateRendering(_);
  38432. var $ = void 0;
  38433. if (c && s ? $ = (k.layerMask & s.layerMask) === 0 : $ = !1,
  38434. k.isEnabled() && k.isVisible && k.subMeshes && !$ && (j !== k && j._activate(_, !0),
  38435. k._activate(_, !0) && k.subMeshes.length)) {
  38436. k.isAnInstance ? k._internalAbstractMeshDataInfo._actAsRegularMesh && (j = k) : j._internalAbstractMeshDataInfo._onlyForInstancesIntermediate = !1,
  38437. j._internalAbstractMeshDataInfo._isActiveIntermediate = !0;
  38438. for (var _e = 0; _e < j.subMeshes.length; _e++) {
  38439. var et = j.subMeshes[_e];
  38440. this._renderingManager.dispatch(et, j)
  38441. }
  38442. }
  38443. }
  38444. }
  38445. for (var tt = 0; tt < d.particleSystems.length; tt++) {
  38446. var rt = d.particleSystems[tt]
  38447. , it = rt.emitter;
  38448. !rt.isStarted() || !it || !it.position || !it.isEnabled() || i.indexOf(it) >= 0 && this._renderingManager.dispatchParticles(rt)
  38449. }
  38450. }
  38451. }
  38452. ,
  38453. e.prototype._bindFrameBuffer = function(i, o) {
  38454. i === void 0 && (i = 0),
  38455. o === void 0 && (o = 0);
  38456. var s = this.getScene();
  38457. if (!!s) {
  38458. var c = s.getEngine();
  38459. this._renderTarget && c.bindFramebuffer(this._renderTarget, this.isCube ? i : void 0, void 0, void 0, this.ignoreCameraViewport, 0, o)
  38460. }
  38461. }
  38462. ,
  38463. e.prototype.unbindFrameBuffer = function(i, o) {
  38464. var s = this;
  38465. !this._renderTarget || i.unBindFramebuffer(this._renderTarget, this.isCube, function() {
  38466. s.onAfterRenderObservable.notifyObservers(o)
  38467. })
  38468. }
  38469. ,
  38470. e.prototype._prepareFrame = function(i, o, s, c) {
  38471. this._postProcessManager ? this._prePassEnabled || this._postProcessManager._prepareFrame(this._texture, this._postProcesses) : (!c || !i.postProcessManager._prepareFrame(this._texture)) && this._bindFrameBuffer(o, s)
  38472. }
  38473. ,
  38474. e.prototype.renderToTarget = function(i, o, s, c, d) {
  38475. var _, b, k, j;
  38476. c === void 0 && (c = 0),
  38477. d === void 0 && (d = null);
  38478. var $ = this.getScene();
  38479. if (!!$) {
  38480. var _e = $.getEngine();
  38481. if (!!this._texture) {
  38482. (_ = _e._debugPushGroup) === null || _ === void 0 || _.call(_e, "render to face #" + i + " layer #" + c, 1),
  38483. this._prepareFrame($, i, c, o),
  38484. this.is2DArray ? (_e.currentRenderPassId = this._renderPassIds[c],
  38485. this.onBeforeRenderObservable.notifyObservers(c)) : (_e.currentRenderPassId = this._renderPassIds[i],
  38486. this.onBeforeRenderObservable.notifyObservers(i));
  38487. var et = _e.snapshotRendering && _e.snapshotRenderingMode === 1;
  38488. if (et)
  38489. this.onClearObservable.hasObservers() ? this.onClearObservable.notifyObservers(_e) : this.skipInitialClear || _e.clear(this.clearColor || $.clearColor, !0, !0, !0);
  38490. else {
  38491. var tt = null
  38492. , rt = this.renderList ? this.renderList : $.getActiveMeshes().data
  38493. , it = this.renderList ? this.renderList.length : $.getActiveMeshes().length;
  38494. this.getCustomRenderList && (tt = this.getCustomRenderList(this.is2DArray ? c : i, rt, it)),
  38495. tt ? this._prepareRenderingManager(tt, tt.length, d, !1) : (this._defaultRenderListPrepared || (this._prepareRenderingManager(rt, it, d, !this.renderList),
  38496. this._defaultRenderListPrepared = !0),
  38497. tt = rt);
  38498. for (var nt = 0, ot = $._beforeRenderTargetClearStage; nt < ot.length; nt++) {
  38499. var at = ot[nt];
  38500. at.action(this, i, c)
  38501. }
  38502. this.onClearObservable.hasObservers() ? this.onClearObservable.notifyObservers(_e) : this.skipInitialClear || _e.clear(this.clearColor || $.clearColor, !0, !0, !0),
  38503. this._doNotChangeAspectRatio || $.updateTransformMatrix(!0);
  38504. for (var st = 0, ut = $._beforeRenderTargetDrawStage; st < ut.length; st++) {
  38505. var at = ut[st];
  38506. at.action(this, i, c)
  38507. }
  38508. this._renderingManager.render(this.customRenderFunction, tt, this.renderParticles, this.renderSprites);
  38509. for (var ct = 0, lt = $._afterRenderTargetDrawStage; ct < lt.length; ct++) {
  38510. var at = lt[ct];
  38511. at.action(this, i, c)
  38512. }
  38513. var ft = this._texture.generateMipMaps;
  38514. this._texture.generateMipMaps = !1,
  38515. this._postProcessManager ? this._postProcessManager._finalizeFrame(!1, (b = this._renderTarget) !== null && b !== void 0 ? b : void 0, i, this._postProcesses, this.ignoreCameraViewport) : o && $.postProcessManager._finalizeFrame(!1, (k = this._renderTarget) !== null && k !== void 0 ? k : void 0, i),
  38516. this._texture.generateMipMaps = ft,
  38517. this._doNotChangeAspectRatio || $.updateTransformMatrix(!0),
  38518. s && Tools.DumpFramebuffer(this.getRenderWidth(), this.getRenderHeight(), _e)
  38519. }
  38520. this.unbindFrameBuffer(_e, i),
  38521. this.isCube && i === 5 && _e.generateMipMapsForCubemap(this._texture),
  38522. (j = _e._debugPopGroup) === null || j === void 0 || j.call(_e, 1)
  38523. }
  38524. }
  38525. }
  38526. ,
  38527. e.prototype.setRenderingOrder = function(i, o, s, c) {
  38528. o === void 0 && (o = null),
  38529. s === void 0 && (s = null),
  38530. c === void 0 && (c = null),
  38531. this._renderingManager.setRenderingOrder(i, o, s, c)
  38532. }
  38533. ,
  38534. e.prototype.setRenderingAutoClearDepthStencil = function(i, o) {
  38535. this._renderingManager.setRenderingAutoClearDepthStencil(i, o),
  38536. this._renderingManager._useSceneAutoClearSetup = !1
  38537. }
  38538. ,
  38539. e.prototype.clone = function() {
  38540. var i = this.getSize()
  38541. , o = new e(this.name,i,this.getScene(),this._renderTargetOptions.generateMipMaps,this._doNotChangeAspectRatio,this._renderTargetOptions.type,this.isCube,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer,this._renderTargetOptions.generateStencilBuffer,void 0,this._renderTargetOptions.format,void 0,this._renderTargetOptions.samples);
  38542. return o.hasAlpha = this.hasAlpha,
  38543. o.level = this.level,
  38544. o.coordinatesMode = this.coordinatesMode,
  38545. this.renderList && (o.renderList = this.renderList.slice(0)),
  38546. o
  38547. }
  38548. ,
  38549. e.prototype.serialize = function() {
  38550. if (!this.name)
  38551. return null;
  38552. var i = a.prototype.serialize.call(this);
  38553. if (i.renderTargetSize = this.getRenderSize(),
  38554. i.renderList = [],
  38555. this.renderList)
  38556. for (var o = 0; o < this.renderList.length; o++)
  38557. i.renderList.push(this.renderList[o].id);
  38558. return i
  38559. }
  38560. ,
  38561. e.prototype.disposeFramebufferObjects = function() {
  38562. var i;
  38563. (i = this._renderTarget) === null || i === void 0 || i.dispose(!0)
  38564. }
  38565. ,
  38566. e.prototype.releaseInternalTexture = function() {
  38567. var i;
  38568. (i = this._renderTarget) === null || i === void 0 || i.releaseTextures(),
  38569. this._texture = null
  38570. }
  38571. ,
  38572. e.prototype.dispose = function() {
  38573. var i;
  38574. this.onResizeObservable.clear(),
  38575. this.onClearObservable.clear(),
  38576. this.onAfterRenderObservable.clear(),
  38577. this.onAfterUnbindObservable.clear(),
  38578. this.onBeforeBindObservable.clear(),
  38579. this.onBeforeRenderObservable.clear(),
  38580. this._postProcessManager && (this._postProcessManager.dispose(),
  38581. this._postProcessManager = null),
  38582. this._prePassRenderTarget && this._prePassRenderTarget.dispose(),
  38583. this._releaseRenderPassId(),
  38584. this.clearPostProcesses(!0),
  38585. this._resizeObserver && (this.getScene().getEngine().onResizeObservable.remove(this._resizeObserver),
  38586. this._resizeObserver = null),
  38587. this.renderList = null;
  38588. var o = this.getScene();
  38589. if (!!o) {
  38590. var s = o.customRenderTargets.indexOf(this);
  38591. s >= 0 && o.customRenderTargets.splice(s, 1);
  38592. for (var c = 0, d = o.cameras; c < d.length; c++) {
  38593. var _ = d[c];
  38594. s = _.customRenderTargets.indexOf(this),
  38595. s >= 0 && _.customRenderTargets.splice(s, 1)
  38596. }
  38597. (i = this._renderTarget) === null || i === void 0 || i.dispose(),
  38598. this._renderTarget = null,
  38599. this._texture = null,
  38600. a.prototype.dispose.call(this)
  38601. }
  38602. }
  38603. ,
  38604. e.prototype._rebuild = function() {
  38605. this.refreshRate === e.REFRESHRATE_RENDER_ONCE && (this.refreshRate = e.REFRESHRATE_RENDER_ONCE),
  38606. this._postProcessManager && this._postProcessManager._rebuild()
  38607. }
  38608. ,
  38609. e.prototype.freeRenderingGroups = function() {
  38610. this._renderingManager && this._renderingManager.freeRenderingGroups()
  38611. }
  38612. ,
  38613. e.prototype.getViewCount = function() {
  38614. return 1
  38615. }
  38616. ,
  38617. e.REFRESHRATE_RENDER_ONCE = 0,
  38618. e.REFRESHRATE_RENDER_ONEVERYFRAME = 1,
  38619. e.REFRESHRATE_RENDER_ONEVERYTWOFRAMES = 2,
  38620. e
  38621. }(Texture);
  38622. Texture._CreateRenderTargetTexture = function(a, e, i, o, s) {
  38623. return new RenderTargetTexture(a,e,i,o)
  38624. }
  38625. ;
  38626. var MultiviewRenderTarget = function(a) {
  38627. __extends(e, a);
  38628. function e(i, o) {
  38629. o === void 0 && (o = 512);
  38630. var s = a.call(this, "multiview rtt", o, i, !1, !0, 0, !1, void 0, !1, !1, !0, void 0, !0) || this
  38631. , c = i.getEngine().createMultiviewRenderTargetTexture(s.getRenderWidth(), s.getRenderHeight());
  38632. return s._texture = c.texture,
  38633. s._texture.isMultiview = !0,
  38634. s._texture.format = 5,
  38635. s.samples = s._getEngine().getCaps().maxSamples || s.samples,
  38636. s
  38637. }
  38638. return e.prototype._bindFrameBuffer = function(i) {
  38639. !this._renderTarget || this.getScene().getEngine().bindMultiviewFramebuffer(this._renderTarget)
  38640. }
  38641. ,
  38642. e.prototype.getViewCount = function() {
  38643. return 2
  38644. }
  38645. ,
  38646. e
  38647. }(RenderTargetTexture);
  38648. Engine.prototype.createMultiviewRenderTargetTexture = function(a, e) {
  38649. var i = this._gl;
  38650. if (!this.getCaps().multiview)
  38651. throw "Multiview is not supported";
  38652. var o = this._createHardwareRenderTargetWrapper(!1, !1, {
  38653. width: a,
  38654. height: e
  38655. });
  38656. o._framebuffer = i.createFramebuffer();
  38657. var s = new InternalTexture(this,InternalTextureSource.Unknown,!0);
  38658. return s.width = a,
  38659. s.height = e,
  38660. o._colorTextureArray = i.createTexture(),
  38661. i.bindTexture(i.TEXTURE_2D_ARRAY, o._colorTextureArray),
  38662. i.texStorage3D(i.TEXTURE_2D_ARRAY, 1, i.RGBA8, a, e, 2),
  38663. o._depthStencilTextureArray = i.createTexture(),
  38664. i.bindTexture(i.TEXTURE_2D_ARRAY, o._depthStencilTextureArray),
  38665. i.texStorage3D(i.TEXTURE_2D_ARRAY, 1, i.DEPTH32F_STENCIL8, a, e, 2),
  38666. s.isReady = !0,
  38667. o.setTextures(s),
  38668. o
  38669. }
  38670. ;
  38671. Engine.prototype.bindMultiviewFramebuffer = function(a) {
  38672. var e = a
  38673. , i = this._gl
  38674. , o = this.getCaps().oculusMultiview || this.getCaps().multiview;
  38675. if (this.bindFramebuffer(e, void 0, void 0, void 0, !0),
  38676. i.bindFramebuffer(i.DRAW_FRAMEBUFFER, e._framebuffer),
  38677. e._colorTextureArray && e._depthStencilTextureArray)
  38678. this.getCaps().oculusMultiview ? (o.framebufferTextureMultisampleMultiviewOVR(i.DRAW_FRAMEBUFFER, i.COLOR_ATTACHMENT0, e._colorTextureArray, 0, e.samples, 0, 2),
  38679. o.framebufferTextureMultisampleMultiviewOVR(i.DRAW_FRAMEBUFFER, i.DEPTH_STENCIL_ATTACHMENT, e._depthStencilTextureArray, 0, e.samples, 0, 2)) : (o.framebufferTextureMultiviewOVR(i.DRAW_FRAMEBUFFER, i.COLOR_ATTACHMENT0, e._colorTextureArray, 0, 0, 2),
  38680. o.framebufferTextureMultiviewOVR(i.DRAW_FRAMEBUFFER, i.DEPTH_STENCIL_ATTACHMENT, e._depthStencilTextureArray, 0, 0, 2));
  38681. else
  38682. throw "Invalid multiview frame buffer"
  38683. }
  38684. ;
  38685. Camera$1.prototype._useMultiviewToSingleView = !1;
  38686. Camera$1.prototype._multiviewTexture = null;
  38687. Camera$1.prototype._resizeOrCreateMultiviewTexture = function(a, e) {
  38688. this._multiviewTexture ? (this._multiviewTexture.getRenderWidth() != a || this._multiviewTexture.getRenderHeight() != e) && (this._multiviewTexture.dispose(),
  38689. this._multiviewTexture = new MultiviewRenderTarget(this.getScene(),{
  38690. width: a,
  38691. height: e
  38692. })) : this._multiviewTexture = new MultiviewRenderTarget(this.getScene(),{
  38693. width: a,
  38694. height: e
  38695. })
  38696. }
  38697. ;
  38698. function createMultiviewUbo(a, e) {
  38699. var i = new UniformBuffer(a,void 0,!0,e);
  38700. return i.addUniform("viewProjection", 16),
  38701. i.addUniform("viewProjectionR", 16),
  38702. i.addUniform("view", 16),
  38703. i.addUniform("projection", 16),
  38704. i.addUniform("viewPosition", 4),
  38705. i
  38706. }
  38707. var currentCreateSceneUniformBuffer = Scene.prototype.createSceneUniformBuffer;
  38708. Scene.prototype._transformMatrixR = Matrix.Zero();
  38709. Scene.prototype._multiviewSceneUbo = null;
  38710. Scene.prototype._createMultiviewUbo = function() {
  38711. this._multiviewSceneUbo = createMultiviewUbo(this.getEngine(), "scene_multiview")
  38712. }
  38713. ;
  38714. Scene.prototype.createSceneUniformBuffer = function(a) {
  38715. return this._multiviewSceneUbo ? createMultiviewUbo(this.getEngine(), a) : currentCreateSceneUniformBuffer.bind(this)(a)
  38716. }
  38717. ;
  38718. Scene.prototype._updateMultiviewUbo = function(a, e) {
  38719. a && e && a.multiplyToRef(e, this._transformMatrixR),
  38720. a && e && (a.multiplyToRef(e, TmpVectors.Matrix[0]),
  38721. Frustum.GetRightPlaneToRef(TmpVectors.Matrix[0], this._frustumPlanes[3])),
  38722. this._multiviewSceneUbo && (this._multiviewSceneUbo.updateMatrix("viewProjection", this.getTransformMatrix()),
  38723. this._multiviewSceneUbo.updateMatrix("viewProjectionR", this._transformMatrixR),
  38724. this._multiviewSceneUbo.updateMatrix("view", this._viewMatrix),
  38725. this._multiviewSceneUbo.updateMatrix("projection", this._projectionMatrix))
  38726. }
  38727. ;
  38728. Scene.prototype._renderMultiviewToSingleView = function(a) {
  38729. a._resizeOrCreateMultiviewTexture(a._rigPostProcess && a._rigPostProcess && a._rigPostProcess.width > 0 ? a._rigPostProcess.width : this.getEngine().getRenderWidth(!0), a._rigPostProcess && a._rigPostProcess && a._rigPostProcess.height > 0 ? a._rigPostProcess.height : this.getEngine().getRenderHeight(!0)),
  38730. this._multiviewSceneUbo || this._createMultiviewUbo(),
  38731. a.outputRenderTarget = a._multiviewTexture,
  38732. this._renderForCamera(a),
  38733. a.outputRenderTarget = null;
  38734. for (var e = 0; e < a._rigCameras.length; e++) {
  38735. var i = this.getEngine();
  38736. this._activeCamera = a._rigCameras[e],
  38737. i.setViewport(this._activeCamera.viewport),
  38738. this.postProcessManager && (this.postProcessManager._prepareFrame(),
  38739. this.postProcessManager._finalizeFrame(this._activeCamera.isIntermediate))
  38740. }
  38741. }
  38742. ;
  38743. ThinEngine.prototype.updateRawTexture = function(a, e, i, o, s, c) {
  38744. if (s === void 0 && (s = null),
  38745. c === void 0 && (c = 0),
  38746. !!a) {
  38747. var d = this._getRGBABufferInternalSizedFormat(c, i)
  38748. , _ = this._getInternalFormat(i)
  38749. , b = this._getWebGLTextureType(c);
  38750. this._bindTextureDirectly(this._gl.TEXTURE_2D, a, !0),
  38751. this._unpackFlipY(o === void 0 ? !0 : !!o),
  38752. this._doNotHandleContextLost || (a._bufferView = e,
  38753. a.format = i,
  38754. a.type = c,
  38755. a.invertY = o,
  38756. a._compression = s),
  38757. a.width % 4 !== 0 && this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1),
  38758. s && e ? this._gl.compressedTexImage2D(this._gl.TEXTURE_2D, 0, this.getCaps().s3tc[s], a.width, a.height, 0, e) : this._gl.texImage2D(this._gl.TEXTURE_2D, 0, d, a.width, a.height, 0, _, b, e),
  38759. a.generateMipMaps && this._gl.generateMipmap(this._gl.TEXTURE_2D),
  38760. this._bindTextureDirectly(this._gl.TEXTURE_2D, null),
  38761. a.isReady = !0
  38762. }
  38763. }
  38764. ;
  38765. ThinEngine.prototype.createRawTexture = function(a, e, i, o, s, c, d, _, b, k) {
  38766. _ === void 0 && (_ = null),
  38767. b === void 0 && (b = 0);
  38768. var j = new InternalTexture(this,InternalTextureSource.Raw);
  38769. j.baseWidth = e,
  38770. j.baseHeight = i,
  38771. j.width = e,
  38772. j.height = i,
  38773. j.format = o,
  38774. j.generateMipMaps = s,
  38775. j.samplingMode = d,
  38776. j.invertY = c,
  38777. j._compression = _,
  38778. j.type = b,
  38779. this._doNotHandleContextLost || (j._bufferView = a),
  38780. this.updateRawTexture(j, a, o, c, _, b),
  38781. this._bindTextureDirectly(this._gl.TEXTURE_2D, j, !0);
  38782. var $ = this._getSamplingParameters(d, s);
  38783. return this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, $.mag),
  38784. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, $.min),
  38785. s && this._gl.generateMipmap(this._gl.TEXTURE_2D),
  38786. this._bindTextureDirectly(this._gl.TEXTURE_2D, null),
  38787. this._internalTexturesCache.push(j),
  38788. j
  38789. }
  38790. ;
  38791. ThinEngine.prototype.createRawCubeTexture = function(a, e, i, o, s, c, d, _) {
  38792. _ === void 0 && (_ = null);
  38793. var b = this._gl
  38794. , k = new InternalTexture(this,InternalTextureSource.CubeRaw);
  38795. k.isCube = !0,
  38796. k.format = i,
  38797. k.type = o,
  38798. this._doNotHandleContextLost || (k._bufferViewArray = a);
  38799. var j = this._getWebGLTextureType(o)
  38800. , $ = this._getInternalFormat(i);
  38801. $ === b.RGB && ($ = b.RGBA),
  38802. j === b.FLOAT && !this._caps.textureFloatLinearFiltering ? (s = !1,
  38803. d = 1,
  38804. Logger$2.Warn("Float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.")) : j === this._gl.HALF_FLOAT_OES && !this._caps.textureHalfFloatLinearFiltering ? (s = !1,
  38805. d = 1,
  38806. Logger$2.Warn("Half float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.")) : j === b.FLOAT && !this._caps.textureFloatRender ? (s = !1,
  38807. Logger$2.Warn("Render to float textures is not supported. Mipmap generation forced to false.")) : j === b.HALF_FLOAT && !this._caps.colorBufferFloat && (s = !1,
  38808. Logger$2.Warn("Render to half float textures is not supported. Mipmap generation forced to false."));
  38809. var _e = e
  38810. , et = _e;
  38811. k.width = _e,
  38812. k.height = et;
  38813. var tt = !this.needPOTTextures || Tools.IsExponentOfTwo(k.width) && Tools.IsExponentOfTwo(k.height);
  38814. tt || (s = !1),
  38815. a && this.updateRawCubeTexture(k, a, i, o, c, _),
  38816. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, k, !0),
  38817. a && s && this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);
  38818. var rt = this._getSamplingParameters(d, s);
  38819. return b.texParameteri(b.TEXTURE_CUBE_MAP, b.TEXTURE_MAG_FILTER, rt.mag),
  38820. b.texParameteri(b.TEXTURE_CUBE_MAP, b.TEXTURE_MIN_FILTER, rt.min),
  38821. b.texParameteri(b.TEXTURE_CUBE_MAP, b.TEXTURE_WRAP_S, b.CLAMP_TO_EDGE),
  38822. b.texParameteri(b.TEXTURE_CUBE_MAP, b.TEXTURE_WRAP_T, b.CLAMP_TO_EDGE),
  38823. this._bindTextureDirectly(b.TEXTURE_CUBE_MAP, null),
  38824. k.generateMipMaps = s,
  38825. k.samplingMode = d,
  38826. k
  38827. }
  38828. ;
  38829. ThinEngine.prototype.updateRawCubeTexture = function(a, e, i, o, s, c, d) {
  38830. c === void 0 && (c = null),
  38831. d === void 0 && (d = 0),
  38832. a._bufferViewArray = e,
  38833. a.format = i,
  38834. a.type = o,
  38835. a.invertY = s,
  38836. a._compression = c;
  38837. var _ = this._gl
  38838. , b = this._getWebGLTextureType(o)
  38839. , k = this._getInternalFormat(i)
  38840. , j = this._getRGBABufferInternalSizedFormat(o)
  38841. , $ = !1;
  38842. k === _.RGB && (k = _.RGBA,
  38843. $ = !0),
  38844. this._bindTextureDirectly(_.TEXTURE_CUBE_MAP, a, !0),
  38845. this._unpackFlipY(s === void 0 ? !0 : !!s),
  38846. a.width % 4 !== 0 && _.pixelStorei(_.UNPACK_ALIGNMENT, 1);
  38847. for (var _e = 0; _e < 6; _e++) {
  38848. var et = e[_e];
  38849. c ? _.compressedTexImage2D(_.TEXTURE_CUBE_MAP_POSITIVE_X + _e, d, this.getCaps().s3tc[c], a.width, a.height, 0, et) : ($ && (et = _convertRGBtoRGBATextureData$1(et, a.width, a.height, o)),
  38850. _.texImage2D(_.TEXTURE_CUBE_MAP_POSITIVE_X + _e, d, j, a.width, a.height, 0, k, b, et))
  38851. }
  38852. var tt = !this.needPOTTextures || Tools.IsExponentOfTwo(a.width) && Tools.IsExponentOfTwo(a.height);
  38853. tt && a.generateMipMaps && d === 0 && this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP),
  38854. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null),
  38855. a.isReady = !0
  38856. }
  38857. ;
  38858. ThinEngine.prototype.createRawCubeTextureFromUrl = function(a, e, i, o, s, c, d, _, b, k, j, $) {
  38859. var _e = this;
  38860. b === void 0 && (b = null),
  38861. k === void 0 && (k = null),
  38862. j === void 0 && (j = 3),
  38863. $ === void 0 && ($ = !1);
  38864. var et = this._gl
  38865. , tt = this.createRawCubeTexture(null, i, o, s, !c, $, j, null);
  38866. e == null || e._addPendingData(tt),
  38867. tt.url = a,
  38868. this._internalTexturesCache.push(tt);
  38869. var rt = function(nt, ot) {
  38870. e == null || e._removePendingData(tt),
  38871. k && nt && k(nt.status + " " + nt.statusText, ot)
  38872. }
  38873. , it = function(nt) {
  38874. var ot = tt.width
  38875. , at = d(nt);
  38876. if (!!at) {
  38877. if (_) {
  38878. var st = _e._getWebGLTextureType(s)
  38879. , ut = _e._getInternalFormat(o)
  38880. , ct = _e._getRGBABufferInternalSizedFormat(s)
  38881. , lt = !1;
  38882. ut === et.RGB && (ut = et.RGBA,
  38883. lt = !0),
  38884. _e._bindTextureDirectly(et.TEXTURE_CUBE_MAP, tt, !0),
  38885. _e._unpackFlipY(!1);
  38886. for (var ft = _(at), ht = 0; ht < ft.length; ht++)
  38887. for (var pt = ot >> ht, dt = 0; dt < 6; dt++) {
  38888. var _t = ft[ht][dt];
  38889. lt && (_t = _convertRGBtoRGBATextureData$1(_t, pt, pt, s)),
  38890. et.texImage2D(dt, ht, ct, pt, pt, 0, ut, st, _t)
  38891. }
  38892. _e._bindTextureDirectly(et.TEXTURE_CUBE_MAP, null)
  38893. } else
  38894. _e.updateRawCubeTexture(tt, at, o, s, $);
  38895. tt.isReady = !0,
  38896. e == null || e._removePendingData(tt),
  38897. b && b()
  38898. }
  38899. };
  38900. return this._loadFile(a, function(nt) {
  38901. it(nt)
  38902. }, void 0, e == null ? void 0 : e.offlineProvider, !0, rt),
  38903. tt
  38904. }
  38905. ;
  38906. function _convertRGBtoRGBATextureData$1(a, e, i, o) {
  38907. var s, c = 1;
  38908. o === 1 ? s = new Float32Array(e * i * 4) : o === 2 ? (s = new Uint16Array(e * i * 4),
  38909. c = 15360) : o === 7 ? s = new Uint32Array(e * i * 4) : s = new Uint8Array(e * i * 4);
  38910. for (var d = 0; d < e; d++)
  38911. for (var _ = 0; _ < i; _++) {
  38912. var b = (_ * e + d) * 3
  38913. , k = (_ * e + d) * 4;
  38914. s[k + 0] = a[b + 0],
  38915. s[k + 1] = a[b + 1],
  38916. s[k + 2] = a[b + 2],
  38917. s[k + 3] = c
  38918. }
  38919. return s
  38920. }
  38921. function _makeCreateRawTextureFunction(a) {
  38922. return function(e, i, o, s, c, d, _, b, k, j) {
  38923. k === void 0 && (k = null),
  38924. j === void 0 && (j = 0);
  38925. var $ = a ? this._gl.TEXTURE_3D : this._gl.TEXTURE_2D_ARRAY
  38926. , _e = a ? InternalTextureSource.Raw3D : InternalTextureSource.Raw2DArray
  38927. , et = new InternalTexture(this,_e);
  38928. et.baseWidth = i,
  38929. et.baseHeight = o,
  38930. et.baseDepth = s,
  38931. et.width = i,
  38932. et.height = o,
  38933. et.depth = s,
  38934. et.format = c,
  38935. et.type = j,
  38936. et.generateMipMaps = d,
  38937. et.samplingMode = b,
  38938. a ? et.is3D = !0 : et.is2DArray = !0,
  38939. this._doNotHandleContextLost || (et._bufferView = e),
  38940. a ? this.updateRawTexture3D(et, e, c, _, k, j) : this.updateRawTexture2DArray(et, e, c, _, k, j),
  38941. this._bindTextureDirectly($, et, !0);
  38942. var tt = this._getSamplingParameters(b, d);
  38943. return this._gl.texParameteri($, this._gl.TEXTURE_MAG_FILTER, tt.mag),
  38944. this._gl.texParameteri($, this._gl.TEXTURE_MIN_FILTER, tt.min),
  38945. d && this._gl.generateMipmap($),
  38946. this._bindTextureDirectly($, null),
  38947. this._internalTexturesCache.push(et),
  38948. et
  38949. }
  38950. }
  38951. ThinEngine.prototype.createRawTexture2DArray = _makeCreateRawTextureFunction(!1);
  38952. ThinEngine.prototype.createRawTexture3D = _makeCreateRawTextureFunction(!0);
  38953. function _makeUpdateRawTextureFunction(a) {
  38954. return function(e, i, o, s, c, d) {
  38955. c === void 0 && (c = null),
  38956. d === void 0 && (d = 0);
  38957. var _ = a ? this._gl.TEXTURE_3D : this._gl.TEXTURE_2D_ARRAY
  38958. , b = this._getWebGLTextureType(d)
  38959. , k = this._getInternalFormat(o)
  38960. , j = this._getRGBABufferInternalSizedFormat(d, o);
  38961. this._bindTextureDirectly(_, e, !0),
  38962. this._unpackFlipY(s === void 0 ? !0 : !!s),
  38963. this._doNotHandleContextLost || (e._bufferView = i,
  38964. e.format = o,
  38965. e.invertY = s,
  38966. e._compression = c),
  38967. e.width % 4 !== 0 && this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1),
  38968. c && i ? this._gl.compressedTexImage3D(_, 0, this.getCaps().s3tc[c], e.width, e.height, e.depth, 0, i) : this._gl.texImage3D(_, 0, j, e.width, e.height, e.depth, 0, k, b, i),
  38969. e.generateMipMaps && this._gl.generateMipmap(_),
  38970. this._bindTextureDirectly(_, null),
  38971. e.isReady = !0
  38972. }
  38973. }
  38974. ThinEngine.prototype.updateRawTexture2DArray = _makeUpdateRawTextureFunction(!1);
  38975. ThinEngine.prototype.updateRawTexture3D = _makeUpdateRawTextureFunction(!0);
  38976. ThinEngine.prototype.createDynamicTexture = function(a, e, i, o) {
  38977. var s = new InternalTexture(this,InternalTextureSource.Dynamic);
  38978. return s.baseWidth = a,
  38979. s.baseHeight = e,
  38980. i && (a = this.needPOTTextures ? ThinEngine.GetExponentOfTwo(a, this._caps.maxTextureSize) : a,
  38981. e = this.needPOTTextures ? ThinEngine.GetExponentOfTwo(e, this._caps.maxTextureSize) : e),
  38982. s.width = a,
  38983. s.height = e,
  38984. s.isReady = !1,
  38985. s.generateMipMaps = i,
  38986. s.samplingMode = o,
  38987. this.updateTextureSamplingMode(o, s),
  38988. this._internalTexturesCache.push(s),
  38989. s
  38990. }
  38991. ;
  38992. ThinEngine.prototype.updateDynamicTexture = function(a, e, i, o, s, c, d) {
  38993. if (o === void 0 && (o = !1),
  38994. c === void 0 && (c = !1),
  38995. !!a) {
  38996. var _ = this._gl
  38997. , b = _.TEXTURE_2D
  38998. , k = this._bindTextureDirectly(b, a, !0, c);
  38999. this._unpackFlipY(i === void 0 ? a.invertY : i),
  39000. o && _.pixelStorei(_.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 1);
  39001. var j = this._getWebGLTextureType(a.type)
  39002. , $ = this._getInternalFormat(s || a.format)
  39003. , _e = this._getRGBABufferInternalSizedFormat(a.type, $);
  39004. _.texImage2D(b, 0, _e, $, j, e),
  39005. a.generateMipMaps && _.generateMipmap(b),
  39006. k || this._bindTextureDirectly(b, null),
  39007. o && _.pixelStorei(_.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0),
  39008. a.isReady = !0
  39009. }
  39010. }
  39011. ;
  39012. ThinEngine.prototype.createExternalTexture = function(a) {
  39013. return null
  39014. }
  39015. ;
  39016. ThinEngine.prototype.setExternalTexture = function(a, e) {
  39017. throw new Error("setExternalTexture: This engine does not support external textures!")
  39018. }
  39019. ;
  39020. ThinEngine.prototype.updateVideoTexture = function(a, e, i) {
  39021. if (!(!a || a._isDisabled)) {
  39022. var o = this._bindTextureDirectly(this._gl.TEXTURE_2D, a, !0);
  39023. this._unpackFlipY(!i);
  39024. try {
  39025. if (this._videoTextureSupported === void 0 && (this._gl.getError(),
  39026. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, e),
  39027. this._gl.getError() !== 0 ? this._videoTextureSupported = !1 : this._videoTextureSupported = !0),
  39028. this._videoTextureSupported)
  39029. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, e);
  39030. else {
  39031. if (!a._workingCanvas) {
  39032. a._workingCanvas = this.createCanvas(a.width, a.height);
  39033. var s = a._workingCanvas.getContext("2d");
  39034. if (!s)
  39035. throw new Error("Unable to get 2d context");
  39036. a._workingContext = s,
  39037. a._workingCanvas.width = a.width,
  39038. a._workingCanvas.height = a.height
  39039. }
  39040. a._workingContext.clearRect(0, 0, a.width, a.height),
  39041. a._workingContext.drawImage(e, 0, 0, e.videoWidth, e.videoHeight, 0, 0, a.width, a.height),
  39042. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, a._workingCanvas)
  39043. }
  39044. a.generateMipMaps && this._gl.generateMipmap(this._gl.TEXTURE_2D),
  39045. o || this._bindTextureDirectly(this._gl.TEXTURE_2D, null),
  39046. a.isReady = !0
  39047. } catch {
  39048. a._isDisabled = !0
  39049. }
  39050. }
  39051. }
  39052. ;
  39053. ThinEngine.prototype.restoreSingleAttachment = function() {
  39054. var a = this._gl;
  39055. this.bindAttachments([a.BACK])
  39056. }
  39057. ;
  39058. ThinEngine.prototype.restoreSingleAttachmentForRenderTarget = function() {
  39059. var a = this._gl;
  39060. this.bindAttachments([a.COLOR_ATTACHMENT0])
  39061. }
  39062. ;
  39063. ThinEngine.prototype.buildTextureLayout = function(a) {
  39064. for (var e = this._gl, i = [], o = 0; o < a.length; o++)
  39065. a[o] ? i.push(e["COLOR_ATTACHMENT" + o]) : i.push(e.NONE);
  39066. return i
  39067. }
  39068. ;
  39069. ThinEngine.prototype.bindAttachments = function(a) {
  39070. var e = this._gl;
  39071. e.drawBuffers(a)
  39072. }
  39073. ;
  39074. ThinEngine.prototype.unBindMultiColorAttachmentFramebuffer = function(a, e, i) {
  39075. e === void 0 && (e = !1),
  39076. this._currentRenderTarget = null;
  39077. var o = this._gl
  39078. , s = a._attachments
  39079. , c = s.length;
  39080. if (a._MSAAFramebuffer) {
  39081. o.bindFramebuffer(o.READ_FRAMEBUFFER, a._MSAAFramebuffer),
  39082. o.bindFramebuffer(o.DRAW_FRAMEBUFFER, a._framebuffer);
  39083. for (var d = 0; d < c; d++) {
  39084. for (var _ = a.textures[d], b = 0; b < c; b++)
  39085. s[b] = o.NONE;
  39086. s[d] = o[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + d : "COLOR_ATTACHMENT" + d + "_WEBGL"],
  39087. o.readBuffer(s[d]),
  39088. o.drawBuffers(s),
  39089. o.blitFramebuffer(0, 0, _.width, _.height, 0, 0, _.width, _.height, o.COLOR_BUFFER_BIT, o.NEAREST)
  39090. }
  39091. for (var d = 0; d < c; d++)
  39092. s[d] = o[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + d : "COLOR_ATTACHMENT" + d + "_WEBGL"];
  39093. o.drawBuffers(s)
  39094. }
  39095. for (var d = 0; d < c; d++) {
  39096. var _ = a.textures[d];
  39097. _.generateMipMaps && !e && !_.isCube && (this._bindTextureDirectly(o.TEXTURE_2D, _, !0),
  39098. o.generateMipmap(o.TEXTURE_2D),
  39099. this._bindTextureDirectly(o.TEXTURE_2D, null))
  39100. }
  39101. i && (a._MSAAFramebuffer && this._bindUnboundFramebuffer(a._framebuffer),
  39102. i()),
  39103. this._bindUnboundFramebuffer(null)
  39104. }
  39105. ;
  39106. ThinEngine.prototype.createMultipleRenderTarget = function(a, e, i) {
  39107. i === void 0 && (i = !0);
  39108. var o = !1
  39109. , s = !0
  39110. , c = !1
  39111. , d = !1
  39112. , _ = 15
  39113. , b = 1
  39114. , k = 0
  39115. , j = 3
  39116. , $ = new Array
  39117. , _e = new Array
  39118. , et = this._createHardwareRenderTargetWrapper(!0, !1, a);
  39119. e !== void 0 && (o = e.generateMipMaps === void 0 ? !1 : e.generateMipMaps,
  39120. s = e.generateDepthBuffer === void 0 ? !0 : e.generateDepthBuffer,
  39121. c = e.generateStencilBuffer === void 0 ? !1 : e.generateStencilBuffer,
  39122. d = e.generateDepthTexture === void 0 ? !1 : e.generateDepthTexture,
  39123. b = e.textureCount || 1,
  39124. e.types && ($ = e.types),
  39125. e.samplingModes && (_e = e.samplingModes),
  39126. this.webGLVersion > 1 && (e.depthTextureFormat === 13 || e.depthTextureFormat === 16 || e.depthTextureFormat === 14) && (_ = e.depthTextureFormat));
  39127. var tt = this._gl
  39128. , rt = tt.createFramebuffer();
  39129. this._bindUnboundFramebuffer(rt);
  39130. var it = a.width || a
  39131. , nt = a.height || a
  39132. , ot = []
  39133. , at = []
  39134. , st = this.webGLVersion > 1 && d && e.depthTextureFormat === 13
  39135. , ut = this._setupFramebufferDepthAttachments(!st && c, !d && s, it, nt);
  39136. et._framebuffer = rt,
  39137. et._depthStencilBuffer = ut,
  39138. et._generateDepthBuffer = !d && s,
  39139. et._generateStencilBuffer = !st && c,
  39140. et._attachments = at;
  39141. for (var ct = 0; ct < b; ct++) {
  39142. var lt = _e[ct] || j
  39143. , ft = $[ct] || k;
  39144. (ft === 1 && !this._caps.textureFloatLinearFiltering || ft === 2 && !this._caps.textureHalfFloatLinearFiltering) && (lt = 1);
  39145. var ht = this._getSamplingParameters(lt, o);
  39146. ft === 1 && !this._caps.textureFloat && (ft = 0,
  39147. Logger$2.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type"));
  39148. var pt = new InternalTexture(this,InternalTextureSource.MultiRenderTarget)
  39149. , dt = tt[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + ct : "COLOR_ATTACHMENT" + ct + "_WEBGL"];
  39150. ot.push(pt),
  39151. at.push(dt),
  39152. tt.activeTexture(tt["TEXTURE" + ct]),
  39153. tt.bindTexture(tt.TEXTURE_2D, pt._hardwareTexture.underlyingResource),
  39154. tt.texParameteri(tt.TEXTURE_2D, tt.TEXTURE_MAG_FILTER, ht.mag),
  39155. tt.texParameteri(tt.TEXTURE_2D, tt.TEXTURE_MIN_FILTER, ht.min),
  39156. tt.texParameteri(tt.TEXTURE_2D, tt.TEXTURE_WRAP_S, tt.CLAMP_TO_EDGE),
  39157. tt.texParameteri(tt.TEXTURE_2D, tt.TEXTURE_WRAP_T, tt.CLAMP_TO_EDGE),
  39158. tt.texImage2D(tt.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(ft), it, nt, 0, tt.RGBA, this._getWebGLTextureType(ft), null),
  39159. tt.framebufferTexture2D(tt.DRAW_FRAMEBUFFER, dt, tt.TEXTURE_2D, pt._hardwareTexture.underlyingResource, 0),
  39160. o && this._gl.generateMipmap(this._gl.TEXTURE_2D),
  39161. this._bindTextureDirectly(tt.TEXTURE_2D, null),
  39162. pt.baseWidth = it,
  39163. pt.baseHeight = nt,
  39164. pt.width = it,
  39165. pt.height = nt,
  39166. pt.isReady = !0,
  39167. pt.samples = 1,
  39168. pt.generateMipMaps = o,
  39169. pt.samplingMode = lt,
  39170. pt.type = ft,
  39171. this._internalTexturesCache.push(pt)
  39172. }
  39173. if (d && this._caps.depthTextureExtension) {
  39174. var _t = new InternalTexture(this,InternalTextureSource.Depth)
  39175. , mt = 5
  39176. , vt = tt.DEPTH_COMPONENT16
  39177. , yt = tt.DEPTH_COMPONENT
  39178. , Et = tt.UNSIGNED_SHORT
  39179. , At = tt.DEPTH_ATTACHMENT;
  39180. this.webGLVersion < 2 ? vt = tt.DEPTH_COMPONENT : _ === 14 ? (mt = 1,
  39181. Et = tt.FLOAT,
  39182. vt = tt.DEPTH_COMPONENT32F) : _ === 16 ? (mt = 0,
  39183. Et = tt.UNSIGNED_INT,
  39184. vt = tt.DEPTH_COMPONENT24,
  39185. At = tt.DEPTH_ATTACHMENT) : _ === 13 && (mt = 12,
  39186. Et = tt.UNSIGNED_INT_24_8,
  39187. vt = tt.DEPTH24_STENCIL8,
  39188. yt = tt.DEPTH_STENCIL,
  39189. At = tt.DEPTH_STENCIL_ATTACHMENT),
  39190. tt.activeTexture(tt.TEXTURE0),
  39191. tt.bindTexture(tt.TEXTURE_2D, _t._hardwareTexture.underlyingResource),
  39192. tt.texParameteri(tt.TEXTURE_2D, tt.TEXTURE_MAG_FILTER, tt.NEAREST),
  39193. tt.texParameteri(tt.TEXTURE_2D, tt.TEXTURE_MIN_FILTER, tt.NEAREST),
  39194. tt.texParameteri(tt.TEXTURE_2D, tt.TEXTURE_WRAP_S, tt.CLAMP_TO_EDGE),
  39195. tt.texParameteri(tt.TEXTURE_2D, tt.TEXTURE_WRAP_T, tt.CLAMP_TO_EDGE),
  39196. tt.texImage2D(tt.TEXTURE_2D, 0, vt, it, nt, 0, yt, Et, null),
  39197. tt.framebufferTexture2D(tt.FRAMEBUFFER, At, tt.TEXTURE_2D, _t._hardwareTexture.underlyingResource, 0),
  39198. _t.baseWidth = it,
  39199. _t.baseHeight = nt,
  39200. _t.width = it,
  39201. _t.height = nt,
  39202. _t.isReady = !0,
  39203. _t.samples = 1,
  39204. _t.generateMipMaps = o,
  39205. _t.samplingMode = 1,
  39206. _t.format = _,
  39207. _t.type = mt,
  39208. ot.push(_t),
  39209. this._internalTexturesCache.push(_t)
  39210. }
  39211. return et.setTextures(ot),
  39212. i && tt.drawBuffers(at),
  39213. this._bindUnboundFramebuffer(null),
  39214. this.resetTextureCache(),
  39215. et
  39216. }
  39217. ;
  39218. ThinEngine.prototype.updateMultipleRenderTargetTextureSampleCount = function(a, e, i) {
  39219. if (i === void 0 && (i = !0),
  39220. this.webGLVersion < 2 || !a || !a.texture)
  39221. return 1;
  39222. if (a.samples === e)
  39223. return e;
  39224. var o = a._attachments.length;
  39225. if (o === 0)
  39226. return 1;
  39227. var s = this._gl;
  39228. e = Math.min(e, this.getCaps().maxMSAASamples),
  39229. a._depthStencilBuffer && (s.deleteRenderbuffer(a._depthStencilBuffer),
  39230. a._depthStencilBuffer = null),
  39231. a._MSAAFramebuffer && (s.deleteFramebuffer(a._MSAAFramebuffer),
  39232. a._MSAAFramebuffer = null);
  39233. for (var c = 0; c < o; c++) {
  39234. var d = a.textures[c]._hardwareTexture;
  39235. d != null && d._MSAARenderBuffer && (s.deleteRenderbuffer(d._MSAARenderBuffer),
  39236. d._MSAARenderBuffer = null)
  39237. }
  39238. if (e > 1 && s.renderbufferStorageMultisample) {
  39239. var _ = s.createFramebuffer();
  39240. if (!_)
  39241. throw new Error("Unable to create multi sampled framebuffer");
  39242. a._MSAAFramebuffer = _,
  39243. this._bindUnboundFramebuffer(_);
  39244. for (var b = [], c = 0; c < o; c++) {
  39245. var k = a.textures[c]
  39246. , d = k._hardwareTexture
  39247. , j = s[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + c : "COLOR_ATTACHMENT" + c + "_WEBGL"]
  39248. , $ = this._createRenderBuffer(k.width, k.height, e, -1, this._getRGBAMultiSampleBufferFormat(k.type), j);
  39249. if (!$)
  39250. throw new Error("Unable to create multi sampled framebuffer");
  39251. d._MSAARenderBuffer = $,
  39252. k.samples = e,
  39253. b.push(j)
  39254. }
  39255. i && s.drawBuffers(b)
  39256. } else
  39257. this._bindUnboundFramebuffer(a._framebuffer);
  39258. return a._depthStencilBuffer = this._setupFramebufferDepthAttachments(a._generateStencilBuffer, a._generateDepthBuffer, a.texture.width, a.texture.height, e),
  39259. this._bindUnboundFramebuffer(null),
  39260. e
  39261. }
  39262. ;
  39263. ThinEngine.prototype._createDepthStencilCubeTexture = function(a, e, i) {
  39264. var o = new InternalTexture(this,InternalTextureSource.DepthStencil);
  39265. if (o.isCube = !0,
  39266. this.webGLVersion === 1)
  39267. return Logger$2.Error("Depth cube texture is not supported by WebGL 1."),
  39268. o;
  39269. var s = __assign({
  39270. bilinearFiltering: !1,
  39271. comparisonFunction: 0,
  39272. generateStencil: !1
  39273. }, e)
  39274. , c = this._gl;
  39275. this._bindTextureDirectly(c.TEXTURE_CUBE_MAP, o, !0),
  39276. this._setupDepthStencilTexture(o, a, s.generateStencil, s.bilinearFiltering, s.comparisonFunction),
  39277. i._depthStencilTexture = o,
  39278. i._depthStencilTextureWithStencil = s.generateStencil;
  39279. for (var d = 0; d < 6; d++)
  39280. s.generateStencil ? c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X + d, 0, c.DEPTH24_STENCIL8, a, a, 0, c.DEPTH_STENCIL, c.UNSIGNED_INT_24_8, null) : c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X + d, 0, c.DEPTH_COMPONENT24, a, a, 0, c.DEPTH_COMPONENT, c.UNSIGNED_INT, null);
  39281. return this._bindTextureDirectly(c.TEXTURE_CUBE_MAP, null),
  39282. this._internalTexturesCache.push(o),
  39283. o
  39284. }
  39285. ;
  39286. ThinEngine.prototype._partialLoadFile = function(a, e, i, o, s) {
  39287. s === void 0 && (s = null);
  39288. var c = function(_) {
  39289. i[e] = _,
  39290. i._internalCount++,
  39291. i._internalCount === 6 && o(i)
  39292. }
  39293. , d = function(_, b) {
  39294. s && _ && s(_.status + " " + _.statusText, b)
  39295. };
  39296. this._loadFile(a, c, void 0, void 0, !0, d)
  39297. }
  39298. ;
  39299. ThinEngine.prototype._cascadeLoadFiles = function(a, e, i, o) {
  39300. o === void 0 && (o = null);
  39301. var s = [];
  39302. s._internalCount = 0;
  39303. for (var c = 0; c < 6; c++)
  39304. this._partialLoadFile(i[c], c, s, e, o)
  39305. }
  39306. ;
  39307. ThinEngine.prototype._cascadeLoadImgs = function(a, e, i, o, s, c) {
  39308. s === void 0 && (s = null);
  39309. var d = [];
  39310. d._internalCount = 0;
  39311. for (var _ = 0; _ < 6; _++)
  39312. this._partialLoadImg(o[_], _, d, a, e, i, s, c)
  39313. }
  39314. ;
  39315. ThinEngine.prototype._partialLoadImg = function(a, e, i, o, s, c, d, _) {
  39316. d === void 0 && (d = null);
  39317. var b = RandomGUID()
  39318. , k = function($) {
  39319. i[e] = $,
  39320. i._internalCount++,
  39321. o && o._removePendingData(b),
  39322. i._internalCount === 6 && c && c(s, i)
  39323. }
  39324. , j = function($, _e) {
  39325. o && o._removePendingData(b),
  39326. d && d($, _e)
  39327. };
  39328. LoadImage(a, k, j, o ? o.offlineProvider : null, _),
  39329. o && o._addPendingData(b)
  39330. }
  39331. ;
  39332. ThinEngine.prototype._setCubeMapTextureParams = function(a, e) {
  39333. var i = this._gl;
  39334. i.texParameteri(i.TEXTURE_CUBE_MAP, i.TEXTURE_MAG_FILTER, i.LINEAR),
  39335. i.texParameteri(i.TEXTURE_CUBE_MAP, i.TEXTURE_MIN_FILTER, e ? i.LINEAR_MIPMAP_LINEAR : i.LINEAR),
  39336. i.texParameteri(i.TEXTURE_CUBE_MAP, i.TEXTURE_WRAP_S, i.CLAMP_TO_EDGE),
  39337. i.texParameteri(i.TEXTURE_CUBE_MAP, i.TEXTURE_WRAP_T, i.CLAMP_TO_EDGE),
  39338. a.samplingMode = e ? 3 : 2,
  39339. this._bindTextureDirectly(i.TEXTURE_CUBE_MAP, null)
  39340. }
  39341. ;
  39342. ThinEngine.prototype.createCubeTextureBase = function(a, e, i, o, s, c, d, _, b, k, j, $, _e, et, tt) {
  39343. var rt = this;
  39344. s === void 0 && (s = null),
  39345. c === void 0 && (c = null),
  39346. _ === void 0 && (_ = null),
  39347. b === void 0 && (b = !1),
  39348. k === void 0 && (k = 0),
  39349. j === void 0 && (j = 0),
  39350. $ === void 0 && ($ = null),
  39351. _e === void 0 && (_e = null),
  39352. et === void 0 && (et = null),
  39353. tt === void 0 && (tt = !1);
  39354. var it = $ || new InternalTexture(this,InternalTextureSource.Cube);
  39355. it.isCube = !0,
  39356. it.url = a,
  39357. it.generateMipMaps = !o,
  39358. it._lodGenerationScale = k,
  39359. it._lodGenerationOffset = j,
  39360. it._useSRGBBuffer = !!tt && this._caps.supportSRGBBuffers && (this.webGLVersion > 1 || this.isWebGPU || !!o),
  39361. this._doNotHandleContextLost || (it._extension = _,
  39362. it._files = i);
  39363. var nt = a;
  39364. this._transformTextureUrl && !$ && (a = this._transformTextureUrl(a));
  39365. for (var ot = a.lastIndexOf("."), at = _ || (ot > -1 ? a.substring(ot).toLowerCase() : ""), st = null, ut = 0, ct = ThinEngine._TextureLoaders; ut < ct.length; ut++) {
  39366. var lt = ct[ut];
  39367. if (lt.canLoad(at)) {
  39368. st = lt;
  39369. break
  39370. }
  39371. }
  39372. var ft = function(pt, dt) {
  39373. a === nt ? c && pt && c(pt.status + " " + pt.statusText, dt) : (Logger$2.Warn("Failed to load " + a + ", falling back to the " + nt),
  39374. rt.createCubeTextureBase(nt, e, i, !!o, s, c, d, _, b, k, j, it, _e, et, tt))
  39375. };
  39376. if (st) {
  39377. var ht = function(pt) {
  39378. _e && _e(it, pt),
  39379. st.loadCubeData(pt, it, b, s, c)
  39380. };
  39381. i && i.length === 6 ? st.supportCascades ? this._cascadeLoadFiles(e, function(pt) {
  39382. return ht(pt.map(function(dt) {
  39383. return new Uint8Array(dt)
  39384. }))
  39385. }, i, c) : c ? c("Textures type does not support cascades.") : Logger$2.Warn("Texture loader does not support cascades.") : this._loadFile(a, function(pt) {
  39386. return ht(new Uint8Array(pt))
  39387. }, void 0, void 0, !0, ft)
  39388. } else {
  39389. if (!i)
  39390. throw new Error("Cannot load cubemap because files were not defined");
  39391. this._cascadeLoadImgs(e, it, function(pt, dt) {
  39392. et && et(pt, dt)
  39393. }, i, c)
  39394. }
  39395. return this._internalTexturesCache.push(it),
  39396. it
  39397. }
  39398. ;
  39399. ThinEngine.prototype.createCubeTexture = function(a, e, i, o, s, c, d, _, b, k, j, $, _e, et) {
  39400. var tt = this;
  39401. s === void 0 && (s = null),
  39402. c === void 0 && (c = null),
  39403. _ === void 0 && (_ = null),
  39404. b === void 0 && (b = !1),
  39405. k === void 0 && (k = 0),
  39406. j === void 0 && (j = 0),
  39407. $ === void 0 && ($ = null),
  39408. et === void 0 && (et = !1);
  39409. var rt = this._gl;
  39410. return this.createCubeTextureBase(a, e, i, !!o, s, c, d, _, b, k, j, $, function(it, nt) {
  39411. return tt._bindTextureDirectly(rt.TEXTURE_CUBE_MAP, it, !0)
  39412. }, function(it, nt) {
  39413. var ot = tt.needPOTTextures ? ThinEngine.GetExponentOfTwo(nt[0].width, tt._caps.maxCubemapTextureSize) : nt[0].width
  39414. , at = ot
  39415. , st = [rt.TEXTURE_CUBE_MAP_POSITIVE_X, rt.TEXTURE_CUBE_MAP_POSITIVE_Y, rt.TEXTURE_CUBE_MAP_POSITIVE_Z, rt.TEXTURE_CUBE_MAP_NEGATIVE_X, rt.TEXTURE_CUBE_MAP_NEGATIVE_Y, rt.TEXTURE_CUBE_MAP_NEGATIVE_Z];
  39416. tt._bindTextureDirectly(rt.TEXTURE_CUBE_MAP, it, !0),
  39417. tt._unpackFlipY(!1);
  39418. var ut = d ? tt._getInternalFormat(d, it._useSRGBBuffer) : it._useSRGBBuffer ? rt.SRGB8_ALPHA8 : rt.RGBA
  39419. , ct = d ? tt._getInternalFormat(d) : rt.RGBA;
  39420. it._useSRGBBuffer && tt.webGLVersion === 1 && (ct = ut);
  39421. for (var lt = 0; lt < st.length; lt++)
  39422. if (nt[lt].width !== ot || nt[lt].height !== at) {
  39423. if (tt._prepareWorkingCanvas(),
  39424. !tt._workingCanvas || !tt._workingContext) {
  39425. Logger$2.Warn("Cannot create canvas to resize texture.");
  39426. return
  39427. }
  39428. tt._workingCanvas.width = ot,
  39429. tt._workingCanvas.height = at,
  39430. tt._workingContext.drawImage(nt[lt], 0, 0, nt[lt].width, nt[lt].height, 0, 0, ot, at),
  39431. rt.texImage2D(st[lt], 0, ut, ct, rt.UNSIGNED_BYTE, tt._workingCanvas)
  39432. } else
  39433. rt.texImage2D(st[lt], 0, ut, ct, rt.UNSIGNED_BYTE, nt[lt]);
  39434. o || rt.generateMipmap(rt.TEXTURE_CUBE_MAP),
  39435. tt._setCubeMapTextureParams(it, !o),
  39436. it.width = ot,
  39437. it.height = at,
  39438. it.isReady = !0,
  39439. d && (it.format = d),
  39440. it.onLoadedObservable.notifyObservers(it),
  39441. it.onLoadedObservable.clear(),
  39442. s && s()
  39443. }, !!et)
  39444. }
  39445. ;
  39446. ThinEngine.prototype.setTextureSampler = function(a, e) {
  39447. throw new Error("setTextureSampler: This engine does not support separate texture sampler objects!")
  39448. }
  39449. ;
  39450. Object.defineProperty(Engine.prototype, "isInVRExclusivePointerMode", {
  39451. get: function() {
  39452. return this._vrExclusivePointerMode
  39453. },
  39454. enumerable: !0,
  39455. configurable: !0
  39456. });
  39457. Engine.prototype._prepareVRComponent = function() {
  39458. this._vrSupported = !1,
  39459. this._vrExclusivePointerMode = !1,
  39460. this.onVRDisplayChangedObservable = new Observable,
  39461. this.onVRRequestPresentComplete = new Observable,
  39462. this.onVRRequestPresentStart = new Observable
  39463. }
  39464. ;
  39465. Engine.prototype.isVRDevicePresent = function() {
  39466. return !!this._vrDisplay
  39467. }
  39468. ;
  39469. Engine.prototype.getVRDevice = function() {
  39470. return this._vrDisplay
  39471. }
  39472. ;
  39473. Engine.prototype.initWebVR = function() {
  39474. return this.initWebVRAsync(),
  39475. this.onVRDisplayChangedObservable
  39476. }
  39477. ;
  39478. Engine.prototype.initWebVRAsync = function() {
  39479. var a = this
  39480. , e = function() {
  39481. var o = {
  39482. vrDisplay: a._vrDisplay,
  39483. vrSupported: a._vrSupported
  39484. };
  39485. a.onVRDisplayChangedObservable.notifyObservers(o),
  39486. a._webVRInitPromise = new Promise(function(s) {
  39487. s(o)
  39488. }
  39489. )
  39490. };
  39491. if (!this._onVrDisplayConnect) {
  39492. this._onVrDisplayConnect = function(o) {
  39493. a._vrDisplay = o.display,
  39494. e()
  39495. }
  39496. ,
  39497. this._onVrDisplayDisconnect = function() {
  39498. a._vrDisplay.cancelAnimationFrame(a._frameHandler),
  39499. a._vrDisplay = void 0,
  39500. a._frameHandler = Engine.QueueNewFrame(a._boundRenderFunction),
  39501. e()
  39502. }
  39503. ,
  39504. this._onVrDisplayPresentChange = function() {
  39505. a._vrExclusivePointerMode = a._vrDisplay && a._vrDisplay.isPresenting
  39506. }
  39507. ;
  39508. var i = this.getHostWindow();
  39509. i && (i.addEventListener("vrdisplayconnect", this._onVrDisplayConnect),
  39510. i.addEventListener("vrdisplaydisconnect", this._onVrDisplayDisconnect),
  39511. i.addEventListener("vrdisplaypresentchange", this._onVrDisplayPresentChange))
  39512. }
  39513. return this._webVRInitPromise = this._webVRInitPromise || this._getVRDisplaysAsync(),
  39514. this._webVRInitPromise.then(e),
  39515. this._webVRInitPromise
  39516. }
  39517. ;
  39518. Engine.prototype._getVRDisplaysAsync = function() {
  39519. var a = this;
  39520. return new Promise(function(e) {
  39521. navigator.getVRDisplays ? navigator.getVRDisplays().then(function(i) {
  39522. a._vrSupported = !0,
  39523. a._vrDisplay = i[0],
  39524. e({
  39525. vrDisplay: a._vrDisplay,
  39526. vrSupported: a._vrSupported
  39527. })
  39528. }) : (a._vrDisplay = void 0,
  39529. a._vrSupported = !1,
  39530. e({
  39531. vrDisplay: a._vrDisplay,
  39532. vrSupported: a._vrSupported
  39533. }))
  39534. }
  39535. )
  39536. }
  39537. ;
  39538. Engine.prototype.enableVR = function(a) {
  39539. var e = this;
  39540. if (this._vrDisplay && !this._vrDisplay.isPresenting) {
  39541. var i = function() {
  39542. e.onVRRequestPresentComplete.notifyObservers(!0),
  39543. e._onVRFullScreenTriggered()
  39544. }
  39545. , o = function() {
  39546. e.onVRRequestPresentComplete.notifyObservers(!1)
  39547. };
  39548. this.onVRRequestPresentStart.notifyObservers(this);
  39549. var s = {
  39550. highRefreshRate: this.vrPresentationAttributes ? this.vrPresentationAttributes.highRefreshRate : !1,
  39551. foveationLevel: this.vrPresentationAttributes ? this.vrPresentationAttributes.foveationLevel : 1,
  39552. multiview: (this.getCaps().multiview || this.getCaps().oculusMultiview) && a.useMultiview
  39553. };
  39554. this._vrDisplay.requestPresent([__assign({
  39555. source: this.getRenderingCanvas(),
  39556. attributes: s
  39557. }, s)]).then(i).catch(o)
  39558. }
  39559. }
  39560. ;
  39561. Engine.prototype._onVRFullScreenTriggered = function() {
  39562. if (this._vrDisplay && this._vrDisplay.isPresenting) {
  39563. this._oldSize = new Size(this.getRenderWidth(),this.getRenderHeight()),
  39564. this._oldHardwareScaleFactor = this.getHardwareScalingLevel();
  39565. var a = this._vrDisplay.getEyeParameters("left");
  39566. this.setHardwareScalingLevel(1),
  39567. this.setSize(a.renderWidth * 2, a.renderHeight)
  39568. } else
  39569. this.setHardwareScalingLevel(this._oldHardwareScaleFactor),
  39570. this.setSize(this._oldSize.width, this._oldSize.height)
  39571. }
  39572. ;
  39573. Engine.prototype.disableVR = function() {
  39574. var a = this;
  39575. this._vrDisplay && this._vrDisplay.isPresenting && this._vrDisplay.exitPresent().then(function() {
  39576. return a._onVRFullScreenTriggered()
  39577. }).catch(function() {
  39578. return a._onVRFullScreenTriggered()
  39579. }),
  39580. IsWindowObjectExist() && (window.removeEventListener("vrdisplaypointerrestricted", this._onVRDisplayPointerRestricted),
  39581. window.removeEventListener("vrdisplaypointerunrestricted", this._onVRDisplayPointerUnrestricted),
  39582. this._onVrDisplayConnect && (window.removeEventListener("vrdisplayconnect", this._onVrDisplayConnect),
  39583. this._onVrDisplayDisconnect && window.removeEventListener("vrdisplaydisconnect", this._onVrDisplayDisconnect),
  39584. this._onVrDisplayPresentChange && window.removeEventListener("vrdisplaypresentchange", this._onVrDisplayPresentChange),
  39585. this._onVrDisplayConnect = null,
  39586. this._onVrDisplayDisconnect = null))
  39587. }
  39588. ;
  39589. Engine.prototype._connectVREvents = function(a, e) {
  39590. var i = this;
  39591. if (this._onVRDisplayPointerRestricted = function() {
  39592. a && a.requestPointerLock()
  39593. }
  39594. ,
  39595. this._onVRDisplayPointerUnrestricted = function() {
  39596. if (!e) {
  39597. var s = i.getHostWindow();
  39598. s.document && s.document.exitPointerLock && s.document.exitPointerLock();
  39599. return
  39600. }
  39601. !e.exitPointerLock || e.exitPointerLock()
  39602. }
  39603. ,
  39604. IsWindowObjectExist()) {
  39605. var o = this.getHostWindow();
  39606. o.addEventListener("vrdisplaypointerrestricted", this._onVRDisplayPointerRestricted, !1),
  39607. o.addEventListener("vrdisplaypointerunrestricted", this._onVRDisplayPointerUnrestricted, !1)
  39608. }
  39609. }
  39610. ;
  39611. Engine.prototype._submitVRFrame = function() {
  39612. if (this._vrDisplay && this._vrDisplay.isPresenting)
  39613. try {
  39614. this._vrDisplay.submitFrame()
  39615. } catch (a) {
  39616. Tools.Warn("webVR submitFrame has had an unexpected failure: " + a)
  39617. }
  39618. }
  39619. ;
  39620. Engine.prototype.isVRPresenting = function() {
  39621. return this._vrDisplay && this._vrDisplay.isPresenting
  39622. }
  39623. ;
  39624. Engine.prototype._requestVRFrame = function() {
  39625. this._frameHandler = Engine.QueueNewFrame(this._boundRenderFunction, this._vrDisplay)
  39626. }
  39627. ;
  39628. Engine.prototype.getInputElement = function() {
  39629. return this.inputElement || this.getRenderingCanvas()
  39630. }
  39631. ;
  39632. Engine.prototype.registerView = function(a, e, i) {
  39633. var o = this;
  39634. this.views || (this.views = []);
  39635. for (var s = 0, c = this.views; s < c.length; s++) {
  39636. var d = c[s];
  39637. if (d.target === a)
  39638. return d
  39639. }
  39640. var _ = this.getRenderingCanvas();
  39641. _ && (a.width = _.width,
  39642. a.height = _.height);
  39643. var b = {
  39644. target: a,
  39645. camera: e,
  39646. clearBeforeCopy: i,
  39647. enabled: !0
  39648. };
  39649. return this.views.push(b),
  39650. e && e.onDisposeObservable.add(function() {
  39651. o.unRegisterView(a)
  39652. }),
  39653. b
  39654. }
  39655. ;
  39656. Engine.prototype.unRegisterView = function(a) {
  39657. if (!this.views)
  39658. return this;
  39659. for (var e = 0, i = this.views; e < i.length; e++) {
  39660. var o = i[e];
  39661. if (o.target === a) {
  39662. var s = this.views.indexOf(o);
  39663. s !== -1 && this.views.splice(s, 1);
  39664. break
  39665. }
  39666. }
  39667. return this
  39668. }
  39669. ;
  39670. Engine.prototype._renderViews = function() {
  39671. if (!this.views)
  39672. return !1;
  39673. var a = this.getRenderingCanvas();
  39674. if (!a)
  39675. return !1;
  39676. for (var e = 0, i = this.views; e < i.length; e++) {
  39677. var o = i[e];
  39678. if (!!o.enabled) {
  39679. var s = o.target
  39680. , c = s.getContext("2d");
  39681. if (!!c) {
  39682. var d = o.camera
  39683. , _ = null
  39684. , b = null;
  39685. if (d) {
  39686. if (b = d.getScene(),
  39687. b.activeCameras && b.activeCameras.length)
  39688. continue;
  39689. this.activeView = o,
  39690. _ = b.activeCamera,
  39691. b.activeCamera = d
  39692. }
  39693. if (o.customResize)
  39694. o.customResize(s);
  39695. else {
  39696. var k = Math.floor(s.clientWidth / this._hardwareScalingLevel)
  39697. , j = Math.floor(s.clientHeight / this._hardwareScalingLevel)
  39698. , $ = k !== s.width || a.width !== s.width || j !== s.height || a.height !== s.height;
  39699. s.clientWidth && s.clientHeight && $ && (s.width = k,
  39700. s.height = j,
  39701. this.setSize(k, j))
  39702. }
  39703. if (!a.width || !a.height)
  39704. return !1;
  39705. this._renderFrame(),
  39706. this.flushFramebuffer(),
  39707. o.clearBeforeCopy && c.clearRect(0, 0, a.width, a.height),
  39708. c.drawImage(a, 0, 0),
  39709. _ && b && (b.activeCamera = _)
  39710. }
  39711. }
  39712. }
  39713. return this.activeView = null,
  39714. !0
  39715. }
  39716. ;
  39717. var ComputeBindingType;
  39718. (function(a) {
  39719. a[a.Texture = 0] = "Texture",
  39720. a[a.StorageTexture = 1] = "StorageTexture",
  39721. a[a.UniformBuffer = 2] = "UniformBuffer",
  39722. a[a.StorageBuffer = 3] = "StorageBuffer",
  39723. a[a.TextureWithoutSampler = 4] = "TextureWithoutSampler",
  39724. a[a.Sampler = 5] = "Sampler"
  39725. }
  39726. )(ComputeBindingType || (ComputeBindingType = {}));
  39727. ThinEngine.prototype.createComputeEffect = function(a, e) {
  39728. throw new Error("createComputeEffect: This engine does not support compute shaders!")
  39729. }
  39730. ;
  39731. ThinEngine.prototype.createComputePipelineContext = function() {
  39732. throw new Error("createComputePipelineContext: This engine does not support compute shaders!")
  39733. }
  39734. ;
  39735. ThinEngine.prototype.createComputeContext = function() {}
  39736. ;
  39737. ThinEngine.prototype.computeDispatch = function(a, e, i, o, s, c, d) {
  39738. throw new Error("computeDispatch: This engine does not support compute shaders!")
  39739. }
  39740. ;
  39741. ThinEngine.prototype.areAllComputeEffectsReady = function() {
  39742. return !0
  39743. }
  39744. ;
  39745. ThinEngine.prototype.releaseComputeEffects = function() {}
  39746. ;
  39747. ThinEngine.prototype._prepareComputePipelineContext = function(a, e, i, o, s) {}
  39748. ;
  39749. ThinEngine.prototype._rebuildComputeEffects = function() {}
  39750. ;
  39751. ThinEngine.prototype._executeWhenComputeStateIsCompiled = function(a, e) {
  39752. e()
  39753. }
  39754. ;
  39755. ThinEngine.prototype._releaseComputeEffect = function(a) {}
  39756. ;
  39757. ThinEngine.prototype._deleteComputePipelineContext = function(a) {}
  39758. ;
  39759. ThinEngine.prototype.createStorageBuffer = function(a, e) {
  39760. throw new Error("createStorageBuffer: Unsupported method in this engine!")
  39761. }
  39762. ;
  39763. ThinEngine.prototype.updateStorageBuffer = function(a, e, i, o) {}
  39764. ;
  39765. ThinEngine.prototype.readFromStorageBuffer = function(a, e, i, o) {
  39766. throw new Error("readFromStorageBuffer: Unsupported method in this engine!")
  39767. }
  39768. ;
  39769. ThinEngine.prototype.setStorageBuffer = function(a, e) {
  39770. throw new Error("setStorageBuffer: Unsupported method in this engine!")
  39771. }
  39772. ;
  39773. function transformTextureUrl(a) {
  39774. var e = function(c) {
  39775. var d = "\\b" + c + "\\b";
  39776. return a && (a === c || a.match(new RegExp(d,"g")))
  39777. };
  39778. if (this._excludedCompressedTextures && this._excludedCompressedTextures.some(e))
  39779. return a;
  39780. var i = a.lastIndexOf(".")
  39781. , o = a.lastIndexOf("?")
  39782. , s = o > -1 ? a.substring(o, a.length) : "";
  39783. return (i > -1 ? a.substring(0, i) : a) + this._textureFormatInUse + s
  39784. }
  39785. Object.defineProperty(Engine.prototype, "texturesSupported", {
  39786. get: function() {
  39787. var a = new Array;
  39788. return this._caps.astc && a.push("-astc.ktx"),
  39789. this._caps.s3tc && a.push("-dxt.ktx"),
  39790. this._caps.pvrtc && a.push("-pvrtc.ktx"),
  39791. this._caps.etc2 && a.push("-etc2.ktx"),
  39792. this._caps.etc1 && a.push("-etc1.ktx"),
  39793. a
  39794. },
  39795. enumerable: !0,
  39796. configurable: !0
  39797. });
  39798. Object.defineProperty(Engine.prototype, "textureFormatInUse", {
  39799. get: function() {
  39800. return this._textureFormatInUse || null
  39801. },
  39802. enumerable: !0,
  39803. configurable: !0
  39804. });
  39805. Engine.prototype.setCompressedTextureExclusions = function(a) {
  39806. this._excludedCompressedTextures = a
  39807. }
  39808. ;
  39809. Engine.prototype.setTextureFormatToUse = function(a) {
  39810. for (var e = this.texturesSupported, i = 0, o = e.length; i < o; i++)
  39811. for (var s = 0, c = a.length; s < c; s++)
  39812. if (e[i] === a[s].toLowerCase())
  39813. return this._transformTextureUrl = transformTextureUrl.bind(this),
  39814. this._textureFormatInUse = e[i];
  39815. return this._textureFormatInUse = "",
  39816. this._transformTextureUrl = null,
  39817. null
  39818. }
  39819. ;
  39820. var NativeDataStream = function() {
  39821. function a() {
  39822. var e = this
  39823. , i = new ArrayBuffer(a.DEFAULT_BUFFER_SIZE);
  39824. this._uint32s = new Uint32Array(i),
  39825. this._int32s = new Int32Array(i),
  39826. this._float32s = new Float32Array(i),
  39827. this._length = a.DEFAULT_BUFFER_SIZE / 4,
  39828. this._position = 0,
  39829. this._nativeDataStream = new _native.NativeDataStream(function() {
  39830. e._flush()
  39831. }
  39832. )
  39833. }
  39834. return a.prototype.writeUint32 = function(e) {
  39835. this._flushIfNecessary(1),
  39836. this._uint32s[this._position++] = e
  39837. }
  39838. ,
  39839. a.prototype.writeInt32 = function(e) {
  39840. this._flushIfNecessary(1),
  39841. this._int32s[this._position++] = e
  39842. }
  39843. ,
  39844. a.prototype.writeFloat32 = function(e) {
  39845. this._flushIfNecessary(1),
  39846. this._float32s[this._position++] = e
  39847. }
  39848. ,
  39849. a.prototype.writeUint32Array = function(e) {
  39850. this._flushIfNecessary(1 + e.length),
  39851. this._uint32s[this._position++] = e.length,
  39852. this._uint32s.set(e, this._position),
  39853. this._position += e.length
  39854. }
  39855. ,
  39856. a.prototype.writeInt32Array = function(e) {
  39857. this._flushIfNecessary(1 + e.length),
  39858. this._uint32s[this._position++] = e.length,
  39859. this._int32s.set(e, this._position),
  39860. this._position += e.length
  39861. }
  39862. ,
  39863. a.prototype.writeFloat32Array = function(e) {
  39864. this._flushIfNecessary(1 + e.length),
  39865. this._uint32s[this._position++] = e.length,
  39866. this._float32s.set(e, this._position),
  39867. this._position += e.length
  39868. }
  39869. ,
  39870. a.prototype.writeNativeData = function(e) {
  39871. this._flushIfNecessary(e.length),
  39872. this._uint32s.set(e, this._position),
  39873. this._position += e.length
  39874. }
  39875. ,
  39876. a.prototype.writeBoolean = function(e) {
  39877. this.writeUint32(e ? 1 : 0)
  39878. }
  39879. ,
  39880. a.prototype._flushIfNecessary = function(e) {
  39881. this._position + e > this._length && this._flush()
  39882. }
  39883. ,
  39884. a.prototype._flush = function() {
  39885. this._nativeDataStream.writeBuffer(this._uint32s.buffer, this._position),
  39886. this._position = 0
  39887. }
  39888. ,
  39889. a.DEFAULT_BUFFER_SIZE = 65536,
  39890. a
  39891. }(), Orientation;
  39892. (function(a) {
  39893. a[a.CW = 0] = "CW",
  39894. a[a.CCW = 1] = "CCW"
  39895. }
  39896. )(Orientation || (Orientation = {}));
  39897. var BezierCurve = function() {
  39898. function a() {}
  39899. return a.Interpolate = function(e, i, o, s, c) {
  39900. for (var d = 1 - 3 * s + 3 * i, _ = 3 * s - 6 * i, b = 3 * i, k = e, j = 0; j < 5; j++) {
  39901. var $ = k * k
  39902. , _e = $ * k
  39903. , et = d * _e + _ * $ + b * k
  39904. , tt = 1 / (3 * d * $ + 2 * _ * k + b);
  39905. k -= (et - e) * tt,
  39906. k = Math.min(1, Math.max(0, k))
  39907. }
  39908. return 3 * Math.pow(1 - k, 2) * k * o + 3 * (1 - k) * Math.pow(k, 2) * c + Math.pow(k, 3)
  39909. }
  39910. ,
  39911. a
  39912. }()
  39913. , Angle = function() {
  39914. function a(e) {
  39915. this._radians = e,
  39916. this._radians < 0 && (this._radians += 2 * Math.PI)
  39917. }
  39918. return a.prototype.degrees = function() {
  39919. return this._radians * 180 / Math.PI
  39920. }
  39921. ,
  39922. a.prototype.radians = function() {
  39923. return this._radians
  39924. }
  39925. ,
  39926. a.BetweenTwoPoints = function(e, i) {
  39927. var o = i.subtract(e)
  39928. , s = Math.atan2(o.y, o.x);
  39929. return new a(s)
  39930. }
  39931. ,
  39932. a.FromRadians = function(e) {
  39933. return new a(e)
  39934. }
  39935. ,
  39936. a.FromDegrees = function(e) {
  39937. return new a(e * Math.PI / 180)
  39938. }
  39939. ,
  39940. a
  39941. }()
  39942. , Arc2 = function() {
  39943. function a(e, i, o) {
  39944. this.startPoint = e,
  39945. this.midPoint = i,
  39946. this.endPoint = o;
  39947. var s = Math.pow(i.x, 2) + Math.pow(i.y, 2)
  39948. , c = (Math.pow(e.x, 2) + Math.pow(e.y, 2) - s) / 2
  39949. , d = (s - Math.pow(o.x, 2) - Math.pow(o.y, 2)) / 2
  39950. , _ = (e.x - i.x) * (i.y - o.y) - (i.x - o.x) * (e.y - i.y);
  39951. this.centerPoint = new Vector2((c * (i.y - o.y) - d * (e.y - i.y)) / _,((e.x - i.x) * d - (i.x - o.x) * c) / _),
  39952. this.radius = this.centerPoint.subtract(this.startPoint).length(),
  39953. this.startAngle = Angle.BetweenTwoPoints(this.centerPoint, this.startPoint);
  39954. var b = this.startAngle.degrees()
  39955. , k = Angle.BetweenTwoPoints(this.centerPoint, this.midPoint).degrees()
  39956. , j = Angle.BetweenTwoPoints(this.centerPoint, this.endPoint).degrees();
  39957. k - b > 180 && (k -= 360),
  39958. k - b < -180 && (k += 360),
  39959. j - k > 180 && (j -= 360),
  39960. j - k < -180 && (j += 360),
  39961. this.orientation = k - b < 0 ? Orientation.CW : Orientation.CCW,
  39962. this.angle = Angle.FromDegrees(this.orientation === Orientation.CW ? b - j : j - b)
  39963. }
  39964. return a
  39965. }()
  39966. , Path2 = function() {
  39967. function a(e, i) {
  39968. this._points = new Array,
  39969. this._length = 0,
  39970. this.closed = !1,
  39971. this._points.push(new Vector2(e,i))
  39972. }
  39973. return a.prototype.addLineTo = function(e, i) {
  39974. if (this.closed)
  39975. return this;
  39976. var o = new Vector2(e,i)
  39977. , s = this._points[this._points.length - 1];
  39978. return this._points.push(o),
  39979. this._length += o.subtract(s).length(),
  39980. this
  39981. }
  39982. ,
  39983. a.prototype.addArcTo = function(e, i, o, s, c) {
  39984. if (c === void 0 && (c = 36),
  39985. this.closed)
  39986. return this;
  39987. var d = this._points[this._points.length - 1]
  39988. , _ = new Vector2(e,i)
  39989. , b = new Vector2(o,s)
  39990. , k = new Arc2(d,_,b)
  39991. , j = k.angle.radians() / c;
  39992. k.orientation === Orientation.CW && (j *= -1);
  39993. for (var $ = k.startAngle.radians() + j, _e = 0; _e < c; _e++) {
  39994. var et = Math.cos($) * k.radius + k.centerPoint.x
  39995. , tt = Math.sin($) * k.radius + k.centerPoint.y;
  39996. this.addLineTo(et, tt),
  39997. $ += j
  39998. }
  39999. return this
  40000. }
  40001. ,
  40002. a.prototype.close = function() {
  40003. return this.closed = !0,
  40004. this
  40005. }
  40006. ,
  40007. a.prototype.length = function() {
  40008. var e = this._length;
  40009. if (this.closed) {
  40010. var i = this._points[this._points.length - 1]
  40011. , o = this._points[0];
  40012. e += o.subtract(i).length()
  40013. }
  40014. return e
  40015. }
  40016. ,
  40017. a.prototype.getPoints = function() {
  40018. return this._points
  40019. }
  40020. ,
  40021. a.prototype.getPointAtLengthPosition = function(e) {
  40022. if (e < 0 || e > 1)
  40023. return Vector2.Zero();
  40024. for (var i = e * this.length(), o = 0, s = 0; s < this._points.length; s++) {
  40025. var c = (s + 1) % this._points.length
  40026. , d = this._points[s]
  40027. , _ = this._points[c]
  40028. , b = _.subtract(d)
  40029. , k = b.length() + o;
  40030. if (i >= o && i <= k) {
  40031. var j = b.normalize()
  40032. , $ = i - o;
  40033. return new Vector2(d.x + j.x * $,d.y + j.y * $)
  40034. }
  40035. o = k
  40036. }
  40037. return Vector2.Zero()
  40038. }
  40039. ,
  40040. a.StartingAt = function(e, i) {
  40041. return new a(e,i)
  40042. }
  40043. ,
  40044. a
  40045. }()
  40046. , Path3D = function() {
  40047. function a(e, i, o, s) {
  40048. i === void 0 && (i = null),
  40049. s === void 0 && (s = !1),
  40050. this.path = e,
  40051. this._curve = new Array,
  40052. this._distances = new Array,
  40053. this._tangents = new Array,
  40054. this._normals = new Array,
  40055. this._binormals = new Array,
  40056. this._pointAtData = {
  40057. id: 0,
  40058. point: Vector3.Zero(),
  40059. previousPointArrayIndex: 0,
  40060. position: 0,
  40061. subPosition: 0,
  40062. interpolateReady: !1,
  40063. interpolationMatrix: Matrix.Identity()
  40064. };
  40065. for (var c = 0; c < e.length; c++)
  40066. this._curve[c] = e[c].clone();
  40067. this._raw = o || !1,
  40068. this._alignTangentsWithPath = s,
  40069. this._compute(i, s)
  40070. }
  40071. return a.prototype.getCurve = function() {
  40072. return this._curve
  40073. }
  40074. ,
  40075. a.prototype.getPoints = function() {
  40076. return this._curve
  40077. }
  40078. ,
  40079. a.prototype.length = function() {
  40080. return this._distances[this._distances.length - 1]
  40081. }
  40082. ,
  40083. a.prototype.getTangents = function() {
  40084. return this._tangents
  40085. }
  40086. ,
  40087. a.prototype.getNormals = function() {
  40088. return this._normals
  40089. }
  40090. ,
  40091. a.prototype.getBinormals = function() {
  40092. return this._binormals
  40093. }
  40094. ,
  40095. a.prototype.getDistances = function() {
  40096. return this._distances
  40097. }
  40098. ,
  40099. a.prototype.getPointAt = function(e) {
  40100. return this._updatePointAtData(e).point
  40101. }
  40102. ,
  40103. a.prototype.getTangentAt = function(e, i) {
  40104. return i === void 0 && (i = !1),
  40105. this._updatePointAtData(e, i),
  40106. i ? Vector3.TransformCoordinates(Vector3.Forward(), this._pointAtData.interpolationMatrix) : this._tangents[this._pointAtData.previousPointArrayIndex]
  40107. }
  40108. ,
  40109. a.prototype.getNormalAt = function(e, i) {
  40110. return i === void 0 && (i = !1),
  40111. this._updatePointAtData(e, i),
  40112. i ? Vector3.TransformCoordinates(Vector3.Right(), this._pointAtData.interpolationMatrix) : this._normals[this._pointAtData.previousPointArrayIndex]
  40113. }
  40114. ,
  40115. a.prototype.getBinormalAt = function(e, i) {
  40116. return i === void 0 && (i = !1),
  40117. this._updatePointAtData(e, i),
  40118. i ? Vector3.TransformCoordinates(Vector3.UpReadOnly, this._pointAtData.interpolationMatrix) : this._binormals[this._pointAtData.previousPointArrayIndex]
  40119. }
  40120. ,
  40121. a.prototype.getDistanceAt = function(e) {
  40122. return this.length() * e
  40123. }
  40124. ,
  40125. a.prototype.getPreviousPointIndexAt = function(e) {
  40126. return this._updatePointAtData(e),
  40127. this._pointAtData.previousPointArrayIndex
  40128. }
  40129. ,
  40130. a.prototype.getSubPositionAt = function(e) {
  40131. return this._updatePointAtData(e),
  40132. this._pointAtData.subPosition
  40133. }
  40134. ,
  40135. a.prototype.getClosestPositionTo = function(e) {
  40136. for (var i = Number.MAX_VALUE, o = 0, s = 0; s < this._curve.length - 1; s++) {
  40137. var c = this._curve[s + 0]
  40138. , d = this._curve[s + 1].subtract(c).normalize()
  40139. , _ = this._distances[s + 1] - this._distances[s + 0]
  40140. , b = Math.min(Math.max(Vector3.Dot(d, e.subtract(c).normalize()), 0) * Vector3.Distance(c, e) / _, 1)
  40141. , k = Vector3.Distance(c.add(d.scale(b * _)), e);
  40142. k < i && (i = k,
  40143. o = (this._distances[s + 0] + _ * b) / this.length())
  40144. }
  40145. return o
  40146. }
  40147. ,
  40148. a.prototype.slice = function(e, i) {
  40149. if (e === void 0 && (e = 0),
  40150. i === void 0 && (i = 1),
  40151. e < 0 && (e = 1 - e * -1 % 1),
  40152. i < 0 && (i = 1 - i * -1 % 1),
  40153. e > i) {
  40154. var o = e;
  40155. e = i,
  40156. i = o
  40157. }
  40158. var s = this.getCurve()
  40159. , c = this.getPointAt(e)
  40160. , d = this.getPreviousPointIndexAt(e)
  40161. , _ = this.getPointAt(i)
  40162. , b = this.getPreviousPointIndexAt(i) + 1
  40163. , k = [];
  40164. return e !== 0 && (d++,
  40165. k.push(c)),
  40166. k.push.apply(k, s.slice(d, b)),
  40167. (i !== 1 || e === 1) && k.push(_),
  40168. new a(k,this.getNormalAt(e),this._raw,this._alignTangentsWithPath)
  40169. }
  40170. ,
  40171. a.prototype.update = function(e, i, o) {
  40172. i === void 0 && (i = null),
  40173. o === void 0 && (o = !1);
  40174. for (var s = 0; s < e.length; s++)
  40175. this._curve[s].x = e[s].x,
  40176. this._curve[s].y = e[s].y,
  40177. this._curve[s].z = e[s].z;
  40178. return this._compute(i, o),
  40179. this
  40180. }
  40181. ,
  40182. a.prototype._compute = function(e, i) {
  40183. i === void 0 && (i = !1);
  40184. var o = this._curve.length;
  40185. if (!(o < 2)) {
  40186. this._tangents[0] = this._getFirstNonNullVector(0),
  40187. this._raw || this._tangents[0].normalize(),
  40188. this._tangents[o - 1] = this._curve[o - 1].subtract(this._curve[o - 2]),
  40189. this._raw || this._tangents[o - 1].normalize();
  40190. var s = this._tangents[0]
  40191. , c = this._normalVector(s, e);
  40192. this._normals[0] = c,
  40193. this._raw || this._normals[0].normalize(),
  40194. this._binormals[0] = Vector3.Cross(s, this._normals[0]),
  40195. this._raw || this._binormals[0].normalize(),
  40196. this._distances[0] = 0;
  40197. for (var d, _, b, k, j, $ = 1; $ < o; $++)
  40198. d = this._getLastNonNullVector($),
  40199. $ < o - 1 && (_ = this._getFirstNonNullVector($),
  40200. this._tangents[$] = i ? _ : d.add(_),
  40201. this._tangents[$].normalize()),
  40202. this._distances[$] = this._distances[$ - 1] + this._curve[$].subtract(this._curve[$ - 1]).length(),
  40203. b = this._tangents[$],
  40204. j = this._binormals[$ - 1],
  40205. this._normals[$] = Vector3.Cross(j, b),
  40206. this._raw || (this._normals[$].length() === 0 ? (k = this._normals[$ - 1],
  40207. this._normals[$] = k.clone()) : this._normals[$].normalize()),
  40208. this._binormals[$] = Vector3.Cross(b, this._normals[$]),
  40209. this._raw || this._binormals[$].normalize();
  40210. this._pointAtData.id = NaN
  40211. }
  40212. }
  40213. ,
  40214. a.prototype._getFirstNonNullVector = function(e) {
  40215. for (var i = 1, o = this._curve[e + i].subtract(this._curve[e]); o.length() === 0 && e + i + 1 < this._curve.length; )
  40216. i++,
  40217. o = this._curve[e + i].subtract(this._curve[e]);
  40218. return o
  40219. }
  40220. ,
  40221. a.prototype._getLastNonNullVector = function(e) {
  40222. for (var i = 1, o = this._curve[e].subtract(this._curve[e - i]); o.length() === 0 && e > i + 1; )
  40223. i++,
  40224. o = this._curve[e].subtract(this._curve[e - i]);
  40225. return o
  40226. }
  40227. ,
  40228. a.prototype._normalVector = function(e, i) {
  40229. var o, s = e.length();
  40230. if (s === 0 && (s = 1),
  40231. i == null) {
  40232. var c;
  40233. Scalar.WithinEpsilon(Math.abs(e.y) / s, 1, Epsilon) ? Scalar.WithinEpsilon(Math.abs(e.x) / s, 1, Epsilon) ? Scalar.WithinEpsilon(Math.abs(e.z) / s, 1, Epsilon) ? c = Vector3.Zero() : c = new Vector3(0,0,1) : c = new Vector3(1,0,0) : c = new Vector3(0,-1,0),
  40234. o = Vector3.Cross(e, c)
  40235. } else
  40236. o = Vector3.Cross(e, i),
  40237. Vector3.CrossToRef(o, e, o);
  40238. return o.normalize(),
  40239. o
  40240. }
  40241. ,
  40242. a.prototype._updatePointAtData = function(e, i) {
  40243. if (i === void 0 && (i = !1),
  40244. this._pointAtData.id === e)
  40245. return this._pointAtData.interpolateReady || this._updateInterpolationMatrix(),
  40246. this._pointAtData;
  40247. this._pointAtData.id = e;
  40248. var o = this.getPoints();
  40249. if (e <= 0)
  40250. return this._setPointAtData(0, 0, o[0], 0, i);
  40251. if (e >= 1)
  40252. return this._setPointAtData(1, 1, o[o.length - 1], o.length - 1, i);
  40253. for (var s = o[0], c, d = 0, _ = e * this.length(), b = 1; b < o.length; b++) {
  40254. c = o[b];
  40255. var k = Vector3.Distance(s, c);
  40256. if (d += k,
  40257. d === _)
  40258. return this._setPointAtData(e, 1, c, b, i);
  40259. if (d > _) {
  40260. var j = d - _
  40261. , $ = j / k
  40262. , _e = s.subtract(c)
  40263. , et = c.add(_e.scaleInPlace($));
  40264. return this._setPointAtData(e, 1 - $, et, b - 1, i)
  40265. }
  40266. s = c
  40267. }
  40268. return this._pointAtData
  40269. }
  40270. ,
  40271. a.prototype._setPointAtData = function(e, i, o, s, c) {
  40272. return this._pointAtData.point = o,
  40273. this._pointAtData.position = e,
  40274. this._pointAtData.subPosition = i,
  40275. this._pointAtData.previousPointArrayIndex = s,
  40276. this._pointAtData.interpolateReady = c,
  40277. c && this._updateInterpolationMatrix(),
  40278. this._pointAtData
  40279. }
  40280. ,
  40281. a.prototype._updateInterpolationMatrix = function() {
  40282. this._pointAtData.interpolationMatrix = Matrix.Identity();
  40283. var e = this._pointAtData.previousPointArrayIndex;
  40284. if (e !== this._tangents.length - 1) {
  40285. var i = e + 1
  40286. , o = this._tangents[e].clone()
  40287. , s = this._normals[e].clone()
  40288. , c = this._binormals[e].clone()
  40289. , d = this._tangents[i].clone()
  40290. , _ = this._normals[i].clone()
  40291. , b = this._binormals[i].clone()
  40292. , k = Quaternion.RotationQuaternionFromAxis(s, c, o)
  40293. , j = Quaternion.RotationQuaternionFromAxis(_, b, d)
  40294. , $ = Quaternion.Slerp(k, j, this._pointAtData.subPosition);
  40295. $.toRotationMatrix(this._pointAtData.interpolationMatrix)
  40296. }
  40297. }
  40298. ,
  40299. a
  40300. }()
  40301. , Curve3 = function() {
  40302. function a(e) {
  40303. this._length = 0,
  40304. this._points = e,
  40305. this._length = this._computeLength(e)
  40306. }
  40307. return a.CreateQuadraticBezier = function(e, i, o, s) {
  40308. s = s > 2 ? s : 3;
  40309. for (var c = new Array, d = function(b, k, j, $) {
  40310. var _e = (1 - b) * (1 - b) * k + 2 * b * (1 - b) * j + b * b * $;
  40311. return _e
  40312. }, _ = 0; _ <= s; _++)
  40313. c.push(new Vector3(d(_ / s, e.x, i.x, o.x),d(_ / s, e.y, i.y, o.y),d(_ / s, e.z, i.z, o.z)));
  40314. return new a(c)
  40315. }
  40316. ,
  40317. a.CreateCubicBezier = function(e, i, o, s, c) {
  40318. c = c > 3 ? c : 4;
  40319. for (var d = new Array, _ = function(k, j, $, _e, et) {
  40320. var tt = (1 - k) * (1 - k) * (1 - k) * j + 3 * k * (1 - k) * (1 - k) * $ + 3 * k * k * (1 - k) * _e + k * k * k * et;
  40321. return tt
  40322. }, b = 0; b <= c; b++)
  40323. d.push(new Vector3(_(b / c, e.x, i.x, o.x, s.x),_(b / c, e.y, i.y, o.y, s.y),_(b / c, e.z, i.z, o.z, s.z)));
  40324. return new a(d)
  40325. }
  40326. ,
  40327. a.CreateHermiteSpline = function(e, i, o, s, c) {
  40328. for (var d = new Array, _ = 1 / c, b = 0; b <= c; b++)
  40329. d.push(Vector3.Hermite(e, i, o, s, b * _));
  40330. return new a(d)
  40331. }
  40332. ,
  40333. a.CreateCatmullRomSpline = function(e, i, o) {
  40334. var s = new Array
  40335. , c = 1 / i
  40336. , d = 0;
  40337. if (o) {
  40338. for (var _ = e.length, b = 0; b < _; b++) {
  40339. d = 0;
  40340. for (var k = 0; k < i; k++)
  40341. s.push(Vector3.CatmullRom(e[b % _], e[(b + 1) % _], e[(b + 2) % _], e[(b + 3) % _], d)),
  40342. d += c
  40343. }
  40344. s.push(s[0])
  40345. } else {
  40346. var j = new Array;
  40347. j.push(e[0].clone()),
  40348. Array.prototype.push.apply(j, e),
  40349. j.push(e[e.length - 1].clone());
  40350. for (var b = 0; b < j.length - 3; b++) {
  40351. d = 0;
  40352. for (var k = 0; k < i; k++)
  40353. s.push(Vector3.CatmullRom(j[b], j[b + 1], j[b + 2], j[b + 3], d)),
  40354. d += c
  40355. }
  40356. b--,
  40357. s.push(Vector3.CatmullRom(j[b], j[b + 1], j[b + 2], j[b + 3], d))
  40358. }
  40359. return new a(s)
  40360. }
  40361. ,
  40362. a.prototype.getPoints = function() {
  40363. return this._points
  40364. }
  40365. ,
  40366. a.prototype.length = function() {
  40367. return this._length
  40368. }
  40369. ,
  40370. a.prototype.continue = function(e) {
  40371. for (var i = this._points[this._points.length - 1], o = this._points.slice(), s = e.getPoints(), c = 1; c < s.length; c++)
  40372. o.push(s[c].subtract(s[0]).add(i));
  40373. var d = new a(o);
  40374. return d
  40375. }
  40376. ,
  40377. a.prototype._computeLength = function(e) {
  40378. for (var i = 0, o = 1; o < e.length; o++)
  40379. i += e[o].subtract(e[o - 1]).length();
  40380. return i
  40381. }
  40382. ,
  40383. a
  40384. }()
  40385. , PositionNormalTextureVertex = function() {
  40386. function a(e, i, o) {
  40387. e === void 0 && (e = Vector3.Zero()),
  40388. i === void 0 && (i = Vector3.Up()),
  40389. o === void 0 && (o = Vector2.Zero()),
  40390. this.position = e,
  40391. this.normal = i,
  40392. this.uv = o
  40393. }
  40394. return a.prototype.clone = function() {
  40395. return new a(this.position.clone(),this.normal.clone(),this.uv.clone())
  40396. }
  40397. ,
  40398. a
  40399. }()
  40400. , SH3ylmBasisConstants = [Math.sqrt(1 / (4 * Math.PI)), -Math.sqrt(3 / (4 * Math.PI)), Math.sqrt(3 / (4 * Math.PI)), -Math.sqrt(3 / (4 * Math.PI)), Math.sqrt(15 / (4 * Math.PI)), -Math.sqrt(15 / (4 * Math.PI)), Math.sqrt(5 / (16 * Math.PI)), -Math.sqrt(15 / (4 * Math.PI)), Math.sqrt(15 / (16 * Math.PI))]
  40401. , SH3ylmBasisTrigonometricTerms = [function(a) {
  40402. return 1
  40403. }
  40404. , function(a) {
  40405. return a.y
  40406. }
  40407. , function(a) {
  40408. return a.z
  40409. }
  40410. , function(a) {
  40411. return a.x
  40412. }
  40413. , function(a) {
  40414. return a.x * a.y
  40415. }
  40416. , function(a) {
  40417. return a.y * a.z
  40418. }
  40419. , function(a) {
  40420. return 3 * a.z * a.z - 1
  40421. }
  40422. , function(a) {
  40423. return a.x * a.z
  40424. }
  40425. , function(a) {
  40426. return a.x * a.x - a.y * a.y
  40427. }
  40428. ]
  40429. , applySH3 = function(a, e) {
  40430. return SH3ylmBasisConstants[a] * SH3ylmBasisTrigonometricTerms[a](e)
  40431. }
  40432. , SHCosKernelConvolution = [Math.PI, 2 * Math.PI / 3, 2 * Math.PI / 3, 2 * Math.PI / 3, Math.PI / 4, Math.PI / 4, Math.PI / 4, Math.PI / 4, Math.PI / 4]
  40433. , SphericalHarmonics = function() {
  40434. function a() {
  40435. this.preScaled = !1,
  40436. this.l00 = Vector3.Zero(),
  40437. this.l1_1 = Vector3.Zero(),
  40438. this.l10 = Vector3.Zero(),
  40439. this.l11 = Vector3.Zero(),
  40440. this.l2_2 = Vector3.Zero(),
  40441. this.l2_1 = Vector3.Zero(),
  40442. this.l20 = Vector3.Zero(),
  40443. this.l21 = Vector3.Zero(),
  40444. this.l22 = Vector3.Zero()
  40445. }
  40446. return a.prototype.addLight = function(e, i, o) {
  40447. TmpVectors.Vector3[0].set(i.r, i.g, i.b);
  40448. var s = TmpVectors.Vector3[0]
  40449. , c = TmpVectors.Vector3[1];
  40450. s.scaleToRef(o, c),
  40451. c.scaleToRef(applySH3(0, e), TmpVectors.Vector3[2]),
  40452. this.l00.addInPlace(TmpVectors.Vector3[2]),
  40453. c.scaleToRef(applySH3(1, e), TmpVectors.Vector3[2]),
  40454. this.l1_1.addInPlace(TmpVectors.Vector3[2]),
  40455. c.scaleToRef(applySH3(2, e), TmpVectors.Vector3[2]),
  40456. this.l10.addInPlace(TmpVectors.Vector3[2]),
  40457. c.scaleToRef(applySH3(3, e), TmpVectors.Vector3[2]),
  40458. this.l11.addInPlace(TmpVectors.Vector3[2]),
  40459. c.scaleToRef(applySH3(4, e), TmpVectors.Vector3[2]),
  40460. this.l2_2.addInPlace(TmpVectors.Vector3[2]),
  40461. c.scaleToRef(applySH3(5, e), TmpVectors.Vector3[2]),
  40462. this.l2_1.addInPlace(TmpVectors.Vector3[2]),
  40463. c.scaleToRef(applySH3(6, e), TmpVectors.Vector3[2]),
  40464. this.l20.addInPlace(TmpVectors.Vector3[2]),
  40465. c.scaleToRef(applySH3(7, e), TmpVectors.Vector3[2]),
  40466. this.l21.addInPlace(TmpVectors.Vector3[2]),
  40467. c.scaleToRef(applySH3(8, e), TmpVectors.Vector3[2]),
  40468. this.l22.addInPlace(TmpVectors.Vector3[2])
  40469. }
  40470. ,
  40471. a.prototype.scaleInPlace = function(e) {
  40472. this.l00.scaleInPlace(e),
  40473. this.l1_1.scaleInPlace(e),
  40474. this.l10.scaleInPlace(e),
  40475. this.l11.scaleInPlace(e),
  40476. this.l2_2.scaleInPlace(e),
  40477. this.l2_1.scaleInPlace(e),
  40478. this.l20.scaleInPlace(e),
  40479. this.l21.scaleInPlace(e),
  40480. this.l22.scaleInPlace(e)
  40481. }
  40482. ,
  40483. a.prototype.convertIncidentRadianceToIrradiance = function() {
  40484. this.l00.scaleInPlace(SHCosKernelConvolution[0]),
  40485. this.l1_1.scaleInPlace(SHCosKernelConvolution[1]),
  40486. this.l10.scaleInPlace(SHCosKernelConvolution[2]),
  40487. this.l11.scaleInPlace(SHCosKernelConvolution[3]),
  40488. this.l2_2.scaleInPlace(SHCosKernelConvolution[4]),
  40489. this.l2_1.scaleInPlace(SHCosKernelConvolution[5]),
  40490. this.l20.scaleInPlace(SHCosKernelConvolution[6]),
  40491. this.l21.scaleInPlace(SHCosKernelConvolution[7]),
  40492. this.l22.scaleInPlace(SHCosKernelConvolution[8])
  40493. }
  40494. ,
  40495. a.prototype.convertIrradianceToLambertianRadiance = function() {
  40496. this.scaleInPlace(1 / Math.PI)
  40497. }
  40498. ,
  40499. a.prototype.preScaleForRendering = function() {
  40500. this.preScaled = !0,
  40501. this.l00.scaleInPlace(SH3ylmBasisConstants[0]),
  40502. this.l1_1.scaleInPlace(SH3ylmBasisConstants[1]),
  40503. this.l10.scaleInPlace(SH3ylmBasisConstants[2]),
  40504. this.l11.scaleInPlace(SH3ylmBasisConstants[3]),
  40505. this.l2_2.scaleInPlace(SH3ylmBasisConstants[4]),
  40506. this.l2_1.scaleInPlace(SH3ylmBasisConstants[5]),
  40507. this.l20.scaleInPlace(SH3ylmBasisConstants[6]),
  40508. this.l21.scaleInPlace(SH3ylmBasisConstants[7]),
  40509. this.l22.scaleInPlace(SH3ylmBasisConstants[8])
  40510. }
  40511. ,
  40512. a.prototype.updateFromArray = function(e) {
  40513. return Vector3.FromArrayToRef(e[0], 0, this.l00),
  40514. Vector3.FromArrayToRef(e[1], 0, this.l1_1),
  40515. Vector3.FromArrayToRef(e[2], 0, this.l10),
  40516. Vector3.FromArrayToRef(e[3], 0, this.l11),
  40517. Vector3.FromArrayToRef(e[4], 0, this.l2_2),
  40518. Vector3.FromArrayToRef(e[5], 0, this.l2_1),
  40519. Vector3.FromArrayToRef(e[6], 0, this.l20),
  40520. Vector3.FromArrayToRef(e[7], 0, this.l21),
  40521. Vector3.FromArrayToRef(e[8], 0, this.l22),
  40522. this
  40523. }
  40524. ,
  40525. a.prototype.updateFromFloatsArray = function(e) {
  40526. return Vector3.FromFloatsToRef(e[0], e[1], e[2], this.l00),
  40527. Vector3.FromFloatsToRef(e[3], e[4], e[5], this.l1_1),
  40528. Vector3.FromFloatsToRef(e[6], e[7], e[8], this.l10),
  40529. Vector3.FromFloatsToRef(e[9], e[10], e[11], this.l11),
  40530. Vector3.FromFloatsToRef(e[12], e[13], e[14], this.l2_2),
  40531. Vector3.FromFloatsToRef(e[15], e[16], e[17], this.l2_1),
  40532. Vector3.FromFloatsToRef(e[18], e[19], e[20], this.l20),
  40533. Vector3.FromFloatsToRef(e[21], e[22], e[23], this.l21),
  40534. Vector3.FromFloatsToRef(e[24], e[25], e[26], this.l22),
  40535. this
  40536. }
  40537. ,
  40538. a.FromArray = function(e) {
  40539. var i = new a;
  40540. return i.updateFromArray(e)
  40541. }
  40542. ,
  40543. a.FromPolynomial = function(e) {
  40544. var i = new a;
  40545. return i.l00 = e.xx.scale(.376127).add(e.yy.scale(.376127)).add(e.zz.scale(.376126)),
  40546. i.l1_1 = e.y.scale(.977204),
  40547. i.l10 = e.z.scale(.977204),
  40548. i.l11 = e.x.scale(.977204),
  40549. i.l2_2 = e.xy.scale(1.16538),
  40550. i.l2_1 = e.yz.scale(1.16538),
  40551. i.l20 = e.zz.scale(1.34567).subtract(e.xx.scale(.672834)).subtract(e.yy.scale(.672834)),
  40552. i.l21 = e.zx.scale(1.16538),
  40553. i.l22 = e.xx.scale(1.16538).subtract(e.yy.scale(1.16538)),
  40554. i.l1_1.scaleInPlace(-1),
  40555. i.l11.scaleInPlace(-1),
  40556. i.l2_1.scaleInPlace(-1),
  40557. i.l21.scaleInPlace(-1),
  40558. i.scaleInPlace(Math.PI),
  40559. i
  40560. }
  40561. ,
  40562. a
  40563. }()
  40564. , SphericalPolynomial = function() {
  40565. function a() {
  40566. this.x = Vector3.Zero(),
  40567. this.y = Vector3.Zero(),
  40568. this.z = Vector3.Zero(),
  40569. this.xx = Vector3.Zero(),
  40570. this.yy = Vector3.Zero(),
  40571. this.zz = Vector3.Zero(),
  40572. this.xy = Vector3.Zero(),
  40573. this.yz = Vector3.Zero(),
  40574. this.zx = Vector3.Zero()
  40575. }
  40576. return Object.defineProperty(a.prototype, "preScaledHarmonics", {
  40577. get: function() {
  40578. return this._harmonics || (this._harmonics = SphericalHarmonics.FromPolynomial(this)),
  40579. this._harmonics.preScaled || this._harmonics.preScaleForRendering(),
  40580. this._harmonics
  40581. },
  40582. enumerable: !1,
  40583. configurable: !0
  40584. }),
  40585. a.prototype.addAmbient = function(e) {
  40586. TmpVectors.Vector3[0].copyFromFloats(e.r, e.g, e.b);
  40587. var i = TmpVectors.Vector3[0];
  40588. this.xx.addInPlace(i),
  40589. this.yy.addInPlace(i),
  40590. this.zz.addInPlace(i)
  40591. }
  40592. ,
  40593. a.prototype.scaleInPlace = function(e) {
  40594. this.x.scaleInPlace(e),
  40595. this.y.scaleInPlace(e),
  40596. this.z.scaleInPlace(e),
  40597. this.xx.scaleInPlace(e),
  40598. this.yy.scaleInPlace(e),
  40599. this.zz.scaleInPlace(e),
  40600. this.yz.scaleInPlace(e),
  40601. this.zx.scaleInPlace(e),
  40602. this.xy.scaleInPlace(e)
  40603. }
  40604. ,
  40605. a.prototype.updateFromHarmonics = function(e) {
  40606. return this._harmonics = e,
  40607. this.x.copyFrom(e.l11),
  40608. this.x.scaleInPlace(1.02333).scaleInPlace(-1),
  40609. this.y.copyFrom(e.l1_1),
  40610. this.y.scaleInPlace(1.02333).scaleInPlace(-1),
  40611. this.z.copyFrom(e.l10),
  40612. this.z.scaleInPlace(1.02333),
  40613. this.xx.copyFrom(e.l00),
  40614. TmpVectors.Vector3[0].copyFrom(e.l20).scaleInPlace(.247708),
  40615. TmpVectors.Vector3[1].copyFrom(e.l22).scaleInPlace(.429043),
  40616. this.xx.scaleInPlace(.886277).subtractInPlace(TmpVectors.Vector3[0]).addInPlace(TmpVectors.Vector3[1]),
  40617. this.yy.copyFrom(e.l00),
  40618. this.yy.scaleInPlace(.886277).subtractInPlace(TmpVectors.Vector3[0]).subtractInPlace(TmpVectors.Vector3[1]),
  40619. this.zz.copyFrom(e.l00),
  40620. TmpVectors.Vector3[0].copyFrom(e.l20).scaleInPlace(.495417),
  40621. this.zz.scaleInPlace(.886277).addInPlace(TmpVectors.Vector3[0]),
  40622. this.yz.copyFrom(e.l2_1),
  40623. this.yz.scaleInPlace(.858086).scaleInPlace(-1),
  40624. this.zx.copyFrom(e.l21),
  40625. this.zx.scaleInPlace(.858086).scaleInPlace(-1),
  40626. this.xy.copyFrom(e.l2_2),
  40627. this.xy.scaleInPlace(.858086),
  40628. this.scaleInPlace(1 / Math.PI),
  40629. this
  40630. }
  40631. ,
  40632. a.FromHarmonics = function(e) {
  40633. var i = new a;
  40634. return i.updateFromHarmonics(e)
  40635. }
  40636. ,
  40637. a.FromArray = function(e) {
  40638. var i = new a;
  40639. return Vector3.FromArrayToRef(e[0], 0, i.x),
  40640. Vector3.FromArrayToRef(e[1], 0, i.y),
  40641. Vector3.FromArrayToRef(e[2], 0, i.z),
  40642. Vector3.FromArrayToRef(e[3], 0, i.xx),
  40643. Vector3.FromArrayToRef(e[4], 0, i.yy),
  40644. Vector3.FromArrayToRef(e[5], 0, i.zz),
  40645. Vector3.FromArrayToRef(e[6], 0, i.yz),
  40646. Vector3.FromArrayToRef(e[7], 0, i.zx),
  40647. Vector3.FromArrayToRef(e[8], 0, i.xy),
  40648. i
  40649. }
  40650. ,
  40651. a
  40652. }()
  40653. , name$2$ = "postprocessVertexShader"
  40654. , shader$2$ = `
  40655. attribute vec2 position;
  40656. uniform vec2 scale;
  40657. varying vec2 vUV;
  40658. const vec2 madd=vec2(0.5,0.5);
  40659. void main(void) {
  40660. vUV=(position*madd+madd)*scale;
  40661. gl_Position=vec4(position,0.0,1.0);
  40662. }`;
  40663. ShaderStore.ShadersStore[name$2$] = shader$2$;
  40664. var PostProcess = function() {
  40665. function a(e, i, o, s, c, d, _, b, k, j, $, _e, et, tt, rt) {
  40666. _ === void 0 && (_ = 1),
  40667. j === void 0 && (j = null),
  40668. $ === void 0 && ($ = 0),
  40669. _e === void 0 && (_e = "postprocess"),
  40670. tt === void 0 && (tt = !1),
  40671. rt === void 0 && (rt = 5),
  40672. this._parentContainer = null,
  40673. this.width = -1,
  40674. this.height = -1,
  40675. this.nodeMaterialSource = null,
  40676. this._outputTexture = null,
  40677. this.autoClear = !0,
  40678. this.alphaMode = 0,
  40679. this.animations = new Array,
  40680. this.enablePixelPerfectMode = !1,
  40681. this.forceFullscreenViewport = !0,
  40682. this.scaleMode = 1,
  40683. this.alwaysForcePOT = !1,
  40684. this._samples = 1,
  40685. this.adaptScaleToCurrentViewport = !1,
  40686. this._reusable = !1,
  40687. this._renderId = 0,
  40688. this.externalTextureSamplerBinding = !1,
  40689. this._textures = new SmartArray(2),
  40690. this._textureCache = [],
  40691. this._currentRenderTextureInd = 0,
  40692. this._scaleRatio = new Vector2(1,1),
  40693. this._texelSize = Vector2.Zero(),
  40694. this.onActivateObservable = new Observable,
  40695. this.onSizeChangedObservable = new Observable,
  40696. this.onApplyObservable = new Observable,
  40697. this.onBeforeRenderObservable = new Observable,
  40698. this.onAfterRenderObservable = new Observable,
  40699. this.name = e,
  40700. d != null ? (this._camera = d,
  40701. this._scene = d.getScene(),
  40702. d.attachPostProcess(this),
  40703. this._engine = this._scene.getEngine(),
  40704. this._scene.postProcesses.push(this),
  40705. this.uniqueId = this._scene.getUniqueId()) : b && (this._engine = b,
  40706. this._engine.postProcesses.push(this)),
  40707. this._options = c,
  40708. this.renderTargetSamplingMode = _ || 1,
  40709. this._reusable = k || !1,
  40710. this._textureType = $,
  40711. this._textureFormat = rt,
  40712. this._samplers = s || [],
  40713. this._samplers.push("textureSampler"),
  40714. this._fragmentUrl = i,
  40715. this._vertexUrl = _e,
  40716. this._parameters = o || [],
  40717. this._parameters.push("scale"),
  40718. this._indexParameters = et,
  40719. this._drawWrapper = new DrawWrapper(this._engine),
  40720. tt || this.updateEffect(j)
  40721. }
  40722. return Object.defineProperty(a.prototype, "samples", {
  40723. get: function() {
  40724. return this._samples
  40725. },
  40726. set: function(e) {
  40727. var i = this;
  40728. this._samples = Math.min(e, this._engine.getCaps().maxMSAASamples),
  40729. this._textures.forEach(function(o) {
  40730. o.samples !== i._samples && i._engine.updateRenderTargetTextureSampleCount(o, i._samples)
  40731. })
  40732. },
  40733. enumerable: !1,
  40734. configurable: !0
  40735. }),
  40736. a.prototype.getEffectName = function() {
  40737. return this._fragmentUrl
  40738. }
  40739. ,
  40740. Object.defineProperty(a.prototype, "onActivate", {
  40741. set: function(e) {
  40742. this._onActivateObserver && this.onActivateObservable.remove(this._onActivateObserver),
  40743. e && (this._onActivateObserver = this.onActivateObservable.add(e))
  40744. },
  40745. enumerable: !1,
  40746. configurable: !0
  40747. }),
  40748. Object.defineProperty(a.prototype, "onSizeChanged", {
  40749. set: function(e) {
  40750. this._onSizeChangedObserver && this.onSizeChangedObservable.remove(this._onSizeChangedObserver),
  40751. this._onSizeChangedObserver = this.onSizeChangedObservable.add(e)
  40752. },
  40753. enumerable: !1,
  40754. configurable: !0
  40755. }),
  40756. Object.defineProperty(a.prototype, "onApply", {
  40757. set: function(e) {
  40758. this._onApplyObserver && this.onApplyObservable.remove(this._onApplyObserver),
  40759. this._onApplyObserver = this.onApplyObservable.add(e)
  40760. },
  40761. enumerable: !1,
  40762. configurable: !0
  40763. }),
  40764. Object.defineProperty(a.prototype, "onBeforeRender", {
  40765. set: function(e) {
  40766. this._onBeforeRenderObserver && this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),
  40767. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(e)
  40768. },
  40769. enumerable: !1,
  40770. configurable: !0
  40771. }),
  40772. Object.defineProperty(a.prototype, "onAfterRender", {
  40773. set: function(e) {
  40774. this._onAfterRenderObserver && this.onAfterRenderObservable.remove(this._onAfterRenderObserver),
  40775. this._onAfterRenderObserver = this.onAfterRenderObservable.add(e)
  40776. },
  40777. enumerable: !1,
  40778. configurable: !0
  40779. }),
  40780. Object.defineProperty(a.prototype, "inputTexture", {
  40781. get: function() {
  40782. return this._textures.data[this._currentRenderTextureInd]
  40783. },
  40784. set: function(e) {
  40785. this._forcedOutputTexture = e
  40786. },
  40787. enumerable: !1,
  40788. configurable: !0
  40789. }),
  40790. a.prototype.restoreDefaultInputTexture = function() {
  40791. this._forcedOutputTexture && (this._forcedOutputTexture = null,
  40792. this.markTextureDirty())
  40793. }
  40794. ,
  40795. a.prototype.getCamera = function() {
  40796. return this._camera
  40797. }
  40798. ,
  40799. Object.defineProperty(a.prototype, "texelSize", {
  40800. get: function() {
  40801. return this._shareOutputWithPostProcess ? this._shareOutputWithPostProcess.texelSize : (this._forcedOutputTexture && this._texelSize.copyFromFloats(1 / this._forcedOutputTexture.width, 1 / this._forcedOutputTexture.height),
  40802. this._texelSize)
  40803. },
  40804. enumerable: !1,
  40805. configurable: !0
  40806. }),
  40807. a.prototype.getClassName = function() {
  40808. return "PostProcess"
  40809. }
  40810. ,
  40811. a.prototype.getEngine = function() {
  40812. return this._engine
  40813. }
  40814. ,
  40815. a.prototype.getEffect = function() {
  40816. return this._drawWrapper.effect
  40817. }
  40818. ,
  40819. a.prototype.shareOutputWith = function(e) {
  40820. return this._disposeTextures(),
  40821. this._shareOutputWithPostProcess = e,
  40822. this
  40823. }
  40824. ,
  40825. a.prototype.useOwnOutput = function() {
  40826. this._textures.length == 0 && (this._textures = new SmartArray(2)),
  40827. this._shareOutputWithPostProcess = null
  40828. }
  40829. ,
  40830. a.prototype.updateEffect = function(e, i, o, s, c, d, _, b) {
  40831. e === void 0 && (e = null),
  40832. i === void 0 && (i = null),
  40833. o === void 0 && (o = null),
  40834. this._postProcessDefines = e,
  40835. this._drawWrapper.effect = this._engine.createEffect({
  40836. vertex: _ != null ? _ : this._vertexUrl,
  40837. fragment: b != null ? b : this._fragmentUrl
  40838. }, ["position"], i || this._parameters, o || this._samplers, e !== null ? e : "", void 0, c, d, s || this._indexParameters)
  40839. }
  40840. ,
  40841. a.prototype.isReusable = function() {
  40842. return this._reusable
  40843. }
  40844. ,
  40845. a.prototype.markTextureDirty = function() {
  40846. this.width = -1
  40847. }
  40848. ,
  40849. a.prototype._createRenderTargetTexture = function(e, i, o) {
  40850. o === void 0 && (o = 0);
  40851. for (var s = 0; s < this._textureCache.length; s++)
  40852. if (this._textureCache[s].texture.width === e.width && this._textureCache[s].texture.height === e.height && this._textureCache[s].postProcessChannel === o && this._textureCache[s].texture._generateDepthBuffer === i.generateDepthBuffer)
  40853. return this._textureCache[s].texture;
  40854. var c = this._engine.createRenderTargetTexture(e, i);
  40855. return this._textureCache.push({
  40856. texture: c,
  40857. postProcessChannel: o,
  40858. lastUsedRenderId: -1
  40859. }),
  40860. c
  40861. }
  40862. ,
  40863. a.prototype._flushTextureCache = function() {
  40864. for (var e = this._renderId, i = this._textureCache.length - 1; i >= 0; i--)
  40865. if (e - this._textureCache[i].lastUsedRenderId > 100) {
  40866. for (var o = !1, s = 0; s < this._textures.length; s++)
  40867. if (this._textures.data[s] === this._textureCache[i].texture) {
  40868. o = !0;
  40869. break
  40870. }
  40871. o || (this._textureCache[i].texture.dispose(),
  40872. this._textureCache.splice(i, 1))
  40873. }
  40874. }
  40875. ,
  40876. a.prototype._resize = function(e, i, o, s, c) {
  40877. this._textures.length > 0 && this._textures.reset(),
  40878. this.width = e,
  40879. this.height = i;
  40880. for (var d = null, _ = 0; _ < o._postProcesses.length; _++)
  40881. if (o._postProcesses[_] !== null) {
  40882. d = o._postProcesses[_];
  40883. break
  40884. }
  40885. var b = {
  40886. width: this.width,
  40887. height: this.height
  40888. }
  40889. , k = {
  40890. generateMipMaps: s,
  40891. generateDepthBuffer: c || d === this,
  40892. generateStencilBuffer: (c || d === this) && this._engine.isStencilEnable,
  40893. samplingMode: this.renderTargetSamplingMode,
  40894. type: this._textureType,
  40895. format: this._textureFormat
  40896. };
  40897. this._textures.push(this._createRenderTargetTexture(b, k, 0)),
  40898. this._reusable && this._textures.push(this._createRenderTargetTexture(b, k, 1)),
  40899. this._texelSize.copyFromFloats(1 / this.width, 1 / this.height),
  40900. this.onSizeChangedObservable.notifyObservers(this)
  40901. }
  40902. ,
  40903. a.prototype.activate = function(e, i, o) {
  40904. var s = this, c, d;
  40905. i === void 0 && (i = null),
  40906. e = e || this._camera;
  40907. var _ = e.getScene()
  40908. , b = _.getEngine()
  40909. , k = b.getCaps().maxTextureSize
  40910. , j = (i ? i.width : this._engine.getRenderWidth(!0)) * this._options | 0
  40911. , $ = (i ? i.height : this._engine.getRenderHeight(!0)) * this._options | 0
  40912. , _e = e.parent;
  40913. _e && (_e.leftCamera == e || _e.rightCamera == e) && (j /= 2);
  40914. var et = this._options.width || j
  40915. , tt = this._options.height || $
  40916. , rt = this.renderTargetSamplingMode !== 7 && this.renderTargetSamplingMode !== 1 && this.renderTargetSamplingMode !== 2;
  40917. if (!this._shareOutputWithPostProcess && !this._forcedOutputTexture) {
  40918. if (this.adaptScaleToCurrentViewport) {
  40919. var it = b.currentViewport;
  40920. it && (et *= it.width,
  40921. tt *= it.height)
  40922. }
  40923. (rt || this.alwaysForcePOT) && (this._options.width || (et = b.needPOTTextures ? Engine.GetExponentOfTwo(et, k, this.scaleMode) : et),
  40924. this._options.height || (tt = b.needPOTTextures ? Engine.GetExponentOfTwo(tt, k, this.scaleMode) : tt)),
  40925. (this.width !== et || this.height !== tt) && this._resize(et, tt, e, rt, o),
  40926. this._textures.forEach(function(st) {
  40927. st.samples !== s.samples && s._engine.updateRenderTargetTextureSampleCount(st, s.samples)
  40928. }),
  40929. this._flushTextureCache(),
  40930. this._renderId++
  40931. }
  40932. var nt;
  40933. if (this._shareOutputWithPostProcess)
  40934. nt = this._shareOutputWithPostProcess.inputTexture;
  40935. else if (this._forcedOutputTexture)
  40936. nt = this._forcedOutputTexture,
  40937. this.width = this._forcedOutputTexture.width,
  40938. this.height = this._forcedOutputTexture.height;
  40939. else {
  40940. nt = this.inputTexture;
  40941. for (var ot = void 0, at = 0; at < this._textureCache.length; at++)
  40942. if (this._textureCache[at].texture === nt) {
  40943. ot = this._textureCache[at];
  40944. break
  40945. }
  40946. ot && (ot.lastUsedRenderId = this._renderId)
  40947. }
  40948. return this.enablePixelPerfectMode ? (this._scaleRatio.copyFromFloats(j / et, $ / tt),
  40949. this._engine.bindFramebuffer(nt, 0, j, $, this.forceFullscreenViewport)) : (this._scaleRatio.copyFromFloats(1, 1),
  40950. this._engine.bindFramebuffer(nt, 0, void 0, void 0, this.forceFullscreenViewport)),
  40951. (d = (c = this._engine)._debugInsertMarker) === null || d === void 0 || d.call(c, "post process " + this.name + " input"),
  40952. this.onActivateObservable.notifyObservers(e),
  40953. this.autoClear && this.alphaMode === 0 && this._engine.clear(this.clearColor ? this.clearColor : _.clearColor, _._allowPostProcessClearColor, !0, !0),
  40954. this._reusable && (this._currentRenderTextureInd = (this._currentRenderTextureInd + 1) % 2),
  40955. nt
  40956. }
  40957. ,
  40958. Object.defineProperty(a.prototype, "isSupported", {
  40959. get: function() {
  40960. return this._drawWrapper.effect.isSupported
  40961. },
  40962. enumerable: !1,
  40963. configurable: !0
  40964. }),
  40965. Object.defineProperty(a.prototype, "aspectRatio", {
  40966. get: function() {
  40967. return this._shareOutputWithPostProcess ? this._shareOutputWithPostProcess.aspectRatio : this._forcedOutputTexture ? this._forcedOutputTexture.width / this._forcedOutputTexture.height : this.width / this.height
  40968. },
  40969. enumerable: !1,
  40970. configurable: !0
  40971. }),
  40972. a.prototype.isReady = function() {
  40973. var e, i;
  40974. return (i = (e = this._drawWrapper.effect) === null || e === void 0 ? void 0 : e.isReady()) !== null && i !== void 0 ? i : !1
  40975. }
  40976. ,
  40977. a.prototype.apply = function() {
  40978. var e;
  40979. if (!(!((e = this._drawWrapper.effect) === null || e === void 0) && e.isReady()))
  40980. return null;
  40981. this._engine.enableEffect(this._drawWrapper),
  40982. this._engine.setState(!1),
  40983. this._engine.setDepthBuffer(!1),
  40984. this._engine.setDepthWrite(!1),
  40985. this._engine.setAlphaMode(this.alphaMode),
  40986. this.alphaConstants && this.getEngine().setAlphaConstants(this.alphaConstants.r, this.alphaConstants.g, this.alphaConstants.b, this.alphaConstants.a);
  40987. var i;
  40988. return this._shareOutputWithPostProcess ? i = this._shareOutputWithPostProcess.inputTexture : this._forcedOutputTexture ? i = this._forcedOutputTexture : i = this.inputTexture,
  40989. this.externalTextureSamplerBinding || this._drawWrapper.effect._bindTexture("textureSampler", i == null ? void 0 : i.texture),
  40990. this._drawWrapper.effect.setVector2("scale", this._scaleRatio),
  40991. this.onApplyObservable.notifyObservers(this._drawWrapper.effect),
  40992. this._drawWrapper.effect
  40993. }
  40994. ,
  40995. a.prototype._disposeTextures = function() {
  40996. if (this._shareOutputWithPostProcess || this._forcedOutputTexture) {
  40997. this._disposeTextureCache();
  40998. return
  40999. }
  41000. this._disposeTextureCache(),
  41001. this._textures.dispose()
  41002. }
  41003. ,
  41004. a.prototype._disposeTextureCache = function() {
  41005. for (var e = this._textureCache.length - 1; e >= 0; e--)
  41006. this._textureCache[e].texture.dispose();
  41007. this._textureCache.length = 0
  41008. }
  41009. ,
  41010. a.prototype.setPrePassRenderer = function(e) {
  41011. return this._prePassEffectConfiguration ? (this._prePassEffectConfiguration = e.addEffectConfiguration(this._prePassEffectConfiguration),
  41012. this._prePassEffectConfiguration.enabled = !0,
  41013. !0) : !1
  41014. }
  41015. ,
  41016. a.prototype.dispose = function(e) {
  41017. e = e || this._camera,
  41018. this._disposeTextures();
  41019. var i;
  41020. if (this._scene && (i = this._scene.postProcesses.indexOf(this),
  41021. i !== -1 && this._scene.postProcesses.splice(i, 1)),
  41022. this._parentContainer) {
  41023. var o = this._parentContainer.postProcesses.indexOf(this);
  41024. o > -1 && this._parentContainer.postProcesses.splice(o, 1),
  41025. this._parentContainer = null
  41026. }
  41027. if (i = this._engine.postProcesses.indexOf(this),
  41028. i !== -1 && this._engine.postProcesses.splice(i, 1),
  41029. !!e) {
  41030. if (e.detachPostProcess(this),
  41031. i = e._postProcesses.indexOf(this),
  41032. i === 0 && e._postProcesses.length > 0) {
  41033. var s = this._camera._getFirstPostProcess();
  41034. s && s.markTextureDirty()
  41035. }
  41036. this.onActivateObservable.clear(),
  41037. this.onAfterRenderObservable.clear(),
  41038. this.onApplyObservable.clear(),
  41039. this.onBeforeRenderObservable.clear(),
  41040. this.onSizeChangedObservable.clear()
  41041. }
  41042. }
  41043. ,
  41044. a.prototype.serialize = function() {
  41045. var e = SerializationHelper.Serialize(this)
  41046. , i = this.getCamera() || this._scene && this._scene.activeCamera;
  41047. return e.customType = "BABYLON." + this.getClassName(),
  41048. e.cameraId = i ? i.id : null,
  41049. e.reusable = this._reusable,
  41050. e.textureType = this._textureType,
  41051. e.fragmentUrl = this._fragmentUrl,
  41052. e.parameters = this._parameters,
  41053. e.samplers = this._samplers,
  41054. e.options = this._options,
  41055. e.defines = this._postProcessDefines,
  41056. e.textureFormat = this._textureFormat,
  41057. e.vertexUrl = this._vertexUrl,
  41058. e.indexParameters = this._indexParameters,
  41059. e
  41060. }
  41061. ,
  41062. a.prototype.clone = function() {
  41063. var e = this.serialize();
  41064. e._engine = this._engine,
  41065. e.cameraId = null;
  41066. var i = a.Parse(e, this._scene, "");
  41067. return i ? (i.onActivateObservable = this.onActivateObservable.clone(),
  41068. i.onSizeChangedObservable = this.onSizeChangedObservable.clone(),
  41069. i.onApplyObservable = this.onApplyObservable.clone(),
  41070. i.onBeforeRenderObservable = this.onBeforeRenderObservable.clone(),
  41071. i.onAfterRenderObservable = this.onAfterRenderObservable.clone(),
  41072. i._prePassEffectConfiguration = this._prePassEffectConfiguration,
  41073. i) : null
  41074. }
  41075. ,
  41076. a.Parse = function(e, i, o) {
  41077. var s = GetClass(e.customType);
  41078. if (!s || !s._Parse)
  41079. return null;
  41080. var c = i ? i.getCameraById(e.cameraId) : null;
  41081. return s._Parse(e, c, i, o)
  41082. }
  41083. ,
  41084. a._Parse = function(e, i, o, s) {
  41085. return SerializationHelper.Parse(function() {
  41086. return new a(e.name,e.fragmentUrl,e.parameters,e.samplers,e.options,i,e.renderTargetSamplingMode,e._engine,e.reusable,e.defines,e.textureType,e.vertexUrl,e.indexParameters,!1,e.textureFormat)
  41087. }, e, o, s)
  41088. }
  41089. ,
  41090. __decorate([serialize()], a.prototype, "uniqueId", void 0),
  41091. __decorate([serialize()], a.prototype, "name", void 0),
  41092. __decorate([serialize()], a.prototype, "width", void 0),
  41093. __decorate([serialize()], a.prototype, "height", void 0),
  41094. __decorate([serialize()], a.prototype, "renderTargetSamplingMode", void 0),
  41095. __decorate([serializeAsColor4()], a.prototype, "clearColor", void 0),
  41096. __decorate([serialize()], a.prototype, "autoClear", void 0),
  41097. __decorate([serialize()], a.prototype, "alphaMode", void 0),
  41098. __decorate([serialize()], a.prototype, "alphaConstants", void 0),
  41099. __decorate([serialize()], a.prototype, "enablePixelPerfectMode", void 0),
  41100. __decorate([serialize()], a.prototype, "forceFullscreenViewport", void 0),
  41101. __decorate([serialize()], a.prototype, "scaleMode", void 0),
  41102. __decorate([serialize()], a.prototype, "alwaysForcePOT", void 0),
  41103. __decorate([serialize("samples")], a.prototype, "_samples", void 0),
  41104. __decorate([serialize()], a.prototype, "adaptScaleToCurrentViewport", void 0),
  41105. a
  41106. }();
  41107. RegisterClass("BABYLON.PostProcess", PostProcess);
  41108. var name$2_ = "helperFunctions"
  41109. , shader$2_ = `const float PI=3.1415926535897932384626433832795;
  41110. const float HALF_MIN=5.96046448e-08;
  41111. const float LinearEncodePowerApprox=2.2;
  41112. const float GammaEncodePowerApprox=1.0/LinearEncodePowerApprox;
  41113. const vec3 LuminanceEncodeApprox=vec3(0.2126,0.7152,0.0722);
  41114. const float Epsilon=0.0000001;
  41115. #define saturate(x) clamp(x,0.0,1.0)
  41116. #define absEps(x) abs(x)+Epsilon
  41117. #define maxEps(x) max(x,Epsilon)
  41118. #define saturateEps(x) clamp(x,Epsilon,1.0)
  41119. mat3 transposeMat3(mat3 inMatrix) {
  41120. vec3 i0=inMatrix[0];
  41121. vec3 i1=inMatrix[1];
  41122. vec3 i2=inMatrix[2];
  41123. mat3 outMatrix=mat3(
  41124. vec3(i0.x,i1.x,i2.x),
  41125. vec3(i0.y,i1.y,i2.y),
  41126. vec3(i0.z,i1.z,i2.z)
  41127. );
  41128. return outMatrix;
  41129. }
  41130. mat3 inverseMat3(mat3 inMatrix) {
  41131. float a00=inMatrix[0][0],a01=inMatrix[0][1],a02=inMatrix[0][2];
  41132. float a10=inMatrix[1][0],a11=inMatrix[1][1],a12=inMatrix[1][2];
  41133. float a20=inMatrix[2][0],a21=inMatrix[2][1],a22=inMatrix[2][2];
  41134. float b01=a22*a11-a12*a21;
  41135. float b11=-a22*a10+a12*a20;
  41136. float b21=a21*a10-a11*a20;
  41137. float det=a00*b01+a01*b11+a02*b21;
  41138. return mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),
  41139. b11,(a22*a00-a02*a20),(-a12*a00+a02*a10),
  41140. b21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;
  41141. }
  41142. float toLinearSpace(float color)
  41143. {
  41144. return pow(color,LinearEncodePowerApprox);
  41145. }
  41146. vec3 toLinearSpace(vec3 color)
  41147. {
  41148. return pow(color,vec3(LinearEncodePowerApprox));
  41149. }
  41150. vec4 toLinearSpace(vec4 color)
  41151. {
  41152. return vec4(pow(color.rgb,vec3(LinearEncodePowerApprox)),color.a);
  41153. }
  41154. vec3 toGammaSpace(vec3 color)
  41155. {
  41156. return pow(color,vec3(GammaEncodePowerApprox));
  41157. }
  41158. vec4 toGammaSpace(vec4 color)
  41159. {
  41160. return vec4(pow(color.rgb,vec3(GammaEncodePowerApprox)),color.a);
  41161. }
  41162. float toGammaSpace(float color)
  41163. {
  41164. return pow(color,GammaEncodePowerApprox);
  41165. }
  41166. float square(float value)
  41167. {
  41168. return value*value;
  41169. }
  41170. float pow5(float value) {
  41171. float sq=value*value;
  41172. return sq*sq*value;
  41173. }
  41174. float getLuminance(vec3 color)
  41175. {
  41176. return clamp(dot(color,LuminanceEncodeApprox),0.,1.);
  41177. }
  41178. float getRand(vec2 seed) {
  41179. return fract(sin(dot(seed.xy ,vec2(12.9898,78.233)))*43758.5453);
  41180. }
  41181. float dither(vec2 seed,float varianceAmount) {
  41182. float rand=getRand(seed);
  41183. float dither=mix(-varianceAmount/255.0,varianceAmount/255.0,rand);
  41184. return dither;
  41185. }
  41186. const float rgbdMaxRange=255.0;
  41187. vec4 toRGBD(vec3 color) {
  41188. float maxRGB=maxEps(max(color.r,max(color.g,color.b)));
  41189. float D=max(rgbdMaxRange/maxRGB,1.);
  41190. D=clamp(floor(D)/255.0,0.,1.);
  41191. vec3 rgb=color.rgb*D;
  41192. rgb=toGammaSpace(rgb);
  41193. return vec4(clamp(rgb,0.,1.),D);
  41194. }
  41195. vec3 fromRGBD(vec4 rgbd) {
  41196. rgbd.rgb=toLinearSpace(rgbd.rgb);
  41197. return rgbd.rgb/rgbd.a;
  41198. }
  41199. vec3 parallaxCorrectNormal( vec3 vertexPos,vec3 origVec,vec3 cubeSize,vec3 cubePos ) {
  41200. vec3 invOrigVec=vec3(1.0,1.0,1.0)/origVec;
  41201. vec3 halfSize=cubeSize*0.5;
  41202. vec3 intersecAtMaxPlane=(cubePos+halfSize-vertexPos)*invOrigVec;
  41203. vec3 intersecAtMinPlane=(cubePos-halfSize-vertexPos)*invOrigVec;
  41204. vec3 largestIntersec=max(intersecAtMaxPlane,intersecAtMinPlane);
  41205. float distance=min(min(largestIntersec.x,largestIntersec.y),largestIntersec.z);
  41206. vec3 intersectPositionWS=vertexPos+origVec*distance;
  41207. return intersectPositionWS-cubePos;
  41208. }
  41209. `;
  41210. ShaderStore.IncludesShadersStore[name$2_] = shader$2_;
  41211. var name$2Z = "rgbdDecodePixelShader"
  41212. , shader$2Z = `
  41213. varying vec2 vUV;
  41214. uniform sampler2D textureSampler;
  41215. #include<helperFunctions>
  41216. void main(void)
  41217. {
  41218. gl_FragColor=vec4(fromRGBD(texture2D(textureSampler,vUV)),1.0);
  41219. }`;
  41220. ShaderStore.ShadersStore[name$2Z] = shader$2Z;
  41221. var name$2Y = "passPixelShader"
  41222. , shader$2Y = `
  41223. varying vec2 vUV;
  41224. uniform sampler2D textureSampler;
  41225. void main(void)
  41226. {
  41227. gl_FragColor=texture2D(textureSampler,vUV);
  41228. }`;
  41229. ShaderStore.ShadersStore[name$2Y] = shader$2Y;
  41230. var name$2X = "passCubePixelShader"
  41231. , shader$2X = `
  41232. varying vec2 vUV;
  41233. uniform samplerCube textureSampler;
  41234. void main(void)
  41235. {
  41236. vec2 uv=vUV*2.0-1.0;
  41237. #ifdef POSITIVEX
  41238. gl_FragColor=textureCube(textureSampler,vec3(1.001,uv.y,uv.x));
  41239. #endif
  41240. #ifdef NEGATIVEX
  41241. gl_FragColor=textureCube(textureSampler,vec3(-1.001,uv.y,uv.x));
  41242. #endif
  41243. #ifdef POSITIVEY
  41244. gl_FragColor=textureCube(textureSampler,vec3(uv.y,1.001,uv.x));
  41245. #endif
  41246. #ifdef NEGATIVEY
  41247. gl_FragColor=textureCube(textureSampler,vec3(uv.y,-1.001,uv.x));
  41248. #endif
  41249. #ifdef POSITIVEZ
  41250. gl_FragColor=textureCube(textureSampler,vec3(uv,1.001));
  41251. #endif
  41252. #ifdef NEGATIVEZ
  41253. gl_FragColor=textureCube(textureSampler,vec3(uv,-1.001));
  41254. #endif
  41255. }`;
  41256. ShaderStore.ShadersStore[name$2X] = shader$2X;
  41257. var PassPostProcess = function(a) {
  41258. __extends(e, a);
  41259. function e(i, o, s, c, d, _, b, k) {
  41260. return s === void 0 && (s = null),
  41261. b === void 0 && (b = 0),
  41262. k === void 0 && (k = !1),
  41263. a.call(this, i, "pass", null, null, o, s, c, d, _, void 0, b, void 0, null, k) || this
  41264. }
  41265. return e.prototype.getClassName = function() {
  41266. return "PassPostProcess"
  41267. }
  41268. ,
  41269. e._Parse = function(i, o, s, c) {
  41270. return SerializationHelper.Parse(function() {
  41271. return new e(i.name,i.options,o,i.renderTargetSamplingMode,i._engine,i.reusable)
  41272. }, i, s, c)
  41273. }
  41274. ,
  41275. e
  41276. }(PostProcess);
  41277. RegisterClass("BABYLON.PassPostProcess", PassPostProcess);
  41278. (function(a) {
  41279. __extends(e, a);
  41280. function e(i, o, s, c, d, _, b, k) {
  41281. s === void 0 && (s = null),
  41282. b === void 0 && (b = 0),
  41283. k === void 0 && (k = !1);
  41284. var j = a.call(this, i, "passCube", null, null, o, s, c, d, _, "#define POSITIVEX", b, void 0, null, k) || this;
  41285. return j._face = 0,
  41286. j
  41287. }
  41288. return Object.defineProperty(e.prototype, "face", {
  41289. get: function() {
  41290. return this._face
  41291. },
  41292. set: function(i) {
  41293. if (!(i < 0 || i > 5))
  41294. switch (this._face = i,
  41295. this._face) {
  41296. case 0:
  41297. this.updateEffect("#define POSITIVEX");
  41298. break;
  41299. case 1:
  41300. this.updateEffect("#define NEGATIVEX");
  41301. break;
  41302. case 2:
  41303. this.updateEffect("#define POSITIVEY");
  41304. break;
  41305. case 3:
  41306. this.updateEffect("#define NEGATIVEY");
  41307. break;
  41308. case 4:
  41309. this.updateEffect("#define POSITIVEZ");
  41310. break;
  41311. case 5:
  41312. this.updateEffect("#define NEGATIVEZ");
  41313. break
  41314. }
  41315. },
  41316. enumerable: !1,
  41317. configurable: !0
  41318. }),
  41319. e.prototype.getClassName = function() {
  41320. return "PassCubePostProcess"
  41321. }
  41322. ,
  41323. e._Parse = function(i, o, s, c) {
  41324. return SerializationHelper.Parse(function() {
  41325. return new e(i.name,i.options,o,i.renderTargetSamplingMode,i._engine,i.reusable)
  41326. }, i, s, c)
  41327. }
  41328. ,
  41329. e
  41330. }
  41331. )(PostProcess);
  41332. Engine._RescalePostProcessFactory = function(a) {
  41333. return new PassPostProcess("rescale",1,null,2,a,!1,0)
  41334. }
  41335. ;
  41336. function CreateResizedCopy(a, e, i, o) {
  41337. o === void 0 && (o = !0);
  41338. var s = a.getScene()
  41339. , c = s.getEngine()
  41340. , d = new RenderTargetTexture("resized" + a.name,{
  41341. width: e,
  41342. height: i
  41343. },s,!a.noMipmap,!0,a._texture.type,!1,a.samplingMode,!1);
  41344. d.wrapU = a.wrapU,
  41345. d.wrapV = a.wrapV,
  41346. d.uOffset = a.uOffset,
  41347. d.vOffset = a.vOffset,
  41348. d.uScale = a.uScale,
  41349. d.vScale = a.vScale,
  41350. d.uAng = a.uAng,
  41351. d.vAng = a.vAng,
  41352. d.wAng = a.wAng,
  41353. d.coordinatesIndex = a.coordinatesIndex,
  41354. d.level = a.level,
  41355. d.anisotropicFilteringLevel = a.anisotropicFilteringLevel,
  41356. d._texture.isReady = !1,
  41357. a.wrapU = Texture.CLAMP_ADDRESSMODE,
  41358. a.wrapV = Texture.CLAMP_ADDRESSMODE;
  41359. var _ = new PassPostProcess("pass",1,null,o ? Texture.BILINEAR_SAMPLINGMODE : Texture.NEAREST_SAMPLINGMODE,c,!1,0);
  41360. return _.externalTextureSamplerBinding = !0,
  41361. _.getEffect().executeWhenCompiled(function() {
  41362. _.onApply = function(k) {
  41363. k.setTexture("textureSampler", a)
  41364. }
  41365. ;
  41366. var b = d.renderTarget;
  41367. b && (s.postProcessManager.directRender([_], b),
  41368. c.unBindFramebuffer(b),
  41369. d.disposeFramebufferObjects(),
  41370. _.dispose(),
  41371. d.getInternalTexture().isReady = !0)
  41372. }),
  41373. d
  41374. }
  41375. function ApplyPostProcess(a, e, i, o, s, c) {
  41376. var d = e.getEngine();
  41377. return e.isReady = !1,
  41378. s = s != null ? s : e.samplingMode,
  41379. o = o != null ? o : e.type,
  41380. c = c != null ? c : e.format,
  41381. o === -1 && (o = 0),
  41382. new Promise(function(_) {
  41383. var b = new PostProcess("postprocess",a,null,null,1,null,s,d,!1,void 0,o,void 0,null,!1,c);
  41384. b.externalTextureSamplerBinding = !0;
  41385. var k = d.createRenderTargetTexture({
  41386. width: e.width,
  41387. height: e.height
  41388. }, {
  41389. generateDepthBuffer: !1,
  41390. generateMipMaps: !1,
  41391. generateStencilBuffer: !1,
  41392. samplingMode: s,
  41393. type: o,
  41394. format: c
  41395. });
  41396. b.getEffect().executeWhenCompiled(function() {
  41397. b.onApply = function(j) {
  41398. j._bindTexture("textureSampler", e),
  41399. j.setFloat2("scale", 1, 1)
  41400. }
  41401. ,
  41402. i.postProcessManager.directRender([b], k, !0),
  41403. d.restoreDefaultFramebuffer(),
  41404. d._releaseTexture(e),
  41405. b && b.dispose(),
  41406. k._swapAndDie(e),
  41407. e.type = o,
  41408. e.format = 5,
  41409. e.isReady = !0,
  41410. _(e)
  41411. })
  41412. }
  41413. )
  41414. }
  41415. var _FloatView, _Int32View;
  41416. function ToHalfFloat(a) {
  41417. _FloatView || (_FloatView = new Float32Array(1),
  41418. _Int32View = new Int32Array(_FloatView.buffer)),
  41419. _FloatView[0] = a;
  41420. var e = _Int32View[0]
  41421. , i = e >> 16 & 32768
  41422. , o = e >> 12 & 2047
  41423. , s = e >> 23 & 255;
  41424. return s < 103 ? i : s > 142 ? (i |= 31744,
  41425. i |= (s == 255 ? 0 : 1) && e & 8388607,
  41426. i) : s < 113 ? (o |= 2048,
  41427. i |= (o >> 114 - s) + (o >> 113 - s & 1),
  41428. i) : (i |= s - 112 << 10 | o >> 1,
  41429. i += o & 1,
  41430. i)
  41431. }
  41432. function FromHalfFloat(a) {
  41433. var e = (a & 32768) >> 15
  41434. , i = (a & 31744) >> 10
  41435. , o = a & 1023;
  41436. return i === 0 ? (e ? -1 : 1) * Math.pow(2, -14) * (o / Math.pow(2, 10)) : i == 31 ? o ? NaN : (e ? -1 : 1) * (1 / 0) : (e ? -1 : 1) * Math.pow(2, i - 15) * (1 + o / Math.pow(2, 10))
  41437. }
  41438. var TextureTools = {
  41439. CreateResizedCopy,
  41440. ApplyPostProcess,
  41441. ToHalfFloat,
  41442. FromHalfFloat
  41443. }
  41444. , RGBDTextureTools = function() {
  41445. function a() {}
  41446. return a.ExpandRGBDTexture = function(e) {
  41447. var i = e._texture;
  41448. if (!(!i || !e.isRGBD)) {
  41449. var o = i.getEngine()
  41450. , s = o.getCaps()
  41451. , c = i.isReady
  41452. , d = !1;
  41453. s.textureHalfFloatRender && s.textureHalfFloatLinearFiltering ? (d = !0,
  41454. i.type = 2) : s.textureFloatRender && s.textureFloatLinearFiltering && (d = !0,
  41455. i.type = 1),
  41456. d && (i.isReady = !1,
  41457. i._isRGBD = !1,
  41458. i.invertY = !1);
  41459. var _ = function() {
  41460. if (d) {
  41461. var b = new PostProcess("rgbdDecode","rgbdDecode",null,null,1,null,3,o,!1,void 0,i.type,void 0,null,!1);
  41462. b.externalTextureSamplerBinding = !0;
  41463. var k = o.createRenderTargetTexture(i.width, {
  41464. generateDepthBuffer: !1,
  41465. generateMipMaps: !1,
  41466. generateStencilBuffer: !1,
  41467. samplingMode: i.samplingMode,
  41468. type: i.type,
  41469. format: 5
  41470. });
  41471. b.getEffect().executeWhenCompiled(function() {
  41472. b.onApply = function(j) {
  41473. j._bindTexture("textureSampler", i),
  41474. j.setFloat2("scale", 1, 1)
  41475. }
  41476. ,
  41477. e.getScene().postProcessManager.directRender([b], k, !0),
  41478. o.restoreDefaultFramebuffer(),
  41479. o._releaseTexture(i),
  41480. b && b.dispose(),
  41481. k._swapAndDie(i),
  41482. i.isReady = !0
  41483. })
  41484. }
  41485. };
  41486. c ? _() : e.onLoadObservable.addOnce(_)
  41487. }
  41488. }
  41489. ,
  41490. a.EncodeTextureToRGBD = function(e, i, o) {
  41491. return o === void 0 && (o = 0),
  41492. ApplyPostProcess("rgbdEncode", e, i, o, 1, 5)
  41493. }
  41494. ,
  41495. a
  41496. }()
  41497. , FileFaceOrientation = function() {
  41498. function a(e, i, o, s) {
  41499. this.name = e,
  41500. this.worldAxisForNormal = i,
  41501. this.worldAxisForFileX = o,
  41502. this.worldAxisForFileY = s
  41503. }
  41504. return a
  41505. }()
  41506. , CubeMapToSphericalPolynomialTools = function() {
  41507. function a() {}
  41508. return a.ConvertCubeMapTextureToSphericalPolynomial = function(e) {
  41509. var i = this, o;
  41510. if (!e.isCube)
  41511. return null;
  41512. (o = e.getScene()) === null || o === void 0 || o.getEngine().flushFramebuffer();
  41513. var s = e.getSize().width, c = e.readPixels(0, void 0, void 0, !1), d = e.readPixels(1, void 0, void 0, !1), _, b;
  41514. e.isRenderTarget ? (_ = e.readPixels(3, void 0, void 0, !1),
  41515. b = e.readPixels(2, void 0, void 0, !1)) : (_ = e.readPixels(2, void 0, void 0, !1),
  41516. b = e.readPixels(3, void 0, void 0, !1));
  41517. var k = e.readPixels(4, void 0, void 0, !1)
  41518. , j = e.readPixels(5, void 0, void 0, !1)
  41519. , $ = e.gammaSpace
  41520. , _e = 5
  41521. , et = 0;
  41522. return (e.textureType == 1 || e.textureType == 2) && (et = 1),
  41523. new Promise(function(tt, rt) {
  41524. Promise.all([d, c, _, b, k, j]).then(function(it) {
  41525. var nt = it[0]
  41526. , ot = it[1]
  41527. , at = it[2]
  41528. , st = it[3]
  41529. , ut = it[4]
  41530. , ct = it[5]
  41531. , lt = {
  41532. size: s,
  41533. right: ot,
  41534. left: nt,
  41535. up: at,
  41536. down: st,
  41537. front: ut,
  41538. back: ct,
  41539. format: _e,
  41540. type: et,
  41541. gammaSpace: $
  41542. };
  41543. tt(i.ConvertCubeMapToSphericalPolynomial(lt))
  41544. })
  41545. }
  41546. )
  41547. }
  41548. ,
  41549. a.ConvertCubeMapToSphericalPolynomial = function(e) {
  41550. for (var i = new SphericalHarmonics, o = 0, s = 2 / e.size, c = s, d = s * .5 - 1, _ = 0; _ < 6; _++)
  41551. for (var b = this.FileFaces[_], k = e[b.name], j = d, $ = e.format === 5 ? 4 : 3, _e = 0; _e < e.size; _e++) {
  41552. for (var et = d, tt = 0; tt < e.size; tt++) {
  41553. var rt = b.worldAxisForFileX.scale(et).add(b.worldAxisForFileY.scale(j)).add(b.worldAxisForNormal);
  41554. rt.normalize();
  41555. var it = Math.pow(1 + et * et + j * j, -3 / 2)
  41556. , nt = k[_e * e.size * $ + tt * $ + 0]
  41557. , ot = k[_e * e.size * $ + tt * $ + 1]
  41558. , at = k[_e * e.size * $ + tt * $ + 2];
  41559. isNaN(nt) && (nt = 0),
  41560. isNaN(ot) && (ot = 0),
  41561. isNaN(at) && (at = 0),
  41562. e.type === 0 && (nt /= 255,
  41563. ot /= 255,
  41564. at /= 255),
  41565. e.gammaSpace && (nt = Math.pow(Scalar.Clamp(nt), ToLinearSpace),
  41566. ot = Math.pow(Scalar.Clamp(ot), ToLinearSpace),
  41567. at = Math.pow(Scalar.Clamp(at), ToLinearSpace));
  41568. var st = 4096;
  41569. nt = Scalar.Clamp(nt, 0, st),
  41570. ot = Scalar.Clamp(ot, 0, st),
  41571. at = Scalar.Clamp(at, 0, st);
  41572. var ut = new Color3(nt,ot,at);
  41573. i.addLight(rt, ut, it),
  41574. o += it,
  41575. et += s
  41576. }
  41577. j += c
  41578. }
  41579. var ct = 4 * Math.PI
  41580. , lt = 6
  41581. , ft = ct * lt / 6
  41582. , ht = ft / o;
  41583. return i.scaleInPlace(ht),
  41584. i.convertIncidentRadianceToIrradiance(),
  41585. i.convertIrradianceToLambertianRadiance(),
  41586. SphericalPolynomial.FromHarmonics(i)
  41587. }
  41588. ,
  41589. a.FileFaces = [new FileFaceOrientation("right",new Vector3(1,0,0),new Vector3(0,0,-1),new Vector3(0,-1,0)), new FileFaceOrientation("left",new Vector3(-1,0,0),new Vector3(0,0,1),new Vector3(0,-1,0)), new FileFaceOrientation("up",new Vector3(0,1,0),new Vector3(1,0,0),new Vector3(0,0,1)), new FileFaceOrientation("down",new Vector3(0,-1,0),new Vector3(1,0,0),new Vector3(0,0,-1)), new FileFaceOrientation("front",new Vector3(0,0,1),new Vector3(1,0,0),new Vector3(0,-1,0)), new FileFaceOrientation("back",new Vector3(0,0,-1),new Vector3(-1,0,0),new Vector3(0,-1,0))],
  41590. a
  41591. }();
  41592. BaseTexture.prototype.forceSphericalPolynomialsRecompute = function() {
  41593. this._texture && (this._texture._sphericalPolynomial = null,
  41594. this._texture._sphericalPolynomialPromise = null,
  41595. this._texture._sphericalPolynomialComputed = !1)
  41596. }
  41597. ;
  41598. Object.defineProperty(BaseTexture.prototype, "sphericalPolynomial", {
  41599. get: function() {
  41600. var a = this;
  41601. if (this._texture) {
  41602. if (this._texture._sphericalPolynomial || this._texture._sphericalPolynomialComputed)
  41603. return this._texture._sphericalPolynomial;
  41604. if (this._texture.isReady)
  41605. return this._texture._sphericalPolynomialPromise || (this._texture._sphericalPolynomialPromise = CubeMapToSphericalPolynomialTools.ConvertCubeMapTextureToSphericalPolynomial(this),
  41606. this._texture._sphericalPolynomialPromise === null ? this._texture._sphericalPolynomialComputed = !0 : this._texture._sphericalPolynomialPromise.then(function(e) {
  41607. a._texture._sphericalPolynomial = e,
  41608. a._texture._sphericalPolynomialComputed = !0
  41609. })),
  41610. null
  41611. }
  41612. return null
  41613. },
  41614. set: function(a) {
  41615. this._texture && (this._texture._sphericalPolynomial = a)
  41616. },
  41617. enumerable: !0,
  41618. configurable: !0
  41619. });
  41620. var name$2W = "rgbdEncodePixelShader"
  41621. , shader$2W = `
  41622. varying vec2 vUV;
  41623. uniform sampler2D textureSampler;
  41624. #include<helperFunctions>
  41625. void main(void)
  41626. {
  41627. gl_FragColor=toRGBD(texture2D(textureSampler,vUV).rgb);
  41628. }`;
  41629. ShaderStore.ShadersStore[name$2W] = shader$2W;
  41630. var defaultEnvironmentTextureImageType = "image/png"
  41631. , currentVersion = 2
  41632. , _MagicBytes = [134, 22, 135, 150, 246, 214, 150, 54];
  41633. function GetEnvInfo(a) {
  41634. for (var e = new DataView(a.buffer,a.byteOffset,a.byteLength), i = 0, o = 0; o < _MagicBytes.length; o++)
  41635. if (e.getUint8(i++) !== _MagicBytes[o])
  41636. return Logger$2.Error("Not a babylon environment map"),
  41637. null;
  41638. for (var s = "", c = 0; c = e.getUint8(i++); )
  41639. s += String.fromCharCode(c);
  41640. var d = JSON.parse(s);
  41641. return d = normalizeEnvInfo(d),
  41642. d.specular && (d.specular.specularDataPosition = i,
  41643. d.specular.lodGenerationScale = d.specular.lodGenerationScale || .8),
  41644. d
  41645. }
  41646. function normalizeEnvInfo(a) {
  41647. if (a.version > currentVersion)
  41648. throw new Error('Unsupported babylon environment map version "' + a.version + '". Latest supported version is "' + currentVersion + '".');
  41649. return a.version === 2 || (a = __assign(__assign({}, a), {
  41650. version: 2,
  41651. imageType: defaultEnvironmentTextureImageType
  41652. })),
  41653. a
  41654. }
  41655. function CreateImageDataArrayBufferViews(a, e) {
  41656. e = normalizeEnvInfo(e);
  41657. var i = e.specular
  41658. , o = Scalar.Log2(e.width);
  41659. if (o = Math.round(o) + 1,
  41660. i.mipmaps.length !== 6 * o)
  41661. throw new Error('Unsupported specular mipmaps number "' + i.mipmaps.length + '"');
  41662. for (var s = new Array(o), c = 0; c < o; c++) {
  41663. s[c] = new Array(6);
  41664. for (var d = 0; d < 6; d++) {
  41665. var _ = i.mipmaps[c * 6 + d];
  41666. s[c][d] = new Uint8Array(a.buffer,a.byteOffset + i.specularDataPosition + _.position,_.length)
  41667. }
  41668. }
  41669. return s
  41670. }
  41671. function UploadEnvLevelsAsync(a, e, i) {
  41672. i = normalizeEnvInfo(i);
  41673. var o = i.specular;
  41674. if (!o)
  41675. return Promise.resolve();
  41676. a._lodGenerationScale = o.lodGenerationScale;
  41677. var s = CreateImageDataArrayBufferViews(e, i);
  41678. return UploadLevelsAsync(a, s, i.imageType)
  41679. }
  41680. function _OnImageReadyAsync(a, e, i, o, s, c, d, _, b, k, j) {
  41681. return new Promise(function($, _e) {
  41682. if (i) {
  41683. var et = e.createTexture(null, !0, !0, null, 1, null, function(rt) {
  41684. _e(rt)
  41685. }, a);
  41686. o.getEffect().executeWhenCompiled(function() {
  41687. o.externalTextureSamplerBinding = !0,
  41688. o.onApply = function(rt) {
  41689. rt._bindTexture("textureSampler", et),
  41690. rt.setFloat2("scale", 1, e._features.needsInvertingBitmap && a instanceof ImageBitmap ? -1 : 1)
  41691. }
  41692. ,
  41693. e.scenes.length && (e.scenes[0].postProcessManager.directRender([o], k, !0, c, d),
  41694. e.restoreDefaultFramebuffer(),
  41695. et.dispose(),
  41696. URL.revokeObjectURL(s),
  41697. $())
  41698. })
  41699. } else {
  41700. if (e._uploadImageToTexture(j, a, c, d),
  41701. _) {
  41702. var tt = b[d];
  41703. tt && e._uploadImageToTexture(tt._texture, a, c, 0)
  41704. }
  41705. $()
  41706. }
  41707. }
  41708. )
  41709. }
  41710. function UploadLevelsAsync(a, e, i) {
  41711. if (i === void 0 && (i = defaultEnvironmentTextureImageType),
  41712. !Tools.IsExponentOfTwo(a.width))
  41713. throw new Error("Texture size must be a power of two");
  41714. var o = Scalar.ILog2(a.width) + 1
  41715. , s = a.getEngine()
  41716. , c = !1
  41717. , d = !1
  41718. , _ = null
  41719. , b = null
  41720. , k = null
  41721. , j = s.getCaps();
  41722. if (a.format = 5,
  41723. a.type = 0,
  41724. a.generateMipMaps = !0,
  41725. a._cachedAnisotropicFilteringLevel = null,
  41726. s.updateTextureSamplingMode(3, a),
  41727. j.textureLOD ? s._features.supportRenderAndCopyToLodForFloatTextures ? j.textureHalfFloatRender && j.textureHalfFloatLinearFiltering ? (c = !0,
  41728. a.type = 2) : j.textureFloatRender && j.textureFloatLinearFiltering && (c = !0,
  41729. a.type = 1) : c = !1 : (c = !1,
  41730. d = !0,
  41731. k = {}),
  41732. c)
  41733. _ = new PostProcess("rgbdDecode","rgbdDecode",null,null,1,null,3,s,!1,void 0,a.type,void 0,null,!1),
  41734. a._isRGBD = !1,
  41735. a.invertY = !1,
  41736. b = s.createRenderTargetCubeTexture(a.width, {
  41737. generateDepthBuffer: !1,
  41738. generateMipMaps: !0,
  41739. generateStencilBuffer: !1,
  41740. samplingMode: 3,
  41741. type: a.type,
  41742. format: 5
  41743. });
  41744. else if (a._isRGBD = !0,
  41745. a.invertY = !0,
  41746. d)
  41747. for (var $ = 3, _e = a._lodGenerationScale, et = a._lodGenerationOffset, tt = 0; tt < $; tt++) {
  41748. var rt = tt / ($ - 1)
  41749. , it = 1 - rt
  41750. , nt = et
  41751. , ot = (o - 1) * _e + et
  41752. , at = nt + (ot - nt) * it
  41753. , st = Math.round(Math.min(Math.max(at, 0), ot))
  41754. , ut = new InternalTexture(s,InternalTextureSource.Temp);
  41755. ut.isCube = !0,
  41756. ut.invertY = !0,
  41757. ut.generateMipMaps = !1,
  41758. s.updateTextureSamplingMode(2, ut);
  41759. var ct = new BaseTexture(null);
  41760. switch (ct.isCube = !0,
  41761. ct._texture = ut,
  41762. k[st] = ct,
  41763. tt) {
  41764. case 0:
  41765. a._lodTextureLow = ct;
  41766. break;
  41767. case 1:
  41768. a._lodTextureMid = ct;
  41769. break;
  41770. case 2:
  41771. a._lodTextureHigh = ct;
  41772. break
  41773. }
  41774. }
  41775. for (var lt = [], ft = function(mt) {
  41776. for (var vt = function(Et) {
  41777. var At = e[mt][Et]
  41778. , gt = new Blob([At],{
  41779. type: i
  41780. })
  41781. , St = URL.createObjectURL(gt)
  41782. , xt = void 0;
  41783. if (typeof Image == "undefined" || s._features.forceBitmapOverHTMLImageElement)
  41784. xt = s.createImageBitmap(gt, {
  41785. premultiplyAlpha: "none"
  41786. }).then(function(Rt) {
  41787. return _OnImageReadyAsync(Rt, s, c, _, St, Et, mt, d, k, b, a)
  41788. });
  41789. else {
  41790. var bt = new Image;
  41791. bt.src = St,
  41792. xt = new Promise(function(Rt, Mt) {
  41793. bt.onload = function() {
  41794. _OnImageReadyAsync(bt, s, c, _, St, Et, mt, d, k, b, a).then(function() {
  41795. return Rt()
  41796. }).catch(function(Pt) {
  41797. Mt(Pt)
  41798. })
  41799. }
  41800. ,
  41801. bt.onerror = function(Pt) {
  41802. Mt(Pt)
  41803. }
  41804. }
  41805. )
  41806. }
  41807. lt.push(xt)
  41808. }, yt = 0; yt < 6; yt++)
  41809. vt(yt)
  41810. }, tt = 0; tt < e.length; tt++)
  41811. ft(tt);
  41812. if (e.length < o) {
  41813. var ht = void 0
  41814. , pt = Math.pow(2, o - 1 - e.length)
  41815. , dt = pt * pt * 4;
  41816. switch (a.type) {
  41817. case 0:
  41818. {
  41819. ht = new Uint8Array(dt);
  41820. break
  41821. }
  41822. case 2:
  41823. {
  41824. ht = new Uint16Array(dt);
  41825. break
  41826. }
  41827. case 1:
  41828. {
  41829. ht = new Float32Array(dt);
  41830. break
  41831. }
  41832. }
  41833. for (var tt = e.length; tt < o; tt++)
  41834. for (var _t = 0; _t < 6; _t++)
  41835. s._uploadArrayBufferViewToTexture(a, ht, _t, tt)
  41836. }
  41837. return Promise.all(lt).then(function() {
  41838. b && (s._releaseTexture(a),
  41839. b._swapAndDie(a)),
  41840. _ && _.dispose(),
  41841. d && (a._lodTextureHigh && a._lodTextureHigh._texture && (a._lodTextureHigh._texture.isReady = !0),
  41842. a._lodTextureMid && a._lodTextureMid._texture && (a._lodTextureMid._texture.isReady = !0),
  41843. a._lodTextureLow && a._lodTextureLow._texture && (a._lodTextureLow._texture.isReady = !0))
  41844. })
  41845. }
  41846. function UploadEnvSpherical(a, e) {
  41847. e = normalizeEnvInfo(e);
  41848. var i = e.irradiance;
  41849. if (!!i) {
  41850. var o = new SphericalPolynomial;
  41851. Vector3.FromArrayToRef(i.x, 0, o.x),
  41852. Vector3.FromArrayToRef(i.y, 0, o.y),
  41853. Vector3.FromArrayToRef(i.z, 0, o.z),
  41854. Vector3.FromArrayToRef(i.xx, 0, o.xx),
  41855. Vector3.FromArrayToRef(i.yy, 0, o.yy),
  41856. Vector3.FromArrayToRef(i.zz, 0, o.zz),
  41857. Vector3.FromArrayToRef(i.yz, 0, o.yz),
  41858. Vector3.FromArrayToRef(i.zx, 0, o.zx),
  41859. Vector3.FromArrayToRef(i.xy, 0, o.xy),
  41860. a._sphericalPolynomial = o
  41861. }
  41862. }
  41863. function _UpdateRGBDAsync(a, e, i, o, s) {
  41864. var c = a.getEngine().createRawCubeTexture(null, a.width, a.format, a.type, a.generateMipMaps, a.invertY, a.samplingMode, a._compression)
  41865. , d = UploadLevelsAsync(c, e).then(function() {
  41866. return a
  41867. });
  41868. return a.onRebuildCallback = function(_) {
  41869. return {
  41870. proxy: d,
  41871. isReady: !0,
  41872. isAsync: !0
  41873. }
  41874. }
  41875. ,
  41876. a._source = InternalTextureSource.CubeRawRGBD,
  41877. a._bufferViewArrayArray = e,
  41878. a._lodGenerationScale = o,
  41879. a._lodGenerationOffset = s,
  41880. a._sphericalPolynomial = i,
  41881. UploadLevelsAsync(a, e).then(function() {
  41882. return a.isReady = !0,
  41883. a
  41884. })
  41885. }
  41886. function ExtractBetweenMarkers(a, e, i, o) {
  41887. for (var s = o, c = 0, d = ""; s < i.length; ) {
  41888. var _ = i.charAt(s);
  41889. if (d)
  41890. _ === d ? d === '"' || d === "'" ? i.charAt(s - 1) !== "\\" && (d = "") : d = "" : d === "*/" && _ === "*" && s + 1 < i.length && (i.charAt(s + 1) === "/" && (d = ""),
  41891. d === "" && s++);
  41892. else
  41893. switch (_) {
  41894. case a:
  41895. c++;
  41896. break;
  41897. case e:
  41898. c--;
  41899. break;
  41900. case '"':
  41901. case "'":
  41902. case "`":
  41903. d = _;
  41904. break;
  41905. case "/":
  41906. if (s + 1 < i.length) {
  41907. var b = i.charAt(s + 1);
  41908. b === "/" ? d = `
  41909. ` : b === "*" && (d = "*/")
  41910. }
  41911. break
  41912. }
  41913. if (s++,
  41914. c === 0)
  41915. break
  41916. }
  41917. return c === 0 ? s - 1 : -1
  41918. }
  41919. function SkipWhitespaces(a, e) {
  41920. for (; e < a.length; ) {
  41921. var i = a[e];
  41922. if (i !== " " && i !== `
  41923. ` && i !== "\r" && i !== " " && i !== `
  41924. ` && i !== "\xA0")
  41925. break;
  41926. e++
  41927. }
  41928. return e
  41929. }
  41930. function IsIdentifierChar(a) {
  41931. var e = a.charCodeAt(0);
  41932. return e >= 48 && e <= 57 || e >= 65 && e <= 90 || e >= 97 && e <= 122 || e == 95
  41933. }
  41934. function RemoveComments(a) {
  41935. for (var e = 0, i = "", o = !1, s = []; e < a.length; ) {
  41936. var c = a.charAt(e);
  41937. if (i)
  41938. c === i ? i === '"' || i === "'" ? (a.charAt(e - 1) !== "\\" && (i = ""),
  41939. s.push(c)) : (i = "",
  41940. o = !1) : i === "*/" && c === "*" && e + 1 < a.length ? (a.charAt(e + 1) === "/" && (i = ""),
  41941. i === "" && (o = !1,
  41942. e++)) : o || s.push(c);
  41943. else {
  41944. switch (c) {
  41945. case '"':
  41946. case "'":
  41947. case "`":
  41948. i = c;
  41949. break;
  41950. case "/":
  41951. if (e + 1 < a.length) {
  41952. var d = a.charAt(e + 1);
  41953. d === "/" ? (i = `
  41954. `,
  41955. o = !0) : d === "*" && (i = "*/",
  41956. o = !0)
  41957. }
  41958. break
  41959. }
  41960. o || s.push(c)
  41961. }
  41962. e++
  41963. }
  41964. return s.join("")
  41965. }
  41966. function FindBackward(a, e, i) {
  41967. for (; e >= 0 && a.charAt(e) !== i; )
  41968. e--;
  41969. return e
  41970. }
  41971. function EscapeRegExp(a) {
  41972. return a.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")
  41973. }
  41974. var ShaderCodeInliner = function() {
  41975. function a(e, i) {
  41976. i === void 0 && (i = 20),
  41977. this.debug = !1,
  41978. this._sourceCode = e,
  41979. this._numMaxIterations = i,
  41980. this._functionDescr = [],
  41981. this.inlineToken = "#define inline"
  41982. }
  41983. return Object.defineProperty(a.prototype, "code", {
  41984. get: function() {
  41985. return this._sourceCode
  41986. },
  41987. enumerable: !1,
  41988. configurable: !0
  41989. }),
  41990. a.prototype.processCode = function() {
  41991. this.debug && console.log("Start inlining process (code size=" + this._sourceCode.length + ")..."),
  41992. this._collectFunctions(),
  41993. this._processInlining(this._numMaxIterations),
  41994. this.debug && console.log("End of inlining process.")
  41995. }
  41996. ,
  41997. a.prototype._collectFunctions = function() {
  41998. for (var e = 0; e < this._sourceCode.length; ) {
  41999. var i = this._sourceCode.indexOf(this.inlineToken, e);
  42000. if (i < 0)
  42001. break;
  42002. var o = this._sourceCode.indexOf("(", i + this.inlineToken.length);
  42003. if (o < 0) {
  42004. this.debug && console.warn("Could not find the opening parenthesis after the token. startIndex=" + e),
  42005. e = i + this.inlineToken.length;
  42006. continue
  42007. }
  42008. var s = a._RegexpFindFunctionNameAndType.exec(this._sourceCode.substring(i + this.inlineToken.length, o));
  42009. if (!s) {
  42010. this.debug && console.warn("Could not extract the name/type of the function from: " + this._sourceCode.substring(i + this.inlineToken.length, o)),
  42011. e = i + this.inlineToken.length;
  42012. continue
  42013. }
  42014. var c = [s[3], s[4]]
  42015. , d = c[0]
  42016. , _ = c[1]
  42017. , b = ExtractBetweenMarkers("(", ")", this._sourceCode, o);
  42018. if (b < 0) {
  42019. this.debug && console.warn("Could not extract the parameters the function '" + _ + "' (type=" + d + "). funcParamsStartIndex=" + o),
  42020. e = i + this.inlineToken.length;
  42021. continue
  42022. }
  42023. var k = this._sourceCode.substring(o + 1, b)
  42024. , j = SkipWhitespaces(this._sourceCode, b + 1);
  42025. if (j === this._sourceCode.length) {
  42026. this.debug && console.warn("Could not extract the body of the function '" + _ + "' (type=" + d + "). funcParamsEndIndex=" + b),
  42027. e = i + this.inlineToken.length;
  42028. continue
  42029. }
  42030. var $ = ExtractBetweenMarkers("{", "}", this._sourceCode, j);
  42031. if ($ < 0) {
  42032. this.debug && console.warn("Could not extract the body of the function '" + _ + "' (type=" + d + "). funcBodyStartIndex=" + j),
  42033. e = i + this.inlineToken.length;
  42034. continue
  42035. }
  42036. for (var _e = this._sourceCode.substring(j, $ + 1), et = RemoveComments(k).split(","), tt = [], rt = 0; rt < et.length; ++rt) {
  42037. var it = et[rt].trim()
  42038. , nt = it.lastIndexOf(" ");
  42039. nt >= 0 && tt.push(it.substring(nt + 1))
  42040. }
  42041. d !== "void" && tt.push("return"),
  42042. this._functionDescr.push({
  42043. name: _,
  42044. type: d,
  42045. parameters: tt,
  42046. body: _e,
  42047. callIndex: 0
  42048. }),
  42049. e = $ + 1;
  42050. var ot = i > 0 ? this._sourceCode.substring(0, i) : ""
  42051. , at = $ + 1 < this._sourceCode.length - 1 ? this._sourceCode.substring($ + 1) : "";
  42052. this._sourceCode = ot + at,
  42053. e -= $ + 1 - i
  42054. }
  42055. this.debug && console.log("Collect functions: " + this._functionDescr.length + " functions found. functionDescr=", this._functionDescr)
  42056. }
  42057. ,
  42058. a.prototype._processInlining = function(e) {
  42059. for (e === void 0 && (e = 20); e-- >= 0 && this._replaceFunctionCallsByCode(); )
  42060. ;
  42061. return this.debug && console.log("numMaxIterations is " + e + " after inlining process"),
  42062. e >= 0
  42063. }
  42064. ,
  42065. a.prototype._replaceFunctionCallsByCode = function() {
  42066. for (var e = !1, i = 0, o = this._functionDescr; i < o.length; i++)
  42067. for (var s = o[i], c = s.name, d = s.type, _ = s.parameters, b = s.body, k = 0; k < this._sourceCode.length; ) {
  42068. var j = this._sourceCode.indexOf(c, k);
  42069. if (j < 0)
  42070. break;
  42071. if (j === 0 || IsIdentifierChar(this._sourceCode.charAt(j - 1))) {
  42072. k = j + c.length;
  42073. continue
  42074. }
  42075. var $ = SkipWhitespaces(this._sourceCode, j + c.length);
  42076. if ($ === this._sourceCode.length || this._sourceCode.charAt($) !== "(") {
  42077. k = j + c.length;
  42078. continue
  42079. }
  42080. var _e = ExtractBetweenMarkers("(", ")", this._sourceCode, $);
  42081. if (_e < 0) {
  42082. this.debug && console.warn("Could not extract the parameters of the function call. Function '" + c + "' (type=" + d + "). callParamsStartIndex=" + $),
  42083. k = j + c.length;
  42084. continue
  42085. }
  42086. var et = this._sourceCode.substring($ + 1, _e)
  42087. , tt = function(ht) {
  42088. for (var pt = [], dt = 0, _t = 0; dt < ht.length; ) {
  42089. if (ht.charAt(dt) === "(") {
  42090. var mt = ExtractBetweenMarkers("(", ")", ht, dt);
  42091. if (mt < 0)
  42092. return null;
  42093. dt = mt
  42094. } else
  42095. ht.charAt(dt) === "," && (pt.push(ht.substring(_t, dt)),
  42096. _t = dt + 1);
  42097. dt++
  42098. }
  42099. return _t < dt && pt.push(ht.substring(_t, dt)),
  42100. pt
  42101. }
  42102. , rt = tt(RemoveComments(et));
  42103. if (rt === null) {
  42104. this.debug && console.warn("Invalid function call: can't extract the parameters of the function call. Function '" + c + "' (type=" + d + "). callParamsStartIndex=" + $ + ", callParams=" + et),
  42105. k = j + c.length;
  42106. continue
  42107. }
  42108. for (var it = [], nt = 0; nt < rt.length; ++nt) {
  42109. var ot = rt[nt].trim();
  42110. it.push(ot)
  42111. }
  42112. var at = d !== "void" ? c + "_" + s.callIndex++ : null;
  42113. if (at && it.push(at + " ="),
  42114. it.length !== _.length) {
  42115. this.debug && console.warn("Invalid function call: not the same number of parameters for the call than the number expected by the function. Function '" + c + "' (type=" + d + "). function parameters=" + _ + ", call parameters=" + it),
  42116. k = j + c.length;
  42117. continue
  42118. }
  42119. k = _e + 1;
  42120. var st = this._replaceNames(b, _, it)
  42121. , ut = j > 0 ? this._sourceCode.substring(0, j) : ""
  42122. , ct = _e + 1 < this._sourceCode.length - 1 ? this._sourceCode.substring(_e + 1) : "";
  42123. if (at) {
  42124. var lt = FindBackward(this._sourceCode, j - 1, `
  42125. `);
  42126. ut = this._sourceCode.substring(0, lt + 1);
  42127. var ft = this._sourceCode.substring(lt + 1, j);
  42128. this._sourceCode = ut + d + " " + at + `;
  42129. ` + st + `
  42130. ` + ft + at + ct,
  42131. this.debug && console.log("Replace function call by code. Function '" + c + "' (type=" + d + "). injectDeclarationIndex=" + lt + ", call parameters=" + it)
  42132. } else
  42133. this._sourceCode = ut + st + ct,
  42134. k += st.length - (_e + 1 - j),
  42135. this.debug && console.log("Replace function call by code. Function '" + c + "' (type=" + d + "). functionCallIndex=" + j + ", call parameters=" + it);
  42136. e = !0
  42137. }
  42138. return e
  42139. }
  42140. ,
  42141. a.prototype._replaceNames = function(e, i, o) {
  42142. for (var s = function(d) {
  42143. var _ = new RegExp(EscapeRegExp(i[d]),"g")
  42144. , b = i[d].length
  42145. , k = o[d];
  42146. e = e.replace(_, function(j) {
  42147. for (var $ = [], _e = 1; _e < arguments.length; _e++)
  42148. $[_e - 1] = arguments[_e];
  42149. var et = $[0];
  42150. return IsIdentifierChar(e.charAt(et - 1)) || IsIdentifierChar(e.charAt(et + b)) ? i[d] : k
  42151. })
  42152. }, c = 0; c < i.length; ++c)
  42153. s(c);
  42154. return e
  42155. }
  42156. ,
  42157. a._RegexpFindFunctionNameAndType = /((\s+?)(\w+)\s+(\w+)\s*?)$/,
  42158. a
  42159. }()
  42160. , NativePipelineContext = function() {
  42161. function a(e) {
  42162. this.isAsync = !1,
  42163. this.isReady = !1,
  42164. this._valueCache = {},
  42165. this.engine = e
  42166. }
  42167. return a.prototype._getVertexShaderCode = function() {
  42168. return null
  42169. }
  42170. ,
  42171. a.prototype._getFragmentShaderCode = function() {
  42172. return null
  42173. }
  42174. ,
  42175. a.prototype._handlesSpectorRebuildCallback = function(e) {
  42176. throw new Error("Not implemented")
  42177. }
  42178. ,
  42179. a.prototype._fillEffectInformation = function(e, i, o, s, c, d, _, b) {
  42180. var k = this.engine;
  42181. if (k.supportsUniformBuffers)
  42182. for (var j in i)
  42183. e.bindUniformBlock(j, i[j]);
  42184. var $ = this.engine.getUniforms(this, o);
  42185. $.forEach(function(tt, rt) {
  42186. s[o[rt]] = tt
  42187. }),
  42188. this._uniforms = s;
  42189. var _e;
  42190. for (_e = 0; _e < c.length; _e++) {
  42191. var et = e.getUniform(c[_e]);
  42192. et == null && (c.splice(_e, 1),
  42193. _e--)
  42194. }
  42195. c.forEach(function(tt, rt) {
  42196. d[tt] = rt
  42197. }),
  42198. b.push.apply(b, k.getAttributes(this, _))
  42199. }
  42200. ,
  42201. a.prototype.dispose = function() {
  42202. this._uniforms = {}
  42203. }
  42204. ,
  42205. a.prototype._cacheMatrix = function(e, i) {
  42206. var o = this._valueCache[e]
  42207. , s = i.updateFlag;
  42208. return o !== void 0 && o === s ? !1 : (this._valueCache[e] = s,
  42209. !0)
  42210. }
  42211. ,
  42212. a.prototype._cacheFloat2 = function(e, i, o) {
  42213. var s = this._valueCache[e];
  42214. if (!s)
  42215. return s = [i, o],
  42216. this._valueCache[e] = s,
  42217. !0;
  42218. var c = !1;
  42219. return s[0] !== i && (s[0] = i,
  42220. c = !0),
  42221. s[1] !== o && (s[1] = o,
  42222. c = !0),
  42223. c
  42224. }
  42225. ,
  42226. a.prototype._cacheFloat3 = function(e, i, o, s) {
  42227. var c = this._valueCache[e];
  42228. if (!c)
  42229. return c = [i, o, s],
  42230. this._valueCache[e] = c,
  42231. !0;
  42232. var d = !1;
  42233. return c[0] !== i && (c[0] = i,
  42234. d = !0),
  42235. c[1] !== o && (c[1] = o,
  42236. d = !0),
  42237. c[2] !== s && (c[2] = s,
  42238. d = !0),
  42239. d
  42240. }
  42241. ,
  42242. a.prototype._cacheFloat4 = function(e, i, o, s, c) {
  42243. var d = this._valueCache[e];
  42244. if (!d)
  42245. return d = [i, o, s, c],
  42246. this._valueCache[e] = d,
  42247. !0;
  42248. var _ = !1;
  42249. return d[0] !== i && (d[0] = i,
  42250. _ = !0),
  42251. d[1] !== o && (d[1] = o,
  42252. _ = !0),
  42253. d[2] !== s && (d[2] = s,
  42254. _ = !0),
  42255. d[3] !== c && (d[3] = c,
  42256. _ = !0),
  42257. _
  42258. }
  42259. ,
  42260. a.prototype.setInt = function(e, i) {
  42261. var o = this._valueCache[e];
  42262. o !== void 0 && o === i || this.engine.setInt(this._uniforms[e], i) && (this._valueCache[e] = i)
  42263. }
  42264. ,
  42265. a.prototype.setInt2 = function(e, i, o) {
  42266. this._cacheFloat2(e, i, o) && (this.engine.setInt2(this._uniforms[e], i, o) || (this._valueCache[e] = null))
  42267. }
  42268. ,
  42269. a.prototype.setInt3 = function(e, i, o, s) {
  42270. this._cacheFloat3(e, i, o, s) && (this.engine.setInt3(this._uniforms[e], i, o, s) || (this._valueCache[e] = null))
  42271. }
  42272. ,
  42273. a.prototype.setInt4 = function(e, i, o, s, c) {
  42274. this._cacheFloat4(e, i, o, s, c) && (this.engine.setInt4(this._uniforms[e], i, o, s, c) || (this._valueCache[e] = null))
  42275. }
  42276. ,
  42277. a.prototype.setIntArray = function(e, i) {
  42278. this._valueCache[e] = null,
  42279. this.engine.setIntArray(this._uniforms[e], i)
  42280. }
  42281. ,
  42282. a.prototype.setIntArray2 = function(e, i) {
  42283. this._valueCache[e] = null,
  42284. this.engine.setIntArray2(this._uniforms[e], i)
  42285. }
  42286. ,
  42287. a.prototype.setIntArray3 = function(e, i) {
  42288. this._valueCache[e] = null,
  42289. this.engine.setIntArray3(this._uniforms[e], i)
  42290. }
  42291. ,
  42292. a.prototype.setIntArray4 = function(e, i) {
  42293. this._valueCache[e] = null,
  42294. this.engine.setIntArray4(this._uniforms[e], i)
  42295. }
  42296. ,
  42297. a.prototype.setFloatArray = function(e, i) {
  42298. this._valueCache[e] = null,
  42299. this.engine.setFloatArray(this._uniforms[e], i)
  42300. }
  42301. ,
  42302. a.prototype.setFloatArray2 = function(e, i) {
  42303. this._valueCache[e] = null,
  42304. this.engine.setFloatArray2(this._uniforms[e], i)
  42305. }
  42306. ,
  42307. a.prototype.setFloatArray3 = function(e, i) {
  42308. this._valueCache[e] = null,
  42309. this.engine.setFloatArray3(this._uniforms[e], i)
  42310. }
  42311. ,
  42312. a.prototype.setFloatArray4 = function(e, i) {
  42313. this._valueCache[e] = null,
  42314. this.engine.setFloatArray4(this._uniforms[e], i)
  42315. }
  42316. ,
  42317. a.prototype.setArray = function(e, i) {
  42318. this._valueCache[e] = null,
  42319. this.engine.setArray(this._uniforms[e], i)
  42320. }
  42321. ,
  42322. a.prototype.setArray2 = function(e, i) {
  42323. this._valueCache[e] = null,
  42324. this.engine.setArray2(this._uniforms[e], i)
  42325. }
  42326. ,
  42327. a.prototype.setArray3 = function(e, i) {
  42328. this._valueCache[e] = null,
  42329. this.engine.setArray3(this._uniforms[e], i)
  42330. }
  42331. ,
  42332. a.prototype.setArray4 = function(e, i) {
  42333. this._valueCache[e] = null,
  42334. this.engine.setArray4(this._uniforms[e], i)
  42335. }
  42336. ,
  42337. a.prototype.setMatrices = function(e, i) {
  42338. !i || (this._valueCache[e] = null,
  42339. this.engine.setMatrices(this._uniforms[e], i))
  42340. }
  42341. ,
  42342. a.prototype.setMatrix = function(e, i) {
  42343. this._cacheMatrix(e, i) && (this.engine.setMatrices(this._uniforms[e], i.toArray()) || (this._valueCache[e] = null))
  42344. }
  42345. ,
  42346. a.prototype.setMatrix3x3 = function(e, i) {
  42347. this._valueCache[e] = null,
  42348. this.engine.setMatrix3x3(this._uniforms[e], i)
  42349. }
  42350. ,
  42351. a.prototype.setMatrix2x2 = function(e, i) {
  42352. this._valueCache[e] = null,
  42353. this.engine.setMatrix2x2(this._uniforms[e], i)
  42354. }
  42355. ,
  42356. a.prototype.setFloat = function(e, i) {
  42357. var o = this._valueCache[e];
  42358. o !== void 0 && o === i || this.engine.setFloat(this._uniforms[e], i) && (this._valueCache[e] = i)
  42359. }
  42360. ,
  42361. a.prototype.setBool = function(e, i) {
  42362. var o = this._valueCache[e];
  42363. o !== void 0 && o === i || this.engine.setInt(this._uniforms[e], i ? 1 : 0) && (this._valueCache[e] = i ? 1 : 0)
  42364. }
  42365. ,
  42366. a.prototype.setVector2 = function(e, i) {
  42367. this._cacheFloat2(e, i.x, i.y) && (this.engine.setFloat2(this._uniforms[e], i.x, i.y) || (this._valueCache[e] = null))
  42368. }
  42369. ,
  42370. a.prototype.setFloat2 = function(e, i, o) {
  42371. this._cacheFloat2(e, i, o) && (this.engine.setFloat2(this._uniforms[e], i, o) || (this._valueCache[e] = null))
  42372. }
  42373. ,
  42374. a.prototype.setVector3 = function(e, i) {
  42375. this._cacheFloat3(e, i.x, i.y, i.z) && (this.engine.setFloat3(this._uniforms[e], i.x, i.y, i.z) || (this._valueCache[e] = null))
  42376. }
  42377. ,
  42378. a.prototype.setFloat3 = function(e, i, o, s) {
  42379. this._cacheFloat3(e, i, o, s) && (this.engine.setFloat3(this._uniforms[e], i, o, s) || (this._valueCache[e] = null))
  42380. }
  42381. ,
  42382. a.prototype.setVector4 = function(e, i) {
  42383. this._cacheFloat4(e, i.x, i.y, i.z, i.w) && (this.engine.setFloat4(this._uniforms[e], i.x, i.y, i.z, i.w) || (this._valueCache[e] = null))
  42384. }
  42385. ,
  42386. a.prototype.setFloat4 = function(e, i, o, s, c) {
  42387. this._cacheFloat4(e, i, o, s, c) && (this.engine.setFloat4(this._uniforms[e], i, o, s, c) || (this._valueCache[e] = null))
  42388. }
  42389. ,
  42390. a.prototype.setColor3 = function(e, i) {
  42391. this._cacheFloat3(e, i.r, i.g, i.b) && (this.engine.setFloat3(this._uniforms[e], i.r, i.g, i.b) || (this._valueCache[e] = null))
  42392. }
  42393. ,
  42394. a.prototype.setColor4 = function(e, i, o) {
  42395. this._cacheFloat4(e, i.r, i.g, i.b, o) && (this.engine.setFloat4(this._uniforms[e], i.r, i.g, i.b, o) || (this._valueCache[e] = null))
  42396. }
  42397. ,
  42398. a.prototype.setDirectColor4 = function(e, i) {
  42399. this._cacheFloat4(e, i.r, i.g, i.b, i.a) && (this.engine.setFloat4(this._uniforms[e], i.r, i.g, i.b, i.a) || (this._valueCache[e] = null))
  42400. }
  42401. ,
  42402. a
  42403. }()
  42404. , NativeRenderTargetWrapper = function(a) {
  42405. __extends(e, a);
  42406. function e(i, o, s, c) {
  42407. var d = a.call(this, i, o, s, c) || this;
  42408. return d.__framebuffer = null,
  42409. d.__framebufferDepthStencil = null,
  42410. d._engine = c,
  42411. d
  42412. }
  42413. return Object.defineProperty(e.prototype, "_framebuffer", {
  42414. get: function() {
  42415. return this.__framebuffer
  42416. },
  42417. set: function(i) {
  42418. this.__framebuffer && this._engine._releaseFramebufferObjects(this.__framebuffer),
  42419. this.__framebuffer = i
  42420. },
  42421. enumerable: !1,
  42422. configurable: !0
  42423. }),
  42424. Object.defineProperty(e.prototype, "_framebufferDepthStencil", {
  42425. get: function() {
  42426. return this.__framebufferDepthStencil
  42427. },
  42428. set: function(i) {
  42429. this.__framebufferDepthStencil && this._engine._releaseFramebufferObjects(this.__framebufferDepthStencil),
  42430. this.__framebufferDepthStencil = i
  42431. },
  42432. enumerable: !1,
  42433. configurable: !0
  42434. }),
  42435. e.prototype.dispose = function(i) {
  42436. i === void 0 && (i = !1),
  42437. this._framebuffer = null,
  42438. this._framebufferDepthStencil = null,
  42439. a.prototype.dispose.call(this, i)
  42440. }
  42441. ,
  42442. e
  42443. }(RenderTargetWrapper)
  42444. , NativeDataBuffer = function(a) {
  42445. __extends(e, a);
  42446. function e() {
  42447. return a !== null && a.apply(this, arguments) || this
  42448. }
  42449. return e
  42450. }(DataBuffer)
  42451. , CommandBufferEncoder = function() {
  42452. function a(e) {
  42453. this._engine = e,
  42454. this._pending = new Array,
  42455. this._isCommandBufferScopeActive = !1,
  42456. this._commandStream = NativeEngine._createNativeDataStream(),
  42457. this._engine.setCommandDataStream(this._commandStream)
  42458. }
  42459. return a.prototype.beginCommandScope = function() {
  42460. if (this._isCommandBufferScopeActive)
  42461. throw new Error("Command scope already active.");
  42462. this._isCommandBufferScopeActive = !0
  42463. }
  42464. ,
  42465. a.prototype.endCommandScope = function() {
  42466. if (!this._isCommandBufferScopeActive)
  42467. throw new Error("Command scope is not active.");
  42468. this._isCommandBufferScopeActive = !1,
  42469. this._submit()
  42470. }
  42471. ,
  42472. a.prototype.startEncodingCommand = function(e) {
  42473. this._commandStream.writeNativeData(e)
  42474. }
  42475. ,
  42476. a.prototype.encodeCommandArgAsUInt32 = function(e) {
  42477. this._commandStream.writeUint32(e)
  42478. }
  42479. ,
  42480. a.prototype.encodeCommandArgAsUInt32s = function(e) {
  42481. this._commandStream.writeUint32Array(e)
  42482. }
  42483. ,
  42484. a.prototype.encodeCommandArgAsInt32 = function(e) {
  42485. this._commandStream.writeInt32(e)
  42486. }
  42487. ,
  42488. a.prototype.encodeCommandArgAsInt32s = function(e) {
  42489. this._commandStream.writeInt32Array(e)
  42490. }
  42491. ,
  42492. a.prototype.encodeCommandArgAsFloat32 = function(e) {
  42493. this._commandStream.writeFloat32(e)
  42494. }
  42495. ,
  42496. a.prototype.encodeCommandArgAsFloat32s = function(e) {
  42497. this._commandStream.writeFloat32Array(e)
  42498. }
  42499. ,
  42500. a.prototype.encodeCommandArgAsNativeData = function(e) {
  42501. this._commandStream.writeNativeData(e),
  42502. this._pending.push(e)
  42503. }
  42504. ,
  42505. a.prototype.finishEncodingCommand = function() {
  42506. this._isCommandBufferScopeActive || this._submit()
  42507. }
  42508. ,
  42509. a.prototype._submit = function() {
  42510. this._engine.submitCommands(),
  42511. this._pending.length = 0
  42512. }
  42513. ,
  42514. a
  42515. }()
  42516. , NativeEngine = function(a) {
  42517. __extends(e, a);
  42518. function e(i) {
  42519. i === void 0 && (i = {});
  42520. var o = a.call(this, null, !1, void 0, i.adaptToDeviceRatio) || this;
  42521. if (o._engine = new _native.Engine,
  42522. o._camera = _native.Camera ? new _native.Camera : null,
  42523. o._commandBufferEncoder = new CommandBufferEncoder(o._engine),
  42524. o._boundBuffersVertexArray = null,
  42525. o._currentDepthTest = _native.Engine.DEPTH_TEST_LEQUAL,
  42526. o._stencilTest = !1,
  42527. o._stencilMask = 255,
  42528. o._stencilFunc = 519,
  42529. o._stencilFuncRef = 0,
  42530. o._stencilFuncMask = 255,
  42531. o._stencilOpStencilFail = 7680,
  42532. o._stencilOpDepthFail = 7680,
  42533. o._stencilOpStencilDepthPass = 7681,
  42534. o._zOffset = 0,
  42535. o._zOffsetUnits = 0,
  42536. o._depthWrite = !0,
  42537. _native.Engine.PROTOCOL_VERSION !== e.PROTOCOL_VERSION)
  42538. throw new Error("Protocol version mismatch: " + _native.Engine.PROTOCOL_VERSION + " (Native) !== " + e.PROTOCOL_VERSION + " (JS)");
  42539. o._webGLVersion = 2,
  42540. o.disableUniformBuffers = !0,
  42541. o._caps = {
  42542. maxTexturesImageUnits: 16,
  42543. maxVertexTextureImageUnits: 16,
  42544. maxCombinedTexturesImageUnits: 32,
  42545. maxTextureSize: 512,
  42546. maxCubemapTextureSize: 512,
  42547. maxRenderTextureSize: 512,
  42548. maxVertexAttribs: 16,
  42549. maxVaryingVectors: 16,
  42550. maxFragmentUniformVectors: 16,
  42551. maxVertexUniformVectors: 16,
  42552. standardDerivatives: !0,
  42553. astc: null,
  42554. pvrtc: null,
  42555. etc1: null,
  42556. etc2: null,
  42557. bptc: null,
  42558. maxAnisotropy: 16,
  42559. uintIndices: !0,
  42560. fragmentDepthSupported: !1,
  42561. highPrecisionShaderSupported: !0,
  42562. colorBufferFloat: !1,
  42563. textureFloat: !0,
  42564. textureFloatLinearFiltering: !1,
  42565. textureFloatRender: !1,
  42566. textureHalfFloat: !1,
  42567. textureHalfFloatLinearFiltering: !1,
  42568. textureHalfFloatRender: !1,
  42569. textureLOD: !0,
  42570. drawBuffersExtension: !1,
  42571. depthTextureExtension: !1,
  42572. vertexArrayObject: !0,
  42573. instancedArrays: !1,
  42574. supportOcclusionQuery: !1,
  42575. canUseTimestampForTimerQuery: !1,
  42576. blendMinMax: !1,
  42577. maxMSAASamples: 1,
  42578. canUseGLInstanceID: !0,
  42579. canUseGLVertexID: !0,
  42580. supportComputeShaders: !1,
  42581. supportSRGBBuffers: !0
  42582. },
  42583. o._features = {
  42584. forceBitmapOverHTMLImageElement: !1,
  42585. supportRenderAndCopyToLodForFloatTextures: !1,
  42586. supportDepthStencilTexture: !1,
  42587. supportShadowSamplers: !1,
  42588. uniformBufferHardCheckMatrix: !1,
  42589. allowTexturePrefiltering: !1,
  42590. trackUbosInFrame: !1,
  42591. checkUbosContentBeforeUpload: !1,
  42592. supportCSM: !1,
  42593. basisNeedsPOT: !1,
  42594. support3DTextures: !1,
  42595. needTypeSuffixInShaderConstants: !1,
  42596. supportMSAA: !1,
  42597. supportSSAO2: !1,
  42598. supportExtendedTextureFormats: !1,
  42599. supportSwitchCaseInShader: !1,
  42600. supportSyncTextureRead: !1,
  42601. needsInvertingBitmap: !0,
  42602. useUBOBindingCache: !0,
  42603. needShaderCodeInlining: !0,
  42604. needToAlwaysBindUniformBuffers: !1,
  42605. supportRenderPasses: !0,
  42606. _collectUbosUpdatedInFrame: !1
  42607. },
  42608. Tools.Log("Babylon Native (v" + Engine.Version + ") launched"),
  42609. Tools.LoadScript = function(d, _, b, k) {
  42610. Tools.LoadFile(d, function(j) {
  42611. Function(j).apply(null),
  42612. _ && _()
  42613. }, void 0, void 0, !1, function(j, $) {
  42614. b && b("LoadScript Error", $)
  42615. })
  42616. }
  42617. ,
  42618. typeof URL == "undefined" && (window.URL = {
  42619. createObjectURL: function() {},
  42620. revokeObjectURL: function() {}
  42621. }),
  42622. typeof Blob == "undefined" && (window.Blob = function(d) {
  42623. return d
  42624. }
  42625. );
  42626. var s = window && window.devicePixelRatio || 1;
  42627. o._hardwareScalingLevel = i.adaptToDeviceRatio ? s : 1,
  42628. o.resize();
  42629. var c = o.getDepthFunction();
  42630. return c && o.setDepthFunction(c),
  42631. o._shaderProcessor = new WebGL2ShaderProcessor,
  42632. o.onNewSceneAddedObservable.add(function(d) {
  42633. var _ = d.render;
  42634. d.render = function() {
  42635. for (var b = [], k = 0; k < arguments.length; k++)
  42636. b[k] = arguments[k];
  42637. o._commandBufferEncoder.beginCommandScope(),
  42638. _.apply(d, b),
  42639. o._commandBufferEncoder.endCommandScope()
  42640. }
  42641. }),
  42642. o
  42643. }
  42644. return e.prototype.getHardwareScalingLevel = function() {
  42645. return this._engine.getHardwareScalingLevel()
  42646. }
  42647. ,
  42648. e.prototype.setHardwareScalingLevel = function(i) {
  42649. this._engine.setHardwareScalingLevel(i)
  42650. }
  42651. ,
  42652. e.prototype.dispose = function() {
  42653. a.prototype.dispose.call(this),
  42654. this._boundBuffersVertexArray && this._deleteVertexArray(this._boundBuffersVertexArray),
  42655. this._engine.dispose()
  42656. }
  42657. ,
  42658. e._createNativeDataStream = function() {
  42659. return new NativeDataStream
  42660. }
  42661. ,
  42662. e.prototype._queueNewFrame = function(i, o) {
  42663. return o.requestAnimationFrame && o !== window ? o.requestAnimationFrame(i) : this._engine.requestAnimationFrame(i),
  42664. 0
  42665. }
  42666. ,
  42667. e.prototype._bindUnboundFramebuffer = function(i) {
  42668. this._currentFramebuffer !== i && (this._currentFramebuffer && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_UNBINDFRAMEBUFFER),
  42669. this._commandBufferEncoder.encodeCommandArgAsNativeData(this._currentFramebuffer),
  42670. this._commandBufferEncoder.finishEncodingCommand()),
  42671. i && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_BINDFRAMEBUFFER),
  42672. this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
  42673. this._commandBufferEncoder.finishEncodingCommand()),
  42674. this._currentFramebuffer = i)
  42675. }
  42676. ,
  42677. e.prototype.getHostDocument = function() {
  42678. return null
  42679. }
  42680. ,
  42681. e.prototype.clear = function(i, o, s, c) {
  42682. if (c === void 0 && (c = !1),
  42683. this.useReverseDepthBuffer)
  42684. throw new Error("reverse depth buffer is not currently implemented");
  42685. this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_CLEAR),
  42686. this._commandBufferEncoder.encodeCommandArgAsUInt32(o && i ? 1 : 0),
  42687. this._commandBufferEncoder.encodeCommandArgAsFloat32(i ? i.r : 0),
  42688. this._commandBufferEncoder.encodeCommandArgAsFloat32(i ? i.g : 0),
  42689. this._commandBufferEncoder.encodeCommandArgAsFloat32(i ? i.b : 0),
  42690. this._commandBufferEncoder.encodeCommandArgAsFloat32(i ? i.a : 1),
  42691. this._commandBufferEncoder.encodeCommandArgAsUInt32(s ? 1 : 0),
  42692. this._commandBufferEncoder.encodeCommandArgAsFloat32(1),
  42693. this._commandBufferEncoder.encodeCommandArgAsUInt32(c ? 1 : 0),
  42694. this._commandBufferEncoder.encodeCommandArgAsUInt32(0),
  42695. this._commandBufferEncoder.finishEncodingCommand()
  42696. }
  42697. ,
  42698. e.prototype.createIndexBuffer = function(i, o) {
  42699. var s = this._normalizeIndexData(i)
  42700. , c = new NativeDataBuffer;
  42701. return c.references = 1,
  42702. c.is32Bits = s.BYTES_PER_ELEMENT === 4,
  42703. s.byteLength && (c.nativeIndexBuffer = this._engine.createIndexBuffer(s.buffer, s.byteOffset, s.byteLength, c.is32Bits, o != null ? o : !1)),
  42704. c
  42705. }
  42706. ,
  42707. e.prototype.createVertexBuffer = function(i, o) {
  42708. var s = ArrayBuffer.isView(i) ? i : new Float32Array(i)
  42709. , c = new NativeDataBuffer;
  42710. return c.references = 1,
  42711. s.byteLength && (c.nativeVertexBuffer = this._engine.createVertexBuffer(s.buffer, s.byteOffset, s.byteLength, o != null ? o : !1)),
  42712. c
  42713. }
  42714. ,
  42715. e.prototype._recordVertexArrayObject = function(i, o, s, c) {
  42716. s && this._engine.recordIndexBuffer(i, s.nativeIndexBuffer);
  42717. for (var d = c.getAttributesNames(), _ = 0; _ < d.length; _++) {
  42718. var b = c.getAttributeLocation(_);
  42719. if (b >= 0) {
  42720. var k = d[_]
  42721. , j = o[k];
  42722. if (j) {
  42723. var $ = j.getBuffer();
  42724. $ && this._engine.recordVertexBuffer(i, $.nativeVertexBuffer, b, j.byteOffset, j.byteStride, j.getSize(), this._getNativeAttribType(j.type), j.normalized)
  42725. }
  42726. }
  42727. }
  42728. }
  42729. ,
  42730. e.prototype.bindBuffers = function(i, o, s) {
  42731. this._boundBuffersVertexArray && this._deleteVertexArray(this._boundBuffersVertexArray),
  42732. this._boundBuffersVertexArray = this._engine.createVertexArray(),
  42733. this._recordVertexArrayObject(this._boundBuffersVertexArray, i, o, s),
  42734. this.bindVertexArrayObject(this._boundBuffersVertexArray)
  42735. }
  42736. ,
  42737. e.prototype.recordVertexArrayObject = function(i, o, s) {
  42738. var c = this._engine.createVertexArray();
  42739. return this._recordVertexArrayObject(c, i, o, s),
  42740. c
  42741. }
  42742. ,
  42743. e.prototype._deleteVertexArray = function(i) {
  42744. this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DELETEVERTEXARRAY),
  42745. this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
  42746. this._commandBufferEncoder.finishEncodingCommand()
  42747. }
  42748. ,
  42749. e.prototype.bindVertexArrayObject = function(i) {
  42750. this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_BINDVERTEXARRAY),
  42751. this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
  42752. this._commandBufferEncoder.finishEncodingCommand()
  42753. }
  42754. ,
  42755. e.prototype.releaseVertexArrayObject = function(i) {
  42756. this._deleteVertexArray(i)
  42757. }
  42758. ,
  42759. e.prototype.getAttributes = function(i, o) {
  42760. var s = i;
  42761. return this._engine.getAttributes(s.nativeProgram, o)
  42762. }
  42763. ,
  42764. e.prototype.drawElementsType = function(i, o, s, c) {
  42765. this._drawCalls.addCount(1, !1),
  42766. this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DRAWINDEXED),
  42767. this._commandBufferEncoder.encodeCommandArgAsUInt32(i),
  42768. this._commandBufferEncoder.encodeCommandArgAsUInt32(o),
  42769. this._commandBufferEncoder.encodeCommandArgAsUInt32(s),
  42770. this._commandBufferEncoder.finishEncodingCommand()
  42771. }
  42772. ,
  42773. e.prototype.drawArraysType = function(i, o, s, c) {
  42774. this._drawCalls.addCount(1, !1),
  42775. this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DRAW),
  42776. this._commandBufferEncoder.encodeCommandArgAsUInt32(i),
  42777. this._commandBufferEncoder.encodeCommandArgAsUInt32(o),
  42778. this._commandBufferEncoder.encodeCommandArgAsUInt32(s),
  42779. this._commandBufferEncoder.finishEncodingCommand()
  42780. }
  42781. ,
  42782. e.prototype.createPipelineContext = function() {
  42783. return new NativePipelineContext(this)
  42784. }
  42785. ,
  42786. e.prototype.createMaterialContext = function() {}
  42787. ,
  42788. e.prototype.createDrawContext = function() {}
  42789. ,
  42790. e.prototype._preparePipelineContext = function(i, o, s, c, d, _, b, k, j) {
  42791. var $ = i;
  42792. c ? $.nativeProgram = this.createRawShaderProgram(i, o, s, void 0, j) : $.nativeProgram = this.createShaderProgram(i, o, s, k, void 0, j)
  42793. }
  42794. ,
  42795. e.prototype._isRenderingStateCompiled = function(i) {
  42796. return !0
  42797. }
  42798. ,
  42799. e.prototype._executeWhenRenderingStateIsCompiled = function(i, o) {
  42800. o()
  42801. }
  42802. ,
  42803. e.prototype.createRawShaderProgram = function(i, o, s, c, d) {
  42804. throw new Error("Not Supported")
  42805. }
  42806. ,
  42807. e.prototype.createShaderProgram = function(i, o, s, c, d, _) {
  42808. this.onBeforeShaderCompilationObservable.notifyObservers(this);
  42809. var b = new ShaderCodeInliner(o);
  42810. b.processCode(),
  42811. o = b.code;
  42812. var k = new ShaderCodeInliner(s);
  42813. k.processCode(),
  42814. s = k.code,
  42815. o = ThinEngine._ConcatenateShader(o, c),
  42816. s = ThinEngine._ConcatenateShader(s, c);
  42817. var j = this._engine.createProgram(o, s);
  42818. return this.onAfterShaderCompilationObservable.notifyObservers(this),
  42819. j
  42820. }
  42821. ,
  42822. e.prototype.inlineShaderCode = function(i) {
  42823. var o = new ShaderCodeInliner(i);
  42824. return o.debug = !1,
  42825. o.processCode(),
  42826. o.code
  42827. }
  42828. ,
  42829. e.prototype._setProgram = function(i) {
  42830. this._currentProgram !== i && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETPROGRAM),
  42831. this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
  42832. this._commandBufferEncoder.finishEncodingCommand(),
  42833. this._currentProgram = i)
  42834. }
  42835. ,
  42836. e.prototype._deletePipelineContext = function(i) {
  42837. var o = i;
  42838. o && o.nativeProgram && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DELETEPROGRAM),
  42839. this._commandBufferEncoder.encodeCommandArgAsNativeData(o.nativeProgram),
  42840. this._commandBufferEncoder.finishEncodingCommand())
  42841. }
  42842. ,
  42843. e.prototype.getUniforms = function(i, o) {
  42844. var s = i;
  42845. return this._engine.getUniforms(s.nativeProgram, o)
  42846. }
  42847. ,
  42848. e.prototype.bindUniformBlock = function(i, o, s) {
  42849. throw new Error("Not Implemented")
  42850. }
  42851. ,
  42852. e.prototype.bindSamplers = function(i) {
  42853. var o = i.getPipelineContext();
  42854. this._setProgram(o.nativeProgram);
  42855. for (var s = i.getSamplers(), c = 0; c < s.length; c++) {
  42856. var d = i.getUniform(s[c]);
  42857. d && (this._boundUniforms[c] = d)
  42858. }
  42859. this._currentEffect = null
  42860. }
  42861. ,
  42862. e.prototype.setMatrix = function(i, o) {
  42863. if (!!i) {
  42864. var s = o.toArray();
  42865. this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETMATRIX),
  42866. this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
  42867. this._commandBufferEncoder.encodeCommandArgAsFloat32s(s),
  42868. this._commandBufferEncoder.finishEncodingCommand()
  42869. }
  42870. }
  42871. ,
  42872. e.prototype.getRenderWidth = function(i) {
  42873. return i === void 0 && (i = !1),
  42874. !i && this._currentRenderTarget ? this._currentRenderTarget.width : this._engine.getRenderWidth()
  42875. }
  42876. ,
  42877. e.prototype.getRenderHeight = function(i) {
  42878. return i === void 0 && (i = !1),
  42879. !i && this._currentRenderTarget ? this._currentRenderTarget.height : this._engine.getRenderHeight()
  42880. }
  42881. ,
  42882. e.prototype.setViewport = function(i, o, s) {
  42883. this._cachedViewport = i,
  42884. this._engine.setViewPort(i.x, i.y, i.width, i.height)
  42885. }
  42886. ,
  42887. e.prototype.setState = function(i, o, s, c, d, _, b) {
  42888. var k, j;
  42889. o === void 0 && (o = 0),
  42890. c === void 0 && (c = !1),
  42891. b === void 0 && (b = 0),
  42892. this._zOffset = o,
  42893. this._zOffsetUnits = b,
  42894. this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETSTATE),
  42895. this._commandBufferEncoder.encodeCommandArgAsUInt32(i ? 1 : 0),
  42896. this._commandBufferEncoder.encodeCommandArgAsFloat32(o),
  42897. this._commandBufferEncoder.encodeCommandArgAsFloat32(b),
  42898. this._commandBufferEncoder.encodeCommandArgAsUInt32(!((j = (k = this.cullBackFaces) !== null && k !== void 0 ? k : d) !== null && j !== void 0) || j ? 1 : 0),
  42899. this._commandBufferEncoder.encodeCommandArgAsUInt32(c ? 1 : 0),
  42900. this._commandBufferEncoder.finishEncodingCommand()
  42901. }
  42902. ,
  42903. e.prototype.getInputElementClientRect = function() {
  42904. var i = {
  42905. bottom: this.getRenderHeight(),
  42906. height: this.getRenderHeight(),
  42907. left: 0,
  42908. right: this.getRenderWidth(),
  42909. top: 0,
  42910. width: this.getRenderWidth(),
  42911. x: 0,
  42912. y: 0,
  42913. toJSON: function() {}
  42914. };
  42915. return i
  42916. }
  42917. ,
  42918. e.prototype.setZOffset = function(i) {
  42919. i !== this._zOffset && (this._zOffset = i,
  42920. this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETZOFFSET),
  42921. this._commandBufferEncoder.encodeCommandArgAsFloat32(this.useReverseDepthBuffer ? -i : i),
  42922. this._commandBufferEncoder.finishEncodingCommand())
  42923. }
  42924. ,
  42925. e.prototype.getZOffset = function() {
  42926. return this._zOffset
  42927. }
  42928. ,
  42929. e.prototype.setZOffsetUnits = function(i) {
  42930. i !== this._zOffsetUnits && (this._zOffsetUnits = i,
  42931. this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETZOFFSETUNITS),
  42932. this._commandBufferEncoder.encodeCommandArgAsFloat32(this.useReverseDepthBuffer ? -i : i),
  42933. this._commandBufferEncoder.finishEncodingCommand())
  42934. }
  42935. ,
  42936. e.prototype.getZOffsetUnits = function() {
  42937. return this._zOffsetUnits
  42938. }
  42939. ,
  42940. e.prototype.setDepthBuffer = function(i) {
  42941. this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETDEPTHTEST),
  42942. this._commandBufferEncoder.encodeCommandArgAsUInt32(i ? this._currentDepthTest : _native.Engine.DEPTH_TEST_ALWAYS),
  42943. this._commandBufferEncoder.finishEncodingCommand()
  42944. }
  42945. ,
  42946. e.prototype.getDepthWrite = function() {
  42947. return this._depthWrite
  42948. }
  42949. ,
  42950. e.prototype.getDepthFunction = function() {
  42951. switch (this._currentDepthTest) {
  42952. case _native.Engine.DEPTH_TEST_NEVER:
  42953. return 512;
  42954. case _native.Engine.DEPTH_TEST_ALWAYS:
  42955. return 519;
  42956. case _native.Engine.DEPTH_TEST_GREATER:
  42957. return 516;
  42958. case _native.Engine.DEPTH_TEST_GEQUAL:
  42959. return 518;
  42960. case _native.Engine.DEPTH_TEST_NOTEQUAL:
  42961. return 517;
  42962. case _native.Engine.DEPTH_TEST_EQUAL:
  42963. return 514;
  42964. case _native.Engine.DEPTH_TEST_LESS:
  42965. return 513;
  42966. case _native.Engine.DEPTH_TEST_LEQUAL:
  42967. return 515
  42968. }
  42969. return null
  42970. }
  42971. ,
  42972. e.prototype.setDepthFunction = function(i) {
  42973. var o = 0;
  42974. switch (i) {
  42975. case 512:
  42976. o = _native.Engine.DEPTH_TEST_NEVER;
  42977. break;
  42978. case 519:
  42979. o = _native.Engine.DEPTH_TEST_ALWAYS;
  42980. break;
  42981. case 516:
  42982. o = _native.Engine.DEPTH_TEST_GREATER;
  42983. break;
  42984. case 518:
  42985. o = _native.Engine.DEPTH_TEST_GEQUAL;
  42986. break;
  42987. case 517:
  42988. o = _native.Engine.DEPTH_TEST_NOTEQUAL;
  42989. break;
  42990. case 514:
  42991. o = _native.Engine.DEPTH_TEST_EQUAL;
  42992. break;
  42993. case 513:
  42994. o = _native.Engine.DEPTH_TEST_LESS;
  42995. break;
  42996. case 515:
  42997. o = _native.Engine.DEPTH_TEST_LEQUAL;
  42998. break
  42999. }
  43000. this._currentDepthTest = o,
  43001. this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETDEPTHTEST),
  43002. this._commandBufferEncoder.encodeCommandArgAsUInt32(this._currentDepthTest),
  43003. this._commandBufferEncoder.finishEncodingCommand()
  43004. }
  43005. ,
  43006. e.prototype.setDepthWrite = function(i) {
  43007. this._depthWrite = i,
  43008. this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETDEPTHWRITE),
  43009. this._commandBufferEncoder.encodeCommandArgAsUInt32(Number(i)),
  43010. this._commandBufferEncoder.finishEncodingCommand()
  43011. }
  43012. ,
  43013. e.prototype.setColorWrite = function(i) {
  43014. this._colorWrite = i,
  43015. this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETCOLORWRITE),
  43016. this._commandBufferEncoder.encodeCommandArgAsUInt32(Number(i)),
  43017. this._commandBufferEncoder.finishEncodingCommand()
  43018. }
  43019. ,
  43020. e.prototype.getColorWrite = function() {
  43021. return this._colorWrite
  43022. }
  43023. ,
  43024. e.prototype.applyStencil = function() {
  43025. this._setStencil(this._stencilMask, this._getStencilOpFail(this._stencilOpStencilFail), this._getStencilDepthFail(this._stencilOpDepthFail), this._getStencilDepthPass(this._stencilOpStencilDepthPass), this._getStencilFunc(this._stencilFunc), this._stencilFuncRef)
  43026. }
  43027. ,
  43028. e.prototype._setStencil = function(i, o, s, c, d, _) {
  43029. this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETSTENCIL),
  43030. this._commandBufferEncoder.encodeCommandArgAsUInt32(i),
  43031. this._commandBufferEncoder.encodeCommandArgAsUInt32(o),
  43032. this._commandBufferEncoder.encodeCommandArgAsUInt32(s),
  43033. this._commandBufferEncoder.encodeCommandArgAsUInt32(c),
  43034. this._commandBufferEncoder.encodeCommandArgAsUInt32(d),
  43035. this._commandBufferEncoder.encodeCommandArgAsUInt32(_),
  43036. this._commandBufferEncoder.finishEncodingCommand()
  43037. }
  43038. ,
  43039. e.prototype.setStencilBuffer = function(i) {
  43040. this._stencilTest = i,
  43041. i ? this.applyStencil() : this._setStencil(255, _native.Engine.STENCIL_OP_FAIL_S_KEEP, _native.Engine.STENCIL_OP_FAIL_Z_KEEP, _native.Engine.STENCIL_OP_PASS_Z_KEEP, _native.Engine.STENCIL_TEST_ALWAYS, 0)
  43042. }
  43043. ,
  43044. e.prototype.getStencilBuffer = function() {
  43045. return this._stencilTest
  43046. }
  43047. ,
  43048. e.prototype.getStencilOperationPass = function() {
  43049. return this._stencilOpStencilDepthPass
  43050. }
  43051. ,
  43052. e.prototype.setStencilOperationPass = function(i) {
  43053. this._stencilOpStencilDepthPass = i,
  43054. this.applyStencil()
  43055. }
  43056. ,
  43057. e.prototype.setStencilMask = function(i) {
  43058. this._stencilMask = i,
  43059. this.applyStencil()
  43060. }
  43061. ,
  43062. e.prototype.setStencilFunction = function(i) {
  43063. this._stencilFunc = i,
  43064. this.applyStencil()
  43065. }
  43066. ,
  43067. e.prototype.setStencilFunctionReference = function(i) {
  43068. this._stencilFuncRef = i,
  43069. this.applyStencil()
  43070. }
  43071. ,
  43072. e.prototype.setStencilFunctionMask = function(i) {
  43073. this._stencilFuncMask = i
  43074. }
  43075. ,
  43076. e.prototype.setStencilOperationFail = function(i) {
  43077. this._stencilOpStencilFail = i,
  43078. this.applyStencil()
  43079. }
  43080. ,
  43081. e.prototype.setStencilOperationDepthFail = function(i) {
  43082. this._stencilOpDepthFail = i,
  43083. this.applyStencil()
  43084. }
  43085. ,
  43086. e.prototype.getStencilMask = function() {
  43087. return this._stencilMask
  43088. }
  43089. ,
  43090. e.prototype.getStencilFunction = function() {
  43091. return this._stencilFunc
  43092. }
  43093. ,
  43094. e.prototype.getStencilFunctionReference = function() {
  43095. return this._stencilFuncRef
  43096. }
  43097. ,
  43098. e.prototype.getStencilFunctionMask = function() {
  43099. return this._stencilFuncMask
  43100. }
  43101. ,
  43102. e.prototype.getStencilOperationFail = function() {
  43103. return this._stencilOpStencilFail
  43104. }
  43105. ,
  43106. e.prototype.getStencilOperationDepthFail = function() {
  43107. return this._stencilOpDepthFail
  43108. }
  43109. ,
  43110. e.prototype.setAlphaConstants = function(i, o, s, c) {
  43111. throw new Error("Setting alpha blend constant color not yet implemented.")
  43112. }
  43113. ,
  43114. e.prototype.setAlphaMode = function(i, o) {
  43115. o === void 0 && (o = !1),
  43116. this._alphaMode !== i && (i = this._getNativeAlphaMode(i),
  43117. this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETBLENDMODE),
  43118. this._commandBufferEncoder.encodeCommandArgAsUInt32(i),
  43119. this._commandBufferEncoder.finishEncodingCommand(),
  43120. o || this.setDepthWrite(i === 0),
  43121. this._alphaMode = i)
  43122. }
  43123. ,
  43124. e.prototype.getAlphaMode = function() {
  43125. return this._alphaMode
  43126. }
  43127. ,
  43128. e.prototype.setInt = function(i, o) {
  43129. return i ? (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETINT),
  43130. this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
  43131. this._commandBufferEncoder.encodeCommandArgAsInt32(o),
  43132. this._commandBufferEncoder.finishEncodingCommand(),
  43133. !0) : !1
  43134. }
  43135. ,
  43136. e.prototype.setIntArray = function(i, o) {
  43137. return i ? (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETINTARRAY),
  43138. this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
  43139. this._commandBufferEncoder.encodeCommandArgAsInt32s(o),
  43140. this._commandBufferEncoder.finishEncodingCommand(),
  43141. !0) : !1
  43142. }
  43143. ,
  43144. e.prototype.setIntArray2 = function(i, o) {
  43145. return i ? (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETINTARRAY2),
  43146. this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
  43147. this._commandBufferEncoder.encodeCommandArgAsInt32s(o),
  43148. this._commandBufferEncoder.finishEncodingCommand(),
  43149. !0) : !1
  43150. }
  43151. ,
  43152. e.prototype.setIntArray3 = function(i, o) {
  43153. return i ? (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETINTARRAY3),
  43154. this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
  43155. this._commandBufferEncoder.encodeCommandArgAsInt32s(o),
  43156. this._commandBufferEncoder.finishEncodingCommand(),
  43157. !0) : !1
  43158. }
  43159. ,
  43160. e.prototype.setIntArray4 = function(i, o) {
  43161. return i ? (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETINTARRAY4),
  43162. this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
  43163. this._commandBufferEncoder.encodeCommandArgAsInt32s(o),
  43164. this._commandBufferEncoder.finishEncodingCommand(),
  43165. !0) : !1
  43166. }
  43167. ,
  43168. e.prototype.setFloatArray = function(i, o) {
  43169. return i ? (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOATARRAY),
  43170. this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
  43171. this._commandBufferEncoder.encodeCommandArgAsFloat32s(o),
  43172. this._commandBufferEncoder.finishEncodingCommand(),
  43173. !0) : !1
  43174. }
  43175. ,
  43176. e.prototype.setFloatArray2 = function(i, o) {
  43177. return i ? (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOATARRAY2),
  43178. this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
  43179. this._commandBufferEncoder.encodeCommandArgAsFloat32s(o),
  43180. this._commandBufferEncoder.finishEncodingCommand(),
  43181. !0) : !1
  43182. }
  43183. ,
  43184. e.prototype.setFloatArray3 = function(i, o) {
  43185. return i ? (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOATARRAY3),
  43186. this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
  43187. this._commandBufferEncoder.encodeCommandArgAsFloat32s(o),
  43188. this._commandBufferEncoder.finishEncodingCommand(),
  43189. !0) : !1
  43190. }
  43191. ,
  43192. e.prototype.setFloatArray4 = function(i, o) {
  43193. return i ? (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOATARRAY4),
  43194. this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
  43195. this._commandBufferEncoder.encodeCommandArgAsFloat32s(o),
  43196. this._commandBufferEncoder.finishEncodingCommand(),
  43197. !0) : !1
  43198. }
  43199. ,
  43200. e.prototype.setArray = function(i, o) {
  43201. return i ? this.setFloatArray(i, new Float32Array(o)) : !1
  43202. }
  43203. ,
  43204. e.prototype.setArray2 = function(i, o) {
  43205. return i ? (this.setFloatArray2(i, new Float32Array(o)),
  43206. !0) : !1
  43207. }
  43208. ,
  43209. e.prototype.setArray3 = function(i, o) {
  43210. return i ? (this.setFloatArray3(i, new Float32Array(o)),
  43211. !0) : !1
  43212. }
  43213. ,
  43214. e.prototype.setArray4 = function(i, o) {
  43215. return i ? (this.setFloatArray4(i, new Float32Array(o)),
  43216. !0) : !1
  43217. }
  43218. ,
  43219. e.prototype.setMatrices = function(i, o) {
  43220. return i ? (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETMATRICES),
  43221. this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
  43222. this._commandBufferEncoder.encodeCommandArgAsFloat32s(o),
  43223. this._commandBufferEncoder.finishEncodingCommand(),
  43224. !0) : !1
  43225. }
  43226. ,
  43227. e.prototype.setMatrix3x3 = function(i, o) {
  43228. return i ? (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETMATRIX3X3),
  43229. this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
  43230. this._commandBufferEncoder.encodeCommandArgAsFloat32s(o),
  43231. this._commandBufferEncoder.finishEncodingCommand(),
  43232. !0) : !1
  43233. }
  43234. ,
  43235. e.prototype.setMatrix2x2 = function(i, o) {
  43236. return i ? (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETMATRIX2X2),
  43237. this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
  43238. this._commandBufferEncoder.encodeCommandArgAsFloat32s(o),
  43239. this._commandBufferEncoder.finishEncodingCommand(),
  43240. !0) : !1
  43241. }
  43242. ,
  43243. e.prototype.setFloat = function(i, o) {
  43244. return i ? (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOAT),
  43245. this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
  43246. this._commandBufferEncoder.encodeCommandArgAsFloat32(o),
  43247. this._commandBufferEncoder.finishEncodingCommand(),
  43248. !0) : !1
  43249. }
  43250. ,
  43251. e.prototype.setFloat2 = function(i, o, s) {
  43252. return i ? (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOAT2),
  43253. this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
  43254. this._commandBufferEncoder.encodeCommandArgAsFloat32(o),
  43255. this._commandBufferEncoder.encodeCommandArgAsFloat32(s),
  43256. this._commandBufferEncoder.finishEncodingCommand(),
  43257. !0) : !1
  43258. }
  43259. ,
  43260. e.prototype.setFloat3 = function(i, o, s, c) {
  43261. return i ? (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOAT3),
  43262. this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
  43263. this._commandBufferEncoder.encodeCommandArgAsFloat32(o),
  43264. this._commandBufferEncoder.encodeCommandArgAsFloat32(s),
  43265. this._commandBufferEncoder.encodeCommandArgAsFloat32(c),
  43266. this._commandBufferEncoder.finishEncodingCommand(),
  43267. !0) : !1
  43268. }
  43269. ,
  43270. e.prototype.setFloat4 = function(i, o, s, c, d) {
  43271. return i ? (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOAT4),
  43272. this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
  43273. this._commandBufferEncoder.encodeCommandArgAsFloat32(o),
  43274. this._commandBufferEncoder.encodeCommandArgAsFloat32(s),
  43275. this._commandBufferEncoder.encodeCommandArgAsFloat32(c),
  43276. this._commandBufferEncoder.encodeCommandArgAsFloat32(d),
  43277. this._commandBufferEncoder.finishEncodingCommand(),
  43278. !0) : !1
  43279. }
  43280. ,
  43281. e.prototype.setColor3 = function(i, o) {
  43282. return i ? (this.setFloat3(i, o.r, o.g, o.b),
  43283. !0) : !1
  43284. }
  43285. ,
  43286. e.prototype.setColor4 = function(i, o, s) {
  43287. return i ? (this.setFloat4(i, o.r, o.g, o.b, s),
  43288. !0) : !1
  43289. }
  43290. ,
  43291. e.prototype.wipeCaches = function(i) {
  43292. this.preventCacheWipeBetweenFrames || (this.resetTextureCache(),
  43293. this._currentEffect = null,
  43294. i && (this._currentProgram = null,
  43295. this._stencilStateComposer.reset(),
  43296. this._depthCullingState.reset(),
  43297. this._alphaState.reset()),
  43298. this._cachedVertexBuffers = null,
  43299. this._cachedIndexBuffer = null,
  43300. this._cachedEffectForVertexBuffers = null)
  43301. }
  43302. ,
  43303. e.prototype._createTexture = function() {
  43304. return this._engine.createTexture()
  43305. }
  43306. ,
  43307. e.prototype._deleteTexture = function(i) {
  43308. i && this._engine.deleteTexture(i)
  43309. }
  43310. ,
  43311. e.prototype.updateDynamicTexture = function(i, o, s, c, d) {
  43312. if (!!i && !!i._hardwareTexture) {
  43313. var _ = o.getCanvasTexture()
  43314. , b = i._hardwareTexture.underlyingResource;
  43315. this._engine.copyTexture(b, _),
  43316. i.isReady = !0
  43317. }
  43318. }
  43319. ,
  43320. e.prototype.createDynamicTexture = function(i, o, s, c) {
  43321. return i = Math.max(i, 1),
  43322. o = Math.max(o, 1),
  43323. this.createRawTexture(new Uint8Array(i * o * 4), i, o, 5, !1, !1, c)
  43324. }
  43325. ,
  43326. e.prototype.createVideoElement = function(i) {
  43327. return this._camera ? this._camera.createVideo(i) : null
  43328. }
  43329. ,
  43330. e.prototype.updateVideoTexture = function(i, o, s) {
  43331. if (i && i._hardwareTexture && this._camera) {
  43332. var c = i._hardwareTexture.underlyingResource;
  43333. this._camera.updateVideoTexture(c, o, s)
  43334. }
  43335. }
  43336. ,
  43337. e.prototype.createRawTexture = function(i, o, s, c, d, _, b, k, j) {
  43338. k === void 0 && (k = null),
  43339. j === void 0 && (j = 0);
  43340. var $ = new InternalTexture(this,InternalTextureSource.Raw);
  43341. if ($.format = c,
  43342. $.generateMipMaps = d,
  43343. $.samplingMode = b,
  43344. $.invertY = _,
  43345. $.baseWidth = o,
  43346. $.baseHeight = s,
  43347. $.width = $.baseWidth,
  43348. $.height = $.baseHeight,
  43349. $._compression = k,
  43350. $.type = j,
  43351. this.updateRawTexture($, i, c, _, k, j),
  43352. $._hardwareTexture) {
  43353. var _e = $._hardwareTexture.underlyingResource
  43354. , et = this._getNativeSamplingMode(b);
  43355. this._setTextureSampling(_e, et)
  43356. }
  43357. return this._internalTexturesCache.push($),
  43358. $
  43359. }
  43360. ,
  43361. e.prototype.updateRawTexture = function(i, o, s, c, d, _) {
  43362. if (_ === void 0 && (_ = 0),
  43363. !!i) {
  43364. if (o && i._hardwareTexture) {
  43365. var b = i._hardwareTexture.underlyingResource;
  43366. this._engine.loadRawTexture(b, o, i.width, i.height, this._getNativeTextureFormat(s, _), i.generateMipMaps, i.invertY)
  43367. }
  43368. i.isReady = !0
  43369. }
  43370. }
  43371. ,
  43372. e.prototype.createTexture = function(i, o, s, c, d, _, b, k, j, $, _e, et, tt, rt, it) {
  43373. var nt = this;
  43374. d === void 0 && (d = 3),
  43375. _ === void 0 && (_ = null),
  43376. b === void 0 && (b = null),
  43377. k === void 0 && (k = null),
  43378. j === void 0 && (j = null),
  43379. $ === void 0 && ($ = null),
  43380. _e === void 0 && (_e = null),
  43381. it === void 0 && (it = !1),
  43382. i = i || "";
  43383. var ot = i.substr(0, 5) === "data:"
  43384. , at = ot && i.indexOf(";base64,") !== -1
  43385. , st = j || new InternalTexture(this,InternalTextureSource.Url)
  43386. , ut = i;
  43387. this._transformTextureUrl && !at && !j && !k && (i = this._transformTextureUrl(i));
  43388. for (var ct = i.lastIndexOf("."), lt = _e || (ct > -1 ? i.substring(ct).toLowerCase() : ""), ft = null, ht = 0, pt = Engine._TextureLoaders; ht < pt.length; ht++) {
  43389. var dt = pt[ht];
  43390. if (dt.canLoad(lt)) {
  43391. ft = dt;
  43392. break
  43393. }
  43394. }
  43395. c && c._addPendingData(st),
  43396. st.url = i,
  43397. st.generateMipMaps = !o,
  43398. st.samplingMode = d,
  43399. st.invertY = s,
  43400. st._useSRGBBuffer = this._getUseSRGBBuffer(it, o),
  43401. this.doNotHandleContextLost || (st._buffer = k);
  43402. var _t = null;
  43403. _ && !j && (_t = st.onLoadedObservable.add(_)),
  43404. j || this._internalTexturesCache.push(st);
  43405. var mt = function(yt, Et) {
  43406. c && c._removePendingData(st),
  43407. i === ut ? (_t && st.onLoadedObservable.remove(_t),
  43408. EngineStore.UseFallbackTexture && nt.createTexture(EngineStore.FallbackTexture, o, st.invertY, c, d, null, b, k, st),
  43409. b && b((yt || "Unknown error") + (EngineStore.UseFallbackTexture ? " - Fallback texture was used" : ""), Et)) : (Logger$2.Warn("Failed to load " + i + ", falling back to " + ut),
  43410. nt.createTexture(ut, o, st.invertY, c, d, _, b, k, st, $, _e, et, tt))
  43411. };
  43412. if (ft)
  43413. throw new Error("Loading textures from IInternalTextureLoader not yet implemented.");
  43414. var vt = function(yt) {
  43415. if (!st._hardwareTexture) {
  43416. c && c._removePendingData(st);
  43417. return
  43418. }
  43419. var Et = st._hardwareTexture.underlyingResource;
  43420. nt._engine.loadTexture(Et, yt, !o, s, it, function() {
  43421. st.baseWidth = nt._engine.getTextureWidth(Et),
  43422. st.baseHeight = nt._engine.getTextureHeight(Et),
  43423. st.width = st.baseWidth,
  43424. st.height = st.baseHeight,
  43425. st.isReady = !0;
  43426. var At = nt._getNativeSamplingMode(d);
  43427. nt._setTextureSampling(Et, At),
  43428. c && c._removePendingData(st),
  43429. st.onLoadedObservable.notifyObservers(st),
  43430. st.onLoadedObservable.clear()
  43431. }, function() {
  43432. throw new Error("Could not load a native texture.")
  43433. })
  43434. };
  43435. if (ot && k)
  43436. if (k instanceof ArrayBuffer)
  43437. vt(new Uint8Array(k));
  43438. else if (ArrayBuffer.isView(k))
  43439. vt(k);
  43440. else if (typeof k == "string")
  43441. vt(new Uint8Array(Tools.DecodeBase64(k)));
  43442. else
  43443. throw new Error("Unsupported buffer type");
  43444. else
  43445. at ? vt(new Uint8Array(Tools.DecodeBase64(i))) : this._loadFile(i, function(yt) {
  43446. return vt(new Uint8Array(yt))
  43447. }, void 0, void 0, !0, function(yt, Et) {
  43448. mt("Unable to load " + (yt && yt.responseURL,
  43449. Et))
  43450. });
  43451. return st
  43452. }
  43453. ,
  43454. e.prototype._createDepthStencilTexture = function(i, o, s) {
  43455. var c = s
  43456. , d = new InternalTexture(this,InternalTextureSource.DepthStencil)
  43457. , _ = i.width || i
  43458. , b = i.height || i
  43459. , k = this._engine.createFrameBuffer(d._hardwareTexture.underlyingResource, _, b, _native.Engine.TEXTURE_FORMAT_RGBA8, !1, !0, !1);
  43460. return c._framebufferDepthStencil = k,
  43461. d
  43462. }
  43463. ,
  43464. e.prototype._releaseFramebufferObjects = function(i) {
  43465. i && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DELETEFRAMEBUFFER),
  43466. this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
  43467. this._commandBufferEncoder.finishEncodingCommand())
  43468. }
  43469. ,
  43470. e.prototype.createImageBitmap = function(i, o) {
  43471. var s = this;
  43472. return new Promise(function(c, d) {
  43473. if (Array.isArray(i)) {
  43474. var _ = i;
  43475. if (_.length) {
  43476. var b = s._engine.createImageBitmap(_[0]);
  43477. if (b) {
  43478. c(b);
  43479. return
  43480. }
  43481. }
  43482. }
  43483. d("Unsupported data for createImageBitmap.")
  43484. }
  43485. )
  43486. }
  43487. ,
  43488. e.prototype.resizeImageBitmap = function(i, o, s) {
  43489. return this._engine.resizeImageBitmap(i, o, s)
  43490. }
  43491. ,
  43492. e.prototype.createCubeTexture = function(i, o, s, c, d, _, b, k, j, $, _e, et, tt, rt) {
  43493. var it = this;
  43494. d === void 0 && (d = null),
  43495. _ === void 0 && (_ = null),
  43496. k === void 0 && (k = null),
  43497. $ === void 0 && ($ = 0),
  43498. _e === void 0 && (_e = 0),
  43499. et === void 0 && (et = null),
  43500. rt === void 0 && (rt = !1);
  43501. var nt = et || new InternalTexture(this,InternalTextureSource.Cube);
  43502. nt.isCube = !0,
  43503. nt.url = i,
  43504. nt.generateMipMaps = !c,
  43505. nt._lodGenerationScale = $,
  43506. nt._lodGenerationOffset = _e,
  43507. this._doNotHandleContextLost || (nt._extension = k,
  43508. nt._files = s);
  43509. var ot = i.lastIndexOf(".")
  43510. , at = k || (ot > -1 ? i.substring(ot).toLowerCase() : "");
  43511. if (at === ".env") {
  43512. var st = function(lt) {
  43513. var ft = GetEnvInfo(lt);
  43514. nt.width = ft.width,
  43515. nt.height = ft.width,
  43516. UploadEnvSpherical(nt, ft);
  43517. var ht = ft.specular;
  43518. if (!ht)
  43519. throw new Error("Nothing else parsed so far");
  43520. nt._lodGenerationScale = ht.lodGenerationScale;
  43521. var pt = CreateImageDataArrayBufferViews(lt, ft);
  43522. nt.format = 5,
  43523. nt.type = 0,
  43524. nt.generateMipMaps = !0,
  43525. nt.getEngine().updateTextureSamplingMode(Texture.TRILINEAR_SAMPLINGMODE, nt),
  43526. nt._isRGBD = !0,
  43527. nt.invertY = !0,
  43528. it._engine.loadCubeTextureWithMips(nt._hardwareTexture.underlyingResource, pt, !1, rt, function() {
  43529. nt.isReady = !0,
  43530. d && d()
  43531. }, function() {
  43532. throw new Error("Could not load a native cube texture.")
  43533. })
  43534. };
  43535. if (s && s.length === 6)
  43536. throw new Error("Multi-file loading not allowed on env files.");
  43537. var ut = function(lt, ft) {
  43538. _ && lt && _(lt.status + " " + lt.statusText, ft)
  43539. };
  43540. this._loadFile(i, function(lt) {
  43541. return st(new Uint8Array(lt))
  43542. }, void 0, void 0, !0, ut)
  43543. } else {
  43544. if (!s || s.length !== 6)
  43545. throw new Error("Cannot load cubemap because 6 files were not defined");
  43546. var ct = [s[0], s[3], s[1], s[4], s[2], s[5]];
  43547. Promise.all(ct.map(function(lt) {
  43548. return Tools.LoadFileAsync(lt).then(function(ft) {
  43549. return new Uint8Array(ft)
  43550. })
  43551. })).then(function(lt) {
  43552. return new Promise(function(ft, ht) {
  43553. it._engine.loadCubeTexture(nt._hardwareTexture.underlyingResource, lt, !c, !0, rt, ft, ht)
  43554. }
  43555. )
  43556. }).then(function() {
  43557. nt.isReady = !0,
  43558. d && d()
  43559. }, function(lt) {
  43560. _ && _("Failed to load cubemap: " + lt.message, lt)
  43561. })
  43562. }
  43563. return this._internalTexturesCache.push(nt),
  43564. nt
  43565. }
  43566. ,
  43567. e.prototype._createHardwareRenderTargetWrapper = function(i, o, s) {
  43568. var c = new NativeRenderTargetWrapper(i,o,s,this);
  43569. return this._renderTargetWrapperCache.push(c),
  43570. c
  43571. }
  43572. ,
  43573. e.prototype.createRenderTargetTexture = function(i, o) {
  43574. var s = this._createHardwareRenderTargetWrapper(!1, !1, i)
  43575. , c = {};
  43576. o !== void 0 && typeof o == "object" ? (c.generateMipMaps = o.generateMipMaps,
  43577. c.generateDepthBuffer = o.generateDepthBuffer === void 0 ? !0 : o.generateDepthBuffer,
  43578. c.generateStencilBuffer = c.generateDepthBuffer && o.generateStencilBuffer,
  43579. c.type = o.type === void 0 ? 0 : o.type,
  43580. c.samplingMode = o.samplingMode === void 0 ? 3 : o.samplingMode,
  43581. c.format = o.format === void 0 ? 5 : o.format) : (c.generateMipMaps = o,
  43582. c.generateDepthBuffer = !0,
  43583. c.generateStencilBuffer = !1,
  43584. c.type = 0,
  43585. c.samplingMode = 3,
  43586. c.format = 5),
  43587. (c.type === 1 && !this._caps.textureFloatLinearFiltering || c.type === 2 && !this._caps.textureHalfFloatLinearFiltering) && (c.samplingMode = 1);
  43588. var d = new InternalTexture(this,InternalTextureSource.RenderTarget)
  43589. , _ = i.width || i
  43590. , b = i.height || i;
  43591. c.type === 1 && !this._caps.textureFloat && (c.type = 0,
  43592. Logger$2.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type"));
  43593. var k = this._engine.createFrameBuffer(d._hardwareTexture.underlyingResource, _, b, this._getNativeTextureFormat(c.format, c.type), !!c.generateStencilBuffer, c.generateDepthBuffer, !!c.generateMipMaps);
  43594. return s._framebuffer = k,
  43595. s._generateDepthBuffer = c.generateDepthBuffer,
  43596. s._generateStencilBuffer = !!c.generateStencilBuffer,
  43597. d.baseWidth = _,
  43598. d.baseHeight = b,
  43599. d.width = _,
  43600. d.height = b,
  43601. d.isReady = !0,
  43602. d.samples = 1,
  43603. d.generateMipMaps = !!c.generateMipMaps,
  43604. d.samplingMode = c.samplingMode,
  43605. d.type = c.type,
  43606. d.format = c.format,
  43607. this._internalTexturesCache.push(d),
  43608. s.setTextures(d),
  43609. s
  43610. }
  43611. ,
  43612. e.prototype.updateTextureSamplingMode = function(i, o) {
  43613. if (o._hardwareTexture) {
  43614. var s = this._getNativeSamplingMode(i);
  43615. this._setTextureSampling(o._hardwareTexture.underlyingResource, s)
  43616. }
  43617. o.samplingMode = i
  43618. }
  43619. ,
  43620. e.prototype.bindFramebuffer = function(i, o, s, c, d) {
  43621. var _ = i;
  43622. if (o)
  43623. throw new Error("Cuboid frame buffers are not yet supported in NativeEngine.");
  43624. if (s || c)
  43625. throw new Error("Required width/height for frame buffers not yet supported in NativeEngine.");
  43626. _._framebufferDepthStencil ? this._bindUnboundFramebuffer(_._framebufferDepthStencil) : this._bindUnboundFramebuffer(_._framebuffer)
  43627. }
  43628. ,
  43629. e.prototype.unBindFramebuffer = function(i, o, s) {
  43630. s && s(),
  43631. this._bindUnboundFramebuffer(null)
  43632. }
  43633. ,
  43634. e.prototype.createDynamicVertexBuffer = function(i) {
  43635. return this.createVertexBuffer(i, !0)
  43636. }
  43637. ,
  43638. e.prototype.updateDynamicIndexBuffer = function(i, o, s) {
  43639. s === void 0 && (s = 0);
  43640. var c = i
  43641. , d = this._normalizeIndexData(o);
  43642. c.is32Bits = d.BYTES_PER_ELEMENT === 4,
  43643. this._engine.updateDynamicIndexBuffer(c.nativeIndexBuffer, d.buffer, d.byteOffset, d.byteLength, s)
  43644. }
  43645. ,
  43646. e.prototype.updateDynamicVertexBuffer = function(i, o, s, c) {
  43647. var d = i
  43648. , _ = ArrayBuffer.isView(o) ? o : new Float32Array(o);
  43649. this._engine.updateDynamicVertexBuffer(d.nativeVertexBuffer, _.buffer, _.byteOffset + (s != null ? s : 0), c != null ? c : _.byteLength)
  43650. }
  43651. ,
  43652. e.prototype._setTexture = function(i, o, s, c) {
  43653. c === void 0 && (c = !1);
  43654. var d = this._boundUniforms[i];
  43655. if (!d)
  43656. return !1;
  43657. if (!o)
  43658. return this._boundTexturesCache[i] != null && (this._activeChannel = i,
  43659. this._setTextureCore(d, null)),
  43660. !1;
  43661. if (o.video)
  43662. this._activeChannel = i,
  43663. o.update();
  43664. else if (o.delayLoadState === 4)
  43665. return o.delayLoad(),
  43666. !1;
  43667. var _;
  43668. return c ? _ = o.depthStencilTexture : o.isReady() ? _ = o.getInternalTexture() : o.isCube ? _ = this.emptyCubeTexture : o.is3D ? _ = this.emptyTexture3D : o.is2DArray ? _ = this.emptyTexture2DArray : _ = this.emptyTexture,
  43669. this._activeChannel = i,
  43670. !_ || !_._hardwareTexture ? !1 : (this._setTextureWrapMode(_._hardwareTexture.underlyingResource, this._getAddressMode(o.wrapU), this._getAddressMode(o.wrapV), this._getAddressMode(o.wrapR)),
  43671. this._updateAnisotropicLevel(o),
  43672. this._setTextureCore(d, _._hardwareTexture.underlyingResource),
  43673. !0)
  43674. }
  43675. ,
  43676. e.prototype._setTextureSampling = function(i, o) {
  43677. this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETTEXTURESAMPLING),
  43678. this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
  43679. this._commandBufferEncoder.encodeCommandArgAsUInt32(o),
  43680. this._commandBufferEncoder.finishEncodingCommand()
  43681. }
  43682. ,
  43683. e.prototype._setTextureWrapMode = function(i, o, s, c) {
  43684. this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETTEXTUREWRAPMODE),
  43685. this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
  43686. this._commandBufferEncoder.encodeCommandArgAsUInt32(o),
  43687. this._commandBufferEncoder.encodeCommandArgAsUInt32(s),
  43688. this._commandBufferEncoder.encodeCommandArgAsUInt32(c),
  43689. this._commandBufferEncoder.finishEncodingCommand()
  43690. }
  43691. ,
  43692. e.prototype._setTextureCore = function(i, o) {
  43693. this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETTEXTURE),
  43694. this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
  43695. this._commandBufferEncoder.encodeCommandArgAsNativeData(o),
  43696. this._commandBufferEncoder.finishEncodingCommand()
  43697. }
  43698. ,
  43699. e.prototype._updateAnisotropicLevel = function(i) {
  43700. var o = i.getInternalTexture()
  43701. , s = i.anisotropicFilteringLevel;
  43702. !o || !o._hardwareTexture || o._cachedAnisotropicFilteringLevel !== s && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETTEXTUREANISOTROPICLEVEL),
  43703. this._commandBufferEncoder.encodeCommandArgAsNativeData(o._hardwareTexture.underlyingResource),
  43704. this._commandBufferEncoder.encodeCommandArgAsUInt32(s),
  43705. this._commandBufferEncoder.finishEncodingCommand(),
  43706. o._cachedAnisotropicFilteringLevel = s)
  43707. }
  43708. ,
  43709. e.prototype._getAddressMode = function(i) {
  43710. switch (i) {
  43711. case 1:
  43712. return _native.Engine.ADDRESS_MODE_WRAP;
  43713. case 0:
  43714. return _native.Engine.ADDRESS_MODE_CLAMP;
  43715. case 2:
  43716. return _native.Engine.ADDRESS_MODE_MIRROR;
  43717. default:
  43718. throw new Error("Unexpected wrap mode: " + i + ".")
  43719. }
  43720. }
  43721. ,
  43722. e.prototype._bindTexture = function(i, o) {
  43723. var s = this._boundUniforms[i];
  43724. if (!!s && o && o._hardwareTexture) {
  43725. var c = o._hardwareTexture.underlyingResource;
  43726. this._setTextureCore(s, c)
  43727. }
  43728. }
  43729. ,
  43730. e.prototype._deleteBuffer = function(i) {
  43731. i.nativeIndexBuffer && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DELETEINDEXBUFFER),
  43732. this._commandBufferEncoder.encodeCommandArgAsNativeData(i.nativeIndexBuffer),
  43733. this._commandBufferEncoder.finishEncodingCommand(),
  43734. delete i.nativeIndexBuffer),
  43735. i.nativeVertexBuffer && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DELETEVERTEXBUFFER),
  43736. this._commandBufferEncoder.encodeCommandArgAsNativeData(i.nativeVertexBuffer),
  43737. this._commandBufferEncoder.finishEncodingCommand(),
  43738. delete i.nativeVertexBuffer)
  43739. }
  43740. ,
  43741. e.prototype.createCanvas = function(i, o) {
  43742. if (!_native.Canvas)
  43743. throw new Error("Native Canvas plugin not available.");
  43744. var s = new _native.Canvas;
  43745. return s.width = i,
  43746. s.height = o,
  43747. s
  43748. }
  43749. ,
  43750. e.prototype.createCanvasImage = function() {
  43751. if (!_native.Canvas)
  43752. throw new Error("Native Canvas plugin not available.");
  43753. var i = new _native.Image;
  43754. return i
  43755. }
  43756. ,
  43757. e.prototype._uploadCompressedDataToTextureDirectly = function(i, o, s, c, d, _, b) {
  43758. throw new Error("_uploadCompressedDataToTextureDirectly not implemented.")
  43759. }
  43760. ,
  43761. e.prototype._uploadDataToTextureDirectly = function(i, o, s, c) {
  43762. throw new Error("_uploadDataToTextureDirectly not implemented.")
  43763. }
  43764. ,
  43765. e.prototype._uploadArrayBufferViewToTexture = function(i, o, s, c) {
  43766. throw new Error("_uploadArrayBufferViewToTexture not implemented.")
  43767. }
  43768. ,
  43769. e.prototype._uploadImageToTexture = function(i, o, s, c) {
  43770. throw new Error("_uploadArrayBufferViewToTexture not implemented.")
  43771. }
  43772. ,
  43773. e.prototype._getNativeSamplingMode = function(i) {
  43774. switch (i) {
  43775. case 1:
  43776. return _native.Engine.TEXTURE_NEAREST_NEAREST;
  43777. case 2:
  43778. return _native.Engine.TEXTURE_LINEAR_LINEAR;
  43779. case 3:
  43780. return _native.Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR;
  43781. case 4:
  43782. return _native.Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST;
  43783. case 5:
  43784. return _native.Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST;
  43785. case 6:
  43786. return _native.Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR;
  43787. case 7:
  43788. return _native.Engine.TEXTURE_NEAREST_LINEAR;
  43789. case 8:
  43790. return _native.Engine.TEXTURE_NEAREST_NEAREST_MIPLINEAR;
  43791. case 9:
  43792. return _native.Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST;
  43793. case 10:
  43794. return _native.Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR;
  43795. case 11:
  43796. return _native.Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST;
  43797. case 12:
  43798. return _native.Engine.TEXTURE_LINEAR_NEAREST;
  43799. default:
  43800. throw new Error("Unsupported sampling mode: " + i + ".")
  43801. }
  43802. }
  43803. ,
  43804. e.prototype._getStencilFunc = function(i) {
  43805. switch (i) {
  43806. case 513:
  43807. return _native.Engine.STENCIL_TEST_LESS;
  43808. case 515:
  43809. return _native.Engine.STENCIL_TEST_LEQUAL;
  43810. case 514:
  43811. return _native.Engine.STENCIL_TEST_EQUAL;
  43812. case 518:
  43813. return _native.Engine.STENCIL_TEST_GEQUAL;
  43814. case 516:
  43815. return _native.Engine.STENCIL_TEST_GREATER;
  43816. case 517:
  43817. return _native.Engine.STENCIL_TEST_NOTEQUAL;
  43818. case 512:
  43819. return _native.Engine.STENCIL_TEST_NEVER;
  43820. case 519:
  43821. return _native.Engine.STENCIL_TEST_ALWAYS;
  43822. default:
  43823. throw new Error("Unsupported stencil func mode: " + i + ".")
  43824. }
  43825. }
  43826. ,
  43827. e.prototype._getStencilOpFail = function(i) {
  43828. switch (i) {
  43829. case 7680:
  43830. return _native.Engine.STENCIL_OP_FAIL_S_KEEP;
  43831. case 0:
  43832. return _native.Engine.STENCIL_OP_FAIL_S_ZERO;
  43833. case 7681:
  43834. return _native.Engine.STENCIL_OP_FAIL_S_REPLACE;
  43835. case 7682:
  43836. return _native.Engine.STENCIL_OP_FAIL_S_INCR;
  43837. case 7683:
  43838. return _native.Engine.STENCIL_OP_FAIL_S_DECR;
  43839. case 5386:
  43840. return _native.Engine.STENCIL_OP_FAIL_S_INVERT;
  43841. case 34055:
  43842. return _native.Engine.STENCIL_OP_FAIL_S_INCRSAT;
  43843. case 34056:
  43844. return _native.Engine.STENCIL_OP_FAIL_S_DECRSAT;
  43845. default:
  43846. throw new Error("Unsupported stencil OpFail mode: " + i + ".")
  43847. }
  43848. }
  43849. ,
  43850. e.prototype._getStencilDepthFail = function(i) {
  43851. switch (i) {
  43852. case 7680:
  43853. return _native.Engine.STENCIL_OP_FAIL_Z_KEEP;
  43854. case 0:
  43855. return _native.Engine.STENCIL_OP_FAIL_Z_ZERO;
  43856. case 7681:
  43857. return _native.Engine.STENCIL_OP_FAIL_Z_REPLACE;
  43858. case 7682:
  43859. return _native.Engine.STENCIL_OP_FAIL_Z_INCR;
  43860. case 7683:
  43861. return _native.Engine.STENCIL_OP_FAIL_Z_DECR;
  43862. case 5386:
  43863. return _native.Engine.STENCIL_OP_FAIL_Z_INVERT;
  43864. case 34055:
  43865. return _native.Engine.STENCIL_OP_FAIL_Z_INCRSAT;
  43866. case 34056:
  43867. return _native.Engine.STENCIL_OP_FAIL_Z_DECRSAT;
  43868. default:
  43869. throw new Error("Unsupported stencil depthFail mode: " + i + ".")
  43870. }
  43871. }
  43872. ,
  43873. e.prototype._getStencilDepthPass = function(i) {
  43874. switch (i) {
  43875. case 7680:
  43876. return _native.Engine.STENCIL_OP_PASS_Z_KEEP;
  43877. case 0:
  43878. return _native.Engine.STENCIL_OP_PASS_Z_ZERO;
  43879. case 7681:
  43880. return _native.Engine.STENCIL_OP_PASS_Z_REPLACE;
  43881. case 7682:
  43882. return _native.Engine.STENCIL_OP_PASS_Z_INCR;
  43883. case 7683:
  43884. return _native.Engine.STENCIL_OP_PASS_Z_DECR;
  43885. case 5386:
  43886. return _native.Engine.STENCIL_OP_PASS_Z_INVERT;
  43887. case 34055:
  43888. return _native.Engine.STENCIL_OP_PASS_Z_INCRSAT;
  43889. case 34056:
  43890. return _native.Engine.STENCIL_OP_PASS_Z_DECRSAT;
  43891. default:
  43892. throw new Error("Unsupported stencil opPass mode: " + i + ".")
  43893. }
  43894. }
  43895. ,
  43896. e.prototype._getNativeTextureFormat = function(i, o) {
  43897. if (i == 4 && o == 0)
  43898. return _native.Engine.TEXTURE_FORMAT_RGB8;
  43899. if (i == 5 && o == 0)
  43900. return _native.Engine.TEXTURE_FORMAT_RGBA8;
  43901. if (i == 5 && o == 1)
  43902. return _native.Engine.TEXTURE_FORMAT_RGBA32F;
  43903. throw new Error("Unsupported texture format or type: format " + i + ", type " + o + ".")
  43904. }
  43905. ,
  43906. e.prototype._getNativeAlphaMode = function(i) {
  43907. switch (i) {
  43908. case 0:
  43909. return _native.Engine.ALPHA_DISABLE;
  43910. case 1:
  43911. return _native.Engine.ALPHA_ADD;
  43912. case 2:
  43913. return _native.Engine.ALPHA_COMBINE;
  43914. case 3:
  43915. return _native.Engine.ALPHA_SUBTRACT;
  43916. case 4:
  43917. return _native.Engine.ALPHA_MULTIPLY;
  43918. case 5:
  43919. return _native.Engine.ALPHA_MAXIMIZED;
  43920. case 6:
  43921. return _native.Engine.ALPHA_ONEONE;
  43922. case 7:
  43923. return _native.Engine.ALPHA_PREMULTIPLIED;
  43924. case 8:
  43925. return _native.Engine.ALPHA_PREMULTIPLIED_PORTERDUFF;
  43926. case 9:
  43927. return _native.Engine.ALPHA_INTERPOLATE;
  43928. case 10:
  43929. return _native.Engine.ALPHA_SCREENMODE;
  43930. default:
  43931. throw new Error("Unsupported alpha mode: " + i + ".")
  43932. }
  43933. }
  43934. ,
  43935. e.prototype._getNativeAttribType = function(i) {
  43936. switch (i) {
  43937. case VertexBuffer.BYTE:
  43938. return _native.Engine.ATTRIB_TYPE_INT8;
  43939. case VertexBuffer.UNSIGNED_BYTE:
  43940. return _native.Engine.ATTRIB_TYPE_UINT8;
  43941. case VertexBuffer.SHORT:
  43942. return _native.Engine.ATTRIB_TYPE_INT16;
  43943. case VertexBuffer.UNSIGNED_SHORT:
  43944. return _native.Engine.ATTRIB_TYPE_UINT16;
  43945. case VertexBuffer.FLOAT:
  43946. return _native.Engine.ATTRIB_TYPE_FLOAT;
  43947. default:
  43948. throw new Error("Unsupported attribute type: " + i + ".")
  43949. }
  43950. }
  43951. ,
  43952. e.prototype.getFontOffset = function(i) {
  43953. var o = {
  43954. ascent: 0,
  43955. height: 0,
  43956. descent: 0
  43957. };
  43958. return o
  43959. }
  43960. ,
  43961. e.PROTOCOL_VERSION = 2,
  43962. e
  43963. }(Engine);
  43964. NativeEngine._createNativeDataStream = function() {
  43965. return _native.NativeDataStream.VALIDATION_ENABLED ? new ValidatedNativeDataStream : new NativeDataStream
  43966. }
  43967. ;
  43968. var ValidatedNativeDataStream = function(a) {
  43969. __extends(e, a);
  43970. function e() {
  43971. return a.call(this) || this
  43972. }
  43973. return e.prototype.writeUint32 = function(i) {
  43974. a.prototype.writeUint32.call(this, _native.NativeDataStream.VALIDATION_UINT_32),
  43975. a.prototype.writeUint32.call(this, i)
  43976. }
  43977. ,
  43978. e.prototype.writeInt32 = function(i) {
  43979. a.prototype.writeUint32.call(this, _native.NativeDataStream.VALIDATION_INT_32),
  43980. a.prototype.writeInt32.call(this, i)
  43981. }
  43982. ,
  43983. e.prototype.writeFloat32 = function(i) {
  43984. a.prototype.writeUint32.call(this, _native.NativeDataStream.VALIDATION_FLOAT_32),
  43985. a.prototype.writeFloat32.call(this, i)
  43986. }
  43987. ,
  43988. e.prototype.writeUint32Array = function(i) {
  43989. a.prototype.writeUint32.call(this, _native.NativeDataStream.VALIDATION_UINT_32_ARRAY),
  43990. a.prototype.writeUint32Array.call(this, i)
  43991. }
  43992. ,
  43993. e.prototype.writeInt32Array = function(i) {
  43994. a.prototype.writeUint32.call(this, _native.NativeDataStream.VALIDATION_INT_32_ARRAY),
  43995. a.prototype.writeInt32Array.call(this, i)
  43996. }
  43997. ,
  43998. e.prototype.writeFloat32Array = function(i) {
  43999. a.prototype.writeUint32.call(this, _native.NativeDataStream.VALIDATION_FLOAT_32_ARRAY),
  44000. a.prototype.writeFloat32Array.call(this, i)
  44001. }
  44002. ,
  44003. e.prototype.writeNativeData = function(i) {
  44004. a.prototype.writeUint32.call(this, _native.NativeDataStream.VALIDATION_NATIVE_DATA),
  44005. a.prototype.writeNativeData.call(this, i)
  44006. }
  44007. ,
  44008. e.prototype.writeBoolean = function(i) {
  44009. a.prototype.writeUint32.call(this, _native.NativeDataStream.VALIDATION_BOOLEAN),
  44010. a.prototype.writeBoolean.call(this, i)
  44011. }
  44012. ,
  44013. e
  44014. }(NativeDataStream), PowerPreference;
  44015. (function(a) {
  44016. a.SRGB = "srgb"
  44017. }
  44018. )(PowerPreference || (PowerPreference = {}));
  44019. (function(a) {
  44020. a.LowPower = "low-power",
  44021. a.HighPerformance = "high-performance"
  44022. }
  44023. )(PowerPreference || (PowerPreference = {}));
  44024. var FeatureName;
  44025. (function(a) {
  44026. a.DepthClipControl = "depth-clip-control",
  44027. a.Depth24UnormStencil8 = "depth24unorm-stencil8",
  44028. a.Depth32FloatStencil8 = "depth32float-stencil8",
  44029. a.TextureCompressionBC = "texture-compression-bc",
  44030. a.TextureCompressionETC2 = "texture-compression-etc2",
  44031. a.TextureCompressionASTC = "texture-compression-astc",
  44032. a.TimestampQuery = "timestamp-query",
  44033. a.IndirectFirstInstance = "indirect-first-instance"
  44034. }
  44035. )(FeatureName || (FeatureName = {}));
  44036. var BufferUsage;
  44037. (function(a) {
  44038. a[a.MapRead = 1] = "MapRead",
  44039. a[a.MapWrite = 2] = "MapWrite",
  44040. a[a.CopySrc = 4] = "CopySrc",
  44041. a[a.CopyDst = 8] = "CopyDst",
  44042. a[a.Index = 16] = "Index",
  44043. a[a.Vertex = 32] = "Vertex",
  44044. a[a.Uniform = 64] = "Uniform",
  44045. a[a.Storage = 128] = "Storage",
  44046. a[a.Indirect = 256] = "Indirect",
  44047. a[a.QueryResolve = 512] = "QueryResolve"
  44048. }
  44049. )(BufferUsage || (BufferUsage = {}));
  44050. var MapMode;
  44051. (function(a) {
  44052. a[a.Read = 1] = "Read",
  44053. a[a.Write = 2] = "Write"
  44054. }
  44055. )(MapMode || (MapMode = {}));
  44056. var TextureDimension;
  44057. (function(a) {
  44058. a.E1d = "1d",
  44059. a.E2d = "2d",
  44060. a.E3d = "3d"
  44061. }
  44062. )(TextureDimension || (TextureDimension = {}));
  44063. var TextureUsage;
  44064. (function(a) {
  44065. a[a.CopySrc = 1] = "CopySrc",
  44066. a[a.CopyDst = 2] = "CopyDst",
  44067. a[a.TextureBinding = 4] = "TextureBinding",
  44068. a[a.StorageBinding = 8] = "StorageBinding",
  44069. a[a.RenderAttachment = 16] = "RenderAttachment"
  44070. }
  44071. )(TextureUsage || (TextureUsage = {}));
  44072. var TextureViewDimension;
  44073. (function(a) {
  44074. a.E1d = "1d",
  44075. a.E2d = "2d",
  44076. a.E2dArray = "2d-array",
  44077. a.Cube = "cube",
  44078. a.CubeArray = "cube-array",
  44079. a.E3d = "3d"
  44080. }
  44081. )(TextureViewDimension || (TextureViewDimension = {}));
  44082. var TextureAspect;
  44083. (function(a) {
  44084. a.All = "all",
  44085. a.StencilOnly = "stencil-only",
  44086. a.DepthOnly = "depth-only"
  44087. }
  44088. )(TextureAspect || (TextureAspect = {}));
  44089. var TextureFormat;
  44090. (function(a) {
  44091. a.R8Unorm = "r8unorm",
  44092. a.R8Snorm = "r8snorm",
  44093. a.R8Uint = "r8uint",
  44094. a.R8Sint = "r8sint",
  44095. a.R16Uint = "r16uint",
  44096. a.R16Sint = "r16sint",
  44097. a.R16Float = "r16float",
  44098. a.RG8Unorm = "rg8unorm",
  44099. a.RG8Snorm = "rg8snorm",
  44100. a.RG8Uint = "rg8uint",
  44101. a.RG8Sint = "rg8sint",
  44102. a.R32Uint = "r32uint",
  44103. a.R32Sint = "r32sint",
  44104. a.R32Float = "r32float",
  44105. a.RG16Uint = "rg16uint",
  44106. a.RG16Sint = "rg16sint",
  44107. a.RG16Float = "rg16float",
  44108. a.RGBA8Unorm = "rgba8unorm",
  44109. a.RGBA8UnormSRGB = "rgba8unorm-srgb",
  44110. a.RGBA8Snorm = "rgba8snorm",
  44111. a.RGBA8Uint = "rgba8uint",
  44112. a.RGBA8Sint = "rgba8sint",
  44113. a.BGRA8Unorm = "bgra8unorm",
  44114. a.BGRA8UnormSRGB = "bgra8unorm-srgb",
  44115. a.RGB9E5UFloat = "rgb9e5ufloat",
  44116. a.RGB10A2Unorm = "rgb10a2unorm",
  44117. a.RG11B10UFloat = "rg11b10ufloat",
  44118. a.RG32Uint = "rg32uint",
  44119. a.RG32Sint = "rg32sint",
  44120. a.RG32Float = "rg32float",
  44121. a.RGBA16Uint = "rgba16uint",
  44122. a.RGBA16Sint = "rgba16sint",
  44123. a.RGBA16Float = "rgba16float",
  44124. a.RGBA32Uint = "rgba32uint",
  44125. a.RGBA32Sint = "rgba32sint",
  44126. a.RGBA32Float = "rgba32float",
  44127. a.Stencil8 = "stencil8",
  44128. a.Depth16Unorm = "depth16unorm",
  44129. a.Depth24Plus = "depth24plus",
  44130. a.Depth24PlusStencil8 = "depth24plus-stencil8",
  44131. a.Depth32Float = "depth32float",
  44132. a.BC1RGBAUnorm = "bc1-rgba-unorm",
  44133. a.BC1RGBAUnormSRGB = "bc1-rgba-unorm-srgb",
  44134. a.BC2RGBAUnorm = "bc2-rgba-unorm",
  44135. a.BC2RGBAUnormSRGB = "bc2-rgba-unorm-srgb",
  44136. a.BC3RGBAUnorm = "bc3-rgba-unorm",
  44137. a.BC3RGBAUnormSRGB = "bc3-rgba-unorm-srgb",
  44138. a.BC4RUnorm = "bc4-r-unorm",
  44139. a.BC4RSnorm = "bc4-r-snorm",
  44140. a.BC5RGUnorm = "bc5-rg-unorm",
  44141. a.BC5RGSnorm = "bc5-rg-snorm",
  44142. a.BC6HRGBUFloat = "bc6h-rgb-ufloat",
  44143. a.BC6HRGBFloat = "bc6h-rgb-float",
  44144. a.BC7RGBAUnorm = "bc7-rgba-unorm",
  44145. a.BC7RGBAUnormSRGB = "bc7-rgba-unorm-srgb",
  44146. a.ETC2RGB8Unorm = "etc2-rgb8unorm",
  44147. a.ETC2RGB8UnormSRGB = "etc2-rgb8unorm-srgb",
  44148. a.ETC2RGB8A1Unorm = "etc2-rgb8a1unorm",
  44149. a.ETC2RGB8A1UnormSRGB = "etc2-rgb8a1unorm-srgb",
  44150. a.ETC2RGBA8Unorm = "etc2-rgba8unorm",
  44151. a.ETC2RGBA8UnormSRGB = "etc2-rgba8unorm-srgb",
  44152. a.EACR11Unorm = "eac-r11unorm",
  44153. a.EACR11Snorm = "eac-r11snorm",
  44154. a.EACRG11Unorm = "eac-rg11unorm",
  44155. a.EACRG11Snorm = "eac-rg11snorm",
  44156. a.ASTC4x4Unorm = "astc-4x4-unorm",
  44157. a.ASTC4x4UnormSRGB = "astc-4x4-unorm-srgb",
  44158. a.ASTC5x4Unorm = "astc-5x4-unorm",
  44159. a.ASTC5x4UnormSRGB = "astc-5x4-unorm-srgb",
  44160. a.ASTC5x5Unorm = "astc-5x5-unorm",
  44161. a.ASTC5x5UnormSRGB = "astc-5x5-unorm-srgb",
  44162. a.ASTC6x5Unorm = "astc-6x5-unorm",
  44163. a.ASTC6x5UnormSRGB = "astc-6x5-unorm-srgb",
  44164. a.ASTC6x6Unorm = "astc-6x6-unorm",
  44165. a.ASTC6x6UnormSRGB = "astc-6x6-unorm-srgb",
  44166. a.ASTC8x5Unorm = "astc-8x5-unorm",
  44167. a.ASTC8x5UnormSRGB = "astc-8x5-unorm-srgb",
  44168. a.ASTC8x6Unorm = "astc-8x6-unorm",
  44169. a.ASTC8x6UnormSRGB = "astc-8x6-unorm-srgb",
  44170. a.ASTC8x8Unorm = "astc-8x8-unorm",
  44171. a.ASTC8x8UnormSRGB = "astc-8x8-unorm-srgb",
  44172. a.ASTC10x5Unorm = "astc-10x5-unorm",
  44173. a.ASTC10x5UnormSRGB = "astc-10x5-unorm-srgb",
  44174. a.ASTC10x6Unorm = "astc-10x6-unorm",
  44175. a.ASTC10x6UnormSRGB = "astc-10x6-unorm-srgb",
  44176. a.ASTC10x8Unorm = "astc-10x8-unorm",
  44177. a.ASTC10x8UnormSRGB = "astc-10x8-unorm-srgb",
  44178. a.ASTC10x10Unorm = "astc-10x10-unorm",
  44179. a.ASTC10x10UnormSRGB = "astc-10x10-unorm-srgb",
  44180. a.ASTC12x10Unorm = "astc-12x10-unorm",
  44181. a.ASTC12x10UnormSRGB = "astc-12x10-unorm-srgb",
  44182. a.ASTC12x12Unorm = "astc-12x12-unorm",
  44183. a.ASTC12x12UnormSRGB = "astc-12x12-unorm-srgb",
  44184. a.Depth24UnormStencil8 = "depth24unorm-stencil8",
  44185. a.Depth32FloatStencil8 = "depth32float-stencil8"
  44186. }
  44187. )(TextureFormat || (TextureFormat = {}));
  44188. var AddressMode;
  44189. (function(a) {
  44190. a.ClampToEdge = "clamp-to-edge",
  44191. a.Repeat = "repeat",
  44192. a.MirrorRepeat = "mirror-repeat"
  44193. }
  44194. )(AddressMode || (AddressMode = {}));
  44195. var FilterMode;
  44196. (function(a) {
  44197. a.Nearest = "nearest",
  44198. a.Linear = "linear"
  44199. }
  44200. )(FilterMode || (FilterMode = {}));
  44201. var CompareFunction;
  44202. (function(a) {
  44203. a.Never = "never",
  44204. a.Less = "less",
  44205. a.Equal = "equal",
  44206. a.LessEqual = "less-equal",
  44207. a.Greater = "greater",
  44208. a.NotEqual = "not-equal",
  44209. a.GreaterEqual = "greater-equal",
  44210. a.Always = "always"
  44211. }
  44212. )(CompareFunction || (CompareFunction = {}));
  44213. var ShaderStage;
  44214. (function(a) {
  44215. a[a.Vertex = 1] = "Vertex",
  44216. a[a.Fragment = 2] = "Fragment",
  44217. a[a.Compute = 4] = "Compute"
  44218. }
  44219. )(ShaderStage || (ShaderStage = {}));
  44220. var BufferBindingType;
  44221. (function(a) {
  44222. a.Uniform = "uniform",
  44223. a.Storage = "storage",
  44224. a.ReadOnlyStorage = "read-only-storage"
  44225. }
  44226. )(BufferBindingType || (BufferBindingType = {}));
  44227. var SamplerBindingType;
  44228. (function(a) {
  44229. a.Filtering = "filtering",
  44230. a.NonFiltering = "non-filtering",
  44231. a.Comparison = "comparison"
  44232. }
  44233. )(SamplerBindingType || (SamplerBindingType = {}));
  44234. var TextureSampleType;
  44235. (function(a) {
  44236. a.Float = "float",
  44237. a.UnfilterableFloat = "unfilterable-float",
  44238. a.Depth = "depth",
  44239. a.Sint = "sint",
  44240. a.Uint = "uint"
  44241. }
  44242. )(TextureSampleType || (TextureSampleType = {}));
  44243. var StorageTextureAccess;
  44244. (function(a) {
  44245. a.WriteOnly = "write-only"
  44246. }
  44247. )(StorageTextureAccess || (StorageTextureAccess = {}));
  44248. var CompilationMessageType;
  44249. (function(a) {
  44250. a.Error = "error",
  44251. a.Warning = "warning",
  44252. a.Info = "info"
  44253. }
  44254. )(CompilationMessageType || (CompilationMessageType = {}));
  44255. var PrimitiveTopology;
  44256. (function(a) {
  44257. a.PointList = "point-list",
  44258. a.LineList = "line-list",
  44259. a.LineStrip = "line-strip",
  44260. a.TriangleList = "triangle-list",
  44261. a.TriangleStrip = "triangle-strip"
  44262. }
  44263. )(PrimitiveTopology || (PrimitiveTopology = {}));
  44264. var FrontFace;
  44265. (function(a) {
  44266. a.CCW = "ccw",
  44267. a.CW = "cw"
  44268. }
  44269. )(FrontFace || (FrontFace = {}));
  44270. var CullMode;
  44271. (function(a) {
  44272. a.None = "none",
  44273. a.Front = "front",
  44274. a.Back = "back"
  44275. }
  44276. )(CullMode || (CullMode = {}));
  44277. var ColorWrite;
  44278. (function(a) {
  44279. a[a.Red = 1] = "Red",
  44280. a[a.Green = 2] = "Green",
  44281. a[a.Blue = 4] = "Blue",
  44282. a[a.Alpha = 8] = "Alpha",
  44283. a[a.All = 15] = "All"
  44284. }
  44285. )(ColorWrite || (ColorWrite = {}));
  44286. var BlendFactor;
  44287. (function(a) {
  44288. a.Zero = "zero",
  44289. a.One = "one",
  44290. a.Src = "src",
  44291. a.OneMinusSrc = "one-minus-src",
  44292. a.SrcAlpha = "src-alpha",
  44293. a.OneMinusSrcAlpha = "one-minus-src-alpha",
  44294. a.Dst = "dst",
  44295. a.OneMinusDst = "one-minus-dst",
  44296. a.DstAlpha = "dst-alpha",
  44297. a.OneMinusDstAlpha = "one-minus-dst-alpha",
  44298. a.SrcAlphaSaturated = "src-alpha-saturated",
  44299. a.Constant = "constant",
  44300. a.OneMinusConstant = "one-minus-constant"
  44301. }
  44302. )(BlendFactor || (BlendFactor = {}));
  44303. var BlendOperation;
  44304. (function(a) {
  44305. a.Add = "add",
  44306. a.Subtract = "subtract",
  44307. a.ReverseSubtract = "reverse-subtract",
  44308. a.Min = "min",
  44309. a.Max = "max"
  44310. }
  44311. )(BlendOperation || (BlendOperation = {}));
  44312. var StencilOperation;
  44313. (function(a) {
  44314. a.Keep = "keep",
  44315. a.Zero = "zero",
  44316. a.Replace = "replace",
  44317. a.Invert = "invert",
  44318. a.IncrementClamp = "increment-clamp",
  44319. a.DecrementClamp = "decrement-clamp",
  44320. a.IncrementWrap = "increment-wrap",
  44321. a.DecrementWrap = "decrement-wrap"
  44322. }
  44323. )(StencilOperation || (StencilOperation = {}));
  44324. var IndexFormat;
  44325. (function(a) {
  44326. a.Uint16 = "uint16",
  44327. a.Uint32 = "uint32"
  44328. }
  44329. )(IndexFormat || (IndexFormat = {}));
  44330. var VertexFormat;
  44331. (function(a) {
  44332. a.Uint8x2 = "uint8x2",
  44333. a.Uint8x4 = "uint8x4",
  44334. a.Sint8x2 = "sint8x2",
  44335. a.Sint8x4 = "sint8x4",
  44336. a.Unorm8x2 = "unorm8x2",
  44337. a.Unorm8x4 = "unorm8x4",
  44338. a.Snorm8x2 = "snorm8x2",
  44339. a.Snorm8x4 = "snorm8x4",
  44340. a.Uint16x2 = "uint16x2",
  44341. a.Uint16x4 = "uint16x4",
  44342. a.Sint16x2 = "sint16x2",
  44343. a.Sint16x4 = "sint16x4",
  44344. a.Unorm16x2 = "unorm16x2",
  44345. a.Unorm16x4 = "unorm16x4",
  44346. a.Snorm16x2 = "snorm16x2",
  44347. a.Snorm16x4 = "snorm16x4",
  44348. a.Float16x2 = "float16x2",
  44349. a.Float16x4 = "float16x4",
  44350. a.Float32 = "float32",
  44351. a.Float32x2 = "float32x2",
  44352. a.Float32x3 = "float32x3",
  44353. a.Float32x4 = "float32x4",
  44354. a.Uint32 = "uint32",
  44355. a.Uint32x2 = "uint32x2",
  44356. a.Uint32x3 = "uint32x3",
  44357. a.Uint32x4 = "uint32x4",
  44358. a.Sint32 = "sint32",
  44359. a.Sint32x2 = "sint32x2",
  44360. a.Sint32x3 = "sint32x3",
  44361. a.Sint32x4 = "sint32x4"
  44362. }
  44363. )(VertexFormat || (VertexFormat = {}));
  44364. var InputStepMode;
  44365. (function(a) {
  44366. a.Vertex = "vertex",
  44367. a.Instance = "instance"
  44368. }
  44369. )(InputStepMode || (InputStepMode = {}));
  44370. var ComputePassTimestampLocation;
  44371. (function(a) {
  44372. a.Beginning = "beginning",
  44373. a.End = "end"
  44374. }
  44375. )(ComputePassTimestampLocation || (ComputePassTimestampLocation = {}));
  44376. var RenderPassTimestampLocation;
  44377. (function(a) {
  44378. a.Beginning = "beginning",
  44379. a.End = "end"
  44380. }
  44381. )(RenderPassTimestampLocation || (RenderPassTimestampLocation = {}));
  44382. var LoadOp;
  44383. (function(a) {
  44384. a.Load = "load"
  44385. }
  44386. )(LoadOp || (LoadOp = {}));
  44387. var StoreOp;
  44388. (function(a) {
  44389. a.Store = "store",
  44390. a.Discard = "discard"
  44391. }
  44392. )(StoreOp || (StoreOp = {}));
  44393. var QueryType;
  44394. (function(a) {
  44395. a.Occlusion = "occlusion",
  44396. a.Timestamp = "timestamp"
  44397. }
  44398. )(QueryType || (QueryType = {}));
  44399. var CanvasCompositingAlphaMode;
  44400. (function(a) {
  44401. a.Opaque = "opaque",
  44402. a.Premultiplied = "premultiplied"
  44403. }
  44404. )(CanvasCompositingAlphaMode || (CanvasCompositingAlphaMode = {}));
  44405. var DeviceLostReason;
  44406. (function(a) {
  44407. a.Destroyed = "destroyed"
  44408. }
  44409. )(DeviceLostReason || (DeviceLostReason = {}));
  44410. var ErrorFilter;
  44411. (function(a) {
  44412. a.OutOfMemory = "out-of-memory",
  44413. a.Validation = "validation"
  44414. }
  44415. )(ErrorFilter || (ErrorFilter = {}));
  44416. var WebGPUShaderProcessor = function() {
  44417. function a() {
  44418. this.shaderLanguage = ShaderLanguage.GLSL
  44419. }
  44420. return a.prototype._addUniformToLeftOverUBO = function(e, i, o) {
  44421. var s, c = 0;
  44422. s = this._getArraySize(e, i, o),
  44423. e = s[0],
  44424. i = s[1],
  44425. c = s[2];
  44426. for (var d = 0; d < this.webgpuProcessingContext.leftOverUniforms.length; d++)
  44427. if (this.webgpuProcessingContext.leftOverUniforms[d].name === e)
  44428. return;
  44429. this.webgpuProcessingContext.leftOverUniforms.push({
  44430. name: e,
  44431. type: i,
  44432. length: c
  44433. })
  44434. }
  44435. ,
  44436. a.prototype._buildLeftOverUBO = function() {
  44437. if (!this.webgpuProcessingContext.leftOverUniforms.length)
  44438. return "";
  44439. var e = a.LeftOvertUBOName
  44440. , i = this.webgpuProcessingContext.availableBuffers[e];
  44441. return i || (i = {
  44442. binding: this.webgpuProcessingContext.getNextFreeUBOBinding()
  44443. },
  44444. this.webgpuProcessingContext.availableBuffers[e] = i,
  44445. this._addBufferBindingDescription(e, i, BufferBindingType.Uniform, !0),
  44446. this._addBufferBindingDescription(e, i, BufferBindingType.Uniform, !1)),
  44447. this._generateLeftOverUBOCode(e, i)
  44448. }
  44449. ,
  44450. a.prototype._collectBindingNames = function() {
  44451. for (var e = 0; e < this.webgpuProcessingContext.bindGroupLayoutEntries.length; e++) {
  44452. var i = this.webgpuProcessingContext.bindGroupLayoutEntries[e];
  44453. if (i === void 0) {
  44454. this.webgpuProcessingContext.bindGroupLayoutEntries[e] = [];
  44455. continue
  44456. }
  44457. for (var o = 0; o < i.length; o++) {
  44458. var s = this.webgpuProcessingContext.bindGroupLayoutEntries[e][o]
  44459. , c = this.webgpuProcessingContext.bindGroupLayoutEntryInfo[e][s.binding].name
  44460. , d = this.webgpuProcessingContext.bindGroupLayoutEntryInfo[e][s.binding].nameInArrayOfTexture;
  44461. s && (s.texture || s.externalTexture || s.storageTexture ? this.webgpuProcessingContext.textureNames.push(d) : s.sampler ? this.webgpuProcessingContext.samplerNames.push(c) : s.buffer && this.webgpuProcessingContext.bufferNames.push(c))
  44462. }
  44463. }
  44464. }
  44465. ,
  44466. a.prototype._preCreateBindGroupEntries = function() {
  44467. for (var e = this.webgpuProcessingContext.bindGroupEntries, i = 0; i < this.webgpuProcessingContext.bindGroupLayoutEntries.length; i++) {
  44468. for (var o = this.webgpuProcessingContext.bindGroupLayoutEntries[i], s = [], c = 0; c < o.length; c++) {
  44469. var d = this.webgpuProcessingContext.bindGroupLayoutEntries[i][c];
  44470. d.sampler || d.texture || d.storageTexture || d.externalTexture ? s.push({
  44471. binding: d.binding,
  44472. resource: void 0
  44473. }) : d.buffer && s.push({
  44474. binding: d.binding,
  44475. resource: {
  44476. buffer: void 0,
  44477. offset: 0,
  44478. size: 0
  44479. }
  44480. })
  44481. }
  44482. e[i] = s
  44483. }
  44484. }
  44485. ,
  44486. a.prototype._addTextureBindingDescription = function(e, i, o, s, c, d) {
  44487. var _ = i.textures[o]
  44488. , b = _.groupIndex
  44489. , k = _.bindingIndex;
  44490. if (this.webgpuProcessingContext.bindGroupLayoutEntries[b] || (this.webgpuProcessingContext.bindGroupLayoutEntries[b] = [],
  44491. this.webgpuProcessingContext.bindGroupLayoutEntryInfo[b] = []),
  44492. !this.webgpuProcessingContext.bindGroupLayoutEntryInfo[b][k]) {
  44493. var j = void 0;
  44494. s === null ? j = this.webgpuProcessingContext.bindGroupLayoutEntries[b].push({
  44495. binding: k,
  44496. visibility: 0,
  44497. externalTexture: {}
  44498. }) : c ? j = this.webgpuProcessingContext.bindGroupLayoutEntries[b].push({
  44499. binding: k,
  44500. visibility: 0,
  44501. storageTexture: {
  44502. access: StorageTextureAccess.WriteOnly,
  44503. format: c,
  44504. viewDimension: s
  44505. }
  44506. }) : j = this.webgpuProcessingContext.bindGroupLayoutEntries[b].push({
  44507. binding: k,
  44508. visibility: 0,
  44509. texture: {
  44510. sampleType: i.sampleType,
  44511. viewDimension: s,
  44512. multisampled: !1
  44513. }
  44514. });
  44515. var $ = i.isTextureArray ? e + o : e;
  44516. this.webgpuProcessingContext.bindGroupLayoutEntryInfo[b][k] = {
  44517. name: e,
  44518. index: j - 1,
  44519. nameInArrayOfTexture: $
  44520. }
  44521. }
  44522. k = this.webgpuProcessingContext.bindGroupLayoutEntryInfo[b][k].index,
  44523. d ? this.webgpuProcessingContext.bindGroupLayoutEntries[b][k].visibility |= ShaderStage.Vertex : this.webgpuProcessingContext.bindGroupLayoutEntries[b][k].visibility |= ShaderStage.Fragment
  44524. }
  44525. ,
  44526. a.prototype._addSamplerBindingDescription = function(e, i, o) {
  44527. var s = i.binding
  44528. , c = s.groupIndex
  44529. , d = s.bindingIndex;
  44530. if (this.webgpuProcessingContext.bindGroupLayoutEntries[c] || (this.webgpuProcessingContext.bindGroupLayoutEntries[c] = [],
  44531. this.webgpuProcessingContext.bindGroupLayoutEntryInfo[c] = []),
  44532. !this.webgpuProcessingContext.bindGroupLayoutEntryInfo[c][d]) {
  44533. var _ = this.webgpuProcessingContext.bindGroupLayoutEntries[c].push({
  44534. binding: d,
  44535. visibility: 0,
  44536. sampler: {
  44537. type: i.type
  44538. }
  44539. });
  44540. this.webgpuProcessingContext.bindGroupLayoutEntryInfo[c][d] = {
  44541. name: e,
  44542. index: _ - 1
  44543. }
  44544. }
  44545. d = this.webgpuProcessingContext.bindGroupLayoutEntryInfo[c][d].index,
  44546. o ? this.webgpuProcessingContext.bindGroupLayoutEntries[c][d].visibility |= ShaderStage.Vertex : this.webgpuProcessingContext.bindGroupLayoutEntries[c][d].visibility |= ShaderStage.Fragment
  44547. }
  44548. ,
  44549. a.prototype._addBufferBindingDescription = function(e, i, o, s) {
  44550. var c = i.binding
  44551. , d = c.groupIndex
  44552. , _ = c.bindingIndex;
  44553. if (this.webgpuProcessingContext.bindGroupLayoutEntries[d] || (this.webgpuProcessingContext.bindGroupLayoutEntries[d] = [],
  44554. this.webgpuProcessingContext.bindGroupLayoutEntryInfo[d] = []),
  44555. !this.webgpuProcessingContext.bindGroupLayoutEntryInfo[d][_]) {
  44556. var b = this.webgpuProcessingContext.bindGroupLayoutEntries[d].push({
  44557. binding: _,
  44558. visibility: 0,
  44559. buffer: {
  44560. type: o
  44561. }
  44562. });
  44563. this.webgpuProcessingContext.bindGroupLayoutEntryInfo[d][_] = {
  44564. name: e,
  44565. index: b - 1
  44566. }
  44567. }
  44568. _ = this.webgpuProcessingContext.bindGroupLayoutEntryInfo[d][_].index,
  44569. s ? this.webgpuProcessingContext.bindGroupLayoutEntries[d][_].visibility |= ShaderStage.Vertex : this.webgpuProcessingContext.bindGroupLayoutEntries[d][_].visibility |= ShaderStage.Fragment
  44570. }
  44571. ,
  44572. a.AutoSamplerSuffix = "Sampler",
  44573. a.LeftOvertUBOName = "LeftOver",
  44574. a.UniformSizes = {
  44575. bool: 1,
  44576. int: 1,
  44577. float: 1,
  44578. vec2: 2,
  44579. ivec2: 2,
  44580. vec3: 3,
  44581. ivec3: 3,
  44582. vec4: 4,
  44583. ivec4: 4,
  44584. mat2: 4,
  44585. mat3: 12,
  44586. mat4: 16,
  44587. i32: 1,
  44588. u32: 1,
  44589. f32: 1,
  44590. mat2x2: 4,
  44591. mat3x3: 12,
  44592. mat4x4: 16
  44593. },
  44594. a._SamplerFunctionByWebGLSamplerType = {
  44595. sampler2D: "sampler2D",
  44596. sampler2DArray: "sampler2DArray",
  44597. sampler2DShadow: "sampler2DShadow",
  44598. sampler2DArrayShadow: "sampler2DArrayShadow",
  44599. samplerCube: "samplerCube",
  44600. sampler3D: "sampler3D"
  44601. },
  44602. a._TextureTypeByWebGLSamplerType = {
  44603. sampler2D: "texture2D",
  44604. sampler2DArray: "texture2DArray",
  44605. sampler2DShadow: "texture2D",
  44606. sampler2DArrayShadow: "texture2DArray",
  44607. samplerCube: "textureCube",
  44608. samplerCubeArray: "textureCubeArray",
  44609. sampler3D: "texture3D"
  44610. },
  44611. a._GpuTextureViewDimensionByWebGPUTextureType = {
  44612. textureCube: TextureViewDimension.Cube,
  44613. textureCubeArray: TextureViewDimension.CubeArray,
  44614. texture2D: TextureViewDimension.E2d,
  44615. texture2DArray: TextureViewDimension.E2dArray,
  44616. texture3D: TextureViewDimension.E3d
  44617. },
  44618. a._SamplerTypeByWebGLSamplerType = {
  44619. sampler2DShadow: "samplerShadow",
  44620. sampler2DArrayShadow: "samplerShadow"
  44621. },
  44622. a._IsComparisonSamplerByWebGPUSamplerType = {
  44623. samplerShadow: !0,
  44624. samplerArrayShadow: !0,
  44625. sampler: !1
  44626. },
  44627. a
  44628. }()
  44629. , WebGPUPipelineContext = function() {
  44630. function a(e, i) {
  44631. this._name = "unnamed",
  44632. this.shaderProcessingContext = e,
  44633. this._leftOverUniformsByName = {},
  44634. this.engine = i
  44635. }
  44636. return Object.defineProperty(a.prototype, "isAsync", {
  44637. get: function() {
  44638. return !1
  44639. },
  44640. enumerable: !1,
  44641. configurable: !0
  44642. }),
  44643. Object.defineProperty(a.prototype, "isReady", {
  44644. get: function() {
  44645. return !!this.stages
  44646. },
  44647. enumerable: !1,
  44648. configurable: !0
  44649. }),
  44650. a.prototype._handlesSpectorRebuildCallback = function(e) {}
  44651. ,
  44652. a.prototype._fillEffectInformation = function(e, i, o, s, c, d, _, b) {
  44653. var k = this.engine;
  44654. e._fragmentSourceCode = "",
  44655. e._vertexSourceCode = "";
  44656. var j = this.shaderProcessingContext.availableTextures, $;
  44657. for ($ = 0; $ < c.length; $++) {
  44658. var _e = c[$]
  44659. , et = j[c[$]];
  44660. et == null || et == null ? (c.splice($, 1),
  44661. $--) : d[_e] = $
  44662. }
  44663. for (var tt = 0, rt = k.getAttributes(this, _); tt < rt.length; tt++) {
  44664. var it = rt[tt];
  44665. b.push(it)
  44666. }
  44667. this.buildUniformLayout();
  44668. var nt = []
  44669. , ot = [];
  44670. for ($ = 0; $ < _.length; $++) {
  44671. var at = b[$];
  44672. at >= 0 && (nt.push(_[$]),
  44673. ot.push(at))
  44674. }
  44675. this.shaderProcessingContext.attributeNamesFromEffect = nt,
  44676. this.shaderProcessingContext.attributeLocationsFromEffect = ot
  44677. }
  44678. ,
  44679. a.prototype.buildUniformLayout = function() {
  44680. if (!!this.shaderProcessingContext.leftOverUniforms.length) {
  44681. this.uniformBuffer = new UniformBuffer(this.engine,void 0,void 0,"leftOver-" + this._name);
  44682. for (var e = 0, i = this.shaderProcessingContext.leftOverUniforms; e < i.length; e++) {
  44683. var o = i[e]
  44684. , s = o.type.replace(/^(.*?)(<.*>)?$/, "$1")
  44685. , c = WebGPUShaderProcessor.UniformSizes[s];
  44686. this.uniformBuffer.addUniform(o.name, c, o.length),
  44687. this._leftOverUniformsByName[o.name] = o.type
  44688. }
  44689. this.uniformBuffer.create()
  44690. }
  44691. }
  44692. ,
  44693. a.prototype.dispose = function() {
  44694. this.uniformBuffer && this.uniformBuffer.dispose()
  44695. }
  44696. ,
  44697. a.prototype.setInt = function(e, i) {
  44698. !this.uniformBuffer || !this._leftOverUniformsByName[e] || this.uniformBuffer.updateInt(e, i)
  44699. }
  44700. ,
  44701. a.prototype.setInt2 = function(e, i, o) {
  44702. !this.uniformBuffer || !this._leftOverUniformsByName[e] || this.uniformBuffer.updateInt2(e, i, o)
  44703. }
  44704. ,
  44705. a.prototype.setInt3 = function(e, i, o, s) {
  44706. !this.uniformBuffer || !this._leftOverUniformsByName[e] || this.uniformBuffer.updateInt3(e, i, o, s)
  44707. }
  44708. ,
  44709. a.prototype.setInt4 = function(e, i, o, s, c) {
  44710. !this.uniformBuffer || !this._leftOverUniformsByName[e] || this.uniformBuffer.updateInt4(e, i, o, s, c)
  44711. }
  44712. ,
  44713. a.prototype.setIntArray = function(e, i) {
  44714. !this.uniformBuffer || !this._leftOverUniformsByName[e] || this.uniformBuffer.updateIntArray(e, i)
  44715. }
  44716. ,
  44717. a.prototype.setIntArray2 = function(e, i) {
  44718. this.setIntArray(e, i)
  44719. }
  44720. ,
  44721. a.prototype.setIntArray3 = function(e, i) {
  44722. this.setIntArray(e, i)
  44723. }
  44724. ,
  44725. a.prototype.setIntArray4 = function(e, i) {
  44726. this.setIntArray(e, i)
  44727. }
  44728. ,
  44729. a.prototype.setArray = function(e, i) {
  44730. !this.uniformBuffer || !this._leftOverUniformsByName[e] || this.uniformBuffer.updateArray(e, i)
  44731. }
  44732. ,
  44733. a.prototype.setArray2 = function(e, i) {
  44734. this.setArray(e, i)
  44735. }
  44736. ,
  44737. a.prototype.setArray3 = function(e, i) {
  44738. this.setArray(e, i)
  44739. }
  44740. ,
  44741. a.prototype.setArray4 = function(e, i) {
  44742. this.setArray(e, i)
  44743. }
  44744. ,
  44745. a.prototype.setMatrices = function(e, i) {
  44746. !this.uniformBuffer || !this._leftOverUniformsByName[e] || this.uniformBuffer.updateMatrices(e, i)
  44747. }
  44748. ,
  44749. a.prototype.setMatrix = function(e, i) {
  44750. !this.uniformBuffer || !this._leftOverUniformsByName[e] || this.uniformBuffer.updateMatrix(e, i)
  44751. }
  44752. ,
  44753. a.prototype.setMatrix3x3 = function(e, i) {
  44754. !this.uniformBuffer || !this._leftOverUniformsByName[e] || this.uniformBuffer.updateMatrix3x3(e, i)
  44755. }
  44756. ,
  44757. a.prototype.setMatrix2x2 = function(e, i) {
  44758. !this.uniformBuffer || !this._leftOverUniformsByName[e] || this.uniformBuffer.updateMatrix2x2(e, i)
  44759. }
  44760. ,
  44761. a.prototype.setFloat = function(e, i) {
  44762. !this.uniformBuffer || !this._leftOverUniformsByName[e] || this.uniformBuffer.updateFloat(e, i)
  44763. }
  44764. ,
  44765. a.prototype.setVector2 = function(e, i) {
  44766. this.setFloat2(e, i.x, i.y)
  44767. }
  44768. ,
  44769. a.prototype.setFloat2 = function(e, i, o) {
  44770. !this.uniformBuffer || !this._leftOverUniformsByName[e] || this.uniformBuffer.updateFloat2(e, i, o)
  44771. }
  44772. ,
  44773. a.prototype.setVector3 = function(e, i) {
  44774. this.setFloat3(e, i.x, i.y, i.z)
  44775. }
  44776. ,
  44777. a.prototype.setFloat3 = function(e, i, o, s) {
  44778. !this.uniformBuffer || !this._leftOverUniformsByName[e] || this.uniformBuffer.updateFloat3(e, i, o, s)
  44779. }
  44780. ,
  44781. a.prototype.setVector4 = function(e, i) {
  44782. this.setFloat4(e, i.x, i.y, i.z, i.w)
  44783. }
  44784. ,
  44785. a.prototype.setFloat4 = function(e, i, o, s, c) {
  44786. !this.uniformBuffer || !this._leftOverUniformsByName[e] || this.uniformBuffer.updateFloat4(e, i, o, s, c)
  44787. }
  44788. ,
  44789. a.prototype.setColor3 = function(e, i) {
  44790. this.setFloat3(e, i.r, i.g, i.b)
  44791. }
  44792. ,
  44793. a.prototype.setColor4 = function(e, i, o) {
  44794. this.setFloat4(e, i.r, i.g, i.b, o)
  44795. }
  44796. ,
  44797. a.prototype.setDirectColor4 = function(e, i) {
  44798. this.setFloat4(e, i.r, i.g, i.b, i.a)
  44799. }
  44800. ,
  44801. a.prototype._getVertexShaderCode = function() {
  44802. var e;
  44803. return (e = this.sources) === null || e === void 0 ? void 0 : e.vertex
  44804. }
  44805. ,
  44806. a.prototype._getFragmentShaderCode = function() {
  44807. var e;
  44808. return (e = this.sources) === null || e === void 0 ? void 0 : e.fragment
  44809. }
  44810. ,
  44811. a
  44812. }()
  44813. , _maxGroups = 4
  44814. , _maxBindingsPerGroup = 1 << 16
  44815. , _typeToLocationSize = {
  44816. mat2: 2,
  44817. mat3: 3,
  44818. mat4: 4,
  44819. mat2x2: 2,
  44820. mat3x3: 3,
  44821. mat4x4: 4
  44822. }
  44823. , WebGPUShaderProcessingContext = function() {
  44824. function a(e) {
  44825. this.shaderLanguage = e,
  44826. this._attributeNextLocation = 0,
  44827. this._varyingNextLocation = 0,
  44828. this.freeGroupIndex = 0,
  44829. this.freeBindingIndex = 0,
  44830. this.availableVaryings = {},
  44831. this.availableAttributes = {},
  44832. this.availableBuffers = {},
  44833. this.availableTextures = {},
  44834. this.availableSamplers = {},
  44835. this.orderedAttributes = [],
  44836. this.bindGroupLayoutEntries = [],
  44837. this.bindGroupLayoutEntryInfo = [],
  44838. this.bindGroupEntries = [],
  44839. this.bufferNames = [],
  44840. this.textureNames = [],
  44841. this.samplerNames = [],
  44842. this.leftOverUniforms = [],
  44843. this._findStartingGroupBinding()
  44844. }
  44845. return Object.defineProperty(a, "KnownUBOs", {
  44846. get: function() {
  44847. return a._SimplifiedKnownBindings ? a._SimplifiedKnownUBOs : a._KnownUBOs
  44848. },
  44849. enumerable: !1,
  44850. configurable: !0
  44851. }),
  44852. a.prototype._findStartingGroupBinding = function() {
  44853. var e = a.KnownUBOs
  44854. , i = [];
  44855. for (var o in e) {
  44856. var s = e[o].binding;
  44857. s.groupIndex !== -1 && (i[s.groupIndex] === void 0 ? i[s.groupIndex] = s.bindingIndex : i[s.groupIndex] = Math.max(i[s.groupIndex], s.bindingIndex))
  44858. }
  44859. this.freeGroupIndex = i.length - 1,
  44860. this.freeGroupIndex === 0 ? (this.freeGroupIndex++,
  44861. this.freeBindingIndex = 0) : this.freeBindingIndex = i[i.length - 1] + 1
  44862. }
  44863. ,
  44864. a.prototype.getAttributeNextLocation = function(e, i) {
  44865. var o;
  44866. i === void 0 && (i = 0);
  44867. var s = this._attributeNextLocation;
  44868. return this._attributeNextLocation += ((o = _typeToLocationSize[e]) !== null && o !== void 0 ? o : 1) * (i || 1),
  44869. s
  44870. }
  44871. ,
  44872. a.prototype.getVaryingNextLocation = function(e, i) {
  44873. var o;
  44874. i === void 0 && (i = 0);
  44875. var s = this._varyingNextLocation;
  44876. return this._varyingNextLocation += ((o = _typeToLocationSize[e]) !== null && o !== void 0 ? o : 1) * (i || 1),
  44877. s
  44878. }
  44879. ,
  44880. a.prototype.getNextFreeUBOBinding = function() {
  44881. return this._getNextFreeBinding(1)
  44882. }
  44883. ,
  44884. a.prototype._getNextFreeBinding = function(e) {
  44885. if (this.freeBindingIndex > _maxBindingsPerGroup - e && (this.freeGroupIndex++,
  44886. this.freeBindingIndex = 0),
  44887. this.freeGroupIndex === _maxGroups)
  44888. throw "Too many textures or UBOs have been declared and it is not supported in WebGPU.";
  44889. var i = {
  44890. groupIndex: this.freeGroupIndex,
  44891. bindingIndex: this.freeBindingIndex
  44892. };
  44893. return this.freeBindingIndex += e,
  44894. i
  44895. }
  44896. ,
  44897. a._SimplifiedKnownBindings = !0,
  44898. a._SimplifiedKnownUBOs = {
  44899. Scene: {
  44900. binding: {
  44901. groupIndex: 0,
  44902. bindingIndex: 0
  44903. }
  44904. },
  44905. Light0: {
  44906. binding: {
  44907. groupIndex: -1,
  44908. bindingIndex: -1
  44909. }
  44910. },
  44911. Light1: {
  44912. binding: {
  44913. groupIndex: -1,
  44914. bindingIndex: -1
  44915. }
  44916. },
  44917. Light2: {
  44918. binding: {
  44919. groupIndex: -1,
  44920. bindingIndex: -1
  44921. }
  44922. },
  44923. Light3: {
  44924. binding: {
  44925. groupIndex: -1,
  44926. bindingIndex: -1
  44927. }
  44928. },
  44929. Light4: {
  44930. binding: {
  44931. groupIndex: -1,
  44932. bindingIndex: -1
  44933. }
  44934. },
  44935. Light5: {
  44936. binding: {
  44937. groupIndex: -1,
  44938. bindingIndex: -1
  44939. }
  44940. },
  44941. Light6: {
  44942. binding: {
  44943. groupIndex: -1,
  44944. bindingIndex: -1
  44945. }
  44946. },
  44947. Light7: {
  44948. binding: {
  44949. groupIndex: -1,
  44950. bindingIndex: -1
  44951. }
  44952. },
  44953. Light8: {
  44954. binding: {
  44955. groupIndex: -1,
  44956. bindingIndex: -1
  44957. }
  44958. },
  44959. Light9: {
  44960. binding: {
  44961. groupIndex: -1,
  44962. bindingIndex: -1
  44963. }
  44964. },
  44965. Light10: {
  44966. binding: {
  44967. groupIndex: -1,
  44968. bindingIndex: -1
  44969. }
  44970. },
  44971. Light11: {
  44972. binding: {
  44973. groupIndex: -1,
  44974. bindingIndex: -1
  44975. }
  44976. },
  44977. Light12: {
  44978. binding: {
  44979. groupIndex: -1,
  44980. bindingIndex: -1
  44981. }
  44982. },
  44983. Light13: {
  44984. binding: {
  44985. groupIndex: -1,
  44986. bindingIndex: -1
  44987. }
  44988. },
  44989. Light14: {
  44990. binding: {
  44991. groupIndex: -1,
  44992. bindingIndex: -1
  44993. }
  44994. },
  44995. Light15: {
  44996. binding: {
  44997. groupIndex: -1,
  44998. bindingIndex: -1
  44999. }
  45000. },
  45001. Light16: {
  45002. binding: {
  45003. groupIndex: -1,
  45004. bindingIndex: -1
  45005. }
  45006. },
  45007. Light17: {
  45008. binding: {
  45009. groupIndex: -1,
  45010. bindingIndex: -1
  45011. }
  45012. },
  45013. Light18: {
  45014. binding: {
  45015. groupIndex: -1,
  45016. bindingIndex: -1
  45017. }
  45018. },
  45019. Light19: {
  45020. binding: {
  45021. groupIndex: -1,
  45022. bindingIndex: -1
  45023. }
  45024. },
  45025. Light20: {
  45026. binding: {
  45027. groupIndex: -1,
  45028. bindingIndex: -1
  45029. }
  45030. },
  45031. Light21: {
  45032. binding: {
  45033. groupIndex: -1,
  45034. bindingIndex: -1
  45035. }
  45036. },
  45037. Light22: {
  45038. binding: {
  45039. groupIndex: -1,
  45040. bindingIndex: -1
  45041. }
  45042. },
  45043. Light23: {
  45044. binding: {
  45045. groupIndex: -1,
  45046. bindingIndex: -1
  45047. }
  45048. },
  45049. Light24: {
  45050. binding: {
  45051. groupIndex: -1,
  45052. bindingIndex: -1
  45053. }
  45054. },
  45055. Light25: {
  45056. binding: {
  45057. groupIndex: -1,
  45058. bindingIndex: -1
  45059. }
  45060. },
  45061. Light26: {
  45062. binding: {
  45063. groupIndex: -1,
  45064. bindingIndex: -1
  45065. }
  45066. },
  45067. Light27: {
  45068. binding: {
  45069. groupIndex: -1,
  45070. bindingIndex: -1
  45071. }
  45072. },
  45073. Light28: {
  45074. binding: {
  45075. groupIndex: -1,
  45076. bindingIndex: -1
  45077. }
  45078. },
  45079. Light29: {
  45080. binding: {
  45081. groupIndex: -1,
  45082. bindingIndex: -1
  45083. }
  45084. },
  45085. Light30: {
  45086. binding: {
  45087. groupIndex: -1,
  45088. bindingIndex: -1
  45089. }
  45090. },
  45091. Light31: {
  45092. binding: {
  45093. groupIndex: -1,
  45094. bindingIndex: -1
  45095. }
  45096. },
  45097. Material: {
  45098. binding: {
  45099. groupIndex: -1,
  45100. bindingIndex: -1
  45101. }
  45102. },
  45103. Mesh: {
  45104. binding: {
  45105. groupIndex: -1,
  45106. bindingIndex: -1
  45107. }
  45108. }
  45109. },
  45110. a._KnownUBOs = {
  45111. Scene: {
  45112. binding: {
  45113. groupIndex: 0,
  45114. bindingIndex: 0
  45115. }
  45116. },
  45117. Light0: {
  45118. binding: {
  45119. groupIndex: 1,
  45120. bindingIndex: 0
  45121. }
  45122. },
  45123. Light1: {
  45124. binding: {
  45125. groupIndex: 1,
  45126. bindingIndex: 1
  45127. }
  45128. },
  45129. Light2: {
  45130. binding: {
  45131. groupIndex: 1,
  45132. bindingIndex: 2
  45133. }
  45134. },
  45135. Light3: {
  45136. binding: {
  45137. groupIndex: 1,
  45138. bindingIndex: 3
  45139. }
  45140. },
  45141. Light4: {
  45142. binding: {
  45143. groupIndex: 1,
  45144. bindingIndex: 4
  45145. }
  45146. },
  45147. Light5: {
  45148. binding: {
  45149. groupIndex: 1,
  45150. bindingIndex: 5
  45151. }
  45152. },
  45153. Light6: {
  45154. binding: {
  45155. groupIndex: 1,
  45156. bindingIndex: 6
  45157. }
  45158. },
  45159. Light7: {
  45160. binding: {
  45161. groupIndex: 1,
  45162. bindingIndex: 7
  45163. }
  45164. },
  45165. Light8: {
  45166. binding: {
  45167. groupIndex: 1,
  45168. bindingIndex: 8
  45169. }
  45170. },
  45171. Light9: {
  45172. binding: {
  45173. groupIndex: 1,
  45174. bindingIndex: 9
  45175. }
  45176. },
  45177. Light10: {
  45178. binding: {
  45179. groupIndex: 1,
  45180. bindingIndex: 10
  45181. }
  45182. },
  45183. Light11: {
  45184. binding: {
  45185. groupIndex: 1,
  45186. bindingIndex: 11
  45187. }
  45188. },
  45189. Light12: {
  45190. binding: {
  45191. groupIndex: 1,
  45192. bindingIndex: 12
  45193. }
  45194. },
  45195. Light13: {
  45196. binding: {
  45197. groupIndex: 1,
  45198. bindingIndex: 13
  45199. }
  45200. },
  45201. Light14: {
  45202. binding: {
  45203. groupIndex: 1,
  45204. bindingIndex: 14
  45205. }
  45206. },
  45207. Light15: {
  45208. binding: {
  45209. groupIndex: 1,
  45210. bindingIndex: 15
  45211. }
  45212. },
  45213. Light16: {
  45214. binding: {
  45215. groupIndex: 1,
  45216. bindingIndex: 16
  45217. }
  45218. },
  45219. Light17: {
  45220. binding: {
  45221. groupIndex: 1,
  45222. bindingIndex: 17
  45223. }
  45224. },
  45225. Light18: {
  45226. binding: {
  45227. groupIndex: 1,
  45228. bindingIndex: 18
  45229. }
  45230. },
  45231. Light19: {
  45232. binding: {
  45233. groupIndex: 1,
  45234. bindingIndex: 19
  45235. }
  45236. },
  45237. Light20: {
  45238. binding: {
  45239. groupIndex: 1,
  45240. bindingIndex: 20
  45241. }
  45242. },
  45243. Light21: {
  45244. binding: {
  45245. groupIndex: 1,
  45246. bindingIndex: 21
  45247. }
  45248. },
  45249. Light22: {
  45250. binding: {
  45251. groupIndex: 1,
  45252. bindingIndex: 22
  45253. }
  45254. },
  45255. Light23: {
  45256. binding: {
  45257. groupIndex: 1,
  45258. bindingIndex: 23
  45259. }
  45260. },
  45261. Light24: {
  45262. binding: {
  45263. groupIndex: 1,
  45264. bindingIndex: 24
  45265. }
  45266. },
  45267. Light25: {
  45268. binding: {
  45269. groupIndex: 1,
  45270. bindingIndex: 25
  45271. }
  45272. },
  45273. Light26: {
  45274. binding: {
  45275. groupIndex: 1,
  45276. bindingIndex: 26
  45277. }
  45278. },
  45279. Light27: {
  45280. binding: {
  45281. groupIndex: 1,
  45282. bindingIndex: 27
  45283. }
  45284. },
  45285. Light28: {
  45286. binding: {
  45287. groupIndex: 1,
  45288. bindingIndex: 28
  45289. }
  45290. },
  45291. Light29: {
  45292. binding: {
  45293. groupIndex: 1,
  45294. bindingIndex: 29
  45295. }
  45296. },
  45297. Light30: {
  45298. binding: {
  45299. groupIndex: 1,
  45300. bindingIndex: 30
  45301. }
  45302. },
  45303. Light31: {
  45304. binding: {
  45305. groupIndex: 1,
  45306. bindingIndex: 31
  45307. }
  45308. },
  45309. Material: {
  45310. binding: {
  45311. groupIndex: 2,
  45312. bindingIndex: 0
  45313. }
  45314. },
  45315. Mesh: {
  45316. binding: {
  45317. groupIndex: 2,
  45318. bindingIndex: 1
  45319. }
  45320. }
  45321. },
  45322. a
  45323. }()
  45324. , WebGPUShaderProcessorGLSL = function(a) {
  45325. __extends(e, a);
  45326. function e() {
  45327. var i = a !== null && a.apply(this, arguments) || this;
  45328. return i._missingVaryings = [],
  45329. i._textureArrayProcessing = [],
  45330. i.shaderLanguage = ShaderLanguage.GLSL,
  45331. i
  45332. }
  45333. return e.prototype._getArraySize = function(i, o, s) {
  45334. var c = 0
  45335. , d = i.indexOf("[")
  45336. , _ = i.indexOf("]");
  45337. if (d > 0 && _ > 0) {
  45338. var b = i.substring(d + 1, _);
  45339. c = +b,
  45340. isNaN(c) && (c = +s[b.trim()]),
  45341. i = i.substr(0, d)
  45342. }
  45343. return [i, o, c]
  45344. }
  45345. ,
  45346. e.prototype.initializeShaders = function(i) {
  45347. this.webgpuProcessingContext = i,
  45348. this._missingVaryings.length = 0,
  45349. this._textureArrayProcessing.length = 0
  45350. }
  45351. ,
  45352. e.prototype.varyingProcessor = function(i, o, s, c) {
  45353. this._preProcessors = s;
  45354. var d = /\s*varying\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/gm
  45355. , _ = d.exec(i);
  45356. if (_ != null) {
  45357. var b = _[1], k = _[2], j;
  45358. o ? (j = this.webgpuProcessingContext.availableVaryings[k],
  45359. this._missingVaryings[j] = "",
  45360. j === void 0 && Logger$2.Warn('Invalid fragment shader: The varying named "' + k + '" is not declared in the vertex shader! This declaration will be ignored.')) : (j = this.webgpuProcessingContext.getVaryingNextLocation(b, this._getArraySize(k, b, s)[2]),
  45361. this.webgpuProcessingContext.availableVaryings[k] = j,
  45362. this._missingVaryings[j] = "layout(location = " + j + ") in " + b + " " + k + ";"),
  45363. i = i.replace(_[0], j === void 0 ? "" : "layout(location = " + j + ") " + (o ? "in" : "out") + " " + b + " " + k + ";")
  45364. }
  45365. return i
  45366. }
  45367. ,
  45368. e.prototype.attributeProcessor = function(i, o, s) {
  45369. this._preProcessors = o;
  45370. var c = /\s*attribute\s+(\S+)\s+(\S+)\s*;/gm
  45371. , d = c.exec(i);
  45372. if (d != null) {
  45373. var _ = d[1]
  45374. , b = d[2]
  45375. , k = this.webgpuProcessingContext.getAttributeNextLocation(_, this._getArraySize(b, _, o)[2]);
  45376. this.webgpuProcessingContext.availableAttributes[b] = k,
  45377. this.webgpuProcessingContext.orderedAttributes[k] = b,
  45378. i = i.replace(d[0], "layout(location = " + k + ") in " + _ + " " + b + ";")
  45379. }
  45380. return i
  45381. }
  45382. ,
  45383. e.prototype.uniformProcessor = function(i, o, s, c) {
  45384. var d, _;
  45385. this._preProcessors = s;
  45386. var b = /\s*uniform\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/gm
  45387. , k = b.exec(i);
  45388. if (k != null) {
  45389. var j = k[1]
  45390. , $ = k[2];
  45391. if (j.indexOf("sampler") === 0 || j.indexOf("sampler") === 1) {
  45392. var _e = 0;
  45393. d = this._getArraySize($, j, s),
  45394. $ = d[0],
  45395. j = d[1],
  45396. _e = d[2];
  45397. var et = this.webgpuProcessingContext.availableTextures[$];
  45398. if (!et) {
  45399. et = {
  45400. autoBindSampler: !0,
  45401. isTextureArray: _e > 0,
  45402. isStorageTexture: !1,
  45403. textures: [],
  45404. sampleType: TextureSampleType.Float
  45405. };
  45406. for (var tt = 0; tt < (_e || 1); ++tt)
  45407. et.textures.push(this.webgpuProcessingContext.getNextFreeUBOBinding())
  45408. }
  45409. var rt = (_ = WebGPUShaderProcessor._SamplerTypeByWebGLSamplerType[j]) !== null && _ !== void 0 ? _ : "sampler"
  45410. , it = !!WebGPUShaderProcessor._IsComparisonSamplerByWebGPUSamplerType[rt]
  45411. , nt = it ? SamplerBindingType.Comparison : SamplerBindingType.Filtering
  45412. , ot = $ + WebGPUShaderProcessor.AutoSamplerSuffix
  45413. , at = this.webgpuProcessingContext.availableSamplers[ot];
  45414. at || (at = {
  45415. binding: this.webgpuProcessingContext.getNextFreeUBOBinding(),
  45416. type: nt
  45417. });
  45418. var st = j.charAt(0) === "u" ? "u" : j.charAt(0) === "i" ? "i" : "";
  45419. st && (j = j.substr(1));
  45420. var ut = it ? TextureSampleType.Depth : st === "u" ? TextureSampleType.Uint : st === "i" ? TextureSampleType.Sint : TextureSampleType.Float;
  45421. et.sampleType = ut;
  45422. var ct = _e > 0
  45423. , lt = at.binding.groupIndex
  45424. , ft = at.binding.bindingIndex
  45425. , ht = WebGPUShaderProcessor._SamplerFunctionByWebGLSamplerType[j]
  45426. , pt = WebGPUShaderProcessor._TextureTypeByWebGLSamplerType[j]
  45427. , dt = WebGPUShaderProcessor._GpuTextureViewDimensionByWebGPUTextureType[pt];
  45428. if (!ct)
  45429. _e = 1,
  45430. i = "layout(set = " + lt + ", binding = " + ft + ") uniform " + st + rt + " " + ot + `;
  45431. layout(set = ` + et.textures[0].groupIndex + ", binding = " + et.textures[0].bindingIndex + ") uniform " + pt + " " + $ + `Texture;
  45432. #define ` + $ + " " + st + ht + "(" + $ + "Texture, " + ot + ")";
  45433. else {
  45434. var _t = [];
  45435. _t.push("layout(set = " + lt + ", binding = " + ft + ") uniform " + st + rt + " " + ot + ";"),
  45436. i = `\r
  45437. `;
  45438. for (var tt = 0; tt < _e; ++tt) {
  45439. var mt = et.textures[tt].groupIndex
  45440. , vt = et.textures[tt].bindingIndex;
  45441. _t.push("layout(set = " + mt + ", binding = " + vt + ") uniform " + pt + " " + $ + "Texture" + tt + ";"),
  45442. i += (tt > 0 ? `\r
  45443. ` : "") + "#define " + $ + tt + " " + st + ht + "(" + $ + "Texture" + tt + ", " + ot + ")"
  45444. }
  45445. i = _t.join(`\r
  45446. `) + i,
  45447. this._textureArrayProcessing.push($)
  45448. }
  45449. this.webgpuProcessingContext.availableTextures[$] = et,
  45450. this.webgpuProcessingContext.availableSamplers[ot] = at,
  45451. this._addSamplerBindingDescription(ot, at, !o);
  45452. for (var tt = 0; tt < _e; ++tt)
  45453. this._addTextureBindingDescription($, et, tt, dt, null, !o)
  45454. } else
  45455. this._addUniformToLeftOverUBO($, j, s),
  45456. i = ""
  45457. }
  45458. return i
  45459. }
  45460. ,
  45461. e.prototype.uniformBufferProcessor = function(i, o, s) {
  45462. var c = /uniform\s+(\w+)/gm
  45463. , d = c.exec(i);
  45464. if (d != null) {
  45465. var _ = d[1]
  45466. , b = this.webgpuProcessingContext.availableBuffers[_];
  45467. if (!b) {
  45468. var k = WebGPUShaderProcessingContext.KnownUBOs[_]
  45469. , j = void 0;
  45470. k && k.binding.groupIndex !== -1 ? j = k.binding : j = this.webgpuProcessingContext.getNextFreeUBOBinding(),
  45471. b = {
  45472. binding: j
  45473. },
  45474. this.webgpuProcessingContext.availableBuffers[_] = b
  45475. }
  45476. this._addBufferBindingDescription(_, b, BufferBindingType.Uniform, !o),
  45477. i = i.replace("uniform", "layout(set = " + b.binding.groupIndex + ", binding = " + b.binding.bindingIndex + ") uniform")
  45478. }
  45479. return i
  45480. }
  45481. ,
  45482. e.prototype.postProcessor = function(i, o, s, c, d) {
  45483. var _ = i.search(/#extension.+GL_EXT_draw_buffers.+require/) !== -1
  45484. , b = /#extension.+(GL_OVR_multiview2|GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g;
  45485. if (i = i.replace(b, ""),
  45486. i = i.replace(/texture2D\s*\(/g, "texture("),
  45487. s)
  45488. i = i.replace(/texture2DLodEXT\s*\(/g, "textureLod("),
  45489. i = i.replace(/textureCubeLodEXT\s*\(/g, "textureLod("),
  45490. i = i.replace(/textureCube\s*\(/g, "texture("),
  45491. i = i.replace(/gl_FragDepthEXT/g, "gl_FragDepth"),
  45492. i = i.replace(/gl_FragColor/g, "glFragColor"),
  45493. i = i.replace(/gl_FragData/g, "glFragData"),
  45494. i = i.replace(/void\s+?main\s*\(/g, (_ ? "" : `layout(location = 0) out vec4 glFragColor;
  45495. `) + "void main(");
  45496. else {
  45497. i = i.replace(/gl_InstanceID/g, "gl_InstanceIndex"),
  45498. i = i.replace(/gl_VertexID/g, "gl_VertexIndex");
  45499. var k = o.indexOf("#define MULTIVIEW") !== -1;
  45500. if (k)
  45501. return `#extension GL_OVR_multiview2 : require
  45502. layout (num_views = 2) in;
  45503. ` + i
  45504. }
  45505. if (!s) {
  45506. var j = i.lastIndexOf("}");
  45507. i = i.substring(0, j),
  45508. i += `gl_Position.y *= -1.;
  45509. `,
  45510. d.isNDCHalfZRange || (i += `gl_Position.z = (gl_Position.z + gl_Position.w) / 2.0;
  45511. `),
  45512. i += "}"
  45513. }
  45514. return i
  45515. }
  45516. ,
  45517. e.prototype._applyTextureArrayProcessing = function(i, o) {
  45518. for (var s = new RegExp(o + "\\s*\\[(.+)?\\]","gm"), c = s.exec(i); c != null; ) {
  45519. var d = c[1]
  45520. , _ = +d;
  45521. this._preProcessors && isNaN(_) && (_ = +this._preProcessors[d.trim()]),
  45522. i = i.replace(c[0], o + _),
  45523. c = s.exec(i)
  45524. }
  45525. return i
  45526. }
  45527. ,
  45528. e.prototype._generateLeftOverUBOCode = function(i, o) {
  45529. for (var s = "layout(set = " + o.binding.groupIndex + ", binding = " + o.binding.bindingIndex + ") uniform " + i + ` {
  45530. `, c = 0, d = this.webgpuProcessingContext.leftOverUniforms; c < d.length; c++) {
  45531. var _ = d[c];
  45532. _.length > 0 ? s += " " + _.type + " " + _.name + "[" + _.length + `];
  45533. ` : s += " " + _.type + " " + _.name + `;
  45534. `
  45535. }
  45536. return s += `};
  45537. `,
  45538. s
  45539. }
  45540. ,
  45541. e.prototype.finalizeShaders = function(i, o, s) {
  45542. for (var c = 0; c < this._textureArrayProcessing.length; ++c) {
  45543. var d = this._textureArrayProcessing[c];
  45544. i = this._applyTextureArrayProcessing(i, d),
  45545. o = this._applyTextureArrayProcessing(o, d)
  45546. }
  45547. for (var c = 0; c < this._missingVaryings.length; ++c) {
  45548. var _ = this._missingVaryings[c];
  45549. _ && _.length > 0 && (o = _ + `
  45550. ` + o)
  45551. }
  45552. var b = this._buildLeftOverUBO();
  45553. return i = b + i,
  45554. o = b + o,
  45555. this._collectBindingNames(),
  45556. this._preCreateBindGroupEntries(),
  45557. this._preProcessors = null,
  45558. {
  45559. vertexCode: i,
  45560. fragmentCode: o
  45561. }
  45562. }
  45563. ,
  45564. e
  45565. }(WebGPUShaderProcessor)
  45566. , name$2V = "bonesDeclaration"
  45567. , shader$2V = `#if NUM_BONE_INFLUENCERS>0
  45568. attribute matricesIndices : vec4<f32>;
  45569. attribute matricesWeights : vec4<f32>;
  45570. #if NUM_BONE_INFLUENCERS>4
  45571. attribute matricesIndicesExtra : vec4<f32>;
  45572. attribute matricesWeightsExtra : vec4<f32>;
  45573. #endif
  45574. #ifndef BAKED_VERTEX_ANIMATION_TEXTURE
  45575. #ifdef BONETEXTURE
  45576. var boneSampler : texture_2d<f32>;
  45577. uniform boneTextureWidth : f32;
  45578. #else
  45579. uniform mBones : array<mat4x4,BonesPerMesh>;
  45580. #ifdef BONES_VELOCITY_ENABLED
  45581. uniform mPreviousBones : array<mat4x4,BonesPerMesh>;
  45582. #endif
  45583. #endif
  45584. #ifdef BONETEXTURE
  45585. fn readMatrixFromRawSampler(smp : texture_2d<f32>,index : f32) -> mat4x4<f32>
  45586. {
  45587. let offset=i32(index)*4;
  45588. let m0=textureLoad(smp,vec2<i32>(offset+0,0),0);
  45589. let m1=textureLoad(smp,vec2<i32>(offset+1,0),0);
  45590. let m2=textureLoad(smp,vec2<i32>(offset+2,0),0);
  45591. let m3=textureLoad(smp,vec2<i32>(offset+3,0),0);
  45592. return mat4x4<f32>(m0,m1,m2,m3);
  45593. }
  45594. #endif
  45595. #endif
  45596. #endif`;
  45597. ShaderStore.IncludesShadersStoreWGSL[name$2V] = shader$2V;
  45598. var name$2U = "bonesVertex"
  45599. , shader$2U = `#ifndef BAKED_VERTEX_ANIMATION_TEXTURE
  45600. #if NUM_BONE_INFLUENCERS>0
  45601. var influence : mat4x4<f32>;
  45602. #ifdef BONETEXTURE
  45603. influence=readMatrixFromRawSampler(boneSampler,matricesIndices[0])*matricesWeights[0];
  45604. #if NUM_BONE_INFLUENCERS>1
  45605. influence=influence+readMatrixFromRawSampler(boneSampler,matricesIndices[1])*matricesWeights[1];
  45606. #endif
  45607. #if NUM_BONE_INFLUENCERS>2
  45608. influence=influence+readMatrixFromRawSampler(boneSampler,matricesIndices[2])*matricesWeights[2];
  45609. #endif
  45610. #if NUM_BONE_INFLUENCERS>3
  45611. influence=influence+readMatrixFromRawSampler(boneSampler,matricesIndices[3])*matricesWeights[3];
  45612. #endif
  45613. #if NUM_BONE_INFLUENCERS>4
  45614. influence=influence+readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[0])*matricesWeightsExtra[0];
  45615. #endif
  45616. #if NUM_BONE_INFLUENCERS>5
  45617. influence=influence+readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[1])*matricesWeightsExtra[1];
  45618. #endif
  45619. #if NUM_BONE_INFLUENCERS>6
  45620. influence=influence+readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[2])*matricesWeightsExtra[2];
  45621. #endif
  45622. #if NUM_BONE_INFLUENCERS>7
  45623. influence=influence+readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[3])*matricesWeightsExtra[3];
  45624. #endif
  45625. #else
  45626. influence=uniforms.mBones[int(matricesIndices[0])]*matricesWeights[0];
  45627. #if NUM_BONE_INFLUENCERS>1
  45628. influence=influence+uniforms.mBones[int(matricesIndices[1])]*matricesWeights[1];
  45629. #endif
  45630. #if NUM_BONE_INFLUENCERS>2
  45631. influence=influence+uniforms.mBones[int(matricesIndices[2])]*matricesWeights[2];
  45632. #endif
  45633. #if NUM_BONE_INFLUENCERS>3
  45634. influence=influence+uniforms.mBones[int(matricesIndices[3])]*matricesWeights[3];
  45635. #endif
  45636. #if NUM_BONE_INFLUENCERS>4
  45637. influence=influence+uniforms.mBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];
  45638. #endif
  45639. #if NUM_BONE_INFLUENCERS>5
  45640. influence=influence+uniforms.mBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];
  45641. #endif
  45642. #if NUM_BONE_INFLUENCERS>6
  45643. influence=influence+uniforms.mBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];
  45644. #endif
  45645. #if NUM_BONE_INFLUENCERS>7
  45646. influence=influence+uniforms.mBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];
  45647. #endif
  45648. #endif
  45649. finalWorld=finalWorld*influence;
  45650. #endif
  45651. #endif`;
  45652. ShaderStore.IncludesShadersStoreWGSL[name$2U] = shader$2U;
  45653. var name$2T = "bakedVertexAnimationDeclaration"
  45654. , shader$2T = `#ifdef BAKED_VERTEX_ANIMATION_TEXTURE
  45655. uniform bakedVertexAnimationTime: f32;
  45656. uniform bakedVertexAnimationTextureSizeInverted: vec2<f32>;
  45657. uniform bakedVertexAnimationSettings: vec4<f32>;
  45658. var bakedVertexAnimationTexture : texture_2d<f32>;
  45659. #ifdef INSTANCES
  45660. attribute bakedVertexAnimationSettingsInstanced : vec4<f32>;
  45661. attribute bakedVertexAnimationTimeInstanced : f32;
  45662. #endif
  45663. fn readMatrixFromRawSamplerVAT(smp : texture_2d<f32>,index : f32,frame : f32) -> mat4x4<f32>
  45664. {
  45665. let offset=i32(index)*4;
  45666. let frameUV=i32(frame);
  45667. let m0=textureLoad(smp,vec2<i32>(offset+0,frameUV),0);
  45668. let m1=textureLoad(smp,vec2<i32>(offset+1,frameUV),0);
  45669. let m2=textureLoad(smp,vec2<i32>(offset+2,frameUV),0);
  45670. let m3=textureLoad(smp,vec2<i32>(offset+3,frameUV),0);
  45671. return mat4x4<f32>(m0,m1,m2,m3);
  45672. }
  45673. #endif`;
  45674. ShaderStore.IncludesShadersStoreWGSL[name$2T] = shader$2T;
  45675. var name$2S = "bakedVertexAnimation"
  45676. , shader$2S = `#ifdef BAKED_VERTEX_ANIMATION_TEXTURE
  45677. {
  45678. #ifdef INSTANCES
  45679. let VATStartFrame: f32=bakedVertexAnimationSettingsInstanced.x;
  45680. let VATEndFrame: f32=bakedVertexAnimationSettingsInstanced.y;
  45681. let VATOffsetFrame: f32=bakedVertexAnimationSettingsInstanced.z;
  45682. let VATSpeed: f32=bakedVertexAnimationSettingsInstanced.w;
  45683. let time: f32=bakedVertexAnimationTimeInstanced*VATSpeed/totalFrames;
  45684. #else
  45685. let VATStartFrame: f32=uniforms.bakedVertexAnimationSettings.x;
  45686. let VATEndFrame: f32=uniforms.bakedVertexAnimationSettings.y;
  45687. let VATOffsetFrame: f32=uniforms.bakedVertexAnimationSettings.z;
  45688. let VATSpeed: f32=uniforms.bakedVertexAnimationSettings.w;
  45689. let time: f32=uniforms.bakedVertexAnimationTime*VATSpeed/totalFrames;
  45690. #endif
  45691. let totalFrames: f32=VATEndFrame-VATStartFrame+1.0;
  45692. let frameCorrection: f32=select(1.0,0.0,time<1.0);
  45693. let numOfFrames: f32=totalFrames-frameCorrection;
  45694. var VATFrameNum: f32=fract(time)*numOfFrames;
  45695. VATFrameNum=(VATFrameNum+VATOffsetFrame) % numOfFrames;
  45696. VATFrameNum=floor(VATFrameNum);
  45697. VATFrameNum=VATFrameNum+VATStartFrame+frameCorrection;
  45698. var VATInfluence : mat4x4<f32>;
  45699. VATInfluence=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[0],VATFrameNum)*matricesWeights[0];
  45700. #if NUM_BONE_INFLUENCERS>1
  45701. VATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[1],VATFrameNum)*matricesWeights[1];
  45702. #endif
  45703. #if NUM_BONE_INFLUENCERS>2
  45704. VATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[2],VATFrameNum)*matricesWeights[2];
  45705. #endif
  45706. #if NUM_BONE_INFLUENCERS>3
  45707. VATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[3],VATFrameNum)*matricesWeights[3];
  45708. #endif
  45709. #if NUM_BONE_INFLUENCERS>4
  45710. VATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[0],VATFrameNum)*matricesWeightsExtra[0];
  45711. #endif
  45712. #if NUM_BONE_INFLUENCERS>5
  45713. VATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[1],VATFrameNum)*matricesWeightsExtra[1];
  45714. #endif
  45715. #if NUM_BONE_INFLUENCERS>6
  45716. VATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[2],VATFrameNum)*matricesWeightsExtra[2];
  45717. #endif
  45718. #if NUM_BONE_INFLUENCERS>7
  45719. VATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[3],VATFrameNum)*matricesWeightsExtra[3];
  45720. #endif
  45721. finalWorld=finalWorld*VATInfluence;
  45722. }
  45723. #endif`;
  45724. ShaderStore.IncludesShadersStoreWGSL[name$2S] = shader$2S;
  45725. var name$2R = "clipPlaneFragment"
  45726. , shader$2R = `#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)
  45727. if (false) {}
  45728. #endif
  45729. #ifdef CLIPPLANE
  45730. elseif (fClipDistance>0.0)
  45731. {
  45732. discard;
  45733. }
  45734. #endif
  45735. #ifdef CLIPPLANE2
  45736. elseif (fClipDistance2>0.0)
  45737. {
  45738. discard;
  45739. }
  45740. #endif
  45741. #ifdef CLIPPLANE3
  45742. elseif (fClipDistance3>0.0)
  45743. {
  45744. discard;
  45745. }
  45746. #endif
  45747. #ifdef CLIPPLANE4
  45748. elseif (fClipDistance4>0.0)
  45749. {
  45750. discard;
  45751. }
  45752. #endif
  45753. #ifdef CLIPPLANE5
  45754. elseif (fClipDistance5>0.0)
  45755. {
  45756. discard;
  45757. }
  45758. #endif
  45759. #ifdef CLIPPLANE6
  45760. elseif (fClipDistance6>0.0)
  45761. {
  45762. discard;
  45763. }
  45764. #endif`;
  45765. ShaderStore.IncludesShadersStoreWGSL[name$2R] = shader$2R;
  45766. var name$2Q = "clipPlaneFragmentDeclaration"
  45767. , shader$2Q = `#ifdef CLIPPLANE
  45768. varying fClipDistance: f32;
  45769. #endif
  45770. #ifdef CLIPPLANE2
  45771. varying fClipDistance2: f32;
  45772. #endif
  45773. #ifdef CLIPPLANE3
  45774. varying fClipDistance3: f32;
  45775. #endif
  45776. #ifdef CLIPPLANE4
  45777. varying fClipDistance4: f32;
  45778. #endif
  45779. #ifdef CLIPPLANE5
  45780. varying fClipDistance5: f32;
  45781. #endif
  45782. #ifdef CLIPPLANE6
  45783. varying fClipDistance6: f32;
  45784. #endif`;
  45785. ShaderStore.IncludesShadersStoreWGSL[name$2Q] = shader$2Q;
  45786. var name$2P = "clipPlaneVertex"
  45787. , shader$2P = `#ifdef CLIPPLANE
  45788. fClipDistance=dot(worldPos,uniforms.vClipPlane);
  45789. #endif
  45790. #ifdef CLIPPLANE2
  45791. fClipDistance2=dot(worldPos,uniforms.vClipPlane2);
  45792. #endif
  45793. #ifdef CLIPPLANE3
  45794. fClipDistance3=dot(worldPos,uniforms.vClipPlane3);
  45795. #endif
  45796. #ifdef CLIPPLANE4
  45797. fClipDistance4=dot(worldPos,uniforms.vClipPlane4);
  45798. #endif
  45799. #ifdef CLIPPLANE5
  45800. fClipDistance5=dot(worldPos,uniforms.vClipPlane5);
  45801. #endif
  45802. #ifdef CLIPPLANE6
  45803. fClipDistance6=dot(worldPos,uniforms.vClipPlane6);
  45804. #endif`;
  45805. ShaderStore.IncludesShadersStoreWGSL[name$2P] = shader$2P;
  45806. var name$2O = "clipPlaneVertexDeclaration"
  45807. , shader$2O = `#ifdef CLIPPLANE
  45808. uniform vClipPlane: vec4<f32>;
  45809. varying fClipDistance: f32;
  45810. #endif
  45811. #ifdef CLIPPLANE2
  45812. uniform vClipPlane2: vec4<f32>;
  45813. varying fClipDistance2: f32;
  45814. #endif
  45815. #ifdef CLIPPLANE3
  45816. uniform vClipPlane3: vec4<f32>;
  45817. varying fClipDistance3: f32;
  45818. #endif
  45819. #ifdef CLIPPLANE4
  45820. uniform vClipPlane4: vec4<f32>;
  45821. varying fClipDistance4: f32;
  45822. #endif
  45823. #ifdef CLIPPLANE5
  45824. uniform vClipPlane5: vec4<f32>;
  45825. varying fClipDistance5: f32;
  45826. #endif
  45827. #ifdef CLIPPLANE6
  45828. uniform vClipPlane6: vec4<f32>;
  45829. varying fClipDistance6: f32;
  45830. #endif`;
  45831. ShaderStore.IncludesShadersStoreWGSL[name$2O] = shader$2O;
  45832. var name$2N = "instancesDeclaration"
  45833. , shader$2N = `#ifdef INSTANCES
  45834. attribute world0 : vec4<f32>;
  45835. attribute world1 : vec4<f32>;
  45836. attribute world2 : vec4<f32>;
  45837. attribute world3 : vec4<f32>;
  45838. #if defined(THIN_INSTANCES) && !defined(WORLD_UBO)
  45839. uniform world : mat4x4<f32>;
  45840. #endif
  45841. #if defined(VELOCITY) || defined(PREPASS_VELOCITY)
  45842. attribute previousWorld0 : vec4<f32>;
  45843. attribute previousWorld1 : vec4<f32>;
  45844. attribute previousWorld2 : vec4<f32>;
  45845. attribute previousWorld3 : vec4<f32>;
  45846. #ifdef THIN_INSTANCES
  45847. uniform previousWorld : mat4x4<f32>;
  45848. #endif
  45849. #endif
  45850. #else
  45851. #if !defined(WORLD_UBO)
  45852. uniform world : mat4x4<f32>;
  45853. #endif
  45854. #if defined(VELOCITY) || defined(PREPASS_VELOCITY)
  45855. uniform previousWorld : mat4x4<f32>;
  45856. #endif
  45857. #endif`;
  45858. ShaderStore.IncludesShadersStoreWGSL[name$2N] = shader$2N;
  45859. var name$2M = "instancesVertex"
  45860. , shader$2M = `#ifdef INSTANCES
  45861. var finalWorld=mat4x4<f32>(world0,world1,world2,world3);
  45862. #if defined(PREPASS_VELOCITY) || defined(VELOCITY)
  45863. var finalPreviousWorld=mat4x4<f32>(previousWorld0,previousWorld1,previousWorld2,previousWorld3);
  45864. #endif
  45865. #ifdef THIN_INSTANCES
  45866. #if !defined(WORLD_UBO)
  45867. finalWorld=uniforms.world*finalWorld;
  45868. #else
  45869. finalWorld=mesh.world*finalWorld;
  45870. #endif
  45871. #if defined(PREPASS_VELOCITY) || defined(VELOCITY)
  45872. finalPreviousWorld=previousWorld*finalPreviousWorld;
  45873. #endif
  45874. #endif
  45875. #else
  45876. #if !defined(WORLD_UBO)
  45877. var finalWorld=uniforms.world;
  45878. #else
  45879. var finalWorld=mesh.world;
  45880. #endif
  45881. #if defined(PREPASS_VELOCITY) || defined(VELOCITY)
  45882. var finalPreviousWorld=previousWorld;
  45883. #endif
  45884. #endif`;
  45885. ShaderStore.IncludesShadersStoreWGSL[name$2M] = shader$2M;
  45886. var name$2L = "meshUboDeclaration"
  45887. , shader$2L = `[[block]]
  45888. struct Mesh {
  45889. world : mat4x4<f32>;
  45890. visibility : f32;
  45891. };
  45892. var<uniform> mesh : Mesh;
  45893. #define WORLD_UBO
  45894. `;
  45895. ShaderStore.IncludesShadersStoreWGSL[name$2L] = shader$2L;
  45896. var name$2K = "morphTargetsVertex"
  45897. , shader$2K = `#ifdef MORPHTARGETS
  45898. #ifdef MORPHTARGETS_TEXTURE
  45899. vertexID=f32(gl_VertexID)*uniforms.morphTargetTextureInfo.x;
  45900. positionUpdated=positionUpdated+(readVector3FromRawSampler({X},vertexID)-position)*uniforms.morphTargetInfluences[{X}];
  45901. vertexID=vertexID+1.0;
  45902. #ifdef MORPHTARGETS_NORMAL
  45903. normalUpdated=normalUpdated+(readVector3FromRawSampler({X},vertexID)-normal)*uniforms.morphTargetInfluences[{X}];
  45904. vertexID=vertexID+1.0;
  45905. #endif
  45906. #ifdef MORPHTARGETS_UV
  45907. uvUpdated=uvUpdated+(readVector3FromRawSampler({X},vertexID).xy-uv)*uniforms.morphTargetInfluences[{X}];
  45908. vertexID=vertexID+1.0;
  45909. #endif
  45910. #ifdef MORPHTARGETS_TANGENT
  45911. tangentUpdated.xyz=tangentUpdated.xyz+(readVector3FromRawSampler({X},vertexID)-tangent.xyz)*uniforms.morphTargetInfluences[{X}];
  45912. #endif
  45913. #else
  45914. positionUpdated=positionUpdated+(position{X}-position)*uniforms.morphTargetInfluences[{X}];
  45915. #ifdef MORPHTARGETS_NORMAL
  45916. normalUpdated+=(normal{X}-normal)*uniforms.morphTargetInfluences[{X}];
  45917. #endif
  45918. #ifdef MORPHTARGETS_TANGENT
  45919. tangentUpdated.xyz=tangentUpdated.xyz+(tangent{X}-tangent.xyz)*uniforms.morphTargetInfluences[{X}];
  45920. #endif
  45921. #ifdef MORPHTARGETS_UV
  45922. uvUpdated=uvUpdated+(uv_{X}-uv)*uniforms.morphTargetInfluences[{X}];
  45923. #endif
  45924. #endif
  45925. #endif`;
  45926. ShaderStore.IncludesShadersStoreWGSL[name$2K] = shader$2K;
  45927. var name$2J = "morphTargetsVertexDeclaration"
  45928. , shader$2J = `#ifdef MORPHTARGETS
  45929. #ifndef MORPHTARGETS_TEXTURE
  45930. attribute position{X} : vec3<f32>;
  45931. #ifdef MORPHTARGETS_NORMAL
  45932. attribute normal{X} : vec3<f32>;
  45933. #endif
  45934. #ifdef MORPHTARGETS_TANGENT
  45935. attribute tangent{X} : vec3<f32>;
  45936. #endif
  45937. #ifdef MORPHTARGETS_UV
  45938. attribute uv_{X} : vec2<f32>;
  45939. #endif
  45940. #endif
  45941. #endif`;
  45942. ShaderStore.IncludesShadersStoreWGSL[name$2J] = shader$2J;
  45943. var name$2I = "morphTargetsVertexGlobal"
  45944. , shader$2I = `#ifdef MORPHTARGETS
  45945. #ifdef MORPHTARGETS_TEXTURE
  45946. var vertexID : f32;
  45947. #endif
  45948. #endif`;
  45949. ShaderStore.IncludesShadersStoreWGSL[name$2I] = shader$2I;
  45950. var name$2H = "morphTargetsVertexGlobalDeclaration"
  45951. , shader$2H = `#ifdef MORPHTARGETS
  45952. uniform morphTargetInfluences : array<f32,NUM_MORPH_INFLUENCERS>;
  45953. #ifdef MORPHTARGETS_TEXTURE
  45954. uniform morphTargetTextureIndices : array<f32,NUM_MORPH_INFLUENCERS>;
  45955. uniform morphTargetTextureInfo : vec3<f32>;
  45956. var morphTargets : texture_2d_array<f32>;
  45957. var morphTargetsSampler : sampler;
  45958. fn readVector3FromRawSampler(targetIndex : i32,vertexIndex : f32) -> vec3<f32>
  45959. {
  45960. let y=floor(vertexIndex/uniforms.morphTargetTextureInfo.y);
  45961. let x=vertexIndex-y*uniforms.morphTargetTextureInfo.y;
  45962. let textureUV=vec2<f32>((x+0.5)/uniforms.morphTargetTextureInfo.y,(y+0.5)/uniforms.morphTargetTextureInfo.z);
  45963. return textureSampleLevel(morphTargets,morphTargetsSampler,textureUV,i32(uniforms.morphTargetTextureIndices[targetIndex]),0.0).xyz;
  45964. }
  45965. #endif
  45966. #endif`;
  45967. ShaderStore.IncludesShadersStoreWGSL[name$2H] = shader$2H;
  45968. var name$2G = "sceneUboDeclaration"
  45969. , shader$2G = `[[block]]
  45970. struct Scene {
  45971. viewProjection : mat4x4<f32>;
  45972. #ifdef MULTIVIEW
  45973. viewProjectionR : mat4x4<f32>;
  45974. #endif
  45975. view : mat4x4<f32>;
  45976. projection : mat4x4<f32>;
  45977. vEyePosition : vec4<f32>;
  45978. };
  45979. var<uniform> scene : Scene;
  45980. `;
  45981. ShaderStore.IncludesShadersStoreWGSL[name$2G] = shader$2G;
  45982. var builtInName_vertex_index = "gl_VertexID", builtInName_instance_index = "gl_InstanceID", builtInName_position = "gl_Position", builtInName_position_frag = "gl_FragCoord", builtInName_front_facing = "gl_FrontFacing", builtInName_frag_depth = "gl_FragDepth", builtInName_FragColor = "gl_FragColor", leftOverVarName = "uniforms", gpuTextureViewDimensionByWebGPUTextureFunction = {
  45983. texture_1d: TextureViewDimension.E1d,
  45984. texture_2d: TextureViewDimension.E2d,
  45985. texture_2d_array: TextureViewDimension.E2dArray,
  45986. texture_3d: TextureViewDimension.E3d,
  45987. texture_cube: TextureViewDimension.Cube,
  45988. texture_cube_array: TextureViewDimension.CubeArray,
  45989. texture_multisampled_2d: TextureViewDimension.E2d,
  45990. texture_depth_2d: TextureViewDimension.E2d,
  45991. texture_depth_2d_array: TextureViewDimension.E2dArray,
  45992. texture_depth_cube: TextureViewDimension.Cube,
  45993. texture_depth_cube_array: TextureViewDimension.CubeArray,
  45994. texture_depth_multisampled_2d: TextureViewDimension.E2d,
  45995. texture_storage_1d: TextureViewDimension.E1d,
  45996. texture_storage_2d: TextureViewDimension.E2d,
  45997. texture_storage_2d_array: TextureViewDimension.E2dArray,
  45998. texture_storage_3d: TextureViewDimension.E3d,
  45999. texture_external: null
  46000. }, WebGPUShaderProcessorWGSL = function(a) {
  46001. __extends(e, a);
  46002. function e() {
  46003. var i = a !== null && a.apply(this, arguments) || this;
  46004. return i.shaderLanguage = ShaderLanguage.WGSL,
  46005. i.uniformRegexp = /uniform\s+(\w+)\s*:\s*(.+)\s*;/,
  46006. i.textureRegexp = /var\s+(\w+)\s*:\s*((array<\s*)?(texture_\w+)\s*(<\s*(.+)\s*>)?\s*(,\s*\w+\s*>\s*)?);/,
  46007. i.noPrecision = !0,
  46008. i
  46009. }
  46010. return e.prototype._getArraySize = function(i, o, s) {
  46011. var c = 0
  46012. , d = o.lastIndexOf(">");
  46013. if (o.indexOf("array") >= 0 && d > 0) {
  46014. for (var _ = d; _ > 0 && o.charAt(_) !== " " && o.charAt(_) !== ","; )
  46015. _--;
  46016. var b = o.substring(_ + 1, d);
  46017. for (c = +b,
  46018. isNaN(c) && (c = +s[b.trim()]); _ > 0 && (o.charAt(_) === " " || o.charAt(_) === ","); )
  46019. _--;
  46020. o = o.substring(o.indexOf("<") + 1, _ + 1)
  46021. }
  46022. return [i, o, c]
  46023. }
  46024. ,
  46025. e.prototype.initializeShaders = function(i) {
  46026. this.webgpuProcessingContext = i,
  46027. this._attributesWGSL = [],
  46028. this._attributesDeclWGSL = [],
  46029. this._attributeNamesWGSL = [],
  46030. this._varyingsWGSL = [],
  46031. this._varyingsDeclWGSL = [],
  46032. this._varyingNamesWGSL = []
  46033. }
  46034. ,
  46035. e.prototype.preProcessShaderCode = function(i) {
  46036. return RemoveComments(i)
  46037. }
  46038. ,
  46039. e.prototype.varyingProcessor = function(i, o, s, c) {
  46040. var d = /\s*varying\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s*:\s*(.+)\s*;/gm
  46041. , _ = d.exec(i);
  46042. if (_ !== null) {
  46043. var b = _[2], k = _[1], j;
  46044. o ? (j = this.webgpuProcessingContext.availableVaryings[k],
  46045. j === void 0 && Logger$2.Warn('Invalid fragment shader: The varying named "' + k + '" is not declared in the vertex shader! This declaration will be ignored.')) : (j = this.webgpuProcessingContext.getVaryingNextLocation(b, this._getArraySize(k, b, s)[2]),
  46046. this.webgpuProcessingContext.availableVaryings[k] = j,
  46047. this._varyingsWGSL.push("[[location(" + j + ")]] " + k + " : " + b + ";"),
  46048. this._varyingsDeclWGSL.push("var<private> " + k + " : " + b + ";"),
  46049. this._varyingNamesWGSL.push(k)),
  46050. i = ""
  46051. }
  46052. return i
  46053. }
  46054. ,
  46055. e.prototype.attributeProcessor = function(i, o, s) {
  46056. var c = /\s*attribute\s+(\S+)\s*:\s*(.+)\s*;/gm
  46057. , d = c.exec(i);
  46058. if (d !== null) {
  46059. var _ = d[2]
  46060. , b = d[1]
  46061. , k = this.webgpuProcessingContext.getAttributeNextLocation(_, this._getArraySize(b, _, o)[2]);
  46062. this.webgpuProcessingContext.availableAttributes[b] = k,
  46063. this.webgpuProcessingContext.orderedAttributes[k] = b,
  46064. this._attributesWGSL.push("[[location(" + k + ")]] " + b + " : " + _ + ";"),
  46065. this._attributesDeclWGSL.push("var<private> " + b + " : " + _ + ";"),
  46066. this._attributeNamesWGSL.push(b),
  46067. i = ""
  46068. }
  46069. return i
  46070. }
  46071. ,
  46072. e.prototype.uniformProcessor = function(i, o, s, c) {
  46073. var d = this.uniformRegexp.exec(i);
  46074. if (d !== null) {
  46075. var _ = d[2]
  46076. , b = d[1];
  46077. this._addUniformToLeftOverUBO(b, _, s),
  46078. i = ""
  46079. }
  46080. return i
  46081. }
  46082. ,
  46083. e.prototype.textureProcessor = function(i, o, s, c) {
  46084. var d = this.textureRegexp.exec(i);
  46085. if (d !== null) {
  46086. var _ = d[1]
  46087. , b = d[2]
  46088. , k = !!d[3]
  46089. , j = d[4]
  46090. , $ = j.indexOf("storage") > 0
  46091. , _e = d[6]
  46092. , et = $ ? _e.substring(0, _e.indexOf(",")).trim() : null
  46093. , tt = k ? this._getArraySize(_, b, s)[2] : 0
  46094. , rt = this.webgpuProcessingContext.availableTextures[_];
  46095. if (rt)
  46096. tt = rt.textures.length;
  46097. else {
  46098. rt = {
  46099. isTextureArray: tt > 0,
  46100. isStorageTexture: $,
  46101. textures: [],
  46102. sampleType: TextureSampleType.Float
  46103. },
  46104. tt = tt || 1;
  46105. for (var it = 0; it < tt; ++it)
  46106. rt.textures.push(this.webgpuProcessingContext.getNextFreeUBOBinding())
  46107. }
  46108. this.webgpuProcessingContext.availableTextures[_] = rt;
  46109. var nt = j.indexOf("depth") > 0
  46110. , ot = gpuTextureViewDimensionByWebGPUTextureFunction[j]
  46111. , at = nt ? TextureSampleType.Depth : _e === "u32" ? TextureSampleType.Uint : _e === "i32" ? TextureSampleType.Sint : TextureSampleType.Float;
  46112. if (rt.sampleType = at,
  46113. ot === void 0)
  46114. throw `Can't get the texture dimension corresponding to the texture function "` + j + '"!';
  46115. for (var it = 0; it < tt; ++it) {
  46116. var st = rt.textures[it]
  46117. , ut = st.groupIndex
  46118. , ct = st.bindingIndex;
  46119. it === 0 && (i = "[[group(" + ut + "), binding(" + ct + ")]] " + i),
  46120. this._addTextureBindingDescription(_, rt, it, ot, et, !o)
  46121. }
  46122. }
  46123. return i
  46124. }
  46125. ,
  46126. e.prototype.postProcessor = function(i, o, s, c, d) {
  46127. return i
  46128. }
  46129. ,
  46130. e.prototype.finalizeShaders = function(i, o, s) {
  46131. i = this._processSamplers(i, !0),
  46132. o = this._processSamplers(o, !1),
  46133. i = this._processCustomBuffers(i, !0),
  46134. o = this._processCustomBuffers(o, !1);
  46135. var c = this._buildLeftOverUBO();
  46136. i = c + i,
  46137. o = c + o,
  46138. i = i.replace(/#define /g, "//#define ");
  46139. var d = this._varyingsDeclWGSL.join(`
  46140. `) + `
  46141. `
  46142. , _ = "var<private> " + builtInName_vertex_index + ` : u32;
  46143. var<private> ` + builtInName_instance_index + ` : u32;
  46144. var<private> ` + builtInName_position + ` : vec4<f32>;
  46145. `
  46146. , b = this._attributesDeclWGSL.join(`
  46147. `) + `
  46148. `
  46149. , k = `struct VertexInputs {
  46150. [[builtin(vertex_index)]] vertexIndex : u32;
  46151. [[builtin(instance_index)]] instanceIndex : u32;
  46152. `;
  46153. this._attributesWGSL.length > 0 && (k += this._attributesWGSL.join(`
  46154. `)),
  46155. k += `
  46156. };
  46157. `;
  46158. var j = `struct FragmentInputs {
  46159. [[builtin(position)]] position : vec4<f32>;
  46160. `;
  46161. this._varyingsWGSL.length > 0 && (j += this._varyingsWGSL.join(`
  46162. `)),
  46163. j += `
  46164. };
  46165. `,
  46166. i = _ + k + b + j + d + i;
  46167. for (var $ = ` var output : FragmentInputs;
  46168. ` + builtInName_vertex_index + ` = input.vertexIndex;
  46169. ` + builtInName_instance_index + ` = input.instanceIndex;
  46170. `, _e = 0; _e < this._attributeNamesWGSL.length; ++_e) {
  46171. var et = this._attributeNamesWGSL[_e];
  46172. $ += " " + et + " = input." + et + `;
  46173. `
  46174. }
  46175. for (var tt = " output.position = " + builtInName_position + `;
  46176. output.position.y = -output.position.y;
  46177. `, _e = 0; _e < this._varyingNamesWGSL.length; ++_e) {
  46178. var rt = this._varyingNamesWGSL[_e];
  46179. tt += " output." + rt + " = " + rt + `;
  46180. `
  46181. }
  46182. tt += " return output;",
  46183. i = this._injectStartingAndEndingCode(i, $, tt),
  46184. o = o.replace(/#define /g, "//#define ");
  46185. var it = "var<private> " + builtInName_position_frag + ` : vec4<f32>;
  46186. var<private> ` + builtInName_front_facing + ` : bool;
  46187. var<private> ` + builtInName_FragColor + ` : vec4<f32>;
  46188. var<private> ` + builtInName_frag_depth + ` : f32;
  46189. `
  46190. , nt = `struct FragmentInputs {
  46191. [[builtin(position)]] position : vec4<f32>;
  46192. [[builtin(front_facing)]] frontFacing : bool;
  46193. `;
  46194. this._varyingsWGSL.length > 0 && (nt += this._varyingsWGSL.join(`
  46195. `)),
  46196. nt += `
  46197. };
  46198. `;
  46199. for (var ot = `struct FragmentOutputs {
  46200. [[location(0)]] color : vec4<f32>;
  46201. `, at = !1, st = 0; !at && (st = o.indexOf(builtInName_frag_depth, st),
  46202. !(st < 0)); ) {
  46203. var ut = st;
  46204. for (at = !0; st > 1 && o.charAt(st) !== `
  46205. `; ) {
  46206. if (o.charAt(st) === "/" && o.charAt(st - 1) === "/") {
  46207. at = !1;
  46208. break
  46209. }
  46210. st--
  46211. }
  46212. st = ut + 12
  46213. }
  46214. at && (ot += ` [[builtin(frag_depth)]] fragDepth: f32;
  46215. `),
  46216. ot += `};
  46217. `,
  46218. o = it + nt + d + ot + o;
  46219. for (var ct = ` var output : FragmentOutputs;
  46220. ` + builtInName_position_frag + ` = input.position;
  46221. ` + builtInName_front_facing + ` = input.frontFacing;
  46222. `, _e = 0; _e < this._varyingNamesWGSL.length; ++_e) {
  46223. var lt = this._varyingNamesWGSL[_e];
  46224. ct += " " + lt + " = input." + lt + `;
  46225. `
  46226. }
  46227. var ft = " output.color = " + builtInName_FragColor + `;
  46228. `;
  46229. return at && (ft += " output.fragDepth = " + builtInName_frag_depth + `;
  46230. `),
  46231. ft += " return output;",
  46232. o = this._injectStartingAndEndingCode(o, ct, ft),
  46233. this._collectBindingNames(),
  46234. this._preCreateBindGroupEntries(),
  46235. {
  46236. vertexCode: i,
  46237. fragmentCode: o
  46238. }
  46239. }
  46240. ,
  46241. e.prototype._generateLeftOverUBOCode = function(i, o) {
  46242. for (var s = "[[block]] struct " + i + ` {
  46243. `, c = 0, d = this.webgpuProcessingContext.leftOverUniforms; c < d.length; c++) {
  46244. var _ = d[c]
  46245. , b = _.type.replace(/^(.*?)(<.*>)?$/, "$1")
  46246. , k = WebGPUShaderProcessor.UniformSizes[b];
  46247. _.length > 0 ? k <= 2 ? s += " [[align(16)]] " + _.name + " : [[stride(16)]] array<" + _.type + ", " + _.length + `>;
  46248. ` : s += " " + _.name + " : array<" + _.type + ", " + _.length + `>;
  46249. ` : s += " " + _.name + " : " + _.type + `;
  46250. `
  46251. }
  46252. return s += `};
  46253. `,
  46254. s += "[[group(" + o.binding.groupIndex + "), binding(" + o.binding.bindingIndex + ")]] var<uniform> " + leftOverVarName + " : " + i + `;
  46255. `,
  46256. s
  46257. }
  46258. ,
  46259. e.prototype._injectStartingAndEndingCode = function(i, o, s) {
  46260. if (o) {
  46261. var c = i.indexOf("fn main");
  46262. if (c >= 0) {
  46263. for (; c++ < i.length && i.charAt(c) != "{"; )
  46264. ;
  46265. if (c < i.length) {
  46266. for (; c++ < i.length && i.charAt(c) != `
  46267. `; )
  46268. ;
  46269. if (c < i.length) {
  46270. var d = i.substring(0, c + 1)
  46271. , _ = i.substring(c + 1);
  46272. i = d + o + _
  46273. }
  46274. }
  46275. }
  46276. }
  46277. if (s) {
  46278. var b = i.lastIndexOf("}");
  46279. i = i.substring(0, b),
  46280. i += s + `
  46281. }`
  46282. }
  46283. return i
  46284. }
  46285. ,
  46286. e.prototype._processSamplers = function(i, o) {
  46287. for (var s = /var\s+(\w+Sampler)\s*:\s*(sampler|sampler_comparison)\s*;/gm; ; ) {
  46288. var c = s.exec(i);
  46289. if (c === null)
  46290. break;
  46291. var d = c[1]
  46292. , _ = c[2]
  46293. , b = d.indexOf(WebGPUShaderProcessor.AutoSamplerSuffix) === d.length - WebGPUShaderProcessor.AutoSamplerSuffix.length ? d.substring(0, d.indexOf(WebGPUShaderProcessor.AutoSamplerSuffix)) : null
  46294. , k = _ === "sampler_comparison" ? SamplerBindingType.Comparison : SamplerBindingType.Filtering;
  46295. if (b) {
  46296. var j = this.webgpuProcessingContext.availableTextures[b];
  46297. j && (j.autoBindSampler = !0)
  46298. }
  46299. var $ = this.webgpuProcessingContext.availableSamplers[d];
  46300. $ || ($ = {
  46301. binding: this.webgpuProcessingContext.getNextFreeUBOBinding(),
  46302. type: k
  46303. },
  46304. this.webgpuProcessingContext.availableSamplers[d] = $),
  46305. this._addSamplerBindingDescription(d, $, o);
  46306. var _e = i.substring(0, c.index)
  46307. , et = "[[group(" + $.binding.groupIndex + "), binding(" + $.binding.bindingIndex + ")]] "
  46308. , tt = i.substring(c.index);
  46309. i = _e + et + tt,
  46310. s.lastIndex += et.length
  46311. }
  46312. return i
  46313. }
  46314. ,
  46315. e.prototype._processCustomBuffers = function(i, o) {
  46316. for (var s = /var<\s*(uniform|storage)\s*(,\s*(read|read_write)\s*)?>\s+(\S+)\s*:\s*(\S+)\s*;/gm; ; ) {
  46317. var c = s.exec(i);
  46318. if (c === null)
  46319. break;
  46320. var d = c[1]
  46321. , _ = c[3]
  46322. , b = c[4]
  46323. , k = c[5]
  46324. , j = this.webgpuProcessingContext.availableBuffers[b];
  46325. if (!j) {
  46326. var $ = d === "uniform" ? WebGPUShaderProcessingContext.KnownUBOs[k] : null
  46327. , _e = void 0;
  46328. $ ? (b = k,
  46329. _e = $.binding,
  46330. _e.groupIndex === -1 && (_e = this.webgpuProcessingContext.getNextFreeUBOBinding())) : _e = this.webgpuProcessingContext.getNextFreeUBOBinding(),
  46331. j = {
  46332. binding: _e
  46333. },
  46334. this.webgpuProcessingContext.availableBuffers[b] = j
  46335. }
  46336. this._addBufferBindingDescription(b, this.webgpuProcessingContext.availableBuffers[b], _ === "read_write" ? BufferBindingType.Storage : d === "storage" ? BufferBindingType.ReadOnlyStorage : BufferBindingType.Uniform, o);
  46337. var et = j.binding.groupIndex
  46338. , tt = j.binding.bindingIndex
  46339. , rt = i.substring(0, c.index)
  46340. , it = "[[group(" + et + "), binding(" + tt + ")]] "
  46341. , nt = i.substring(c.index);
  46342. i = rt + it + nt,
  46343. s.lastIndex += it.length
  46344. }
  46345. return i
  46346. }
  46347. ,
  46348. e
  46349. }(WebGPUShaderProcessor), WebGPUHardwareTexture = function() {
  46350. function a(e) {
  46351. e === void 0 && (e = null),
  46352. this.format = TextureFormat.RGBA8Unorm,
  46353. this.textureUsages = 0,
  46354. this.textureAdditionalUsages = 0,
  46355. this._webgpuTexture = e,
  46356. this._webgpuMSAATexture = null,
  46357. this.view = null
  46358. }
  46359. return Object.defineProperty(a.prototype, "underlyingResource", {
  46360. get: function() {
  46361. return this._webgpuTexture
  46362. },
  46363. enumerable: !1,
  46364. configurable: !0
  46365. }),
  46366. Object.defineProperty(a.prototype, "msaaTexture", {
  46367. get: function() {
  46368. return this._webgpuMSAATexture
  46369. },
  46370. set: function(e) {
  46371. this._webgpuMSAATexture = e
  46372. },
  46373. enumerable: !1,
  46374. configurable: !0
  46375. }),
  46376. a.prototype.set = function(e) {
  46377. this._webgpuTexture = e
  46378. }
  46379. ,
  46380. a.prototype.setMSAATexture = function(e) {
  46381. this._webgpuMSAATexture = e
  46382. }
  46383. ,
  46384. a.prototype.setUsage = function(e, i, o, s, c) {
  46385. i = e === InternalTextureSource.RenderTarget ? !1 : i,
  46386. this.createView({
  46387. format: this.format,
  46388. dimension: o ? TextureViewDimension.Cube : TextureViewDimension.E2d,
  46389. mipLevelCount: i ? Scalar.ILog2(Math.max(s, c)) + 1 : 1,
  46390. baseArrayLayer: 0,
  46391. baseMipLevel: 0,
  46392. arrayLayerCount: o ? 6 : 1,
  46393. aspect: TextureAspect.All
  46394. })
  46395. }
  46396. ,
  46397. a.prototype.createView = function(e) {
  46398. this.view = this._webgpuTexture.createView(e)
  46399. }
  46400. ,
  46401. a.prototype.reset = function() {
  46402. this._webgpuTexture = null,
  46403. this._webgpuMSAATexture = null,
  46404. this.view = null
  46405. }
  46406. ,
  46407. a.prototype.release = function() {
  46408. var e, i, o;
  46409. (e = this._webgpuTexture) === null || e === void 0 || e.destroy(),
  46410. (i = this._webgpuMSAATexture) === null || i === void 0 || i.destroy(),
  46411. (o = this._copyInvertYTempTexture) === null || o === void 0 || o.destroy(),
  46412. this.reset()
  46413. }
  46414. ,
  46415. a
  46416. }(), mipmapVertexSource = `
  46417. const vec2 pos[4] = vec2[4](vec2(-1.0f, 1.0f), vec2(1.0f, 1.0f), vec2(-1.0f, -1.0f), vec2(1.0f, -1.0f));
  46418. const vec2 tex[4] = vec2[4](vec2(0.0f, 0.0f), vec2(1.0f, 0.0f), vec2(0.0f, 1.0f), vec2(1.0f, 1.0f));
  46419. layout(location = 0) out vec2 vTex;
  46420. void main() {
  46421. vTex = tex[gl_VertexIndex];
  46422. gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);
  46423. }
  46424. `, mipmapFragmentSource = `
  46425. layout(set = 0, binding = 0) uniform sampler imgSampler;
  46426. layout(set = 0, binding = 1) uniform texture2D img;
  46427. layout(location = 0) in vec2 vTex;
  46428. layout(location = 0) out vec4 outColor;
  46429. void main() {
  46430. outColor = texture(sampler2D(img, imgSampler), vTex);
  46431. }
  46432. `, invertYPreMultiplyAlphaVertexSource = `
  46433. #extension GL_EXT_samplerless_texture_functions : enable
  46434. const vec2 pos[4] = vec2[4](vec2(-1.0f, 1.0f), vec2(1.0f, 1.0f), vec2(-1.0f, -1.0f), vec2(1.0f, -1.0f));
  46435. const vec2 tex[4] = vec2[4](vec2(0.0f, 0.0f), vec2(1.0f, 0.0f), vec2(0.0f, 1.0f), vec2(1.0f, 1.0f));
  46436. layout(set = 0, binding = 0) uniform texture2D img;
  46437. #ifdef INVERTY
  46438. layout(location = 0) out flat ivec2 vTextureSize;
  46439. #endif
  46440. void main() {
  46441. #ifdef INVERTY
  46442. vTextureSize = textureSize(img, 0);
  46443. #endif
  46444. gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);
  46445. }
  46446. `, invertYPreMultiplyAlphaFragmentSource = `
  46447. #extension GL_EXT_samplerless_texture_functions : enable
  46448. layout(set = 0, binding = 0) uniform texture2D img;
  46449. #ifdef INVERTY
  46450. layout(location = 0) in flat ivec2 vTextureSize;
  46451. #endif
  46452. layout(location = 0) out vec4 outColor;
  46453. void main() {
  46454. #ifdef INVERTY
  46455. vec4 color = texelFetch(img, ivec2(gl_FragCoord.x, vTextureSize.y - gl_FragCoord.y), 0);
  46456. #else
  46457. vec4 color = texelFetch(img, ivec2(gl_FragCoord.xy), 0);
  46458. #endif
  46459. #ifdef PREMULTIPLYALPHA
  46460. color.rgb *= color.a;
  46461. #endif
  46462. outColor = color;
  46463. }
  46464. `, clearVertexSource = `
  46465. const vec2 pos[4] = vec2[4](vec2(-1.0f, 1.0f), vec2(1.0f, 1.0f), vec2(-1.0f, -1.0f), vec2(1.0f, -1.0f));
  46466. void main() {
  46467. gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);
  46468. }
  46469. `, clearFragmentSource = `
  46470. layout(set = 0, binding = 0) uniform Uniforms {
  46471. uniform vec4 color;
  46472. };
  46473. layout(location = 0) out vec4 outColor;
  46474. void main() {
  46475. outColor = color;
  46476. }
  46477. `, PipelineType;
  46478. (function(a) {
  46479. a[a.MipMap = 0] = "MipMap",
  46480. a[a.InvertYPremultiplyAlpha = 1] = "InvertYPremultiplyAlpha",
  46481. a[a.Clear = 2] = "Clear"
  46482. }
  46483. )(PipelineType || (PipelineType = {}));
  46484. var shadersForPipelineType = [{
  46485. vertex: mipmapVertexSource,
  46486. fragment: mipmapFragmentSource
  46487. }, {
  46488. vertex: invertYPreMultiplyAlphaVertexSource,
  46489. fragment: invertYPreMultiplyAlphaFragmentSource
  46490. }, {
  46491. vertex: clearVertexSource,
  46492. fragment: clearFragmentSource
  46493. }], WebGPUTextureHelper = function() {
  46494. function a(e, i, o, s) {
  46495. this._pipelines = {},
  46496. this._compiledShaders = [],
  46497. this._deferredReleaseTextures = [],
  46498. this._device = e,
  46499. this._glslang = i,
  46500. this._tintWASM = o,
  46501. this._bufferManager = s,
  46502. this._mipmapSampler = e.createSampler({
  46503. minFilter: FilterMode.Linear
  46504. }),
  46505. this._getPipeline(TextureFormat.RGBA8Unorm)
  46506. }
  46507. return a.ComputeNumMipmapLevels = function(e, i) {
  46508. return Scalar.ILog2(Math.max(e, i)) + 1
  46509. }
  46510. ,
  46511. a.prototype._getPipeline = function(e, i, o) {
  46512. i === void 0 && (i = PipelineType.MipMap);
  46513. var s = i === PipelineType.MipMap ? 1 << 0 : i === PipelineType.InvertYPremultiplyAlpha ? ((o.invertY ? 1 : 0) << 1) + ((o.premultiplyAlpha ? 1 : 0) << 2) : i === PipelineType.Clear ? 1 << 3 : 0;
  46514. this._pipelines[e] || (this._pipelines[e] = []);
  46515. var c = this._pipelines[e][s];
  46516. if (!c) {
  46517. var d = `#version 450\r
  46518. `;
  46519. i === PipelineType.InvertYPremultiplyAlpha && (o.invertY && (d += `#define INVERTY\r
  46520. `),
  46521. o.premultiplyAlpha && (d += `#define PREMULTIPLYALPHA\r
  46522. `));
  46523. var _ = this._compiledShaders[s];
  46524. if (!_) {
  46525. var b = this._glslang.compileGLSL(d + shadersForPipelineType[i].vertex, "vertex")
  46526. , k = this._glslang.compileGLSL(d + shadersForPipelineType[i].fragment, "fragment");
  46527. this._tintWASM && (b = this._tintWASM.convertSpirV2WGSL(b),
  46528. k = this._tintWASM.convertSpirV2WGSL(k));
  46529. var j = this._device.createShaderModule({
  46530. code: b
  46531. })
  46532. , $ = this._device.createShaderModule({
  46533. code: k
  46534. });
  46535. _ = this._compiledShaders[s] = [j, $]
  46536. }
  46537. var _e = this._device.createRenderPipeline({
  46538. vertex: {
  46539. module: _[0],
  46540. entryPoint: "main"
  46541. },
  46542. fragment: {
  46543. module: _[1],
  46544. entryPoint: "main",
  46545. targets: [{
  46546. format: e
  46547. }]
  46548. },
  46549. primitive: {
  46550. topology: PrimitiveTopology.TriangleStrip,
  46551. stripIndexFormat: IndexFormat.Uint16
  46552. }
  46553. });
  46554. c = this._pipelines[e][s] = [_e, _e.getBindGroupLayout(0)]
  46555. }
  46556. return c
  46557. }
  46558. ,
  46559. a._GetTextureTypeFromFormat = function(e) {
  46560. switch (e) {
  46561. case TextureFormat.R8Unorm:
  46562. case TextureFormat.R8Snorm:
  46563. case TextureFormat.R8Uint:
  46564. case TextureFormat.R8Sint:
  46565. case TextureFormat.RG8Unorm:
  46566. case TextureFormat.RG8Snorm:
  46567. case TextureFormat.RG8Uint:
  46568. case TextureFormat.RG8Sint:
  46569. case TextureFormat.RGBA8Unorm:
  46570. case TextureFormat.RGBA8UnormSRGB:
  46571. case TextureFormat.RGBA8Snorm:
  46572. case TextureFormat.RGBA8Uint:
  46573. case TextureFormat.RGBA8Sint:
  46574. case TextureFormat.BGRA8Unorm:
  46575. case TextureFormat.BGRA8UnormSRGB:
  46576. case TextureFormat.RGB10A2Unorm:
  46577. case TextureFormat.RGB9E5UFloat:
  46578. case TextureFormat.RG11B10UFloat:
  46579. case TextureFormat.Depth24UnormStencil8:
  46580. case TextureFormat.Depth32FloatStencil8:
  46581. case TextureFormat.BC7RGBAUnorm:
  46582. case TextureFormat.BC7RGBAUnormSRGB:
  46583. case TextureFormat.BC6HRGBUFloat:
  46584. case TextureFormat.BC6HRGBFloat:
  46585. case TextureFormat.BC5RGUnorm:
  46586. case TextureFormat.BC5RGSnorm:
  46587. case TextureFormat.BC3RGBAUnorm:
  46588. case TextureFormat.BC3RGBAUnormSRGB:
  46589. case TextureFormat.BC2RGBAUnorm:
  46590. case TextureFormat.BC2RGBAUnormSRGB:
  46591. case TextureFormat.BC4RUnorm:
  46592. case TextureFormat.BC4RSnorm:
  46593. case TextureFormat.BC1RGBAUnorm:
  46594. case TextureFormat.BC1RGBAUnormSRGB:
  46595. case TextureFormat.ETC2RGB8Unorm:
  46596. case TextureFormat.ETC2RGB8UnormSRGB:
  46597. case TextureFormat.ETC2RGB8A1Unorm:
  46598. case TextureFormat.ETC2RGB8A1UnormSRGB:
  46599. case TextureFormat.ETC2RGBA8Unorm:
  46600. case TextureFormat.ETC2RGBA8UnormSRGB:
  46601. case TextureFormat.EACR11Unorm:
  46602. case TextureFormat.EACR11Snorm:
  46603. case TextureFormat.EACRG11Unorm:
  46604. case TextureFormat.EACRG11Snorm:
  46605. case TextureFormat.ASTC4x4Unorm:
  46606. case TextureFormat.ASTC4x4UnormSRGB:
  46607. case TextureFormat.ASTC5x4Unorm:
  46608. case TextureFormat.ASTC5x4UnormSRGB:
  46609. case TextureFormat.ASTC5x5Unorm:
  46610. case TextureFormat.ASTC5x5UnormSRGB:
  46611. case TextureFormat.ASTC6x5Unorm:
  46612. case TextureFormat.ASTC6x5UnormSRGB:
  46613. case TextureFormat.ASTC6x6Unorm:
  46614. case TextureFormat.ASTC6x6UnormSRGB:
  46615. case TextureFormat.ASTC8x5Unorm:
  46616. case TextureFormat.ASTC8x5UnormSRGB:
  46617. case TextureFormat.ASTC8x6Unorm:
  46618. case TextureFormat.ASTC8x6UnormSRGB:
  46619. case TextureFormat.ASTC8x8Unorm:
  46620. case TextureFormat.ASTC8x8UnormSRGB:
  46621. case TextureFormat.ASTC10x5Unorm:
  46622. case TextureFormat.ASTC10x5UnormSRGB:
  46623. case TextureFormat.ASTC10x6Unorm:
  46624. case TextureFormat.ASTC10x6UnormSRGB:
  46625. case TextureFormat.ASTC10x8Unorm:
  46626. case TextureFormat.ASTC10x8UnormSRGB:
  46627. case TextureFormat.ASTC10x10Unorm:
  46628. case TextureFormat.ASTC10x10UnormSRGB:
  46629. case TextureFormat.ASTC12x10Unorm:
  46630. case TextureFormat.ASTC12x10UnormSRGB:
  46631. case TextureFormat.ASTC12x12Unorm:
  46632. case TextureFormat.ASTC12x12UnormSRGB:
  46633. return 0;
  46634. case TextureFormat.R16Uint:
  46635. case TextureFormat.R16Sint:
  46636. case TextureFormat.RG16Uint:
  46637. case TextureFormat.RG16Sint:
  46638. case TextureFormat.RGBA16Uint:
  46639. case TextureFormat.RGBA16Sint:
  46640. case TextureFormat.Depth16Unorm:
  46641. return 5;
  46642. case TextureFormat.R16Float:
  46643. case TextureFormat.RG16Float:
  46644. case TextureFormat.RGBA16Float:
  46645. return 2;
  46646. case TextureFormat.R32Uint:
  46647. case TextureFormat.R32Sint:
  46648. case TextureFormat.RG32Uint:
  46649. case TextureFormat.RG32Sint:
  46650. case TextureFormat.RGBA32Uint:
  46651. case TextureFormat.RGBA32Sint:
  46652. return 7;
  46653. case TextureFormat.R32Float:
  46654. case TextureFormat.RG32Float:
  46655. case TextureFormat.RGBA32Float:
  46656. case TextureFormat.Depth32Float:
  46657. return 1;
  46658. case TextureFormat.Stencil8:
  46659. throw "No fixed size for Stencil8 format!";
  46660. case TextureFormat.Depth24Plus:
  46661. throw "No fixed size for Depth24Plus format!";
  46662. case TextureFormat.Depth24PlusStencil8:
  46663. throw "No fixed size for Depth24PlusStencil8 format!"
  46664. }
  46665. return 0
  46666. }
  46667. ,
  46668. a._GetBlockInformationFromFormat = function(e) {
  46669. switch (e) {
  46670. case TextureFormat.R8Unorm:
  46671. case TextureFormat.R8Snorm:
  46672. case TextureFormat.R8Uint:
  46673. case TextureFormat.R8Sint:
  46674. return {
  46675. width: 1,
  46676. height: 1,
  46677. length: 1
  46678. };
  46679. case TextureFormat.R16Uint:
  46680. case TextureFormat.R16Sint:
  46681. case TextureFormat.R16Float:
  46682. case TextureFormat.RG8Unorm:
  46683. case TextureFormat.RG8Snorm:
  46684. case TextureFormat.RG8Uint:
  46685. case TextureFormat.RG8Sint:
  46686. return {
  46687. width: 1,
  46688. height: 1,
  46689. length: 2
  46690. };
  46691. case TextureFormat.R32Uint:
  46692. case TextureFormat.R32Sint:
  46693. case TextureFormat.R32Float:
  46694. case TextureFormat.RG16Uint:
  46695. case TextureFormat.RG16Sint:
  46696. case TextureFormat.RG16Float:
  46697. case TextureFormat.RGBA8Unorm:
  46698. case TextureFormat.RGBA8UnormSRGB:
  46699. case TextureFormat.RGBA8Snorm:
  46700. case TextureFormat.RGBA8Uint:
  46701. case TextureFormat.RGBA8Sint:
  46702. case TextureFormat.BGRA8Unorm:
  46703. case TextureFormat.BGRA8UnormSRGB:
  46704. case TextureFormat.RGB9E5UFloat:
  46705. case TextureFormat.RGB10A2Unorm:
  46706. case TextureFormat.RG11B10UFloat:
  46707. return {
  46708. width: 1,
  46709. height: 1,
  46710. length: 4
  46711. };
  46712. case TextureFormat.RG32Uint:
  46713. case TextureFormat.RG32Sint:
  46714. case TextureFormat.RG32Float:
  46715. case TextureFormat.RGBA16Uint:
  46716. case TextureFormat.RGBA16Sint:
  46717. case TextureFormat.RGBA16Float:
  46718. return {
  46719. width: 1,
  46720. height: 1,
  46721. length: 8
  46722. };
  46723. case TextureFormat.RGBA32Uint:
  46724. case TextureFormat.RGBA32Sint:
  46725. case TextureFormat.RGBA32Float:
  46726. return {
  46727. width: 1,
  46728. height: 1,
  46729. length: 16
  46730. };
  46731. case TextureFormat.Stencil8:
  46732. throw "No fixed size for Stencil8 format!";
  46733. case TextureFormat.Depth16Unorm:
  46734. return {
  46735. width: 1,
  46736. height: 1,
  46737. length: 2
  46738. };
  46739. case TextureFormat.Depth24Plus:
  46740. throw "No fixed size for Depth24Plus format!";
  46741. case TextureFormat.Depth24PlusStencil8:
  46742. throw "No fixed size for Depth24PlusStencil8 format!";
  46743. case TextureFormat.Depth32Float:
  46744. return {
  46745. width: 1,
  46746. height: 1,
  46747. length: 4
  46748. };
  46749. case TextureFormat.Depth24UnormStencil8:
  46750. return {
  46751. width: 1,
  46752. height: 1,
  46753. length: 4
  46754. };
  46755. case TextureFormat.Depth32FloatStencil8:
  46756. return {
  46757. width: 1,
  46758. height: 1,
  46759. length: 5
  46760. };
  46761. case TextureFormat.BC7RGBAUnorm:
  46762. case TextureFormat.BC7RGBAUnormSRGB:
  46763. case TextureFormat.BC6HRGBUFloat:
  46764. case TextureFormat.BC6HRGBFloat:
  46765. case TextureFormat.BC5RGUnorm:
  46766. case TextureFormat.BC5RGSnorm:
  46767. case TextureFormat.BC3RGBAUnorm:
  46768. case TextureFormat.BC3RGBAUnormSRGB:
  46769. case TextureFormat.BC2RGBAUnorm:
  46770. case TextureFormat.BC2RGBAUnormSRGB:
  46771. return {
  46772. width: 4,
  46773. height: 4,
  46774. length: 16
  46775. };
  46776. case TextureFormat.BC4RUnorm:
  46777. case TextureFormat.BC4RSnorm:
  46778. case TextureFormat.BC1RGBAUnorm:
  46779. case TextureFormat.BC1RGBAUnormSRGB:
  46780. return {
  46781. width: 4,
  46782. height: 4,
  46783. length: 8
  46784. };
  46785. case TextureFormat.ETC2RGB8Unorm:
  46786. case TextureFormat.ETC2RGB8UnormSRGB:
  46787. case TextureFormat.ETC2RGB8A1Unorm:
  46788. case TextureFormat.ETC2RGB8A1UnormSRGB:
  46789. case TextureFormat.EACR11Unorm:
  46790. case TextureFormat.EACR11Snorm:
  46791. return {
  46792. width: 4,
  46793. height: 4,
  46794. length: 8
  46795. };
  46796. case TextureFormat.ETC2RGBA8Unorm:
  46797. case TextureFormat.ETC2RGBA8UnormSRGB:
  46798. case TextureFormat.EACRG11Unorm:
  46799. case TextureFormat.EACRG11Snorm:
  46800. return {
  46801. width: 4,
  46802. height: 4,
  46803. length: 16
  46804. };
  46805. case TextureFormat.ASTC4x4Unorm:
  46806. case TextureFormat.ASTC4x4UnormSRGB:
  46807. return {
  46808. width: 4,
  46809. height: 4,
  46810. length: 16
  46811. };
  46812. case TextureFormat.ASTC5x4Unorm:
  46813. case TextureFormat.ASTC5x4UnormSRGB:
  46814. return {
  46815. width: 5,
  46816. height: 4,
  46817. length: 16
  46818. };
  46819. case TextureFormat.ASTC5x5Unorm:
  46820. case TextureFormat.ASTC5x5UnormSRGB:
  46821. return {
  46822. width: 5,
  46823. height: 5,
  46824. length: 16
  46825. };
  46826. case TextureFormat.ASTC6x5Unorm:
  46827. case TextureFormat.ASTC6x5UnormSRGB:
  46828. return {
  46829. width: 6,
  46830. height: 5,
  46831. length: 16
  46832. };
  46833. case TextureFormat.ASTC6x6Unorm:
  46834. case TextureFormat.ASTC6x6UnormSRGB:
  46835. return {
  46836. width: 6,
  46837. height: 6,
  46838. length: 16
  46839. };
  46840. case TextureFormat.ASTC8x5Unorm:
  46841. case TextureFormat.ASTC8x5UnormSRGB:
  46842. return {
  46843. width: 8,
  46844. height: 5,
  46845. length: 16
  46846. };
  46847. case TextureFormat.ASTC8x6Unorm:
  46848. case TextureFormat.ASTC8x6UnormSRGB:
  46849. return {
  46850. width: 8,
  46851. height: 6,
  46852. length: 16
  46853. };
  46854. case TextureFormat.ASTC8x8Unorm:
  46855. case TextureFormat.ASTC8x8UnormSRGB:
  46856. return {
  46857. width: 8,
  46858. height: 8,
  46859. length: 16
  46860. };
  46861. case TextureFormat.ASTC10x5Unorm:
  46862. case TextureFormat.ASTC10x5UnormSRGB:
  46863. return {
  46864. width: 10,
  46865. height: 5,
  46866. length: 16
  46867. };
  46868. case TextureFormat.ASTC10x6Unorm:
  46869. case TextureFormat.ASTC10x6UnormSRGB:
  46870. return {
  46871. width: 10,
  46872. height: 6,
  46873. length: 16
  46874. };
  46875. case TextureFormat.ASTC10x8Unorm:
  46876. case TextureFormat.ASTC10x8UnormSRGB:
  46877. return {
  46878. width: 10,
  46879. height: 8,
  46880. length: 16
  46881. };
  46882. case TextureFormat.ASTC10x10Unorm:
  46883. case TextureFormat.ASTC10x10UnormSRGB:
  46884. return {
  46885. width: 10,
  46886. height: 10,
  46887. length: 16
  46888. };
  46889. case TextureFormat.ASTC12x10Unorm:
  46890. case TextureFormat.ASTC12x10UnormSRGB:
  46891. return {
  46892. width: 12,
  46893. height: 10,
  46894. length: 16
  46895. };
  46896. case TextureFormat.ASTC12x12Unorm:
  46897. case TextureFormat.ASTC12x12UnormSRGB:
  46898. return {
  46899. width: 12,
  46900. height: 12,
  46901. length: 16
  46902. }
  46903. }
  46904. return {
  46905. width: 1,
  46906. height: 1,
  46907. length: 4
  46908. }
  46909. }
  46910. ,
  46911. a._IsHardwareTexture = function(e) {
  46912. return !!e.release
  46913. }
  46914. ,
  46915. a._IsInternalTexture = function(e) {
  46916. return !!e.dispose
  46917. }
  46918. ,
  46919. a.GetCompareFunction = function(e) {
  46920. switch (e) {
  46921. case 519:
  46922. return CompareFunction.Always;
  46923. case 514:
  46924. return CompareFunction.Equal;
  46925. case 516:
  46926. return CompareFunction.Greater;
  46927. case 518:
  46928. return CompareFunction.GreaterEqual;
  46929. case 513:
  46930. return CompareFunction.Less;
  46931. case 515:
  46932. return CompareFunction.LessEqual;
  46933. case 512:
  46934. return CompareFunction.Never;
  46935. case 517:
  46936. return CompareFunction.NotEqual;
  46937. default:
  46938. return CompareFunction.Less
  46939. }
  46940. }
  46941. ,
  46942. a.IsImageBitmap = function(e) {
  46943. return e.close !== void 0
  46944. }
  46945. ,
  46946. a.IsImageBitmapArray = function(e) {
  46947. return Array.isArray(e) && e[0].close !== void 0
  46948. }
  46949. ,
  46950. a.prototype.setCommandEncoder = function(e) {
  46951. this._commandEncoderForCreation = e
  46952. }
  46953. ,
  46954. a.IsCompressedFormat = function(e) {
  46955. switch (e) {
  46956. case TextureFormat.BC7RGBAUnormSRGB:
  46957. case TextureFormat.BC7RGBAUnorm:
  46958. case TextureFormat.BC6HRGBFloat:
  46959. case TextureFormat.BC6HRGBUFloat:
  46960. case TextureFormat.BC5RGSnorm:
  46961. case TextureFormat.BC5RGUnorm:
  46962. case TextureFormat.BC4RSnorm:
  46963. case TextureFormat.BC4RUnorm:
  46964. case TextureFormat.BC3RGBAUnormSRGB:
  46965. case TextureFormat.BC3RGBAUnorm:
  46966. case TextureFormat.BC2RGBAUnormSRGB:
  46967. case TextureFormat.BC2RGBAUnorm:
  46968. case TextureFormat.BC1RGBAUnormSRGB:
  46969. case TextureFormat.BC1RGBAUnorm:
  46970. case TextureFormat.ETC2RGB8Unorm:
  46971. case TextureFormat.ETC2RGB8UnormSRGB:
  46972. case TextureFormat.ETC2RGB8A1Unorm:
  46973. case TextureFormat.ETC2RGB8A1UnormSRGB:
  46974. case TextureFormat.ETC2RGBA8Unorm:
  46975. case TextureFormat.ETC2RGBA8UnormSRGB:
  46976. case TextureFormat.EACR11Unorm:
  46977. case TextureFormat.EACR11Snorm:
  46978. case TextureFormat.EACRG11Unorm:
  46979. case TextureFormat.EACRG11Snorm:
  46980. case TextureFormat.ASTC4x4Unorm:
  46981. case TextureFormat.ASTC4x4UnormSRGB:
  46982. case TextureFormat.ASTC5x4Unorm:
  46983. case TextureFormat.ASTC5x4UnormSRGB:
  46984. case TextureFormat.ASTC5x5Unorm:
  46985. case TextureFormat.ASTC5x5UnormSRGB:
  46986. case TextureFormat.ASTC6x5Unorm:
  46987. case TextureFormat.ASTC6x5UnormSRGB:
  46988. case TextureFormat.ASTC6x6Unorm:
  46989. case TextureFormat.ASTC6x6UnormSRGB:
  46990. case TextureFormat.ASTC8x5Unorm:
  46991. case TextureFormat.ASTC8x5UnormSRGB:
  46992. case TextureFormat.ASTC8x6Unorm:
  46993. case TextureFormat.ASTC8x6UnormSRGB:
  46994. case TextureFormat.ASTC8x8Unorm:
  46995. case TextureFormat.ASTC8x8UnormSRGB:
  46996. case TextureFormat.ASTC10x5Unorm:
  46997. case TextureFormat.ASTC10x5UnormSRGB:
  46998. case TextureFormat.ASTC10x6Unorm:
  46999. case TextureFormat.ASTC10x6UnormSRGB:
  47000. case TextureFormat.ASTC10x8Unorm:
  47001. case TextureFormat.ASTC10x8UnormSRGB:
  47002. case TextureFormat.ASTC10x10Unorm:
  47003. case TextureFormat.ASTC10x10UnormSRGB:
  47004. case TextureFormat.ASTC12x10Unorm:
  47005. case TextureFormat.ASTC12x10UnormSRGB:
  47006. case TextureFormat.ASTC12x12Unorm:
  47007. case TextureFormat.ASTC12x12UnormSRGB:
  47008. return !0
  47009. }
  47010. return !1
  47011. }
  47012. ,
  47013. a.GetWebGPUTextureFormat = function(e, i, o) {
  47014. switch (o === void 0 && (o = !1),
  47015. i) {
  47016. case 15:
  47017. return TextureFormat.Depth16Unorm;
  47018. case 13:
  47019. return TextureFormat.Depth24PlusStencil8;
  47020. case 14:
  47021. return TextureFormat.Depth32Float;
  47022. case 36492:
  47023. return o ? TextureFormat.BC7RGBAUnormSRGB : TextureFormat.BC7RGBAUnorm;
  47024. case 36495:
  47025. return TextureFormat.BC6HRGBUFloat;
  47026. case 36494:
  47027. return TextureFormat.BC6HRGBFloat;
  47028. case 33779:
  47029. return o ? TextureFormat.BC3RGBAUnormSRGB : TextureFormat.BC3RGBAUnorm;
  47030. case 33778:
  47031. return o ? TextureFormat.BC2RGBAUnormSRGB : TextureFormat.BC2RGBAUnorm;
  47032. case 33777:
  47033. case 33776:
  47034. return o ? TextureFormat.BC1RGBAUnormSRGB : TextureFormat.BC1RGBAUnorm;
  47035. case 37808:
  47036. return o ? TextureFormat.ASTC4x4UnormSRGB : TextureFormat.ASTC4x4Unorm;
  47037. case 36196:
  47038. return o ? TextureFormat.ETC2RGB8UnormSRGB : TextureFormat.ETC2RGB8Unorm
  47039. }
  47040. switch (e) {
  47041. case 3:
  47042. switch (i) {
  47043. case 6:
  47044. return TextureFormat.R8Snorm;
  47045. case 7:
  47046. return TextureFormat.RG8Snorm;
  47047. case 4:
  47048. throw "RGB format not supported in WebGPU";
  47049. case 8:
  47050. return TextureFormat.R8Sint;
  47051. case 9:
  47052. return TextureFormat.RG8Sint;
  47053. case 10:
  47054. throw "RGB_INTEGER format not supported in WebGPU";
  47055. case 11:
  47056. return TextureFormat.RGBA8Sint;
  47057. default:
  47058. return TextureFormat.RGBA8Snorm
  47059. }
  47060. case 0:
  47061. switch (i) {
  47062. case 6:
  47063. return TextureFormat.R8Unorm;
  47064. case 7:
  47065. return TextureFormat.RG8Unorm;
  47066. case 4:
  47067. throw "TEXTUREFORMAT_RGB format not supported in WebGPU";
  47068. case 5:
  47069. return o ? TextureFormat.RGBA8UnormSRGB : TextureFormat.RGBA8Unorm;
  47070. case 12:
  47071. return o ? TextureFormat.BGRA8UnormSRGB : TextureFormat.BGRA8Unorm;
  47072. case 8:
  47073. return TextureFormat.R8Uint;
  47074. case 9:
  47075. return TextureFormat.RG8Uint;
  47076. case 10:
  47077. throw "RGB_INTEGER format not supported in WebGPU";
  47078. case 11:
  47079. return TextureFormat.RGBA8Uint;
  47080. case 0:
  47081. throw "TEXTUREFORMAT_ALPHA format not supported in WebGPU";
  47082. case 1:
  47083. throw "TEXTUREFORMAT_LUMINANCE format not supported in WebGPU";
  47084. case 2:
  47085. throw "TEXTUREFORMAT_LUMINANCE_ALPHA format not supported in WebGPU";
  47086. default:
  47087. return TextureFormat.RGBA8Unorm
  47088. }
  47089. case 4:
  47090. switch (i) {
  47091. case 8:
  47092. return TextureFormat.R16Sint;
  47093. case 9:
  47094. return TextureFormat.RG16Sint;
  47095. case 10:
  47096. throw "TEXTUREFORMAT_RGB_INTEGER format not supported in WebGPU";
  47097. case 11:
  47098. return TextureFormat.RGBA16Sint;
  47099. default:
  47100. return TextureFormat.RGBA16Sint
  47101. }
  47102. case 5:
  47103. switch (i) {
  47104. case 8:
  47105. return TextureFormat.R16Uint;
  47106. case 9:
  47107. return TextureFormat.RG16Uint;
  47108. case 10:
  47109. throw "TEXTUREFORMAT_RGB_INTEGER format not supported in WebGPU";
  47110. case 11:
  47111. return TextureFormat.RGBA16Uint;
  47112. default:
  47113. return TextureFormat.RGBA16Uint
  47114. }
  47115. case 6:
  47116. switch (i) {
  47117. case 8:
  47118. return TextureFormat.R32Sint;
  47119. case 9:
  47120. return TextureFormat.RG32Sint;
  47121. case 10:
  47122. throw "TEXTUREFORMAT_RGB_INTEGER format not supported in WebGPU";
  47123. case 11:
  47124. return TextureFormat.RGBA32Sint;
  47125. default:
  47126. return TextureFormat.RGBA32Sint
  47127. }
  47128. case 7:
  47129. switch (i) {
  47130. case 8:
  47131. return TextureFormat.R32Uint;
  47132. case 9:
  47133. return TextureFormat.RG32Uint;
  47134. case 10:
  47135. throw "TEXTUREFORMAT_RGB_INTEGER format not supported in WebGPU";
  47136. case 11:
  47137. return TextureFormat.RGBA32Uint;
  47138. default:
  47139. return TextureFormat.RGBA32Uint
  47140. }
  47141. case 1:
  47142. switch (i) {
  47143. case 6:
  47144. return TextureFormat.R32Float;
  47145. case 7:
  47146. return TextureFormat.RG32Float;
  47147. case 4:
  47148. throw "TEXTUREFORMAT_RGB format not supported in WebGPU";
  47149. case 5:
  47150. return TextureFormat.RGBA32Float;
  47151. default:
  47152. return TextureFormat.RGBA32Float
  47153. }
  47154. case 2:
  47155. switch (i) {
  47156. case 6:
  47157. return TextureFormat.R16Float;
  47158. case 7:
  47159. return TextureFormat.RG16Float;
  47160. case 4:
  47161. throw "TEXTUREFORMAT_RGB format not supported in WebGPU";
  47162. case 5:
  47163. return TextureFormat.RGBA16Float;
  47164. default:
  47165. return TextureFormat.RGBA16Float
  47166. }
  47167. case 10:
  47168. throw "TEXTURETYPE_UNSIGNED_SHORT_5_6_5 format not supported in WebGPU";
  47169. case 13:
  47170. throw "TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV format not supported in WebGPU";
  47171. case 14:
  47172. throw "TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV format not supported in WebGPU";
  47173. case 8:
  47174. throw "TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 format not supported in WebGPU";
  47175. case 9:
  47176. throw "TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 format not supported in WebGPU";
  47177. case 11:
  47178. switch (i) {
  47179. case 5:
  47180. return TextureFormat.RGB10A2Unorm;
  47181. case 11:
  47182. throw "TEXTUREFORMAT_RGBA_INTEGER format not supported in WebGPU when type is TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV";
  47183. default:
  47184. return TextureFormat.RGB10A2Unorm
  47185. }
  47186. }
  47187. return o ? TextureFormat.RGBA8UnormSRGB : TextureFormat.RGBA8Unorm
  47188. }
  47189. ,
  47190. a.GetNumChannelsFromWebGPUTextureFormat = function(e) {
  47191. switch (e) {
  47192. case TextureFormat.R8Unorm:
  47193. case TextureFormat.R8Snorm:
  47194. case TextureFormat.R8Uint:
  47195. case TextureFormat.R8Sint:
  47196. case TextureFormat.BC4RUnorm:
  47197. case TextureFormat.BC4RSnorm:
  47198. case TextureFormat.R16Uint:
  47199. case TextureFormat.R16Sint:
  47200. case TextureFormat.Depth16Unorm:
  47201. case TextureFormat.R16Float:
  47202. case TextureFormat.R32Uint:
  47203. case TextureFormat.R32Sint:
  47204. case TextureFormat.R32Float:
  47205. case TextureFormat.Depth32Float:
  47206. case TextureFormat.Stencil8:
  47207. case TextureFormat.Depth24Plus:
  47208. case TextureFormat.EACR11Unorm:
  47209. case TextureFormat.EACR11Snorm:
  47210. return 1;
  47211. case TextureFormat.RG8Unorm:
  47212. case TextureFormat.RG8Snorm:
  47213. case TextureFormat.RG8Uint:
  47214. case TextureFormat.RG8Sint:
  47215. case TextureFormat.Depth24UnormStencil8:
  47216. case TextureFormat.Depth32FloatStencil8:
  47217. case TextureFormat.BC5RGUnorm:
  47218. case TextureFormat.BC5RGSnorm:
  47219. case TextureFormat.RG16Uint:
  47220. case TextureFormat.RG16Sint:
  47221. case TextureFormat.RG16Float:
  47222. case TextureFormat.RG32Uint:
  47223. case TextureFormat.RG32Sint:
  47224. case TextureFormat.RG32Float:
  47225. case TextureFormat.Depth24PlusStencil8:
  47226. case TextureFormat.EACRG11Unorm:
  47227. case TextureFormat.EACRG11Snorm:
  47228. return 2;
  47229. case TextureFormat.RGB9E5UFloat:
  47230. case TextureFormat.RG11B10UFloat:
  47231. case TextureFormat.BC6HRGBUFloat:
  47232. case TextureFormat.BC6HRGBFloat:
  47233. case TextureFormat.ETC2RGB8Unorm:
  47234. case TextureFormat.ETC2RGB8UnormSRGB:
  47235. return 3;
  47236. case TextureFormat.RGBA8Unorm:
  47237. case TextureFormat.RGBA8UnormSRGB:
  47238. case TextureFormat.RGBA8Snorm:
  47239. case TextureFormat.RGBA8Uint:
  47240. case TextureFormat.RGBA8Sint:
  47241. case TextureFormat.BGRA8Unorm:
  47242. case TextureFormat.BGRA8UnormSRGB:
  47243. case TextureFormat.RGB10A2Unorm:
  47244. case TextureFormat.BC7RGBAUnorm:
  47245. case TextureFormat.BC7RGBAUnormSRGB:
  47246. case TextureFormat.BC3RGBAUnorm:
  47247. case TextureFormat.BC3RGBAUnormSRGB:
  47248. case TextureFormat.BC2RGBAUnorm:
  47249. case TextureFormat.BC2RGBAUnormSRGB:
  47250. case TextureFormat.BC1RGBAUnorm:
  47251. case TextureFormat.BC1RGBAUnormSRGB:
  47252. case TextureFormat.RGBA16Uint:
  47253. case TextureFormat.RGBA16Sint:
  47254. case TextureFormat.RGBA16Float:
  47255. case TextureFormat.RGBA32Uint:
  47256. case TextureFormat.RGBA32Sint:
  47257. case TextureFormat.RGBA32Float:
  47258. case TextureFormat.ETC2RGB8A1Unorm:
  47259. case TextureFormat.ETC2RGB8A1UnormSRGB:
  47260. case TextureFormat.ETC2RGBA8Unorm:
  47261. case TextureFormat.ETC2RGBA8UnormSRGB:
  47262. case TextureFormat.ASTC4x4Unorm:
  47263. case TextureFormat.ASTC4x4UnormSRGB:
  47264. case TextureFormat.ASTC5x4Unorm:
  47265. case TextureFormat.ASTC5x4UnormSRGB:
  47266. case TextureFormat.ASTC5x5Unorm:
  47267. case TextureFormat.ASTC5x5UnormSRGB:
  47268. case TextureFormat.ASTC6x5Unorm:
  47269. case TextureFormat.ASTC6x5UnormSRGB:
  47270. case TextureFormat.ASTC6x6Unorm:
  47271. case TextureFormat.ASTC6x6UnormSRGB:
  47272. case TextureFormat.ASTC8x5Unorm:
  47273. case TextureFormat.ASTC8x5UnormSRGB:
  47274. case TextureFormat.ASTC8x6Unorm:
  47275. case TextureFormat.ASTC8x6UnormSRGB:
  47276. case TextureFormat.ASTC8x8Unorm:
  47277. case TextureFormat.ASTC8x8UnormSRGB:
  47278. case TextureFormat.ASTC10x5Unorm:
  47279. case TextureFormat.ASTC10x5UnormSRGB:
  47280. case TextureFormat.ASTC10x6Unorm:
  47281. case TextureFormat.ASTC10x6UnormSRGB:
  47282. case TextureFormat.ASTC10x8Unorm:
  47283. case TextureFormat.ASTC10x8UnormSRGB:
  47284. case TextureFormat.ASTC10x10Unorm:
  47285. case TextureFormat.ASTC10x10UnormSRGB:
  47286. case TextureFormat.ASTC12x10Unorm:
  47287. case TextureFormat.ASTC12x10UnormSRGB:
  47288. case TextureFormat.ASTC12x12Unorm:
  47289. case TextureFormat.ASTC12x12UnormSRGB:
  47290. return 4
  47291. }
  47292. throw "Unknown format " + e + "!"
  47293. }
  47294. ,
  47295. a.prototype.invertYPreMultiplyAlpha = function(e, i, o, s, c, d, _, b, k, j, $) {
  47296. var _e, et, tt, rt, it, nt, ot;
  47297. c === void 0 && (c = !1),
  47298. d === void 0 && (d = !1),
  47299. _ === void 0 && (_ = 0),
  47300. b === void 0 && (b = 0),
  47301. k === void 0 && (k = 1);
  47302. var at = j === void 0
  47303. , st = this._getPipeline(s, PipelineType.InvertYPremultiplyAlpha, {
  47304. invertY: c,
  47305. premultiplyAlpha: d
  47306. })
  47307. , ut = st[0]
  47308. , ct = st[1];
  47309. _ = Math.max(_, 0),
  47310. at && (j = this._device.createCommandEncoder({})),
  47311. (et = (_e = j).pushDebugGroup) === null || et === void 0 || et.call(_e, "internal process texture - invertY=" + c + " premultiplyAlpha=" + d);
  47312. var lt;
  47313. if (a._IsHardwareTexture(e) ? (lt = e.underlyingResource,
  47314. c && !d && k === 1 && _ === 0 || (e = void 0)) : (lt = e,
  47315. e = void 0),
  47316. !!lt) {
  47317. var ft = e
  47318. , ht = (tt = ft == null ? void 0 : ft._copyInvertYTempTexture) !== null && tt !== void 0 ? tt : this.createTexture({
  47319. width: i,
  47320. height: o,
  47321. layers: 1
  47322. }, !1, !1, !1, !1, !1, s, 1, j, TextureUsage.CopySrc | TextureUsage.RenderAttachment | TextureUsage.TextureBinding)
  47323. , pt = (rt = ft == null ? void 0 : ft._copyInvertYRenderPassDescr) !== null && rt !== void 0 ? rt : {
  47324. colorAttachments: [{
  47325. view: ht.createView({
  47326. format: s,
  47327. dimension: TextureViewDimension.E2d,
  47328. baseMipLevel: 0,
  47329. mipLevelCount: 1,
  47330. arrayLayerCount: 1,
  47331. baseArrayLayer: 0
  47332. }),
  47333. loadValue: LoadOp.Load,
  47334. storeOp: StoreOp.Store
  47335. }]
  47336. }
  47337. , dt = j.beginRenderPass(pt)
  47338. , _t = (it = ft == null ? void 0 : ft._copyInvertYBindGroupd) !== null && it !== void 0 ? it : this._device.createBindGroup({
  47339. layout: ct,
  47340. entries: [{
  47341. binding: 0,
  47342. resource: lt.createView({
  47343. format: s,
  47344. dimension: TextureViewDimension.E2d,
  47345. baseMipLevel: b,
  47346. mipLevelCount: 1,
  47347. arrayLayerCount: k,
  47348. baseArrayLayer: _
  47349. })
  47350. }]
  47351. });
  47352. dt.setPipeline(ut),
  47353. dt.setBindGroup(0, _t),
  47354. dt.draw(4, 1, 0, 0),
  47355. dt.endPass(),
  47356. j.copyTextureToTexture({
  47357. texture: ht
  47358. }, {
  47359. texture: lt,
  47360. mipLevel: b,
  47361. origin: {
  47362. x: 0,
  47363. y: 0,
  47364. z: _
  47365. }
  47366. }, {
  47367. width: i,
  47368. height: o,
  47369. depthOrArrayLayers: 1
  47370. }),
  47371. ft ? (ft._copyInvertYTempTexture = ht,
  47372. ft._copyInvertYRenderPassDescr = pt,
  47373. ft._copyInvertYBindGroupd = _t) : this._deferredReleaseTextures.push([ht, null]),
  47374. (ot = (nt = j).popDebugGroup) === null || ot === void 0 || ot.call(nt),
  47375. at && (this._device.queue.submit([j.finish()]),
  47376. j = null)
  47377. }
  47378. }
  47379. ,
  47380. a.prototype.copyWithInvertY = function(e, i, o, s) {
  47381. var c, d, _, b, k = s === void 0, j = this._getPipeline(i, PipelineType.InvertYPremultiplyAlpha, {
  47382. invertY: !0,
  47383. premultiplyAlpha: !1
  47384. }), $ = j[0], _e = j[1];
  47385. k && (s = this._device.createCommandEncoder({})),
  47386. (d = (c = s).pushDebugGroup) === null || d === void 0 || d.call(c, "internal copy texture with invertY");
  47387. var et = s.beginRenderPass(o)
  47388. , tt = this._device.createBindGroup({
  47389. layout: _e,
  47390. entries: [{
  47391. binding: 0,
  47392. resource: e
  47393. }]
  47394. });
  47395. et.setPipeline($),
  47396. et.setBindGroup(0, tt),
  47397. et.draw(4, 1, 0, 0),
  47398. et.endPass(),
  47399. (b = (_ = s).popDebugGroup) === null || b === void 0 || b.call(_),
  47400. k && (this._device.queue.submit([s.finish()]),
  47401. s = null)
  47402. }
  47403. ,
  47404. a.prototype.createTexture = function(e, i, o, s, c, d, _, b, k, j, $) {
  47405. i === void 0 && (i = !1),
  47406. o === void 0 && (o = !1),
  47407. s === void 0 && (s = !1),
  47408. c === void 0 && (c = !1),
  47409. d === void 0 && (d = !1),
  47410. _ === void 0 && (_ = TextureFormat.RGBA8Unorm),
  47411. b === void 0 && (b = 1),
  47412. j === void 0 && (j = -1),
  47413. $ === void 0 && ($ = 0);
  47414. var _e = e.layers || 1
  47415. , et = {
  47416. width: e.width,
  47417. height: e.height,
  47418. depthOrArrayLayers: _e
  47419. }
  47420. , tt = a.IsCompressedFormat(_)
  47421. , rt = i ? a.ComputeNumMipmapLevels(e.width, e.height) : 1
  47422. , it = j >= 0 ? j : TextureUsage.CopySrc | TextureUsage.CopyDst | TextureUsage.TextureBinding;
  47423. $ |= i && !tt ? TextureUsage.CopySrc | TextureUsage.RenderAttachment : 0,
  47424. tt || ($ |= TextureUsage.RenderAttachment | TextureUsage.CopyDst);
  47425. var nt = this._device.createTexture({
  47426. size: et,
  47427. dimension: d ? TextureDimension.E3d : TextureDimension.E2d,
  47428. format: _,
  47429. usage: it | $,
  47430. sampleCount: b,
  47431. mipLevelCount: rt
  47432. });
  47433. return a.IsImageBitmap(e) && (this.updateTexture(e, nt, e.width, e.height, _e, _, 0, 0, s, c, 0, 0, k),
  47434. i && o && this.generateMipmaps(nt, _, rt, 0, k)),
  47435. nt
  47436. }
  47437. ,
  47438. a.prototype.createCubeTexture = function(e, i, o, s, c, d, _, b, k, j) {
  47439. i === void 0 && (i = !1),
  47440. o === void 0 && (o = !1),
  47441. s === void 0 && (s = !1),
  47442. c === void 0 && (c = !1),
  47443. d === void 0 && (d = TextureFormat.RGBA8Unorm),
  47444. _ === void 0 && (_ = 1),
  47445. k === void 0 && (k = -1),
  47446. j === void 0 && (j = 0);
  47447. var $ = a.IsImageBitmapArray(e) ? e[0].width : e.width
  47448. , _e = a.IsImageBitmapArray(e) ? e[0].height : e.height
  47449. , et = a.IsCompressedFormat(d)
  47450. , tt = i ? a.ComputeNumMipmapLevels($, _e) : 1
  47451. , rt = k >= 0 ? k : TextureUsage.CopySrc | TextureUsage.CopyDst | TextureUsage.TextureBinding;
  47452. j |= i && !et ? TextureUsage.CopySrc | TextureUsage.RenderAttachment : 0,
  47453. et || (j |= TextureUsage.RenderAttachment | TextureUsage.CopyDst);
  47454. var it = this._device.createTexture({
  47455. size: {
  47456. width: $,
  47457. height: _e,
  47458. depthOrArrayLayers: 6
  47459. },
  47460. dimension: TextureDimension.E2d,
  47461. format: d,
  47462. usage: rt | j,
  47463. sampleCount: _,
  47464. mipLevelCount: tt
  47465. });
  47466. return a.IsImageBitmapArray(e) && (this.updateCubeTextures(e, it, $, _e, d, s, c, 0, 0, b),
  47467. i && o && this.generateCubeMipmaps(it, d, tt, b)),
  47468. it
  47469. }
  47470. ,
  47471. a.prototype.generateCubeMipmaps = function(e, i, o, s) {
  47472. var c, d, _, b, k = s === void 0;
  47473. k && (s = this._device.createCommandEncoder({})),
  47474. (d = (c = s).pushDebugGroup) === null || d === void 0 || d.call(c, "create cube mipmaps - " + o + " levels");
  47475. for (var j = 0; j < 6; ++j)
  47476. this.generateMipmaps(e, i, o, j, s);
  47477. (b = (_ = s).popDebugGroup) === null || b === void 0 || b.call(_),
  47478. k && (this._device.queue.submit([s.finish()]),
  47479. s = null)
  47480. }
  47481. ,
  47482. a.prototype.generateMipmaps = function(e, i, o, s, c) {
  47483. var d, _, b, k, j, $, _e, et;
  47484. s === void 0 && (s = 0);
  47485. var tt = c === void 0
  47486. , rt = this._getPipeline(i)
  47487. , it = rt[0]
  47488. , nt = rt[1];
  47489. s = Math.max(s, 0),
  47490. tt && (c = this._device.createCommandEncoder({})),
  47491. (_ = (d = c).pushDebugGroup) === null || _ === void 0 || _.call(d, "create mipmaps for face #" + s + " - " + o + " levels");
  47492. var ot;
  47493. if (a._IsHardwareTexture(e) ? (ot = e.underlyingResource,
  47494. e._mipmapGenRenderPassDescr = e._mipmapGenRenderPassDescr || [],
  47495. e._mipmapGenBindGroup = e._mipmapGenBindGroup || []) : (ot = e,
  47496. e = void 0),
  47497. !!ot) {
  47498. for (var at = e, st = 1; st < o; ++st) {
  47499. var ut = (k = (b = at == null ? void 0 : at._mipmapGenRenderPassDescr[s]) === null || b === void 0 ? void 0 : b[st - 1]) !== null && k !== void 0 ? k : {
  47500. colorAttachments: [{
  47501. view: ot.createView({
  47502. format: i,
  47503. dimension: TextureViewDimension.E2d,
  47504. baseMipLevel: st,
  47505. mipLevelCount: 1,
  47506. arrayLayerCount: 1,
  47507. baseArrayLayer: s
  47508. }),
  47509. loadValue: LoadOp.Load,
  47510. storeOp: StoreOp.Store
  47511. }]
  47512. };
  47513. at && (at._mipmapGenRenderPassDescr[s] = at._mipmapGenRenderPassDescr[s] || [],
  47514. at._mipmapGenRenderPassDescr[s][st - 1] = ut);
  47515. var ct = c.beginRenderPass(ut)
  47516. , lt = ($ = (j = at == null ? void 0 : at._mipmapGenBindGroup[s]) === null || j === void 0 ? void 0 : j[st - 1]) !== null && $ !== void 0 ? $ : this._device.createBindGroup({
  47517. layout: nt,
  47518. entries: [{
  47519. binding: 0,
  47520. resource: this._mipmapSampler
  47521. }, {
  47522. binding: 1,
  47523. resource: ot.createView({
  47524. format: i,
  47525. dimension: TextureViewDimension.E2d,
  47526. baseMipLevel: st - 1,
  47527. mipLevelCount: 1,
  47528. arrayLayerCount: 1,
  47529. baseArrayLayer: s
  47530. })
  47531. }]
  47532. });
  47533. at && (at._mipmapGenBindGroup[s] = at._mipmapGenBindGroup[s] || [],
  47534. at._mipmapGenBindGroup[s][st - 1] = lt),
  47535. ct.setPipeline(it),
  47536. ct.setBindGroup(0, lt),
  47537. ct.draw(4, 1, 0, 0),
  47538. ct.endPass()
  47539. }
  47540. (et = (_e = c).popDebugGroup) === null || et === void 0 || et.call(_e),
  47541. tt && (this._device.queue.submit([c.finish()]),
  47542. c = null)
  47543. }
  47544. }
  47545. ,
  47546. a.prototype.createGPUTextureForInternalTexture = function(e, i, o, s, c) {
  47547. e._hardwareTexture || (e._hardwareTexture = new WebGPUHardwareTexture),
  47548. i === void 0 && (i = e.width),
  47549. o === void 0 && (o = e.height),
  47550. s === void 0 && (s = e.depth);
  47551. var d = e._hardwareTexture;
  47552. d.format = a.GetWebGPUTextureFormat(e.type, e.format, e._useSRGBBuffer),
  47553. d.textureUsages = e._source === InternalTextureSource.RenderTarget || e.source === InternalTextureSource.MultiRenderTarget ? TextureUsage.TextureBinding | TextureUsage.CopySrc | TextureUsage.RenderAttachment : e._source === InternalTextureSource.DepthStencil ? TextureUsage.TextureBinding | TextureUsage.RenderAttachment : -1,
  47554. d.textureAdditionalUsages = (c != null ? c : 0) & 1 ? TextureUsage.StorageBinding : 0;
  47555. var _ = e.generateMipMaps
  47556. , b = s || 1;
  47557. if (e.isCube) {
  47558. var k = this.createCubeTexture({
  47559. width: i,
  47560. height: o
  47561. }, e.generateMipMaps, e.generateMipMaps, e.invertY, !1, d.format, 1, this._commandEncoderForCreation, d.textureUsages, d.textureAdditionalUsages);
  47562. d.set(k),
  47563. d.createView({
  47564. format: d.format,
  47565. dimension: TextureViewDimension.Cube,
  47566. mipLevelCount: _ ? a.ComputeNumMipmapLevels(i, o) : 1,
  47567. baseArrayLayer: 0,
  47568. baseMipLevel: 0,
  47569. arrayLayerCount: 6,
  47570. aspect: TextureAspect.All
  47571. })
  47572. } else {
  47573. var k = this.createTexture({
  47574. width: i,
  47575. height: o,
  47576. layers: b
  47577. }, e.generateMipMaps, e.generateMipMaps, e.invertY, !1, e.is3D, d.format, 1, this._commandEncoderForCreation, d.textureUsages, d.textureAdditionalUsages);
  47578. d.set(k),
  47579. d.createView({
  47580. format: d.format,
  47581. dimension: e.is2DArray ? TextureViewDimension.E2dArray : e.is3D ? TextureDimension.E3d : TextureViewDimension.E2d,
  47582. mipLevelCount: _ ? a.ComputeNumMipmapLevels(i, o) : 1,
  47583. baseArrayLayer: 0,
  47584. baseMipLevel: 0,
  47585. arrayLayerCount: e.is3D ? 1 : b,
  47586. aspect: TextureAspect.All
  47587. })
  47588. }
  47589. return e.width = e.baseWidth = i,
  47590. e.height = e.baseHeight = o,
  47591. e.depth = e.baseDepth = s,
  47592. this.createMSAATexture(e, e.samples),
  47593. d
  47594. }
  47595. ,
  47596. a.prototype.createMSAATexture = function(e, i) {
  47597. var o = e._hardwareTexture;
  47598. if (o != null && o.msaaTexture && (this.releaseTexture(o.msaaTexture),
  47599. o.msaaTexture = null),
  47600. !(!o || (i != null ? i : 1) <= 1)) {
  47601. var s = e.width
  47602. , c = e.height
  47603. , d = e.depth || 1;
  47604. if (e.isCube) {
  47605. var _ = this.createCubeTexture({
  47606. width: s,
  47607. height: c
  47608. }, !1, !1, e.invertY, !1, o.format, i, this._commandEncoderForCreation, o.textureUsages, o.textureAdditionalUsages);
  47609. o.setMSAATexture(_)
  47610. } else {
  47611. var _ = this.createTexture({
  47612. width: s,
  47613. height: c,
  47614. layers: d
  47615. }, !1, !1, e.invertY, !1, e.is3D, o.format, i, this._commandEncoderForCreation, o.textureUsages, o.textureAdditionalUsages);
  47616. o.setMSAATexture(_)
  47617. }
  47618. }
  47619. }
  47620. ,
  47621. a.prototype.updateCubeTextures = function(e, i, o, s, c, d, _, b, k, j) {
  47622. d === void 0 && (d = !1),
  47623. _ === void 0 && (_ = !1),
  47624. b === void 0 && (b = 0),
  47625. k === void 0 && (k = 0);
  47626. for (var $ = [0, 3, 1, 4, 2, 5], _e = 0; _e < $.length; ++_e) {
  47627. var et = e[$[_e]];
  47628. this.updateTexture(et, i, o, s, 1, c, _e, 0, d, _, b, k, j)
  47629. }
  47630. }
  47631. ,
  47632. a.prototype.updateTexture = function(e, i, o, s, c, d, _, b, k, j, $, _e, et, tt) {
  47633. _ === void 0 && (_ = 0),
  47634. b === void 0 && (b = 0),
  47635. k === void 0 && (k = !1),
  47636. j === void 0 && (j = !1),
  47637. $ === void 0 && ($ = 0),
  47638. _e === void 0 && (_e = 0);
  47639. var rt = a._IsInternalTexture(i) ? i._hardwareTexture.underlyingResource : i
  47640. , it = a._GetBlockInformationFromFormat(d)
  47641. , nt = a._IsInternalTexture(i) ? i._hardwareTexture : i
  47642. , ot = {
  47643. texture: rt,
  47644. origin: {
  47645. x: $,
  47646. y: _e,
  47647. z: Math.max(_, 0)
  47648. },
  47649. mipLevel: b,
  47650. premultipliedAlpha: j
  47651. }
  47652. , at = {
  47653. width: Math.ceil(o / it.width) * it.width,
  47654. height: Math.ceil(s / it.height) * it.height,
  47655. depthOrArrayLayers: c || 1
  47656. };
  47657. if (e.byteLength !== void 0) {
  47658. e = e;
  47659. var st = Math.ceil(o / it.width) * it.length
  47660. , ut = Math.ceil(st / 256) * 256 === st;
  47661. if (ut) {
  47662. var ct = et === void 0;
  47663. ct && (et = this._device.createCommandEncoder({}));
  47664. var lt = this._bufferManager.createRawBuffer(e.byteLength, BufferUsage.MapWrite | BufferUsage.CopySrc, !0)
  47665. , ft = lt.getMappedRange();
  47666. new Uint8Array(ft).set(e),
  47667. lt.unmap(),
  47668. et.copyBufferToTexture({
  47669. buffer: lt,
  47670. offset: 0,
  47671. bytesPerRow: st,
  47672. rowsPerImage: s
  47673. }, ot, at),
  47674. ct && (this._device.queue.submit([et.finish()]),
  47675. et = null),
  47676. this._bufferManager.releaseBuffer(lt)
  47677. } else
  47678. this._device.queue.writeTexture(ot, e, {
  47679. offset: 0,
  47680. bytesPerRow: st,
  47681. rowsPerImage: s
  47682. }, at);
  47683. (k || j) && this.invertYPreMultiplyAlpha(nt, o, s, d, k, j, _, b, c || 1, et, tt)
  47684. } else if (e = e,
  47685. k)
  47686. if (ot.premultipliedAlpha = !1,
  47687. a._IsInternalTexture(i) && $ === 0 && _e === 0 && o === i.width && s === i.height)
  47688. this._device.queue.copyExternalImageToTexture({
  47689. source: e
  47690. }, ot, at),
  47691. this.invertYPreMultiplyAlpha(nt, o, s, d, k, j, _, b, c || 1, void 0, tt);
  47692. else {
  47693. et = this._device.createCommandEncoder({});
  47694. var ht = this.createTexture({
  47695. width: o,
  47696. height: s,
  47697. layers: 1
  47698. }, !1, !1, !1, !1, !1, d, 1, et, TextureUsage.CopySrc | TextureUsage.TextureBinding);
  47699. this._deferredReleaseTextures.push([ht, null]),
  47700. at.depthOrArrayLayers = 1,
  47701. this._device.queue.copyExternalImageToTexture({
  47702. source: e
  47703. }, {
  47704. texture: ht
  47705. }, at),
  47706. at.depthOrArrayLayers = c || 1,
  47707. this.invertYPreMultiplyAlpha(ht, o, s, d, k, j, _, b, c || 1, et, tt),
  47708. et.copyTextureToTexture({
  47709. texture: ht
  47710. }, ot, at),
  47711. this._device.queue.submit([et.finish()]),
  47712. et = null
  47713. }
  47714. else
  47715. this._device.queue.copyExternalImageToTexture({
  47716. source: e
  47717. }, ot, at)
  47718. }
  47719. ,
  47720. a.prototype.readPixels = function(e, i, o, s, c, d, _, b, k, j) {
  47721. _ === void 0 && (_ = 0),
  47722. b === void 0 && (b = 0),
  47723. k === void 0 && (k = null),
  47724. j === void 0 && (j = !1);
  47725. var $ = a._GetBlockInformationFromFormat(d)
  47726. , _e = Math.ceil(s / $.width) * $.length
  47727. , et = Math.ceil(_e / 256) * 256
  47728. , tt = et * c
  47729. , rt = this._bufferManager.createRawBuffer(tt, BufferUsage.MapRead | BufferUsage.CopyDst)
  47730. , it = this._device.createCommandEncoder({});
  47731. return it.copyTextureToBuffer({
  47732. texture: e,
  47733. mipLevel: b,
  47734. origin: {
  47735. x: i,
  47736. y: o,
  47737. z: Math.max(_, 0)
  47738. }
  47739. }, {
  47740. buffer: rt,
  47741. offset: 0,
  47742. bytesPerRow: et
  47743. }, {
  47744. width: s,
  47745. height: c,
  47746. depthOrArrayLayers: 1
  47747. }),
  47748. this._device.queue.submit([it.finish()]),
  47749. this._bufferManager.readDataFromBuffer(rt, tt, s, c, _e, et, a._GetTextureTypeFromFormat(d), 0, k, !0, j)
  47750. }
  47751. ,
  47752. a.prototype.releaseTexture = function(e) {
  47753. if (a._IsInternalTexture(e)) {
  47754. var i = e._hardwareTexture
  47755. , o = e._irradianceTexture;
  47756. this._deferredReleaseTextures.push([i, o])
  47757. } else
  47758. this._deferredReleaseTextures.push([e, null])
  47759. }
  47760. ,
  47761. a.prototype.destroyDeferredTextures = function() {
  47762. for (var e = 0; e < this._deferredReleaseTextures.length; ++e) {
  47763. var i = this._deferredReleaseTextures[e]
  47764. , o = i[0]
  47765. , s = i[1];
  47766. o && (a._IsHardwareTexture(o) ? o.release() : o.destroy()),
  47767. s == null || s.dispose()
  47768. }
  47769. this._deferredReleaseTextures.length = 0
  47770. }
  47771. ,
  47772. a
  47773. }(), WebGPUDataBuffer = function(a) {
  47774. __extends(e, a);
  47775. function e(i) {
  47776. var o = a.call(this) || this;
  47777. return o._buffer = i,
  47778. o
  47779. }
  47780. return Object.defineProperty(e.prototype, "underlyingResource", {
  47781. get: function() {
  47782. return this._buffer
  47783. },
  47784. enumerable: !1,
  47785. configurable: !0
  47786. }),
  47787. e
  47788. }(DataBuffer), WebGPUBufferManager = function() {
  47789. function a(e) {
  47790. this._deferredReleaseBuffers = [],
  47791. this._device = e
  47792. }
  47793. return a._IsGPUBuffer = function(e) {
  47794. return e.underlyingResource === void 0
  47795. }
  47796. ,
  47797. a.prototype.createRawBuffer = function(e, i, o) {
  47798. o === void 0 && (o = !1);
  47799. var s = e.byteLength !== void 0 ? e.byteLength + 3 & -4 : e + 3 & -4
  47800. , c = {
  47801. mappedAtCreation: o,
  47802. size: s,
  47803. usage: i
  47804. };
  47805. return this._device.createBuffer(c)
  47806. }
  47807. ,
  47808. a.prototype.createBuffer = function(e, i) {
  47809. var o = e.byteLength !== void 0
  47810. , s = this.createRawBuffer(e, i)
  47811. , c = new WebGPUDataBuffer(s);
  47812. return c.references = 1,
  47813. c.capacity = o ? e.byteLength : e,
  47814. o && this.setSubData(c, 0, e),
  47815. c
  47816. }
  47817. ,
  47818. a.prototype.setRawData = function(e, i, o, s, c) {
  47819. this._device.queue.writeBuffer(e, i, o.buffer, s, c)
  47820. }
  47821. ,
  47822. a.prototype.setSubData = function(e, i, o, s, c) {
  47823. s === void 0 && (s = 0),
  47824. c === void 0 && (c = 0);
  47825. var d = e.underlyingResource;
  47826. c = c || o.byteLength,
  47827. c = Math.min(c, e.capacity - i);
  47828. var _ = o.byteOffset + s
  47829. , b = _ + c
  47830. , k = c + 3 & -4;
  47831. if (k !== c) {
  47832. var j = new Uint8Array(o.buffer.slice(_, b));
  47833. o = new Uint8Array(k),
  47834. o.set(j),
  47835. s = 0,
  47836. _ = 0,
  47837. b = k,
  47838. c = k
  47839. }
  47840. for (var $ = 1024 * 1024 * 15, _e = 0; b - (_ + _e) > $; )
  47841. this._device.queue.writeBuffer(d, i + _e, o.buffer, _ + _e, $),
  47842. _e += $;
  47843. this._device.queue.writeBuffer(d, i + _e, o.buffer, _ + _e, c - _e)
  47844. }
  47845. ,
  47846. a.prototype._GetHalfFloatAsFloatRGBAArrayBuffer = function(e, i, o) {
  47847. o || (o = new Float32Array(e));
  47848. for (var s = new Uint16Array(i); e--; )
  47849. o[e] = FromHalfFloat(s[e]);
  47850. return o
  47851. }
  47852. ,
  47853. a.prototype.readDataFromBuffer = function(e, i, o, s, c, d, _, b, k, j, $) {
  47854. var _e = this;
  47855. _ === void 0 && (_ = 0),
  47856. b === void 0 && (b = 0),
  47857. k === void 0 && (k = null),
  47858. j === void 0 && (j = !0),
  47859. $ === void 0 && ($ = !1);
  47860. var et = _ === 1 ? 2 : _ === 2 ? 1 : 0;
  47861. return new Promise(function(tt, rt) {
  47862. e.mapAsync(MapMode.Read, b, i).then(function() {
  47863. var it = e.getMappedRange(b, i)
  47864. , nt = k;
  47865. if ($)
  47866. nt === null ? nt = allocateAndCopyTypedBuffer(_, i, !0, it) : nt = allocateAndCopyTypedBuffer(_, nt.buffer, void 0, it);
  47867. else if (nt === null)
  47868. switch (et) {
  47869. case 0:
  47870. nt = new Uint8Array(i),
  47871. nt.set(new Uint8Array(it));
  47872. break;
  47873. case 1:
  47874. nt = _e._GetHalfFloatAsFloatRGBAArrayBuffer(i / 2, it);
  47875. break;
  47876. case 2:
  47877. nt = new Float32Array(i / 4),
  47878. nt.set(new Float32Array(it));
  47879. break
  47880. }
  47881. else
  47882. switch (et) {
  47883. case 0:
  47884. nt = new Uint8Array(nt.buffer),
  47885. nt.set(new Uint8Array(it));
  47886. break;
  47887. case 1:
  47888. nt = _e._GetHalfFloatAsFloatRGBAArrayBuffer(i / 2, it, k);
  47889. break;
  47890. case 2:
  47891. nt = new Float32Array(nt.buffer),
  47892. nt.set(new Float32Array(it));
  47893. break
  47894. }
  47895. if (c !== d) {
  47896. et === 1 && !$ && (c *= 2,
  47897. d *= 2);
  47898. for (var ot = new Uint8Array(nt.buffer), at = c, st = 0, ut = 1; ut < s; ++ut) {
  47899. st = ut * d;
  47900. for (var ct = 0; ct < c; ++ct)
  47901. ot[at++] = ot[st++]
  47902. }
  47903. et !== 0 && !$ ? nt = new Float32Array(ot.buffer,0,at / 4) : nt = new Uint8Array(ot.buffer,0,at)
  47904. }
  47905. e.unmap(),
  47906. j && _e.releaseBuffer(e),
  47907. tt(nt)
  47908. }, function(it) {
  47909. return rt(it)
  47910. })
  47911. }
  47912. )
  47913. }
  47914. ,
  47915. a.prototype.releaseBuffer = function(e) {
  47916. return a._IsGPUBuffer(e) ? (this._deferredReleaseBuffers.push(e),
  47917. !0) : (e.references--,
  47918. e.references === 0 ? (this._deferredReleaseBuffers.push(e.underlyingResource),
  47919. !0) : !1)
  47920. }
  47921. ,
  47922. a.prototype.destroyDeferredBuffers = function() {
  47923. for (var e = 0; e < this._deferredReleaseBuffers.length; ++e)
  47924. this._deferredReleaseBuffers[e].destroy();
  47925. this._deferredReleaseBuffers.length = 0
  47926. }
  47927. ,
  47928. a
  47929. }(), WebGPURenderPassWrapper = function() {
  47930. function a() {
  47931. this.colorAttachmentGPUTextures = [],
  47932. this.reset()
  47933. }
  47934. return a.prototype.reset = function(e) {
  47935. e === void 0 && (e = !1),
  47936. this.renderPass = null,
  47937. e && (this.renderPassDescriptor = null,
  47938. this.colorAttachmentViewDescriptor = null,
  47939. this.depthAttachmentViewDescriptor = null,
  47940. this.colorAttachmentGPUTextures = [],
  47941. this.depthTextureFormat = void 0)
  47942. }
  47943. ,
  47944. a
  47945. }(), filterToBits = [0 | 0 << 1 | 0 << 2, 0 | 0 << 1 | 0 << 2, 1 | 1 << 1 | 0 << 2, 1 | 1 << 1 | 1 << 2, 0 | 0 << 1 | 0 << 2, 0 | 1 << 1 | 0 << 2, 0 | 1 << 1 | 1 << 2, 0 | 1 << 1 | 0 << 2, 0 | 0 << 1 | 1 << 2, 1 | 0 << 1 | 0 << 2, 1 | 0 << 1 | 1 << 2, 1 | 1 << 1 | 0 << 2, 1 | 0 << 1 | 0 << 2], comparisonFunctionToBits = [0 << 3 | 0 << 4 | 0 << 5 | 0 << 6, 0 << 3 | 0 << 4 | 0 << 5 | 1 << 6, 0 << 3 | 0 << 4 | 1 << 5 | 0 << 6, 0 << 3 | 0 << 4 | 1 << 5 | 1 << 6, 0 << 3 | 1 << 4 | 0 << 5 | 0 << 6, 0 << 3 | 1 << 4 | 0 << 5 | 1 << 6, 0 << 3 | 1 << 4 | 1 << 5 | 0 << 6, 0 << 3 | 1 << 4 | 1 << 5 | 1 << 6, 1 << 3 | 0 << 4 | 0 << 5 | 0 << 6], filterNoMipToBits = [0 << 7, 1 << 7, 1 << 7, 0 << 7, 0 << 7, 0 << 7, 0 << 7, 1 << 7, 0 << 7, 0 << 7, 0 << 7, 0 << 7, 1 << 7], WebGPUCacheSampler = function() {
  47946. function a(e) {
  47947. this._samplers = {},
  47948. this._device = e,
  47949. this.disabled = !1
  47950. }
  47951. return a.GetSamplerHashCode = function(e) {
  47952. var i, o, s, c = e._cachedAnisotropicFilteringLevel && e._cachedAnisotropicFilteringLevel > 1 ? 4 : 1, d = filterToBits[e.samplingMode] + comparisonFunctionToBits[(e._comparisonFunction || 514) - 512 + 1] + filterNoMipToBits[e.samplingMode] + (((i = e._cachedWrapU) !== null && i !== void 0 ? i : 1) << 8) + (((o = e._cachedWrapV) !== null && o !== void 0 ? o : 1) << 10) + (((s = e._cachedWrapR) !== null && s !== void 0 ? s : 1) << 12) + ((e.useMipMaps ? 1 : 0) << 14) + (c << 15);
  47953. return d
  47954. }
  47955. ,
  47956. a._GetSamplerFilterDescriptor = function(e, i) {
  47957. var o, s, c, d, _, b = e.useMipMaps;
  47958. switch (e.samplingMode) {
  47959. case 11:
  47960. o = FilterMode.Linear,
  47961. s = FilterMode.Linear,
  47962. c = FilterMode.Nearest,
  47963. b || (d = _ = 0);
  47964. break;
  47965. case 3:
  47966. case 3:
  47967. o = FilterMode.Linear,
  47968. s = FilterMode.Linear,
  47969. b ? c = FilterMode.Linear : (c = FilterMode.Nearest,
  47970. d = _ = 0);
  47971. break;
  47972. case 8:
  47973. o = FilterMode.Nearest,
  47974. s = FilterMode.Nearest,
  47975. b ? c = FilterMode.Linear : (c = FilterMode.Nearest,
  47976. d = _ = 0);
  47977. break;
  47978. case 4:
  47979. o = FilterMode.Nearest,
  47980. s = FilterMode.Nearest,
  47981. c = FilterMode.Nearest,
  47982. b || (d = _ = 0);
  47983. break;
  47984. case 5:
  47985. o = FilterMode.Nearest,
  47986. s = FilterMode.Linear,
  47987. c = FilterMode.Nearest,
  47988. b || (d = _ = 0);
  47989. break;
  47990. case 6:
  47991. o = FilterMode.Nearest,
  47992. s = FilterMode.Linear,
  47993. b ? c = FilterMode.Linear : (c = FilterMode.Nearest,
  47994. d = _ = 0);
  47995. break;
  47996. case 7:
  47997. o = FilterMode.Nearest,
  47998. s = FilterMode.Linear,
  47999. c = FilterMode.Nearest,
  48000. d = _ = 0;
  48001. break;
  48002. case 1:
  48003. case 1:
  48004. o = FilterMode.Nearest,
  48005. s = FilterMode.Nearest,
  48006. c = FilterMode.Nearest,
  48007. d = _ = 0;
  48008. break;
  48009. case 9:
  48010. o = FilterMode.Linear,
  48011. s = FilterMode.Nearest,
  48012. c = FilterMode.Nearest,
  48013. b || (d = _ = 0);
  48014. break;
  48015. case 10:
  48016. o = FilterMode.Linear,
  48017. s = FilterMode.Nearest,
  48018. b ? c = FilterMode.Linear : (c = FilterMode.Nearest,
  48019. d = _ = 0);
  48020. break;
  48021. case 2:
  48022. case 2:
  48023. o = FilterMode.Linear,
  48024. s = FilterMode.Linear,
  48025. c = FilterMode.Nearest,
  48026. d = _ = 0;
  48027. break;
  48028. case 12:
  48029. o = FilterMode.Linear,
  48030. s = FilterMode.Nearest,
  48031. c = FilterMode.Nearest,
  48032. d = _ = 0;
  48033. break;
  48034. default:
  48035. o = FilterMode.Nearest,
  48036. s = FilterMode.Nearest,
  48037. c = FilterMode.Nearest,
  48038. d = _ = 0;
  48039. break
  48040. }
  48041. return i > 1 && (d !== 0 || _ !== 0) ? {
  48042. magFilter: FilterMode.Linear,
  48043. minFilter: FilterMode.Linear,
  48044. mipmapFilter: FilterMode.Linear,
  48045. anisotropyEnabled: !0
  48046. } : {
  48047. magFilter: o,
  48048. minFilter: s,
  48049. mipmapFilter: c,
  48050. lodMinClamp: d,
  48051. lodMaxClamp: _
  48052. }
  48053. }
  48054. ,
  48055. a._GetWrappingMode = function(e) {
  48056. switch (e) {
  48057. case 1:
  48058. return AddressMode.Repeat;
  48059. case 0:
  48060. return AddressMode.ClampToEdge;
  48061. case 2:
  48062. return AddressMode.MirrorRepeat
  48063. }
  48064. return AddressMode.Repeat
  48065. }
  48066. ,
  48067. a._GetSamplerWrappingDescriptor = function(e) {
  48068. return {
  48069. addressModeU: this._GetWrappingMode(e._cachedWrapU),
  48070. addressModeV: this._GetWrappingMode(e._cachedWrapV),
  48071. addressModeW: this._GetWrappingMode(e._cachedWrapR)
  48072. }
  48073. }
  48074. ,
  48075. a._GetSamplerDescriptor = function(e) {
  48076. var i = e.useMipMaps && e._cachedAnisotropicFilteringLevel && e._cachedAnisotropicFilteringLevel > 1 ? 4 : 1
  48077. , o = this._GetSamplerFilterDescriptor(e, i);
  48078. return __assign(__assign(__assign({}, o), this._GetSamplerWrappingDescriptor(e)), {
  48079. compare: e._comparisonFunction ? WebGPUTextureHelper.GetCompareFunction(e._comparisonFunction) : void 0,
  48080. maxAnisotropy: o.anisotropyEnabled ? i : 1
  48081. })
  48082. }
  48083. ,
  48084. a.prototype.getSampler = function(e, i, o) {
  48085. if (i === void 0 && (i = !1),
  48086. o === void 0 && (o = 0),
  48087. this.disabled)
  48088. return this._device.createSampler(a._GetSamplerDescriptor(e));
  48089. i ? o = 0 : o === 0 && (o = a.GetSamplerHashCode(e));
  48090. var s = i ? void 0 : this._samplers[o];
  48091. return s || (s = this._device.createSampler(a._GetSamplerDescriptor(e)),
  48092. i || (this._samplers[o] = s)),
  48093. s
  48094. }
  48095. ,
  48096. a
  48097. }(), StatePosition;
  48098. (function(a) {
  48099. a[a.StencilReadMask = 0] = "StencilReadMask",
  48100. a[a.StencilWriteMask = 1] = "StencilWriteMask",
  48101. a[a.DepthBias = 2] = "DepthBias",
  48102. a[a.DepthBiasSlopeScale = 3] = "DepthBiasSlopeScale",
  48103. a[a.MRTAttachments1 = 4] = "MRTAttachments1",
  48104. a[a.MRTAttachments2 = 5] = "MRTAttachments2",
  48105. a[a.DepthStencilState = 6] = "DepthStencilState",
  48106. a[a.RasterizationState = 7] = "RasterizationState",
  48107. a[a.ColorStates = 8] = "ColorStates",
  48108. a[a.ShaderStage = 9] = "ShaderStage",
  48109. a[a.TextureStage = 10] = "TextureStage",
  48110. a[a.VertexState = 11] = "VertexState",
  48111. a[a.NumStates = 12] = "NumStates"
  48112. }
  48113. )(StatePosition || (StatePosition = {}));
  48114. var textureFormatToIndex = {
  48115. "": 0,
  48116. r8unorm: 1,
  48117. r8uint: 2,
  48118. r8sint: 3,
  48119. r16uint: 4,
  48120. r16sint: 5,
  48121. r16float: 6,
  48122. rg8unorm: 7,
  48123. rg8uint: 8,
  48124. rg8sint: 9,
  48125. r32uint: 10,
  48126. r32sint: 11,
  48127. r32float: 12,
  48128. rg16uint: 13,
  48129. rg16sint: 14,
  48130. rg16float: 15,
  48131. rgba8unorm: 16,
  48132. "rgba8unorm-srgb": 17,
  48133. rgba8uint: 18,
  48134. rgba8sint: 19,
  48135. bgra8unorm: 20,
  48136. "bgra8unorm-srgb": 21,
  48137. rgb10a2unorm: 22,
  48138. rg32uint: 23,
  48139. rg32sint: 24,
  48140. rg32float: 25,
  48141. rgba16uint: 26,
  48142. rgba16sint: 27,
  48143. rgba16float: 28,
  48144. rgba32uint: 29,
  48145. rgba32sint: 30,
  48146. rgba32float: 31,
  48147. stencil8: 32,
  48148. depth16unorm: 33,
  48149. depth24plus: 34,
  48150. "depth24plus-stencil8": 35,
  48151. depth32float: 36,
  48152. "depth24unorm-stencil8": 37,
  48153. "depth32float-stencil8": 38
  48154. }
  48155. , alphaBlendFactorToIndex = {
  48156. 0: 1,
  48157. 1: 2,
  48158. 768: 3,
  48159. 769: 4,
  48160. 770: 5,
  48161. 771: 6,
  48162. 772: 7,
  48163. 773: 8,
  48164. 774: 9,
  48165. 775: 10,
  48166. 776: 11,
  48167. 32769: 12,
  48168. 32770: 13,
  48169. 32771: 12,
  48170. 32772: 13
  48171. }
  48172. , stencilOpToIndex = {
  48173. 0: 0,
  48174. 7680: 1,
  48175. 7681: 2,
  48176. 7682: 3,
  48177. 7683: 4,
  48178. 5386: 5,
  48179. 34055: 6,
  48180. 34056: 7
  48181. }
  48182. , WebGPUCacheRenderPipeline = function() {
  48183. function a(e, i, o) {
  48184. this._device = e,
  48185. this._useTextureStage = o,
  48186. this._states = new Array(30),
  48187. this._statesLength = 0,
  48188. this._stateDirtyLowestIndex = 0,
  48189. this._emptyVertexBuffer = i,
  48190. this._mrtFormats = [],
  48191. this._parameter = {
  48192. token: void 0,
  48193. pipeline: null
  48194. },
  48195. this.disabled = !1,
  48196. this.vertexBuffers = [],
  48197. this._kMaxVertexBufferStride = e.limits.maxVertexBufferArrayStride || 2048,
  48198. this.reset()
  48199. }
  48200. return a.prototype.reset = function() {
  48201. this._isDirty = !0,
  48202. this.vertexBuffers.length = 0,
  48203. this.setAlphaToCoverage(!1),
  48204. this.resetDepthCullingState(),
  48205. this.setClampDepth(!1),
  48206. this.setDepthBias(0),
  48207. this._webgpuColorFormat = [TextureFormat.BGRA8Unorm],
  48208. this.setColorFormat(TextureFormat.BGRA8Unorm),
  48209. this.setMRTAttachments([], []),
  48210. this.setAlphaBlendEnabled(!1),
  48211. this.setAlphaBlendFactors([null, null, null, null], [null, null]),
  48212. this.setWriteMask(15),
  48213. this.setDepthStencilFormat(TextureFormat.Depth24PlusStencil8),
  48214. this.setStencilEnabled(!1),
  48215. this.resetStencilState(),
  48216. this.setBuffers(null, null, null),
  48217. this._setTextureState(0)
  48218. }
  48219. ,
  48220. Object.defineProperty(a.prototype, "colorFormats", {
  48221. get: function() {
  48222. return this._mrtAttachments1 > 0 ? this._mrtFormats : this._webgpuColorFormat
  48223. },
  48224. enumerable: !1,
  48225. configurable: !0
  48226. }),
  48227. a.prototype.getRenderPipeline = function(e, i, o, s) {
  48228. if (s === void 0 && (s = 0),
  48229. this.disabled) {
  48230. var c = a._GetTopology(e);
  48231. return this._setVertexState(i),
  48232. this._parameter.pipeline = this._createRenderPipeline(i, c, o),
  48233. a.NumCacheMiss++,
  48234. a._NumPipelineCreationCurrentFrame++,
  48235. this._parameter.pipeline
  48236. }
  48237. if (this._setShaderStage(i.uniqueId),
  48238. this._setRasterizationState(e, o),
  48239. this._setColorStates(),
  48240. this._setDepthStencilState(),
  48241. this._setVertexState(i),
  48242. this._setTextureState(s),
  48243. this.lastStateDirtyLowestIndex = this._stateDirtyLowestIndex,
  48244. !this._isDirty && this._parameter.pipeline)
  48245. return this._stateDirtyLowestIndex = this._statesLength,
  48246. a.NumCacheHitWithoutHash++,
  48247. this._parameter.pipeline;
  48248. if (this._getRenderPipeline(this._parameter),
  48249. this._isDirty = !1,
  48250. this._stateDirtyLowestIndex = this._statesLength,
  48251. this._parameter.pipeline)
  48252. return a.NumCacheHitWithHash++,
  48253. this._parameter.pipeline;
  48254. var d = a._GetTopology(e);
  48255. return this._parameter.pipeline = this._createRenderPipeline(i, d, o),
  48256. this._setRenderPipeline(this._parameter),
  48257. a.NumCacheMiss++,
  48258. a._NumPipelineCreationCurrentFrame++,
  48259. this._parameter.pipeline
  48260. }
  48261. ,
  48262. a.prototype.endFrame = function() {
  48263. a.NumPipelineCreationLastFrame = a._NumPipelineCreationCurrentFrame,
  48264. a._NumPipelineCreationCurrentFrame = 0
  48265. }
  48266. ,
  48267. a.prototype.setAlphaToCoverage = function(e) {
  48268. this._alphaToCoverageEnabled = e
  48269. }
  48270. ,
  48271. a.prototype.setFrontFace = function(e) {
  48272. this._frontFace = e
  48273. }
  48274. ,
  48275. a.prototype.setCullEnabled = function(e) {
  48276. this._cullEnabled = e
  48277. }
  48278. ,
  48279. a.prototype.setCullFace = function(e) {
  48280. this._cullFace = e
  48281. }
  48282. ,
  48283. a.prototype.setClampDepth = function(e) {
  48284. this._clampDepth = e
  48285. }
  48286. ,
  48287. a.prototype.resetDepthCullingState = function() {
  48288. this.setDepthCullingState(!1, 2, 1, 0, 0, !0, !0, 519)
  48289. }
  48290. ,
  48291. a.prototype.setDepthCullingState = function(e, i, o, s, c, d, _, b) {
  48292. this._depthWriteEnabled = _,
  48293. this._depthTestEnabled = d,
  48294. this._depthCompare = (b != null ? b : 519) - 512,
  48295. this._cullFace = o,
  48296. this._cullEnabled = e,
  48297. this._frontFace = i,
  48298. this.setDepthBiasSlopeScale(s),
  48299. this.setDepthBias(c)
  48300. }
  48301. ,
  48302. a.prototype.setDepthBias = function(e) {
  48303. this._depthBias !== e && (this._depthBias = e,
  48304. this._states[StatePosition.DepthBias] = e,
  48305. this._isDirty = !0,
  48306. this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, StatePosition.DepthBias))
  48307. }
  48308. ,
  48309. a.prototype.setDepthBiasSlopeScale = function(e) {
  48310. this._depthBiasSlopeScale !== e && (this._depthBiasSlopeScale = e,
  48311. this._states[StatePosition.DepthBiasSlopeScale] = e,
  48312. this._isDirty = !0,
  48313. this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, StatePosition.DepthBiasSlopeScale))
  48314. }
  48315. ,
  48316. a.prototype.setColorFormat = function(e) {
  48317. this._webgpuColorFormat[0] = e,
  48318. this._colorFormat = textureFormatToIndex[e]
  48319. }
  48320. ,
  48321. a.prototype.setMRTAttachments = function(e, i) {
  48322. var o;
  48323. if (e.length > 10)
  48324. throw "Can't handle more than 10 attachments for a MRT in cache render pipeline!";
  48325. this.mrtAttachments = e,
  48326. this.mrtTextureArray = i;
  48327. for (var s = [0, 0], c = 0, d = 0, _ = 0, b = 0; b < e.length; ++b) {
  48328. var k = e[b];
  48329. if (k !== 0) {
  48330. var j = i[k - 1]
  48331. , $ = j == null ? void 0 : j._hardwareTexture;
  48332. this._mrtFormats[_] = (o = $ == null ? void 0 : $.format) !== null && o !== void 0 ? o : this._webgpuColorFormat[0],
  48333. s[c] += textureFormatToIndex[this._mrtFormats[_]] << d,
  48334. d += 6,
  48335. _++,
  48336. d >= 32 && (d = 0,
  48337. c++)
  48338. }
  48339. }
  48340. this._mrtFormats.length = _,
  48341. (this._mrtAttachments1 !== s[0] || this._mrtAttachments2 !== s[1]) && (this._mrtAttachments1 = s[0],
  48342. this._mrtAttachments2 = s[1],
  48343. this._states[StatePosition.MRTAttachments1] = s[0],
  48344. this._states[StatePosition.MRTAttachments2] = s[1],
  48345. this._isDirty = !0,
  48346. this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, StatePosition.MRTAttachments1))
  48347. }
  48348. ,
  48349. a.prototype.setAlphaBlendEnabled = function(e) {
  48350. this._alphaBlendEnabled = e
  48351. }
  48352. ,
  48353. a.prototype.setAlphaBlendFactors = function(e, i) {
  48354. this._alphaBlendFuncParams = e,
  48355. this._alphaBlendEqParams = i
  48356. }
  48357. ,
  48358. a.prototype.setWriteMask = function(e) {
  48359. this._writeMask = e
  48360. }
  48361. ,
  48362. a.prototype.setDepthStencilFormat = function(e) {
  48363. this._webgpuDepthStencilFormat = e,
  48364. this._depthStencilFormat = e === void 0 ? 0 : textureFormatToIndex[e]
  48365. }
  48366. ,
  48367. a.prototype.setDepthTestEnabled = function(e) {
  48368. this._depthTestEnabled = e
  48369. }
  48370. ,
  48371. a.prototype.setDepthWriteEnabled = function(e) {
  48372. this._depthWriteEnabled = e
  48373. }
  48374. ,
  48375. a.prototype.setDepthCompare = function(e) {
  48376. this._depthCompare = (e != null ? e : 519) - 512
  48377. }
  48378. ,
  48379. a.prototype.setStencilEnabled = function(e) {
  48380. this._stencilEnabled = e
  48381. }
  48382. ,
  48383. a.prototype.setStencilCompare = function(e) {
  48384. this._stencilFrontCompare = (e != null ? e : 519) - 512
  48385. }
  48386. ,
  48387. a.prototype.setStencilDepthFailOp = function(e) {
  48388. this._stencilFrontDepthFailOp = e === null ? 1 : stencilOpToIndex[e]
  48389. }
  48390. ,
  48391. a.prototype.setStencilPassOp = function(e) {
  48392. this._stencilFrontPassOp = e === null ? 2 : stencilOpToIndex[e]
  48393. }
  48394. ,
  48395. a.prototype.setStencilFailOp = function(e) {
  48396. this._stencilFrontFailOp = e === null ? 1 : stencilOpToIndex[e]
  48397. }
  48398. ,
  48399. a.prototype.setStencilReadMask = function(e) {
  48400. this._stencilReadMask !== e && (this._stencilReadMask = e,
  48401. this._states[StatePosition.StencilReadMask] = e,
  48402. this._isDirty = !0,
  48403. this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, StatePosition.StencilReadMask))
  48404. }
  48405. ,
  48406. a.prototype.setStencilWriteMask = function(e) {
  48407. this._stencilWriteMask !== e && (this._stencilWriteMask = e,
  48408. this._states[StatePosition.StencilWriteMask] = e,
  48409. this._isDirty = !0,
  48410. this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, StatePosition.StencilWriteMask))
  48411. }
  48412. ,
  48413. a.prototype.resetStencilState = function() {
  48414. this.setStencilState(!1, 519, 7680, 7681, 7680, 255, 255)
  48415. }
  48416. ,
  48417. a.prototype.setStencilState = function(e, i, o, s, c, d, _) {
  48418. this._stencilEnabled = e,
  48419. this._stencilFrontCompare = (i != null ? i : 519) - 512,
  48420. this._stencilFrontDepthFailOp = o === null ? 1 : stencilOpToIndex[o],
  48421. this._stencilFrontPassOp = s === null ? 2 : stencilOpToIndex[s],
  48422. this._stencilFrontFailOp = c === null ? 1 : stencilOpToIndex[c],
  48423. this.setStencilReadMask(d),
  48424. this.setStencilWriteMask(_)
  48425. }
  48426. ,
  48427. a.prototype.setBuffers = function(e, i, o) {
  48428. this._vertexBuffers = e,
  48429. this._overrideVertexBuffers = o,
  48430. this._indexBuffer = i
  48431. }
  48432. ,
  48433. a._GetTopology = function(e) {
  48434. switch (e) {
  48435. case 0:
  48436. return PrimitiveTopology.TriangleList;
  48437. case 2:
  48438. return PrimitiveTopology.PointList;
  48439. case 1:
  48440. return PrimitiveTopology.LineList;
  48441. case 3:
  48442. return PrimitiveTopology.PointList;
  48443. case 4:
  48444. return PrimitiveTopology.LineList;
  48445. case 5:
  48446. throw "LineLoop is an unsupported fillmode in WebGPU";
  48447. case 6:
  48448. return PrimitiveTopology.LineStrip;
  48449. case 7:
  48450. return PrimitiveTopology.TriangleStrip;
  48451. case 8:
  48452. throw "TriangleFan is an unsupported fillmode in WebGPU";
  48453. default:
  48454. return PrimitiveTopology.TriangleList
  48455. }
  48456. }
  48457. ,
  48458. a._GetAphaBlendOperation = function(e) {
  48459. switch (e) {
  48460. case 32774:
  48461. return BlendOperation.Add;
  48462. case 32778:
  48463. return BlendOperation.Subtract;
  48464. case 32779:
  48465. return BlendOperation.ReverseSubtract;
  48466. case 32775:
  48467. return BlendOperation.Min;
  48468. case 32776:
  48469. return BlendOperation.Max;
  48470. default:
  48471. return BlendOperation.Add
  48472. }
  48473. }
  48474. ,
  48475. a._GetAphaBlendFactor = function(e) {
  48476. switch (e) {
  48477. case 0:
  48478. return BlendFactor.Zero;
  48479. case 1:
  48480. return BlendFactor.One;
  48481. case 768:
  48482. return BlendFactor.Src;
  48483. case 769:
  48484. return BlendFactor.OneMinusSrc;
  48485. case 770:
  48486. return BlendFactor.SrcAlpha;
  48487. case 771:
  48488. return BlendFactor.OneMinusSrcAlpha;
  48489. case 772:
  48490. return BlendFactor.DstAlpha;
  48491. case 773:
  48492. return BlendFactor.OneMinusDstAlpha;
  48493. case 774:
  48494. return BlendFactor.Dst;
  48495. case 775:
  48496. return BlendFactor.OneMinusDst;
  48497. case 776:
  48498. return BlendFactor.SrcAlphaSaturated;
  48499. case 32769:
  48500. return BlendFactor.Constant;
  48501. case 32770:
  48502. return BlendFactor.OneMinusConstant;
  48503. case 32771:
  48504. return BlendFactor.Constant;
  48505. case 32772:
  48506. return BlendFactor.OneMinusConstant;
  48507. default:
  48508. return BlendFactor.One
  48509. }
  48510. }
  48511. ,
  48512. a._GetCompareFunction = function(e) {
  48513. switch (e) {
  48514. case 0:
  48515. return CompareFunction.Never;
  48516. case 1:
  48517. return CompareFunction.Less;
  48518. case 2:
  48519. return CompareFunction.Equal;
  48520. case 3:
  48521. return CompareFunction.LessEqual;
  48522. case 4:
  48523. return CompareFunction.Greater;
  48524. case 5:
  48525. return CompareFunction.NotEqual;
  48526. case 6:
  48527. return CompareFunction.GreaterEqual;
  48528. case 7:
  48529. return CompareFunction.Always
  48530. }
  48531. return CompareFunction.Never
  48532. }
  48533. ,
  48534. a._GetStencilOpFunction = function(e) {
  48535. switch (e) {
  48536. case 0:
  48537. return StencilOperation.Zero;
  48538. case 1:
  48539. return StencilOperation.Keep;
  48540. case 2:
  48541. return StencilOperation.Replace;
  48542. case 3:
  48543. return StencilOperation.IncrementClamp;
  48544. case 4:
  48545. return StencilOperation.DecrementClamp;
  48546. case 5:
  48547. return StencilOperation.Invert;
  48548. case 6:
  48549. return StencilOperation.IncrementWrap;
  48550. case 7:
  48551. return StencilOperation.DecrementWrap
  48552. }
  48553. return StencilOperation.Keep
  48554. }
  48555. ,
  48556. a._GetVertexInputDescriptorFormat = function(e) {
  48557. var i = e.type
  48558. , o = e.normalized
  48559. , s = e.getSize();
  48560. switch (i) {
  48561. case VertexBuffer.BYTE:
  48562. switch (s) {
  48563. case 1:
  48564. case 2:
  48565. return o ? VertexFormat.Snorm8x2 : VertexFormat.Sint8x2;
  48566. case 3:
  48567. case 4:
  48568. return o ? VertexFormat.Snorm8x4 : VertexFormat.Sint8x4
  48569. }
  48570. break;
  48571. case VertexBuffer.UNSIGNED_BYTE:
  48572. switch (s) {
  48573. case 1:
  48574. case 2:
  48575. return o ? VertexFormat.Unorm8x2 : VertexFormat.Uint8x2;
  48576. case 3:
  48577. case 4:
  48578. return o ? VertexFormat.Unorm8x4 : VertexFormat.Uint8x4
  48579. }
  48580. break;
  48581. case VertexBuffer.SHORT:
  48582. switch (s) {
  48583. case 1:
  48584. case 2:
  48585. return o ? VertexFormat.Snorm16x2 : VertexFormat.Sint16x2;
  48586. case 3:
  48587. case 4:
  48588. return o ? VertexFormat.Snorm16x4 : VertexFormat.Sint16x4
  48589. }
  48590. break;
  48591. case VertexBuffer.UNSIGNED_SHORT:
  48592. switch (s) {
  48593. case 1:
  48594. case 2:
  48595. return o ? VertexFormat.Unorm16x2 : VertexFormat.Uint16x2;
  48596. case 3:
  48597. case 4:
  48598. return o ? VertexFormat.Unorm16x4 : VertexFormat.Uint16x4
  48599. }
  48600. break;
  48601. case VertexBuffer.INT:
  48602. switch (s) {
  48603. case 1:
  48604. return VertexFormat.Sint32;
  48605. case 2:
  48606. return VertexFormat.Sint32x2;
  48607. case 3:
  48608. return VertexFormat.Sint32x3;
  48609. case 4:
  48610. return VertexFormat.Sint32x4
  48611. }
  48612. break;
  48613. case VertexBuffer.UNSIGNED_INT:
  48614. switch (s) {
  48615. case 1:
  48616. return VertexFormat.Uint32;
  48617. case 2:
  48618. return VertexFormat.Uint32x2;
  48619. case 3:
  48620. return VertexFormat.Uint32x3;
  48621. case 4:
  48622. return VertexFormat.Uint32x4
  48623. }
  48624. break;
  48625. case VertexBuffer.FLOAT:
  48626. switch (s) {
  48627. case 1:
  48628. return VertexFormat.Float32;
  48629. case 2:
  48630. return VertexFormat.Float32x2;
  48631. case 3:
  48632. return VertexFormat.Float32x3;
  48633. case 4:
  48634. return VertexFormat.Float32x4
  48635. }
  48636. break
  48637. }
  48638. throw new Error("Invalid Format '" + e.getKind() + "' - type=" + i + ", normalized=" + o + ", size=" + s)
  48639. }
  48640. ,
  48641. a.prototype._getAphaBlendState = function() {
  48642. return this._alphaBlendEnabled ? {
  48643. srcFactor: a._GetAphaBlendFactor(this._alphaBlendFuncParams[2]),
  48644. dstFactor: a._GetAphaBlendFactor(this._alphaBlendFuncParams[3]),
  48645. operation: a._GetAphaBlendOperation(this._alphaBlendEqParams[1])
  48646. } : null
  48647. }
  48648. ,
  48649. a.prototype._getColorBlendState = function() {
  48650. return this._alphaBlendEnabled ? {
  48651. srcFactor: a._GetAphaBlendFactor(this._alphaBlendFuncParams[0]),
  48652. dstFactor: a._GetAphaBlendFactor(this._alphaBlendFuncParams[1]),
  48653. operation: a._GetAphaBlendOperation(this._alphaBlendEqParams[0])
  48654. } : null
  48655. }
  48656. ,
  48657. a.prototype._setShaderStage = function(e) {
  48658. this._shaderId !== e && (this._shaderId = e,
  48659. this._states[StatePosition.ShaderStage] = e,
  48660. this._isDirty = !0,
  48661. this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, StatePosition.ShaderStage))
  48662. }
  48663. ,
  48664. a.prototype._setRasterizationState = function(e, i) {
  48665. var o = this._frontFace
  48666. , s = this._cullEnabled ? this._cullFace : 0
  48667. , c = this._clampDepth ? 1 : 0
  48668. , d = this._alphaToCoverageEnabled ? 1 : 0
  48669. , _ = o - 1 + (s << 1) + (c << 3) + (d << 4) + (e << 5) + (i << 8);
  48670. this._rasterizationState !== _ && (this._rasterizationState = _,
  48671. this._states[StatePosition.RasterizationState] = this._rasterizationState,
  48672. this._isDirty = !0,
  48673. this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, StatePosition.RasterizationState))
  48674. }
  48675. ,
  48676. a.prototype._setColorStates = function() {
  48677. var e = ((this._writeMask ? 1 : 0) << 22) + (this._colorFormat << 23) + ((this._depthWriteEnabled ? 1 : 0) << 29);
  48678. this._alphaBlendEnabled && (e += ((this._alphaBlendFuncParams[0] === null ? 2 : alphaBlendFactorToIndex[this._alphaBlendFuncParams[0]]) << 0) + ((this._alphaBlendFuncParams[1] === null ? 2 : alphaBlendFactorToIndex[this._alphaBlendFuncParams[1]]) << 4) + ((this._alphaBlendFuncParams[2] === null ? 2 : alphaBlendFactorToIndex[this._alphaBlendFuncParams[2]]) << 8) + ((this._alphaBlendFuncParams[3] === null ? 2 : alphaBlendFactorToIndex[this._alphaBlendFuncParams[3]]) << 12) + ((this._alphaBlendEqParams[0] === null ? 1 : this._alphaBlendEqParams[0] - 32773) << 16) + ((this._alphaBlendEqParams[1] === null ? 1 : this._alphaBlendEqParams[1] - 32773) << 19)),
  48679. e !== this._colorStates && (this._colorStates = e,
  48680. this._states[StatePosition.ColorStates] = this._colorStates,
  48681. this._isDirty = !0,
  48682. this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, StatePosition.ColorStates))
  48683. }
  48684. ,
  48685. a.prototype._setDepthStencilState = function() {
  48686. var e = this._stencilEnabled ? this._stencilFrontCompare + (this._stencilFrontDepthFailOp << 3) + (this._stencilFrontPassOp << 6) + (this._stencilFrontFailOp << 9) : 591
  48687. , i = this._depthStencilFormat + ((this._depthTestEnabled ? this._depthCompare : 7) << 6) + (e << 10);
  48688. this._depthStencilState !== i && (this._depthStencilState = i,
  48689. this._states[StatePosition.DepthStencilState] = this._depthStencilState,
  48690. this._isDirty = !0,
  48691. this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, StatePosition.DepthStencilState))
  48692. }
  48693. ,
  48694. a.prototype._setVertexState = function(e) {
  48695. for (var i, o, s = this._statesLength, c = StatePosition.VertexState, d = e._pipelineContext, _ = d.shaderProcessingContext.attributeNamesFromEffect, b = d.shaderProcessingContext.attributeLocationsFromEffect, k, j = 0, $ = 0; $ < _.length; $++) {
  48696. var _e = b[$]
  48697. , et = (i = this._overrideVertexBuffers && this._overrideVertexBuffers[_[$]]) !== null && i !== void 0 ? i : this._vertexBuffers[_[$]];
  48698. et || (et = this._emptyVertexBuffer);
  48699. var tt = (o = et.getBuffer()) === null || o === void 0 ? void 0 : o.underlyingResource;
  48700. if (et._validOffsetRange === void 0) {
  48701. var rt = et.byteOffset
  48702. , it = et.getSize(!0)
  48703. , nt = et.byteStride;
  48704. et._validOffsetRange = rt <= this._kMaxVertexBufferStride - it && (nt === 0 || rt + it <= nt)
  48705. }
  48706. k && k === tt && et._validOffsetRange || (this.vertexBuffers[j++] = et,
  48707. k = et._validOffsetRange ? tt : null);
  48708. var ot = et.hashCode + (_e << 7);
  48709. this._isDirty = this._isDirty || this._states[c] !== ot,
  48710. this._states[c++] = ot
  48711. }
  48712. this.vertexBuffers.length = j,
  48713. this._statesLength = c,
  48714. this._isDirty = this._isDirty || c !== s,
  48715. this._isDirty && (this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, StatePosition.VertexState))
  48716. }
  48717. ,
  48718. a.prototype._setTextureState = function(e) {
  48719. this._textureState !== e && (this._textureState = e,
  48720. this._states[StatePosition.TextureStage] = this._textureState,
  48721. this._isDirty = !0,
  48722. this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, StatePosition.TextureStage))
  48723. }
  48724. ,
  48725. a.prototype._createPipelineLayout = function(e) {
  48726. if (this._useTextureStage)
  48727. return this._createPipelineLayoutWithTextureStage(e);
  48728. for (var i = [], o = e.shaderProcessingContext.bindGroupLayoutEntries, s = 0; s < o.length; s++) {
  48729. var c = o[s];
  48730. i[s] = this._device.createBindGroupLayout({
  48731. entries: c
  48732. })
  48733. }
  48734. return e.bindGroupLayouts = i,
  48735. this._device.createPipelineLayout({
  48736. bindGroupLayouts: i
  48737. })
  48738. }
  48739. ,
  48740. a.prototype._createPipelineLayoutWithTextureStage = function(e) {
  48741. for (var i, o = e.shaderProcessingContext, s = o.bindGroupLayoutEntries, c = 1, d = 0; d < s.length; d++)
  48742. for (var _ = s[d], b = 0; b < _.length; b++) {
  48743. var k = s[d][b];
  48744. if (k.texture) {
  48745. var j = o.bindGroupLayoutEntryInfo[d][k.binding].name
  48746. , $ = o.availableTextures[j]
  48747. , _e = $.autoBindSampler ? o.availableSamplers[j + WebGPUShaderProcessor.AutoSamplerSuffix] : null
  48748. , et = $.sampleType
  48749. , tt = (i = _e == null ? void 0 : _e.type) !== null && i !== void 0 ? i : SamplerBindingType.Filtering;
  48750. if (this._textureState & c && et !== TextureSampleType.Depth && ($.autoBindSampler && (tt = SamplerBindingType.NonFiltering),
  48751. et = TextureSampleType.UnfilterableFloat),
  48752. k.texture.sampleType = et,
  48753. _e) {
  48754. var rt = o.bindGroupLayoutEntryInfo[_e.binding.groupIndex][_e.binding.bindingIndex].index;
  48755. s[_e.binding.groupIndex][rt].sampler.type = tt
  48756. }
  48757. c = c << 1
  48758. }
  48759. }
  48760. for (var it = [], d = 0; d < s.length; ++d)
  48761. it[d] = this._device.createBindGroupLayout({
  48762. entries: s[d]
  48763. });
  48764. return e.bindGroupLayouts = it,
  48765. this._device.createPipelineLayout({
  48766. bindGroupLayouts: it
  48767. })
  48768. }
  48769. ,
  48770. a.prototype._getVertexInputDescriptor = function(e, i) {
  48771. for (var o, s, c = [], d = e._pipelineContext, _ = d.shaderProcessingContext.attributeNamesFromEffect, b = d.shaderProcessingContext.attributeLocationsFromEffect, k, j, $ = 0; $ < _.length; $++) {
  48772. var _e = b[$]
  48773. , et = (o = this._overrideVertexBuffers && this._overrideVertexBuffers[_[$]]) !== null && o !== void 0 ? o : this._vertexBuffers[_[$]];
  48774. et || (et = this._emptyVertexBuffer);
  48775. var tt = (s = et.getBuffer()) === null || s === void 0 ? void 0 : s.underlyingResource
  48776. , rt = et.byteOffset
  48777. , it = !et._validOffsetRange;
  48778. if (!(k && j && k === tt) || it) {
  48779. var nt = {
  48780. arrayStride: et.byteStride,
  48781. stepMode: et.getIsInstanced() ? InputStepMode.Instance : InputStepMode.Vertex,
  48782. attributes: []
  48783. };
  48784. c.push(nt),
  48785. j = nt.attributes,
  48786. it && (rt = 0,
  48787. tt = null)
  48788. }
  48789. j.push({
  48790. shaderLocation: _e,
  48791. offset: rt,
  48792. format: a._GetVertexInputDescriptorFormat(et)
  48793. }),
  48794. k = tt
  48795. }
  48796. return c
  48797. }
  48798. ,
  48799. a.prototype._createRenderPipeline = function(e, i, o) {
  48800. var s = e._pipelineContext
  48801. , c = this._getVertexInputDescriptor(e, i)
  48802. , d = this._createPipelineLayout(s)
  48803. , _ = []
  48804. , b = this._getAphaBlendState()
  48805. , k = this._getColorBlendState();
  48806. if (this._mrtAttachments1 > 0)
  48807. for (var j = 0; j < this._mrtFormats.length; ++j) {
  48808. var $ = {
  48809. format: this._mrtFormats[j],
  48810. writeMask: this._writeMask
  48811. };
  48812. b && k && ($.blend = {
  48813. alpha: b,
  48814. color: k
  48815. }),
  48816. _.push($)
  48817. }
  48818. else {
  48819. var $ = {
  48820. format: this._webgpuColorFormat[0],
  48821. writeMask: this._writeMask
  48822. };
  48823. b && k && ($.blend = {
  48824. alpha: b,
  48825. color: k
  48826. }),
  48827. _.push($)
  48828. }
  48829. var _e = {
  48830. compare: a._GetCompareFunction(this._stencilEnabled ? this._stencilFrontCompare : 7),
  48831. depthFailOp: a._GetStencilOpFunction(this._stencilEnabled ? this._stencilFrontDepthFailOp : 1),
  48832. failOp: a._GetStencilOpFunction(this._stencilEnabled ? this._stencilFrontFailOp : 1),
  48833. passOp: a._GetStencilOpFunction(this._stencilEnabled ? this._stencilFrontPassOp : 1)
  48834. }
  48835. , et = void 0;
  48836. return (i === PrimitiveTopology.LineStrip || i === PrimitiveTopology.TriangleStrip) && (et = !this._indexBuffer || this._indexBuffer.is32Bits ? IndexFormat.Uint32 : IndexFormat.Uint16),
  48837. this._device.createRenderPipeline({
  48838. layout: d,
  48839. vertex: {
  48840. module: s.stages.vertexStage.module,
  48841. entryPoint: s.stages.vertexStage.entryPoint,
  48842. buffers: c
  48843. },
  48844. primitive: {
  48845. topology: i,
  48846. stripIndexFormat: et,
  48847. frontFace: this._frontFace === 1 ? FrontFace.CCW : FrontFace.CW,
  48848. cullMode: this._cullEnabled ? this._cullFace === 2 ? CullMode.Front : CullMode.Back : CullMode.None
  48849. },
  48850. fragment: s.stages.fragmentStage ? {
  48851. module: s.stages.fragmentStage.module,
  48852. entryPoint: s.stages.fragmentStage.entryPoint,
  48853. targets: _
  48854. } : void 0,
  48855. multisample: {
  48856. count: o
  48857. },
  48858. depthStencil: this._webgpuDepthStencilFormat === void 0 ? void 0 : {
  48859. depthWriteEnabled: this._depthWriteEnabled,
  48860. depthCompare: this._depthTestEnabled ? a._GetCompareFunction(this._depthCompare) : CompareFunction.Always,
  48861. format: this._webgpuDepthStencilFormat,
  48862. stencilFront: _e,
  48863. stencilBack: _e,
  48864. stencilReadMask: this._stencilReadMask,
  48865. stencilWriteMask: this._stencilWriteMask,
  48866. depthBias: this._depthBias,
  48867. depthBiasClamp: this._depthBiasClamp,
  48868. depthBiasSlopeScale: this._depthBiasSlopeScale
  48869. }
  48870. })
  48871. }
  48872. ,
  48873. a.NumCacheHitWithoutHash = 0,
  48874. a.NumCacheHitWithHash = 0,
  48875. a.NumCacheMiss = 0,
  48876. a.NumPipelineCreationLastFrame = 0,
  48877. a._NumPipelineCreationCurrentFrame = 0,
  48878. a
  48879. }()
  48880. , NodeState = function() {
  48881. function a() {
  48882. this.values = {}
  48883. }
  48884. return a.prototype.count = function() {
  48885. var e = 0
  48886. , i = this.pipeline ? 1 : 0;
  48887. for (var o in this.values) {
  48888. var s = this.values[o]
  48889. , c = s.count()
  48890. , d = c[0]
  48891. , _ = c[1];
  48892. e += d,
  48893. i += _,
  48894. e++
  48895. }
  48896. return [e, i]
  48897. }
  48898. ,
  48899. a
  48900. }()
  48901. , WebGPUCacheRenderPipelineTree = function(a) {
  48902. __extends(e, a);
  48903. function e(i, o, s) {
  48904. var c = a.call(this, i, o, s) || this;
  48905. return c._nodeStack = [],
  48906. c._nodeStack[0] = e._Cache,
  48907. c
  48908. }
  48909. return e.GetNodeCounts = function() {
  48910. var i = e._Cache.count();
  48911. return {
  48912. nodeCount: i[0],
  48913. pipelineCount: i[1]
  48914. }
  48915. }
  48916. ,
  48917. e._GetPipelines = function(i, o, s, c) {
  48918. if (i.pipeline) {
  48919. var d = s.slice();
  48920. d.length = c,
  48921. o.push(d)
  48922. }
  48923. for (var _ in i.values) {
  48924. var b = i.values[_];
  48925. s[c] = parseInt(_),
  48926. e._GetPipelines(b, o, s, c + 1)
  48927. }
  48928. }
  48929. ,
  48930. e.GetPipelines = function() {
  48931. var i = [];
  48932. return e._GetPipelines(e._Cache, i, [], 0),
  48933. i
  48934. }
  48935. ,
  48936. e.prototype._getRenderPipeline = function(i) {
  48937. for (var o = this._nodeStack[this._stateDirtyLowestIndex], s = this._stateDirtyLowestIndex; s < this._statesLength; ++s) {
  48938. var c = o.values[this._states[s]];
  48939. c || (c = new NodeState,
  48940. o.values[this._states[s]] = c),
  48941. o = c,
  48942. this._nodeStack[s + 1] = o
  48943. }
  48944. i.token = o,
  48945. i.pipeline = o.pipeline
  48946. }
  48947. ,
  48948. e.prototype._setRenderPipeline = function(i) {
  48949. i.token.pipeline = i.pipeline
  48950. }
  48951. ,
  48952. e._Cache = new NodeState,
  48953. e
  48954. }(WebGPUCacheRenderPipeline)
  48955. , WebGPUStencilStateComposer = function(a) {
  48956. __extends(e, a);
  48957. function e(i) {
  48958. var o = a.call(this, !1) || this;
  48959. return o._cache = i,
  48960. o.reset(),
  48961. o
  48962. }
  48963. return Object.defineProperty(e.prototype, "func", {
  48964. get: function() {
  48965. return this._func
  48966. },
  48967. set: function(i) {
  48968. this._func !== i && (this._func = i,
  48969. this._cache.setStencilCompare(i))
  48970. },
  48971. enumerable: !1,
  48972. configurable: !0
  48973. }),
  48974. Object.defineProperty(e.prototype, "funcMask", {
  48975. get: function() {
  48976. return this._funcMask
  48977. },
  48978. set: function(i) {
  48979. this._funcMask !== i && (this._funcMask = i,
  48980. this._cache.setStencilReadMask(i))
  48981. },
  48982. enumerable: !1,
  48983. configurable: !0
  48984. }),
  48985. Object.defineProperty(e.prototype, "opStencilFail", {
  48986. get: function() {
  48987. return this._opStencilFail
  48988. },
  48989. set: function(i) {
  48990. this._opStencilFail !== i && (this._opStencilFail = i,
  48991. this._cache.setStencilFailOp(i))
  48992. },
  48993. enumerable: !1,
  48994. configurable: !0
  48995. }),
  48996. Object.defineProperty(e.prototype, "opDepthFail", {
  48997. get: function() {
  48998. return this._opDepthFail
  48999. },
  49000. set: function(i) {
  49001. this._opDepthFail !== i && (this._opDepthFail = i,
  49002. this._cache.setStencilDepthFailOp(i))
  49003. },
  49004. enumerable: !1,
  49005. configurable: !0
  49006. }),
  49007. Object.defineProperty(e.prototype, "opStencilDepthPass", {
  49008. get: function() {
  49009. return this._opStencilDepthPass
  49010. },
  49011. set: function(i) {
  49012. this._opStencilDepthPass !== i && (this._opStencilDepthPass = i,
  49013. this._cache.setStencilPassOp(i))
  49014. },
  49015. enumerable: !1,
  49016. configurable: !0
  49017. }),
  49018. Object.defineProperty(e.prototype, "mask", {
  49019. get: function() {
  49020. return this._mask
  49021. },
  49022. set: function(i) {
  49023. this._mask !== i && (this._mask = i,
  49024. this._cache.setStencilWriteMask(i))
  49025. },
  49026. enumerable: !1,
  49027. configurable: !0
  49028. }),
  49029. Object.defineProperty(e.prototype, "enabled", {
  49030. get: function() {
  49031. return this._enabled
  49032. },
  49033. set: function(i) {
  49034. this._enabled !== i && (this._enabled = i,
  49035. this._cache.setStencilEnabled(i))
  49036. },
  49037. enumerable: !1,
  49038. configurable: !0
  49039. }),
  49040. e.prototype.reset = function() {
  49041. a.prototype.reset.call(this),
  49042. this._cache.resetStencilState()
  49043. }
  49044. ,
  49045. e.prototype.apply = function(i) {
  49046. var o, s = (o = this.stencilMaterial) === null || o === void 0 ? void 0 : o.enabled;
  49047. this.enabled = s ? this.stencilMaterial.enabled : this.stencilGlobal.enabled,
  49048. this.enabled && (this.func = s ? this.stencilMaterial.func : this.stencilGlobal.func,
  49049. this.funcRef = s ? this.stencilMaterial.funcRef : this.stencilGlobal.funcRef,
  49050. this.funcMask = s ? this.stencilMaterial.funcMask : this.stencilGlobal.funcMask,
  49051. this.opStencilFail = s ? this.stencilMaterial.opStencilFail : this.stencilGlobal.opStencilFail,
  49052. this.opDepthFail = s ? this.stencilMaterial.opDepthFail : this.stencilGlobal.opDepthFail,
  49053. this.opStencilDepthPass = s ? this.stencilMaterial.opStencilDepthPass : this.stencilGlobal.opStencilDepthPass,
  49054. this.mask = s ? this.stencilMaterial.mask : this.stencilGlobal.mask)
  49055. }
  49056. ,
  49057. e
  49058. }(StencilStateComposer)
  49059. , WebGPUDepthCullingState = function(a) {
  49060. __extends(e, a);
  49061. function e(i) {
  49062. var o = a.call(this, !1) || this;
  49063. return o._cache = i,
  49064. o.reset(),
  49065. o
  49066. }
  49067. return Object.defineProperty(e.prototype, "zOffset", {
  49068. get: function() {
  49069. return this._zOffset
  49070. },
  49071. set: function(i) {
  49072. this._zOffset !== i && (this._zOffset = i,
  49073. this._isZOffsetDirty = !0,
  49074. this._cache.setDepthBiasSlopeScale(i))
  49075. },
  49076. enumerable: !1,
  49077. configurable: !0
  49078. }),
  49079. Object.defineProperty(e.prototype, "zOffsetUnits", {
  49080. get: function() {
  49081. return this._zOffsetUnits
  49082. },
  49083. set: function(i) {
  49084. this._zOffsetUnits !== i && (this._zOffsetUnits = i,
  49085. this._isZOffsetDirty = !0,
  49086. this._cache.setDepthBias(i))
  49087. },
  49088. enumerable: !1,
  49089. configurable: !0
  49090. }),
  49091. Object.defineProperty(e.prototype, "cullFace", {
  49092. get: function() {
  49093. return this._cullFace
  49094. },
  49095. set: function(i) {
  49096. this._cullFace !== i && (this._cullFace = i,
  49097. this._isCullFaceDirty = !0,
  49098. this._cache.setCullFace(i != null ? i : 1))
  49099. },
  49100. enumerable: !1,
  49101. configurable: !0
  49102. }),
  49103. Object.defineProperty(e.prototype, "cull", {
  49104. get: function() {
  49105. return this._cull
  49106. },
  49107. set: function(i) {
  49108. this._cull !== i && (this._cull = i,
  49109. this._isCullDirty = !0,
  49110. this._cache.setCullEnabled(!!i))
  49111. },
  49112. enumerable: !1,
  49113. configurable: !0
  49114. }),
  49115. Object.defineProperty(e.prototype, "depthFunc", {
  49116. get: function() {
  49117. return this._depthFunc
  49118. },
  49119. set: function(i) {
  49120. this._depthFunc !== i && (this._depthFunc = i,
  49121. this._isDepthFuncDirty = !0,
  49122. this._cache.setDepthCompare(i))
  49123. },
  49124. enumerable: !1,
  49125. configurable: !0
  49126. }),
  49127. Object.defineProperty(e.prototype, "depthMask", {
  49128. get: function() {
  49129. return this._depthMask
  49130. },
  49131. set: function(i) {
  49132. this._depthMask !== i && (this._depthMask = i,
  49133. this._isDepthMaskDirty = !0,
  49134. this._cache.setDepthWriteEnabled(i))
  49135. },
  49136. enumerable: !1,
  49137. configurable: !0
  49138. }),
  49139. Object.defineProperty(e.prototype, "depthTest", {
  49140. get: function() {
  49141. return this._depthTest
  49142. },
  49143. set: function(i) {
  49144. this._depthTest !== i && (this._depthTest = i,
  49145. this._isDepthTestDirty = !0,
  49146. this._cache.setDepthTestEnabled(i))
  49147. },
  49148. enumerable: !1,
  49149. configurable: !0
  49150. }),
  49151. Object.defineProperty(e.prototype, "frontFace", {
  49152. get: function() {
  49153. return this._frontFace
  49154. },
  49155. set: function(i) {
  49156. this._frontFace !== i && (this._frontFace = i,
  49157. this._isFrontFaceDirty = !0,
  49158. this._cache.setFrontFace(i != null ? i : 2))
  49159. },
  49160. enumerable: !1,
  49161. configurable: !0
  49162. }),
  49163. e.prototype.reset = function() {
  49164. a.prototype.reset.call(this),
  49165. this._cache.resetDepthCullingState()
  49166. }
  49167. ,
  49168. e.prototype.apply = function(i) {}
  49169. ,
  49170. e
  49171. }(DepthCullingState)
  49172. , ExternalTexture = function() {
  49173. function a(e) {
  49174. this.useMipMaps = !1,
  49175. this.type = 16,
  49176. this._video = e,
  49177. this.uniqueId = InternalTexture._Counter++
  49178. }
  49179. return a.IsExternalTexture = function(e) {
  49180. return e.underlyingResource !== void 0
  49181. }
  49182. ,
  49183. a.prototype.getClassName = function() {
  49184. return "ExternalTexture"
  49185. }
  49186. ,
  49187. Object.defineProperty(a.prototype, "underlyingResource", {
  49188. get: function() {
  49189. return this._video
  49190. },
  49191. enumerable: !1,
  49192. configurable: !0
  49193. }),
  49194. a.prototype.isReady = function() {
  49195. return this._video.readyState >= this._video.HAVE_CURRENT_DATA
  49196. }
  49197. ,
  49198. a.prototype.dispose = function() {}
  49199. ,
  49200. a
  49201. }()
  49202. , WebGPUMaterialContext = function() {
  49203. function a() {
  49204. this.uniqueId = a._Counter++,
  49205. this.updateId = 0,
  49206. this.reset()
  49207. }
  49208. return Object.defineProperty(a.prototype, "forceBindGroupCreation", {
  49209. get: function() {
  49210. return this._numExternalTextures > 0
  49211. },
  49212. enumerable: !1,
  49213. configurable: !0
  49214. }),
  49215. Object.defineProperty(a.prototype, "hasFloatTextures", {
  49216. get: function() {
  49217. return this._numFloatTextures > 0
  49218. },
  49219. enumerable: !1,
  49220. configurable: !0
  49221. }),
  49222. a.prototype.reset = function() {
  49223. this.samplers = {},
  49224. this.textures = {},
  49225. this.isDirty = !0,
  49226. this._numFloatTextures = 0,
  49227. this._numExternalTextures = 0
  49228. }
  49229. ,
  49230. a.prototype.setSampler = function(e, i) {
  49231. var o = this.samplers[e]
  49232. , s = -1;
  49233. o ? s = o.hashCode : this.samplers[e] = o = {
  49234. sampler: i,
  49235. hashCode: 0
  49236. },
  49237. o.sampler = i,
  49238. o.hashCode = i ? WebGPUCacheSampler.GetSamplerHashCode(i) : 0;
  49239. var c = s !== o.hashCode;
  49240. c && this.updateId++,
  49241. this.isDirty || (this.isDirty = c)
  49242. }
  49243. ,
  49244. a.prototype.setTexture = function(e, i) {
  49245. var o, s, c, d = this.textures[e], _ = -1;
  49246. d ? _ = (s = (o = d.texture) === null || o === void 0 ? void 0 : o.uniqueId) !== null && s !== void 0 ? s : -1 : this.textures[e] = d = {
  49247. texture: i,
  49248. isFloatTexture: !1,
  49249. isExternalTexture: !1
  49250. },
  49251. d.isExternalTexture && this._numExternalTextures--,
  49252. d.isFloatTexture && this._numFloatTextures--,
  49253. i ? (d.isFloatTexture = i.type === 1,
  49254. d.isExternalTexture = ExternalTexture.IsExternalTexture(i),
  49255. d.isFloatTexture && this._numFloatTextures++,
  49256. d.isExternalTexture && this._numExternalTextures++) : (d.isFloatTexture = !1,
  49257. d.isExternalTexture = !1),
  49258. d.texture = i;
  49259. var b = _ !== ((c = i == null ? void 0 : i.uniqueId) !== null && c !== void 0 ? c : -1);
  49260. b && this.updateId++,
  49261. this.isDirty || (this.isDirty = b)
  49262. }
  49263. ,
  49264. a._Counter = 0,
  49265. a
  49266. }()
  49267. , WebGPUDrawContext = function() {
  49268. function a(e) {
  49269. this._bufferManager = e,
  49270. this.uniqueId = a._Counter++,
  49271. this._useInstancing = !1,
  49272. this._currentInstanceCount = 0,
  49273. this.reset()
  49274. }
  49275. return a.prototype.isDirty = function(e) {
  49276. return this._isDirty || this.materialContextUpdateId !== e
  49277. }
  49278. ,
  49279. a.prototype.resetIsDirty = function(e) {
  49280. this._isDirty = !1,
  49281. this.materialContextUpdateId = e
  49282. }
  49283. ,
  49284. Object.defineProperty(a.prototype, "useInstancing", {
  49285. get: function() {
  49286. return this._useInstancing
  49287. },
  49288. set: function(e) {
  49289. this._useInstancing !== e && (e ? (this.indirectDrawBuffer = this._bufferManager.createRawBuffer(40, BufferUsage.CopyDst | BufferUsage.Indirect),
  49290. this._indirectDrawData = new Uint32Array(5),
  49291. this._indirectDrawData[3] = 0,
  49292. this._indirectDrawData[4] = 0) : (this.indirectDrawBuffer && this._bufferManager.releaseBuffer(this.indirectDrawBuffer),
  49293. this.indirectDrawBuffer = void 0,
  49294. this._indirectDrawData = void 0),
  49295. this._useInstancing = e,
  49296. this._currentInstanceCount = -1)
  49297. },
  49298. enumerable: !1,
  49299. configurable: !0
  49300. }),
  49301. a.prototype.reset = function() {
  49302. this.buffers = {},
  49303. this._isDirty = !0,
  49304. this.materialContextUpdateId = 0,
  49305. this.fastBundle = void 0,
  49306. this.bindGroups = void 0
  49307. }
  49308. ,
  49309. a.prototype.setBuffer = function(e, i) {
  49310. var o;
  49311. this._isDirty || (this._isDirty = (i == null ? void 0 : i.uniqueId) !== ((o = this.buffers[e]) === null || o === void 0 ? void 0 : o.uniqueId)),
  49312. this.buffers[e] = i
  49313. }
  49314. ,
  49315. a.prototype.setIndirectData = function(e, i, o) {
  49316. i === this._currentInstanceCount || !this.indirectDrawBuffer || !this._indirectDrawData || (this._currentInstanceCount = i,
  49317. this._indirectDrawData[0] = e,
  49318. this._indirectDrawData[1] = i,
  49319. this._indirectDrawData[2] = o,
  49320. this._bufferManager.setRawData(this.indirectDrawBuffer, 0, this._indirectDrawData, 0, 20))
  49321. }
  49322. ,
  49323. a.prototype.dispose = function() {
  49324. this.indirectDrawBuffer && (this._bufferManager.releaseBuffer(this.indirectDrawBuffer),
  49325. this.indirectDrawBuffer = void 0,
  49326. this._indirectDrawData = void 0),
  49327. this.fastBundle = void 0,
  49328. this.bindGroups = void 0,
  49329. this.buffers = void 0
  49330. }
  49331. ,
  49332. a._Counter = 0,
  49333. a
  49334. }()
  49335. , WebGPUBindGroupCacheNode = function() {
  49336. function a() {
  49337. this.values = {}
  49338. }
  49339. return a
  49340. }()
  49341. , WebGPUCacheBindGroups = function() {
  49342. function a(e, i, o) {
  49343. this.disabled = !1,
  49344. this._device = e,
  49345. this._cacheSampler = i,
  49346. this._engine = o
  49347. }
  49348. return Object.defineProperty(a, "Statistics", {
  49349. get: function() {
  49350. return {
  49351. totalCreated: a.NumBindGroupsCreatedTotal,
  49352. lastFrameCreated: a.NumBindGroupsCreatedLastFrame,
  49353. lookupLastFrame: a.NumBindGroupsLookupLastFrame,
  49354. noLookupLastFrame: a.NumBindGroupsNoLookupLastFrame
  49355. }
  49356. },
  49357. enumerable: !1,
  49358. configurable: !0
  49359. }),
  49360. a.prototype.endFrame = function() {
  49361. a.NumBindGroupsCreatedLastFrame = a._NumBindGroupsCreatedCurrentFrame,
  49362. a.NumBindGroupsLookupLastFrame = a._NumBindGroupsLookupCurrentFrame,
  49363. a.NumBindGroupsNoLookupLastFrame = a._NumBindGroupsNoLookupCurrentFrame,
  49364. a._NumBindGroupsCreatedCurrentFrame = 0,
  49365. a._NumBindGroupsLookupCurrentFrame = 0,
  49366. a._NumBindGroupsNoLookupCurrentFrame = 0
  49367. }
  49368. ,
  49369. a.prototype.getBindGroups = function(e, i, o) {
  49370. var s, c, d, _, b, k, j, $, _e, et, tt = void 0, rt = a._Cache, it = this.disabled || o.forceBindGroupCreation;
  49371. if (!it) {
  49372. if (!i.isDirty(o.updateId) && !o.isDirty)
  49373. return a._NumBindGroupsNoLookupCurrentFrame++,
  49374. i.bindGroups;
  49375. for (var nt = 0, ot = e.shaderProcessingContext.bufferNames; nt < ot.length; nt++) {
  49376. var at = ot[nt]
  49377. , st = (c = (s = i.buffers[at]) === null || s === void 0 ? void 0 : s.uniqueId) !== null && c !== void 0 ? c : 0
  49378. , ut = rt.values[st];
  49379. ut || (ut = new WebGPUBindGroupCacheNode,
  49380. rt.values[st] = ut),
  49381. rt = ut
  49382. }
  49383. for (var ct = 0, lt = e.shaderProcessingContext.samplerNames; ct < lt.length; ct++) {
  49384. var ft = lt[ct]
  49385. , ht = (_ = (d = o.samplers[ft]) === null || d === void 0 ? void 0 : d.hashCode) !== null && _ !== void 0 ? _ : 0
  49386. , ut = rt.values[ht];
  49387. ut || (ut = new WebGPUBindGroupCacheNode,
  49388. rt.values[ht] = ut),
  49389. rt = ut
  49390. }
  49391. for (var pt = 0, dt = e.shaderProcessingContext.textureNames; pt < dt.length; pt++) {
  49392. var _t = dt[pt]
  49393. , mt = (j = (k = (b = o.textures[_t]) === null || b === void 0 ? void 0 : b.texture) === null || k === void 0 ? void 0 : k.uniqueId) !== null && j !== void 0 ? j : 0
  49394. , ut = rt.values[mt];
  49395. ut || (ut = new WebGPUBindGroupCacheNode,
  49396. rt.values[mt] = ut),
  49397. rt = ut
  49398. }
  49399. tt = rt.bindGroups
  49400. }
  49401. if (i.resetIsDirty(o.updateId),
  49402. o.isDirty = !1,
  49403. tt)
  49404. return i.bindGroups = tt,
  49405. a._NumBindGroupsLookupCurrentFrame++,
  49406. tt;
  49407. tt = [],
  49408. i.bindGroups = tt,
  49409. it || (rt.bindGroups = tt),
  49410. a.NumBindGroupsCreatedTotal++,
  49411. a._NumBindGroupsCreatedCurrentFrame++;
  49412. for (var vt = e.bindGroupLayouts, yt = 0; yt < e.shaderProcessingContext.bindGroupLayoutEntries.length; yt++) {
  49413. for (var Et = e.shaderProcessingContext.bindGroupLayoutEntries[yt], At = e.shaderProcessingContext.bindGroupEntries[yt], gt = 0; gt < Et.length; gt++) {
  49414. var St = e.shaderProcessingContext.bindGroupLayoutEntries[yt][gt]
  49415. , xt = e.shaderProcessingContext.bindGroupLayoutEntryInfo[yt][St.binding]
  49416. , bt = ($ = xt.nameInArrayOfTexture) !== null && $ !== void 0 ? $ : xt.name;
  49417. if (St.sampler) {
  49418. var Rt = o.samplers[bt];
  49419. if (Rt) {
  49420. var Mt = Rt.sampler;
  49421. if (!Mt) {
  49422. this._engine.dbgSanityChecks && Logger$2.Error("Trying to bind a null sampler! entry=" + JSON.stringify(St) + ", name=" + bt + ", bindingInfo=" + JSON.stringify(Rt, function(wt, Nt) {
  49423. return wt === "texture" ? "<no dump>" : Nt
  49424. }) + ", materialContext.uniqueId=" + o.uniqueId, 50);
  49425. continue
  49426. }
  49427. At[gt].resource = this._cacheSampler.getSampler(Mt, !1, Rt.hashCode)
  49428. } else
  49429. Logger$2.Error('Sampler "' + bt + '" could not be bound. entry=' + JSON.stringify(St) + ", materialContext=" + JSON.stringify(o, function(wt, Nt) {
  49430. return wt === "texture" || wt === "sampler" ? "<no dump>" : Nt
  49431. }), 50)
  49432. } else if (St.texture || St.storageTexture) {
  49433. var Rt = o.textures[bt];
  49434. if (Rt) {
  49435. if (this._engine.dbgSanityChecks && Rt.texture === null) {
  49436. Logger$2.Error("Trying to bind a null texture! entry=" + JSON.stringify(St) + ", bindingInfo=" + JSON.stringify(Rt, function(Nt, Ft) {
  49437. return Nt === "texture" ? "<no dump>" : Ft
  49438. }) + ", materialContext.uniqueId=" + o.uniqueId, 50);
  49439. continue
  49440. }
  49441. var Pt = Rt.texture._hardwareTexture;
  49442. if (this._engine.dbgSanityChecks && (!Pt || !Pt.view)) {
  49443. Logger$2.Error("Trying to bind a null gpu texture! entry=" + JSON.stringify(St) + ", name=" + bt + ", bindingInfo=" + JSON.stringify(Rt, function(Nt, Ft) {
  49444. return Nt === "texture" ? "<no dump>" : Ft
  49445. }) + ", isReady=" + ((_e = Rt.texture) === null || _e === void 0 ? void 0 : _e.isReady) + ", materialContext.uniqueId=" + o.uniqueId, 50);
  49446. continue
  49447. }
  49448. At[gt].resource = Pt.view
  49449. } else
  49450. Logger$2.Error('Texture "' + bt + '" could not be bound. entry=' + JSON.stringify(St) + ", materialContext=" + JSON.stringify(o, function(Nt, Ft) {
  49451. return Nt === "texture" || Nt === "sampler" ? "<no dump>" : Ft
  49452. }), 50)
  49453. } else if (St.externalTexture) {
  49454. var Rt = o.textures[bt];
  49455. if (Rt) {
  49456. if (this._engine.dbgSanityChecks && Rt.texture === null) {
  49457. Logger$2.Error("Trying to bind a null external texture! entry=" + JSON.stringify(St) + ", name=" + bt + ", bindingInfo=" + JSON.stringify(Rt, function(Nt, Ft) {
  49458. return Nt === "texture" ? "<no dump>" : Ft
  49459. }) + ", materialContext.uniqueId=" + o.uniqueId, 50);
  49460. continue
  49461. }
  49462. var It = Rt.texture.underlyingResource;
  49463. if (this._engine.dbgSanityChecks && !It) {
  49464. Logger$2.Error("Trying to bind a null gpu external texture! entry=" + JSON.stringify(St) + ", name=" + bt + ", bindingInfo=" + JSON.stringify(Rt, function(Nt, Ft) {
  49465. return Nt === "texture" ? "<no dump>" : Ft
  49466. }) + ", isReady=" + ((et = Rt.texture) === null || et === void 0 ? void 0 : et.isReady) + ", materialContext.uniqueId=" + o.uniqueId, 50);
  49467. continue
  49468. }
  49469. At[gt].resource = this._device.importExternalTexture({
  49470. source: It
  49471. })
  49472. } else
  49473. Logger$2.Error('Texture "' + bt + '" could not be bound. entry=' + JSON.stringify(St) + ", materialContext=" + JSON.stringify(o, function(Nt, Ft) {
  49474. return Nt === "texture" || Nt === "sampler" ? "<no dump>" : Ft
  49475. }), 50)
  49476. } else if (St.buffer) {
  49477. var Dt = i.buffers[bt];
  49478. if (Dt) {
  49479. var Ct = Dt.underlyingResource;
  49480. At[gt].resource.buffer = Ct,
  49481. At[gt].resource.size = Dt.capacity
  49482. } else
  49483. Logger$2.Error(`Can't find buffer "` + bt + '". entry=' + JSON.stringify(St) + ", buffers=" + JSON.stringify(i.buffers) + ", drawContext.uniqueId=" + i.uniqueId, 50)
  49484. }
  49485. }
  49486. var Ot = vt[yt];
  49487. tt[yt] = this._device.createBindGroup({
  49488. layout: Ot,
  49489. entries: At
  49490. })
  49491. }
  49492. return tt
  49493. }
  49494. ,
  49495. a.NumBindGroupsCreatedTotal = 0,
  49496. a.NumBindGroupsCreatedLastFrame = 0,
  49497. a.NumBindGroupsLookupLastFrame = 0,
  49498. a.NumBindGroupsNoLookupLastFrame = 0,
  49499. a._Cache = new WebGPUBindGroupCacheNode,
  49500. a._NumBindGroupsCreatedCurrentFrame = 0,
  49501. a._NumBindGroupsLookupCurrentFrame = 0,
  49502. a._NumBindGroupsNoLookupCurrentFrame = 0,
  49503. a
  49504. }()
  49505. , name$2F = "clearQuadVertexShader"
  49506. , shader$2F = `uniform float depthValue;
  49507. const vec2 pos[4]={
  49508. vec2(-1.0,1.0),
  49509. vec2(1.0,1.0),
  49510. vec2(-1.0,-1.0),
  49511. vec2(1.0,-1.0)
  49512. };
  49513. void main(void) {
  49514. gl_Position=vec4(pos[gl_VertexID],depthValue,1.0);
  49515. }
  49516. `;
  49517. ShaderStore.ShadersStore[name$2F] = shader$2F;
  49518. var name$2E = "clearQuadPixelShader"
  49519. , shader$2E = `uniform vec4 color;
  49520. void main() {
  49521. gl_FragColor=color;
  49522. }
  49523. `;
  49524. ShaderStore.ShadersStore[name$2E] = shader$2E;
  49525. var WebGPUClearQuad = function() {
  49526. function a(e, i, o) {
  49527. this._bindGroups = {},
  49528. this._bundleCache = {},
  49529. this._device = e,
  49530. this._engine = i,
  49531. this._cacheRenderPipeline = new WebGPUCacheRenderPipelineTree(this._device,o,!i._caps.textureFloatLinearFiltering),
  49532. this._cacheRenderPipeline.setDepthTestEnabled(!1),
  49533. this._cacheRenderPipeline.setStencilReadMask(255),
  49534. this._effect = i.createEffect("clearQuad", [], ["color", "depthValue"])
  49535. }
  49536. return a.prototype.setDepthStencilFormat = function(e) {
  49537. this._depthTextureFormat = e,
  49538. this._cacheRenderPipeline.setDepthStencilFormat(e)
  49539. }
  49540. ,
  49541. a.prototype.setColorFormat = function(e) {
  49542. this._cacheRenderPipeline.setColorFormat(e)
  49543. }
  49544. ,
  49545. a.prototype.setMRTAttachments = function(e, i) {
  49546. this._cacheRenderPipeline.setMRTAttachments(e, i)
  49547. }
  49548. ,
  49549. a.prototype.clear = function(e, i, o, s, c) {
  49550. var d, _;
  49551. c === void 0 && (c = 1);
  49552. var b, k = null, j = 0;
  49553. if (e)
  49554. b = e;
  49555. else {
  49556. if (j = (i ? i.r + i.g * 256 + i.b * 256 * 256 + i.a * 256 * 256 * 256 : 0) + (o ? Math.pow(2, 32) : 0) + (s ? Math.pow(2, 33) : 0) + (this._engine.useReverseDepthBuffer ? Math.pow(2, 34) : 0) + c * Math.pow(2, 35),
  49557. k = this._bundleCache[j],
  49558. k)
  49559. return k;
  49560. b = this._device.createRenderBundleEncoder({
  49561. colorFormats: this._cacheRenderPipeline.colorFormats,
  49562. depthStencilFormat: this._depthTextureFormat,
  49563. sampleCount: c
  49564. })
  49565. }
  49566. this._cacheRenderPipeline.setDepthWriteEnabled(!!o),
  49567. this._cacheRenderPipeline.setStencilEnabled(!!s),
  49568. this._cacheRenderPipeline.setStencilWriteMask(s ? 255 : 0),
  49569. this._cacheRenderPipeline.setStencilCompare(s ? 519 : 512),
  49570. this._cacheRenderPipeline.setStencilPassOp(s ? 7681 : 7680),
  49571. this._cacheRenderPipeline.setWriteMask(i ? 15 : 0);
  49572. var $ = this._cacheRenderPipeline.getRenderPipeline(7, this._effect, c)
  49573. , _e = this._effect._pipelineContext;
  49574. i && this._effect.setDirectColor4("color", i),
  49575. this._effect.setFloat("depthValue", this._engine.useReverseDepthBuffer ? this._engine._clearReverseDepthValue : this._engine._clearDepthValue),
  49576. (d = _e.uniformBuffer) === null || d === void 0 || d.update();
  49577. var et = (_ = _e.uniformBuffer) === null || _ === void 0 ? void 0 : _.getBuffer()
  49578. , tt = this._bindGroups[et.uniqueId];
  49579. if (!tt) {
  49580. var rt = _e.bindGroupLayouts;
  49581. tt = this._bindGroups[et.uniqueId] = [],
  49582. tt.push(this._device.createBindGroup({
  49583. layout: rt[0],
  49584. entries: []
  49585. })),
  49586. WebGPUShaderProcessingContext._SimplifiedKnownBindings || tt.push(this._device.createBindGroup({
  49587. layout: rt[1],
  49588. entries: []
  49589. })),
  49590. tt.push(this._device.createBindGroup({
  49591. layout: rt[WebGPUShaderProcessingContext._SimplifiedKnownBindings ? 1 : 2],
  49592. entries: [{
  49593. binding: 0,
  49594. resource: {
  49595. buffer: et.underlyingResource,
  49596. size: et.capacity
  49597. }
  49598. }]
  49599. }))
  49600. }
  49601. b.setPipeline($);
  49602. for (var it = 0; it < tt.length; ++it)
  49603. b.setBindGroup(it, tt[it]);
  49604. return b.draw(4, 1, 0, 0),
  49605. e || (k = b.finish(),
  49606. this._bundleCache[j] = k),
  49607. k
  49608. }
  49609. ,
  49610. a
  49611. }()
  49612. , WebGPURenderItemViewport = function() {
  49613. function a(e, i, o, s) {
  49614. this.x = Math.floor(e),
  49615. this.y = Math.floor(i),
  49616. this.w = Math.floor(o),
  49617. this.h = Math.floor(s)
  49618. }
  49619. return a.prototype.run = function(e) {
  49620. e.setViewport(this.x, this.y, this.w, this.h, 0, 1)
  49621. }
  49622. ,
  49623. a.prototype.clone = function() {
  49624. return new a(this.x,this.y,this.w,this.h)
  49625. }
  49626. ,
  49627. a
  49628. }()
  49629. , WebGPURenderItemScissor = function() {
  49630. function a(e, i, o, s) {
  49631. this.x = e,
  49632. this.y = i,
  49633. this.w = o,
  49634. this.h = s
  49635. }
  49636. return a.prototype.run = function(e) {
  49637. e.setScissorRect(this.x, this.y, this.w, this.h)
  49638. }
  49639. ,
  49640. a.prototype.clone = function() {
  49641. return new a(this.x,this.y,this.w,this.h)
  49642. }
  49643. ,
  49644. a
  49645. }()
  49646. , WebGPURenderItemStencilRef = function() {
  49647. function a(e) {
  49648. this.ref = e
  49649. }
  49650. return a.prototype.run = function(e) {
  49651. e.setStencilReference(this.ref)
  49652. }
  49653. ,
  49654. a.prototype.clone = function() {
  49655. return new a(this.ref)
  49656. }
  49657. ,
  49658. a
  49659. }()
  49660. , WebGPURenderItemBlendColor = function() {
  49661. function a(e) {
  49662. this.color = e
  49663. }
  49664. return a.prototype.run = function(e) {
  49665. e.setBlendConstant(this.color)
  49666. }
  49667. ,
  49668. a.prototype.clone = function() {
  49669. return new a(this.color)
  49670. }
  49671. ,
  49672. a
  49673. }()
  49674. , WebGPURenderItemBeginOcclusionQuery = function() {
  49675. function a(e) {
  49676. this.query = e
  49677. }
  49678. return a.prototype.run = function(e) {
  49679. e.beginOcclusionQuery(this.query)
  49680. }
  49681. ,
  49682. a.prototype.clone = function() {
  49683. return new a(this.query)
  49684. }
  49685. ,
  49686. a
  49687. }()
  49688. , WebGPURenderItemEndOcclusionQuery = function() {
  49689. function a() {}
  49690. return a.prototype.run = function(e) {
  49691. e.endOcclusionQuery()
  49692. }
  49693. ,
  49694. a.prototype.clone = function() {
  49695. return new a
  49696. }
  49697. ,
  49698. a
  49699. }()
  49700. , WebGPURenderItemBundles = function() {
  49701. function a() {
  49702. this.bundles = []
  49703. }
  49704. return a.prototype.run = function(e) {
  49705. e.executeBundles(this.bundles)
  49706. }
  49707. ,
  49708. a.prototype.clone = function() {
  49709. var e = new a;
  49710. return e.bundles = this.bundles,
  49711. e
  49712. }
  49713. ,
  49714. a
  49715. }()
  49716. , WebGPUBundleList = function() {
  49717. function a(e) {
  49718. this.numDrawCalls = 0,
  49719. this._device = e,
  49720. this._list = new Array(10),
  49721. this._listLength = 0
  49722. }
  49723. return a.prototype.addBundle = function(e) {
  49724. if (!this._currentItemIsBundle) {
  49725. var i = new WebGPURenderItemBundles;
  49726. this._list[this._listLength++] = i,
  49727. this._currentBundleList = i.bundles,
  49728. this._currentItemIsBundle = !0
  49729. }
  49730. e && this._currentBundleList.push(e)
  49731. }
  49732. ,
  49733. a.prototype._finishBundle = function() {
  49734. this._currentItemIsBundle && this._bundleEncoder && (this._currentBundleList.push(this._bundleEncoder.finish()),
  49735. this._bundleEncoder = void 0,
  49736. this._currentItemIsBundle = !1)
  49737. }
  49738. ,
  49739. a.prototype.addItem = function(e) {
  49740. this._finishBundle(),
  49741. this._list[this._listLength++] = e,
  49742. this._currentItemIsBundle = !1
  49743. }
  49744. ,
  49745. a.prototype.getBundleEncoder = function(e, i, o) {
  49746. return this._currentItemIsBundle || (this.addBundle(),
  49747. this._bundleEncoder = this._device.createRenderBundleEncoder({
  49748. colorFormats: e,
  49749. depthStencilFormat: i,
  49750. sampleCount: o
  49751. })),
  49752. this._bundleEncoder
  49753. }
  49754. ,
  49755. a.prototype.close = function() {
  49756. this._finishBundle()
  49757. }
  49758. ,
  49759. a.prototype.run = function(e) {
  49760. this.close();
  49761. for (var i = 0; i < this._listLength; ++i)
  49762. this._list[i].run(e)
  49763. }
  49764. ,
  49765. a.prototype.reset = function() {
  49766. this._listLength = 0,
  49767. this._currentItemIsBundle = !1,
  49768. this.numDrawCalls = 0
  49769. }
  49770. ,
  49771. a.prototype.clone = function() {
  49772. this.close();
  49773. var e = new a(this._device);
  49774. e._list = new Array(this._listLength),
  49775. e._listLength = this._listLength,
  49776. e.numDrawCalls = this.numDrawCalls;
  49777. for (var i = 0; i < this._listLength; ++i)
  49778. e._list[i] = this._list[i].clone();
  49779. return e
  49780. }
  49781. ,
  49782. a
  49783. }()
  49784. , WebGPUQuerySet = function() {
  49785. function a(e, i, o, s, c) {
  49786. c === void 0 && (c = !0),
  49787. this._dstBuffers = [],
  49788. this._device = o,
  49789. this._bufferManager = s,
  49790. this._count = e,
  49791. this._canUseMultipleBuffers = c,
  49792. this._querySet = o.createQuerySet({
  49793. type: i,
  49794. count: e
  49795. }),
  49796. this._queryBuffer = s.createRawBuffer(8 * e, BufferUsage.QueryResolve | BufferUsage.CopySrc),
  49797. c || this._dstBuffers.push(this._bufferManager.createRawBuffer(8 * this._count, BufferUsage.MapRead | BufferUsage.CopyDst))
  49798. }
  49799. return Object.defineProperty(a.prototype, "querySet", {
  49800. get: function() {
  49801. return this._querySet
  49802. },
  49803. enumerable: !1,
  49804. configurable: !0
  49805. }),
  49806. a.prototype._getBuffer = function(e, i) {
  49807. if (!this._canUseMultipleBuffers && this._dstBuffers.length === 0)
  49808. return null;
  49809. var o = this._device.createCommandEncoder(), s;
  49810. return this._dstBuffers.length === 0 ? s = this._bufferManager.createRawBuffer(8 * this._count, BufferUsage.MapRead | BufferUsage.CopyDst) : (s = this._dstBuffers[this._dstBuffers.length - 1],
  49811. this._dstBuffers.length--),
  49812. o.resolveQuerySet(this._querySet, e, i, this._queryBuffer, 0),
  49813. o.copyBufferToBuffer(this._queryBuffer, 0, s, 0, 8 * i),
  49814. this._device.queue.submit([o.finish()]),
  49815. s
  49816. }
  49817. ,
  49818. a.prototype.readValues = function(e, i) {
  49819. return e === void 0 && (e = 0),
  49820. i === void 0 && (i = 1),
  49821. __awaiter(this, void 0, void 0, function() {
  49822. var o, s;
  49823. return __generator(this, function(c) {
  49824. switch (c.label) {
  49825. case 0:
  49826. return o = this._getBuffer(e, i),
  49827. o === null ? [2, null] : [4, o.mapAsync(MapMode.Read)];
  49828. case 1:
  49829. return c.sent(),
  49830. s = new BigUint64Array(o.getMappedRange()).slice(),
  49831. o.unmap(),
  49832. this._dstBuffers[this._dstBuffers.length] = o,
  49833. [2, s]
  49834. }
  49835. })
  49836. })
  49837. }
  49838. ,
  49839. a.prototype.readValue = function(e) {
  49840. return e === void 0 && (e = 0),
  49841. __awaiter(this, void 0, void 0, function() {
  49842. var i, o, s;
  49843. return __generator(this, function(c) {
  49844. switch (c.label) {
  49845. case 0:
  49846. return i = this._getBuffer(e, 1),
  49847. i === null ? [2, null] : [4, i.mapAsync(MapMode.Read)];
  49848. case 1:
  49849. return c.sent(),
  49850. o = new BigUint64Array(i.getMappedRange()),
  49851. s = Number(o[0]),
  49852. i.unmap(),
  49853. this._dstBuffers[this._dstBuffers.length] = i,
  49854. [2, s]
  49855. }
  49856. })
  49857. })
  49858. }
  49859. ,
  49860. a.prototype.readTwoValuesAndSubtract = function(e) {
  49861. return e === void 0 && (e = 0),
  49862. __awaiter(this, void 0, void 0, function() {
  49863. var i, o, s;
  49864. return __generator(this, function(c) {
  49865. switch (c.label) {
  49866. case 0:
  49867. return i = this._getBuffer(e, 2),
  49868. i === null ? [2, null] : [4, i.mapAsync(MapMode.Read)];
  49869. case 1:
  49870. return c.sent(),
  49871. o = new BigUint64Array(i.getMappedRange()),
  49872. s = Number(o[1] - o[0]),
  49873. i.unmap(),
  49874. this._dstBuffers[this._dstBuffers.length] = i,
  49875. [2, s]
  49876. }
  49877. })
  49878. })
  49879. }
  49880. ,
  49881. a.prototype.dispose = function() {
  49882. this._querySet.destroy(),
  49883. this._bufferManager.releaseBuffer(this._queryBuffer);
  49884. for (var e = 0; e < this._dstBuffers.length; ++e)
  49885. this._bufferManager.releaseBuffer(this._dstBuffers[e])
  49886. }
  49887. ,
  49888. a
  49889. }()
  49890. , WebGPUTimestampQuery = function() {
  49891. function a(e, i) {
  49892. this._enabled = !1,
  49893. this._gpuFrameTimeCounter = new PerfCounter,
  49894. this._measureDurationState = 0,
  49895. this._device = e,
  49896. this._bufferManager = i
  49897. }
  49898. return Object.defineProperty(a.prototype, "gpuFrameTimeCounter", {
  49899. get: function() {
  49900. return this._gpuFrameTimeCounter
  49901. },
  49902. enumerable: !1,
  49903. configurable: !0
  49904. }),
  49905. Object.defineProperty(a.prototype, "enable", {
  49906. get: function() {
  49907. return this._enabled
  49908. },
  49909. set: function(e) {
  49910. this._enabled !== e && (this._enabled = e,
  49911. this._measureDurationState = 0,
  49912. e ? this._measureDuration = new WebGPUDurationMeasure(this._device,this._bufferManager) : this._measureDuration.dispose())
  49913. },
  49914. enumerable: !1,
  49915. configurable: !0
  49916. }),
  49917. a.prototype.startFrame = function(e) {
  49918. this._enabled && this._measureDurationState === 0 && (this._measureDuration.start(e),
  49919. this._measureDurationState = 1)
  49920. }
  49921. ,
  49922. a.prototype.endFrame = function(e) {
  49923. var i = this;
  49924. this._measureDurationState === 1 && (this._measureDurationState = 2,
  49925. this._measureDuration.stop(e).then(function(o) {
  49926. o !== null && o >= 0 && (i._gpuFrameTimeCounter.fetchNewFrame(),
  49927. i._gpuFrameTimeCounter.addCount(o, !0)),
  49928. i._measureDurationState = 0
  49929. }))
  49930. }
  49931. ,
  49932. a
  49933. }()
  49934. , WebGPUDurationMeasure = function() {
  49935. function a(e, i) {
  49936. this._querySet = new WebGPUQuerySet(2,QueryType.Timestamp,e,i)
  49937. }
  49938. return a.prototype.start = function(e) {
  49939. e.writeTimestamp(this._querySet.querySet, 0)
  49940. }
  49941. ,
  49942. a.prototype.stop = function(e) {
  49943. return __awaiter(this, void 0, void 0, function() {
  49944. return __generator(this, function(i) {
  49945. return e.writeTimestamp(this._querySet.querySet, 1),
  49946. [2, this._querySet.readTwoValuesAndSubtract(0)]
  49947. })
  49948. })
  49949. }
  49950. ,
  49951. a.prototype.dispose = function() {
  49952. this._querySet.dispose()
  49953. }
  49954. ,
  49955. a
  49956. }()
  49957. , WebGPUOcclusionQuery = function() {
  49958. function a(e, i, o, s, c) {
  49959. s === void 0 && (s = 50),
  49960. c === void 0 && (c = 100),
  49961. this._availableIndices = [],
  49962. this._engine = e,
  49963. this._device = i,
  49964. this._bufferManager = o,
  49965. this._frameLastBuffer = -1,
  49966. this._currentTotalIndices = 0,
  49967. this._countIncrement = c,
  49968. this._allocateNewIndices(s)
  49969. }
  49970. return Object.defineProperty(a.prototype, "querySet", {
  49971. get: function() {
  49972. return this._querySet.querySet
  49973. },
  49974. enumerable: !1,
  49975. configurable: !0
  49976. }),
  49977. Object.defineProperty(a.prototype, "hasQueries", {
  49978. get: function() {
  49979. return this._currentTotalIndices !== this._availableIndices.length
  49980. },
  49981. enumerable: !1,
  49982. configurable: !0
  49983. }),
  49984. Object.defineProperty(a.prototype, "canBeginQuery", {
  49985. get: function() {
  49986. var e = this._engine._getCurrentRenderPassIndex();
  49987. switch (e) {
  49988. case 0:
  49989. return this._engine._mainRenderPassWrapper.renderPassDescriptor.occlusionQuerySet !== void 0;
  49990. case 1:
  49991. return this._engine._rttRenderPassWrapper.renderPassDescriptor.occlusionQuerySet !== void 0
  49992. }
  49993. return !1
  49994. },
  49995. enumerable: !1,
  49996. configurable: !0
  49997. }),
  49998. a.prototype.createQuery = function() {
  49999. this._availableIndices.length === 0 && this._allocateNewIndices();
  50000. var e = this._availableIndices[this._availableIndices.length - 1];
  50001. return this._availableIndices.length--,
  50002. e
  50003. }
  50004. ,
  50005. a.prototype.deleteQuery = function(e) {
  50006. this._availableIndices[this._availableIndices.length - 1] = e
  50007. }
  50008. ,
  50009. a.prototype.isQueryResultAvailable = function(e) {
  50010. return this._retrieveQueryBuffer(),
  50011. !!this._lastBuffer && e < this._lastBuffer.length
  50012. }
  50013. ,
  50014. a.prototype.getQueryResult = function(e) {
  50015. var i, o;
  50016. return Number((o = (i = this._lastBuffer) === null || i === void 0 ? void 0 : i[e]) !== null && o !== void 0 ? o : -1)
  50017. }
  50018. ,
  50019. a.prototype._retrieveQueryBuffer = function() {
  50020. var e = this;
  50021. this._lastBuffer && this._frameLastBuffer === this._engine.frameId || this._frameLastBuffer !== this._engine.frameId && (this._frameLastBuffer = this._engine.frameId,
  50022. this._querySet.readValues(0, this._currentTotalIndices).then(function(i) {
  50023. e._lastBuffer = i
  50024. }))
  50025. }
  50026. ,
  50027. a.prototype._allocateNewIndices = function(e) {
  50028. e = e != null ? e : this._countIncrement,
  50029. this._delayQuerySetDispose();
  50030. for (var i = 0; i < e; ++i)
  50031. this._availableIndices.push(this._currentTotalIndices + i);
  50032. this._currentTotalIndices += e,
  50033. this._querySet = new WebGPUQuerySet(this._currentTotalIndices,QueryType.Occlusion,this._device,this._bufferManager,!1)
  50034. }
  50035. ,
  50036. a.prototype._delayQuerySetDispose = function() {
  50037. var e = this._querySet;
  50038. e && setTimeout(function() {
  50039. return e.dispose
  50040. }, 1e3)
  50041. }
  50042. ,
  50043. a.prototype.dispose = function() {
  50044. var e;
  50045. (e = this._querySet) === null || e === void 0 || e.dispose(),
  50046. this._availableIndices = []
  50047. }
  50048. ,
  50049. a
  50050. }()
  50051. , WebGPUTintWASM = function() {
  50052. function a() {
  50053. this._twgsl = null
  50054. }
  50055. return a.prototype.initTwgsl = function(e) {
  50056. return __awaiter(this, void 0, void 0, function() {
  50057. var i;
  50058. return __generator(this, function(o) {
  50059. switch (o.label) {
  50060. case 0:
  50061. return e = e || {},
  50062. e = __assign(__assign({}, a._twgslDefaultOptions), e),
  50063. e.twgsl ? (this._twgsl = e.twgsl,
  50064. [2, Promise.resolve()]) : e.jsPath && e.wasmPath ? IsWindowObjectExist() ? [4, Tools.LoadScriptAsync(e.jsPath)] : [3, 2] : [3, 3];
  50065. case 1:
  50066. return o.sent(),
  50067. [3, 3];
  50068. case 2:
  50069. importScripts(e.jsPath),
  50070. o.label = 3;
  50071. case 3:
  50072. return self.twgsl ? (i = this,
  50073. [4, self.twgsl(e.wasmPath)]) : [3, 5];
  50074. case 4:
  50075. return i._twgsl = o.sent(),
  50076. [2, Promise.resolve()];
  50077. case 5:
  50078. return [2, Promise.reject("twgsl is not available.")]
  50079. }
  50080. })
  50081. })
  50082. }
  50083. ,
  50084. a.prototype.convertSpirV2WGSL = function(e) {
  50085. return this._twgsl.convertSpirV2WGSL(e)
  50086. }
  50087. ,
  50088. a._twgslDefaultOptions = {
  50089. jsPath: "https://preview.babylonjs.com/twgsl/twgsl.js",
  50090. wasmPath: "https://preview.babylonjs.com/twgsl/twgsl.wasm"
  50091. },
  50092. a
  50093. }()
  50094. , WebGPUSnapshotRendering = function() {
  50095. function a(e, i, o, s) {
  50096. this._record = !1,
  50097. this._play = !1,
  50098. this._mainPassBundleList = [],
  50099. this._enabled = !1,
  50100. this._engine = e,
  50101. this._mode = i,
  50102. this._bundleList = o,
  50103. this._bundleListRenderTarget = s
  50104. }
  50105. return Object.defineProperty(a.prototype, "enabled", {
  50106. get: function() {
  50107. return this._enabled
  50108. },
  50109. set: function(e) {
  50110. this._mainPassBundleList.length = 0,
  50111. this._record = this._enabled = e,
  50112. this._play = !1,
  50113. e && (this._modeSaved = this._mode,
  50114. this._mode = 0)
  50115. },
  50116. enumerable: !1,
  50117. configurable: !0
  50118. }),
  50119. Object.defineProperty(a.prototype, "play", {
  50120. get: function() {
  50121. return this._play
  50122. },
  50123. enumerable: !1,
  50124. configurable: !0
  50125. }),
  50126. Object.defineProperty(a.prototype, "record", {
  50127. get: function() {
  50128. return this._record
  50129. },
  50130. enumerable: !1,
  50131. configurable: !0
  50132. }),
  50133. Object.defineProperty(a.prototype, "mode", {
  50134. get: function() {
  50135. return this._mode
  50136. },
  50137. set: function(e) {
  50138. this._record ? this._modeSaved = e : this._mode = e
  50139. },
  50140. enumerable: !1,
  50141. configurable: !0
  50142. }),
  50143. a.prototype.endMainRenderPass = function() {
  50144. this._record && this._mainPassBundleList.push(this._bundleList.clone())
  50145. }
  50146. ,
  50147. a.prototype.endRenderTargetPass = function(e, i) {
  50148. var o, s, c, d;
  50149. if (this._play)
  50150. (s = (o = i._bundleLists) === null || o === void 0 ? void 0 : o[i._currentLayer]) === null || s === void 0 || s.run(e),
  50151. this._mode === 1 && this._engine._reportDrawCall((d = (c = i._bundleLists) === null || c === void 0 ? void 0 : c[i._currentLayer]) === null || d === void 0 ? void 0 : d.numDrawCalls);
  50152. else if (this._record)
  50153. i._bundleLists || (i._bundleLists = []),
  50154. i._bundleLists[i._currentLayer] = this._bundleListRenderTarget.clone(),
  50155. i._bundleLists[i._currentLayer].run(e),
  50156. this._bundleListRenderTarget.reset();
  50157. else
  50158. return !1;
  50159. return !0
  50160. }
  50161. ,
  50162. a.prototype.endFrame = function(e) {
  50163. if (this._record && (this._mainPassBundleList.push(this._bundleList.clone()),
  50164. this._record = !1,
  50165. this._play = !0,
  50166. this._mode = this._modeSaved),
  50167. e !== null && this._play)
  50168. for (var i = 0; i < this._mainPassBundleList.length; ++i)
  50169. this._mainPassBundleList[i].run(e),
  50170. this._mode === 1 && this._engine._reportDrawCall(this._mainPassBundleList[i].numDrawCalls)
  50171. }
  50172. ,
  50173. a.prototype.reset = function() {
  50174. this.enabled = !1,
  50175. this.enabled = !0
  50176. }
  50177. ,
  50178. a
  50179. }()
  50180. , WebGPUEngine = function(a) {
  50181. __extends(e, a);
  50182. function e(i, o) {
  50183. o === void 0 && (o = {});
  50184. var s, c, d, _, b = a.call(this, null) || this;
  50185. if (b._uploadEncoderDescriptor = {
  50186. label: "upload"
  50187. },
  50188. b._renderEncoderDescriptor = {
  50189. label: "render"
  50190. },
  50191. b._renderTargetEncoderDescriptor = {
  50192. label: "renderTarget"
  50193. },
  50194. b._clearDepthValue = 1,
  50195. b._clearReverseDepthValue = 0,
  50196. b._clearStencilValue = 0,
  50197. b._defaultSampleCount = 4,
  50198. b._glslang = null,
  50199. b._tintWASM = null,
  50200. b._compiledComputeEffects = {},
  50201. b._counters = {
  50202. numEnableEffects: 0,
  50203. numEnableDrawWrapper: 0,
  50204. numBundleCreationNonCompatMode: 0,
  50205. numBundleReuseNonCompatMode: 0
  50206. },
  50207. b.countersLastFrame = {
  50208. numEnableEffects: 0,
  50209. numEnableDrawWrapper: 0,
  50210. numBundleCreationNonCompatMode: 0,
  50211. numBundleReuseNonCompatMode: 0
  50212. },
  50213. b.numMaxUncapturedErrors = 20,
  50214. b._commandBuffers = [null, null, null],
  50215. b._currentRenderPass = null,
  50216. b._mainRenderPassWrapper = new WebGPURenderPassWrapper,
  50217. b._mainRenderPassCopyWrapper = new WebGPURenderPassWrapper,
  50218. b._rttRenderPassWrapper = new WebGPURenderPassWrapper,
  50219. b._pendingDebugCommands = [],
  50220. b._onAfterUnbindFrameBufferObservable = new Observable,
  50221. b._currentOverrideVertexBuffers = null,
  50222. b._currentIndexBuffer = null,
  50223. b.__colorWrite = !0,
  50224. b._forceEnableEffect = !1,
  50225. b.dbgShowShaderCode = !1,
  50226. b.dbgSanityChecks = !0,
  50227. b.dbgVerboseLogsForFirstFrames = !1,
  50228. b.dbgVerboseLogsNumFrames = 10,
  50229. b.dbgLogIfNotDrawWrapper = !0,
  50230. b.dbgShowEmptyEnableEffectCalls = !0,
  50231. b._viewportsCurrent = [{
  50232. x: 0,
  50233. y: 0,
  50234. w: 0,
  50235. h: 0
  50236. }, {
  50237. x: 0,
  50238. y: 0,
  50239. w: 0,
  50240. h: 0
  50241. }],
  50242. b._scissorsCurrent = [{
  50243. x: 0,
  50244. y: 0,
  50245. w: 0,
  50246. h: 0
  50247. }, {
  50248. x: 0,
  50249. y: 0,
  50250. w: 0,
  50251. h: 0
  50252. }],
  50253. b._scissorCached = {
  50254. x: 0,
  50255. y: 0,
  50256. z: 0,
  50257. w: 0
  50258. },
  50259. b._stencilRefsCurrent = [-1, -1],
  50260. b._blendColorsCurrent = [[null, null, null, null], [null, null, null, null]],
  50261. b.isNDCHalfZRange = !0,
  50262. b.hasOriginBottomLeft = !1,
  50263. o.deviceDescriptor = o.deviceDescriptor || {},
  50264. o.swapChainFormat = o.swapChainFormat || TextureFormat.BGRA8Unorm,
  50265. o.antialiasing = o.antialiasing === void 0 ? !0 : o.antialiasing,
  50266. o.stencil = (s = o.stencil) !== null && s !== void 0 ? s : !0,
  50267. o.enableGPUDebugMarkers = (c = o.enableGPUDebugMarkers) !== null && c !== void 0 ? c : !1,
  50268. Logger$2.Log("Babylon.js v" + Engine.Version + " - " + b.description + " engine"),
  50269. !navigator.gpu)
  50270. return Logger$2.Error("WebGPU is not supported by your browser."),
  50271. b;
  50272. b._isWebGPU = !0,
  50273. b._shaderPlatformName = "WEBGPU",
  50274. o.deterministicLockstep === void 0 && (o.deterministicLockstep = !1),
  50275. o.lockstepMaxSteps === void 0 && (o.lockstepMaxSteps = 4),
  50276. o.audioEngine === void 0 && (o.audioEngine = !0),
  50277. b._deterministicLockstep = o.deterministicLockstep,
  50278. b._lockstepMaxSteps = o.lockstepMaxSteps,
  50279. b._timeStep = o.timeStep || 1 / 60,
  50280. b._doNotHandleContextLost = !!o.doNotHandleContextLost,
  50281. b._canvas = i,
  50282. b._options = o,
  50283. b.premultipliedAlpha = (d = o.premultipliedAlpha) !== null && d !== void 0 ? d : !0;
  50284. var k = IsWindowObjectExist() && window.devicePixelRatio || 1
  50285. , j = o.limitDeviceRatio || k
  50286. , $ = (_ = o.adaptToDeviceRatio) !== null && _ !== void 0 ? _ : !1;
  50287. return b._hardwareScalingLevel = $ ? 1 / Math.min(j, k) : 1,
  50288. b._mainPassSampleCount = o.antialiasing ? b._defaultSampleCount : 1,
  50289. b._isStencilEnable = o.stencil,
  50290. b._sharedInit(i, !!o.doNotHandleTouchAction, o.audioEngine),
  50291. b._shaderProcessor = new WebGPUShaderProcessorGLSL,
  50292. b._shaderProcessorWGSL = new WebGPUShaderProcessorWGSL,
  50293. b._invertYFinalFramebuffer = (!!b._options.forceCopyForInvertYFinalFramebuffer || !b._canvas.style) && !b._options.disableCopyForInvertYFinalFramebuffer,
  50294. b._invertYFinalFramebuffer || b._canvas.style && (b._canvas.style.transform = "scaleY(-1)"),
  50295. b
  50296. }
  50297. return Object.defineProperty(e.prototype, "snapshotRenderingMode", {
  50298. get: function() {
  50299. return this._snapshotRendering.mode
  50300. },
  50301. set: function(i) {
  50302. this._snapshotRendering.mode = i
  50303. },
  50304. enumerable: !1,
  50305. configurable: !0
  50306. }),
  50307. e.prototype.snapshotRenderingReset = function() {
  50308. this._snapshotRendering.reset()
  50309. }
  50310. ,
  50311. Object.defineProperty(e.prototype, "snapshotRendering", {
  50312. get: function() {
  50313. return this._snapshotRendering.enabled
  50314. },
  50315. set: function(i) {
  50316. this._snapshotRendering.enabled = i
  50317. },
  50318. enumerable: !1,
  50319. configurable: !0
  50320. }),
  50321. Object.defineProperty(e.prototype, "disableCacheSamplers", {
  50322. get: function() {
  50323. return this._cacheSampler ? this._cacheSampler.disabled : !1
  50324. },
  50325. set: function(i) {
  50326. this._cacheSampler && (this._cacheSampler.disabled = i)
  50327. },
  50328. enumerable: !1,
  50329. configurable: !0
  50330. }),
  50331. Object.defineProperty(e.prototype, "disableCacheRenderPipelines", {
  50332. get: function() {
  50333. return this._cacheRenderPipeline ? this._cacheRenderPipeline.disabled : !1
  50334. },
  50335. set: function(i) {
  50336. this._cacheRenderPipeline && (this._cacheRenderPipeline.disabled = i)
  50337. },
  50338. enumerable: !1,
  50339. configurable: !0
  50340. }),
  50341. Object.defineProperty(e.prototype, "disableCacheBindGroups", {
  50342. get: function() {
  50343. return this._cacheBindGroups ? this._cacheBindGroups.disabled : !1
  50344. },
  50345. set: function(i) {
  50346. this._cacheBindGroups && (this._cacheBindGroups.disabled = i)
  50347. },
  50348. enumerable: !1,
  50349. configurable: !0
  50350. }),
  50351. Object.defineProperty(e, "IsSupportedAsync", {
  50352. get: function() {
  50353. return navigator.gpu ? navigator.gpu.requestAdapter().then(function(i) {
  50354. return !!i
  50355. }, function(i) {
  50356. return !1
  50357. }).catch(function(i) {
  50358. return !1
  50359. }) : Promise.resolve(!1)
  50360. },
  50361. enumerable: !1,
  50362. configurable: !0
  50363. }),
  50364. Object.defineProperty(e, "IsSupported", {
  50365. get: function() {
  50366. return Logger$2.Warn("You must call IsSupportedAsync for WebGPU!"),
  50367. !1
  50368. },
  50369. enumerable: !1,
  50370. configurable: !0
  50371. }),
  50372. Object.defineProperty(e.prototype, "supportsUniformBuffers", {
  50373. get: function() {
  50374. return !0
  50375. },
  50376. enumerable: !1,
  50377. configurable: !0
  50378. }),
  50379. Object.defineProperty(e.prototype, "supportedExtensions", {
  50380. get: function() {
  50381. return this._adapterSupportedExtensions
  50382. },
  50383. enumerable: !1,
  50384. configurable: !0
  50385. }),
  50386. Object.defineProperty(e.prototype, "enabledExtensions", {
  50387. get: function() {
  50388. return this._deviceEnabledExtensions
  50389. },
  50390. enumerable: !1,
  50391. configurable: !0
  50392. }),
  50393. Object.defineProperty(e.prototype, "name", {
  50394. get: function() {
  50395. return "WebGPU"
  50396. },
  50397. enumerable: !1,
  50398. configurable: !0
  50399. }),
  50400. Object.defineProperty(e.prototype, "description", {
  50401. get: function() {
  50402. var i = this.name + this.version;
  50403. return i
  50404. },
  50405. enumerable: !1,
  50406. configurable: !0
  50407. }),
  50408. Object.defineProperty(e.prototype, "version", {
  50409. get: function() {
  50410. return 1
  50411. },
  50412. enumerable: !1,
  50413. configurable: !0
  50414. }),
  50415. e.prototype.getInfo = function() {
  50416. return {
  50417. vendor: "unknown vendor",
  50418. renderer: "unknown renderer",
  50419. version: "unknown version"
  50420. }
  50421. }
  50422. ,
  50423. Object.defineProperty(e.prototype, "compatibilityMode", {
  50424. get: function() {
  50425. return this._compatibilityMode
  50426. },
  50427. set: function(i) {
  50428. this._compatibilityMode = i
  50429. },
  50430. enumerable: !1,
  50431. configurable: !0
  50432. }),
  50433. Object.defineProperty(e.prototype, "currentSampleCount", {
  50434. get: function() {
  50435. return this._currentRenderTarget ? this._currentRenderTarget.samples : this._mainPassSampleCount
  50436. },
  50437. enumerable: !1,
  50438. configurable: !0
  50439. }),
  50440. e.CreateAsync = function(i, o) {
  50441. o === void 0 && (o = {});
  50442. var s = new e(i,o);
  50443. return new Promise(function(c) {
  50444. s.initAsync(o.glslangOptions, o.twgslOptions).then(function() {
  50445. return c(s)
  50446. })
  50447. }
  50448. )
  50449. }
  50450. ,
  50451. e.prototype.initAsync = function(i, o) {
  50452. var s = this, c;
  50453. return this._initGlslang(i != null ? i : (c = this._options) === null || c === void 0 ? void 0 : c.glslangOptions).then(function(d) {
  50454. var _;
  50455. return s._glslang = d,
  50456. s._tintWASM = e.UseTWGSL ? new WebGPUTintWASM : null,
  50457. s._tintWASM ? s._tintWASM.initTwgsl(o != null ? o : (_ = s._options) === null || _ === void 0 ? void 0 : _.twgslOptions).then(function() {
  50458. return navigator.gpu.requestAdapter(s._options)
  50459. }, function(b) {
  50460. throw Logger$2.Error("Can not initialize twgsl!"),
  50461. Logger$2.Error(b),
  50462. Error("WebGPU initializations stopped.")
  50463. }) : navigator.gpu.requestAdapter(s._options)
  50464. }, function(d) {
  50465. throw Logger$2.Error("Can not initialize glslang!"),
  50466. Logger$2.Error(d),
  50467. Error("WebGPU initializations stopped.")
  50468. }).then(function(d) {
  50469. var _;
  50470. if (d) {
  50471. s._adapter = d,
  50472. s._adapterSupportedExtensions = [],
  50473. (_ = s._adapter.features) === null || _ === void 0 || _.forEach(function(tt) {
  50474. return s._adapterSupportedExtensions.push(tt)
  50475. });
  50476. var b = s._options.deviceDescriptor;
  50477. if (b != null && b.requiredFeatures) {
  50478. for (var k = b.requiredFeatures, j = [], $ = 0, _e = k; $ < _e.length; $++) {
  50479. var et = _e[$];
  50480. s._adapterSupportedExtensions.indexOf(et) !== -1 && j.push(et)
  50481. }
  50482. b.requiredFeatures = j
  50483. }
  50484. return s._adapter.requestDevice(s._options.deviceDescriptor)
  50485. } else
  50486. throw "Could not retrieve a WebGPU adapter (adapter is null)."
  50487. }).then(function(d) {
  50488. var _, b;
  50489. s._device = d,
  50490. s._deviceEnabledExtensions = [],
  50491. (_ = s._device.features) === null || _ === void 0 || _.forEach(function(j) {
  50492. return s._deviceEnabledExtensions.push(j)
  50493. });
  50494. var k = -1;
  50495. s._device.addEventListener("uncapturederror", function(j) {
  50496. ++k < s.numMaxUncapturedErrors ? Logger$2.Warn("WebGPU uncaptured error (" + (k + 1) + "): " + j.error + " - " + j.error.message) : k++ === s.numMaxUncapturedErrors && Logger$2.Warn("WebGPU uncaptured error: too many warnings (" + s.numMaxUncapturedErrors + "), no more warnings will be reported to the console for this engine.")
  50497. }),
  50498. s._doNotHandleContextLost || (b = s._device.lost) === null || b === void 0 || b.then(function(j) {
  50499. s._contextWasLost = !0,
  50500. Logger$2.Warn("WebGPU context lost. " + j),
  50501. s.onContextLostObservable.notifyObservers(s),
  50502. s._restoreEngineAfterContextLost(s.initAsync.bind(s))
  50503. })
  50504. }, function(d) {
  50505. Logger$2.Error("Could not retrieve a WebGPU device."),
  50506. Logger$2.Error(d)
  50507. }).then(function() {
  50508. s._bufferManager = new WebGPUBufferManager(s._device),
  50509. s._textureHelper = new WebGPUTextureHelper(s._device,s._glslang,s._tintWASM,s._bufferManager),
  50510. s._cacheSampler = new WebGPUCacheSampler(s._device),
  50511. s._cacheBindGroups = new WebGPUCacheBindGroups(s._device,s._cacheSampler,s),
  50512. s._timestampQuery = new WebGPUTimestampQuery(s._device,s._bufferManager),
  50513. s._occlusionQuery = s._device.createQuerySet ? new WebGPUOcclusionQuery(s,s._device,s._bufferManager) : void 0,
  50514. s._bundleList = new WebGPUBundleList(s._device),
  50515. s._bundleListRenderTarget = new WebGPUBundleList(s._device),
  50516. s._snapshotRendering = new WebGPUSnapshotRendering(s,s._snapshotRenderingMode,s._bundleList,s._bundleListRenderTarget),
  50517. s.dbgVerboseLogsForFirstFrames && s._count === void 0 && (s._count = 0,
  50518. console.log("%c frame #" + s._count + " - begin", "background: #ffff00")),
  50519. s._uploadEncoder = s._device.createCommandEncoder(s._uploadEncoderDescriptor),
  50520. s._renderEncoder = s._device.createCommandEncoder(s._renderEncoderDescriptor),
  50521. s._renderTargetEncoder = s._device.createCommandEncoder(s._renderTargetEncoderDescriptor),
  50522. s._emptyVertexBuffer = new VertexBuffer(s,[0],"",!1,!1,1,!1,0,1),
  50523. s._initializeLimits(),
  50524. s._cacheRenderPipeline = new WebGPUCacheRenderPipelineTree(s._device,s._emptyVertexBuffer,!s._caps.textureFloatLinearFiltering),
  50525. s._depthCullingState = new WebGPUDepthCullingState(s._cacheRenderPipeline),
  50526. s._stencilStateComposer = new WebGPUStencilStateComposer(s._cacheRenderPipeline),
  50527. s._stencilStateComposer.stencilGlobal = s._stencilState,
  50528. s._depthCullingState.depthTest = !0,
  50529. s._depthCullingState.depthFunc = 515,
  50530. s._depthCullingState.depthMask = !0,
  50531. s._textureHelper.setCommandEncoder(s._uploadEncoder),
  50532. s._clearQuad = new WebGPUClearQuad(s._device,s,s._emptyVertexBuffer),
  50533. s._defaultDrawContext = s.createDrawContext(),
  50534. s._currentDrawContext = s._defaultDrawContext,
  50535. s._defaultMaterialContext = s.createMaterialContext(),
  50536. s._currentMaterialContext = s._defaultMaterialContext,
  50537. s._initializeContextAndSwapChain(),
  50538. s._initializeMainAttachments(),
  50539. s.resize()
  50540. }).catch(function(d) {
  50541. Logger$2.Error("Can not create WebGPU Device and/or context."),
  50542. Logger$2.Error(d),
  50543. console.trace && console.trace()
  50544. })
  50545. }
  50546. ,
  50547. e.prototype._initGlslang = function(i) {
  50548. return i = i || {},
  50549. i = __assign(__assign({}, e._glslangDefaultOptions), i),
  50550. i.glslang ? Promise.resolve(i.glslang) : self.glslang ? self.glslang(i.wasmPath) : i.jsPath && i.wasmPath ? IsWindowObjectExist() ? Tools.LoadScriptAsync(i.jsPath).then(function() {
  50551. return self.glslang(i.wasmPath)
  50552. }) : (importScripts(i.jsPath),
  50553. self.glslang(i.wasmPath)) : Promise.reject("gslang is not available.")
  50554. }
  50555. ,
  50556. e.prototype._initializeLimits = function() {
  50557. this._caps = {
  50558. maxTexturesImageUnits: 16,
  50559. maxVertexTextureImageUnits: 16,
  50560. maxCombinedTexturesImageUnits: 32,
  50561. maxTextureSize: 8192,
  50562. maxCubemapTextureSize: 2048,
  50563. maxRenderTextureSize: 8192,
  50564. maxVertexAttribs: 16,
  50565. maxVaryingVectors: 15,
  50566. maxFragmentUniformVectors: 1024,
  50567. maxVertexUniformVectors: 1024,
  50568. standardDerivatives: !0,
  50569. astc: null,
  50570. s3tc: this._deviceEnabledExtensions.indexOf(FeatureName.TextureCompressionBC) >= 0 ? !0 : void 0,
  50571. pvrtc: null,
  50572. etc1: null,
  50573. etc2: null,
  50574. bptc: this._deviceEnabledExtensions.indexOf(FeatureName.TextureCompressionBC) >= 0 ? !0 : void 0,
  50575. maxAnisotropy: 4,
  50576. uintIndices: !0,
  50577. fragmentDepthSupported: !0,
  50578. highPrecisionShaderSupported: !0,
  50579. colorBufferFloat: !0,
  50580. textureFloat: !0,
  50581. textureFloatLinearFiltering: !1,
  50582. textureFloatRender: !0,
  50583. textureHalfFloat: !0,
  50584. textureHalfFloatLinearFiltering: !0,
  50585. textureHalfFloatRender: !0,
  50586. textureLOD: !0,
  50587. drawBuffersExtension: !0,
  50588. depthTextureExtension: !0,
  50589. vertexArrayObject: !1,
  50590. instancedArrays: !0,
  50591. timerQuery: typeof BigUint64Array != "undefined" && this.enabledExtensions.indexOf(FeatureName.TimestampQuery) !== -1 ? !0 : void 0,
  50592. supportOcclusionQuery: typeof BigUint64Array != "undefined",
  50593. canUseTimestampForTimerQuery: !0,
  50594. multiview: !1,
  50595. oculusMultiview: !1,
  50596. parallelShaderCompile: void 0,
  50597. blendMinMax: !0,
  50598. maxMSAASamples: 4,
  50599. canUseGLInstanceID: !0,
  50600. canUseGLVertexID: !0,
  50601. supportComputeShaders: !0,
  50602. supportSRGBBuffers: !0
  50603. },
  50604. this._caps.parallelShaderCompile = null,
  50605. this._features = {
  50606. forceBitmapOverHTMLImageElement: !0,
  50607. supportRenderAndCopyToLodForFloatTextures: !0,
  50608. supportDepthStencilTexture: !0,
  50609. supportShadowSamplers: !0,
  50610. uniformBufferHardCheckMatrix: !1,
  50611. allowTexturePrefiltering: !0,
  50612. trackUbosInFrame: !0,
  50613. checkUbosContentBeforeUpload: !0,
  50614. supportCSM: !0,
  50615. basisNeedsPOT: !1,
  50616. support3DTextures: !0,
  50617. needTypeSuffixInShaderConstants: !0,
  50618. supportMSAA: !0,
  50619. supportSSAO2: !0,
  50620. supportExtendedTextureFormats: !0,
  50621. supportSwitchCaseInShader: !0,
  50622. supportSyncTextureRead: !1,
  50623. needsInvertingBitmap: !1,
  50624. useUBOBindingCache: !1,
  50625. needShaderCodeInlining: !0,
  50626. needToAlwaysBindUniformBuffers: !0,
  50627. supportRenderPasses: !0,
  50628. _collectUbosUpdatedInFrame: !1
  50629. }
  50630. }
  50631. ,
  50632. e.prototype._initializeContextAndSwapChain = function() {
  50633. this._context = this._canvas.getContext("webgpu"),
  50634. this._configureContext(this._canvas.width, this._canvas.height),
  50635. this._colorFormat = this._options.swapChainFormat,
  50636. this._mainRenderPassWrapper.colorAttachmentGPUTextures = [new WebGPUHardwareTexture],
  50637. this._mainRenderPassWrapper.colorAttachmentGPUTextures[0].format = this._colorFormat,
  50638. this._invertYFinalFramebuffer && (this._mainRenderPassCopyWrapper.colorAttachmentGPUTextures = [new WebGPUHardwareTexture],
  50639. this._mainRenderPassCopyWrapper.colorAttachmentGPUTextures[0].format = this._colorFormat)
  50640. }
  50641. ,
  50642. e.prototype._initializeMainAttachments = function() {
  50643. var i, o;
  50644. this._mainTextureExtends = {
  50645. width: this.getRenderWidth(),
  50646. height: this.getRenderHeight(),
  50647. depthOrArrayLayers: 1
  50648. };
  50649. var s;
  50650. if (this._options.antialiasing) {
  50651. var c = {
  50652. size: this._mainTextureExtends,
  50653. mipLevelCount: 1,
  50654. sampleCount: this._mainPassSampleCount,
  50655. dimension: TextureDimension.E2d,
  50656. format: this._options.swapChainFormat,
  50657. usage: TextureUsage.RenderAttachment
  50658. };
  50659. (i = this._mainTexture) === null || i === void 0 || i.destroy(),
  50660. this._mainTexture = this._device.createTexture(c),
  50661. s = [{
  50662. view: this._mainTexture.createView(),
  50663. loadValue: new Color4(0,0,0,1),
  50664. storeOp: StoreOp.Store
  50665. }]
  50666. } else
  50667. s = [{
  50668. view: void 0,
  50669. loadValue: new Color4(0,0,0,1),
  50670. storeOp: StoreOp.Store
  50671. }];
  50672. if (this._invertYFinalFramebuffer) {
  50673. var d = {
  50674. size: this._mainTextureExtends,
  50675. mipLevelCount: 1,
  50676. sampleCount: 1,
  50677. dimension: TextureDimension.E2d,
  50678. format: this._options.swapChainFormat,
  50679. usage: TextureUsage.RenderAttachment | TextureUsage.TextureBinding
  50680. };
  50681. (o = this._mainTextureLastCopy) === null || o === void 0 || o.destroy(),
  50682. this._mainTextureLastCopy = this._device.createTexture(d),
  50683. this._options.antialiasing ? s[0].resolveTarget = this._mainTextureLastCopy.createView() : s[0].view = this._mainTextureLastCopy.createView(),
  50684. this._mainRenderPassCopyWrapper.renderPassDescriptor = {
  50685. colorAttachments: [{
  50686. view: void 0,
  50687. loadValue: new Color4(0,0,0,1),
  50688. storeOp: StoreOp.Store
  50689. }]
  50690. }
  50691. }
  50692. this._mainRenderPassWrapper.depthTextureFormat = this.isStencilEnable ? TextureFormat.Depth24PlusStencil8 : TextureFormat.Depth32Float,
  50693. this._setDepthTextureFormat(this._mainRenderPassWrapper);
  50694. var _ = {
  50695. size: this._mainTextureExtends,
  50696. mipLevelCount: 1,
  50697. sampleCount: this._mainPassSampleCount,
  50698. dimension: TextureDimension.E2d,
  50699. format: this._mainRenderPassWrapper.depthTextureFormat,
  50700. usage: TextureUsage.RenderAttachment
  50701. };
  50702. this._depthTexture && this._depthTexture.destroy(),
  50703. this._depthTexture = this._device.createTexture(_);
  50704. var b = {
  50705. view: this._depthTexture.createView(),
  50706. depthLoadValue: this._clearDepthValue,
  50707. depthStoreOp: StoreOp.Store,
  50708. stencilLoadValue: this._clearStencilValue,
  50709. stencilStoreOp: StoreOp.Store
  50710. };
  50711. this._mainRenderPassWrapper.renderPassDescriptor = {
  50712. colorAttachments: s,
  50713. depthStencilAttachment: b
  50714. },
  50715. this._mainRenderPassWrapper.renderPass !== null && this._endMainRenderPass()
  50716. }
  50717. ,
  50718. e.prototype._configureContext = function(i, o) {
  50719. this._context.configure({
  50720. device: this._device,
  50721. format: this._options.swapChainFormat,
  50722. usage: TextureUsage.RenderAttachment | TextureUsage.CopySrc,
  50723. compositingAlphaMode: this.premultipliedAlpha ? CanvasCompositingAlphaMode.Premultiplied : CanvasCompositingAlphaMode.Opaque,
  50724. size: {
  50725. width: i,
  50726. height: o,
  50727. depthOrArrayLayers: 1
  50728. }
  50729. })
  50730. }
  50731. ,
  50732. e.prototype.setSize = function(i, o, s) {
  50733. return s === void 0 && (s = !1),
  50734. a.prototype.setSize.call(this, i, o, s) ? (this.dbgVerboseLogsForFirstFrames && (this._count === void 0 && (this._count = 0),
  50735. (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - setSize called -", i, o)),
  50736. this._configureContext(i, o),
  50737. this._initializeMainAttachments(),
  50738. this.snapshotRendering && this.snapshotRenderingReset(),
  50739. !0) : !1
  50740. }
  50741. ,
  50742. e.prototype._getShaderProcessor = function(i) {
  50743. return i === ShaderLanguage.WGSL ? this._shaderProcessorWGSL : this._shaderProcessor
  50744. }
  50745. ,
  50746. e.prototype._getShaderProcessingContext = function(i) {
  50747. return new WebGPUShaderProcessingContext(i)
  50748. }
  50749. ,
  50750. e.prototype.applyStates = function() {
  50751. this._stencilStateComposer.apply(),
  50752. this._cacheRenderPipeline.setAlphaBlendEnabled(this._alphaState.alphaBlend)
  50753. }
  50754. ,
  50755. e.prototype.wipeCaches = function(i) {
  50756. this.preventCacheWipeBetweenFrames && !i || (this._forceEnableEffect = !0,
  50757. this._currentIndexBuffer = null,
  50758. this._currentOverrideVertexBuffers = null,
  50759. this._cacheRenderPipeline.setBuffers(null, null, null),
  50760. i && (this._stencilStateComposer.reset(),
  50761. this._depthCullingState.reset(),
  50762. this._depthCullingState.depthFunc = 515,
  50763. this._alphaState.reset(),
  50764. this._alphaMode = 1,
  50765. this._alphaEquation = 0,
  50766. this._cacheRenderPipeline.setAlphaBlendFactors(this._alphaState._blendFunctionParameters, this._alphaState._blendEquationParameters),
  50767. this._cacheRenderPipeline.setAlphaBlendEnabled(!1),
  50768. this.setColorWrite(!0)),
  50769. this._cachedVertexBuffers = null,
  50770. this._cachedIndexBuffer = null,
  50771. this._cachedEffectForVertexBuffers = null)
  50772. }
  50773. ,
  50774. e.prototype.setColorWrite = function(i) {
  50775. this.__colorWrite = i,
  50776. this._cacheRenderPipeline.setWriteMask(i ? 15 : 0)
  50777. }
  50778. ,
  50779. e.prototype.getColorWrite = function() {
  50780. return this.__colorWrite
  50781. }
  50782. ,
  50783. e.prototype._resetCurrentViewport = function(i) {
  50784. this._viewportsCurrent[i].x = 0,
  50785. this._viewportsCurrent[i].y = 0,
  50786. this._viewportsCurrent[i].w = 0,
  50787. this._viewportsCurrent[i].h = 0,
  50788. i === 1 && (this._viewportCached.x = 0,
  50789. this._viewportCached.y = 0,
  50790. this._viewportCached.z = 0,
  50791. this._viewportCached.w = 0)
  50792. }
  50793. ,
  50794. e.prototype._mustUpdateViewport = function(i) {
  50795. var o = i === this._mainRenderPassWrapper.renderPass ? 0 : 1
  50796. , s = this._viewportCached.x
  50797. , c = this._viewportCached.y
  50798. , d = this._viewportCached.z
  50799. , _ = this._viewportCached.w
  50800. , b = this._viewportsCurrent[o].x !== s || this._viewportsCurrent[o].y !== c || this._viewportsCurrent[o].w !== d || this._viewportsCurrent[o].h !== _;
  50801. return b && (this._viewportsCurrent[o].x = this._viewportCached.x,
  50802. this._viewportsCurrent[o].y = this._viewportCached.y,
  50803. this._viewportsCurrent[o].w = this._viewportCached.z,
  50804. this._viewportsCurrent[o].h = this._viewportCached.w),
  50805. b
  50806. }
  50807. ,
  50808. e.prototype._applyViewport = function(i) {
  50809. i.setViewport(Math.floor(this._viewportCached.x), Math.floor(this._viewportCached.y), Math.floor(this._viewportCached.z), Math.floor(this._viewportCached.w), 0, 1),
  50810. this.dbgVerboseLogsForFirstFrames && (this._count === void 0 && (this._count = 0),
  50811. (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - viewport applied - (", this._viewportCached.x, this._viewportCached.y, this._viewportCached.z, this._viewportCached.w, ") current pass is main pass=" + (i === this._mainRenderPassWrapper.renderPass)))
  50812. }
  50813. ,
  50814. e.prototype._viewport = function(i, o, s, c) {
  50815. this._viewportCached.x = i,
  50816. this._viewportCached.y = o,
  50817. this._viewportCached.z = s,
  50818. this._viewportCached.w = c
  50819. }
  50820. ,
  50821. e.prototype._resetCurrentScissor = function(i) {
  50822. this._scissorsCurrent[i].x = 0,
  50823. this._scissorsCurrent[i].y = 0,
  50824. this._scissorsCurrent[i].w = 0,
  50825. this._scissorsCurrent[i].h = 0
  50826. }
  50827. ,
  50828. e.prototype._mustUpdateScissor = function(i) {
  50829. var o = i === this._mainRenderPassWrapper.renderPass ? 0 : 1
  50830. , s = this._scissorCached.x
  50831. , c = this._scissorCached.y
  50832. , d = this._scissorCached.z
  50833. , _ = this._scissorCached.w
  50834. , b = this._scissorsCurrent[o].x !== s || this._scissorsCurrent[o].y !== c || this._scissorsCurrent[o].w !== d || this._scissorsCurrent[o].h !== _;
  50835. return b && (this._scissorsCurrent[o].x = this._scissorCached.x,
  50836. this._scissorsCurrent[o].y = this._scissorCached.y,
  50837. this._scissorsCurrent[o].w = this._scissorCached.z,
  50838. this._scissorsCurrent[o].h = this._scissorCached.w),
  50839. b
  50840. }
  50841. ,
  50842. e.prototype._applyScissor = function(i) {
  50843. i.setScissorRect(this._scissorCached.x, this._scissorCached.y, this._scissorCached.z, this._scissorCached.w),
  50844. this.dbgVerboseLogsForFirstFrames && (this._count === void 0 && (this._count = 0),
  50845. (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - scissor applied - (", this._scissorCached.x, this._scissorCached.y, this._scissorCached.z, this._scissorCached.w, ") current pass is main pass=" + (i === this._mainRenderPassWrapper.renderPass)))
  50846. }
  50847. ,
  50848. e.prototype._scissorIsActive = function() {
  50849. return this._scissorCached.x !== 0 || this._scissorCached.y !== 0 || this._scissorCached.z !== 0 || this._scissorCached.w !== 0
  50850. }
  50851. ,
  50852. e.prototype.enableScissor = function(i, o, s, c) {
  50853. this._scissorCached.x = i,
  50854. this._scissorCached.y = o,
  50855. this._scissorCached.z = s,
  50856. this._scissorCached.w = c
  50857. }
  50858. ,
  50859. e.prototype.disableScissor = function() {
  50860. this._scissorCached.x = 0,
  50861. this._scissorCached.y = 0,
  50862. this._scissorCached.z = 0,
  50863. this._scissorCached.w = 0,
  50864. this._resetCurrentScissor(0),
  50865. this._resetCurrentScissor(1)
  50866. }
  50867. ,
  50868. e.prototype._resetCurrentStencilRef = function(i) {
  50869. this._stencilRefsCurrent[i] = -1
  50870. }
  50871. ,
  50872. e.prototype._mustUpdateStencilRef = function(i) {
  50873. var o = i === this._mainRenderPassWrapper.renderPass ? 0 : 1
  50874. , s = this._stencilStateComposer.funcRef !== this._stencilRefsCurrent[o];
  50875. return s && (this._stencilRefsCurrent[o] = this._stencilStateComposer.funcRef),
  50876. s
  50877. }
  50878. ,
  50879. e.prototype._applyStencilRef = function(i) {
  50880. var o;
  50881. i.setStencilReference((o = this._stencilStateComposer.funcRef) !== null && o !== void 0 ? o : 0)
  50882. }
  50883. ,
  50884. e.prototype._resetCurrentColorBlend = function(i) {
  50885. this._blendColorsCurrent[i][0] = this._blendColorsCurrent[i][1] = this._blendColorsCurrent[i][2] = this._blendColorsCurrent[i][3] = null
  50886. }
  50887. ,
  50888. e.prototype._mustUpdateBlendColor = function(i) {
  50889. var o = i === this._mainRenderPassWrapper.renderPass ? 0 : 1
  50890. , s = this._alphaState._blendConstants
  50891. , c = s[0] !== this._blendColorsCurrent[o][0] || s[1] !== this._blendColorsCurrent[o][1] || s[2] !== this._blendColorsCurrent[o][2] || s[3] !== this._blendColorsCurrent[o][3];
  50892. return c && (this._blendColorsCurrent[o][0] = s[0],
  50893. this._blendColorsCurrent[o][1] = s[1],
  50894. this._blendColorsCurrent[o][2] = s[2],
  50895. this._blendColorsCurrent[o][3] = s[3]),
  50896. c
  50897. }
  50898. ,
  50899. e.prototype._applyBlendColor = function(i) {
  50900. i.setBlendConstant(this._alphaState._blendConstants)
  50901. }
  50902. ,
  50903. e.prototype.clear = function(i, o, s, c) {
  50904. c === void 0 && (c = !1),
  50905. i && i.a === void 0 && (i.a = 1);
  50906. var d = this._scissorIsActive();
  50907. this.dbgVerboseLogsForFirstFrames && (this._count === void 0 && (this._count = 0),
  50908. (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - clear called - backBuffer=", o, " depth=", s, " stencil=", c, " scissor is active=", d)),
  50909. this._currentRenderTarget ? d ? (this._rttRenderPassWrapper.renderPass || this._startRenderTargetRenderPass(this._currentRenderTarget, !1, o ? i : null, s, c),
  50910. this.compatibilityMode ? this._applyScissor(this._currentRenderPass) : this._bundleListRenderTarget.addItem(new WebGPURenderItemScissor(this._scissorCached.x,this._scissorCached.y,this._scissorCached.z,this._scissorCached.w)),
  50911. this._clearFullQuad(o ? i : null, s, c)) : (this._currentRenderPass && this._endRenderTargetRenderPass(),
  50912. this._startRenderTargetRenderPass(this._currentRenderTarget, !0, o ? i : null, s, c)) : ((!this._mainRenderPassWrapper.renderPass || !d) && this._startMainRenderPass(!d, o ? i : null, s, c),
  50913. d && (this.compatibilityMode ? this._applyScissor(this._currentRenderPass) : this._bundleList.addItem(new WebGPURenderItemScissor(this._scissorCached.x,this._scissorCached.y,this._scissorCached.z,this._scissorCached.w)),
  50914. this._clearFullQuad(o ? i : null, s, c)))
  50915. }
  50916. ,
  50917. e.prototype._clearFullQuad = function(i, o, s) {
  50918. var c, d, _, b = this.compatibilityMode ? this._getCurrentRenderPass() : null, k = this._getCurrentRenderPassIndex(), j = k === 0 ? this._bundleList : this._bundleListRenderTarget;
  50919. this._clearQuad.setColorFormat(this._colorFormat),
  50920. this._clearQuad.setDepthStencilFormat(this._depthTextureFormat),
  50921. this._clearQuad.setMRTAttachments((c = this._cacheRenderPipeline.mrtAttachments) !== null && c !== void 0 ? c : [], (d = this._cacheRenderPipeline.mrtTextureArray) !== null && d !== void 0 ? d : []),
  50922. this.compatibilityMode ? b.setStencilReference(this._clearStencilValue) : j.addItem(new WebGPURenderItemStencilRef(this._clearStencilValue));
  50923. var $ = this._clearQuad.clear(b, i, o, s, this.currentSampleCount);
  50924. this.compatibilityMode ? this._applyStencilRef(b) : (j.addBundle($),
  50925. j.addItem(new WebGPURenderItemStencilRef((_ = this._stencilStateComposer.funcRef) !== null && _ !== void 0 ? _ : 0)),
  50926. this._reportDrawCall())
  50927. }
  50928. ,
  50929. e.prototype.createVertexBuffer = function(i) {
  50930. var o;
  50931. i instanceof Array ? o = new Float32Array(i) : i instanceof ArrayBuffer ? o = new Uint8Array(i) : o = i;
  50932. var s = this._bufferManager.createBuffer(o, BufferUsage.Vertex | BufferUsage.CopyDst);
  50933. return s
  50934. }
  50935. ,
  50936. e.prototype.createDynamicVertexBuffer = function(i) {
  50937. return this.createVertexBuffer(i)
  50938. }
  50939. ,
  50940. e.prototype.createIndexBuffer = function(i, o) {
  50941. var s = !0, c;
  50942. i instanceof Uint32Array || i instanceof Int32Array ? c = i : i instanceof Uint16Array ? (c = i,
  50943. s = !1) : i.length > 65535 ? c = new Uint32Array(i) : (c = new Uint16Array(i),
  50944. s = !1);
  50945. var d = this._bufferManager.createBuffer(c, BufferUsage.Index | BufferUsage.CopyDst);
  50946. return d.is32Bits = s,
  50947. d
  50948. }
  50949. ,
  50950. e.prototype._createBuffer = function(i, o) {
  50951. var s;
  50952. i instanceof Array ? s = new Float32Array(i) : i instanceof ArrayBuffer ? s = new Uint8Array(i) : s = i;
  50953. var c = 0;
  50954. return o & 1 && (c |= BufferUsage.CopySrc),
  50955. o & 2 && (c |= BufferUsage.CopyDst),
  50956. o & 4 && (c |= BufferUsage.Uniform),
  50957. o & 8 && (c |= BufferUsage.Vertex),
  50958. o & 16 && (c |= BufferUsage.Index),
  50959. o & 32 && (c |= BufferUsage.Storage),
  50960. this._bufferManager.createBuffer(s, c)
  50961. }
  50962. ,
  50963. e.prototype.bindBuffersDirectly = function(i, o, s, c, d) {
  50964. throw "Not implemented on WebGPU"
  50965. }
  50966. ,
  50967. e.prototype.updateAndBindInstancesBuffer = function(i, o, s) {
  50968. throw "Not implemented on WebGPU"
  50969. }
  50970. ,
  50971. e.prototype.bindBuffers = function(i, o, s, c) {
  50972. this._currentIndexBuffer = o,
  50973. this._currentOverrideVertexBuffers = c != null ? c : null,
  50974. this._cacheRenderPipeline.setBuffers(i, o, this._currentOverrideVertexBuffers)
  50975. }
  50976. ,
  50977. e.prototype._releaseBuffer = function(i) {
  50978. return this._bufferManager.releaseBuffer(i)
  50979. }
  50980. ,
  50981. e.prototype.createEffect = function(i, o, s, c, d, _, b, k, j, $) {
  50982. var _e;
  50983. $ === void 0 && ($ = ShaderLanguage.GLSL);
  50984. var et = i.vertexElement || i.vertex || i.vertexToken || i.vertexSource || i
  50985. , tt = i.fragmentElement || i.fragment || i.fragmentToken || i.fragmentSource || i
  50986. , rt = this._getGlobalDefines()
  50987. , it = (_e = d != null ? d : o.defines) !== null && _e !== void 0 ? _e : "";
  50988. rt && (it += `
  50989. ` + rt);
  50990. var nt = et + "+" + tt + "@" + it;
  50991. if (this._compiledEffects[nt]) {
  50992. var ot = this._compiledEffects[nt];
  50993. return b && ot.isReady() && b(ot),
  50994. ot
  50995. }
  50996. var at = new Effect(i,o,s,c,this,d,_,b,k,j,nt,$);
  50997. return this._compiledEffects[nt] = at,
  50998. at
  50999. }
  51000. ,
  51001. e.prototype._compileRawShaderToSpirV = function(i, o) {
  51002. return this._glslang.compileGLSL(i, o)
  51003. }
  51004. ,
  51005. e.prototype._compileShaderToSpirV = function(i, o, s, c) {
  51006. return this._compileRawShaderToSpirV(c + (s ? s + `
  51007. ` : "") + i, o)
  51008. }
  51009. ,
  51010. e.prototype._getWGSLShader = function(i, o, s, c) {
  51011. return s ? s = "//" + s.split(`
  51012. `).join(`
  51013. //`) + `
  51014. ` : s = "",
  51015. s + i
  51016. }
  51017. ,
  51018. e.prototype._createPipelineStageDescriptor = function(i, o, s) {
  51019. return this._tintWASM && s === ShaderLanguage.GLSL && (i = this._tintWASM.convertSpirV2WGSL(i),
  51020. o = this._tintWASM.convertSpirV2WGSL(o)),
  51021. {
  51022. vertexStage: {
  51023. module: this._device.createShaderModule({
  51024. code: i
  51025. }),
  51026. entryPoint: "main"
  51027. },
  51028. fragmentStage: {
  51029. module: this._device.createShaderModule({
  51030. code: o
  51031. }),
  51032. entryPoint: "main"
  51033. }
  51034. }
  51035. }
  51036. ,
  51037. e.prototype._compileRawPipelineStageDescriptor = function(i, o, s) {
  51038. var c = s === ShaderLanguage.GLSL ? this._compileRawShaderToSpirV(i, "vertex") : i
  51039. , d = s === ShaderLanguage.GLSL ? this._compileRawShaderToSpirV(o, "fragment") : o;
  51040. return this._createPipelineStageDescriptor(c, d, s)
  51041. }
  51042. ,
  51043. e.prototype._compilePipelineStageDescriptor = function(i, o, s, c) {
  51044. this.onBeforeShaderCompilationObservable.notifyObservers(this);
  51045. var d = `#version 450
  51046. `
  51047. , _ = c === ShaderLanguage.GLSL ? this._compileShaderToSpirV(i, "vertex", s, d) : this._getWGSLShader(i, "vertex", s, d)
  51048. , b = c === ShaderLanguage.GLSL ? this._compileShaderToSpirV(o, "fragment", s, d) : this._getWGSLShader(o, "fragment", s, d)
  51049. , k = this._createPipelineStageDescriptor(_, b, c);
  51050. return this.onAfterShaderCompilationObservable.notifyObservers(this),
  51051. k
  51052. }
  51053. ,
  51054. e.prototype.createRawShaderProgram = function(i, o, s, c, d) {
  51055. throw "Not available on WebGPU"
  51056. }
  51057. ,
  51058. e.prototype.createShaderProgram = function(i, o, s, c, d, _) {
  51059. throw "Not available on WebGPU"
  51060. }
  51061. ,
  51062. e.prototype.inlineShaderCode = function(i) {
  51063. var o = new ShaderCodeInliner(i);
  51064. return o.debug = !1,
  51065. o.processCode(),
  51066. o.code
  51067. }
  51068. ,
  51069. e.prototype.createPipelineContext = function(i) {
  51070. return new WebGPUPipelineContext(i,this)
  51071. }
  51072. ,
  51073. e.prototype.createMaterialContext = function() {
  51074. return new WebGPUMaterialContext
  51075. }
  51076. ,
  51077. e.prototype.createDrawContext = function() {
  51078. return new WebGPUDrawContext(this._bufferManager)
  51079. }
  51080. ,
  51081. e.prototype._preparePipelineContext = function(i, o, s, c, d, _, b, k, j, $) {
  51082. var _e = i
  51083. , et = _e.shaderProcessingContext.shaderLanguage;
  51084. this.dbgShowShaderCode && (console.log(k),
  51085. console.log(o),
  51086. console.log(s)),
  51087. _e.sources = {
  51088. fragment: s,
  51089. vertex: o,
  51090. rawVertex: d,
  51091. rawFragment: _
  51092. },
  51093. c ? _e.stages = this._compileRawPipelineStageDescriptor(o, s, et) : _e.stages = this._compilePipelineStageDescriptor(o, s, k, et)
  51094. }
  51095. ,
  51096. e.prototype.getAttributes = function(i, o) {
  51097. for (var s = new Array(o.length), c = i, d = 0; d < o.length; d++) {
  51098. var _ = o[d]
  51099. , b = c.shaderProcessingContext.availableAttributes[_];
  51100. b !== void 0 && (s[d] = b)
  51101. }
  51102. return s
  51103. }
  51104. ,
  51105. e.prototype.enableEffect = function(i) {
  51106. if (!!i) {
  51107. var o = !0;
  51108. if (!DrawWrapper.IsWrapper(i))
  51109. o = i !== this._currentEffect,
  51110. this._currentEffect = i,
  51111. this._currentMaterialContext = this._defaultMaterialContext,
  51112. this._currentDrawContext = this._defaultDrawContext,
  51113. this._counters.numEnableEffects++,
  51114. this.dbgLogIfNotDrawWrapper && Logger$2.Warn("enableEffect has been called with an Effect and not a Wrapper! effect.uniqueId=" + i.uniqueId + ", effect.name=" + i.name + ", effect.name.vertex=" + i.name.vertex + ", effect.name.fragment=" + i.name.fragment, 10);
  51115. else if (!i.effect || i.effect === this._currentEffect && i.materialContext === this._currentMaterialContext && i.drawContext === this._currentDrawContext && !this._forceEnableEffect) {
  51116. if (!i.effect && this.dbgShowEmptyEnableEffectCalls)
  51117. throw console.error("drawWrapper=", i),
  51118. "Invalid call to enableEffect: the effect property is empty!";
  51119. return
  51120. } else if (o = i.effect !== this._currentEffect,
  51121. this._currentEffect = i.effect,
  51122. this._currentMaterialContext = i.materialContext,
  51123. this._currentDrawContext = i.drawContext,
  51124. this._counters.numEnableDrawWrapper++,
  51125. !this._currentMaterialContext)
  51126. throw console.error("drawWrapper=", i),
  51127. "Invalid call to enableEffect: the materialContext property is empty!";
  51128. this._stencilStateComposer.stencilMaterial = void 0,
  51129. this._forceEnableEffect = o || this._forceEnableEffect ? !1 : this._forceEnableEffect,
  51130. o && (this._currentEffect.onBind && this._currentEffect.onBind(this._currentEffect),
  51131. this._currentEffect._onBindObservable && this._currentEffect._onBindObservable.notifyObservers(this._currentEffect))
  51132. }
  51133. }
  51134. ,
  51135. e.prototype._releaseEffect = function(i) {
  51136. this._compiledEffects[i._key] && (delete this._compiledEffects[i._key],
  51137. this._deletePipelineContext(i.getPipelineContext()))
  51138. }
  51139. ,
  51140. e.prototype.releaseEffects = function() {
  51141. for (var i in this._compiledEffects) {
  51142. var o = this._compiledEffects[i].getPipelineContext();
  51143. this._deletePipelineContext(o)
  51144. }
  51145. this._compiledEffects = {}
  51146. }
  51147. ,
  51148. e.prototype._deletePipelineContext = function(i) {
  51149. var o = i;
  51150. o && i.dispose()
  51151. }
  51152. ,
  51153. Object.defineProperty(e.prototype, "needPOTTextures", {
  51154. get: function() {
  51155. return !1
  51156. },
  51157. enumerable: !1,
  51158. configurable: !0
  51159. }),
  51160. e.prototype._createHardwareTexture = function() {
  51161. return new WebGPUHardwareTexture
  51162. }
  51163. ,
  51164. e.prototype._releaseTexture = function(i) {
  51165. var o = this._internalTexturesCache.indexOf(i);
  51166. o !== -1 && this._internalTexturesCache.splice(o, 1),
  51167. this._textureHelper.releaseTexture(i)
  51168. }
  51169. ,
  51170. e.prototype._getRGBABufferInternalSizedFormat = function(i, o) {
  51171. return 5
  51172. }
  51173. ,
  51174. e.prototype.updateTextureComparisonFunction = function(i, o) {
  51175. i._comparisonFunction = o
  51176. }
  51177. ,
  51178. e.prototype._createInternalTexture = function(i, o, s, c) {
  51179. var d, _;
  51180. s === void 0 && (s = !0),
  51181. c === void 0 && (c = InternalTextureSource.Unknown);
  51182. var b = {};
  51183. o !== void 0 && typeof o == "object" ? (b.generateMipMaps = o.generateMipMaps,
  51184. b.type = o.type === void 0 ? 0 : o.type,
  51185. b.samplingMode = o.samplingMode === void 0 ? 3 : o.samplingMode,
  51186. b.format = o.format === void 0 ? 5 : o.format,
  51187. b.samples = (d = o.samples) !== null && d !== void 0 ? d : 1,
  51188. b.creationFlags = (_ = o.creationFlags) !== null && _ !== void 0 ? _ : 0) : (b.generateMipMaps = o,
  51189. b.type = 0,
  51190. b.samplingMode = 3,
  51191. b.format = 5,
  51192. b.samples = 1,
  51193. b.creationFlags = 0),
  51194. (b.type === 1 && !this._caps.textureFloatLinearFiltering || b.type === 2 && !this._caps.textureHalfFloatLinearFiltering) && (b.samplingMode = 1),
  51195. b.type === 1 && !this._caps.textureFloat && (b.type = 0,
  51196. Logger$2.Warn("Float textures are not supported. Type forced to TEXTURETYPE_UNSIGNED_BYTE"));
  51197. var k = new InternalTexture(this,c)
  51198. , j = i.width || i
  51199. , $ = i.height || i
  51200. , _e = i.layers || 0;
  51201. return k.baseWidth = j,
  51202. k.baseHeight = $,
  51203. k.width = j,
  51204. k.height = $,
  51205. k.depth = _e,
  51206. k.isReady = !0,
  51207. k.samples = b.samples,
  51208. k.generateMipMaps = !!b.generateMipMaps,
  51209. k.samplingMode = b.samplingMode,
  51210. k.type = b.type,
  51211. k.format = b.format,
  51212. k.is2DArray = _e > 0,
  51213. k._cachedWrapU = 0,
  51214. k._cachedWrapV = 0,
  51215. this._internalTexturesCache.push(k),
  51216. s || this._textureHelper.createGPUTextureForInternalTexture(k, j, $, _e || 1, b.creationFlags),
  51217. k
  51218. }
  51219. ,
  51220. e.prototype.createTexture = function(i, o, s, c, d, _, b, k, j, $, _e, et, tt, rt, it) {
  51221. var nt = this;
  51222. return d === void 0 && (d = 3),
  51223. _ === void 0 && (_ = null),
  51224. b === void 0 && (b = null),
  51225. k === void 0 && (k = null),
  51226. j === void 0 && (j = null),
  51227. $ === void 0 && ($ = null),
  51228. _e === void 0 && (_e = null),
  51229. this._createTextureBase(i, o, s, c, d, _, b, function(ot, at, st, ut, ct, lt, ft, ht, pt) {
  51230. var dt, _t = ut;
  51231. if (ot.baseWidth = _t.width,
  51232. ot.baseHeight = _t.height,
  51233. ot.width = _t.width,
  51234. ot.height = _t.height,
  51235. ot.format = $ != null ? $ : -1,
  51236. ht(ot.width, ot.height, _t, at, ot, function() {}),
  51237. !((dt = ot._hardwareTexture) === null || dt === void 0) && dt.underlyingResource)
  51238. !lt && !ft && nt._generateMipmaps(ot, nt._uploadEncoder);
  51239. else {
  51240. var mt = nt._textureHelper.createGPUTextureForInternalTexture(ot, _t.width, _t.height, void 0, rt);
  51241. WebGPUTextureHelper.IsImageBitmap(_t) && (nt._textureHelper.updateTexture(_t, ot, _t.width, _t.height, ot.depth, mt.format, 0, 0, ct, !1, 0, 0, nt._uploadEncoder),
  51242. !lt && !ft && nt._generateMipmaps(ot, nt._uploadEncoder))
  51243. }
  51244. st && st._removePendingData(ot),
  51245. ot.isReady = !0,
  51246. ot.onLoadedObservable.notifyObservers(ot),
  51247. ot.onLoadedObservable.clear()
  51248. }, function() {
  51249. return !1
  51250. }, k, j, $, _e, et, tt, it)
  51251. }
  51252. ,
  51253. e.prototype.generateMipMapsForCubemap = function(i, o) {
  51254. var s;
  51255. if (i.generateMipMaps) {
  51256. var c = (s = i._hardwareTexture) === null || s === void 0 ? void 0 : s.underlyingResource;
  51257. c || this._textureHelper.createGPUTextureForInternalTexture(i),
  51258. this._generateMipmaps(i, i.source === InternalTextureSource.RenderTarget || i.source === InternalTextureSource.MultiRenderTarget ? this._renderTargetEncoder : void 0)
  51259. }
  51260. }
  51261. ,
  51262. e.prototype.updateTextureSamplingMode = function(i, o, s) {
  51263. s === void 0 && (s = !1),
  51264. s && (o.generateMipMaps = !0,
  51265. this._generateMipmaps(o)),
  51266. o.samplingMode = i
  51267. }
  51268. ,
  51269. e.prototype.updateTextureWrappingMode = function(i, o, s, c) {
  51270. s === void 0 && (s = null),
  51271. c === void 0 && (c = null),
  51272. o !== null && (i._cachedWrapU = o),
  51273. s !== null && (i._cachedWrapV = s),
  51274. (i.is2DArray || i.is3D) && c !== null && (i._cachedWrapR = c)
  51275. }
  51276. ,
  51277. e.prototype.updateTextureDimensions = function(i, o, s, c) {
  51278. if (c === void 0 && (c = 1),
  51279. !!i._hardwareTexture && !(i.width === o && i.height === s && i.depth === c)) {
  51280. var d = i._hardwareTexture.textureAdditionalUsages;
  51281. i._hardwareTexture.release(),
  51282. this._textureHelper.createGPUTextureForInternalTexture(i, o, s, c, d)
  51283. }
  51284. }
  51285. ,
  51286. e.prototype._setInternalTexture = function(i, o, s, c) {
  51287. if (s = s != null ? s : i,
  51288. this._currentEffect) {
  51289. var d = this._currentEffect._pipelineContext
  51290. , _ = d.shaderProcessingContext.availableTextures[s];
  51291. if (this._currentMaterialContext.setTexture(i, o),
  51292. _ && _.autoBindSampler) {
  51293. var b = s + WebGPUShaderProcessor.AutoSamplerSuffix;
  51294. this._currentMaterialContext.setSampler(b, o)
  51295. }
  51296. }
  51297. }
  51298. ,
  51299. e.prototype.setTexture = function(i, o, s, c) {
  51300. this._setTexture(i, s, !1, !1, c, c)
  51301. }
  51302. ,
  51303. e.prototype.setTextureArray = function(i, o, s, c) {
  51304. for (var d = 0; d < s.length; d++)
  51305. this._setTexture(-1, s[d], !0, !1, c + d.toString(), c, d)
  51306. }
  51307. ,
  51308. e.prototype._setTexture = function(i, o, s, c, d, _, b) {
  51309. if (c === void 0 && (c = !1),
  51310. d === void 0 && (d = ""),
  51311. b === void 0 && (b = 0),
  51312. _ = _ != null ? _ : d,
  51313. this._currentEffect) {
  51314. if (!o)
  51315. return this._currentMaterialContext.setTexture(d, null),
  51316. !1;
  51317. if (o.video)
  51318. o.update();
  51319. else if (o.delayLoadState === 4)
  51320. return o.delayLoad(),
  51321. !1;
  51322. var k = null;
  51323. if (c ? k = o.depthStencilTexture : o.isReady() ? k = o.getInternalTexture() : o.isCube ? k = this.emptyCubeTexture : o.is3D ? k = this.emptyTexture3D : o.is2DArray ? k = this.emptyTexture2DArray : k = this.emptyTexture,
  51324. k && !k.isMultiview) {
  51325. if (k.isCube && k._cachedCoordinatesMode !== o.coordinatesMode) {
  51326. k._cachedCoordinatesMode = o.coordinatesMode;
  51327. var j = o.coordinatesMode !== 3 && o.coordinatesMode !== 5 ? 1 : 0;
  51328. o.wrapU = j,
  51329. o.wrapV = j
  51330. }
  51331. k._cachedWrapU = o.wrapU,
  51332. k._cachedWrapV = o.wrapV,
  51333. k.is3D && (k._cachedWrapR = o.wrapR),
  51334. this._setAnisotropicLevel(0, k, o.anisotropicFilteringLevel)
  51335. }
  51336. this._setInternalTexture(d, k, _, b)
  51337. } else
  51338. this.dbgVerboseLogsForFirstFrames && (this._count === void 0 && (this._count = 0),
  51339. (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - _setTexture called with a null _currentEffect! texture=", o));
  51340. return !0
  51341. }
  51342. ,
  51343. e.prototype._setAnisotropicLevel = function(i, o, s) {
  51344. o._cachedAnisotropicFilteringLevel !== s && (o._cachedAnisotropicFilteringLevel = Math.min(s, this._caps.maxAnisotropy))
  51345. }
  51346. ,
  51347. e.prototype._bindTexture = function(i, o, s) {
  51348. i !== void 0 && this._setInternalTexture(s, o)
  51349. }
  51350. ,
  51351. e.prototype.generateMipmaps = function(i) {
  51352. this._generateMipmaps(i, this._renderTargetEncoder)
  51353. }
  51354. ,
  51355. e.prototype._generateMipmaps = function(i, o) {
  51356. var s = i._hardwareTexture;
  51357. if (!!s) {
  51358. o = o != null ? o : this._currentRenderTarget && !this._currentRenderPass ? this._renderTargetEncoder : this._currentRenderPass ? this._uploadEncoder : this._renderEncoder;
  51359. var c = i._hardwareTexture.format
  51360. , d = WebGPUTextureHelper.ComputeNumMipmapLevels(i.width, i.height);
  51361. this.dbgVerboseLogsForFirstFrames && (this._count === void 0 && (this._count = 0),
  51362. (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - generate mipmaps called - width=", i.width, "height=", i.height, "isCube=", i.isCube)),
  51363. i.isCube ? this._textureHelper.generateCubeMipmaps(s, c, d, o) : this._textureHelper.generateMipmaps(s, c, d, 0, o)
  51364. }
  51365. }
  51366. ,
  51367. e.prototype.updateTextureData = function(i, o, s, c, d, _, b, k) {
  51368. var j;
  51369. b === void 0 && (b = 0),
  51370. k === void 0 && (k = 0);
  51371. var $ = i._hardwareTexture;
  51372. !((j = i._hardwareTexture) === null || j === void 0) && j.underlyingResource || ($ = this._textureHelper.createGPUTextureForInternalTexture(i));
  51373. var _e = new Uint8Array(o.buffer,o.byteOffset,o.byteLength);
  51374. this._textureHelper.updateTexture(_e, i, d, _, i.depth, $.format, b, k, i.invertY, !1, s, c, this._uploadEncoder)
  51375. }
  51376. ,
  51377. e.prototype._uploadCompressedDataToTextureDirectly = function(i, o, s, c, d, _, b) {
  51378. var k;
  51379. _ === void 0 && (_ = 0),
  51380. b === void 0 && (b = 0);
  51381. var j = i._hardwareTexture;
  51382. !((k = i._hardwareTexture) === null || k === void 0) && k.underlyingResource || (i.format = o,
  51383. j = this._textureHelper.createGPUTextureForInternalTexture(i, s, c));
  51384. var $ = new Uint8Array(d.buffer,d.byteOffset,d.byteLength);
  51385. this._textureHelper.updateTexture($, i, s, c, i.depth, j.format, _, b, !1, !1, 0, 0, this._uploadEncoder)
  51386. }
  51387. ,
  51388. e.prototype._uploadDataToTextureDirectly = function(i, o, s, c, d, _) {
  51389. var b;
  51390. s === void 0 && (s = 0),
  51391. c === void 0 && (c = 0),
  51392. _ === void 0 && (_ = !1);
  51393. var k = Math.round(Math.log(i.width) * Math.LOG2E)
  51394. , j = Math.round(Math.log(i.height) * Math.LOG2E)
  51395. , $ = _ ? i.width : Math.pow(2, Math.max(k - c, 0))
  51396. , _e = _ ? i.height : Math.pow(2, Math.max(j - c, 0))
  51397. , et = i._hardwareTexture;
  51398. !((b = i._hardwareTexture) === null || b === void 0) && b.underlyingResource || (et = this._textureHelper.createGPUTextureForInternalTexture(i, $, _e));
  51399. var tt = new Uint8Array(o.buffer,o.byteOffset,o.byteLength);
  51400. this._textureHelper.updateTexture(tt, i, $, _e, i.depth, et.format, s, c, i.invertY, !1, 0, 0, this._uploadEncoder)
  51401. }
  51402. ,
  51403. e.prototype._uploadArrayBufferViewToTexture = function(i, o, s, c) {
  51404. s === void 0 && (s = 0),
  51405. c === void 0 && (c = 0),
  51406. this._uploadDataToTextureDirectly(i, o, s, c)
  51407. }
  51408. ,
  51409. e.prototype._uploadImageToTexture = function(i, o, s, c) {
  51410. var d;
  51411. s === void 0 && (s = 0),
  51412. c === void 0 && (c = 0);
  51413. var _ = i._hardwareTexture;
  51414. !((d = i._hardwareTexture) === null || d === void 0) && d.underlyingResource || (_ = this._textureHelper.createGPUTextureForInternalTexture(i));
  51415. var b = o
  51416. , k = Math.ceil(i.width / (1 << c))
  51417. , j = Math.ceil(i.height / (1 << c));
  51418. this._textureHelper.updateTexture(b, i, k, j, i.depth, _.format, s, c, i.invertY, !1, 0, 0, this._uploadEncoder)
  51419. }
  51420. ,
  51421. e.prototype.readPixels = function(i, o, s, c, d, _) {
  51422. _ === void 0 && (_ = !0);
  51423. var b = this._rttRenderPassWrapper.renderPass ? this._rttRenderPassWrapper : this._mainRenderPassWrapper
  51424. , k = b.colorAttachmentGPUTextures[0].underlyingResource
  51425. , j = b.colorAttachmentGPUTextures[0].format;
  51426. return k ? (_ && this.flushFramebuffer(),
  51427. this._textureHelper.readPixels(k, i, o, s, c, j)) : Promise.resolve(new Uint8Array(0))
  51428. }
  51429. ,
  51430. e.prototype.beginFrame = function() {
  51431. a.prototype.beginFrame.call(this)
  51432. }
  51433. ,
  51434. e.prototype.endFrame = function() {
  51435. if (this._snapshotRendering.endFrame(this._mainRenderPassWrapper.renderPass),
  51436. this._endMainRenderPass(),
  51437. this._timestampQuery.endFrame(this._renderEncoder),
  51438. this._invertYFinalFramebuffer && this._mainRenderPassCopyWrapper.renderPassDescriptor.colorAttachments[0].view && this._textureHelper.copyWithInvertY(this._mainTextureLastCopy.createView(), this._mainRenderPassWrapper.colorAttachmentGPUTextures[0].format, this._mainRenderPassCopyWrapper.renderPassDescriptor, this._renderEncoder),
  51439. this.flushFramebuffer(!1),
  51440. this.dbgVerboseLogsForFirstFrames && (this._count === void 0 && (this._count = 0),
  51441. (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - counters")),
  51442. this._textureHelper.destroyDeferredTextures(),
  51443. this._bufferManager.destroyDeferredBuffers(),
  51444. this._features._collectUbosUpdatedInFrame) {
  51445. if (this.dbgVerboseLogsForFirstFrames && (this._count === void 0 && (this._count = 0),
  51446. !this._count || this._count < this.dbgVerboseLogsNumFrames)) {
  51447. var i = [];
  51448. for (var o in UniformBuffer._updatedUbosInFrame)
  51449. i.push(o + ":" + UniformBuffer._updatedUbosInFrame[o]);
  51450. console.log("frame #" + this._count + " - updated ubos -", i.join(", "))
  51451. }
  51452. UniformBuffer._updatedUbosInFrame = {}
  51453. }
  51454. this.countersLastFrame.numEnableEffects = this._counters.numEnableEffects,
  51455. this.countersLastFrame.numEnableDrawWrapper = this._counters.numEnableDrawWrapper,
  51456. this.countersLastFrame.numBundleCreationNonCompatMode = this._counters.numBundleCreationNonCompatMode,
  51457. this.countersLastFrame.numBundleReuseNonCompatMode = this._counters.numBundleReuseNonCompatMode,
  51458. this._counters.numEnableEffects = 0,
  51459. this._counters.numEnableDrawWrapper = 0,
  51460. this._counters.numBundleCreationNonCompatMode = 0,
  51461. this._counters.numBundleReuseNonCompatMode = 0,
  51462. this._cacheRenderPipeline.endFrame(),
  51463. this._cacheBindGroups.endFrame(),
  51464. this._pendingDebugCommands.length = 0,
  51465. a.prototype.endFrame.call(this),
  51466. this.dbgVerboseLogsForFirstFrames && (this._count === void 0 && (this._count = 0),
  51467. this._count < this.dbgVerboseLogsNumFrames && console.log("%c frame #" + this._count + " - end", "background: #ffff00"),
  51468. this._count < this.dbgVerboseLogsNumFrames && (this._count++,
  51469. this._count !== this.dbgVerboseLogsNumFrames && console.log("%c frame #" + this._count + " - begin", "background: #ffff00")))
  51470. }
  51471. ,
  51472. e.prototype.flushFramebuffer = function(i) {
  51473. i === void 0 && (i = !0);
  51474. var o = !this._currentRenderPass
  51475. , s = 0;
  51476. this._currentRenderPass && this._currentRenderTarget && (s |= 1,
  51477. this._endRenderTargetRenderPass()),
  51478. this._mainRenderPassWrapper.renderPass && (s |= 2,
  51479. this._endMainRenderPass()),
  51480. this._commandBuffers[0] = this._uploadEncoder.finish(),
  51481. this._commandBuffers[1] = this._renderTargetEncoder.finish(),
  51482. this._commandBuffers[2] = this._renderEncoder.finish(),
  51483. this._device.queue.submit(this._commandBuffers),
  51484. this._uploadEncoder = this._device.createCommandEncoder(this._uploadEncoderDescriptor),
  51485. this._renderEncoder = this._device.createCommandEncoder(this._renderEncoderDescriptor),
  51486. this._renderTargetEncoder = this._device.createCommandEncoder(this._renderTargetEncoderDescriptor),
  51487. this._timestampQuery.startFrame(this._uploadEncoder),
  51488. this._textureHelper.setCommandEncoder(this._uploadEncoder),
  51489. this._bundleList.reset(),
  51490. this._bundleListRenderTarget.reset(),
  51491. i && (s & 2 && this._startMainRenderPass(!1),
  51492. s & 1 && this._startRenderTargetRenderPass(this._currentRenderTarget, !1, null, !1, !1),
  51493. o && this._currentRenderTarget && (this._currentRenderPass = null))
  51494. }
  51495. ,
  51496. e.prototype._currentFrameBufferIsDefaultFrameBuffer = function() {
  51497. return this._currentRenderTarget === null
  51498. }
  51499. ,
  51500. e.prototype._startRenderTargetRenderPass = function(i, o, s, c, d) {
  51501. var _, b, k, j = i._depthStencilTexture, $ = j == null ? void 0 : j._hardwareTexture, _e = $ == null ? void 0 : $.underlyingResource, et = $ == null ? void 0 : $.msaaTexture, tt = _e == null ? void 0 : _e.createView(this._rttRenderPassWrapper.depthAttachmentViewDescriptor), rt = et == null ? void 0 : et.createView(this._rttRenderPassWrapper.depthAttachmentViewDescriptor), it = [];
  51502. this.useReverseDepthBuffer && this.setDepthFunctionToGreaterOrEqual();
  51503. var nt = o && s || LoadOp.Load
  51504. , ot = o && c ? this.useReverseDepthBuffer ? this._clearReverseDepthValue : this._clearDepthValue : LoadOp.Load
  51505. , at = o && d ? this._clearStencilValue : LoadOp.Load;
  51506. if (i._attachments && i.isMulti) {
  51507. (!this._mrtAttachments || this._mrtAttachments.length === 0) && (this._mrtAttachments = i._attachments);
  51508. for (var st = 0; st < this._mrtAttachments.length; ++st) {
  51509. var ut = this._mrtAttachments[st];
  51510. if (ut !== 0) {
  51511. var ct = i.textures[ut - 1]
  51512. , lt = ct == null ? void 0 : ct._hardwareTexture
  51513. , ft = lt == null ? void 0 : lt.underlyingResource;
  51514. if (lt && ft) {
  51515. var ht = __assign(__assign({}, this._rttRenderPassWrapper.colorAttachmentViewDescriptor), {
  51516. format: lt.format
  51517. })
  51518. , pt = lt.msaaTexture
  51519. , dt = ft.createView(ht)
  51520. , _t = pt == null ? void 0 : pt.createView(ht);
  51521. it.push({
  51522. view: _t || dt,
  51523. resolveTarget: pt ? dt : void 0,
  51524. loadValue: nt,
  51525. storeOp: StoreOp.Store
  51526. })
  51527. }
  51528. }
  51529. }
  51530. this._cacheRenderPipeline.setMRTAttachments(this._mrtAttachments, i.textures)
  51531. } else {
  51532. var mt = i.texture
  51533. , vt = mt._hardwareTexture
  51534. , yt = vt.underlyingResource
  51535. , pt = vt.msaaTexture
  51536. , dt = yt.createView(this._rttRenderPassWrapper.colorAttachmentViewDescriptor)
  51537. , _t = pt == null ? void 0 : pt.createView(this._rttRenderPassWrapper.colorAttachmentViewDescriptor);
  51538. it.push({
  51539. view: _t || dt,
  51540. resolveTarget: pt ? dt : void 0,
  51541. loadValue: nt,
  51542. storeOp: StoreOp.Store
  51543. })
  51544. }
  51545. if ((_ = this._debugPushGroup) === null || _ === void 0 || _.call(this, "render target pass", 1),
  51546. this._rttRenderPassWrapper.renderPassDescriptor = {
  51547. colorAttachments: it,
  51548. depthStencilAttachment: j && _e ? {
  51549. view: rt || tt,
  51550. depthLoadValue: ot,
  51551. depthStoreOp: StoreOp.Store,
  51552. stencilLoadValue: i._depthStencilTextureWithStencil ? at : LoadOp.Load,
  51553. stencilStoreOp: StoreOp.Store
  51554. } : void 0,
  51555. occlusionQuerySet: !((b = this._occlusionQuery) === null || b === void 0) && b.hasQueries ? this._occlusionQuery.querySet : void 0
  51556. },
  51557. this._rttRenderPassWrapper.renderPass = this._renderTargetEncoder.beginRenderPass(this._rttRenderPassWrapper.renderPassDescriptor),
  51558. this.dbgVerboseLogsForFirstFrames && (this._count === void 0 && (this._count = 0),
  51559. !this._count || this._count < this.dbgVerboseLogsNumFrames)) {
  51560. var mt = i.texture;
  51561. console.log("frame #" + this._count + " - render target begin pass - internalTexture.uniqueId=", mt.uniqueId, "width=", mt.width, "height=", mt.height, this._rttRenderPassWrapper.renderPassDescriptor)
  51562. }
  51563. this._currentRenderPass = this._rttRenderPassWrapper.renderPass,
  51564. (k = this._debugFlushPendingCommands) === null || k === void 0 || k.call(this),
  51565. this._resetCurrentViewport(1),
  51566. this._resetCurrentScissor(1),
  51567. this._resetCurrentStencilRef(1),
  51568. this._resetCurrentColorBlend(1)
  51569. }
  51570. ,
  51571. e.prototype._endRenderTargetRenderPass = function() {
  51572. var i, o, s;
  51573. if (this._currentRenderPass) {
  51574. var c = this._currentRenderTarget.texture._hardwareTexture;
  51575. !this._snapshotRendering.endRenderTargetPass(this._currentRenderPass, c) && !this.compatibilityMode && (this._bundleListRenderTarget.run(this._currentRenderPass),
  51576. this._bundleListRenderTarget.reset()),
  51577. this._currentRenderPass.endPass(),
  51578. this.dbgVerboseLogsForFirstFrames && (this._count === void 0 && (this._count = 0),
  51579. (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - render target end pass - internalTexture.uniqueId=", (o = (i = this._currentRenderTarget) === null || i === void 0 ? void 0 : i.texture) === null || o === void 0 ? void 0 : o.uniqueId)),
  51580. (s = this._debugPopGroup) === null || s === void 0 || s.call(this, 1),
  51581. this._resetCurrentViewport(1),
  51582. this._resetCurrentScissor(1),
  51583. this._resetCurrentStencilRef(1),
  51584. this._resetCurrentColorBlend(1),
  51585. this._currentRenderPass = null,
  51586. this._rttRenderPassWrapper.reset()
  51587. }
  51588. }
  51589. ,
  51590. e.prototype._getCurrentRenderPass = function() {
  51591. return this._currentRenderTarget && !this._currentRenderPass ? this._startRenderTargetRenderPass(this._currentRenderTarget, !1, null, !1, !1) : this._currentRenderPass || this._startMainRenderPass(!1),
  51592. this._currentRenderPass
  51593. }
  51594. ,
  51595. e.prototype._getCurrentRenderPassIndex = function() {
  51596. return this._currentRenderPass === null ? -1 : this._currentRenderPass === this._mainRenderPassWrapper.renderPass ? 0 : 1
  51597. }
  51598. ,
  51599. e.prototype._startMainRenderPass = function(i, o, s, c) {
  51600. var d, _, b;
  51601. this._mainRenderPassWrapper.renderPass && this._endMainRenderPass(),
  51602. this.useReverseDepthBuffer && this.setDepthFunctionToGreaterOrEqual();
  51603. var k = i && o || LoadOp.Load
  51604. , j = i && s ? this.useReverseDepthBuffer ? this._clearReverseDepthValue : this._clearDepthValue : LoadOp.Load
  51605. , $ = i && c ? this._clearStencilValue : LoadOp.Load;
  51606. this._mainRenderPassWrapper.renderPassDescriptor.colorAttachments[0].loadValue = k,
  51607. this._mainRenderPassWrapper.renderPassDescriptor.depthStencilAttachment.depthLoadValue = j,
  51608. this._mainRenderPassWrapper.renderPassDescriptor.depthStencilAttachment.stencilLoadValue = $,
  51609. this._mainRenderPassWrapper.renderPassDescriptor.occlusionQuerySet = !((d = this._occlusionQuery) === null || d === void 0) && d.hasQueries ? this._occlusionQuery.querySet : void 0;
  51610. var _e = this._invertYFinalFramebuffer ? this._mainRenderPassCopyWrapper : this._mainRenderPassWrapper;
  51611. this._swapChainTexture = this._context.getCurrentTexture(),
  51612. _e.colorAttachmentGPUTextures[0].set(this._swapChainTexture),
  51613. this._options.antialiasing ? this._invertYFinalFramebuffer ? _e.renderPassDescriptor.colorAttachments[0].view = this._swapChainTexture.createView() : _e.renderPassDescriptor.colorAttachments[0].resolveTarget = this._swapChainTexture.createView() : _e.renderPassDescriptor.colorAttachments[0].view = this._swapChainTexture.createView(),
  51614. this.dbgVerboseLogsForFirstFrames && (this._count === void 0 && (this._count = 0),
  51615. (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - main begin pass - texture width=" + this._mainTextureExtends.width, " height=" + this._mainTextureExtends.height, this._mainRenderPassWrapper.renderPassDescriptor)),
  51616. (_ = this._debugPushGroup) === null || _ === void 0 || _.call(this, "main pass", 0),
  51617. this._currentRenderPass = this._renderEncoder.beginRenderPass(this._mainRenderPassWrapper.renderPassDescriptor),
  51618. this._mainRenderPassWrapper.renderPass = this._currentRenderPass,
  51619. (b = this._debugFlushPendingCommands) === null || b === void 0 || b.call(this),
  51620. this._resetCurrentViewport(0),
  51621. this._resetCurrentScissor(0),
  51622. this._resetCurrentStencilRef(0),
  51623. this._resetCurrentColorBlend(0)
  51624. }
  51625. ,
  51626. e.prototype._endMainRenderPass = function() {
  51627. var i;
  51628. this._mainRenderPassWrapper.renderPass !== null && (this._snapshotRendering.endMainRenderPass(),
  51629. !this.compatibilityMode && !this._snapshotRendering.play && (this._bundleList.run(this._mainRenderPassWrapper.renderPass),
  51630. this._bundleList.reset()),
  51631. this._mainRenderPassWrapper.renderPass.endPass(),
  51632. this.dbgVerboseLogsForFirstFrames && (this._count === void 0 && (this._count = 0),
  51633. (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - main end pass")),
  51634. (i = this._debugPopGroup) === null || i === void 0 || i.call(this, 0),
  51635. this._resetCurrentViewport(0),
  51636. this._resetCurrentScissor(0),
  51637. this._resetCurrentStencilRef(0),
  51638. this._resetCurrentColorBlend(0),
  51639. this._mainRenderPassWrapper.renderPass === this._currentRenderPass && (this._currentRenderPass = null),
  51640. this._mainRenderPassWrapper.reset(!1))
  51641. }
  51642. ,
  51643. e.prototype.bindFramebuffer = function(i, o, s, c, d, _, b) {
  51644. var k, j;
  51645. o === void 0 && (o = 0),
  51646. _ === void 0 && (_ = 0),
  51647. b === void 0 && (b = 0);
  51648. var $ = (k = i.texture) === null || k === void 0 ? void 0 : k._hardwareTexture;
  51649. if (!$) {
  51650. this.dbgSanityChecks && console.error("bindFramebuffer: Trying to bind a texture that does not have a hardware texture!", i, $);
  51651. return
  51652. }
  51653. this._currentRenderTarget && this.unBindFramebuffer(this._currentRenderTarget),
  51654. this._currentRenderTarget = i,
  51655. $._currentLayer = i.isCube ? b * 6 + o : b,
  51656. this._rttRenderPassWrapper.colorAttachmentGPUTextures[0] = $,
  51657. this._rttRenderPassWrapper.depthTextureFormat = this._currentRenderTarget._depthStencilTexture ? WebGPUTextureHelper.GetWebGPUTextureFormat(-1, this._currentRenderTarget._depthStencilTexture.format) : void 0,
  51658. this._setDepthTextureFormat(this._rttRenderPassWrapper),
  51659. this._setColorFormat(this._rttRenderPassWrapper),
  51660. this._rttRenderPassWrapper.colorAttachmentViewDescriptor = {
  51661. format: this._colorFormat,
  51662. dimension: TextureViewDimension.E2d,
  51663. mipLevelCount: 1,
  51664. baseArrayLayer: i.isCube ? b * 6 + o : b,
  51665. baseMipLevel: _,
  51666. arrayLayerCount: 1,
  51667. aspect: TextureAspect.All
  51668. },
  51669. this._rttRenderPassWrapper.depthAttachmentViewDescriptor = {
  51670. format: this._depthTextureFormat,
  51671. dimension: TextureViewDimension.E2d,
  51672. mipLevelCount: 1,
  51673. baseArrayLayer: i.isCube ? b * 6 + o : b,
  51674. baseMipLevel: 0,
  51675. arrayLayerCount: 1,
  51676. aspect: TextureAspect.All
  51677. },
  51678. this.dbgVerboseLogsForFirstFrames && (this._count === void 0 && (this._count = 0),
  51679. (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - bindFramebuffer called - internalTexture.uniqueId=", (j = i.texture) === null || j === void 0 ? void 0 : j.uniqueId, "face=", o, "lodLevel=", _, "layer=", b, this._rttRenderPassWrapper.colorAttachmentViewDescriptor, this._rttRenderPassWrapper.depthAttachmentViewDescriptor)),
  51680. this._currentRenderPass = null,
  51681. this.snapshotRendering && this.snapshotRenderingMode === 1 && this._getCurrentRenderPass(),
  51682. this._cachedViewport && !d ? this.setViewport(this._cachedViewport, s, c) : (s || (s = i.width,
  51683. _ && (s = s / Math.pow(2, _))),
  51684. c || (c = i.height,
  51685. _ && (c = c / Math.pow(2, _))),
  51686. this._viewport(0, 0, s, c)),
  51687. this.wipeCaches()
  51688. }
  51689. ,
  51690. e.prototype.unBindFramebuffer = function(i, o, s) {
  51691. var c, d;
  51692. o === void 0 && (o = !1);
  51693. var _ = this._currentRenderTarget;
  51694. this._currentRenderTarget = null,
  51695. s && s(),
  51696. this._currentRenderTarget = _,
  51697. this._currentRenderPass && this._currentRenderPass !== this._mainRenderPassWrapper.renderPass && this._endRenderTargetRenderPass(),
  51698. ((c = i.texture) === null || c === void 0 ? void 0 : c.generateMipMaps) && !o && !i.isCube && this._generateMipmaps(i.texture),
  51699. this._currentRenderTarget = null,
  51700. this._onAfterUnbindFrameBufferObservable.notifyObservers(this),
  51701. this.dbgVerboseLogsForFirstFrames && (this._count === void 0 && (this._count = 0),
  51702. (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - unBindFramebuffer called - internalTexture.uniqueId=", (d = i.texture) === null || d === void 0 ? void 0 : d.uniqueId)),
  51703. this._mrtAttachments = [],
  51704. this._cacheRenderPipeline.setMRTAttachments(this._mrtAttachments, []),
  51705. this._currentRenderPass = this._mainRenderPassWrapper.renderPass,
  51706. this._setDepthTextureFormat(this._mainRenderPassWrapper),
  51707. this._setColorFormat(this._mainRenderPassWrapper)
  51708. }
  51709. ,
  51710. e.prototype.restoreDefaultFramebuffer = function() {
  51711. this._currentRenderTarget ? this.unBindFramebuffer(this._currentRenderTarget) : (this._currentRenderPass = this._mainRenderPassWrapper.renderPass,
  51712. this._setDepthTextureFormat(this._mainRenderPassWrapper),
  51713. this._setColorFormat(this._mainRenderPassWrapper)),
  51714. this._currentRenderPass && this._cachedViewport && this.setViewport(this._cachedViewport),
  51715. this.wipeCaches()
  51716. }
  51717. ,
  51718. e.prototype._setColorFormat = function(i) {
  51719. var o = i.colorAttachmentGPUTextures[0].format;
  51720. this._cacheRenderPipeline.setColorFormat(o),
  51721. this._colorFormat !== o && (this._colorFormat = o)
  51722. }
  51723. ,
  51724. e.prototype._setDepthTextureFormat = function(i) {
  51725. this._cacheRenderPipeline.setDepthStencilFormat(i.depthTextureFormat),
  51726. this._depthTextureFormat !== i.depthTextureFormat && (this._depthTextureFormat = i.depthTextureFormat)
  51727. }
  51728. ,
  51729. e.prototype.setDitheringState = function(i) {}
  51730. ,
  51731. e.prototype.setRasterizerState = function(i) {}
  51732. ,
  51733. e.prototype.setState = function(i, o, s, c, d, _, b) {
  51734. var k, j;
  51735. o === void 0 && (o = 0),
  51736. c === void 0 && (c = !1),
  51737. b === void 0 && (b = 0),
  51738. (this._depthCullingState.cull !== i || s) && (this._depthCullingState.cull = i);
  51739. var $ = !((j = (k = this.cullBackFaces) !== null && k !== void 0 ? k : d) !== null && j !== void 0) || j ? 1 : 2;
  51740. (this._depthCullingState.cullFace !== $ || s) && (this._depthCullingState.cullFace = $),
  51741. this.setZOffset(o),
  51742. this.setZOffsetUnits(b);
  51743. var _e = c ? 1 : 2;
  51744. (this._depthCullingState.frontFace !== _e || s) && (this._depthCullingState.frontFace = _e),
  51745. this._stencilStateComposer.stencilMaterial = _
  51746. }
  51747. ,
  51748. e.prototype._applyRenderPassChanges = function(i, o) {
  51749. var s, c = this._mustUpdateViewport(i), d = this._mustUpdateScissor(i), _ = this._stencilStateComposer.enabled ? this._mustUpdateStencilRef(i) : !1, b = this._alphaState.alphaBlend ? this._mustUpdateBlendColor(i) : !1;
  51750. o ? (c && o.addItem(new WebGPURenderItemViewport(this._viewportCached.x,this._viewportCached.y,this._viewportCached.z,this._viewportCached.w)),
  51751. d && o.addItem(new WebGPURenderItemScissor(this._scissorCached.x,this._scissorCached.y,this._scissorCached.z,this._scissorCached.w)),
  51752. _ && o.addItem(new WebGPURenderItemStencilRef((s = this._stencilStateComposer.funcRef) !== null && s !== void 0 ? s : 0)),
  51753. b && o.addItem(new WebGPURenderItemBlendColor(this._alphaState._blendConstants.slice()))) : (c && this._applyViewport(i),
  51754. d && this._applyScissor(i),
  51755. _ && this._applyStencilRef(i),
  51756. b && this._applyBlendColor(i))
  51757. }
  51758. ,
  51759. e.prototype._draw = function(i, o, s, c, d) {
  51760. var _, b = this._getCurrentRenderPass(), k = this._getCurrentRenderPassIndex(), j = k === 0 ? this._bundleList : this._bundleListRenderTarget;
  51761. this.applyStates();
  51762. var $ = this._currentEffect._pipelineContext;
  51763. if ($.uniformBuffer && ($.uniformBuffer.update(),
  51764. this.bindUniformBufferBase($.uniformBuffer.getBuffer(), 0, WebGPUShaderProcessor.LeftOvertUBOName)),
  51765. this._snapshotRendering.play) {
  51766. this._reportDrawCall();
  51767. return
  51768. }
  51769. !this.compatibilityMode && (this._currentDrawContext.isDirty(this._currentMaterialContext.updateId) || this._currentMaterialContext.isDirty || this._currentMaterialContext.forceBindGroupCreation) && (this._currentDrawContext.fastBundle = void 0);
  51770. var _e = !this.compatibilityMode && this._currentDrawContext.fastBundle
  51771. , et = b;
  51772. if (_e || this._snapshotRendering.record) {
  51773. if (this._applyRenderPassChanges(b, j),
  51774. !this._snapshotRendering.record) {
  51775. this._counters.numBundleReuseNonCompatMode++,
  51776. this._currentDrawContext.indirectDrawBuffer && this._currentDrawContext.setIndirectData(c, d || 1, s),
  51777. j.addBundle(this._currentDrawContext.fastBundle),
  51778. this._reportDrawCall();
  51779. return
  51780. }
  51781. et = j.getBundleEncoder(this._cacheRenderPipeline.colorFormats, this._depthTextureFormat, this.currentSampleCount),
  51782. j.numDrawCalls++
  51783. }
  51784. var tt = 0;
  51785. if (!this._caps.textureFloatLinearFiltering && this._currentMaterialContext.hasFloatTextures)
  51786. for (var rt = 1, it = 0; it < $.shaderProcessingContext.textureNames.length; ++it) {
  51787. var nt = $.shaderProcessingContext.textureNames[it]
  51788. , ot = (_ = this._currentMaterialContext.textures[nt]) === null || _ === void 0 ? void 0 : _.texture;
  51789. (ot == null ? void 0 : ot.type) === 1 && (tt |= rt),
  51790. rt = rt << 1
  51791. }
  51792. var at = this._cacheRenderPipeline.getRenderPipeline(o, this._currentEffect, this.currentSampleCount, tt)
  51793. , st = this._cacheBindGroups.getBindGroups($, this._currentDrawContext, this._currentMaterialContext);
  51794. this._snapshotRendering.record || (this._applyRenderPassChanges(b, this.compatibilityMode ? null : j),
  51795. this.compatibilityMode || (this._counters.numBundleCreationNonCompatMode++,
  51796. et = this._device.createRenderBundleEncoder({
  51797. colorFormats: this._cacheRenderPipeline.colorFormats,
  51798. depthStencilFormat: this._depthTextureFormat,
  51799. sampleCount: this.currentSampleCount
  51800. }))),
  51801. et.setPipeline(at),
  51802. this._currentIndexBuffer && et.setIndexBuffer(this._currentIndexBuffer.underlyingResource, this._currentIndexBuffer.is32Bits ? IndexFormat.Uint32 : IndexFormat.Uint16, 0);
  51803. for (var ut = this._cacheRenderPipeline.vertexBuffers, ct = 0; ct < ut.length; ct++) {
  51804. var lt = ut[ct]
  51805. , ft = lt.getBuffer();
  51806. ft && et.setVertexBuffer(ct, ft.underlyingResource, lt._validOffsetRange ? 0 : lt.byteOffset)
  51807. }
  51808. for (var it = 0; it < st.length; it++)
  51809. et.setBindGroup(it, st[it]);
  51810. var ht = !this.compatibilityMode && !this._snapshotRendering.record;
  51811. ht && this._currentDrawContext.indirectDrawBuffer ? (this._currentDrawContext.setIndirectData(c, d || 1, s),
  51812. i === 0 ? et.drawIndexedIndirect(this._currentDrawContext.indirectDrawBuffer, 0) : et.drawIndirect(this._currentDrawContext.indirectDrawBuffer, 0)) : i === 0 ? et.drawIndexed(c, d || 1, s, 0, 0) : et.draw(c, d || 1, s, 0),
  51813. ht && (this._currentDrawContext.fastBundle = et.finish(),
  51814. j.addBundle(this._currentDrawContext.fastBundle)),
  51815. this._reportDrawCall()
  51816. }
  51817. ,
  51818. e.prototype.drawElementsType = function(i, o, s, c) {
  51819. c === void 0 && (c = 1),
  51820. this._draw(0, i, o, s, c)
  51821. }
  51822. ,
  51823. e.prototype.drawArraysType = function(i, o, s, c) {
  51824. c === void 0 && (c = 1),
  51825. this._currentIndexBuffer = null,
  51826. this._draw(1, i, o, s, c)
  51827. }
  51828. ,
  51829. e.prototype.dispose = function() {
  51830. var i, o, s;
  51831. (i = this._mainTexture) === null || i === void 0 || i.destroy(),
  51832. (o = this._mainTextureLastCopy) === null || o === void 0 || o.destroy(),
  51833. (s = this._depthTexture) === null || s === void 0 || s.destroy(),
  51834. a.prototype.dispose.call(this)
  51835. }
  51836. ,
  51837. e.prototype.getRenderWidth = function(i) {
  51838. return i === void 0 && (i = !1),
  51839. !i && this._currentRenderTarget ? this._currentRenderTarget.width : this._canvas.width
  51840. }
  51841. ,
  51842. e.prototype.getRenderHeight = function(i) {
  51843. return i === void 0 && (i = !1),
  51844. !i && this._currentRenderTarget ? this._currentRenderTarget.height : this._canvas.height
  51845. }
  51846. ,
  51847. e.prototype.getRenderingCanvas = function() {
  51848. return this._canvas
  51849. }
  51850. ,
  51851. e.prototype.getError = function() {
  51852. return 0
  51853. }
  51854. ,
  51855. e.prototype.bindSamplers = function(i) {}
  51856. ,
  51857. e.prototype._bindTextureDirectly = function(i, o, s, c) {
  51858. return !1
  51859. }
  51860. ,
  51861. e.prototype.areAllEffectsReady = function() {
  51862. return !0
  51863. }
  51864. ,
  51865. e.prototype._executeWhenRenderingStateIsCompiled = function(i, o) {
  51866. o()
  51867. }
  51868. ,
  51869. e.prototype._isRenderingStateCompiled = function(i) {
  51870. return !0
  51871. }
  51872. ,
  51873. e.prototype._getUnpackAlignement = function() {
  51874. return 1
  51875. }
  51876. ,
  51877. e.prototype._unpackFlipY = function(i) {}
  51878. ,
  51879. e.prototype._bindUnboundFramebuffer = function(i) {
  51880. throw "_bindUnboundFramebuffer is not implementedin WebGPU! You probably want to use restoreDefaultFramebuffer or unBindFramebuffer instead"
  51881. }
  51882. ,
  51883. e.prototype._getSamplingParameters = function(i, o) {
  51884. throw "_getSamplingParameters is not available in WebGPU"
  51885. }
  51886. ,
  51887. e.prototype.getUniforms = function(i, o) {
  51888. return []
  51889. }
  51890. ,
  51891. e.prototype.setIntArray = function(i, o) {
  51892. return !1
  51893. }
  51894. ,
  51895. e.prototype.setIntArray2 = function(i, o) {
  51896. return !1
  51897. }
  51898. ,
  51899. e.prototype.setIntArray3 = function(i, o) {
  51900. return !1
  51901. }
  51902. ,
  51903. e.prototype.setIntArray4 = function(i, o) {
  51904. return !1
  51905. }
  51906. ,
  51907. e.prototype.setArray = function(i, o) {
  51908. return !1
  51909. }
  51910. ,
  51911. e.prototype.setArray2 = function(i, o) {
  51912. return !1
  51913. }
  51914. ,
  51915. e.prototype.setArray3 = function(i, o) {
  51916. return !1
  51917. }
  51918. ,
  51919. e.prototype.setArray4 = function(i, o) {
  51920. return !1
  51921. }
  51922. ,
  51923. e.prototype.setMatrices = function(i, o) {
  51924. return !1
  51925. }
  51926. ,
  51927. e.prototype.setMatrix3x3 = function(i, o) {
  51928. return !1
  51929. }
  51930. ,
  51931. e.prototype.setMatrix2x2 = function(i, o) {
  51932. return !1
  51933. }
  51934. ,
  51935. e.prototype.setFloat = function(i, o) {
  51936. return !1
  51937. }
  51938. ,
  51939. e.prototype.setFloat2 = function(i, o, s) {
  51940. return !1
  51941. }
  51942. ,
  51943. e.prototype.setFloat3 = function(i, o, s, c) {
  51944. return !1
  51945. }
  51946. ,
  51947. e.prototype.setFloat4 = function(i, o, s, c, d) {
  51948. return !1
  51949. }
  51950. ,
  51951. e._glslangDefaultOptions = {
  51952. jsPath: "https://preview.babylonjs.com/glslang/glslang.js",
  51953. wasmPath: "https://preview.babylonjs.com/glslang/glslang.wasm"
  51954. },
  51955. e.UseTWGSL = !0,
  51956. e
  51957. }(Engine);
  51958. WebGPUEngine.prototype.setAlphaMode = function(a, e) {
  51959. if (e === void 0 && (e = !1),
  51960. !(this._alphaMode === a && (a === 0 && !this._alphaState.alphaBlend || a !== 0 && this._alphaState.alphaBlend))) {
  51961. switch (a) {
  51962. case 0:
  51963. this._alphaState.alphaBlend = !1;
  51964. break;
  51965. case 7:
  51966. this._alphaState.setAlphaBlendFunctionParameters(1, 771, 1, 1),
  51967. this._alphaState.alphaBlend = !0;
  51968. break;
  51969. case 8:
  51970. this._alphaState.setAlphaBlendFunctionParameters(1, 771, 1, 771),
  51971. this._alphaState.alphaBlend = !0;
  51972. break;
  51973. case 2:
  51974. this._alphaState.setAlphaBlendFunctionParameters(770, 771, 1, 1),
  51975. this._alphaState.alphaBlend = !0;
  51976. break;
  51977. case 6:
  51978. this._alphaState.setAlphaBlendFunctionParameters(1, 1, 0, 1),
  51979. this._alphaState.alphaBlend = !0;
  51980. break;
  51981. case 1:
  51982. this._alphaState.setAlphaBlendFunctionParameters(770, 1, 0, 1),
  51983. this._alphaState.alphaBlend = !0;
  51984. break;
  51985. case 3:
  51986. this._alphaState.setAlphaBlendFunctionParameters(0, 769, 1, 1),
  51987. this._alphaState.alphaBlend = !0;
  51988. break;
  51989. case 4:
  51990. this._alphaState.setAlphaBlendFunctionParameters(774, 0, 1, 1),
  51991. this._alphaState.alphaBlend = !0;
  51992. break;
  51993. case 5:
  51994. this._alphaState.setAlphaBlendFunctionParameters(770, 769, 1, 1),
  51995. this._alphaState.alphaBlend = !0;
  51996. break;
  51997. case 9:
  51998. this._alphaState.setAlphaBlendFunctionParameters(32769, 32770, 32771, 32772),
  51999. this._alphaState.alphaBlend = !0;
  52000. break;
  52001. case 10:
  52002. this._alphaState.setAlphaBlendFunctionParameters(1, 769, 1, 771),
  52003. this._alphaState.alphaBlend = !0;
  52004. break;
  52005. case 11:
  52006. this._alphaState.setAlphaBlendFunctionParameters(1, 1, 1, 1),
  52007. this._alphaState.alphaBlend = !0;
  52008. break;
  52009. case 12:
  52010. this._alphaState.setAlphaBlendFunctionParameters(772, 1, 0, 0),
  52011. this._alphaState.alphaBlend = !0;
  52012. break;
  52013. case 13:
  52014. this._alphaState.setAlphaBlendFunctionParameters(775, 769, 773, 771),
  52015. this._alphaState.alphaBlend = !0;
  52016. break;
  52017. case 14:
  52018. this._alphaState.setAlphaBlendFunctionParameters(1, 771, 1, 771),
  52019. this._alphaState.alphaBlend = !0;
  52020. break;
  52021. case 15:
  52022. this._alphaState.setAlphaBlendFunctionParameters(1, 1, 1, 0),
  52023. this._alphaState.alphaBlend = !0;
  52024. break;
  52025. case 16:
  52026. this._alphaState.setAlphaBlendFunctionParameters(775, 769, 0, 1),
  52027. this._alphaState.alphaBlend = !0;
  52028. break;
  52029. case 17:
  52030. this._alphaState.setAlphaBlendFunctionParameters(770, 771, 1, 771),
  52031. this._alphaState.alphaBlend = !0;
  52032. break
  52033. }
  52034. e || (this.setDepthWrite(a === Engine.ALPHA_DISABLE),
  52035. this._cacheRenderPipeline.setDepthWriteEnabled(a === Engine.ALPHA_DISABLE)),
  52036. this._alphaMode = a,
  52037. this._cacheRenderPipeline.setAlphaBlendEnabled(this._alphaState.alphaBlend),
  52038. this._cacheRenderPipeline.setAlphaBlendFactors(this._alphaState._blendFunctionParameters, this._alphaState._blendEquationParameters)
  52039. }
  52040. }
  52041. ;
  52042. WebGPUEngine.prototype.setAlphaEquation = function(a) {
  52043. Engine.prototype.setAlphaEquation.call(this, a),
  52044. this._cacheRenderPipeline.setAlphaBlendFactors(this._alphaState._blendFunctionParameters, this._alphaState._blendEquationParameters)
  52045. }
  52046. ;
  52047. var ComputeEffect = function() {
  52048. function a(e, i, o, s) {
  52049. var c = this;
  52050. s === void 0 && (s = "");
  52051. var d, _;
  52052. this.name = null,
  52053. this.defines = "",
  52054. this.onCompiled = null,
  52055. this.onError = null,
  52056. this.uniqueId = 0,
  52057. this.onCompileObservable = new Observable,
  52058. this.onErrorObservable = new Observable,
  52059. this.onBindObservable = new Observable,
  52060. this._wasPreviouslyReady = !1,
  52061. this._isReady = !1,
  52062. this._compilationError = "",
  52063. this._key = "",
  52064. this._computeSourceCodeOverride = "",
  52065. this._pipelineContext = null,
  52066. this._computeSourceCode = "",
  52067. this._rawComputeSourceCode = "",
  52068. this._shaderLanguage = ShaderLanguage.WGSL,
  52069. this.name = e,
  52070. this._key = s,
  52071. this._engine = o,
  52072. this.uniqueId = a._uniqueIdSeed++,
  52073. this.defines = (d = i.defines) !== null && d !== void 0 ? d : "",
  52074. this.onError = i.onError,
  52075. this.onCompiled = i.onCompiled,
  52076. this._entryPoint = (_ = i.entryPoint) !== null && _ !== void 0 ? _ : "main",
  52077. this._shaderStore = ShaderStore.GetShadersStore(this._shaderLanguage),
  52078. this._shaderRepository = ShaderStore.GetShadersRepository(this._shaderLanguage),
  52079. this._includeShaderStore = ShaderStore.GetIncludesShadersStore(this._shaderLanguage);
  52080. var b, k = IsWindowObjectExist() ? this._engine.getHostDocument() : null;
  52081. e.computeSource ? b = "source:" + e.computeSource : e.computeElement ? (b = k ? k.getElementById(e.computeElement) : null,
  52082. b || (b = e.computeElement)) : b = e.compute || e;
  52083. var j = {
  52084. defines: this.defines.split(`
  52085. `),
  52086. indexParameters: void 0,
  52087. isFragment: !1,
  52088. shouldUseHighPrecisionShader: !1,
  52089. processor: null,
  52090. supportsUniformBuffers: this._engine.supportsUniformBuffers,
  52091. shadersRepository: this._shaderRepository,
  52092. includesShadersStore: this._includeShaderStore,
  52093. version: (this._engine.version * 100).toString(),
  52094. platformName: this._engine.shaderPlatformName,
  52095. processingContext: null,
  52096. isNDCHalfZRange: this._engine.isNDCHalfZRange,
  52097. useReverseDepthBuffer: this._engine.useReverseDepthBuffer
  52098. };
  52099. this._loadShader(b, "Compute", "", function($) {
  52100. ShaderProcessor.Initialize(j),
  52101. ShaderProcessor.PreProcess($, j, function(_e) {
  52102. c._rawComputeSourceCode = $,
  52103. i.processFinalCode && (_e = i.processFinalCode(_e));
  52104. var et = ShaderProcessor.Finalize(_e, "", j);
  52105. c._useFinalCode(et.vertexCode, e)
  52106. }, c._engine)
  52107. })
  52108. }
  52109. return a.prototype._useFinalCode = function(e, i) {
  52110. if (i) {
  52111. var o = i.computeElement || i.compute || i.spectorName || i;
  52112. this._computeSourceCode = "//#define SHADER_NAME compute:" + o + `
  52113. ` + e
  52114. } else
  52115. this._computeSourceCode = e;
  52116. this._prepareEffect()
  52117. }
  52118. ,
  52119. Object.defineProperty(a.prototype, "key", {
  52120. get: function() {
  52121. return this._key
  52122. },
  52123. enumerable: !1,
  52124. configurable: !0
  52125. }),
  52126. a.prototype.isReady = function() {
  52127. try {
  52128. return this._isReadyInternal()
  52129. } catch {
  52130. return !1
  52131. }
  52132. }
  52133. ,
  52134. a.prototype._isReadyInternal = function() {
  52135. return this._isReady ? !0 : this._pipelineContext ? this._pipelineContext.isReady : !1
  52136. }
  52137. ,
  52138. a.prototype.getEngine = function() {
  52139. return this._engine
  52140. }
  52141. ,
  52142. a.prototype.getPipelineContext = function() {
  52143. return this._pipelineContext
  52144. }
  52145. ,
  52146. a.prototype.getCompilationError = function() {
  52147. return this._compilationError
  52148. }
  52149. ,
  52150. a.prototype.executeWhenCompiled = function(e) {
  52151. var i = this;
  52152. if (this.isReady()) {
  52153. e(this);
  52154. return
  52155. }
  52156. this.onCompileObservable.add(function(o) {
  52157. e(o)
  52158. }),
  52159. (!this._pipelineContext || this._pipelineContext.isAsync) && setTimeout(function() {
  52160. i._checkIsReady(null)
  52161. }, 16)
  52162. }
  52163. ,
  52164. a.prototype._checkIsReady = function(e) {
  52165. var i = this;
  52166. try {
  52167. if (this._isReadyInternal())
  52168. return
  52169. } catch (o) {
  52170. this._processCompilationErrors(o, e);
  52171. return
  52172. }
  52173. setTimeout(function() {
  52174. i._checkIsReady(e)
  52175. }, 16)
  52176. }
  52177. ,
  52178. a.prototype._loadShader = function(e, i, o, s) {
  52179. if (typeof HTMLElement != "undefined" && e instanceof HTMLElement) {
  52180. var c = GetDOMTextContent(e);
  52181. s(c);
  52182. return
  52183. }
  52184. if (e.substr(0, 7) === "source:") {
  52185. s(e.substr(7));
  52186. return
  52187. }
  52188. if (e.substr(0, 7) === "base64:") {
  52189. var d = window.atob(e.substr(7));
  52190. s(d);
  52191. return
  52192. }
  52193. if (this._shaderStore[e + i + "Shader"]) {
  52194. s(this._shaderStore[e + i + "Shader"]);
  52195. return
  52196. }
  52197. if (o && this._shaderStore[e + o + "Shader"]) {
  52198. s(this._shaderStore[e + o + "Shader"]);
  52199. return
  52200. }
  52201. var _;
  52202. e[0] === "." || e[0] === "/" || e.indexOf("http") > -1 ? _ = e : _ = this._shaderRepository + e,
  52203. this._engine._loadFile(_ + "." + i.toLowerCase() + ".fx", s)
  52204. }
  52205. ,
  52206. Object.defineProperty(a.prototype, "computeSourceCode", {
  52207. get: function() {
  52208. var e, i;
  52209. return this._computeSourceCodeOverride ? this._computeSourceCodeOverride : (i = (e = this._pipelineContext) === null || e === void 0 ? void 0 : e._getComputeShaderCode()) !== null && i !== void 0 ? i : this._computeSourceCode
  52210. },
  52211. enumerable: !1,
  52212. configurable: !0
  52213. }),
  52214. Object.defineProperty(a.prototype, "rawComputeSourceCode", {
  52215. get: function() {
  52216. return this._rawComputeSourceCode
  52217. },
  52218. enumerable: !1,
  52219. configurable: !0
  52220. }),
  52221. a.prototype._prepareEffect = function() {
  52222. var e = this
  52223. , i = this.defines
  52224. , o = this._pipelineContext;
  52225. this._isReady = !1;
  52226. try {
  52227. var s = this._engine;
  52228. this._pipelineContext = s.createComputePipelineContext(),
  52229. this._pipelineContext._name = this._key,
  52230. s._prepareComputePipelineContext(this._pipelineContext, this._computeSourceCodeOverride ? this._computeSourceCodeOverride : this._computeSourceCode, this._rawComputeSourceCode, this._computeSourceCodeOverride ? null : i, this._entryPoint),
  52231. s._executeWhenComputeStateIsCompiled(this._pipelineContext, function() {
  52232. e._compilationError = "",
  52233. e._isReady = !0,
  52234. e.onCompiled && e.onCompiled(e),
  52235. e.onCompileObservable.notifyObservers(e),
  52236. e.onCompileObservable.clear(),
  52237. o && e.getEngine()._deleteComputePipelineContext(o)
  52238. }),
  52239. this._pipelineContext.isAsync && this._checkIsReady(o)
  52240. } catch (c) {
  52241. this._processCompilationErrors(c, o)
  52242. }
  52243. }
  52244. ,
  52245. a.prototype._getShaderCodeAndErrorLine = function(e, i) {
  52246. var o = /COMPUTE SHADER ERROR: 0:(\d+?):/
  52247. , s = null;
  52248. if (i && e) {
  52249. var c = i.match(o);
  52250. if (c && c.length === 2) {
  52251. var d = parseInt(c[1])
  52252. , _ = e.split(`
  52253. `, -1);
  52254. _.length >= d && (s = "Offending line [" + d + "] in compute code: " + _[d - 1])
  52255. }
  52256. }
  52257. return [e, s]
  52258. }
  52259. ,
  52260. a.prototype._processCompilationErrors = function(e, i) {
  52261. var o, s;
  52262. if (i === void 0 && (i = null),
  52263. this._compilationError = e.message,
  52264. Logger$2.Error("Unable to compile compute effect:"),
  52265. Logger$2.Error(`Defines:\r
  52266. ` + this.defines),
  52267. a.LogShaderCodeOnCompilationError) {
  52268. var c = null
  52269. , d = null;
  52270. !((s = this._pipelineContext) === null || s === void 0) && s._getComputeShaderCode() && (o = this._getShaderCodeAndErrorLine(this._pipelineContext._getComputeShaderCode(), this._compilationError),
  52271. d = o[0],
  52272. c = o[1],
  52273. d && (Logger$2.Error("Compute code:"),
  52274. Logger$2.Error(d))),
  52275. c && Logger$2.Error(c)
  52276. }
  52277. Logger$2.Error("Error: " + this._compilationError),
  52278. i && (this._pipelineContext = i,
  52279. this._isReady = !0,
  52280. this.onError && this.onError(this, this._compilationError),
  52281. this.onErrorObservable.notifyObservers(this))
  52282. }
  52283. ,
  52284. a.prototype.dispose = function() {
  52285. this._pipelineContext && this._pipelineContext.dispose(),
  52286. this._engine._releaseComputeEffect(this)
  52287. }
  52288. ,
  52289. a.RegisterShader = function(e, i) {
  52290. ShaderStore.GetShadersStore(ShaderLanguage.WGSL)[e + "ComputeShader"] = i
  52291. }
  52292. ,
  52293. a._uniqueIdSeed = 0,
  52294. a.LogShaderCodeOnCompilationError = !0,
  52295. a
  52296. }()
  52297. , WebGPUComputeContext = function() {
  52298. function a(e, i) {
  52299. this._device = e,
  52300. this._cacheSampler = i,
  52301. this.uniqueId = a._Counter++,
  52302. this._bindGroupEntries = [],
  52303. this.clear()
  52304. }
  52305. return a.prototype.getBindGroups = function(e, i, o) {
  52306. if (!o)
  52307. throw new Error("WebGPUComputeContext.getBindGroups: bindingsMapping is required until browsers support reflection for wgsl shaders!");
  52308. if (this._bindGroups.length === 0) {
  52309. var s = this._bindGroupEntries.length > 0;
  52310. for (var c in e) {
  52311. var d = e[c]
  52312. , _ = o[c]
  52313. , b = _.group
  52314. , k = _.binding
  52315. , j = d.type
  52316. , $ = d.object
  52317. , _e = d.indexInGroupEntries
  52318. , et = this._bindGroupEntries[b];
  52319. switch (et || (et = this._bindGroupEntries[b] = []),
  52320. j) {
  52321. case ComputeBindingType.Sampler:
  52322. {
  52323. var tt = $;
  52324. _e !== void 0 && s ? et[_e].resource = this._cacheSampler.getSampler(tt) : (d.indexInGroupEntries = et.length,
  52325. et.push({
  52326. binding: k,
  52327. resource: this._cacheSampler.getSampler(tt)
  52328. }));
  52329. break
  52330. }
  52331. case ComputeBindingType.Texture:
  52332. case ComputeBindingType.TextureWithoutSampler:
  52333. {
  52334. var rt = $
  52335. , it = rt._texture._hardwareTexture;
  52336. _e !== void 0 && s ? (j === ComputeBindingType.Texture && (et[_e++].resource = this._cacheSampler.getSampler(rt._texture)),
  52337. et[_e].resource = it.view) : (d.indexInGroupEntries = et.length,
  52338. j === ComputeBindingType.Texture && et.push({
  52339. binding: k - 1,
  52340. resource: this._cacheSampler.getSampler(rt._texture)
  52341. }),
  52342. et.push({
  52343. binding: k,
  52344. resource: it.view
  52345. }));
  52346. break
  52347. }
  52348. case ComputeBindingType.StorageTexture:
  52349. {
  52350. var rt = $
  52351. , it = rt._texture._hardwareTexture;
  52352. (it.textureAdditionalUsages & TextureUsage.StorageBinding) === 0 && Logger$2.Error("computeDispatch: The texture (name=" + rt.name + ", uniqueId=" + rt.uniqueId + ") is not a storage texture!", 50),
  52353. _e !== void 0 && s ? et[_e].resource = it.view : (d.indexInGroupEntries = et.length,
  52354. et.push({
  52355. binding: k,
  52356. resource: it.view
  52357. }));
  52358. break
  52359. }
  52360. case ComputeBindingType.UniformBuffer:
  52361. case ComputeBindingType.StorageBuffer:
  52362. {
  52363. var nt = (j === ComputeBindingType.UniformBuffer,
  52364. $)
  52365. , ot = nt.getBuffer()
  52366. , at = ot.underlyingResource;
  52367. _e !== void 0 && s ? (et[_e].resource.buffer = at,
  52368. et[_e].resource.size = ot.capacity) : (d.indexInGroupEntries = et.length,
  52369. et.push({
  52370. binding: k,
  52371. resource: {
  52372. buffer: at,
  52373. offset: 0,
  52374. size: ot.capacity
  52375. }
  52376. }));
  52377. break
  52378. }
  52379. }
  52380. }
  52381. for (var st = 0; st < this._bindGroupEntries.length; ++st) {
  52382. var et = this._bindGroupEntries[st];
  52383. if (!et) {
  52384. this._bindGroups[st] = void 0;
  52385. continue
  52386. }
  52387. this._bindGroups[st] = this._device.createBindGroup({
  52388. layout: i.getBindGroupLayout(st),
  52389. entries: et
  52390. })
  52391. }
  52392. this._bindGroups.length = this._bindGroupEntries.length
  52393. }
  52394. return this._bindGroups
  52395. }
  52396. ,
  52397. a.prototype.clear = function() {
  52398. this._bindGroups = []
  52399. }
  52400. ,
  52401. a._Counter = 0,
  52402. a
  52403. }()
  52404. , WebGPUComputePipelineContext = function() {
  52405. function a(e) {
  52406. this._name = "unnamed",
  52407. this.engine = e
  52408. }
  52409. return Object.defineProperty(a.prototype, "isAsync", {
  52410. get: function() {
  52411. return !1
  52412. },
  52413. enumerable: !1,
  52414. configurable: !0
  52415. }),
  52416. Object.defineProperty(a.prototype, "isReady", {
  52417. get: function() {
  52418. return !!this.stage
  52419. },
  52420. enumerable: !1,
  52421. configurable: !0
  52422. }),
  52423. a.prototype._getComputeShaderCode = function() {
  52424. var e;
  52425. return (e = this.sources) === null || e === void 0 ? void 0 : e.compute
  52426. }
  52427. ,
  52428. a.prototype.dispose = function() {}
  52429. ,
  52430. a
  52431. }();
  52432. WebGPUEngine.prototype.createComputeContext = function() {
  52433. return new WebGPUComputeContext(this._device,this._cacheSampler)
  52434. }
  52435. ;
  52436. WebGPUEngine.prototype.createComputeEffect = function(a, e) {
  52437. var i = a.computeElement || a.compute || a.computeToken || a.computeSource || a
  52438. , o = i + "@" + e.defines;
  52439. if (this._compiledComputeEffects[o]) {
  52440. var s = this._compiledComputeEffects[o];
  52441. return e.onCompiled && s.isReady() && e.onCompiled(s),
  52442. s
  52443. }
  52444. var c = new ComputeEffect(a,e,this,o);
  52445. return this._compiledComputeEffects[o] = c,
  52446. c
  52447. }
  52448. ;
  52449. WebGPUEngine.prototype.createComputePipelineContext = function() {
  52450. return new WebGPUComputePipelineContext(this)
  52451. }
  52452. ;
  52453. WebGPUEngine.prototype.areAllComputeEffectsReady = function() {
  52454. for (var a in this._compiledComputeEffects) {
  52455. var e = this._compiledComputeEffects[a];
  52456. if (!e.isReady())
  52457. return !1
  52458. }
  52459. return !0
  52460. }
  52461. ;
  52462. WebGPUEngine.prototype.computeDispatch = function(a, e, i, o, s, c, d) {
  52463. var _ = this;
  52464. if (this._currentRenderTarget) {
  52465. this._onAfterUnbindFrameBufferObservable.addOnce(function() {
  52466. _.computeDispatch(a, e, i, o, s, c, d)
  52467. });
  52468. return
  52469. }
  52470. var b = a._pipelineContext
  52471. , k = e;
  52472. b.computePipeline || (b.computePipeline = this._device.createComputePipeline({
  52473. compute: b.stage
  52474. }));
  52475. var j = this._renderTargetEncoder
  52476. , $ = j.beginComputePass();
  52477. $.setPipeline(b.computePipeline);
  52478. for (var _e = k.getBindGroups(i, b.computePipeline, d), et = 0; et < _e.length; ++et) {
  52479. var tt = _e[et];
  52480. !tt || $.setBindGroup(et, tt)
  52481. }
  52482. $.dispatch(o, s, c),
  52483. $.endPass()
  52484. }
  52485. ;
  52486. WebGPUEngine.prototype.releaseComputeEffects = function() {
  52487. for (var a in this._compiledComputeEffects) {
  52488. var e = this._compiledComputeEffects[a].getPipelineContext();
  52489. this._deleteComputePipelineContext(e)
  52490. }
  52491. this._compiledComputeEffects = {}
  52492. }
  52493. ;
  52494. WebGPUEngine.prototype._prepareComputePipelineContext = function(a, e, i, o, s) {
  52495. var c = a;
  52496. this.dbgShowShaderCode && (console.log(o),
  52497. console.log(e)),
  52498. c.sources = {
  52499. compute: e,
  52500. rawCompute: i
  52501. },
  52502. c.stage = this._createComputePipelineStageDescriptor(e, o, s)
  52503. }
  52504. ;
  52505. WebGPUEngine.prototype._releaseComputeEffect = function(a) {
  52506. this._compiledComputeEffects[a._key] && (delete this._compiledComputeEffects[a._key],
  52507. this._deleteComputePipelineContext(a.getPipelineContext()))
  52508. }
  52509. ;
  52510. WebGPUEngine.prototype._rebuildComputeEffects = function() {
  52511. for (var a in this._compiledComputeEffects) {
  52512. var e = this._compiledComputeEffects[a];
  52513. e._pipelineContext = null,
  52514. e._wasPreviouslyReady = !1,
  52515. e._prepareEffect()
  52516. }
  52517. }
  52518. ;
  52519. WebGPUEngine.prototype._deleteComputePipelineContext = function(a) {
  52520. var e = a;
  52521. e && a.dispose()
  52522. }
  52523. ;
  52524. WebGPUEngine.prototype._createComputePipelineStageDescriptor = function(a, e, i) {
  52525. return e ? e = "//" + e.split(`
  52526. `).join(`
  52527. //`) + `
  52528. ` : e = "",
  52529. {
  52530. module: this._device.createShaderModule({
  52531. code: e + a
  52532. }),
  52533. entryPoint: i
  52534. }
  52535. }
  52536. ;
  52537. WebGPUEngine.prototype._createDepthStencilCubeTexture = function(a, e) {
  52538. var i = new InternalTexture(this,InternalTextureSource.DepthStencil);
  52539. i.isCube = !0;
  52540. var o = __assign({
  52541. bilinearFiltering: !1,
  52542. comparisonFunction: 0,
  52543. generateStencil: !1,
  52544. samples: 1
  52545. }, e);
  52546. return i.format = o.generateStencil ? 13 : 14,
  52547. this._setupDepthStencilTexture(i, a, o.generateStencil, o.bilinearFiltering, o.comparisonFunction, o.samples),
  52548. this._textureHelper.createGPUTextureForInternalTexture(i),
  52549. this._internalTexturesCache.push(i),
  52550. i
  52551. }
  52552. ;
  52553. WebGPUEngine.prototype.createCubeTexture = function(a, e, i, o, s, c, d, _, b, k, j, $, _e) {
  52554. var et = this;
  52555. return s === void 0 && (s = null),
  52556. c === void 0 && (c = null),
  52557. _ === void 0 && (_ = null),
  52558. b === void 0 && (b = !1),
  52559. k === void 0 && (k = 0),
  52560. j === void 0 && (j = 0),
  52561. $ === void 0 && ($ = null),
  52562. _e === void 0 && (_e = !1),
  52563. this.createCubeTextureBase(a, e, i, !!o, s, c, d, _, b, k, j, $, null, function(tt, rt) {
  52564. var it = rt
  52565. , nt = it[0].width
  52566. , ot = nt;
  52567. et._setCubeMapTextureParams(tt, !o),
  52568. tt.format = d != null ? d : -1;
  52569. var at = et._textureHelper.createGPUTextureForInternalTexture(tt, nt, ot);
  52570. et._textureHelper.updateCubeTextures(it, at.underlyingResource, nt, ot, at.format, !1, !1, 0, 0, et._uploadEncoder),
  52571. o || et._generateMipmaps(tt, et._uploadEncoder),
  52572. tt.isReady = !0,
  52573. tt.onLoadedObservable.notifyObservers(tt),
  52574. tt.onLoadedObservable.clear(),
  52575. s && s()
  52576. }, !!_e)
  52577. }
  52578. ;
  52579. WebGPUEngine.prototype._setCubeMapTextureParams = function(a, e) {
  52580. a.samplingMode = e ? 3 : 2,
  52581. a._cachedWrapU = 0,
  52582. a._cachedWrapV = 0
  52583. }
  52584. ;
  52585. WebGPUEngine.prototype._debugPushGroup = function(a, e) {
  52586. if (!!this._options.enableGPUDebugMarkers)
  52587. if (e === 0 || e === 1) {
  52588. var i = e === 0 ? this._renderEncoder : this._renderTargetEncoder;
  52589. i.pushDebugGroup(a)
  52590. } else
  52591. this._currentRenderPass ? this._currentRenderPass.pushDebugGroup(a) : this._pendingDebugCommands.push(["push", a])
  52592. }
  52593. ;
  52594. WebGPUEngine.prototype._debugPopGroup = function(a) {
  52595. if (!!this._options.enableGPUDebugMarkers)
  52596. if (a === 0 || a === 1) {
  52597. var e = a === 0 ? this._renderEncoder : this._renderTargetEncoder;
  52598. e.popDebugGroup()
  52599. } else
  52600. this._currentRenderPass ? this._currentRenderPass.popDebugGroup() : this._pendingDebugCommands.push(["pop", null])
  52601. }
  52602. ;
  52603. WebGPUEngine.prototype._debugInsertMarker = function(a, e) {
  52604. if (!!this._options.enableGPUDebugMarkers)
  52605. if (e === 0 || e === 1) {
  52606. var i = e === 0 ? this._renderEncoder : this._renderTargetEncoder;
  52607. i.insertDebugMarker(a)
  52608. } else
  52609. this._currentRenderPass ? this._currentRenderPass.insertDebugMarker(a) : this._pendingDebugCommands.push(["insert", a])
  52610. }
  52611. ;
  52612. WebGPUEngine.prototype._debugFlushPendingCommands = function() {
  52613. for (var a = 0; a < this._pendingDebugCommands.length; ++a) {
  52614. var e = this._pendingDebugCommands[a]
  52615. , i = e[0]
  52616. , o = e[1];
  52617. switch (i) {
  52618. case "push":
  52619. this._debugPushGroup(o);
  52620. break;
  52621. case "pop":
  52622. this._debugPopGroup();
  52623. break;
  52624. case "insert":
  52625. this._debugInsertMarker(o);
  52626. break
  52627. }
  52628. }
  52629. this._pendingDebugCommands.length = 0
  52630. }
  52631. ;
  52632. WebGPUEngine.prototype.updateDynamicIndexBuffer = function(a, e, i) {
  52633. i === void 0 && (i = 0);
  52634. var o = a, s;
  52635. e instanceof Uint16Array ? a.is32Bits ? s = Uint32Array.from(e) : s = e : e instanceof Uint32Array ? a.is32Bits ? s = e : s = Uint16Array.from(e) : a.is32Bits ? s = new Uint32Array(e) : s = new Uint16Array(e),
  52636. this._bufferManager.setSubData(o, i, s)
  52637. }
  52638. ;
  52639. WebGPUEngine.prototype.updateDynamicVertexBuffer = function(a, e, i, o) {
  52640. var s = a;
  52641. i === void 0 && (i = 0);
  52642. var c;
  52643. o === void 0 ? (e instanceof Array ? c = new Float32Array(e) : e instanceof ArrayBuffer ? c = new Uint8Array(e) : c = e,
  52644. o = c.byteLength) : e instanceof Array ? c = new Float32Array(e) : e instanceof ArrayBuffer ? c = new Uint8Array(e) : c = e,
  52645. this._bufferManager.setSubData(s, i, c, 0, o)
  52646. }
  52647. ;
  52648. WebGPUEngine.prototype.updateDynamicTexture = function(a, e, i, o, s, c, d) {
  52649. var _;
  52650. if (o === void 0 && (o = !1),
  52651. !!a) {
  52652. var b = e.width
  52653. , k = e.height
  52654. , j = a._hardwareTexture;
  52655. !((_ = a._hardwareTexture) === null || _ === void 0) && _.underlyingResource || (j = this._textureHelper.createGPUTextureForInternalTexture(a, b, k)),
  52656. this._textureHelper.updateTexture(e, a, b, k, a.depth, j.format, 0, 0, i, o, 0, 0, this._uploadEncoder, d),
  52657. a.generateMipMaps && this._generateMipmaps(a, this._uploadEncoder),
  52658. a.isReady = !0
  52659. }
  52660. }
  52661. ;
  52662. var WebGPUExternalTexture = function(a) {
  52663. __extends(e, a);
  52664. function e(i) {
  52665. return a.call(this, i) || this
  52666. }
  52667. return e
  52668. }(ExternalTexture);
  52669. Effect.prototype.setExternalTexture = function(a, e) {
  52670. this._engine.setExternalTexture(a, e)
  52671. }
  52672. ;
  52673. WebGPUEngine.prototype.createExternalTexture = function(a) {
  52674. var e = new WebGPUExternalTexture(a);
  52675. return e
  52676. }
  52677. ;
  52678. WebGPUEngine.prototype.setExternalTexture = function(a, e) {
  52679. if (!e) {
  52680. this._currentMaterialContext.setTexture(a, null);
  52681. return
  52682. }
  52683. this._setInternalTexture(a, e)
  52684. }
  52685. ;
  52686. WebGPUEngine.prototype.unBindMultiColorAttachmentFramebuffer = function(a, e, i) {
  52687. e === void 0 && (e = !1),
  52688. i && i();
  52689. var o = a._attachments
  52690. , s = o.length;
  52691. this._currentRenderPass && this._currentRenderPass !== this._mainRenderPassWrapper.renderPass && this._endRenderTargetRenderPass();
  52692. for (var c = 0; c < s; c++) {
  52693. var d = a.textures[c];
  52694. d.generateMipMaps && !e && !d.isCube && this._generateMipmaps(d)
  52695. }
  52696. this._currentRenderTarget = null,
  52697. this._mrtAttachments = [],
  52698. this._cacheRenderPipeline.setMRTAttachments(this._mrtAttachments, []),
  52699. this._currentRenderPass = this._mainRenderPassWrapper.renderPass,
  52700. this._setDepthTextureFormat(this._mainRenderPassWrapper),
  52701. this._setColorFormat(this._mainRenderPassWrapper)
  52702. }
  52703. ;
  52704. WebGPUEngine.prototype.createMultipleRenderTarget = function(a, e, i) {
  52705. var o, s = !1, c = !0, d = !1, _ = !1, b = 15, k = 1, j = 0, $ = 3, _e = new Array, et = new Array, tt = this._createHardwareRenderTargetWrapper(!0, !1, a);
  52706. e !== void 0 && (s = e.generateMipMaps === void 0 ? !1 : e.generateMipMaps,
  52707. c = e.generateDepthBuffer === void 0 ? !0 : e.generateDepthBuffer,
  52708. d = e.generateStencilBuffer === void 0 ? !1 : e.generateStencilBuffer,
  52709. _ = e.generateDepthTexture === void 0 ? !1 : e.generateDepthTexture,
  52710. k = e.textureCount || 1,
  52711. b = (o = e.depthTextureFormat) !== null && o !== void 0 ? o : 15,
  52712. e.types && (_e = e.types),
  52713. e.samplingModes && (et = e.samplingModes));
  52714. var rt = a.width || a
  52715. , it = a.height || a
  52716. , nt = null;
  52717. (c || d || _) && (nt = tt.createDepthStencilTexture(0, !1, d, 1, b));
  52718. var ot = []
  52719. , at = [];
  52720. tt._generateDepthBuffer = c,
  52721. tt._generateStencilBuffer = d,
  52722. tt._attachments = at;
  52723. for (var st = 0; st < k; st++) {
  52724. var ut = et[st] || $
  52725. , ct = _e[st] || j;
  52726. (ct === 1 && !this._caps.textureFloatLinearFiltering || ct === 2 && !this._caps.textureHalfFloatLinearFiltering) && (ut = 1),
  52727. ct === 1 && !this._caps.textureFloat && (ct = 0,
  52728. Logger$2.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type"));
  52729. var lt = new InternalTexture(this,InternalTextureSource.MultiRenderTarget);
  52730. ot.push(lt),
  52731. at.push(st + 1),
  52732. lt.baseWidth = rt,
  52733. lt.baseHeight = it,
  52734. lt.width = rt,
  52735. lt.height = it,
  52736. lt.isReady = !0,
  52737. lt.samples = 1,
  52738. lt.generateMipMaps = s,
  52739. lt.samplingMode = ut,
  52740. lt.type = ct,
  52741. lt._cachedWrapU = 0,
  52742. lt._cachedWrapV = 0,
  52743. this._internalTexturesCache.push(lt),
  52744. this._textureHelper.createGPUTextureForInternalTexture(lt)
  52745. }
  52746. return nt && (nt.incrementReferences(),
  52747. ot.push(nt),
  52748. this._internalTexturesCache.push(nt)),
  52749. tt.setTextures(ot),
  52750. tt
  52751. }
  52752. ;
  52753. WebGPUEngine.prototype.updateMultipleRenderTargetTextureSampleCount = function(a, e) {
  52754. if (!a || !a.textures || a.textures[0].samples === e)
  52755. return e;
  52756. var i = a._attachments.length;
  52757. if (i === 0)
  52758. return 1;
  52759. e = Math.min(e, this.getCaps().maxMSAASamples);
  52760. for (var o = 0; o < i; ++o) {
  52761. var s = a.textures[o];
  52762. this._textureHelper.createMSAATexture(s, e),
  52763. s.samples = e
  52764. }
  52765. return a._depthStencilTexture && a._depthStencilTexture !== a.textures[a.textures.length - 1] && (this._textureHelper.createMSAATexture(a._depthStencilTexture, e),
  52766. a._depthStencilTexture.samples = e),
  52767. e
  52768. }
  52769. ;
  52770. WebGPUEngine.prototype.bindAttachments = function(a) {
  52771. a.length === 0 || !this._currentRenderTarget || (this._mrtAttachments = a)
  52772. }
  52773. ;
  52774. WebGPUEngine.prototype.buildTextureLayout = function(a) {
  52775. for (var e = [], i = 0; i < a.length; i++)
  52776. a[i] ? e.push(i + 1) : e.push(0);
  52777. return e
  52778. }
  52779. ;
  52780. WebGPUEngine.prototype.restoreSingleAttachment = function() {}
  52781. ;
  52782. WebGPUEngine.prototype.getGPUFrameTimeCounter = function() {
  52783. return this._timestampQuery.gpuFrameTimeCounter
  52784. }
  52785. ;
  52786. WebGPUEngine.prototype.captureGPUFrameTime = function(a) {
  52787. this._timestampQuery.enable = a && !!this._caps.timerQuery
  52788. }
  52789. ;
  52790. WebGPUEngine.prototype.createQuery = function() {
  52791. return this._occlusionQuery.createQuery()
  52792. }
  52793. ;
  52794. WebGPUEngine.prototype.deleteQuery = function(a) {
  52795. return this._occlusionQuery.deleteQuery(a),
  52796. this
  52797. }
  52798. ;
  52799. WebGPUEngine.prototype.isQueryResultAvailable = function(a) {
  52800. return this._occlusionQuery.isQueryResultAvailable(a)
  52801. }
  52802. ;
  52803. WebGPUEngine.prototype.getQueryResult = function(a) {
  52804. return this._occlusionQuery.getQueryResult(a)
  52805. }
  52806. ;
  52807. WebGPUEngine.prototype.beginOcclusionQuery = function(a, e) {
  52808. var i;
  52809. if (this.compatibilityMode) {
  52810. if (this._occlusionQuery.canBeginQuery)
  52811. return (i = this._currentRenderPass) === null || i === void 0 || i.beginOcclusionQuery(e),
  52812. !0
  52813. } else {
  52814. var o = this._getCurrentRenderPassIndex()
  52815. , s = o === 0 ? this._bundleList : this._bundleListRenderTarget;
  52816. return s.addItem(new WebGPURenderItemBeginOcclusionQuery(e)),
  52817. !0
  52818. }
  52819. return !1
  52820. }
  52821. ;
  52822. WebGPUEngine.prototype.endOcclusionQuery = function(a) {
  52823. var e;
  52824. if (this.compatibilityMode)
  52825. (e = this._currentRenderPass) === null || e === void 0 || e.endOcclusionQuery();
  52826. else {
  52827. var i = this._getCurrentRenderPassIndex()
  52828. , o = i === 0 ? this._bundleList : this._bundleListRenderTarget;
  52829. o.addItem(new WebGPURenderItemEndOcclusionQuery)
  52830. }
  52831. return this
  52832. }
  52833. ;
  52834. WebGPUEngine.prototype.createRawTexture = function(a, e, i, o, s, c, d, _, b, k) {
  52835. _ === void 0 && (_ = null),
  52836. b === void 0 && (b = 0),
  52837. k === void 0 && (k = 0);
  52838. var j = new InternalTexture(this,InternalTextureSource.Raw);
  52839. return j.baseWidth = e,
  52840. j.baseHeight = i,
  52841. j.width = e,
  52842. j.height = i,
  52843. j.format = o,
  52844. j.generateMipMaps = s,
  52845. j.samplingMode = d,
  52846. j.invertY = c,
  52847. j._compression = _,
  52848. j.type = b,
  52849. this._doNotHandleContextLost || (j._bufferView = a),
  52850. this._textureHelper.createGPUTextureForInternalTexture(j, e, i, void 0, k),
  52851. this.updateRawTexture(j, a, o, c, _, b),
  52852. this._internalTexturesCache.push(j),
  52853. j
  52854. }
  52855. ;
  52856. WebGPUEngine.prototype.updateRawTexture = function(a, e, i, o, s, c) {
  52857. if (s === void 0 && (s = null),
  52858. c === void 0 && (c = 0),
  52859. !!a) {
  52860. if (this._doNotHandleContextLost || (a._bufferView = e,
  52861. a.invertY = o,
  52862. a._compression = s),
  52863. e) {
  52864. var d = a._hardwareTexture
  52865. , _ = i === 4;
  52866. _ && (e = _convertRGBtoRGBATextureData(e, a.width, a.height, c));
  52867. var b = new Uint8Array(e.buffer,e.byteOffset,e.byteLength);
  52868. this._textureHelper.updateTexture(b, a, a.width, a.height, a.depth, d.format, 0, 0, o, !1, 0, 0, this._uploadEncoder),
  52869. a.generateMipMaps && this._generateMipmaps(a, this._uploadEncoder)
  52870. }
  52871. a.isReady = !0
  52872. }
  52873. }
  52874. ;
  52875. WebGPUEngine.prototype.createRawCubeTexture = function(a, e, i, o, s, c, d, _) {
  52876. _ === void 0 && (_ = null);
  52877. var b = new InternalTexture(this,InternalTextureSource.CubeRaw);
  52878. return o === 1 && !this._caps.textureFloatLinearFiltering ? (s = !1,
  52879. d = 1,
  52880. Logger$2.Warn("Float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.")) : o === 2 && !this._caps.textureHalfFloatLinearFiltering ? (s = !1,
  52881. d = 1,
  52882. Logger$2.Warn("Half float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.")) : o === 1 && !this._caps.textureFloatRender ? (s = !1,
  52883. Logger$2.Warn("Render to float textures is not supported. Mipmap generation forced to false.")) : o === 2 && !this._caps.colorBufferFloat && (s = !1,
  52884. Logger$2.Warn("Render to half float textures is not supported. Mipmap generation forced to false.")),
  52885. b.isCube = !0,
  52886. b.format = i === 4 ? 5 : i,
  52887. b.type = o,
  52888. b.generateMipMaps = s,
  52889. b.width = e,
  52890. b.height = e,
  52891. b.samplingMode = d,
  52892. this._doNotHandleContextLost || (b._bufferViewArray = a),
  52893. b._cachedWrapU = 0,
  52894. b._cachedWrapV = 0,
  52895. this._textureHelper.createGPUTextureForInternalTexture(b),
  52896. a && this.updateRawCubeTexture(b, a, i, o, c, _),
  52897. b
  52898. }
  52899. ;
  52900. WebGPUEngine.prototype.updateRawCubeTexture = function(a, e, i, o, s, c, d) {
  52901. c === void 0 && (c = null),
  52902. a._bufferViewArray = e,
  52903. a.invertY = s,
  52904. a._compression = c;
  52905. for (var _ = a._hardwareTexture, b = i === 4, k = [], j = 0; j < e.length; ++j) {
  52906. var $ = e[j];
  52907. b && ($ = _convertRGBtoRGBATextureData(e[j], a.width, a.height, o)),
  52908. k.push(new Uint8Array($.buffer,$.byteOffset,$.byteLength))
  52909. }
  52910. this._textureHelper.updateCubeTextures(k, _.underlyingResource, a.width, a.height, _.format, s, !1, 0, 0, this._uploadEncoder),
  52911. a.generateMipMaps && this._generateMipmaps(a, this._uploadEncoder),
  52912. a.isReady = !0
  52913. }
  52914. ;
  52915. WebGPUEngine.prototype.createRawCubeTextureFromUrl = function(a, e, i, o, s, c, d, _, b, k, j, $) {
  52916. var _e = this;
  52917. b === void 0 && (b = null),
  52918. k === void 0 && (k = null),
  52919. j === void 0 && (j = 3),
  52920. $ === void 0 && ($ = !1);
  52921. var et = this.createRawCubeTexture(null, i, o, s, !c, $, j, null);
  52922. e == null || e._addPendingData(et),
  52923. et.url = a,
  52924. this._internalTexturesCache.push(et);
  52925. var tt = function(it, nt) {
  52926. e == null || e._removePendingData(et),
  52927. k && it && k(it.status + " " + it.statusText, nt)
  52928. }
  52929. , rt = function(it) {
  52930. var nt = et.width
  52931. , ot = d(it);
  52932. if (!!ot) {
  52933. var at = [0, 2, 4, 1, 3, 5];
  52934. if (_)
  52935. for (var st = o === 4, ut = _(ot), ct = et._hardwareTexture, lt = [0, 1, 2, 3, 4, 5], ft = 0; ft < ut.length; ft++) {
  52936. for (var ht = nt >> ft, pt = [], dt = 0; dt < 6; dt++) {
  52937. var _t = ut[ft][lt[dt]];
  52938. st && (_t = _convertRGBtoRGBATextureData(_t, ht, ht, s)),
  52939. pt.push(new Uint8Array(_t.buffer,_t.byteOffset,_t.byteLength))
  52940. }
  52941. _e._textureHelper.updateCubeTextures(pt, ct.underlyingResource, ht, ht, ct.format, $, !1, 0, 0, _e._uploadEncoder)
  52942. }
  52943. else {
  52944. for (var pt = [], dt = 0; dt < 6; dt++)
  52945. pt.push(ot[at[dt]]);
  52946. _e.updateRawCubeTexture(et, pt, o, s, $)
  52947. }
  52948. et.isReady = !0,
  52949. e == null || e._removePendingData(et),
  52950. b && b()
  52951. }
  52952. };
  52953. return this._loadFile(a, function(it) {
  52954. rt(it)
  52955. }, void 0, e == null ? void 0 : e.offlineProvider, !0, tt),
  52956. et
  52957. }
  52958. ;
  52959. WebGPUEngine.prototype.createRawTexture3D = function(a, e, i, o, s, c, d, _, b, k, j) {
  52960. b === void 0 && (b = null),
  52961. k === void 0 && (k = 0),
  52962. j === void 0 && (j = 0);
  52963. var $ = InternalTextureSource.Raw3D
  52964. , _e = new InternalTexture(this,$);
  52965. return _e.baseWidth = e,
  52966. _e.baseHeight = i,
  52967. _e.baseDepth = o,
  52968. _e.width = e,
  52969. _e.height = i,
  52970. _e.depth = o,
  52971. _e.format = s,
  52972. _e.type = k,
  52973. _e.generateMipMaps = c,
  52974. _e.samplingMode = _,
  52975. _e.is3D = !0,
  52976. this._doNotHandleContextLost || (_e._bufferView = a),
  52977. this._textureHelper.createGPUTextureForInternalTexture(_e, e, i, void 0, j),
  52978. this.updateRawTexture3D(_e, a, s, d, b, k),
  52979. this._internalTexturesCache.push(_e),
  52980. _e
  52981. }
  52982. ;
  52983. WebGPUEngine.prototype.updateRawTexture3D = function(a, e, i, o, s, c) {
  52984. if (s === void 0 && (s = null),
  52985. c === void 0 && (c = 0),
  52986. this._doNotHandleContextLost || (a._bufferView = e,
  52987. a.format = i,
  52988. a.invertY = o,
  52989. a._compression = s),
  52990. e) {
  52991. var d = a._hardwareTexture
  52992. , _ = i === 4;
  52993. _ && (e = _convertRGBtoRGBATextureData(e, a.width, a.height, c));
  52994. var b = new Uint8Array(e.buffer,e.byteOffset,e.byteLength);
  52995. this._textureHelper.updateTexture(b, a, a.width, a.height, a.depth, d.format, 0, 0, o, !1, 0, 0, this._uploadEncoder),
  52996. a.generateMipMaps && this._generateMipmaps(a, this._uploadEncoder)
  52997. }
  52998. a.isReady = !0
  52999. }
  53000. ;
  53001. WebGPUEngine.prototype.createRawTexture2DArray = function(a, e, i, o, s, c, d, _, b, k, j) {
  53002. b === void 0 && (b = null),
  53003. k === void 0 && (k = 0),
  53004. j === void 0 && (j = 0);
  53005. var $ = InternalTextureSource.Raw2DArray
  53006. , _e = new InternalTexture(this,$);
  53007. return _e.baseWidth = e,
  53008. _e.baseHeight = i,
  53009. _e.baseDepth = o,
  53010. _e.width = e,
  53011. _e.height = i,
  53012. _e.depth = o,
  53013. _e.format = s,
  53014. _e.type = k,
  53015. _e.generateMipMaps = c,
  53016. _e.samplingMode = _,
  53017. _e.is2DArray = !0,
  53018. this._doNotHandleContextLost || (_e._bufferView = a),
  53019. this._textureHelper.createGPUTextureForInternalTexture(_e, e, i, o, j),
  53020. this.updateRawTexture2DArray(_e, a, s, d, b, k),
  53021. this._internalTexturesCache.push(_e),
  53022. _e
  53023. }
  53024. ;
  53025. WebGPUEngine.prototype.updateRawTexture2DArray = function(a, e, i, o, s, c) {
  53026. if (s === void 0 && (s = null),
  53027. c === void 0 && (c = 0),
  53028. this._doNotHandleContextLost || (a._bufferView = e,
  53029. a.format = i,
  53030. a.invertY = o,
  53031. a._compression = s),
  53032. e) {
  53033. var d = a._hardwareTexture
  53034. , _ = i === 4;
  53035. _ && (e = _convertRGBtoRGBATextureData(e, a.width, a.height, c));
  53036. var b = new Uint8Array(e.buffer,e.byteOffset,e.byteLength);
  53037. this._textureHelper.updateTexture(b, a, a.width, a.height, a.depth, d.format, 0, 0, o, !1, 0, 0, this._uploadEncoder),
  53038. a.generateMipMaps && this._generateMipmaps(a, this._uploadEncoder)
  53039. }
  53040. a.isReady = !0
  53041. }
  53042. ;
  53043. function _convertRGBtoRGBATextureData(a, e, i, o) {
  53044. var s, c = 1;
  53045. o === 1 ? s = new Float32Array(e * i * 4) : o === 2 ? (s = new Uint16Array(e * i * 4),
  53046. c = 15360) : o === 7 ? s = new Uint32Array(e * i * 4) : s = new Uint8Array(e * i * 4);
  53047. for (var d = 0; d < e; d++)
  53048. for (var _ = 0; _ < i; _++) {
  53049. var b = (_ * e + d) * 3
  53050. , k = (_ * e + d) * 4;
  53051. s[k + 0] = a[b + 0],
  53052. s[k + 1] = a[b + 1],
  53053. s[k + 2] = a[b + 2],
  53054. s[k + 3] = c
  53055. }
  53056. return s
  53057. }
  53058. WebGPUEngine.prototype._readTexturePixels = function(a, e, i, o, s, c, d, _) {
  53059. o === void 0 && (o = -1),
  53060. s === void 0 && (s = 0),
  53061. c === void 0 && (c = null),
  53062. d === void 0 && (d = !0),
  53063. _ === void 0 && (_ = !1);
  53064. var b = a._hardwareTexture;
  53065. return d && this.flushFramebuffer(),
  53066. this._textureHelper.readPixels(b.underlyingResource, 0, 0, e, i, b.format, o, s, c, _)
  53067. }
  53068. ;
  53069. WebGPUEngine.prototype._readTexturePixelsSync = function(a, e, i, o, s, c, d, _) {
  53070. throw "_readTexturePixelsSync is unsupported in WebGPU!"
  53071. }
  53072. ;
  53073. WebGPUEngine.prototype._createHardwareRenderTargetWrapper = function(a, e, i) {
  53074. var o = new RenderTargetWrapper(a,e,i,this);
  53075. return this._renderTargetWrapperCache.push(o),
  53076. o
  53077. }
  53078. ;
  53079. WebGPUEngine.prototype.createRenderTargetTexture = function(a, e) {
  53080. var i = this._createHardwareRenderTargetWrapper(!1, !1, a)
  53081. , o = {};
  53082. e !== void 0 && typeof e == "object" ? (o.generateDepthBuffer = e.generateDepthBuffer === void 0 ? !0 : e.generateDepthBuffer,
  53083. o.generateStencilBuffer = o.generateDepthBuffer && e.generateStencilBuffer) : (o.generateDepthBuffer = !0,
  53084. o.generateStencilBuffer = !1);
  53085. var s = this._createInternalTexture(a, e, !0, InternalTextureSource.RenderTarget);
  53086. return i._generateDepthBuffer = o.generateDepthBuffer,
  53087. i._generateStencilBuffer = !!o.generateStencilBuffer,
  53088. i.setTextures(s),
  53089. (i._generateDepthBuffer || i._generateStencilBuffer) && i.createDepthStencilTexture(0, o.samplingMode === void 0 || o.samplingMode === 2 || o.samplingMode === 2 || o.samplingMode === 3 || o.samplingMode === 3 || o.samplingMode === 5 || o.samplingMode === 6 || o.samplingMode === 7 || o.samplingMode === 11, i._generateStencilBuffer, i.samples),
  53090. e !== void 0 && typeof e == "object" && e.createMipMaps && !o.generateMipMaps && (s.generateMipMaps = !0),
  53091. this._textureHelper.createGPUTextureForInternalTexture(s, void 0, void 0, void 0, o.creationFlags),
  53092. e !== void 0 && typeof e == "object" && e.createMipMaps && !o.generateMipMaps && (s.generateMipMaps = !1),
  53093. i
  53094. }
  53095. ;
  53096. WebGPUEngine.prototype._createDepthStencilTexture = function(a, e, i) {
  53097. var o = new InternalTexture(this,InternalTextureSource.DepthStencil)
  53098. , s = __assign({
  53099. bilinearFiltering: !1,
  53100. comparisonFunction: 0,
  53101. generateStencil: !1,
  53102. samples: 1,
  53103. depthTextureFormat: 15
  53104. }, e);
  53105. return o.format = s.generateStencil ? 13 : s.depthTextureFormat === 15 ? 14 : s.depthTextureFormat,
  53106. this._setupDepthStencilTexture(o, a, s.generateStencil, s.bilinearFiltering, s.comparisonFunction, s.samples),
  53107. this._textureHelper.createGPUTextureForInternalTexture(o),
  53108. this._internalTexturesCache.push(o),
  53109. o
  53110. }
  53111. ;
  53112. WebGPUEngine.prototype._setupDepthStencilTexture = function(a, e, i, o, s, c) {
  53113. c === void 0 && (c = 1);
  53114. var d = e.width || e
  53115. , _ = e.height || e
  53116. , b = e.layers || 0;
  53117. a.baseWidth = d,
  53118. a.baseHeight = _,
  53119. a.width = d,
  53120. a.height = _,
  53121. a.is2DArray = b > 0,
  53122. a.depth = b,
  53123. a.isReady = !0,
  53124. a.samples = c,
  53125. a.generateMipMaps = !1,
  53126. a.samplingMode = o ? 2 : 1,
  53127. a.type = 1,
  53128. a._comparisonFunction = s,
  53129. a._cachedWrapU = 0,
  53130. a._cachedWrapV = 0
  53131. }
  53132. ;
  53133. WebGPUEngine.prototype.updateRenderTargetTextureSampleCount = function(a, e) {
  53134. return !a || !a.texture || a.samples === e || (e = Math.min(e, this.getCaps().maxMSAASamples),
  53135. this._textureHelper.createMSAATexture(a.texture, e),
  53136. a._depthStencilTexture && (this._textureHelper.createMSAATexture(a._depthStencilTexture, e),
  53137. a._depthStencilTexture.samples = e),
  53138. a.texture.samples = e),
  53139. e
  53140. }
  53141. ;
  53142. WebGPUEngine.prototype.createRenderTargetCubeTexture = function(a, e) {
  53143. var i = this._createHardwareRenderTargetWrapper(!1, !0, a)
  53144. , o = __assign({
  53145. generateMipMaps: !0,
  53146. generateDepthBuffer: !0,
  53147. generateStencilBuffer: !1,
  53148. type: 0,
  53149. samplingMode: 3,
  53150. format: 5,
  53151. samples: 1
  53152. }, e);
  53153. o.generateStencilBuffer = o.generateDepthBuffer && o.generateStencilBuffer,
  53154. i._generateDepthBuffer = o.generateDepthBuffer,
  53155. i._generateStencilBuffer = o.generateStencilBuffer;
  53156. var s = new InternalTexture(this,InternalTextureSource.RenderTarget);
  53157. return s.width = a,
  53158. s.height = a,
  53159. s.depth = 0,
  53160. s.isReady = !0,
  53161. s.isCube = !0,
  53162. s.samples = o.samples,
  53163. s.generateMipMaps = o.generateMipMaps,
  53164. s.samplingMode = o.samplingMode,
  53165. s.type = o.type,
  53166. s.format = o.format,
  53167. this._internalTexturesCache.push(s),
  53168. i.setTextures(s),
  53169. (i._generateDepthBuffer || i._generateStencilBuffer) && i.createDepthStencilTexture(0, o.samplingMode === void 0 || o.samplingMode === 2 || o.samplingMode === 2 || o.samplingMode === 3 || o.samplingMode === 3 || o.samplingMode === 5 || o.samplingMode === 6 || o.samplingMode === 7 || o.samplingMode === 11, i._generateStencilBuffer, i.samples),
  53170. e && e.createMipMaps && !o.generateMipMaps && (s.generateMipMaps = !0),
  53171. this._textureHelper.createGPUTextureForInternalTexture(s),
  53172. e && e.createMipMaps && !o.generateMipMaps && (s.generateMipMaps = !1),
  53173. i
  53174. }
  53175. ;
  53176. Effect.prototype.setTextureSampler = function(a, e) {
  53177. this._engine.setTextureSampler(a, e)
  53178. }
  53179. ;
  53180. WebGPUEngine.prototype.setTextureSampler = function(a, e) {
  53181. var i;
  53182. (i = this._currentMaterialContext) === null || i === void 0 || i.setSampler(a, e)
  53183. }
  53184. ;
  53185. Effect.prototype.setStorageBuffer = function(a, e) {
  53186. this._engine.setStorageBuffer(a, e)
  53187. }
  53188. ;
  53189. WebGPUEngine.prototype.createStorageBuffer = function(a, e) {
  53190. return this._createBuffer(a, e | 32)
  53191. }
  53192. ;
  53193. WebGPUEngine.prototype.updateStorageBuffer = function(a, e, i, o) {
  53194. var s = a;
  53195. i === void 0 && (i = 0);
  53196. var c;
  53197. o === void 0 ? (e instanceof Array ? c = new Float32Array(e) : e instanceof ArrayBuffer ? c = new Uint8Array(e) : c = e,
  53198. o = c.byteLength) : e instanceof Array ? c = new Float32Array(e) : e instanceof ArrayBuffer ? c = new Uint8Array(e) : c = e,
  53199. this._bufferManager.setSubData(s, i, c, 0, o)
  53200. }
  53201. ;
  53202. WebGPUEngine.prototype.readFromStorageBuffer = function(a, e, i, o) {
  53203. var s = this;
  53204. i = i || a.capacity;
  53205. var c = this._bufferManager.createRawBuffer(i, BufferUsage.MapRead | BufferUsage.CopyDst);
  53206. return this._renderTargetEncoder.copyBufferToBuffer(a.underlyingResource, e != null ? e : 0, c, 0, i),
  53207. new Promise(function(d, _) {
  53208. s.onEndFrameObservable.addOnce(function() {
  53209. c.mapAsync(MapMode.Read, 0, i).then(function() {
  53210. var b = c.getMappedRange(0, i)
  53211. , k = o;
  53212. if (k === void 0)
  53213. k = new Uint8Array(i),
  53214. k.set(new Uint8Array(b));
  53215. else {
  53216. var j = k.constructor;
  53217. k = new j(k.buffer),
  53218. k.set(new j(b))
  53219. }
  53220. c.unmap(),
  53221. s._bufferManager.releaseBuffer(c),
  53222. d(k)
  53223. }, function(b) {
  53224. return _(b)
  53225. })
  53226. })
  53227. }
  53228. )
  53229. }
  53230. ;
  53231. WebGPUEngine.prototype.setStorageBuffer = function(a, e) {
  53232. var i, o;
  53233. (i = this._currentDrawContext) === null || i === void 0 || i.setBuffer(a, (o = e == null ? void 0 : e.getBuffer()) !== null && o !== void 0 ? o : null)
  53234. }
  53235. ;
  53236. WebGPUEngine.prototype.createUniformBuffer = function(a) {
  53237. var e;
  53238. a instanceof Array ? e = new Float32Array(a) : e = a;
  53239. var i = this._bufferManager.createBuffer(e, BufferUsage.Uniform | BufferUsage.CopyDst);
  53240. return i
  53241. }
  53242. ;
  53243. WebGPUEngine.prototype.createDynamicUniformBuffer = function(a) {
  53244. return this.createUniformBuffer(a)
  53245. }
  53246. ;
  53247. WebGPUEngine.prototype.updateUniformBuffer = function(a, e, i, o) {
  53248. i === void 0 && (i = 0);
  53249. var s = a, c;
  53250. o === void 0 ? (e instanceof Float32Array ? c = e : c = new Float32Array(e),
  53251. o = c.byteLength) : e instanceof Float32Array ? c = e : c = new Float32Array(e),
  53252. this._bufferManager.setSubData(s, i, c, 0, o)
  53253. }
  53254. ;
  53255. WebGPUEngine.prototype.bindUniformBufferBase = function(a, e, i) {
  53256. this._currentDrawContext.setBuffer(i, a)
  53257. }
  53258. ;
  53259. WebGPUEngine.prototype.bindUniformBlock = function(a, e, i) {}
  53260. ;
  53261. WebGPUEngine.prototype.updateVideoTexture = function(a, e, i) {
  53262. var o = this, s;
  53263. if (!(!a || a._isDisabled)) {
  53264. this._videoTextureSupported === void 0 && (this._videoTextureSupported = !0);
  53265. var c = a._hardwareTexture;
  53266. !((s = a._hardwareTexture) === null || s === void 0) && s.underlyingResource || (c = this._textureHelper.createGPUTextureForInternalTexture(a)),
  53267. this.createImageBitmap(e).then(function(d) {
  53268. o._textureHelper.updateTexture(d, a, a.width, a.height, a.depth, c.format, 0, 0, !i, !1, 0, 0, o._uploadEncoder),
  53269. a.generateMipMaps && o._generateMipmaps(a, o._uploadEncoder),
  53270. a.isReady = !0
  53271. }).catch(function(d) {
  53272. a.isReady = !0
  53273. })
  53274. }
  53275. }
  53276. ;
  53277. var SceneLoaderFlags = function() {
  53278. function a() {}
  53279. return Object.defineProperty(a, "ForceFullSceneLoadingForIncremental", {
  53280. get: function() {
  53281. return a._ForceFullSceneLoadingForIncremental
  53282. },
  53283. set: function(e) {
  53284. a._ForceFullSceneLoadingForIncremental = e
  53285. },
  53286. enumerable: !1,
  53287. configurable: !0
  53288. }),
  53289. Object.defineProperty(a, "ShowLoadingScreen", {
  53290. get: function() {
  53291. return a._ShowLoadingScreen
  53292. },
  53293. set: function(e) {
  53294. a._ShowLoadingScreen = e
  53295. },
  53296. enumerable: !1,
  53297. configurable: !0
  53298. }),
  53299. Object.defineProperty(a, "loggingLevel", {
  53300. get: function() {
  53301. return a._loggingLevel
  53302. },
  53303. set: function(e) {
  53304. a._loggingLevel = e
  53305. },
  53306. enumerable: !1,
  53307. configurable: !0
  53308. }),
  53309. Object.defineProperty(a, "CleanBoneMatrixWeights", {
  53310. get: function() {
  53311. return a._CleanBoneMatrixWeights
  53312. },
  53313. set: function(e) {
  53314. a._CleanBoneMatrixWeights = e
  53315. },
  53316. enumerable: !1,
  53317. configurable: !0
  53318. }),
  53319. a._ForceFullSceneLoadingForIncremental = !1,
  53320. a._ShowLoadingScreen = !0,
  53321. a._CleanBoneMatrixWeights = !1,
  53322. a._loggingLevel = 0,
  53323. a
  53324. }(), SceneLoaderAnimationGroupLoadingMode;
  53325. (function(a) {
  53326. a[a.Clean = 0] = "Clean",
  53327. a[a.Stop = 1] = "Stop",
  53328. a[a.Sync = 2] = "Sync",
  53329. a[a.NoSync = 3] = "NoSync"
  53330. }
  53331. )(SceneLoaderAnimationGroupLoadingMode || (SceneLoaderAnimationGroupLoadingMode = {}));
  53332. var SceneLoader = function() {
  53333. function a() {}
  53334. return Object.defineProperty(a, "ForceFullSceneLoadingForIncremental", {
  53335. get: function() {
  53336. return SceneLoaderFlags.ForceFullSceneLoadingForIncremental
  53337. },
  53338. set: function(e) {
  53339. SceneLoaderFlags.ForceFullSceneLoadingForIncremental = e
  53340. },
  53341. enumerable: !1,
  53342. configurable: !0
  53343. }),
  53344. Object.defineProperty(a, "ShowLoadingScreen", {
  53345. get: function() {
  53346. return SceneLoaderFlags.ShowLoadingScreen
  53347. },
  53348. set: function(e) {
  53349. SceneLoaderFlags.ShowLoadingScreen = e
  53350. },
  53351. enumerable: !1,
  53352. configurable: !0
  53353. }),
  53354. Object.defineProperty(a, "loggingLevel", {
  53355. get: function() {
  53356. return SceneLoaderFlags.loggingLevel
  53357. },
  53358. set: function(e) {
  53359. SceneLoaderFlags.loggingLevel = e
  53360. },
  53361. enumerable: !1,
  53362. configurable: !0
  53363. }),
  53364. Object.defineProperty(a, "CleanBoneMatrixWeights", {
  53365. get: function() {
  53366. return SceneLoaderFlags.CleanBoneMatrixWeights
  53367. },
  53368. set: function(e) {
  53369. SceneLoaderFlags.CleanBoneMatrixWeights = e
  53370. },
  53371. enumerable: !1,
  53372. configurable: !0
  53373. }),
  53374. a.GetDefaultPlugin = function() {
  53375. return a._registeredPlugins[".babylon"]
  53376. }
  53377. ,
  53378. a._GetPluginForExtension = function(e) {
  53379. var i = a._registeredPlugins[e];
  53380. return i || (Logger$2.Warn("Unable to find a plugin to load " + e + " files. Trying to use .babylon default plugin. To load from a specific filetype (eg. gltf) see: https://doc.babylonjs.com/how_to/load_from_any_file_type"),
  53381. a.GetDefaultPlugin())
  53382. }
  53383. ,
  53384. a._GetPluginForDirectLoad = function(e) {
  53385. for (var i in a._registeredPlugins) {
  53386. var o = a._registeredPlugins[i].plugin;
  53387. if (o.canDirectLoad && o.canDirectLoad(e))
  53388. return a._registeredPlugins[i]
  53389. }
  53390. return a.GetDefaultPlugin()
  53391. }
  53392. ,
  53393. a._GetPluginForFilename = function(e) {
  53394. var i = e.indexOf("?");
  53395. i !== -1 && (e = e.substring(0, i));
  53396. var o = e.lastIndexOf(".")
  53397. , s = e.substring(o, e.length).toLowerCase();
  53398. return a._GetPluginForExtension(s)
  53399. }
  53400. ,
  53401. a._GetDirectLoad = function(e) {
  53402. return e.substr(0, 5) === "data:" ? e.substr(5) : null
  53403. }
  53404. ,
  53405. a._FormatErrorMessage = function(e, i, o) {
  53406. var s = "Unable to load from " + e.url;
  53407. return i ? s += ": " + i : o && (s += ": " + o),
  53408. s
  53409. }
  53410. ,
  53411. a._LoadData = function(e, i, o, s, c, d, _) {
  53412. var b = a._GetDirectLoad(e.url), k = _ ? a._GetPluginForExtension(_) : b ? a._GetPluginForDirectLoad(e.url) : a._GetPluginForFilename(e.url), j;
  53413. if (k.plugin.createPlugin !== void 0 ? j = k.plugin.createPlugin() : j = k.plugin,
  53414. !j)
  53415. throw "The loader plugin corresponding to the file type you are trying to load has not been found. If using es6, please import the plugin you wish to use before.";
  53416. if (a.OnPluginActivatedObservable.notifyObservers(j),
  53417. b && (j.canDirectLoad && j.canDirectLoad(e.url) || !IsBase64DataUrl(e.url))) {
  53418. if (j.directLoad) {
  53419. var $ = j.directLoad(i, b);
  53420. $.then ? $.then(function(ft) {
  53421. o(j, ft)
  53422. }).catch(function(ft) {
  53423. c("Error in directLoad of _loadData: " + ft, ft)
  53424. }) : o(j, $)
  53425. } else
  53426. o(j, b);
  53427. return j
  53428. }
  53429. var _e = k.isBinary
  53430. , et = function(ft, ht) {
  53431. if (i.isDisposed) {
  53432. c("Scene has been disposed");
  53433. return
  53434. }
  53435. o(j, ft, ht)
  53436. }
  53437. , tt = null
  53438. , rt = !1
  53439. , it = j.onDisposeObservable;
  53440. it && it.add(function() {
  53441. rt = !0,
  53442. tt && (tt.abort(),
  53443. tt = null),
  53444. d()
  53445. });
  53446. var nt = function() {
  53447. if (!rt) {
  53448. var ft = function(pt, dt) {
  53449. c(pt == null ? void 0 : pt.statusText, dt)
  53450. }
  53451. , ht = e.file || e.url;
  53452. tt = j.loadFile ? j.loadFile(i, ht, et, s, _e, ft) : i._loadFile(ht, et, s, !0, _e, ft)
  53453. }
  53454. }
  53455. , ot = i.getEngine()
  53456. , at = ot.enableOfflineSupport;
  53457. if (at) {
  53458. for (var st = !1, ut = 0, ct = i.disableOfflineSupportExceptionRules; ut < ct.length; ut++) {
  53459. var lt = ct[ut];
  53460. if (lt.test(e.url)) {
  53461. st = !0;
  53462. break
  53463. }
  53464. }
  53465. at = !st
  53466. }
  53467. return at && Engine.OfflineProviderFactory ? i.offlineProvider = Engine.OfflineProviderFactory(e.url, nt, ot.disableManifestCheck) : nt(),
  53468. j
  53469. }
  53470. ,
  53471. a._GetFileInfo = function(e, i) {
  53472. var o, s, c = null;
  53473. if (!i)
  53474. o = e,
  53475. s = Tools.GetFilename(e),
  53476. e = Tools.GetFolderPath(e);
  53477. else if (i.name) {
  53478. var d = i;
  53479. o = "file:" + d.name,
  53480. s = d.name,
  53481. c = d
  53482. } else if (typeof i == "string" && StartsWith(i, "data:"))
  53483. o = i,
  53484. s = "";
  53485. else {
  53486. var _ = i;
  53487. if (_.substr(0, 1) === "/")
  53488. return Tools.Error("Wrong sceneFilename parameter"),
  53489. null;
  53490. o = e + _,
  53491. s = _
  53492. }
  53493. return {
  53494. url: o,
  53495. rootUrl: e,
  53496. name: s,
  53497. file: c
  53498. }
  53499. }
  53500. ,
  53501. a.GetPluginForExtension = function(e) {
  53502. return a._GetPluginForExtension(e).plugin
  53503. }
  53504. ,
  53505. a.IsPluginForExtensionAvailable = function(e) {
  53506. return !!a._registeredPlugins[e]
  53507. }
  53508. ,
  53509. a.RegisterPlugin = function(e) {
  53510. if (typeof e.extensions == "string") {
  53511. var i = e.extensions;
  53512. a._registeredPlugins[i.toLowerCase()] = {
  53513. plugin: e,
  53514. isBinary: !1
  53515. }
  53516. } else {
  53517. var o = e.extensions;
  53518. Object.keys(o).forEach(function(s) {
  53519. a._registeredPlugins[s.toLowerCase()] = {
  53520. plugin: e,
  53521. isBinary: o[s].isBinary
  53522. }
  53523. })
  53524. }
  53525. }
  53526. ,
  53527. a.ImportMesh = function(e, i, o, s, c, d, _, b) {
  53528. if (o === void 0 && (o = ""),
  53529. s === void 0 && (s = EngineStore.LastCreatedScene),
  53530. c === void 0 && (c = null),
  53531. d === void 0 && (d = null),
  53532. _ === void 0 && (_ = null),
  53533. b === void 0 && (b = null),
  53534. !s)
  53535. return Logger$2.Error("No scene available to import mesh to"),
  53536. null;
  53537. var k = a._GetFileInfo(i, o);
  53538. if (!k)
  53539. return null;
  53540. var j = {};
  53541. s._addPendingData(j);
  53542. var $ = function() {
  53543. s._removePendingData(j)
  53544. }
  53545. , _e = function(rt, it) {
  53546. var nt = a._FormatErrorMessage(k, rt, it);
  53547. _ ? _(s, nt, new Error(nt)) : Logger$2.Error(nt),
  53548. $()
  53549. }
  53550. , et = d ? function(rt) {
  53551. try {
  53552. d(rt)
  53553. } catch (it) {
  53554. _e("Error in onProgress callback: " + it, it)
  53555. }
  53556. }
  53557. : void 0
  53558. , tt = function(rt, it, nt, ot, at, st, ut) {
  53559. if (s.importedMeshesFiles.push(k.url),
  53560. c)
  53561. try {
  53562. c(rt, it, nt, ot, at, st, ut)
  53563. } catch (ct) {
  53564. _e("Error in onSuccess callback: " + ct, ct)
  53565. }
  53566. s._removePendingData(j)
  53567. };
  53568. return a._LoadData(k, s, function(rt, it, nt) {
  53569. if (rt.rewriteRootURL && (k.rootUrl = rt.rewriteRootURL(k.rootUrl, nt)),
  53570. rt.importMesh) {
  53571. var ot = rt
  53572. , at = new Array
  53573. , st = new Array
  53574. , ut = new Array;
  53575. if (!ot.importMesh(e, s, it, k.rootUrl, at, st, ut, _e))
  53576. return;
  53577. s.loadingPluginName = rt.name,
  53578. tt(at, st, ut, [], [], [], [])
  53579. } else {
  53580. var ct = rt;
  53581. ct.importMeshAsync(e, s, it, k.rootUrl, et, k.name).then(function(lt) {
  53582. s.loadingPluginName = rt.name,
  53583. tt(lt.meshes, lt.particleSystems, lt.skeletons, lt.animationGroups, lt.transformNodes, lt.geometries, lt.lights)
  53584. }).catch(function(lt) {
  53585. _e(lt.message, lt)
  53586. })
  53587. }
  53588. }, et, _e, $, b)
  53589. }
  53590. ,
  53591. a.ImportMeshAsync = function(e, i, o, s, c, d) {
  53592. return o === void 0 && (o = ""),
  53593. s === void 0 && (s = EngineStore.LastCreatedScene),
  53594. c === void 0 && (c = null),
  53595. d === void 0 && (d = null),
  53596. new Promise(function(_, b) {
  53597. a.ImportMesh(e, i, o, s, function(k, j, $, _e, et, tt, rt) {
  53598. _({
  53599. meshes: k,
  53600. particleSystems: j,
  53601. skeletons: $,
  53602. animationGroups: _e,
  53603. transformNodes: et,
  53604. geometries: tt,
  53605. lights: rt
  53606. })
  53607. }, c, function(k, j, $) {
  53608. b($ || new Error(j))
  53609. }, d)
  53610. }
  53611. )
  53612. }
  53613. ,
  53614. a.Load = function(e, i, o, s, c, d, _) {
  53615. return i === void 0 && (i = ""),
  53616. o === void 0 && (o = EngineStore.LastCreatedEngine),
  53617. s === void 0 && (s = null),
  53618. c === void 0 && (c = null),
  53619. d === void 0 && (d = null),
  53620. _ === void 0 && (_ = null),
  53621. o ? a.Append(e, i, new Scene(o), s, c, d, _) : (Tools.Error("No engine available"),
  53622. null)
  53623. }
  53624. ,
  53625. a.LoadAsync = function(e, i, o, s, c) {
  53626. return i === void 0 && (i = ""),
  53627. o === void 0 && (o = EngineStore.LastCreatedEngine),
  53628. s === void 0 && (s = null),
  53629. c === void 0 && (c = null),
  53630. new Promise(function(d, _) {
  53631. a.Load(e, i, o, function(b) {
  53632. d(b)
  53633. }, s, function(b, k, j) {
  53634. _(j || new Error(k))
  53635. }, c)
  53636. }
  53637. )
  53638. }
  53639. ,
  53640. a.Append = function(e, i, o, s, c, d, _) {
  53641. var b = this;
  53642. if (i === void 0 && (i = ""),
  53643. o === void 0 && (o = EngineStore.LastCreatedScene),
  53644. s === void 0 && (s = null),
  53645. c === void 0 && (c = null),
  53646. d === void 0 && (d = null),
  53647. _ === void 0 && (_ = null),
  53648. !o)
  53649. return Logger$2.Error("No scene available to append to"),
  53650. null;
  53651. var k = a._GetFileInfo(e, i);
  53652. if (!k)
  53653. return null;
  53654. a.ShowLoadingScreen && !this._showingLoadingScreen && (this._showingLoadingScreen = !0,
  53655. o.getEngine().displayLoadingUI(),
  53656. o.executeWhenReady(function() {
  53657. o.getEngine().hideLoadingUI(),
  53658. b._showingLoadingScreen = !1
  53659. }));
  53660. var j = {};
  53661. o._addPendingData(j);
  53662. var $ = function() {
  53663. o._removePendingData(j)
  53664. }
  53665. , _e = function(rt, it) {
  53666. var nt = a._FormatErrorMessage(k, rt, it);
  53667. d ? d(o, nt, new Error(nt)) : Logger$2.Error(nt),
  53668. $()
  53669. }
  53670. , et = c ? function(rt) {
  53671. try {
  53672. c(rt)
  53673. } catch (it) {
  53674. _e("Error in onProgress callback", it)
  53675. }
  53676. }
  53677. : void 0
  53678. , tt = function() {
  53679. if (s)
  53680. try {
  53681. s(o)
  53682. } catch (rt) {
  53683. _e("Error in onSuccess callback", rt)
  53684. }
  53685. o._removePendingData(j)
  53686. };
  53687. return a._LoadData(k, o, function(rt, it) {
  53688. if (rt.load) {
  53689. var nt = rt;
  53690. if (!nt.load(o, it, k.rootUrl, _e))
  53691. return;
  53692. o.loadingPluginName = rt.name,
  53693. tt()
  53694. } else {
  53695. var ot = rt;
  53696. ot.loadAsync(o, it, k.rootUrl, et, k.name).then(function() {
  53697. o.loadingPluginName = rt.name,
  53698. tt()
  53699. }).catch(function(at) {
  53700. _e(at.message, at)
  53701. })
  53702. }
  53703. }, et, _e, $, _)
  53704. }
  53705. ,
  53706. a.AppendAsync = function(e, i, o, s, c) {
  53707. return i === void 0 && (i = ""),
  53708. o === void 0 && (o = EngineStore.LastCreatedScene),
  53709. s === void 0 && (s = null),
  53710. c === void 0 && (c = null),
  53711. new Promise(function(d, _) {
  53712. a.Append(e, i, o, function(b) {
  53713. d(b)
  53714. }, s, function(b, k, j) {
  53715. _(j || new Error(k))
  53716. }, c)
  53717. }
  53718. )
  53719. }
  53720. ,
  53721. a.LoadAssetContainer = function(e, i, o, s, c, d, _) {
  53722. if (i === void 0 && (i = ""),
  53723. o === void 0 && (o = EngineStore.LastCreatedScene),
  53724. s === void 0 && (s = null),
  53725. c === void 0 && (c = null),
  53726. d === void 0 && (d = null),
  53727. _ === void 0 && (_ = null),
  53728. !o)
  53729. return Logger$2.Error("No scene available to load asset container to"),
  53730. null;
  53731. var b = a._GetFileInfo(e, i);
  53732. if (!b)
  53733. return null;
  53734. var k = {};
  53735. o._addPendingData(k);
  53736. var j = function() {
  53737. o._removePendingData(k)
  53738. }
  53739. , $ = function(tt, rt) {
  53740. var it = a._FormatErrorMessage(b, tt, rt);
  53741. d ? d(o, it, new Error(it)) : Logger$2.Error(it),
  53742. j()
  53743. }
  53744. , _e = c ? function(tt) {
  53745. try {
  53746. c(tt)
  53747. } catch (rt) {
  53748. $("Error in onProgress callback", rt)
  53749. }
  53750. }
  53751. : void 0
  53752. , et = function(tt) {
  53753. if (s)
  53754. try {
  53755. s(tt)
  53756. } catch (rt) {
  53757. $("Error in onSuccess callback", rt)
  53758. }
  53759. o._removePendingData(k)
  53760. };
  53761. return a._LoadData(b, o, function(tt, rt) {
  53762. if (tt.loadAssetContainer) {
  53763. var it = tt
  53764. , nt = it.loadAssetContainer(o, rt, b.rootUrl, $);
  53765. if (!nt)
  53766. return;
  53767. o.loadingPluginName = tt.name,
  53768. et(nt)
  53769. } else if (tt.loadAssetContainerAsync) {
  53770. var ot = tt;
  53771. ot.loadAssetContainerAsync(o, rt, b.rootUrl, _e, b.name).then(function(at) {
  53772. o.loadingPluginName = tt.name,
  53773. et(at)
  53774. }).catch(function(at) {
  53775. $(at.message, at)
  53776. })
  53777. } else
  53778. $("LoadAssetContainer is not supported by this plugin. Plugin did not provide a loadAssetContainer or loadAssetContainerAsync method.")
  53779. }, _e, $, j, _)
  53780. }
  53781. ,
  53782. a.LoadAssetContainerAsync = function(e, i, o, s, c) {
  53783. return i === void 0 && (i = ""),
  53784. o === void 0 && (o = EngineStore.LastCreatedScene),
  53785. s === void 0 && (s = null),
  53786. c === void 0 && (c = null),
  53787. new Promise(function(d, _) {
  53788. a.LoadAssetContainer(e, i, o, function(b) {
  53789. d(b)
  53790. }, s, function(b, k, j) {
  53791. _(j || new Error(k))
  53792. }, c)
  53793. }
  53794. )
  53795. }
  53796. ,
  53797. a.ImportAnimations = function(e, i, o, s, c, d, _, b, k, j) {
  53798. if (i === void 0 && (i = ""),
  53799. o === void 0 && (o = EngineStore.LastCreatedScene),
  53800. s === void 0 && (s = !0),
  53801. c === void 0 && (c = SceneLoaderAnimationGroupLoadingMode.Clean),
  53802. d === void 0 && (d = null),
  53803. _ === void 0 && (_ = null),
  53804. b === void 0 && (b = null),
  53805. k === void 0 && (k = null),
  53806. j === void 0 && (j = null),
  53807. !o) {
  53808. Logger$2.Error("No scene available to load animations to");
  53809. return
  53810. }
  53811. if (s) {
  53812. for (var $ = 0, _e = o.animatables; $ < _e.length; $++) {
  53813. var et = _e[$];
  53814. et.reset()
  53815. }
  53816. o.stopAllAnimations(),
  53817. o.animationGroups.slice().forEach(function(nt) {
  53818. nt.dispose()
  53819. });
  53820. var tt = o.getNodes();
  53821. tt.forEach(function(nt) {
  53822. nt.animations && (nt.animations = [])
  53823. })
  53824. } else
  53825. switch (c) {
  53826. case SceneLoaderAnimationGroupLoadingMode.Clean:
  53827. o.animationGroups.slice().forEach(function(nt) {
  53828. nt.dispose()
  53829. });
  53830. break;
  53831. case SceneLoaderAnimationGroupLoadingMode.Stop:
  53832. o.animationGroups.forEach(function(nt) {
  53833. nt.stop()
  53834. });
  53835. break;
  53836. case SceneLoaderAnimationGroupLoadingMode.Sync:
  53837. o.animationGroups.forEach(function(nt) {
  53838. nt.reset(),
  53839. nt.restart()
  53840. });
  53841. break;
  53842. case SceneLoaderAnimationGroupLoadingMode.NoSync:
  53843. break;
  53844. default:
  53845. Logger$2.Error("Unknown animation group loading mode value '" + c + "'");
  53846. return
  53847. }
  53848. var rt = o.animatables.length
  53849. , it = function(nt) {
  53850. nt.mergeAnimationsTo(o, o.animatables.slice(rt), d),
  53851. nt.dispose(),
  53852. o.onAnimationFileImportedObservable.notifyObservers(o),
  53853. _ && _(o)
  53854. };
  53855. this.LoadAssetContainer(e, i, o, it, b, k, j)
  53856. }
  53857. ,
  53858. a.ImportAnimationsAsync = function(e, i, o, s, c, d, _, b, k, j) {
  53859. return i === void 0 && (i = ""),
  53860. o === void 0 && (o = EngineStore.LastCreatedScene),
  53861. s === void 0 && (s = !0),
  53862. c === void 0 && (c = SceneLoaderAnimationGroupLoadingMode.Clean),
  53863. d === void 0 && (d = null),
  53864. b === void 0 && (b = null),
  53865. j === void 0 && (j = null),
  53866. new Promise(function($, _e) {
  53867. a.ImportAnimations(e, i, o, s, c, d, function(et) {
  53868. $(et)
  53869. }, b, function(et, tt, rt) {
  53870. _e(rt || new Error(tt))
  53871. }, j)
  53872. }
  53873. )
  53874. }
  53875. ,
  53876. a.NO_LOGGING = 0,
  53877. a.MINIMAL_LOGGING = 1,
  53878. a.SUMMARY_LOGGING = 2,
  53879. a.DETAILED_LOGGING = 3,
  53880. a.OnPluginActivatedObservable = new Observable,
  53881. a._registeredPlugins = {},
  53882. a._showingLoadingScreen = !1,
  53883. a
  53884. }(), AnimationKeyInterpolation;
  53885. (function(a) {
  53886. a[a.NONE = 0] = "NONE",
  53887. a[a.STEP = 1] = "STEP"
  53888. }
  53889. )(AnimationKeyInterpolation || (AnimationKeyInterpolation = {}));
  53890. var AnimationRange = function() {
  53891. function a(e, i, o) {
  53892. this.name = e,
  53893. this.from = i,
  53894. this.to = o
  53895. }
  53896. return a.prototype.clone = function() {
  53897. return new a(this.name,this.from,this.to)
  53898. }
  53899. ,
  53900. a
  53901. }()
  53902. , Animation = function() {
  53903. function a(e, i, o, s, c, d) {
  53904. this.name = e,
  53905. this.targetProperty = i,
  53906. this.framePerSecond = o,
  53907. this.dataType = s,
  53908. this.loopMode = c,
  53909. this.enableBlending = d,
  53910. this._runtimeAnimations = new Array,
  53911. this._events = new Array,
  53912. this.blendingSpeed = .01,
  53913. this._ranges = {},
  53914. this.targetPropertyPath = i.split("."),
  53915. this.dataType = s,
  53916. this.loopMode = c === void 0 ? a.ANIMATIONLOOPMODE_CYCLE : c,
  53917. this.uniqueId = a._UniqueIdGenerator++
  53918. }
  53919. return a._PrepareAnimation = function(e, i, o, s, c, d, _, b) {
  53920. var k = void 0;
  53921. if (!isNaN(parseFloat(c)) && isFinite(c) ? k = a.ANIMATIONTYPE_FLOAT : c instanceof Quaternion ? k = a.ANIMATIONTYPE_QUATERNION : c instanceof Vector3 ? k = a.ANIMATIONTYPE_VECTOR3 : c instanceof Vector2 ? k = a.ANIMATIONTYPE_VECTOR2 : c instanceof Color3 ? k = a.ANIMATIONTYPE_COLOR3 : c instanceof Color4 ? k = a.ANIMATIONTYPE_COLOR4 : c instanceof Size && (k = a.ANIMATIONTYPE_SIZE),
  53922. k == null)
  53923. return null;
  53924. var j = new a(e,i,o,k,_)
  53925. , $ = [{
  53926. frame: 0,
  53927. value: c
  53928. }, {
  53929. frame: s,
  53930. value: d
  53931. }];
  53932. return j.setKeys($),
  53933. b !== void 0 && j.setEasingFunction(b),
  53934. j
  53935. }
  53936. ,
  53937. a.CreateAnimation = function(e, i, o, s) {
  53938. var c = new a(e + "Animation",e,o,i,a.ANIMATIONLOOPMODE_CONSTANT);
  53939. return c.setEasingFunction(s),
  53940. c
  53941. }
  53942. ,
  53943. a.CreateAndStartAnimation = function(e, i, o, s, c, d, _, b, k, j, $) {
  53944. var _e = a._PrepareAnimation(e, o, s, c, d, _, b, k);
  53945. return !_e || (i.getScene && ($ = i.getScene()),
  53946. !$) ? null : $.beginDirectAnimation(i, [_e], 0, c, _e.loopMode === 1, 1, j)
  53947. }
  53948. ,
  53949. a.CreateAndStartHierarchyAnimation = function(e, i, o, s, c, d, _, b, k, j, $) {
  53950. var _e = a._PrepareAnimation(e, s, c, d, _, b, k, j);
  53951. if (!_e)
  53952. return null;
  53953. var et = i.getScene();
  53954. return et.beginDirectHierarchyAnimation(i, o, [_e], 0, d, _e.loopMode === 1, 1, $)
  53955. }
  53956. ,
  53957. a.CreateMergeAndStartAnimation = function(e, i, o, s, c, d, _, b, k, j) {
  53958. var $ = a._PrepareAnimation(e, o, s, c, d, _, b, k);
  53959. return $ ? (i.animations.push($),
  53960. i.getScene().beginAnimation(i, 0, c, $.loopMode === 1, 1, j)) : null
  53961. }
  53962. ,
  53963. a.MakeAnimationAdditive = function(e, i, o, s, c) {
  53964. i === void 0 && (i = 0),
  53965. s === void 0 && (s = !1);
  53966. var d = e;
  53967. if (s && (d = e.clone(),
  53968. d.name = c || d.name),
  53969. !d._keys.length)
  53970. return d;
  53971. i = i >= 0 ? i : 0;
  53972. var _ = 0
  53973. , b = d._keys[0]
  53974. , k = d._keys.length - 1
  53975. , j = d._keys[k]
  53976. , $ = {
  53977. referenceValue: b.value,
  53978. referencePosition: TmpVectors.Vector3[0],
  53979. referenceQuaternion: TmpVectors.Quaternion[0],
  53980. referenceScaling: TmpVectors.Vector3[1],
  53981. keyPosition: TmpVectors.Vector3[2],
  53982. keyQuaternion: TmpVectors.Quaternion[1],
  53983. keyScaling: TmpVectors.Vector3[3]
  53984. }
  53985. , _e = !1
  53986. , et = b.frame
  53987. , tt = j.frame;
  53988. if (o) {
  53989. var rt = d.getRange(o);
  53990. rt && (et = rt.from,
  53991. tt = rt.to)
  53992. }
  53993. var it = b.frame === et
  53994. , nt = j.frame === tt;
  53995. if (d._keys.length === 1) {
  53996. var ot = d._getKeyValue(d._keys[0]);
  53997. $.referenceValue = ot.clone ? ot.clone() : ot,
  53998. _e = !0
  53999. } else if (i <= b.frame) {
  54000. var ot = d._getKeyValue(b.value);
  54001. $.referenceValue = ot.clone ? ot.clone() : ot,
  54002. _e = !0
  54003. } else if (i >= j.frame) {
  54004. var ot = d._getKeyValue(j.value);
  54005. $.referenceValue = ot.clone ? ot.clone() : ot,
  54006. _e = !0
  54007. }
  54008. for (var at = 0; !_e || !it || !nt && at < d._keys.length - 1; ) {
  54009. var st = d._keys[at]
  54010. , ut = d._keys[at + 1];
  54011. if (!_e && i >= st.frame && i <= ut.frame) {
  54012. var ot = void 0;
  54013. if (i === st.frame)
  54014. ot = d._getKeyValue(st.value);
  54015. else if (i === ut.frame)
  54016. ot = d._getKeyValue(ut.value);
  54017. else {
  54018. var ct = {
  54019. key: at,
  54020. repeatCount: 0,
  54021. loopMode: this.ANIMATIONLOOPMODE_CONSTANT
  54022. };
  54023. ot = d._interpolate(i, ct)
  54024. }
  54025. $.referenceValue = ot.clone ? ot.clone() : ot,
  54026. _e = !0
  54027. }
  54028. if (!it && et >= st.frame && et <= ut.frame) {
  54029. if (et === st.frame)
  54030. _ = at;
  54031. else if (et === ut.frame)
  54032. _ = at + 1;
  54033. else {
  54034. var ct = {
  54035. key: at,
  54036. repeatCount: 0,
  54037. loopMode: this.ANIMATIONLOOPMODE_CONSTANT
  54038. }
  54039. , ot = d._interpolate(et, ct)
  54040. , lt = {
  54041. frame: et,
  54042. value: ot.clone ? ot.clone() : ot
  54043. };
  54044. d._keys.splice(at + 1, 0, lt),
  54045. _ = at + 1
  54046. }
  54047. it = !0
  54048. }
  54049. if (!nt && tt >= st.frame && tt <= ut.frame) {
  54050. if (tt === st.frame)
  54051. k = at;
  54052. else if (tt === ut.frame)
  54053. k = at + 1;
  54054. else {
  54055. var ct = {
  54056. key: at,
  54057. repeatCount: 0,
  54058. loopMode: this.ANIMATIONLOOPMODE_CONSTANT
  54059. }
  54060. , ot = d._interpolate(tt, ct)
  54061. , lt = {
  54062. frame: tt,
  54063. value: ot.clone ? ot.clone() : ot
  54064. };
  54065. d._keys.splice(at + 1, 0, lt),
  54066. k = at + 1
  54067. }
  54068. nt = !0
  54069. }
  54070. at++
  54071. }
  54072. d.dataType === a.ANIMATIONTYPE_QUATERNION ? $.referenceValue.normalize().conjugateInPlace() : d.dataType === a.ANIMATIONTYPE_MATRIX && ($.referenceValue.decompose($.referenceScaling, $.referenceQuaternion, $.referencePosition),
  54073. $.referenceQuaternion.normalize().conjugateInPlace());
  54074. for (var at = _; at <= k; at++) {
  54075. var lt = d._keys[at];
  54076. if (!(at && d.dataType !== a.ANIMATIONTYPE_FLOAT && lt.value === b.value))
  54077. switch (d.dataType) {
  54078. case a.ANIMATIONTYPE_MATRIX:
  54079. lt.value.decompose($.keyScaling, $.keyQuaternion, $.keyPosition),
  54080. $.keyPosition.subtractInPlace($.referencePosition),
  54081. $.keyScaling.divideInPlace($.referenceScaling),
  54082. $.referenceQuaternion.multiplyToRef($.keyQuaternion, $.keyQuaternion),
  54083. Matrix.ComposeToRef($.keyScaling, $.keyQuaternion, $.keyPosition, lt.value);
  54084. break;
  54085. case a.ANIMATIONTYPE_QUATERNION:
  54086. $.referenceValue.multiplyToRef(lt.value, lt.value);
  54087. break;
  54088. case a.ANIMATIONTYPE_VECTOR2:
  54089. case a.ANIMATIONTYPE_VECTOR3:
  54090. case a.ANIMATIONTYPE_COLOR3:
  54091. case a.ANIMATIONTYPE_COLOR4:
  54092. lt.value.subtractToRef($.referenceValue, lt.value);
  54093. break;
  54094. case a.ANIMATIONTYPE_SIZE:
  54095. lt.value.width -= $.referenceValue.width,
  54096. lt.value.height -= $.referenceValue.height;
  54097. break;
  54098. default:
  54099. lt.value -= $.referenceValue
  54100. }
  54101. }
  54102. return d
  54103. }
  54104. ,
  54105. a.TransitionTo = function(e, i, o, s, c, d, _, b) {
  54106. if (b === void 0 && (b = null),
  54107. _ <= 0)
  54108. return o[e] = i,
  54109. b && b(),
  54110. null;
  54111. var k = c * (_ / 1e3);
  54112. d.setKeys([{
  54113. frame: 0,
  54114. value: o[e].clone ? o[e].clone() : o[e]
  54115. }, {
  54116. frame: k,
  54117. value: i
  54118. }]),
  54119. o.animations || (o.animations = []),
  54120. o.animations.push(d);
  54121. var j = s.beginAnimation(o, 0, k, !1);
  54122. return j.onAnimationEnd = b,
  54123. j
  54124. }
  54125. ,
  54126. Object.defineProperty(a.prototype, "runtimeAnimations", {
  54127. get: function() {
  54128. return this._runtimeAnimations
  54129. },
  54130. enumerable: !1,
  54131. configurable: !0
  54132. }),
  54133. Object.defineProperty(a.prototype, "hasRunningRuntimeAnimations", {
  54134. get: function() {
  54135. for (var e = 0, i = this._runtimeAnimations; e < i.length; e++) {
  54136. var o = i[e];
  54137. if (!o.isStopped())
  54138. return !0
  54139. }
  54140. return !1
  54141. },
  54142. enumerable: !1,
  54143. configurable: !0
  54144. }),
  54145. a.prototype.toString = function(e) {
  54146. var i = "Name: " + this.name + ", property: " + this.targetProperty;
  54147. if (i += ", datatype: " + ["Float", "Vector3", "Quaternion", "Matrix", "Color3", "Vector2"][this.dataType],
  54148. i += ", nKeys: " + (this._keys ? this._keys.length : "none"),
  54149. i += ", nRanges: " + (this._ranges ? Object.keys(this._ranges).length : "none"),
  54150. e) {
  54151. i += ", Ranges: {";
  54152. var o = !0;
  54153. for (var s in this._ranges)
  54154. o && (i += ", ",
  54155. o = !1),
  54156. i += s;
  54157. i += "}"
  54158. }
  54159. return i
  54160. }
  54161. ,
  54162. a.prototype.addEvent = function(e) {
  54163. this._events.push(e),
  54164. this._events.sort(function(i, o) {
  54165. return i.frame - o.frame
  54166. })
  54167. }
  54168. ,
  54169. a.prototype.removeEvents = function(e) {
  54170. for (var i = 0; i < this._events.length; i++)
  54171. this._events[i].frame === e && (this._events.splice(i, 1),
  54172. i--)
  54173. }
  54174. ,
  54175. a.prototype.getEvents = function() {
  54176. return this._events
  54177. }
  54178. ,
  54179. a.prototype.createRange = function(e, i, o) {
  54180. this._ranges[e] || (this._ranges[e] = new AnimationRange(e,i,o))
  54181. }
  54182. ,
  54183. a.prototype.deleteRange = function(e, i) {
  54184. i === void 0 && (i = !0);
  54185. var o = this._ranges[e];
  54186. if (!!o) {
  54187. if (i)
  54188. for (var s = o.from, c = o.to, d = this._keys.length - 1; d >= 0; d--)
  54189. this._keys[d].frame >= s && this._keys[d].frame <= c && this._keys.splice(d, 1);
  54190. this._ranges[e] = null
  54191. }
  54192. }
  54193. ,
  54194. a.prototype.getRange = function(e) {
  54195. return this._ranges[e]
  54196. }
  54197. ,
  54198. a.prototype.getKeys = function() {
  54199. return this._keys
  54200. }
  54201. ,
  54202. a.prototype.getHighestFrame = function() {
  54203. for (var e = 0, i = 0, o = this._keys.length; i < o; i++)
  54204. e < this._keys[i].frame && (e = this._keys[i].frame);
  54205. return e
  54206. }
  54207. ,
  54208. a.prototype.getEasingFunction = function() {
  54209. return this._easingFunction
  54210. }
  54211. ,
  54212. a.prototype.setEasingFunction = function(e) {
  54213. this._easingFunction = e
  54214. }
  54215. ,
  54216. a.prototype.floatInterpolateFunction = function(e, i, o) {
  54217. return Scalar.Lerp(e, i, o)
  54218. }
  54219. ,
  54220. a.prototype.floatInterpolateFunctionWithTangents = function(e, i, o, s, c) {
  54221. return Scalar.Hermite(e, i, o, s, c)
  54222. }
  54223. ,
  54224. a.prototype.quaternionInterpolateFunction = function(e, i, o) {
  54225. return Quaternion.Slerp(e, i, o)
  54226. }
  54227. ,
  54228. a.prototype.quaternionInterpolateFunctionWithTangents = function(e, i, o, s, c) {
  54229. return Quaternion.Hermite(e, i, o, s, c).normalize()
  54230. }
  54231. ,
  54232. a.prototype.vector3InterpolateFunction = function(e, i, o) {
  54233. return Vector3.Lerp(e, i, o)
  54234. }
  54235. ,
  54236. a.prototype.vector3InterpolateFunctionWithTangents = function(e, i, o, s, c) {
  54237. return Vector3.Hermite(e, i, o, s, c)
  54238. }
  54239. ,
  54240. a.prototype.vector2InterpolateFunction = function(e, i, o) {
  54241. return Vector2.Lerp(e, i, o)
  54242. }
  54243. ,
  54244. a.prototype.vector2InterpolateFunctionWithTangents = function(e, i, o, s, c) {
  54245. return Vector2.Hermite(e, i, o, s, c)
  54246. }
  54247. ,
  54248. a.prototype.sizeInterpolateFunction = function(e, i, o) {
  54249. return Size.Lerp(e, i, o)
  54250. }
  54251. ,
  54252. a.prototype.color3InterpolateFunction = function(e, i, o) {
  54253. return Color3.Lerp(e, i, o)
  54254. }
  54255. ,
  54256. a.prototype.color3InterpolateFunctionWithTangents = function(e, i, o, s, c) {
  54257. return Color3.Hermite(e, i, o, s, c)
  54258. }
  54259. ,
  54260. a.prototype.color4InterpolateFunction = function(e, i, o) {
  54261. return Color4.Lerp(e, i, o)
  54262. }
  54263. ,
  54264. a.prototype.color4InterpolateFunctionWithTangents = function(e, i, o, s, c) {
  54265. return Color4.Hermite(e, i, o, s, c)
  54266. }
  54267. ,
  54268. a.prototype._getKeyValue = function(e) {
  54269. return typeof e == "function" ? e() : e
  54270. }
  54271. ,
  54272. a.prototype.evaluate = function(e) {
  54273. return this._interpolate(e, {
  54274. key: 0,
  54275. repeatCount: 0,
  54276. loopMode: a.ANIMATIONLOOPMODE_CONSTANT
  54277. })
  54278. }
  54279. ,
  54280. a.prototype._interpolate = function(e, i) {
  54281. if (i.loopMode === a.ANIMATIONLOOPMODE_CONSTANT && i.repeatCount > 0)
  54282. return i.highLimitValue.clone ? i.highLimitValue.clone() : i.highLimitValue;
  54283. var o = this._keys;
  54284. if (o.length === 1)
  54285. return this._getKeyValue(o[0].value);
  54286. var s = i.key;
  54287. if (o[s].frame >= e)
  54288. for (; s - 1 >= 0 && o[s].frame >= e; )
  54289. s--;
  54290. for (var c = s; c < o.length - 1; c++) {
  54291. var d = o[c + 1];
  54292. if (d.frame >= e) {
  54293. i.key = c;
  54294. var _ = o[c]
  54295. , b = this._getKeyValue(_.value)
  54296. , k = this._getKeyValue(d.value);
  54297. if (_.interpolation === AnimationKeyInterpolation.STEP)
  54298. return d.frame > e ? b : k;
  54299. var j = _.outTangent !== void 0 && d.inTangent !== void 0
  54300. , $ = d.frame - _.frame
  54301. , _e = (e - _.frame) / $
  54302. , et = this.getEasingFunction();
  54303. switch (et != null && (_e = et.ease(_e)),
  54304. this.dataType) {
  54305. case a.ANIMATIONTYPE_FLOAT:
  54306. var tt = j ? this.floatInterpolateFunctionWithTangents(b, _.outTangent * $, k, d.inTangent * $, _e) : this.floatInterpolateFunction(b, k, _e);
  54307. switch (i.loopMode) {
  54308. case a.ANIMATIONLOOPMODE_CYCLE:
  54309. case a.ANIMATIONLOOPMODE_CONSTANT:
  54310. return tt;
  54311. case a.ANIMATIONLOOPMODE_RELATIVE:
  54312. return i.offsetValue * i.repeatCount + tt
  54313. }
  54314. break;
  54315. case a.ANIMATIONTYPE_QUATERNION:
  54316. var rt = j ? this.quaternionInterpolateFunctionWithTangents(b, _.outTangent.scale($), k, d.inTangent.scale($), _e) : this.quaternionInterpolateFunction(b, k, _e);
  54317. switch (i.loopMode) {
  54318. case a.ANIMATIONLOOPMODE_CYCLE:
  54319. case a.ANIMATIONLOOPMODE_CONSTANT:
  54320. return rt;
  54321. case a.ANIMATIONLOOPMODE_RELATIVE:
  54322. return rt.addInPlace(i.offsetValue.scale(i.repeatCount))
  54323. }
  54324. return rt;
  54325. case a.ANIMATIONTYPE_VECTOR3:
  54326. var it = j ? this.vector3InterpolateFunctionWithTangents(b, _.outTangent.scale($), k, d.inTangent.scale($), _e) : this.vector3InterpolateFunction(b, k, _e);
  54327. switch (i.loopMode) {
  54328. case a.ANIMATIONLOOPMODE_CYCLE:
  54329. case a.ANIMATIONLOOPMODE_CONSTANT:
  54330. return it;
  54331. case a.ANIMATIONLOOPMODE_RELATIVE:
  54332. return it.add(i.offsetValue.scale(i.repeatCount))
  54333. }
  54334. case a.ANIMATIONTYPE_VECTOR2:
  54335. var nt = j ? this.vector2InterpolateFunctionWithTangents(b, _.outTangent.scale($), k, d.inTangent.scale($), _e) : this.vector2InterpolateFunction(b, k, _e);
  54336. switch (i.loopMode) {
  54337. case a.ANIMATIONLOOPMODE_CYCLE:
  54338. case a.ANIMATIONLOOPMODE_CONSTANT:
  54339. return nt;
  54340. case a.ANIMATIONLOOPMODE_RELATIVE:
  54341. return nt.add(i.offsetValue.scale(i.repeatCount))
  54342. }
  54343. case a.ANIMATIONTYPE_SIZE:
  54344. switch (i.loopMode) {
  54345. case a.ANIMATIONLOOPMODE_CYCLE:
  54346. case a.ANIMATIONLOOPMODE_CONSTANT:
  54347. return this.sizeInterpolateFunction(b, k, _e);
  54348. case a.ANIMATIONLOOPMODE_RELATIVE:
  54349. return this.sizeInterpolateFunction(b, k, _e).add(i.offsetValue.scale(i.repeatCount))
  54350. }
  54351. case a.ANIMATIONTYPE_COLOR3:
  54352. var ot = j ? this.color3InterpolateFunctionWithTangents(b, _.outTangent.scale($), k, d.inTangent.scale($), _e) : this.color3InterpolateFunction(b, k, _e);
  54353. switch (i.loopMode) {
  54354. case a.ANIMATIONLOOPMODE_CYCLE:
  54355. case a.ANIMATIONLOOPMODE_CONSTANT:
  54356. return ot;
  54357. case a.ANIMATIONLOOPMODE_RELATIVE:
  54358. return ot.add(i.offsetValue.scale(i.repeatCount))
  54359. }
  54360. case a.ANIMATIONTYPE_COLOR4:
  54361. var at = j ? this.color4InterpolateFunctionWithTangents(b, _.outTangent.scale($), k, d.inTangent.scale($), _e) : this.color4InterpolateFunction(b, k, _e);
  54362. switch (i.loopMode) {
  54363. case a.ANIMATIONLOOPMODE_CYCLE:
  54364. case a.ANIMATIONLOOPMODE_CONSTANT:
  54365. return at;
  54366. case a.ANIMATIONLOOPMODE_RELATIVE:
  54367. return at.add(i.offsetValue.scale(i.repeatCount))
  54368. }
  54369. case a.ANIMATIONTYPE_MATRIX:
  54370. switch (i.loopMode) {
  54371. case a.ANIMATIONLOOPMODE_CYCLE:
  54372. case a.ANIMATIONLOOPMODE_CONSTANT:
  54373. if (a.AllowMatricesInterpolation)
  54374. return this.matrixInterpolateFunction(b, k, _e, i.workValue);
  54375. case a.ANIMATIONLOOPMODE_RELATIVE:
  54376. return b
  54377. }
  54378. }
  54379. break
  54380. }
  54381. }
  54382. return this._getKeyValue(o[o.length - 1].value)
  54383. }
  54384. ,
  54385. a.prototype.matrixInterpolateFunction = function(e, i, o, s) {
  54386. return a.AllowMatrixDecomposeForInterpolation ? s ? (Matrix.DecomposeLerpToRef(e, i, o, s),
  54387. s) : Matrix.DecomposeLerp(e, i, o) : s ? (Matrix.LerpToRef(e, i, o, s),
  54388. s) : Matrix.Lerp(e, i, o)
  54389. }
  54390. ,
  54391. a.prototype.clone = function() {
  54392. var e = new a(this.name,this.targetPropertyPath.join("."),this.framePerSecond,this.dataType,this.loopMode);
  54393. if (e.enableBlending = this.enableBlending,
  54394. e.blendingSpeed = this.blendingSpeed,
  54395. this._keys && e.setKeys(this._keys),
  54396. this._ranges) {
  54397. e._ranges = {};
  54398. for (var i in this._ranges) {
  54399. var o = this._ranges[i];
  54400. !o || (e._ranges[i] = o.clone())
  54401. }
  54402. }
  54403. return e
  54404. }
  54405. ,
  54406. a.prototype.setKeys = function(e) {
  54407. this._keys = e.slice(0)
  54408. }
  54409. ,
  54410. a.prototype.serialize = function() {
  54411. var e = {};
  54412. e.name = this.name,
  54413. e.property = this.targetProperty,
  54414. e.framePerSecond = this.framePerSecond,
  54415. e.dataType = this.dataType,
  54416. e.loopBehavior = this.loopMode,
  54417. e.enableBlending = this.enableBlending,
  54418. e.blendingSpeed = this.blendingSpeed;
  54419. var i = this.dataType;
  54420. e.keys = [];
  54421. for (var o = this.getKeys(), s = 0; s < o.length; s++) {
  54422. var c = o[s]
  54423. , d = {};
  54424. switch (d.frame = c.frame,
  54425. i) {
  54426. case a.ANIMATIONTYPE_FLOAT:
  54427. d.values = [c.value],
  54428. c.inTangent !== void 0 && d.values.push(c.inTangent),
  54429. c.outTangent !== void 0 && (c.inTangent === void 0 && d.values.push(void 0),
  54430. d.values.push(c.outTangent));
  54431. break;
  54432. case a.ANIMATIONTYPE_QUATERNION:
  54433. case a.ANIMATIONTYPE_MATRIX:
  54434. case a.ANIMATIONTYPE_VECTOR3:
  54435. case a.ANIMATIONTYPE_COLOR3:
  54436. case a.ANIMATIONTYPE_COLOR4:
  54437. d.values = c.value.asArray(),
  54438. c.inTangent != null && d.values.push(c.inTangent.asArray()),
  54439. c.outTangent != null && (c.inTangent === void 0 && d.values.push(void 0),
  54440. d.values.push(c.outTangent.asArray()));
  54441. break
  54442. }
  54443. e.keys.push(d)
  54444. }
  54445. e.ranges = [];
  54446. for (var _ in this._ranges) {
  54447. var b = this._ranges[_];
  54448. if (!!b) {
  54449. var k = {};
  54450. k.name = _,
  54451. k.from = b.from,
  54452. k.to = b.to,
  54453. e.ranges.push(k)
  54454. }
  54455. }
  54456. return e
  54457. }
  54458. ,
  54459. a._UniversalLerp = function(e, i, o) {
  54460. var s = e.constructor;
  54461. return s.Lerp ? s.Lerp(e, i, o) : s.Slerp ? s.Slerp(e, i, o) : e.toFixed ? e * (1 - o) + o * i : i
  54462. }
  54463. ,
  54464. a.Parse = function(e) {
  54465. var i = new a(e.name,e.property,e.framePerSecond,e.dataType,e.loopBehavior), o = e.dataType, s = [], c, d;
  54466. for (e.enableBlending && (i.enableBlending = e.enableBlending),
  54467. e.blendingSpeed && (i.blendingSpeed = e.blendingSpeed),
  54468. d = 0; d < e.keys.length; d++) {
  54469. var _ = e.keys[d]
  54470. , b = void 0
  54471. , k = void 0;
  54472. switch (o) {
  54473. case a.ANIMATIONTYPE_FLOAT:
  54474. c = _.values[0],
  54475. _.values.length >= 1 && (b = _.values[1]),
  54476. _.values.length >= 2 && (k = _.values[2]);
  54477. break;
  54478. case a.ANIMATIONTYPE_QUATERNION:
  54479. if (c = Quaternion.FromArray(_.values),
  54480. _.values.length >= 8) {
  54481. var j = Quaternion.FromArray(_.values.slice(4, 8));
  54482. j.equals(Quaternion.Zero()) || (b = j)
  54483. }
  54484. if (_.values.length >= 12) {
  54485. var $ = Quaternion.FromArray(_.values.slice(8, 12));
  54486. $.equals(Quaternion.Zero()) || (k = $)
  54487. }
  54488. break;
  54489. case a.ANIMATIONTYPE_MATRIX:
  54490. c = Matrix.FromArray(_.values);
  54491. break;
  54492. case a.ANIMATIONTYPE_COLOR3:
  54493. c = Color3.FromArray(_.values),
  54494. _.values[3] && (b = Color3.FromArray(_.values[3])),
  54495. _.values[4] && (k = Color3.FromArray(_.values[4]));
  54496. break;
  54497. case a.ANIMATIONTYPE_COLOR4:
  54498. c = Color4.FromArray(_.values),
  54499. _.values[4] && (b = Color4.FromArray(_.values[4])),
  54500. _.values[5] && (k = Color4.FromArray(_.values[5]));
  54501. break;
  54502. case a.ANIMATIONTYPE_VECTOR3:
  54503. default:
  54504. c = Vector3.FromArray(_.values),
  54505. _.values[3] && (b = Vector3.FromArray(_.values[3])),
  54506. _.values[4] && (k = Vector3.FromArray(_.values[4]));
  54507. break
  54508. }
  54509. var _e = {};
  54510. _e.frame = _.frame,
  54511. _e.value = c,
  54512. b != null && (_e.inTangent = b),
  54513. k != null && (_e.outTangent = k),
  54514. s.push(_e)
  54515. }
  54516. if (i.setKeys(s),
  54517. e.ranges)
  54518. for (d = 0; d < e.ranges.length; d++)
  54519. c = e.ranges[d],
  54520. i.createRange(c.name, c.from, c.to);
  54521. return i
  54522. }
  54523. ,
  54524. a.AppendSerializedAnimations = function(e, i) {
  54525. SerializationHelper.AppendSerializedAnimations(e, i)
  54526. }
  54527. ,
  54528. a.ParseFromFileAsync = function(e, i) {
  54529. var o = this;
  54530. return new Promise(function(s, c) {
  54531. var d = new WebRequest;
  54532. d.addEventListener("readystatechange", function() {
  54533. if (d.readyState == 4)
  54534. if (d.status == 200) {
  54535. var _ = JSON.parse(d.responseText);
  54536. if (_.length) {
  54537. for (var b = new Array, k = 0, j = _; k < j.length; k++) {
  54538. var $ = j[k];
  54539. b.push(o.Parse($))
  54540. }
  54541. s(b)
  54542. } else {
  54543. var b = o.Parse(_);
  54544. e && (b.name = e),
  54545. s(b)
  54546. }
  54547. } else
  54548. c("Unable to load the animation")
  54549. }),
  54550. d.open("GET", i),
  54551. d.send()
  54552. }
  54553. )
  54554. }
  54555. ,
  54556. a.CreateFromSnippetAsync = function(e) {
  54557. var i = this;
  54558. return new Promise(function(o, s) {
  54559. var c = new WebRequest;
  54560. c.addEventListener("readystatechange", function() {
  54561. if (c.readyState == 4)
  54562. if (c.status == 200) {
  54563. var d = JSON.parse(JSON.parse(c.responseText).jsonPayload);
  54564. if (d.animations) {
  54565. for (var _ = JSON.parse(d.animations), b = new Array, k = 0, j = _.animations; k < j.length; k++) {
  54566. var $ = j[k]
  54567. , _e = i.Parse($);
  54568. _e.snippetId = e,
  54569. b.push(_e)
  54570. }
  54571. o(b)
  54572. } else {
  54573. var _ = JSON.parse(d.animation)
  54574. , _e = i.Parse(_);
  54575. _e.snippetId = e,
  54576. o(_e)
  54577. }
  54578. } else
  54579. s("Unable to load the snippet " + e)
  54580. }),
  54581. c.open("GET", i.SnippetUrl + "/" + e.replace(/#/g, "/")),
  54582. c.send()
  54583. }
  54584. )
  54585. }
  54586. ,
  54587. a._UniqueIdGenerator = 0,
  54588. a.AllowMatricesInterpolation = !1,
  54589. a.AllowMatrixDecomposeForInterpolation = !0,
  54590. a.SnippetUrl = "https://snippet.babylonjs.com",
  54591. a.ANIMATIONTYPE_FLOAT = 0,
  54592. a.ANIMATIONTYPE_VECTOR3 = 1,
  54593. a.ANIMATIONTYPE_QUATERNION = 2,
  54594. a.ANIMATIONTYPE_MATRIX = 3,
  54595. a.ANIMATIONTYPE_COLOR3 = 4,
  54596. a.ANIMATIONTYPE_COLOR4 = 7,
  54597. a.ANIMATIONTYPE_VECTOR2 = 5,
  54598. a.ANIMATIONTYPE_SIZE = 6,
  54599. a.ANIMATIONLOOPMODE_RELATIVE = 0,
  54600. a.ANIMATIONLOOPMODE_CYCLE = 1,
  54601. a.ANIMATIONLOOPMODE_CONSTANT = 2,
  54602. a
  54603. }();
  54604. RegisterClass("BABYLON.Animation", Animation);
  54605. Node$2._AnimationRangeFactory = function(a, e, i) {
  54606. return new AnimationRange(a,e,i)
  54607. }
  54608. ;
  54609. var _staticOffsetValueQuaternion = Object.freeze(new Quaternion(0,0,0,0))
  54610. , _staticOffsetValueVector3 = Object.freeze(Vector3.Zero())
  54611. , _staticOffsetValueVector2 = Object.freeze(Vector2.Zero())
  54612. , _staticOffsetValueSize = Object.freeze(Size.Zero())
  54613. , _staticOffsetValueColor3 = Object.freeze(Color3.Black())
  54614. , RuntimeAnimation = function() {
  54615. function a(e, i, o, s) {
  54616. var c = this;
  54617. if (this._events = new Array,
  54618. this._currentFrame = 0,
  54619. this._originalValue = new Array,
  54620. this._originalBlendValue = null,
  54621. this._offsetsCache = {},
  54622. this._highLimitsCache = {},
  54623. this._stopped = !1,
  54624. this._blendingFactor = 0,
  54625. this._currentValue = null,
  54626. this._currentActiveTarget = null,
  54627. this._directTarget = null,
  54628. this._targetPath = "",
  54629. this._weight = 1,
  54630. this._ratioOffset = 0,
  54631. this._previousDelay = 0,
  54632. this._previousRatio = 0,
  54633. this._targetIsArray = !1,
  54634. this._animation = i,
  54635. this._target = e,
  54636. this._scene = o,
  54637. this._host = s,
  54638. this._activeTargets = [],
  54639. i._runtimeAnimations.push(this),
  54640. this._animationState = {
  54641. key: 0,
  54642. repeatCount: 0,
  54643. loopMode: this._getCorrectLoopMode()
  54644. },
  54645. this._animation.dataType === Animation.ANIMATIONTYPE_MATRIX && (this._animationState.workValue = Matrix.Zero()),
  54646. this._keys = this._animation.getKeys(),
  54647. this._minFrame = this._keys[0].frame,
  54648. this._maxFrame = this._keys[this._keys.length - 1].frame,
  54649. this._minValue = this._keys[0].value,
  54650. this._maxValue = this._keys[this._keys.length - 1].value,
  54651. this._minFrame !== 0) {
  54652. var d = {
  54653. frame: 0,
  54654. value: this._minValue
  54655. };
  54656. this._keys.splice(0, 0, d)
  54657. }
  54658. if (this._target instanceof Array) {
  54659. for (var _ = 0, b = 0, k = this._target; b < k.length; b++) {
  54660. var j = k[b];
  54661. this._preparePath(j, _),
  54662. this._getOriginalValues(_),
  54663. _++
  54664. }
  54665. this._targetIsArray = !0
  54666. } else
  54667. this._preparePath(this._target),
  54668. this._getOriginalValues(),
  54669. this._targetIsArray = !1,
  54670. this._directTarget = this._activeTargets[0];
  54671. var $ = i.getEvents();
  54672. $ && $.length > 0 && $.forEach(function(_e) {
  54673. c._events.push(_e._clone())
  54674. }),
  54675. this._enableBlending = e && e.animationPropertiesOverride ? e.animationPropertiesOverride.enableBlending : this._animation.enableBlending
  54676. }
  54677. return Object.defineProperty(a.prototype, "currentFrame", {
  54678. get: function() {
  54679. return this._currentFrame
  54680. },
  54681. enumerable: !1,
  54682. configurable: !0
  54683. }),
  54684. Object.defineProperty(a.prototype, "weight", {
  54685. get: function() {
  54686. return this._weight
  54687. },
  54688. enumerable: !1,
  54689. configurable: !0
  54690. }),
  54691. Object.defineProperty(a.prototype, "currentValue", {
  54692. get: function() {
  54693. return this._currentValue
  54694. },
  54695. enumerable: !1,
  54696. configurable: !0
  54697. }),
  54698. Object.defineProperty(a.prototype, "targetPath", {
  54699. get: function() {
  54700. return this._targetPath
  54701. },
  54702. enumerable: !1,
  54703. configurable: !0
  54704. }),
  54705. Object.defineProperty(a.prototype, "target", {
  54706. get: function() {
  54707. return this._currentActiveTarget
  54708. },
  54709. enumerable: !1,
  54710. configurable: !0
  54711. }),
  54712. Object.defineProperty(a.prototype, "isAdditive", {
  54713. get: function() {
  54714. return this._host && this._host.isAdditive
  54715. },
  54716. enumerable: !1,
  54717. configurable: !0
  54718. }),
  54719. a.prototype._preparePath = function(e, i) {
  54720. i === void 0 && (i = 0);
  54721. var o = this._animation.targetPropertyPath;
  54722. if (o.length > 1) {
  54723. for (var s = e[o[0]], c = 1; c < o.length - 1; c++)
  54724. s = s[o[c]];
  54725. this._targetPath = o[o.length - 1],
  54726. this._activeTargets[i] = s
  54727. } else
  54728. this._targetPath = o[0],
  54729. this._activeTargets[i] = e
  54730. }
  54731. ,
  54732. Object.defineProperty(a.prototype, "animation", {
  54733. get: function() {
  54734. return this._animation
  54735. },
  54736. enumerable: !1,
  54737. configurable: !0
  54738. }),
  54739. a.prototype.reset = function(e) {
  54740. if (e === void 0 && (e = !1),
  54741. e)
  54742. if (this._target instanceof Array)
  54743. for (var i = 0, o = 0, s = this._target; o < s.length; o++) {
  54744. var c = s[o];
  54745. this._originalValue[i] !== void 0 && this._setValue(c, this._activeTargets[i], this._originalValue[i], -1, i),
  54746. i++
  54747. }
  54748. else
  54749. this._originalValue[0] !== void 0 && this._setValue(this._target, this._directTarget, this._originalValue[0], -1, 0);
  54750. this._offsetsCache = {},
  54751. this._highLimitsCache = {},
  54752. this._currentFrame = 0,
  54753. this._blendingFactor = 0;
  54754. for (var i = 0; i < this._events.length; i++)
  54755. this._events[i].isDone = !1
  54756. }
  54757. ,
  54758. a.prototype.isStopped = function() {
  54759. return this._stopped
  54760. }
  54761. ,
  54762. a.prototype.dispose = function() {
  54763. var e = this._animation.runtimeAnimations.indexOf(this);
  54764. e > -1 && this._animation.runtimeAnimations.splice(e, 1)
  54765. }
  54766. ,
  54767. a.prototype.setValue = function(e, i) {
  54768. if (this._targetIsArray) {
  54769. for (var o = 0; o < this._target.length; o++) {
  54770. var s = this._target[o];
  54771. this._setValue(s, this._activeTargets[o], e, i, o)
  54772. }
  54773. return
  54774. }
  54775. this._setValue(this._target, this._directTarget, e, i, 0)
  54776. }
  54777. ,
  54778. a.prototype._getOriginalValues = function(e) {
  54779. e === void 0 && (e = 0);
  54780. var i, o = this._activeTargets[e];
  54781. o.getRestPose && this._targetPath === "_matrix" ? i = o.getRestPose() : i = o[this._targetPath],
  54782. i && i.clone ? this._originalValue[e] = i.clone() : this._originalValue[e] = i
  54783. }
  54784. ,
  54785. a.prototype._setValue = function(e, i, o, s, c) {
  54786. if (this._currentActiveTarget = i,
  54787. this._weight = s,
  54788. this._enableBlending && this._blendingFactor <= 1) {
  54789. if (!this._originalBlendValue) {
  54790. var d = i[this._targetPath];
  54791. d.clone ? this._originalBlendValue = d.clone() : this._originalBlendValue = d
  54792. }
  54793. this._originalBlendValue.m ? Animation.AllowMatrixDecomposeForInterpolation ? this._currentValue ? Matrix.DecomposeLerpToRef(this._originalBlendValue, o, this._blendingFactor, this._currentValue) : this._currentValue = Matrix.DecomposeLerp(this._originalBlendValue, o, this._blendingFactor) : this._currentValue ? Matrix.LerpToRef(this._originalBlendValue, o, this._blendingFactor, this._currentValue) : this._currentValue = Matrix.Lerp(this._originalBlendValue, o, this._blendingFactor) : this._currentValue = Animation._UniversalLerp(this._originalBlendValue, o, this._blendingFactor);
  54794. var _ = e && e.animationPropertiesOverride ? e.animationPropertiesOverride.blendingSpeed : this._animation.blendingSpeed;
  54795. this._blendingFactor += _
  54796. } else
  54797. this._currentValue ? this._currentValue.copyFrom ? this._currentValue.copyFrom(o) : this._currentValue = o : o != null && o.clone ? this._currentValue = o.clone() : this._currentValue = o;
  54798. s !== -1 ? this._scene._registerTargetForLateAnimationBinding(this, this._originalValue[c]) : i[this._targetPath] = this._currentValue,
  54799. e.markAsDirty && e.markAsDirty(this._animation.targetProperty)
  54800. }
  54801. ,
  54802. a.prototype._getCorrectLoopMode = function() {
  54803. return this._target && this._target.animationPropertiesOverride ? this._target.animationPropertiesOverride.loopMode : this._animation.loopMode
  54804. }
  54805. ,
  54806. a.prototype.goToFrame = function(e) {
  54807. var i = this._animation.getKeys();
  54808. e < i[0].frame ? e = i[0].frame : e > i[i.length - 1].frame && (e = i[i.length - 1].frame);
  54809. var o = this._events;
  54810. if (o.length)
  54811. for (var s = 0; s < o.length; s++)
  54812. o[s].onlyOnce || (o[s].isDone = o[s].frame < e);
  54813. this._currentFrame = e;
  54814. var c = this._animation._interpolate(e, this._animationState);
  54815. this.setValue(c, -1)
  54816. }
  54817. ,
  54818. a.prototype._prepareForSpeedRatioChange = function(e) {
  54819. var i = this._previousDelay * (this._animation.framePerSecond * e) / 1e3;
  54820. this._ratioOffset = this._previousRatio - i
  54821. }
  54822. ,
  54823. a.prototype.animate = function(e, i, o, s, c, d) {
  54824. d === void 0 && (d = -1);
  54825. var _ = this._animation
  54826. , b = _.targetPropertyPath;
  54827. if (!b || b.length < 1)
  54828. return this._stopped = !0,
  54829. !1;
  54830. var k = !0;
  54831. (i < this._minFrame || i > this._maxFrame) && (i = this._minFrame),
  54832. (o < this._minFrame || o > this._maxFrame) && (o = this._maxFrame);
  54833. var j = o - i, $, _e = e * (_.framePerSecond * c) / 1e3 + this._ratioOffset, et = 0;
  54834. if (this._previousDelay = e,
  54835. this._previousRatio = _e,
  54836. !s && o >= i && _e >= j)
  54837. k = !1,
  54838. et = _._getKeyValue(this._maxValue);
  54839. else if (!s && i >= o && _e <= j)
  54840. k = !1,
  54841. et = _._getKeyValue(this._minValue);
  54842. else if (this._animationState.loopMode !== Animation.ANIMATIONLOOPMODE_CYCLE) {
  54843. var tt = o.toString() + i.toString();
  54844. if (!this._offsetsCache[tt]) {
  54845. this._animationState.repeatCount = 0,
  54846. this._animationState.loopMode = Animation.ANIMATIONLOOPMODE_CYCLE;
  54847. var rt = _._interpolate(i, this._animationState)
  54848. , it = _._interpolate(o, this._animationState);
  54849. switch (this._animationState.loopMode = this._getCorrectLoopMode(),
  54850. _.dataType) {
  54851. case Animation.ANIMATIONTYPE_FLOAT:
  54852. this._offsetsCache[tt] = it - rt;
  54853. break;
  54854. case Animation.ANIMATIONTYPE_QUATERNION:
  54855. this._offsetsCache[tt] = it.subtract(rt);
  54856. break;
  54857. case Animation.ANIMATIONTYPE_VECTOR3:
  54858. this._offsetsCache[tt] = it.subtract(rt);
  54859. break;
  54860. case Animation.ANIMATIONTYPE_VECTOR2:
  54861. this._offsetsCache[tt] = it.subtract(rt);
  54862. break;
  54863. case Animation.ANIMATIONTYPE_SIZE:
  54864. this._offsetsCache[tt] = it.subtract(rt);
  54865. break;
  54866. case Animation.ANIMATIONTYPE_COLOR3:
  54867. this._offsetsCache[tt] = it.subtract(rt);
  54868. break
  54869. }
  54870. this._highLimitsCache[tt] = it
  54871. }
  54872. et = this._highLimitsCache[tt],
  54873. $ = this._offsetsCache[tt]
  54874. }
  54875. if ($ === void 0)
  54876. switch (_.dataType) {
  54877. case Animation.ANIMATIONTYPE_FLOAT:
  54878. $ = 0;
  54879. break;
  54880. case Animation.ANIMATIONTYPE_QUATERNION:
  54881. $ = _staticOffsetValueQuaternion;
  54882. break;
  54883. case Animation.ANIMATIONTYPE_VECTOR3:
  54884. $ = _staticOffsetValueVector3;
  54885. break;
  54886. case Animation.ANIMATIONTYPE_VECTOR2:
  54887. $ = _staticOffsetValueVector2;
  54888. break;
  54889. case Animation.ANIMATIONTYPE_SIZE:
  54890. $ = _staticOffsetValueSize;
  54891. break;
  54892. case Animation.ANIMATIONTYPE_COLOR3:
  54893. $ = _staticOffsetValueColor3
  54894. }
  54895. var nt;
  54896. if (this._host && this._host.syncRoot) {
  54897. var ot = this._host.syncRoot
  54898. , at = (ot.masterFrame - ot.fromFrame) / (ot.toFrame - ot.fromFrame);
  54899. nt = i + (o - i) * at
  54900. } else
  54901. _e > 0 && i > o || _e < 0 && i < o ? nt = k && j !== 0 ? o + _e % j : i : nt = k && j !== 0 ? i + _e % j : o;
  54902. var st = this._events;
  54903. if ((c > 0 && this.currentFrame > nt || c < 0 && this.currentFrame < nt) && (this._onLoop(),
  54904. st.length))
  54905. for (var ut = 0; ut < st.length; ut++)
  54906. st[ut].onlyOnce || (st[ut].isDone = !1);
  54907. this._currentFrame = nt,
  54908. this._animationState.repeatCount = j === 0 ? 0 : _e / j >> 0,
  54909. this._animationState.highLimitValue = et,
  54910. this._animationState.offsetValue = $;
  54911. var ct = _._interpolate(nt, this._animationState);
  54912. if (this.setValue(ct, d),
  54913. st.length) {
  54914. for (var ut = 0; ut < st.length; ut++)
  54915. if (j > 0 && nt >= st[ut].frame && st[ut].frame >= i || j < 0 && nt <= st[ut].frame && st[ut].frame <= i) {
  54916. var lt = st[ut];
  54917. lt.isDone || (lt.onlyOnce && (st.splice(ut, 1),
  54918. ut--),
  54919. lt.isDone = !0,
  54920. lt.action(nt))
  54921. }
  54922. }
  54923. return k || (this._stopped = !0),
  54924. k
  54925. }
  54926. ,
  54927. a
  54928. }()
  54929. , Bone = function(a) {
  54930. __extends(e, a);
  54931. function e(i, o, s, c, d, _, b) {
  54932. s === void 0 && (s = null),
  54933. c === void 0 && (c = null),
  54934. d === void 0 && (d = null),
  54935. _ === void 0 && (_ = null),
  54936. b === void 0 && (b = null);
  54937. var k = a.call(this, i, o.getScene()) || this;
  54938. return k.name = i,
  54939. k.children = new Array,
  54940. k.animations = new Array,
  54941. k._index = null,
  54942. k._absoluteTransform = new Matrix,
  54943. k._invertedAbsoluteTransform = new Matrix,
  54944. k._scalingDeterminant = 1,
  54945. k._worldTransform = new Matrix,
  54946. k._needToDecompose = !0,
  54947. k._needToCompose = !1,
  54948. k._linkedTransformNode = null,
  54949. k._waitingTransformNodeId = null,
  54950. k._skeleton = o,
  54951. k._localMatrix = c ? c.clone() : Matrix.Identity(),
  54952. k._restPose = d || k._localMatrix.clone(),
  54953. k._baseMatrix = _ || k._localMatrix.clone(),
  54954. k._index = b,
  54955. o.bones.push(k),
  54956. k.setParent(s, !1),
  54957. (_ || c) && k._updateDifferenceMatrix(),
  54958. k
  54959. }
  54960. return Object.defineProperty(e.prototype, "_matrix", {
  54961. get: function() {
  54962. return this._compose(),
  54963. this._localMatrix
  54964. },
  54965. set: function(i) {
  54966. this._needToCompose = !1,
  54967. i.updateFlag !== this._localMatrix.updateFlag && (this._localMatrix.copyFrom(i),
  54968. this._markAsDirtyAndDecompose())
  54969. },
  54970. enumerable: !1,
  54971. configurable: !0
  54972. }),
  54973. e.prototype.getClassName = function() {
  54974. return "Bone"
  54975. }
  54976. ,
  54977. e.prototype.getSkeleton = function() {
  54978. return this._skeleton
  54979. }
  54980. ,
  54981. e.prototype.getParent = function() {
  54982. return this._parent
  54983. }
  54984. ,
  54985. e.prototype.getChildren = function() {
  54986. return this.children
  54987. }
  54988. ,
  54989. e.prototype.getIndex = function() {
  54990. return this._index === null ? this.getSkeleton().bones.indexOf(this) : this._index
  54991. }
  54992. ,
  54993. e.prototype.setParent = function(i, o) {
  54994. if (o === void 0 && (o = !0),
  54995. this._parent !== i) {
  54996. if (this._parent) {
  54997. var s = this._parent.children.indexOf(this);
  54998. s !== -1 && this._parent.children.splice(s, 1)
  54999. }
  55000. this._parent = i,
  55001. this._parent && this._parent.children.push(this),
  55002. o && this._updateDifferenceMatrix(),
  55003. this.markAsDirty()
  55004. }
  55005. }
  55006. ,
  55007. e.prototype.getLocalMatrix = function() {
  55008. return this._compose(),
  55009. this._localMatrix
  55010. }
  55011. ,
  55012. e.prototype.getBaseMatrix = function() {
  55013. return this._baseMatrix
  55014. }
  55015. ,
  55016. e.prototype.getRestPose = function() {
  55017. return this._restPose
  55018. }
  55019. ,
  55020. e.prototype.setRestPose = function(i) {
  55021. this._restPose.copyFrom(i)
  55022. }
  55023. ,
  55024. e.prototype.getBindPose = function() {
  55025. return this._baseMatrix
  55026. }
  55027. ,
  55028. e.prototype.setBindPose = function(i) {
  55029. this.updateMatrix(i)
  55030. }
  55031. ,
  55032. e.prototype.getWorldMatrix = function() {
  55033. return this._worldTransform
  55034. }
  55035. ,
  55036. e.prototype.returnToRest = function() {
  55037. var i;
  55038. if (this._linkedTransformNode) {
  55039. var o = TmpVectors.Vector3[0]
  55040. , s = TmpVectors.Quaternion[0]
  55041. , c = TmpVectors.Vector3[1];
  55042. this.getRestPose().decompose(o, s, c),
  55043. this._linkedTransformNode.position.copyFrom(c),
  55044. this._linkedTransformNode.rotationQuaternion = (i = this._linkedTransformNode.rotationQuaternion) !== null && i !== void 0 ? i : Quaternion.Identity(),
  55045. this._linkedTransformNode.rotationQuaternion.copyFrom(s),
  55046. this._linkedTransformNode.scaling.copyFrom(o)
  55047. } else
  55048. this._matrix = this._restPose
  55049. }
  55050. ,
  55051. e.prototype.getInvertedAbsoluteTransform = function() {
  55052. return this._invertedAbsoluteTransform
  55053. }
  55054. ,
  55055. e.prototype.getAbsoluteTransform = function() {
  55056. return this._absoluteTransform
  55057. }
  55058. ,
  55059. e.prototype.linkTransformNode = function(i) {
  55060. this._linkedTransformNode && this._skeleton._numBonesWithLinkedTransformNode--,
  55061. this._linkedTransformNode = i,
  55062. this._linkedTransformNode && this._skeleton._numBonesWithLinkedTransformNode++
  55063. }
  55064. ,
  55065. e.prototype.getTransformNode = function() {
  55066. return this._linkedTransformNode
  55067. }
  55068. ,
  55069. Object.defineProperty(e.prototype, "position", {
  55070. get: function() {
  55071. return this._decompose(),
  55072. this._localPosition
  55073. },
  55074. set: function(i) {
  55075. this._decompose(),
  55076. this._localPosition.copyFrom(i),
  55077. this._markAsDirtyAndCompose()
  55078. },
  55079. enumerable: !1,
  55080. configurable: !0
  55081. }),
  55082. Object.defineProperty(e.prototype, "rotation", {
  55083. get: function() {
  55084. return this.getRotation()
  55085. },
  55086. set: function(i) {
  55087. this.setRotation(i)
  55088. },
  55089. enumerable: !1,
  55090. configurable: !0
  55091. }),
  55092. Object.defineProperty(e.prototype, "rotationQuaternion", {
  55093. get: function() {
  55094. return this._decompose(),
  55095. this._localRotation
  55096. },
  55097. set: function(i) {
  55098. this.setRotationQuaternion(i)
  55099. },
  55100. enumerable: !1,
  55101. configurable: !0
  55102. }),
  55103. Object.defineProperty(e.prototype, "scaling", {
  55104. get: function() {
  55105. return this.getScale()
  55106. },
  55107. set: function(i) {
  55108. this.setScale(i)
  55109. },
  55110. enumerable: !1,
  55111. configurable: !0
  55112. }),
  55113. Object.defineProperty(e.prototype, "animationPropertiesOverride", {
  55114. get: function() {
  55115. return this._skeleton.animationPropertiesOverride
  55116. },
  55117. enumerable: !1,
  55118. configurable: !0
  55119. }),
  55120. e.prototype._decompose = function() {
  55121. !this._needToDecompose || (this._needToDecompose = !1,
  55122. this._localScaling || (this._localScaling = Vector3.Zero(),
  55123. this._localRotation = Quaternion.Zero(),
  55124. this._localPosition = Vector3.Zero()),
  55125. this._localMatrix.decompose(this._localScaling, this._localRotation, this._localPosition))
  55126. }
  55127. ,
  55128. e.prototype._compose = function() {
  55129. if (!!this._needToCompose) {
  55130. if (!this._localScaling) {
  55131. this._needToCompose = !1;
  55132. return
  55133. }
  55134. this._needToCompose = !1,
  55135. Matrix.ComposeToRef(this._localScaling, this._localRotation, this._localPosition, this._localMatrix)
  55136. }
  55137. }
  55138. ,
  55139. e.prototype.updateMatrix = function(i, o, s) {
  55140. o === void 0 && (o = !0),
  55141. s === void 0 && (s = !0),
  55142. this._baseMatrix.copyFrom(i),
  55143. o && this._updateDifferenceMatrix(),
  55144. s ? this._matrix = i : this.markAsDirty()
  55145. }
  55146. ,
  55147. e.prototype._updateDifferenceMatrix = function(i, o) {
  55148. if (o === void 0 && (o = !0),
  55149. i || (i = this._baseMatrix),
  55150. this._parent ? i.multiplyToRef(this._parent._absoluteTransform, this._absoluteTransform) : this._absoluteTransform.copyFrom(i),
  55151. this._absoluteTransform.invertToRef(this._invertedAbsoluteTransform),
  55152. o)
  55153. for (var s = 0; s < this.children.length; s++)
  55154. this.children[s]._updateDifferenceMatrix();
  55155. this._scalingDeterminant = this._absoluteTransform.determinant() < 0 ? -1 : 1
  55156. }
  55157. ,
  55158. e.prototype.markAsDirty = function(i) {
  55159. return this._currentRenderId++,
  55160. this._childUpdateId++,
  55161. this._skeleton._markAsDirty(),
  55162. this
  55163. }
  55164. ,
  55165. e.prototype._markAsDirtyAndCompose = function() {
  55166. this.markAsDirty(),
  55167. this._needToCompose = !0
  55168. }
  55169. ,
  55170. e.prototype._markAsDirtyAndDecompose = function() {
  55171. this.markAsDirty(),
  55172. this._needToDecompose = !0
  55173. }
  55174. ,
  55175. e.prototype.translate = function(i, o, s) {
  55176. o === void 0 && (o = Space.LOCAL);
  55177. var c = this.getLocalMatrix();
  55178. if (o == Space.LOCAL)
  55179. c.addAtIndex(12, i.x),
  55180. c.addAtIndex(13, i.y),
  55181. c.addAtIndex(14, i.z);
  55182. else {
  55183. var d = null;
  55184. s && (d = s.getWorldMatrix()),
  55185. this._skeleton.computeAbsoluteTransforms();
  55186. var _ = e._tmpMats[0]
  55187. , b = e._tmpVecs[0];
  55188. this._parent ? s && d ? (_.copyFrom(this._parent.getAbsoluteTransform()),
  55189. _.multiplyToRef(d, _)) : _.copyFrom(this._parent.getAbsoluteTransform()) : Matrix.IdentityToRef(_),
  55190. _.setTranslationFromFloats(0, 0, 0),
  55191. _.invert(),
  55192. Vector3.TransformCoordinatesToRef(i, _, b),
  55193. c.addAtIndex(12, b.x),
  55194. c.addAtIndex(13, b.y),
  55195. c.addAtIndex(14, b.z)
  55196. }
  55197. this._markAsDirtyAndDecompose()
  55198. }
  55199. ,
  55200. e.prototype.setPosition = function(i, o, s) {
  55201. o === void 0 && (o = Space.LOCAL);
  55202. var c = this.getLocalMatrix();
  55203. if (o == Space.LOCAL)
  55204. c.setTranslationFromFloats(i.x, i.y, i.z);
  55205. else {
  55206. var d = null;
  55207. s && (d = s.getWorldMatrix()),
  55208. this._skeleton.computeAbsoluteTransforms();
  55209. var _ = e._tmpMats[0]
  55210. , b = e._tmpVecs[0];
  55211. this._parent ? (s && d ? (_.copyFrom(this._parent.getAbsoluteTransform()),
  55212. _.multiplyToRef(d, _)) : _.copyFrom(this._parent.getAbsoluteTransform()),
  55213. _.invert()) : Matrix.IdentityToRef(_),
  55214. Vector3.TransformCoordinatesToRef(i, _, b),
  55215. c.setTranslationFromFloats(b.x, b.y, b.z)
  55216. }
  55217. this._markAsDirtyAndDecompose()
  55218. }
  55219. ,
  55220. e.prototype.setAbsolutePosition = function(i, o) {
  55221. this.setPosition(i, Space.WORLD, o)
  55222. }
  55223. ,
  55224. e.prototype.scale = function(i, o, s, c) {
  55225. c === void 0 && (c = !1);
  55226. var d = this.getLocalMatrix()
  55227. , _ = e._tmpMats[0];
  55228. Matrix.ScalingToRef(i, o, s, _),
  55229. _.multiplyToRef(d, d),
  55230. _.invert();
  55231. for (var b = 0, k = this.children; b < k.length; b++) {
  55232. var j = k[b]
  55233. , $ = j.getLocalMatrix();
  55234. $.multiplyToRef(_, $),
  55235. $.multiplyAtIndex(12, i),
  55236. $.multiplyAtIndex(13, o),
  55237. $.multiplyAtIndex(14, s),
  55238. j._markAsDirtyAndDecompose()
  55239. }
  55240. if (this._markAsDirtyAndDecompose(),
  55241. c)
  55242. for (var _e = 0, et = this.children; _e < et.length; _e++) {
  55243. var j = et[_e];
  55244. j.scale(i, o, s, c)
  55245. }
  55246. }
  55247. ,
  55248. e.prototype.setScale = function(i) {
  55249. this._decompose(),
  55250. this._localScaling.copyFrom(i),
  55251. this._markAsDirtyAndCompose()
  55252. }
  55253. ,
  55254. e.prototype.getScale = function() {
  55255. return this._decompose(),
  55256. this._localScaling
  55257. }
  55258. ,
  55259. e.prototype.getScaleToRef = function(i) {
  55260. this._decompose(),
  55261. i.copyFrom(this._localScaling)
  55262. }
  55263. ,
  55264. e.prototype.setYawPitchRoll = function(i, o, s, c, d) {
  55265. if (c === void 0 && (c = Space.LOCAL),
  55266. c === Space.LOCAL) {
  55267. var _ = e._tmpQuat;
  55268. Quaternion.RotationYawPitchRollToRef(i, o, s, _),
  55269. this.setRotationQuaternion(_, c, d);
  55270. return
  55271. }
  55272. var b = e._tmpMats[0];
  55273. if (!!this._getNegativeRotationToRef(b, d)) {
  55274. var k = e._tmpMats[1];
  55275. Matrix.RotationYawPitchRollToRef(i, o, s, k),
  55276. b.multiplyToRef(k, k),
  55277. this._rotateWithMatrix(k, c, d)
  55278. }
  55279. }
  55280. ,
  55281. e.prototype.rotate = function(i, o, s, c) {
  55282. s === void 0 && (s = Space.LOCAL);
  55283. var d = e._tmpMats[0];
  55284. d.setTranslationFromFloats(0, 0, 0),
  55285. Matrix.RotationAxisToRef(i, o, d),
  55286. this._rotateWithMatrix(d, s, c)
  55287. }
  55288. ,
  55289. e.prototype.setAxisAngle = function(i, o, s, c) {
  55290. if (s === void 0 && (s = Space.LOCAL),
  55291. s === Space.LOCAL) {
  55292. var d = e._tmpQuat;
  55293. Quaternion.RotationAxisToRef(i, o, d),
  55294. this.setRotationQuaternion(d, s, c);
  55295. return
  55296. }
  55297. var _ = e._tmpMats[0];
  55298. if (!!this._getNegativeRotationToRef(_, c)) {
  55299. var b = e._tmpMats[1];
  55300. Matrix.RotationAxisToRef(i, o, b),
  55301. _.multiplyToRef(b, b),
  55302. this._rotateWithMatrix(b, s, c)
  55303. }
  55304. }
  55305. ,
  55306. e.prototype.setRotation = function(i, o, s) {
  55307. o === void 0 && (o = Space.LOCAL),
  55308. this.setYawPitchRoll(i.y, i.x, i.z, o, s)
  55309. }
  55310. ,
  55311. e.prototype.setRotationQuaternion = function(i, o, s) {
  55312. if (o === void 0 && (o = Space.LOCAL),
  55313. o === Space.LOCAL) {
  55314. this._decompose(),
  55315. this._localRotation.copyFrom(i),
  55316. this._markAsDirtyAndCompose();
  55317. return
  55318. }
  55319. var c = e._tmpMats[0];
  55320. if (!!this._getNegativeRotationToRef(c, s)) {
  55321. var d = e._tmpMats[1];
  55322. Matrix.FromQuaternionToRef(i, d),
  55323. c.multiplyToRef(d, d),
  55324. this._rotateWithMatrix(d, o, s)
  55325. }
  55326. }
  55327. ,
  55328. e.prototype.setRotationMatrix = function(i, o, s) {
  55329. if (o === void 0 && (o = Space.LOCAL),
  55330. o === Space.LOCAL) {
  55331. var c = e._tmpQuat;
  55332. Quaternion.FromRotationMatrixToRef(i, c),
  55333. this.setRotationQuaternion(c, o, s);
  55334. return
  55335. }
  55336. var d = e._tmpMats[0];
  55337. if (!!this._getNegativeRotationToRef(d, s)) {
  55338. var _ = e._tmpMats[1];
  55339. _.copyFrom(i),
  55340. d.multiplyToRef(i, _),
  55341. this._rotateWithMatrix(_, o, s)
  55342. }
  55343. }
  55344. ,
  55345. e.prototype._rotateWithMatrix = function(i, o, s) {
  55346. o === void 0 && (o = Space.LOCAL);
  55347. var c = this.getLocalMatrix()
  55348. , d = c.m[12]
  55349. , _ = c.m[13]
  55350. , b = c.m[14]
  55351. , k = this.getParent()
  55352. , j = e._tmpMats[3]
  55353. , $ = e._tmpMats[4];
  55354. k && o == Space.WORLD ? (s ? (j.copyFrom(s.getWorldMatrix()),
  55355. k.getAbsoluteTransform().multiplyToRef(j, j)) : j.copyFrom(k.getAbsoluteTransform()),
  55356. $.copyFrom(j),
  55357. $.invert(),
  55358. c.multiplyToRef(j, c),
  55359. c.multiplyToRef(i, c),
  55360. c.multiplyToRef($, c)) : o == Space.WORLD && s ? (j.copyFrom(s.getWorldMatrix()),
  55361. $.copyFrom(j),
  55362. $.invert(),
  55363. c.multiplyToRef(j, c),
  55364. c.multiplyToRef(i, c),
  55365. c.multiplyToRef($, c)) : c.multiplyToRef(i, c),
  55366. c.setTranslationFromFloats(d, _, b),
  55367. this.computeAbsoluteTransforms(),
  55368. this._markAsDirtyAndDecompose()
  55369. }
  55370. ,
  55371. e.prototype._getNegativeRotationToRef = function(i, o) {
  55372. var s = e._tmpMats[2];
  55373. return i.copyFrom(this.getAbsoluteTransform()),
  55374. o && (i.multiplyToRef(o.getWorldMatrix(), i),
  55375. Matrix.ScalingToRef(o.scaling.x, o.scaling.y, o.scaling.z, s)),
  55376. i.invert(),
  55377. isNaN(i.m[0]) ? !1 : (s.multiplyAtIndex(0, this._scalingDeterminant),
  55378. i.multiplyToRef(s, i),
  55379. !0)
  55380. }
  55381. ,
  55382. e.prototype.getPosition = function(i, o) {
  55383. i === void 0 && (i = Space.LOCAL),
  55384. o === void 0 && (o = null);
  55385. var s = Vector3.Zero();
  55386. return this.getPositionToRef(i, o, s),
  55387. s
  55388. }
  55389. ,
  55390. e.prototype.getPositionToRef = function(i, o, s) {
  55391. if (i === void 0 && (i = Space.LOCAL),
  55392. i == Space.LOCAL) {
  55393. var c = this.getLocalMatrix();
  55394. s.x = c.m[12],
  55395. s.y = c.m[13],
  55396. s.z = c.m[14]
  55397. } else {
  55398. var d = null;
  55399. o && (d = o.getWorldMatrix()),
  55400. this._skeleton.computeAbsoluteTransforms();
  55401. var _ = e._tmpMats[0];
  55402. o && d ? (_.copyFrom(this.getAbsoluteTransform()),
  55403. _.multiplyToRef(d, _)) : _ = this.getAbsoluteTransform(),
  55404. s.x = _.m[12],
  55405. s.y = _.m[13],
  55406. s.z = _.m[14]
  55407. }
  55408. }
  55409. ,
  55410. e.prototype.getAbsolutePosition = function(i) {
  55411. i === void 0 && (i = null);
  55412. var o = Vector3.Zero();
  55413. return this.getPositionToRef(Space.WORLD, i, o),
  55414. o
  55415. }
  55416. ,
  55417. e.prototype.getAbsolutePositionToRef = function(i, o) {
  55418. this.getPositionToRef(Space.WORLD, i, o)
  55419. }
  55420. ,
  55421. e.prototype.computeAbsoluteTransforms = function() {
  55422. if (this._compose(),
  55423. this._parent)
  55424. this._localMatrix.multiplyToRef(this._parent._absoluteTransform, this._absoluteTransform);
  55425. else {
  55426. this._absoluteTransform.copyFrom(this._localMatrix);
  55427. var i = this._skeleton.getPoseMatrix();
  55428. i && this._absoluteTransform.multiplyToRef(i, this._absoluteTransform)
  55429. }
  55430. for (var o = this.children, s = o.length, c = 0; c < s; c++)
  55431. o[c].computeAbsoluteTransforms()
  55432. }
  55433. ,
  55434. e.prototype.getDirection = function(i, o) {
  55435. o === void 0 && (o = null);
  55436. var s = Vector3.Zero();
  55437. return this.getDirectionToRef(i, o, s),
  55438. s
  55439. }
  55440. ,
  55441. e.prototype.getDirectionToRef = function(i, o, s) {
  55442. o === void 0 && (o = null);
  55443. var c = null;
  55444. o && (c = o.getWorldMatrix()),
  55445. this._skeleton.computeAbsoluteTransforms();
  55446. var d = e._tmpMats[0];
  55447. d.copyFrom(this.getAbsoluteTransform()),
  55448. o && c && d.multiplyToRef(c, d),
  55449. Vector3.TransformNormalToRef(i, d, s),
  55450. s.normalize()
  55451. }
  55452. ,
  55453. e.prototype.getRotation = function(i, o) {
  55454. i === void 0 && (i = Space.LOCAL),
  55455. o === void 0 && (o = null);
  55456. var s = Vector3.Zero();
  55457. return this.getRotationToRef(i, o, s),
  55458. s
  55459. }
  55460. ,
  55461. e.prototype.getRotationToRef = function(i, o, s) {
  55462. i === void 0 && (i = Space.LOCAL),
  55463. o === void 0 && (o = null);
  55464. var c = e._tmpQuat;
  55465. this.getRotationQuaternionToRef(i, o, c),
  55466. c.toEulerAnglesToRef(s)
  55467. }
  55468. ,
  55469. e.prototype.getRotationQuaternion = function(i, o) {
  55470. i === void 0 && (i = Space.LOCAL),
  55471. o === void 0 && (o = null);
  55472. var s = Quaternion.Identity();
  55473. return this.getRotationQuaternionToRef(i, o, s),
  55474. s
  55475. }
  55476. ,
  55477. e.prototype.getRotationQuaternionToRef = function(i, o, s) {
  55478. if (i === void 0 && (i = Space.LOCAL),
  55479. o === void 0 && (o = null),
  55480. i == Space.LOCAL)
  55481. this._decompose(),
  55482. s.copyFrom(this._localRotation);
  55483. else {
  55484. var c = e._tmpMats[0]
  55485. , d = this.getAbsoluteTransform();
  55486. o ? d.multiplyToRef(o.getWorldMatrix(), c) : c.copyFrom(d),
  55487. c.multiplyAtIndex(0, this._scalingDeterminant),
  55488. c.multiplyAtIndex(1, this._scalingDeterminant),
  55489. c.multiplyAtIndex(2, this._scalingDeterminant),
  55490. c.decompose(void 0, s, void 0)
  55491. }
  55492. }
  55493. ,
  55494. e.prototype.getRotationMatrix = function(i, o) {
  55495. i === void 0 && (i = Space.LOCAL);
  55496. var s = Matrix.Identity();
  55497. return this.getRotationMatrixToRef(i, o, s),
  55498. s
  55499. }
  55500. ,
  55501. e.prototype.getRotationMatrixToRef = function(i, o, s) {
  55502. if (i === void 0 && (i = Space.LOCAL),
  55503. i == Space.LOCAL)
  55504. this.getLocalMatrix().getRotationMatrixToRef(s);
  55505. else {
  55506. var c = e._tmpMats[0]
  55507. , d = this.getAbsoluteTransform();
  55508. o ? d.multiplyToRef(o.getWorldMatrix(), c) : c.copyFrom(d),
  55509. c.multiplyAtIndex(0, this._scalingDeterminant),
  55510. c.multiplyAtIndex(1, this._scalingDeterminant),
  55511. c.multiplyAtIndex(2, this._scalingDeterminant),
  55512. c.getRotationMatrixToRef(s)
  55513. }
  55514. }
  55515. ,
  55516. e.prototype.getAbsolutePositionFromLocal = function(i, o) {
  55517. o === void 0 && (o = null);
  55518. var s = Vector3.Zero();
  55519. return this.getAbsolutePositionFromLocalToRef(i, o, s),
  55520. s
  55521. }
  55522. ,
  55523. e.prototype.getAbsolutePositionFromLocalToRef = function(i, o, s) {
  55524. o === void 0 && (o = null);
  55525. var c = null;
  55526. o && (c = o.getWorldMatrix()),
  55527. this._skeleton.computeAbsoluteTransforms();
  55528. var d = e._tmpMats[0];
  55529. o && c ? (d.copyFrom(this.getAbsoluteTransform()),
  55530. d.multiplyToRef(c, d)) : d = this.getAbsoluteTransform(),
  55531. Vector3.TransformCoordinatesToRef(i, d, s)
  55532. }
  55533. ,
  55534. e.prototype.getLocalPositionFromAbsolute = function(i, o) {
  55535. o === void 0 && (o = null);
  55536. var s = Vector3.Zero();
  55537. return this.getLocalPositionFromAbsoluteToRef(i, o, s),
  55538. s
  55539. }
  55540. ,
  55541. e.prototype.getLocalPositionFromAbsoluteToRef = function(i, o, s) {
  55542. o === void 0 && (o = null);
  55543. var c = null;
  55544. o && (c = o.getWorldMatrix()),
  55545. this._skeleton.computeAbsoluteTransforms();
  55546. var d = e._tmpMats[0];
  55547. d.copyFrom(this.getAbsoluteTransform()),
  55548. o && c && d.multiplyToRef(c, d),
  55549. d.invert(),
  55550. Vector3.TransformCoordinatesToRef(i, d, s)
  55551. }
  55552. ,
  55553. e.prototype.setCurrentPoseAsRest = function() {
  55554. this.setRestPose(this.getLocalMatrix())
  55555. }
  55556. ,
  55557. e._tmpVecs = ArrayTools.BuildArray(2, Vector3.Zero),
  55558. e._tmpQuat = Quaternion.Identity(),
  55559. e._tmpMats = ArrayTools.BuildArray(5, Matrix.Identity),
  55560. e
  55561. }(Node$2)
  55562. , Animatable = function() {
  55563. function a(e, i, o, s, c, d, _, b, k, j) {
  55564. o === void 0 && (o = 0),
  55565. s === void 0 && (s = 100),
  55566. c === void 0 && (c = !1),
  55567. d === void 0 && (d = 1),
  55568. j === void 0 && (j = !1),
  55569. this.target = i,
  55570. this.fromFrame = o,
  55571. this.toFrame = s,
  55572. this.loopAnimation = c,
  55573. this.onAnimationEnd = _,
  55574. this.onAnimationLoop = k,
  55575. this.isAdditive = j,
  55576. this._localDelayOffset = null,
  55577. this._pausedDelay = null,
  55578. this._manualJumpDelay = null,
  55579. this._runtimeAnimations = new Array,
  55580. this._paused = !1,
  55581. this._speedRatio = 1,
  55582. this._weight = -1,
  55583. this._syncRoot = null,
  55584. this._frameToSyncFromJump = 0,
  55585. this.disposeOnEnd = !0,
  55586. this.animationStarted = !1,
  55587. this.onAnimationEndObservable = new Observable,
  55588. this.onAnimationLoopObservable = new Observable,
  55589. this._scene = e,
  55590. b && this.appendAnimations(i, b),
  55591. this._speedRatio = d,
  55592. e._activeAnimatables.push(this)
  55593. }
  55594. return Object.defineProperty(a.prototype, "syncRoot", {
  55595. get: function() {
  55596. return this._syncRoot
  55597. },
  55598. enumerable: !1,
  55599. configurable: !0
  55600. }),
  55601. Object.defineProperty(a.prototype, "masterFrame", {
  55602. get: function() {
  55603. return this._runtimeAnimations.length === 0 ? 0 : this._runtimeAnimations[0].currentFrame
  55604. },
  55605. enumerable: !1,
  55606. configurable: !0
  55607. }),
  55608. Object.defineProperty(a.prototype, "weight", {
  55609. get: function() {
  55610. return this._weight
  55611. },
  55612. set: function(e) {
  55613. if (e === -1) {
  55614. this._weight = -1;
  55615. return
  55616. }
  55617. this._weight = Math.min(Math.max(e, 0), 1)
  55618. },
  55619. enumerable: !1,
  55620. configurable: !0
  55621. }),
  55622. Object.defineProperty(a.prototype, "speedRatio", {
  55623. get: function() {
  55624. return this._speedRatio
  55625. },
  55626. set: function(e) {
  55627. for (var i = 0; i < this._runtimeAnimations.length; i++) {
  55628. var o = this._runtimeAnimations[i];
  55629. o._prepareForSpeedRatioChange(e)
  55630. }
  55631. this._speedRatio = e
  55632. },
  55633. enumerable: !1,
  55634. configurable: !0
  55635. }),
  55636. a.prototype.syncWith = function(e) {
  55637. if (this._syncRoot = e,
  55638. e) {
  55639. var i = this._scene._activeAnimatables.indexOf(this);
  55640. i > -1 && (this._scene._activeAnimatables.splice(i, 1),
  55641. this._scene._activeAnimatables.push(this))
  55642. }
  55643. return this
  55644. }
  55645. ,
  55646. a.prototype.getAnimations = function() {
  55647. return this._runtimeAnimations
  55648. }
  55649. ,
  55650. a.prototype.appendAnimations = function(e, i) {
  55651. for (var o = this, s = 0; s < i.length; s++) {
  55652. var c = i[s]
  55653. , d = new RuntimeAnimation(e,c,this._scene,this);
  55654. d._onLoop = function() {
  55655. o.onAnimationLoopObservable.notifyObservers(o),
  55656. o.onAnimationLoop && o.onAnimationLoop()
  55657. }
  55658. ,
  55659. this._runtimeAnimations.push(d)
  55660. }
  55661. }
  55662. ,
  55663. a.prototype.getAnimationByTargetProperty = function(e) {
  55664. for (var i = this._runtimeAnimations, o = 0; o < i.length; o++)
  55665. if (i[o].animation.targetProperty === e)
  55666. return i[o].animation;
  55667. return null
  55668. }
  55669. ,
  55670. a.prototype.getRuntimeAnimationByTargetProperty = function(e) {
  55671. for (var i = this._runtimeAnimations, o = 0; o < i.length; o++)
  55672. if (i[o].animation.targetProperty === e)
  55673. return i[o];
  55674. return null
  55675. }
  55676. ,
  55677. a.prototype.reset = function() {
  55678. for (var e = this._runtimeAnimations, i = 0; i < e.length; i++)
  55679. e[i].reset(!0);
  55680. this._localDelayOffset = null,
  55681. this._pausedDelay = null
  55682. }
  55683. ,
  55684. a.prototype.enableBlending = function(e) {
  55685. for (var i = this._runtimeAnimations, o = 0; o < i.length; o++)
  55686. i[o].animation.enableBlending = !0,
  55687. i[o].animation.blendingSpeed = e
  55688. }
  55689. ,
  55690. a.prototype.disableBlending = function() {
  55691. for (var e = this._runtimeAnimations, i = 0; i < e.length; i++)
  55692. e[i].animation.enableBlending = !1
  55693. }
  55694. ,
  55695. a.prototype.goToFrame = function(e) {
  55696. var i, o = this._runtimeAnimations;
  55697. if (o[0]) {
  55698. var s = o[0].animation.framePerSecond;
  55699. this._frameToSyncFromJump = (i = this._frameToSyncFromJump) !== null && i !== void 0 ? i : o[0].currentFrame;
  55700. var c = this.speedRatio === 0 ? 0 : (e - this._frameToSyncFromJump) / s * 1e3 / this.speedRatio;
  55701. this._manualJumpDelay = -c
  55702. }
  55703. for (var d = 0; d < o.length; d++)
  55704. o[d].goToFrame(e)
  55705. }
  55706. ,
  55707. a.prototype.pause = function() {
  55708. this._paused || (this._paused = !0)
  55709. }
  55710. ,
  55711. a.prototype.restart = function() {
  55712. this._paused = !1
  55713. }
  55714. ,
  55715. a.prototype._raiseOnAnimationEnd = function() {
  55716. this.onAnimationEnd && this.onAnimationEnd(),
  55717. this.onAnimationEndObservable.notifyObservers(this)
  55718. }
  55719. ,
  55720. a.prototype.stop = function(e, i) {
  55721. if (e || i) {
  55722. var o = this._scene._activeAnimatables.indexOf(this);
  55723. if (o > -1) {
  55724. for (var s = this._runtimeAnimations, c = s.length - 1; c >= 0; c--) {
  55725. var d = s[c];
  55726. e && d.animation.name != e || i && !i(d.target) || (d.dispose(),
  55727. s.splice(c, 1))
  55728. }
  55729. s.length == 0 && (this._scene._activeAnimatables.splice(o, 1),
  55730. this._raiseOnAnimationEnd())
  55731. }
  55732. } else {
  55733. var c = this._scene._activeAnimatables.indexOf(this);
  55734. if (c > -1) {
  55735. this._scene._activeAnimatables.splice(c, 1);
  55736. for (var s = this._runtimeAnimations, c = 0; c < s.length; c++)
  55737. s[c].dispose();
  55738. this._raiseOnAnimationEnd()
  55739. }
  55740. }
  55741. }
  55742. ,
  55743. a.prototype.waitAsync = function() {
  55744. var e = this;
  55745. return new Promise(function(i, o) {
  55746. e.onAnimationEndObservable.add(function() {
  55747. i(e)
  55748. }, void 0, void 0, e, !0)
  55749. }
  55750. )
  55751. }
  55752. ,
  55753. a.prototype._animate = function(e) {
  55754. if (this._paused)
  55755. return this.animationStarted = !1,
  55756. this._pausedDelay === null && (this._pausedDelay = e),
  55757. !0;
  55758. if (this._localDelayOffset === null ? (this._localDelayOffset = e,
  55759. this._pausedDelay = null) : this._pausedDelay !== null && (this._localDelayOffset += e - this._pausedDelay,
  55760. this._pausedDelay = null),
  55761. this._manualJumpDelay !== null && (this._localDelayOffset += this._manualJumpDelay,
  55762. this._manualJumpDelay = null,
  55763. this._frameToSyncFromJump = null),
  55764. this._weight === 0)
  55765. return !0;
  55766. var i = !1, o = this._runtimeAnimations, s;
  55767. for (s = 0; s < o.length; s++) {
  55768. var c = o[s]
  55769. , d = c.animate(e - this._localDelayOffset, this.fromFrame, this.toFrame, this.loopAnimation, this._speedRatio, this._weight);
  55770. i = i || d
  55771. }
  55772. if (this.animationStarted = i,
  55773. !i) {
  55774. if (this.disposeOnEnd)
  55775. for (s = this._scene._activeAnimatables.indexOf(this),
  55776. this._scene._activeAnimatables.splice(s, 1),
  55777. s = 0; s < o.length; s++)
  55778. o[s].dispose();
  55779. this._raiseOnAnimationEnd(),
  55780. this.disposeOnEnd && (this.onAnimationEnd = null,
  55781. this.onAnimationLoop = null,
  55782. this.onAnimationLoopObservable.clear(),
  55783. this.onAnimationEndObservable.clear())
  55784. }
  55785. return i
  55786. }
  55787. ,
  55788. a
  55789. }();
  55790. Scene.prototype._animate = function() {
  55791. if (!!this.animationsEnabled) {
  55792. var a = PrecisionDate.Now;
  55793. if (!this._animationTimeLast) {
  55794. if (this._pendingData.length > 0)
  55795. return;
  55796. this._animationTimeLast = a
  55797. }
  55798. this.deltaTime = this.useConstantAnimationDeltaTime ? 16 : (a - this._animationTimeLast) * this.animationTimeScale,
  55799. this._animationTimeLast = a;
  55800. var e = this._activeAnimatables;
  55801. if (e.length !== 0) {
  55802. this._animationTime += this.deltaTime;
  55803. for (var i = this._animationTime, o = 0; o < e.length; o++) {
  55804. var s = e[o];
  55805. !s._animate(i) && s.disposeOnEnd && o--
  55806. }
  55807. this._processLateAnimationBindings()
  55808. }
  55809. }
  55810. }
  55811. ;
  55812. Scene.prototype.beginWeightedAnimation = function(a, e, i, o, s, c, d, _, b, k, j) {
  55813. o === void 0 && (o = 1),
  55814. c === void 0 && (c = 1),
  55815. j === void 0 && (j = !1);
  55816. var $ = this.beginAnimation(a, e, i, s, c, d, _, !1, b, k, j);
  55817. return $.weight = o,
  55818. $
  55819. }
  55820. ;
  55821. Scene.prototype.beginAnimation = function(a, e, i, o, s, c, d, _, b, k, j) {
  55822. s === void 0 && (s = 1),
  55823. _ === void 0 && (_ = !0),
  55824. j === void 0 && (j = !1),
  55825. e > i && s > 0 && (s *= -1),
  55826. _ && this.stopAnimation(a, void 0, b),
  55827. d || (d = new Animatable(this,a,e,i,o,s,c,void 0,k,j));
  55828. var $ = b ? b(a) : !0;
  55829. if (a.animations && $ && d.appendAnimations(a, a.animations),
  55830. a.getAnimatables)
  55831. for (var _e = a.getAnimatables(), et = 0; et < _e.length; et++)
  55832. this.beginAnimation(_e[et], e, i, o, s, c, d, _, b, k);
  55833. return d.reset(),
  55834. d
  55835. }
  55836. ;
  55837. Scene.prototype.beginHierarchyAnimation = function(a, e, i, o, s, c, d, _, b, k, j, $) {
  55838. c === void 0 && (c = 1),
  55839. b === void 0 && (b = !0),
  55840. $ === void 0 && ($ = !1);
  55841. var _e = a.getDescendants(e)
  55842. , et = [];
  55843. et.push(this.beginAnimation(a, i, o, s, c, d, _, b, k, void 0, $));
  55844. for (var tt = 0, rt = _e; tt < rt.length; tt++) {
  55845. var it = rt[tt];
  55846. et.push(this.beginAnimation(it, i, o, s, c, d, _, b, k, void 0, $))
  55847. }
  55848. return et
  55849. }
  55850. ;
  55851. Scene.prototype.beginDirectAnimation = function(a, e, i, o, s, c, d, _, b) {
  55852. if (b === void 0 && (b = !1),
  55853. c === void 0 && (c = 1),
  55854. i > o && c > 0)
  55855. c *= -1;
  55856. else if (o > i && c < 0) {
  55857. var k = o;
  55858. o = i,
  55859. i = k
  55860. }
  55861. var j = new Animatable(this,a,i,o,s,c,d,e,_,b);
  55862. return j
  55863. }
  55864. ;
  55865. Scene.prototype.beginDirectHierarchyAnimation = function(a, e, i, o, s, c, d, _, b, k) {
  55866. k === void 0 && (k = !1);
  55867. var j = a.getDescendants(e)
  55868. , $ = [];
  55869. $.push(this.beginDirectAnimation(a, i, o, s, c, d, _, b, k));
  55870. for (var _e = 0, et = j; _e < et.length; _e++) {
  55871. var tt = et[_e];
  55872. $.push(this.beginDirectAnimation(tt, i, o, s, c, d, _, b, k))
  55873. }
  55874. return $
  55875. }
  55876. ;
  55877. Scene.prototype.getAnimatableByTarget = function(a) {
  55878. for (var e = 0; e < this._activeAnimatables.length; e++)
  55879. if (this._activeAnimatables[e].target === a)
  55880. return this._activeAnimatables[e];
  55881. return null
  55882. }
  55883. ;
  55884. Scene.prototype.getAllAnimatablesByTarget = function(a) {
  55885. for (var e = [], i = 0; i < this._activeAnimatables.length; i++)
  55886. this._activeAnimatables[i].target === a && e.push(this._activeAnimatables[i]);
  55887. return e
  55888. }
  55889. ;
  55890. Scene.prototype.stopAnimation = function(a, e, i) {
  55891. for (var o = this.getAllAnimatablesByTarget(a), s = 0, c = o; s < c.length; s++) {
  55892. var d = c[s];
  55893. d.stop(e, i)
  55894. }
  55895. }
  55896. ;
  55897. Scene.prototype.stopAllAnimations = function() {
  55898. if (this._activeAnimatables) {
  55899. for (var a = 0; a < this._activeAnimatables.length; a++)
  55900. this._activeAnimatables[a].stop();
  55901. this._activeAnimatables = []
  55902. }
  55903. for (var e = 0, i = this.animationGroups; e < i.length; e++) {
  55904. var o = i[e];
  55905. o.stop()
  55906. }
  55907. }
  55908. ;
  55909. Scene.prototype._registerTargetForLateAnimationBinding = function(a, e) {
  55910. var i = a.target;
  55911. this._registeredForLateAnimationBindings.pushNoDuplicate(i),
  55912. i._lateAnimationHolders || (i._lateAnimationHolders = {}),
  55913. i._lateAnimationHolders[a.targetPath] || (i._lateAnimationHolders[a.targetPath] = {
  55914. totalWeight: 0,
  55915. totalAdditiveWeight: 0,
  55916. animations: [],
  55917. additiveAnimations: [],
  55918. originalValue: e
  55919. }),
  55920. a.isAdditive ? (i._lateAnimationHolders[a.targetPath].additiveAnimations.push(a),
  55921. i._lateAnimationHolders[a.targetPath].totalAdditiveWeight += a.weight) : (i._lateAnimationHolders[a.targetPath].animations.push(a),
  55922. i._lateAnimationHolders[a.targetPath].totalWeight += a.weight)
  55923. }
  55924. ;
  55925. Scene.prototype._processLateAnimationBindingsForMatrices = function(a) {
  55926. if (a.totalWeight === 0 && a.totalAdditiveWeight === 0)
  55927. return a.originalValue;
  55928. var e = 1
  55929. , i = TmpVectors.Vector3[0]
  55930. , o = TmpVectors.Vector3[1]
  55931. , s = TmpVectors.Quaternion[0]
  55932. , c = 0
  55933. , d = a.animations[0]
  55934. , _ = a.originalValue
  55935. , b = 1
  55936. , k = !1;
  55937. if (a.totalWeight < 1)
  55938. b = 1 - a.totalWeight,
  55939. _.decompose(o, s, i);
  55940. else {
  55941. if (c = 1,
  55942. e = a.totalWeight,
  55943. b = d.weight / e,
  55944. b == 1)
  55945. if (a.totalAdditiveWeight)
  55946. k = !0;
  55947. else
  55948. return d.currentValue;
  55949. d.currentValue.decompose(o, s, i)
  55950. }
  55951. if (!k) {
  55952. o.scaleInPlace(b),
  55953. i.scaleInPlace(b),
  55954. s.scaleInPlace(b);
  55955. for (var j = c; j < a.animations.length; j++) {
  55956. var $ = a.animations[j];
  55957. if ($.weight !== 0) {
  55958. var b = $.weight / e
  55959. , _e = TmpVectors.Vector3[2]
  55960. , et = TmpVectors.Vector3[3]
  55961. , tt = TmpVectors.Quaternion[1];
  55962. $.currentValue.decompose(et, tt, _e),
  55963. et.scaleAndAddToRef(b, o),
  55964. tt.scaleAndAddToRef(b, s),
  55965. _e.scaleAndAddToRef(b, i)
  55966. }
  55967. }
  55968. }
  55969. for (var rt = 0; rt < a.additiveAnimations.length; rt++) {
  55970. var $ = a.additiveAnimations[rt];
  55971. if ($.weight !== 0) {
  55972. var _e = TmpVectors.Vector3[2]
  55973. , et = TmpVectors.Vector3[3]
  55974. , tt = TmpVectors.Quaternion[1];
  55975. $.currentValue.decompose(et, tt, _e),
  55976. et.multiplyToRef(o, et),
  55977. Vector3.LerpToRef(o, et, $.weight, o),
  55978. s.multiplyToRef(tt, tt),
  55979. Quaternion.SlerpToRef(s, tt, $.weight, s),
  55980. _e.scaleAndAddToRef($.weight, i)
  55981. }
  55982. }
  55983. var it = d ? d._animationState.workValue : TmpVectors.Matrix[0].clone();
  55984. return Matrix.ComposeToRef(o, s, i, it),
  55985. it
  55986. }
  55987. ;
  55988. Scene.prototype._processLateAnimationBindingsForQuaternions = function(a, e) {
  55989. if (a.totalWeight === 0 && a.totalAdditiveWeight === 0)
  55990. return e;
  55991. var i = a.animations[0]
  55992. , o = a.originalValue
  55993. , s = e;
  55994. if (a.totalWeight === 0 && a.totalAdditiveWeight > 0)
  55995. s.copyFrom(o);
  55996. else if (a.animations.length === 1) {
  55997. if (Quaternion.SlerpToRef(o, i.currentValue, Math.min(1, a.totalWeight), s),
  55998. a.totalAdditiveWeight === 0)
  55999. return s
  56000. } else if (a.animations.length > 1) {
  56001. var c = 1
  56002. , d = void 0
  56003. , _ = void 0;
  56004. if (a.totalWeight < 1) {
  56005. var b = 1 - a.totalWeight;
  56006. d = [],
  56007. _ = [],
  56008. d.push(o),
  56009. _.push(b)
  56010. } else {
  56011. if (a.animations.length === 2 && (Quaternion.SlerpToRef(a.animations[0].currentValue, a.animations[1].currentValue, a.animations[1].weight / a.totalWeight, e),
  56012. a.totalAdditiveWeight === 0))
  56013. return e;
  56014. d = [],
  56015. _ = [],
  56016. c = a.totalWeight
  56017. }
  56018. for (var k = 0; k < a.animations.length; k++) {
  56019. var j = a.animations[k];
  56020. d.push(j.currentValue),
  56021. _.push(j.weight / c)
  56022. }
  56023. for (var $ = 0, _e = 0; _e < d.length; ) {
  56024. if (!_e) {
  56025. Quaternion.SlerpToRef(d[_e], d[_e + 1], _[_e + 1] / (_[_e] + _[_e + 1]), e),
  56026. s = e,
  56027. $ = _[_e] + _[_e + 1],
  56028. _e += 2;
  56029. continue
  56030. }
  56031. $ += _[_e],
  56032. Quaternion.SlerpToRef(s, d[_e], _[_e] / $, s),
  56033. _e++
  56034. }
  56035. }
  56036. for (var et = 0; et < a.additiveAnimations.length; et++) {
  56037. var j = a.additiveAnimations[et];
  56038. j.weight !== 0 && (s.multiplyToRef(j.currentValue, TmpVectors.Quaternion[0]),
  56039. Quaternion.SlerpToRef(s, TmpVectors.Quaternion[0], j.weight, s))
  56040. }
  56041. return s
  56042. }
  56043. ;
  56044. Scene.prototype._processLateAnimationBindings = function() {
  56045. if (!!this._registeredForLateAnimationBindings.length) {
  56046. for (var a = 0; a < this._registeredForLateAnimationBindings.length; a++) {
  56047. var e = this._registeredForLateAnimationBindings.data[a];
  56048. for (var i in e._lateAnimationHolders) {
  56049. var o = e._lateAnimationHolders[i]
  56050. , s = o.animations[0]
  56051. , c = o.originalValue
  56052. , d = Animation.AllowMatrixDecomposeForInterpolation && c.m
  56053. , _ = e[i];
  56054. if (d)
  56055. _ = this._processLateAnimationBindingsForMatrices(o);
  56056. else {
  56057. var b = c.w !== void 0;
  56058. if (b)
  56059. _ = this._processLateAnimationBindingsForQuaternions(o, _ || Quaternion.Identity());
  56060. else {
  56061. var k = 0
  56062. , j = 1;
  56063. if (o.totalWeight < 1)
  56064. s && c.scale ? _ = c.scale(1 - o.totalWeight) : s ? _ = c * (1 - o.totalWeight) : c.clone ? _ = c.clone() : _ = c;
  56065. else if (s) {
  56066. j = o.totalWeight;
  56067. var $ = s.weight / j;
  56068. $ !== 1 ? s.currentValue.scale ? _ = s.currentValue.scale($) : _ = s.currentValue * $ : _ = s.currentValue,
  56069. k = 1
  56070. }
  56071. for (var _e = k; _e < o.animations.length; _e++) {
  56072. var et = o.animations[_e]
  56073. , tt = et.weight / j;
  56074. if (tt)
  56075. et.currentValue.scaleAndAddToRef ? et.currentValue.scaleAndAddToRef(tt, _) : _ += et.currentValue * tt;
  56076. else
  56077. continue
  56078. }
  56079. for (var rt = 0; rt < o.additiveAnimations.length; rt++) {
  56080. var et = o.additiveAnimations[rt]
  56081. , tt = et.weight;
  56082. if (tt)
  56083. et.currentValue.scaleAndAddToRef ? et.currentValue.scaleAndAddToRef(tt, _) : _ += et.currentValue * tt;
  56084. else
  56085. continue
  56086. }
  56087. }
  56088. }
  56089. e[i] = _
  56090. }
  56091. e._lateAnimationHolders = {}
  56092. }
  56093. this._registeredForLateAnimationBindings.reset()
  56094. }
  56095. }
  56096. ;
  56097. Bone.prototype.copyAnimationRange = function(a, e, i, o, s) {
  56098. o === void 0 && (o = !1),
  56099. s === void 0 && (s = null),
  56100. this.animations.length === 0 && (this.animations.push(new Animation(this.name,"_matrix",a.animations[0].framePerSecond,Animation.ANIMATIONTYPE_MATRIX,0)),
  56101. this.animations[0].setKeys([]));
  56102. var c = a.animations[0].getRange(e);
  56103. if (!c)
  56104. return !1;
  56105. for (var d = c.from, _ = c.to, b = a.animations[0].getKeys(), k = a.length, j = a.getParent(), $ = this.getParent(), _e = o && j && k && this.length && k !== this.length, et = _e && $ && j ? $.length / j.length : 1, tt = o && !$ && s && (s.x !== 1 || s.y !== 1 || s.z !== 1), rt = this.animations[0].getKeys(), it, nt, ot, at = 0, st = b.length; at < st; at++)
  56106. it = b[at],
  56107. it.frame >= d && it.frame <= _ && (o ? (ot = it.value.clone(),
  56108. _e ? (nt = ot.getTranslation(),
  56109. ot.setTranslation(nt.scaleInPlace(et))) : tt && s ? (nt = ot.getTranslation(),
  56110. ot.setTranslation(nt.multiplyInPlace(s))) : ot = it.value) : ot = it.value,
  56111. rt.push({
  56112. frame: it.frame + i,
  56113. value: ot
  56114. }));
  56115. return this.animations[0].createRange(e, d + i, _ + i),
  56116. !0
  56117. }
  56118. ;
  56119. var TargetedAnimation = function() {
  56120. function a() {}
  56121. return a.prototype.getClassName = function() {
  56122. return "TargetedAnimation"
  56123. }
  56124. ,
  56125. a.prototype.serialize = function() {
  56126. var e = {};
  56127. return e.animation = this.animation.serialize(),
  56128. e.targetId = this.target.id,
  56129. e
  56130. }
  56131. ,
  56132. a
  56133. }()
  56134. , AnimationGroup = function() {
  56135. function a(e, i) {
  56136. i === void 0 && (i = null),
  56137. this.name = e,
  56138. this._targetedAnimations = new Array,
  56139. this._animatables = new Array,
  56140. this._from = Number.MAX_VALUE,
  56141. this._to = -Number.MAX_VALUE,
  56142. this._speedRatio = 1,
  56143. this._loopAnimation = !1,
  56144. this._isAdditive = !1,
  56145. this._parentContainer = null,
  56146. this.onAnimationEndObservable = new Observable,
  56147. this.onAnimationLoopObservable = new Observable,
  56148. this.onAnimationGroupLoopObservable = new Observable,
  56149. this.onAnimationGroupEndObservable = new Observable,
  56150. this.onAnimationGroupPauseObservable = new Observable,
  56151. this.onAnimationGroupPlayObservable = new Observable,
  56152. this.metadata = null,
  56153. this._scene = i || EngineStore.LastCreatedScene,
  56154. this.uniqueId = this._scene.getUniqueId(),
  56155. this._scene.addAnimationGroup(this)
  56156. }
  56157. return Object.defineProperty(a.prototype, "from", {
  56158. get: function() {
  56159. return this._from
  56160. },
  56161. enumerable: !1,
  56162. configurable: !0
  56163. }),
  56164. Object.defineProperty(a.prototype, "to", {
  56165. get: function() {
  56166. return this._to
  56167. },
  56168. enumerable: !1,
  56169. configurable: !0
  56170. }),
  56171. Object.defineProperty(a.prototype, "isStarted", {
  56172. get: function() {
  56173. return this._isStarted
  56174. },
  56175. enumerable: !1,
  56176. configurable: !0
  56177. }),
  56178. Object.defineProperty(a.prototype, "isPlaying", {
  56179. get: function() {
  56180. return this._isStarted && !this._isPaused
  56181. },
  56182. enumerable: !1,
  56183. configurable: !0
  56184. }),
  56185. Object.defineProperty(a.prototype, "speedRatio", {
  56186. get: function() {
  56187. return this._speedRatio
  56188. },
  56189. set: function(e) {
  56190. if (this._speedRatio !== e) {
  56191. this._speedRatio = e;
  56192. for (var i = 0; i < this._animatables.length; i++) {
  56193. var o = this._animatables[i];
  56194. o.speedRatio = this._speedRatio
  56195. }
  56196. }
  56197. },
  56198. enumerable: !1,
  56199. configurable: !0
  56200. }),
  56201. Object.defineProperty(a.prototype, "loopAnimation", {
  56202. get: function() {
  56203. return this._loopAnimation
  56204. },
  56205. set: function(e) {
  56206. if (this._loopAnimation !== e) {
  56207. this._loopAnimation = e;
  56208. for (var i = 0; i < this._animatables.length; i++) {
  56209. var o = this._animatables[i];
  56210. o.loopAnimation = this._loopAnimation
  56211. }
  56212. }
  56213. },
  56214. enumerable: !1,
  56215. configurable: !0
  56216. }),
  56217. Object.defineProperty(a.prototype, "isAdditive", {
  56218. get: function() {
  56219. return this._isAdditive
  56220. },
  56221. set: function(e) {
  56222. if (this._isAdditive !== e) {
  56223. this._isAdditive = e;
  56224. for (var i = 0; i < this._animatables.length; i++) {
  56225. var o = this._animatables[i];
  56226. o.isAdditive = this._isAdditive
  56227. }
  56228. }
  56229. },
  56230. enumerable: !1,
  56231. configurable: !0
  56232. }),
  56233. Object.defineProperty(a.prototype, "targetedAnimations", {
  56234. get: function() {
  56235. return this._targetedAnimations
  56236. },
  56237. enumerable: !1,
  56238. configurable: !0
  56239. }),
  56240. Object.defineProperty(a.prototype, "animatables", {
  56241. get: function() {
  56242. return this._animatables
  56243. },
  56244. enumerable: !1,
  56245. configurable: !0
  56246. }),
  56247. Object.defineProperty(a.prototype, "children", {
  56248. get: function() {
  56249. return this._targetedAnimations
  56250. },
  56251. enumerable: !1,
  56252. configurable: !0
  56253. }),
  56254. a.prototype.addTargetedAnimation = function(e, i) {
  56255. var o = new TargetedAnimation;
  56256. o.animation = e,
  56257. o.target = i;
  56258. var s = e.getKeys();
  56259. return this._from > s[0].frame && (this._from = s[0].frame),
  56260. this._to < s[s.length - 1].frame && (this._to = s[s.length - 1].frame),
  56261. this._targetedAnimations.push(o),
  56262. o
  56263. }
  56264. ,
  56265. a.prototype.normalize = function(e, i) {
  56266. e === void 0 && (e = null),
  56267. i === void 0 && (i = null),
  56268. e == null && (e = this._from),
  56269. i == null && (i = this._to);
  56270. for (var o = 0; o < this._targetedAnimations.length; o++) {
  56271. var s = this._targetedAnimations[o]
  56272. , c = s.animation.getKeys()
  56273. , d = c[0]
  56274. , _ = c[c.length - 1];
  56275. if (d.frame > e) {
  56276. var b = {
  56277. frame: e,
  56278. value: d.value,
  56279. inTangent: d.inTangent,
  56280. outTangent: d.outTangent,
  56281. interpolation: d.interpolation
  56282. };
  56283. c.splice(0, 0, b)
  56284. }
  56285. if (_.frame < i) {
  56286. var b = {
  56287. frame: i,
  56288. value: _.value,
  56289. inTangent: _.inTangent,
  56290. outTangent: _.outTangent,
  56291. interpolation: _.interpolation
  56292. };
  56293. c.push(b)
  56294. }
  56295. }
  56296. return this._from = e,
  56297. this._to = i,
  56298. this
  56299. }
  56300. ,
  56301. a.prototype._processLoop = function(e, i, o) {
  56302. var s = this;
  56303. e.onAnimationLoop = function() {
  56304. s.onAnimationLoopObservable.notifyObservers(i),
  56305. !s._animationLoopFlags[o] && (s._animationLoopFlags[o] = !0,
  56306. s._animationLoopCount++,
  56307. s._animationLoopCount === s._targetedAnimations.length && (s.onAnimationGroupLoopObservable.notifyObservers(s),
  56308. s._animationLoopCount = 0,
  56309. s._animationLoopFlags = []))
  56310. }
  56311. }
  56312. ,
  56313. a.prototype.start = function(e, i, o, s, c) {
  56314. var d = this;
  56315. if (e === void 0 && (e = !1),
  56316. i === void 0 && (i = 1),
  56317. this._isStarted || this._targetedAnimations.length === 0)
  56318. return this;
  56319. this._loopAnimation = e,
  56320. this._animationLoopCount = 0,
  56321. this._animationLoopFlags = [];
  56322. for (var _ = function() {
  56323. var j = b._targetedAnimations[k]
  56324. , $ = b._scene.beginDirectAnimation(j.target, [j.animation], o !== void 0 ? o : b._from, s !== void 0 ? s : b._to, e, i, void 0, void 0, c !== void 0 ? c : b._isAdditive);
  56325. $.onAnimationEnd = function() {
  56326. d.onAnimationEndObservable.notifyObservers(j),
  56327. d._checkAnimationGroupEnded($)
  56328. }
  56329. ,
  56330. b._processLoop($, j, k),
  56331. b._animatables.push($)
  56332. }, b = this, k = 0; k < this._targetedAnimations.length; k++)
  56333. _();
  56334. return this._speedRatio = i,
  56335. this._isStarted = !0,
  56336. this._isPaused = !1,
  56337. this.onAnimationGroupPlayObservable.notifyObservers(this),
  56338. this
  56339. }
  56340. ,
  56341. a.prototype.pause = function() {
  56342. if (!this._isStarted)
  56343. return this;
  56344. this._isPaused = !0;
  56345. for (var e = 0; e < this._animatables.length; e++) {
  56346. var i = this._animatables[e];
  56347. i.pause()
  56348. }
  56349. return this.onAnimationGroupPauseObservable.notifyObservers(this),
  56350. this
  56351. }
  56352. ,
  56353. a.prototype.play = function(e) {
  56354. return this.isStarted && this._animatables.length === this._targetedAnimations.length ? (e !== void 0 && (this.loopAnimation = e),
  56355. this.restart()) : (this.stop(),
  56356. this.start(e, this._speedRatio)),
  56357. this._isPaused = !1,
  56358. this
  56359. }
  56360. ,
  56361. a.prototype.reset = function() {
  56362. if (!this._isStarted)
  56363. return this.play(),
  56364. this.goToFrame(0),
  56365. this.stop(),
  56366. this;
  56367. for (var e = 0; e < this._animatables.length; e++) {
  56368. var i = this._animatables[e];
  56369. i.reset()
  56370. }
  56371. return this
  56372. }
  56373. ,
  56374. a.prototype.restart = function() {
  56375. if (!this._isStarted)
  56376. return this;
  56377. for (var e = 0; e < this._animatables.length; e++) {
  56378. var i = this._animatables[e];
  56379. i.restart()
  56380. }
  56381. return this.onAnimationGroupPlayObservable.notifyObservers(this),
  56382. this
  56383. }
  56384. ,
  56385. a.prototype.stop = function() {
  56386. if (!this._isStarted)
  56387. return this;
  56388. for (var e = this._animatables.slice(), i = 0; i < e.length; i++)
  56389. e[i].stop();
  56390. return this._isStarted = !1,
  56391. this
  56392. }
  56393. ,
  56394. a.prototype.setWeightForAllAnimatables = function(e) {
  56395. for (var i = 0; i < this._animatables.length; i++) {
  56396. var o = this._animatables[i];
  56397. o.weight = e
  56398. }
  56399. return this
  56400. }
  56401. ,
  56402. a.prototype.syncAllAnimationsWith = function(e) {
  56403. for (var i = 0; i < this._animatables.length; i++) {
  56404. var o = this._animatables[i];
  56405. o.syncWith(e)
  56406. }
  56407. return this
  56408. }
  56409. ,
  56410. a.prototype.goToFrame = function(e) {
  56411. if (!this._isStarted)
  56412. return this;
  56413. for (var i = 0; i < this._animatables.length; i++) {
  56414. var o = this._animatables[i];
  56415. o.goToFrame(e)
  56416. }
  56417. return this
  56418. }
  56419. ,
  56420. a.prototype.dispose = function() {
  56421. this._targetedAnimations = [],
  56422. this._animatables = [];
  56423. var e = this._scene.animationGroups.indexOf(this);
  56424. if (e > -1 && this._scene.animationGroups.splice(e, 1),
  56425. this._parentContainer) {
  56426. var i = this._parentContainer.animationGroups.indexOf(this);
  56427. i > -1 && this._parentContainer.animationGroups.splice(i, 1),
  56428. this._parentContainer = null
  56429. }
  56430. this.onAnimationEndObservable.clear(),
  56431. this.onAnimationGroupEndObservable.clear(),
  56432. this.onAnimationGroupPauseObservable.clear(),
  56433. this.onAnimationGroupPlayObservable.clear(),
  56434. this.onAnimationLoopObservable.clear(),
  56435. this.onAnimationGroupLoopObservable.clear()
  56436. }
  56437. ,
  56438. a.prototype._checkAnimationGroupEnded = function(e) {
  56439. var i = this._animatables.indexOf(e);
  56440. i > -1 && this._animatables.splice(i, 1),
  56441. this._animatables.length === 0 && (this._isStarted = !1,
  56442. this.onAnimationGroupEndObservable.notifyObservers(this))
  56443. }
  56444. ,
  56445. a.prototype.clone = function(e, i, o) {
  56446. o === void 0 && (o = !1);
  56447. for (var s = new a(e || this.name,this._scene), c = 0, d = this._targetedAnimations; c < d.length; c++) {
  56448. var _ = d[c];
  56449. s.addTargetedAnimation(o ? _.animation.clone() : _.animation, i ? i(_.target) : _.target)
  56450. }
  56451. return s
  56452. }
  56453. ,
  56454. a.prototype.serialize = function() {
  56455. var e = {};
  56456. e.name = this.name,
  56457. e.from = this.from,
  56458. e.to = this.to,
  56459. e.targetedAnimations = [];
  56460. for (var i = 0; i < this.targetedAnimations.length; i++) {
  56461. var o = this.targetedAnimations[i];
  56462. e.targetedAnimations[i] = o.serialize()
  56463. }
  56464. return Tags && Tags.HasTags(this) && (e.tags = Tags.GetTags(this)),
  56465. this.metadata && (e.metadata = this.metadata),
  56466. e
  56467. }
  56468. ,
  56469. a.Parse = function(e, i) {
  56470. for (var o = new a(e.name,i), s = 0; s < e.targetedAnimations.length; s++) {
  56471. var c = e.targetedAnimations[s]
  56472. , d = Animation.Parse(c.animation)
  56473. , _ = c.targetId;
  56474. if (c.animation.property === "influence") {
  56475. var b = i.getMorphTargetById(_);
  56476. b && o.addTargetedAnimation(d, b)
  56477. } else {
  56478. var k = i.getNodeById(_);
  56479. k != null && o.addTargetedAnimation(d, k)
  56480. }
  56481. }
  56482. return e.from !== null && e.to !== null && o.normalize(e.from, e.to),
  56483. Tags && Tags.AddTagsTo(o, e.tags),
  56484. e.metadata !== void 0 && (o.metadata = e.metadata),
  56485. o
  56486. }
  56487. ,
  56488. a.MakeAnimationAdditive = function(e, i, o, s, c) {
  56489. i === void 0 && (i = 0),
  56490. s === void 0 && (s = !1);
  56491. var d = e;
  56492. s && (d = e.clone(c || d.name));
  56493. for (var _ = d.targetedAnimations, b = 0; b < _.length; b++) {
  56494. var k = _[b];
  56495. Animation.MakeAnimationAdditive(k.animation, i, o)
  56496. }
  56497. return d.isAdditive = !0,
  56498. d
  56499. }
  56500. ,
  56501. a.prototype.getClassName = function() {
  56502. return "AnimationGroup"
  56503. }
  56504. ,
  56505. a.prototype.toString = function(e) {
  56506. var i = "Name: " + this.name;
  56507. return i += ", type: " + this.getClassName(),
  56508. e && (i += ", from: " + this._from,
  56509. i += ", to: " + this._to,
  56510. i += ", isStarted: " + this._isStarted,
  56511. i += ", speedRatio: " + this._speedRatio,
  56512. i += ", targetedAnimations length: " + this._targetedAnimations.length,
  56513. i += ", animatables length: " + this._animatables),
  56514. i
  56515. }
  56516. ,
  56517. a
  56518. }()
  56519. , RawTexture = function(a) {
  56520. __extends(e, a);
  56521. function e(i, o, s, c, d, _, b, k, j, $) {
  56522. _ === void 0 && (_ = !0),
  56523. b === void 0 && (b = !1),
  56524. k === void 0 && (k = 3),
  56525. j === void 0 && (j = 0);
  56526. var _e = a.call(this, null, d, !_, b, void 0, void 0, void 0, void 0, void 0, void 0, void 0, void 0, $) || this;
  56527. return _e.format = c,
  56528. _e._engine && (!_e._engine._caps.textureFloatLinearFiltering && j === 1 && (k = 1),
  56529. !_e._engine._caps.textureHalfFloatLinearFiltering && j === 2 && (k = 1),
  56530. _e._texture = _e._engine.createRawTexture(i, o, s, c, _, b, k, null, j, $ != null ? $ : 0),
  56531. _e.wrapU = Texture.CLAMP_ADDRESSMODE,
  56532. _e.wrapV = Texture.CLAMP_ADDRESSMODE),
  56533. _e
  56534. }
  56535. return e.prototype.update = function(i) {
  56536. this._getEngine().updateRawTexture(this._texture, i, this._texture.format, this._texture.invertY, null, this._texture.type)
  56537. }
  56538. ,
  56539. e.CreateLuminanceTexture = function(i, o, s, c, d, _, b) {
  56540. return d === void 0 && (d = !0),
  56541. _ === void 0 && (_ = !1),
  56542. b === void 0 && (b = 3),
  56543. new e(i,o,s,1,c,d,_,b)
  56544. }
  56545. ,
  56546. e.CreateLuminanceAlphaTexture = function(i, o, s, c, d, _, b) {
  56547. return d === void 0 && (d = !0),
  56548. _ === void 0 && (_ = !1),
  56549. b === void 0 && (b = 3),
  56550. new e(i,o,s,2,c,d,_,b)
  56551. }
  56552. ,
  56553. e.CreateAlphaTexture = function(i, o, s, c, d, _, b) {
  56554. return d === void 0 && (d = !0),
  56555. _ === void 0 && (_ = !1),
  56556. b === void 0 && (b = 3),
  56557. new e(i,o,s,0,c,d,_,b)
  56558. }
  56559. ,
  56560. e.CreateRGBTexture = function(i, o, s, c, d, _, b, k) {
  56561. return d === void 0 && (d = !0),
  56562. _ === void 0 && (_ = !1),
  56563. b === void 0 && (b = 3),
  56564. k === void 0 && (k = 0),
  56565. new e(i,o,s,4,c,d,_,b,k)
  56566. }
  56567. ,
  56568. e.CreateRGBATexture = function(i, o, s, c, d, _, b, k) {
  56569. return d === void 0 && (d = !0),
  56570. _ === void 0 && (_ = !1),
  56571. b === void 0 && (b = 3),
  56572. k === void 0 && (k = 0),
  56573. new e(i,o,s,5,c,d,_,b,k)
  56574. }
  56575. ,
  56576. e.CreateRGBAStorageTexture = function(i, o, s, c, d, _, b, k) {
  56577. return d === void 0 && (d = !0),
  56578. _ === void 0 && (_ = !1),
  56579. b === void 0 && (b = 3),
  56580. k === void 0 && (k = 0),
  56581. new e(i,o,s,5,c,d,_,b,k,1)
  56582. }
  56583. ,
  56584. e.CreateRTexture = function(i, o, s, c, d, _, b, k) {
  56585. return d === void 0 && (d = !0),
  56586. _ === void 0 && (_ = !1),
  56587. b === void 0 && (b = Texture.TRILINEAR_SAMPLINGMODE),
  56588. k === void 0 && (k = 1),
  56589. new e(i,o,s,6,c,d,_,b,k)
  56590. }
  56591. ,
  56592. e.CreateRStorageTexture = function(i, o, s, c, d, _, b, k) {
  56593. return d === void 0 && (d = !0),
  56594. _ === void 0 && (_ = !1),
  56595. b === void 0 && (b = Texture.TRILINEAR_SAMPLINGMODE),
  56596. k === void 0 && (k = 1),
  56597. new e(i,o,s,6,c,d,_,b,k,1)
  56598. }
  56599. ,
  56600. e
  56601. }(Texture)
  56602. , Skeleton = function() {
  56603. function a(e, i, o) {
  56604. this.name = e,
  56605. this.id = i,
  56606. this.bones = new Array,
  56607. this.needInitialSkinMatrix = !1,
  56608. this.overrideMesh = null,
  56609. this._isDirty = !0,
  56610. this._meshesWithPoseMatrix = new Array,
  56611. this._identity = Matrix.Identity(),
  56612. this._ranges = {},
  56613. this._lastAbsoluteTransformsUpdateId = -1,
  56614. this._canUseTextureForBones = !1,
  56615. this._uniqueId = 0,
  56616. this._numBonesWithLinkedTransformNode = 0,
  56617. this._hasWaitingData = null,
  56618. this._waitingOverrideMeshId = null,
  56619. this._parentContainer = null,
  56620. this.doNotSerialize = !1,
  56621. this._useTextureToStoreBoneMatrices = !0,
  56622. this._animationPropertiesOverride = null,
  56623. this.onBeforeComputeObservable = new Observable,
  56624. this.bones = [],
  56625. this._scene = o || EngineStore.LastCreatedScene,
  56626. this._uniqueId = this._scene.getUniqueId(),
  56627. this._scene.addSkeleton(this),
  56628. this._isDirty = !0;
  56629. var s = this._scene.getEngine().getCaps();
  56630. this._canUseTextureForBones = s.textureFloat && s.maxVertexTextureImageUnits > 0
  56631. }
  56632. return Object.defineProperty(a.prototype, "useTextureToStoreBoneMatrices", {
  56633. get: function() {
  56634. return this._useTextureToStoreBoneMatrices
  56635. },
  56636. set: function(e) {
  56637. this._useTextureToStoreBoneMatrices = e,
  56638. this._markAsDirty()
  56639. },
  56640. enumerable: !1,
  56641. configurable: !0
  56642. }),
  56643. Object.defineProperty(a.prototype, "animationPropertiesOverride", {
  56644. get: function() {
  56645. return this._animationPropertiesOverride ? this._animationPropertiesOverride : this._scene.animationPropertiesOverride
  56646. },
  56647. set: function(e) {
  56648. this._animationPropertiesOverride = e
  56649. },
  56650. enumerable: !1,
  56651. configurable: !0
  56652. }),
  56653. Object.defineProperty(a.prototype, "isUsingTextureForMatrices", {
  56654. get: function() {
  56655. return this.useTextureToStoreBoneMatrices && this._canUseTextureForBones
  56656. },
  56657. enumerable: !1,
  56658. configurable: !0
  56659. }),
  56660. Object.defineProperty(a.prototype, "uniqueId", {
  56661. get: function() {
  56662. return this._uniqueId
  56663. },
  56664. enumerable: !1,
  56665. configurable: !0
  56666. }),
  56667. a.prototype.getClassName = function() {
  56668. return "Skeleton"
  56669. }
  56670. ,
  56671. a.prototype.getChildren = function() {
  56672. return this.bones.filter(function(e) {
  56673. return !e.getParent()
  56674. })
  56675. }
  56676. ,
  56677. a.prototype.getTransformMatrices = function(e) {
  56678. return this.needInitialSkinMatrix && e._bonesTransformMatrices ? e._bonesTransformMatrices : (this._transformMatrices || this.prepare(),
  56679. this._transformMatrices)
  56680. }
  56681. ,
  56682. a.prototype.getTransformMatrixTexture = function(e) {
  56683. return this.needInitialSkinMatrix && e._transformMatrixTexture ? e._transformMatrixTexture : this._transformMatrixTexture
  56684. }
  56685. ,
  56686. a.prototype.getScene = function() {
  56687. return this._scene
  56688. }
  56689. ,
  56690. a.prototype.toString = function(e) {
  56691. var i = "Name: " + this.name + ", nBones: " + this.bones.length;
  56692. if (i += ", nAnimationRanges: " + (this._ranges ? Object.keys(this._ranges).length : "none"),
  56693. e) {
  56694. i += ", Ranges: {";
  56695. var o = !0;
  56696. for (var s in this._ranges)
  56697. o && (i += ", ",
  56698. o = !1),
  56699. i += s;
  56700. i += "}"
  56701. }
  56702. return i
  56703. }
  56704. ,
  56705. a.prototype.getBoneIndexByName = function(e) {
  56706. for (var i = 0, o = this.bones.length; i < o; i++)
  56707. if (this.bones[i].name === e)
  56708. return i;
  56709. return -1
  56710. }
  56711. ,
  56712. a.prototype.createAnimationRange = function(e, i, o) {
  56713. if (!this._ranges[e]) {
  56714. this._ranges[e] = new AnimationRange(e,i,o);
  56715. for (var s = 0, c = this.bones.length; s < c; s++)
  56716. this.bones[s].animations[0] && this.bones[s].animations[0].createRange(e, i, o)
  56717. }
  56718. }
  56719. ,
  56720. a.prototype.deleteAnimationRange = function(e, i) {
  56721. i === void 0 && (i = !0);
  56722. for (var o = 0, s = this.bones.length; o < s; o++)
  56723. this.bones[o].animations[0] && this.bones[o].animations[0].deleteRange(e, i);
  56724. this._ranges[e] = null
  56725. }
  56726. ,
  56727. a.prototype.getAnimationRange = function(e) {
  56728. return this._ranges[e] || null
  56729. }
  56730. ,
  56731. a.prototype.getAnimationRanges = function() {
  56732. var e = [], i;
  56733. for (i in this._ranges)
  56734. e.push(this._ranges[i]);
  56735. return e
  56736. }
  56737. ,
  56738. a.prototype.copyAnimationRange = function(e, i, o) {
  56739. if (o === void 0 && (o = !1),
  56740. this._ranges[i] || !e.getAnimationRange(i))
  56741. return !1;
  56742. var s = !0, c = this._getHighestAnimationFrame() + 1, d = {}, _ = e.bones, b, k;
  56743. for (k = 0,
  56744. b = _.length; k < b; k++)
  56745. d[_[k].name] = _[k];
  56746. this.bones.length !== _.length && (Logger$2.Warn("copyAnimationRange: this rig has " + this.bones.length + " bones, while source as " + _.length),
  56747. s = !1);
  56748. var j = o && this.dimensionsAtRest && e.dimensionsAtRest ? this.dimensionsAtRest.divide(e.dimensionsAtRest) : null;
  56749. for (k = 0,
  56750. b = this.bones.length; k < b; k++) {
  56751. var $ = this.bones[k].name
  56752. , _e = d[$];
  56753. _e ? s = s && this.bones[k].copyAnimationRange(_e, i, c, o, j) : (Logger$2.Warn("copyAnimationRange: not same rig, missing source bone " + $),
  56754. s = !1)
  56755. }
  56756. var et = e.getAnimationRange(i);
  56757. return et && (this._ranges[i] = new AnimationRange(i,et.from + c,et.to + c)),
  56758. s
  56759. }
  56760. ,
  56761. a.prototype.returnToRest = function() {
  56762. for (var e = 0, i = this.bones; e < i.length; e++) {
  56763. var o = i[e];
  56764. o._index !== -1 && o.returnToRest()
  56765. }
  56766. }
  56767. ,
  56768. a.prototype._getHighestAnimationFrame = function() {
  56769. for (var e = 0, i = 0, o = this.bones.length; i < o; i++)
  56770. if (this.bones[i].animations[0]) {
  56771. var s = this.bones[i].animations[0].getHighestFrame();
  56772. e < s && (e = s)
  56773. }
  56774. return e
  56775. }
  56776. ,
  56777. a.prototype.beginAnimation = function(e, i, o, s) {
  56778. var c = this.getAnimationRange(e);
  56779. return c ? this._scene.beginAnimation(this, c.from, c.to, i, o, s) : null
  56780. }
  56781. ,
  56782. a.MakeAnimationAdditive = function(e, i, o) {
  56783. i === void 0 && (i = 0);
  56784. var s = e.getAnimationRange(o);
  56785. if (!s)
  56786. return null;
  56787. for (var c = e._scene.getAllAnimatablesByTarget(e), d = null, _ = 0; _ < c.length; _++) {
  56788. var b = c[_];
  56789. if (b.fromFrame === (s == null ? void 0 : s.from) && b.toFrame === (s == null ? void 0 : s.to)) {
  56790. d = b;
  56791. break
  56792. }
  56793. }
  56794. for (var k = e.getAnimatables(), _ = 0; _ < k.length; _++) {
  56795. var j = k[_]
  56796. , $ = j.animations;
  56797. if (!!$)
  56798. for (var _e = 0; _e < $.length; _e++)
  56799. Animation.MakeAnimationAdditive($[_e], i, o)
  56800. }
  56801. return d && (d.isAdditive = !0),
  56802. e
  56803. }
  56804. ,
  56805. a.prototype._markAsDirty = function() {
  56806. this._isDirty = !0
  56807. }
  56808. ,
  56809. a.prototype._registerMeshWithPoseMatrix = function(e) {
  56810. this._meshesWithPoseMatrix.push(e)
  56811. }
  56812. ,
  56813. a.prototype._unregisterMeshWithPoseMatrix = function(e) {
  56814. var i = this._meshesWithPoseMatrix.indexOf(e);
  56815. i > -1 && this._meshesWithPoseMatrix.splice(i, 1)
  56816. }
  56817. ,
  56818. a.prototype._computeTransformMatrices = function(e, i) {
  56819. this.onBeforeComputeObservable.notifyObservers(this);
  56820. for (var o = 0; o < this.bones.length; o++) {
  56821. var s = this.bones[o];
  56822. s._childUpdateId++;
  56823. var c = s.getParent();
  56824. if (c ? s.getLocalMatrix().multiplyToRef(c.getWorldMatrix(), s.getWorldMatrix()) : i ? s.getLocalMatrix().multiplyToRef(i, s.getWorldMatrix()) : s.getWorldMatrix().copyFrom(s.getLocalMatrix()),
  56825. s._index !== -1) {
  56826. var d = s._index === null ? o : s._index;
  56827. s.getInvertedAbsoluteTransform().multiplyToArray(s.getWorldMatrix(), e, d * 16)
  56828. }
  56829. }
  56830. this._identity.copyToArray(e, this.bones.length * 16)
  56831. }
  56832. ,
  56833. a.prototype.prepare = function() {
  56834. if (this._numBonesWithLinkedTransformNode > 0)
  56835. for (var e = 0, i = this.bones; e < i.length; e++) {
  56836. var o = i[e];
  56837. o._linkedTransformNode && (o._linkedTransformNode.computeWorldMatrix(),
  56838. o._matrix = o._linkedTransformNode._localMatrix)
  56839. }
  56840. if (!!this._isDirty) {
  56841. if (this.needInitialSkinMatrix)
  56842. for (var s = 0; s < this._meshesWithPoseMatrix.length; s++) {
  56843. var c = this._meshesWithPoseMatrix[s]
  56844. , d = c.getPoseMatrix();
  56845. if ((!c._bonesTransformMatrices || c._bonesTransformMatrices.length !== 16 * (this.bones.length + 1)) && (c._bonesTransformMatrices = new Float32Array(16 * (this.bones.length + 1))),
  56846. this._synchronizedWithMesh !== c) {
  56847. this._synchronizedWithMesh = c;
  56848. for (var _ = 0; _ < this.bones.length; _++) {
  56849. var b = this.bones[_];
  56850. if (!b.getParent()) {
  56851. var k = b.getBaseMatrix();
  56852. k.multiplyToRef(d, TmpVectors.Matrix[1]),
  56853. b._updateDifferenceMatrix(TmpVectors.Matrix[1])
  56854. }
  56855. }
  56856. if (this.isUsingTextureForMatrices) {
  56857. var j = (this.bones.length + 1) * 4;
  56858. (!c._transformMatrixTexture || c._transformMatrixTexture.getSize().width !== j) && (c._transformMatrixTexture && c._transformMatrixTexture.dispose(),
  56859. c._transformMatrixTexture = RawTexture.CreateRGBATexture(c._bonesTransformMatrices, (this.bones.length + 1) * 4, 1, this._scene, !1, !1, 1, 1))
  56860. }
  56861. }
  56862. this._computeTransformMatrices(c._bonesTransformMatrices, d),
  56863. this.isUsingTextureForMatrices && c._transformMatrixTexture && c._transformMatrixTexture.update(c._bonesTransformMatrices)
  56864. }
  56865. else
  56866. (!this._transformMatrices || this._transformMatrices.length !== 16 * (this.bones.length + 1)) && (this._transformMatrices = new Float32Array(16 * (this.bones.length + 1)),
  56867. this.isUsingTextureForMatrices && (this._transformMatrixTexture && this._transformMatrixTexture.dispose(),
  56868. this._transformMatrixTexture = RawTexture.CreateRGBATexture(this._transformMatrices, (this.bones.length + 1) * 4, 1, this._scene, !1, !1, 1, 1))),
  56869. this._computeTransformMatrices(this._transformMatrices, null),
  56870. this.isUsingTextureForMatrices && this._transformMatrixTexture && this._transformMatrixTexture.update(this._transformMatrices);
  56871. this._isDirty = !1,
  56872. this._scene._activeBones.addCount(this.bones.length, !1)
  56873. }
  56874. }
  56875. ,
  56876. a.prototype.getAnimatables = function() {
  56877. if (!this._animatables || this._animatables.length !== this.bones.length) {
  56878. this._animatables = [];
  56879. for (var e = 0; e < this.bones.length; e++)
  56880. this._animatables.push(this.bones[e])
  56881. }
  56882. return this._animatables
  56883. }
  56884. ,
  56885. a.prototype.clone = function(e, i) {
  56886. var o = new a(e,i || e,this._scene);
  56887. o.needInitialSkinMatrix = this.needInitialSkinMatrix,
  56888. o.overrideMesh = this.overrideMesh;
  56889. for (var s = 0; s < this.bones.length; s++) {
  56890. var c = this.bones[s]
  56891. , d = null
  56892. , _ = c.getParent();
  56893. if (_) {
  56894. var b = this.bones.indexOf(_);
  56895. d = o.bones[b]
  56896. }
  56897. var k = new Bone(c.name,o,d,c.getBaseMatrix().clone(),c.getRestPose().clone());
  56898. k._index = c._index,
  56899. c._linkedTransformNode && k.linkTransformNode(c._linkedTransformNode),
  56900. DeepCopier.DeepCopy(c.animations, k.animations)
  56901. }
  56902. if (this._ranges) {
  56903. o._ranges = {};
  56904. for (var j in this._ranges) {
  56905. var $ = this._ranges[j];
  56906. $ && (o._ranges[j] = $.clone())
  56907. }
  56908. }
  56909. return this._isDirty = !0,
  56910. o
  56911. }
  56912. ,
  56913. a.prototype.enableBlending = function(e) {
  56914. e === void 0 && (e = .01),
  56915. this.bones.forEach(function(i) {
  56916. i.animations.forEach(function(o) {
  56917. o.enableBlending = !0,
  56918. o.blendingSpeed = e
  56919. })
  56920. })
  56921. }
  56922. ,
  56923. a.prototype.dispose = function() {
  56924. if (this._meshesWithPoseMatrix = [],
  56925. this.getScene().stopAnimation(this),
  56926. this.getScene().removeSkeleton(this),
  56927. this._parentContainer) {
  56928. var e = this._parentContainer.skeletons.indexOf(this);
  56929. e > -1 && this._parentContainer.skeletons.splice(e, 1),
  56930. this._parentContainer = null
  56931. }
  56932. this._transformMatrixTexture && (this._transformMatrixTexture.dispose(),
  56933. this._transformMatrixTexture = null)
  56934. }
  56935. ,
  56936. a.prototype.serialize = function() {
  56937. var e, i, o = {};
  56938. o.name = this.name,
  56939. o.id = this.id,
  56940. this.dimensionsAtRest && (o.dimensionsAtRest = this.dimensionsAtRest.asArray()),
  56941. o.bones = [],
  56942. o.needInitialSkinMatrix = this.needInitialSkinMatrix,
  56943. o.overrideMeshId = (e = this.overrideMesh) === null || e === void 0 ? void 0 : e.id;
  56944. for (var s = 0; s < this.bones.length; s++) {
  56945. var c = this.bones[s]
  56946. , d = c.getParent()
  56947. , _ = {
  56948. parentBoneIndex: d ? this.bones.indexOf(d) : -1,
  56949. index: c.getIndex(),
  56950. name: c.name,
  56951. id: c.id,
  56952. matrix: c.getBaseMatrix().toArray(),
  56953. rest: c.getRestPose().toArray(),
  56954. linkedTransformNodeId: (i = c.getTransformNode()) === null || i === void 0 ? void 0 : i.id
  56955. };
  56956. o.bones.push(_),
  56957. c.length && (_.length = c.length),
  56958. c.metadata && (_.metadata = c.metadata),
  56959. c.animations && c.animations.length > 0 && (_.animation = c.animations[0].serialize()),
  56960. o.ranges = [];
  56961. for (var b in this._ranges) {
  56962. var k = this._ranges[b];
  56963. if (!!k) {
  56964. var j = {};
  56965. j.name = b,
  56966. j.from = k.from,
  56967. j.to = k.to,
  56968. o.ranges.push(j)
  56969. }
  56970. }
  56971. }
  56972. return o
  56973. }
  56974. ,
  56975. a.Parse = function(e, i) {
  56976. var o = new a(e.name,e.id,i);
  56977. e.dimensionsAtRest && (o.dimensionsAtRest = Vector3.FromArray(e.dimensionsAtRest)),
  56978. o.needInitialSkinMatrix = e.needInitialSkinMatrix,
  56979. e.overrideMeshId && (o._hasWaitingData = !0,
  56980. o._waitingOverrideMeshId = e.overrideMeshId);
  56981. var s;
  56982. for (s = 0; s < e.bones.length; s++) {
  56983. var c = e.bones[s]
  56984. , d = e.bones[s].index
  56985. , _ = null;
  56986. c.parentBoneIndex > -1 && (_ = o.bones[c.parentBoneIndex]);
  56987. var b = c.rest ? Matrix.FromArray(c.rest) : null
  56988. , k = new Bone(c.name,o,_,Matrix.FromArray(c.matrix),b,null,d);
  56989. c.id !== void 0 && c.id !== null && (k.id = c.id),
  56990. c.length && (k.length = c.length),
  56991. c.metadata && (k.metadata = c.metadata),
  56992. c.animation && k.animations.push(Animation.Parse(c.animation)),
  56993. c.linkedTransformNodeId !== void 0 && c.linkedTransformNodeId !== null && (o._hasWaitingData = !0,
  56994. k._waitingTransformNodeId = c.linkedTransformNodeId)
  56995. }
  56996. if (e.ranges)
  56997. for (s = 0; s < e.ranges.length; s++) {
  56998. var j = e.ranges[s];
  56999. o.createAnimationRange(j.name, j.from, j.to)
  57000. }
  57001. return o
  57002. }
  57003. ,
  57004. a.prototype.computeAbsoluteTransforms = function(e) {
  57005. e === void 0 && (e = !1);
  57006. var i = this._scene.getRenderId();
  57007. (this._lastAbsoluteTransformsUpdateId != i || e) && (this.bones[0].computeAbsoluteTransforms(),
  57008. this._lastAbsoluteTransformsUpdateId = i)
  57009. }
  57010. ,
  57011. a.prototype.getPoseMatrix = function() {
  57012. var e = null;
  57013. return this._meshesWithPoseMatrix.length > 0 && (e = this._meshesWithPoseMatrix[0].getPoseMatrix()),
  57014. e
  57015. }
  57016. ,
  57017. a.prototype.sortBones = function() {
  57018. for (var e = new Array, i = new Array(this.bones.length), o = 0; o < this.bones.length; o++)
  57019. this._sortBones(o, e, i);
  57020. this.bones = e
  57021. }
  57022. ,
  57023. a.prototype._sortBones = function(e, i, o) {
  57024. if (!o[e]) {
  57025. o[e] = !0;
  57026. var s = this.bones[e];
  57027. s._index === void 0 && (s._index = e);
  57028. var c = s.getParent();
  57029. c && this._sortBones(this.bones.indexOf(c), i, o),
  57030. i.push(s)
  57031. }
  57032. }
  57033. ,
  57034. a.prototype.setCurrentPoseAsRest = function() {
  57035. this.bones.forEach(function(e) {
  57036. e.setCurrentPoseAsRest()
  57037. })
  57038. }
  57039. ,
  57040. a
  57041. }()
  57042. , IntersectionInfo = function() {
  57043. function a(e, i, o) {
  57044. this.bu = e,
  57045. this.bv = i,
  57046. this.distance = o,
  57047. this.faceId = 0,
  57048. this.subMeshId = 0
  57049. }
  57050. return a
  57051. }()
  57052. , SubMesh = function() {
  57053. function a(e, i, o, s, c, d, _, b, k) {
  57054. b === void 0 && (b = !0),
  57055. k === void 0 && (k = !0),
  57056. this.materialIndex = e,
  57057. this.verticesStart = i,
  57058. this.verticesCount = o,
  57059. this.indexStart = s,
  57060. this.indexCount = c,
  57061. this._mainDrawWrapperOverride = null,
  57062. this._linesIndexCount = 0,
  57063. this._linesIndexBuffer = null,
  57064. this._lastColliderWorldVertices = null,
  57065. this._lastColliderTransformMatrix = null,
  57066. this._renderId = 0,
  57067. this._alphaIndex = 0,
  57068. this._distanceToCamera = 0,
  57069. this._currentMaterial = null,
  57070. this._mesh = d,
  57071. this._renderingMesh = _ || d,
  57072. k && d.subMeshes.push(this),
  57073. this._engine = this._mesh.getScene().getEngine(),
  57074. this.resetDrawCache(),
  57075. this._trianglePlanes = [],
  57076. this._id = d.subMeshes.length - 1,
  57077. b && (this.refreshBoundingInfo(),
  57078. d.computeWorldMatrix(!0))
  57079. }
  57080. return Object.defineProperty(a.prototype, "materialDefines", {
  57081. get: function() {
  57082. var e;
  57083. return this._mainDrawWrapperOverride ? this._mainDrawWrapperOverride.defines : (e = this._getDrawWrapper()) === null || e === void 0 ? void 0 : e.defines
  57084. },
  57085. set: function(e) {
  57086. var i, o = (i = this._mainDrawWrapperOverride) !== null && i !== void 0 ? i : this._getDrawWrapper(void 0, !0);
  57087. o.defines = e
  57088. },
  57089. enumerable: !1,
  57090. configurable: !0
  57091. }),
  57092. a.prototype._getDrawWrapper = function(e, i) {
  57093. i === void 0 && (i = !1),
  57094. e = e != null ? e : this._engine.currentRenderPassId;
  57095. var o = this._drawWrappers[e];
  57096. return !o && i && (this._drawWrappers[e] = o = new DrawWrapper(this._mesh.getScene().getEngine())),
  57097. o
  57098. }
  57099. ,
  57100. a.prototype._removeDrawWrapper = function(e, i) {
  57101. var o;
  57102. i === void 0 && (i = !0),
  57103. i && ((o = this._drawWrappers[e]) === null || o === void 0 || o.dispose()),
  57104. this._drawWrappers[e] = void 0
  57105. }
  57106. ,
  57107. Object.defineProperty(a.prototype, "effect", {
  57108. get: function() {
  57109. var e, i;
  57110. return this._mainDrawWrapperOverride ? this._mainDrawWrapperOverride.effect : (i = (e = this._getDrawWrapper()) === null || e === void 0 ? void 0 : e.effect) !== null && i !== void 0 ? i : null
  57111. },
  57112. enumerable: !1,
  57113. configurable: !0
  57114. }),
  57115. Object.defineProperty(a.prototype, "_drawWrapper", {
  57116. get: function() {
  57117. var e;
  57118. return (e = this._mainDrawWrapperOverride) !== null && e !== void 0 ? e : this._getDrawWrapper(void 0, !0)
  57119. },
  57120. enumerable: !1,
  57121. configurable: !0
  57122. }),
  57123. Object.defineProperty(a.prototype, "_drawWrapperOverride", {
  57124. get: function() {
  57125. return this._mainDrawWrapperOverride
  57126. },
  57127. enumerable: !1,
  57128. configurable: !0
  57129. }),
  57130. a.prototype._setMainDrawWrapperOverride = function(e) {
  57131. this._mainDrawWrapperOverride = e
  57132. }
  57133. ,
  57134. a.prototype.setEffect = function(e, i, o, s) {
  57135. i === void 0 && (i = null),
  57136. s === void 0 && (s = !0);
  57137. var c = this._drawWrapper;
  57138. c.setEffect(e, i, s),
  57139. o !== void 0 && (c.materialContext = o),
  57140. e || (c.defines = null,
  57141. c.materialContext = void 0)
  57142. }
  57143. ,
  57144. a.prototype.resetDrawCache = function() {
  57145. if (this._drawWrappers)
  57146. for (var e = 0, i = this._drawWrappers; e < i.length; e++) {
  57147. var o = i[e];
  57148. o == null || o.dispose()
  57149. }
  57150. this._drawWrappers = []
  57151. }
  57152. ,
  57153. a.AddToMesh = function(e, i, o, s, c, d, _, b) {
  57154. return b === void 0 && (b = !0),
  57155. new a(e,i,o,s,c,d,_,b)
  57156. }
  57157. ,
  57158. Object.defineProperty(a.prototype, "IsGlobal", {
  57159. get: function() {
  57160. return this.verticesStart === 0 && this.verticesCount === this._mesh.getTotalVertices()
  57161. },
  57162. enumerable: !1,
  57163. configurable: !0
  57164. }),
  57165. a.prototype.getBoundingInfo = function() {
  57166. return this.IsGlobal ? this._mesh.getBoundingInfo() : this._boundingInfo
  57167. }
  57168. ,
  57169. a.prototype.setBoundingInfo = function(e) {
  57170. return this._boundingInfo = e,
  57171. this
  57172. }
  57173. ,
  57174. a.prototype.getMesh = function() {
  57175. return this._mesh
  57176. }
  57177. ,
  57178. a.prototype.getRenderingMesh = function() {
  57179. return this._renderingMesh
  57180. }
  57181. ,
  57182. a.prototype.getReplacementMesh = function() {
  57183. return this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh ? this._mesh : null
  57184. }
  57185. ,
  57186. a.prototype.getEffectiveMesh = function() {
  57187. var e = this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh ? this._mesh : null;
  57188. return e || this._renderingMesh
  57189. }
  57190. ,
  57191. a.prototype.getMaterial = function() {
  57192. var e, i = (e = this._renderingMesh.getMaterialForRenderPass(this._engine.currentRenderPassId)) !== null && e !== void 0 ? e : this._renderingMesh.material;
  57193. if (i == null)
  57194. return this._mesh.getScene().defaultMaterial;
  57195. if (this._IsMultiMaterial(i)) {
  57196. var o = i.getSubMaterial(this.materialIndex);
  57197. return this._currentMaterial !== o && (this._currentMaterial = o,
  57198. this.resetDrawCache()),
  57199. o
  57200. }
  57201. return i
  57202. }
  57203. ,
  57204. a.prototype._IsMultiMaterial = function(e) {
  57205. return e.getSubMaterial !== void 0
  57206. }
  57207. ,
  57208. a.prototype.refreshBoundingInfo = function(e) {
  57209. if (e === void 0 && (e = null),
  57210. this._lastColliderWorldVertices = null,
  57211. this.IsGlobal || !this._renderingMesh || !this._renderingMesh.geometry)
  57212. return this;
  57213. if (e || (e = this._renderingMesh.getVerticesData(VertexBuffer.PositionKind)),
  57214. !e)
  57215. return this._boundingInfo = this._mesh.getBoundingInfo(),
  57216. this;
  57217. var i = this._renderingMesh.getIndices(), o;
  57218. if (this.indexStart === 0 && this.indexCount === i.length) {
  57219. var s = this._renderingMesh.getBoundingInfo();
  57220. o = {
  57221. minimum: s.minimum.clone(),
  57222. maximum: s.maximum.clone()
  57223. }
  57224. } else
  57225. o = extractMinAndMaxIndexed(e, i, this.indexStart, this.indexCount, this._renderingMesh.geometry.boundingBias);
  57226. return this._boundingInfo ? this._boundingInfo.reConstruct(o.minimum, o.maximum) : this._boundingInfo = new BoundingInfo(o.minimum,o.maximum),
  57227. this
  57228. }
  57229. ,
  57230. a.prototype._checkCollision = function(e) {
  57231. var i = this.getBoundingInfo();
  57232. return i._checkCollision(e)
  57233. }
  57234. ,
  57235. a.prototype.updateBoundingInfo = function(e) {
  57236. var i = this.getBoundingInfo();
  57237. return i || (this.refreshBoundingInfo(),
  57238. i = this.getBoundingInfo()),
  57239. i && i.update(e),
  57240. this
  57241. }
  57242. ,
  57243. a.prototype.isInFrustum = function(e) {
  57244. var i = this.getBoundingInfo();
  57245. return i ? i.isInFrustum(e, this._mesh.cullingStrategy) : !1
  57246. }
  57247. ,
  57248. a.prototype.isCompletelyInFrustum = function(e) {
  57249. var i = this.getBoundingInfo();
  57250. return i ? i.isCompletelyInFrustum(e) : !1
  57251. }
  57252. ,
  57253. a.prototype.render = function(e) {
  57254. return this._renderingMesh.render(this, e, this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh ? this._mesh : void 0),
  57255. this
  57256. }
  57257. ,
  57258. a.prototype._getLinesIndexBuffer = function(e, i) {
  57259. if (!this._linesIndexBuffer) {
  57260. for (var o = [], s = this.indexStart; s < this.indexStart + this.indexCount; s += 3)
  57261. o.push(e[s], e[s + 1], e[s + 1], e[s + 2], e[s + 2], e[s]);
  57262. this._linesIndexBuffer = i.createIndexBuffer(o),
  57263. this._linesIndexCount = o.length
  57264. }
  57265. return this._linesIndexBuffer
  57266. }
  57267. ,
  57268. a.prototype.canIntersects = function(e) {
  57269. var i = this.getBoundingInfo();
  57270. return i ? e.intersectsBox(i.boundingBox) : !1
  57271. }
  57272. ,
  57273. a.prototype.intersects = function(e, i, o, s, c) {
  57274. var d = this.getMaterial();
  57275. if (!d)
  57276. return null;
  57277. var _ = 3
  57278. , b = !1;
  57279. switch (d.fillMode) {
  57280. case 3:
  57281. case 4:
  57282. case 5:
  57283. case 6:
  57284. case 8:
  57285. return null;
  57286. case 7:
  57287. _ = 1,
  57288. b = !0;
  57289. break
  57290. }
  57291. return this._mesh.getClassName() === "InstancedLinesMesh" || this._mesh.getClassName() === "LinesMesh" ? o.length ? this._intersectLines(e, i, o, this._mesh.intersectionThreshold, s) : this._intersectUnIndexedLines(e, i, o, this._mesh.intersectionThreshold, s) : !o.length && this._mesh._unIndexed ? this._intersectUnIndexedTriangles(e, i, o, s, c) : this._intersectTriangles(e, i, o, _, b, s, c)
  57292. }
  57293. ,
  57294. a.prototype._intersectLines = function(e, i, o, s, c) {
  57295. for (var d = null, _ = this.indexStart; _ < this.indexStart + this.indexCount; _ += 2) {
  57296. var b = i[o[_]]
  57297. , k = i[o[_ + 1]]
  57298. , j = e.intersectionSegment(b, k, s);
  57299. if (!(j < 0) && (c || !d || j < d.distance) && (d = new IntersectionInfo(null,null,j),
  57300. d.faceId = _ / 2,
  57301. c))
  57302. break
  57303. }
  57304. return d
  57305. }
  57306. ,
  57307. a.prototype._intersectUnIndexedLines = function(e, i, o, s, c) {
  57308. for (var d = null, _ = this.verticesStart; _ < this.verticesStart + this.verticesCount; _ += 2) {
  57309. var b = i[_]
  57310. , k = i[_ + 1]
  57311. , j = e.intersectionSegment(b, k, s);
  57312. if (!(j < 0) && (c || !d || j < d.distance) && (d = new IntersectionInfo(null,null,j),
  57313. d.faceId = _ / 2,
  57314. c))
  57315. break
  57316. }
  57317. return d
  57318. }
  57319. ,
  57320. a.prototype._intersectTriangles = function(e, i, o, s, c, d, _) {
  57321. for (var b = null, k = -1, j = this.indexStart; j < this.indexStart + this.indexCount - (3 - s); j += s) {
  57322. k++;
  57323. var $ = o[j]
  57324. , _e = o[j + 1]
  57325. , et = o[j + 2];
  57326. if (c && et === 4294967295) {
  57327. j += 2;
  57328. continue
  57329. }
  57330. var tt = i[$]
  57331. , rt = i[_e]
  57332. , it = i[et];
  57333. if (!(!tt || !rt || !it) && !(_ && !_(tt, rt, it, e))) {
  57334. var nt = e.intersectsTriangle(tt, rt, it);
  57335. if (nt) {
  57336. if (nt.distance < 0)
  57337. continue;
  57338. if ((d || !b || nt.distance < b.distance) && (b = nt,
  57339. b.faceId = k,
  57340. d))
  57341. break
  57342. }
  57343. }
  57344. }
  57345. return b
  57346. }
  57347. ,
  57348. a.prototype._intersectUnIndexedTriangles = function(e, i, o, s, c) {
  57349. for (var d = null, _ = this.verticesStart; _ < this.verticesStart + this.verticesCount; _ += 3) {
  57350. var b = i[_]
  57351. , k = i[_ + 1]
  57352. , j = i[_ + 2];
  57353. if (!(c && !c(b, k, j, e))) {
  57354. var $ = e.intersectsTriangle(b, k, j);
  57355. if ($) {
  57356. if ($.distance < 0)
  57357. continue;
  57358. if ((s || !d || $.distance < d.distance) && (d = $,
  57359. d.faceId = _ / 3,
  57360. s))
  57361. break
  57362. }
  57363. }
  57364. }
  57365. return d
  57366. }
  57367. ,
  57368. a.prototype._rebuild = function() {
  57369. this._linesIndexBuffer && (this._linesIndexBuffer = null)
  57370. }
  57371. ,
  57372. a.prototype.clone = function(e, i) {
  57373. var o = new a(this.materialIndex,this.verticesStart,this.verticesCount,this.indexStart,this.indexCount,e,i,!1);
  57374. if (!this.IsGlobal) {
  57375. var s = this.getBoundingInfo();
  57376. if (!s)
  57377. return o;
  57378. o._boundingInfo = new BoundingInfo(s.minimum,s.maximum)
  57379. }
  57380. return o
  57381. }
  57382. ,
  57383. a.prototype.dispose = function() {
  57384. this._linesIndexBuffer && (this._mesh.getScene().getEngine()._releaseBuffer(this._linesIndexBuffer),
  57385. this._linesIndexBuffer = null);
  57386. var e = this._mesh.subMeshes.indexOf(this);
  57387. this._mesh.subMeshes.splice(e, 1),
  57388. this.resetDrawCache()
  57389. }
  57390. ,
  57391. a.prototype.getClassName = function() {
  57392. return "SubMesh"
  57393. }
  57394. ,
  57395. a.CreateFromIndices = function(e, i, o, s, c, d) {
  57396. d === void 0 && (d = !0);
  57397. for (var _ = Number.MAX_VALUE, b = -Number.MAX_VALUE, k = c || s, j = k.getIndices(), $ = i; $ < i + o; $++) {
  57398. var _e = j[$];
  57399. _e < _ && (_ = _e),
  57400. _e > b && (b = _e)
  57401. }
  57402. return new a(e,_,b - _ + 1,i,o,s,c,d)
  57403. }
  57404. ,
  57405. a
  57406. }()
  57407. , Geometry = function() {
  57408. function a(e, i, o, s, c) {
  57409. s === void 0 && (s = !1),
  57410. c === void 0 && (c = null),
  57411. this.delayLoadState = 0,
  57412. this._totalVertices = 0,
  57413. this._isDisposed = !1,
  57414. this._indexBufferIsUpdatable = !1,
  57415. this._positionsCache = [],
  57416. this._parentContainer = null,
  57417. this.useBoundingInfoFromGeometry = !1,
  57418. this.id = e,
  57419. this.uniqueId = i.getUniqueId(),
  57420. this._engine = i.getEngine(),
  57421. this._meshes = [],
  57422. this._scene = i,
  57423. this._vertexBuffers = {},
  57424. this._indices = [],
  57425. this._updatable = s,
  57426. o ? this.setAllVerticesData(o, s) : (this._totalVertices = 0,
  57427. this._indices = []),
  57428. this._engine.getCaps().vertexArrayObject && (this._vertexArrayObjects = {}),
  57429. c && (this.applyToMesh(c),
  57430. c.computeWorldMatrix(!0))
  57431. }
  57432. return Object.defineProperty(a.prototype, "boundingBias", {
  57433. get: function() {
  57434. return this._boundingBias
  57435. },
  57436. set: function(e) {
  57437. this._boundingBias ? this._boundingBias.copyFrom(e) : this._boundingBias = e.clone(),
  57438. this._updateBoundingInfo(!0, null)
  57439. },
  57440. enumerable: !1,
  57441. configurable: !0
  57442. }),
  57443. a.CreateGeometryForMesh = function(e) {
  57444. var i = new a(a.RandomId(),e.getScene());
  57445. return i.applyToMesh(e),
  57446. i
  57447. }
  57448. ,
  57449. Object.defineProperty(a.prototype, "meshes", {
  57450. get: function() {
  57451. return this._meshes
  57452. },
  57453. enumerable: !1,
  57454. configurable: !0
  57455. }),
  57456. Object.defineProperty(a.prototype, "extend", {
  57457. get: function() {
  57458. return this._extend
  57459. },
  57460. enumerable: !1,
  57461. configurable: !0
  57462. }),
  57463. a.prototype.getScene = function() {
  57464. return this._scene
  57465. }
  57466. ,
  57467. a.prototype.getEngine = function() {
  57468. return this._engine
  57469. }
  57470. ,
  57471. a.prototype.isReady = function() {
  57472. return this.delayLoadState === 1 || this.delayLoadState === 0
  57473. }
  57474. ,
  57475. Object.defineProperty(a.prototype, "doNotSerialize", {
  57476. get: function() {
  57477. for (var e = 0; e < this._meshes.length; e++)
  57478. if (!this._meshes[e].doNotSerialize)
  57479. return !1;
  57480. return !0
  57481. },
  57482. enumerable: !1,
  57483. configurable: !0
  57484. }),
  57485. a.prototype._rebuild = function() {
  57486. this._vertexArrayObjects && (this._vertexArrayObjects = {}),
  57487. this._meshes.length !== 0 && this._indices && (this._indexBuffer = this._engine.createIndexBuffer(this._indices, this._updatable));
  57488. for (var e in this._vertexBuffers) {
  57489. var i = this._vertexBuffers[e];
  57490. i._rebuild()
  57491. }
  57492. }
  57493. ,
  57494. a.prototype.setAllVerticesData = function(e, i) {
  57495. e.applyToGeometry(this, i),
  57496. this.notifyUpdate()
  57497. }
  57498. ,
  57499. a.prototype.setVerticesData = function(e, i, o, s) {
  57500. o === void 0 && (o = !1),
  57501. o && Array.isArray(i) && (i = new Float32Array(i));
  57502. var c = new VertexBuffer(this._engine,i,e,o,this._meshes.length === 0,s);
  57503. this.setVerticesBuffer(c)
  57504. }
  57505. ,
  57506. a.prototype.removeVerticesData = function(e) {
  57507. this._vertexBuffers[e] && (this._vertexBuffers[e].dispose(),
  57508. delete this._vertexBuffers[e]),
  57509. this._vertexArrayObjects && this._disposeVertexArrayObjects()
  57510. }
  57511. ,
  57512. a.prototype.setVerticesBuffer = function(e, i, o) {
  57513. i === void 0 && (i = null),
  57514. o === void 0 && (o = !0);
  57515. var s = e.getKind();
  57516. this._vertexBuffers[s] && o && this._vertexBuffers[s].dispose(),
  57517. e._buffer && e._buffer._increaseReferences(),
  57518. this._vertexBuffers[s] = e;
  57519. var c = this._meshes
  57520. , d = c.length;
  57521. if (s === VertexBuffer.PositionKind) {
  57522. var _ = e.getData();
  57523. i != null ? this._totalVertices = i : _ != null && (this._totalVertices = _.length / (e.type === VertexBuffer.BYTE ? e.byteStride : e.byteStride / 4)),
  57524. this._updateExtend(_),
  57525. this._resetPointsArrayCache();
  57526. for (var b = 0; b < d; b++) {
  57527. var k = c[b];
  57528. k.buildBoundingInfo(this._extend.minimum, this._extend.maximum),
  57529. k._createGlobalSubMesh(!1),
  57530. k.computeWorldMatrix(!0),
  57531. k.synchronizeInstances()
  57532. }
  57533. }
  57534. this.notifyUpdate(s)
  57535. }
  57536. ,
  57537. a.prototype.updateVerticesDataDirectly = function(e, i, o, s) {
  57538. s === void 0 && (s = !1);
  57539. var c = this.getVertexBuffer(e);
  57540. !c || (c.updateDirectly(i, o, s),
  57541. this.notifyUpdate(e))
  57542. }
  57543. ,
  57544. a.prototype.updateVerticesData = function(e, i, o) {
  57545. o === void 0 && (o = !1);
  57546. var s = this.getVertexBuffer(e);
  57547. !s || (s.update(i),
  57548. e === VertexBuffer.PositionKind && this._updateBoundingInfo(o, i),
  57549. this.notifyUpdate(e))
  57550. }
  57551. ,
  57552. a.prototype._updateBoundingInfo = function(e, i) {
  57553. if (e && this._updateExtend(i),
  57554. this._resetPointsArrayCache(),
  57555. e)
  57556. for (var o = this._meshes, s = 0, c = o; s < c.length; s++) {
  57557. var d = c[s];
  57558. d.hasBoundingInfo ? d.getBoundingInfo().reConstruct(this._extend.minimum, this._extend.maximum) : d.buildBoundingInfo(this._extend.minimum, this._extend.maximum);
  57559. for (var _ = d.subMeshes, b = 0, k = _; b < k.length; b++) {
  57560. var j = k[b];
  57561. j.refreshBoundingInfo()
  57562. }
  57563. }
  57564. }
  57565. ,
  57566. a.prototype._bind = function(e, i, o, s) {
  57567. if (!!e) {
  57568. i === void 0 && (i = this._indexBuffer);
  57569. var c = this.getVertexBuffers();
  57570. if (!!c) {
  57571. if (i != this._indexBuffer || !this._vertexArrayObjects && !s) {
  57572. this._engine.bindBuffers(c, i, e, o);
  57573. return
  57574. }
  57575. var d = s || this._vertexArrayObjects;
  57576. d[e.key] || (d[e.key] = this._engine.recordVertexArrayObject(c, i, e, o)),
  57577. this._engine.bindVertexArrayObject(d[e.key], i)
  57578. }
  57579. }
  57580. }
  57581. ,
  57582. a.prototype.getTotalVertices = function() {
  57583. return this.isReady() ? this._totalVertices : 0
  57584. }
  57585. ,
  57586. a.prototype.getVerticesData = function(e, i, o) {
  57587. var s = this.getVertexBuffer(e);
  57588. return s ? s.getFloatData(this._totalVertices, o || i && this._meshes.length !== 1) : null
  57589. }
  57590. ,
  57591. a.prototype.isVertexBufferUpdatable = function(e) {
  57592. var i = this._vertexBuffers[e];
  57593. return i ? i.isUpdatable() : !1
  57594. }
  57595. ,
  57596. a.prototype.getVertexBuffer = function(e) {
  57597. return this.isReady() ? this._vertexBuffers[e] : null
  57598. }
  57599. ,
  57600. a.prototype.getVertexBuffers = function() {
  57601. return this.isReady() ? this._vertexBuffers : null
  57602. }
  57603. ,
  57604. a.prototype.isVerticesDataPresent = function(e) {
  57605. return this._vertexBuffers ? this._vertexBuffers[e] !== void 0 : this._delayInfo ? this._delayInfo.indexOf(e) !== -1 : !1
  57606. }
  57607. ,
  57608. a.prototype.getVerticesDataKinds = function() {
  57609. var e = [], i;
  57610. if (!this._vertexBuffers && this._delayInfo)
  57611. for (i in this._delayInfo)
  57612. e.push(i);
  57613. else
  57614. for (i in this._vertexBuffers)
  57615. e.push(i);
  57616. return e
  57617. }
  57618. ,
  57619. a.prototype.updateIndices = function(e, i, o) {
  57620. if (o === void 0 && (o = !1),
  57621. !!this._indexBuffer)
  57622. if (!this._indexBufferIsUpdatable)
  57623. this.setIndices(e, null, !0);
  57624. else {
  57625. var s = e.length !== this._indices.length;
  57626. if (o || (this._indices = e.slice()),
  57627. this._engine.updateDynamicIndexBuffer(this._indexBuffer, e, i),
  57628. s)
  57629. for (var c = 0, d = this._meshes; c < d.length; c++) {
  57630. var _ = d[c];
  57631. _._createGlobalSubMesh(!0)
  57632. }
  57633. }
  57634. }
  57635. ,
  57636. a.prototype.setIndices = function(e, i, o) {
  57637. i === void 0 && (i = null),
  57638. o === void 0 && (o = !1),
  57639. this._indexBuffer && this._engine._releaseBuffer(this._indexBuffer),
  57640. this._indices = e,
  57641. this._indexBufferIsUpdatable = o,
  57642. this._meshes.length !== 0 && this._indices && (this._indexBuffer = this._engine.createIndexBuffer(this._indices, o)),
  57643. i != null && (this._totalVertices = i);
  57644. for (var s = 0, c = this._meshes; s < c.length; s++) {
  57645. var d = c[s];
  57646. d._createGlobalSubMesh(!0),
  57647. d.synchronizeInstances()
  57648. }
  57649. this.notifyUpdate()
  57650. }
  57651. ,
  57652. a.prototype.getTotalIndices = function() {
  57653. return this.isReady() ? this._indices.length : 0
  57654. }
  57655. ,
  57656. a.prototype.getIndices = function(e, i) {
  57657. if (!this.isReady())
  57658. return null;
  57659. var o = this._indices;
  57660. return !i && (!e || this._meshes.length === 1) ? o : Tools.Slice(o)
  57661. }
  57662. ,
  57663. a.prototype.getIndexBuffer = function() {
  57664. return this.isReady() ? this._indexBuffer : null
  57665. }
  57666. ,
  57667. a.prototype._releaseVertexArrayObject = function(e) {
  57668. e === void 0 && (e = null),
  57669. !(!e || !this._vertexArrayObjects) && this._vertexArrayObjects[e.key] && (this._engine.releaseVertexArrayObject(this._vertexArrayObjects[e.key]),
  57670. delete this._vertexArrayObjects[e.key])
  57671. }
  57672. ,
  57673. a.prototype.releaseForMesh = function(e, i) {
  57674. var o = this._meshes
  57675. , s = o.indexOf(e);
  57676. s !== -1 && (o.splice(s, 1),
  57677. this._vertexArrayObjects && e._invalidateInstanceVertexArrayObject(),
  57678. e._geometry = null,
  57679. o.length === 0 && i && this.dispose())
  57680. }
  57681. ,
  57682. a.prototype.applyToMesh = function(e) {
  57683. if (e._geometry !== this) {
  57684. var i = e._geometry;
  57685. i && i.releaseForMesh(e),
  57686. this._vertexArrayObjects && e._invalidateInstanceVertexArrayObject();
  57687. var o = this._meshes;
  57688. e._geometry = this,
  57689. e._internalAbstractMeshDataInfo._positions = null,
  57690. this._scene.pushGeometry(this),
  57691. o.push(e),
  57692. this.isReady() ? this._applyToMesh(e) : this._boundingInfo && e.setBoundingInfo(this._boundingInfo)
  57693. }
  57694. }
  57695. ,
  57696. a.prototype._updateExtend = function(e) {
  57697. e === void 0 && (e = null),
  57698. this.useBoundingInfoFromGeometry && this._boundingInfo ? this._extend = {
  57699. minimum: this._boundingInfo.minimum.clone(),
  57700. maximum: this._boundingInfo.maximum.clone()
  57701. } : (e || (e = this.getVerticesData(VertexBuffer.PositionKind)),
  57702. this._extend = extractMinAndMax(e, 0, this._totalVertices, this.boundingBias, 3))
  57703. }
  57704. ,
  57705. a.prototype._applyToMesh = function(e) {
  57706. var i = this._meshes.length;
  57707. for (var o in this._vertexBuffers)
  57708. i === 1 && this._vertexBuffers[o].create(),
  57709. o === VertexBuffer.PositionKind && (this._extend || this._updateExtend(),
  57710. e.buildBoundingInfo(this._extend.minimum, this._extend.maximum),
  57711. e._createGlobalSubMesh(!1),
  57712. e._updateBoundingInfo());
  57713. i === 1 && this._indices && this._indices.length > 0 && (this._indexBuffer = this._engine.createIndexBuffer(this._indices, this._updatable)),
  57714. e._syncGeometryWithMorphTargetManager(),
  57715. e.synchronizeInstances()
  57716. }
  57717. ,
  57718. a.prototype.notifyUpdate = function(e) {
  57719. this.onGeometryUpdated && this.onGeometryUpdated(this, e),
  57720. this._vertexArrayObjects && this._disposeVertexArrayObjects();
  57721. for (var i = 0, o = this._meshes; i < o.length; i++) {
  57722. var s = o[i];
  57723. s._markSubMeshesAsAttributesDirty()
  57724. }
  57725. }
  57726. ,
  57727. a.prototype.load = function(e, i) {
  57728. if (this.delayLoadState !== 2) {
  57729. if (this.isReady()) {
  57730. i && i();
  57731. return
  57732. }
  57733. this.delayLoadState = 2,
  57734. this._queueLoad(e, i)
  57735. }
  57736. }
  57737. ,
  57738. a.prototype._queueLoad = function(e, i) {
  57739. var o = this;
  57740. !this.delayLoadingFile || (e._addPendingData(this),
  57741. e._loadFile(this.delayLoadingFile, function(s) {
  57742. if (!!o._delayLoadingFunction) {
  57743. o._delayLoadingFunction(JSON.parse(s), o),
  57744. o.delayLoadState = 1,
  57745. o._delayInfo = [],
  57746. e._removePendingData(o);
  57747. for (var c = o._meshes, d = c.length, _ = 0; _ < d; _++)
  57748. o._applyToMesh(c[_]);
  57749. i && i()
  57750. }
  57751. }, void 0, !0))
  57752. }
  57753. ,
  57754. a.prototype.toLeftHanded = function() {
  57755. var e = this.getIndices(!1);
  57756. if (e != null && e.length > 0) {
  57757. for (var i = 0; i < e.length; i += 3) {
  57758. var o = e[i + 0];
  57759. e[i + 0] = e[i + 2],
  57760. e[i + 2] = o
  57761. }
  57762. this.setIndices(e)
  57763. }
  57764. var s = this.getVerticesData(VertexBuffer.PositionKind, !1);
  57765. if (s != null && s.length > 0) {
  57766. for (var i = 0; i < s.length; i += 3)
  57767. s[i + 2] = -s[i + 2];
  57768. this.setVerticesData(VertexBuffer.PositionKind, s, !1)
  57769. }
  57770. var c = this.getVerticesData(VertexBuffer.NormalKind, !1);
  57771. if (c != null && c.length > 0) {
  57772. for (var i = 0; i < c.length; i += 3)
  57773. c[i + 2] = -c[i + 2];
  57774. this.setVerticesData(VertexBuffer.NormalKind, c, !1)
  57775. }
  57776. }
  57777. ,
  57778. a.prototype._resetPointsArrayCache = function() {
  57779. this._positions = null
  57780. }
  57781. ,
  57782. a.prototype._generatePointsArray = function() {
  57783. if (this._positions)
  57784. return !0;
  57785. var e = this.getVerticesData(VertexBuffer.PositionKind);
  57786. if (!e || e.length === 0)
  57787. return !1;
  57788. for (var i = this._positionsCache.length * 3, o = this._positionsCache.length; i < e.length; i += 3,
  57789. ++o)
  57790. this._positionsCache[o] = Vector3.FromArray(e, i);
  57791. for (var i = 0, o = 0; i < e.length; i += 3,
  57792. ++o)
  57793. this._positionsCache[o].set(e[0 + i], e[1 + i], e[2 + i]);
  57794. return this._positionsCache.length = e.length / 3,
  57795. this._positions = this._positionsCache,
  57796. !0
  57797. }
  57798. ,
  57799. a.prototype.isDisposed = function() {
  57800. return this._isDisposed
  57801. }
  57802. ,
  57803. a.prototype._disposeVertexArrayObjects = function() {
  57804. if (this._vertexArrayObjects) {
  57805. for (var e in this._vertexArrayObjects)
  57806. this._engine.releaseVertexArrayObject(this._vertexArrayObjects[e]);
  57807. this._vertexArrayObjects = {};
  57808. for (var i = this._meshes, o = i.length, s = 0; s < o; s++)
  57809. i[s]._invalidateInstanceVertexArrayObject()
  57810. }
  57811. }
  57812. ,
  57813. a.prototype.dispose = function() {
  57814. var e = this._meshes, i = e.length, o;
  57815. for (o = 0; o < i; o++)
  57816. this.releaseForMesh(e[o]);
  57817. this._meshes = [],
  57818. this._disposeVertexArrayObjects();
  57819. for (var s in this._vertexBuffers)
  57820. this._vertexBuffers[s].dispose();
  57821. if (this._vertexBuffers = {},
  57822. this._totalVertices = 0,
  57823. this._indexBuffer && this._engine._releaseBuffer(this._indexBuffer),
  57824. this._indexBuffer = null,
  57825. this._indices = [],
  57826. this.delayLoadState = 0,
  57827. this.delayLoadingFile = null,
  57828. this._delayLoadingFunction = null,
  57829. this._delayInfo = [],
  57830. this._boundingInfo = null,
  57831. this._scene.removeGeometry(this),
  57832. this._parentContainer) {
  57833. var c = this._parentContainer.geometries.indexOf(this);
  57834. c > -1 && this._parentContainer.geometries.splice(c, 1),
  57835. this._parentContainer = null
  57836. }
  57837. this._isDisposed = !0
  57838. }
  57839. ,
  57840. a.prototype.copy = function(e) {
  57841. var i = new VertexData;
  57842. i.indices = [];
  57843. var o = this.getIndices();
  57844. if (o)
  57845. for (var s = 0; s < o.length; s++)
  57846. i.indices.push(o[s]);
  57847. var c = !1, d = !1, _;
  57848. for (_ in this._vertexBuffers) {
  57849. var b = this.getVerticesData(_);
  57850. if (b && (b instanceof Float32Array ? i.set(new Float32Array(b), _) : i.set(b.slice(0), _),
  57851. !d)) {
  57852. var k = this.getVertexBuffer(_);
  57853. k && (c = k.isUpdatable(),
  57854. d = !c)
  57855. }
  57856. }
  57857. var j = new a(e,this._scene,i,c);
  57858. j.delayLoadState = this.delayLoadState,
  57859. j.delayLoadingFile = this.delayLoadingFile,
  57860. j._delayLoadingFunction = this._delayLoadingFunction;
  57861. for (_ in this._delayInfo)
  57862. j._delayInfo = j._delayInfo || [],
  57863. j._delayInfo.push(_);
  57864. return j._boundingInfo = new BoundingInfo(this._extend.minimum,this._extend.maximum),
  57865. j
  57866. }
  57867. ,
  57868. a.prototype.serialize = function() {
  57869. var e = {};
  57870. return e.id = this.id,
  57871. e.uniqueId = this.uniqueId,
  57872. e.updatable = this._updatable,
  57873. Tags && Tags.HasTags(this) && (e.tags = Tags.GetTags(this)),
  57874. e
  57875. }
  57876. ,
  57877. a.prototype.toNumberArray = function(e) {
  57878. return Array.isArray(e) ? e : Array.prototype.slice.call(e)
  57879. }
  57880. ,
  57881. a.prototype.clearCachedData = function() {
  57882. this._indices = [],
  57883. this._resetPointsArrayCache();
  57884. for (var e in this._vertexBuffers)
  57885. !this._vertexBuffers.hasOwnProperty(e) || (this._vertexBuffers[e]._buffer._data = null)
  57886. }
  57887. ,
  57888. a.prototype.serializeVerticeData = function() {
  57889. var e = this.serialize();
  57890. return this.isVerticesDataPresent(VertexBuffer.PositionKind) && (e.positions = this.toNumberArray(this.getVerticesData(VertexBuffer.PositionKind)),
  57891. this.isVertexBufferUpdatable(VertexBuffer.PositionKind) && (e.positions._updatable = !0)),
  57892. this.isVerticesDataPresent(VertexBuffer.NormalKind) && (e.normals = this.toNumberArray(this.getVerticesData(VertexBuffer.NormalKind)),
  57893. this.isVertexBufferUpdatable(VertexBuffer.NormalKind) && (e.normals._updatable = !0)),
  57894. this.isVerticesDataPresent(VertexBuffer.TangentKind) && (e.tangents = this.toNumberArray(this.getVerticesData(VertexBuffer.TangentKind)),
  57895. this.isVertexBufferUpdatable(VertexBuffer.TangentKind) && (e.tangents._updatable = !0)),
  57896. this.isVerticesDataPresent(VertexBuffer.UVKind) && (e.uvs = this.toNumberArray(this.getVerticesData(VertexBuffer.UVKind)),
  57897. this.isVertexBufferUpdatable(VertexBuffer.UVKind) && (e.uvs._updatable = !0)),
  57898. this.isVerticesDataPresent(VertexBuffer.UV2Kind) && (e.uv2s = this.toNumberArray(this.getVerticesData(VertexBuffer.UV2Kind)),
  57899. this.isVertexBufferUpdatable(VertexBuffer.UV2Kind) && (e.uv2s._updatable = !0)),
  57900. this.isVerticesDataPresent(VertexBuffer.UV3Kind) && (e.uv3s = this.toNumberArray(this.getVerticesData(VertexBuffer.UV3Kind)),
  57901. this.isVertexBufferUpdatable(VertexBuffer.UV3Kind) && (e.uv3s._updatable = !0)),
  57902. this.isVerticesDataPresent(VertexBuffer.UV4Kind) && (e.uv4s = this.toNumberArray(this.getVerticesData(VertexBuffer.UV4Kind)),
  57903. this.isVertexBufferUpdatable(VertexBuffer.UV4Kind) && (e.uv4s._updatable = !0)),
  57904. this.isVerticesDataPresent(VertexBuffer.UV5Kind) && (e.uv5s = this.toNumberArray(this.getVerticesData(VertexBuffer.UV5Kind)),
  57905. this.isVertexBufferUpdatable(VertexBuffer.UV5Kind) && (e.uv5s._updatable = !0)),
  57906. this.isVerticesDataPresent(VertexBuffer.UV6Kind) && (e.uv6s = this.toNumberArray(this.getVerticesData(VertexBuffer.UV6Kind)),
  57907. this.isVertexBufferUpdatable(VertexBuffer.UV6Kind) && (e.uv6s._updatable = !0)),
  57908. this.isVerticesDataPresent(VertexBuffer.ColorKind) && (e.colors = this.toNumberArray(this.getVerticesData(VertexBuffer.ColorKind)),
  57909. this.isVertexBufferUpdatable(VertexBuffer.ColorKind) && (e.colors._updatable = !0)),
  57910. this.isVerticesDataPresent(VertexBuffer.MatricesIndicesKind) && (e.matricesIndices = this.toNumberArray(this.getVerticesData(VertexBuffer.MatricesIndicesKind)),
  57911. e.matricesIndices._isExpanded = !0,
  57912. this.isVertexBufferUpdatable(VertexBuffer.MatricesIndicesKind) && (e.matricesIndices._updatable = !0)),
  57913. this.isVerticesDataPresent(VertexBuffer.MatricesWeightsKind) && (e.matricesWeights = this.toNumberArray(this.getVerticesData(VertexBuffer.MatricesWeightsKind)),
  57914. this.isVertexBufferUpdatable(VertexBuffer.MatricesWeightsKind) && (e.matricesWeights._updatable = !0)),
  57915. e.indices = this.toNumberArray(this.getIndices()),
  57916. e
  57917. }
  57918. ,
  57919. a.ExtractFromMesh = function(e, i) {
  57920. var o = e._geometry;
  57921. return o ? o.copy(i) : null
  57922. }
  57923. ,
  57924. a.RandomId = function() {
  57925. return Tools.RandomId()
  57926. }
  57927. ,
  57928. a._GetGeometryByLoadedUniqueId = function(e, i) {
  57929. for (var o = 0; o < i.geometries.length; o++)
  57930. if (i.geometries[o]._loadedUniqueId === e)
  57931. return i.geometries[o];
  57932. return null
  57933. }
  57934. ,
  57935. a._ImportGeometry = function(e, i) {
  57936. var o = i.getScene()
  57937. , s = e.geometryUniqueId
  57938. , c = e.geometryId;
  57939. if (s || c) {
  57940. var d = s ? this._GetGeometryByLoadedUniqueId(s, o) : o.getGeometryById(c);
  57941. d && d.applyToMesh(i)
  57942. } else if (e instanceof ArrayBuffer) {
  57943. var _ = i._binaryInfo;
  57944. if (_.positionsAttrDesc && _.positionsAttrDesc.count > 0) {
  57945. var b = new Float32Array(e,_.positionsAttrDesc.offset,_.positionsAttrDesc.count);
  57946. i.setVerticesData(VertexBuffer.PositionKind, b, !1)
  57947. }
  57948. if (_.normalsAttrDesc && _.normalsAttrDesc.count > 0) {
  57949. var k = new Float32Array(e,_.normalsAttrDesc.offset,_.normalsAttrDesc.count);
  57950. i.setVerticesData(VertexBuffer.NormalKind, k, !1)
  57951. }
  57952. if (_.tangetsAttrDesc && _.tangetsAttrDesc.count > 0) {
  57953. var j = new Float32Array(e,_.tangetsAttrDesc.offset,_.tangetsAttrDesc.count);
  57954. i.setVerticesData(VertexBuffer.TangentKind, j, !1)
  57955. }
  57956. if (_.uvsAttrDesc && _.uvsAttrDesc.count > 0) {
  57957. var $ = new Float32Array(e,_.uvsAttrDesc.offset,_.uvsAttrDesc.count);
  57958. i.setVerticesData(VertexBuffer.UVKind, $, !1)
  57959. }
  57960. if (_.uvs2AttrDesc && _.uvs2AttrDesc.count > 0) {
  57961. var _e = new Float32Array(e,_.uvs2AttrDesc.offset,_.uvs2AttrDesc.count);
  57962. i.setVerticesData(VertexBuffer.UV2Kind, _e, !1)
  57963. }
  57964. if (_.uvs3AttrDesc && _.uvs3AttrDesc.count > 0) {
  57965. var et = new Float32Array(e,_.uvs3AttrDesc.offset,_.uvs3AttrDesc.count);
  57966. i.setVerticesData(VertexBuffer.UV3Kind, et, !1)
  57967. }
  57968. if (_.uvs4AttrDesc && _.uvs4AttrDesc.count > 0) {
  57969. var tt = new Float32Array(e,_.uvs4AttrDesc.offset,_.uvs4AttrDesc.count);
  57970. i.setVerticesData(VertexBuffer.UV4Kind, tt, !1)
  57971. }
  57972. if (_.uvs5AttrDesc && _.uvs5AttrDesc.count > 0) {
  57973. var rt = new Float32Array(e,_.uvs5AttrDesc.offset,_.uvs5AttrDesc.count);
  57974. i.setVerticesData(VertexBuffer.UV5Kind, rt, !1)
  57975. }
  57976. if (_.uvs6AttrDesc && _.uvs6AttrDesc.count > 0) {
  57977. var it = new Float32Array(e,_.uvs6AttrDesc.offset,_.uvs6AttrDesc.count);
  57978. i.setVerticesData(VertexBuffer.UV6Kind, it, !1)
  57979. }
  57980. if (_.colorsAttrDesc && _.colorsAttrDesc.count > 0) {
  57981. var nt = new Float32Array(e,_.colorsAttrDesc.offset,_.colorsAttrDesc.count);
  57982. i.setVerticesData(VertexBuffer.ColorKind, nt, !1, _.colorsAttrDesc.stride)
  57983. }
  57984. if (_.matricesIndicesAttrDesc && _.matricesIndicesAttrDesc.count > 0) {
  57985. for (var ot = new Int32Array(e,_.matricesIndicesAttrDesc.offset,_.matricesIndicesAttrDesc.count), at = [], st = 0; st < ot.length; st++) {
  57986. var ut = ot[st];
  57987. at.push(ut & 255),
  57988. at.push((ut & 65280) >> 8),
  57989. at.push((ut & 16711680) >> 16),
  57990. at.push(ut >> 24 & 255)
  57991. }
  57992. i.setVerticesData(VertexBuffer.MatricesIndicesKind, at, !1)
  57993. }
  57994. if (_.matricesIndicesExtraAttrDesc && _.matricesIndicesExtraAttrDesc.count > 0) {
  57995. for (var ot = new Int32Array(e,_.matricesIndicesExtraAttrDesc.offset,_.matricesIndicesExtraAttrDesc.count), at = [], st = 0; st < ot.length; st++) {
  57996. var ut = ot[st];
  57997. at.push(ut & 255),
  57998. at.push((ut & 65280) >> 8),
  57999. at.push((ut & 16711680) >> 16),
  58000. at.push(ut >> 24 & 255)
  58001. }
  58002. i.setVerticesData(VertexBuffer.MatricesIndicesExtraKind, at, !1)
  58003. }
  58004. if (_.matricesWeightsAttrDesc && _.matricesWeightsAttrDesc.count > 0) {
  58005. var ct = new Float32Array(e,_.matricesWeightsAttrDesc.offset,_.matricesWeightsAttrDesc.count);
  58006. i.setVerticesData(VertexBuffer.MatricesWeightsKind, ct, !1)
  58007. }
  58008. if (_.indicesAttrDesc && _.indicesAttrDesc.count > 0) {
  58009. var lt = new Int32Array(e,_.indicesAttrDesc.offset,_.indicesAttrDesc.count);
  58010. i.setIndices(lt, null)
  58011. }
  58012. if (_.subMeshesAttrDesc && _.subMeshesAttrDesc.count > 0) {
  58013. var ft = new Int32Array(e,_.subMeshesAttrDesc.offset,_.subMeshesAttrDesc.count * 5);
  58014. i.subMeshes = [];
  58015. for (var st = 0; st < _.subMeshesAttrDesc.count; st++) {
  58016. var ht = ft[st * 5 + 0]
  58017. , pt = ft[st * 5 + 1]
  58018. , dt = ft[st * 5 + 2]
  58019. , _t = ft[st * 5 + 3]
  58020. , mt = ft[st * 5 + 4];
  58021. SubMesh.AddToMesh(ht, pt, dt, _t, mt, i)
  58022. }
  58023. }
  58024. } else if (e.positions && e.normals && e.indices) {
  58025. if (i.setVerticesData(VertexBuffer.PositionKind, e.positions, e.positions._updatable),
  58026. i.setVerticesData(VertexBuffer.NormalKind, e.normals, e.normals._updatable),
  58027. e.tangents && i.setVerticesData(VertexBuffer.TangentKind, e.tangents, e.tangents._updatable),
  58028. e.uvs && i.setVerticesData(VertexBuffer.UVKind, e.uvs, e.uvs._updatable),
  58029. e.uvs2 && i.setVerticesData(VertexBuffer.UV2Kind, e.uvs2, e.uvs2._updatable),
  58030. e.uvs3 && i.setVerticesData(VertexBuffer.UV3Kind, e.uvs3, e.uvs3._updatable),
  58031. e.uvs4 && i.setVerticesData(VertexBuffer.UV4Kind, e.uvs4, e.uvs4._updatable),
  58032. e.uvs5 && i.setVerticesData(VertexBuffer.UV5Kind, e.uvs5, e.uvs5._updatable),
  58033. e.uvs6 && i.setVerticesData(VertexBuffer.UV6Kind, e.uvs6, e.uvs6._updatable),
  58034. e.colors && i.setVerticesData(VertexBuffer.ColorKind, Color4.CheckColors4(e.colors, e.positions.length / 3), e.colors._updatable),
  58035. e.matricesIndices)
  58036. if (e.matricesIndices._isExpanded)
  58037. delete e.matricesIndices._isExpanded,
  58038. i.setVerticesData(VertexBuffer.MatricesIndicesKind, e.matricesIndices, e.matricesIndices._updatable);
  58039. else {
  58040. for (var at = [], st = 0; st < e.matricesIndices.length; st++) {
  58041. var vt = e.matricesIndices[st];
  58042. at.push(vt & 255),
  58043. at.push((vt & 65280) >> 8),
  58044. at.push((vt & 16711680) >> 16),
  58045. at.push(vt >> 24 & 255)
  58046. }
  58047. i.setVerticesData(VertexBuffer.MatricesIndicesKind, at, e.matricesIndices._updatable)
  58048. }
  58049. if (e.matricesIndicesExtra)
  58050. if (e.matricesIndicesExtra._isExpanded)
  58051. delete e.matricesIndices._isExpanded,
  58052. i.setVerticesData(VertexBuffer.MatricesIndicesExtraKind, e.matricesIndicesExtra, e.matricesIndicesExtra._updatable);
  58053. else {
  58054. for (var at = [], st = 0; st < e.matricesIndicesExtra.length; st++) {
  58055. var vt = e.matricesIndicesExtra[st];
  58056. at.push(vt & 255),
  58057. at.push((vt & 65280) >> 8),
  58058. at.push((vt & 16711680) >> 16),
  58059. at.push(vt >> 24 & 255)
  58060. }
  58061. i.setVerticesData(VertexBuffer.MatricesIndicesExtraKind, at, e.matricesIndicesExtra._updatable)
  58062. }
  58063. e.matricesWeights && (a._CleanMatricesWeights(e, i),
  58064. i.setVerticesData(VertexBuffer.MatricesWeightsKind, e.matricesWeights, e.matricesWeights._updatable)),
  58065. e.matricesWeightsExtra && i.setVerticesData(VertexBuffer.MatricesWeightsExtraKind, e.matricesWeightsExtra, e.matricesWeights._updatable),
  58066. i.setIndices(e.indices, null)
  58067. }
  58068. if (e.subMeshes) {
  58069. i.subMeshes = [];
  58070. for (var yt = 0; yt < e.subMeshes.length; yt++) {
  58071. var Et = e.subMeshes[yt];
  58072. SubMesh.AddToMesh(Et.materialIndex, Et.verticesStart, Et.verticesCount, Et.indexStart, Et.indexCount, i)
  58073. }
  58074. }
  58075. i._shouldGenerateFlatShading && (i.convertToFlatShadedMesh(),
  58076. i._shouldGenerateFlatShading = !1),
  58077. i.computeWorldMatrix(!0),
  58078. o.onMeshImportedObservable.notifyObservers(i)
  58079. }
  58080. ,
  58081. a._CleanMatricesWeights = function(e, i) {
  58082. var o = .001;
  58083. if (!!SceneLoaderFlags.CleanBoneMatrixWeights) {
  58084. var s = 0;
  58085. if (e.skeletonId > -1) {
  58086. var c = i.getScene().getLastSkeletonById(e.skeletonId);
  58087. if (!c)
  58088. return;
  58089. s = c.bones.length
  58090. } else
  58091. return;
  58092. for (var d = i.getVerticesData(VertexBuffer.MatricesIndicesKind), _ = i.getVerticesData(VertexBuffer.MatricesIndicesExtraKind), b = e.matricesWeights, k = e.matricesWeightsExtra, j = e.numBoneInfluencer, $ = b.length, _e = 0; _e < $; _e += 4) {
  58093. for (var et = 0, tt = -1, rt = 0; rt < 4; rt++) {
  58094. var it = b[_e + rt];
  58095. et += it,
  58096. it < o && tt < 0 && (tt = rt)
  58097. }
  58098. if (k)
  58099. for (var rt = 0; rt < 4; rt++) {
  58100. var it = k[_e + rt];
  58101. et += it,
  58102. it < o && tt < 0 && (tt = rt + 4)
  58103. }
  58104. if ((tt < 0 || tt > j - 1) && (tt = j - 1),
  58105. et > o) {
  58106. for (var nt = 1 / et, rt = 0; rt < 4; rt++)
  58107. b[_e + rt] *= nt;
  58108. if (k)
  58109. for (var rt = 0; rt < 4; rt++)
  58110. k[_e + rt] *= nt
  58111. } else
  58112. tt >= 4 ? (k[_e + tt - 4] = 1 - et,
  58113. _[_e + tt - 4] = s) : (b[_e + tt] = 1 - et,
  58114. d[_e + tt] = s)
  58115. }
  58116. i.setVerticesData(VertexBuffer.MatricesIndicesKind, d),
  58117. e.matricesWeightsExtra && i.setVerticesData(VertexBuffer.MatricesIndicesExtraKind, _)
  58118. }
  58119. }
  58120. ,
  58121. a.Parse = function(e, i, o) {
  58122. var s = new a(e.id,i,void 0,e.updatable);
  58123. return s._loadedUniqueId = e.uniqueId,
  58124. Tags && Tags.AddTagsTo(s, e.tags),
  58125. e.delayLoadingFile ? (s.delayLoadState = 4,
  58126. s.delayLoadingFile = o + e.delayLoadingFile,
  58127. s._boundingInfo = new BoundingInfo(Vector3.FromArray(e.boundingBoxMinimum),Vector3.FromArray(e.boundingBoxMaximum)),
  58128. s._delayInfo = [],
  58129. e.hasUVs && s._delayInfo.push(VertexBuffer.UVKind),
  58130. e.hasUVs2 && s._delayInfo.push(VertexBuffer.UV2Kind),
  58131. e.hasUVs3 && s._delayInfo.push(VertexBuffer.UV3Kind),
  58132. e.hasUVs4 && s._delayInfo.push(VertexBuffer.UV4Kind),
  58133. e.hasUVs5 && s._delayInfo.push(VertexBuffer.UV5Kind),
  58134. e.hasUVs6 && s._delayInfo.push(VertexBuffer.UV6Kind),
  58135. e.hasColors && s._delayInfo.push(VertexBuffer.ColorKind),
  58136. e.hasMatricesIndices && s._delayInfo.push(VertexBuffer.MatricesIndicesKind),
  58137. e.hasMatricesWeights && s._delayInfo.push(VertexBuffer.MatricesWeightsKind),
  58138. s._delayLoadingFunction = VertexData.ImportVertexData) : VertexData.ImportVertexData(e, s),
  58139. i.pushGeometry(s, !0),
  58140. s
  58141. }
  58142. ,
  58143. a
  58144. }()
  58145. , Light = function(a) {
  58146. __extends(e, a);
  58147. function e(i, o) {
  58148. var s = a.call(this, i, o) || this;
  58149. return s.diffuse = new Color3(1,1,1),
  58150. s.specular = new Color3(1,1,1),
  58151. s.falloffType = e.FALLOFF_DEFAULT,
  58152. s.intensity = 1,
  58153. s._range = Number.MAX_VALUE,
  58154. s._inverseSquaredRange = 0,
  58155. s._photometricScale = 1,
  58156. s._intensityMode = e.INTENSITYMODE_AUTOMATIC,
  58157. s._radius = 1e-5,
  58158. s.renderPriority = 0,
  58159. s._shadowEnabled = !0,
  58160. s._excludeWithLayerMask = 0,
  58161. s._includeOnlyWithLayerMask = 0,
  58162. s._lightmapMode = 0,
  58163. s._excludedMeshesIds = new Array,
  58164. s._includedOnlyMeshesIds = new Array,
  58165. s._isLight = !0,
  58166. s.getScene().addLight(s),
  58167. s._uniformBuffer = new UniformBuffer(s.getScene().getEngine(),void 0,void 0,i),
  58168. s._buildUniformLayout(),
  58169. s.includedOnlyMeshes = new Array,
  58170. s.excludedMeshes = new Array,
  58171. s._resyncMeshes(),
  58172. s
  58173. }
  58174. return Object.defineProperty(e.prototype, "range", {
  58175. get: function() {
  58176. return this._range
  58177. },
  58178. set: function(i) {
  58179. this._range = i,
  58180. this._inverseSquaredRange = 1 / (this.range * this.range)
  58181. },
  58182. enumerable: !1,
  58183. configurable: !0
  58184. }),
  58185. Object.defineProperty(e.prototype, "intensityMode", {
  58186. get: function() {
  58187. return this._intensityMode
  58188. },
  58189. set: function(i) {
  58190. this._intensityMode = i,
  58191. this._computePhotometricScale()
  58192. },
  58193. enumerable: !1,
  58194. configurable: !0
  58195. }),
  58196. Object.defineProperty(e.prototype, "radius", {
  58197. get: function() {
  58198. return this._radius
  58199. },
  58200. set: function(i) {
  58201. this._radius = i,
  58202. this._computePhotometricScale()
  58203. },
  58204. enumerable: !1,
  58205. configurable: !0
  58206. }),
  58207. Object.defineProperty(e.prototype, "shadowEnabled", {
  58208. get: function() {
  58209. return this._shadowEnabled
  58210. },
  58211. set: function(i) {
  58212. this._shadowEnabled !== i && (this._shadowEnabled = i,
  58213. this._markMeshesAsLightDirty())
  58214. },
  58215. enumerable: !1,
  58216. configurable: !0
  58217. }),
  58218. Object.defineProperty(e.prototype, "includedOnlyMeshes", {
  58219. get: function() {
  58220. return this._includedOnlyMeshes
  58221. },
  58222. set: function(i) {
  58223. this._includedOnlyMeshes = i,
  58224. this._hookArrayForIncludedOnly(i)
  58225. },
  58226. enumerable: !1,
  58227. configurable: !0
  58228. }),
  58229. Object.defineProperty(e.prototype, "excludedMeshes", {
  58230. get: function() {
  58231. return this._excludedMeshes
  58232. },
  58233. set: function(i) {
  58234. this._excludedMeshes = i,
  58235. this._hookArrayForExcluded(i)
  58236. },
  58237. enumerable: !1,
  58238. configurable: !0
  58239. }),
  58240. Object.defineProperty(e.prototype, "excludeWithLayerMask", {
  58241. get: function() {
  58242. return this._excludeWithLayerMask
  58243. },
  58244. set: function(i) {
  58245. this._excludeWithLayerMask = i,
  58246. this._resyncMeshes()
  58247. },
  58248. enumerable: !1,
  58249. configurable: !0
  58250. }),
  58251. Object.defineProperty(e.prototype, "includeOnlyWithLayerMask", {
  58252. get: function() {
  58253. return this._includeOnlyWithLayerMask
  58254. },
  58255. set: function(i) {
  58256. this._includeOnlyWithLayerMask = i,
  58257. this._resyncMeshes()
  58258. },
  58259. enumerable: !1,
  58260. configurable: !0
  58261. }),
  58262. Object.defineProperty(e.prototype, "lightmapMode", {
  58263. get: function() {
  58264. return this._lightmapMode
  58265. },
  58266. set: function(i) {
  58267. this._lightmapMode !== i && (this._lightmapMode = i,
  58268. this._markMeshesAsLightDirty())
  58269. },
  58270. enumerable: !1,
  58271. configurable: !0
  58272. }),
  58273. e.prototype.transferTexturesToEffect = function(i, o) {
  58274. return this
  58275. }
  58276. ,
  58277. e.prototype._bindLight = function(i, o, s, c, d) {
  58278. d === void 0 && (d = !0);
  58279. var _ = i.toString()
  58280. , b = !1;
  58281. if (this._uniformBuffer.bindToEffect(s, "Light" + _),
  58282. this._renderId !== o.getRenderId() || !this._uniformBuffer.useUbo) {
  58283. this._renderId = o.getRenderId();
  58284. var k = this.getScaledIntensity();
  58285. this.transferToEffect(s, _),
  58286. this.diffuse.scaleToRef(k, TmpColors.Color3[0]),
  58287. this._uniformBuffer.updateColor4("vLightDiffuse", TmpColors.Color3[0], this.range, _),
  58288. c && (this.specular.scaleToRef(k, TmpColors.Color3[1]),
  58289. this._uniformBuffer.updateColor4("vLightSpecular", TmpColors.Color3[1], this.radius, _)),
  58290. b = !0
  58291. }
  58292. if (this.transferTexturesToEffect(s, _),
  58293. o.shadowsEnabled && this.shadowEnabled && d) {
  58294. var j = this.getShadowGenerator();
  58295. j && (j.bindShadowLight(_, s),
  58296. b = !0)
  58297. }
  58298. b ? this._uniformBuffer.update() : this._uniformBuffer.bindUniformBuffer()
  58299. }
  58300. ,
  58301. e.prototype.getClassName = function() {
  58302. return "Light"
  58303. }
  58304. ,
  58305. e.prototype.toString = function(i) {
  58306. var o = "Name: " + this.name;
  58307. if (o += ", type: " + ["Point", "Directional", "Spot", "Hemispheric"][this.getTypeID()],
  58308. this.animations)
  58309. for (var s = 0; s < this.animations.length; s++)
  58310. o += ", animation[0]: " + this.animations[s].toString(i);
  58311. return o
  58312. }
  58313. ,
  58314. e.prototype._syncParentEnabledState = function() {
  58315. a.prototype._syncParentEnabledState.call(this),
  58316. this.isDisposed() || this._resyncMeshes()
  58317. }
  58318. ,
  58319. e.prototype.setEnabled = function(i) {
  58320. a.prototype.setEnabled.call(this, i),
  58321. this._resyncMeshes()
  58322. }
  58323. ,
  58324. e.prototype.getShadowGenerator = function() {
  58325. return this._shadowGenerator
  58326. }
  58327. ,
  58328. e.prototype.getAbsolutePosition = function() {
  58329. return Vector3.Zero()
  58330. }
  58331. ,
  58332. e.prototype.canAffectMesh = function(i) {
  58333. return i ? !(this.includedOnlyMeshes && this.includedOnlyMeshes.length > 0 && this.includedOnlyMeshes.indexOf(i) === -1 || this.excludedMeshes && this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(i) !== -1 || this.includeOnlyWithLayerMask !== 0 && (this.includeOnlyWithLayerMask & i.layerMask) === 0 || this.excludeWithLayerMask !== 0 && this.excludeWithLayerMask & i.layerMask) : !0
  58334. }
  58335. ,
  58336. e.prototype.dispose = function(i, o) {
  58337. if (o === void 0 && (o = !1),
  58338. this._shadowGenerator && (this._shadowGenerator.dispose(),
  58339. this._shadowGenerator = null),
  58340. this.getScene().stopAnimation(this),
  58341. this._parentContainer) {
  58342. var s = this._parentContainer.lights.indexOf(this);
  58343. s > -1 && this._parentContainer.lights.splice(s, 1),
  58344. this._parentContainer = null
  58345. }
  58346. for (var c = 0, d = this.getScene().meshes; c < d.length; c++) {
  58347. var _ = d[c];
  58348. _._removeLightSource(this, !0)
  58349. }
  58350. this._uniformBuffer.dispose(),
  58351. this.getScene().removeLight(this),
  58352. a.prototype.dispose.call(this, i, o)
  58353. }
  58354. ,
  58355. e.prototype.getTypeID = function() {
  58356. return 0
  58357. }
  58358. ,
  58359. e.prototype.getScaledIntensity = function() {
  58360. return this._photometricScale * this.intensity
  58361. }
  58362. ,
  58363. e.prototype.clone = function(i, o) {
  58364. o === void 0 && (o = null);
  58365. var s = e.GetConstructorFromName(this.getTypeID(), i, this.getScene());
  58366. if (!s)
  58367. return null;
  58368. var c = SerializationHelper.Clone(s, this);
  58369. return i && (c.name = i),
  58370. o && (c.parent = o),
  58371. c.setEnabled(this.isEnabled()),
  58372. this.onClonedObservable.notifyObservers(c),
  58373. c
  58374. }
  58375. ,
  58376. e.prototype.serialize = function() {
  58377. var i = SerializationHelper.Serialize(this);
  58378. return i.uniqueId = this.uniqueId,
  58379. i.type = this.getTypeID(),
  58380. this.parent && (i.parentId = this.parent.uniqueId),
  58381. this.excludedMeshes.length > 0 && (i.excludedMeshesIds = [],
  58382. this.excludedMeshes.forEach(function(o) {
  58383. i.excludedMeshesIds.push(o.id)
  58384. })),
  58385. this.includedOnlyMeshes.length > 0 && (i.includedOnlyMeshesIds = [],
  58386. this.includedOnlyMeshes.forEach(function(o) {
  58387. i.includedOnlyMeshesIds.push(o.id)
  58388. })),
  58389. SerializationHelper.AppendSerializedAnimations(this, i),
  58390. i.ranges = this.serializeAnimationRanges(),
  58391. i.isEnabled = this.isEnabled(),
  58392. i
  58393. }
  58394. ,
  58395. e.GetConstructorFromName = function(i, o, s) {
  58396. var c = Node$2.Construct("Light_Type_" + i, o, s);
  58397. return c || null
  58398. }
  58399. ,
  58400. e.Parse = function(i, o) {
  58401. var s = e.GetConstructorFromName(i.type, i.name, o);
  58402. if (!s)
  58403. return null;
  58404. var c = SerializationHelper.Parse(s, i, o);
  58405. if (i.excludedMeshesIds && (c._excludedMeshesIds = i.excludedMeshesIds),
  58406. i.includedOnlyMeshesIds && (c._includedOnlyMeshesIds = i.includedOnlyMeshesIds),
  58407. i.parentId && (c._waitingParentId = i.parentId),
  58408. i.falloffType !== void 0 && (c.falloffType = i.falloffType),
  58409. i.lightmapMode !== void 0 && (c.lightmapMode = i.lightmapMode),
  58410. i.animations) {
  58411. for (var d = 0; d < i.animations.length; d++) {
  58412. var _ = i.animations[d]
  58413. , b = GetClass("BABYLON.Animation");
  58414. b && c.animations.push(b.Parse(_))
  58415. }
  58416. Node$2.ParseAnimationRanges(c, i, o)
  58417. }
  58418. return i.autoAnimate && o.beginAnimation(c, i.autoAnimateFrom, i.autoAnimateTo, i.autoAnimateLoop, i.autoAnimateSpeed || 1),
  58419. i.isEnabled !== void 0 && c.setEnabled(i.isEnabled),
  58420. c
  58421. }
  58422. ,
  58423. e.prototype._hookArrayForExcluded = function(i) {
  58424. var o = this
  58425. , s = i.push;
  58426. i.push = function() {
  58427. for (var k = [], j = 0; j < arguments.length; j++)
  58428. k[j] = arguments[j];
  58429. for (var $ = s.apply(i, k), _e = 0, et = k; _e < et.length; _e++) {
  58430. var tt = et[_e];
  58431. tt._resyncLightSource(o)
  58432. }
  58433. return $
  58434. }
  58435. ;
  58436. var c = i.splice;
  58437. i.splice = function(k, j) {
  58438. for (var $ = c.apply(i, [k, j]), _e = 0, et = $; _e < et.length; _e++) {
  58439. var tt = et[_e];
  58440. tt._resyncLightSource(o)
  58441. }
  58442. return $
  58443. }
  58444. ;
  58445. for (var d = 0, _ = i; d < _.length; d++) {
  58446. var b = _[d];
  58447. b._resyncLightSource(this)
  58448. }
  58449. }
  58450. ,
  58451. e.prototype._hookArrayForIncludedOnly = function(i) {
  58452. var o = this
  58453. , s = i.push;
  58454. i.push = function() {
  58455. for (var d = [], _ = 0; _ < arguments.length; _++)
  58456. d[_] = arguments[_];
  58457. var b = s.apply(i, d);
  58458. return o._resyncMeshes(),
  58459. b
  58460. }
  58461. ;
  58462. var c = i.splice;
  58463. i.splice = function(d, _) {
  58464. var b = c.apply(i, [d, _]);
  58465. return o._resyncMeshes(),
  58466. b
  58467. }
  58468. ,
  58469. this._resyncMeshes()
  58470. }
  58471. ,
  58472. e.prototype._resyncMeshes = function() {
  58473. for (var i = 0, o = this.getScene().meshes; i < o.length; i++) {
  58474. var s = o[i];
  58475. s._resyncLightSource(this)
  58476. }
  58477. }
  58478. ,
  58479. e.prototype._markMeshesAsLightDirty = function() {
  58480. for (var i = 0, o = this.getScene().meshes; i < o.length; i++) {
  58481. var s = o[i];
  58482. s.lightSources.indexOf(this) !== -1 && s._markSubMeshesAsLightDirty()
  58483. }
  58484. }
  58485. ,
  58486. e.prototype._computePhotometricScale = function() {
  58487. this._photometricScale = this._getPhotometricScale(),
  58488. this.getScene().resetCachedMaterial()
  58489. }
  58490. ,
  58491. e.prototype._getPhotometricScale = function() {
  58492. var i = 0
  58493. , o = this.getTypeID()
  58494. , s = this.intensityMode;
  58495. switch (s === e.INTENSITYMODE_AUTOMATIC && (o === e.LIGHTTYPEID_DIRECTIONALLIGHT ? s = e.INTENSITYMODE_ILLUMINANCE : s = e.INTENSITYMODE_LUMINOUSINTENSITY),
  58496. o) {
  58497. case e.LIGHTTYPEID_POINTLIGHT:
  58498. case e.LIGHTTYPEID_SPOTLIGHT:
  58499. switch (s) {
  58500. case e.INTENSITYMODE_LUMINOUSPOWER:
  58501. i = 1 / (4 * Math.PI);
  58502. break;
  58503. case e.INTENSITYMODE_LUMINOUSINTENSITY:
  58504. i = 1;
  58505. break;
  58506. case e.INTENSITYMODE_LUMINANCE:
  58507. i = this.radius * this.radius;
  58508. break
  58509. }
  58510. break;
  58511. case e.LIGHTTYPEID_DIRECTIONALLIGHT:
  58512. switch (s) {
  58513. case e.INTENSITYMODE_ILLUMINANCE:
  58514. i = 1;
  58515. break;
  58516. case e.INTENSITYMODE_LUMINANCE:
  58517. var c = this.radius;
  58518. c = Math.max(c, .001);
  58519. var d = 2 * Math.PI * (1 - Math.cos(c));
  58520. i = d;
  58521. break
  58522. }
  58523. break;
  58524. case e.LIGHTTYPEID_HEMISPHERICLIGHT:
  58525. i = 1;
  58526. break
  58527. }
  58528. return i
  58529. }
  58530. ,
  58531. e.prototype._reorderLightsInScene = function() {
  58532. var i = this.getScene();
  58533. this._renderPriority != 0 && (i.requireLightSorting = !0),
  58534. this.getScene().sortLightsByPriority()
  58535. }
  58536. ,
  58537. e.FALLOFF_DEFAULT = LightConstants.FALLOFF_DEFAULT,
  58538. e.FALLOFF_PHYSICAL = LightConstants.FALLOFF_PHYSICAL,
  58539. e.FALLOFF_GLTF = LightConstants.FALLOFF_GLTF,
  58540. e.FALLOFF_STANDARD = LightConstants.FALLOFF_STANDARD,
  58541. e.LIGHTMAP_DEFAULT = LightConstants.LIGHTMAP_DEFAULT,
  58542. e.LIGHTMAP_SPECULAR = LightConstants.LIGHTMAP_SPECULAR,
  58543. e.LIGHTMAP_SHADOWSONLY = LightConstants.LIGHTMAP_SHADOWSONLY,
  58544. e.INTENSITYMODE_AUTOMATIC = LightConstants.INTENSITYMODE_AUTOMATIC,
  58545. e.INTENSITYMODE_LUMINOUSPOWER = LightConstants.INTENSITYMODE_LUMINOUSPOWER,
  58546. e.INTENSITYMODE_LUMINOUSINTENSITY = LightConstants.INTENSITYMODE_LUMINOUSINTENSITY,
  58547. e.INTENSITYMODE_ILLUMINANCE = LightConstants.INTENSITYMODE_ILLUMINANCE,
  58548. e.INTENSITYMODE_LUMINANCE = LightConstants.INTENSITYMODE_LUMINANCE,
  58549. e.LIGHTTYPEID_POINTLIGHT = LightConstants.LIGHTTYPEID_POINTLIGHT,
  58550. e.LIGHTTYPEID_DIRECTIONALLIGHT = LightConstants.LIGHTTYPEID_DIRECTIONALLIGHT,
  58551. e.LIGHTTYPEID_SPOTLIGHT = LightConstants.LIGHTTYPEID_SPOTLIGHT,
  58552. e.LIGHTTYPEID_HEMISPHERICLIGHT = LightConstants.LIGHTTYPEID_HEMISPHERICLIGHT,
  58553. __decorate([serializeAsColor3()], e.prototype, "diffuse", void 0),
  58554. __decorate([serializeAsColor3()], e.prototype, "specular", void 0),
  58555. __decorate([serialize()], e.prototype, "falloffType", void 0),
  58556. __decorate([serialize()], e.prototype, "intensity", void 0),
  58557. __decorate([serialize()], e.prototype, "range", null),
  58558. __decorate([serialize()], e.prototype, "intensityMode", null),
  58559. __decorate([serialize()], e.prototype, "radius", null),
  58560. __decorate([serialize()], e.prototype, "_renderPriority", void 0),
  58561. __decorate([expandToProperty("_reorderLightsInScene")], e.prototype, "renderPriority", void 0),
  58562. __decorate([serialize("shadowEnabled")], e.prototype, "_shadowEnabled", void 0),
  58563. __decorate([serialize("excludeWithLayerMask")], e.prototype, "_excludeWithLayerMask", void 0),
  58564. __decorate([serialize("includeOnlyWithLayerMask")], e.prototype, "_includeOnlyWithLayerMask", void 0),
  58565. __decorate([serialize("lightmapMode")], e.prototype, "_lightmapMode", void 0),
  58566. e
  58567. }(Node$2)
  58568. , ThinMaterialHelper = function() {
  58569. function a() {}
  58570. return a.BindClipPlane = function(e, i) {
  58571. if (i.clipPlane) {
  58572. var o = i.clipPlane;
  58573. e.setFloat4("vClipPlane", o.normal.x, o.normal.y, o.normal.z, o.d)
  58574. }
  58575. if (i.clipPlane2) {
  58576. var o = i.clipPlane2;
  58577. e.setFloat4("vClipPlane2", o.normal.x, o.normal.y, o.normal.z, o.d)
  58578. }
  58579. if (i.clipPlane3) {
  58580. var o = i.clipPlane3;
  58581. e.setFloat4("vClipPlane3", o.normal.x, o.normal.y, o.normal.z, o.d)
  58582. }
  58583. if (i.clipPlane4) {
  58584. var o = i.clipPlane4;
  58585. e.setFloat4("vClipPlane4", o.normal.x, o.normal.y, o.normal.z, o.d)
  58586. }
  58587. if (i.clipPlane5) {
  58588. var o = i.clipPlane5;
  58589. e.setFloat4("vClipPlane5", o.normal.x, o.normal.y, o.normal.z, o.d)
  58590. }
  58591. if (i.clipPlane6) {
  58592. var o = i.clipPlane6;
  58593. e.setFloat4("vClipPlane6", o.normal.x, o.normal.y, o.normal.z, o.d)
  58594. }
  58595. }
  58596. ,
  58597. a
  58598. }()
  58599. , MaterialHelper = function() {
  58600. function a() {}
  58601. return a.BindSceneUniformBuffer = function(e, i) {
  58602. i.bindToEffect(e, "Scene")
  58603. }
  58604. ,
  58605. a.PrepareDefinesForMergedUV = function(e, i, o) {
  58606. i._needUVs = !0,
  58607. i[o] = !0,
  58608. e.getTextureMatrix().isIdentityAs3x2() ? (i[o + "DIRECTUV"] = e.coordinatesIndex + 1,
  58609. i["MAINUV" + (e.coordinatesIndex + 1)] = !0) : i[o + "DIRECTUV"] = 0
  58610. }
  58611. ,
  58612. a.BindTextureMatrix = function(e, i, o) {
  58613. var s = e.getTextureMatrix();
  58614. i.updateMatrix(o + "Matrix", s)
  58615. }
  58616. ,
  58617. a.GetFogState = function(e, i) {
  58618. return i.fogEnabled && e.applyFog && i.fogMode !== Scene.FOGMODE_NONE
  58619. }
  58620. ,
  58621. a.PrepareDefinesForMisc = function(e, i, o, s, c, d, _) {
  58622. _._areMiscDirty && (_.LOGARITHMICDEPTH = o,
  58623. _.POINTSIZE = s,
  58624. _.FOG = c && this.GetFogState(e, i),
  58625. _.NONUNIFORMSCALING = e.nonUniformScaling,
  58626. _.ALPHATEST = d)
  58627. }
  58628. ,
  58629. a.PrepareDefinesForFrameBoundValues = function(e, i, o, s, c, d) {
  58630. c === void 0 && (c = null),
  58631. d === void 0 && (d = !1);
  58632. var _ = !1
  58633. , b = !1
  58634. , k = !1
  58635. , j = !1
  58636. , $ = !1
  58637. , _e = !1
  58638. , et = !1;
  58639. b = c == null ? e.clipPlane !== void 0 && e.clipPlane !== null : c,
  58640. k = c == null ? e.clipPlane2 !== void 0 && e.clipPlane2 !== null : c,
  58641. j = c == null ? e.clipPlane3 !== void 0 && e.clipPlane3 !== null : c,
  58642. $ = c == null ? e.clipPlane4 !== void 0 && e.clipPlane4 !== null : c,
  58643. _e = c == null ? e.clipPlane5 !== void 0 && e.clipPlane5 !== null : c,
  58644. et = c == null ? e.clipPlane6 !== void 0 && e.clipPlane6 !== null : c,
  58645. o.CLIPPLANE !== b && (o.CLIPPLANE = b,
  58646. _ = !0),
  58647. o.CLIPPLANE2 !== k && (o.CLIPPLANE2 = k,
  58648. _ = !0),
  58649. o.CLIPPLANE3 !== j && (o.CLIPPLANE3 = j,
  58650. _ = !0),
  58651. o.CLIPPLANE4 !== $ && (o.CLIPPLANE4 = $,
  58652. _ = !0),
  58653. o.CLIPPLANE5 !== _e && (o.CLIPPLANE5 = _e,
  58654. _ = !0),
  58655. o.CLIPPLANE6 !== et && (o.CLIPPLANE6 = et,
  58656. _ = !0),
  58657. o.DEPTHPREPASS !== !i.getColorWrite() && (o.DEPTHPREPASS = !o.DEPTHPREPASS,
  58658. _ = !0),
  58659. o.INSTANCES !== s && (o.INSTANCES = s,
  58660. _ = !0),
  58661. o.THIN_INSTANCES !== d && (o.THIN_INSTANCES = d,
  58662. _ = !0),
  58663. _ && o.markAsUnprocessed()
  58664. }
  58665. ,
  58666. a.PrepareDefinesForBones = function(e, i) {
  58667. if (e.useBones && e.computeBonesUsingShaders && e.skeleton) {
  58668. i.NUM_BONE_INFLUENCERS = e.numBoneInfluencers;
  58669. var o = i.BONETEXTURE !== void 0;
  58670. if (e.skeleton.isUsingTextureForMatrices && o)
  58671. i.BONETEXTURE = !0;
  58672. else {
  58673. i.BonesPerMesh = e.skeleton.bones.length + 1,
  58674. i.BONETEXTURE = o ? !1 : void 0;
  58675. var s = e.getScene().prePassRenderer;
  58676. if (s && s.enabled) {
  58677. var c = s.excludedSkinnedMesh.indexOf(e) === -1;
  58678. i.BONES_VELOCITY_ENABLED = c
  58679. }
  58680. }
  58681. } else
  58682. i.NUM_BONE_INFLUENCERS = 0,
  58683. i.BonesPerMesh = 0
  58684. }
  58685. ,
  58686. a.PrepareDefinesForMorphTargets = function(e, i) {
  58687. var o = e.morphTargetManager;
  58688. o ? (i.MORPHTARGETS_UV = o.supportsUVs && i.UV1,
  58689. i.MORPHTARGETS_TANGENT = o.supportsTangents && i.TANGENT,
  58690. i.MORPHTARGETS_NORMAL = o.supportsNormals && i.NORMAL,
  58691. i.MORPHTARGETS = o.numInfluencers > 0,
  58692. i.NUM_MORPH_INFLUENCERS = o.numInfluencers,
  58693. i.MORPHTARGETS_TEXTURE = o.isUsingTextureForTargets) : (i.MORPHTARGETS_UV = !1,
  58694. i.MORPHTARGETS_TANGENT = !1,
  58695. i.MORPHTARGETS_NORMAL = !1,
  58696. i.MORPHTARGETS = !1,
  58697. i.NUM_MORPH_INFLUENCERS = 0)
  58698. }
  58699. ,
  58700. a.PrepareDefinesForBakedVertexAnimation = function(e, i) {
  58701. var o = e.bakedVertexAnimationManager;
  58702. i.BAKED_VERTEX_ANIMATION_TEXTURE = !!(o && o.isEnabled)
  58703. }
  58704. ,
  58705. a.PrepareDefinesForAttributes = function(e, i, o, s, c, d, _) {
  58706. if (c === void 0 && (c = !1),
  58707. d === void 0 && (d = !0),
  58708. _ === void 0 && (_ = !0),
  58709. !i._areAttributesDirty && i._needNormals === i._normals && i._needUVs === i._uvs)
  58710. return !1;
  58711. i._normals = i._needNormals,
  58712. i._uvs = i._needUVs,
  58713. i.NORMAL = i._needNormals && e.isVerticesDataPresent(VertexBuffer.NormalKind),
  58714. i._needNormals && e.isVerticesDataPresent(VertexBuffer.TangentKind) && (i.TANGENT = !0);
  58715. for (var b = 1; b <= 6; ++b)
  58716. i["UV" + b] = i._needUVs ? e.isVerticesDataPresent("uv" + (b === 1 ? "" : b)) : !1;
  58717. if (o) {
  58718. var k = e.useVertexColors && e.isVerticesDataPresent(VertexBuffer.ColorKind);
  58719. i.VERTEXCOLOR = k,
  58720. i.VERTEXALPHA = e.hasVertexAlpha && k && d
  58721. }
  58722. return s && this.PrepareDefinesForBones(e, i),
  58723. c && this.PrepareDefinesForMorphTargets(e, i),
  58724. _ && this.PrepareDefinesForBakedVertexAnimation(e, i),
  58725. !0
  58726. }
  58727. ,
  58728. a.PrepareDefinesForMultiview = function(e, i) {
  58729. if (e.activeCamera) {
  58730. var o = i.MULTIVIEW;
  58731. i.MULTIVIEW = e.activeCamera.outputRenderTarget !== null && e.activeCamera.outputRenderTarget.getViewCount() > 1,
  58732. i.MULTIVIEW != o && i.markAsUnprocessed()
  58733. }
  58734. }
  58735. ,
  58736. a.PrepareDefinesForOIT = function(e, i, o) {
  58737. var s = i.ORDER_INDEPENDENT_TRANSPARENCY
  58738. , c = i.ORDER_INDEPENDENT_TRANSPARENCY_16BITS;
  58739. i.ORDER_INDEPENDENT_TRANSPARENCY = e.useOrderIndependentTransparency && o,
  58740. i.ORDER_INDEPENDENT_TRANSPARENCY_16BITS = !e.getEngine().getCaps().textureFloatLinearFiltering,
  58741. (s !== i.ORDER_INDEPENDENT_TRANSPARENCY || c !== i.ORDER_INDEPENDENT_TRANSPARENCY_16BITS) && i.markAsUnprocessed()
  58742. }
  58743. ,
  58744. a.PrepareDefinesForPrePass = function(e, i, o) {
  58745. var s = i.PREPASS;
  58746. if (!!i._arePrePassDirty) {
  58747. var c = [{
  58748. type: 1,
  58749. define: "PREPASS_POSITION",
  58750. index: "PREPASS_POSITION_INDEX"
  58751. }, {
  58752. type: 2,
  58753. define: "PREPASS_VELOCITY",
  58754. index: "PREPASS_VELOCITY_INDEX"
  58755. }, {
  58756. type: 3,
  58757. define: "PREPASS_REFLECTIVITY",
  58758. index: "PREPASS_REFLECTIVITY_INDEX"
  58759. }, {
  58760. type: 0,
  58761. define: "PREPASS_IRRADIANCE",
  58762. index: "PREPASS_IRRADIANCE_INDEX"
  58763. }, {
  58764. type: 7,
  58765. define: "PREPASS_ALBEDO_SQRT",
  58766. index: "PREPASS_ALBEDO_SQRT_INDEX"
  58767. }, {
  58768. type: 5,
  58769. define: "PREPASS_DEPTH",
  58770. index: "PREPASS_DEPTH_INDEX"
  58771. }, {
  58772. type: 6,
  58773. define: "PREPASS_NORMAL",
  58774. index: "PREPASS_NORMAL_INDEX"
  58775. }];
  58776. if (e.prePassRenderer && e.prePassRenderer.enabled && o) {
  58777. i.PREPASS = !0,
  58778. i.SCENE_MRT_COUNT = e.prePassRenderer.mrtCount;
  58779. for (var d = 0; d < c.length; d++) {
  58780. var _ = e.prePassRenderer.getIndex(c[d].type);
  58781. _ !== -1 ? (i[c[d].define] = !0,
  58782. i[c[d].index] = _) : i[c[d].define] = !1
  58783. }
  58784. } else {
  58785. i.PREPASS = !1;
  58786. for (var d = 0; d < c.length; d++)
  58787. i[c[d].define] = !1
  58788. }
  58789. i.PREPASS != s && (i.markAsUnprocessed(),
  58790. i.markAsImageProcessingDirty())
  58791. }
  58792. }
  58793. ,
  58794. a.PrepareDefinesForLight = function(e, i, o, s, c, d, _) {
  58795. switch (_.needNormals = !0,
  58796. c["LIGHT" + s] === void 0 && (_.needRebuild = !0),
  58797. c["LIGHT" + s] = !0,
  58798. c["SPOTLIGHT" + s] = !1,
  58799. c["HEMILIGHT" + s] = !1,
  58800. c["POINTLIGHT" + s] = !1,
  58801. c["DIRLIGHT" + s] = !1,
  58802. o.prepareLightSpecificDefines(c, s),
  58803. c["LIGHT_FALLOFF_PHYSICAL" + s] = !1,
  58804. c["LIGHT_FALLOFF_GLTF" + s] = !1,
  58805. c["LIGHT_FALLOFF_STANDARD" + s] = !1,
  58806. o.falloffType) {
  58807. case Light.FALLOFF_GLTF:
  58808. c["LIGHT_FALLOFF_GLTF" + s] = !0;
  58809. break;
  58810. case Light.FALLOFF_PHYSICAL:
  58811. c["LIGHT_FALLOFF_PHYSICAL" + s] = !0;
  58812. break;
  58813. case Light.FALLOFF_STANDARD:
  58814. c["LIGHT_FALLOFF_STANDARD" + s] = !0;
  58815. break
  58816. }
  58817. if (d && !o.specular.equalsFloats(0, 0, 0) && (_.specularEnabled = !0),
  58818. c["SHADOW" + s] = !1,
  58819. c["SHADOWCSM" + s] = !1,
  58820. c["SHADOWCSMDEBUG" + s] = !1,
  58821. c["SHADOWCSMNUM_CASCADES" + s] = !1,
  58822. c["SHADOWCSMUSESHADOWMAXZ" + s] = !1,
  58823. c["SHADOWCSMNOBLEND" + s] = !1,
  58824. c["SHADOWCSM_RIGHTHANDED" + s] = !1,
  58825. c["SHADOWPCF" + s] = !1,
  58826. c["SHADOWPCSS" + s] = !1,
  58827. c["SHADOWPOISSON" + s] = !1,
  58828. c["SHADOWESM" + s] = !1,
  58829. c["SHADOWCLOSEESM" + s] = !1,
  58830. c["SHADOWCUBE" + s] = !1,
  58831. c["SHADOWLOWQUALITY" + s] = !1,
  58832. c["SHADOWMEDIUMQUALITY" + s] = !1,
  58833. i && i.receiveShadows && e.shadowsEnabled && o.shadowEnabled) {
  58834. var b = o.getShadowGenerator();
  58835. if (b) {
  58836. var k = b.getShadowMap();
  58837. k && k.renderList && k.renderList.length > 0 && (_.shadowEnabled = !0,
  58838. b.prepareDefines(c, s))
  58839. }
  58840. }
  58841. o.lightmapMode != Light.LIGHTMAP_DEFAULT ? (_.lightmapMode = !0,
  58842. c["LIGHTMAPEXCLUDED" + s] = !0,
  58843. c["LIGHTMAPNOSPECULAR" + s] = o.lightmapMode == Light.LIGHTMAP_SHADOWSONLY) : (c["LIGHTMAPEXCLUDED" + s] = !1,
  58844. c["LIGHTMAPNOSPECULAR" + s] = !1)
  58845. }
  58846. ,
  58847. a.PrepareDefinesForLights = function(e, i, o, s, c, d) {
  58848. if (c === void 0 && (c = 4),
  58849. d === void 0 && (d = !1),
  58850. !o._areLightsDirty)
  58851. return o._needNormals;
  58852. var _ = 0
  58853. , b = {
  58854. needNormals: !1,
  58855. needRebuild: !1,
  58856. lightmapMode: !1,
  58857. shadowEnabled: !1,
  58858. specularEnabled: !1
  58859. };
  58860. if (e.lightsEnabled && !d)
  58861. for (var k = 0, j = i.lightSources; k < j.length; k++) {
  58862. var $ = j[k];
  58863. if (this.PrepareDefinesForLight(e, i, $, _, o, s, b),
  58864. _++,
  58865. _ === c)
  58866. break
  58867. }
  58868. o.SPECULARTERM = b.specularEnabled,
  58869. o.SHADOWS = b.shadowEnabled;
  58870. for (var _e = _; _e < c; _e++)
  58871. o["LIGHT" + _e] !== void 0 && (o["LIGHT" + _e] = !1,
  58872. o["HEMILIGHT" + _e] = !1,
  58873. o["POINTLIGHT" + _e] = !1,
  58874. o["DIRLIGHT" + _e] = !1,
  58875. o["SPOTLIGHT" + _e] = !1,
  58876. o["SHADOW" + _e] = !1,
  58877. o["SHADOWCSM" + _e] = !1,
  58878. o["SHADOWCSMDEBUG" + _e] = !1,
  58879. o["SHADOWCSMNUM_CASCADES" + _e] = !1,
  58880. o["SHADOWCSMUSESHADOWMAXZ" + _e] = !1,
  58881. o["SHADOWCSMNOBLEND" + _e] = !1,
  58882. o["SHADOWCSM_RIGHTHANDED" + _e] = !1,
  58883. o["SHADOWPCF" + _e] = !1,
  58884. o["SHADOWPCSS" + _e] = !1,
  58885. o["SHADOWPOISSON" + _e] = !1,
  58886. o["SHADOWESM" + _e] = !1,
  58887. o["SHADOWCLOSEESM" + _e] = !1,
  58888. o["SHADOWCUBE" + _e] = !1,
  58889. o["SHADOWLOWQUALITY" + _e] = !1,
  58890. o["SHADOWMEDIUMQUALITY" + _e] = !1);
  58891. var et = e.getEngine().getCaps();
  58892. return o.SHADOWFLOAT === void 0 && (b.needRebuild = !0),
  58893. o.SHADOWFLOAT = b.shadowEnabled && (et.textureFloatRender && et.textureFloatLinearFiltering || et.textureHalfFloatRender && et.textureHalfFloatLinearFiltering),
  58894. o.LIGHTMAPEXCLUDED = b.lightmapMode,
  58895. b.needRebuild && o.rebuild(),
  58896. b.needNormals
  58897. }
  58898. ,
  58899. a.PrepareUniformsAndSamplersForLight = function(e, i, o, s, c, d) {
  58900. c === void 0 && (c = null),
  58901. d === void 0 && (d = !1),
  58902. c && c.push("Light" + e),
  58903. !d && (i.push("vLightData" + e, "vLightDiffuse" + e, "vLightSpecular" + e, "vLightDirection" + e, "vLightFalloff" + e, "vLightGround" + e, "lightMatrix" + e, "shadowsInfo" + e, "depthValues" + e),
  58904. o.push("shadowSampler" + e),
  58905. o.push("depthSampler" + e),
  58906. i.push("viewFrustumZ" + e, "cascadeBlendFactor" + e, "lightSizeUVCorrection" + e, "depthCorrection" + e, "penumbraDarkness" + e, "frustumLengths" + e),
  58907. s && (o.push("projectionLightSampler" + e),
  58908. i.push("textureProjectionMatrix" + e)))
  58909. }
  58910. ,
  58911. a.PrepareUniformsAndSamplersList = function(e, i, o, s) {
  58912. s === void 0 && (s = 4);
  58913. var c, d = null;
  58914. if (e.uniformsNames) {
  58915. var _ = e;
  58916. c = _.uniformsNames,
  58917. d = _.uniformBuffersNames,
  58918. i = _.samplers,
  58919. o = _.defines,
  58920. s = _.maxSimultaneousLights || 0
  58921. } else
  58922. c = e,
  58923. i || (i = []);
  58924. for (var b = 0; b < s && o["LIGHT" + b]; b++)
  58925. this.PrepareUniformsAndSamplersForLight(b, c, i, o["PROJECTEDLIGHTTEXTURE" + b], d);
  58926. o.NUM_MORPH_INFLUENCERS && c.push("morphTargetInfluences"),
  58927. o.BAKED_VERTEX_ANIMATION_TEXTURE && (c.push("bakedVertexAnimationSettings"),
  58928. c.push("bakedVertexAnimationTextureSizeInverted"),
  58929. c.push("bakedVertexAnimationTime"),
  58930. i.push("bakedVertexAnimationTexture"))
  58931. }
  58932. ,
  58933. a.HandleFallbacksForShadows = function(e, i, o, s) {
  58934. o === void 0 && (o = 4),
  58935. s === void 0 && (s = 0);
  58936. for (var c = 0, d = 0; d < o && e["LIGHT" + d]; d++)
  58937. d > 0 && (c = s + d,
  58938. i.addFallback(c, "LIGHT" + d)),
  58939. e.SHADOWS || (e["SHADOW" + d] && i.addFallback(s, "SHADOW" + d),
  58940. e["SHADOWPCF" + d] && i.addFallback(s, "SHADOWPCF" + d),
  58941. e["SHADOWPCSS" + d] && i.addFallback(s, "SHADOWPCSS" + d),
  58942. e["SHADOWPOISSON" + d] && i.addFallback(s, "SHADOWPOISSON" + d),
  58943. e["SHADOWESM" + d] && i.addFallback(s, "SHADOWESM" + d),
  58944. e["SHADOWCLOSEESM" + d] && i.addFallback(s, "SHADOWCLOSEESM" + d));
  58945. return c++
  58946. }
  58947. ,
  58948. a.PrepareAttributesForMorphTargetsInfluencers = function(e, i, o) {
  58949. this._TmpMorphInfluencers.NUM_MORPH_INFLUENCERS = o,
  58950. this.PrepareAttributesForMorphTargets(e, i, this._TmpMorphInfluencers)
  58951. }
  58952. ,
  58953. a.PrepareAttributesForMorphTargets = function(e, i, o) {
  58954. var s = o.NUM_MORPH_INFLUENCERS;
  58955. if (s > 0 && EngineStore.LastCreatedEngine) {
  58956. var c = EngineStore.LastCreatedEngine.getCaps().maxVertexAttribs
  58957. , d = i.morphTargetManager;
  58958. if (d != null && d.isUsingTextureForTargets)
  58959. return;
  58960. for (var _ = d && d.supportsNormals && o.NORMAL, b = d && d.supportsTangents && o.TANGENT, k = d && d.supportsUVs && o.UV1, j = 0; j < s; j++)
  58961. e.push(VertexBuffer.PositionKind + j),
  58962. _ && e.push(VertexBuffer.NormalKind + j),
  58963. b && e.push(VertexBuffer.TangentKind + j),
  58964. k && e.push(VertexBuffer.UVKind + "_" + j),
  58965. e.length > c && Logger$2.Error("Cannot add more vertex attributes for mesh " + i.name)
  58966. }
  58967. }
  58968. ,
  58969. a.PrepareAttributesForBakedVertexAnimation = function(e, i, o) {
  58970. var s = o.BAKED_VERTEX_ANIMATION_TEXTURE && o.INSTANCES;
  58971. s && (e.push("bakedVertexAnimationSettingsInstanced"),
  58972. e.push("bakedVertexAnimationTimeInstanced"))
  58973. }
  58974. ,
  58975. a.PrepareAttributesForBones = function(e, i, o, s) {
  58976. o.NUM_BONE_INFLUENCERS > 0 && (s.addCPUSkinningFallback(0, i),
  58977. e.push(VertexBuffer.MatricesIndicesKind),
  58978. e.push(VertexBuffer.MatricesWeightsKind),
  58979. o.NUM_BONE_INFLUENCERS > 4 && (e.push(VertexBuffer.MatricesIndicesExtraKind),
  58980. e.push(VertexBuffer.MatricesWeightsExtraKind)))
  58981. }
  58982. ,
  58983. a.PrepareAttributesForInstances = function(e, i) {
  58984. (i.INSTANCES || i.THIN_INSTANCES) && this.PushAttributesForInstances(e, !!i.PREPASS_VELOCITY)
  58985. }
  58986. ,
  58987. a.PushAttributesForInstances = function(e, i) {
  58988. i === void 0 && (i = !1),
  58989. e.push("world0"),
  58990. e.push("world1"),
  58991. e.push("world2"),
  58992. e.push("world3"),
  58993. i && (e.push("previousWorld0"),
  58994. e.push("previousWorld1"),
  58995. e.push("previousWorld2"),
  58996. e.push("previousWorld3"))
  58997. }
  58998. ,
  58999. a.BindLightProperties = function(e, i, o) {
  59000. e.transferToEffect(i, o + "")
  59001. }
  59002. ,
  59003. a.BindLight = function(e, i, o, s, c, d) {
  59004. d === void 0 && (d = !0),
  59005. e._bindLight(i, o, s, c, d)
  59006. }
  59007. ,
  59008. a.BindLights = function(e, i, o, s, c) {
  59009. c === void 0 && (c = 4);
  59010. for (var d = Math.min(i.lightSources.length, c), _ = 0; _ < d; _++) {
  59011. var b = i.lightSources[_];
  59012. this.BindLight(b, _, e, o, typeof s == "boolean" ? s : s.SPECULARTERM, i.receiveShadows)
  59013. }
  59014. }
  59015. ,
  59016. a.BindFogParameters = function(e, i, o, s) {
  59017. s === void 0 && (s = !1),
  59018. e.fogEnabled && i.applyFog && e.fogMode !== Scene.FOGMODE_NONE && (o.setFloat4("vFogInfos", e.fogMode, e.fogStart, e.fogEnd, e.fogDensity),
  59019. s ? (e.fogColor.toLinearSpaceToRef(this._tempFogColor),
  59020. o.setColor3("vFogColor", this._tempFogColor)) : o.setColor3("vFogColor", e.fogColor))
  59021. }
  59022. ,
  59023. a.BindBonesParameters = function(e, i, o) {
  59024. if (!(!i || !e) && (e.computeBonesUsingShaders && i._bonesComputationForcedToCPU && (e.computeBonesUsingShaders = !1),
  59025. e.useBones && e.computeBonesUsingShaders && e.skeleton)) {
  59026. var s = e.skeleton;
  59027. if (s.isUsingTextureForMatrices && i.getUniformIndex("boneTextureWidth") > -1) {
  59028. var c = s.getTransformMatrixTexture(e);
  59029. i.setTexture("boneSampler", c),
  59030. i.setFloat("boneTextureWidth", 4 * (s.bones.length + 1))
  59031. } else {
  59032. var d = s.getTransformMatrices(e);
  59033. d && (i.setMatrices("mBones", d),
  59034. o && e.getScene().prePassRenderer && e.getScene().prePassRenderer.getIndex(2) && (o.previousBones[e.uniqueId] || (o.previousBones[e.uniqueId] = d.slice()),
  59035. i.setMatrices("mPreviousBones", o.previousBones[e.uniqueId]),
  59036. a._CopyBonesTransformationMatrices(d, o.previousBones[e.uniqueId])))
  59037. }
  59038. }
  59039. }
  59040. ,
  59041. a._CopyBonesTransformationMatrices = function(e, i) {
  59042. return i.set(e),
  59043. i
  59044. }
  59045. ,
  59046. a.BindMorphTargetParameters = function(e, i) {
  59047. var o = e.morphTargetManager;
  59048. !e || !o || i.setFloatArray("morphTargetInfluences", o.influences)
  59049. }
  59050. ,
  59051. a.BindLogDepth = function(e, i, o) {
  59052. if (!e || e.LOGARITHMICDEPTH) {
  59053. var s = o.activeCamera;
  59054. s.mode === Camera$1.ORTHOGRAPHIC_CAMERA && Logger$2.Error("Logarithmic depth is not compatible with orthographic cameras!", 20),
  59055. i.setFloat("logarithmicDepthConstant", 2 / (Math.log(s.maxZ + 1) / Math.LN2))
  59056. }
  59057. }
  59058. ,
  59059. a.BindClipPlane = function(e, i) {
  59060. ThinMaterialHelper.BindClipPlane(e, i)
  59061. }
  59062. ,
  59063. a._TmpMorphInfluencers = {
  59064. NUM_MORPH_INFLUENCERS: 0
  59065. },
  59066. a._tempFogColor = Color3.Black(),
  59067. a
  59068. }()
  59069. , MaterialStencilState = function() {
  59070. function a() {
  59071. this.reset()
  59072. }
  59073. return a.prototype.reset = function() {
  59074. this.enabled = !1,
  59075. this.mask = 255,
  59076. this.func = 519,
  59077. this.funcRef = 1,
  59078. this.funcMask = 255,
  59079. this.opStencilFail = 7680,
  59080. this.opDepthFail = 7680,
  59081. this.opStencilDepthPass = 7681
  59082. }
  59083. ,
  59084. Object.defineProperty(a.prototype, "func", {
  59085. get: function() {
  59086. return this._func
  59087. },
  59088. set: function(e) {
  59089. this._func = e
  59090. },
  59091. enumerable: !1,
  59092. configurable: !0
  59093. }),
  59094. Object.defineProperty(a.prototype, "funcRef", {
  59095. get: function() {
  59096. return this._funcRef
  59097. },
  59098. set: function(e) {
  59099. this._funcRef = e
  59100. },
  59101. enumerable: !1,
  59102. configurable: !0
  59103. }),
  59104. Object.defineProperty(a.prototype, "funcMask", {
  59105. get: function() {
  59106. return this._funcMask
  59107. },
  59108. set: function(e) {
  59109. this._funcMask = e
  59110. },
  59111. enumerable: !1,
  59112. configurable: !0
  59113. }),
  59114. Object.defineProperty(a.prototype, "opStencilFail", {
  59115. get: function() {
  59116. return this._opStencilFail
  59117. },
  59118. set: function(e) {
  59119. this._opStencilFail = e
  59120. },
  59121. enumerable: !1,
  59122. configurable: !0
  59123. }),
  59124. Object.defineProperty(a.prototype, "opDepthFail", {
  59125. get: function() {
  59126. return this._opDepthFail
  59127. },
  59128. set: function(e) {
  59129. this._opDepthFail = e
  59130. },
  59131. enumerable: !1,
  59132. configurable: !0
  59133. }),
  59134. Object.defineProperty(a.prototype, "opStencilDepthPass", {
  59135. get: function() {
  59136. return this._opStencilDepthPass
  59137. },
  59138. set: function(e) {
  59139. this._opStencilDepthPass = e
  59140. },
  59141. enumerable: !1,
  59142. configurable: !0
  59143. }),
  59144. Object.defineProperty(a.prototype, "mask", {
  59145. get: function() {
  59146. return this._mask
  59147. },
  59148. set: function(e) {
  59149. this._mask = e
  59150. },
  59151. enumerable: !1,
  59152. configurable: !0
  59153. }),
  59154. Object.defineProperty(a.prototype, "enabled", {
  59155. get: function() {
  59156. return this._enabled
  59157. },
  59158. set: function(e) {
  59159. this._enabled = e
  59160. },
  59161. enumerable: !1,
  59162. configurable: !0
  59163. }),
  59164. a.prototype.getClassName = function() {
  59165. return "MaterialStencilState"
  59166. }
  59167. ,
  59168. a.prototype.copyTo = function(e) {
  59169. SerializationHelper.Clone(function() {
  59170. return e
  59171. }, this)
  59172. }
  59173. ,
  59174. a.prototype.serialize = function() {
  59175. return SerializationHelper.Serialize(this)
  59176. }
  59177. ,
  59178. a.prototype.parse = function(e, i, o) {
  59179. var s = this;
  59180. SerializationHelper.Parse(function() {
  59181. return s
  59182. }, e, i, o)
  59183. }
  59184. ,
  59185. __decorate([serialize()], a.prototype, "func", null),
  59186. __decorate([serialize()], a.prototype, "funcRef", null),
  59187. __decorate([serialize()], a.prototype, "funcMask", null),
  59188. __decorate([serialize()], a.prototype, "opStencilFail", null),
  59189. __decorate([serialize()], a.prototype, "opDepthFail", null),
  59190. __decorate([serialize()], a.prototype, "opStencilDepthPass", null),
  59191. __decorate([serialize()], a.prototype, "mask", null),
  59192. __decorate([serialize()], a.prototype, "enabled", null),
  59193. a
  59194. }()
  59195. , Material = function() {
  59196. function a(e, i, o) {
  59197. this.shadowDepthWrapper = null,
  59198. this.allowShaderHotSwapping = !0,
  59199. this.metadata = null,
  59200. this.reservedDataStore = null,
  59201. this.checkReadyOnEveryCall = !1,
  59202. this.checkReadyOnlyOnce = !1,
  59203. this.state = "",
  59204. this._alpha = 1,
  59205. this._backFaceCulling = !0,
  59206. this._cullBackFaces = !0,
  59207. this.onCompiled = null,
  59208. this.onError = null,
  59209. this.getRenderTargetTextures = null,
  59210. this.doNotSerialize = !1,
  59211. this._storeEffectOnSubMeshes = !1,
  59212. this.animations = null,
  59213. this.onDisposeObservable = new Observable,
  59214. this._onDisposeObserver = null,
  59215. this._onUnBindObservable = null,
  59216. this._onBindObserver = null,
  59217. this._alphaMode = 2,
  59218. this._needDepthPrePass = !1,
  59219. this.disableDepthWrite = !1,
  59220. this.disableColorWrite = !1,
  59221. this.forceDepthWrite = !1,
  59222. this.depthFunction = 0,
  59223. this.separateCullingPass = !1,
  59224. this._fogEnabled = !0,
  59225. this.pointSize = 1,
  59226. this.zOffset = 0,
  59227. this.zOffsetUnits = 0,
  59228. this.stencil = new MaterialStencilState,
  59229. this._useUBO = !1,
  59230. this._fillMode = a.TriangleFillMode,
  59231. this._cachedDepthWriteState = !1,
  59232. this._cachedColorWriteState = !1,
  59233. this._cachedDepthFunctionState = 0,
  59234. this._indexInSceneMaterialArray = -1,
  59235. this.meshMap = null,
  59236. this._parentContainer = null,
  59237. this._forceAlphaTest = !1,
  59238. this._transparencyMode = null,
  59239. this.name = e,
  59240. this._scene = i || EngineStore.LastCreatedScene,
  59241. this.id = e || Tools.RandomId(),
  59242. this.uniqueId = this._scene.getUniqueId(),
  59243. this._materialContext = this._scene.getEngine().createMaterialContext(),
  59244. this._drawWrapper = new DrawWrapper(this._scene.getEngine(),!1),
  59245. this._drawWrapper.materialContext = this._materialContext,
  59246. this._scene.useRightHandedSystem ? this.sideOrientation = a.ClockWiseSideOrientation : this.sideOrientation = a.CounterClockWiseSideOrientation,
  59247. this._uniformBuffer = new UniformBuffer(this._scene.getEngine(),void 0,void 0,e),
  59248. this._useUBO = this.getScene().getEngine().supportsUniformBuffers,
  59249. o || this._scene.addMaterial(this),
  59250. this._scene.useMaterialMeshMap && (this.meshMap = {})
  59251. }
  59252. return Object.defineProperty(a.prototype, "canRenderToMRT", {
  59253. get: function() {
  59254. return !1
  59255. },
  59256. enumerable: !1,
  59257. configurable: !0
  59258. }),
  59259. Object.defineProperty(a.prototype, "alpha", {
  59260. get: function() {
  59261. return this._alpha
  59262. },
  59263. set: function(e) {
  59264. this._alpha !== e && (this._alpha = e,
  59265. this.markAsDirty(a.MiscDirtyFlag))
  59266. },
  59267. enumerable: !1,
  59268. configurable: !0
  59269. }),
  59270. Object.defineProperty(a.prototype, "backFaceCulling", {
  59271. get: function() {
  59272. return this._backFaceCulling
  59273. },
  59274. set: function(e) {
  59275. this._backFaceCulling !== e && (this._backFaceCulling = e,
  59276. this.markAsDirty(a.TextureDirtyFlag))
  59277. },
  59278. enumerable: !1,
  59279. configurable: !0
  59280. }),
  59281. Object.defineProperty(a.prototype, "cullBackFaces", {
  59282. get: function() {
  59283. return this._cullBackFaces
  59284. },
  59285. set: function(e) {
  59286. this._cullBackFaces !== e && (this._cullBackFaces = e,
  59287. this.markAsDirty(a.TextureDirtyFlag))
  59288. },
  59289. enumerable: !1,
  59290. configurable: !0
  59291. }),
  59292. Object.defineProperty(a.prototype, "hasRenderTargetTextures", {
  59293. get: function() {
  59294. return !1
  59295. },
  59296. enumerable: !1,
  59297. configurable: !0
  59298. }),
  59299. Object.defineProperty(a.prototype, "onDispose", {
  59300. set: function(e) {
  59301. this._onDisposeObserver && this.onDisposeObservable.remove(this._onDisposeObserver),
  59302. this._onDisposeObserver = this.onDisposeObservable.add(e)
  59303. },
  59304. enumerable: !1,
  59305. configurable: !0
  59306. }),
  59307. Object.defineProperty(a.prototype, "onBindObservable", {
  59308. get: function() {
  59309. return this._onBindObservable || (this._onBindObservable = new Observable),
  59310. this._onBindObservable
  59311. },
  59312. enumerable: !1,
  59313. configurable: !0
  59314. }),
  59315. Object.defineProperty(a.prototype, "onBind", {
  59316. set: function(e) {
  59317. this._onBindObserver && this.onBindObservable.remove(this._onBindObserver),
  59318. this._onBindObserver = this.onBindObservable.add(e)
  59319. },
  59320. enumerable: !1,
  59321. configurable: !0
  59322. }),
  59323. Object.defineProperty(a.prototype, "onUnBindObservable", {
  59324. get: function() {
  59325. return this._onUnBindObservable || (this._onUnBindObservable = new Observable),
  59326. this._onUnBindObservable
  59327. },
  59328. enumerable: !1,
  59329. configurable: !0
  59330. }),
  59331. Object.defineProperty(a.prototype, "onEffectCreatedObservable", {
  59332. get: function() {
  59333. return this._onEffectCreatedObservable || (this._onEffectCreatedObservable = new Observable),
  59334. this._onEffectCreatedObservable
  59335. },
  59336. enumerable: !1,
  59337. configurable: !0
  59338. }),
  59339. Object.defineProperty(a.prototype, "alphaMode", {
  59340. get: function() {
  59341. return this._alphaMode
  59342. },
  59343. set: function(e) {
  59344. this._alphaMode !== e && (this._alphaMode = e,
  59345. this.markAsDirty(a.TextureDirtyFlag))
  59346. },
  59347. enumerable: !1,
  59348. configurable: !0
  59349. }),
  59350. Object.defineProperty(a.prototype, "needDepthPrePass", {
  59351. get: function() {
  59352. return this._needDepthPrePass
  59353. },
  59354. set: function(e) {
  59355. this._needDepthPrePass !== e && (this._needDepthPrePass = e,
  59356. this._needDepthPrePass && (this.checkReadyOnEveryCall = !0))
  59357. },
  59358. enumerable: !1,
  59359. configurable: !0
  59360. }),
  59361. Object.defineProperty(a.prototype, "isPrePassCapable", {
  59362. get: function() {
  59363. return !1
  59364. },
  59365. enumerable: !1,
  59366. configurable: !0
  59367. }),
  59368. Object.defineProperty(a.prototype, "fogEnabled", {
  59369. get: function() {
  59370. return this._fogEnabled
  59371. },
  59372. set: function(e) {
  59373. this._fogEnabled !== e && (this._fogEnabled = e,
  59374. this.markAsDirty(a.MiscDirtyFlag))
  59375. },
  59376. enumerable: !1,
  59377. configurable: !0
  59378. }),
  59379. Object.defineProperty(a.prototype, "wireframe", {
  59380. get: function() {
  59381. switch (this._fillMode) {
  59382. case a.WireFrameFillMode:
  59383. case a.LineListDrawMode:
  59384. case a.LineLoopDrawMode:
  59385. case a.LineStripDrawMode:
  59386. return !0
  59387. }
  59388. return this._scene.forceWireframe
  59389. },
  59390. set: function(e) {
  59391. this.fillMode = e ? a.WireFrameFillMode : a.TriangleFillMode
  59392. },
  59393. enumerable: !1,
  59394. configurable: !0
  59395. }),
  59396. Object.defineProperty(a.prototype, "pointsCloud", {
  59397. get: function() {
  59398. switch (this._fillMode) {
  59399. case a.PointFillMode:
  59400. case a.PointListDrawMode:
  59401. return !0
  59402. }
  59403. return this._scene.forcePointsCloud
  59404. },
  59405. set: function(e) {
  59406. this.fillMode = e ? a.PointFillMode : a.TriangleFillMode
  59407. },
  59408. enumerable: !1,
  59409. configurable: !0
  59410. }),
  59411. Object.defineProperty(a.prototype, "fillMode", {
  59412. get: function() {
  59413. return this._fillMode
  59414. },
  59415. set: function(e) {
  59416. this._fillMode !== e && (this._fillMode = e,
  59417. this.markAsDirty(a.MiscDirtyFlag))
  59418. },
  59419. enumerable: !1,
  59420. configurable: !0
  59421. }),
  59422. a.prototype._getDrawWrapper = function() {
  59423. return this._drawWrapper
  59424. }
  59425. ,
  59426. a.prototype._setDrawWrapper = function(e) {
  59427. this._drawWrapper = e
  59428. }
  59429. ,
  59430. a.prototype.toString = function(e) {
  59431. var i = "Name: " + this.name;
  59432. return i
  59433. }
  59434. ,
  59435. a.prototype.getClassName = function() {
  59436. return "Material"
  59437. }
  59438. ,
  59439. Object.defineProperty(a.prototype, "isFrozen", {
  59440. get: function() {
  59441. return this.checkReadyOnlyOnce
  59442. },
  59443. enumerable: !1,
  59444. configurable: !0
  59445. }),
  59446. a.prototype.freeze = function() {
  59447. this.markDirty(),
  59448. this.checkReadyOnlyOnce = !0
  59449. }
  59450. ,
  59451. a.prototype.unfreeze = function() {
  59452. this.markDirty(),
  59453. this.checkReadyOnlyOnce = !1
  59454. }
  59455. ,
  59456. a.prototype.isReady = function(e, i) {
  59457. return !0
  59458. }
  59459. ,
  59460. a.prototype.isReadyForSubMesh = function(e, i, o) {
  59461. return !1
  59462. }
  59463. ,
  59464. a.prototype.getEffect = function() {
  59465. return this._drawWrapper.effect
  59466. }
  59467. ,
  59468. a.prototype.getScene = function() {
  59469. return this._scene
  59470. }
  59471. ,
  59472. Object.defineProperty(a.prototype, "transparencyMode", {
  59473. get: function() {
  59474. return this._transparencyMode
  59475. },
  59476. set: function(e) {
  59477. this._transparencyMode !== e && (this._transparencyMode = e,
  59478. this._forceAlphaTest = e === a.MATERIAL_ALPHATESTANDBLEND,
  59479. this._markAllSubMeshesAsTexturesAndMiscDirty())
  59480. },
  59481. enumerable: !1,
  59482. configurable: !0
  59483. }),
  59484. Object.defineProperty(a.prototype, "_disableAlphaBlending", {
  59485. get: function() {
  59486. return this._transparencyMode === a.MATERIAL_OPAQUE || this._transparencyMode === a.MATERIAL_ALPHATEST
  59487. },
  59488. enumerable: !1,
  59489. configurable: !0
  59490. }),
  59491. a.prototype.needAlphaBlending = function() {
  59492. return this._disableAlphaBlending ? !1 : this.alpha < 1
  59493. }
  59494. ,
  59495. a.prototype.needAlphaBlendingForMesh = function(e) {
  59496. return this._disableAlphaBlending && e.visibility >= 1 ? !1 : this.needAlphaBlending() || e.visibility < 1 || e.hasVertexAlpha
  59497. }
  59498. ,
  59499. a.prototype.needAlphaTesting = function() {
  59500. return !!this._forceAlphaTest
  59501. }
  59502. ,
  59503. a.prototype._shouldTurnAlphaTestOn = function(e) {
  59504. return !this.needAlphaBlendingForMesh(e) && this.needAlphaTesting()
  59505. }
  59506. ,
  59507. a.prototype.getAlphaTestTexture = function() {
  59508. return null
  59509. }
  59510. ,
  59511. a.prototype.markDirty = function() {
  59512. for (var e = this.getScene().meshes, i = 0, o = e; i < o.length; i++) {
  59513. var s = o[i];
  59514. if (!!s.subMeshes)
  59515. for (var c = 0, d = s.subMeshes; c < d.length; c++) {
  59516. var _ = d[c];
  59517. _.getMaterial() === this && (!_.effect || (_.effect._wasPreviouslyReady = !1))
  59518. }
  59519. }
  59520. }
  59521. ,
  59522. a.prototype._preBind = function(e, i) {
  59523. i === void 0 && (i = null);
  59524. var o = this._scene.getEngine()
  59525. , s = i == null ? this.sideOrientation : i
  59526. , c = s === a.ClockWiseSideOrientation;
  59527. return o.enableEffect(e || this._getDrawWrapper()),
  59528. o.setState(this.backFaceCulling, this.zOffset, !1, c, this.cullBackFaces, this.stencil, this.zOffsetUnits),
  59529. c
  59530. }
  59531. ,
  59532. a.prototype.bind = function(e, i) {}
  59533. ,
  59534. a.prototype.bindForSubMesh = function(e, i, o) {}
  59535. ,
  59536. a.prototype.bindOnlyWorldMatrix = function(e) {}
  59537. ,
  59538. a.prototype.bindView = function(e) {
  59539. this._useUBO ? this._needToBindSceneUbo = !0 : e.setMatrix("view", this.getScene().getViewMatrix())
  59540. }
  59541. ,
  59542. a.prototype.bindViewProjection = function(e) {
  59543. this._useUBO ? this._needToBindSceneUbo = !0 : (e.setMatrix("viewProjection", this.getScene().getTransformMatrix()),
  59544. e.setMatrix("projection", this.getScene().getProjectionMatrix()))
  59545. }
  59546. ,
  59547. a.prototype.bindEyePosition = function(e, i) {
  59548. this._useUBO ? this._needToBindSceneUbo = !0 : this._scene.bindEyePosition(e, i)
  59549. }
  59550. ,
  59551. a.prototype._afterBind = function(e, i) {
  59552. if (i === void 0 && (i = null),
  59553. this._scene._cachedMaterial = this,
  59554. this._needToBindSceneUbo && i && (this._needToBindSceneUbo = !1,
  59555. MaterialHelper.BindSceneUniformBuffer(i, this.getScene().getSceneUniformBuffer()),
  59556. this._scene.finalizeSceneUbo()),
  59557. e ? this._scene._cachedVisibility = e.visibility : this._scene._cachedVisibility = 1,
  59558. this._onBindObservable && e && this._onBindObservable.notifyObservers(e),
  59559. this.disableDepthWrite) {
  59560. var o = this._scene.getEngine();
  59561. this._cachedDepthWriteState = o.getDepthWrite(),
  59562. o.setDepthWrite(!1)
  59563. }
  59564. if (this.disableColorWrite) {
  59565. var o = this._scene.getEngine();
  59566. this._cachedColorWriteState = o.getColorWrite(),
  59567. o.setColorWrite(!1)
  59568. }
  59569. if (this.depthFunction !== 0) {
  59570. var o = this._scene.getEngine();
  59571. this._cachedDepthFunctionState = o.getDepthFunction() || 0,
  59572. o.setDepthFunction(this.depthFunction)
  59573. }
  59574. }
  59575. ,
  59576. a.prototype.unbind = function() {
  59577. if (this._onUnBindObservable && this._onUnBindObservable.notifyObservers(this),
  59578. this.depthFunction !== 0) {
  59579. var e = this._scene.getEngine();
  59580. e.setDepthFunction(this._cachedDepthFunctionState)
  59581. }
  59582. if (this.disableDepthWrite) {
  59583. var e = this._scene.getEngine();
  59584. e.setDepthWrite(this._cachedDepthWriteState)
  59585. }
  59586. if (this.disableColorWrite) {
  59587. var e = this._scene.getEngine();
  59588. e.setColorWrite(this._cachedColorWriteState)
  59589. }
  59590. }
  59591. ,
  59592. a.prototype.getActiveTextures = function() {
  59593. return []
  59594. }
  59595. ,
  59596. a.prototype.hasTexture = function(e) {
  59597. return !1
  59598. }
  59599. ,
  59600. a.prototype.clone = function(e) {
  59601. return null
  59602. }
  59603. ,
  59604. a.prototype.getBindedMeshes = function() {
  59605. var e = this;
  59606. if (this.meshMap) {
  59607. var i = new Array;
  59608. for (var o in this.meshMap) {
  59609. var s = this.meshMap[o];
  59610. s && i.push(s)
  59611. }
  59612. return i
  59613. } else {
  59614. var c = this._scene.meshes;
  59615. return c.filter(function(d) {
  59616. return d.material === e
  59617. })
  59618. }
  59619. }
  59620. ,
  59621. a.prototype.forceCompilation = function(e, i, o, s) {
  59622. var c = this
  59623. , d = __assign({
  59624. clipPlane: !1,
  59625. useInstances: !1
  59626. }, o)
  59627. , _ = this.getScene()
  59628. , b = this.allowShaderHotSwapping;
  59629. this.allowShaderHotSwapping = !1;
  59630. var k = function() {
  59631. if (!(!c._scene || !c._scene.getEngine())) {
  59632. var j = _.clipPlane;
  59633. if (d.clipPlane && (_.clipPlane = new Plane(0,0,0,1)),
  59634. c._storeEffectOnSubMeshes) {
  59635. var $ = !0
  59636. , _e = null;
  59637. if (e.subMeshes) {
  59638. var et = new SubMesh(0,0,0,0,0,e,void 0,!1,!1);
  59639. et.materialDefines && (et.materialDefines._renderId = -1),
  59640. c.isReadyForSubMesh(e, et, d.useInstances) || (et.effect && et.effect.getCompilationError() && et.effect.allFallbacksProcessed() ? _e = et.effect.getCompilationError() : ($ = !1,
  59641. setTimeout(k, 16)))
  59642. }
  59643. $ && (c.allowShaderHotSwapping = b,
  59644. _e && s && s(_e),
  59645. i && i(c))
  59646. } else
  59647. c.isReady() ? (c.allowShaderHotSwapping = b,
  59648. i && i(c)) : setTimeout(k, 16);
  59649. d.clipPlane && (_.clipPlane = j)
  59650. }
  59651. };
  59652. k()
  59653. }
  59654. ,
  59655. a.prototype.forceCompilationAsync = function(e, i) {
  59656. var o = this;
  59657. return new Promise(function(s, c) {
  59658. o.forceCompilation(e, function() {
  59659. s()
  59660. }, i, function(d) {
  59661. c(d)
  59662. })
  59663. }
  59664. )
  59665. }
  59666. ,
  59667. a.prototype.markAsDirty = function(e) {
  59668. this.getScene().blockMaterialDirtyMechanism || (a._DirtyCallbackArray.length = 0,
  59669. e & a.TextureDirtyFlag && a._DirtyCallbackArray.push(a._TextureDirtyCallBack),
  59670. e & a.LightDirtyFlag && a._DirtyCallbackArray.push(a._LightsDirtyCallBack),
  59671. e & a.FresnelDirtyFlag && a._DirtyCallbackArray.push(a._FresnelDirtyCallBack),
  59672. e & a.AttributesDirtyFlag && a._DirtyCallbackArray.push(a._AttributeDirtyCallBack),
  59673. e & a.MiscDirtyFlag && a._DirtyCallbackArray.push(a._MiscDirtyCallBack),
  59674. e & a.PrePassDirtyFlag && a._DirtyCallbackArray.push(a._PrePassDirtyCallBack),
  59675. a._DirtyCallbackArray.length && this._markAllSubMeshesAsDirty(a._RunDirtyCallBacks),
  59676. this.getScene().resetCachedMaterial())
  59677. }
  59678. ,
  59679. a.prototype._markAllSubMeshesAsDirty = function(e) {
  59680. if (!this.getScene().blockMaterialDirtyMechanism)
  59681. for (var i = this.getScene().meshes, o = 0, s = i; o < s.length; o++) {
  59682. var c = s[o];
  59683. if (!!c.subMeshes)
  59684. for (var d = 0, _ = c.subMeshes; d < _.length; d++) {
  59685. var b = _[d];
  59686. if (b.getMaterial() === this)
  59687. for (var k = 0, j = b._drawWrappers; k < j.length; k++) {
  59688. var $ = j[k];
  59689. !$ || !$.defines || !$.defines.markAllAsDirty || this._materialContext === $.materialContext && e($.defines)
  59690. }
  59691. }
  59692. }
  59693. }
  59694. ,
  59695. a.prototype._markScenePrePassDirty = function() {
  59696. if (!this.getScene().blockMaterialDirtyMechanism) {
  59697. var e = this.getScene().enablePrePassRenderer();
  59698. e && e.markAsDirty()
  59699. }
  59700. }
  59701. ,
  59702. a.prototype._markAllSubMeshesAsAllDirty = function() {
  59703. this._markAllSubMeshesAsDirty(a._AllDirtyCallBack)
  59704. }
  59705. ,
  59706. a.prototype._markAllSubMeshesAsImageProcessingDirty = function() {
  59707. this._markAllSubMeshesAsDirty(a._ImageProcessingDirtyCallBack)
  59708. }
  59709. ,
  59710. a.prototype._markAllSubMeshesAsTexturesDirty = function() {
  59711. this._markAllSubMeshesAsDirty(a._TextureDirtyCallBack)
  59712. }
  59713. ,
  59714. a.prototype._markAllSubMeshesAsFresnelDirty = function() {
  59715. this._markAllSubMeshesAsDirty(a._FresnelDirtyCallBack)
  59716. }
  59717. ,
  59718. a.prototype._markAllSubMeshesAsFresnelAndMiscDirty = function() {
  59719. this._markAllSubMeshesAsDirty(a._FresnelAndMiscDirtyCallBack)
  59720. }
  59721. ,
  59722. a.prototype._markAllSubMeshesAsLightsDirty = function() {
  59723. this._markAllSubMeshesAsDirty(a._LightsDirtyCallBack)
  59724. }
  59725. ,
  59726. a.prototype._markAllSubMeshesAsAttributesDirty = function() {
  59727. this._markAllSubMeshesAsDirty(a._AttributeDirtyCallBack)
  59728. }
  59729. ,
  59730. a.prototype._markAllSubMeshesAsMiscDirty = function() {
  59731. this._markAllSubMeshesAsDirty(a._MiscDirtyCallBack)
  59732. }
  59733. ,
  59734. a.prototype._markAllSubMeshesAsPrePassDirty = function() {
  59735. this._markAllSubMeshesAsDirty(a._MiscDirtyCallBack)
  59736. }
  59737. ,
  59738. a.prototype._markAllSubMeshesAsTexturesAndMiscDirty = function() {
  59739. this._markAllSubMeshesAsDirty(a._TextureAndMiscDirtyCallBack)
  59740. }
  59741. ,
  59742. a.prototype.setPrePassRenderer = function(e) {
  59743. return !1
  59744. }
  59745. ,
  59746. a.prototype.dispose = function(e, i, o) {
  59747. var s = this.getScene();
  59748. if (s.stopAnimation(this),
  59749. s.freeProcessedMaterials(),
  59750. s.removeMaterial(this),
  59751. this._parentContainer) {
  59752. var c = this._parentContainer.materials.indexOf(this);
  59753. c > -1 && this._parentContainer.materials.splice(c, 1),
  59754. this._parentContainer = null
  59755. }
  59756. if (o !== !0)
  59757. if (this.meshMap)
  59758. for (var d in this.meshMap) {
  59759. var _ = this.meshMap[d];
  59760. _ && (_.material = null,
  59761. this.releaseVertexArrayObject(_, e))
  59762. }
  59763. else
  59764. for (var b = s.meshes, k = 0, j = b; k < j.length; k++) {
  59765. var _ = j[k];
  59766. _.material === this && !_.sourceMesh && (_.material = null,
  59767. this.releaseVertexArrayObject(_, e))
  59768. }
  59769. this._uniformBuffer.dispose(),
  59770. e && this._drawWrapper.effect && (this._storeEffectOnSubMeshes || this._drawWrapper.effect.dispose(),
  59771. this._drawWrapper.effect = null),
  59772. this.metadata = null,
  59773. this.onDisposeObservable.notifyObservers(this),
  59774. this.onDisposeObservable.clear(),
  59775. this._onBindObservable && this._onBindObservable.clear(),
  59776. this._onUnBindObservable && this._onUnBindObservable.clear(),
  59777. this._onEffectCreatedObservable && this._onEffectCreatedObservable.clear()
  59778. }
  59779. ,
  59780. a.prototype.releaseVertexArrayObject = function(e, i) {
  59781. if (e.geometry) {
  59782. var o = e.geometry;
  59783. if (this._storeEffectOnSubMeshes)
  59784. for (var s = 0, c = e.subMeshes; s < c.length; s++) {
  59785. var d = c[s];
  59786. o._releaseVertexArrayObject(d.effect),
  59787. i && d.effect && d.effect.dispose()
  59788. }
  59789. else
  59790. o._releaseVertexArrayObject(this._drawWrapper.effect)
  59791. }
  59792. }
  59793. ,
  59794. a.prototype.serialize = function() {
  59795. var e = SerializationHelper.Serialize(this);
  59796. return e.stencil = this.stencil.serialize(),
  59797. e
  59798. }
  59799. ,
  59800. a.Parse = function(e, i, o) {
  59801. if (!e.customType)
  59802. e.customType = "BABYLON.StandardMaterial";
  59803. else if (e.customType === "BABYLON.PBRMaterial" && e.overloadedAlbedo && (e.customType = "BABYLON.LegacyPBRMaterial",
  59804. !BABYLON.LegacyPBRMaterial))
  59805. return Logger$2.Error("Your scene is trying to load a legacy version of the PBRMaterial, please, include it from the materials library."),
  59806. null;
  59807. var s = Tools.Instantiate(e.customType);
  59808. return s.Parse(e, i, o)
  59809. }
  59810. ,
  59811. a.TriangleFillMode = 0,
  59812. a.WireFrameFillMode = 1,
  59813. a.PointFillMode = 2,
  59814. a.PointListDrawMode = 3,
  59815. a.LineListDrawMode = 4,
  59816. a.LineLoopDrawMode = 5,
  59817. a.LineStripDrawMode = 6,
  59818. a.TriangleStripDrawMode = 7,
  59819. a.TriangleFanDrawMode = 8,
  59820. a.ClockWiseSideOrientation = 0,
  59821. a.CounterClockWiseSideOrientation = 1,
  59822. a.TextureDirtyFlag = 1,
  59823. a.LightDirtyFlag = 2,
  59824. a.FresnelDirtyFlag = 4,
  59825. a.AttributesDirtyFlag = 8,
  59826. a.MiscDirtyFlag = 16,
  59827. a.PrePassDirtyFlag = 32,
  59828. a.AllDirtyFlag = 63,
  59829. a.MATERIAL_OPAQUE = 0,
  59830. a.MATERIAL_ALPHATEST = 1,
  59831. a.MATERIAL_ALPHABLEND = 2,
  59832. a.MATERIAL_ALPHATESTANDBLEND = 3,
  59833. a.MATERIAL_NORMALBLENDMETHOD_WHITEOUT = 0,
  59834. a.MATERIAL_NORMALBLENDMETHOD_RNM = 1,
  59835. a._AllDirtyCallBack = function(e) {
  59836. return e.markAllAsDirty()
  59837. }
  59838. ,
  59839. a._ImageProcessingDirtyCallBack = function(e) {
  59840. return e.markAsImageProcessingDirty()
  59841. }
  59842. ,
  59843. a._TextureDirtyCallBack = function(e) {
  59844. return e.markAsTexturesDirty()
  59845. }
  59846. ,
  59847. a._FresnelDirtyCallBack = function(e) {
  59848. return e.markAsFresnelDirty()
  59849. }
  59850. ,
  59851. a._MiscDirtyCallBack = function(e) {
  59852. return e.markAsMiscDirty()
  59853. }
  59854. ,
  59855. a._PrePassDirtyCallBack = function(e) {
  59856. return e.markAsPrePassDirty()
  59857. }
  59858. ,
  59859. a._LightsDirtyCallBack = function(e) {
  59860. return e.markAsLightDirty()
  59861. }
  59862. ,
  59863. a._AttributeDirtyCallBack = function(e) {
  59864. return e.markAsAttributesDirty()
  59865. }
  59866. ,
  59867. a._FresnelAndMiscDirtyCallBack = function(e) {
  59868. a._FresnelDirtyCallBack(e),
  59869. a._MiscDirtyCallBack(e)
  59870. }
  59871. ,
  59872. a._TextureAndMiscDirtyCallBack = function(e) {
  59873. a._TextureDirtyCallBack(e),
  59874. a._MiscDirtyCallBack(e)
  59875. }
  59876. ,
  59877. a._DirtyCallbackArray = [],
  59878. a._RunDirtyCallBacks = function(e) {
  59879. for (var i = 0, o = a._DirtyCallbackArray; i < o.length; i++) {
  59880. var s = o[i];
  59881. s(e)
  59882. }
  59883. }
  59884. ,
  59885. __decorate([serialize()], a.prototype, "id", void 0),
  59886. __decorate([serialize()], a.prototype, "uniqueId", void 0),
  59887. __decorate([serialize()], a.prototype, "name", void 0),
  59888. __decorate([serialize()], a.prototype, "metadata", void 0),
  59889. __decorate([serialize()], a.prototype, "checkReadyOnEveryCall", void 0),
  59890. __decorate([serialize()], a.prototype, "checkReadyOnlyOnce", void 0),
  59891. __decorate([serialize()], a.prototype, "state", void 0),
  59892. __decorate([serialize("alpha")], a.prototype, "_alpha", void 0),
  59893. __decorate([serialize("backFaceCulling")], a.prototype, "_backFaceCulling", void 0),
  59894. __decorate([serialize("cullBackFaces")], a.prototype, "_cullBackFaces", void 0),
  59895. __decorate([serialize()], a.prototype, "sideOrientation", void 0),
  59896. __decorate([serialize("alphaMode")], a.prototype, "_alphaMode", void 0),
  59897. __decorate([serialize()], a.prototype, "_needDepthPrePass", void 0),
  59898. __decorate([serialize()], a.prototype, "disableDepthWrite", void 0),
  59899. __decorate([serialize()], a.prototype, "disableColorWrite", void 0),
  59900. __decorate([serialize()], a.prototype, "forceDepthWrite", void 0),
  59901. __decorate([serialize()], a.prototype, "depthFunction", void 0),
  59902. __decorate([serialize()], a.prototype, "separateCullingPass", void 0),
  59903. __decorate([serialize("fogEnabled")], a.prototype, "_fogEnabled", void 0),
  59904. __decorate([serialize()], a.prototype, "pointSize", void 0),
  59905. __decorate([serialize()], a.prototype, "zOffset", void 0),
  59906. __decorate([serialize()], a.prototype, "zOffsetUnits", void 0),
  59907. __decorate([serialize()], a.prototype, "pointsCloud", null),
  59908. __decorate([serialize()], a.prototype, "fillMode", null),
  59909. __decorate([serialize()], a.prototype, "transparencyMode", null),
  59910. a
  59911. }()
  59912. , MultiMaterial = function(a) {
  59913. __extends(e, a);
  59914. function e(i, o) {
  59915. var s = a.call(this, i, o, !0) || this;
  59916. return o.multiMaterials.push(s),
  59917. s.subMaterials = new Array,
  59918. s._storeEffectOnSubMeshes = !0,
  59919. s
  59920. }
  59921. return Object.defineProperty(e.prototype, "subMaterials", {
  59922. get: function() {
  59923. return this._subMaterials
  59924. },
  59925. set: function(i) {
  59926. this._subMaterials = i,
  59927. this._hookArray(i)
  59928. },
  59929. enumerable: !1,
  59930. configurable: !0
  59931. }),
  59932. e.prototype.getChildren = function() {
  59933. return this.subMaterials
  59934. }
  59935. ,
  59936. e.prototype._hookArray = function(i) {
  59937. var o = this
  59938. , s = i.push;
  59939. i.push = function() {
  59940. for (var d = [], _ = 0; _ < arguments.length; _++)
  59941. d[_] = arguments[_];
  59942. var b = s.apply(i, d);
  59943. return o._markAllSubMeshesAsTexturesDirty(),
  59944. b
  59945. }
  59946. ;
  59947. var c = i.splice;
  59948. i.splice = function(d, _) {
  59949. var b = c.apply(i, [d, _]);
  59950. return o._markAllSubMeshesAsTexturesDirty(),
  59951. b
  59952. }
  59953. }
  59954. ,
  59955. e.prototype.getSubMaterial = function(i) {
  59956. return i < 0 || i >= this.subMaterials.length ? this.getScene().defaultMaterial : this.subMaterials[i]
  59957. }
  59958. ,
  59959. e.prototype.getActiveTextures = function() {
  59960. var i;
  59961. return (i = a.prototype.getActiveTextures.call(this)).concat.apply(i, this.subMaterials.map(function(o) {
  59962. return o ? o.getActiveTextures() : []
  59963. }))
  59964. }
  59965. ,
  59966. e.prototype.hasTexture = function(i) {
  59967. var o;
  59968. if (a.prototype.hasTexture.call(this, i))
  59969. return !0;
  59970. for (var s = 0; s < this.subMaterials.length; s++)
  59971. if (!((o = this.subMaterials[s]) === null || o === void 0) && o.hasTexture(i))
  59972. return !0;
  59973. return !1
  59974. }
  59975. ,
  59976. e.prototype.getClassName = function() {
  59977. return "MultiMaterial"
  59978. }
  59979. ,
  59980. e.prototype.isReadyForSubMesh = function(i, o, s) {
  59981. for (var c = 0; c < this.subMaterials.length; c++) {
  59982. var d = this.subMaterials[c];
  59983. if (d) {
  59984. if (d._storeEffectOnSubMeshes) {
  59985. if (!d.isReadyForSubMesh(i, o, s))
  59986. return !1;
  59987. continue
  59988. }
  59989. if (!d.isReady(i))
  59990. return !1
  59991. }
  59992. }
  59993. return !0
  59994. }
  59995. ,
  59996. e.prototype.clone = function(i, o) {
  59997. for (var s = new e(i,this.getScene()), c = 0; c < this.subMaterials.length; c++) {
  59998. var d = null
  59999. , _ = this.subMaterials[c];
  60000. o && _ ? d = _.clone(i + "-" + _.name) : d = this.subMaterials[c],
  60001. s.subMaterials.push(d)
  60002. }
  60003. return s
  60004. }
  60005. ,
  60006. e.prototype.serialize = function() {
  60007. var i = {};
  60008. i.name = this.name,
  60009. i.id = this.id,
  60010. Tags && (i.tags = Tags.GetTags(this)),
  60011. i.materials = [];
  60012. for (var o = 0; o < this.subMaterials.length; o++) {
  60013. var s = this.subMaterials[o];
  60014. s ? i.materials.push(s.id) : i.materials.push(null)
  60015. }
  60016. return i
  60017. }
  60018. ,
  60019. e.prototype.dispose = function(i, o, s) {
  60020. var c = this.getScene();
  60021. if (!!c) {
  60022. if (s)
  60023. for (var _ = 0; _ < this.subMaterials.length; _++) {
  60024. var d = this.subMaterials[_];
  60025. d && d.dispose(i, o)
  60026. }
  60027. var _ = c.multiMaterials.indexOf(this);
  60028. _ >= 0 && c.multiMaterials.splice(_, 1),
  60029. a.prototype.dispose.call(this, i, o)
  60030. }
  60031. }
  60032. ,
  60033. e.ParseMultiMaterial = function(i, o) {
  60034. var s = new e(i.name,o);
  60035. s.id = i.id,
  60036. Tags && Tags.AddTagsTo(s, i.tags);
  60037. for (var c = 0; c < i.materials.length; c++) {
  60038. var d = i.materials[c];
  60039. d ? s.subMaterials.push(o.getLastMaterialById(d)) : s.subMaterials.push(null)
  60040. }
  60041. return s
  60042. }
  60043. ,
  60044. e
  60045. }(Material);
  60046. RegisterClass("BABYLON.MultiMaterial", MultiMaterial);
  60047. var MeshLODLevel = function() {
  60048. function a(e, i) {
  60049. this.distanceOrScreenCoverage = e,
  60050. this.mesh = i
  60051. }
  60052. return a
  60053. }()
  60054. , _injectLTSMesh = function(a) {
  60055. a.prototype.setMaterialByID = function(e) {
  60056. return this.setMaterialById(e)
  60057. }
  60058. ,
  60059. a.CreateDisc = a.CreateDisc || function() {
  60060. throw _WarnImport("MeshBuilder")
  60061. }
  60062. ,
  60063. a.CreateBox = a.CreateBox || function() {
  60064. throw _WarnImport("MeshBuilder")
  60065. }
  60066. ,
  60067. a.CreateSphere = a.CreateSphere || function() {
  60068. throw _WarnImport("MeshBuilder")
  60069. }
  60070. ,
  60071. a.CreateCylinder = a.CreateCylinder || function() {
  60072. throw _WarnImport("MeshBuilder")
  60073. }
  60074. ,
  60075. a.CreateTorusKnot = a.CreateTorusKnot || function() {
  60076. throw _WarnImport("MeshBuilder")
  60077. }
  60078. ,
  60079. a.CreateTorus = a.CreateTorus || function() {
  60080. throw _WarnImport("MeshBuilder")
  60081. }
  60082. ,
  60083. a.CreatePlane = a.CreatePlane || function() {
  60084. throw _WarnImport("MeshBuilder")
  60085. }
  60086. ,
  60087. a.CreateGround = a.CreateGround || function() {
  60088. throw _WarnImport("MeshBuilder")
  60089. }
  60090. ,
  60091. a.CreateTiledGround = a.CreateTiledGround || function() {
  60092. throw _WarnImport("MeshBuilder")
  60093. }
  60094. ,
  60095. a.CreateGroundFromHeightMap = a.CreateGroundFromHeightMap || function() {
  60096. throw _WarnImport("MeshBuilder")
  60097. }
  60098. ,
  60099. a.CreateTube = a.CreateTube || function() {
  60100. throw _WarnImport("MeshBuilder")
  60101. }
  60102. ,
  60103. a.CreatePolyhedron = a.CreatePolyhedron || function() {
  60104. throw _WarnImport("MeshBuilder")
  60105. }
  60106. ,
  60107. a.CreateIcoSphere = a.CreateIcoSphere || function() {
  60108. throw _WarnImport("MeshBuilder")
  60109. }
  60110. ,
  60111. a.CreateDecal = a.CreateDecal || function() {
  60112. throw _WarnImport("MeshBuilder")
  60113. }
  60114. ,
  60115. a.CreateCapsule = a.CreateCapsule || function() {
  60116. throw _WarnImport("MeshBuilder")
  60117. }
  60118. ,
  60119. a.ExtendToGoldberg = a.ExtendToGoldberg || function() {
  60120. throw _WarnImport("MeshBuilder")
  60121. }
  60122. }
  60123. , _CreationDataStorage = function() {
  60124. function a() {}
  60125. return a
  60126. }()
  60127. , _InstanceDataStorage = function() {
  60128. function a() {
  60129. this.visibleInstances = {},
  60130. this.batchCache = new _InstancesBatch,
  60131. this.batchCacheReplacementModeInFrozenMode = new _InstancesBatch,
  60132. this.instancesBufferSize = 32 * 16 * 4
  60133. }
  60134. return a
  60135. }()
  60136. , _InstancesBatch = function() {
  60137. function a() {
  60138. this.mustReturn = !1,
  60139. this.visibleInstances = new Array,
  60140. this.renderSelf = new Array,
  60141. this.hardwareInstancedRendering = new Array
  60142. }
  60143. return a
  60144. }()
  60145. , _ThinInstanceDataStorage = function() {
  60146. function a() {
  60147. this.instancesCount = 0,
  60148. this.matrixBuffer = null,
  60149. this.previousMatrixBuffer = null,
  60150. this.matrixBufferSize = 32 * 16,
  60151. this.matrixData = null,
  60152. this.boundingVectors = [],
  60153. this.worldMatrices = null
  60154. }
  60155. return a
  60156. }()
  60157. , _InternalMeshDataInfo = function() {
  60158. function a() {
  60159. this._areNormalsFrozen = !1,
  60160. this._source = null,
  60161. this.meshMap = null,
  60162. this._preActivateId = -1,
  60163. this._LODLevels = new Array,
  60164. this._useLODScreenCoverage = !1,
  60165. this._effectiveMaterial = null,
  60166. this._forcedInstanceCount = 0
  60167. }
  60168. return a
  60169. }()
  60170. , Mesh = function(a) {
  60171. __extends(e, a);
  60172. function e(i, o, s, c, d, _) {
  60173. o === void 0 && (o = null),
  60174. s === void 0 && (s = null),
  60175. c === void 0 && (c = null),
  60176. _ === void 0 && (_ = !0);
  60177. var b = a.call(this, i, o) || this;
  60178. if (b._internalMeshDataInfo = new _InternalMeshDataInfo,
  60179. b.delayLoadState = 0,
  60180. b.instances = new Array,
  60181. b._creationDataStorage = null,
  60182. b._geometry = null,
  60183. b._instanceDataStorage = new _InstanceDataStorage,
  60184. b._thinInstanceDataStorage = new _ThinInstanceDataStorage,
  60185. b._shouldGenerateFlatShading = !1,
  60186. b._originalBuilderSideOrientation = e.DEFAULTSIDE,
  60187. b.overrideMaterialSideOrientation = null,
  60188. b.ignoreCameraMaxZ = !1,
  60189. o = b.getScene(),
  60190. c) {
  60191. if (c._geometry && c._geometry.applyToMesh(b),
  60192. DeepCopier.DeepCopy(c, b, ["name", "material", "skeleton", "instances", "parent", "uniqueId", "source", "metadata", "morphTargetManager", "hasInstances", "source", "worldMatrixInstancedBuffer", "previousWorldMatrixInstancedBuffer", "hasLODLevels", "geometry", "isBlocked", "areNormalsFrozen", "facetNb", "isFacetDataEnabled", "lightSources", "useBones", "isAnInstance", "collider", "edgesRenderer", "forward", "up", "right", "absolutePosition", "absoluteScaling", "absoluteRotationQuaternion", "isWorldMatrixFrozen", "nonUniformScaling", "behaviors", "worldMatrixFromCache", "hasThinInstances", "cloneMeshMap", "hasBoundingInfo"], ["_poseMatrix"]),
  60193. b._internalMeshDataInfo._source = c,
  60194. o.useClonedMeshMap && (c._internalMeshDataInfo.meshMap || (c._internalMeshDataInfo.meshMap = {}),
  60195. c._internalMeshDataInfo.meshMap[b.uniqueId] = b),
  60196. b._originalBuilderSideOrientation = c._originalBuilderSideOrientation,
  60197. b._creationDataStorage = c._creationDataStorage,
  60198. c._ranges) {
  60199. var k = c._ranges;
  60200. for (var i in k)
  60201. !k.hasOwnProperty(i) || !k[i] || b.createAnimationRange(i, k[i].from, k[i].to)
  60202. }
  60203. c.metadata && c.metadata.clone ? b.metadata = c.metadata.clone() : b.metadata = c.metadata,
  60204. Tags && Tags.HasTags(c) && Tags.AddTagsTo(b, Tags.GetTags(c, !0)),
  60205. b.setEnabled(c.isEnabled()),
  60206. b.parent = c.parent,
  60207. b.setPivotMatrix(c.getPivotMatrix()),
  60208. b.id = i + "." + c.id,
  60209. b.material = c.material;
  60210. var j;
  60211. if (!d)
  60212. for (var $ = c.getDescendants(!0), _e = 0; _e < $.length; _e++) {
  60213. var et = $[_e];
  60214. et.clone && et.clone(i + "." + et.name, b)
  60215. }
  60216. if (c.morphTargetManager && (b.morphTargetManager = c.morphTargetManager),
  60217. o.getPhysicsEngine) {
  60218. var tt = o.getPhysicsEngine();
  60219. if (_ && tt) {
  60220. var rt = tt.getImpostorForPhysicsObject(c);
  60221. rt && (b.physicsImpostor = rt.clone(b))
  60222. }
  60223. }
  60224. for (j = 0; j < o.particleSystems.length; j++) {
  60225. var it = o.particleSystems[j];
  60226. it.emitter === c && it.clone(it.name, b)
  60227. }
  60228. b.refreshBoundingInfo(),
  60229. b.computeWorldMatrix(!0)
  60230. }
  60231. return s !== null && (b.parent = s),
  60232. b._instanceDataStorage.hardwareInstancedRendering = b.getEngine().getCaps().instancedArrays,
  60233. b._internalMeshDataInfo._onMeshReadyObserverAdded = function(nt) {
  60234. nt.unregisterOnNextCall = !0,
  60235. b.isReady(!0) ? b.onMeshReadyObservable.notifyObservers(b) : b._internalMeshDataInfo._checkReadinessObserver || (b._internalMeshDataInfo._checkReadinessObserver = b._scene.onBeforeRenderObservable.add(function() {
  60236. b.isReady(!0) && (b._scene.onBeforeRenderObservable.remove(b._internalMeshDataInfo._checkReadinessObserver),
  60237. b._internalMeshDataInfo._checkReadinessObserver = null,
  60238. b.onMeshReadyObservable.notifyObservers(b))
  60239. }))
  60240. }
  60241. ,
  60242. b.onMeshReadyObservable = new Observable(b._internalMeshDataInfo._onMeshReadyObserverAdded),
  60243. c && c.onClonedObservable.notifyObservers(b),
  60244. b
  60245. }
  60246. return e._GetDefaultSideOrientation = function(i) {
  60247. return i || e.FRONTSIDE
  60248. }
  60249. ,
  60250. Object.defineProperty(e.prototype, "useLODScreenCoverage", {
  60251. get: function() {
  60252. return this._internalMeshDataInfo._useLODScreenCoverage
  60253. },
  60254. set: function(i) {
  60255. this._internalMeshDataInfo._useLODScreenCoverage = i
  60256. },
  60257. enumerable: !1,
  60258. configurable: !0
  60259. }),
  60260. Object.defineProperty(e.prototype, "computeBonesUsingShaders", {
  60261. get: function() {
  60262. return this._internalAbstractMeshDataInfo._computeBonesUsingShaders
  60263. },
  60264. set: function(i) {
  60265. this._internalAbstractMeshDataInfo._computeBonesUsingShaders !== i && (i && this._internalMeshDataInfo._sourcePositions && (this.setVerticesData(VertexBuffer.PositionKind, this._internalMeshDataInfo._sourcePositions.slice(), !0),
  60266. this._internalMeshDataInfo._sourceNormals && this.setVerticesData(VertexBuffer.NormalKind, this._internalMeshDataInfo._sourceNormals.slice(), !0)),
  60267. this._internalAbstractMeshDataInfo._computeBonesUsingShaders = i,
  60268. this._markSubMeshesAsAttributesDirty())
  60269. },
  60270. enumerable: !1,
  60271. configurable: !0
  60272. }),
  60273. Object.defineProperty(e.prototype, "onBeforeRenderObservable", {
  60274. get: function() {
  60275. return this._internalMeshDataInfo._onBeforeRenderObservable || (this._internalMeshDataInfo._onBeforeRenderObservable = new Observable),
  60276. this._internalMeshDataInfo._onBeforeRenderObservable
  60277. },
  60278. enumerable: !1,
  60279. configurable: !0
  60280. }),
  60281. Object.defineProperty(e.prototype, "onBeforeBindObservable", {
  60282. get: function() {
  60283. return this._internalMeshDataInfo._onBeforeBindObservable || (this._internalMeshDataInfo._onBeforeBindObservable = new Observable),
  60284. this._internalMeshDataInfo._onBeforeBindObservable
  60285. },
  60286. enumerable: !1,
  60287. configurable: !0
  60288. }),
  60289. Object.defineProperty(e.prototype, "onAfterRenderObservable", {
  60290. get: function() {
  60291. return this._internalMeshDataInfo._onAfterRenderObservable || (this._internalMeshDataInfo._onAfterRenderObservable = new Observable),
  60292. this._internalMeshDataInfo._onAfterRenderObservable
  60293. },
  60294. enumerable: !1,
  60295. configurable: !0
  60296. }),
  60297. Object.defineProperty(e.prototype, "onBetweenPassObservable", {
  60298. get: function() {
  60299. return this._internalMeshDataInfo._onBetweenPassObservable || (this._internalMeshDataInfo._onBetweenPassObservable = new Observable),
  60300. this._internalMeshDataInfo._onBetweenPassObservable
  60301. },
  60302. enumerable: !1,
  60303. configurable: !0
  60304. }),
  60305. Object.defineProperty(e.prototype, "onBeforeDrawObservable", {
  60306. get: function() {
  60307. return this._internalMeshDataInfo._onBeforeDrawObservable || (this._internalMeshDataInfo._onBeforeDrawObservable = new Observable),
  60308. this._internalMeshDataInfo._onBeforeDrawObservable
  60309. },
  60310. enumerable: !1,
  60311. configurable: !0
  60312. }),
  60313. Object.defineProperty(e.prototype, "onBeforeDraw", {
  60314. set: function(i) {
  60315. this._onBeforeDrawObserver && this.onBeforeDrawObservable.remove(this._onBeforeDrawObserver),
  60316. this._onBeforeDrawObserver = this.onBeforeDrawObservable.add(i)
  60317. },
  60318. enumerable: !1,
  60319. configurable: !0
  60320. }),
  60321. Object.defineProperty(e.prototype, "hasInstances", {
  60322. get: function() {
  60323. return this.instances.length > 0
  60324. },
  60325. enumerable: !1,
  60326. configurable: !0
  60327. }),
  60328. Object.defineProperty(e.prototype, "hasThinInstances", {
  60329. get: function() {
  60330. var i;
  60331. return ((i = this._thinInstanceDataStorage.instancesCount) !== null && i !== void 0 ? i : 0) > 0
  60332. },
  60333. enumerable: !1,
  60334. configurable: !0
  60335. }),
  60336. Object.defineProperty(e.prototype, "forcedInstanceCount", {
  60337. get: function() {
  60338. return this._internalMeshDataInfo._forcedInstanceCount
  60339. },
  60340. set: function(i) {
  60341. this._internalMeshDataInfo._forcedInstanceCount = i
  60342. },
  60343. enumerable: !1,
  60344. configurable: !0
  60345. }),
  60346. Object.defineProperty(e.prototype, "source", {
  60347. get: function() {
  60348. return this._internalMeshDataInfo._source
  60349. },
  60350. enumerable: !1,
  60351. configurable: !0
  60352. }),
  60353. Object.defineProperty(e.prototype, "cloneMeshMap", {
  60354. get: function() {
  60355. return this._internalMeshDataInfo.meshMap
  60356. },
  60357. enumerable: !1,
  60358. configurable: !0
  60359. }),
  60360. Object.defineProperty(e.prototype, "isUnIndexed", {
  60361. get: function() {
  60362. return this._unIndexed
  60363. },
  60364. set: function(i) {
  60365. this._unIndexed !== i && (this._unIndexed = i,
  60366. this._markSubMeshesAsAttributesDirty())
  60367. },
  60368. enumerable: !1,
  60369. configurable: !0
  60370. }),
  60371. Object.defineProperty(e.prototype, "worldMatrixInstancedBuffer", {
  60372. get: function() {
  60373. return this._instanceDataStorage.instancesData
  60374. },
  60375. enumerable: !1,
  60376. configurable: !0
  60377. }),
  60378. Object.defineProperty(e.prototype, "previousWorldMatrixInstancedBuffer", {
  60379. get: function() {
  60380. return this._instanceDataStorage.instancesPreviousData
  60381. },
  60382. enumerable: !1,
  60383. configurable: !0
  60384. }),
  60385. Object.defineProperty(e.prototype, "manualUpdateOfWorldMatrixInstancedBuffer", {
  60386. get: function() {
  60387. return this._instanceDataStorage.manualUpdate
  60388. },
  60389. set: function(i) {
  60390. this._instanceDataStorage.manualUpdate = i
  60391. },
  60392. enumerable: !1,
  60393. configurable: !0
  60394. }),
  60395. Object.defineProperty(e.prototype, "manualUpdateOfPreviousWorldMatrixInstancedBuffer", {
  60396. get: function() {
  60397. return this._instanceDataStorage.previousManualUpdate
  60398. },
  60399. set: function(i) {
  60400. this._instanceDataStorage.previousManualUpdate = i
  60401. },
  60402. enumerable: !1,
  60403. configurable: !0
  60404. }),
  60405. e.prototype.instantiateHierarchy = function(i, o, s) {
  60406. i === void 0 && (i = null);
  60407. var c = this.getTotalVertices() > 0 && (!o || !o.doNotInstantiate) ? this.createInstance("instance of " + (this.name || this.id)) : this.clone("Clone of " + (this.name || this.id), i || this.parent, !0);
  60408. c && (c.parent = i || this.parent,
  60409. c.position = this.position.clone(),
  60410. c.scaling = this.scaling.clone(),
  60411. this.rotationQuaternion ? c.rotationQuaternion = this.rotationQuaternion.clone() : c.rotation = this.rotation.clone(),
  60412. s && s(this, c));
  60413. for (var d = 0, _ = this.getChildTransformNodes(!0); d < _.length; d++) {
  60414. var b = _[d];
  60415. b.instantiateHierarchy(c, o, s)
  60416. }
  60417. return c
  60418. }
  60419. ,
  60420. e.prototype.getClassName = function() {
  60421. return "Mesh"
  60422. }
  60423. ,
  60424. Object.defineProperty(e.prototype, "_isMesh", {
  60425. get: function() {
  60426. return !0
  60427. },
  60428. enumerable: !1,
  60429. configurable: !0
  60430. }),
  60431. e.prototype.toString = function(i) {
  60432. var o = a.prototype.toString.call(this, i);
  60433. if (o += ", n vertices: " + this.getTotalVertices(),
  60434. o += ", parent: " + (this._waitingParentId ? this._waitingParentId : this.parent ? this.parent.name : "NONE"),
  60435. this.animations)
  60436. for (var s = 0; s < this.animations.length; s++)
  60437. o += ", animation[0]: " + this.animations[s].toString(i);
  60438. if (i)
  60439. if (this._geometry) {
  60440. var c = this.getIndices()
  60441. , d = this.getVerticesData(VertexBuffer.PositionKind);
  60442. d && c && (o += ", flat shading: " + (d.length / 3 === c.length ? "YES" : "NO"))
  60443. } else
  60444. o += ", flat shading: UNKNOWN";
  60445. return o
  60446. }
  60447. ,
  60448. e.prototype._unBindEffect = function() {
  60449. a.prototype._unBindEffect.call(this);
  60450. for (var i = 0, o = this.instances; i < o.length; i++) {
  60451. var s = o[i];
  60452. s._unBindEffect()
  60453. }
  60454. }
  60455. ,
  60456. Object.defineProperty(e.prototype, "hasLODLevels", {
  60457. get: function() {
  60458. return this._internalMeshDataInfo._LODLevels.length > 0
  60459. },
  60460. enumerable: !1,
  60461. configurable: !0
  60462. }),
  60463. e.prototype.getLODLevels = function() {
  60464. return this._internalMeshDataInfo._LODLevels
  60465. }
  60466. ,
  60467. e.prototype._sortLODLevels = function() {
  60468. var i = this._internalMeshDataInfo._useLODScreenCoverage ? -1 : 1;
  60469. this._internalMeshDataInfo._LODLevels.sort(function(o, s) {
  60470. return o.distanceOrScreenCoverage < s.distanceOrScreenCoverage ? i : o.distanceOrScreenCoverage > s.distanceOrScreenCoverage ? -i : 0
  60471. })
  60472. }
  60473. ,
  60474. e.prototype.addLODLevel = function(i, o) {
  60475. if (o && o._masterMesh)
  60476. return Logger$2.Warn("You cannot use a mesh as LOD level twice"),
  60477. this;
  60478. var s = new MeshLODLevel(i,o);
  60479. return this._internalMeshDataInfo._LODLevels.push(s),
  60480. o && (o._masterMesh = this),
  60481. this._sortLODLevels(),
  60482. this
  60483. }
  60484. ,
  60485. e.prototype.getLODLevelAtDistance = function(i) {
  60486. for (var o = this._internalMeshDataInfo, s = 0; s < o._LODLevels.length; s++) {
  60487. var c = o._LODLevels[s];
  60488. if (c.distanceOrScreenCoverage === i)
  60489. return c.mesh
  60490. }
  60491. return null
  60492. }
  60493. ,
  60494. e.prototype.removeLODLevel = function(i) {
  60495. for (var o = this._internalMeshDataInfo, s = 0; s < o._LODLevels.length; s++)
  60496. o._LODLevels[s].mesh === i && (o._LODLevels.splice(s, 1),
  60497. i && (i._masterMesh = null));
  60498. return this._sortLODLevels(),
  60499. this
  60500. }
  60501. ,
  60502. e.prototype.getLOD = function(i, o) {
  60503. var s = this._internalMeshDataInfo;
  60504. if (!s._LODLevels || s._LODLevels.length === 0)
  60505. return this;
  60506. var c;
  60507. if (o)
  60508. c = o;
  60509. else {
  60510. var d = this.getBoundingInfo();
  60511. c = d.boundingSphere
  60512. }
  60513. var _ = c.centerWorld.subtract(i.globalPosition).length()
  60514. , b = s._useLODScreenCoverage
  60515. , k = _
  60516. , j = 1;
  60517. if (b) {
  60518. var $ = i.screenArea
  60519. , _e = c.radiusWorld * i.minZ / _;
  60520. _e = _e * _e * Math.PI,
  60521. k = _e / $,
  60522. j = -1
  60523. }
  60524. if (j * s._LODLevels[s._LODLevels.length - 1].distanceOrScreenCoverage > j * k)
  60525. return this.onLODLevelSelection && this.onLODLevelSelection(k, this, this),
  60526. this;
  60527. for (var et = 0; et < s._LODLevels.length; et++) {
  60528. var tt = s._LODLevels[et];
  60529. if (j * tt.distanceOrScreenCoverage < j * k) {
  60530. if (tt.mesh) {
  60531. if (tt.mesh.delayLoadState === 4)
  60532. return tt.mesh._checkDelayState(),
  60533. this;
  60534. if (tt.mesh.delayLoadState === 2)
  60535. return this;
  60536. tt.mesh._preActivate(),
  60537. tt.mesh._updateSubMeshesBoundingInfo(this.worldMatrixFromCache)
  60538. }
  60539. return this.onLODLevelSelection && this.onLODLevelSelection(k, this, tt.mesh),
  60540. tt.mesh
  60541. }
  60542. }
  60543. return this.onLODLevelSelection && this.onLODLevelSelection(k, this, this),
  60544. this
  60545. }
  60546. ,
  60547. Object.defineProperty(e.prototype, "geometry", {
  60548. get: function() {
  60549. return this._geometry
  60550. },
  60551. enumerable: !1,
  60552. configurable: !0
  60553. }),
  60554. e.prototype.getTotalVertices = function() {
  60555. return this._geometry === null || this._geometry === void 0 ? 0 : this._geometry.getTotalVertices()
  60556. }
  60557. ,
  60558. e.prototype.getVerticesData = function(i, o, s) {
  60559. var c, d;
  60560. if (!this._geometry)
  60561. return null;
  60562. var _ = (d = (c = this._userInstancedBuffersStorage) === null || c === void 0 ? void 0 : c.vertexBuffers[i]) === null || d === void 0 ? void 0 : d.getFloatData(this._geometry.getTotalVertices(), s || o && this._geometry.meshes.length !== 1);
  60563. return _ || (_ = this._geometry.getVerticesData(i, o, s)),
  60564. _
  60565. }
  60566. ,
  60567. e.prototype.getVertexBuffer = function(i) {
  60568. var o, s;
  60569. return this._geometry ? (s = (o = this._userInstancedBuffersStorage) === null || o === void 0 ? void 0 : o.vertexBuffers[i]) !== null && s !== void 0 ? s : this._geometry.getVertexBuffer(i) : null
  60570. }
  60571. ,
  60572. e.prototype.isVerticesDataPresent = function(i) {
  60573. var o;
  60574. return this._geometry ? ((o = this._userInstancedBuffersStorage) === null || o === void 0 ? void 0 : o.vertexBuffers[i]) !== void 0 || this._geometry.isVerticesDataPresent(i) : this._delayInfo ? this._delayInfo.indexOf(i) !== -1 : !1
  60575. }
  60576. ,
  60577. e.prototype.isVertexBufferUpdatable = function(i) {
  60578. var o, s;
  60579. return this._geometry ? ((s = (o = this._userInstancedBuffersStorage) === null || o === void 0 ? void 0 : o.vertexBuffers[i]) === null || s === void 0 ? void 0 : s.isUpdatable()) || this._geometry.isVertexBufferUpdatable(i) : this._delayInfo ? this._delayInfo.indexOf(i) !== -1 : !1
  60580. }
  60581. ,
  60582. e.prototype.getVerticesDataKinds = function() {
  60583. if (!this._geometry) {
  60584. var i = new Array;
  60585. return this._delayInfo && this._delayInfo.forEach(function(c) {
  60586. i.push(c)
  60587. }),
  60588. i
  60589. }
  60590. var o = this._geometry.getVerticesDataKinds();
  60591. if (this._userInstancedBuffersStorage)
  60592. for (var s in this._userInstancedBuffersStorage.vertexBuffers)
  60593. o.push(s);
  60594. return o
  60595. }
  60596. ,
  60597. e.prototype.getTotalIndices = function() {
  60598. return this._geometry ? this._geometry.getTotalIndices() : 0
  60599. }
  60600. ,
  60601. e.prototype.getIndices = function(i, o) {
  60602. return this._geometry ? this._geometry.getIndices(i, o) : []
  60603. }
  60604. ,
  60605. Object.defineProperty(e.prototype, "isBlocked", {
  60606. get: function() {
  60607. return this._masterMesh !== null && this._masterMesh !== void 0
  60608. },
  60609. enumerable: !1,
  60610. configurable: !0
  60611. }),
  60612. e.prototype.isReady = function(i, o) {
  60613. var s, c, d, _, b, k;
  60614. if (i === void 0 && (i = !1),
  60615. o === void 0 && (o = !1),
  60616. this.delayLoadState === 2 || !a.prototype.isReady.call(this, i))
  60617. return !1;
  60618. if (!this.subMeshes || this.subMeshes.length === 0 || !i)
  60619. return !0;
  60620. var j = this.getEngine()
  60621. , $ = this.getScene()
  60622. , _e = o || j.getCaps().instancedArrays && (this.instances.length > 0 || this.hasThinInstances);
  60623. this.computeWorldMatrix();
  60624. var et = this.material || $.defaultMaterial;
  60625. if (et) {
  60626. if (et._storeEffectOnSubMeshes)
  60627. for (var tt = 0, rt = this.subMeshes; tt < rt.length; tt++) {
  60628. var it = rt[tt]
  60629. , nt = it.getMaterial();
  60630. if (nt) {
  60631. if (nt._storeEffectOnSubMeshes) {
  60632. if (!nt.isReadyForSubMesh(this, it, _e))
  60633. return !1
  60634. } else if (!nt.isReady(this, _e))
  60635. return !1
  60636. }
  60637. }
  60638. else if (!et.isReady(this, _e))
  60639. return !1
  60640. }
  60641. for (var ot = j.currentRenderPassId, at = 0, st = this.lightSources; at < st.length; at++) {
  60642. var ut = st[at]
  60643. , ct = ut.getShadowGenerator();
  60644. if (ct && (!(!((s = ct.getShadowMap()) === null || s === void 0) && s.renderList) || ((c = ct.getShadowMap()) === null || c === void 0 ? void 0 : c.renderList) && ((_ = (d = ct.getShadowMap()) === null || d === void 0 ? void 0 : d.renderList) === null || _ === void 0 ? void 0 : _.indexOf(this)) !== -1)) {
  60645. ct.getShadowMap() && (j.currentRenderPassId = ct.getShadowMap().renderPassId);
  60646. for (var lt = 0, ft = this.subMeshes; lt < ft.length; lt++) {
  60647. var it = ft[lt];
  60648. if (!ct.isReady(it, _e, (k = (b = it.getMaterial()) === null || b === void 0 ? void 0 : b.needAlphaBlendingForMesh(this)) !== null && k !== void 0 ? k : !1))
  60649. return j.currentRenderPassId = ot,
  60650. !1
  60651. }
  60652. j.currentRenderPassId = ot
  60653. }
  60654. }
  60655. for (var ht = 0, pt = this._internalMeshDataInfo._LODLevels; ht < pt.length; ht++) {
  60656. var dt = pt[ht];
  60657. if (dt.mesh && !dt.mesh.isReady(_e))
  60658. return !1
  60659. }
  60660. return !0
  60661. }
  60662. ,
  60663. Object.defineProperty(e.prototype, "areNormalsFrozen", {
  60664. get: function() {
  60665. return this._internalMeshDataInfo._areNormalsFrozen
  60666. },
  60667. enumerable: !1,
  60668. configurable: !0
  60669. }),
  60670. e.prototype.freezeNormals = function() {
  60671. return this._internalMeshDataInfo._areNormalsFrozen = !0,
  60672. this
  60673. }
  60674. ,
  60675. e.prototype.unfreezeNormals = function() {
  60676. return this._internalMeshDataInfo._areNormalsFrozen = !1,
  60677. this
  60678. }
  60679. ,
  60680. Object.defineProperty(e.prototype, "overridenInstanceCount", {
  60681. set: function(i) {
  60682. this._instanceDataStorage.overridenInstanceCount = i
  60683. },
  60684. enumerable: !1,
  60685. configurable: !0
  60686. }),
  60687. e.prototype._preActivate = function() {
  60688. var i = this._internalMeshDataInfo
  60689. , o = this.getScene().getRenderId();
  60690. return i._preActivateId === o ? this : (i._preActivateId = o,
  60691. this._instanceDataStorage.visibleInstances = null,
  60692. this)
  60693. }
  60694. ,
  60695. e.prototype._preActivateForIntermediateRendering = function(i) {
  60696. return this._instanceDataStorage.visibleInstances && (this._instanceDataStorage.visibleInstances.intermediateDefaultRenderId = i),
  60697. this
  60698. }
  60699. ,
  60700. e.prototype._registerInstanceForRenderId = function(i, o) {
  60701. return this._instanceDataStorage.visibleInstances || (this._instanceDataStorage.visibleInstances = {
  60702. defaultRenderId: o,
  60703. selfDefaultRenderId: this._renderId
  60704. }),
  60705. this._instanceDataStorage.visibleInstances[o] || (this._instanceDataStorage.previousRenderId !== void 0 && this._instanceDataStorage.isFrozen && (this._instanceDataStorage.visibleInstances[this._instanceDataStorage.previousRenderId] = null),
  60706. this._instanceDataStorage.previousRenderId = o,
  60707. this._instanceDataStorage.visibleInstances[o] = new Array),
  60708. this._instanceDataStorage.visibleInstances[o].push(i),
  60709. this
  60710. }
  60711. ,
  60712. e.prototype._afterComputeWorldMatrix = function() {
  60713. a.prototype._afterComputeWorldMatrix.call(this),
  60714. this.hasThinInstances && (this.doNotSyncBoundingInfo || this.thinInstanceRefreshBoundingInfo(!1))
  60715. }
  60716. ,
  60717. e.prototype._postActivate = function() {
  60718. this.edgesShareWithInstances && this.edgesRenderer && this.edgesRenderer.isEnabled && this._renderingGroup && (this._renderingGroup._edgesRenderers.pushNoDuplicate(this.edgesRenderer),
  60719. this.edgesRenderer.customInstances.push(this.getWorldMatrix()))
  60720. }
  60721. ,
  60722. e.prototype.refreshBoundingInfo = function(i, o) {
  60723. if (i === void 0 && (i = !1),
  60724. o === void 0 && (o = !0),
  60725. this.hasBoundingInfo && this.getBoundingInfo().isLocked)
  60726. return this;
  60727. var s = this.geometry ? this.geometry.boundingBias : null;
  60728. return this._refreshBoundingInfo(this._getPositionData(i, o), s),
  60729. this
  60730. }
  60731. ,
  60732. e.prototype._createGlobalSubMesh = function(i) {
  60733. var o = this.getTotalVertices();
  60734. if (!o || !this.getIndices())
  60735. return null;
  60736. if (this.subMeshes && this.subMeshes.length > 0) {
  60737. var s = this.getIndices();
  60738. if (!s)
  60739. return null;
  60740. var c = s.length
  60741. , d = !1;
  60742. if (i)
  60743. d = !0;
  60744. else
  60745. for (var _ = 0, b = this.subMeshes; _ < b.length; _++) {
  60746. var k = b[_];
  60747. if (k.indexStart + k.indexCount > c) {
  60748. d = !0;
  60749. break
  60750. }
  60751. if (k.verticesStart + k.verticesCount > o) {
  60752. d = !0;
  60753. break
  60754. }
  60755. }
  60756. if (!d)
  60757. return this.subMeshes[0]
  60758. }
  60759. return this.releaseSubMeshes(),
  60760. new SubMesh(0,0,o,0,this.getTotalIndices(),this)
  60761. }
  60762. ,
  60763. e.prototype.subdivide = function(i) {
  60764. if (!(i < 1)) {
  60765. for (var o = this.getTotalIndices(), s = o / i | 0, c = 0; s % 3 !== 0; )
  60766. s++;
  60767. this.releaseSubMeshes();
  60768. for (var d = 0; d < i && !(c >= o); d++)
  60769. SubMesh.CreateFromIndices(0, c, d === i - 1 ? o - c : s, this),
  60770. c += s;
  60771. this.synchronizeInstances()
  60772. }
  60773. }
  60774. ,
  60775. e.prototype.setVerticesData = function(i, o, s, c) {
  60776. if (s === void 0 && (s = !1),
  60777. this._geometry)
  60778. this._geometry.setVerticesData(i, o, s, c);
  60779. else {
  60780. var d = new VertexData;
  60781. d.set(o, i);
  60782. var _ = this.getScene();
  60783. new Geometry(Geometry.RandomId(),_,d,s,this)
  60784. }
  60785. return this
  60786. }
  60787. ,
  60788. e.prototype.removeVerticesData = function(i) {
  60789. !this._geometry || this._geometry.removeVerticesData(i)
  60790. }
  60791. ,
  60792. e.prototype.markVerticesDataAsUpdatable = function(i, o) {
  60793. o === void 0 && (o = !0);
  60794. var s = this.getVertexBuffer(i);
  60795. !s || s.isUpdatable() === o || this.setVerticesData(i, this.getVerticesData(i), o)
  60796. }
  60797. ,
  60798. e.prototype.setVerticesBuffer = function(i, o) {
  60799. return o === void 0 && (o = !0),
  60800. this._geometry || (this._geometry = Geometry.CreateGeometryForMesh(this)),
  60801. this._geometry.setVerticesBuffer(i, null, o),
  60802. this
  60803. }
  60804. ,
  60805. e.prototype.updateVerticesData = function(i, o, s, c) {
  60806. return this._geometry ? (c ? (this.makeGeometryUnique(),
  60807. this.updateVerticesData(i, o, s, !1)) : this._geometry.updateVerticesData(i, o, s),
  60808. this) : this
  60809. }
  60810. ,
  60811. e.prototype.updateMeshPositions = function(i, o) {
  60812. o === void 0 && (o = !0);
  60813. var s = this.getVerticesData(VertexBuffer.PositionKind);
  60814. if (!s)
  60815. return this;
  60816. if (i(s),
  60817. this.updateVerticesData(VertexBuffer.PositionKind, s, !1, !1),
  60818. o) {
  60819. var c = this.getIndices()
  60820. , d = this.getVerticesData(VertexBuffer.NormalKind);
  60821. if (!d)
  60822. return this;
  60823. VertexData.ComputeNormals(s, c, d),
  60824. this.updateVerticesData(VertexBuffer.NormalKind, d, !1, !1)
  60825. }
  60826. return this
  60827. }
  60828. ,
  60829. e.prototype.makeGeometryUnique = function() {
  60830. if (!this._geometry)
  60831. return this;
  60832. if (this._geometry.meshes.length === 1)
  60833. return this;
  60834. var i = this._geometry
  60835. , o = this._geometry.copy(Geometry.RandomId());
  60836. return i.releaseForMesh(this, !0),
  60837. o.applyToMesh(this),
  60838. this
  60839. }
  60840. ,
  60841. e.prototype.setIndices = function(i, o, s) {
  60842. if (o === void 0 && (o = null),
  60843. s === void 0 && (s = !1),
  60844. this._geometry)
  60845. this._geometry.setIndices(i, o, s);
  60846. else {
  60847. var c = new VertexData;
  60848. c.indices = i;
  60849. var d = this.getScene();
  60850. new Geometry(Geometry.RandomId(),d,c,s,this)
  60851. }
  60852. return this
  60853. }
  60854. ,
  60855. e.prototype.updateIndices = function(i, o, s) {
  60856. return s === void 0 && (s = !1),
  60857. this._geometry ? (this._geometry.updateIndices(i, o, s),
  60858. this) : this
  60859. }
  60860. ,
  60861. e.prototype.toLeftHanded = function() {
  60862. return this._geometry ? (this._geometry.toLeftHanded(),
  60863. this) : this
  60864. }
  60865. ,
  60866. e.prototype._bind = function(i, o, s) {
  60867. if (!this._geometry)
  60868. return this;
  60869. var c = this.getScene().getEngine();
  60870. this.morphTargetManager && this.morphTargetManager.isUsingTextureForTargets && this.morphTargetManager._bind(o);
  60871. var d;
  60872. if (this._unIndexed)
  60873. d = null;
  60874. else
  60875. switch (s) {
  60876. case Material.PointFillMode:
  60877. d = null;
  60878. break;
  60879. case Material.WireFrameFillMode:
  60880. d = i._getLinesIndexBuffer(this.getIndices(), c);
  60881. break;
  60882. default:
  60883. case Material.TriangleFillMode:
  60884. d = this._geometry.getIndexBuffer();
  60885. break
  60886. }
  60887. return !this._userInstancedBuffersStorage || this.hasThinInstances ? this._geometry._bind(o, d) : this._geometry._bind(o, d, this._userInstancedBuffersStorage.vertexBuffers, this._userInstancedBuffersStorage.vertexArrayObjects),
  60888. this
  60889. }
  60890. ,
  60891. e.prototype._draw = function(i, o, s) {
  60892. if (!this._geometry || !this._geometry.getVertexBuffers() || !this._unIndexed && !this._geometry.getIndexBuffer())
  60893. return this;
  60894. this._internalMeshDataInfo._onBeforeDrawObservable && this._internalMeshDataInfo._onBeforeDrawObservable.notifyObservers(this);
  60895. var c = this.getScene()
  60896. , d = c.getEngine();
  60897. return this._unIndexed || o == Material.PointFillMode ? d.drawArraysType(o, i.verticesStart, i.verticesCount, this.forcedInstanceCount || s) : o == Material.WireFrameFillMode ? d.drawElementsType(o, 0, i._linesIndexCount, this.forcedInstanceCount || s) : d.drawElementsType(o, i.indexStart, i.indexCount, this.forcedInstanceCount || s),
  60898. this
  60899. }
  60900. ,
  60901. e.prototype.registerBeforeRender = function(i) {
  60902. return this.onBeforeRenderObservable.add(i),
  60903. this
  60904. }
  60905. ,
  60906. e.prototype.unregisterBeforeRender = function(i) {
  60907. return this.onBeforeRenderObservable.removeCallback(i),
  60908. this
  60909. }
  60910. ,
  60911. e.prototype.registerAfterRender = function(i) {
  60912. return this.onAfterRenderObservable.add(i),
  60913. this
  60914. }
  60915. ,
  60916. e.prototype.unregisterAfterRender = function(i) {
  60917. return this.onAfterRenderObservable.removeCallback(i),
  60918. this
  60919. }
  60920. ,
  60921. e.prototype._getInstancesRenderList = function(i, o) {
  60922. if (o === void 0 && (o = !1),
  60923. this._instanceDataStorage.isFrozen) {
  60924. if (o)
  60925. return this._instanceDataStorage.batchCacheReplacementModeInFrozenMode.hardwareInstancedRendering[i] = !1,
  60926. this._instanceDataStorage.batchCacheReplacementModeInFrozenMode.renderSelf[i] = !0,
  60927. this._instanceDataStorage.batchCacheReplacementModeInFrozenMode;
  60928. if (this._instanceDataStorage.previousBatch)
  60929. return this._instanceDataStorage.previousBatch
  60930. }
  60931. var s = this.getScene()
  60932. , c = s._isInIntermediateRendering()
  60933. , d = c ? this._internalAbstractMeshDataInfo._onlyForInstancesIntermediate : this._internalAbstractMeshDataInfo._onlyForInstances
  60934. , _ = this._instanceDataStorage.batchCache;
  60935. if (_.mustReturn = !1,
  60936. _.renderSelf[i] = o || !d && this.isEnabled() && this.isVisible,
  60937. _.visibleInstances[i] = null,
  60938. this._instanceDataStorage.visibleInstances && !o) {
  60939. var b = this._instanceDataStorage.visibleInstances
  60940. , k = s.getRenderId()
  60941. , j = c ? b.intermediateDefaultRenderId : b.defaultRenderId;
  60942. _.visibleInstances[i] = b[k],
  60943. !_.visibleInstances[i] && j && (_.visibleInstances[i] = b[j])
  60944. }
  60945. return _.hardwareInstancedRendering[i] = !o && this._instanceDataStorage.hardwareInstancedRendering && _.visibleInstances[i] !== null && _.visibleInstances[i] !== void 0,
  60946. this._instanceDataStorage.previousBatch = _,
  60947. _
  60948. }
  60949. ,
  60950. e.prototype._renderWithInstances = function(i, o, s, c, d) {
  60951. var _, b = s.visibleInstances[i._id];
  60952. if (!b)
  60953. return this;
  60954. for (var k = this._instanceDataStorage, j = k.instancesBufferSize, $ = k.instancesBuffer, _e = k.instancesPreviousBuffer, et = b.length + 1, tt = et * 16 * 4; k.instancesBufferSize < tt; )
  60955. k.instancesBufferSize *= 2;
  60956. (!k.instancesData || j != k.instancesBufferSize) && (k.instancesData = new Float32Array(k.instancesBufferSize / 4)),
  60957. (this._scene.needsPreviousWorldMatrices && !k.instancesPreviousData || j != k.instancesBufferSize) && (k.instancesPreviousData = new Float32Array(k.instancesBufferSize / 4));
  60958. var rt = 0
  60959. , it = 0
  60960. , nt = s.renderSelf[i._id]
  60961. , ot = !$ || j !== k.instancesBufferSize || this._scene.needsPreviousWorldMatrices && !k.instancesPreviousBuffer;
  60962. if (!this._instanceDataStorage.manualUpdate && (!k.isFrozen || ot)) {
  60963. var at = this._effectiveMesh.getWorldMatrix();
  60964. if (nt && (this._scene.needsPreviousWorldMatrices && (k.masterMeshPreviousWorldMatrix ? (k.masterMeshPreviousWorldMatrix.copyToArray(k.instancesPreviousData, rt),
  60965. k.masterMeshPreviousWorldMatrix.copyFrom(at)) : (k.masterMeshPreviousWorldMatrix = at.clone(),
  60966. k.masterMeshPreviousWorldMatrix.copyToArray(k.instancesPreviousData, rt))),
  60967. at.copyToArray(k.instancesData, rt),
  60968. rt += 16,
  60969. it++),
  60970. b) {
  60971. if (e.INSTANCEDMESH_SORT_TRANSPARENT && this._scene.activeCamera && ((_ = i.getMaterial()) === null || _ === void 0 ? void 0 : _.needAlphaBlendingForMesh(i.getRenderingMesh()))) {
  60972. for (var st = this._scene.activeCamera.globalPosition, ut = 0; ut < b.length; ut++) {
  60973. var ct = b[ut];
  60974. ct._distanceToCamera = Vector3.Distance(ct.getBoundingInfo().boundingSphere.centerWorld, st)
  60975. }
  60976. b.sort(function(pt, dt) {
  60977. return pt._distanceToCamera > dt._distanceToCamera ? -1 : pt._distanceToCamera < dt._distanceToCamera ? 1 : 0
  60978. })
  60979. }
  60980. for (var lt = 0; lt < b.length; lt++) {
  60981. var ft = b[lt]
  60982. , ht = ft.getWorldMatrix();
  60983. ht.copyToArray(k.instancesData, rt),
  60984. this._scene.needsPreviousWorldMatrices && (ft._previousWorldMatrix ? (ft._previousWorldMatrix.copyToArray(k.instancesPreviousData, rt),
  60985. ft._previousWorldMatrix.copyFrom(ht)) : (ft._previousWorldMatrix = ht.clone(),
  60986. ft._previousWorldMatrix.copyToArray(k.instancesPreviousData, rt))),
  60987. rt += 16,
  60988. it++
  60989. }
  60990. }
  60991. } else
  60992. it = (nt ? 1 : 0) + b.length;
  60993. return ot ? ($ && $.dispose(),
  60994. _e && _e.dispose(),
  60995. $ = new Buffer(d,k.instancesData,!0,16,!1,!0),
  60996. k.instancesBuffer = $,
  60997. this._userInstancedBuffersStorage || (this._userInstancedBuffersStorage = {
  60998. data: {},
  60999. vertexBuffers: {},
  61000. strides: {},
  61001. sizes: {},
  61002. vertexArrayObjects: this.getEngine().getCaps().vertexArrayObject ? {} : void 0
  61003. }),
  61004. this._userInstancedBuffersStorage.vertexBuffers.world0 = $.createVertexBuffer("world0", 0, 4),
  61005. this._userInstancedBuffersStorage.vertexBuffers.world1 = $.createVertexBuffer("world1", 4, 4),
  61006. this._userInstancedBuffersStorage.vertexBuffers.world2 = $.createVertexBuffer("world2", 8, 4),
  61007. this._userInstancedBuffersStorage.vertexBuffers.world3 = $.createVertexBuffer("world3", 12, 4),
  61008. this._scene.needsPreviousWorldMatrices && (_e = new Buffer(d,k.instancesPreviousData,!0,16,!1,!0),
  61009. k.instancesPreviousBuffer = _e,
  61010. this._userInstancedBuffersStorage.vertexBuffers.previousWorld0 = _e.createVertexBuffer("previousWorld0", 0, 4),
  61011. this._userInstancedBuffersStorage.vertexBuffers.previousWorld1 = _e.createVertexBuffer("previousWorld1", 4, 4),
  61012. this._userInstancedBuffersStorage.vertexBuffers.previousWorld2 = _e.createVertexBuffer("previousWorld2", 8, 4),
  61013. this._userInstancedBuffersStorage.vertexBuffers.previousWorld3 = _e.createVertexBuffer("previousWorld3", 12, 4)),
  61014. this._invalidateInstanceVertexArrayObject()) : this._instanceDataStorage.isFrozen || ($.updateDirectly(k.instancesData, 0, it),
  61015. this._scene.needsPreviousWorldMatrices && (!this._instanceDataStorage.manualUpdate || this._instanceDataStorage.previousManualUpdate) && _e.updateDirectly(k.instancesPreviousData, 0, it)),
  61016. this._processInstancedBuffers(b, nt),
  61017. this.getScene()._activeIndices.addCount(i.indexCount * it, !1),
  61018. d._currentDrawContext && (d._currentDrawContext.useInstancing = !0),
  61019. this._bind(i, c, o),
  61020. this._draw(i, o, it),
  61021. this._scene.needsPreviousWorldMatrices && !ot && this._instanceDataStorage.manualUpdate && !this._instanceDataStorage.isFrozen && !this._instanceDataStorage.previousManualUpdate && _e.updateDirectly(k.instancesData, 0, it),
  61022. d.unbindInstanceAttributes(),
  61023. this
  61024. }
  61025. ,
  61026. e.prototype._renderWithThinInstances = function(i, o, s, c) {
  61027. var d, _, b = (_ = (d = this._thinInstanceDataStorage) === null || d === void 0 ? void 0 : d.instancesCount) !== null && _ !== void 0 ? _ : 0;
  61028. this.getScene()._activeIndices.addCount(i.indexCount * b, !1),
  61029. c._currentDrawContext && (c._currentDrawContext.useInstancing = !0),
  61030. this._bind(i, s, o),
  61031. this._draw(i, o, b),
  61032. this._scene.needsPreviousWorldMatrices && !this._thinInstanceDataStorage.previousMatrixData && this._thinInstanceDataStorage.matrixData && (this._thinInstanceDataStorage.previousMatrixBuffer ? this._thinInstanceDataStorage.previousMatrixBuffer.updateDirectly(this._thinInstanceDataStorage.matrixData, 0, b) : this._thinInstanceDataStorage.previousMatrixBuffer = this._thinInstanceCreateMatrixBuffer("previousWorld", this._thinInstanceDataStorage.matrixData, !1)),
  61033. c.unbindInstanceAttributes()
  61034. }
  61035. ,
  61036. e.prototype._processInstancedBuffers = function(i, o) {}
  61037. ,
  61038. e.prototype._processRendering = function(i, o, s, c, d, _, b, k) {
  61039. var j = this.getScene()
  61040. , $ = j.getEngine();
  61041. if (_ && o.getRenderingMesh().hasThinInstances)
  61042. return this._renderWithThinInstances(o, c, s, $),
  61043. this;
  61044. if (_)
  61045. this._renderWithInstances(o, c, d, s, $);
  61046. else {
  61047. $._currentDrawContext && ($._currentDrawContext.useInstancing = !1);
  61048. var _e = 0;
  61049. d.renderSelf[o._id] && (b && b(!1, i._effectiveMesh.getWorldMatrix(), k, i._effectiveMesh),
  61050. _e++,
  61051. this._draw(o, c, this._instanceDataStorage.overridenInstanceCount));
  61052. var et = d.visibleInstances[o._id];
  61053. if (et) {
  61054. var tt = et.length;
  61055. _e += tt;
  61056. for (var rt = 0; rt < tt; rt++) {
  61057. var it = et[rt]
  61058. , nt = it.getWorldMatrix();
  61059. b && b(!0, nt, k),
  61060. this._draw(o, c)
  61061. }
  61062. }
  61063. j._activeIndices.addCount(o.indexCount * _e, !1)
  61064. }
  61065. return this
  61066. }
  61067. ,
  61068. e.prototype._rebuild = function(i) {
  61069. if (i === void 0 && (i = !1),
  61070. this._instanceDataStorage.instancesBuffer && (i && this._instanceDataStorage.instancesBuffer.dispose(),
  61071. this._instanceDataStorage.instancesBuffer = null),
  61072. this._userInstancedBuffersStorage) {
  61073. for (var o in this._userInstancedBuffersStorage.vertexBuffers) {
  61074. var s = this._userInstancedBuffersStorage.vertexBuffers[o];
  61075. s && (i && s.dispose(),
  61076. this._userInstancedBuffersStorage.vertexBuffers[o] = null)
  61077. }
  61078. this._userInstancedBuffersStorage.vertexArrayObjects && (this._userInstancedBuffersStorage.vertexArrayObjects = {})
  61079. }
  61080. this._internalMeshDataInfo._effectiveMaterial = null,
  61081. a.prototype._rebuild.call(this, i)
  61082. }
  61083. ,
  61084. e.prototype._freeze = function() {
  61085. if (!!this.subMeshes) {
  61086. for (var i = 0; i < this.subMeshes.length; i++)
  61087. this._getInstancesRenderList(i);
  61088. this._internalMeshDataInfo._effectiveMaterial = null,
  61089. this._instanceDataStorage.isFrozen = !0
  61090. }
  61091. }
  61092. ,
  61093. e.prototype._unFreeze = function() {
  61094. this._instanceDataStorage.isFrozen = !1,
  61095. this._instanceDataStorage.previousBatch = null
  61096. }
  61097. ,
  61098. e.prototype.render = function(i, o, s) {
  61099. var c, d, _, b = this.getScene();
  61100. if (this._internalAbstractMeshDataInfo._isActiveIntermediate ? this._internalAbstractMeshDataInfo._isActiveIntermediate = !1 : this._internalAbstractMeshDataInfo._isActive = !1,
  61101. this._checkOcclusionQuery())
  61102. return this;
  61103. var k = this._getInstancesRenderList(i._id, !!s);
  61104. if (k.mustReturn)
  61105. return this;
  61106. if (!this._geometry || !this._geometry.getVertexBuffers() || !this._unIndexed && !this._geometry.getIndexBuffer())
  61107. return this;
  61108. var j = b.getEngine()
  61109. , $ = 0
  61110. , _e = null;
  61111. this.ignoreCameraMaxZ && b.activeCamera && !b._isInIntermediateRendering() && ($ = b.activeCamera.maxZ,
  61112. _e = b.activeCamera,
  61113. b.activeCamera.maxZ = 0,
  61114. b.updateTransformMatrix(!0)),
  61115. this._internalMeshDataInfo._onBeforeRenderObservable && this._internalMeshDataInfo._onBeforeRenderObservable.notifyObservers(this);
  61116. var et = k.hardwareInstancedRendering[i._id] || i.getRenderingMesh().hasThinInstances
  61117. , tt = this._instanceDataStorage
  61118. , rt = i.getMaterial();
  61119. if (!rt)
  61120. return _e && (_e.maxZ = $,
  61121. b.updateTransformMatrix(!0)),
  61122. this;
  61123. if (!tt.isFrozen || !this._internalMeshDataInfo._effectiveMaterial || this._internalMeshDataInfo._effectiveMaterial !== rt) {
  61124. if (rt._storeEffectOnSubMeshes) {
  61125. if (!rt.isReadyForSubMesh(this, i, et))
  61126. return _e && (_e.maxZ = $,
  61127. b.updateTransformMatrix(!0)),
  61128. this
  61129. } else if (!rt.isReady(this, et))
  61130. return _e && (_e.maxZ = $,
  61131. b.updateTransformMatrix(!0)),
  61132. this;
  61133. this._internalMeshDataInfo._effectiveMaterial = rt
  61134. } else if (rt._storeEffectOnSubMeshes && !(!((c = i.effect) === null || c === void 0) && c._wasPreviouslyReady) || !rt._storeEffectOnSubMeshes && !(!((d = rt.getEffect()) === null || d === void 0) && d._wasPreviouslyReady))
  61135. return _e && (_e.maxZ = $,
  61136. b.updateTransformMatrix(!0)),
  61137. this;
  61138. o && j.setAlphaMode(this._internalMeshDataInfo._effectiveMaterial.alphaMode);
  61139. var it;
  61140. this._internalMeshDataInfo._effectiveMaterial._storeEffectOnSubMeshes ? it = i._drawWrapper : it = this._internalMeshDataInfo._effectiveMaterial._getDrawWrapper();
  61141. for (var nt = (_ = it == null ? void 0 : it.effect) !== null && _ !== void 0 ? _ : null, ot = 0, at = b._beforeRenderingMeshStage; ot < at.length; ot++) {
  61142. var st = at[ot];
  61143. st.action(this, i, k, nt)
  61144. }
  61145. if (!it || !nt)
  61146. return _e && (_e.maxZ = $,
  61147. b.updateTransformMatrix(!0)),
  61148. this;
  61149. var ut = s || this._effectiveMesh, ct;
  61150. if (!tt.isFrozen && (this._internalMeshDataInfo._effectiveMaterial.backFaceCulling || this.overrideMaterialSideOrientation !== null)) {
  61151. var lt = ut._getWorldMatrixDeterminant();
  61152. ct = this.overrideMaterialSideOrientation,
  61153. ct == null && (ct = this._internalMeshDataInfo._effectiveMaterial.sideOrientation),
  61154. lt < 0 && (ct = ct === Material.ClockWiseSideOrientation ? Material.CounterClockWiseSideOrientation : Material.ClockWiseSideOrientation),
  61155. tt.sideOrientation = ct
  61156. } else
  61157. ct = tt.sideOrientation;
  61158. var ft = this._internalMeshDataInfo._effectiveMaterial._preBind(it, ct);
  61159. this._internalMeshDataInfo._effectiveMaterial.forceDepthWrite && j.setDepthWrite(!0);
  61160. var ht = b.forcePointsCloud ? Material.PointFillMode : b.forceWireframe ? Material.WireFrameFillMode : this._internalMeshDataInfo._effectiveMaterial.fillMode;
  61161. this._internalMeshDataInfo._onBeforeBindObservable && this._internalMeshDataInfo._onBeforeBindObservable.notifyObservers(this),
  61162. et || this._bind(i, nt, ht);
  61163. var pt = this._internalMeshDataInfo._effectiveMaterial
  61164. , dt = ut.getWorldMatrix();
  61165. pt._storeEffectOnSubMeshes ? pt.bindForSubMesh(dt, this, i) : pt.bind(dt, this),
  61166. !pt.backFaceCulling && pt.separateCullingPass && (j.setState(!0, pt.zOffset, !1, !ft, pt.cullBackFaces, pt.stencil, pt.zOffsetUnits),
  61167. this._processRendering(this, i, nt, ht, k, et, this._onBeforeDraw, this._internalMeshDataInfo._effectiveMaterial),
  61168. j.setState(!0, pt.zOffset, !1, ft, pt.cullBackFaces, pt.stencil, pt.zOffsetUnits),
  61169. this._internalMeshDataInfo._onBetweenPassObservable && this._internalMeshDataInfo._onBetweenPassObservable.notifyObservers(i)),
  61170. this._processRendering(this, i, nt, ht, k, et, this._onBeforeDraw, this._internalMeshDataInfo._effectiveMaterial),
  61171. this._internalMeshDataInfo._effectiveMaterial.unbind();
  61172. for (var _t = 0, mt = b._afterRenderingMeshStage; _t < mt.length; _t++) {
  61173. var st = mt[_t];
  61174. st.action(this, i, k, nt)
  61175. }
  61176. return this._internalMeshDataInfo._onAfterRenderObservable && this._internalMeshDataInfo._onAfterRenderObservable.notifyObservers(this),
  61177. _e && (_e.maxZ = $,
  61178. b.updateTransformMatrix(!0)),
  61179. this
  61180. }
  61181. ,
  61182. e.prototype._onBeforeDraw = function(i, o, s) {
  61183. i && s && s.bindOnlyWorldMatrix(o)
  61184. }
  61185. ,
  61186. e.prototype.cleanMatrixWeights = function() {
  61187. this.isVerticesDataPresent(VertexBuffer.MatricesWeightsKind) && (this.isVerticesDataPresent(VertexBuffer.MatricesWeightsExtraKind) ? this.normalizeSkinWeightsAndExtra() : this.normalizeSkinFourWeights())
  61188. }
  61189. ,
  61190. e.prototype.normalizeSkinFourWeights = function() {
  61191. for (var i = this.getVerticesData(VertexBuffer.MatricesWeightsKind), o = i.length, s = 0; s < o; s += 4) {
  61192. var c = i[s] + i[s + 1] + i[s + 2] + i[s + 3];
  61193. if (c === 0)
  61194. i[s] = 1;
  61195. else {
  61196. var d = 1 / c;
  61197. i[s] *= d,
  61198. i[s + 1] *= d,
  61199. i[s + 2] *= d,
  61200. i[s + 3] *= d
  61201. }
  61202. }
  61203. this.setVerticesData(VertexBuffer.MatricesWeightsKind, i)
  61204. }
  61205. ,
  61206. e.prototype.normalizeSkinWeightsAndExtra = function() {
  61207. for (var i = this.getVerticesData(VertexBuffer.MatricesWeightsExtraKind), o = this.getVerticesData(VertexBuffer.MatricesWeightsKind), s = o.length, c = 0; c < s; c += 4) {
  61208. var d = o[c] + o[c + 1] + o[c + 2] + o[c + 3];
  61209. if (d += i[c] + i[c + 1] + i[c + 2] + i[c + 3],
  61210. d === 0)
  61211. o[c] = 1;
  61212. else {
  61213. var _ = 1 / d;
  61214. o[c] *= _,
  61215. o[c + 1] *= _,
  61216. o[c + 2] *= _,
  61217. o[c + 3] *= _,
  61218. i[c] *= _,
  61219. i[c + 1] *= _,
  61220. i[c + 2] *= _,
  61221. i[c + 3] *= _
  61222. }
  61223. }
  61224. this.setVerticesData(VertexBuffer.MatricesWeightsKind, o),
  61225. this.setVerticesData(VertexBuffer.MatricesWeightsKind, i)
  61226. }
  61227. ,
  61228. e.prototype.validateSkinning = function() {
  61229. var i = this.getVerticesData(VertexBuffer.MatricesWeightsExtraKind)
  61230. , o = this.getVerticesData(VertexBuffer.MatricesWeightsKind);
  61231. if (o === null || this.skeleton == null)
  61232. return {
  61233. skinned: !1,
  61234. valid: !0,
  61235. report: "not skinned"
  61236. };
  61237. for (var s = o.length, c = 0, d = 0, _ = 0, b = 0, k = i === null ? 4 : 8, j = new Array, $ = 0; $ <= k; $++)
  61238. j[$] = 0;
  61239. for (var _e = .001, $ = 0; $ < s; $ += 4) {
  61240. for (var et = o[$], tt = et, rt = tt === 0 ? 0 : 1, it = 1; it < k; it++) {
  61241. var nt = it < 4 ? o[$ + it] : i[$ + it - 4];
  61242. nt > et && c++,
  61243. nt !== 0 && rt++,
  61244. tt += nt,
  61245. et = nt
  61246. }
  61247. if (j[rt]++,
  61248. rt > _ && (_ = rt),
  61249. tt === 0)
  61250. d++;
  61251. else {
  61252. var ot = 1 / tt
  61253. , at = 0;
  61254. for (it = 0; it < k; it++)
  61255. it < 4 ? at += Math.abs(o[$ + it] - o[$ + it] * ot) : at += Math.abs(i[$ + it - 4] - i[$ + it - 4] * ot);
  61256. at > _e && b++
  61257. }
  61258. }
  61259. for (var st = this.skeleton.bones.length, ut = this.getVerticesData(VertexBuffer.MatricesIndicesKind), ct = this.getVerticesData(VertexBuffer.MatricesIndicesExtraKind), lt = 0, $ = 0; $ < s; $ += 4)
  61260. for (var it = 0; it < k; it++) {
  61261. var ft = it < 4 ? ut[$ + it] : ct[$ + it - 4];
  61262. (ft >= st || ft < 0) && lt++
  61263. }
  61264. var ht = "Number of Weights = " + s / 4 + `
  61265. Maximum influences = ` + _ + `
  61266. Missing Weights = ` + d + `
  61267. Not Sorted = ` + c + `
  61268. Not Normalized = ` + b + `
  61269. WeightCounts = [` + j + `]
  61270. Number of bones = ` + st + `
  61271. Bad Bone Indices = ` + lt;
  61272. return {
  61273. skinned: !0,
  61274. valid: d === 0 && b === 0 && lt === 0,
  61275. report: ht
  61276. }
  61277. }
  61278. ,
  61279. e.prototype._checkDelayState = function() {
  61280. var i = this.getScene();
  61281. return this._geometry ? this._geometry.load(i) : this.delayLoadState === 4 && (this.delayLoadState = 2,
  61282. this._queueLoad(i)),
  61283. this
  61284. }
  61285. ,
  61286. e.prototype._queueLoad = function(i) {
  61287. var o = this;
  61288. i._addPendingData(this);
  61289. var s = this.delayLoadingFile.indexOf(".babylonbinarymeshdata") !== -1;
  61290. return Tools.LoadFile(this.delayLoadingFile, function(c) {
  61291. c instanceof ArrayBuffer ? o._delayLoadingFunction(c, o) : o._delayLoadingFunction(JSON.parse(c), o),
  61292. o.instances.forEach(function(d) {
  61293. d.refreshBoundingInfo(),
  61294. d._syncSubMeshes()
  61295. }),
  61296. o.delayLoadState = 1,
  61297. i._removePendingData(o)
  61298. }, function() {}, i.offlineProvider, s),
  61299. this
  61300. }
  61301. ,
  61302. e.prototype.isInFrustum = function(i) {
  61303. return this.delayLoadState === 2 || !a.prototype.isInFrustum.call(this, i) ? !1 : (this._checkDelayState(),
  61304. !0)
  61305. }
  61306. ,
  61307. e.prototype.setMaterialById = function(i) {
  61308. var o = this.getScene().materials, s;
  61309. for (s = o.length - 1; s > -1; s--)
  61310. if (o[s].id === i)
  61311. return this.material = o[s],
  61312. this;
  61313. var c = this.getScene().multiMaterials;
  61314. for (s = c.length - 1; s > -1; s--)
  61315. if (c[s].id === i)
  61316. return this.material = c[s],
  61317. this;
  61318. return this
  61319. }
  61320. ,
  61321. e.prototype.getAnimatables = function() {
  61322. var i = new Array;
  61323. return this.material && i.push(this.material),
  61324. this.skeleton && i.push(this.skeleton),
  61325. i
  61326. }
  61327. ,
  61328. e.prototype.bakeTransformIntoVertices = function(i) {
  61329. if (!this.isVerticesDataPresent(VertexBuffer.PositionKind))
  61330. return this;
  61331. var o = this.subMeshes.splice(0);
  61332. this._resetPointsArrayCache();
  61333. var s = this.getVerticesData(VertexBuffer.PositionKind), c = new Array, d;
  61334. for (d = 0; d < s.length; d += 3)
  61335. Vector3.TransformCoordinates(Vector3.FromArray(s, d), i).toArray(c, d);
  61336. if (this.setVerticesData(VertexBuffer.PositionKind, c, this.getVertexBuffer(VertexBuffer.PositionKind).isUpdatable()),
  61337. this.isVerticesDataPresent(VertexBuffer.NormalKind)) {
  61338. for (s = this.getVerticesData(VertexBuffer.NormalKind),
  61339. c = [],
  61340. d = 0; d < s.length; d += 3)
  61341. Vector3.TransformNormal(Vector3.FromArray(s, d), i).normalize().toArray(c, d);
  61342. this.setVerticesData(VertexBuffer.NormalKind, c, this.getVertexBuffer(VertexBuffer.NormalKind).isUpdatable())
  61343. }
  61344. return i.determinant() < 0 && this.flipFaces(),
  61345. this.releaseSubMeshes(),
  61346. this.subMeshes = o,
  61347. this
  61348. }
  61349. ,
  61350. e.prototype.bakeCurrentTransformIntoVertices = function(i) {
  61351. return i === void 0 && (i = !0),
  61352. this.bakeTransformIntoVertices(this.computeWorldMatrix(!0)),
  61353. this.resetLocalMatrix(i),
  61354. this
  61355. }
  61356. ,
  61357. Object.defineProperty(e.prototype, "_positions", {
  61358. get: function() {
  61359. return this._internalAbstractMeshDataInfo._positions ? this._internalAbstractMeshDataInfo._positions : this._geometry ? this._geometry._positions : null
  61360. },
  61361. enumerable: !1,
  61362. configurable: !0
  61363. }),
  61364. e.prototype._resetPointsArrayCache = function() {
  61365. return this._geometry && this._geometry._resetPointsArrayCache(),
  61366. this
  61367. }
  61368. ,
  61369. e.prototype._generatePointsArray = function() {
  61370. return this._geometry ? this._geometry._generatePointsArray() : !1
  61371. }
  61372. ,
  61373. e.prototype.clone = function(i, o, s, c) {
  61374. return i === void 0 && (i = ""),
  61375. o === void 0 && (o = null),
  61376. c === void 0 && (c = !0),
  61377. new e(i,this.getScene(),o,this,s,c)
  61378. }
  61379. ,
  61380. e.prototype.dispose = function(i, o) {
  61381. o === void 0 && (o = !1),
  61382. this.morphTargetManager = null,
  61383. this._geometry && this._geometry.releaseForMesh(this, !0);
  61384. var s = this._internalMeshDataInfo;
  61385. if (s._onBeforeDrawObservable && s._onBeforeDrawObservable.clear(),
  61386. s._onBeforeBindObservable && s._onBeforeBindObservable.clear(),
  61387. s._onBeforeRenderObservable && s._onBeforeRenderObservable.clear(),
  61388. s._onAfterRenderObservable && s._onAfterRenderObservable.clear(),
  61389. s._onBetweenPassObservable && s._onBetweenPassObservable.clear(),
  61390. this._scene.useClonedMeshMap) {
  61391. if (s.meshMap)
  61392. for (var c in s.meshMap) {
  61393. var d = s.meshMap[c];
  61394. d && (d._internalMeshDataInfo._source = null,
  61395. s.meshMap[c] = void 0)
  61396. }
  61397. s._source && s._source._internalMeshDataInfo.meshMap && (s._source._internalMeshDataInfo.meshMap[this.uniqueId] = void 0)
  61398. } else
  61399. for (var _ = this.getScene().meshes, b = 0, k = _; b < k.length; b++) {
  61400. var j = k[b]
  61401. , d = j;
  61402. d._internalMeshDataInfo && d._internalMeshDataInfo._source && d._internalMeshDataInfo._source === this && (d._internalMeshDataInfo._source = null)
  61403. }
  61404. s._source = null,
  61405. this._disposeInstanceSpecificData(),
  61406. this._disposeThinInstanceSpecificData(),
  61407. this._internalMeshDataInfo._checkReadinessObserver && this._scene.onBeforeRenderObservable.remove(this._internalMeshDataInfo._checkReadinessObserver),
  61408. a.prototype.dispose.call(this, i, o)
  61409. }
  61410. ,
  61411. e.prototype._disposeInstanceSpecificData = function() {}
  61412. ,
  61413. e.prototype._disposeThinInstanceSpecificData = function() {}
  61414. ,
  61415. e.prototype._invalidateInstanceVertexArrayObject = function() {}
  61416. ,
  61417. e.prototype.applyDisplacementMap = function(i, o, s, c, d, _, b) {
  61418. var k = this;
  61419. b === void 0 && (b = !1);
  61420. var j = this.getScene()
  61421. , $ = function(_e) {
  61422. var et = _e.width
  61423. , tt = _e.height
  61424. , rt = k.getEngine().createCanvas(et, tt)
  61425. , it = rt.getContext("2d");
  61426. it.drawImage(_e, 0, 0);
  61427. var nt = it.getImageData(0, 0, et, tt).data;
  61428. k.applyDisplacementMapFromBuffer(nt, et, tt, o, s, d, _, b),
  61429. c && c(k)
  61430. };
  61431. return Tools.LoadImage(i, $, function() {}, j.offlineProvider),
  61432. this
  61433. }
  61434. ,
  61435. e.prototype.applyDisplacementMapFromBuffer = function(i, o, s, c, d, _, b, k) {
  61436. if (k === void 0 && (k = !1),
  61437. !this.isVerticesDataPresent(VertexBuffer.PositionKind) || !this.isVerticesDataPresent(VertexBuffer.NormalKind) || !this.isVerticesDataPresent(VertexBuffer.UVKind))
  61438. return Logger$2.Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing"),
  61439. this;
  61440. var j = this.getVerticesData(VertexBuffer.PositionKind, !0, !0)
  61441. , $ = this.getVerticesData(VertexBuffer.NormalKind)
  61442. , _e = this.getVerticesData(VertexBuffer.UVKind)
  61443. , et = Vector3.Zero()
  61444. , tt = Vector3.Zero()
  61445. , rt = Vector2.Zero();
  61446. _ = _ || Vector2.Zero(),
  61447. b = b || new Vector2(1,1);
  61448. for (var it = 0; it < j.length; it += 3) {
  61449. Vector3.FromArrayToRef(j, it, et),
  61450. Vector3.FromArrayToRef($, it, tt),
  61451. Vector2.FromArrayToRef(_e, it / 3 * 2, rt);
  61452. var nt = Math.abs(rt.x * b.x + _.x % 1) * (o - 1) % o | 0
  61453. , ot = Math.abs(rt.y * b.y + _.y % 1) * (s - 1) % s | 0
  61454. , at = (nt + ot * o) * 4
  61455. , st = i[at] / 255
  61456. , ut = i[at + 1] / 255
  61457. , ct = i[at + 2] / 255
  61458. , lt = st * .3 + ut * .59 + ct * .11;
  61459. tt.normalize(),
  61460. tt.scaleInPlace(c + (d - c) * lt),
  61461. et = et.add(tt),
  61462. et.toArray(j, it)
  61463. }
  61464. return VertexData.ComputeNormals(j, this.getIndices(), $),
  61465. k ? (this.setVerticesData(VertexBuffer.PositionKind, j),
  61466. this.setVerticesData(VertexBuffer.NormalKind, $),
  61467. this.setVerticesData(VertexBuffer.UVKind, _e)) : (this.updateVerticesData(VertexBuffer.PositionKind, j),
  61468. this.updateVerticesData(VertexBuffer.NormalKind, $)),
  61469. this
  61470. }
  61471. ,
  61472. e.prototype.convertToFlatShadedMesh = function() {
  61473. var i = this.getVerticesDataKinds(), o = {}, s = {}, c = {}, d = !1, _, b;
  61474. for (_ = 0; _ < i.length; _++) {
  61475. b = i[_];
  61476. var k = this.getVertexBuffer(b);
  61477. if (b === VertexBuffer.NormalKind) {
  61478. d = k.isUpdatable(),
  61479. i.splice(_, 1),
  61480. _--;
  61481. continue
  61482. }
  61483. o[b] = k,
  61484. s[b] = this.getVerticesData(b),
  61485. c[b] = []
  61486. }
  61487. var j = this.subMeshes.slice(0), $ = this.getIndices(), _e = this.getTotalIndices(), et;
  61488. for (et = 0; et < _e; et++) {
  61489. var tt = $[et];
  61490. for (_ = 0; _ < i.length; _++) {
  61491. b = i[_];
  61492. for (var rt = o[b].getStrideSize(), it = 0; it < rt; it++)
  61493. c[b].push(s[b][tt * rt + it])
  61494. }
  61495. }
  61496. var nt = [], ot = c[VertexBuffer.PositionKind], at = this.getScene().useRightHandedSystem, st;
  61497. for (at ? st = this.overrideMaterialSideOrientation === 1 : st = this.overrideMaterialSideOrientation === 0,
  61498. et = 0; et < _e; et += 3) {
  61499. $[et] = et,
  61500. $[et + 1] = et + 1,
  61501. $[et + 2] = et + 2;
  61502. var ut = Vector3.FromArray(ot, et * 3)
  61503. , ct = Vector3.FromArray(ot, (et + 1) * 3)
  61504. , lt = Vector3.FromArray(ot, (et + 2) * 3)
  61505. , ft = ut.subtract(ct)
  61506. , ht = lt.subtract(ct)
  61507. , pt = Vector3.Normalize(Vector3.Cross(ft, ht));
  61508. st && pt.scaleInPlace(-1);
  61509. for (var dt = 0; dt < 3; dt++)
  61510. nt.push(pt.x),
  61511. nt.push(pt.y),
  61512. nt.push(pt.z)
  61513. }
  61514. for (this.setIndices($),
  61515. this.setVerticesData(VertexBuffer.NormalKind, nt, d),
  61516. _ = 0; _ < i.length; _++)
  61517. b = i[_],
  61518. this.setVerticesData(b, c[b], o[b].isUpdatable());
  61519. this.releaseSubMeshes();
  61520. for (var _t = 0; _t < j.length; _t++) {
  61521. var mt = j[_t];
  61522. SubMesh.AddToMesh(mt.materialIndex, mt.indexStart, mt.indexCount, mt.indexStart, mt.indexCount, this)
  61523. }
  61524. return this.synchronizeInstances(),
  61525. this
  61526. }
  61527. ,
  61528. e.prototype.convertToUnIndexedMesh = function() {
  61529. var i = this.getVerticesDataKinds(), o = {}, s = {}, c = {}, d, _;
  61530. for (d = 0; d < i.length; d++) {
  61531. _ = i[d];
  61532. var b = this.getVertexBuffer(_);
  61533. o[_] = b,
  61534. s[_] = o[_].getData(),
  61535. c[_] = []
  61536. }
  61537. var k = this.subMeshes.slice(0), j = this.getIndices(), $ = this.getTotalIndices(), _e;
  61538. for (_e = 0; _e < $; _e++) {
  61539. var et = j[_e];
  61540. for (d = 0; d < i.length; d++) {
  61541. _ = i[d];
  61542. for (var tt = o[_].getStrideSize(), rt = 0; rt < tt; rt++)
  61543. c[_].push(s[_][et * tt + rt])
  61544. }
  61545. }
  61546. for (_e = 0; _e < $; _e += 3)
  61547. j[_e] = _e,
  61548. j[_e + 1] = _e + 1,
  61549. j[_e + 2] = _e + 2;
  61550. for (this.setIndices(j),
  61551. d = 0; d < i.length; d++)
  61552. _ = i[d],
  61553. this.setVerticesData(_, c[_], o[_].isUpdatable());
  61554. this.releaseSubMeshes();
  61555. for (var it = 0; it < k.length; it++) {
  61556. var nt = k[it];
  61557. SubMesh.AddToMesh(nt.materialIndex, nt.indexStart, nt.indexCount, nt.indexStart, nt.indexCount, this)
  61558. }
  61559. return this._unIndexed = !0,
  61560. this.synchronizeInstances(),
  61561. this
  61562. }
  61563. ,
  61564. e.prototype.flipFaces = function(i) {
  61565. i === void 0 && (i = !1);
  61566. var o = VertexData.ExtractFromMesh(this), s;
  61567. if (i && this.isVerticesDataPresent(VertexBuffer.NormalKind) && o.normals)
  61568. for (s = 0; s < o.normals.length; s++)
  61569. o.normals[s] *= -1;
  61570. if (o.indices) {
  61571. var c;
  61572. for (s = 0; s < o.indices.length; s += 3)
  61573. c = o.indices[s + 1],
  61574. o.indices[s + 1] = o.indices[s + 2],
  61575. o.indices[s + 2] = c
  61576. }
  61577. return o.applyToMesh(this, this.isVertexBufferUpdatable(VertexBuffer.PositionKind)),
  61578. this
  61579. }
  61580. ,
  61581. e.prototype.increaseVertices = function(i) {
  61582. var o = VertexData.ExtractFromMesh(this)
  61583. , s = o.uvs && !Array.isArray(o.uvs) && Array.from ? Array.from(o.uvs) : o.uvs
  61584. , c = o.indices && !Array.isArray(o.indices) && Array.from ? Array.from(o.indices) : o.indices
  61585. , d = o.positions && !Array.isArray(o.positions) && Array.from ? Array.from(o.positions) : o.positions
  61586. , _ = o.normals && !Array.isArray(o.normals) && Array.from ? Array.from(o.normals) : o.normals;
  61587. if (!c || !d || !_ || !s)
  61588. Logger$2.Warn("VertexData contains null entries");
  61589. else {
  61590. o.indices = c,
  61591. o.positions = d,
  61592. o.normals = _,
  61593. o.uvs = s;
  61594. for (var b = i + 1, k = new Array, j = 0; j < b + 1; j++)
  61595. k[j] = new Array;
  61596. for (var $, _e, et = new Vector3(0,0,0), tt = new Vector3(0,0,0), rt = new Vector2(0,0), it = new Array, nt = new Array, ot = new Array, at, st = d.length, ut = s.length, j = 0; j < c.length; j += 3) {
  61597. nt[0] = c[j],
  61598. nt[1] = c[j + 1],
  61599. nt[2] = c[j + 2];
  61600. for (var ct = 0; ct < 3; ct++)
  61601. if ($ = nt[ct],
  61602. _e = nt[(ct + 1) % 3],
  61603. ot[$] === void 0 && ot[_e] === void 0 ? (ot[$] = new Array,
  61604. ot[_e] = new Array) : (ot[$] === void 0 && (ot[$] = new Array),
  61605. ot[_e] === void 0 && (ot[_e] = new Array)),
  61606. ot[$][_e] === void 0 && ot[_e][$] === void 0) {
  61607. ot[$][_e] = [],
  61608. et.x = (d[3 * _e] - d[3 * $]) / b,
  61609. et.y = (d[3 * _e + 1] - d[3 * $ + 1]) / b,
  61610. et.z = (d[3 * _e + 2] - d[3 * $ + 2]) / b,
  61611. tt.x = (_[3 * _e] - _[3 * $]) / b,
  61612. tt.y = (_[3 * _e + 1] - _[3 * $ + 1]) / b,
  61613. tt.z = (_[3 * _e + 2] - _[3 * $ + 2]) / b,
  61614. rt.x = (s[2 * _e] - s[2 * $]) / b,
  61615. rt.y = (s[2 * _e + 1] - s[2 * $ + 1]) / b,
  61616. ot[$][_e].push($);
  61617. for (var lt = 1; lt < b; lt++)
  61618. ot[$][_e].push(d.length / 3),
  61619. d[st] = d[3 * $] + lt * et.x,
  61620. _[st++] = _[3 * $] + lt * tt.x,
  61621. d[st] = d[3 * $ + 1] + lt * et.y,
  61622. _[st++] = _[3 * $ + 1] + lt * tt.y,
  61623. d[st] = d[3 * $ + 2] + lt * et.z,
  61624. _[st++] = _[3 * $ + 2] + lt * tt.z,
  61625. s[ut++] = s[2 * $] + lt * rt.x,
  61626. s[ut++] = s[2 * $ + 1] + lt * rt.y;
  61627. ot[$][_e].push(_e),
  61628. ot[_e][$] = new Array,
  61629. at = ot[$][_e].length;
  61630. for (var ft = 0; ft < at; ft++)
  61631. ot[_e][$][ft] = ot[$][_e][at - 1 - ft]
  61632. }
  61633. k[0][0] = c[j],
  61634. k[1][0] = ot[c[j]][c[j + 1]][1],
  61635. k[1][1] = ot[c[j]][c[j + 2]][1];
  61636. for (var lt = 2; lt < b; lt++) {
  61637. k[lt][0] = ot[c[j]][c[j + 1]][lt],
  61638. k[lt][lt] = ot[c[j]][c[j + 2]][lt],
  61639. et.x = (d[3 * k[lt][lt]] - d[3 * k[lt][0]]) / lt,
  61640. et.y = (d[3 * k[lt][lt] + 1] - d[3 * k[lt][0] + 1]) / lt,
  61641. et.z = (d[3 * k[lt][lt] + 2] - d[3 * k[lt][0] + 2]) / lt,
  61642. tt.x = (_[3 * k[lt][lt]] - _[3 * k[lt][0]]) / lt,
  61643. tt.y = (_[3 * k[lt][lt] + 1] - _[3 * k[lt][0] + 1]) / lt,
  61644. tt.z = (_[3 * k[lt][lt] + 2] - _[3 * k[lt][0] + 2]) / lt,
  61645. rt.x = (s[2 * k[lt][lt]] - s[2 * k[lt][0]]) / lt,
  61646. rt.y = (s[2 * k[lt][lt] + 1] - s[2 * k[lt][0] + 1]) / lt;
  61647. for (var ct = 1; ct < lt; ct++)
  61648. k[lt][ct] = d.length / 3,
  61649. d[st] = d[3 * k[lt][0]] + ct * et.x,
  61650. _[st++] = _[3 * k[lt][0]] + ct * tt.x,
  61651. d[st] = d[3 * k[lt][0] + 1] + ct * et.y,
  61652. _[st++] = _[3 * k[lt][0] + 1] + ct * tt.y,
  61653. d[st] = d[3 * k[lt][0] + 2] + ct * et.z,
  61654. _[st++] = _[3 * k[lt][0] + 2] + ct * tt.z,
  61655. s[ut++] = s[2 * k[lt][0]] + ct * rt.x,
  61656. s[ut++] = s[2 * k[lt][0] + 1] + ct * rt.y
  61657. }
  61658. k[b] = ot[c[j + 1]][c[j + 2]],
  61659. it.push(k[0][0], k[1][0], k[1][1]);
  61660. for (var lt = 1; lt < b; lt++) {
  61661. for (var ct = 0; ct < lt; ct++)
  61662. it.push(k[lt][ct], k[lt + 1][ct], k[lt + 1][ct + 1]),
  61663. it.push(k[lt][ct], k[lt + 1][ct + 1], k[lt][ct + 1]);
  61664. it.push(k[lt][ct], k[lt + 1][ct], k[lt + 1][ct + 1])
  61665. }
  61666. }
  61667. o.indices = it,
  61668. o.applyToMesh(this, this.isVertexBufferUpdatable(VertexBuffer.PositionKind))
  61669. }
  61670. }
  61671. ,
  61672. e.prototype.forceSharedVertices = function() {
  61673. var i = VertexData.ExtractFromMesh(this)
  61674. , o = i.uvs
  61675. , s = i.indices
  61676. , c = i.positions
  61677. , d = i.colors;
  61678. if (s === void 0 || c === void 0 || s === null || c === null)
  61679. Logger$2.Warn("VertexData contains empty entries");
  61680. else {
  61681. for (var _ = new Array, b = new Array, k = new Array, j = new Array, $ = new Array, _e = 0, et = {}, tt, rt, it = 0; it < s.length; it += 3) {
  61682. rt = [s[it], s[it + 1], s[it + 2]],
  61683. $ = new Array;
  61684. for (var nt = 0; nt < 3; nt++) {
  61685. $[nt] = "";
  61686. for (var ot = 0; ot < 3; ot++)
  61687. Math.abs(c[3 * rt[nt] + ot]) < 1e-8 && (c[3 * rt[nt] + ot] = 0),
  61688. $[nt] += c[3 * rt[nt] + ot] + "|"
  61689. }
  61690. if (!($[0] == $[1] || $[0] == $[2] || $[1] == $[2]))
  61691. for (var nt = 0; nt < 3; nt++) {
  61692. if (tt = et[$[nt]],
  61693. tt === void 0) {
  61694. et[$[nt]] = _e,
  61695. tt = _e++;
  61696. for (var ot = 0; ot < 3; ot++)
  61697. _.push(c[3 * rt[nt] + ot]);
  61698. if (d != null)
  61699. for (var ot = 0; ot < 4; ot++)
  61700. j.push(d[4 * rt[nt] + ot]);
  61701. if (o != null)
  61702. for (var ot = 0; ot < 2; ot++)
  61703. k.push(o[2 * rt[nt] + ot])
  61704. }
  61705. b.push(tt)
  61706. }
  61707. }
  61708. var at = new Array;
  61709. VertexData.ComputeNormals(_, b, at),
  61710. i.positions = _,
  61711. i.indices = b,
  61712. i.normals = at,
  61713. o != null && (i.uvs = k),
  61714. d != null && (i.colors = j),
  61715. i.applyToMesh(this, this.isVertexBufferUpdatable(VertexBuffer.PositionKind))
  61716. }
  61717. }
  61718. ,
  61719. e._instancedMeshFactory = function(i, o) {
  61720. throw _WarnImport("InstancedMesh")
  61721. }
  61722. ,
  61723. e._PhysicsImpostorParser = function(i, o, s) {
  61724. throw _WarnImport("PhysicsImpostor")
  61725. }
  61726. ,
  61727. e.prototype.createInstance = function(i) {
  61728. return e._instancedMeshFactory(i, this)
  61729. }
  61730. ,
  61731. e.prototype.synchronizeInstances = function() {
  61732. for (var i = 0; i < this.instances.length; i++) {
  61733. var o = this.instances[i];
  61734. o._syncSubMeshes()
  61735. }
  61736. return this
  61737. }
  61738. ,
  61739. e.prototype.optimizeIndices = function(i) {
  61740. var o = this
  61741. , s = this.getIndices()
  61742. , c = this.getVerticesData(VertexBuffer.PositionKind);
  61743. if (!c || !s)
  61744. return this;
  61745. for (var d = new Array, _ = 0; _ < c.length; _ = _ + 3)
  61746. d.push(Vector3.FromArray(c, _));
  61747. var b = new Array;
  61748. return AsyncLoop.SyncAsyncForLoop(d.length, 40, function(k) {
  61749. for (var j = d.length - 1 - k, $ = d[j], _e = 0; _e < j; ++_e) {
  61750. var et = d[_e];
  61751. if ($.equals(et)) {
  61752. b[j] = _e;
  61753. break
  61754. }
  61755. }
  61756. }, function() {
  61757. for (var k = 0; k < s.length; ++k)
  61758. s[k] = b[s[k]] || s[k];
  61759. var j = o.subMeshes.slice(0);
  61760. o.setIndices(s),
  61761. o.subMeshes = j,
  61762. i && i(o)
  61763. }),
  61764. this
  61765. }
  61766. ,
  61767. e.prototype.serialize = function(i) {
  61768. i.name = this.name,
  61769. i.id = this.id,
  61770. i.uniqueId = this.uniqueId,
  61771. i.type = this.getClassName(),
  61772. Tags && Tags.HasTags(this) && (i.tags = Tags.GetTags(this)),
  61773. i.position = this.position.asArray(),
  61774. this.rotationQuaternion ? i.rotationQuaternion = this.rotationQuaternion.asArray() : this.rotation && (i.rotation = this.rotation.asArray()),
  61775. i.scaling = this.scaling.asArray(),
  61776. this._postMultiplyPivotMatrix ? i.pivotMatrix = this.getPivotMatrix().asArray() : i.localMatrix = this.getPivotMatrix().asArray(),
  61777. i.isEnabled = this.isEnabled(!1),
  61778. i.isVisible = this.isVisible,
  61779. i.infiniteDistance = this.infiniteDistance,
  61780. i.pickable = this.isPickable,
  61781. i.receiveShadows = this.receiveShadows,
  61782. i.billboardMode = this.billboardMode,
  61783. i.visibility = this.visibility,
  61784. i.checkCollisions = this.checkCollisions,
  61785. i.isBlocker = this.isBlocker,
  61786. i.overrideMaterialSideOrientation = this.overrideMaterialSideOrientation,
  61787. this.parent && (i.parentId = this.parent.uniqueId),
  61788. i.isUnIndexed = this.isUnIndexed;
  61789. var o = this._geometry;
  61790. if (o && this.subMeshes) {
  61791. i.geometryUniqueId = o.uniqueId,
  61792. i.geometryId = o.id,
  61793. i.subMeshes = [];
  61794. for (var s = 0; s < this.subMeshes.length; s++) {
  61795. var c = this.subMeshes[s];
  61796. i.subMeshes.push({
  61797. materialIndex: c.materialIndex,
  61798. verticesStart: c.verticesStart,
  61799. verticesCount: c.verticesCount,
  61800. indexStart: c.indexStart,
  61801. indexCount: c.indexCount
  61802. })
  61803. }
  61804. }
  61805. if (this.material ? this.material.doNotSerialize || (i.materialId = this.material.id) : (this.material = null,
  61806. i.materialId = this._scene.defaultMaterial.id),
  61807. this.morphTargetManager && (i.morphTargetManagerId = this.morphTargetManager.uniqueId),
  61808. this.skeleton && (i.skeletonId = this.skeleton.id,
  61809. i.numBoneInfluencers = this.numBoneInfluencers),
  61810. this.getScene()._getComponent(SceneComponentConstants.NAME_PHYSICSENGINE)) {
  61811. var d = this.getPhysicsImpostor();
  61812. d && (i.physicsMass = d.getParam("mass"),
  61813. i.physicsFriction = d.getParam("friction"),
  61814. i.physicsRestitution = d.getParam("mass"),
  61815. i.physicsImpostor = d.type)
  61816. }
  61817. this.metadata && (i.metadata = this.metadata),
  61818. i.instances = [];
  61819. for (var _ = 0; _ < this.instances.length; _++) {
  61820. var b = this.instances[_];
  61821. if (!b.doNotSerialize) {
  61822. var k = {
  61823. name: b.name,
  61824. id: b.id,
  61825. isEnabled: b.isEnabled(!1),
  61826. isVisible: b.isVisible,
  61827. isPickable: b.isPickable,
  61828. checkCollisions: b.checkCollisions,
  61829. position: b.position.asArray(),
  61830. scaling: b.scaling.asArray()
  61831. };
  61832. if (b.parent && (k.parentId = b.parent.uniqueId),
  61833. b.rotationQuaternion ? k.rotationQuaternion = b.rotationQuaternion.asArray() : b.rotation && (k.rotation = b.rotation.asArray()),
  61834. this.getScene()._getComponent(SceneComponentConstants.NAME_PHYSICSENGINE)) {
  61835. var d = b.getPhysicsImpostor();
  61836. d && (k.physicsMass = d.getParam("mass"),
  61837. k.physicsFriction = d.getParam("friction"),
  61838. k.physicsRestitution = d.getParam("mass"),
  61839. k.physicsImpostor = d.type)
  61840. }
  61841. b.metadata && (k.metadata = b.metadata),
  61842. i.instances.push(k),
  61843. SerializationHelper.AppendSerializedAnimations(b, k),
  61844. k.ranges = b.serializeAnimationRanges()
  61845. }
  61846. }
  61847. if (this._thinInstanceDataStorage.instancesCount && this._thinInstanceDataStorage.matrixData && (i.thinInstances = {
  61848. instancesCount: this._thinInstanceDataStorage.instancesCount,
  61849. matrixData: Tools.SliceToArray(this._thinInstanceDataStorage.matrixData),
  61850. matrixBufferSize: this._thinInstanceDataStorage.matrixBufferSize,
  61851. enablePicking: this.thinInstanceEnablePicking
  61852. },
  61853. this._userThinInstanceBuffersStorage)) {
  61854. var j = {
  61855. data: {},
  61856. sizes: {},
  61857. strides: {}
  61858. };
  61859. for (var $ in this._userThinInstanceBuffersStorage.data)
  61860. j.data[$] = Tools.SliceToArray(this._userThinInstanceBuffersStorage.data[$]),
  61861. j.sizes[$] = this._userThinInstanceBuffersStorage.sizes[$],
  61862. j.strides[$] = this._userThinInstanceBuffersStorage.strides[$];
  61863. i.thinInstances.userThinInstance = j
  61864. }
  61865. SerializationHelper.AppendSerializedAnimations(this, i),
  61866. i.ranges = this.serializeAnimationRanges(),
  61867. i.layerMask = this.layerMask,
  61868. i.alphaIndex = this.alphaIndex,
  61869. i.hasVertexAlpha = this.hasVertexAlpha,
  61870. i.overlayAlpha = this.overlayAlpha,
  61871. i.overlayColor = this.overlayColor.asArray(),
  61872. i.renderOverlay = this.renderOverlay,
  61873. i.applyFog = this.applyFog,
  61874. this.actionManager && (i.actions = this.actionManager.serialize(this.name))
  61875. }
  61876. ,
  61877. e.prototype._syncGeometryWithMorphTargetManager = function() {
  61878. if (!!this.geometry) {
  61879. this._markSubMeshesAsAttributesDirty();
  61880. var i = this._internalAbstractMeshDataInfo._morphTargetManager;
  61881. if (i && i.vertexCount) {
  61882. if (i.vertexCount !== this.getTotalVertices()) {
  61883. Logger$2.Error("Mesh is incompatible with morph targets. Targets and mesh must all have the same vertices count."),
  61884. this.morphTargetManager = null;
  61885. return
  61886. }
  61887. if (i.isUsingTextureForTargets)
  61888. return;
  61889. for (var o = 0; o < i.numInfluencers; o++) {
  61890. var s = i.getActiveTarget(o)
  61891. , c = s.getPositions();
  61892. if (!c) {
  61893. Logger$2.Error("Invalid morph target. Target must have positions.");
  61894. return
  61895. }
  61896. this.geometry.setVerticesData(VertexBuffer.PositionKind + o, c, !1, 3);
  61897. var d = s.getNormals();
  61898. d && this.geometry.setVerticesData(VertexBuffer.NormalKind + o, d, !1, 3);
  61899. var _ = s.getTangents();
  61900. _ && this.geometry.setVerticesData(VertexBuffer.TangentKind + o, _, !1, 3);
  61901. var b = s.getUVs();
  61902. b && this.geometry.setVerticesData(VertexBuffer.UVKind + "_" + o, b, !1, 2)
  61903. }
  61904. } else
  61905. for (var o = 0; this.geometry.isVerticesDataPresent(VertexBuffer.PositionKind + o); )
  61906. this.geometry.removeVerticesData(VertexBuffer.PositionKind + o),
  61907. this.geometry.isVerticesDataPresent(VertexBuffer.NormalKind + o) && this.geometry.removeVerticesData(VertexBuffer.NormalKind + o),
  61908. this.geometry.isVerticesDataPresent(VertexBuffer.TangentKind + o) && this.geometry.removeVerticesData(VertexBuffer.TangentKind + o),
  61909. this.geometry.isVerticesDataPresent(VertexBuffer.UVKind + o) && this.geometry.removeVerticesData(VertexBuffer.UVKind + "_" + o),
  61910. o++
  61911. }
  61912. }
  61913. ,
  61914. e.Parse = function(i, o, s) {
  61915. var c;
  61916. if (i.type && i.type === "LinesMesh" ? c = e._LinesMeshParser(i, o) : i.type && i.type === "GroundMesh" ? c = e._GroundMeshParser(i, o) : c = new e(i.name,o),
  61917. c.id = i.id,
  61918. Tags && Tags.AddTagsTo(c, i.tags),
  61919. c.position = Vector3.FromArray(i.position),
  61920. i.metadata !== void 0 && (c.metadata = i.metadata),
  61921. i.rotationQuaternion ? c.rotationQuaternion = Quaternion.FromArray(i.rotationQuaternion) : i.rotation && (c.rotation = Vector3.FromArray(i.rotation)),
  61922. c.scaling = Vector3.FromArray(i.scaling),
  61923. i.localMatrix ? c.setPreTransformMatrix(Matrix.FromArray(i.localMatrix)) : i.pivotMatrix && c.setPivotMatrix(Matrix.FromArray(i.pivotMatrix)),
  61924. c.setEnabled(i.isEnabled),
  61925. c.isVisible = i.isVisible,
  61926. c.infiniteDistance = i.infiniteDistance,
  61927. c.showBoundingBox = i.showBoundingBox,
  61928. c.showSubMeshesBoundingBox = i.showSubMeshesBoundingBox,
  61929. i.applyFog !== void 0 && (c.applyFog = i.applyFog),
  61930. i.pickable !== void 0 && (c.isPickable = i.pickable),
  61931. i.alphaIndex !== void 0 && (c.alphaIndex = i.alphaIndex),
  61932. c.receiveShadows = i.receiveShadows,
  61933. c.billboardMode = i.billboardMode,
  61934. i.visibility !== void 0 && (c.visibility = i.visibility),
  61935. c.checkCollisions = i.checkCollisions,
  61936. c.overrideMaterialSideOrientation = i.overrideMaterialSideOrientation,
  61937. i.isBlocker !== void 0 && (c.isBlocker = i.isBlocker),
  61938. c._shouldGenerateFlatShading = i.useFlatShading,
  61939. i.freezeWorldMatrix && (c._waitingData.freezeWorldMatrix = i.freezeWorldMatrix),
  61940. i.parentId && (c._waitingParentId = i.parentId),
  61941. i.actions !== void 0 && (c._waitingData.actions = i.actions),
  61942. i.overlayAlpha !== void 0 && (c.overlayAlpha = i.overlayAlpha),
  61943. i.overlayColor !== void 0 && (c.overlayColor = Color3.FromArray(i.overlayColor)),
  61944. i.renderOverlay !== void 0 && (c.renderOverlay = i.renderOverlay),
  61945. c.isUnIndexed = !!i.isUnIndexed,
  61946. c.hasVertexAlpha = i.hasVertexAlpha,
  61947. i.delayLoadingFile ? (c.delayLoadState = 4,
  61948. c.delayLoadingFile = s + i.delayLoadingFile,
  61949. c.buildBoundingInfo(Vector3.FromArray(i.boundingBoxMinimum), Vector3.FromArray(i.boundingBoxMaximum)),
  61950. i._binaryInfo && (c._binaryInfo = i._binaryInfo),
  61951. c._delayInfo = [],
  61952. i.hasUVs && c._delayInfo.push(VertexBuffer.UVKind),
  61953. i.hasUVs2 && c._delayInfo.push(VertexBuffer.UV2Kind),
  61954. i.hasUVs3 && c._delayInfo.push(VertexBuffer.UV3Kind),
  61955. i.hasUVs4 && c._delayInfo.push(VertexBuffer.UV4Kind),
  61956. i.hasUVs5 && c._delayInfo.push(VertexBuffer.UV5Kind),
  61957. i.hasUVs6 && c._delayInfo.push(VertexBuffer.UV6Kind),
  61958. i.hasColors && c._delayInfo.push(VertexBuffer.ColorKind),
  61959. i.hasMatricesIndices && c._delayInfo.push(VertexBuffer.MatricesIndicesKind),
  61960. i.hasMatricesWeights && c._delayInfo.push(VertexBuffer.MatricesWeightsKind),
  61961. c._delayLoadingFunction = Geometry._ImportGeometry,
  61962. SceneLoaderFlags.ForceFullSceneLoadingForIncremental && c._checkDelayState()) : Geometry._ImportGeometry(i, c),
  61963. i.materialId ? c.setMaterialById(i.materialId) : c.material = null,
  61964. i.morphTargetManagerId > -1 && (c.morphTargetManager = o.getMorphTargetManagerById(i.morphTargetManagerId)),
  61965. i.skeletonId !== void 0 && i.skeletonId !== null && (c.skeleton = o.getLastSkeletonById(i.skeletonId),
  61966. i.numBoneInfluencers && (c.numBoneInfluencers = i.numBoneInfluencers)),
  61967. i.animations) {
  61968. for (var d = 0; d < i.animations.length; d++) {
  61969. var _ = i.animations[d]
  61970. , b = GetClass("BABYLON.Animation");
  61971. b && c.animations.push(b.Parse(_))
  61972. }
  61973. Node$2.ParseAnimationRanges(c, i, o)
  61974. }
  61975. if (i.autoAnimate && o.beginAnimation(c, i.autoAnimateFrom, i.autoAnimateTo, i.autoAnimateLoop, i.autoAnimateSpeed || 1),
  61976. i.layerMask && !isNaN(i.layerMask) ? c.layerMask = Math.abs(parseInt(i.layerMask)) : c.layerMask = 268435455,
  61977. i.physicsImpostor && e._PhysicsImpostorParser(o, c, i),
  61978. i.lodMeshIds && (c._waitingData.lods = {
  61979. ids: i.lodMeshIds,
  61980. distances: i.lodDistances ? i.lodDistances : null,
  61981. coverages: i.lodCoverages ? i.lodCoverages : null
  61982. }),
  61983. i.instances)
  61984. for (var k = 0; k < i.instances.length; k++) {
  61985. var j = i.instances[k]
  61986. , $ = c.createInstance(j.name);
  61987. if (j.id && ($.id = j.id),
  61988. Tags && (j.tags ? Tags.AddTagsTo($, j.tags) : Tags.AddTagsTo($, i.tags)),
  61989. $.position = Vector3.FromArray(j.position),
  61990. j.metadata !== void 0 && ($.metadata = j.metadata),
  61991. j.parentId && ($._waitingParentId = j.parentId),
  61992. j.isEnabled !== void 0 && j.isEnabled !== null && $.setEnabled(j.isEnabled),
  61993. j.isVisible !== void 0 && j.isVisible !== null && ($.isVisible = j.isVisible),
  61994. j.isPickable !== void 0 && j.isPickable !== null && ($.isPickable = j.isPickable),
  61995. j.rotationQuaternion ? $.rotationQuaternion = Quaternion.FromArray(j.rotationQuaternion) : j.rotation && ($.rotation = Vector3.FromArray(j.rotation)),
  61996. $.scaling = Vector3.FromArray(j.scaling),
  61997. j.checkCollisions != null && j.checkCollisions != null && ($.checkCollisions = j.checkCollisions),
  61998. j.pickable != null && j.pickable != null && ($.isPickable = j.pickable),
  61999. j.showBoundingBox != null && j.showBoundingBox != null && ($.showBoundingBox = j.showBoundingBox),
  62000. j.showSubMeshesBoundingBox != null && j.showSubMeshesBoundingBox != null && ($.showSubMeshesBoundingBox = j.showSubMeshesBoundingBox),
  62001. j.alphaIndex != null && j.showSubMeshesBoundingBox != null && ($.alphaIndex = j.alphaIndex),
  62002. j.physicsImpostor && e._PhysicsImpostorParser(o, $, j),
  62003. j.animations) {
  62004. for (d = 0; d < j.animations.length; d++) {
  62005. _ = j.animations[d];
  62006. var b = GetClass("BABYLON.Animation");
  62007. b && $.animations.push(b.Parse(_))
  62008. }
  62009. Node$2.ParseAnimationRanges($, j, o),
  62010. j.autoAnimate && o.beginAnimation($, j.autoAnimateFrom, j.autoAnimateTo, j.autoAnimateLoop, j.autoAnimateSpeed || 1)
  62011. }
  62012. }
  62013. if (i.thinInstances) {
  62014. var _e = i.thinInstances;
  62015. if (c.thinInstanceEnablePicking = !!_e.enablePicking,
  62016. _e.matrixData ? (c.thinInstanceSetBuffer("matrix", new Float32Array(_e.matrixData), 16, !1),
  62017. c._thinInstanceDataStorage.matrixBufferSize = _e.matrixBufferSize,
  62018. c._thinInstanceDataStorage.instancesCount = _e.instancesCount) : c._thinInstanceDataStorage.matrixBufferSize = _e.matrixBufferSize,
  62019. i.thinInstances.userThinInstance) {
  62020. var et = i.thinInstances.userThinInstance;
  62021. for (var tt in et.data)
  62022. c.thinInstanceSetBuffer(tt, new Float32Array(et.data[tt]), et.strides[tt], !1),
  62023. c._userThinInstanceBuffersStorage.sizes[tt] = et.sizes[tt]
  62024. }
  62025. }
  62026. return c
  62027. }
  62028. ,
  62029. e.prototype.setPositionsForCPUSkinning = function() {
  62030. var i = this._internalMeshDataInfo;
  62031. if (!i._sourcePositions) {
  62032. var o = this.getVerticesData(VertexBuffer.PositionKind);
  62033. if (!o)
  62034. return i._sourcePositions;
  62035. i._sourcePositions = new Float32Array(o),
  62036. this.isVertexBufferUpdatable(VertexBuffer.PositionKind) || this.setVerticesData(VertexBuffer.PositionKind, o, !0)
  62037. }
  62038. return i._sourcePositions
  62039. }
  62040. ,
  62041. e.prototype.setNormalsForCPUSkinning = function() {
  62042. var i = this._internalMeshDataInfo;
  62043. if (!i._sourceNormals) {
  62044. var o = this.getVerticesData(VertexBuffer.NormalKind);
  62045. if (!o)
  62046. return i._sourceNormals;
  62047. i._sourceNormals = new Float32Array(o),
  62048. this.isVertexBufferUpdatable(VertexBuffer.NormalKind) || this.setVerticesData(VertexBuffer.NormalKind, o, !0)
  62049. }
  62050. return i._sourceNormals
  62051. }
  62052. ,
  62053. e.prototype.applySkeleton = function(i) {
  62054. if (!this.geometry)
  62055. return this;
  62056. if (this.geometry._softwareSkinningFrameId == this.getScene().getFrameId())
  62057. return this;
  62058. if (this.geometry._softwareSkinningFrameId = this.getScene().getFrameId(),
  62059. !this.isVerticesDataPresent(VertexBuffer.PositionKind))
  62060. return this;
  62061. if (!this.isVerticesDataPresent(VertexBuffer.MatricesIndicesKind))
  62062. return this;
  62063. if (!this.isVerticesDataPresent(VertexBuffer.MatricesWeightsKind))
  62064. return this;
  62065. var o = this.isVerticesDataPresent(VertexBuffer.NormalKind)
  62066. , s = this._internalMeshDataInfo;
  62067. if (!s._sourcePositions) {
  62068. var c = this.subMeshes.slice();
  62069. this.setPositionsForCPUSkinning(),
  62070. this.subMeshes = c
  62071. }
  62072. o && !s._sourceNormals && this.setNormalsForCPUSkinning();
  62073. var d = this.getVerticesData(VertexBuffer.PositionKind);
  62074. if (!d)
  62075. return this;
  62076. d instanceof Float32Array || (d = new Float32Array(d));
  62077. var _ = this.getVerticesData(VertexBuffer.NormalKind);
  62078. if (o) {
  62079. if (!_)
  62080. return this;
  62081. _ instanceof Float32Array || (_ = new Float32Array(_))
  62082. }
  62083. var b = this.getVerticesData(VertexBuffer.MatricesIndicesKind)
  62084. , k = this.getVerticesData(VertexBuffer.MatricesWeightsKind);
  62085. if (!k || !b)
  62086. return this;
  62087. for (var j = this.numBoneInfluencers > 4, $ = j ? this.getVerticesData(VertexBuffer.MatricesIndicesExtraKind) : null, _e = j ? this.getVerticesData(VertexBuffer.MatricesWeightsExtraKind) : null, et = i.getTransformMatrices(this), tt = Vector3.Zero(), rt = new Matrix, it = new Matrix, nt = 0, ot, at = 0; at < d.length; at += 3,
  62088. nt += 4) {
  62089. var st;
  62090. for (ot = 0; ot < 4; ot++)
  62091. st = k[nt + ot],
  62092. st > 0 && (Matrix.FromFloat32ArrayToRefScaled(et, Math.floor(b[nt + ot] * 16), st, it),
  62093. rt.addToSelf(it));
  62094. if (j)
  62095. for (ot = 0; ot < 4; ot++)
  62096. st = _e[nt + ot],
  62097. st > 0 && (Matrix.FromFloat32ArrayToRefScaled(et, Math.floor($[nt + ot] * 16), st, it),
  62098. rt.addToSelf(it));
  62099. Vector3.TransformCoordinatesFromFloatsToRef(s._sourcePositions[at], s._sourcePositions[at + 1], s._sourcePositions[at + 2], rt, tt),
  62100. tt.toArray(d, at),
  62101. o && (Vector3.TransformNormalFromFloatsToRef(s._sourceNormals[at], s._sourceNormals[at + 1], s._sourceNormals[at + 2], rt, tt),
  62102. tt.toArray(_, at)),
  62103. rt.reset()
  62104. }
  62105. return this.updateVerticesData(VertexBuffer.PositionKind, d),
  62106. o && this.updateVerticesData(VertexBuffer.NormalKind, _),
  62107. this
  62108. }
  62109. ,
  62110. e.MinMax = function(i) {
  62111. var o = null
  62112. , s = null;
  62113. return i.forEach(function(c) {
  62114. var d = c.getBoundingInfo()
  62115. , _ = d.boundingBox;
  62116. !o || !s ? (o = _.minimumWorld,
  62117. s = _.maximumWorld) : (o.minimizeInPlace(_.minimumWorld),
  62118. s.maximizeInPlace(_.maximumWorld))
  62119. }),
  62120. !o || !s ? {
  62121. min: Vector3.Zero(),
  62122. max: Vector3.Zero()
  62123. } : {
  62124. min: o,
  62125. max: s
  62126. }
  62127. }
  62128. ,
  62129. e.Center = function(i) {
  62130. var o = i instanceof Array ? e.MinMax(i) : i;
  62131. return Vector3.Center(o.min, o.max)
  62132. }
  62133. ,
  62134. e.MergeMeshes = function(i, o, s, c, d, _) {
  62135. return o === void 0 && (o = !0),
  62136. runCoroutineSync(e._MergeMeshesCoroutine(i, o, s, c, d, _, !1))
  62137. }
  62138. ,
  62139. e.MergeMeshesAsync = function(i, o, s, c, d, _) {
  62140. return o === void 0 && (o = !0),
  62141. runCoroutineAsync(e._MergeMeshesCoroutine(i, o, s, c, d, _, !0), createYieldingScheduler())
  62142. }
  62143. ,
  62144. e._MergeMeshesCoroutine = function(i, o, s, c, d, _, b) {
  62145. var k, j, $, _e, et, tt, rt, it, nt, ot, at, st, ut, ct, lt, ft, ht, pt, dt, _t, mt, vt, yt, Et;
  62146. return o === void 0 && (o = !0),
  62147. __generator(this, function(At) {
  62148. switch (At.label) {
  62149. case 0:
  62150. if (i = i.filter(Boolean),
  62151. i.length === 0)
  62152. return [2, null];
  62153. if (!s) {
  62154. for (j = 0,
  62155. k = 0; k < i.length; k++)
  62156. if (j += i[k].getTotalVertices(),
  62157. j >= 65536)
  62158. return Logger$2.Warn("Cannot merge meshes because resulting mesh will have more than 65536 vertices. Please use allow32BitsIndices = true to use 32 bits indices"),
  62159. [2, null]
  62160. }
  62161. for (_ && ($ = null,
  62162. d = !1),
  62163. tt = new Array,
  62164. rt = new Array,
  62165. it = new Array,
  62166. k = 0; k < i.length; k++) {
  62167. if (nt = i[k],
  62168. nt.isAnInstance)
  62169. return Logger$2.Warn("Cannot merge instance meshes."),
  62170. [2, null];
  62171. if (d && it.push(nt.getTotalIndices()),
  62172. _)
  62173. if (nt.material)
  62174. if (ot = nt.material,
  62175. ot instanceof MultiMaterial) {
  62176. for (et = 0; et < ot.subMaterials.length; et++)
  62177. tt.indexOf(ot.subMaterials[et]) < 0 && tt.push(ot.subMaterials[et]);
  62178. for (_e = 0; _e < nt.subMeshes.length; _e++)
  62179. rt.push(tt.indexOf(ot.subMaterials[nt.subMeshes[_e].materialIndex])),
  62180. it.push(nt.subMeshes[_e].indexCount)
  62181. } else
  62182. for (tt.indexOf(ot) < 0 && tt.push(ot),
  62183. _e = 0; _e < nt.subMeshes.length; _e++)
  62184. rt.push(tt.indexOf(ot)),
  62185. it.push(nt.subMeshes[_e].indexCount);
  62186. else
  62187. for (_e = 0; _e < nt.subMeshes.length; _e++)
  62188. rt.push(0),
  62189. it.push(nt.subMeshes[_e].indexCount)
  62190. }
  62191. return at = i[0],
  62192. st = function(gt) {
  62193. var St = gt.computeWorldMatrix(!0)
  62194. , xt = VertexData.ExtractFromMesh(gt, !0, !0);
  62195. return xt.transform(St),
  62196. xt
  62197. }
  62198. ,
  62199. ut = st(at),
  62200. b ? [4] : [3, 2];
  62201. case 1:
  62202. At.sent(),
  62203. At.label = 2;
  62204. case 2:
  62205. ct = new Array(i.length - 1),
  62206. lt = 1,
  62207. At.label = 3;
  62208. case 3:
  62209. return lt < i.length ? (ct[lt - 1] = st(i[lt]),
  62210. b ? [4] : [3, 5]) : [3, 6];
  62211. case 4:
  62212. At.sent(),
  62213. At.label = 5;
  62214. case 5:
  62215. return lt++,
  62216. [3, 3];
  62217. case 6:
  62218. ft = ut._mergeCoroutine(ct, s, b),
  62219. ht = ft.next(),
  62220. At.label = 7;
  62221. case 7:
  62222. return ht.done ? [3, 10] : b ? [4] : [3, 9];
  62223. case 8:
  62224. At.sent(),
  62225. At.label = 9;
  62226. case 9:
  62227. return ht = ft.next(),
  62228. [3, 7];
  62229. case 10:
  62230. pt = ht.value,
  62231. c || (c = new e(at.name + "_merged",at.getScene())),
  62232. dt = pt._applyToCoroutine(c, void 0, b),
  62233. _t = dt.next(),
  62234. At.label = 11;
  62235. case 11:
  62236. return _t.done ? [3, 14] : b ? [4] : [3, 13];
  62237. case 12:
  62238. At.sent(),
  62239. At.label = 13;
  62240. case 13:
  62241. return _t = dt.next(),
  62242. [3, 11];
  62243. case 14:
  62244. if (c.checkCollisions = at.checkCollisions,
  62245. c.overrideMaterialSideOrientation = at.overrideMaterialSideOrientation,
  62246. o)
  62247. for (k = 0; k < i.length; k++)
  62248. i[k].dispose();
  62249. if (d || _) {
  62250. for (c.releaseSubMeshes(),
  62251. k = 0,
  62252. mt = 0; k < it.length; )
  62253. SubMesh.CreateFromIndices(0, mt, it[k], c, void 0, !1),
  62254. mt += it[k],
  62255. k++;
  62256. for (vt = 0,
  62257. yt = c.subMeshes; vt < yt.length; vt++)
  62258. Et = yt[vt],
  62259. Et.refreshBoundingInfo();
  62260. c.computeWorldMatrix(!0)
  62261. }
  62262. if (_) {
  62263. for ($ = new MultiMaterial(at.name + "_merged",at.getScene()),
  62264. $.subMaterials = tt,
  62265. _e = 0; _e < c.subMeshes.length; _e++)
  62266. c.subMeshes[_e].materialIndex = rt[_e];
  62267. c.material = $
  62268. } else
  62269. c.material = at.material;
  62270. return [2, c]
  62271. }
  62272. })
  62273. }
  62274. ,
  62275. e.prototype.addInstance = function(i) {
  62276. i._indexInSourceMeshInstanceArray = this.instances.length,
  62277. this.instances.push(i)
  62278. }
  62279. ,
  62280. e.prototype.removeInstance = function(i) {
  62281. var o = i._indexInSourceMeshInstanceArray;
  62282. if (o != -1) {
  62283. if (o !== this.instances.length - 1) {
  62284. var s = this.instances[this.instances.length - 1];
  62285. this.instances[o] = s,
  62286. s._indexInSourceMeshInstanceArray = o
  62287. }
  62288. i._indexInSourceMeshInstanceArray = -1,
  62289. this.instances.pop()
  62290. }
  62291. }
  62292. ,
  62293. e.FRONTSIDE = VertexData.FRONTSIDE,
  62294. e.BACKSIDE = VertexData.BACKSIDE,
  62295. e.DOUBLESIDE = VertexData.DOUBLESIDE,
  62296. e.DEFAULTSIDE = VertexData.DEFAULTSIDE,
  62297. e.NO_CAP = 0,
  62298. e.CAP_START = 1,
  62299. e.CAP_END = 2,
  62300. e.CAP_ALL = 3,
  62301. e.NO_FLIP = 0,
  62302. e.FLIP_TILE = 1,
  62303. e.ROTATE_TILE = 2,
  62304. e.FLIP_ROW = 3,
  62305. e.ROTATE_ROW = 4,
  62306. e.FLIP_N_ROTATE_TILE = 5,
  62307. e.FLIP_N_ROTATE_ROW = 6,
  62308. e.CENTER = 0,
  62309. e.LEFT = 1,
  62310. e.RIGHT = 2,
  62311. e.TOP = 3,
  62312. e.BOTTOM = 4,
  62313. e.INSTANCEDMESH_SORT_TRANSPARENT = !1,
  62314. e._GroundMeshParser = function(i, o) {
  62315. throw _WarnImport("GroundMesh")
  62316. }
  62317. ,
  62318. e._LinesMeshParser = function(i, o) {
  62319. throw _WarnImport("LinesMesh")
  62320. }
  62321. ,
  62322. e
  62323. }(AbstractMesh);
  62324. RegisterClass("BABYLON.Mesh", Mesh);
  62325. _injectLTSMesh(Mesh);
  62326. var AutoRotationBehavior = function() {
  62327. function a() {
  62328. this._zoomStopsAnimation = !1,
  62329. this._idleRotationSpeed = .05,
  62330. this._idleRotationWaitTime = 2e3,
  62331. this._idleRotationSpinupTime = 2e3,
  62332. this._isPointerDown = !1,
  62333. this._lastFrameTime = null,
  62334. this._lastInteractionTime = -1 / 0,
  62335. this._cameraRotationSpeed = 0,
  62336. this._lastFrameRadius = 0
  62337. }
  62338. return Object.defineProperty(a.prototype, "name", {
  62339. get: function() {
  62340. return "AutoRotation"
  62341. },
  62342. enumerable: !1,
  62343. configurable: !0
  62344. }),
  62345. Object.defineProperty(a.prototype, "zoomStopsAnimation", {
  62346. get: function() {
  62347. return this._zoomStopsAnimation
  62348. },
  62349. set: function(e) {
  62350. this._zoomStopsAnimation = e
  62351. },
  62352. enumerable: !1,
  62353. configurable: !0
  62354. }),
  62355. Object.defineProperty(a.prototype, "idleRotationSpeed", {
  62356. get: function() {
  62357. return this._idleRotationSpeed
  62358. },
  62359. set: function(e) {
  62360. this._idleRotationSpeed = e
  62361. },
  62362. enumerable: !1,
  62363. configurable: !0
  62364. }),
  62365. Object.defineProperty(a.prototype, "idleRotationWaitTime", {
  62366. get: function() {
  62367. return this._idleRotationWaitTime
  62368. },
  62369. set: function(e) {
  62370. this._idleRotationWaitTime = e
  62371. },
  62372. enumerable: !1,
  62373. configurable: !0
  62374. }),
  62375. Object.defineProperty(a.prototype, "idleRotationSpinupTime", {
  62376. get: function() {
  62377. return this._idleRotationSpinupTime
  62378. },
  62379. set: function(e) {
  62380. this._idleRotationSpinupTime = e
  62381. },
  62382. enumerable: !1,
  62383. configurable: !0
  62384. }),
  62385. Object.defineProperty(a.prototype, "rotationInProgress", {
  62386. get: function() {
  62387. return Math.abs(this._cameraRotationSpeed) > 0
  62388. },
  62389. enumerable: !1,
  62390. configurable: !0
  62391. }),
  62392. a.prototype.init = function() {}
  62393. ,
  62394. a.prototype.attach = function(e) {
  62395. var i = this;
  62396. this._attachedCamera = e;
  62397. var o = this._attachedCamera.getScene();
  62398. this._onPrePointerObservableObserver = o.onPrePointerObservable.add(function(s) {
  62399. if (s.type === PointerEventTypes.POINTERDOWN) {
  62400. i._isPointerDown = !0;
  62401. return
  62402. }
  62403. s.type === PointerEventTypes.POINTERUP && (i._isPointerDown = !1)
  62404. }),
  62405. this._onAfterCheckInputsObserver = e.onAfterCheckInputsObservable.add(function() {
  62406. var s = PrecisionDate.Now
  62407. , c = 0;
  62408. i._lastFrameTime != null && (c = s - i._lastFrameTime),
  62409. i._lastFrameTime = s,
  62410. i._applyUserInteraction();
  62411. var d = s - i._lastInteractionTime - i._idleRotationWaitTime
  62412. , _ = Math.max(Math.min(d / i._idleRotationSpinupTime, 1), 0);
  62413. i._cameraRotationSpeed = i._idleRotationSpeed * _,
  62414. i._attachedCamera && (i._attachedCamera.alpha -= i._cameraRotationSpeed * (c / 1e3))
  62415. })
  62416. }
  62417. ,
  62418. a.prototype.detach = function() {
  62419. if (!!this._attachedCamera) {
  62420. var e = this._attachedCamera.getScene();
  62421. this._onPrePointerObservableObserver && e.onPrePointerObservable.remove(this._onPrePointerObservableObserver),
  62422. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),
  62423. this._attachedCamera = null
  62424. }
  62425. }
  62426. ,
  62427. a.prototype.resetLastInteractionTime = function(e) {
  62428. this._lastInteractionTime = e != null ? e : PrecisionDate.Now
  62429. }
  62430. ,
  62431. a.prototype._userIsZooming = function() {
  62432. return this._attachedCamera ? this._attachedCamera.inertialRadiusOffset !== 0 : !1
  62433. }
  62434. ,
  62435. a.prototype._shouldAnimationStopForInteraction = function() {
  62436. if (!this._attachedCamera)
  62437. return !1;
  62438. var e = !1;
  62439. return this._lastFrameRadius === this._attachedCamera.radius && this._attachedCamera.inertialRadiusOffset !== 0 && (e = !0),
  62440. this._lastFrameRadius = this._attachedCamera.radius,
  62441. this._zoomStopsAnimation ? e : this._userIsZooming()
  62442. }
  62443. ,
  62444. a.prototype._applyUserInteraction = function() {
  62445. this._userIsMoving() && !this._shouldAnimationStopForInteraction() && (this._lastInteractionTime = PrecisionDate.Now)
  62446. }
  62447. ,
  62448. a.prototype._userIsMoving = function() {
  62449. return this._attachedCamera ? this._attachedCamera.inertialAlphaOffset !== 0 || this._attachedCamera.inertialBetaOffset !== 0 || this._attachedCamera.inertialRadiusOffset !== 0 || this._attachedCamera.inertialPanningX !== 0 || this._attachedCamera.inertialPanningY !== 0 || this._isPointerDown : !1
  62450. }
  62451. ,
  62452. a
  62453. }()
  62454. , EasingFunction = function() {
  62455. function a() {
  62456. this._easingMode = a.EASINGMODE_EASEIN
  62457. }
  62458. return a.prototype.setEasingMode = function(e) {
  62459. var i = Math.min(Math.max(e, 0), 2);
  62460. this._easingMode = i
  62461. }
  62462. ,
  62463. a.prototype.getEasingMode = function() {
  62464. return this._easingMode
  62465. }
  62466. ,
  62467. a.prototype.easeInCore = function(e) {
  62468. throw new Error("You must implement this method")
  62469. }
  62470. ,
  62471. a.prototype.ease = function(e) {
  62472. switch (this._easingMode) {
  62473. case a.EASINGMODE_EASEIN:
  62474. return this.easeInCore(e);
  62475. case a.EASINGMODE_EASEOUT:
  62476. return 1 - this.easeInCore(1 - e)
  62477. }
  62478. return e >= .5 ? (1 - this.easeInCore((1 - e) * 2)) * .5 + .5 : this.easeInCore(e * 2) * .5
  62479. }
  62480. ,
  62481. a.EASINGMODE_EASEIN = 0,
  62482. a.EASINGMODE_EASEOUT = 1,
  62483. a.EASINGMODE_EASEINOUT = 2,
  62484. a
  62485. }()
  62486. , CircleEase = function(a) {
  62487. __extends(e, a);
  62488. function e() {
  62489. return a !== null && a.apply(this, arguments) || this
  62490. }
  62491. return e.prototype.easeInCore = function(i) {
  62492. return i = Math.max(0, Math.min(1, i)),
  62493. 1 - Math.sqrt(1 - i * i)
  62494. }
  62495. ,
  62496. e
  62497. }(EasingFunction)
  62498. , BackEase = function(a) {
  62499. __extends(e, a);
  62500. function e(i) {
  62501. i === void 0 && (i = 1);
  62502. var o = a.call(this) || this;
  62503. return o.amplitude = i,
  62504. o
  62505. }
  62506. return e.prototype.easeInCore = function(i) {
  62507. var o = Math.max(0, this.amplitude);
  62508. return Math.pow(i, 3) - i * o * Math.sin(3.141592653589793 * i)
  62509. }
  62510. ,
  62511. e
  62512. }(EasingFunction);
  62513. (function(a) {
  62514. __extends(e, a);
  62515. function e(i, o) {
  62516. i === void 0 && (i = 3),
  62517. o === void 0 && (o = 2);
  62518. var s = a.call(this) || this;
  62519. return s.bounces = i,
  62520. s.bounciness = o,
  62521. s
  62522. }
  62523. return e.prototype.easeInCore = function(i) {
  62524. var o = Math.max(0, this.bounces)
  62525. , s = this.bounciness;
  62526. s <= 1 && (s = 1.001);
  62527. var c = Math.pow(s, o)
  62528. , d = 1 - s
  62529. , _ = (1 - c) / d + c * .5
  62530. , b = i * _
  62531. , k = Math.log(-b * (1 - s) + 1) / Math.log(s)
  62532. , j = Math.floor(k)
  62533. , $ = j + 1
  62534. , _e = (1 - Math.pow(s, j)) / (d * _)
  62535. , et = (1 - Math.pow(s, $)) / (d * _)
  62536. , tt = (_e + et) * .5
  62537. , rt = i - tt
  62538. , it = tt - _e;
  62539. return -Math.pow(1 / s, o - j) / (it * it) * (rt - it) * (rt + it)
  62540. }
  62541. ,
  62542. e
  62543. }
  62544. )(EasingFunction);
  62545. (function(a) {
  62546. __extends(e, a);
  62547. function e() {
  62548. return a !== null && a.apply(this, arguments) || this
  62549. }
  62550. return e.prototype.easeInCore = function(i) {
  62551. return i * i * i
  62552. }
  62553. ,
  62554. e
  62555. }
  62556. )(EasingFunction);
  62557. (function(a) {
  62558. __extends(e, a);
  62559. function e(i, o) {
  62560. i === void 0 && (i = 3),
  62561. o === void 0 && (o = 3);
  62562. var s = a.call(this) || this;
  62563. return s.oscillations = i,
  62564. s.springiness = o,
  62565. s
  62566. }
  62567. return e.prototype.easeInCore = function(i) {
  62568. var o, s = Math.max(0, this.oscillations), c = Math.max(0, this.springiness);
  62569. return c == 0 ? o = i : o = (Math.exp(c * i) - 1) / (Math.exp(c) - 1),
  62570. o * Math.sin((6.283185307179586 * s + 1.5707963267948966) * i)
  62571. }
  62572. ,
  62573. e
  62574. }
  62575. )(EasingFunction);
  62576. var ExponentialEase = function(a) {
  62577. __extends(e, a);
  62578. function e(i) {
  62579. i === void 0 && (i = 2);
  62580. var o = a.call(this) || this;
  62581. return o.exponent = i,
  62582. o
  62583. }
  62584. return e.prototype.easeInCore = function(i) {
  62585. return this.exponent <= 0 ? i : (Math.exp(this.exponent * i) - 1) / (Math.exp(this.exponent) - 1)
  62586. }
  62587. ,
  62588. e
  62589. }(EasingFunction);
  62590. (function(a) {
  62591. __extends(e, a);
  62592. function e(i) {
  62593. i === void 0 && (i = 2);
  62594. var o = a.call(this) || this;
  62595. return o.power = i,
  62596. o
  62597. }
  62598. return e.prototype.easeInCore = function(i) {
  62599. var o = Math.max(0, this.power);
  62600. return Math.pow(i, o)
  62601. }
  62602. ,
  62603. e
  62604. }
  62605. )(EasingFunction);
  62606. (function(a) {
  62607. __extends(e, a);
  62608. function e() {
  62609. return a !== null && a.apply(this, arguments) || this
  62610. }
  62611. return e.prototype.easeInCore = function(i) {
  62612. return i * i
  62613. }
  62614. ,
  62615. e
  62616. }
  62617. )(EasingFunction);
  62618. (function(a) {
  62619. __extends(e, a);
  62620. function e() {
  62621. return a !== null && a.apply(this, arguments) || this
  62622. }
  62623. return e.prototype.easeInCore = function(i) {
  62624. return i * i * i * i
  62625. }
  62626. ,
  62627. e
  62628. }
  62629. )(EasingFunction);
  62630. (function(a) {
  62631. __extends(e, a);
  62632. function e() {
  62633. return a !== null && a.apply(this, arguments) || this
  62634. }
  62635. return e.prototype.easeInCore = function(i) {
  62636. return i * i * i * i * i
  62637. }
  62638. ,
  62639. e
  62640. }
  62641. )(EasingFunction);
  62642. var SineEase = function(a) {
  62643. __extends(e, a);
  62644. function e() {
  62645. return a !== null && a.apply(this, arguments) || this
  62646. }
  62647. return e.prototype.easeInCore = function(i) {
  62648. return 1 - Math.sin(1.5707963267948966 * (1 - i))
  62649. }
  62650. ,
  62651. e
  62652. }(EasingFunction);
  62653. (function(a) {
  62654. __extends(e, a);
  62655. function e(i, o, s, c) {
  62656. i === void 0 && (i = 0),
  62657. o === void 0 && (o = 0),
  62658. s === void 0 && (s = 1),
  62659. c === void 0 && (c = 1);
  62660. var d = a.call(this) || this;
  62661. return d.x1 = i,
  62662. d.y1 = o,
  62663. d.x2 = s,
  62664. d.y2 = c,
  62665. d
  62666. }
  62667. return e.prototype.easeInCore = function(i) {
  62668. return BezierCurve.Interpolate(i, this.x1, this.y1, this.x2, this.y2)
  62669. }
  62670. ,
  62671. e
  62672. }
  62673. )(EasingFunction);
  62674. var BouncingBehavior = function() {
  62675. function a() {
  62676. this.transitionDuration = 450,
  62677. this.lowerRadiusTransitionRange = 2,
  62678. this.upperRadiusTransitionRange = -2,
  62679. this._autoTransitionRange = !1,
  62680. this._radiusIsAnimating = !1,
  62681. this._radiusBounceTransition = null,
  62682. this._animatables = new Array
  62683. }
  62684. return Object.defineProperty(a.prototype, "name", {
  62685. get: function() {
  62686. return "Bouncing"
  62687. },
  62688. enumerable: !1,
  62689. configurable: !0
  62690. }),
  62691. Object.defineProperty(a.prototype, "autoTransitionRange", {
  62692. get: function() {
  62693. return this._autoTransitionRange
  62694. },
  62695. set: function(e) {
  62696. var i = this;
  62697. if (this._autoTransitionRange !== e) {
  62698. this._autoTransitionRange = e;
  62699. var o = this._attachedCamera;
  62700. !o || (e ? this._onMeshTargetChangedObserver = o.onMeshTargetChangedObservable.add(function(s) {
  62701. if (!!s) {
  62702. s.computeWorldMatrix(!0);
  62703. var c = s.getBoundingInfo().diagonalLength;
  62704. i.lowerRadiusTransitionRange = c * .05,
  62705. i.upperRadiusTransitionRange = c * .05
  62706. }
  62707. }) : this._onMeshTargetChangedObserver && o.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver))
  62708. }
  62709. },
  62710. enumerable: !1,
  62711. configurable: !0
  62712. }),
  62713. a.prototype.init = function() {}
  62714. ,
  62715. a.prototype.attach = function(e) {
  62716. var i = this;
  62717. this._attachedCamera = e,
  62718. this._onAfterCheckInputsObserver = e.onAfterCheckInputsObservable.add(function() {
  62719. !i._attachedCamera || (i._isRadiusAtLimit(i._attachedCamera.lowerRadiusLimit) && i._applyBoundRadiusAnimation(i.lowerRadiusTransitionRange),
  62720. i._isRadiusAtLimit(i._attachedCamera.upperRadiusLimit) && i._applyBoundRadiusAnimation(i.upperRadiusTransitionRange))
  62721. })
  62722. }
  62723. ,
  62724. a.prototype.detach = function() {
  62725. !this._attachedCamera || (this._onAfterCheckInputsObserver && this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),
  62726. this._onMeshTargetChangedObserver && this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver),
  62727. this._attachedCamera = null)
  62728. }
  62729. ,
  62730. a.prototype._isRadiusAtLimit = function(e) {
  62731. return this._attachedCamera ? this._attachedCamera.radius === e && !this._radiusIsAnimating : !1
  62732. }
  62733. ,
  62734. a.prototype._applyBoundRadiusAnimation = function(e) {
  62735. var i = this;
  62736. if (!!this._attachedCamera) {
  62737. this._radiusBounceTransition || (a.EasingFunction.setEasingMode(a.EasingMode),
  62738. this._radiusBounceTransition = Animation.CreateAnimation("radius", Animation.ANIMATIONTYPE_FLOAT, 60, a.EasingFunction)),
  62739. this._cachedWheelPrecision = this._attachedCamera.wheelPrecision,
  62740. this._attachedCamera.wheelPrecision = 1 / 0,
  62741. this._attachedCamera.inertialRadiusOffset = 0,
  62742. this.stopAllAnimations(),
  62743. this._radiusIsAnimating = !0;
  62744. var o = Animation.TransitionTo("radius", this._attachedCamera.radius + e, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusBounceTransition, this.transitionDuration, function() {
  62745. return i._clearAnimationLocks()
  62746. });
  62747. o && this._animatables.push(o)
  62748. }
  62749. }
  62750. ,
  62751. a.prototype._clearAnimationLocks = function() {
  62752. this._radiusIsAnimating = !1,
  62753. this._attachedCamera && (this._attachedCamera.wheelPrecision = this._cachedWheelPrecision)
  62754. }
  62755. ,
  62756. a.prototype.stopAllAnimations = function() {
  62757. for (this._attachedCamera && (this._attachedCamera.animations = []); this._animatables.length; )
  62758. this._animatables[0].onAnimationEnd = null,
  62759. this._animatables[0].stop(),
  62760. this._animatables.shift()
  62761. }
  62762. ,
  62763. a.EasingFunction = new BackEase(.3),
  62764. a.EasingMode = EasingFunction.EASINGMODE_EASEOUT,
  62765. a
  62766. }()
  62767. , FramingBehavior = function() {
  62768. function a() {
  62769. this.onTargetFramingAnimationEndObservable = new Observable,
  62770. this._mode = a.FitFrustumSidesMode,
  62771. this._radiusScale = 1,
  62772. this._positionScale = .5,
  62773. this._defaultElevation = .3,
  62774. this._elevationReturnTime = 1500,
  62775. this._elevationReturnWaitTime = 1e3,
  62776. this._zoomStopsAnimation = !1,
  62777. this._framingTime = 1500,
  62778. this.autoCorrectCameraLimitsAndSensibility = !0,
  62779. this._isPointerDown = !1,
  62780. this._lastInteractionTime = -1 / 0,
  62781. this._animatables = new Array,
  62782. this._betaIsAnimating = !1
  62783. }
  62784. return Object.defineProperty(a.prototype, "name", {
  62785. get: function() {
  62786. return "Framing"
  62787. },
  62788. enumerable: !1,
  62789. configurable: !0
  62790. }),
  62791. Object.defineProperty(a.prototype, "mode", {
  62792. get: function() {
  62793. return this._mode
  62794. },
  62795. set: function(e) {
  62796. this._mode = e
  62797. },
  62798. enumerable: !1,
  62799. configurable: !0
  62800. }),
  62801. Object.defineProperty(a.prototype, "radiusScale", {
  62802. get: function() {
  62803. return this._radiusScale
  62804. },
  62805. set: function(e) {
  62806. this._radiusScale = e
  62807. },
  62808. enumerable: !1,
  62809. configurable: !0
  62810. }),
  62811. Object.defineProperty(a.prototype, "positionScale", {
  62812. get: function() {
  62813. return this._positionScale
  62814. },
  62815. set: function(e) {
  62816. this._positionScale = e
  62817. },
  62818. enumerable: !1,
  62819. configurable: !0
  62820. }),
  62821. Object.defineProperty(a.prototype, "defaultElevation", {
  62822. get: function() {
  62823. return this._defaultElevation
  62824. },
  62825. set: function(e) {
  62826. this._defaultElevation = e
  62827. },
  62828. enumerable: !1,
  62829. configurable: !0
  62830. }),
  62831. Object.defineProperty(a.prototype, "elevationReturnTime", {
  62832. get: function() {
  62833. return this._elevationReturnTime
  62834. },
  62835. set: function(e) {
  62836. this._elevationReturnTime = e
  62837. },
  62838. enumerable: !1,
  62839. configurable: !0
  62840. }),
  62841. Object.defineProperty(a.prototype, "elevationReturnWaitTime", {
  62842. get: function() {
  62843. return this._elevationReturnWaitTime
  62844. },
  62845. set: function(e) {
  62846. this._elevationReturnWaitTime = e
  62847. },
  62848. enumerable: !1,
  62849. configurable: !0
  62850. }),
  62851. Object.defineProperty(a.prototype, "zoomStopsAnimation", {
  62852. get: function() {
  62853. return this._zoomStopsAnimation
  62854. },
  62855. set: function(e) {
  62856. this._zoomStopsAnimation = e
  62857. },
  62858. enumerable: !1,
  62859. configurable: !0
  62860. }),
  62861. Object.defineProperty(a.prototype, "framingTime", {
  62862. get: function() {
  62863. return this._framingTime
  62864. },
  62865. set: function(e) {
  62866. this._framingTime = e
  62867. },
  62868. enumerable: !1,
  62869. configurable: !0
  62870. }),
  62871. a.prototype.init = function() {}
  62872. ,
  62873. a.prototype.attach = function(e) {
  62874. var i = this;
  62875. this._attachedCamera = e;
  62876. var o = this._attachedCamera.getScene();
  62877. a.EasingFunction.setEasingMode(a.EasingMode),
  62878. this._onPrePointerObservableObserver = o.onPrePointerObservable.add(function(s) {
  62879. if (s.type === PointerEventTypes.POINTERDOWN) {
  62880. i._isPointerDown = !0;
  62881. return
  62882. }
  62883. s.type === PointerEventTypes.POINTERUP && (i._isPointerDown = !1)
  62884. }),
  62885. this._onMeshTargetChangedObserver = e.onMeshTargetChangedObservable.add(function(s) {
  62886. s && i.zoomOnMesh(s, void 0, function() {
  62887. i.onTargetFramingAnimationEndObservable.notifyObservers()
  62888. })
  62889. }),
  62890. this._onAfterCheckInputsObserver = e.onAfterCheckInputsObservable.add(function() {
  62891. i._applyUserInteraction(),
  62892. i._maintainCameraAboveGround()
  62893. })
  62894. }
  62895. ,
  62896. a.prototype.detach = function() {
  62897. if (!!this._attachedCamera) {
  62898. var e = this._attachedCamera.getScene();
  62899. this._onPrePointerObservableObserver && e.onPrePointerObservable.remove(this._onPrePointerObservableObserver),
  62900. this._onAfterCheckInputsObserver && this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),
  62901. this._onMeshTargetChangedObserver && this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver),
  62902. this._attachedCamera = null
  62903. }
  62904. }
  62905. ,
  62906. a.prototype.zoomOnMesh = function(e, i, o) {
  62907. i === void 0 && (i = !1),
  62908. o === void 0 && (o = null),
  62909. e.computeWorldMatrix(!0);
  62910. var s = e.getBoundingInfo().boundingBox;
  62911. this.zoomOnBoundingInfo(s.minimumWorld, s.maximumWorld, i, o)
  62912. }
  62913. ,
  62914. a.prototype.zoomOnMeshHierarchy = function(e, i, o) {
  62915. i === void 0 && (i = !1),
  62916. o === void 0 && (o = null),
  62917. e.computeWorldMatrix(!0);
  62918. var s = e.getHierarchyBoundingVectors(!0);
  62919. this.zoomOnBoundingInfo(s.min, s.max, i, o)
  62920. }
  62921. ,
  62922. a.prototype.zoomOnMeshesHierarchy = function(e, i, o) {
  62923. i === void 0 && (i = !1),
  62924. o === void 0 && (o = null);
  62925. for (var s = new Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE), c = new Vector3(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE), d = 0; d < e.length; d++) {
  62926. var _ = e[d].getHierarchyBoundingVectors(!0);
  62927. Vector3.CheckExtends(_.min, s, c),
  62928. Vector3.CheckExtends(_.max, s, c)
  62929. }
  62930. this.zoomOnBoundingInfo(s, c, i, o)
  62931. }
  62932. ,
  62933. a.prototype.zoomOnBoundingInfo = function(e, i, o, s) {
  62934. var c = this;
  62935. o === void 0 && (o = !1),
  62936. s === void 0 && (s = null);
  62937. var d;
  62938. if (!!this._attachedCamera) {
  62939. var _ = e.y
  62940. , b = i.y
  62941. , k = _ + (b - _) * this._positionScale
  62942. , j = i.subtract(e).scale(.5);
  62943. if (o)
  62944. d = new Vector3(0,k,0);
  62945. else {
  62946. var $ = e.add(j);
  62947. d = new Vector3($.x,k,$.z)
  62948. }
  62949. this._vectorTransition || (this._vectorTransition = Animation.CreateAnimation("target", Animation.ANIMATIONTYPE_VECTOR3, 60, a.EasingFunction)),
  62950. this._betaIsAnimating = !0;
  62951. var _e = Animation.TransitionTo("target", d, this._attachedCamera, this._attachedCamera.getScene(), 60, this._vectorTransition, this._framingTime);
  62952. _e && this._animatables.push(_e);
  62953. var et = 0;
  62954. if (this._mode === a.FitFrustumSidesMode) {
  62955. var tt = this._calculateLowerRadiusFromModelBoundingSphere(e, i);
  62956. this.autoCorrectCameraLimitsAndSensibility && (this._attachedCamera.lowerRadiusLimit = j.length() + this._attachedCamera.minZ),
  62957. et = tt
  62958. } else
  62959. this._mode === a.IgnoreBoundsSizeMode && (et = this._calculateLowerRadiusFromModelBoundingSphere(e, i),
  62960. this.autoCorrectCameraLimitsAndSensibility && this._attachedCamera.lowerRadiusLimit === null && (this._attachedCamera.lowerRadiusLimit = this._attachedCamera.minZ));
  62961. if (this.autoCorrectCameraLimitsAndSensibility) {
  62962. var rt = i.subtract(e).length();
  62963. this._attachedCamera.panningSensibility = 5e3 / rt,
  62964. this._attachedCamera.wheelPrecision = 100 / et
  62965. }
  62966. this._radiusTransition || (this._radiusTransition = Animation.CreateAnimation("radius", Animation.ANIMATIONTYPE_FLOAT, 60, a.EasingFunction)),
  62967. _e = Animation.TransitionTo("radius", et, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusTransition, this._framingTime, function() {
  62968. c.stopAllAnimations(),
  62969. s && s(),
  62970. c._attachedCamera && c._attachedCamera.useInputToRestoreState && c._attachedCamera.storeState()
  62971. }),
  62972. _e && this._animatables.push(_e)
  62973. }
  62974. }
  62975. ,
  62976. a.prototype._calculateLowerRadiusFromModelBoundingSphere = function(e, i) {
  62977. var o = i.subtract(e)
  62978. , s = o.length()
  62979. , c = this._getFrustumSlope()
  62980. , d = s * .5
  62981. , _ = d * this._radiusScale
  62982. , b = _ * Math.sqrt(1 + 1 / (c.x * c.x))
  62983. , k = _ * Math.sqrt(1 + 1 / (c.y * c.y))
  62984. , j = Math.max(b, k)
  62985. , $ = this._attachedCamera;
  62986. return $ ? ($.lowerRadiusLimit && this._mode === a.IgnoreBoundsSizeMode && (j = j < $.lowerRadiusLimit ? $.lowerRadiusLimit : j),
  62987. $.upperRadiusLimit && (j = j > $.upperRadiusLimit ? $.upperRadiusLimit : j),
  62988. j) : 0
  62989. }
  62990. ,
  62991. a.prototype._maintainCameraAboveGround = function() {
  62992. var e = this;
  62993. if (!(this._elevationReturnTime < 0)) {
  62994. var i = PrecisionDate.Now - this._lastInteractionTime
  62995. , o = Math.PI * .5 - this._defaultElevation
  62996. , s = Math.PI * .5;
  62997. if (this._attachedCamera && !this._betaIsAnimating && this._attachedCamera.beta > s && i >= this._elevationReturnWaitTime) {
  62998. this._betaIsAnimating = !0,
  62999. this.stopAllAnimations(),
  63000. this._betaTransition || (this._betaTransition = Animation.CreateAnimation("beta", Animation.ANIMATIONTYPE_FLOAT, 60, a.EasingFunction));
  63001. var c = Animation.TransitionTo("beta", o, this._attachedCamera, this._attachedCamera.getScene(), 60, this._betaTransition, this._elevationReturnTime, function() {
  63002. e._clearAnimationLocks(),
  63003. e.stopAllAnimations()
  63004. });
  63005. c && this._animatables.push(c)
  63006. }
  63007. }
  63008. }
  63009. ,
  63010. a.prototype._getFrustumSlope = function() {
  63011. var e = this._attachedCamera;
  63012. if (!e)
  63013. return Vector2.Zero();
  63014. var i = e.getScene().getEngine()
  63015. , o = i.getAspectRatio(e)
  63016. , s = Math.tan(e.fov / 2)
  63017. , c = s * o;
  63018. return new Vector2(c,s)
  63019. }
  63020. ,
  63021. a.prototype._clearAnimationLocks = function() {
  63022. this._betaIsAnimating = !1
  63023. }
  63024. ,
  63025. a.prototype._applyUserInteraction = function() {
  63026. this.isUserIsMoving && (this._lastInteractionTime = PrecisionDate.Now,
  63027. this.stopAllAnimations(),
  63028. this._clearAnimationLocks())
  63029. }
  63030. ,
  63031. a.prototype.stopAllAnimations = function() {
  63032. for (this._attachedCamera && (this._attachedCamera.animations = []); this._animatables.length; )
  63033. this._animatables[0] && (this._animatables[0].onAnimationEnd = null,
  63034. this._animatables[0].stop()),
  63035. this._animatables.shift()
  63036. }
  63037. ,
  63038. Object.defineProperty(a.prototype, "isUserIsMoving", {
  63039. get: function() {
  63040. return this._attachedCamera ? this._attachedCamera.inertialAlphaOffset !== 0 || this._attachedCamera.inertialBetaOffset !== 0 || this._attachedCamera.inertialRadiusOffset !== 0 || this._attachedCamera.inertialPanningX !== 0 || this._attachedCamera.inertialPanningY !== 0 || this._isPointerDown : !1
  63041. },
  63042. enumerable: !1,
  63043. configurable: !0
  63044. }),
  63045. a.EasingFunction = new ExponentialEase,
  63046. a.EasingMode = EasingFunction.EASINGMODE_EASEINOUT,
  63047. a.IgnoreBoundsSizeMode = 0,
  63048. a.FitFrustumSidesMode = 1,
  63049. a
  63050. }()
  63051. , TargetCamera = function(a) {
  63052. __extends(e, a);
  63053. function e(i, o, s, c) {
  63054. c === void 0 && (c = !0);
  63055. var d = a.call(this, i, o, s, c) || this;
  63056. return d._tmpUpVector = Vector3.Zero(),
  63057. d._tmpTargetVector = Vector3.Zero(),
  63058. d.cameraDirection = new Vector3(0,0,0),
  63059. d.cameraRotation = new Vector2(0,0),
  63060. d.ignoreParentScaling = !1,
  63061. d.updateUpVectorFromRotation = !1,
  63062. d._tmpQuaternion = new Quaternion,
  63063. d.rotation = new Vector3(0,0,0),
  63064. d.speed = 2,
  63065. d.noRotationConstraint = !1,
  63066. d.invertRotation = !1,
  63067. d.inverseRotationSpeed = .2,
  63068. d.lockedTarget = null,
  63069. d._currentTarget = Vector3.Zero(),
  63070. d._initialFocalDistance = 1,
  63071. d._viewMatrix = Matrix.Zero(),
  63072. d._camMatrix = Matrix.Zero(),
  63073. d._cameraTransformMatrix = Matrix.Zero(),
  63074. d._cameraRotationMatrix = Matrix.Zero(),
  63075. d._referencePoint = new Vector3(0,0,1),
  63076. d._transformedReferencePoint = Vector3.Zero(),
  63077. d._defaultUp = Vector3.Up(),
  63078. d._cachedRotationZ = 0,
  63079. d._cachedQuaternionRotationZ = 0,
  63080. d
  63081. }
  63082. return e.prototype.getFrontPosition = function(i) {
  63083. this.getWorldMatrix();
  63084. var o = this.getTarget().subtract(this.position);
  63085. return o.normalize(),
  63086. o.scaleInPlace(i),
  63087. this.globalPosition.add(o)
  63088. }
  63089. ,
  63090. e.prototype._getLockedTargetPosition = function() {
  63091. return this.lockedTarget ? (this.lockedTarget.absolutePosition && this.lockedTarget.computeWorldMatrix(),
  63092. this.lockedTarget.absolutePosition || this.lockedTarget) : null
  63093. }
  63094. ,
  63095. e.prototype.storeState = function() {
  63096. return this._storedPosition = this.position.clone(),
  63097. this._storedRotation = this.rotation.clone(),
  63098. this.rotationQuaternion && (this._storedRotationQuaternion = this.rotationQuaternion.clone()),
  63099. a.prototype.storeState.call(this)
  63100. }
  63101. ,
  63102. e.prototype._restoreStateValues = function() {
  63103. return a.prototype._restoreStateValues.call(this) ? (this.position = this._storedPosition.clone(),
  63104. this.rotation = this._storedRotation.clone(),
  63105. this.rotationQuaternion && (this.rotationQuaternion = this._storedRotationQuaternion.clone()),
  63106. this.cameraDirection.copyFromFloats(0, 0, 0),
  63107. this.cameraRotation.copyFromFloats(0, 0),
  63108. !0) : !1
  63109. }
  63110. ,
  63111. e.prototype._initCache = function() {
  63112. a.prototype._initCache.call(this),
  63113. this._cache.lockedTarget = new Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),
  63114. this._cache.rotation = new Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),
  63115. this._cache.rotationQuaternion = new Quaternion(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)
  63116. }
  63117. ,
  63118. e.prototype._updateCache = function(i) {
  63119. i || a.prototype._updateCache.call(this);
  63120. var o = this._getLockedTargetPosition();
  63121. o ? this._cache.lockedTarget ? this._cache.lockedTarget.copyFrom(o) : this._cache.lockedTarget = o.clone() : this._cache.lockedTarget = null,
  63122. this._cache.rotation.copyFrom(this.rotation),
  63123. this.rotationQuaternion && this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion)
  63124. }
  63125. ,
  63126. e.prototype._isSynchronizedViewMatrix = function() {
  63127. if (!a.prototype._isSynchronizedViewMatrix.call(this))
  63128. return !1;
  63129. var i = this._getLockedTargetPosition();
  63130. return (this._cache.lockedTarget ? this._cache.lockedTarget.equals(i) : !i) && (this.rotationQuaternion ? this.rotationQuaternion.equals(this._cache.rotationQuaternion) : this._cache.rotation.equals(this.rotation))
  63131. }
  63132. ,
  63133. e.prototype._computeLocalCameraSpeed = function() {
  63134. var i = this.getEngine();
  63135. return this.speed * Math.sqrt(i.getDeltaTime() / (i.getFps() * 100))
  63136. }
  63137. ,
  63138. e.prototype.setTarget = function(i) {
  63139. this.upVector.normalize(),
  63140. this._initialFocalDistance = i.subtract(this.position).length(),
  63141. this.position.z === i.z && (this.position.z += Epsilon),
  63142. this._referencePoint.normalize().scaleInPlace(this._initialFocalDistance),
  63143. Matrix.LookAtLHToRef(this.position, i, this._defaultUp, this._camMatrix),
  63144. this._camMatrix.invert(),
  63145. this.rotation.x = Math.atan(this._camMatrix.m[6] / this._camMatrix.m[10]);
  63146. var o = i.subtract(this.position);
  63147. o.x >= 0 ? this.rotation.y = -Math.atan(o.z / o.x) + Math.PI / 2 : this.rotation.y = -Math.atan(o.z / o.x) - Math.PI / 2,
  63148. this.rotation.z = 0,
  63149. isNaN(this.rotation.x) && (this.rotation.x = 0),
  63150. isNaN(this.rotation.y) && (this.rotation.y = 0),
  63151. isNaN(this.rotation.z) && (this.rotation.z = 0),
  63152. this.rotationQuaternion && Quaternion.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion)
  63153. }
  63154. ,
  63155. Object.defineProperty(e.prototype, "target", {
  63156. get: function() {
  63157. return this.getTarget()
  63158. },
  63159. set: function(i) {
  63160. this.setTarget(i)
  63161. },
  63162. enumerable: !1,
  63163. configurable: !0
  63164. }),
  63165. e.prototype.getTarget = function() {
  63166. return this._currentTarget
  63167. }
  63168. ,
  63169. e.prototype._decideIfNeedsToMove = function() {
  63170. return Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0
  63171. }
  63172. ,
  63173. e.prototype._updatePosition = function() {
  63174. if (this.parent) {
  63175. this.parent.getWorldMatrix().invertToRef(TmpVectors.Matrix[0]),
  63176. Vector3.TransformNormalToRef(this.cameraDirection, TmpVectors.Matrix[0], TmpVectors.Vector3[0]),
  63177. this.position.addInPlace(TmpVectors.Vector3[0]);
  63178. return
  63179. }
  63180. this.position.addInPlace(this.cameraDirection)
  63181. }
  63182. ,
  63183. e.prototype._checkInputs = function() {
  63184. var i = this.invertRotation ? -this.inverseRotationSpeed : 1
  63185. , o = this._decideIfNeedsToMove()
  63186. , s = Math.abs(this.cameraRotation.x) > 0 || Math.abs(this.cameraRotation.y) > 0;
  63187. if (o && this._updatePosition(),
  63188. s) {
  63189. if (this.rotationQuaternion && this.rotationQuaternion.toEulerAnglesToRef(this.rotation),
  63190. this.rotation.x += this.cameraRotation.x * i,
  63191. this.rotation.y += this.cameraRotation.y * i,
  63192. !this.noRotationConstraint) {
  63193. var c = 1.570796;
  63194. this.rotation.x > c && (this.rotation.x = c),
  63195. this.rotation.x < -c && (this.rotation.x = -c)
  63196. }
  63197. if (this.rotationQuaternion) {
  63198. var d = this.rotation.lengthSquared();
  63199. d && Quaternion.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion)
  63200. }
  63201. }
  63202. o && (Math.abs(this.cameraDirection.x) < this.speed * Epsilon && (this.cameraDirection.x = 0),
  63203. Math.abs(this.cameraDirection.y) < this.speed * Epsilon && (this.cameraDirection.y = 0),
  63204. Math.abs(this.cameraDirection.z) < this.speed * Epsilon && (this.cameraDirection.z = 0),
  63205. this.cameraDirection.scaleInPlace(this.inertia)),
  63206. s && (Math.abs(this.cameraRotation.x) < this.speed * Epsilon && (this.cameraRotation.x = 0),
  63207. Math.abs(this.cameraRotation.y) < this.speed * Epsilon && (this.cameraRotation.y = 0),
  63208. this.cameraRotation.scaleInPlace(this.inertia)),
  63209. a.prototype._checkInputs.call(this)
  63210. }
  63211. ,
  63212. e.prototype._updateCameraRotationMatrix = function() {
  63213. this.rotationQuaternion ? this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix) : Matrix.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this._cameraRotationMatrix)
  63214. }
  63215. ,
  63216. e.prototype._rotateUpVectorWithCameraRotationMatrix = function() {
  63217. return Vector3.TransformNormalToRef(this._defaultUp, this._cameraRotationMatrix, this.upVector),
  63218. this
  63219. }
  63220. ,
  63221. e.prototype._getViewMatrix = function() {
  63222. return this.lockedTarget && this.setTarget(this._getLockedTargetPosition()),
  63223. this._updateCameraRotationMatrix(),
  63224. this.rotationQuaternion && this._cachedQuaternionRotationZ != this.rotationQuaternion.z ? (this._rotateUpVectorWithCameraRotationMatrix(),
  63225. this._cachedQuaternionRotationZ = this.rotationQuaternion.z) : this._cachedRotationZ !== this.rotation.z && (this._rotateUpVectorWithCameraRotationMatrix(),
  63226. this._cachedRotationZ = this.rotation.z),
  63227. Vector3.TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint),
  63228. this.position.addToRef(this._transformedReferencePoint, this._currentTarget),
  63229. this.updateUpVectorFromRotation && (this.rotationQuaternion ? Axis.Y.rotateByQuaternionToRef(this.rotationQuaternion, this.upVector) : (Quaternion.FromEulerVectorToRef(this.rotation, this._tmpQuaternion),
  63230. Axis.Y.rotateByQuaternionToRef(this._tmpQuaternion, this.upVector))),
  63231. this._computeViewMatrix(this.position, this._currentTarget, this.upVector),
  63232. this._viewMatrix
  63233. }
  63234. ,
  63235. e.prototype._computeViewMatrix = function(i, o, s) {
  63236. if (this.ignoreParentScaling) {
  63237. if (this.parent) {
  63238. var c = this.parent.getWorldMatrix();
  63239. Vector3.TransformCoordinatesToRef(i, c, this._globalPosition),
  63240. Vector3.TransformCoordinatesToRef(o, c, this._tmpTargetVector),
  63241. Vector3.TransformNormalToRef(s, c, this._tmpUpVector),
  63242. this._markSyncedWithParent()
  63243. } else
  63244. this._globalPosition.copyFrom(i),
  63245. this._tmpTargetVector.copyFrom(o),
  63246. this._tmpUpVector.copyFrom(s);
  63247. this.getScene().useRightHandedSystem ? Matrix.LookAtRHToRef(this._globalPosition, this._tmpTargetVector, this._tmpUpVector, this._viewMatrix) : Matrix.LookAtLHToRef(this._globalPosition, this._tmpTargetVector, this._tmpUpVector, this._viewMatrix);
  63248. return
  63249. }
  63250. if (this.getScene().useRightHandedSystem ? Matrix.LookAtRHToRef(i, o, s, this._viewMatrix) : Matrix.LookAtLHToRef(i, o, s, this._viewMatrix),
  63251. this.parent) {
  63252. var c = this.parent.getWorldMatrix();
  63253. this._viewMatrix.invert(),
  63254. this._viewMatrix.multiplyToRef(c, this._viewMatrix),
  63255. this._viewMatrix.getTranslationToRef(this._globalPosition),
  63256. this._viewMatrix.invert(),
  63257. this._markSyncedWithParent()
  63258. } else
  63259. this._globalPosition.copyFrom(i)
  63260. }
  63261. ,
  63262. e.prototype.createRigCamera = function(i, o) {
  63263. if (this.cameraRigMode !== Camera$1.RIG_MODE_NONE) {
  63264. var s = new e(i,this.position.clone(),this.getScene());
  63265. return s.isRigCamera = !0,
  63266. s.rigParent = this,
  63267. (this.cameraRigMode === Camera$1.RIG_MODE_VR || this.cameraRigMode === Camera$1.RIG_MODE_WEBVR) && (this.rotationQuaternion || (this.rotationQuaternion = new Quaternion),
  63268. s._cameraRigParams = {},
  63269. s.rotationQuaternion = new Quaternion),
  63270. s
  63271. }
  63272. return null
  63273. }
  63274. ,
  63275. e.prototype._updateRigCameras = function() {
  63276. var i = this._rigCameras[0]
  63277. , o = this._rigCameras[1];
  63278. switch (this.computeWorldMatrix(),
  63279. this.cameraRigMode) {
  63280. case Camera$1.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  63281. case Camera$1.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  63282. case Camera$1.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  63283. case Camera$1.RIG_MODE_STEREOSCOPIC_OVERUNDER:
  63284. case Camera$1.RIG_MODE_STEREOSCOPIC_INTERLACED:
  63285. var s = this.cameraRigMode === Camera$1.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED ? 1 : -1
  63286. , c = this.cameraRigMode === Camera$1.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED ? -1 : 1;
  63287. this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * s, i),
  63288. this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * c, o);
  63289. break;
  63290. case Camera$1.RIG_MODE_VR:
  63291. i.rotationQuaternion ? (i.rotationQuaternion.copyFrom(this.rotationQuaternion),
  63292. o.rotationQuaternion.copyFrom(this.rotationQuaternion)) : (i.rotation.copyFrom(this.rotation),
  63293. o.rotation.copyFrom(this.rotation)),
  63294. i.position.copyFrom(this.position),
  63295. o.position.copyFrom(this.position);
  63296. break
  63297. }
  63298. a.prototype._updateRigCameras.call(this)
  63299. }
  63300. ,
  63301. e.prototype._getRigCamPositionAndTarget = function(i, o) {
  63302. var s = this.getTarget();
  63303. s.subtractToRef(this.position, e._TargetFocalPoint),
  63304. e._TargetFocalPoint.normalize().scaleInPlace(this._initialFocalDistance);
  63305. var c = e._TargetFocalPoint.addInPlace(this.position);
  63306. Matrix.TranslationToRef(-c.x, -c.y, -c.z, e._TargetTransformMatrix),
  63307. e._TargetTransformMatrix.multiplyToRef(Matrix.RotationAxis(o.upVector, i), e._RigCamTransformMatrix),
  63308. Matrix.TranslationToRef(c.x, c.y, c.z, e._TargetTransformMatrix),
  63309. e._RigCamTransformMatrix.multiplyToRef(e._TargetTransformMatrix, e._RigCamTransformMatrix),
  63310. Vector3.TransformCoordinatesToRef(this.position, e._RigCamTransformMatrix, o.position),
  63311. o.setTarget(c)
  63312. }
  63313. ,
  63314. e.prototype.getClassName = function() {
  63315. return "TargetCamera"
  63316. }
  63317. ,
  63318. e._RigCamTransformMatrix = new Matrix,
  63319. e._TargetTransformMatrix = new Matrix,
  63320. e._TargetFocalPoint = new Vector3,
  63321. __decorate([serializeAsVector3()], e.prototype, "rotation", void 0),
  63322. __decorate([serialize()], e.prototype, "speed", void 0),
  63323. __decorate([serializeAsMeshReference("lockedTargetId")], e.prototype, "lockedTarget", void 0),
  63324. e
  63325. }(Camera$1)
  63326. , CameraInputTypes = {}
  63327. , CameraInputsManager = function() {
  63328. function a(e) {
  63329. this.attachedToElement = !1,
  63330. this.attached = {},
  63331. this.camera = e,
  63332. this.checkInputs = function() {}
  63333. }
  63334. return a.prototype.add = function(e) {
  63335. var i = e.getSimpleName();
  63336. if (this.attached[i]) {
  63337. Logger$2.Warn("camera input of type " + i + " already exists on camera");
  63338. return
  63339. }
  63340. this.attached[i] = e,
  63341. e.camera = this.camera,
  63342. e.checkInputs && (this.checkInputs = this._addCheckInputs(e.checkInputs.bind(e))),
  63343. this.attachedToElement && e.attachControl()
  63344. }
  63345. ,
  63346. a.prototype.remove = function(e) {
  63347. for (var i in this.attached) {
  63348. var o = this.attached[i];
  63349. o === e && (o.detachControl(),
  63350. o.camera = null,
  63351. delete this.attached[i],
  63352. this.rebuildInputCheck())
  63353. }
  63354. }
  63355. ,
  63356. a.prototype.removeByType = function(e) {
  63357. for (var i in this.attached) {
  63358. var o = this.attached[i];
  63359. o.getClassName() === e && (o.detachControl(),
  63360. o.camera = null,
  63361. delete this.attached[i],
  63362. this.rebuildInputCheck())
  63363. }
  63364. }
  63365. ,
  63366. a.prototype._addCheckInputs = function(e) {
  63367. var i = this.checkInputs;
  63368. return function() {
  63369. i(),
  63370. e()
  63371. }
  63372. }
  63373. ,
  63374. a.prototype.attachInput = function(e) {
  63375. this.attachedToElement && e.attachControl(this.noPreventDefault)
  63376. }
  63377. ,
  63378. a.prototype.attachElement = function(e) {
  63379. if (e === void 0 && (e = !1),
  63380. !this.attachedToElement) {
  63381. e = Camera$1.ForceAttachControlToAlwaysPreventDefault ? !1 : e,
  63382. this.attachedToElement = !0,
  63383. this.noPreventDefault = e;
  63384. for (var i in this.attached)
  63385. this.attached[i].attachControl(e)
  63386. }
  63387. }
  63388. ,
  63389. a.prototype.detachElement = function(e) {
  63390. e === void 0 && (e = !1);
  63391. for (var i in this.attached)
  63392. this.attached[i].detachControl(),
  63393. e && (this.attached[i].camera = null);
  63394. this.attachedToElement = !1
  63395. }
  63396. ,
  63397. a.prototype.rebuildInputCheck = function() {
  63398. this.checkInputs = function() {}
  63399. ;
  63400. for (var e in this.attached) {
  63401. var i = this.attached[e];
  63402. i.checkInputs && (this.checkInputs = this._addCheckInputs(i.checkInputs.bind(i)))
  63403. }
  63404. }
  63405. ,
  63406. a.prototype.clear = function() {
  63407. this.attachedToElement && this.detachElement(!0),
  63408. this.attached = {},
  63409. this.attachedToElement = !1,
  63410. this.checkInputs = function() {}
  63411. }
  63412. ,
  63413. a.prototype.serialize = function(e) {
  63414. var i = {};
  63415. for (var o in this.attached) {
  63416. var s = this.attached[o]
  63417. , c = SerializationHelper.Serialize(s);
  63418. i[s.getClassName()] = c
  63419. }
  63420. e.inputsmgr = i
  63421. }
  63422. ,
  63423. a.prototype.parse = function(e) {
  63424. var i = e.inputsmgr;
  63425. if (i) {
  63426. this.clear();
  63427. for (var o in i) {
  63428. var s = CameraInputTypes[o];
  63429. if (s) {
  63430. var c = i[o]
  63431. , d = SerializationHelper.Parse(function() {
  63432. return new s
  63433. }, c, null);
  63434. this.add(d)
  63435. }
  63436. }
  63437. } else
  63438. for (var o in this.attached) {
  63439. var s = CameraInputTypes[this.attached[o].getClassName()];
  63440. if (s) {
  63441. var d = SerializationHelper.Parse(function() {
  63442. return new s
  63443. }, e, null);
  63444. this.remove(this.attached[o]),
  63445. this.add(d)
  63446. }
  63447. }
  63448. }
  63449. ,
  63450. a
  63451. }()
  63452. , BaseCameraPointersInput = function() {
  63453. function a() {
  63454. this._currentActiveButton = -1,
  63455. this.buttons = [0, 1, 2]
  63456. }
  63457. return a.prototype.attachControl = function(e) {
  63458. var i = this;
  63459. e = Tools.BackCompatCameraNoPreventDefault(arguments);
  63460. var o = this.camera.getEngine()
  63461. , s = o.getInputElement()
  63462. , c = 0
  63463. , d = null;
  63464. this.pointA = null,
  63465. this.pointB = null,
  63466. this._altKey = !1,
  63467. this._ctrlKey = !1,
  63468. this._metaKey = !1,
  63469. this._shiftKey = !1,
  63470. this._buttonsPressed = 0,
  63471. this._pointerInput = function(b, k) {
  63472. var j = b.event
  63473. , $ = j.pointerType === "touch";
  63474. if (!o.isInVRExclusivePointerMode && !(b.type !== PointerEventTypes.POINTERMOVE && i.buttons.indexOf(j.button) === -1)) {
  63475. var _e = j.srcElement || j.target;
  63476. if (i._altKey = j.altKey,
  63477. i._ctrlKey = j.ctrlKey,
  63478. i._metaKey = j.metaKey,
  63479. i._shiftKey = j.shiftKey,
  63480. i._buttonsPressed = j.buttons,
  63481. o.isPointerLock) {
  63482. var et = j.movementX || j.mozMovementX || j.webkitMovementX || j.msMovementX || 0
  63483. , tt = j.movementY || j.mozMovementY || j.webkitMovementY || j.msMovementY || 0;
  63484. i.onTouch(null, et, tt),
  63485. i.pointA = null,
  63486. i.pointB = null
  63487. } else if (b.type === PointerEventTypes.POINTERDOWN && (i._currentActiveButton === -1 || $)) {
  63488. try {
  63489. _e == null || _e.setPointerCapture(j.pointerId)
  63490. } catch {}
  63491. i.pointA === null ? i.pointA = {
  63492. x: j.clientX,
  63493. y: j.clientY,
  63494. pointerId: j.pointerId,
  63495. type: j.pointerType
  63496. } : i.pointB === null && (i.pointB = {
  63497. x: j.clientX,
  63498. y: j.clientY,
  63499. pointerId: j.pointerId,
  63500. type: j.pointerType
  63501. }),
  63502. i._currentActiveButton === -1 && !$ && (i._currentActiveButton = j.button),
  63503. i.onButtonDown(j),
  63504. e || (j.preventDefault(),
  63505. s && s.focus())
  63506. } else if (b.type === PointerEventTypes.POINTERDOUBLETAP)
  63507. i.onDoubleTap(j.pointerType);
  63508. else if (b.type === PointerEventTypes.POINTERUP && (i._currentActiveButton === j.button || $)) {
  63509. try {
  63510. _e == null || _e.releasePointerCapture(j.pointerId)
  63511. } catch {}
  63512. $ || (i.pointB = null),
  63513. o._badOS ? i.pointA = i.pointB = null : i.pointB && i.pointA && i.pointA.pointerId == j.pointerId ? (i.pointA = i.pointB,
  63514. i.pointB = null) : i.pointA && i.pointB && i.pointB.pointerId == j.pointerId ? i.pointB = null : i.pointA = i.pointB = null,
  63515. (c !== 0 || d) && (i.onMultiTouch(i.pointA, i.pointB, c, 0, d, null),
  63516. c = 0,
  63517. d = null),
  63518. i._currentActiveButton = -1,
  63519. i.onButtonUp(j),
  63520. e || j.preventDefault()
  63521. } else if (b.type === PointerEventTypes.POINTERMOVE) {
  63522. if (e || j.preventDefault(),
  63523. i.pointA && i.pointB === null) {
  63524. var et = j.clientX - i.pointA.x
  63525. , tt = j.clientY - i.pointA.y;
  63526. i.onTouch(i.pointA, et, tt),
  63527. i.pointA.x = j.clientX,
  63528. i.pointA.y = j.clientY
  63529. } else if (i.pointA && i.pointB) {
  63530. var rt = i.pointA.pointerId === j.pointerId ? i.pointA : i.pointB;
  63531. rt.x = j.clientX,
  63532. rt.y = j.clientY;
  63533. var it = i.pointA.x - i.pointB.x
  63534. , nt = i.pointA.y - i.pointB.y
  63535. , ot = it * it + nt * nt
  63536. , at = {
  63537. x: (i.pointA.x + i.pointB.x) / 2,
  63538. y: (i.pointA.y + i.pointB.y) / 2,
  63539. pointerId: j.pointerId,
  63540. type: b.type
  63541. };
  63542. i.onMultiTouch(i.pointA, i.pointB, c, ot, d, at),
  63543. d = at,
  63544. c = ot
  63545. }
  63546. }
  63547. }
  63548. }
  63549. ,
  63550. this._observer = this.camera.getScene().onPointerObservable.add(this._pointerInput, PointerEventTypes.POINTERDOWN | PointerEventTypes.POINTERUP | PointerEventTypes.POINTERMOVE | PointerEventTypes.POINTERDOUBLETAP),
  63551. this._onLostFocus = function() {
  63552. i.pointA = i.pointB = null,
  63553. c = 0,
  63554. d = null,
  63555. i.onLostFocus()
  63556. }
  63557. ,
  63558. s && s.addEventListener("contextmenu", this.onContextMenu.bind(this), !1);
  63559. var _ = this.camera.getScene().getEngine().getHostWindow();
  63560. _ && Tools.RegisterTopRootEvents(_, [{
  63561. name: "blur",
  63562. handler: this._onLostFocus
  63563. }])
  63564. }
  63565. ,
  63566. a.prototype.detachControl = function(e) {
  63567. if (this._onLostFocus) {
  63568. var i = this.camera.getScene().getEngine().getHostWindow();
  63569. i && Tools.UnregisterTopRootEvents(i, [{
  63570. name: "blur",
  63571. handler: this._onLostFocus
  63572. }])
  63573. }
  63574. if (this._observer) {
  63575. if (this.camera.getScene().onPointerObservable.remove(this._observer),
  63576. this._observer = null,
  63577. this.onContextMenu) {
  63578. var o = this.camera.getScene().getEngine().getInputElement();
  63579. o && o.removeEventListener("contextmenu", this.onContextMenu)
  63580. }
  63581. this._onLostFocus = null
  63582. }
  63583. this._altKey = !1,
  63584. this._ctrlKey = !1,
  63585. this._metaKey = !1,
  63586. this._shiftKey = !1,
  63587. this._buttonsPressed = 0
  63588. }
  63589. ,
  63590. a.prototype.getClassName = function() {
  63591. return "BaseCameraPointersInput"
  63592. }
  63593. ,
  63594. a.prototype.getSimpleName = function() {
  63595. return "pointers"
  63596. }
  63597. ,
  63598. a.prototype.onDoubleTap = function(e) {}
  63599. ,
  63600. a.prototype.onTouch = function(e, i, o) {}
  63601. ,
  63602. a.prototype.onMultiTouch = function(e, i, o, s, c, d) {}
  63603. ,
  63604. a.prototype.onContextMenu = function(e) {
  63605. e.preventDefault()
  63606. }
  63607. ,
  63608. a.prototype.onButtonDown = function(e) {}
  63609. ,
  63610. a.prototype.onButtonUp = function(e) {}
  63611. ,
  63612. a.prototype.onLostFocus = function() {}
  63613. ,
  63614. __decorate([serialize()], a.prototype, "buttons", void 0),
  63615. a
  63616. }()
  63617. , ArcRotateCameraPointersInput = function(a) {
  63618. __extends(e, a);
  63619. function e() {
  63620. var i = a !== null && a.apply(this, arguments) || this;
  63621. return i.buttons = [0, 1, 2],
  63622. i.angularSensibilityX = 1e3,
  63623. i.angularSensibilityY = 1e3,
  63624. i.pinchPrecision = 12,
  63625. i.pinchDeltaPercentage = 0,
  63626. i.useNaturalPinchZoom = !1,
  63627. i.pinchZoom = !0,
  63628. i.panningSensibility = 1e3,
  63629. i.multiTouchPanning = !0,
  63630. i.multiTouchPanAndZoom = !0,
  63631. i.pinchInwards = !0,
  63632. i._isPanClick = !1,
  63633. i._twoFingerActivityCount = 0,
  63634. i._isPinching = !1,
  63635. i
  63636. }
  63637. return e.prototype.getClassName = function() {
  63638. return "ArcRotateCameraPointersInput"
  63639. }
  63640. ,
  63641. e.prototype._computeMultiTouchPanning = function(i, o) {
  63642. if (this.panningSensibility !== 0 && i && o) {
  63643. var s = o.x - i.x
  63644. , c = o.y - i.y;
  63645. this.camera.inertialPanningX += -s / this.panningSensibility,
  63646. this.camera.inertialPanningY += c / this.panningSensibility
  63647. }
  63648. }
  63649. ,
  63650. e.prototype._computePinchZoom = function(i, o) {
  63651. var s = this.camera.radius || e.MinimumRadiusForPinch;
  63652. this.useNaturalPinchZoom ? this.camera.radius = s * Math.sqrt(i) / Math.sqrt(o) : this.pinchDeltaPercentage ? this.camera.inertialRadiusOffset += (o - i) * .001 * s * this.pinchDeltaPercentage : this.camera.inertialRadiusOffset += (o - i) / (this.pinchPrecision * (this.pinchInwards ? 1 : -1) * (this.angularSensibilityX + this.angularSensibilityY) / 2)
  63653. }
  63654. ,
  63655. e.prototype.onTouch = function(i, o, s) {
  63656. this.panningSensibility !== 0 && (this._ctrlKey && this.camera._useCtrlForPanning || this._isPanClick) ? (this.camera.inertialPanningX += -o / this.panningSensibility,
  63657. this.camera.inertialPanningY += s / this.panningSensibility) : (this.camera.inertialAlphaOffset -= o / this.angularSensibilityX,
  63658. this.camera.inertialBetaOffset -= s / this.angularSensibilityY)
  63659. }
  63660. ,
  63661. e.prototype.onDoubleTap = function(i) {
  63662. this.camera.useInputToRestoreState && this.camera.restoreState()
  63663. }
  63664. ,
  63665. e.prototype.onMultiTouch = function(i, o, s, c, d, _) {
  63666. s === 0 && d === null || c === 0 && _ === null || (this.multiTouchPanAndZoom ? (this._computePinchZoom(s, c),
  63667. this._computeMultiTouchPanning(d, _)) : this.multiTouchPanning && this.pinchZoom ? (this._twoFingerActivityCount++,
  63668. this._isPinching || this._twoFingerActivityCount < 20 && Math.abs(Math.sqrt(c) - Math.sqrt(s)) > this.camera.pinchToPanMaxDistance ? (this._computePinchZoom(s, c),
  63669. this._isPinching = !0) : this._computeMultiTouchPanning(d, _)) : this.multiTouchPanning ? this._computeMultiTouchPanning(d, _) : this.pinchZoom && this._computePinchZoom(s, c))
  63670. }
  63671. ,
  63672. e.prototype.onButtonDown = function(i) {
  63673. this._isPanClick = i.button === this.camera._panningMouseButton
  63674. }
  63675. ,
  63676. e.prototype.onButtonUp = function(i) {
  63677. this._twoFingerActivityCount = 0,
  63678. this._isPinching = !1
  63679. }
  63680. ,
  63681. e.prototype.onLostFocus = function() {
  63682. this._isPanClick = !1,
  63683. this._twoFingerActivityCount = 0,
  63684. this._isPinching = !1
  63685. }
  63686. ,
  63687. e.MinimumRadiusForPinch = .001,
  63688. __decorate([serialize()], e.prototype, "buttons", void 0),
  63689. __decorate([serialize()], e.prototype, "angularSensibilityX", void 0),
  63690. __decorate([serialize()], e.prototype, "angularSensibilityY", void 0),
  63691. __decorate([serialize()], e.prototype, "pinchPrecision", void 0),
  63692. __decorate([serialize()], e.prototype, "pinchDeltaPercentage", void 0),
  63693. __decorate([serialize()], e.prototype, "useNaturalPinchZoom", void 0),
  63694. __decorate([serialize()], e.prototype, "pinchZoom", void 0),
  63695. __decorate([serialize()], e.prototype, "panningSensibility", void 0),
  63696. __decorate([serialize()], e.prototype, "multiTouchPanning", void 0),
  63697. __decorate([serialize()], e.prototype, "multiTouchPanAndZoom", void 0),
  63698. e
  63699. }(BaseCameraPointersInput);
  63700. CameraInputTypes.ArcRotateCameraPointersInput = ArcRotateCameraPointersInput;
  63701. var ArcRotateCameraKeyboardMoveInput = function() {
  63702. function a() {
  63703. this.keysUp = [38],
  63704. this.keysDown = [40],
  63705. this.keysLeft = [37],
  63706. this.keysRight = [39],
  63707. this.keysReset = [220],
  63708. this.panningSensibility = 50,
  63709. this.zoomingSensibility = 25,
  63710. this.useAltToZoom = !0,
  63711. this.angularSpeed = .01,
  63712. this._keys = new Array
  63713. }
  63714. return a.prototype.attachControl = function(e) {
  63715. var i = this;
  63716. e = Tools.BackCompatCameraNoPreventDefault(arguments),
  63717. !this._onCanvasBlurObserver && (this._scene = this.camera.getScene(),
  63718. this._engine = this._scene.getEngine(),
  63719. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function() {
  63720. i._keys = []
  63721. }),
  63722. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function(o) {
  63723. var s = o.event;
  63724. if (!s.metaKey) {
  63725. if (o.type === KeyboardEventTypes.KEYDOWN) {
  63726. if (i._ctrlPressed = s.ctrlKey,
  63727. i._altPressed = s.altKey,
  63728. i.keysUp.indexOf(s.keyCode) !== -1 || i.keysDown.indexOf(s.keyCode) !== -1 || i.keysLeft.indexOf(s.keyCode) !== -1 || i.keysRight.indexOf(s.keyCode) !== -1 || i.keysReset.indexOf(s.keyCode) !== -1) {
  63729. var c = i._keys.indexOf(s.keyCode);
  63730. c === -1 && i._keys.push(s.keyCode),
  63731. s.preventDefault && (e || s.preventDefault())
  63732. }
  63733. } else if (i.keysUp.indexOf(s.keyCode) !== -1 || i.keysDown.indexOf(s.keyCode) !== -1 || i.keysLeft.indexOf(s.keyCode) !== -1 || i.keysRight.indexOf(s.keyCode) !== -1 || i.keysReset.indexOf(s.keyCode) !== -1) {
  63734. var c = i._keys.indexOf(s.keyCode);
  63735. c >= 0 && i._keys.splice(c, 1),
  63736. s.preventDefault && (e || s.preventDefault())
  63737. }
  63738. }
  63739. }))
  63740. }
  63741. ,
  63742. a.prototype.detachControl = function(e) {
  63743. this._scene && (this._onKeyboardObserver && this._scene.onKeyboardObservable.remove(this._onKeyboardObserver),
  63744. this._onCanvasBlurObserver && this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver),
  63745. this._onKeyboardObserver = null,
  63746. this._onCanvasBlurObserver = null),
  63747. this._keys = []
  63748. }
  63749. ,
  63750. a.prototype.checkInputs = function() {
  63751. if (this._onKeyboardObserver)
  63752. for (var e = this.camera, i = 0; i < this._keys.length; i++) {
  63753. var o = this._keys[i];
  63754. this.keysLeft.indexOf(o) !== -1 ? this._ctrlPressed && this.camera._useCtrlForPanning ? e.inertialPanningX -= 1 / this.panningSensibility : e.inertialAlphaOffset -= this.angularSpeed : this.keysUp.indexOf(o) !== -1 ? this._ctrlPressed && this.camera._useCtrlForPanning ? e.inertialPanningY += 1 / this.panningSensibility : this._altPressed && this.useAltToZoom ? e.inertialRadiusOffset += 1 / this.zoomingSensibility : e.inertialBetaOffset -= this.angularSpeed : this.keysRight.indexOf(o) !== -1 ? this._ctrlPressed && this.camera._useCtrlForPanning ? e.inertialPanningX += 1 / this.panningSensibility : e.inertialAlphaOffset += this.angularSpeed : this.keysDown.indexOf(o) !== -1 ? this._ctrlPressed && this.camera._useCtrlForPanning ? e.inertialPanningY -= 1 / this.panningSensibility : this._altPressed && this.useAltToZoom ? e.inertialRadiusOffset -= 1 / this.zoomingSensibility : e.inertialBetaOffset += this.angularSpeed : this.keysReset.indexOf(o) !== -1 && e.useInputToRestoreState && e.restoreState()
  63755. }
  63756. }
  63757. ,
  63758. a.prototype.getClassName = function() {
  63759. return "ArcRotateCameraKeyboardMoveInput"
  63760. }
  63761. ,
  63762. a.prototype.getSimpleName = function() {
  63763. return "keyboard"
  63764. }
  63765. ,
  63766. __decorate([serialize()], a.prototype, "keysUp", void 0),
  63767. __decorate([serialize()], a.prototype, "keysDown", void 0),
  63768. __decorate([serialize()], a.prototype, "keysLeft", void 0),
  63769. __decorate([serialize()], a.prototype, "keysRight", void 0),
  63770. __decorate([serialize()], a.prototype, "keysReset", void 0),
  63771. __decorate([serialize()], a.prototype, "panningSensibility", void 0),
  63772. __decorate([serialize()], a.prototype, "zoomingSensibility", void 0),
  63773. __decorate([serialize()], a.prototype, "useAltToZoom", void 0),
  63774. __decorate([serialize()], a.prototype, "angularSpeed", void 0),
  63775. a
  63776. }();
  63777. CameraInputTypes.ArcRotateCameraKeyboardMoveInput = ArcRotateCameraKeyboardMoveInput;
  63778. var ffMultiplier = 40
  63779. , ArcRotateCameraMouseWheelInput = function() {
  63780. function a() {
  63781. this.wheelPrecision = 3,
  63782. this.zoomToMouseLocation = !1,
  63783. this.wheelDeltaPercentage = 0,
  63784. this.customComputeDeltaFromMouseWheel = null,
  63785. this._inertialPanning = Vector3.Zero()
  63786. }
  63787. return a.prototype.computeDeltaFromMouseWheelLegacyEvent = function(e, i) {
  63788. var o = 0
  63789. , s = e * .01 * this.wheelDeltaPercentage * i;
  63790. return e > 0 ? o = s / (1 + this.wheelDeltaPercentage) : o = s * (1 + this.wheelDeltaPercentage),
  63791. o
  63792. }
  63793. ,
  63794. a.prototype.attachControl = function(e) {
  63795. var i = this;
  63796. e = Tools.BackCompatCameraNoPreventDefault(arguments),
  63797. this._wheel = function(o, s) {
  63798. if (o.type === PointerEventTypes.POINTERWHEEL) {
  63799. var c = o.event
  63800. , d = 0
  63801. , _ = c
  63802. , b = 0
  63803. , k = c.deltaMode === EventConstants.DOM_DELTA_LINE ? ffMultiplier : 1;
  63804. if (c.deltaY !== void 0 ? b = -(c.deltaY * k) : c.wheelDeltaY !== void 0 ? b = -(c.wheelDeltaY * k) : b = _.wheelDelta,
  63805. i.customComputeDeltaFromMouseWheel)
  63806. d = i.customComputeDeltaFromMouseWheel(b, i, c);
  63807. else if (i.wheelDeltaPercentage) {
  63808. if (d = i.computeDeltaFromMouseWheelLegacyEvent(b, i.camera.radius),
  63809. d > 0) {
  63810. for (var j = i.camera.radius, $ = i.camera.inertialRadiusOffset + d, _e = 0; _e < 20 && Math.abs($) > .001; _e++)
  63811. j -= $,
  63812. $ *= i.camera.inertia;
  63813. j = Scalar.Clamp(j, 0, Number.MAX_VALUE),
  63814. d = i.computeDeltaFromMouseWheelLegacyEvent(b, j)
  63815. }
  63816. } else
  63817. d = b / (i.wheelPrecision * 40);
  63818. d && (i.zoomToMouseLocation && i._hitPlane ? i._zoomToMouse(d) : i.camera.inertialRadiusOffset += d),
  63819. c.preventDefault && (e || c.preventDefault())
  63820. }
  63821. }
  63822. ,
  63823. this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, PointerEventTypes.POINTERWHEEL),
  63824. this.zoomToMouseLocation && this._inertialPanning.setAll(0)
  63825. }
  63826. ,
  63827. a.prototype.detachControl = function(e) {
  63828. this._observer && (this.camera.getScene().onPointerObservable.remove(this._observer),
  63829. this._observer = null,
  63830. this._wheel = null)
  63831. }
  63832. ,
  63833. a.prototype.checkInputs = function() {
  63834. if (!!this.zoomToMouseLocation) {
  63835. var e = this.camera
  63836. , i = 0 + e.inertialAlphaOffset + e.inertialBetaOffset + e.inertialRadiusOffset;
  63837. i && (this._updateHitPlane(),
  63838. e.target.addInPlace(this._inertialPanning),
  63839. this._inertialPanning.scaleInPlace(e.inertia),
  63840. this._zeroIfClose(this._inertialPanning))
  63841. }
  63842. }
  63843. ,
  63844. a.prototype.getClassName = function() {
  63845. return "ArcRotateCameraMouseWheelInput"
  63846. }
  63847. ,
  63848. a.prototype.getSimpleName = function() {
  63849. return "mousewheel"
  63850. }
  63851. ,
  63852. a.prototype._updateHitPlane = function() {
  63853. var e = this.camera
  63854. , i = e.target.subtract(e.position);
  63855. this._hitPlane = Plane.FromPositionAndNormal(Vector3.Zero(), i)
  63856. }
  63857. ,
  63858. a.prototype._getPosition = function() {
  63859. var e, i = this.camera, o = i.getScene(), s = o.createPickingRay(o.pointerX, o.pointerY, Matrix.Identity(), i, !1), c = 0;
  63860. return this._hitPlane && (c = (e = s.intersectsPlane(this._hitPlane)) !== null && e !== void 0 ? e : 0),
  63861. s.origin.addInPlace(s.direction.scaleInPlace(c))
  63862. }
  63863. ,
  63864. a.prototype._zoomToMouse = function(e) {
  63865. var i, o, s = this.camera, c = 1 - s.inertia;
  63866. if (s.lowerRadiusLimit) {
  63867. var d = (i = s.lowerRadiusLimit) !== null && i !== void 0 ? i : 0;
  63868. s.radius - (s.inertialRadiusOffset + e) / c < d && (e = (s.radius - d) * c - s.inertialRadiusOffset)
  63869. }
  63870. if (s.upperRadiusLimit) {
  63871. var _ = (o = s.upperRadiusLimit) !== null && o !== void 0 ? o : 0;
  63872. s.radius - (s.inertialRadiusOffset + e) / c > _ && (e = (s.radius - _) * c - s.inertialRadiusOffset)
  63873. }
  63874. var b = e / c
  63875. , k = b / s.radius
  63876. , j = this._getPosition()
  63877. , $ = j.subtract(s.target)
  63878. , _e = $.scale(k);
  63879. _e.scaleInPlace(c),
  63880. this._inertialPanning.addInPlace(_e),
  63881. s.inertialRadiusOffset += e
  63882. }
  63883. ,
  63884. a.prototype._zeroIfClose = function(e) {
  63885. Math.abs(e.x) < Epsilon && (e.x = 0),
  63886. Math.abs(e.y) < Epsilon && (e.y = 0),
  63887. Math.abs(e.z) < Epsilon && (e.z = 0)
  63888. }
  63889. ,
  63890. __decorate([serialize()], a.prototype, "wheelPrecision", void 0),
  63891. __decorate([serialize()], a.prototype, "zoomToMouseLocation", void 0),
  63892. __decorate([serialize()], a.prototype, "wheelDeltaPercentage", void 0),
  63893. a
  63894. }();
  63895. CameraInputTypes.ArcRotateCameraMouseWheelInput = ArcRotateCameraMouseWheelInput;
  63896. var ArcRotateCameraInputsManager = function(a) {
  63897. __extends(e, a);
  63898. function e(i) {
  63899. return a.call(this, i) || this
  63900. }
  63901. return e.prototype.addMouseWheel = function() {
  63902. return this.add(new ArcRotateCameraMouseWheelInput),
  63903. this
  63904. }
  63905. ,
  63906. e.prototype.addPointers = function() {
  63907. return this.add(new ArcRotateCameraPointersInput),
  63908. this
  63909. }
  63910. ,
  63911. e.prototype.addKeyboard = function() {
  63912. return this.add(new ArcRotateCameraKeyboardMoveInput),
  63913. this
  63914. }
  63915. ,
  63916. e
  63917. }(CameraInputsManager);
  63918. Node$2.AddNodeConstructor("ArcRotateCamera", function(a, e) {
  63919. return function() {
  63920. return new ArcRotateCamera(a,0,0,1,Vector3.Zero(),e)
  63921. }
  63922. });
  63923. var ArcRotateCamera = function(a) {
  63924. __extends(e, a);
  63925. function e(i, o, s, c, d, _, b) {
  63926. b === void 0 && (b = !0);
  63927. var k = a.call(this, i, Vector3.Zero(), _, b) || this;
  63928. return k.inertialAlphaOffset = 0,
  63929. k.inertialBetaOffset = 0,
  63930. k.inertialRadiusOffset = 0,
  63931. k.lowerAlphaLimit = null,
  63932. k.upperAlphaLimit = null,
  63933. k.lowerBetaLimit = .01,
  63934. k.upperBetaLimit = Math.PI - .01,
  63935. k.lowerRadiusLimit = null,
  63936. k.upperRadiusLimit = null,
  63937. k.inertialPanningX = 0,
  63938. k.inertialPanningY = 0,
  63939. k.pinchToPanMaxDistance = 20,
  63940. k.panningDistanceLimit = null,
  63941. k.panningOriginTarget = Vector3.Zero(),
  63942. k.panningInertia = .9,
  63943. k.zoomOnFactor = 1,
  63944. k.targetScreenOffset = Vector2.Zero(),
  63945. k.allowUpsideDown = !0,
  63946. k.useInputToRestoreState = !0,
  63947. k._viewMatrix = new Matrix,
  63948. k.panningAxis = new Vector3(1,1,0),
  63949. k._transformedDirection = new Vector3,
  63950. k.mapPanning = !1,
  63951. k.onMeshTargetChangedObservable = new Observable,
  63952. k.checkCollisions = !1,
  63953. k.collisionRadius = new Vector3(.5,.5,.5),
  63954. k._previousPosition = Vector3.Zero(),
  63955. k._collisionVelocity = Vector3.Zero(),
  63956. k._newPosition = Vector3.Zero(),
  63957. k._computationVector = Vector3.Zero(),
  63958. k._onCollisionPositionChange = function(j, $, _e) {
  63959. _e === void 0 && (_e = null),
  63960. _e ? (k.setPosition($),
  63961. k.onCollide && k.onCollide(_e)) : k._previousPosition.copyFrom(k._position);
  63962. var et = Math.cos(k.alpha)
  63963. , tt = Math.sin(k.alpha)
  63964. , rt = Math.cos(k.beta)
  63965. , it = Math.sin(k.beta);
  63966. it === 0 && (it = 1e-4);
  63967. var nt = k._getTargetPosition();
  63968. k._computationVector.copyFromFloats(k.radius * et * it, k.radius * rt, k.radius * tt * it),
  63969. nt.addToRef(k._computationVector, k._newPosition),
  63970. k._position.copyFrom(k._newPosition);
  63971. var ot = k.upVector;
  63972. k.allowUpsideDown && k.beta < 0 && (ot = ot.clone(),
  63973. ot = ot.negate()),
  63974. k._computeViewMatrix(k._position, nt, ot),
  63975. k._viewMatrix.addAtIndex(12, k.targetScreenOffset.x),
  63976. k._viewMatrix.addAtIndex(13, k.targetScreenOffset.y),
  63977. k._collisionTriggered = !1
  63978. }
  63979. ,
  63980. k._target = Vector3.Zero(),
  63981. d && k.setTarget(d),
  63982. k.alpha = o,
  63983. k.beta = s,
  63984. k.radius = c,
  63985. k.getViewMatrix(),
  63986. k.inputs = new ArcRotateCameraInputsManager(k),
  63987. k.inputs.addKeyboard().addMouseWheel().addPointers(),
  63988. k
  63989. }
  63990. return Object.defineProperty(e.prototype, "target", {
  63991. get: function() {
  63992. return this._target
  63993. },
  63994. set: function(i) {
  63995. this.setTarget(i)
  63996. },
  63997. enumerable: !1,
  63998. configurable: !0
  63999. }),
  64000. Object.defineProperty(e.prototype, "targetHost", {
  64001. get: function() {
  64002. return this._targetHost
  64003. },
  64004. set: function(i) {
  64005. i && this.setTarget(i)
  64006. },
  64007. enumerable: !1,
  64008. configurable: !0
  64009. }),
  64010. e.prototype.getTarget = function() {
  64011. return this.target
  64012. }
  64013. ,
  64014. Object.defineProperty(e.prototype, "position", {
  64015. get: function() {
  64016. return this._position
  64017. },
  64018. set: function(i) {
  64019. this.setPosition(i)
  64020. },
  64021. enumerable: !1,
  64022. configurable: !0
  64023. }),
  64024. Object.defineProperty(e.prototype, "upVector", {
  64025. get: function() {
  64026. return this._upVector
  64027. },
  64028. set: function(i) {
  64029. this._upToYMatrix || (this._YToUpMatrix = new Matrix,
  64030. this._upToYMatrix = new Matrix,
  64031. this._upVector = Vector3.Zero()),
  64032. i.normalize(),
  64033. this._upVector.copyFrom(i),
  64034. this.setMatUp()
  64035. },
  64036. enumerable: !1,
  64037. configurable: !0
  64038. }),
  64039. e.prototype.setMatUp = function() {
  64040. Matrix.RotationAlignToRef(Vector3.UpReadOnly, this._upVector, this._YToUpMatrix),
  64041. Matrix.RotationAlignToRef(this._upVector, Vector3.UpReadOnly, this._upToYMatrix)
  64042. }
  64043. ,
  64044. Object.defineProperty(e.prototype, "angularSensibilityX", {
  64045. get: function() {
  64046. var i = this.inputs.attached.pointers;
  64047. return i ? i.angularSensibilityX : 0
  64048. },
  64049. set: function(i) {
  64050. var o = this.inputs.attached.pointers;
  64051. o && (o.angularSensibilityX = i)
  64052. },
  64053. enumerable: !1,
  64054. configurable: !0
  64055. }),
  64056. Object.defineProperty(e.prototype, "angularSensibilityY", {
  64057. get: function() {
  64058. var i = this.inputs.attached.pointers;
  64059. return i ? i.angularSensibilityY : 0
  64060. },
  64061. set: function(i) {
  64062. var o = this.inputs.attached.pointers;
  64063. o && (o.angularSensibilityY = i)
  64064. },
  64065. enumerable: !1,
  64066. configurable: !0
  64067. }),
  64068. Object.defineProperty(e.prototype, "pinchPrecision", {
  64069. get: function() {
  64070. var i = this.inputs.attached.pointers;
  64071. return i ? i.pinchPrecision : 0
  64072. },
  64073. set: function(i) {
  64074. var o = this.inputs.attached.pointers;
  64075. o && (o.pinchPrecision = i)
  64076. },
  64077. enumerable: !1,
  64078. configurable: !0
  64079. }),
  64080. Object.defineProperty(e.prototype, "pinchDeltaPercentage", {
  64081. get: function() {
  64082. var i = this.inputs.attached.pointers;
  64083. return i ? i.pinchDeltaPercentage : 0
  64084. },
  64085. set: function(i) {
  64086. var o = this.inputs.attached.pointers;
  64087. o && (o.pinchDeltaPercentage = i)
  64088. },
  64089. enumerable: !1,
  64090. configurable: !0
  64091. }),
  64092. Object.defineProperty(e.prototype, "useNaturalPinchZoom", {
  64093. get: function() {
  64094. var i = this.inputs.attached.pointers;
  64095. return i ? i.useNaturalPinchZoom : !1
  64096. },
  64097. set: function(i) {
  64098. var o = this.inputs.attached.pointers;
  64099. o && (o.useNaturalPinchZoom = i)
  64100. },
  64101. enumerable: !1,
  64102. configurable: !0
  64103. }),
  64104. Object.defineProperty(e.prototype, "panningSensibility", {
  64105. get: function() {
  64106. var i = this.inputs.attached.pointers;
  64107. return i ? i.panningSensibility : 0
  64108. },
  64109. set: function(i) {
  64110. var o = this.inputs.attached.pointers;
  64111. o && (o.panningSensibility = i)
  64112. },
  64113. enumerable: !1,
  64114. configurable: !0
  64115. }),
  64116. Object.defineProperty(e.prototype, "keysUp", {
  64117. get: function() {
  64118. var i = this.inputs.attached.keyboard;
  64119. return i ? i.keysUp : []
  64120. },
  64121. set: function(i) {
  64122. var o = this.inputs.attached.keyboard;
  64123. o && (o.keysUp = i)
  64124. },
  64125. enumerable: !1,
  64126. configurable: !0
  64127. }),
  64128. Object.defineProperty(e.prototype, "keysDown", {
  64129. get: function() {
  64130. var i = this.inputs.attached.keyboard;
  64131. return i ? i.keysDown : []
  64132. },
  64133. set: function(i) {
  64134. var o = this.inputs.attached.keyboard;
  64135. o && (o.keysDown = i)
  64136. },
  64137. enumerable: !1,
  64138. configurable: !0
  64139. }),
  64140. Object.defineProperty(e.prototype, "keysLeft", {
  64141. get: function() {
  64142. var i = this.inputs.attached.keyboard;
  64143. return i ? i.keysLeft : []
  64144. },
  64145. set: function(i) {
  64146. var o = this.inputs.attached.keyboard;
  64147. o && (o.keysLeft = i)
  64148. },
  64149. enumerable: !1,
  64150. configurable: !0
  64151. }),
  64152. Object.defineProperty(e.prototype, "keysRight", {
  64153. get: function() {
  64154. var i = this.inputs.attached.keyboard;
  64155. return i ? i.keysRight : []
  64156. },
  64157. set: function(i) {
  64158. var o = this.inputs.attached.keyboard;
  64159. o && (o.keysRight = i)
  64160. },
  64161. enumerable: !1,
  64162. configurable: !0
  64163. }),
  64164. Object.defineProperty(e.prototype, "wheelPrecision", {
  64165. get: function() {
  64166. var i = this.inputs.attached.mousewheel;
  64167. return i ? i.wheelPrecision : 0
  64168. },
  64169. set: function(i) {
  64170. var o = this.inputs.attached.mousewheel;
  64171. o && (o.wheelPrecision = i)
  64172. },
  64173. enumerable: !1,
  64174. configurable: !0
  64175. }),
  64176. Object.defineProperty(e.prototype, "zoomToMouseLocation", {
  64177. get: function() {
  64178. var i = this.inputs.attached.mousewheel;
  64179. return i ? i.zoomToMouseLocation : !1
  64180. },
  64181. set: function(i) {
  64182. var o = this.inputs.attached.mousewheel;
  64183. o && (o.zoomToMouseLocation = i)
  64184. },
  64185. enumerable: !1,
  64186. configurable: !0
  64187. }),
  64188. Object.defineProperty(e.prototype, "wheelDeltaPercentage", {
  64189. get: function() {
  64190. var i = this.inputs.attached.mousewheel;
  64191. return i ? i.wheelDeltaPercentage : 0
  64192. },
  64193. set: function(i) {
  64194. var o = this.inputs.attached.mousewheel;
  64195. o && (o.wheelDeltaPercentage = i)
  64196. },
  64197. enumerable: !1,
  64198. configurable: !0
  64199. }),
  64200. Object.defineProperty(e.prototype, "bouncingBehavior", {
  64201. get: function() {
  64202. return this._bouncingBehavior
  64203. },
  64204. enumerable: !1,
  64205. configurable: !0
  64206. }),
  64207. Object.defineProperty(e.prototype, "useBouncingBehavior", {
  64208. get: function() {
  64209. return this._bouncingBehavior != null
  64210. },
  64211. set: function(i) {
  64212. i !== this.useBouncingBehavior && (i ? (this._bouncingBehavior = new BouncingBehavior,
  64213. this.addBehavior(this._bouncingBehavior)) : this._bouncingBehavior && (this.removeBehavior(this._bouncingBehavior),
  64214. this._bouncingBehavior = null))
  64215. },
  64216. enumerable: !1,
  64217. configurable: !0
  64218. }),
  64219. Object.defineProperty(e.prototype, "framingBehavior", {
  64220. get: function() {
  64221. return this._framingBehavior
  64222. },
  64223. enumerable: !1,
  64224. configurable: !0
  64225. }),
  64226. Object.defineProperty(e.prototype, "useFramingBehavior", {
  64227. get: function() {
  64228. return this._framingBehavior != null
  64229. },
  64230. set: function(i) {
  64231. i !== this.useFramingBehavior && (i ? (this._framingBehavior = new FramingBehavior,
  64232. this.addBehavior(this._framingBehavior)) : this._framingBehavior && (this.removeBehavior(this._framingBehavior),
  64233. this._framingBehavior = null))
  64234. },
  64235. enumerable: !1,
  64236. configurable: !0
  64237. }),
  64238. Object.defineProperty(e.prototype, "autoRotationBehavior", {
  64239. get: function() {
  64240. return this._autoRotationBehavior
  64241. },
  64242. enumerable: !1,
  64243. configurable: !0
  64244. }),
  64245. Object.defineProperty(e.prototype, "useAutoRotationBehavior", {
  64246. get: function() {
  64247. return this._autoRotationBehavior != null
  64248. },
  64249. set: function(i) {
  64250. i !== this.useAutoRotationBehavior && (i ? (this._autoRotationBehavior = new AutoRotationBehavior,
  64251. this.addBehavior(this._autoRotationBehavior)) : this._autoRotationBehavior && (this.removeBehavior(this._autoRotationBehavior),
  64252. this._autoRotationBehavior = null))
  64253. },
  64254. enumerable: !1,
  64255. configurable: !0
  64256. }),
  64257. e.prototype._initCache = function() {
  64258. a.prototype._initCache.call(this),
  64259. this._cache._target = new Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),
  64260. this._cache.alpha = void 0,
  64261. this._cache.beta = void 0,
  64262. this._cache.radius = void 0,
  64263. this._cache.targetScreenOffset = Vector2.Zero()
  64264. }
  64265. ,
  64266. e.prototype._updateCache = function(i) {
  64267. i || a.prototype._updateCache.call(this),
  64268. this._cache._target.copyFrom(this._getTargetPosition()),
  64269. this._cache.alpha = this.alpha,
  64270. this._cache.beta = this.beta,
  64271. this._cache.radius = this.radius,
  64272. this._cache.targetScreenOffset.copyFrom(this.targetScreenOffset)
  64273. }
  64274. ,
  64275. e.prototype._getTargetPosition = function() {
  64276. if (this._targetHost && this._targetHost.getAbsolutePosition) {
  64277. var i = this._targetHost.getAbsolutePosition();
  64278. this._targetBoundingCenter ? i.addToRef(this._targetBoundingCenter, this._target) : this._target.copyFrom(i)
  64279. }
  64280. var o = this._getLockedTargetPosition();
  64281. return o || this._target
  64282. }
  64283. ,
  64284. e.prototype.storeState = function() {
  64285. return this._storedAlpha = this.alpha,
  64286. this._storedBeta = this.beta,
  64287. this._storedRadius = this.radius,
  64288. this._storedTarget = this._getTargetPosition().clone(),
  64289. this._storedTargetScreenOffset = this.targetScreenOffset.clone(),
  64290. a.prototype.storeState.call(this)
  64291. }
  64292. ,
  64293. e.prototype._restoreStateValues = function() {
  64294. return a.prototype._restoreStateValues.call(this) ? (this.setTarget(this._storedTarget.clone()),
  64295. this.alpha = this._storedAlpha,
  64296. this.beta = this._storedBeta,
  64297. this.radius = this._storedRadius,
  64298. this.targetScreenOffset = this._storedTargetScreenOffset.clone(),
  64299. this.inertialAlphaOffset = 0,
  64300. this.inertialBetaOffset = 0,
  64301. this.inertialRadiusOffset = 0,
  64302. this.inertialPanningX = 0,
  64303. this.inertialPanningY = 0,
  64304. !0) : !1
  64305. }
  64306. ,
  64307. e.prototype._isSynchronizedViewMatrix = function() {
  64308. return a.prototype._isSynchronizedViewMatrix.call(this) ? this._cache._target.equals(this._getTargetPosition()) && this._cache.alpha === this.alpha && this._cache.beta === this.beta && this._cache.radius === this.radius && this._cache.targetScreenOffset.equals(this.targetScreenOffset) : !1
  64309. }
  64310. ,
  64311. e.prototype.attachControl = function(i, o, s, c) {
  64312. var d = this;
  64313. s === void 0 && (s = !0),
  64314. c === void 0 && (c = 2),
  64315. o = Tools.BackCompatCameraNoPreventDefault(arguments),
  64316. this._useCtrlForPanning = s,
  64317. this._panningMouseButton = c,
  64318. typeof arguments[0] == "boolean" && (arguments.length > 1 && (this._useCtrlForPanning = arguments[1]),
  64319. arguments.length > 2 && (this._panningMouseButton = arguments[2])),
  64320. this.inputs.attachElement(o),
  64321. this._reset = function() {
  64322. d.inertialAlphaOffset = 0,
  64323. d.inertialBetaOffset = 0,
  64324. d.inertialRadiusOffset = 0,
  64325. d.inertialPanningX = 0,
  64326. d.inertialPanningY = 0
  64327. }
  64328. }
  64329. ,
  64330. e.prototype.detachControl = function(i) {
  64331. this.inputs.detachElement(),
  64332. this._reset && this._reset()
  64333. }
  64334. ,
  64335. e.prototype._checkInputs = function() {
  64336. if (!this._collisionTriggered) {
  64337. if (this.inputs.checkInputs(),
  64338. this.inertialAlphaOffset !== 0 || this.inertialBetaOffset !== 0 || this.inertialRadiusOffset !== 0) {
  64339. var i = this.inertialAlphaOffset;
  64340. this.beta <= 0 && (i *= -1),
  64341. this.getScene().useRightHandedSystem && (i *= -1),
  64342. this.parent && this.parent._getWorldMatrixDeterminant() < 0 && (i *= -1),
  64343. this.alpha += i,
  64344. this.beta += this.inertialBetaOffset,
  64345. this.radius -= this.inertialRadiusOffset,
  64346. this.inertialAlphaOffset *= this.inertia,
  64347. this.inertialBetaOffset *= this.inertia,
  64348. this.inertialRadiusOffset *= this.inertia,
  64349. Math.abs(this.inertialAlphaOffset) < Epsilon && (this.inertialAlphaOffset = 0),
  64350. Math.abs(this.inertialBetaOffset) < Epsilon && (this.inertialBetaOffset = 0),
  64351. Math.abs(this.inertialRadiusOffset) < this.speed * Epsilon && (this.inertialRadiusOffset = 0)
  64352. }
  64353. if (this.inertialPanningX !== 0 || this.inertialPanningY !== 0) {
  64354. var o = new Vector3(this.inertialPanningX,this.inertialPanningY,this.inertialPanningY);
  64355. if (this._viewMatrix.invertToRef(this._cameraTransformMatrix),
  64356. o.multiplyInPlace(this.panningAxis),
  64357. Vector3.TransformNormalToRef(o, this._cameraTransformMatrix, this._transformedDirection),
  64358. this.mapPanning && (this._transformedDirection.y = 0),
  64359. !this._targetHost)
  64360. if (this.panningDistanceLimit) {
  64361. this._transformedDirection.addInPlace(this._target);
  64362. var s = Vector3.DistanceSquared(this._transformedDirection, this.panningOriginTarget);
  64363. s <= this.panningDistanceLimit * this.panningDistanceLimit && this._target.copyFrom(this._transformedDirection)
  64364. } else
  64365. this._target.addInPlace(this._transformedDirection);
  64366. this.inertialPanningX *= this.panningInertia,
  64367. this.inertialPanningY *= this.panningInertia,
  64368. Math.abs(this.inertialPanningX) < this.speed * Epsilon && (this.inertialPanningX = 0),
  64369. Math.abs(this.inertialPanningY) < this.speed * Epsilon && (this.inertialPanningY = 0)
  64370. }
  64371. this._checkLimits(),
  64372. a.prototype._checkInputs.call(this)
  64373. }
  64374. }
  64375. ,
  64376. e.prototype._checkLimits = function() {
  64377. this.lowerBetaLimit === null || this.lowerBetaLimit === void 0 ? this.allowUpsideDown && this.beta > Math.PI && (this.beta = this.beta - 2 * Math.PI) : this.beta < this.lowerBetaLimit && (this.beta = this.lowerBetaLimit),
  64378. this.upperBetaLimit === null || this.upperBetaLimit === void 0 ? this.allowUpsideDown && this.beta < -Math.PI && (this.beta = this.beta + 2 * Math.PI) : this.beta > this.upperBetaLimit && (this.beta = this.upperBetaLimit),
  64379. this.lowerAlphaLimit !== null && this.alpha < this.lowerAlphaLimit && (this.alpha = this.lowerAlphaLimit),
  64380. this.upperAlphaLimit !== null && this.alpha > this.upperAlphaLimit && (this.alpha = this.upperAlphaLimit),
  64381. this.lowerRadiusLimit !== null && this.radius < this.lowerRadiusLimit && (this.radius = this.lowerRadiusLimit,
  64382. this.inertialRadiusOffset = 0),
  64383. this.upperRadiusLimit !== null && this.radius > this.upperRadiusLimit && (this.radius = this.upperRadiusLimit,
  64384. this.inertialRadiusOffset = 0)
  64385. }
  64386. ,
  64387. e.prototype.rebuildAnglesAndRadius = function() {
  64388. this._position.subtractToRef(this._getTargetPosition(), this._computationVector),
  64389. (this._upVector.x !== 0 || this._upVector.y !== 1 || this._upVector.z !== 0) && Vector3.TransformCoordinatesToRef(this._computationVector, this._upToYMatrix, this._computationVector),
  64390. this.radius = this._computationVector.length(),
  64391. this.radius === 0 && (this.radius = 1e-4);
  64392. var i = this.alpha;
  64393. this._computationVector.x === 0 && this._computationVector.z === 0 ? this.alpha = Math.PI / 2 : this.alpha = Math.acos(this._computationVector.x / Math.sqrt(Math.pow(this._computationVector.x, 2) + Math.pow(this._computationVector.z, 2))),
  64394. this._computationVector.z < 0 && (this.alpha = 2 * Math.PI - this.alpha);
  64395. var o = Math.round((i - this.alpha) / (2 * Math.PI));
  64396. this.alpha += o * 2 * Math.PI,
  64397. this.beta = Math.acos(this._computationVector.y / this.radius),
  64398. this._checkLimits()
  64399. }
  64400. ,
  64401. e.prototype.setPosition = function(i) {
  64402. this._position.equals(i) || (this._position.copyFrom(i),
  64403. this.rebuildAnglesAndRadius())
  64404. }
  64405. ,
  64406. e.prototype.setTarget = function(i, o, s) {
  64407. if (o === void 0 && (o = !1),
  64408. s === void 0 && (s = !1),
  64409. i.getBoundingInfo)
  64410. o ? this._targetBoundingCenter = i.getBoundingInfo().boundingBox.centerWorld.clone() : this._targetBoundingCenter = null,
  64411. i.computeWorldMatrix(),
  64412. this._targetHost = i,
  64413. this._target = this._getTargetPosition(),
  64414. this.onMeshTargetChangedObservable.notifyObservers(this._targetHost);
  64415. else {
  64416. var c = i
  64417. , d = this._getTargetPosition();
  64418. if (d && !s && d.equals(c))
  64419. return;
  64420. this._targetHost = null,
  64421. this._target = c,
  64422. this._targetBoundingCenter = null,
  64423. this.onMeshTargetChangedObservable.notifyObservers(null)
  64424. }
  64425. this.rebuildAnglesAndRadius()
  64426. }
  64427. ,
  64428. e.prototype._getViewMatrix = function() {
  64429. var i = Math.cos(this.alpha)
  64430. , o = Math.sin(this.alpha)
  64431. , s = Math.cos(this.beta)
  64432. , c = Math.sin(this.beta);
  64433. c === 0 && (c = 1e-4),
  64434. this.radius === 0 && (this.radius = 1e-4);
  64435. var d = this._getTargetPosition();
  64436. if (this._computationVector.copyFromFloats(this.radius * i * c, this.radius * s, this.radius * o * c),
  64437. (this._upVector.x !== 0 || this._upVector.y !== 1 || this._upVector.z !== 0) && Vector3.TransformCoordinatesToRef(this._computationVector, this._YToUpMatrix, this._computationVector),
  64438. d.addToRef(this._computationVector, this._newPosition),
  64439. this.getScene().collisionsEnabled && this.checkCollisions) {
  64440. var _ = this.getScene().collisionCoordinator;
  64441. this._collider || (this._collider = _.createCollider()),
  64442. this._collider._radius = this.collisionRadius,
  64443. this._newPosition.subtractToRef(this._position, this._collisionVelocity),
  64444. this._collisionTriggered = !0,
  64445. _.getNewPosition(this._position, this._collisionVelocity, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId)
  64446. } else {
  64447. this._position.copyFrom(this._newPosition);
  64448. var b = this.upVector;
  64449. this.allowUpsideDown && c < 0 && (b = b.negate()),
  64450. this._computeViewMatrix(this._position, d, b),
  64451. this._viewMatrix.addAtIndex(12, this.targetScreenOffset.x),
  64452. this._viewMatrix.addAtIndex(13, this.targetScreenOffset.y)
  64453. }
  64454. return this._currentTarget = d,
  64455. this._viewMatrix
  64456. }
  64457. ,
  64458. e.prototype.zoomOn = function(i, o) {
  64459. o === void 0 && (o = !1),
  64460. i = i || this.getScene().meshes;
  64461. var s = Mesh.MinMax(i)
  64462. , c = Vector3.Distance(s.min, s.max);
  64463. this.radius = c * this.zoomOnFactor,
  64464. this.focusOn({
  64465. min: s.min,
  64466. max: s.max,
  64467. distance: c
  64468. }, o)
  64469. }
  64470. ,
  64471. e.prototype.focusOn = function(i, o) {
  64472. o === void 0 && (o = !1);
  64473. var s, c;
  64474. if (i.min === void 0) {
  64475. var d = i || this.getScene().meshes;
  64476. s = Mesh.MinMax(d),
  64477. c = Vector3.Distance(s.min, s.max)
  64478. } else {
  64479. var _ = i;
  64480. s = _,
  64481. c = _.distance
  64482. }
  64483. this._target = Mesh.Center(s),
  64484. o || (this.maxZ = c * 2)
  64485. }
  64486. ,
  64487. e.prototype.createRigCamera = function(i, o) {
  64488. var s = 0;
  64489. switch (this.cameraRigMode) {
  64490. case Camera$1.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  64491. case Camera$1.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  64492. case Camera$1.RIG_MODE_STEREOSCOPIC_OVERUNDER:
  64493. case Camera$1.RIG_MODE_STEREOSCOPIC_INTERLACED:
  64494. case Camera$1.RIG_MODE_VR:
  64495. s = this._cameraRigParams.stereoHalfAngle * (o === 0 ? 1 : -1);
  64496. break;
  64497. case Camera$1.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  64498. s = this._cameraRigParams.stereoHalfAngle * (o === 0 ? -1 : 1);
  64499. break
  64500. }
  64501. var c = new e(i,this.alpha + s,this.beta,this.radius,this._target,this.getScene());
  64502. return c._cameraRigParams = {},
  64503. c.isRigCamera = !0,
  64504. c.rigParent = this,
  64505. c.upVector = this.upVector,
  64506. c
  64507. }
  64508. ,
  64509. e.prototype._updateRigCameras = function() {
  64510. var i = this._rigCameras[0]
  64511. , o = this._rigCameras[1];
  64512. switch (i.beta = o.beta = this.beta,
  64513. this.cameraRigMode) {
  64514. case Camera$1.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  64515. case Camera$1.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  64516. case Camera$1.RIG_MODE_STEREOSCOPIC_OVERUNDER:
  64517. case Camera$1.RIG_MODE_STEREOSCOPIC_INTERLACED:
  64518. case Camera$1.RIG_MODE_VR:
  64519. i.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle,
  64520. o.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
  64521. break;
  64522. case Camera$1.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  64523. i.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle,
  64524. o.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle;
  64525. break
  64526. }
  64527. a.prototype._updateRigCameras.call(this)
  64528. }
  64529. ,
  64530. e.prototype.dispose = function() {
  64531. this.inputs.clear(),
  64532. a.prototype.dispose.call(this)
  64533. }
  64534. ,
  64535. e.prototype.getClassName = function() {
  64536. return "ArcRotateCamera"
  64537. }
  64538. ,
  64539. __decorate([serialize()], e.prototype, "alpha", void 0),
  64540. __decorate([serialize()], e.prototype, "beta", void 0),
  64541. __decorate([serialize()], e.prototype, "radius", void 0),
  64542. __decorate([serializeAsVector3("target")], e.prototype, "_target", void 0),
  64543. __decorate([serializeAsMeshReference("targetHost")], e.prototype, "_targetHost", void 0),
  64544. __decorate([serialize()], e.prototype, "inertialAlphaOffset", void 0),
  64545. __decorate([serialize()], e.prototype, "inertialBetaOffset", void 0),
  64546. __decorate([serialize()], e.prototype, "inertialRadiusOffset", void 0),
  64547. __decorate([serialize()], e.prototype, "lowerAlphaLimit", void 0),
  64548. __decorate([serialize()], e.prototype, "upperAlphaLimit", void 0),
  64549. __decorate([serialize()], e.prototype, "lowerBetaLimit", void 0),
  64550. __decorate([serialize()], e.prototype, "upperBetaLimit", void 0),
  64551. __decorate([serialize()], e.prototype, "lowerRadiusLimit", void 0),
  64552. __decorate([serialize()], e.prototype, "upperRadiusLimit", void 0),
  64553. __decorate([serialize()], e.prototype, "inertialPanningX", void 0),
  64554. __decorate([serialize()], e.prototype, "inertialPanningY", void 0),
  64555. __decorate([serialize()], e.prototype, "pinchToPanMaxDistance", void 0),
  64556. __decorate([serialize()], e.prototype, "panningDistanceLimit", void 0),
  64557. __decorate([serializeAsVector3()], e.prototype, "panningOriginTarget", void 0),
  64558. __decorate([serialize()], e.prototype, "panningInertia", void 0),
  64559. __decorate([serialize()], e.prototype, "zoomToMouseLocation", null),
  64560. __decorate([serialize()], e.prototype, "zoomOnFactor", void 0),
  64561. __decorate([serialize()], e.prototype, "targetScreenOffset", void 0),
  64562. __decorate([serialize()], e.prototype, "allowUpsideDown", void 0),
  64563. __decorate([serialize()], e.prototype, "useInputToRestoreState", void 0),
  64564. e
  64565. }(TargetCamera)
  64566. , FreeCameraKeyboardMoveInput = function() {
  64567. function a() {
  64568. this.keysUp = [38],
  64569. this.keysUpward = [33],
  64570. this.keysDown = [40],
  64571. this.keysDownward = [34],
  64572. this.keysLeft = [37],
  64573. this.keysRight = [39],
  64574. this.rotationSpeed = .5,
  64575. this.keysRotateLeft = [],
  64576. this.keysRotateRight = [],
  64577. this._keys = new Array
  64578. }
  64579. return a.prototype.attachControl = function(e) {
  64580. var i = this;
  64581. e = Tools.BackCompatCameraNoPreventDefault(arguments),
  64582. !this._onCanvasBlurObserver && (this._scene = this.camera.getScene(),
  64583. this._engine = this._scene.getEngine(),
  64584. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function() {
  64585. i._keys = []
  64586. }),
  64587. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function(o) {
  64588. var s = o.event;
  64589. if (!s.metaKey) {
  64590. if (o.type === KeyboardEventTypes.KEYDOWN) {
  64591. if (i.keysUp.indexOf(s.keyCode) !== -1 || i.keysDown.indexOf(s.keyCode) !== -1 || i.keysLeft.indexOf(s.keyCode) !== -1 || i.keysRight.indexOf(s.keyCode) !== -1 || i.keysUpward.indexOf(s.keyCode) !== -1 || i.keysDownward.indexOf(s.keyCode) !== -1 || i.keysRotateLeft.indexOf(s.keyCode) !== -1 || i.keysRotateRight.indexOf(s.keyCode) !== -1) {
  64592. var c = i._keys.indexOf(s.keyCode);
  64593. c === -1 && i._keys.push(s.keyCode),
  64594. e || s.preventDefault()
  64595. }
  64596. } else if (i.keysUp.indexOf(s.keyCode) !== -1 || i.keysDown.indexOf(s.keyCode) !== -1 || i.keysLeft.indexOf(s.keyCode) !== -1 || i.keysRight.indexOf(s.keyCode) !== -1 || i.keysUpward.indexOf(s.keyCode) !== -1 || i.keysDownward.indexOf(s.keyCode) !== -1 || i.keysRotateLeft.indexOf(s.keyCode) !== -1 || i.keysRotateRight.indexOf(s.keyCode) !== -1) {
  64597. var c = i._keys.indexOf(s.keyCode);
  64598. c >= 0 && i._keys.splice(c, 1),
  64599. e || s.preventDefault()
  64600. }
  64601. }
  64602. }))
  64603. }
  64604. ,
  64605. a.prototype.detachControl = function(e) {
  64606. this._scene && (this._onKeyboardObserver && this._scene.onKeyboardObservable.remove(this._onKeyboardObserver),
  64607. this._onCanvasBlurObserver && this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver),
  64608. this._onKeyboardObserver = null,
  64609. this._onCanvasBlurObserver = null),
  64610. this._keys = []
  64611. }
  64612. ,
  64613. a.prototype.checkInputs = function() {
  64614. if (this._onKeyboardObserver)
  64615. for (var e = this.camera, i = 0; i < this._keys.length; i++) {
  64616. var o = this._keys[i]
  64617. , s = e._computeLocalCameraSpeed();
  64618. this.keysLeft.indexOf(o) !== -1 ? e._localDirection.copyFromFloats(-s, 0, 0) : this.keysUp.indexOf(o) !== -1 ? e._localDirection.copyFromFloats(0, 0, s) : this.keysRight.indexOf(o) !== -1 ? e._localDirection.copyFromFloats(s, 0, 0) : this.keysDown.indexOf(o) !== -1 ? e._localDirection.copyFromFloats(0, 0, -s) : this.keysUpward.indexOf(o) !== -1 ? e._localDirection.copyFromFloats(0, s, 0) : this.keysDownward.indexOf(o) !== -1 ? e._localDirection.copyFromFloats(0, -s, 0) : this.keysRotateLeft.indexOf(o) !== -1 ? (e._localDirection.copyFromFloats(0, 0, 0),
  64619. e.cameraRotation.y -= this._getLocalRotation()) : this.keysRotateRight.indexOf(o) !== -1 && (e._localDirection.copyFromFloats(0, 0, 0),
  64620. e.cameraRotation.y += this._getLocalRotation()),
  64621. e.getScene().useRightHandedSystem && (e._localDirection.z *= -1),
  64622. e.getViewMatrix().invertToRef(e._cameraTransformMatrix),
  64623. Vector3.TransformNormalToRef(e._localDirection, e._cameraTransformMatrix, e._transformedDirection),
  64624. e.cameraDirection.addInPlace(e._transformedDirection)
  64625. }
  64626. }
  64627. ,
  64628. a.prototype.getClassName = function() {
  64629. return "FreeCameraKeyboardMoveInput"
  64630. }
  64631. ,
  64632. a.prototype._onLostFocus = function() {
  64633. this._keys = []
  64634. }
  64635. ,
  64636. a.prototype.getSimpleName = function() {
  64637. return "keyboard"
  64638. }
  64639. ,
  64640. a.prototype._getLocalRotation = function() {
  64641. var e = this.rotationSpeed * this._engine.getDeltaTime() / 1e3;
  64642. return this.camera.getScene().useRightHandedSystem && (e *= -1),
  64643. this.camera.parent && this.camera.parent._getWorldMatrixDeterminant() < 0 && (e *= -1),
  64644. e
  64645. }
  64646. ,
  64647. __decorate([serialize()], a.prototype, "keysUp", void 0),
  64648. __decorate([serialize()], a.prototype, "keysUpward", void 0),
  64649. __decorate([serialize()], a.prototype, "keysDown", void 0),
  64650. __decorate([serialize()], a.prototype, "keysDownward", void 0),
  64651. __decorate([serialize()], a.prototype, "keysLeft", void 0),
  64652. __decorate([serialize()], a.prototype, "keysRight", void 0),
  64653. __decorate([serialize()], a.prototype, "rotationSpeed", void 0),
  64654. __decorate([serialize()], a.prototype, "keysRotateLeft", void 0),
  64655. __decorate([serialize()], a.prototype, "keysRotateRight", void 0),
  64656. a
  64657. }();
  64658. CameraInputTypes.FreeCameraKeyboardMoveInput = FreeCameraKeyboardMoveInput;
  64659. var FreeCameraMouseInput = function() {
  64660. function a(e) {
  64661. e === void 0 && (e = !0),
  64662. this.touchEnabled = e,
  64663. this.buttons = [0, 1, 2],
  64664. this.angularSensibility = 2e3,
  64665. this.previousPosition = null,
  64666. this.onPointerMovedObservable = new Observable,
  64667. this._allowCameraRotation = !0,
  64668. this._currentActiveButton = -1
  64669. }
  64670. return a.prototype.attachControl = function(e) {
  64671. var i = this;
  64672. e = Tools.BackCompatCameraNoPreventDefault(arguments);
  64673. var o = this.camera.getEngine()
  64674. , s = o.getInputElement();
  64675. this._pointerInput || (this._pointerInput = function(c) {
  64676. var d = c.event
  64677. , _ = d.pointerType === "touch";
  64678. if (!o.isInVRExclusivePointerMode && !(!i.touchEnabled && _) && !(c.type !== PointerEventTypes.POINTERMOVE && i.buttons.indexOf(d.button) === -1)) {
  64679. var b = d.srcElement || d.target;
  64680. if (c.type === PointerEventTypes.POINTERDOWN && (i._currentActiveButton === -1 || _)) {
  64681. try {
  64682. b == null || b.setPointerCapture(d.pointerId)
  64683. } catch {}
  64684. i._currentActiveButton === -1 && (i._currentActiveButton = d.button),
  64685. i.previousPosition = {
  64686. x: d.clientX,
  64687. y: d.clientY
  64688. },
  64689. e || (d.preventDefault(),
  64690. s && s.focus()),
  64691. o.isPointerLock && i._onMouseMove && i._onMouseMove(c.event)
  64692. } else if (c.type === PointerEventTypes.POINTERUP && (i._currentActiveButton === d.button || _)) {
  64693. try {
  64694. b == null || b.releasePointerCapture(d.pointerId)
  64695. } catch {}
  64696. i._currentActiveButton = -1,
  64697. i.previousPosition = null,
  64698. e || d.preventDefault()
  64699. } else if (c.type === PointerEventTypes.POINTERMOVE) {
  64700. if (o.isPointerLock && i._onMouseMove)
  64701. i._onMouseMove(c.event);
  64702. else if (i.previousPosition) {
  64703. var k = d.clientX - i.previousPosition.x
  64704. , j = d.clientY - i.previousPosition.y;
  64705. i.camera.getScene().useRightHandedSystem && (k *= -1),
  64706. i.camera.parent && i.camera.parent._getWorldMatrixDeterminant() < 0 && (k *= -1),
  64707. i._allowCameraRotation && (i.camera.cameraRotation.y += k / i.angularSensibility,
  64708. i.camera.cameraRotation.x += j / i.angularSensibility),
  64709. i.onPointerMovedObservable.notifyObservers({
  64710. offsetX: k,
  64711. offsetY: j
  64712. }),
  64713. i.previousPosition = {
  64714. x: d.clientX,
  64715. y: d.clientY
  64716. },
  64717. e || d.preventDefault()
  64718. }
  64719. }
  64720. }
  64721. }
  64722. ),
  64723. this._onMouseMove = function(c) {
  64724. if (!!o.isPointerLock && !o.isInVRExclusivePointerMode) {
  64725. var d = c.movementX || c.mozMovementX || c.webkitMovementX || c.msMovementX || 0;
  64726. i.camera.getScene().useRightHandedSystem && (d *= -1),
  64727. i.camera.parent && i.camera.parent._getWorldMatrixDeterminant() < 0 && (d *= -1),
  64728. i.camera.cameraRotation.y += d / i.angularSensibility;
  64729. var _ = c.movementY || c.mozMovementY || c.webkitMovementY || c.msMovementY || 0;
  64730. i.camera.cameraRotation.x += _ / i.angularSensibility,
  64731. i.previousPosition = null,
  64732. e || c.preventDefault()
  64733. }
  64734. }
  64735. ,
  64736. this._observer = this.camera.getScene().onPointerObservable.add(this._pointerInput, PointerEventTypes.POINTERDOWN | PointerEventTypes.POINTERUP | PointerEventTypes.POINTERMOVE),
  64737. s && s.addEventListener("contextmenu", this.onContextMenu.bind(this), !1)
  64738. }
  64739. ,
  64740. a.prototype.onContextMenu = function(e) {
  64741. e.preventDefault()
  64742. }
  64743. ,
  64744. a.prototype.detachControl = function(e) {
  64745. if (this._observer) {
  64746. if (this.camera.getScene().onPointerObservable.remove(this._observer),
  64747. this.onContextMenu) {
  64748. var i = this.camera.getEngine()
  64749. , o = i.getInputElement();
  64750. o && o.removeEventListener("contextmenu", this.onContextMenu)
  64751. }
  64752. this.onPointerMovedObservable && this.onPointerMovedObservable.clear(),
  64753. this._observer = null,
  64754. this._onMouseMove = null,
  64755. this.previousPosition = null
  64756. }
  64757. }
  64758. ,
  64759. a.prototype.getClassName = function() {
  64760. return "FreeCameraMouseInput"
  64761. }
  64762. ,
  64763. a.prototype.getSimpleName = function() {
  64764. return "mouse"
  64765. }
  64766. ,
  64767. __decorate([serialize()], a.prototype, "buttons", void 0),
  64768. __decorate([serialize()], a.prototype, "angularSensibility", void 0),
  64769. a
  64770. }();
  64771. CameraInputTypes.FreeCameraMouseInput = FreeCameraMouseInput;
  64772. var BaseCameraMouseWheelInput = function() {
  64773. function a() {
  64774. this.wheelPrecisionX = 3,
  64775. this.wheelPrecisionY = 3,
  64776. this.wheelPrecisionZ = 3,
  64777. this.onChangedObservable = new Observable,
  64778. this._wheelDeltaX = 0,
  64779. this._wheelDeltaY = 0,
  64780. this._wheelDeltaZ = 0,
  64781. this._ffMultiplier = 12,
  64782. this._normalize = 120
  64783. }
  64784. return a.prototype.attachControl = function(e) {
  64785. var i = this;
  64786. e = Tools.BackCompatCameraNoPreventDefault(arguments),
  64787. this._wheel = function(o) {
  64788. if (o.type === PointerEventTypes.POINTERWHEEL) {
  64789. var s = o.event
  64790. , c = s.deltaMode === EventConstants.DOM_DELTA_LINE ? i._ffMultiplier : 1;
  64791. s.deltaY !== void 0 ? (i._wheelDeltaX += i.wheelPrecisionX * c * s.deltaX / i._normalize,
  64792. i._wheelDeltaY -= i.wheelPrecisionY * c * s.deltaY / i._normalize,
  64793. i._wheelDeltaZ += i.wheelPrecisionZ * c * s.deltaZ / i._normalize) : s.wheelDeltaY !== void 0 ? (i._wheelDeltaX += i.wheelPrecisionX * c * s.wheelDeltaX / i._normalize,
  64794. i._wheelDeltaY -= i.wheelPrecisionY * c * s.wheelDeltaY / i._normalize,
  64795. i._wheelDeltaZ += i.wheelPrecisionZ * c * s.wheelDeltaZ / i._normalize) : s.wheelDelta && (i._wheelDeltaY -= i.wheelPrecisionY * s.wheelDelta / i._normalize),
  64796. s.preventDefault && (e || s.preventDefault())
  64797. }
  64798. }
  64799. ,
  64800. this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, PointerEventTypes.POINTERWHEEL)
  64801. }
  64802. ,
  64803. a.prototype.detachControl = function(e) {
  64804. this._observer && (this.camera.getScene().onPointerObservable.remove(this._observer),
  64805. this._observer = null,
  64806. this._wheel = null),
  64807. this.onChangedObservable && this.onChangedObservable.clear()
  64808. }
  64809. ,
  64810. a.prototype.checkInputs = function() {
  64811. this.onChangedObservable.notifyObservers({
  64812. wheelDeltaX: this._wheelDeltaX,
  64813. wheelDeltaY: this._wheelDeltaY,
  64814. wheelDeltaZ: this._wheelDeltaZ
  64815. }),
  64816. this._wheelDeltaX = 0,
  64817. this._wheelDeltaY = 0,
  64818. this._wheelDeltaZ = 0
  64819. }
  64820. ,
  64821. a.prototype.getClassName = function() {
  64822. return "BaseCameraMouseWheelInput"
  64823. }
  64824. ,
  64825. a.prototype.getSimpleName = function() {
  64826. return "mousewheel"
  64827. }
  64828. ,
  64829. __decorate([serialize()], a.prototype, "wheelPrecisionX", void 0),
  64830. __decorate([serialize()], a.prototype, "wheelPrecisionY", void 0),
  64831. __decorate([serialize()], a.prototype, "wheelPrecisionZ", void 0),
  64832. a
  64833. }(), _CameraProperty;
  64834. (function(a) {
  64835. a[a.MoveRelative = 0] = "MoveRelative",
  64836. a[a.RotateRelative = 1] = "RotateRelative",
  64837. a[a.MoveScene = 2] = "MoveScene"
  64838. }
  64839. )(_CameraProperty || (_CameraProperty = {}));
  64840. var FreeCameraMouseWheelInput = function(a) {
  64841. __extends(e, a);
  64842. function e() {
  64843. var i = a !== null && a.apply(this, arguments) || this;
  64844. return i._moveRelative = Vector3.Zero(),
  64845. i._rotateRelative = Vector3.Zero(),
  64846. i._moveScene = Vector3.Zero(),
  64847. i._wheelXAction = _CameraProperty.MoveRelative,
  64848. i._wheelXActionCoordinate = Coordinate.X,
  64849. i._wheelYAction = _CameraProperty.MoveRelative,
  64850. i._wheelYActionCoordinate = Coordinate.Z,
  64851. i._wheelZAction = null,
  64852. i._wheelZActionCoordinate = null,
  64853. i
  64854. }
  64855. return e.prototype.getClassName = function() {
  64856. return "FreeCameraMouseWheelInput"
  64857. }
  64858. ,
  64859. Object.defineProperty(e.prototype, "wheelXMoveRelative", {
  64860. get: function() {
  64861. return this._wheelXAction !== _CameraProperty.MoveRelative ? null : this._wheelXActionCoordinate
  64862. },
  64863. set: function(i) {
  64864. i === null && this._wheelXAction !== _CameraProperty.MoveRelative || (this._wheelXAction = _CameraProperty.MoveRelative,
  64865. this._wheelXActionCoordinate = i)
  64866. },
  64867. enumerable: !1,
  64868. configurable: !0
  64869. }),
  64870. Object.defineProperty(e.prototype, "wheelYMoveRelative", {
  64871. get: function() {
  64872. return this._wheelYAction !== _CameraProperty.MoveRelative ? null : this._wheelYActionCoordinate
  64873. },
  64874. set: function(i) {
  64875. i === null && this._wheelYAction !== _CameraProperty.MoveRelative || (this._wheelYAction = _CameraProperty.MoveRelative,
  64876. this._wheelYActionCoordinate = i)
  64877. },
  64878. enumerable: !1,
  64879. configurable: !0
  64880. }),
  64881. Object.defineProperty(e.prototype, "wheelZMoveRelative", {
  64882. get: function() {
  64883. return this._wheelZAction !== _CameraProperty.MoveRelative ? null : this._wheelZActionCoordinate
  64884. },
  64885. set: function(i) {
  64886. i === null && this._wheelZAction !== _CameraProperty.MoveRelative || (this._wheelZAction = _CameraProperty.MoveRelative,
  64887. this._wheelZActionCoordinate = i)
  64888. },
  64889. enumerable: !1,
  64890. configurable: !0
  64891. }),
  64892. Object.defineProperty(e.prototype, "wheelXRotateRelative", {
  64893. get: function() {
  64894. return this._wheelXAction !== _CameraProperty.RotateRelative ? null : this._wheelXActionCoordinate
  64895. },
  64896. set: function(i) {
  64897. i === null && this._wheelXAction !== _CameraProperty.RotateRelative || (this._wheelXAction = _CameraProperty.RotateRelative,
  64898. this._wheelXActionCoordinate = i)
  64899. },
  64900. enumerable: !1,
  64901. configurable: !0
  64902. }),
  64903. Object.defineProperty(e.prototype, "wheelYRotateRelative", {
  64904. get: function() {
  64905. return this._wheelYAction !== _CameraProperty.RotateRelative ? null : this._wheelYActionCoordinate
  64906. },
  64907. set: function(i) {
  64908. i === null && this._wheelYAction !== _CameraProperty.RotateRelative || (this._wheelYAction = _CameraProperty.RotateRelative,
  64909. this._wheelYActionCoordinate = i)
  64910. },
  64911. enumerable: !1,
  64912. configurable: !0
  64913. }),
  64914. Object.defineProperty(e.prototype, "wheelZRotateRelative", {
  64915. get: function() {
  64916. return this._wheelZAction !== _CameraProperty.RotateRelative ? null : this._wheelZActionCoordinate
  64917. },
  64918. set: function(i) {
  64919. i === null && this._wheelZAction !== _CameraProperty.RotateRelative || (this._wheelZAction = _CameraProperty.RotateRelative,
  64920. this._wheelZActionCoordinate = i)
  64921. },
  64922. enumerable: !1,
  64923. configurable: !0
  64924. }),
  64925. Object.defineProperty(e.prototype, "wheelXMoveScene", {
  64926. get: function() {
  64927. return this._wheelXAction !== _CameraProperty.MoveScene ? null : this._wheelXActionCoordinate
  64928. },
  64929. set: function(i) {
  64930. i === null && this._wheelXAction !== _CameraProperty.MoveScene || (this._wheelXAction = _CameraProperty.MoveScene,
  64931. this._wheelXActionCoordinate = i)
  64932. },
  64933. enumerable: !1,
  64934. configurable: !0
  64935. }),
  64936. Object.defineProperty(e.prototype, "wheelYMoveScene", {
  64937. get: function() {
  64938. return this._wheelYAction !== _CameraProperty.MoveScene ? null : this._wheelYActionCoordinate
  64939. },
  64940. set: function(i) {
  64941. i === null && this._wheelYAction !== _CameraProperty.MoveScene || (this._wheelYAction = _CameraProperty.MoveScene,
  64942. this._wheelYActionCoordinate = i)
  64943. },
  64944. enumerable: !1,
  64945. configurable: !0
  64946. }),
  64947. Object.defineProperty(e.prototype, "wheelZMoveScene", {
  64948. get: function() {
  64949. return this._wheelZAction !== _CameraProperty.MoveScene ? null : this._wheelZActionCoordinate
  64950. },
  64951. set: function(i) {
  64952. i === null && this._wheelZAction !== _CameraProperty.MoveScene || (this._wheelZAction = _CameraProperty.MoveScene,
  64953. this._wheelZActionCoordinate = i)
  64954. },
  64955. enumerable: !1,
  64956. configurable: !0
  64957. }),
  64958. e.prototype.checkInputs = function() {
  64959. if (!(this._wheelDeltaX === 0 && this._wheelDeltaY === 0 && this._wheelDeltaZ == 0)) {
  64960. this._moveRelative.setAll(0),
  64961. this._rotateRelative.setAll(0),
  64962. this._moveScene.setAll(0),
  64963. this._updateCamera(),
  64964. this.camera.getScene().useRightHandedSystem && (this._moveRelative.z *= -1);
  64965. var i = Matrix.Zero();
  64966. this.camera.getViewMatrix().invertToRef(i);
  64967. var o = Vector3.Zero();
  64968. Vector3.TransformNormalToRef(this._moveRelative, i, o),
  64969. this.camera.cameraRotation.x += this._rotateRelative.x / 200,
  64970. this.camera.cameraRotation.y += this._rotateRelative.y / 200,
  64971. this.camera.cameraDirection.addInPlace(o),
  64972. this.camera.cameraDirection.addInPlace(this._moveScene),
  64973. a.prototype.checkInputs.call(this)
  64974. }
  64975. }
  64976. ,
  64977. e.prototype._updateCamera = function() {
  64978. this._updateCameraProperty(this._wheelDeltaX, this._wheelXAction, this._wheelXActionCoordinate),
  64979. this._updateCameraProperty(this._wheelDeltaY, this._wheelYAction, this._wheelYActionCoordinate),
  64980. this._updateCameraProperty(this._wheelDeltaZ, this._wheelZAction, this._wheelZActionCoordinate)
  64981. }
  64982. ,
  64983. e.prototype._updateCameraProperty = function(i, o, s) {
  64984. if (i !== 0 && !(o === null || s === null)) {
  64985. var c = null;
  64986. switch (o) {
  64987. case _CameraProperty.MoveRelative:
  64988. c = this._moveRelative;
  64989. break;
  64990. case _CameraProperty.RotateRelative:
  64991. c = this._rotateRelative;
  64992. break;
  64993. case _CameraProperty.MoveScene:
  64994. c = this._moveScene;
  64995. break
  64996. }
  64997. switch (s) {
  64998. case Coordinate.X:
  64999. c.set(i, 0, 0);
  65000. break;
  65001. case Coordinate.Y:
  65002. c.set(0, i, 0);
  65003. break;
  65004. case Coordinate.Z:
  65005. c.set(0, 0, i);
  65006. break
  65007. }
  65008. }
  65009. }
  65010. ,
  65011. __decorate([serialize()], e.prototype, "wheelXMoveRelative", null),
  65012. __decorate([serialize()], e.prototype, "wheelYMoveRelative", null),
  65013. __decorate([serialize()], e.prototype, "wheelZMoveRelative", null),
  65014. __decorate([serialize()], e.prototype, "wheelXRotateRelative", null),
  65015. __decorate([serialize()], e.prototype, "wheelYRotateRelative", null),
  65016. __decorate([serialize()], e.prototype, "wheelZRotateRelative", null),
  65017. __decorate([serialize()], e.prototype, "wheelXMoveScene", null),
  65018. __decorate([serialize()], e.prototype, "wheelYMoveScene", null),
  65019. __decorate([serialize()], e.prototype, "wheelZMoveScene", null),
  65020. e
  65021. }(BaseCameraMouseWheelInput);
  65022. CameraInputTypes.FreeCameraMouseWheelInput = FreeCameraMouseWheelInput;
  65023. var FreeCameraTouchInput = function() {
  65024. function a(e) {
  65025. e === void 0 && (e = !1),
  65026. this.allowMouse = e,
  65027. this.touchAngularSensibility = 2e5,
  65028. this.touchMoveSensibility = 250,
  65029. this.singleFingerRotate = !1,
  65030. this._offsetX = null,
  65031. this._offsetY = null,
  65032. this._pointerPressed = new Array
  65033. }
  65034. return a.prototype.attachControl = function(e) {
  65035. var i = this;
  65036. e = Tools.BackCompatCameraNoPreventDefault(arguments);
  65037. var o = null;
  65038. if (this._pointerInput === void 0 && (this._onLostFocus = function() {
  65039. i._offsetX = null,
  65040. i._offsetY = null
  65041. }
  65042. ,
  65043. this._pointerInput = function(d) {
  65044. var _ = d.event
  65045. , b = !i.camera.getEngine().hostInformation.isMobile && _ instanceof MouseEvent;
  65046. if (!(!i.allowMouse && (_.pointerType === "mouse" || b))) {
  65047. if (d.type === PointerEventTypes.POINTERDOWN) {
  65048. if (e || _.preventDefault(),
  65049. i._pointerPressed.push(_.pointerId),
  65050. i._pointerPressed.length !== 1)
  65051. return;
  65052. o = {
  65053. x: _.clientX,
  65054. y: _.clientY
  65055. }
  65056. } else if (d.type === PointerEventTypes.POINTERUP) {
  65057. e || _.preventDefault();
  65058. var k = i._pointerPressed.indexOf(_.pointerId);
  65059. if (k === -1 || (i._pointerPressed.splice(k, 1),
  65060. k != 0))
  65061. return;
  65062. o = null,
  65063. i._offsetX = null,
  65064. i._offsetY = null
  65065. } else if (d.type === PointerEventTypes.POINTERMOVE) {
  65066. if (e || _.preventDefault(),
  65067. !o)
  65068. return;
  65069. var k = i._pointerPressed.indexOf(_.pointerId);
  65070. if (k != 0)
  65071. return;
  65072. i._offsetX = _.clientX - o.x,
  65073. i._offsetY = -(_.clientY - o.y)
  65074. }
  65075. }
  65076. }
  65077. ),
  65078. this._observer = this.camera.getScene().onPointerObservable.add(this._pointerInput, PointerEventTypes.POINTERDOWN | PointerEventTypes.POINTERUP | PointerEventTypes.POINTERMOVE),
  65079. this._onLostFocus) {
  65080. var s = this.camera.getEngine()
  65081. , c = s.getInputElement();
  65082. c && c.addEventListener("blur", this._onLostFocus)
  65083. }
  65084. }
  65085. ,
  65086. a.prototype.detachControl = function(e) {
  65087. if (this._pointerInput) {
  65088. if (this._observer && (this.camera.getScene().onPointerObservable.remove(this._observer),
  65089. this._observer = null),
  65090. this._onLostFocus) {
  65091. var i = this.camera.getEngine()
  65092. , o = i.getInputElement();
  65093. o && o.removeEventListener("blur", this._onLostFocus),
  65094. this._onLostFocus = null
  65095. }
  65096. this._pointerPressed = [],
  65097. this._offsetX = null,
  65098. this._offsetY = null
  65099. }
  65100. }
  65101. ,
  65102. a.prototype.checkInputs = function() {
  65103. if (!(this._offsetX === null || this._offsetY === null) && !(this._offsetX === 0 && this._offsetY === 0)) {
  65104. var e = this.camera;
  65105. e.cameraRotation.y = this._offsetX / this.touchAngularSensibility;
  65106. var i = this.singleFingerRotate && this._pointerPressed.length === 1 || !this.singleFingerRotate && this._pointerPressed.length > 1;
  65107. if (i)
  65108. e.cameraRotation.x = -this._offsetY / this.touchAngularSensibility;
  65109. else {
  65110. var o = e._computeLocalCameraSpeed()
  65111. , s = new Vector3(0,0,o * this._offsetY / this.touchMoveSensibility);
  65112. Matrix.RotationYawPitchRollToRef(e.rotation.y, e.rotation.x, 0, e._cameraRotationMatrix),
  65113. e.cameraDirection.addInPlace(Vector3.TransformCoordinates(s, e._cameraRotationMatrix))
  65114. }
  65115. }
  65116. }
  65117. ,
  65118. a.prototype.getClassName = function() {
  65119. return "FreeCameraTouchInput"
  65120. }
  65121. ,
  65122. a.prototype.getSimpleName = function() {
  65123. return "touch"
  65124. }
  65125. ,
  65126. __decorate([serialize()], a.prototype, "touchAngularSensibility", void 0),
  65127. __decorate([serialize()], a.prototype, "touchMoveSensibility", void 0),
  65128. a
  65129. }();
  65130. CameraInputTypes.FreeCameraTouchInput = FreeCameraTouchInput;
  65131. var FreeCameraInputsManager = function(a) {
  65132. __extends(e, a);
  65133. function e(i) {
  65134. var o = a.call(this, i) || this;
  65135. return o._mouseInput = null,
  65136. o._mouseWheelInput = null,
  65137. o
  65138. }
  65139. return e.prototype.addKeyboard = function() {
  65140. return this.add(new FreeCameraKeyboardMoveInput),
  65141. this
  65142. }
  65143. ,
  65144. e.prototype.addMouse = function(i) {
  65145. return i === void 0 && (i = !0),
  65146. this._mouseInput || (this._mouseInput = new FreeCameraMouseInput(i),
  65147. this.add(this._mouseInput)),
  65148. this
  65149. }
  65150. ,
  65151. e.prototype.removeMouse = function() {
  65152. return this._mouseInput && this.remove(this._mouseInput),
  65153. this
  65154. }
  65155. ,
  65156. e.prototype.addMouseWheel = function() {
  65157. return this._mouseWheelInput || (this._mouseWheelInput = new FreeCameraMouseWheelInput,
  65158. this.add(this._mouseWheelInput)),
  65159. this
  65160. }
  65161. ,
  65162. e.prototype.removeMouseWheel = function() {
  65163. return this._mouseWheelInput && this.remove(this._mouseWheelInput),
  65164. this
  65165. }
  65166. ,
  65167. e.prototype.addTouch = function() {
  65168. return this.add(new FreeCameraTouchInput),
  65169. this
  65170. }
  65171. ,
  65172. e.prototype.clear = function() {
  65173. a.prototype.clear.call(this),
  65174. this._mouseInput = null
  65175. }
  65176. ,
  65177. e
  65178. }(CameraInputsManager)
  65179. , FreeCamera = function(a) {
  65180. __extends(e, a);
  65181. function e(i, o, s, c) {
  65182. c === void 0 && (c = !0);
  65183. var d = a.call(this, i, o, s, c) || this;
  65184. return d.ellipsoid = new Vector3(.5,1,.5),
  65185. d.ellipsoidOffset = new Vector3(0,0,0),
  65186. d.checkCollisions = !1,
  65187. d.applyGravity = !1,
  65188. d._needMoveForGravity = !1,
  65189. d._oldPosition = Vector3.Zero(),
  65190. d._diffPosition = Vector3.Zero(),
  65191. d._newPosition = Vector3.Zero(),
  65192. d._collisionMask = -1,
  65193. d._onCollisionPositionChange = function(_, b, k) {
  65194. k === void 0 && (k = null);
  65195. var j = function($) {
  65196. d._newPosition.copyFrom($),
  65197. d._newPosition.subtractToRef(d._oldPosition, d._diffPosition),
  65198. d._diffPosition.length() > Engine.CollisionsEpsilon && (d.position.addInPlace(d._diffPosition),
  65199. d.onCollide && k && d.onCollide(k))
  65200. };
  65201. j(b)
  65202. }
  65203. ,
  65204. d.inputs = new FreeCameraInputsManager(d),
  65205. d.inputs.addKeyboard().addMouse(),
  65206. d
  65207. }
  65208. return Object.defineProperty(e.prototype, "angularSensibility", {
  65209. get: function() {
  65210. var i = this.inputs.attached.mouse;
  65211. return i ? i.angularSensibility : 0
  65212. },
  65213. set: function(i) {
  65214. var o = this.inputs.attached.mouse;
  65215. o && (o.angularSensibility = i)
  65216. },
  65217. enumerable: !1,
  65218. configurable: !0
  65219. }),
  65220. Object.defineProperty(e.prototype, "keysUp", {
  65221. get: function() {
  65222. var i = this.inputs.attached.keyboard;
  65223. return i ? i.keysUp : []
  65224. },
  65225. set: function(i) {
  65226. var o = this.inputs.attached.keyboard;
  65227. o && (o.keysUp = i)
  65228. },
  65229. enumerable: !1,
  65230. configurable: !0
  65231. }),
  65232. Object.defineProperty(e.prototype, "keysUpward", {
  65233. get: function() {
  65234. var i = this.inputs.attached.keyboard;
  65235. return i ? i.keysUpward : []
  65236. },
  65237. set: function(i) {
  65238. var o = this.inputs.attached.keyboard;
  65239. o && (o.keysUpward = i)
  65240. },
  65241. enumerable: !1,
  65242. configurable: !0
  65243. }),
  65244. Object.defineProperty(e.prototype, "keysDown", {
  65245. get: function() {
  65246. var i = this.inputs.attached.keyboard;
  65247. return i ? i.keysDown : []
  65248. },
  65249. set: function(i) {
  65250. var o = this.inputs.attached.keyboard;
  65251. o && (o.keysDown = i)
  65252. },
  65253. enumerable: !1,
  65254. configurable: !0
  65255. }),
  65256. Object.defineProperty(e.prototype, "keysDownward", {
  65257. get: function() {
  65258. var i = this.inputs.attached.keyboard;
  65259. return i ? i.keysDownward : []
  65260. },
  65261. set: function(i) {
  65262. var o = this.inputs.attached.keyboard;
  65263. o && (o.keysDownward = i)
  65264. },
  65265. enumerable: !1,
  65266. configurable: !0
  65267. }),
  65268. Object.defineProperty(e.prototype, "keysLeft", {
  65269. get: function() {
  65270. var i = this.inputs.attached.keyboard;
  65271. return i ? i.keysLeft : []
  65272. },
  65273. set: function(i) {
  65274. var o = this.inputs.attached.keyboard;
  65275. o && (o.keysLeft = i)
  65276. },
  65277. enumerable: !1,
  65278. configurable: !0
  65279. }),
  65280. Object.defineProperty(e.prototype, "keysRight", {
  65281. get: function() {
  65282. var i = this.inputs.attached.keyboard;
  65283. return i ? i.keysRight : []
  65284. },
  65285. set: function(i) {
  65286. var o = this.inputs.attached.keyboard;
  65287. o && (o.keysRight = i)
  65288. },
  65289. enumerable: !1,
  65290. configurable: !0
  65291. }),
  65292. Object.defineProperty(e.prototype, "keysRotateLeft", {
  65293. get: function() {
  65294. var i = this.inputs.attached.keyboard;
  65295. return i ? i.keysRotateLeft : []
  65296. },
  65297. set: function(i) {
  65298. var o = this.inputs.attached.keyboard;
  65299. o && (o.keysRotateLeft = i)
  65300. },
  65301. enumerable: !1,
  65302. configurable: !0
  65303. }),
  65304. Object.defineProperty(e.prototype, "keysRotateRight", {
  65305. get: function() {
  65306. var i = this.inputs.attached.keyboard;
  65307. return i ? i.keysRotateRight : []
  65308. },
  65309. set: function(i) {
  65310. var o = this.inputs.attached.keyboard;
  65311. o && (o.keysRotateRight = i)
  65312. },
  65313. enumerable: !1,
  65314. configurable: !0
  65315. }),
  65316. e.prototype.attachControl = function(i, o) {
  65317. o = Tools.BackCompatCameraNoPreventDefault(arguments),
  65318. this.inputs.attachElement(o)
  65319. }
  65320. ,
  65321. e.prototype.detachControl = function(i) {
  65322. this.inputs.detachElement(),
  65323. this.cameraDirection = new Vector3(0,0,0),
  65324. this.cameraRotation = new Vector2(0,0)
  65325. }
  65326. ,
  65327. Object.defineProperty(e.prototype, "collisionMask", {
  65328. get: function() {
  65329. return this._collisionMask
  65330. },
  65331. set: function(i) {
  65332. this._collisionMask = isNaN(i) ? -1 : i
  65333. },
  65334. enumerable: !1,
  65335. configurable: !0
  65336. }),
  65337. e.prototype._collideWithWorld = function(i) {
  65338. var o;
  65339. this.parent ? o = Vector3.TransformCoordinates(this.position, this.parent.getWorldMatrix()) : o = this.position,
  65340. o.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition),
  65341. this._oldPosition.addInPlace(this.ellipsoidOffset);
  65342. var s = this.getScene().collisionCoordinator;
  65343. this._collider || (this._collider = s.createCollider()),
  65344. this._collider._radius = this.ellipsoid,
  65345. this._collider.collisionMask = this._collisionMask;
  65346. var c = i;
  65347. this.applyGravity && (c = i.add(this.getScene().gravity)),
  65348. s.getNewPosition(this._oldPosition, c, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId)
  65349. }
  65350. ,
  65351. e.prototype._checkInputs = function() {
  65352. this._localDirection || (this._localDirection = Vector3.Zero(),
  65353. this._transformedDirection = Vector3.Zero()),
  65354. this.inputs.checkInputs(),
  65355. a.prototype._checkInputs.call(this)
  65356. }
  65357. ,
  65358. e.prototype._decideIfNeedsToMove = function() {
  65359. return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0
  65360. }
  65361. ,
  65362. e.prototype._updatePosition = function() {
  65363. this.checkCollisions && this.getScene().collisionsEnabled ? this._collideWithWorld(this.cameraDirection) : a.prototype._updatePosition.call(this)
  65364. }
  65365. ,
  65366. e.prototype.dispose = function() {
  65367. this.inputs.clear(),
  65368. a.prototype.dispose.call(this)
  65369. }
  65370. ,
  65371. e.prototype.getClassName = function() {
  65372. return "FreeCamera"
  65373. }
  65374. ,
  65375. __decorate([serializeAsVector3()], e.prototype, "ellipsoid", void 0),
  65376. __decorate([serializeAsVector3()], e.prototype, "ellipsoidOffset", void 0),
  65377. __decorate([serialize()], e.prototype, "checkCollisions", void 0),
  65378. __decorate([serialize()], e.prototype, "applyGravity", void 0),
  65379. e
  65380. }(TargetCamera)
  65381. , ShadowLight = function(a) {
  65382. __extends(e, a);
  65383. function e() {
  65384. var i = a !== null && a.apply(this, arguments) || this;
  65385. return i._needProjectionMatrixCompute = !0,
  65386. i
  65387. }
  65388. return e.prototype._setPosition = function(i) {
  65389. this._position = i
  65390. }
  65391. ,
  65392. Object.defineProperty(e.prototype, "position", {
  65393. get: function() {
  65394. return this._position
  65395. },
  65396. set: function(i) {
  65397. this._setPosition(i)
  65398. },
  65399. enumerable: !1,
  65400. configurable: !0
  65401. }),
  65402. e.prototype._setDirection = function(i) {
  65403. this._direction = i
  65404. }
  65405. ,
  65406. Object.defineProperty(e.prototype, "direction", {
  65407. get: function() {
  65408. return this._direction
  65409. },
  65410. set: function(i) {
  65411. this._setDirection(i)
  65412. },
  65413. enumerable: !1,
  65414. configurable: !0
  65415. }),
  65416. Object.defineProperty(e.prototype, "shadowMinZ", {
  65417. get: function() {
  65418. return this._shadowMinZ
  65419. },
  65420. set: function(i) {
  65421. this._shadowMinZ = i,
  65422. this.forceProjectionMatrixCompute()
  65423. },
  65424. enumerable: !1,
  65425. configurable: !0
  65426. }),
  65427. Object.defineProperty(e.prototype, "shadowMaxZ", {
  65428. get: function() {
  65429. return this._shadowMaxZ
  65430. },
  65431. set: function(i) {
  65432. this._shadowMaxZ = i,
  65433. this.forceProjectionMatrixCompute()
  65434. },
  65435. enumerable: !1,
  65436. configurable: !0
  65437. }),
  65438. e.prototype.computeTransformedInformation = function() {
  65439. return this.parent && this.parent.getWorldMatrix ? (this.transformedPosition || (this.transformedPosition = Vector3.Zero()),
  65440. Vector3.TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this.transformedPosition),
  65441. this.direction && (this.transformedDirection || (this.transformedDirection = Vector3.Zero()),
  65442. Vector3.TransformNormalToRef(this.direction, this.parent.getWorldMatrix(), this.transformedDirection)),
  65443. !0) : !1
  65444. }
  65445. ,
  65446. e.prototype.getDepthScale = function() {
  65447. return 50
  65448. }
  65449. ,
  65450. e.prototype.getShadowDirection = function(i) {
  65451. return this.transformedDirection ? this.transformedDirection : this.direction
  65452. }
  65453. ,
  65454. e.prototype.getAbsolutePosition = function() {
  65455. return this.transformedPosition ? this.transformedPosition : this.position
  65456. }
  65457. ,
  65458. e.prototype.setDirectionToTarget = function(i) {
  65459. return this.direction = Vector3.Normalize(i.subtract(this.position)),
  65460. this.direction
  65461. }
  65462. ,
  65463. e.prototype.getRotation = function() {
  65464. this.direction.normalize();
  65465. var i = Vector3.Cross(this.direction, Axis.Y)
  65466. , o = Vector3.Cross(i, this.direction);
  65467. return Vector3.RotationFromAxis(i, o, this.direction)
  65468. }
  65469. ,
  65470. e.prototype.needCube = function() {
  65471. return !1
  65472. }
  65473. ,
  65474. e.prototype.needProjectionMatrixCompute = function() {
  65475. return this._needProjectionMatrixCompute
  65476. }
  65477. ,
  65478. e.prototype.forceProjectionMatrixCompute = function() {
  65479. this._needProjectionMatrixCompute = !0
  65480. }
  65481. ,
  65482. e.prototype._initCache = function() {
  65483. a.prototype._initCache.call(this),
  65484. this._cache.position = Vector3.Zero()
  65485. }
  65486. ,
  65487. e.prototype._isSynchronized = function() {
  65488. return !!this._cache.position.equals(this.position)
  65489. }
  65490. ,
  65491. e.prototype.computeWorldMatrix = function(i) {
  65492. return !i && this.isSynchronized() ? (this._currentRenderId = this.getScene().getRenderId(),
  65493. this._worldMatrix) : (this._updateCache(),
  65494. this._cache.position.copyFrom(this.position),
  65495. this._worldMatrix || (this._worldMatrix = Matrix.Identity()),
  65496. Matrix.TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix),
  65497. this.parent && this.parent.getWorldMatrix && (this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix),
  65498. this._markSyncedWithParent()),
  65499. this._worldMatrixDeterminantIsDirty = !0,
  65500. this._worldMatrix)
  65501. }
  65502. ,
  65503. e.prototype.getDepthMinZ = function(i) {
  65504. return this.shadowMinZ !== void 0 ? this.shadowMinZ : i.minZ
  65505. }
  65506. ,
  65507. e.prototype.getDepthMaxZ = function(i) {
  65508. return this.shadowMaxZ !== void 0 ? this.shadowMaxZ : i.maxZ
  65509. }
  65510. ,
  65511. e.prototype.setShadowProjectionMatrix = function(i, o, s) {
  65512. return this.customProjectionMatrixBuilder ? this.customProjectionMatrixBuilder(o, s, i) : this._setDefaultShadowProjectionMatrix(i, o, s),
  65513. this
  65514. }
  65515. ,
  65516. __decorate([serializeAsVector3()], e.prototype, "position", null),
  65517. __decorate([serializeAsVector3()], e.prototype, "direction", null),
  65518. __decorate([serialize()], e.prototype, "shadowMinZ", null),
  65519. __decorate([serialize()], e.prototype, "shadowMaxZ", null),
  65520. e
  65521. }(Light);
  65522. Node$2.AddNodeConstructor("Light_Type_1", function(a, e) {
  65523. return function() {
  65524. return new DirectionalLight(a,Vector3.Zero(),e)
  65525. }
  65526. });
  65527. var DirectionalLight = function(a) {
  65528. __extends(e, a);
  65529. function e(i, o, s) {
  65530. var c = a.call(this, i, s) || this;
  65531. return c._shadowFrustumSize = 0,
  65532. c._shadowOrthoScale = .1,
  65533. c.autoUpdateExtends = !0,
  65534. c.autoCalcShadowZBounds = !1,
  65535. c._orthoLeft = Number.MAX_VALUE,
  65536. c._orthoRight = Number.MIN_VALUE,
  65537. c._orthoTop = Number.MIN_VALUE,
  65538. c._orthoBottom = Number.MAX_VALUE,
  65539. c.position = o.scale(-1),
  65540. c.direction = o,
  65541. c
  65542. }
  65543. return Object.defineProperty(e.prototype, "shadowFrustumSize", {
  65544. get: function() {
  65545. return this._shadowFrustumSize
  65546. },
  65547. set: function(i) {
  65548. this._shadowFrustumSize = i,
  65549. this.forceProjectionMatrixCompute()
  65550. },
  65551. enumerable: !1,
  65552. configurable: !0
  65553. }),
  65554. Object.defineProperty(e.prototype, "shadowOrthoScale", {
  65555. get: function() {
  65556. return this._shadowOrthoScale
  65557. },
  65558. set: function(i) {
  65559. this._shadowOrthoScale = i,
  65560. this.forceProjectionMatrixCompute()
  65561. },
  65562. enumerable: !1,
  65563. configurable: !0
  65564. }),
  65565. Object.defineProperty(e.prototype, "orthoLeft", {
  65566. get: function() {
  65567. return this._orthoLeft
  65568. },
  65569. set: function(i) {
  65570. this._orthoLeft = i
  65571. },
  65572. enumerable: !1,
  65573. configurable: !0
  65574. }),
  65575. Object.defineProperty(e.prototype, "orthoRight", {
  65576. get: function() {
  65577. return this._orthoRight
  65578. },
  65579. set: function(i) {
  65580. this._orthoRight = i
  65581. },
  65582. enumerable: !1,
  65583. configurable: !0
  65584. }),
  65585. Object.defineProperty(e.prototype, "orthoTop", {
  65586. get: function() {
  65587. return this._orthoTop
  65588. },
  65589. set: function(i) {
  65590. this._orthoTop = i
  65591. },
  65592. enumerable: !1,
  65593. configurable: !0
  65594. }),
  65595. Object.defineProperty(e.prototype, "orthoBottom", {
  65596. get: function() {
  65597. return this._orthoBottom
  65598. },
  65599. set: function(i) {
  65600. this._orthoBottom = i
  65601. },
  65602. enumerable: !1,
  65603. configurable: !0
  65604. }),
  65605. e.prototype.getClassName = function() {
  65606. return "DirectionalLight"
  65607. }
  65608. ,
  65609. e.prototype.getTypeID = function() {
  65610. return Light.LIGHTTYPEID_DIRECTIONALLIGHT
  65611. }
  65612. ,
  65613. e.prototype._setDefaultShadowProjectionMatrix = function(i, o, s) {
  65614. this.shadowFrustumSize > 0 ? this._setDefaultFixedFrustumShadowProjectionMatrix(i) : this._setDefaultAutoExtendShadowProjectionMatrix(i, o, s)
  65615. }
  65616. ,
  65617. e.prototype._setDefaultFixedFrustumShadowProjectionMatrix = function(i) {
  65618. var o = this.getScene().activeCamera;
  65619. !o || Matrix.OrthoLHToRef(this.shadowFrustumSize, this.shadowFrustumSize, this.shadowMinZ !== void 0 ? this.shadowMinZ : o.minZ, this.shadowMaxZ !== void 0 ? this.shadowMaxZ : o.maxZ, i, this.getScene().getEngine().isNDCHalfZRange)
  65620. }
  65621. ,
  65622. e.prototype._setDefaultAutoExtendShadowProjectionMatrix = function(i, o, s) {
  65623. var c = this.getScene().activeCamera;
  65624. if (!!c) {
  65625. if (this.autoUpdateExtends || this._orthoLeft === Number.MAX_VALUE) {
  65626. var d = Vector3.Zero();
  65627. this._orthoLeft = Number.MAX_VALUE,
  65628. this._orthoRight = Number.MIN_VALUE,
  65629. this._orthoTop = Number.MIN_VALUE,
  65630. this._orthoBottom = Number.MAX_VALUE;
  65631. for (var _ = Number.MAX_VALUE, b = Number.MIN_VALUE, k = 0; k < s.length; k++) {
  65632. var j = s[k];
  65633. if (!!j)
  65634. for (var $ = j.getBoundingInfo(), _e = $.boundingBox, et = 0; et < _e.vectorsWorld.length; et++)
  65635. Vector3.TransformCoordinatesToRef(_e.vectorsWorld[et], o, d),
  65636. d.x < this._orthoLeft && (this._orthoLeft = d.x),
  65637. d.y < this._orthoBottom && (this._orthoBottom = d.y),
  65638. d.x > this._orthoRight && (this._orthoRight = d.x),
  65639. d.y > this._orthoTop && (this._orthoTop = d.y),
  65640. this.autoCalcShadowZBounds && (d.z < _ && (_ = d.z),
  65641. d.z > b && (b = d.z))
  65642. }
  65643. this.autoCalcShadowZBounds && (this._shadowMinZ = _,
  65644. this._shadowMaxZ = b)
  65645. }
  65646. var tt = this._orthoRight - this._orthoLeft
  65647. , rt = this._orthoTop - this._orthoBottom
  65648. , it = this.shadowMinZ !== void 0 ? this.shadowMinZ : c.minZ
  65649. , nt = this.shadowMaxZ !== void 0 ? this.shadowMaxZ : c.maxZ
  65650. , ot = this.getScene().getEngine().useReverseDepthBuffer;
  65651. Matrix.OrthoOffCenterLHToRef(this._orthoLeft - tt * this.shadowOrthoScale, this._orthoRight + tt * this.shadowOrthoScale, this._orthoBottom - rt * this.shadowOrthoScale, this._orthoTop + rt * this.shadowOrthoScale, ot ? nt : it, ot ? it : nt, i, this.getScene().getEngine().isNDCHalfZRange)
  65652. }
  65653. }
  65654. ,
  65655. e.prototype._buildUniformLayout = function() {
  65656. this._uniformBuffer.addUniform("vLightData", 4),
  65657. this._uniformBuffer.addUniform("vLightDiffuse", 4),
  65658. this._uniformBuffer.addUniform("vLightSpecular", 4),
  65659. this._uniformBuffer.addUniform("shadowsInfo", 3),
  65660. this._uniformBuffer.addUniform("depthValues", 2),
  65661. this._uniformBuffer.create()
  65662. }
  65663. ,
  65664. e.prototype.transferToEffect = function(i, o) {
  65665. return this.computeTransformedInformation() ? (this._uniformBuffer.updateFloat4("vLightData", this.transformedDirection.x, this.transformedDirection.y, this.transformedDirection.z, 1, o),
  65666. this) : (this._uniformBuffer.updateFloat4("vLightData", this.direction.x, this.direction.y, this.direction.z, 1, o),
  65667. this)
  65668. }
  65669. ,
  65670. e.prototype.transferToNodeMaterialEffect = function(i, o) {
  65671. return this.computeTransformedInformation() ? (i.setFloat3(o, this.transformedDirection.x, this.transformedDirection.y, this.transformedDirection.z),
  65672. this) : (i.setFloat3(o, this.direction.x, this.direction.y, this.direction.z),
  65673. this)
  65674. }
  65675. ,
  65676. e.prototype.getDepthMinZ = function(i) {
  65677. var o = this._scene.getEngine();
  65678. return !o.useReverseDepthBuffer && o.isNDCHalfZRange ? 0 : 1
  65679. }
  65680. ,
  65681. e.prototype.getDepthMaxZ = function(i) {
  65682. var o = this._scene.getEngine();
  65683. return o.useReverseDepthBuffer && o.isNDCHalfZRange ? 0 : 1
  65684. }
  65685. ,
  65686. e.prototype.prepareLightSpecificDefines = function(i, o) {
  65687. i["DIRLIGHT" + o] = !0
  65688. }
  65689. ,
  65690. __decorate([serialize()], e.prototype, "shadowFrustumSize", null),
  65691. __decorate([serialize()], e.prototype, "shadowOrthoScale", null),
  65692. __decorate([serialize()], e.prototype, "autoUpdateExtends", void 0),
  65693. __decorate([serialize()], e.prototype, "autoCalcShadowZBounds", void 0),
  65694. __decorate([serialize("orthoLeft")], e.prototype, "_orthoLeft", void 0),
  65695. __decorate([serialize("orthoRight")], e.prototype, "_orthoRight", void 0),
  65696. __decorate([serialize("orthoTop")], e.prototype, "_orthoTop", void 0),
  65697. __decorate([serialize("orthoBottom")], e.prototype, "_orthoBottom", void 0),
  65698. e
  65699. }(ShadowLight);
  65700. Node$2.AddNodeConstructor("Light_Type_3", function(a, e) {
  65701. return function() {
  65702. return new HemisphericLight(a,Vector3.Zero(),e)
  65703. }
  65704. });
  65705. var HemisphericLight = function(a) {
  65706. __extends(e, a);
  65707. function e(i, o, s) {
  65708. var c = a.call(this, i, s) || this;
  65709. return c.groundColor = new Color3(0,0,0),
  65710. c.direction = o || Vector3.Up(),
  65711. c
  65712. }
  65713. return e.prototype._buildUniformLayout = function() {
  65714. this._uniformBuffer.addUniform("vLightData", 4),
  65715. this._uniformBuffer.addUniform("vLightDiffuse", 4),
  65716. this._uniformBuffer.addUniform("vLightSpecular", 4),
  65717. this._uniformBuffer.addUniform("vLightGround", 3),
  65718. this._uniformBuffer.addUniform("shadowsInfo", 3),
  65719. this._uniformBuffer.addUniform("depthValues", 2),
  65720. this._uniformBuffer.create()
  65721. }
  65722. ,
  65723. e.prototype.getClassName = function() {
  65724. return "HemisphericLight"
  65725. }
  65726. ,
  65727. e.prototype.setDirectionToTarget = function(i) {
  65728. return this.direction = Vector3.Normalize(i.subtract(Vector3.Zero())),
  65729. this.direction
  65730. }
  65731. ,
  65732. e.prototype.getShadowGenerator = function() {
  65733. return null
  65734. }
  65735. ,
  65736. e.prototype.transferToEffect = function(i, o) {
  65737. var s = Vector3.Normalize(this.direction);
  65738. return this._uniformBuffer.updateFloat4("vLightData", s.x, s.y, s.z, 0, o),
  65739. this._uniformBuffer.updateColor3("vLightGround", this.groundColor.scale(this.intensity), o),
  65740. this
  65741. }
  65742. ,
  65743. e.prototype.transferToNodeMaterialEffect = function(i, o) {
  65744. var s = Vector3.Normalize(this.direction);
  65745. return i.setFloat3(o, s.x, s.y, s.z),
  65746. this
  65747. }
  65748. ,
  65749. e.prototype.computeWorldMatrix = function() {
  65750. return this._worldMatrix || (this._worldMatrix = Matrix.Identity()),
  65751. this._worldMatrix
  65752. }
  65753. ,
  65754. e.prototype.getTypeID = function() {
  65755. return Light.LIGHTTYPEID_HEMISPHERICLIGHT
  65756. }
  65757. ,
  65758. e.prototype.prepareLightSpecificDefines = function(i, o) {
  65759. i["HEMILIGHT" + o] = !0
  65760. }
  65761. ,
  65762. __decorate([serializeAsColor3()], e.prototype, "groundColor", void 0),
  65763. __decorate([serializeAsVector3()], e.prototype, "direction", void 0),
  65764. e
  65765. }(Light)
  65766. , name$2D = "kernelBlurVaryingDeclaration"
  65767. , shader$2D = "varying vec2 sampleCoord{X};";
  65768. ShaderStore.IncludesShadersStore[name$2D] = shader$2D;
  65769. var name$2C = "packingFunctions"
  65770. , shader$2C = `vec4 pack(float depth)
  65771. {
  65772. const vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);
  65773. const vec4 bit_mask=vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);
  65774. vec4 res=fract(depth*bit_shift);
  65775. res-=res.xxyz*bit_mask;
  65776. return res;
  65777. }
  65778. float unpack(vec4 color)
  65779. {
  65780. const vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);
  65781. return dot(color,bit_shift);
  65782. }`;
  65783. ShaderStore.IncludesShadersStore[name$2C] = shader$2C;
  65784. var name$2B = "kernelBlurFragment"
  65785. , shader$2B = `#ifdef DOF
  65786. factor=sampleCoC(sampleCoord{X});
  65787. computedWeight=KERNEL_WEIGHT{X}*factor;
  65788. sumOfWeights+=computedWeight;
  65789. #else
  65790. computedWeight=KERNEL_WEIGHT{X};
  65791. #endif
  65792. #ifdef PACKEDFLOAT
  65793. blend+=unpack(texture2D(textureSampler,sampleCoord{X}))*computedWeight;
  65794. #else
  65795. blend+=texture2D(textureSampler,sampleCoord{X})*computedWeight;
  65796. #endif`;
  65797. ShaderStore.IncludesShadersStore[name$2B] = shader$2B;
  65798. var name$2A = "kernelBlurFragment2"
  65799. , shader$2A = `#ifdef DOF
  65800. factor=sampleCoC(sampleCenter+delta*KERNEL_DEP_OFFSET{X});
  65801. computedWeight=KERNEL_DEP_WEIGHT{X}*factor;
  65802. sumOfWeights+=computedWeight;
  65803. #else
  65804. computedWeight=KERNEL_DEP_WEIGHT{X};
  65805. #endif
  65806. #ifdef PACKEDFLOAT
  65807. blend+=unpack(texture2D(textureSampler,sampleCenter+delta*KERNEL_DEP_OFFSET{X}))*computedWeight;
  65808. #else
  65809. blend+=texture2D(textureSampler,sampleCenter+delta*KERNEL_DEP_OFFSET{X})*computedWeight;
  65810. #endif`;
  65811. ShaderStore.IncludesShadersStore[name$2A] = shader$2A;
  65812. var name$2z = "kernelBlurPixelShader"
  65813. , shader$2z = `
  65814. uniform sampler2D textureSampler;
  65815. uniform vec2 delta;
  65816. varying vec2 sampleCenter;
  65817. #ifdef DOF
  65818. uniform sampler2D circleOfConfusionSampler;
  65819. uniform vec2 cameraMinMaxZ;
  65820. float sampleDistance(in vec2 offset) {
  65821. float depth=texture2D(circleOfConfusionSampler,offset).g;
  65822. return cameraMinMaxZ.x+(cameraMinMaxZ.y-cameraMinMaxZ.x)*depth;
  65823. }
  65824. float sampleCoC(in vec2 offset) {
  65825. float coc=texture2D(circleOfConfusionSampler,offset).r;
  65826. return coc;
  65827. }
  65828. #endif
  65829. #include<kernelBlurVaryingDeclaration>[0..varyingCount]
  65830. #ifdef PACKEDFLOAT
  65831. #include<packingFunctions>
  65832. #endif
  65833. void main(void)
  65834. {
  65835. float computedWeight=0.0;
  65836. #ifdef PACKEDFLOAT
  65837. float blend=0.;
  65838. #else
  65839. vec4 blend=vec4(0.);
  65840. #endif
  65841. #ifdef DOF
  65842. float sumOfWeights=CENTER_WEIGHT;
  65843. float factor=0.0;
  65844. #ifdef PACKEDFLOAT
  65845. blend+=unpack(texture2D(textureSampler,sampleCenter))*CENTER_WEIGHT;
  65846. #else
  65847. blend+=texture2D(textureSampler,sampleCenter)*CENTER_WEIGHT;
  65848. #endif
  65849. #endif
  65850. #include<kernelBlurFragment>[0..varyingCount]
  65851. #include<kernelBlurFragment2>[0..depCount]
  65852. #ifdef PACKEDFLOAT
  65853. gl_FragColor=pack(blend);
  65854. #else
  65855. gl_FragColor=blend;
  65856. #endif
  65857. #ifdef DOF
  65858. gl_FragColor/=sumOfWeights;
  65859. #endif
  65860. }`;
  65861. ShaderStore.ShadersStore[name$2z] = shader$2z;
  65862. var name$2y = "kernelBlurVertex"
  65863. , shader$2y = "sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};";
  65864. ShaderStore.IncludesShadersStore[name$2y] = shader$2y;
  65865. var name$2x = "kernelBlurVertexShader"
  65866. , shader$2x = `
  65867. attribute vec2 position;
  65868. uniform vec2 delta;
  65869. varying vec2 sampleCenter;
  65870. #include<kernelBlurVaryingDeclaration>[0..varyingCount]
  65871. const vec2 madd=vec2(0.5,0.5);
  65872. void main(void) {
  65873. sampleCenter=(position*madd+madd);
  65874. #include<kernelBlurVertex>[0..varyingCount]
  65875. gl_Position=vec4(position,0.0,1.0);
  65876. }`;
  65877. ShaderStore.ShadersStore[name$2x] = shader$2x;
  65878. var BlurPostProcess = function(a) {
  65879. __extends(e, a);
  65880. function e(i, o, s, c, d, _, b, k, j, $, _e) {
  65881. _ === void 0 && (_ = Texture.BILINEAR_SAMPLINGMODE),
  65882. j === void 0 && (j = 0),
  65883. $ === void 0 && ($ = ""),
  65884. _e === void 0 && (_e = !1);
  65885. var et = a.call(this, i, "kernelBlur", ["delta", "direction", "cameraMinMaxZ"], ["circleOfConfusionSampler"], c, d, _, b, k, null, j, "kernelBlur", {
  65886. varyingCount: 0,
  65887. depCount: 0
  65888. }, !0) || this;
  65889. return et.blockCompilation = _e,
  65890. et._packedFloat = !1,
  65891. et._staticDefines = "",
  65892. et._staticDefines = $,
  65893. et.direction = o,
  65894. et.onApplyObservable.add(function(tt) {
  65895. et._outputTexture ? tt.setFloat2("delta", 1 / et._outputTexture.width * et.direction.x, 1 / et._outputTexture.height * et.direction.y) : tt.setFloat2("delta", 1 / et.width * et.direction.x, 1 / et.height * et.direction.y)
  65896. }),
  65897. et.kernel = s,
  65898. et
  65899. }
  65900. return Object.defineProperty(e.prototype, "kernel", {
  65901. get: function() {
  65902. return this._idealKernel
  65903. },
  65904. set: function(i) {
  65905. this._idealKernel !== i && (i = Math.max(i, 1),
  65906. this._idealKernel = i,
  65907. this._kernel = this._nearestBestKernel(i),
  65908. this.blockCompilation || this._updateParameters())
  65909. },
  65910. enumerable: !1,
  65911. configurable: !0
  65912. }),
  65913. Object.defineProperty(e.prototype, "packedFloat", {
  65914. get: function() {
  65915. return this._packedFloat
  65916. },
  65917. set: function(i) {
  65918. this._packedFloat !== i && (this._packedFloat = i,
  65919. this.blockCompilation || this._updateParameters())
  65920. },
  65921. enumerable: !1,
  65922. configurable: !0
  65923. }),
  65924. e.prototype.getClassName = function() {
  65925. return "BlurPostProcess"
  65926. }
  65927. ,
  65928. e.prototype.updateEffect = function(i, o, s, c, d, _) {
  65929. this._updateParameters(d, _)
  65930. }
  65931. ,
  65932. e.prototype._updateParameters = function(i, o) {
  65933. for (var s = this._kernel, c = (s - 1) / 2, d = [], _ = [], b = 0, k = 0; k < s; k++) {
  65934. var j = k / (s - 1)
  65935. , $ = this._gaussianWeight(j * 2 - 1);
  65936. d[k] = k - c,
  65937. _[k] = $,
  65938. b += $
  65939. }
  65940. for (var k = 0; k < _.length; k++)
  65941. _[k] /= b;
  65942. for (var _e = [], et = [], tt = [], k = 0; k <= c; k += 2) {
  65943. var rt = Math.min(k + 1, Math.floor(c))
  65944. , it = k === rt;
  65945. if (it)
  65946. tt.push({
  65947. o: d[k],
  65948. w: _[k]
  65949. });
  65950. else {
  65951. var nt = rt === c
  65952. , ot = _[k] + _[rt] * (nt ? .5 : 1)
  65953. , at = d[k] + 1 / (1 + _[k] / _[rt]);
  65954. at === 0 ? (tt.push({
  65955. o: d[k],
  65956. w: _[k]
  65957. }),
  65958. tt.push({
  65959. o: d[k + 1],
  65960. w: _[k + 1]
  65961. })) : (tt.push({
  65962. o: at,
  65963. w: ot
  65964. }),
  65965. tt.push({
  65966. o: -at,
  65967. w: ot
  65968. }))
  65969. }
  65970. }
  65971. for (var k = 0; k < tt.length; k++)
  65972. et[k] = tt[k].o,
  65973. _e[k] = tt[k].w;
  65974. d = et,
  65975. _ = _e;
  65976. var st = this.getEngine().getCaps().maxVaryingVectors
  65977. , ut = Math.max(st, 0) - 1
  65978. , ct = Math.min(d.length, ut)
  65979. , lt = "";
  65980. lt += this._staticDefines,
  65981. this._staticDefines.indexOf("DOF") != -1 && (lt += "#define CENTER_WEIGHT " + this._glslFloat(_[ct - 1]) + `\r
  65982. `,
  65983. ct--);
  65984. for (var k = 0; k < ct; k++)
  65985. lt += "#define KERNEL_OFFSET" + k + " " + this._glslFloat(d[k]) + `\r
  65986. `,
  65987. lt += "#define KERNEL_WEIGHT" + k + " " + this._glslFloat(_[k]) + `\r
  65988. `;
  65989. for (var ft = 0, k = ut; k < d.length; k++)
  65990. lt += "#define KERNEL_DEP_OFFSET" + ft + " " + this._glslFloat(d[k]) + `\r
  65991. `,
  65992. lt += "#define KERNEL_DEP_WEIGHT" + ft + " " + this._glslFloat(_[k]) + `\r
  65993. `,
  65994. ft++;
  65995. this.packedFloat && (lt += "#define PACKEDFLOAT 1"),
  65996. this.blockCompilation = !1,
  65997. a.prototype.updateEffect.call(this, lt, null, null, {
  65998. varyingCount: ct,
  65999. depCount: ft
  66000. }, i, o)
  66001. }
  66002. ,
  66003. e.prototype._nearestBestKernel = function(i) {
  66004. for (var o = Math.round(i), s = 0, c = [o, o - 1, o + 1, o - 2, o + 2]; s < c.length; s++) {
  66005. var d = c[s];
  66006. if (d % 2 !== 0 && Math.floor(d / 2) % 2 === 0 && d > 0)
  66007. return Math.max(d, 3)
  66008. }
  66009. return Math.max(o, 3)
  66010. }
  66011. ,
  66012. e.prototype._gaussianWeight = function(i) {
  66013. var o = .3333333333333333
  66014. , s = Math.sqrt(2 * Math.PI) * o
  66015. , c = -(i * i / (2 * o * o))
  66016. , d = 1 / s * Math.exp(c);
  66017. return d
  66018. }
  66019. ,
  66020. e.prototype._glslFloat = function(i, o) {
  66021. return o === void 0 && (o = 8),
  66022. i.toFixed(o).replace(/0+$/, "")
  66023. }
  66024. ,
  66025. e._Parse = function(i, o, s, c) {
  66026. return SerializationHelper.Parse(function() {
  66027. return new e(i.name,i.direction,i.kernel,i.options,o,i.renderTargetSamplingMode,s.getEngine(),i.reusable,i.textureType,void 0,!1)
  66028. }, i, s, c)
  66029. }
  66030. ,
  66031. __decorate([serialize("kernel")], e.prototype, "_kernel", void 0),
  66032. __decorate([serialize("packedFloat")], e.prototype, "_packedFloat", void 0),
  66033. __decorate([serializeAsVector2()], e.prototype, "direction", void 0),
  66034. e
  66035. }(PostProcess);
  66036. RegisterClass("BABYLON.BlurPostProcess", BlurPostProcess);
  66037. var EffectFallbacks = function() {
  66038. function a() {
  66039. this._defines = {},
  66040. this._currentRank = 32,
  66041. this._maxRank = -1,
  66042. this._mesh = null
  66043. }
  66044. return a.prototype.unBindMesh = function() {
  66045. this._mesh = null
  66046. }
  66047. ,
  66048. a.prototype.addFallback = function(e, i) {
  66049. this._defines[e] || (e < this._currentRank && (this._currentRank = e),
  66050. e > this._maxRank && (this._maxRank = e),
  66051. this._defines[e] = new Array),
  66052. this._defines[e].push(i)
  66053. }
  66054. ,
  66055. a.prototype.addCPUSkinningFallback = function(e, i) {
  66056. this._mesh = i,
  66057. e < this._currentRank && (this._currentRank = e),
  66058. e > this._maxRank && (this._maxRank = e)
  66059. }
  66060. ,
  66061. Object.defineProperty(a.prototype, "hasMoreFallbacks", {
  66062. get: function() {
  66063. return this._currentRank <= this._maxRank
  66064. },
  66065. enumerable: !1,
  66066. configurable: !0
  66067. }),
  66068. a.prototype.reduce = function(e, i) {
  66069. if (this._mesh && this._mesh.computeBonesUsingShaders && this._mesh.numBoneInfluencers > 0) {
  66070. this._mesh.computeBonesUsingShaders = !1,
  66071. e = e.replace("#define NUM_BONE_INFLUENCERS " + this._mesh.numBoneInfluencers, "#define NUM_BONE_INFLUENCERS 0"),
  66072. i._bonesComputationForcedToCPU = !0;
  66073. for (var o = this._mesh.getScene(), s = 0; s < o.meshes.length; s++) {
  66074. var c = o.meshes[s];
  66075. if (!c.material) {
  66076. !this._mesh.material && c.computeBonesUsingShaders && c.numBoneInfluencers > 0 && (c.computeBonesUsingShaders = !1);
  66077. continue
  66078. }
  66079. if (!(!c.computeBonesUsingShaders || c.numBoneInfluencers === 0)) {
  66080. if (c.material.getEffect() === i)
  66081. c.computeBonesUsingShaders = !1;
  66082. else if (c.subMeshes)
  66083. for (var d = 0, _ = c.subMeshes; d < _.length; d++) {
  66084. var b = _[d]
  66085. , k = b.effect;
  66086. if (k === i) {
  66087. c.computeBonesUsingShaders = !1;
  66088. break
  66089. }
  66090. }
  66091. }
  66092. }
  66093. } else {
  66094. var j = this._defines[this._currentRank];
  66095. if (j)
  66096. for (var s = 0; s < j.length; s++)
  66097. e = e.replace("#define " + j[s], "");
  66098. this._currentRank++
  66099. }
  66100. return e
  66101. }
  66102. ,
  66103. a
  66104. }()
  66105. , name$2w = "bayerDitherFunctions"
  66106. , shader$2w = `
  66107. float bayerDither2(vec2 _P) {
  66108. return mod(2.0*_P.y+_P.x+1.0,4.0);
  66109. }
  66110. float bayerDither4(vec2 _P) {
  66111. vec2 P1=mod(_P,2.0);
  66112. vec2 P2=floor(0.5*mod(_P,4.0));
  66113. return 4.0*bayerDither2(P1)+bayerDither2(P2);
  66114. }
  66115. float bayerDither8(vec2 _P) {
  66116. vec2 P1=mod(_P,2.0);
  66117. vec2 P2=floor(0.5*mod(_P,4.0));
  66118. vec2 P4=floor(0.25*mod(_P,8.0));
  66119. return 4.0*(4.0*bayerDither2(P1)+bayerDither2(P2))+bayerDither2(P4);
  66120. }
  66121. `;
  66122. ShaderStore.IncludesShadersStore[name$2w] = shader$2w;
  66123. var name$2v = "shadowMapFragmentExtraDeclaration"
  66124. , shader$2v = `#if SM_FLOAT == 0
  66125. #include<packingFunctions>
  66126. #endif
  66127. #if SM_SOFTTRANSPARENTSHADOW == 1
  66128. #include<bayerDitherFunctions>
  66129. uniform float softTransparentShadowSM;
  66130. #endif
  66131. varying float vDepthMetricSM;
  66132. #if SM_USEDISTANCE == 1
  66133. uniform vec3 lightDataSM;
  66134. varying vec3 vPositionWSM;
  66135. #endif
  66136. uniform vec3 biasAndScaleSM;
  66137. uniform vec2 depthValuesSM;
  66138. #if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP == 1
  66139. varying float zSM;
  66140. #endif
  66141. `;
  66142. ShaderStore.IncludesShadersStore[name$2v] = shader$2v;
  66143. var name$2u = "clipPlaneFragmentDeclaration"
  66144. , shader$2u = `#ifdef CLIPPLANE
  66145. varying float fClipDistance;
  66146. #endif
  66147. #ifdef CLIPPLANE2
  66148. varying float fClipDistance2;
  66149. #endif
  66150. #ifdef CLIPPLANE3
  66151. varying float fClipDistance3;
  66152. #endif
  66153. #ifdef CLIPPLANE4
  66154. varying float fClipDistance4;
  66155. #endif
  66156. #ifdef CLIPPLANE5
  66157. varying float fClipDistance5;
  66158. #endif
  66159. #ifdef CLIPPLANE6
  66160. varying float fClipDistance6;
  66161. #endif`;
  66162. ShaderStore.IncludesShadersStore[name$2u] = shader$2u;
  66163. var name$2t = "clipPlaneFragment"
  66164. , shader$2t = `#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)
  66165. if (false) {}
  66166. #endif
  66167. #ifdef CLIPPLANE
  66168. else if (fClipDistance>0.0)
  66169. {
  66170. discard;
  66171. }
  66172. #endif
  66173. #ifdef CLIPPLANE2
  66174. else if (fClipDistance2>0.0)
  66175. {
  66176. discard;
  66177. }
  66178. #endif
  66179. #ifdef CLIPPLANE3
  66180. else if (fClipDistance3>0.0)
  66181. {
  66182. discard;
  66183. }
  66184. #endif
  66185. #ifdef CLIPPLANE4
  66186. else if (fClipDistance4>0.0)
  66187. {
  66188. discard;
  66189. }
  66190. #endif
  66191. #ifdef CLIPPLANE5
  66192. else if (fClipDistance5>0.0)
  66193. {
  66194. discard;
  66195. }
  66196. #endif
  66197. #ifdef CLIPPLANE6
  66198. else if (fClipDistance6>0.0)
  66199. {
  66200. discard;
  66201. }
  66202. #endif`;
  66203. ShaderStore.IncludesShadersStore[name$2t] = shader$2t;
  66204. var name$2s = "shadowMapFragment"
  66205. , shader$2s = ` float depthSM=vDepthMetricSM;
  66206. #if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP == 1
  66207. #if SM_USEDISTANCE == 1
  66208. depthSM=(length(vPositionWSM-lightDataSM)+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;
  66209. #else
  66210. #ifdef USE_REVERSE_DEPTHBUFFER
  66211. depthSM=(-zSM+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;
  66212. #else
  66213. depthSM=(zSM+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;
  66214. #endif
  66215. #endif
  66216. #ifdef USE_REVERSE_DEPTHBUFFER
  66217. gl_FragDepth=clamp(1.0-depthSM,0.0,1.0);
  66218. #else
  66219. gl_FragDepth=clamp(depthSM,0.0,1.0);
  66220. #endif
  66221. #elif SM_USEDISTANCE == 1
  66222. depthSM=(length(vPositionWSM-lightDataSM)+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;
  66223. #endif
  66224. #if SM_ESM == 1
  66225. depthSM=clamp(exp(-min(87.,biasAndScaleSM.z*depthSM)),0.,1.);
  66226. #endif
  66227. #if SM_FLOAT == 1
  66228. gl_FragColor=vec4(depthSM,1.0,1.0,1.0);
  66229. #else
  66230. gl_FragColor=pack(depthSM);
  66231. #endif
  66232. return;`;
  66233. ShaderStore.IncludesShadersStore[name$2s] = shader$2s;
  66234. var name$2r = "shadowMapPixelShader"
  66235. , shader$2r = `#include<shadowMapFragmentExtraDeclaration>
  66236. #ifdef ALPHATEST
  66237. varying vec2 vUV;
  66238. uniform sampler2D diffuseSampler;
  66239. #endif
  66240. #include<clipPlaneFragmentDeclaration>
  66241. void main(void)
  66242. {
  66243. #include<clipPlaneFragment>
  66244. #ifdef ALPHATEST
  66245. float alphaFromAlphaTexture=texture2D(diffuseSampler,vUV).a;
  66246. if (alphaFromAlphaTexture<0.4)
  66247. discard;
  66248. #endif
  66249. #if SM_SOFTTRANSPARENTSHADOW == 1
  66250. #ifdef ALPHATEST
  66251. if ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM*alphaFromAlphaTexture) discard;
  66252. #else
  66253. if ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM) discard;
  66254. #endif
  66255. #endif
  66256. #include<shadowMapFragment>
  66257. }`;
  66258. ShaderStore.ShadersStore[name$2r] = shader$2r;
  66259. var name$2q = "bonesDeclaration"
  66260. , shader$2q = `#if NUM_BONE_INFLUENCERS>0
  66261. attribute vec4 matricesIndices;
  66262. attribute vec4 matricesWeights;
  66263. #if NUM_BONE_INFLUENCERS>4
  66264. attribute vec4 matricesIndicesExtra;
  66265. attribute vec4 matricesWeightsExtra;
  66266. #endif
  66267. #ifndef BAKED_VERTEX_ANIMATION_TEXTURE
  66268. #ifdef BONETEXTURE
  66269. uniform sampler2D boneSampler;
  66270. uniform float boneTextureWidth;
  66271. #else
  66272. uniform mat4 mBones[BonesPerMesh];
  66273. #ifdef BONES_VELOCITY_ENABLED
  66274. uniform mat4 mPreviousBones[BonesPerMesh];
  66275. #endif
  66276. #endif
  66277. #ifdef BONETEXTURE
  66278. #define inline
  66279. mat4 readMatrixFromRawSampler(sampler2D smp,float index)
  66280. {
  66281. float offset=index*4.0;
  66282. float dx=1.0/boneTextureWidth;
  66283. vec4 m0=texture2D(smp,vec2(dx*(offset+0.5),0.));
  66284. vec4 m1=texture2D(smp,vec2(dx*(offset+1.5),0.));
  66285. vec4 m2=texture2D(smp,vec2(dx*(offset+2.5),0.));
  66286. vec4 m3=texture2D(smp,vec2(dx*(offset+3.5),0.));
  66287. return mat4(m0,m1,m2,m3);
  66288. }
  66289. #endif
  66290. #endif
  66291. #endif`;
  66292. ShaderStore.IncludesShadersStore[name$2q] = shader$2q;
  66293. var name$2p = "bakedVertexAnimationDeclaration"
  66294. , shader$2p = `#ifdef BAKED_VERTEX_ANIMATION_TEXTURE
  66295. uniform float bakedVertexAnimationTime;
  66296. uniform vec2 bakedVertexAnimationTextureSizeInverted;
  66297. uniform vec4 bakedVertexAnimationSettings;
  66298. uniform sampler2D bakedVertexAnimationTexture;
  66299. #ifdef INSTANCES
  66300. attribute vec4 bakedVertexAnimationSettingsInstanced;
  66301. attribute float bakedVertexAnimationTimeInstanced;
  66302. #endif
  66303. #define inline
  66304. mat4 readMatrixFromRawSamplerVAT(sampler2D smp,float index,float frame)
  66305. {
  66306. float offset=index*4.0;
  66307. float frameUV=(frame+0.5)*bakedVertexAnimationTextureSizeInverted.y;
  66308. float dx=bakedVertexAnimationTextureSizeInverted.x;
  66309. vec4 m0=texture2D(smp,vec2(dx*(offset+0.5),frameUV));
  66310. vec4 m1=texture2D(smp,vec2(dx*(offset+1.5),frameUV));
  66311. vec4 m2=texture2D(smp,vec2(dx*(offset+2.5),frameUV));
  66312. vec4 m3=texture2D(smp,vec2(dx*(offset+3.5),frameUV));
  66313. return mat4(m0,m1,m2,m3);
  66314. }
  66315. #endif`;
  66316. ShaderStore.IncludesShadersStore[name$2p] = shader$2p;
  66317. var name$2o = "morphTargetsVertexGlobalDeclaration"
  66318. , shader$2o = `#ifdef MORPHTARGETS
  66319. uniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];
  66320. #ifdef MORPHTARGETS_TEXTURE
  66321. precision mediump sampler2DArray;
  66322. uniform float morphTargetTextureIndices[NUM_MORPH_INFLUENCERS];
  66323. uniform vec3 morphTargetTextureInfo;
  66324. uniform sampler2DArray morphTargets;
  66325. vec3 readVector3FromRawSampler(int targetIndex,float vertexIndex)
  66326. {
  66327. float y=floor(vertexIndex/morphTargetTextureInfo.y);
  66328. float x=vertexIndex-y*morphTargetTextureInfo.y;
  66329. vec3 textureUV=vec3((x+0.5)/morphTargetTextureInfo.y,(y+0.5)/morphTargetTextureInfo.z,morphTargetTextureIndices[targetIndex]);
  66330. return texture(morphTargets,textureUV).xyz;
  66331. }
  66332. #endif
  66333. #endif`;
  66334. ShaderStore.IncludesShadersStore[name$2o] = shader$2o;
  66335. var name$2n = "morphTargetsVertexDeclaration"
  66336. , shader$2n = `#ifdef MORPHTARGETS
  66337. #ifndef MORPHTARGETS_TEXTURE
  66338. attribute vec3 position{X};
  66339. #ifdef MORPHTARGETS_NORMAL
  66340. attribute vec3 normal{X};
  66341. #endif
  66342. #ifdef MORPHTARGETS_TANGENT
  66343. attribute vec3 tangent{X};
  66344. #endif
  66345. #ifdef MORPHTARGETS_UV
  66346. attribute vec2 uv_{X};
  66347. #endif
  66348. #endif
  66349. #endif`;
  66350. ShaderStore.IncludesShadersStore[name$2n] = shader$2n;
  66351. var name$2m = "sceneVertexDeclaration"
  66352. , shader$2m = `uniform mat4 viewProjection;
  66353. #ifdef MULTIVIEW
  66354. uniform mat4 viewProjectionR;
  66355. #endif
  66356. uniform mat4 view;
  66357. uniform mat4 projection;
  66358. uniform vec4 vEyePosition;
  66359. `;
  66360. ShaderStore.IncludesShadersStore[name$2m] = shader$2m;
  66361. var name$2l = "meshVertexDeclaration"
  66362. , shader$2l = `uniform mat4 world;
  66363. uniform float visibility;
  66364. `;
  66365. ShaderStore.IncludesShadersStore[name$2l] = shader$2l;
  66366. var name$2k = "shadowMapVertexDeclaration"
  66367. , shader$2k = `#include<sceneVertexDeclaration>
  66368. #include<meshVertexDeclaration>
  66369. `;
  66370. ShaderStore.IncludesShadersStore[name$2k] = shader$2k;
  66371. var name$2j = "sceneUboDeclaration"
  66372. , shader$2j = `layout(std140,column_major) uniform;
  66373. uniform Scene {
  66374. mat4 viewProjection;
  66375. #ifdef MULTIVIEW
  66376. mat4 viewProjectionR;
  66377. #endif
  66378. mat4 view;
  66379. mat4 projection;
  66380. vec4 vEyePosition;
  66381. };
  66382. `;
  66383. ShaderStore.IncludesShadersStore[name$2j] = shader$2j;
  66384. var name$2i = "meshUboDeclaration"
  66385. , shader$2i = `layout(std140,column_major) uniform;
  66386. uniform Mesh
  66387. {
  66388. mat4 world;
  66389. float visibility;
  66390. };
  66391. #define WORLD_UBO`;
  66392. ShaderStore.IncludesShadersStore[name$2i] = shader$2i;
  66393. var name$2h = "shadowMapUboDeclaration"
  66394. , shader$2h = `layout(std140,column_major) uniform;
  66395. #include<sceneUboDeclaration>
  66396. #include<meshUboDeclaration>
  66397. `;
  66398. ShaderStore.IncludesShadersStore[name$2h] = shader$2h;
  66399. var name$2g = "shadowMapVertexExtraDeclaration"
  66400. , shader$2g = `#if SM_NORMALBIAS == 1
  66401. uniform vec3 lightDataSM;
  66402. #endif
  66403. uniform vec3 biasAndScaleSM;
  66404. uniform vec2 depthValuesSM;
  66405. varying float vDepthMetricSM;
  66406. #if SM_USEDISTANCE == 1
  66407. varying vec3 vPositionWSM;
  66408. #endif
  66409. #if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP == 1
  66410. varying float zSM;
  66411. #endif
  66412. `;
  66413. ShaderStore.IncludesShadersStore[name$2g] = shader$2g;
  66414. var name$2f = "clipPlaneVertexDeclaration"
  66415. , shader$2f = `#ifdef CLIPPLANE
  66416. uniform vec4 vClipPlane;
  66417. varying float fClipDistance;
  66418. #endif
  66419. #ifdef CLIPPLANE2
  66420. uniform vec4 vClipPlane2;
  66421. varying float fClipDistance2;
  66422. #endif
  66423. #ifdef CLIPPLANE3
  66424. uniform vec4 vClipPlane3;
  66425. varying float fClipDistance3;
  66426. #endif
  66427. #ifdef CLIPPLANE4
  66428. uniform vec4 vClipPlane4;
  66429. varying float fClipDistance4;
  66430. #endif
  66431. #ifdef CLIPPLANE5
  66432. uniform vec4 vClipPlane5;
  66433. varying float fClipDistance5;
  66434. #endif
  66435. #ifdef CLIPPLANE6
  66436. uniform vec4 vClipPlane6;
  66437. varying float fClipDistance6;
  66438. #endif`;
  66439. ShaderStore.IncludesShadersStore[name$2f] = shader$2f;
  66440. var name$2e = "morphTargetsVertexGlobal"
  66441. , shader$2e = `#ifdef MORPHTARGETS
  66442. #ifdef MORPHTARGETS_TEXTURE
  66443. float vertexID;
  66444. #endif
  66445. #endif`;
  66446. ShaderStore.IncludesShadersStore[name$2e] = shader$2e;
  66447. var name$2d = "morphTargetsVertex"
  66448. , shader$2d = `#ifdef MORPHTARGETS
  66449. #ifdef MORPHTARGETS_TEXTURE
  66450. vertexID=float(gl_VertexID)*morphTargetTextureInfo.x;
  66451. positionUpdated+=(readVector3FromRawSampler({X},vertexID)-position)*morphTargetInfluences[{X}];
  66452. vertexID+=1.0;
  66453. #ifdef MORPHTARGETS_NORMAL
  66454. normalUpdated+=(readVector3FromRawSampler({X},vertexID)-normal)*morphTargetInfluences[{X}];
  66455. vertexID+=1.0;
  66456. #endif
  66457. #ifdef MORPHTARGETS_UV
  66458. uvUpdated+=(readVector3FromRawSampler({X},vertexID).xy-uv)*morphTargetInfluences[{X}];
  66459. vertexID+=1.0;
  66460. #endif
  66461. #ifdef MORPHTARGETS_TANGENT
  66462. tangentUpdated.xyz+=(readVector3FromRawSampler({X},vertexID)-tangent.xyz)*morphTargetInfluences[{X}];
  66463. #endif
  66464. #else
  66465. positionUpdated+=(position{X}-position)*morphTargetInfluences[{X}];
  66466. #ifdef MORPHTARGETS_NORMAL
  66467. normalUpdated+=(normal{X}-normal)*morphTargetInfluences[{X}];
  66468. #endif
  66469. #ifdef MORPHTARGETS_TANGENT
  66470. tangentUpdated.xyz+=(tangent{X}-tangent.xyz)*morphTargetInfluences[{X}];
  66471. #endif
  66472. #ifdef MORPHTARGETS_UV
  66473. uvUpdated+=(uv_{X}-uv)*morphTargetInfluences[{X}];
  66474. #endif
  66475. #endif
  66476. #endif`;
  66477. ShaderStore.IncludesShadersStore[name$2d] = shader$2d;
  66478. var name$2c = "instancesVertex"
  66479. , shader$2c = `#ifdef INSTANCES
  66480. mat4 finalWorld=mat4(world0,world1,world2,world3);
  66481. #if defined(PREPASS_VELOCITY) || defined(VELOCITY)
  66482. mat4 finalPreviousWorld=mat4(previousWorld0,previousWorld1,previousWorld2,previousWorld3);
  66483. #endif
  66484. #ifdef THIN_INSTANCES
  66485. finalWorld=world*finalWorld;
  66486. #if defined(PREPASS_VELOCITY) || defined(VELOCITY)
  66487. finalPreviousWorld=previousWorld*finalPreviousWorld;
  66488. #endif
  66489. #endif
  66490. #else
  66491. mat4 finalWorld=world;
  66492. #if defined(PREPASS_VELOCITY) || defined(VELOCITY)
  66493. mat4 finalPreviousWorld=previousWorld;
  66494. #endif
  66495. #endif`;
  66496. ShaderStore.IncludesShadersStore[name$2c] = shader$2c;
  66497. var name$2b = "bonesVertex"
  66498. , shader$2b = `#ifndef BAKED_VERTEX_ANIMATION_TEXTURE
  66499. #if NUM_BONE_INFLUENCERS>0
  66500. mat4 influence;
  66501. #ifdef BONETEXTURE
  66502. influence=readMatrixFromRawSampler(boneSampler,matricesIndices[0])*matricesWeights[0];
  66503. #if NUM_BONE_INFLUENCERS>1
  66504. influence+=readMatrixFromRawSampler(boneSampler,matricesIndices[1])*matricesWeights[1];
  66505. #endif
  66506. #if NUM_BONE_INFLUENCERS>2
  66507. influence+=readMatrixFromRawSampler(boneSampler,matricesIndices[2])*matricesWeights[2];
  66508. #endif
  66509. #if NUM_BONE_INFLUENCERS>3
  66510. influence+=readMatrixFromRawSampler(boneSampler,matricesIndices[3])*matricesWeights[3];
  66511. #endif
  66512. #if NUM_BONE_INFLUENCERS>4
  66513. influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[0])*matricesWeightsExtra[0];
  66514. #endif
  66515. #if NUM_BONE_INFLUENCERS>5
  66516. influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[1])*matricesWeightsExtra[1];
  66517. #endif
  66518. #if NUM_BONE_INFLUENCERS>6
  66519. influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[2])*matricesWeightsExtra[2];
  66520. #endif
  66521. #if NUM_BONE_INFLUENCERS>7
  66522. influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[3])*matricesWeightsExtra[3];
  66523. #endif
  66524. #else
  66525. influence=mBones[int(matricesIndices[0])]*matricesWeights[0];
  66526. #if NUM_BONE_INFLUENCERS>1
  66527. influence+=mBones[int(matricesIndices[1])]*matricesWeights[1];
  66528. #endif
  66529. #if NUM_BONE_INFLUENCERS>2
  66530. influence+=mBones[int(matricesIndices[2])]*matricesWeights[2];
  66531. #endif
  66532. #if NUM_BONE_INFLUENCERS>3
  66533. influence+=mBones[int(matricesIndices[3])]*matricesWeights[3];
  66534. #endif
  66535. #if NUM_BONE_INFLUENCERS>4
  66536. influence+=mBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];
  66537. #endif
  66538. #if NUM_BONE_INFLUENCERS>5
  66539. influence+=mBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];
  66540. #endif
  66541. #if NUM_BONE_INFLUENCERS>6
  66542. influence+=mBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];
  66543. #endif
  66544. #if NUM_BONE_INFLUENCERS>7
  66545. influence+=mBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];
  66546. #endif
  66547. #endif
  66548. finalWorld=finalWorld*influence;
  66549. #endif
  66550. #endif`;
  66551. ShaderStore.IncludesShadersStore[name$2b] = shader$2b;
  66552. var name$2a = "bakedVertexAnimation"
  66553. , shader$2a = `#ifdef BAKED_VERTEX_ANIMATION_TEXTURE
  66554. {
  66555. #ifdef INSTANCES
  66556. #define BVASNAME bakedVertexAnimationSettingsInstanced
  66557. #else
  66558. #define BVASNAME bakedVertexAnimationSettings
  66559. #endif
  66560. float VATStartFrame=BVASNAME.x;
  66561. float VATEndFrame=BVASNAME.y;
  66562. float VATOffsetFrame=BVASNAME.z;
  66563. float VATSpeed=BVASNAME.w;
  66564. float totalFrames=VATEndFrame-VATStartFrame+1.0;
  66565. #ifdef INSTANCES
  66566. float time=bakedVertexAnimationTimeInstanced*VATSpeed/totalFrames;
  66567. #else
  66568. float time=bakedVertexAnimationTime*VATSpeed/totalFrames;
  66569. #endif
  66570. float frameCorrection=time<1.0 ? 0.0 : 1.0;
  66571. float numOfFrames=totalFrames-frameCorrection;
  66572. float VATFrameNum=fract(time)*numOfFrames;
  66573. VATFrameNum=mod(VATFrameNum+VATOffsetFrame,numOfFrames);
  66574. VATFrameNum=floor(VATFrameNum);
  66575. VATFrameNum+=VATStartFrame+frameCorrection;
  66576. mat4 VATInfluence;
  66577. VATInfluence=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[0],VATFrameNum)*matricesWeights[0];
  66578. #if NUM_BONE_INFLUENCERS>1
  66579. VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[1],VATFrameNum)*matricesWeights[1];
  66580. #endif
  66581. #if NUM_BONE_INFLUENCERS>2
  66582. VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[2],VATFrameNum)*matricesWeights[2];
  66583. #endif
  66584. #if NUM_BONE_INFLUENCERS>3
  66585. VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[3],VATFrameNum)*matricesWeights[3];
  66586. #endif
  66587. #if NUM_BONE_INFLUENCERS>4
  66588. VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[0],VATFrameNum)*matricesWeightsExtra[0];
  66589. #endif
  66590. #if NUM_BONE_INFLUENCERS>5
  66591. VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[1],VATFrameNum)*matricesWeightsExtra[1];
  66592. #endif
  66593. #if NUM_BONE_INFLUENCERS>6
  66594. VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[2],VATFrameNum)*matricesWeightsExtra[2];
  66595. #endif
  66596. #if NUM_BONE_INFLUENCERS>7
  66597. VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[3],VATFrameNum)*matricesWeightsExtra[3];
  66598. #endif
  66599. finalWorld=finalWorld*VATInfluence;
  66600. }
  66601. #endif`;
  66602. ShaderStore.IncludesShadersStore[name$2a] = shader$2a;
  66603. var name$29 = "shadowMapVertexNormalBias"
  66604. , shader$29 = `
  66605. #if SM_NORMALBIAS == 1
  66606. #if SM_DIRECTIONINLIGHTDATA == 1
  66607. vec3 worldLightDirSM=normalize(-lightDataSM.xyz);
  66608. #else
  66609. vec3 directionToLightSM=lightDataSM.xyz-worldPos.xyz;
  66610. vec3 worldLightDirSM=normalize(directionToLightSM);
  66611. #endif
  66612. float ndlSM=dot(vNormalW,worldLightDirSM);
  66613. float sinNLSM=sqrt(1.0-ndlSM*ndlSM);
  66614. float normalBiasSM=biasAndScaleSM.y*sinNLSM;
  66615. worldPos.xyz-=vNormalW*normalBiasSM;
  66616. #endif
  66617. `;
  66618. ShaderStore.IncludesShadersStore[name$29] = shader$29;
  66619. var name$28 = "shadowMapVertexMetric"
  66620. , shader$28 = `#if SM_USEDISTANCE == 1
  66621. vPositionWSM=worldPos.xyz;
  66622. #endif
  66623. #if SM_DEPTHTEXTURE == 1
  66624. #ifdef IS_NDC_HALF_ZRANGE
  66625. #define BIASFACTOR 0.5
  66626. #else
  66627. #define BIASFACTOR 1.0
  66628. #endif
  66629. #ifdef USE_REVERSE_DEPTHBUFFER
  66630. gl_Position.z-=biasAndScaleSM.x*gl_Position.w*BIASFACTOR;
  66631. #else
  66632. gl_Position.z+=biasAndScaleSM.x*gl_Position.w*BIASFACTOR;
  66633. #endif
  66634. #endif
  66635. #if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP == 1
  66636. zSM=gl_Position.z;
  66637. gl_Position.z=0.0;
  66638. #elif SM_USEDISTANCE == 0
  66639. #ifdef USE_REVERSE_DEPTHBUFFER
  66640. vDepthMetricSM=(-gl_Position.z+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;
  66641. #else
  66642. vDepthMetricSM=(gl_Position.z+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;
  66643. #endif
  66644. #endif
  66645. `;
  66646. ShaderStore.IncludesShadersStore[name$28] = shader$28;
  66647. var name$27 = "clipPlaneVertex"
  66648. , shader$27 = `#ifdef CLIPPLANE
  66649. fClipDistance=dot(worldPos,vClipPlane);
  66650. #endif
  66651. #ifdef CLIPPLANE2
  66652. fClipDistance2=dot(worldPos,vClipPlane2);
  66653. #endif
  66654. #ifdef CLIPPLANE3
  66655. fClipDistance3=dot(worldPos,vClipPlane3);
  66656. #endif
  66657. #ifdef CLIPPLANE4
  66658. fClipDistance4=dot(worldPos,vClipPlane4);
  66659. #endif
  66660. #ifdef CLIPPLANE5
  66661. fClipDistance5=dot(worldPos,vClipPlane5);
  66662. #endif
  66663. #ifdef CLIPPLANE6
  66664. fClipDistance6=dot(worldPos,vClipPlane6);
  66665. #endif`;
  66666. ShaderStore.IncludesShadersStore[name$27] = shader$27;
  66667. var name$26 = "shadowMapVertexShader"
  66668. , shader$26 = `
  66669. attribute vec3 position;
  66670. #ifdef NORMAL
  66671. attribute vec3 normal;
  66672. #endif
  66673. #include<bonesDeclaration>
  66674. #include<bakedVertexAnimationDeclaration>
  66675. #include<morphTargetsVertexGlobalDeclaration>
  66676. #include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
  66677. #ifdef INSTANCES
  66678. attribute vec4 world0;
  66679. attribute vec4 world1;
  66680. attribute vec4 world2;
  66681. attribute vec4 world3;
  66682. #endif
  66683. #include<helperFunctions>
  66684. #include<__decl__shadowMapVertex>
  66685. #ifdef ALPHATEST
  66686. varying vec2 vUV;
  66687. uniform mat4 diffuseMatrix;
  66688. #ifdef UV1
  66689. attribute vec2 uv;
  66690. #endif
  66691. #ifdef UV2
  66692. attribute vec2 uv2;
  66693. #endif
  66694. #endif
  66695. #include<shadowMapVertexExtraDeclaration>
  66696. #include<clipPlaneVertexDeclaration>
  66697. void main(void)
  66698. {
  66699. vec3 positionUpdated=position;
  66700. #ifdef UV1
  66701. vec2 uvUpdated=uv;
  66702. #endif
  66703. #ifdef NORMAL
  66704. vec3 normalUpdated=normal;
  66705. #endif
  66706. #include<morphTargetsVertexGlobal>
  66707. #include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
  66708. #include<instancesVertex>
  66709. #include<bonesVertex>
  66710. #include<bakedVertexAnimation>
  66711. vec4 worldPos=finalWorld*vec4(positionUpdated,1.0);
  66712. #ifdef NORMAL
  66713. mat3 normWorldSM=mat3(finalWorld);
  66714. #if defined(INSTANCES) && defined(THIN_INSTANCES)
  66715. vec3 vNormalW=normalUpdated/vec3(dot(normWorldSM[0],normWorldSM[0]),dot(normWorldSM[1],normWorldSM[1]),dot(normWorldSM[2],normWorldSM[2]));
  66716. vNormalW=normalize(normWorldSM*vNormalW);
  66717. #else
  66718. #ifdef NONUNIFORMSCALING
  66719. normWorldSM=transposeMat3(inverseMat3(normWorldSM));
  66720. #endif
  66721. vec3 vNormalW=normalize(normWorldSM*normalUpdated);
  66722. #endif
  66723. #endif
  66724. #include<shadowMapVertexNormalBias>
  66725. gl_Position=viewProjection*worldPos;
  66726. #include<shadowMapVertexMetric>
  66727. #ifdef ALPHATEST
  66728. #ifdef UV1
  66729. vUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));
  66730. #endif
  66731. #ifdef UV2
  66732. vUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));
  66733. #endif
  66734. #endif
  66735. #include<clipPlaneVertex>
  66736. }`;
  66737. ShaderStore.ShadersStore[name$26] = shader$26;
  66738. var name$25 = "depthBoxBlurPixelShader"
  66739. , shader$25 = `
  66740. varying vec2 vUV;
  66741. uniform sampler2D textureSampler;
  66742. uniform vec2 screenSize;
  66743. void main(void)
  66744. {
  66745. vec4 colorDepth=vec4(0.0);
  66746. for (int x=-OFFSET; x<=OFFSET; x++)
  66747. for (int y=-OFFSET; y<=OFFSET; y++)
  66748. colorDepth+=texture2D(textureSampler,vUV+vec2(x,y)/screenSize);
  66749. gl_FragColor=(colorDepth/float((OFFSET*2+1)*(OFFSET*2+1)));
  66750. }`;
  66751. ShaderStore.ShadersStore[name$25] = shader$25;
  66752. var name$24 = "shadowMapFragmentSoftTransparentShadow"
  66753. , shader$24 = `#if SM_SOFTTRANSPARENTSHADOW == 1
  66754. if ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM*alpha) discard;
  66755. #endif
  66756. `;
  66757. ShaderStore.IncludesShadersStore[name$24] = shader$24;
  66758. var ShadowGenerator = function() {
  66759. function a(e, i, o) {
  66760. this.onBeforeShadowMapRenderObservable = new Observable,
  66761. this.onAfterShadowMapRenderObservable = new Observable,
  66762. this.onBeforeShadowMapRenderMeshObservable = new Observable,
  66763. this.onAfterShadowMapRenderMeshObservable = new Observable,
  66764. this._bias = 5e-5,
  66765. this._normalBias = 0,
  66766. this._blurBoxOffset = 1,
  66767. this._blurScale = 2,
  66768. this._blurKernel = 1,
  66769. this._useKernelBlur = !1,
  66770. this._filter = a.FILTER_NONE,
  66771. this._filteringQuality = a.QUALITY_HIGH,
  66772. this._contactHardeningLightSizeUVRatio = .1,
  66773. this._darkness = 0,
  66774. this._transparencyShadow = !1,
  66775. this.enableSoftTransparentShadow = !1,
  66776. this.frustumEdgeFalloff = 0,
  66777. this.forceBackFacesOnly = !1,
  66778. this._lightDirection = Vector3.Zero(),
  66779. this._viewMatrix = Matrix.Zero(),
  66780. this._projectionMatrix = Matrix.Zero(),
  66781. this._transformMatrix = Matrix.Zero(),
  66782. this._cachedPosition = new Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),
  66783. this._cachedDirection = new Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),
  66784. this._currentFaceIndex = 0,
  66785. this._currentFaceIndexCache = 0,
  66786. this._defaultTextureMatrix = Matrix.Identity(),
  66787. this._mapSize = e,
  66788. this._light = i,
  66789. this._scene = i.getScene(),
  66790. i._shadowGenerator = this,
  66791. this.id = i.id,
  66792. this._useUBO = this._scene.getEngine().supportsUniformBuffers,
  66793. this._useUBO && (this._sceneUBOs = [],
  66794. this._sceneUBOs.push(this._scene.createSceneUniformBuffer('Scene for Shadow Generator (light "' + this._light.name + '")'))),
  66795. a._SceneComponentInitialization(this._scene);
  66796. var s = this._scene.getEngine().getCaps();
  66797. o ? s.textureFloatRender && s.textureFloatLinearFiltering ? this._textureType = 1 : s.textureHalfFloatRender && s.textureHalfFloatLinearFiltering ? this._textureType = 2 : this._textureType = 0 : s.textureHalfFloatRender && s.textureHalfFloatLinearFiltering ? this._textureType = 2 : s.textureFloatRender && s.textureFloatLinearFiltering ? this._textureType = 1 : this._textureType = 0,
  66798. this._initializeGenerator(),
  66799. this._applyFilterValues()
  66800. }
  66801. return Object.defineProperty(a.prototype, "bias", {
  66802. get: function() {
  66803. return this._bias
  66804. },
  66805. set: function(e) {
  66806. this._bias = e
  66807. },
  66808. enumerable: !1,
  66809. configurable: !0
  66810. }),
  66811. Object.defineProperty(a.prototype, "normalBias", {
  66812. get: function() {
  66813. return this._normalBias
  66814. },
  66815. set: function(e) {
  66816. this._normalBias = e
  66817. },
  66818. enumerable: !1,
  66819. configurable: !0
  66820. }),
  66821. Object.defineProperty(a.prototype, "blurBoxOffset", {
  66822. get: function() {
  66823. return this._blurBoxOffset
  66824. },
  66825. set: function(e) {
  66826. this._blurBoxOffset !== e && (this._blurBoxOffset = e,
  66827. this._disposeBlurPostProcesses())
  66828. },
  66829. enumerable: !1,
  66830. configurable: !0
  66831. }),
  66832. Object.defineProperty(a.prototype, "blurScale", {
  66833. get: function() {
  66834. return this._blurScale
  66835. },
  66836. set: function(e) {
  66837. this._blurScale !== e && (this._blurScale = e,
  66838. this._disposeBlurPostProcesses())
  66839. },
  66840. enumerable: !1,
  66841. configurable: !0
  66842. }),
  66843. Object.defineProperty(a.prototype, "blurKernel", {
  66844. get: function() {
  66845. return this._blurKernel
  66846. },
  66847. set: function(e) {
  66848. this._blurKernel !== e && (this._blurKernel = e,
  66849. this._disposeBlurPostProcesses())
  66850. },
  66851. enumerable: !1,
  66852. configurable: !0
  66853. }),
  66854. Object.defineProperty(a.prototype, "useKernelBlur", {
  66855. get: function() {
  66856. return this._useKernelBlur
  66857. },
  66858. set: function(e) {
  66859. this._useKernelBlur !== e && (this._useKernelBlur = e,
  66860. this._disposeBlurPostProcesses())
  66861. },
  66862. enumerable: !1,
  66863. configurable: !0
  66864. }),
  66865. Object.defineProperty(a.prototype, "depthScale", {
  66866. get: function() {
  66867. return this._depthScale !== void 0 ? this._depthScale : this._light.getDepthScale()
  66868. },
  66869. set: function(e) {
  66870. this._depthScale = e
  66871. },
  66872. enumerable: !1,
  66873. configurable: !0
  66874. }),
  66875. a.prototype._validateFilter = function(e) {
  66876. return e
  66877. }
  66878. ,
  66879. Object.defineProperty(a.prototype, "filter", {
  66880. get: function() {
  66881. return this._filter
  66882. },
  66883. set: function(e) {
  66884. if (e = this._validateFilter(e),
  66885. this._light.needCube()) {
  66886. if (e === a.FILTER_BLUREXPONENTIALSHADOWMAP) {
  66887. this.useExponentialShadowMap = !0;
  66888. return
  66889. } else if (e === a.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP) {
  66890. this.useCloseExponentialShadowMap = !0;
  66891. return
  66892. } else if (e === a.FILTER_PCF || e === a.FILTER_PCSS) {
  66893. this.usePoissonSampling = !0;
  66894. return
  66895. }
  66896. }
  66897. if ((e === a.FILTER_PCF || e === a.FILTER_PCSS) && !this._scene.getEngine()._features.supportShadowSamplers) {
  66898. this.usePoissonSampling = !0;
  66899. return
  66900. }
  66901. this._filter !== e && (this._filter = e,
  66902. this._disposeBlurPostProcesses(),
  66903. this._applyFilterValues(),
  66904. this._light._markMeshesAsLightDirty())
  66905. },
  66906. enumerable: !1,
  66907. configurable: !0
  66908. }),
  66909. Object.defineProperty(a.prototype, "usePoissonSampling", {
  66910. get: function() {
  66911. return this.filter === a.FILTER_POISSONSAMPLING
  66912. },
  66913. set: function(e) {
  66914. var i = this._validateFilter(a.FILTER_POISSONSAMPLING);
  66915. !e && this.filter !== a.FILTER_POISSONSAMPLING || (this.filter = e ? i : a.FILTER_NONE)
  66916. },
  66917. enumerable: !1,
  66918. configurable: !0
  66919. }),
  66920. Object.defineProperty(a.prototype, "useExponentialShadowMap", {
  66921. get: function() {
  66922. return this.filter === a.FILTER_EXPONENTIALSHADOWMAP
  66923. },
  66924. set: function(e) {
  66925. var i = this._validateFilter(a.FILTER_EXPONENTIALSHADOWMAP);
  66926. !e && this.filter !== a.FILTER_EXPONENTIALSHADOWMAP || (this.filter = e ? i : a.FILTER_NONE)
  66927. },
  66928. enumerable: !1,
  66929. configurable: !0
  66930. }),
  66931. Object.defineProperty(a.prototype, "useBlurExponentialShadowMap", {
  66932. get: function() {
  66933. return this.filter === a.FILTER_BLUREXPONENTIALSHADOWMAP
  66934. },
  66935. set: function(e) {
  66936. var i = this._validateFilter(a.FILTER_BLUREXPONENTIALSHADOWMAP);
  66937. !e && this.filter !== a.FILTER_BLUREXPONENTIALSHADOWMAP || (this.filter = e ? i : a.FILTER_NONE)
  66938. },
  66939. enumerable: !1,
  66940. configurable: !0
  66941. }),
  66942. Object.defineProperty(a.prototype, "useCloseExponentialShadowMap", {
  66943. get: function() {
  66944. return this.filter === a.FILTER_CLOSEEXPONENTIALSHADOWMAP
  66945. },
  66946. set: function(e) {
  66947. var i = this._validateFilter(a.FILTER_CLOSEEXPONENTIALSHADOWMAP);
  66948. !e && this.filter !== a.FILTER_CLOSEEXPONENTIALSHADOWMAP || (this.filter = e ? i : a.FILTER_NONE)
  66949. },
  66950. enumerable: !1,
  66951. configurable: !0
  66952. }),
  66953. Object.defineProperty(a.prototype, "useBlurCloseExponentialShadowMap", {
  66954. get: function() {
  66955. return this.filter === a.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP
  66956. },
  66957. set: function(e) {
  66958. var i = this._validateFilter(a.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP);
  66959. !e && this.filter !== a.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP || (this.filter = e ? i : a.FILTER_NONE)
  66960. },
  66961. enumerable: !1,
  66962. configurable: !0
  66963. }),
  66964. Object.defineProperty(a.prototype, "usePercentageCloserFiltering", {
  66965. get: function() {
  66966. return this.filter === a.FILTER_PCF
  66967. },
  66968. set: function(e) {
  66969. var i = this._validateFilter(a.FILTER_PCF);
  66970. !e && this.filter !== a.FILTER_PCF || (this.filter = e ? i : a.FILTER_NONE)
  66971. },
  66972. enumerable: !1,
  66973. configurable: !0
  66974. }),
  66975. Object.defineProperty(a.prototype, "filteringQuality", {
  66976. get: function() {
  66977. return this._filteringQuality
  66978. },
  66979. set: function(e) {
  66980. this._filteringQuality !== e && (this._filteringQuality = e,
  66981. this._disposeBlurPostProcesses(),
  66982. this._applyFilterValues(),
  66983. this._light._markMeshesAsLightDirty())
  66984. },
  66985. enumerable: !1,
  66986. configurable: !0
  66987. }),
  66988. Object.defineProperty(a.prototype, "useContactHardeningShadow", {
  66989. get: function() {
  66990. return this.filter === a.FILTER_PCSS
  66991. },
  66992. set: function(e) {
  66993. var i = this._validateFilter(a.FILTER_PCSS);
  66994. !e && this.filter !== a.FILTER_PCSS || (this.filter = e ? i : a.FILTER_NONE)
  66995. },
  66996. enumerable: !1,
  66997. configurable: !0
  66998. }),
  66999. Object.defineProperty(a.prototype, "contactHardeningLightSizeUVRatio", {
  67000. get: function() {
  67001. return this._contactHardeningLightSizeUVRatio
  67002. },
  67003. set: function(e) {
  67004. this._contactHardeningLightSizeUVRatio = e
  67005. },
  67006. enumerable: !1,
  67007. configurable: !0
  67008. }),
  67009. Object.defineProperty(a.prototype, "darkness", {
  67010. get: function() {
  67011. return this._darkness
  67012. },
  67013. set: function(e) {
  67014. this.setDarkness(e)
  67015. },
  67016. enumerable: !1,
  67017. configurable: !0
  67018. }),
  67019. a.prototype.getDarkness = function() {
  67020. return this._darkness
  67021. }
  67022. ,
  67023. a.prototype.setDarkness = function(e) {
  67024. return e >= 1 ? this._darkness = 1 : e <= 0 ? this._darkness = 0 : this._darkness = e,
  67025. this
  67026. }
  67027. ,
  67028. Object.defineProperty(a.prototype, "transparencyShadow", {
  67029. get: function() {
  67030. return this._transparencyShadow
  67031. },
  67032. set: function(e) {
  67033. this.setTransparencyShadow(e)
  67034. },
  67035. enumerable: !1,
  67036. configurable: !0
  67037. }),
  67038. a.prototype.setTransparencyShadow = function(e) {
  67039. return this._transparencyShadow = e,
  67040. this
  67041. }
  67042. ,
  67043. a.prototype.getShadowMap = function() {
  67044. return this._shadowMap
  67045. }
  67046. ,
  67047. a.prototype.getShadowMapForRendering = function() {
  67048. return this._shadowMap2 ? this._shadowMap2 : this._shadowMap
  67049. }
  67050. ,
  67051. a.prototype.getClassName = function() {
  67052. return a.CLASSNAME
  67053. }
  67054. ,
  67055. a.prototype.addShadowCaster = function(e, i) {
  67056. if (i === void 0 && (i = !0),
  67057. !this._shadowMap)
  67058. return this;
  67059. if (this._shadowMap.renderList || (this._shadowMap.renderList = []),
  67060. this._shadowMap.renderList.indexOf(e) === -1 && this._shadowMap.renderList.push(e),
  67061. i)
  67062. for (var o = 0, s = e.getChildMeshes(); o < s.length; o++) {
  67063. var c = s[o];
  67064. this._shadowMap.renderList.indexOf(c) === -1 && this._shadowMap.renderList.push(c)
  67065. }
  67066. return this
  67067. }
  67068. ,
  67069. a.prototype.removeShadowCaster = function(e, i) {
  67070. if (i === void 0 && (i = !0),
  67071. !this._shadowMap || !this._shadowMap.renderList)
  67072. return this;
  67073. var o = this._shadowMap.renderList.indexOf(e);
  67074. if (o !== -1 && this._shadowMap.renderList.splice(o, 1),
  67075. i)
  67076. for (var s = 0, c = e.getChildren(); s < c.length; s++) {
  67077. var d = c[s];
  67078. this.removeShadowCaster(d)
  67079. }
  67080. return this
  67081. }
  67082. ,
  67083. a.prototype.getLight = function() {
  67084. return this._light
  67085. }
  67086. ,
  67087. Object.defineProperty(a.prototype, "mapSize", {
  67088. get: function() {
  67089. return this._mapSize
  67090. },
  67091. set: function(e) {
  67092. this._mapSize = e,
  67093. this._light._markMeshesAsLightDirty(),
  67094. this.recreateShadowMap()
  67095. },
  67096. enumerable: !1,
  67097. configurable: !0
  67098. }),
  67099. a.prototype._initializeGenerator = function() {
  67100. this._light._markMeshesAsLightDirty(),
  67101. this._initializeShadowMap()
  67102. }
  67103. ,
  67104. a.prototype._createTargetRenderTexture = function() {
  67105. var e = this._scene.getEngine();
  67106. e._features.supportDepthStencilTexture ? (this._shadowMap = new RenderTargetTexture(this._light.name + "_shadowMap",this._mapSize,this._scene,!1,!0,this._textureType,this._light.needCube(),void 0,!1,!1),
  67107. this._shadowMap.createDepthStencilTexture(e.useReverseDepthBuffer ? 516 : 513, !0)) : this._shadowMap = new RenderTargetTexture(this._light.name + "_shadowMap",this._mapSize,this._scene,!1,!0,this._textureType,this._light.needCube())
  67108. }
  67109. ,
  67110. a.prototype._initializeShadowMap = function() {
  67111. var e = this;
  67112. if (this._createTargetRenderTexture(),
  67113. this._shadowMap !== null) {
  67114. this._shadowMap.wrapU = Texture.CLAMP_ADDRESSMODE,
  67115. this._shadowMap.wrapV = Texture.CLAMP_ADDRESSMODE,
  67116. this._shadowMap.anisotropicFilteringLevel = 1,
  67117. this._shadowMap.updateSamplingMode(Texture.BILINEAR_SAMPLINGMODE),
  67118. this._shadowMap.renderParticles = !1,
  67119. this._shadowMap.ignoreCameraViewport = !0,
  67120. this._storedUniqueId && (this._shadowMap.uniqueId = this._storedUniqueId),
  67121. this._shadowMap.customRenderFunction = this._renderForShadowMap.bind(this),
  67122. this._shadowMap.customIsReadyFunction = function(d, _) {
  67123. return !0
  67124. }
  67125. ;
  67126. var i = this._scene.getEngine();
  67127. this._shadowMap.onBeforeBindObservable.add(function() {
  67128. var d;
  67129. e._currentSceneUBO = e._scene.getSceneUniformBuffer(),
  67130. (d = i._debugPushGroup) === null || d === void 0 || d.call(i, "shadow map generation for pass id " + i.currentRenderPassId, 1)
  67131. }),
  67132. this._shadowMap.onBeforeRenderObservable.add(function(d) {
  67133. e._sceneUBOs && e._scene.setSceneUniformBuffer(e._sceneUBOs[0]),
  67134. e._currentFaceIndex = d,
  67135. e._filter === a.FILTER_PCF && i.setColorWrite(!1),
  67136. e.getTransformMatrix(),
  67137. e._scene.setTransformMatrix(e._viewMatrix, e._projectionMatrix),
  67138. e._useUBO && (e._scene.getSceneUniformBuffer().unbindEffect(),
  67139. e._scene.finalizeSceneUbo())
  67140. }),
  67141. this._shadowMap.onAfterUnbindObservable.add(function() {
  67142. var d, _;
  67143. if (e._sceneUBOs && e._scene.setSceneUniformBuffer(e._currentSceneUBO),
  67144. e._scene.updateTransformMatrix(),
  67145. e._filter === a.FILTER_PCF && i.setColorWrite(!0),
  67146. !e.useBlurExponentialShadowMap && !e.useBlurCloseExponentialShadowMap) {
  67147. (d = i._debugPopGroup) === null || d === void 0 || d.call(i, 1);
  67148. return
  67149. }
  67150. var b = e.getShadowMapForRendering();
  67151. b && (e._scene.postProcessManager.directRender(e._blurPostProcesses, b.renderTarget, !0),
  67152. i.unBindFramebuffer(b.renderTarget, !0),
  67153. (_ = i._debugPopGroup) === null || _ === void 0 || _.call(i, 1))
  67154. });
  67155. var o = new Color4(0,0,0,0)
  67156. , s = new Color4(1,1,1,1);
  67157. this._shadowMap.onClearObservable.add(function(d) {
  67158. e._filter === a.FILTER_PCF ? d.clear(s, !1, !0, !1) : e.useExponentialShadowMap || e.useBlurExponentialShadowMap ? d.clear(o, !0, !0, !1) : d.clear(s, !0, !0, !1)
  67159. }),
  67160. this._shadowMap.onResizeObservable.add(function(d) {
  67161. e._storedUniqueId = e._shadowMap.uniqueId,
  67162. e._mapSize = d.getRenderSize(),
  67163. e._light._markMeshesAsLightDirty(),
  67164. e.recreateShadowMap()
  67165. });
  67166. for (var c = RenderingManager.MIN_RENDERINGGROUPS; c < RenderingManager.MAX_RENDERINGGROUPS; c++)
  67167. this._shadowMap.setRenderingAutoClearDepthStencil(c, !1)
  67168. }
  67169. }
  67170. ,
  67171. a.prototype._initializeBlurRTTAndPostProcesses = function() {
  67172. var e = this
  67173. , i = this._scene.getEngine()
  67174. , o = this._mapSize / this.blurScale;
  67175. (!this.useKernelBlur || this.blurScale !== 1) && (this._shadowMap2 = new RenderTargetTexture(this._light.name + "_shadowMap2",o,this._scene,!1,!0,this._textureType,void 0,void 0,!1),
  67176. this._shadowMap2.wrapU = Texture.CLAMP_ADDRESSMODE,
  67177. this._shadowMap2.wrapV = Texture.CLAMP_ADDRESSMODE,
  67178. this._shadowMap2.updateSamplingMode(Texture.BILINEAR_SAMPLINGMODE)),
  67179. this.useKernelBlur ? (this._kernelBlurXPostprocess = new BlurPostProcess(this._light.name + "KernelBlurX",new Vector2(1,0),this.blurKernel,1,null,Texture.BILINEAR_SAMPLINGMODE,i,!1,this._textureType),
  67180. this._kernelBlurXPostprocess.width = o,
  67181. this._kernelBlurXPostprocess.height = o,
  67182. this._kernelBlurXPostprocess.externalTextureSamplerBinding = !0,
  67183. this._kernelBlurXPostprocess.onApplyObservable.add(function(s) {
  67184. s.setTexture("textureSampler", e._shadowMap)
  67185. }),
  67186. this._kernelBlurYPostprocess = new BlurPostProcess(this._light.name + "KernelBlurY",new Vector2(0,1),this.blurKernel,1,null,Texture.BILINEAR_SAMPLINGMODE,i,!1,this._textureType),
  67187. this._kernelBlurXPostprocess.autoClear = !1,
  67188. this._kernelBlurYPostprocess.autoClear = !1,
  67189. this._textureType === 0 && (this._kernelBlurXPostprocess.packedFloat = !0,
  67190. this._kernelBlurYPostprocess.packedFloat = !0),
  67191. this._blurPostProcesses = [this._kernelBlurXPostprocess, this._kernelBlurYPostprocess]) : (this._boxBlurPostprocess = new PostProcess(this._light.name + "DepthBoxBlur","depthBoxBlur",["screenSize", "boxOffset"],[],1,null,Texture.BILINEAR_SAMPLINGMODE,i,!1,"#define OFFSET " + this._blurBoxOffset,this._textureType),
  67192. this._boxBlurPostprocess.externalTextureSamplerBinding = !0,
  67193. this._boxBlurPostprocess.onApplyObservable.add(function(s) {
  67194. s.setFloat2("screenSize", o, o),
  67195. s.setTexture("textureSampler", e._shadowMap)
  67196. }),
  67197. this._boxBlurPostprocess.autoClear = !1,
  67198. this._blurPostProcesses = [this._boxBlurPostprocess])
  67199. }
  67200. ,
  67201. a.prototype._renderForShadowMap = function(e, i, o, s) {
  67202. var c;
  67203. if (s.length)
  67204. for (c = 0; c < s.length; c++)
  67205. this._renderSubMeshForShadowMap(s.data[c]);
  67206. for (c = 0; c < e.length; c++)
  67207. this._renderSubMeshForShadowMap(e.data[c]);
  67208. for (c = 0; c < i.length; c++)
  67209. this._renderSubMeshForShadowMap(i.data[c]);
  67210. if (this._transparencyShadow)
  67211. for (c = 0; c < o.length; c++)
  67212. this._renderSubMeshForShadowMap(o.data[c], !0);
  67213. else
  67214. for (c = 0; c < o.length; c++)
  67215. o.data[c].getEffectiveMesh()._internalAbstractMeshDataInfo._isActiveIntermediate = !1
  67216. }
  67217. ,
  67218. a.prototype._bindCustomEffectForRenderSubMeshForShadowMap = function(e, i, o) {
  67219. i.setMatrix("viewProjection", this.getTransformMatrix())
  67220. }
  67221. ,
  67222. a.prototype._renderSubMeshForShadowMap = function(e, i) {
  67223. var o, s;
  67224. i === void 0 && (i = !1);
  67225. var c = e.getRenderingMesh()
  67226. , d = e.getEffectiveMesh()
  67227. , _ = this._scene
  67228. , b = _.getEngine()
  67229. , k = e.getMaterial();
  67230. if (d._internalAbstractMeshDataInfo._isActiveIntermediate = !1,
  67231. !(!k || e.verticesCount === 0 || e._renderId === _.getRenderId())) {
  67232. var j = d._getWorldMatrixDeterminant() < 0
  67233. , $ = (o = c.overrideMaterialSideOrientation) !== null && o !== void 0 ? o : k.sideOrientation;
  67234. (_.useRightHandedSystem && !j || !_.useRightHandedSystem && j) && ($ = $ === 0 ? 1 : 0);
  67235. var _e = $ === 0;
  67236. b.setState(k.backFaceCulling, void 0, void 0, _e, k.cullBackFaces);
  67237. var et = c._getInstancesRenderList(e._id, !!e.getReplacementMesh());
  67238. if (!et.mustReturn) {
  67239. var tt = b.getCaps().instancedArrays && (et.visibleInstances[e._id] !== null && et.visibleInstances[e._id] !== void 0 || c.hasThinInstances);
  67240. if (!(this.customAllowRendering && !this.customAllowRendering(e)))
  67241. if (this.isReady(e, tt, i)) {
  67242. e._renderId = _.getRenderId();
  67243. var rt = k.shadowDepthWrapper
  67244. , it = (s = rt == null ? void 0 : rt.getEffect(e, this, b.currentRenderPassId)) !== null && s !== void 0 ? s : e._getDrawWrapper()
  67245. , nt = DrawWrapper.GetEffect(it);
  67246. if (b.enableEffect(it),
  67247. tt || c._bind(e, nt, k.fillMode),
  67248. this.getTransformMatrix(),
  67249. nt.setFloat3("biasAndScaleSM", this.bias, this.normalBias, this.depthScale),
  67250. this.getLight().getTypeID() === Light.LIGHTTYPEID_DIRECTIONALLIGHT ? nt.setVector3("lightDataSM", this._cachedDirection) : nt.setVector3("lightDataSM", this._cachedPosition),
  67251. _.activeCamera && nt.setFloat2("depthValuesSM", this.getLight().getDepthMinZ(_.activeCamera), this.getLight().getDepthMinZ(_.activeCamera) + this.getLight().getDepthMaxZ(_.activeCamera)),
  67252. i && this.enableSoftTransparentShadow && nt.setFloat("softTransparentShadowSM", d.visibility * k.alpha),
  67253. rt)
  67254. e._setMainDrawWrapperOverride(it),
  67255. rt.standalone ? rt.baseMaterial.bindForSubMesh(d.getWorldMatrix(), c, e) : k.bindForSubMesh(d.getWorldMatrix(), c, e),
  67256. e._setMainDrawWrapperOverride(null);
  67257. else {
  67258. if (k && k.needAlphaTesting()) {
  67259. var ot = k.getAlphaTestTexture();
  67260. ot && (nt.setTexture("diffuseSampler", ot),
  67261. nt.setMatrix("diffuseMatrix", ot.getTextureMatrix() || this._defaultTextureMatrix))
  67262. }
  67263. if (c.useBones && c.computeBonesUsingShaders && c.skeleton) {
  67264. var at = c.skeleton;
  67265. if (at.isUsingTextureForMatrices) {
  67266. var st = at.getTransformMatrixTexture(c);
  67267. if (!st)
  67268. return;
  67269. nt.setTexture("boneSampler", st),
  67270. nt.setFloat("boneTextureWidth", 4 * (at.bones.length + 1))
  67271. } else
  67272. nt.setMatrices("mBones", at.getTransformMatrices(c))
  67273. }
  67274. MaterialHelper.BindMorphTargetParameters(c, nt),
  67275. c.morphTargetManager && c.morphTargetManager.isUsingTextureForTargets && c.morphTargetManager._bind(nt),
  67276. MaterialHelper.BindClipPlane(nt, _)
  67277. }
  67278. !this._useUBO && !rt && this._bindCustomEffectForRenderSubMeshForShadowMap(e, nt, d),
  67279. MaterialHelper.BindSceneUniformBuffer(nt, this._scene.getSceneUniformBuffer()),
  67280. this._scene.getSceneUniformBuffer().bindUniformBuffer();
  67281. var ut = d.getWorldMatrix();
  67282. tt && (d.getMeshUniformBuffer().bindToEffect(nt, "Mesh"),
  67283. d.transferToEffect(ut)),
  67284. this.forceBackFacesOnly && b.setState(!0, 0, !1, !0, k.cullBackFaces),
  67285. this.onBeforeShadowMapRenderMeshObservable.notifyObservers(c),
  67286. this.onBeforeShadowMapRenderObservable.notifyObservers(nt),
  67287. c._processRendering(d, e, nt, k.fillMode, et, tt, function(ct, lt, ft, ht) {
  67288. ht && d !== ht ? (ht.getMeshUniformBuffer().bindToEffect(nt, "Mesh"),
  67289. ht.transferToEffect(lt)) : (d.getMeshUniformBuffer().bindToEffect(nt, "Mesh"),
  67290. d.transferToEffect(ut))
  67291. }),
  67292. this.forceBackFacesOnly && b.setState(!0, 0, !1, !1, k.cullBackFaces),
  67293. this.onAfterShadowMapRenderObservable.notifyObservers(nt),
  67294. this.onAfterShadowMapRenderMeshObservable.notifyObservers(c)
  67295. } else
  67296. this._shadowMap && this._shadowMap.resetRefreshCounter()
  67297. }
  67298. }
  67299. }
  67300. ,
  67301. a.prototype._applyFilterValues = function() {
  67302. !this._shadowMap || (this.filter === a.FILTER_NONE || this.filter === a.FILTER_PCSS ? this._shadowMap.updateSamplingMode(Texture.NEAREST_SAMPLINGMODE) : this._shadowMap.updateSamplingMode(Texture.BILINEAR_SAMPLINGMODE))
  67303. }
  67304. ,
  67305. a.prototype.forceCompilation = function(e, i) {
  67306. var o = this
  67307. , s = __assign({
  67308. useInstances: !1
  67309. }, i)
  67310. , c = this.getShadowMap();
  67311. if (!c) {
  67312. e && e(this);
  67313. return
  67314. }
  67315. var d = c.renderList;
  67316. if (!d) {
  67317. e && e(this);
  67318. return
  67319. }
  67320. for (var _ = new Array, b = 0, k = d; b < k.length; b++) {
  67321. var j = k[b];
  67322. _.push.apply(_, j.subMeshes)
  67323. }
  67324. if (_.length === 0) {
  67325. e && e(this);
  67326. return
  67327. }
  67328. var $ = 0
  67329. , _e = function() {
  67330. var et, tt;
  67331. if (!(!o._scene || !o._scene.getEngine())) {
  67332. for (; o.isReady(_[$], s.useInstances, (tt = (et = _[$].getMaterial()) === null || et === void 0 ? void 0 : et.needAlphaBlendingForMesh(_[$].getMesh())) !== null && tt !== void 0 ? tt : !1); )
  67333. if ($++,
  67334. $ >= _.length) {
  67335. e && e(o);
  67336. return
  67337. }
  67338. setTimeout(_e, 16)
  67339. }
  67340. };
  67341. _e()
  67342. }
  67343. ,
  67344. a.prototype.forceCompilationAsync = function(e) {
  67345. var i = this;
  67346. return new Promise(function(o) {
  67347. i.forceCompilation(function() {
  67348. o()
  67349. }, e)
  67350. }
  67351. )
  67352. }
  67353. ,
  67354. a.prototype._isReadyCustomDefines = function(e, i, o) {}
  67355. ,
  67356. a.prototype._prepareShadowDefines = function(e, i, o, s) {
  67357. o.push("#define SM_FLOAT " + (this._textureType !== 0 ? "1" : "0")),
  67358. o.push("#define SM_ESM " + (this.useExponentialShadowMap || this.useBlurExponentialShadowMap ? "1" : "0")),
  67359. o.push("#define SM_DEPTHTEXTURE " + (this.usePercentageCloserFiltering || this.useContactHardeningShadow ? "1" : "0"));
  67360. var c = e.getMesh();
  67361. return o.push("#define SM_NORMALBIAS " + (this.normalBias && c.isVerticesDataPresent(VertexBuffer.NormalKind) ? "1" : "0")),
  67362. o.push("#define SM_DIRECTIONINLIGHTDATA " + (this.getLight().getTypeID() === Light.LIGHTTYPEID_DIRECTIONALLIGHT ? "1" : "0")),
  67363. o.push("#define SM_USEDISTANCE " + (this._light.needCube() ? "1" : "0")),
  67364. o.push("#define SM_SOFTTRANSPARENTSHADOW " + (this.enableSoftTransparentShadow && s ? "1" : "0")),
  67365. this._isReadyCustomDefines(o, e, i),
  67366. o
  67367. }
  67368. ,
  67369. a.prototype.isReady = function(e, i, o) {
  67370. var s = e.getMaterial()
  67371. , c = s == null ? void 0 : s.shadowDepthWrapper
  67372. , d = [];
  67373. if (this._prepareShadowDefines(e, i, d, o),
  67374. c) {
  67375. if (!c.isReadyForSubMesh(e, d, this, i, this._scene.getEngine().currentRenderPassId))
  67376. return !1
  67377. } else {
  67378. var _ = e._getDrawWrapper(void 0, !0)
  67379. , b = _.effect
  67380. , k = _.defines
  67381. , j = [VertexBuffer.PositionKind]
  67382. , $ = e.getMesh();
  67383. if (this.normalBias && $.isVerticesDataPresent(VertexBuffer.NormalKind) && (j.push(VertexBuffer.NormalKind),
  67384. d.push("#define NORMAL"),
  67385. $.nonUniformScaling && d.push("#define NONUNIFORMSCALING")),
  67386. s && s.needAlphaTesting()) {
  67387. var _e = s.getAlphaTestTexture();
  67388. if (_e) {
  67389. if (!_e.isReady())
  67390. return !1;
  67391. d.push("#define ALPHATEST"),
  67392. $.isVerticesDataPresent(VertexBuffer.UVKind) && (j.push(VertexBuffer.UVKind),
  67393. d.push("#define UV1")),
  67394. $.isVerticesDataPresent(VertexBuffer.UV2Kind) && _e.coordinatesIndex === 1 && (j.push(VertexBuffer.UV2Kind),
  67395. d.push("#define UV2"))
  67396. }
  67397. }
  67398. var et = new EffectFallbacks;
  67399. if ($.useBones && $.computeBonesUsingShaders && $.skeleton) {
  67400. j.push(VertexBuffer.MatricesIndicesKind),
  67401. j.push(VertexBuffer.MatricesWeightsKind),
  67402. $.numBoneInfluencers > 4 && (j.push(VertexBuffer.MatricesIndicesExtraKind),
  67403. j.push(VertexBuffer.MatricesWeightsExtraKind));
  67404. var tt = $.skeleton;
  67405. d.push("#define NUM_BONE_INFLUENCERS " + $.numBoneInfluencers),
  67406. $.numBoneInfluencers > 0 && et.addCPUSkinningFallback(0, $),
  67407. tt.isUsingTextureForMatrices ? d.push("#define BONETEXTURE") : d.push("#define BonesPerMesh " + (tt.bones.length + 1))
  67408. } else
  67409. d.push("#define NUM_BONE_INFLUENCERS 0");
  67410. var rt = $.morphTargetManager
  67411. , it = 0;
  67412. rt && rt.numInfluencers > 0 && (d.push("#define MORPHTARGETS"),
  67413. it = rt.numInfluencers,
  67414. d.push("#define NUM_MORPH_INFLUENCERS " + it),
  67415. rt.isUsingTextureForTargets && d.push("#define MORPHTARGETS_TEXTURE"),
  67416. MaterialHelper.PrepareAttributesForMorphTargetsInfluencers(j, $, it));
  67417. var nt = this._scene;
  67418. if (nt.clipPlane && d.push("#define CLIPPLANE"),
  67419. nt.clipPlane2 && d.push("#define CLIPPLANE2"),
  67420. nt.clipPlane3 && d.push("#define CLIPPLANE3"),
  67421. nt.clipPlane4 && d.push("#define CLIPPLANE4"),
  67422. nt.clipPlane5 && d.push("#define CLIPPLANE5"),
  67423. nt.clipPlane6 && d.push("#define CLIPPLANE6"),
  67424. i && (d.push("#define INSTANCES"),
  67425. MaterialHelper.PushAttributesForInstances(j),
  67426. e.getRenderingMesh().hasThinInstances && d.push("#define THIN_INSTANCES")),
  67427. this.customShaderOptions && this.customShaderOptions.defines)
  67428. for (var ot = 0, at = this.customShaderOptions.defines; ot < at.length; ot++) {
  67429. var st = at[ot];
  67430. d.indexOf(st) === -1 && d.push(st)
  67431. }
  67432. var ut = d.join(`
  67433. `);
  67434. if (k !== ut) {
  67435. k = ut;
  67436. var ct = "shadowMap"
  67437. , lt = ["world", "mBones", "viewProjection", "diffuseMatrix", "lightDataSM", "depthValuesSM", "biasAndScaleSM", "morphTargetInfluences", "boneTextureWidth", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "softTransparentShadowSM", "morphTargetTextureInfo", "morphTargetTextureIndices"]
  67438. , ft = ["diffuseSampler", "boneSampler", "morphTargets"]
  67439. , ht = ["Scene", "Mesh"];
  67440. if (this.customShaderOptions) {
  67441. if (ct = this.customShaderOptions.shaderName,
  67442. this.customShaderOptions.attributes)
  67443. for (var pt = 0, dt = this.customShaderOptions.attributes; pt < dt.length; pt++) {
  67444. var _t = dt[pt];
  67445. j.indexOf(_t) === -1 && j.push(_t)
  67446. }
  67447. if (this.customShaderOptions.uniforms)
  67448. for (var mt = 0, vt = this.customShaderOptions.uniforms; mt < vt.length; mt++) {
  67449. var yt = vt[mt];
  67450. lt.indexOf(yt) === -1 && lt.push(yt)
  67451. }
  67452. if (this.customShaderOptions.samplers)
  67453. for (var Et = 0, At = this.customShaderOptions.samplers; Et < At.length; Et++) {
  67454. var gt = At[Et];
  67455. ft.indexOf(gt) === -1 && ft.push(gt)
  67456. }
  67457. }
  67458. var St = this._scene.getEngine();
  67459. b = St.createEffect(ct, {
  67460. attributes: j,
  67461. uniformsNames: lt,
  67462. uniformBuffersNames: ht,
  67463. samplers: ft,
  67464. defines: ut,
  67465. fallbacks: et,
  67466. onCompiled: null,
  67467. onError: null,
  67468. indexParameters: {
  67469. maxSimultaneousMorphTargets: it
  67470. }
  67471. }, St),
  67472. _.setEffect(b, k)
  67473. }
  67474. if (!b.isReady())
  67475. return !1
  67476. }
  67477. return (this.useBlurExponentialShadowMap || this.useBlurCloseExponentialShadowMap) && (!this._blurPostProcesses || !this._blurPostProcesses.length) && this._initializeBlurRTTAndPostProcesses(),
  67478. !(this._kernelBlurXPostprocess && !this._kernelBlurXPostprocess.isReady() || this._kernelBlurYPostprocess && !this._kernelBlurYPostprocess.isReady() || this._boxBlurPostprocess && !this._boxBlurPostprocess.isReady())
  67479. }
  67480. ,
  67481. a.prototype.prepareDefines = function(e, i) {
  67482. var o = this._scene
  67483. , s = this._light;
  67484. !o.shadowsEnabled || !s.shadowEnabled || (e["SHADOW" + i] = !0,
  67485. this.useContactHardeningShadow ? (e["SHADOWPCSS" + i] = !0,
  67486. this._filteringQuality === a.QUALITY_LOW ? e["SHADOWLOWQUALITY" + i] = !0 : this._filteringQuality === a.QUALITY_MEDIUM && (e["SHADOWMEDIUMQUALITY" + i] = !0)) : this.usePercentageCloserFiltering ? (e["SHADOWPCF" + i] = !0,
  67487. this._filteringQuality === a.QUALITY_LOW ? e["SHADOWLOWQUALITY" + i] = !0 : this._filteringQuality === a.QUALITY_MEDIUM && (e["SHADOWMEDIUMQUALITY" + i] = !0)) : this.usePoissonSampling ? e["SHADOWPOISSON" + i] = !0 : this.useExponentialShadowMap || this.useBlurExponentialShadowMap ? e["SHADOWESM" + i] = !0 : (this.useCloseExponentialShadowMap || this.useBlurCloseExponentialShadowMap) && (e["SHADOWCLOSEESM" + i] = !0),
  67488. s.needCube() && (e["SHADOWCUBE" + i] = !0))
  67489. }
  67490. ,
  67491. a.prototype.bindShadowLight = function(e, i) {
  67492. var o = this._light
  67493. , s = this._scene;
  67494. if (!(!s.shadowsEnabled || !o.shadowEnabled)) {
  67495. var c = s.activeCamera;
  67496. if (!!c) {
  67497. var d = this.getShadowMap();
  67498. !d || (o.needCube() || i.setMatrix("lightMatrix" + e, this.getTransformMatrix()),
  67499. this._filter === a.FILTER_PCF ? (i.setDepthStencilTexture("shadowSampler" + e, this.getShadowMapForRendering()),
  67500. o._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), d.getSize().width, 1 / d.getSize().width, this.frustumEdgeFalloff, e)) : this._filter === a.FILTER_PCSS ? (i.setDepthStencilTexture("shadowSampler" + e, this.getShadowMapForRendering()),
  67501. i.setTexture("depthSampler" + e, this.getShadowMapForRendering()),
  67502. o._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), 1 / d.getSize().width, this._contactHardeningLightSizeUVRatio * d.getSize().width, this.frustumEdgeFalloff, e)) : (i.setTexture("shadowSampler" + e, this.getShadowMapForRendering()),
  67503. o._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), this.blurScale / d.getSize().width, this.depthScale, this.frustumEdgeFalloff, e)),
  67504. o._uniformBuffer.updateFloat2("depthValues", this.getLight().getDepthMinZ(c), this.getLight().getDepthMinZ(c) + this.getLight().getDepthMaxZ(c), e))
  67505. }
  67506. }
  67507. }
  67508. ,
  67509. a.prototype.getTransformMatrix = function() {
  67510. var e = this._scene;
  67511. if (this._currentRenderId === e.getRenderId() && this._currentFaceIndexCache === this._currentFaceIndex)
  67512. return this._transformMatrix;
  67513. this._currentRenderId = e.getRenderId(),
  67514. this._currentFaceIndexCache = this._currentFaceIndex;
  67515. var i = this._light.position;
  67516. if (this._light.computeTransformedInformation() && (i = this._light.transformedPosition),
  67517. Vector3.NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex), this._lightDirection),
  67518. Math.abs(Vector3.Dot(this._lightDirection, Vector3.Up())) === 1 && (this._lightDirection.z = 1e-13),
  67519. this._light.needProjectionMatrixCompute() || !this._cachedPosition || !this._cachedDirection || !i.equals(this._cachedPosition) || !this._lightDirection.equals(this._cachedDirection)) {
  67520. this._cachedPosition.copyFrom(i),
  67521. this._cachedDirection.copyFrom(this._lightDirection),
  67522. Matrix.LookAtLHToRef(i, i.add(this._lightDirection), Vector3.Up(), this._viewMatrix);
  67523. var o = this.getShadowMap();
  67524. if (o) {
  67525. var s = o.renderList;
  67526. s && this._light.setShadowProjectionMatrix(this._projectionMatrix, this._viewMatrix, s)
  67527. }
  67528. this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix)
  67529. }
  67530. return this._transformMatrix
  67531. }
  67532. ,
  67533. a.prototype.recreateShadowMap = function() {
  67534. var e = this._shadowMap;
  67535. if (!!e) {
  67536. var i = e.renderList;
  67537. if (this._disposeRTTandPostProcesses(),
  67538. this._initializeGenerator(),
  67539. this.filter = this.filter,
  67540. this._applyFilterValues(),
  67541. i) {
  67542. this._shadowMap.renderList || (this._shadowMap.renderList = []);
  67543. for (var o = 0, s = i; o < s.length; o++) {
  67544. var c = s[o];
  67545. this._shadowMap.renderList.push(c)
  67546. }
  67547. } else
  67548. this._shadowMap.renderList = null
  67549. }
  67550. }
  67551. ,
  67552. a.prototype._disposeBlurPostProcesses = function() {
  67553. this._shadowMap2 && (this._shadowMap2.dispose(),
  67554. this._shadowMap2 = null),
  67555. this._boxBlurPostprocess && (this._boxBlurPostprocess.dispose(),
  67556. this._boxBlurPostprocess = null),
  67557. this._kernelBlurXPostprocess && (this._kernelBlurXPostprocess.dispose(),
  67558. this._kernelBlurXPostprocess = null),
  67559. this._kernelBlurYPostprocess && (this._kernelBlurYPostprocess.dispose(),
  67560. this._kernelBlurYPostprocess = null),
  67561. this._blurPostProcesses = []
  67562. }
  67563. ,
  67564. a.prototype._disposeRTTandPostProcesses = function() {
  67565. this._shadowMap && (this._shadowMap.dispose(),
  67566. this._shadowMap = null),
  67567. this._disposeBlurPostProcesses()
  67568. }
  67569. ,
  67570. a.prototype._disposeSceneUBOs = function() {
  67571. if (this._sceneUBOs) {
  67572. for (var e = 0, i = this._sceneUBOs; e < i.length; e++) {
  67573. var o = i[e];
  67574. o.dispose()
  67575. }
  67576. this._sceneUBOs = []
  67577. }
  67578. }
  67579. ,
  67580. a.prototype.dispose = function() {
  67581. this._disposeRTTandPostProcesses(),
  67582. this._disposeSceneUBOs(),
  67583. this._light && (this._light._shadowGenerator = null,
  67584. this._light._markMeshesAsLightDirty()),
  67585. this.onBeforeShadowMapRenderMeshObservable.clear(),
  67586. this.onBeforeShadowMapRenderObservable.clear(),
  67587. this.onAfterShadowMapRenderMeshObservable.clear(),
  67588. this.onAfterShadowMapRenderObservable.clear()
  67589. }
  67590. ,
  67591. a.prototype.serialize = function() {
  67592. var e = {}
  67593. , i = this.getShadowMap();
  67594. if (!i)
  67595. return e;
  67596. if (e.className = this.getClassName(),
  67597. e.lightId = this._light.id,
  67598. e.id = this.id,
  67599. e.mapSize = i.getRenderSize(),
  67600. e.forceBackFacesOnly = this.forceBackFacesOnly,
  67601. e.darkness = this.getDarkness(),
  67602. e.transparencyShadow = this._transparencyShadow,
  67603. e.frustumEdgeFalloff = this.frustumEdgeFalloff,
  67604. e.bias = this.bias,
  67605. e.normalBias = this.normalBias,
  67606. e.usePercentageCloserFiltering = this.usePercentageCloserFiltering,
  67607. e.useContactHardeningShadow = this.useContactHardeningShadow,
  67608. e.contactHardeningLightSizeUVRatio = this.contactHardeningLightSizeUVRatio,
  67609. e.filteringQuality = this.filteringQuality,
  67610. e.useExponentialShadowMap = this.useExponentialShadowMap,
  67611. e.useBlurExponentialShadowMap = this.useBlurExponentialShadowMap,
  67612. e.useCloseExponentialShadowMap = this.useBlurExponentialShadowMap,
  67613. e.useBlurCloseExponentialShadowMap = this.useBlurExponentialShadowMap,
  67614. e.usePoissonSampling = this.usePoissonSampling,
  67615. e.depthScale = this.depthScale,
  67616. e.blurBoxOffset = this.blurBoxOffset,
  67617. e.blurKernel = this.blurKernel,
  67618. e.blurScale = this.blurScale,
  67619. e.useKernelBlur = this.useKernelBlur,
  67620. e.renderList = [],
  67621. i.renderList)
  67622. for (var o = 0; o < i.renderList.length; o++) {
  67623. var s = i.renderList[o];
  67624. e.renderList.push(s.id)
  67625. }
  67626. return e
  67627. }
  67628. ,
  67629. a.Parse = function(e, i, o) {
  67630. for (var s = i.getLightById(e.lightId), c = o ? o(e.mapSize, s) : new a(e.mapSize,s), d = c.getShadowMap(), _ = 0; _ < e.renderList.length; _++) {
  67631. var b = i.getMeshesById(e.renderList[_]);
  67632. b.forEach(function(k) {
  67633. !d || (d.renderList || (d.renderList = []),
  67634. d.renderList.push(k))
  67635. })
  67636. }
  67637. return e.id !== void 0 && (c.id = e.id),
  67638. c.forceBackFacesOnly = !!e.forceBackFacesOnly,
  67639. e.darkness !== void 0 && c.setDarkness(e.darkness),
  67640. e.transparencyShadow && c.setTransparencyShadow(!0),
  67641. e.frustumEdgeFalloff !== void 0 && (c.frustumEdgeFalloff = e.frustumEdgeFalloff),
  67642. e.bias !== void 0 && (c.bias = e.bias),
  67643. e.normalBias !== void 0 && (c.normalBias = e.normalBias),
  67644. e.usePercentageCloserFiltering ? c.usePercentageCloserFiltering = !0 : e.useContactHardeningShadow ? c.useContactHardeningShadow = !0 : e.usePoissonSampling ? c.usePoissonSampling = !0 : e.useExponentialShadowMap ? c.useExponentialShadowMap = !0 : e.useBlurExponentialShadowMap ? c.useBlurExponentialShadowMap = !0 : e.useCloseExponentialShadowMap ? c.useCloseExponentialShadowMap = !0 : e.useBlurCloseExponentialShadowMap ? c.useBlurCloseExponentialShadowMap = !0 : e.useVarianceShadowMap ? c.useExponentialShadowMap = !0 : e.useBlurVarianceShadowMap && (c.useBlurExponentialShadowMap = !0),
  67645. e.contactHardeningLightSizeUVRatio !== void 0 && (c.contactHardeningLightSizeUVRatio = e.contactHardeningLightSizeUVRatio),
  67646. e.filteringQuality !== void 0 && (c.filteringQuality = e.filteringQuality),
  67647. e.depthScale && (c.depthScale = e.depthScale),
  67648. e.blurScale && (c.blurScale = e.blurScale),
  67649. e.blurBoxOffset && (c.blurBoxOffset = e.blurBoxOffset),
  67650. e.useKernelBlur && (c.useKernelBlur = e.useKernelBlur),
  67651. e.blurKernel && (c.blurKernel = e.blurKernel),
  67652. c
  67653. }
  67654. ,
  67655. a.CLASSNAME = "ShadowGenerator",
  67656. a.FILTER_NONE = 0,
  67657. a.FILTER_EXPONENTIALSHADOWMAP = 1,
  67658. a.FILTER_POISSONSAMPLING = 2,
  67659. a.FILTER_BLUREXPONENTIALSHADOWMAP = 3,
  67660. a.FILTER_CLOSEEXPONENTIALSHADOWMAP = 4,
  67661. a.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP = 5,
  67662. a.FILTER_PCF = 6,
  67663. a.FILTER_PCSS = 7,
  67664. a.QUALITY_HIGH = 0,
  67665. a.QUALITY_MEDIUM = 1,
  67666. a.QUALITY_LOW = 2,
  67667. a._SceneComponentInitialization = function(e) {
  67668. throw _WarnImport("ShadowGeneratorSceneComponent")
  67669. }
  67670. ,
  67671. a
  67672. }()
  67673. , PushMaterial = function(a) {
  67674. __extends(e, a);
  67675. function e(i, o, s) {
  67676. s === void 0 && (s = !0);
  67677. var c = a.call(this, i, o) || this;
  67678. return c._normalMatrix = new Matrix,
  67679. c._storeEffectOnSubMeshes = s,
  67680. c
  67681. }
  67682. return e.prototype.getEffect = function() {
  67683. return this._storeEffectOnSubMeshes ? this._activeEffect : a.prototype.getEffect.call(this)
  67684. }
  67685. ,
  67686. e.prototype.isReady = function(i, o) {
  67687. return i ? !this._storeEffectOnSubMeshes || !i.subMeshes || i.subMeshes.length === 0 ? !0 : this.isReadyForSubMesh(i, i.subMeshes[0], o) : !1
  67688. }
  67689. ,
  67690. e.prototype._isReadyForSubMesh = function(i) {
  67691. var o = i.materialDefines;
  67692. return !!(!this.checkReadyOnEveryCall && i.effect && o && o._renderId === this.getScene().getRenderId())
  67693. }
  67694. ,
  67695. e.prototype.bindOnlyWorldMatrix = function(i) {
  67696. this._activeEffect.setMatrix("world", i)
  67697. }
  67698. ,
  67699. e.prototype.bindOnlyNormalMatrix = function(i) {
  67700. this._activeEffect.setMatrix("normalMatrix", i)
  67701. }
  67702. ,
  67703. e.prototype.bind = function(i, o) {
  67704. !o || this.bindForSubMesh(i, o, o.subMeshes[0])
  67705. }
  67706. ,
  67707. e.prototype._afterBind = function(i, o) {
  67708. o === void 0 && (o = null),
  67709. a.prototype._afterBind.call(this, i, o),
  67710. this.getScene()._cachedEffect = o
  67711. }
  67712. ,
  67713. e.prototype._mustRebind = function(i, o, s) {
  67714. return s === void 0 && (s = 1),
  67715. i.isCachedMaterialInvalid(this, o, s)
  67716. }
  67717. ,
  67718. e
  67719. }(Material)
  67720. , onCreatedEffectParameters$3 = {
  67721. effect: null,
  67722. subMesh: null
  67723. }
  67724. , ShaderMaterial = function(a) {
  67725. __extends(e, a);
  67726. function e(i, o, s, c, d) {
  67727. c === void 0 && (c = {}),
  67728. d === void 0 && (d = !0);
  67729. var _ = a.call(this, i, o, d) || this;
  67730. return _._textures = {},
  67731. _._textureArrays = {},
  67732. _._externalTextures = {},
  67733. _._floats = {},
  67734. _._ints = {},
  67735. _._floatsArrays = {},
  67736. _._colors3 = {},
  67737. _._colors3Arrays = {},
  67738. _._colors4 = {},
  67739. _._colors4Arrays = {},
  67740. _._vectors2 = {},
  67741. _._vectors3 = {},
  67742. _._vectors4 = {},
  67743. _._matrices = {},
  67744. _._matrixArrays = {},
  67745. _._matrices3x3 = {},
  67746. _._matrices2x2 = {},
  67747. _._vectors2Arrays = {},
  67748. _._vectors3Arrays = {},
  67749. _._vectors4Arrays = {},
  67750. _._uniformBuffers = {},
  67751. _._textureSamplers = {},
  67752. _._storageBuffers = {},
  67753. _._cachedWorldViewMatrix = new Matrix,
  67754. _._cachedWorldViewProjectionMatrix = new Matrix,
  67755. _._multiview = !1,
  67756. _._shaderPath = s,
  67757. _._options = __assign({
  67758. needAlphaBlending: !1,
  67759. needAlphaTesting: !1,
  67760. attributes: ["position", "normal", "uv"],
  67761. uniforms: ["worldViewProjection"],
  67762. uniformBuffers: [],
  67763. samplers: [],
  67764. externalTextures: [],
  67765. samplerObjects: [],
  67766. storageBuffers: [],
  67767. defines: [],
  67768. useClipPlane: !1
  67769. }, c),
  67770. _
  67771. }
  67772. return Object.defineProperty(e.prototype, "shaderPath", {
  67773. get: function() {
  67774. return this._shaderPath
  67775. },
  67776. set: function(i) {
  67777. this._shaderPath = i
  67778. },
  67779. enumerable: !1,
  67780. configurable: !0
  67781. }),
  67782. Object.defineProperty(e.prototype, "options", {
  67783. get: function() {
  67784. return this._options
  67785. },
  67786. enumerable: !1,
  67787. configurable: !0
  67788. }),
  67789. e.prototype.getClassName = function() {
  67790. return "ShaderMaterial"
  67791. }
  67792. ,
  67793. e.prototype.needAlphaBlending = function() {
  67794. return this.alpha < 1 || this._options.needAlphaBlending
  67795. }
  67796. ,
  67797. e.prototype.needAlphaTesting = function() {
  67798. return this._options.needAlphaTesting
  67799. }
  67800. ,
  67801. e.prototype._checkUniform = function(i) {
  67802. this._options.uniforms.indexOf(i) === -1 && this._options.uniforms.push(i)
  67803. }
  67804. ,
  67805. e.prototype.setTexture = function(i, o) {
  67806. return this._options.samplers.indexOf(i) === -1 && this._options.samplers.push(i),
  67807. this._textures[i] = o,
  67808. this
  67809. }
  67810. ,
  67811. e.prototype.setTextureArray = function(i, o) {
  67812. return this._options.samplers.indexOf(i) === -1 && this._options.samplers.push(i),
  67813. this._checkUniform(i),
  67814. this._textureArrays[i] = o,
  67815. this
  67816. }
  67817. ,
  67818. e.prototype.setExternalTexture = function(i, o) {
  67819. return this._options.externalTextures.indexOf(i) === -1 && this._options.externalTextures.push(i),
  67820. this._externalTextures[i] = o,
  67821. this
  67822. }
  67823. ,
  67824. e.prototype.setFloat = function(i, o) {
  67825. return this._checkUniform(i),
  67826. this._floats[i] = o,
  67827. this
  67828. }
  67829. ,
  67830. e.prototype.setInt = function(i, o) {
  67831. return this._checkUniform(i),
  67832. this._ints[i] = o,
  67833. this
  67834. }
  67835. ,
  67836. e.prototype.setFloats = function(i, o) {
  67837. return this._checkUniform(i),
  67838. this._floatsArrays[i] = o,
  67839. this
  67840. }
  67841. ,
  67842. e.prototype.setColor3 = function(i, o) {
  67843. return this._checkUniform(i),
  67844. this._colors3[i] = o,
  67845. this
  67846. }
  67847. ,
  67848. e.prototype.setColor3Array = function(i, o) {
  67849. return this._checkUniform(i),
  67850. this._colors3Arrays[i] = o.reduce(function(s, c) {
  67851. return c.toArray(s, s.length),
  67852. s
  67853. }, []),
  67854. this
  67855. }
  67856. ,
  67857. e.prototype.setColor4 = function(i, o) {
  67858. return this._checkUniform(i),
  67859. this._colors4[i] = o,
  67860. this
  67861. }
  67862. ,
  67863. e.prototype.setColor4Array = function(i, o) {
  67864. return this._checkUniform(i),
  67865. this._colors4Arrays[i] = o.reduce(function(s, c) {
  67866. return c.toArray(s, s.length),
  67867. s
  67868. }, []),
  67869. this
  67870. }
  67871. ,
  67872. e.prototype.setVector2 = function(i, o) {
  67873. return this._checkUniform(i),
  67874. this._vectors2[i] = o,
  67875. this
  67876. }
  67877. ,
  67878. e.prototype.setVector3 = function(i, o) {
  67879. return this._checkUniform(i),
  67880. this._vectors3[i] = o,
  67881. this
  67882. }
  67883. ,
  67884. e.prototype.setVector4 = function(i, o) {
  67885. return this._checkUniform(i),
  67886. this._vectors4[i] = o,
  67887. this
  67888. }
  67889. ,
  67890. e.prototype.setMatrix = function(i, o) {
  67891. return this._checkUniform(i),
  67892. this._matrices[i] = o,
  67893. this
  67894. }
  67895. ,
  67896. e.prototype.setMatrices = function(i, o) {
  67897. this._checkUniform(i);
  67898. for (var s = new Float32Array(o.length * 16), c = 0; c < o.length; c++) {
  67899. var d = o[c];
  67900. d.copyToArray(s, c * 16)
  67901. }
  67902. return this._matrixArrays[i] = s,
  67903. this
  67904. }
  67905. ,
  67906. e.prototype.setMatrix3x3 = function(i, o) {
  67907. return this._checkUniform(i),
  67908. this._matrices3x3[i] = o,
  67909. this
  67910. }
  67911. ,
  67912. e.prototype.setMatrix2x2 = function(i, o) {
  67913. return this._checkUniform(i),
  67914. this._matrices2x2[i] = o,
  67915. this
  67916. }
  67917. ,
  67918. e.prototype.setArray2 = function(i, o) {
  67919. return this._checkUniform(i),
  67920. this._vectors2Arrays[i] = o,
  67921. this
  67922. }
  67923. ,
  67924. e.prototype.setArray3 = function(i, o) {
  67925. return this._checkUniform(i),
  67926. this._vectors3Arrays[i] = o,
  67927. this
  67928. }
  67929. ,
  67930. e.prototype.setArray4 = function(i, o) {
  67931. return this._checkUniform(i),
  67932. this._vectors4Arrays[i] = o,
  67933. this
  67934. }
  67935. ,
  67936. e.prototype.setUniformBuffer = function(i, o) {
  67937. return this._options.uniformBuffers.indexOf(i) === -1 && this._options.uniformBuffers.push(i),
  67938. this._uniformBuffers[i] = o,
  67939. this
  67940. }
  67941. ,
  67942. e.prototype.setTextureSampler = function(i, o) {
  67943. return this._options.samplerObjects.indexOf(i) === -1 && this._options.samplerObjects.push(i),
  67944. this._textureSamplers[i] = o,
  67945. this
  67946. }
  67947. ,
  67948. e.prototype.setStorageBuffer = function(i, o) {
  67949. return this._options.storageBuffers.indexOf(i) === -1 && this._options.storageBuffers.push(i),
  67950. this._storageBuffers[i] = o,
  67951. this
  67952. }
  67953. ,
  67954. e.prototype.isReadyForSubMesh = function(i, o, s) {
  67955. return this.isReady(i, s, o)
  67956. }
  67957. ,
  67958. e.prototype.isReady = function(i, o, s) {
  67959. var c, d, _, b, k = s && this._storeEffectOnSubMeshes;
  67960. if (this.isFrozen)
  67961. if (k) {
  67962. if (s.effect && s.effect._wasPreviouslyReady)
  67963. return !0
  67964. } else {
  67965. var j = this._drawWrapper.effect;
  67966. if (j && j._wasPreviouslyReady && this._effectUsesInstances === o)
  67967. return !0
  67968. }
  67969. var $ = this.getScene()
  67970. , _e = $.getEngine()
  67971. , et = []
  67972. , tt = []
  67973. , rt = new EffectFallbacks
  67974. , it = this._shaderPath
  67975. , nt = this._options.uniforms
  67976. , ot = this._options.uniformBuffers
  67977. , at = this._options.samplers;
  67978. _e.getCaps().multiview && $.activeCamera && $.activeCamera.outputRenderTarget && $.activeCamera.outputRenderTarget.getViewCount() > 1 && (this._multiview = !0,
  67979. et.push("#define MULTIVIEW"),
  67980. this._options.uniforms.indexOf("viewProjection") !== -1 && this._options.uniforms.indexOf("viewProjectionR") === -1 && this._options.uniforms.push("viewProjectionR"));
  67981. for (var st = 0; st < this._options.defines.length; st++) {
  67982. var ut = this._options.defines[st].indexOf("#define") === 0 ? this._options.defines[st] : "#define " + this._options.defines[st];
  67983. et.push(ut)
  67984. }
  67985. for (var st = 0; st < this._options.attributes.length; st++)
  67986. tt.push(this._options.attributes[st]);
  67987. if (i && i.isVerticesDataPresent(VertexBuffer.ColorKind) && (tt.push(VertexBuffer.ColorKind),
  67988. et.push("#define VERTEXCOLOR")),
  67989. o && (et.push("#define INSTANCES"),
  67990. MaterialHelper.PushAttributesForInstances(tt),
  67991. i != null && i.hasThinInstances && et.push("#define THIN_INSTANCES")),
  67992. i && i.useBones && i.computeBonesUsingShaders && i.skeleton) {
  67993. tt.push(VertexBuffer.MatricesIndicesKind),
  67994. tt.push(VertexBuffer.MatricesWeightsKind),
  67995. i.numBoneInfluencers > 4 && (tt.push(VertexBuffer.MatricesIndicesExtraKind),
  67996. tt.push(VertexBuffer.MatricesWeightsExtraKind));
  67997. var ct = i.skeleton;
  67998. et.push("#define NUM_BONE_INFLUENCERS " + i.numBoneInfluencers),
  67999. rt.addCPUSkinningFallback(0, i),
  68000. ct.isUsingTextureForMatrices ? (et.push("#define BONETEXTURE"),
  68001. this._options.uniforms.indexOf("boneTextureWidth") === -1 && this._options.uniforms.push("boneTextureWidth"),
  68002. this._options.samplers.indexOf("boneSampler") === -1 && this._options.samplers.push("boneSampler")) : (et.push("#define BonesPerMesh " + (ct.bones.length + 1)),
  68003. this._options.uniforms.indexOf("mBones") === -1 && this._options.uniforms.push("mBones"))
  68004. } else
  68005. et.push("#define NUM_BONE_INFLUENCERS 0");
  68006. var lt = 0
  68007. , ft = i ? i.morphTargetManager : null;
  68008. if (ft) {
  68009. var ht = ft.supportsUVs && et.indexOf("#define UV1") !== -1
  68010. , pt = ft.supportsTangents && et.indexOf("#define TANGENT") !== -1
  68011. , dt = ft.supportsNormals && et.indexOf("#define NORMAL") !== -1;
  68012. lt = ft.numInfluencers,
  68013. ht && et.push("#define MORPHTARGETS_UV"),
  68014. pt && et.push("#define MORPHTARGETS_TANGENT"),
  68015. dt && et.push("#define MORPHTARGETS_NORMAL"),
  68016. lt > 0 && et.push("#define MORPHTARGETS"),
  68017. ft.isUsingTextureForTargets && (et.push("#define MORPHTARGETS_TEXTURE"),
  68018. this._options.uniforms.indexOf("morphTargetTextureIndices") === -1 && this._options.uniforms.push("morphTargetTextureIndices"),
  68019. this._options.samplers.indexOf("morphTargets") === -1 && this._options.samplers.push("morphTargets")),
  68020. et.push("#define NUM_MORPH_INFLUENCERS " + lt);
  68021. for (var st = 0; st < lt; st++)
  68022. tt.push(VertexBuffer.PositionKind + st),
  68023. dt && tt.push(VertexBuffer.NormalKind + st),
  68024. pt && tt.push(VertexBuffer.TangentKind + st),
  68025. ht && tt.push(VertexBuffer.UVKind + "_" + st);
  68026. lt > 0 && (nt = nt.slice(),
  68027. nt.push("morphTargetInfluences"),
  68028. nt.push("morphTargetTextureInfo"),
  68029. nt.push("morphTargetTextureIndices"))
  68030. } else
  68031. et.push("#define NUM_MORPH_INFLUENCERS 0");
  68032. if (i) {
  68033. var _t = i.bakedVertexAnimationManager;
  68034. _t && _t.isEnabled && (et.push("#define BAKED_VERTEX_ANIMATION_TEXTURE"),
  68035. this._options.uniforms.indexOf("bakedVertexAnimationSettings") === -1 && this._options.uniforms.push("bakedVertexAnimationSettings"),
  68036. this._options.uniforms.indexOf("bakedVertexAnimationTextureSizeInverted") === -1 && this._options.uniforms.push("bakedVertexAnimationTextureSizeInverted"),
  68037. this._options.uniforms.indexOf("bakedVertexAnimationTime") === -1 && this._options.uniforms.push("bakedVertexAnimationTime"),
  68038. this._options.samplers.indexOf("bakedVertexAnimationTexture") === -1 && this._options.samplers.push("bakedVertexAnimationTexture")),
  68039. MaterialHelper.PrepareAttributesForBakedVertexAnimation(tt, i, et)
  68040. }
  68041. for (var mt in this._textures)
  68042. if (!this._textures[mt].isReady())
  68043. return !1;
  68044. i && this._shouldTurnAlphaTestOn(i) && et.push("#define ALPHATEST"),
  68045. (this._options.useClipPlane === null && !!$.clipPlane || this._options.useClipPlane) && (et.push("#define CLIPPLANE"),
  68046. nt.indexOf("vClipPlane") === -1 && nt.push("vClipPlane")),
  68047. (this._options.useClipPlane === null && !!$.clipPlane2 || this._options.useClipPlane) && (et.push("#define CLIPPLANE2"),
  68048. nt.indexOf("vClipPlane2") === -1 && nt.push("vClipPlane2")),
  68049. (this._options.useClipPlane === null && !!$.clipPlane3 || this._options.useClipPlane) && (et.push("#define CLIPPLANE3"),
  68050. nt.indexOf("vClipPlane3") === -1 && nt.push("vClipPlane3")),
  68051. (this._options.useClipPlane === null && !!$.clipPlane4 || this._options.useClipPlane) && (et.push("#define CLIPPLANE4"),
  68052. nt.indexOf("vClipPlane4") === -1 && nt.push("vClipPlane4")),
  68053. (this._options.useClipPlane === null && !!$.clipPlane5 || this._options.useClipPlane) && (et.push("#define CLIPPLANE5"),
  68054. nt.indexOf("vClipPlane5") === -1 && nt.push("vClipPlane5")),
  68055. (this._options.useClipPlane === null && !!$.clipPlane6 || this._options.useClipPlane) && (et.push("#define CLIPPLANE6"),
  68056. nt.indexOf("vClipPlane6") === -1 && nt.push("vClipPlane6")),
  68057. this.customShaderNameResolve && (nt = nt.slice(),
  68058. ot = ot.slice(),
  68059. at = at.slice(),
  68060. it = this.customShaderNameResolve(it, nt, ot, at, et, tt));
  68061. var vt = k ? s._getDrawWrapper() : this._drawWrapper
  68062. , yt = (c = vt == null ? void 0 : vt.effect) !== null && c !== void 0 ? c : null
  68063. , Et = (d = vt == null ? void 0 : vt.defines) !== null && d !== void 0 ? d : null
  68064. , At = et.join(`
  68065. `)
  68066. , gt = yt;
  68067. return Et !== At && (gt = _e.createEffect(it, {
  68068. attributes: tt,
  68069. uniformsNames: nt,
  68070. uniformBuffersNames: ot,
  68071. samplers: at,
  68072. defines: At,
  68073. fallbacks: rt,
  68074. onCompiled: this.onCompiled,
  68075. onError: this.onError,
  68076. indexParameters: {
  68077. maxSimultaneousMorphTargets: lt
  68078. },
  68079. shaderLanguage: this._options.shaderLanguage
  68080. }, _e),
  68081. k ? s.setEffect(gt, At, this._materialContext) : vt && vt.setEffect(gt, At),
  68082. this._onEffectCreatedObservable && (onCreatedEffectParameters$3.effect = gt,
  68083. onCreatedEffectParameters$3.subMesh = (_ = s != null ? s : i == null ? void 0 : i.subMeshes[0]) !== null && _ !== void 0 ? _ : null,
  68084. this._onEffectCreatedObservable.notifyObservers(onCreatedEffectParameters$3))),
  68085. this._effectUsesInstances = !!o,
  68086. !((b = !(gt != null && gt.isReady())) !== null && b !== void 0) || b ? !1 : (yt !== gt && $.resetCachedMaterial(),
  68087. gt._wasPreviouslyReady = !0,
  68088. !0)
  68089. }
  68090. ,
  68091. e.prototype.bindOnlyWorldMatrix = function(i, o) {
  68092. var s = this.getScene()
  68093. , c = o != null ? o : this.getEffect();
  68094. !c || (this._options.uniforms.indexOf("world") !== -1 && c.setMatrix("world", i),
  68095. this._options.uniforms.indexOf("worldView") !== -1 && (i.multiplyToRef(s.getViewMatrix(), this._cachedWorldViewMatrix),
  68096. c.setMatrix("worldView", this._cachedWorldViewMatrix)),
  68097. this._options.uniforms.indexOf("worldViewProjection") !== -1 && (i.multiplyToRef(s.getTransformMatrix(), this._cachedWorldViewProjectionMatrix),
  68098. c.setMatrix("worldViewProjection", this._cachedWorldViewProjectionMatrix)))
  68099. }
  68100. ,
  68101. e.prototype.bindForSubMesh = function(i, o, s) {
  68102. var c;
  68103. this.bind(i, o, (c = s._drawWrapperOverride) === null || c === void 0 ? void 0 : c.effect, s)
  68104. }
  68105. ,
  68106. e.prototype.bind = function(i, o, s, c) {
  68107. var d, _ = c && this._storeEffectOnSubMeshes, b = s != null ? s : _ ? c.effect : this.getEffect();
  68108. if (!!b) {
  68109. this._activeEffect = b,
  68110. this.bindOnlyWorldMatrix(i, s);
  68111. var k = this._options.uniformBuffers
  68112. , j = !1;
  68113. if (b && k && k.length > 0 && this.getScene().getEngine().supportsUniformBuffers)
  68114. for (var $ = 0; $ < k.length; ++$) {
  68115. var _e = k[$];
  68116. switch (_e) {
  68117. case "Mesh":
  68118. o && (o.getMeshUniformBuffer().bindToEffect(b, "Mesh"),
  68119. o.transferToEffect(i));
  68120. break;
  68121. case "Scene":
  68122. MaterialHelper.BindSceneUniformBuffer(b, this.getScene().getSceneUniformBuffer()),
  68123. this.getScene().finalizeSceneUbo(),
  68124. j = !0;
  68125. break
  68126. }
  68127. }
  68128. var et = o && _ ? this._mustRebind(this.getScene(), b, o.visibility) : this.getScene().getCachedMaterial() !== this;
  68129. if (b && et) {
  68130. !j && this._options.uniforms.indexOf("view") !== -1 && b.setMatrix("view", this.getScene().getViewMatrix()),
  68131. !j && this._options.uniforms.indexOf("projection") !== -1 && b.setMatrix("projection", this.getScene().getProjectionMatrix()),
  68132. !j && this._options.uniforms.indexOf("viewProjection") !== -1 && (b.setMatrix("viewProjection", this.getScene().getTransformMatrix()),
  68133. this._multiview && b.setMatrix("viewProjectionR", this.getScene()._transformMatrixR)),
  68134. this.getScene().activeCamera && this._options.uniforms.indexOf("cameraPosition") !== -1 && b.setVector3("cameraPosition", this.getScene().activeCamera.globalPosition),
  68135. MaterialHelper.BindBonesParameters(o, b),
  68136. MaterialHelper.BindClipPlane(b, this.getScene());
  68137. var tt;
  68138. for (tt in this._textures)
  68139. b.setTexture(tt, this._textures[tt]);
  68140. for (tt in this._textureArrays)
  68141. b.setTextureArray(tt, this._textureArrays[tt]);
  68142. for (tt in this._externalTextures)
  68143. b.setExternalTexture(tt, this._externalTextures[tt]);
  68144. for (tt in this._ints)
  68145. b.setInt(tt, this._ints[tt]);
  68146. for (tt in this._floats)
  68147. b.setFloat(tt, this._floats[tt]);
  68148. for (tt in this._floatsArrays)
  68149. b.setArray(tt, this._floatsArrays[tt]);
  68150. for (tt in this._colors3)
  68151. b.setColor3(tt, this._colors3[tt]);
  68152. for (tt in this._colors3Arrays)
  68153. b.setArray3(tt, this._colors3Arrays[tt]);
  68154. for (tt in this._colors4) {
  68155. var rt = this._colors4[tt];
  68156. b.setFloat4(tt, rt.r, rt.g, rt.b, rt.a)
  68157. }
  68158. for (tt in this._colors4Arrays)
  68159. b.setArray4(tt, this._colors4Arrays[tt]);
  68160. for (tt in this._vectors2)
  68161. b.setVector2(tt, this._vectors2[tt]);
  68162. for (tt in this._vectors3)
  68163. b.setVector3(tt, this._vectors3[tt]);
  68164. for (tt in this._vectors4)
  68165. b.setVector4(tt, this._vectors4[tt]);
  68166. for (tt in this._matrices)
  68167. b.setMatrix(tt, this._matrices[tt]);
  68168. for (tt in this._matrixArrays)
  68169. b.setMatrices(tt, this._matrixArrays[tt]);
  68170. for (tt in this._matrices3x3)
  68171. b.setMatrix3x3(tt, this._matrices3x3[tt]);
  68172. for (tt in this._matrices2x2)
  68173. b.setMatrix2x2(tt, this._matrices2x2[tt]);
  68174. for (tt in this._vectors2Arrays)
  68175. b.setArray2(tt, this._vectors2Arrays[tt]);
  68176. for (tt in this._vectors3Arrays)
  68177. b.setArray3(tt, this._vectors3Arrays[tt]);
  68178. for (tt in this._vectors4Arrays)
  68179. b.setArray4(tt, this._vectors4Arrays[tt]);
  68180. for (tt in this._uniformBuffers) {
  68181. var it = this._uniformBuffers[tt].getBuffer();
  68182. it && b.bindUniformBuffer(it, tt)
  68183. }
  68184. for (tt in this._textureSamplers)
  68185. b.setTextureSampler(tt, this._textureSamplers[tt]);
  68186. for (tt in this._storageBuffers)
  68187. b.setStorageBuffer(tt, this._storageBuffers[tt])
  68188. }
  68189. if (b && o && (et || !this.isFrozen)) {
  68190. var nt = o.morphTargetManager;
  68191. nt && nt.numInfluencers > 0 && MaterialHelper.BindMorphTargetParameters(o, b);
  68192. var ot = o.bakedVertexAnimationManager;
  68193. ot && ot.isEnabled && ((d = o.bakedVertexAnimationManager) === null || d === void 0 || d.bind(b, this._effectUsesInstances))
  68194. }
  68195. this._afterBind(o, b)
  68196. }
  68197. }
  68198. ,
  68199. e.prototype.getActiveTextures = function() {
  68200. var i = a.prototype.getActiveTextures.call(this);
  68201. for (var o in this._textures)
  68202. i.push(this._textures[o]);
  68203. for (var o in this._textureArrays)
  68204. for (var s = this._textureArrays[o], c = 0; c < s.length; c++)
  68205. i.push(s[c]);
  68206. return i
  68207. }
  68208. ,
  68209. e.prototype.hasTexture = function(i) {
  68210. if (a.prototype.hasTexture.call(this, i))
  68211. return !0;
  68212. for (var o in this._textures)
  68213. if (this._textures[o] === i)
  68214. return !0;
  68215. for (var o in this._textureArrays)
  68216. for (var s = this._textureArrays[o], c = 0; c < s.length; c++)
  68217. if (s[c] === i)
  68218. return !0;
  68219. return !1
  68220. }
  68221. ,
  68222. e.prototype.clone = function(i) {
  68223. var o = this
  68224. , s = SerializationHelper.Clone(function() {
  68225. return new e(i,o.getScene(),o._shaderPath,o._options,o._storeEffectOnSubMeshes)
  68226. }, this);
  68227. s.name = i,
  68228. s.id = i,
  68229. typeof s._shaderPath == "object" && (s._shaderPath = __assign({}, s._shaderPath)),
  68230. this._options = __assign({}, this._options),
  68231. Object.keys(this._options).forEach(function(d) {
  68232. var _ = o._options[d];
  68233. Array.isArray(_) && (o._options[d] = _.slice(0))
  68234. }),
  68235. this.stencil.copyTo(s.stencil);
  68236. for (var c in this._textures)
  68237. s.setTexture(c, this._textures[c]);
  68238. for (var c in this._textureArrays)
  68239. s.setTextureArray(c, this._textureArrays[c]);
  68240. for (var c in this._externalTextures)
  68241. s.setExternalTexture(c, this._externalTextures[c]);
  68242. for (var c in this._ints)
  68243. s.setInt(c, this._ints[c]);
  68244. for (var c in this._floats)
  68245. s.setFloat(c, this._floats[c]);
  68246. for (var c in this._floatsArrays)
  68247. s.setFloats(c, this._floatsArrays[c]);
  68248. for (var c in this._colors3)
  68249. s.setColor3(c, this._colors3[c]);
  68250. for (var c in this._colors3Arrays)
  68251. s._colors3Arrays[c] = this._colors3Arrays[c];
  68252. for (var c in this._colors4)
  68253. s.setColor4(c, this._colors4[c]);
  68254. for (var c in this._colors4Arrays)
  68255. s._colors4Arrays[c] = this._colors4Arrays[c];
  68256. for (var c in this._vectors2)
  68257. s.setVector2(c, this._vectors2[c]);
  68258. for (var c in this._vectors3)
  68259. s.setVector3(c, this._vectors3[c]);
  68260. for (var c in this._vectors4)
  68261. s.setVector4(c, this._vectors4[c]);
  68262. for (var c in this._matrices)
  68263. s.setMatrix(c, this._matrices[c]);
  68264. for (var c in this._matrixArrays)
  68265. s._matrixArrays[c] = this._matrixArrays[c].slice();
  68266. for (var c in this._matrices3x3)
  68267. s.setMatrix3x3(c, this._matrices3x3[c]);
  68268. for (var c in this._matrices2x2)
  68269. s.setMatrix2x2(c, this._matrices2x2[c]);
  68270. for (var c in this._vectors2Arrays)
  68271. s.setArray2(c, this._vectors2Arrays[c]);
  68272. for (var c in this._vectors3Arrays)
  68273. s.setArray3(c, this._vectors3Arrays[c]);
  68274. for (var c in this._vectors4Arrays)
  68275. s.setArray4(c, this._vectors4Arrays[c]);
  68276. for (var c in this._uniformBuffers)
  68277. s.setUniformBuffer(c, this._uniformBuffers[c]);
  68278. for (var c in this._textureSamplers)
  68279. s.setTextureSampler(c, this._textureSamplers[c]);
  68280. for (var c in this._storageBuffers)
  68281. s.setStorageBuffer(c, this._storageBuffers[c]);
  68282. return s
  68283. }
  68284. ,
  68285. e.prototype.dispose = function(i, o, s) {
  68286. if (o) {
  68287. var c;
  68288. for (c in this._textures)
  68289. this._textures[c].dispose();
  68290. for (c in this._textureArrays)
  68291. for (var d = this._textureArrays[c], _ = 0; _ < d.length; _++)
  68292. d[_].dispose()
  68293. }
  68294. this._textures = {},
  68295. a.prototype.dispose.call(this, i, o, s)
  68296. }
  68297. ,
  68298. e.prototype.serialize = function() {
  68299. var i = SerializationHelper.Serialize(this);
  68300. i.customType = "BABYLON.ShaderMaterial",
  68301. i.options = this._options,
  68302. i.shaderPath = this._shaderPath,
  68303. i.storeEffectOnSubMeshes = this._storeEffectOnSubMeshes;
  68304. var o;
  68305. i.stencil = this.stencil.serialize(),
  68306. i.textures = {};
  68307. for (o in this._textures)
  68308. i.textures[o] = this._textures[o].serialize();
  68309. i.textureArrays = {};
  68310. for (o in this._textureArrays) {
  68311. i.textureArrays[o] = [];
  68312. for (var s = this._textureArrays[o], c = 0; c < s.length; c++)
  68313. i.textureArrays[o].push(s[c].serialize())
  68314. }
  68315. i.ints = {};
  68316. for (o in this._ints)
  68317. i.ints[o] = this._ints[o];
  68318. i.floats = {};
  68319. for (o in this._floats)
  68320. i.floats[o] = this._floats[o];
  68321. i.FloatArrays = {};
  68322. for (o in this._floatsArrays)
  68323. i.FloatArrays[o] = this._floatsArrays[o];
  68324. i.colors3 = {};
  68325. for (o in this._colors3)
  68326. i.colors3[o] = this._colors3[o].asArray();
  68327. i.colors3Arrays = {};
  68328. for (o in this._colors3Arrays)
  68329. i.colors3Arrays[o] = this._colors3Arrays[o];
  68330. i.colors4 = {};
  68331. for (o in this._colors4)
  68332. i.colors4[o] = this._colors4[o].asArray();
  68333. i.colors4Arrays = {};
  68334. for (o in this._colors4Arrays)
  68335. i.colors4Arrays[o] = this._colors4Arrays[o];
  68336. i.vectors2 = {};
  68337. for (o in this._vectors2)
  68338. i.vectors2[o] = this._vectors2[o].asArray();
  68339. i.vectors3 = {};
  68340. for (o in this._vectors3)
  68341. i.vectors3[o] = this._vectors3[o].asArray();
  68342. i.vectors4 = {};
  68343. for (o in this._vectors4)
  68344. i.vectors4[o] = this._vectors4[o].asArray();
  68345. i.matrices = {};
  68346. for (o in this._matrices)
  68347. i.matrices[o] = this._matrices[o].asArray();
  68348. i.matrixArray = {};
  68349. for (o in this._matrixArrays)
  68350. i.matrixArray[o] = this._matrixArrays[o];
  68351. i.matrices3x3 = {};
  68352. for (o in this._matrices3x3)
  68353. i.matrices3x3[o] = this._matrices3x3[o];
  68354. i.matrices2x2 = {};
  68355. for (o in this._matrices2x2)
  68356. i.matrices2x2[o] = this._matrices2x2[o];
  68357. i.vectors2Arrays = {};
  68358. for (o in this._vectors2Arrays)
  68359. i.vectors2Arrays[o] = this._vectors2Arrays[o];
  68360. i.vectors3Arrays = {};
  68361. for (o in this._vectors3Arrays)
  68362. i.vectors3Arrays[o] = this._vectors3Arrays[o];
  68363. i.vectors4Arrays = {};
  68364. for (o in this._vectors4Arrays)
  68365. i.vectors4Arrays[o] = this._vectors4Arrays[o];
  68366. return i
  68367. }
  68368. ,
  68369. e.Parse = function(i, o, s) {
  68370. var c = SerializationHelper.Parse(function() {
  68371. return new e(i.name,o,i.shaderPath,i.options,i.storeEffectOnSubMeshes)
  68372. }, i, o, s), d;
  68373. i.stencil && c.stencil.parse(i.stencil, o, s);
  68374. for (d in i.textures)
  68375. c.setTexture(d, Texture.Parse(i.textures[d], o, s));
  68376. for (d in i.textureArrays) {
  68377. for (var _ = i.textureArrays[d], b = new Array, k = 0; k < _.length; k++)
  68378. b.push(Texture.Parse(_[k], o, s));
  68379. c.setTextureArray(d, b)
  68380. }
  68381. for (d in i.ints)
  68382. c.setInt(d, i.ints[d]);
  68383. for (d in i.floats)
  68384. c.setFloat(d, i.floats[d]);
  68385. for (d in i.floatsArrays)
  68386. c.setFloats(d, i.floatsArrays[d]);
  68387. for (d in i.colors3)
  68388. c.setColor3(d, Color3.FromArray(i.colors3[d]));
  68389. for (d in i.colors3Arrays) {
  68390. var j = i.colors3Arrays[d].reduce(function($, _e, et) {
  68391. return et % 3 === 0 ? $.push([_e]) : $[$.length - 1].push(_e),
  68392. $
  68393. }, []).map(function($) {
  68394. return Color3.FromArray($)
  68395. });
  68396. c.setColor3Array(d, j)
  68397. }
  68398. for (d in i.colors4)
  68399. c.setColor4(d, Color4.FromArray(i.colors4[d]));
  68400. for (d in i.colors4Arrays) {
  68401. var j = i.colors4Arrays[d].reduce(function(_e, et, tt) {
  68402. return tt % 4 === 0 ? _e.push([et]) : _e[_e.length - 1].push(et),
  68403. _e
  68404. }, []).map(function(_e) {
  68405. return Color4.FromArray(_e)
  68406. });
  68407. c.setColor4Array(d, j)
  68408. }
  68409. for (d in i.vectors2)
  68410. c.setVector2(d, Vector2.FromArray(i.vectors2[d]));
  68411. for (d in i.vectors3)
  68412. c.setVector3(d, Vector3.FromArray(i.vectors3[d]));
  68413. for (d in i.vectors4)
  68414. c.setVector4(d, Vector4.FromArray(i.vectors4[d]));
  68415. for (d in i.matrices)
  68416. c.setMatrix(d, Matrix.FromArray(i.matrices[d]));
  68417. for (d in i.matrixArray)
  68418. c._matrixArrays[d] = new Float32Array(i.matrixArray[d]);
  68419. for (d in i.matrices3x3)
  68420. c.setMatrix3x3(d, i.matrices3x3[d]);
  68421. for (d in i.matrices2x2)
  68422. c.setMatrix2x2(d, i.matrices2x2[d]);
  68423. for (d in i.vectors2Arrays)
  68424. c.setArray2(d, i.vectors2Arrays[d]);
  68425. for (d in i.vectors3Arrays)
  68426. c.setArray3(d, i.vectors3Arrays[d]);
  68427. for (d in i.vectors4Arrays)
  68428. c.setArray4(d, i.vectors4Arrays[d]);
  68429. return c
  68430. }
  68431. ,
  68432. e.ParseFromFileAsync = function(i, o, s, c) {
  68433. var d = this;
  68434. return c === void 0 && (c = ""),
  68435. new Promise(function(_, b) {
  68436. var k = new WebRequest;
  68437. k.addEventListener("readystatechange", function() {
  68438. if (k.readyState == 4)
  68439. if (k.status == 200) {
  68440. var j = JSON.parse(k.responseText)
  68441. , $ = d.Parse(j, s || Engine.LastCreatedScene, c);
  68442. i && ($.name = i),
  68443. _($)
  68444. } else
  68445. b("Unable to load the ShaderMaterial")
  68446. }),
  68447. k.open("GET", o),
  68448. k.send()
  68449. }
  68450. )
  68451. }
  68452. ,
  68453. e.CreateFromSnippetAsync = function(i, o, s) {
  68454. var c = this;
  68455. return s === void 0 && (s = ""),
  68456. new Promise(function(d, _) {
  68457. var b = new WebRequest;
  68458. b.addEventListener("readystatechange", function() {
  68459. if (b.readyState == 4)
  68460. if (b.status == 200) {
  68461. var k = JSON.parse(JSON.parse(b.responseText).jsonPayload)
  68462. , j = JSON.parse(k.shaderMaterial)
  68463. , $ = c.Parse(j, o || Engine.LastCreatedScene, s);
  68464. $.snippetId = i,
  68465. d($)
  68466. } else
  68467. _("Unable to load the snippet " + i)
  68468. }),
  68469. b.open("GET", c.SnippetUrl + "/" + i.replace(/#/g, "/")),
  68470. b.send()
  68471. }
  68472. )
  68473. }
  68474. ,
  68475. e.SnippetUrl = "https://snippet.babylonjs.com",
  68476. e
  68477. }(PushMaterial);
  68478. RegisterClass("BABYLON.ShaderMaterial", ShaderMaterial);
  68479. var PrePassConfiguration = function() {
  68480. function a() {
  68481. this.previousWorldMatrices = {},
  68482. this.previousBones = {}
  68483. }
  68484. return a.AddUniforms = function(e) {
  68485. e.push("previousWorld", "previousViewProjection", "mPreviousBones")
  68486. }
  68487. ,
  68488. a.AddSamplers = function(e) {}
  68489. ,
  68490. a.prototype.bindForSubMesh = function(e, i, o, s, c) {
  68491. if (i.prePassRenderer && i.prePassRenderer.enabled && i.prePassRenderer.currentRTisSceneRT && i.prePassRenderer.getIndex(2) !== -1) {
  68492. this.previousWorldMatrices[o.uniqueId] || (this.previousWorldMatrices[o.uniqueId] = s.clone()),
  68493. this.previousViewProjection || (this.previousViewProjection = i.getTransformMatrix().clone(),
  68494. this.currentViewProjection = i.getTransformMatrix().clone());
  68495. var d = i.getEngine();
  68496. this.currentViewProjection.updateFlag !== i.getTransformMatrix().updateFlag ? (this._lastUpdateFrameId = d.frameId,
  68497. this.previousViewProjection.copyFrom(this.currentViewProjection),
  68498. this.currentViewProjection.copyFrom(i.getTransformMatrix())) : this._lastUpdateFrameId !== d.frameId && (this._lastUpdateFrameId = d.frameId,
  68499. this.previousViewProjection.copyFrom(this.currentViewProjection)),
  68500. e.setMatrix("previousWorld", this.previousWorldMatrices[o.uniqueId]),
  68501. e.setMatrix("previousViewProjection", this.previousViewProjection),
  68502. this.previousWorldMatrices[o.uniqueId] = s.clone()
  68503. }
  68504. }
  68505. ,
  68506. a
  68507. }()
  68508. , MaterialFlags = function() {
  68509. function a() {}
  68510. return Object.defineProperty(a, "DiffuseTextureEnabled", {
  68511. get: function() {
  68512. return this._DiffuseTextureEnabled
  68513. },
  68514. set: function(e) {
  68515. this._DiffuseTextureEnabled !== e && (this._DiffuseTextureEnabled = e,
  68516. Engine.MarkAllMaterialsAsDirty(1))
  68517. },
  68518. enumerable: !1,
  68519. configurable: !0
  68520. }),
  68521. Object.defineProperty(a, "DetailTextureEnabled", {
  68522. get: function() {
  68523. return this._DetailTextureEnabled
  68524. },
  68525. set: function(e) {
  68526. this._DetailTextureEnabled !== e && (this._DetailTextureEnabled = e,
  68527. Engine.MarkAllMaterialsAsDirty(1))
  68528. },
  68529. enumerable: !1,
  68530. configurable: !0
  68531. }),
  68532. Object.defineProperty(a, "AmbientTextureEnabled", {
  68533. get: function() {
  68534. return this._AmbientTextureEnabled
  68535. },
  68536. set: function(e) {
  68537. this._AmbientTextureEnabled !== e && (this._AmbientTextureEnabled = e,
  68538. Engine.MarkAllMaterialsAsDirty(1))
  68539. },
  68540. enumerable: !1,
  68541. configurable: !0
  68542. }),
  68543. Object.defineProperty(a, "OpacityTextureEnabled", {
  68544. get: function() {
  68545. return this._OpacityTextureEnabled
  68546. },
  68547. set: function(e) {
  68548. this._OpacityTextureEnabled !== e && (this._OpacityTextureEnabled = e,
  68549. Engine.MarkAllMaterialsAsDirty(1))
  68550. },
  68551. enumerable: !1,
  68552. configurable: !0
  68553. }),
  68554. Object.defineProperty(a, "ReflectionTextureEnabled", {
  68555. get: function() {
  68556. return this._ReflectionTextureEnabled
  68557. },
  68558. set: function(e) {
  68559. this._ReflectionTextureEnabled !== e && (this._ReflectionTextureEnabled = e,
  68560. Engine.MarkAllMaterialsAsDirty(1))
  68561. },
  68562. enumerable: !1,
  68563. configurable: !0
  68564. }),
  68565. Object.defineProperty(a, "EmissiveTextureEnabled", {
  68566. get: function() {
  68567. return this._EmissiveTextureEnabled
  68568. },
  68569. set: function(e) {
  68570. this._EmissiveTextureEnabled !== e && (this._EmissiveTextureEnabled = e,
  68571. Engine.MarkAllMaterialsAsDirty(1))
  68572. },
  68573. enumerable: !1,
  68574. configurable: !0
  68575. }),
  68576. Object.defineProperty(a, "SpecularTextureEnabled", {
  68577. get: function() {
  68578. return this._SpecularTextureEnabled
  68579. },
  68580. set: function(e) {
  68581. this._SpecularTextureEnabled !== e && (this._SpecularTextureEnabled = e,
  68582. Engine.MarkAllMaterialsAsDirty(1))
  68583. },
  68584. enumerable: !1,
  68585. configurable: !0
  68586. }),
  68587. Object.defineProperty(a, "BumpTextureEnabled", {
  68588. get: function() {
  68589. return this._BumpTextureEnabled
  68590. },
  68591. set: function(e) {
  68592. this._BumpTextureEnabled !== e && (this._BumpTextureEnabled = e,
  68593. Engine.MarkAllMaterialsAsDirty(1))
  68594. },
  68595. enumerable: !1,
  68596. configurable: !0
  68597. }),
  68598. Object.defineProperty(a, "LightmapTextureEnabled", {
  68599. get: function() {
  68600. return this._LightmapTextureEnabled
  68601. },
  68602. set: function(e) {
  68603. this._LightmapTextureEnabled !== e && (this._LightmapTextureEnabled = e,
  68604. Engine.MarkAllMaterialsAsDirty(1))
  68605. },
  68606. enumerable: !1,
  68607. configurable: !0
  68608. }),
  68609. Object.defineProperty(a, "RefractionTextureEnabled", {
  68610. get: function() {
  68611. return this._RefractionTextureEnabled
  68612. },
  68613. set: function(e) {
  68614. this._RefractionTextureEnabled !== e && (this._RefractionTextureEnabled = e,
  68615. Engine.MarkAllMaterialsAsDirty(1))
  68616. },
  68617. enumerable: !1,
  68618. configurable: !0
  68619. }),
  68620. Object.defineProperty(a, "ColorGradingTextureEnabled", {
  68621. get: function() {
  68622. return this._ColorGradingTextureEnabled
  68623. },
  68624. set: function(e) {
  68625. this._ColorGradingTextureEnabled !== e && (this._ColorGradingTextureEnabled = e,
  68626. Engine.MarkAllMaterialsAsDirty(1))
  68627. },
  68628. enumerable: !1,
  68629. configurable: !0
  68630. }),
  68631. Object.defineProperty(a, "FresnelEnabled", {
  68632. get: function() {
  68633. return this._FresnelEnabled
  68634. },
  68635. set: function(e) {
  68636. this._FresnelEnabled !== e && (this._FresnelEnabled = e,
  68637. Engine.MarkAllMaterialsAsDirty(4))
  68638. },
  68639. enumerable: !1,
  68640. configurable: !0
  68641. }),
  68642. Object.defineProperty(a, "ClearCoatTextureEnabled", {
  68643. get: function() {
  68644. return this._ClearCoatTextureEnabled
  68645. },
  68646. set: function(e) {
  68647. this._ClearCoatTextureEnabled !== e && (this._ClearCoatTextureEnabled = e,
  68648. Engine.MarkAllMaterialsAsDirty(1))
  68649. },
  68650. enumerable: !1,
  68651. configurable: !0
  68652. }),
  68653. Object.defineProperty(a, "ClearCoatBumpTextureEnabled", {
  68654. get: function() {
  68655. return this._ClearCoatBumpTextureEnabled
  68656. },
  68657. set: function(e) {
  68658. this._ClearCoatBumpTextureEnabled !== e && (this._ClearCoatBumpTextureEnabled = e,
  68659. Engine.MarkAllMaterialsAsDirty(1))
  68660. },
  68661. enumerable: !1,
  68662. configurable: !0
  68663. }),
  68664. Object.defineProperty(a, "ClearCoatTintTextureEnabled", {
  68665. get: function() {
  68666. return this._ClearCoatTintTextureEnabled
  68667. },
  68668. set: function(e) {
  68669. this._ClearCoatTintTextureEnabled !== e && (this._ClearCoatTintTextureEnabled = e,
  68670. Engine.MarkAllMaterialsAsDirty(1))
  68671. },
  68672. enumerable: !1,
  68673. configurable: !0
  68674. }),
  68675. Object.defineProperty(a, "SheenTextureEnabled", {
  68676. get: function() {
  68677. return this._SheenTextureEnabled
  68678. },
  68679. set: function(e) {
  68680. this._SheenTextureEnabled !== e && (this._SheenTextureEnabled = e,
  68681. Engine.MarkAllMaterialsAsDirty(1))
  68682. },
  68683. enumerable: !1,
  68684. configurable: !0
  68685. }),
  68686. Object.defineProperty(a, "AnisotropicTextureEnabled", {
  68687. get: function() {
  68688. return this._AnisotropicTextureEnabled
  68689. },
  68690. set: function(e) {
  68691. this._AnisotropicTextureEnabled !== e && (this._AnisotropicTextureEnabled = e,
  68692. Engine.MarkAllMaterialsAsDirty(1))
  68693. },
  68694. enumerable: !1,
  68695. configurable: !0
  68696. }),
  68697. Object.defineProperty(a, "ThicknessTextureEnabled", {
  68698. get: function() {
  68699. return this._ThicknessTextureEnabled
  68700. },
  68701. set: function(e) {
  68702. this._ThicknessTextureEnabled !== e && (this._ThicknessTextureEnabled = e,
  68703. Engine.MarkAllMaterialsAsDirty(1))
  68704. },
  68705. enumerable: !1,
  68706. configurable: !0
  68707. }),
  68708. Object.defineProperty(a, "RefractionIntensityTextureEnabled", {
  68709. get: function() {
  68710. return this._ThicknessTextureEnabled
  68711. },
  68712. set: function(e) {
  68713. this._RefractionIntensityTextureEnabled !== e && (this._RefractionIntensityTextureEnabled = e,
  68714. Engine.MarkAllMaterialsAsDirty(1))
  68715. },
  68716. enumerable: !1,
  68717. configurable: !0
  68718. }),
  68719. Object.defineProperty(a, "TranslucencyIntensityTextureEnabled", {
  68720. get: function() {
  68721. return this._ThicknessTextureEnabled
  68722. },
  68723. set: function(e) {
  68724. this._TranslucencyIntensityTextureEnabled !== e && (this._TranslucencyIntensityTextureEnabled = e,
  68725. Engine.MarkAllMaterialsAsDirty(1))
  68726. },
  68727. enumerable: !1,
  68728. configurable: !0
  68729. }),
  68730. a._DiffuseTextureEnabled = !0,
  68731. a._DetailTextureEnabled = !0,
  68732. a._AmbientTextureEnabled = !0,
  68733. a._OpacityTextureEnabled = !0,
  68734. a._ReflectionTextureEnabled = !0,
  68735. a._EmissiveTextureEnabled = !0,
  68736. a._SpecularTextureEnabled = !0,
  68737. a._BumpTextureEnabled = !0,
  68738. a._LightmapTextureEnabled = !0,
  68739. a._RefractionTextureEnabled = !0,
  68740. a._ColorGradingTextureEnabled = !0,
  68741. a._FresnelEnabled = !0,
  68742. a._ClearCoatTextureEnabled = !0,
  68743. a._ClearCoatBumpTextureEnabled = !0,
  68744. a._ClearCoatTintTextureEnabled = !0,
  68745. a._SheenTextureEnabled = !0,
  68746. a._AnisotropicTextureEnabled = !0,
  68747. a._ThicknessTextureEnabled = !0,
  68748. a._RefractionIntensityTextureEnabled = !0,
  68749. a._TranslucencyIntensityTextureEnabled = !0,
  68750. a
  68751. }()
  68752. , name$23 = "defaultFragmentDeclaration"
  68753. , shader$23 = `uniform vec4 vEyePosition;
  68754. uniform vec4 vDiffuseColor;
  68755. #ifdef SPECULARTERM
  68756. uniform vec4 vSpecularColor;
  68757. #endif
  68758. uniform vec3 vEmissiveColor;
  68759. uniform vec3 vAmbientColor;
  68760. uniform float visibility;
  68761. #ifdef DIFFUSE
  68762. uniform vec2 vDiffuseInfos;
  68763. #endif
  68764. #ifdef AMBIENT
  68765. uniform vec2 vAmbientInfos;
  68766. #endif
  68767. #ifdef OPACITY
  68768. uniform vec2 vOpacityInfos;
  68769. #endif
  68770. #ifdef EMISSIVE
  68771. uniform vec2 vEmissiveInfos;
  68772. #endif
  68773. #ifdef LIGHTMAP
  68774. uniform vec2 vLightmapInfos;
  68775. #endif
  68776. #ifdef BUMP
  68777. uniform vec3 vBumpInfos;
  68778. uniform vec2 vTangentSpaceParams;
  68779. #endif
  68780. #ifdef ALPHATEST
  68781. uniform float alphaCutOff;
  68782. #endif
  68783. #if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)
  68784. uniform mat4 view;
  68785. #endif
  68786. #ifdef REFRACTION
  68787. uniform vec4 vRefractionInfos;
  68788. #ifndef REFRACTIONMAP_3D
  68789. uniform mat4 refractionMatrix;
  68790. #endif
  68791. #ifdef REFRACTIONFRESNEL
  68792. uniform vec4 refractionLeftColor;
  68793. uniform vec4 refractionRightColor;
  68794. #endif
  68795. #if defined(USE_LOCAL_REFRACTIONMAP_CUBIC) && defined(REFRACTIONMAP_3D)
  68796. uniform vec3 vRefractionPosition;
  68797. uniform vec3 vRefractionSize;
  68798. #endif
  68799. #endif
  68800. #if defined(SPECULAR) && defined(SPECULARTERM)
  68801. uniform vec2 vSpecularInfos;
  68802. #endif
  68803. #ifdef DIFFUSEFRESNEL
  68804. uniform vec4 diffuseLeftColor;
  68805. uniform vec4 diffuseRightColor;
  68806. #endif
  68807. #ifdef OPACITYFRESNEL
  68808. uniform vec4 opacityParts;
  68809. #endif
  68810. #ifdef EMISSIVEFRESNEL
  68811. uniform vec4 emissiveLeftColor;
  68812. uniform vec4 emissiveRightColor;
  68813. #endif
  68814. #ifdef REFLECTION
  68815. uniform vec2 vReflectionInfos;
  68816. #if defined(REFLECTIONMAP_PLANAR) || defined(REFLECTIONMAP_CUBIC) || defined(REFLECTIONMAP_PROJECTION) || defined(REFLECTIONMAP_EQUIRECTANGULAR) || defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_SKYBOX)
  68817. uniform mat4 reflectionMatrix;
  68818. #endif
  68819. #ifndef REFLECTIONMAP_SKYBOX
  68820. #if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)
  68821. uniform vec3 vReflectionPosition;
  68822. uniform vec3 vReflectionSize;
  68823. #endif
  68824. #endif
  68825. #ifdef REFLECTIONFRESNEL
  68826. uniform vec4 reflectionLeftColor;
  68827. uniform vec4 reflectionRightColor;
  68828. #endif
  68829. #endif
  68830. #ifdef DETAIL
  68831. uniform vec4 vDetailInfos;
  68832. #endif`;
  68833. ShaderStore.IncludesShadersStore[name$23] = shader$23;
  68834. var name$22 = "defaultUboDeclaration"
  68835. , shader$22 = `layout(std140,column_major) uniform;
  68836. uniform Material
  68837. {
  68838. vec4 diffuseLeftColor;
  68839. vec4 diffuseRightColor;
  68840. vec4 opacityParts;
  68841. vec4 reflectionLeftColor;
  68842. vec4 reflectionRightColor;
  68843. vec4 refractionLeftColor;
  68844. vec4 refractionRightColor;
  68845. vec4 emissiveLeftColor;
  68846. vec4 emissiveRightColor;
  68847. vec2 vDiffuseInfos;
  68848. vec2 vAmbientInfos;
  68849. vec2 vOpacityInfos;
  68850. vec2 vReflectionInfos;
  68851. vec3 vReflectionPosition;
  68852. vec3 vReflectionSize;
  68853. vec2 vEmissiveInfos;
  68854. vec2 vLightmapInfos;
  68855. vec2 vSpecularInfos;
  68856. vec3 vBumpInfos;
  68857. mat4 diffuseMatrix;
  68858. mat4 ambientMatrix;
  68859. mat4 opacityMatrix;
  68860. mat4 reflectionMatrix;
  68861. mat4 emissiveMatrix;
  68862. mat4 lightmapMatrix;
  68863. mat4 specularMatrix;
  68864. mat4 bumpMatrix;
  68865. vec2 vTangentSpaceParams;
  68866. float pointSize;
  68867. float alphaCutOff;
  68868. mat4 refractionMatrix;
  68869. vec4 vRefractionInfos;
  68870. vec3 vRefractionPosition;
  68871. vec3 vRefractionSize;
  68872. vec4 vSpecularColor;
  68873. vec3 vEmissiveColor;
  68874. vec4 vDiffuseColor;
  68875. vec3 vAmbientColor;
  68876. vec4 vDetailInfos;
  68877. mat4 detailMatrix;
  68878. };
  68879. #include<sceneUboDeclaration>
  68880. #include<meshUboDeclaration>
  68881. `;
  68882. ShaderStore.IncludesShadersStore[name$22] = shader$22;
  68883. var name$21 = "prePassDeclaration"
  68884. , shader$21 = `#ifdef PREPASS
  68885. #extension GL_EXT_draw_buffers : require
  68886. layout(location=0) out highp vec4 glFragData[{X}];
  68887. highp vec4 gl_FragColor;
  68888. #ifdef PREPASS_DEPTH
  68889. varying highp vec3 vViewPos;
  68890. #endif
  68891. #ifdef PREPASS_VELOCITY
  68892. varying highp vec4 vCurrentPosition;
  68893. varying highp vec4 vPreviousPosition;
  68894. #endif
  68895. #endif
  68896. `;
  68897. ShaderStore.IncludesShadersStore[name$21] = shader$21;
  68898. var name$20 = "oitDeclaration"
  68899. , shader$20 = `#ifdef ORDER_INDEPENDENT_TRANSPARENCY
  68900. #extension GL_EXT_draw_buffers : require
  68901. layout(location=0) out vec2 depth;
  68902. layout(location=1) out vec4 frontColor;
  68903. layout(location=2) out vec4 backColor;
  68904. #define MAX_DEPTH 99999.0
  68905. highp vec4 gl_FragColor;
  68906. uniform sampler2D oitDepthSampler;
  68907. uniform sampler2D oitFrontColorSampler;
  68908. #endif
  68909. `;
  68910. ShaderStore.IncludesShadersStore[name$20] = shader$20;
  68911. var name$1$ = "mainUVVaryingDeclaration"
  68912. , shader$1$ = `#ifdef MAINUV{X}
  68913. varying vec2 vMainUV{X};
  68914. #endif
  68915. `;
  68916. ShaderStore.IncludesShadersStore[name$1$] = shader$1$;
  68917. var name$1_ = "lightFragmentDeclaration"
  68918. , shader$1_ = `#ifdef LIGHT{X}
  68919. uniform vec4 vLightData{X};
  68920. uniform vec4 vLightDiffuse{X};
  68921. #ifdef SPECULARTERM
  68922. uniform vec4 vLightSpecular{X};
  68923. #else
  68924. vec4 vLightSpecular{X}=vec4(0.);
  68925. #endif
  68926. #ifdef SHADOW{X}
  68927. #ifdef SHADOWCSM{X}
  68928. uniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];
  68929. uniform float viewFrustumZ{X}[SHADOWCSMNUM_CASCADES{X}];
  68930. uniform float frustumLengths{X}[SHADOWCSMNUM_CASCADES{X}];
  68931. uniform float cascadeBlendFactor{X};
  68932. varying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];
  68933. varying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];
  68934. varying vec4 vPositionFromCamera{X};
  68935. #if defined(SHADOWPCSS{X})
  68936. uniform highp sampler2DArrayShadow shadowSampler{X};
  68937. uniform highp sampler2DArray depthSampler{X};
  68938. uniform vec2 lightSizeUVCorrection{X}[SHADOWCSMNUM_CASCADES{X}];
  68939. uniform float depthCorrection{X}[SHADOWCSMNUM_CASCADES{X}];
  68940. uniform float penumbraDarkness{X};
  68941. #elif defined(SHADOWPCF{X})
  68942. uniform highp sampler2DArrayShadow shadowSampler{X};
  68943. #else
  68944. uniform highp sampler2DArray shadowSampler{X};
  68945. #endif
  68946. #ifdef SHADOWCSMDEBUG{X}
  68947. const vec3 vCascadeColorsMultiplier{X}[8]=vec3[8]
  68948. (
  68949. vec3 ( 1.5,0.0,0.0 ),
  68950. vec3 ( 0.0,1.5,0.0 ),
  68951. vec3 ( 0.0,0.0,5.5 ),
  68952. vec3 ( 1.5,0.0,5.5 ),
  68953. vec3 ( 1.5,1.5,0.0 ),
  68954. vec3 ( 1.0,1.0,1.0 ),
  68955. vec3 ( 0.0,1.0,5.5 ),
  68956. vec3 ( 0.5,3.5,0.75 )
  68957. );
  68958. vec3 shadowDebug{X};
  68959. #endif
  68960. #ifdef SHADOWCSMUSESHADOWMAXZ{X}
  68961. int index{X}=-1;
  68962. #else
  68963. int index{X}=SHADOWCSMNUM_CASCADES{X}-1;
  68964. #endif
  68965. float diff{X}=0.;
  68966. #elif defined(SHADOWCUBE{X})
  68967. uniform samplerCube shadowSampler{X};
  68968. #else
  68969. varying vec4 vPositionFromLight{X};
  68970. varying float vDepthMetric{X};
  68971. #if defined(SHADOWPCSS{X})
  68972. uniform highp sampler2DShadow shadowSampler{X};
  68973. uniform highp sampler2D depthSampler{X};
  68974. #elif defined(SHADOWPCF{X})
  68975. uniform highp sampler2DShadow shadowSampler{X};
  68976. #else
  68977. uniform sampler2D shadowSampler{X};
  68978. #endif
  68979. uniform mat4 lightMatrix{X};
  68980. #endif
  68981. uniform vec4 shadowsInfo{X};
  68982. uniform vec2 depthValues{X};
  68983. #endif
  68984. #ifdef SPOTLIGHT{X}
  68985. uniform vec4 vLightDirection{X};
  68986. uniform vec4 vLightFalloff{X};
  68987. #elif defined(POINTLIGHT{X})
  68988. uniform vec4 vLightFalloff{X};
  68989. #elif defined(HEMILIGHT{X})
  68990. uniform vec3 vLightGround{X};
  68991. #endif
  68992. #ifdef PROJECTEDLIGHTTEXTURE{X}
  68993. uniform mat4 textureProjectionMatrix{X};
  68994. uniform sampler2D projectionLightSampler{X};
  68995. #endif
  68996. #endif`;
  68997. ShaderStore.IncludesShadersStore[name$1_] = shader$1_;
  68998. var name$1Z = "lightUboDeclaration"
  68999. , shader$1Z = `#ifdef LIGHT{X}
  69000. uniform Light{X}
  69001. {
  69002. vec4 vLightData;
  69003. vec4 vLightDiffuse;
  69004. vec4 vLightSpecular;
  69005. #ifdef SPOTLIGHT{X}
  69006. vec4 vLightDirection;
  69007. vec4 vLightFalloff;
  69008. #elif defined(POINTLIGHT{X})
  69009. vec4 vLightFalloff;
  69010. #elif defined(HEMILIGHT{X})
  69011. vec3 vLightGround;
  69012. #endif
  69013. vec4 shadowsInfo;
  69014. vec2 depthValues;
  69015. } light{X};
  69016. #ifdef PROJECTEDLIGHTTEXTURE{X}
  69017. uniform mat4 textureProjectionMatrix{X};
  69018. uniform sampler2D projectionLightSampler{X};
  69019. #endif
  69020. #ifdef SHADOW{X}
  69021. #ifdef SHADOWCSM{X}
  69022. uniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];
  69023. uniform float viewFrustumZ{X}[SHADOWCSMNUM_CASCADES{X}];
  69024. uniform float frustumLengths{X}[SHADOWCSMNUM_CASCADES{X}];
  69025. uniform float cascadeBlendFactor{X};
  69026. varying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];
  69027. varying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];
  69028. varying vec4 vPositionFromCamera{X};
  69029. #if defined(SHADOWPCSS{X})
  69030. uniform highp sampler2DArrayShadow shadowSampler{X};
  69031. uniform highp sampler2DArray depthSampler{X};
  69032. uniform vec2 lightSizeUVCorrection{X}[SHADOWCSMNUM_CASCADES{X}];
  69033. uniform float depthCorrection{X}[SHADOWCSMNUM_CASCADES{X}];
  69034. uniform float penumbraDarkness{X};
  69035. #elif defined(SHADOWPCF{X})
  69036. uniform highp sampler2DArrayShadow shadowSampler{X};
  69037. #else
  69038. uniform highp sampler2DArray shadowSampler{X};
  69039. #endif
  69040. #ifdef SHADOWCSMDEBUG{X}
  69041. const vec3 vCascadeColorsMultiplier{X}[8]=vec3[8]
  69042. (
  69043. vec3 ( 1.5,0.0,0.0 ),
  69044. vec3 ( 0.0,1.5,0.0 ),
  69045. vec3 ( 0.0,0.0,5.5 ),
  69046. vec3 ( 1.5,0.0,5.5 ),
  69047. vec3 ( 1.5,1.5,0.0 ),
  69048. vec3 ( 1.0,1.0,1.0 ),
  69049. vec3 ( 0.0,1.0,5.5 ),
  69050. vec3 ( 0.5,3.5,0.75 )
  69051. );
  69052. vec3 shadowDebug{X};
  69053. #endif
  69054. #ifdef SHADOWCSMUSESHADOWMAXZ{X}
  69055. int index{X}=-1;
  69056. #else
  69057. int index{X}=SHADOWCSMNUM_CASCADES{X}-1;
  69058. #endif
  69059. float diff{X}=0.;
  69060. #elif defined(SHADOWCUBE{X})
  69061. uniform samplerCube shadowSampler{X};
  69062. #else
  69063. varying vec4 vPositionFromLight{X};
  69064. varying float vDepthMetric{X};
  69065. #if defined(SHADOWPCSS{X})
  69066. uniform highp sampler2DShadow shadowSampler{X};
  69067. uniform highp sampler2D depthSampler{X};
  69068. #elif defined(SHADOWPCF{X})
  69069. uniform highp sampler2DShadow shadowSampler{X};
  69070. #else
  69071. uniform sampler2D shadowSampler{X};
  69072. #endif
  69073. uniform mat4 lightMatrix{X};
  69074. #endif
  69075. #endif
  69076. #endif`;
  69077. ShaderStore.IncludesShadersStore[name$1Z] = shader$1Z;
  69078. var name$1Y = "lightsFragmentFunctions"
  69079. , shader$1Y = `
  69080. struct lightingInfo
  69081. {
  69082. vec3 diffuse;
  69083. #ifdef SPECULARTERM
  69084. vec3 specular;
  69085. #endif
  69086. #ifdef NDOTL
  69087. float ndl;
  69088. #endif
  69089. };
  69090. lightingInfo computeLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {
  69091. lightingInfo result;
  69092. vec3 lightVectorW;
  69093. float attenuation=1.0;
  69094. if (lightData.w == 0.)
  69095. {
  69096. vec3 direction=lightData.xyz-vPositionW;
  69097. attenuation=max(0.,1.0-length(direction)/range);
  69098. lightVectorW=normalize(direction);
  69099. }
  69100. else
  69101. {
  69102. lightVectorW=normalize(-lightData.xyz);
  69103. }
  69104. float ndl=max(0.,dot(vNormal,lightVectorW));
  69105. #ifdef NDOTL
  69106. result.ndl=ndl;
  69107. #endif
  69108. result.diffuse=ndl*diffuseColor*attenuation;
  69109. #ifdef SPECULARTERM
  69110. vec3 angleW=normalize(viewDirectionW+lightVectorW);
  69111. float specComp=max(0.,dot(vNormal,angleW));
  69112. specComp=pow(specComp,max(1.,glossiness));
  69113. result.specular=specComp*specularColor*attenuation;
  69114. #endif
  69115. return result;
  69116. }
  69117. lightingInfo computeSpotLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec4 lightDirection,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {
  69118. lightingInfo result;
  69119. vec3 direction=lightData.xyz-vPositionW;
  69120. vec3 lightVectorW=normalize(direction);
  69121. float attenuation=max(0.,1.0-length(direction)/range);
  69122. float cosAngle=max(0.,dot(lightDirection.xyz,-lightVectorW));
  69123. if (cosAngle>=lightDirection.w)
  69124. {
  69125. cosAngle=max(0.,pow(cosAngle,lightData.w));
  69126. attenuation*=cosAngle;
  69127. float ndl=max(0.,dot(vNormal,lightVectorW));
  69128. #ifdef NDOTL
  69129. result.ndl=ndl;
  69130. #endif
  69131. result.diffuse=ndl*diffuseColor*attenuation;
  69132. #ifdef SPECULARTERM
  69133. vec3 angleW=normalize(viewDirectionW+lightVectorW);
  69134. float specComp=max(0.,dot(vNormal,angleW));
  69135. specComp=pow(specComp,max(1.,glossiness));
  69136. result.specular=specComp*specularColor*attenuation;
  69137. #endif
  69138. return result;
  69139. }
  69140. result.diffuse=vec3(0.);
  69141. #ifdef SPECULARTERM
  69142. result.specular=vec3(0.);
  69143. #endif
  69144. #ifdef NDOTL
  69145. result.ndl=0.;
  69146. #endif
  69147. return result;
  69148. }
  69149. lightingInfo computeHemisphericLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,vec3 groundColor,float glossiness) {
  69150. lightingInfo result;
  69151. float ndl=dot(vNormal,lightData.xyz)*0.5+0.5;
  69152. #ifdef NDOTL
  69153. result.ndl=ndl;
  69154. #endif
  69155. result.diffuse=mix(groundColor,diffuseColor,ndl);
  69156. #ifdef SPECULARTERM
  69157. vec3 angleW=normalize(viewDirectionW+lightData.xyz);
  69158. float specComp=max(0.,dot(vNormal,angleW));
  69159. specComp=pow(specComp,max(1.,glossiness));
  69160. result.specular=specComp*specularColor;
  69161. #endif
  69162. return result;
  69163. }
  69164. #define inline
  69165. vec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix){
  69166. vec4 strq=textureProjectionMatrix*vec4(vPositionW,1.0);
  69167. strq/=strq.w;
  69168. vec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;
  69169. return textureColor;
  69170. }`;
  69171. ShaderStore.IncludesShadersStore[name$1Y] = shader$1Y;
  69172. var name$1X = "shadowsFragmentFunctions"
  69173. , shader$1X = `#ifdef SHADOWS
  69174. #ifndef SHADOWFLOAT
  69175. float unpack(vec4 color)
  69176. {
  69177. const vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);
  69178. return dot(color,bit_shift);
  69179. }
  69180. #endif
  69181. float computeFallOff(float value,vec2 clipSpace,float frustumEdgeFalloff)
  69182. {
  69183. float mask=smoothstep(1.0-frustumEdgeFalloff,1.00000012,clamp(dot(clipSpace,clipSpace),0.,1.));
  69184. return mix(value,1.0,mask);
  69185. }
  69186. #define inline
  69187. float computeShadowCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,vec2 depthValues)
  69188. {
  69189. vec3 directionToLight=vPositionW-lightPosition;
  69190. float depth=length(directionToLight);
  69191. depth=(depth+depthValues.x)/(depthValues.y);
  69192. depth=clamp(depth,0.,1.0);
  69193. directionToLight=normalize(directionToLight);
  69194. directionToLight.y=-directionToLight.y;
  69195. #ifndef SHADOWFLOAT
  69196. float shadow=unpack(textureCube(shadowSampler,directionToLight));
  69197. #else
  69198. float shadow=textureCube(shadowSampler,directionToLight).x;
  69199. #endif
  69200. return depth>shadow ? darkness : 1.0;
  69201. }
  69202. #define inline
  69203. float computeShadowWithPoissonSamplingCube(vec3 lightPosition,samplerCube shadowSampler,float mapSize,float darkness,vec2 depthValues)
  69204. {
  69205. vec3 directionToLight=vPositionW-lightPosition;
  69206. float depth=length(directionToLight);
  69207. depth=(depth+depthValues.x)/(depthValues.y);
  69208. depth=clamp(depth,0.,1.0);
  69209. directionToLight=normalize(directionToLight);
  69210. directionToLight.y=-directionToLight.y;
  69211. float visibility=1.;
  69212. vec3 poissonDisk[4];
  69213. poissonDisk[0]=vec3(-1.0,1.0,-1.0);
  69214. poissonDisk[1]=vec3(1.0,-1.0,-1.0);
  69215. poissonDisk[2]=vec3(-1.0,-1.0,-1.0);
  69216. poissonDisk[3]=vec3(1.0,-1.0,1.0);
  69217. #ifndef SHADOWFLOAT
  69218. if (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))<depth) visibility-=0.25;
  69219. if (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize))<depth) visibility-=0.25;
  69220. if (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize))<depth) visibility-=0.25;
  69221. if (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize))<depth) visibility-=0.25;
  69222. #else
  69223. if (textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize).x<depth) visibility-=0.25;
  69224. if (textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize).x<depth) visibility-=0.25;
  69225. if (textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize).x<depth) visibility-=0.25;
  69226. if (textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize).x<depth) visibility-=0.25;
  69227. #endif
  69228. return min(1.0,visibility+darkness);
  69229. }
  69230. #define inline
  69231. float computeShadowWithESMCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)
  69232. {
  69233. vec3 directionToLight=vPositionW-lightPosition;
  69234. float depth=length(directionToLight);
  69235. depth=(depth+depthValues.x)/(depthValues.y);
  69236. float shadowPixelDepth=clamp(depth,0.,1.0);
  69237. directionToLight=normalize(directionToLight);
  69238. directionToLight.y=-directionToLight.y;
  69239. #ifndef SHADOWFLOAT
  69240. float shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));
  69241. #else
  69242. float shadowMapSample=textureCube(shadowSampler,directionToLight).x;
  69243. #endif
  69244. float esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);
  69245. return esm;
  69246. }
  69247. #define inline
  69248. float computeShadowWithCloseESMCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)
  69249. {
  69250. vec3 directionToLight=vPositionW-lightPosition;
  69251. float depth=length(directionToLight);
  69252. depth=(depth+depthValues.x)/(depthValues.y);
  69253. float shadowPixelDepth=clamp(depth,0.,1.0);
  69254. directionToLight=normalize(directionToLight);
  69255. directionToLight.y=-directionToLight.y;
  69256. #ifndef SHADOWFLOAT
  69257. float shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));
  69258. #else
  69259. float shadowMapSample=textureCube(shadowSampler,directionToLight).x;
  69260. #endif
  69261. float esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);
  69262. return esm;
  69263. }
  69264. #if defined(WEBGL2) || defined(WEBGPU)
  69265. #define inline
  69266. float computeShadowCSM(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray shadowSampler,float darkness,float frustumEdgeFalloff)
  69267. {
  69268. vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
  69269. vec2 uv=0.5*clipSpace.xy+vec2(0.5);
  69270. vec3 uvLayer=vec3(uv.x,uv.y,layer);
  69271. float shadowPixelDepth=clamp(depthMetric,0.,1.0);
  69272. #ifndef SHADOWFLOAT
  69273. float shadow=unpack(texture2D(shadowSampler,uvLayer));
  69274. #else
  69275. float shadow=texture2D(shadowSampler,uvLayer).x;
  69276. #endif
  69277. return shadowPixelDepth>shadow ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.;
  69278. }
  69279. #endif
  69280. #define inline
  69281. float computeShadow(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float frustumEdgeFalloff)
  69282. {
  69283. vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
  69284. vec2 uv=0.5*clipSpace.xy+vec2(0.5);
  69285. if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)
  69286. {
  69287. return 1.0;
  69288. }
  69289. else
  69290. {
  69291. float shadowPixelDepth=clamp(depthMetric,0.,1.0);
  69292. #ifndef SHADOWFLOAT
  69293. float shadow=unpack(texture2D(shadowSampler,uv));
  69294. #else
  69295. float shadow=texture2D(shadowSampler,uv).x;
  69296. #endif
  69297. return shadowPixelDepth>shadow ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.;
  69298. }
  69299. }
  69300. #define inline
  69301. float computeShadowWithPoissonSampling(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float mapSize,float darkness,float frustumEdgeFalloff)
  69302. {
  69303. vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
  69304. vec2 uv=0.5*clipSpace.xy+vec2(0.5);
  69305. if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)
  69306. {
  69307. return 1.0;
  69308. }
  69309. else
  69310. {
  69311. float shadowPixelDepth=clamp(depthMetric,0.,1.0);
  69312. float visibility=1.;
  69313. vec2 poissonDisk[4];
  69314. poissonDisk[0]=vec2(-0.94201624,-0.39906216);
  69315. poissonDisk[1]=vec2(0.94558609,-0.76890725);
  69316. poissonDisk[2]=vec2(-0.094184101,-0.92938870);
  69317. poissonDisk[3]=vec2(0.34495938,0.29387760);
  69318. #ifndef SHADOWFLOAT
  69319. if (unpack(texture2D(shadowSampler,uv+poissonDisk[0]*mapSize))<shadowPixelDepth) visibility-=0.25;
  69320. if (unpack(texture2D(shadowSampler,uv+poissonDisk[1]*mapSize))<shadowPixelDepth) visibility-=0.25;
  69321. if (unpack(texture2D(shadowSampler,uv+poissonDisk[2]*mapSize))<shadowPixelDepth) visibility-=0.25;
  69322. if (unpack(texture2D(shadowSampler,uv+poissonDisk[3]*mapSize))<shadowPixelDepth) visibility-=0.25;
  69323. #else
  69324. if (texture2D(shadowSampler,uv+poissonDisk[0]*mapSize).x<shadowPixelDepth) visibility-=0.25;
  69325. if (texture2D(shadowSampler,uv+poissonDisk[1]*mapSize).x<shadowPixelDepth) visibility-=0.25;
  69326. if (texture2D(shadowSampler,uv+poissonDisk[2]*mapSize).x<shadowPixelDepth) visibility-=0.25;
  69327. if (texture2D(shadowSampler,uv+poissonDisk[3]*mapSize).x<shadowPixelDepth) visibility-=0.25;
  69328. #endif
  69329. return computeFallOff(min(1.0,visibility+darkness),clipSpace.xy,frustumEdgeFalloff);
  69330. }
  69331. }
  69332. #define inline
  69333. float computeShadowWithESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)
  69334. {
  69335. vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
  69336. vec2 uv=0.5*clipSpace.xy+vec2(0.5);
  69337. if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)
  69338. {
  69339. return 1.0;
  69340. }
  69341. else
  69342. {
  69343. float shadowPixelDepth=clamp(depthMetric,0.,1.0);
  69344. #ifndef SHADOWFLOAT
  69345. float shadowMapSample=unpack(texture2D(shadowSampler,uv));
  69346. #else
  69347. float shadowMapSample=texture2D(shadowSampler,uv).x;
  69348. #endif
  69349. float esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);
  69350. return computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);
  69351. }
  69352. }
  69353. #define inline
  69354. float computeShadowWithCloseESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)
  69355. {
  69356. vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
  69357. vec2 uv=0.5*clipSpace.xy+vec2(0.5);
  69358. if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)
  69359. {
  69360. return 1.0;
  69361. }
  69362. else
  69363. {
  69364. float shadowPixelDepth=clamp(depthMetric,0.,1.0);
  69365. #ifndef SHADOWFLOAT
  69366. float shadowMapSample=unpack(texture2D(shadowSampler,uv));
  69367. #else
  69368. float shadowMapSample=texture2D(shadowSampler,uv).x;
  69369. #endif
  69370. float esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);
  69371. return computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);
  69372. }
  69373. }
  69374. #ifdef IS_NDC_HALF_ZRANGE
  69375. #define ZINCLIP clipSpace.z
  69376. #else
  69377. #define ZINCLIP uvDepth.z
  69378. #endif
  69379. #if defined(WEBGL2) || defined(WEBGPU)
  69380. #define GREATEST_LESS_THAN_ONE 0.99999994
  69381. #define inline
  69382. float computeShadowWithCSMPCF1(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,float darkness,float frustumEdgeFalloff)
  69383. {
  69384. vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
  69385. vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));
  69386. uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);
  69387. vec4 uvDepthLayer=vec4(uvDepth.x,uvDepth.y,layer,uvDepth.z);
  69388. float shadow=texture2D(shadowSampler,uvDepthLayer);
  69389. shadow=mix(darkness,1.,shadow);
  69390. return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);
  69391. }
  69392. #define inline
  69393. float computeShadowWithCSMPCF3(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)
  69394. {
  69395. vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
  69396. vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));
  69397. uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);
  69398. vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;
  69399. uv+=0.5;
  69400. vec2 st=fract(uv);
  69401. vec2 base_uv=floor(uv)-0.5;
  69402. base_uv*=shadowMapSizeAndInverse.y;
  69403. vec2 uvw0=3.-2.*st;
  69404. vec2 uvw1=1.+2.*st;
  69405. vec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;
  69406. vec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;
  69407. float shadow=0.;
  69408. shadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[0]),layer,uvDepth.z));
  69409. shadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[0]),layer,uvDepth.z));
  69410. shadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[1]),layer,uvDepth.z));
  69411. shadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[1]),layer,uvDepth.z));
  69412. shadow=shadow/16.;
  69413. shadow=mix(darkness,1.,shadow);
  69414. return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);
  69415. }
  69416. #define inline
  69417. float computeShadowWithCSMPCF5(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)
  69418. {
  69419. vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
  69420. vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));
  69421. uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);
  69422. vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;
  69423. uv+=0.5;
  69424. vec2 st=fract(uv);
  69425. vec2 base_uv=floor(uv)-0.5;
  69426. base_uv*=shadowMapSizeAndInverse.y;
  69427. vec2 uvw0=4.-3.*st;
  69428. vec2 uvw1=vec2(7.);
  69429. vec2 uvw2=1.+3.*st;
  69430. vec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;
  69431. vec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;
  69432. float shadow=0.;
  69433. shadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[0]),layer,uvDepth.z));
  69434. shadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[0]),layer,uvDepth.z));
  69435. shadow+=uvw2.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[0]),layer,uvDepth.z));
  69436. shadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[1]),layer,uvDepth.z));
  69437. shadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[1]),layer,uvDepth.z));
  69438. shadow+=uvw2.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[1]),layer,uvDepth.z));
  69439. shadow+=uvw0.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[2]),layer,uvDepth.z));
  69440. shadow+=uvw1.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[2]),layer,uvDepth.z));
  69441. shadow+=uvw2.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[2]),layer,uvDepth.z));
  69442. shadow=shadow/144.;
  69443. shadow=mix(darkness,1.,shadow);
  69444. return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);
  69445. }
  69446. #define inline
  69447. float computeShadowWithPCF1(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,float darkness,float frustumEdgeFalloff)
  69448. {
  69449. if (depthMetric>1.0 || depthMetric<0.0) {
  69450. return 1.0;
  69451. }
  69452. else
  69453. {
  69454. vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
  69455. vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));
  69456. uvDepth.z=ZINCLIP;
  69457. float shadow=texture2D(shadowSampler,uvDepth);
  69458. shadow=mix(darkness,1.,shadow);
  69459. return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);
  69460. }
  69461. }
  69462. #define inline
  69463. float computeShadowWithPCF3(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)
  69464. {
  69465. if (depthMetric>1.0 || depthMetric<0.0) {
  69466. return 1.0;
  69467. }
  69468. else
  69469. {
  69470. vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
  69471. vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));
  69472. uvDepth.z=ZINCLIP;
  69473. vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;
  69474. uv+=0.5;
  69475. vec2 st=fract(uv);
  69476. vec2 base_uv=floor(uv)-0.5;
  69477. base_uv*=shadowMapSizeAndInverse.y;
  69478. vec2 uvw0=3.-2.*st;
  69479. vec2 uvw1=1.+2.*st;
  69480. vec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;
  69481. vec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;
  69482. float shadow=0.;
  69483. shadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z));
  69484. shadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z));
  69485. shadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z));
  69486. shadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z));
  69487. shadow=shadow/16.;
  69488. shadow=mix(darkness,1.,shadow);
  69489. return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);
  69490. }
  69491. }
  69492. #define inline
  69493. float computeShadowWithPCF5(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)
  69494. {
  69495. if (depthMetric>1.0 || depthMetric<0.0) {
  69496. return 1.0;
  69497. }
  69498. else
  69499. {
  69500. vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
  69501. vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));
  69502. uvDepth.z=ZINCLIP;
  69503. vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;
  69504. uv+=0.5;
  69505. vec2 st=fract(uv);
  69506. vec2 base_uv=floor(uv)-0.5;
  69507. base_uv*=shadowMapSizeAndInverse.y;
  69508. vec2 uvw0=4.-3.*st;
  69509. vec2 uvw1=vec2(7.);
  69510. vec2 uvw2=1.+3.*st;
  69511. vec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;
  69512. vec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;
  69513. float shadow=0.;
  69514. shadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z));
  69515. shadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z));
  69516. shadow+=uvw2.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[0]),uvDepth.z));
  69517. shadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z));
  69518. shadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z));
  69519. shadow+=uvw2.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[1]),uvDepth.z));
  69520. shadow+=uvw0.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[2]),uvDepth.z));
  69521. shadow+=uvw1.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[2]),uvDepth.z));
  69522. shadow+=uvw2.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[2]),uvDepth.z));
  69523. shadow=shadow/144.;
  69524. shadow=mix(darkness,1.,shadow);
  69525. return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);
  69526. }
  69527. }
  69528. const vec3 PoissonSamplers32[64]=vec3[64](
  69529. vec3(0.06407013,0.05409927,0.),
  69530. vec3(0.7366577,0.5789394,0.),
  69531. vec3(-0.6270542,-0.5320278,0.),
  69532. vec3(-0.4096107,0.8411095,0.),
  69533. vec3(0.6849564,-0.4990818,0.),
  69534. vec3(-0.874181,-0.04579735,0.),
  69535. vec3(0.9989998,0.0009880066,0.),
  69536. vec3(-0.004920578,-0.9151649,0.),
  69537. vec3(0.1805763,0.9747483,0.),
  69538. vec3(-0.2138451,0.2635818,0.),
  69539. vec3(0.109845,0.3884785,0.),
  69540. vec3(0.06876755,-0.3581074,0.),
  69541. vec3(0.374073,-0.7661266,0.),
  69542. vec3(0.3079132,-0.1216763,0.),
  69543. vec3(-0.3794335,-0.8271583,0.),
  69544. vec3(-0.203878,-0.07715034,0.),
  69545. vec3(0.5912697,0.1469799,0.),
  69546. vec3(-0.88069,0.3031784,0.),
  69547. vec3(0.5040108,0.8283722,0.),
  69548. vec3(-0.5844124,0.5494877,0.),
  69549. vec3(0.6017799,-0.1726654,0.),
  69550. vec3(-0.5554981,0.1559997,0.),
  69551. vec3(-0.3016369,-0.3900928,0.),
  69552. vec3(-0.5550632,-0.1723762,0.),
  69553. vec3(0.925029,0.2995041,0.),
  69554. vec3(-0.2473137,0.5538505,0.),
  69555. vec3(0.9183037,-0.2862392,0.),
  69556. vec3(0.2469421,0.6718712,0.),
  69557. vec3(0.3916397,-0.4328209,0.),
  69558. vec3(-0.03576927,-0.6220032,0.),
  69559. vec3(-0.04661255,0.7995201,0.),
  69560. vec3(0.4402924,0.3640312,0.),
  69561. vec3(0.,0.,0.),
  69562. vec3(0.,0.,0.),
  69563. vec3(0.,0.,0.),
  69564. vec3(0.,0.,0.),
  69565. vec3(0.,0.,0.),
  69566. vec3(0.,0.,0.),
  69567. vec3(0.,0.,0.),
  69568. vec3(0.,0.,0.),
  69569. vec3(0.,0.,0.),
  69570. vec3(0.,0.,0.),
  69571. vec3(0.,0.,0.),
  69572. vec3(0.,0.,0.),
  69573. vec3(0.,0.,0.),
  69574. vec3(0.,0.,0.),
  69575. vec3(0.,0.,0.),
  69576. vec3(0.,0.,0.),
  69577. vec3(0.,0.,0.),
  69578. vec3(0.,0.,0.),
  69579. vec3(0.,0.,0.),
  69580. vec3(0.,0.,0.),
  69581. vec3(0.,0.,0.),
  69582. vec3(0.,0.,0.),
  69583. vec3(0.,0.,0.),
  69584. vec3(0.,0.,0.),
  69585. vec3(0.,0.,0.),
  69586. vec3(0.,0.,0.),
  69587. vec3(0.,0.,0.),
  69588. vec3(0.,0.,0.),
  69589. vec3(0.,0.,0.),
  69590. vec3(0.,0.,0.),
  69591. vec3(0.,0.,0.),
  69592. vec3(0.,0.,0.)
  69593. );
  69594. const vec3 PoissonSamplers64[64]=vec3[64](
  69595. vec3(-0.613392,0.617481,0.),
  69596. vec3(0.170019,-0.040254,0.),
  69597. vec3(-0.299417,0.791925,0.),
  69598. vec3(0.645680,0.493210,0.),
  69599. vec3(-0.651784,0.717887,0.),
  69600. vec3(0.421003,0.027070,0.),
  69601. vec3(-0.817194,-0.271096,0.),
  69602. vec3(-0.705374,-0.668203,0.),
  69603. vec3(0.977050,-0.108615,0.),
  69604. vec3(0.063326,0.142369,0.),
  69605. vec3(0.203528,0.214331,0.),
  69606. vec3(-0.667531,0.326090,0.),
  69607. vec3(-0.098422,-0.295755,0.),
  69608. vec3(-0.885922,0.215369,0.),
  69609. vec3(0.566637,0.605213,0.),
  69610. vec3(0.039766,-0.396100,0.),
  69611. vec3(0.751946,0.453352,0.),
  69612. vec3(0.078707,-0.715323,0.),
  69613. vec3(-0.075838,-0.529344,0.),
  69614. vec3(0.724479,-0.580798,0.),
  69615. vec3(0.222999,-0.215125,0.),
  69616. vec3(-0.467574,-0.405438,0.),
  69617. vec3(-0.248268,-0.814753,0.),
  69618. vec3(0.354411,-0.887570,0.),
  69619. vec3(0.175817,0.382366,0.),
  69620. vec3(0.487472,-0.063082,0.),
  69621. vec3(-0.084078,0.898312,0.),
  69622. vec3(0.488876,-0.783441,0.),
  69623. vec3(0.470016,0.217933,0.),
  69624. vec3(-0.696890,-0.549791,0.),
  69625. vec3(-0.149693,0.605762,0.),
  69626. vec3(0.034211,0.979980,0.),
  69627. vec3(0.503098,-0.308878,0.),
  69628. vec3(-0.016205,-0.872921,0.),
  69629. vec3(0.385784,-0.393902,0.),
  69630. vec3(-0.146886,-0.859249,0.),
  69631. vec3(0.643361,0.164098,0.),
  69632. vec3(0.634388,-0.049471,0.),
  69633. vec3(-0.688894,0.007843,0.),
  69634. vec3(0.464034,-0.188818,0.),
  69635. vec3(-0.440840,0.137486,0.),
  69636. vec3(0.364483,0.511704,0.),
  69637. vec3(0.034028,0.325968,0.),
  69638. vec3(0.099094,-0.308023,0.),
  69639. vec3(0.693960,-0.366253,0.),
  69640. vec3(0.678884,-0.204688,0.),
  69641. vec3(0.001801,0.780328,0.),
  69642. vec3(0.145177,-0.898984,0.),
  69643. vec3(0.062655,-0.611866,0.),
  69644. vec3(0.315226,-0.604297,0.),
  69645. vec3(-0.780145,0.486251,0.),
  69646. vec3(-0.371868,0.882138,0.),
  69647. vec3(0.200476,0.494430,0.),
  69648. vec3(-0.494552,-0.711051,0.),
  69649. vec3(0.612476,0.705252,0.),
  69650. vec3(-0.578845,-0.768792,0.),
  69651. vec3(-0.772454,-0.090976,0.),
  69652. vec3(0.504440,0.372295,0.),
  69653. vec3(0.155736,0.065157,0.),
  69654. vec3(0.391522,0.849605,0.),
  69655. vec3(-0.620106,-0.328104,0.),
  69656. vec3(0.789239,-0.419965,0.),
  69657. vec3(-0.545396,0.538133,0.),
  69658. vec3(-0.178564,-0.596057,0.)
  69659. );
  69660. #define inline
  69661. float computeShadowWithCSMPCSS(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,int searchTapCount,int pcfTapCount,vec3[64] poissonSamplers,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)
  69662. {
  69663. vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
  69664. vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));
  69665. uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);
  69666. vec4 uvDepthLayer=vec4(uvDepth.x,uvDepth.y,layer,uvDepth.z);
  69667. float blockerDepth=0.0;
  69668. float sumBlockerDepth=0.0;
  69669. float numBlocker=0.0;
  69670. for (int i=0; i<searchTapCount; i ++) {
  69671. blockerDepth=texture2D(depthSampler,vec3(uvDepth.xy+(lightSizeUV*lightSizeUVCorrection*shadowMapSizeInverse*PoissonSamplers32[i].xy),layer)).r;
  69672. if (blockerDepth<depthMetric) {
  69673. sumBlockerDepth+=blockerDepth;
  69674. numBlocker++;
  69675. }
  69676. }
  69677. if (numBlocker<1.0) {
  69678. return 1.0;
  69679. }
  69680. else
  69681. {
  69682. float avgBlockerDepth=sumBlockerDepth/numBlocker;
  69683. float AAOffset=shadowMapSizeInverse*10.;
  69684. float penumbraRatio=((depthMetric-avgBlockerDepth)*depthCorrection+AAOffset);
  69685. vec4 filterRadius=vec4(penumbraRatio*lightSizeUV*lightSizeUVCorrection*shadowMapSizeInverse,0.,0.);
  69686. float random=getRand(vPositionFromLight.xy);
  69687. float rotationAngle=random*3.1415926;
  69688. vec2 rotationVector=vec2(cos(rotationAngle),sin(rotationAngle));
  69689. float shadow=0.;
  69690. for (int i=0; i<pcfTapCount; i++) {
  69691. vec4 offset=vec4(poissonSamplers[i],0.);
  69692. offset=vec4(offset.x*rotationVector.x-offset.y*rotationVector.y,offset.y*rotationVector.x+offset.x*rotationVector.y,0.,0.);
  69693. shadow+=texture2D(shadowSampler,uvDepthLayer+offset*filterRadius);
  69694. }
  69695. shadow/=float(pcfTapCount);
  69696. shadow=mix(shadow,1.,min((depthMetric-avgBlockerDepth)*depthCorrection*penumbraDarkness,1.));
  69697. shadow=mix(darkness,1.,shadow);
  69698. return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);
  69699. }
  69700. }
  69701. #define inline
  69702. float computeShadowWithPCSS(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,int searchTapCount,int pcfTapCount,vec3[64] poissonSamplers)
  69703. {
  69704. if (depthMetric>1.0 || depthMetric<0.0) {
  69705. return 1.0;
  69706. }
  69707. else
  69708. {
  69709. vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
  69710. vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));
  69711. uvDepth.z=ZINCLIP;
  69712. float blockerDepth=0.0;
  69713. float sumBlockerDepth=0.0;
  69714. float numBlocker=0.0;
  69715. for (int i=0; i<searchTapCount; i ++) {
  69716. blockerDepth=texture2D(depthSampler,uvDepth.xy+(lightSizeUV*shadowMapSizeInverse*PoissonSamplers32[i].xy)).r;
  69717. if (blockerDepth<depthMetric) {
  69718. sumBlockerDepth+=blockerDepth;
  69719. numBlocker++;
  69720. }
  69721. }
  69722. if (numBlocker<1.0) {
  69723. return 1.0;
  69724. }
  69725. else
  69726. {
  69727. float avgBlockerDepth=sumBlockerDepth/numBlocker;
  69728. float AAOffset=shadowMapSizeInverse*10.;
  69729. float penumbraRatio=((depthMetric-avgBlockerDepth)+AAOffset);
  69730. float filterRadius=penumbraRatio*lightSizeUV*shadowMapSizeInverse;
  69731. float random=getRand(vPositionFromLight.xy);
  69732. float rotationAngle=random*3.1415926;
  69733. vec2 rotationVector=vec2(cos(rotationAngle),sin(rotationAngle));
  69734. float shadow=0.;
  69735. for (int i=0; i<pcfTapCount; i++) {
  69736. vec3 offset=poissonSamplers[i];
  69737. offset=vec3(offset.x*rotationVector.x-offset.y*rotationVector.y,offset.y*rotationVector.x+offset.x*rotationVector.y,0.);
  69738. shadow+=texture2D(shadowSampler,uvDepth+offset*filterRadius);
  69739. }
  69740. shadow/=float(pcfTapCount);
  69741. shadow=mix(shadow,1.,depthMetric-avgBlockerDepth);
  69742. shadow=mix(darkness,1.,shadow);
  69743. return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);
  69744. }
  69745. }
  69746. }
  69747. #define inline
  69748. float computeShadowWithPCSS16(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)
  69749. {
  69750. return computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,16,PoissonSamplers32);
  69751. }
  69752. #define inline
  69753. float computeShadowWithPCSS32(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)
  69754. {
  69755. return computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,32,PoissonSamplers32);
  69756. }
  69757. #define inline
  69758. float computeShadowWithPCSS64(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)
  69759. {
  69760. return computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,32,64,PoissonSamplers64);
  69761. }
  69762. #define inline
  69763. float computeShadowWithCSMPCSS16(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)
  69764. {
  69765. return computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,16,PoissonSamplers32,lightSizeUVCorrection,depthCorrection,penumbraDarkness);
  69766. }
  69767. #define inline
  69768. float computeShadowWithCSMPCSS32(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)
  69769. {
  69770. return computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,32,PoissonSamplers32,lightSizeUVCorrection,depthCorrection,penumbraDarkness);
  69771. }
  69772. #define inline
  69773. float computeShadowWithCSMPCSS64(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)
  69774. {
  69775. return computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,32,64,PoissonSamplers64,lightSizeUVCorrection,depthCorrection,penumbraDarkness);
  69776. }
  69777. #endif
  69778. #endif
  69779. `;
  69780. ShaderStore.IncludesShadersStore[name$1X] = shader$1X;
  69781. var name$1W = "samplerFragmentDeclaration"
  69782. , shader$1W = `#ifdef _DEFINENAME_
  69783. #if _DEFINENAME_DIRECTUV == 1
  69784. #define v_VARYINGNAME_UV vMainUV1
  69785. #elif _DEFINENAME_DIRECTUV == 2
  69786. #define v_VARYINGNAME_UV vMainUV2
  69787. #elif _DEFINENAME_DIRECTUV == 3
  69788. #define v_VARYINGNAME_UV vMainUV3
  69789. #elif _DEFINENAME_DIRECTUV == 4
  69790. #define v_VARYINGNAME_UV vMainUV4
  69791. #elif _DEFINENAME_DIRECTUV == 5
  69792. #define v_VARYINGNAME_UV vMainUV5
  69793. #elif _DEFINENAME_DIRECTUV == 6
  69794. #define v_VARYINGNAME_UV vMainUV6
  69795. #else
  69796. varying vec2 v_VARYINGNAME_UV;
  69797. #endif
  69798. uniform sampler2D _SAMPLERNAME_Sampler;
  69799. #endif
  69800. `;
  69801. ShaderStore.IncludesShadersStore[name$1W] = shader$1W;
  69802. var name$1V = "fresnelFunction"
  69803. , shader$1V = `#ifdef FRESNEL
  69804. float computeFresnelTerm(vec3 viewDirection,vec3 worldNormal,float bias,float power)
  69805. {
  69806. float fresnelTerm=pow(bias+abs(dot(viewDirection,worldNormal)),power);
  69807. return clamp(fresnelTerm,0.,1.);
  69808. }
  69809. #endif`;
  69810. ShaderStore.IncludesShadersStore[name$1V] = shader$1V;
  69811. var name$1U = "reflectionFunction"
  69812. , shader$1U = `vec3 computeFixedEquirectangularCoords(vec4 worldPos,vec3 worldNormal,vec3 direction)
  69813. {
  69814. float lon=atan(direction.z,direction.x);
  69815. float lat=acos(direction.y);
  69816. vec2 sphereCoords=vec2(lon,lat)*RECIPROCAL_PI2*2.0;
  69817. float s=sphereCoords.x*0.5+0.5;
  69818. float t=sphereCoords.y;
  69819. return vec3(s,t,0);
  69820. }
  69821. vec3 computeMirroredFixedEquirectangularCoords(vec4 worldPos,vec3 worldNormal,vec3 direction)
  69822. {
  69823. float lon=atan(direction.z,direction.x);
  69824. float lat=acos(direction.y);
  69825. vec2 sphereCoords=vec2(lon,lat)*RECIPROCAL_PI2*2.0;
  69826. float s=sphereCoords.x*0.5+0.5;
  69827. float t=sphereCoords.y;
  69828. return vec3(1.0-s,t,0);
  69829. }
  69830. vec3 computeEquirectangularCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix)
  69831. {
  69832. vec3 cameraToVertex=normalize(worldPos.xyz-eyePosition);
  69833. vec3 r=normalize(reflect(cameraToVertex,worldNormal));
  69834. r=vec3(reflectionMatrix*vec4(r,0));
  69835. float lon=atan(r.z,r.x);
  69836. float lat=acos(r.y);
  69837. vec2 sphereCoords=vec2(lon,lat)*RECIPROCAL_PI2*2.0;
  69838. float s=sphereCoords.x*0.5+0.5;
  69839. float t=sphereCoords.y;
  69840. return vec3(s,t,0);
  69841. }
  69842. vec3 computeSphericalCoords(vec4 worldPos,vec3 worldNormal,mat4 view,mat4 reflectionMatrix)
  69843. {
  69844. vec3 viewDir=normalize(vec3(view*worldPos));
  69845. vec3 viewNormal=normalize(vec3(view*vec4(worldNormal,0.0)));
  69846. vec3 r=reflect(viewDir,viewNormal);
  69847. r=vec3(reflectionMatrix*vec4(r,0));
  69848. r.z=r.z-1.0;
  69849. float m=2.0*length(r);
  69850. return vec3(r.x/m+0.5,1.0-r.y/m-0.5,0);
  69851. }
  69852. vec3 computePlanarCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix)
  69853. {
  69854. vec3 viewDir=worldPos.xyz-eyePosition;
  69855. vec3 coords=normalize(reflect(viewDir,worldNormal));
  69856. return vec3(reflectionMatrix*vec4(coords,1));
  69857. }
  69858. vec3 computeCubicCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix)
  69859. {
  69860. vec3 viewDir=normalize(worldPos.xyz-eyePosition);
  69861. vec3 coords=reflect(viewDir,worldNormal);
  69862. coords=vec3(reflectionMatrix*vec4(coords,0));
  69863. #ifdef INVERTCUBICMAP
  69864. coords.y*=-1.0;
  69865. #endif
  69866. return coords;
  69867. }
  69868. vec3 computeCubicLocalCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix,vec3 reflectionSize,vec3 reflectionPosition)
  69869. {
  69870. vec3 viewDir=normalize(worldPos.xyz-eyePosition);
  69871. vec3 coords=reflect(viewDir,worldNormal);
  69872. coords=parallaxCorrectNormal(worldPos.xyz,coords,reflectionSize,reflectionPosition);
  69873. coords=vec3(reflectionMatrix*vec4(coords,0));
  69874. #ifdef INVERTCUBICMAP
  69875. coords.y*=-1.0;
  69876. #endif
  69877. return coords;
  69878. }
  69879. vec3 computeProjectionCoords(vec4 worldPos,mat4 view,mat4 reflectionMatrix)
  69880. {
  69881. return vec3(reflectionMatrix*(view*worldPos));
  69882. }
  69883. vec3 computeSkyBoxCoords(vec3 positionW,mat4 reflectionMatrix)
  69884. {
  69885. return vec3(reflectionMatrix*vec4(positionW,1.));
  69886. }
  69887. #ifdef REFLECTION
  69888. vec3 computeReflectionCoords(vec4 worldPos,vec3 worldNormal)
  69889. {
  69890. #ifdef REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED
  69891. vec3 direction=normalize(vDirectionW);
  69892. return computeMirroredFixedEquirectangularCoords(worldPos,worldNormal,direction);
  69893. #endif
  69894. #ifdef REFLECTIONMAP_EQUIRECTANGULAR_FIXED
  69895. vec3 direction=normalize(vDirectionW);
  69896. return computeFixedEquirectangularCoords(worldPos,worldNormal,direction);
  69897. #endif
  69898. #ifdef REFLECTIONMAP_EQUIRECTANGULAR
  69899. return computeEquirectangularCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix);
  69900. #endif
  69901. #ifdef REFLECTIONMAP_SPHERICAL
  69902. return computeSphericalCoords(worldPos,worldNormal,view,reflectionMatrix);
  69903. #endif
  69904. #ifdef REFLECTIONMAP_PLANAR
  69905. return computePlanarCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix);
  69906. #endif
  69907. #ifdef REFLECTIONMAP_CUBIC
  69908. #ifdef USE_LOCAL_REFLECTIONMAP_CUBIC
  69909. return computeCubicLocalCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix,vReflectionSize,vReflectionPosition);
  69910. #else
  69911. return computeCubicCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix);
  69912. #endif
  69913. #endif
  69914. #ifdef REFLECTIONMAP_PROJECTION
  69915. return computeProjectionCoords(worldPos,view,reflectionMatrix);
  69916. #endif
  69917. #ifdef REFLECTIONMAP_SKYBOX
  69918. return computeSkyBoxCoords(vPositionUVW,reflectionMatrix);
  69919. #endif
  69920. #ifdef REFLECTIONMAP_EXPLICIT
  69921. return vec3(0,0,0);
  69922. #endif
  69923. }
  69924. #endif`;
  69925. ShaderStore.IncludesShadersStore[name$1U] = shader$1U;
  69926. var name$1T = "imageProcessingDeclaration"
  69927. , shader$1T = `#ifdef EXPOSURE
  69928. uniform float exposureLinear;
  69929. #endif
  69930. #ifdef CONTRAST
  69931. uniform float contrast;
  69932. #endif
  69933. #ifdef VIGNETTE
  69934. uniform vec2 vInverseScreenSize;
  69935. uniform vec4 vignetteSettings1;
  69936. uniform vec4 vignetteSettings2;
  69937. #endif
  69938. #ifdef COLORCURVES
  69939. uniform vec4 vCameraColorCurveNegative;
  69940. uniform vec4 vCameraColorCurveNeutral;
  69941. uniform vec4 vCameraColorCurvePositive;
  69942. #endif
  69943. #ifdef COLORGRADING
  69944. #ifdef COLORGRADING3D
  69945. uniform highp sampler3D txColorTransform;
  69946. #else
  69947. uniform sampler2D txColorTransform;
  69948. #endif
  69949. uniform vec4 colorTransformSettings;
  69950. #endif`;
  69951. ShaderStore.IncludesShadersStore[name$1T] = shader$1T;
  69952. var name$1S = "imageProcessingFunctions"
  69953. , shader$1S = `#if defined(COLORGRADING) && !defined(COLORGRADING3D)
  69954. #define inline
  69955. vec3 sampleTexture3D(sampler2D colorTransform,vec3 color,vec2 sampler3dSetting)
  69956. {
  69957. float sliceSize=2.0*sampler3dSetting.x;
  69958. #ifdef SAMPLER3DGREENDEPTH
  69959. float sliceContinuous=(color.g-sampler3dSetting.x)*sampler3dSetting.y;
  69960. #else
  69961. float sliceContinuous=(color.b-sampler3dSetting.x)*sampler3dSetting.y;
  69962. #endif
  69963. float sliceInteger=floor(sliceContinuous);
  69964. float sliceFraction=sliceContinuous-sliceInteger;
  69965. #ifdef SAMPLER3DGREENDEPTH
  69966. vec2 sliceUV=color.rb;
  69967. #else
  69968. vec2 sliceUV=color.rg;
  69969. #endif
  69970. sliceUV.x*=sliceSize;
  69971. sliceUV.x+=sliceInteger*sliceSize;
  69972. sliceUV=saturate(sliceUV);
  69973. vec4 slice0Color=texture2D(colorTransform,sliceUV);
  69974. sliceUV.x+=sliceSize;
  69975. sliceUV=saturate(sliceUV);
  69976. vec4 slice1Color=texture2D(colorTransform,sliceUV);
  69977. vec3 result=mix(slice0Color.rgb,slice1Color.rgb,sliceFraction);
  69978. #ifdef SAMPLER3DBGRMAP
  69979. color.rgb=result.rgb;
  69980. #else
  69981. color.rgb=result.bgr;
  69982. #endif
  69983. return color;
  69984. }
  69985. #endif
  69986. #ifdef TONEMAPPING_ACES
  69987. const mat3 ACESInputMat=mat3(
  69988. vec3(0.59719,0.07600,0.02840),
  69989. vec3(0.35458,0.90834,0.13383),
  69990. vec3(0.04823,0.01566,0.83777)
  69991. );
  69992. const mat3 ACESOutputMat=mat3(
  69993. vec3( 1.60475,-0.10208,-0.00327),
  69994. vec3(-0.53108,1.10813,-0.07276),
  69995. vec3(-0.07367,-0.00605,1.07602)
  69996. );
  69997. vec3 RRTAndODTFit(vec3 v)
  69998. {
  69999. vec3 a=v*(v+0.0245786)-0.000090537;
  70000. vec3 b=v*(0.983729*v+0.4329510)+0.238081;
  70001. return a/b;
  70002. }
  70003. vec3 ACESFitted(vec3 color)
  70004. {
  70005. color=ACESInputMat*color;
  70006. color=RRTAndODTFit(color);
  70007. color=ACESOutputMat*color;
  70008. color=saturate(color);
  70009. return color;
  70010. }
  70011. #endif
  70012. vec4 applyImageProcessing(vec4 result) {
  70013. #ifdef EXPOSURE
  70014. result.rgb*=exposureLinear;
  70015. #endif
  70016. #ifdef VIGNETTE
  70017. vec2 viewportXY=gl_FragCoord.xy*vInverseScreenSize;
  70018. viewportXY=viewportXY*2.0-1.0;
  70019. vec3 vignetteXY1=vec3(viewportXY*vignetteSettings1.xy+vignetteSettings1.zw,1.0);
  70020. float vignetteTerm=dot(vignetteXY1,vignetteXY1);
  70021. float vignette=pow(vignetteTerm,vignetteSettings2.w);
  70022. vec3 vignetteColor=vignetteSettings2.rgb;
  70023. #ifdef VIGNETTEBLENDMODEMULTIPLY
  70024. vec3 vignetteColorMultiplier=mix(vignetteColor,vec3(1,1,1),vignette);
  70025. result.rgb*=vignetteColorMultiplier;
  70026. #endif
  70027. #ifdef VIGNETTEBLENDMODEOPAQUE
  70028. result.rgb=mix(vignetteColor,result.rgb,vignette);
  70029. #endif
  70030. #endif
  70031. #ifdef TONEMAPPING
  70032. #ifdef TONEMAPPING_ACES
  70033. result.rgb=ACESFitted(result.rgb);
  70034. #else
  70035. const float tonemappingCalibration=1.590579;
  70036. result.rgb=1.0-exp2(-tonemappingCalibration*result.rgb);
  70037. #endif
  70038. #endif
  70039. result.rgb=toGammaSpace(result.rgb);
  70040. result.rgb=saturate(result.rgb);
  70041. #ifdef CONTRAST
  70042. vec3 resultHighContrast=result.rgb*result.rgb*(3.0-2.0*result.rgb);
  70043. if (contrast<1.0) {
  70044. result.rgb=mix(vec3(0.5,0.5,0.5),result.rgb,contrast);
  70045. } else {
  70046. result.rgb=mix(result.rgb,resultHighContrast,contrast-1.0);
  70047. }
  70048. #endif
  70049. #ifdef COLORGRADING
  70050. vec3 colorTransformInput=result.rgb*colorTransformSettings.xxx+colorTransformSettings.yyy;
  70051. #ifdef COLORGRADING3D
  70052. vec3 colorTransformOutput=texture(txColorTransform,colorTransformInput).rgb;
  70053. #else
  70054. vec3 colorTransformOutput=sampleTexture3D(txColorTransform,colorTransformInput,colorTransformSettings.yz).rgb;
  70055. #endif
  70056. result.rgb=mix(result.rgb,colorTransformOutput,colorTransformSettings.www);
  70057. #endif
  70058. #ifdef COLORCURVES
  70059. float luma=getLuminance(result.rgb);
  70060. vec2 curveMix=clamp(vec2(luma*3.0-1.5,luma*-3.0+1.5),vec2(0.0),vec2(1.0));
  70061. vec4 colorCurve=vCameraColorCurveNeutral+curveMix.x*vCameraColorCurvePositive-curveMix.y*vCameraColorCurveNegative;
  70062. result.rgb*=colorCurve.rgb;
  70063. result.rgb=mix(vec3(luma),result.rgb,colorCurve.a);
  70064. #endif
  70065. return result;
  70066. }`;
  70067. ShaderStore.IncludesShadersStore[name$1S] = shader$1S;
  70068. var name$1R = "bumpFragmentMainFunctions"
  70069. , shader$1R = `#if defined(BUMP) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC) || defined(DETAIL)
  70070. #if defined(TANGENT) && defined(NORMAL)
  70071. varying mat3 vTBN;
  70072. #endif
  70073. #ifdef OBJECTSPACE_NORMALMAP
  70074. uniform mat4 normalMatrix;
  70075. #endif
  70076. vec3 perturbNormalBase(mat3 cotangentFrame,vec3 normal,float scale)
  70077. {
  70078. #ifdef NORMALXYSCALE
  70079. normal=normalize(normal*vec3(scale,scale,1.0));
  70080. #endif
  70081. return normalize(cotangentFrame*normal);
  70082. }
  70083. vec3 perturbNormal(mat3 cotangentFrame,vec3 textureSample,float scale)
  70084. {
  70085. return perturbNormalBase(cotangentFrame,textureSample*2.0-1.0,scale);
  70086. }
  70087. mat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv,vec2 tangentSpaceParams)
  70088. {
  70089. vec3 dp1=dFdx(p);
  70090. vec3 dp2=dFdy(p);
  70091. vec2 duv1=dFdx(uv);
  70092. vec2 duv2=dFdy(uv);
  70093. vec3 dp2perp=cross(dp2,normal);
  70094. vec3 dp1perp=cross(normal,dp1);
  70095. vec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;
  70096. vec3 bitangent=dp2perp*duv1.y+dp1perp*duv2.y;
  70097. tangent*=tangentSpaceParams.x;
  70098. bitangent*=tangentSpaceParams.y;
  70099. float invmax=inversesqrt(max(dot(tangent,tangent),dot(bitangent,bitangent)));
  70100. return mat3(tangent*invmax,bitangent*invmax,normal);
  70101. }
  70102. #endif
  70103. `;
  70104. ShaderStore.IncludesShadersStore[name$1R] = shader$1R;
  70105. var name$1Q = "bumpFragmentFunctions"
  70106. , shader$1Q = `#if defined(BUMP)
  70107. #include<samplerFragmentDeclaration>(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_SAMPLERNAME_,bump)
  70108. #endif
  70109. #if defined(DETAIL)
  70110. #include<samplerFragmentDeclaration>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_SAMPLERNAME_,detail)
  70111. #endif
  70112. #if defined(BUMP) && defined(PARALLAX)
  70113. const float minSamples=4.;
  70114. const float maxSamples=15.;
  70115. const int iMaxSamples=15;
  70116. vec2 parallaxOcclusion(vec3 vViewDirCoT,vec3 vNormalCoT,vec2 texCoord,float parallaxScale) {
  70117. float parallaxLimit=length(vViewDirCoT.xy)/vViewDirCoT.z;
  70118. parallaxLimit*=parallaxScale;
  70119. vec2 vOffsetDir=normalize(vViewDirCoT.xy);
  70120. vec2 vMaxOffset=vOffsetDir*parallaxLimit;
  70121. float numSamples=maxSamples+(dot(vViewDirCoT,vNormalCoT)*(minSamples-maxSamples));
  70122. float stepSize=1.0/numSamples;
  70123. float currRayHeight=1.0;
  70124. vec2 vCurrOffset=vec2(0,0);
  70125. vec2 vLastOffset=vec2(0,0);
  70126. float lastSampledHeight=1.0;
  70127. float currSampledHeight=1.0;
  70128. for (int i=0; i<iMaxSamples; i++)
  70129. {
  70130. currSampledHeight=texture2D(bumpSampler,texCoord+vCurrOffset).w;
  70131. if (currSampledHeight>currRayHeight)
  70132. {
  70133. float delta1=currSampledHeight-currRayHeight;
  70134. float delta2=(currRayHeight+stepSize)-lastSampledHeight;
  70135. float ratio=delta1/(delta1+delta2);
  70136. vCurrOffset=(ratio)* vLastOffset+(1.0-ratio)*vCurrOffset;
  70137. break;
  70138. }
  70139. else
  70140. {
  70141. currRayHeight-=stepSize;
  70142. vLastOffset=vCurrOffset;
  70143. vCurrOffset+=stepSize*vMaxOffset;
  70144. lastSampledHeight=currSampledHeight;
  70145. }
  70146. }
  70147. return vCurrOffset;
  70148. }
  70149. vec2 parallaxOffset(vec3 viewDir,float heightScale)
  70150. {
  70151. float height=texture2D(bumpSampler,vBumpUV).w;
  70152. vec2 texCoordOffset=heightScale*viewDir.xy*height;
  70153. return -texCoordOffset;
  70154. }
  70155. #endif
  70156. `;
  70157. ShaderStore.IncludesShadersStore[name$1Q] = shader$1Q;
  70158. var name$1P = "logDepthDeclaration"
  70159. , shader$1P = `#ifdef LOGARITHMICDEPTH
  70160. uniform float logarithmicDepthConstant;
  70161. varying float vFragmentDepth;
  70162. #endif`;
  70163. ShaderStore.IncludesShadersStore[name$1P] = shader$1P;
  70164. var name$1O = "fogFragmentDeclaration"
  70165. , shader$1O = `#ifdef FOG
  70166. #define FOGMODE_NONE 0.
  70167. #define FOGMODE_EXP 1.
  70168. #define FOGMODE_EXP2 2.
  70169. #define FOGMODE_LINEAR 3.
  70170. #define E 2.71828
  70171. uniform vec4 vFogInfos;
  70172. uniform vec3 vFogColor;
  70173. varying vec3 vFogDistance;
  70174. float CalcFogFactor()
  70175. {
  70176. float fogCoeff=1.0;
  70177. float fogStart=vFogInfos.y;
  70178. float fogEnd=vFogInfos.z;
  70179. float fogDensity=vFogInfos.w;
  70180. float fogDistance=length(vFogDistance);
  70181. if (FOGMODE_LINEAR == vFogInfos.x)
  70182. {
  70183. fogCoeff=(fogEnd-fogDistance)/(fogEnd-fogStart);
  70184. }
  70185. else if (FOGMODE_EXP == vFogInfos.x)
  70186. {
  70187. fogCoeff=1.0/pow(E,fogDistance*fogDensity);
  70188. }
  70189. else if (FOGMODE_EXP2 == vFogInfos.x)
  70190. {
  70191. fogCoeff=1.0/pow(E,fogDistance*fogDistance*fogDensity*fogDensity);
  70192. }
  70193. return clamp(fogCoeff,0.0,1.0);
  70194. }
  70195. #endif`;
  70196. ShaderStore.IncludesShadersStore[name$1O] = shader$1O;
  70197. var name$1N = "oitFragment"
  70198. , shader$1N = `#ifdef ORDER_INDEPENDENT_TRANSPARENCY
  70199. float fragDepth=gl_FragCoord.z;
  70200. #ifdef ORDER_INDEPENDENT_TRANSPARENCY_16BITS
  70201. uint halfFloat=packHalf2x16(vec2(fragDepth));
  70202. vec2 full=unpackHalf2x16(halfFloat);
  70203. fragDepth=full.x;
  70204. #endif
  70205. ivec2 fragCoord=ivec2(gl_FragCoord.xy);
  70206. vec2 lastDepth=texelFetch(oitDepthSampler,fragCoord,0).rg;
  70207. vec4 lastFrontColor=texelFetch(oitFrontColorSampler,fragCoord,0);
  70208. depth.rg=vec2(-MAX_DEPTH);
  70209. frontColor=lastFrontColor;
  70210. backColor=vec4(0.0);
  70211. #ifdef USE_REVERSE_DEPTHBUFFER
  70212. float furthestDepth=-lastDepth.x;
  70213. float nearestDepth=lastDepth.y;
  70214. #else
  70215. float nearestDepth=-lastDepth.x;
  70216. float furthestDepth=lastDepth.y;
  70217. #endif
  70218. float alphaMultiplier=1.0-lastFrontColor.a;
  70219. #ifdef USE_REVERSE_DEPTHBUFFER
  70220. if (fragDepth>nearestDepth || fragDepth<furthestDepth) {
  70221. #else
  70222. if (fragDepth<nearestDepth || fragDepth>furthestDepth) {
  70223. #endif
  70224. return;
  70225. }
  70226. #ifdef USE_REVERSE_DEPTHBUFFER
  70227. if (fragDepth<nearestDepth && fragDepth>furthestDepth) {
  70228. #else
  70229. if (fragDepth>nearestDepth && fragDepth<furthestDepth) {
  70230. #endif
  70231. depth.rg=vec2(-fragDepth,fragDepth);
  70232. return;
  70233. }
  70234. #endif`;
  70235. ShaderStore.IncludesShadersStore[name$1N] = shader$1N;
  70236. var name$1M = "bumpFragment"
  70237. , shader$1M = `vec2 uvOffset=vec2(0.0,0.0);
  70238. #if defined(BUMP) || defined(PARALLAX) || defined(DETAIL)
  70239. #ifdef NORMALXYSCALE
  70240. float normalScale=1.0;
  70241. #elif defined(BUMP)
  70242. float normalScale=vBumpInfos.y;
  70243. #else
  70244. float normalScale=1.0;
  70245. #endif
  70246. #if defined(TANGENT) && defined(NORMAL)
  70247. mat3 TBN=vTBN;
  70248. #elif defined(BUMP)
  70249. vec2 TBNUV=gl_FrontFacing ? vBumpUV : -vBumpUV;
  70250. mat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,TBNUV,vTangentSpaceParams);
  70251. #else
  70252. vec2 TBNUV=gl_FrontFacing ? vDetailUV : -vDetailUV;
  70253. mat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,TBNUV,vec2(1.,1.));
  70254. #endif
  70255. #elif defined(ANISOTROPIC)
  70256. #if defined(TANGENT) && defined(NORMAL)
  70257. mat3 TBN=vTBN;
  70258. #else
  70259. vec2 TBNUV=gl_FrontFacing ? vMainUV1 : -vMainUV1;
  70260. mat3 TBN=cotangent_frame(normalW,vPositionW,TBNUV,vec2(1.,1.));
  70261. #endif
  70262. #endif
  70263. #ifdef PARALLAX
  70264. mat3 invTBN=transposeMat3(TBN);
  70265. #ifdef PARALLAXOCCLUSION
  70266. uvOffset=parallaxOcclusion(invTBN*-viewDirectionW,invTBN*normalW,vBumpUV,vBumpInfos.z);
  70267. #else
  70268. uvOffset=parallaxOffset(invTBN*viewDirectionW,vBumpInfos.z);
  70269. #endif
  70270. #endif
  70271. #ifdef DETAIL
  70272. vec4 detailColor=texture2D(detailSampler,vDetailUV+uvOffset);
  70273. vec2 detailNormalRG=detailColor.wy*2.0-1.0;
  70274. float detailNormalB=sqrt(1.-saturate(dot(detailNormalRG,detailNormalRG)));
  70275. vec3 detailNormal=vec3(detailNormalRG,detailNormalB);
  70276. #endif
  70277. #ifdef BUMP
  70278. #ifdef OBJECTSPACE_NORMALMAP
  70279. normalW=normalize(texture2D(bumpSampler,vBumpUV).xyz*2.0-1.0);
  70280. normalW=normalize(mat3(normalMatrix)*normalW);
  70281. #elif !defined(DETAIL)
  70282. normalW=perturbNormal(TBN,texture2D(bumpSampler,vBumpUV+uvOffset).xyz,vBumpInfos.y);
  70283. #else
  70284. vec3 bumpNormal=texture2D(bumpSampler,vBumpUV+uvOffset).xyz*2.0-1.0;
  70285. #if DETAIL_NORMALBLENDMETHOD == 0
  70286. detailNormal.xy*=vDetailInfos.z;
  70287. vec3 blendedNormal=normalize(vec3(bumpNormal.xy+detailNormal.xy,bumpNormal.z*detailNormal.z));
  70288. #elif DETAIL_NORMALBLENDMETHOD == 1
  70289. detailNormal.xy*=vDetailInfos.z;
  70290. bumpNormal+=vec3(0.0,0.0,1.0);
  70291. detailNormal*=vec3(-1.0,-1.0,1.0);
  70292. vec3 blendedNormal=bumpNormal*dot(bumpNormal,detailNormal)/bumpNormal.z-detailNormal;
  70293. #endif
  70294. normalW=perturbNormalBase(TBN,blendedNormal,vBumpInfos.y);
  70295. #endif
  70296. #elif defined(DETAIL)
  70297. detailNormal.xy*=vDetailInfos.z;
  70298. normalW=perturbNormalBase(TBN,detailNormal,vDetailInfos.z);
  70299. #endif
  70300. `;
  70301. ShaderStore.IncludesShadersStore[name$1M] = shader$1M;
  70302. var name$1L = "depthPrePass"
  70303. , shader$1L = `#ifdef DEPTHPREPASS
  70304. gl_FragColor=vec4(0.,0.,0.,1.0);
  70305. return;
  70306. #endif`;
  70307. ShaderStore.IncludesShadersStore[name$1L] = shader$1L;
  70308. var name$1K = "lightFragment"
  70309. , shader$1K = `#ifdef LIGHT{X}
  70310. #if defined(SHADOWONLY) || defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X})
  70311. #else
  70312. #ifdef PBR
  70313. #ifdef SPOTLIGHT{X}
  70314. preInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);
  70315. #elif defined(POINTLIGHT{X})
  70316. preInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);
  70317. #elif defined(HEMILIGHT{X})
  70318. preInfo=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);
  70319. #elif defined(DIRLIGHT{X})
  70320. preInfo=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);
  70321. #endif
  70322. preInfo.NdotV=NdotV;
  70323. #ifdef SPOTLIGHT{X}
  70324. #ifdef LIGHT_FALLOFF_GLTF{X}
  70325. preInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);
  70326. preInfo.attenuation*=computeDirectionalLightFalloff_GLTF(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);
  70327. #elif defined(LIGHT_FALLOFF_PHYSICAL{X})
  70328. preInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);
  70329. preInfo.attenuation*=computeDirectionalLightFalloff_Physical(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w);
  70330. #elif defined(LIGHT_FALLOFF_STANDARD{X})
  70331. preInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);
  70332. preInfo.attenuation*=computeDirectionalLightFalloff_Standard(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w);
  70333. #else
  70334. preInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);
  70335. preInfo.attenuation*=computeDirectionalLightFalloff(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);
  70336. #endif
  70337. #elif defined(POINTLIGHT{X})
  70338. #ifdef LIGHT_FALLOFF_GLTF{X}
  70339. preInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);
  70340. #elif defined(LIGHT_FALLOFF_PHYSICAL{X})
  70341. preInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);
  70342. #elif defined(LIGHT_FALLOFF_STANDARD{X})
  70343. preInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);
  70344. #else
  70345. preInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);
  70346. #endif
  70347. #else
  70348. preInfo.attenuation=1.0;
  70349. #endif
  70350. #ifdef HEMILIGHT{X}
  70351. preInfo.roughness=roughness;
  70352. #else
  70353. preInfo.roughness=adjustRoughnessFromLightProperties(roughness,light{X}.vLightSpecular.a,preInfo.lightDistance);
  70354. #endif
  70355. #ifdef HEMILIGHT{X}
  70356. info.diffuse=computeHemisphericDiffuseLighting(preInfo,light{X}.vLightDiffuse.rgb,light{X}.vLightGround);
  70357. #elif defined(SS_TRANSLUCENCY)
  70358. info.diffuse=computeDiffuseAndTransmittedLighting(preInfo,light{X}.vLightDiffuse.rgb,subSurfaceOut.transmittance);
  70359. #else
  70360. info.diffuse=computeDiffuseLighting(preInfo,light{X}.vLightDiffuse.rgb);
  70361. #endif
  70362. #ifdef SPECULARTERM
  70363. #ifdef ANISOTROPIC
  70364. info.specular=computeAnisotropicSpecularLighting(preInfo,viewDirectionW,normalW,anisotropicOut.anisotropicTangent,anisotropicOut.anisotropicBitangent,anisotropicOut.anisotropy,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);
  70365. #else
  70366. info.specular=computeSpecularLighting(preInfo,normalW,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);
  70367. #endif
  70368. #endif
  70369. #ifdef SHEEN
  70370. #ifdef SHEEN_LINKWITHALBEDO
  70371. preInfo.roughness=sheenOut.sheenIntensity;
  70372. #else
  70373. #ifdef HEMILIGHT{X}
  70374. preInfo.roughness=sheenOut.sheenRoughness;
  70375. #else
  70376. preInfo.roughness=adjustRoughnessFromLightProperties(sheenOut.sheenRoughness,light{X}.vLightSpecular.a,preInfo.lightDistance);
  70377. #endif
  70378. #endif
  70379. info.sheen=computeSheenLighting(preInfo,normalW,sheenOut.sheenColor,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);
  70380. #endif
  70381. #ifdef CLEARCOAT
  70382. #ifdef HEMILIGHT{X}
  70383. preInfo.roughness=clearcoatOut.clearCoatRoughness;
  70384. #else
  70385. preInfo.roughness=adjustRoughnessFromLightProperties(clearcoatOut.clearCoatRoughness,light{X}.vLightSpecular.a,preInfo.lightDistance);
  70386. #endif
  70387. info.clearCoat=computeClearCoatLighting(preInfo,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatAARoughnessFactors.x,clearcoatOut.clearCoatIntensity,light{X}.vLightDiffuse.rgb);
  70388. #ifdef CLEARCOAT_TINT
  70389. absorption=computeClearCoatLightingAbsorption(clearcoatOut.clearCoatNdotVRefract,preInfo.L,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatColor,clearcoatOut.clearCoatThickness,clearcoatOut.clearCoatIntensity);
  70390. info.diffuse*=absorption;
  70391. #ifdef SPECULARTERM
  70392. info.specular*=absorption;
  70393. #endif
  70394. #endif
  70395. info.diffuse*=info.clearCoat.w;
  70396. #ifdef SPECULARTERM
  70397. info.specular*=info.clearCoat.w;
  70398. #endif
  70399. #ifdef SHEEN
  70400. info.sheen*=info.clearCoat.w;
  70401. #endif
  70402. #endif
  70403. #else
  70404. #ifdef SPOTLIGHT{X}
  70405. info=computeSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular.rgb,light{X}.vLightDiffuse.a,glossiness);
  70406. #elif defined(HEMILIGHT{X})
  70407. info=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular.rgb,light{X}.vLightGround,glossiness);
  70408. #elif defined(POINTLIGHT{X}) || defined(DIRLIGHT{X})
  70409. info=computeLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular.rgb,light{X}.vLightDiffuse.a,glossiness);
  70410. #endif
  70411. #endif
  70412. #ifdef PROJECTEDLIGHTTEXTURE{X}
  70413. info.diffuse*=computeProjectionTextureDiffuseLighting(projectionLightSampler{X},textureProjectionMatrix{X});
  70414. #endif
  70415. #endif
  70416. #ifdef SHADOW{X}
  70417. #ifdef SHADOWCSM{X}
  70418. for (int i=0; i<SHADOWCSMNUM_CASCADES{X}; i++)
  70419. {
  70420. #ifdef SHADOWCSM_RIGHTHANDED{X}
  70421. diff{X}=viewFrustumZ{X}[i]+vPositionFromCamera{X}.z;
  70422. #else
  70423. diff{X}=viewFrustumZ{X}[i]-vPositionFromCamera{X}.z;
  70424. #endif
  70425. if (diff{X}>=0.) {
  70426. index{X}=i;
  70427. break;
  70428. }
  70429. }
  70430. #ifdef SHADOWCSMUSESHADOWMAXZ{X}
  70431. if (index{X}>=0)
  70432. #endif
  70433. {
  70434. #if defined(SHADOWPCF{X})
  70435. #if defined(SHADOWLOWQUALITY{X})
  70436. shadow=computeShadowWithCSMPCF1(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
  70437. #elif defined(SHADOWMEDIUMQUALITY{X})
  70438. shadow=computeShadowWithCSMPCF3(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
  70439. #else
  70440. shadow=computeShadowWithCSMPCF5(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
  70441. #endif
  70442. #elif defined(SHADOWPCSS{X})
  70443. #if defined(SHADOWLOWQUALITY{X})
  70444. shadow=computeShadowWithCSMPCSS16(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});
  70445. #elif defined(SHADOWMEDIUMQUALITY{X})
  70446. shadow=computeShadowWithCSMPCSS32(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});
  70447. #else
  70448. shadow=computeShadowWithCSMPCSS64(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});
  70449. #endif
  70450. #else
  70451. shadow=computeShadowCSM(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
  70452. #endif
  70453. #ifdef SHADOWCSMDEBUG{X}
  70454. shadowDebug{X}=vec3(shadow)*vCascadeColorsMultiplier{X}[index{X}];
  70455. #endif
  70456. #ifndef SHADOWCSMNOBLEND{X}
  70457. float frustumLength=frustumLengths{X}[index{X}];
  70458. float diffRatio=clamp(diff{X}/frustumLength,0.,1.)*cascadeBlendFactor{X};
  70459. if (index{X}<(SHADOWCSMNUM_CASCADES{X}-1) && diffRatio<1.)
  70460. {
  70461. index{X}+=1;
  70462. float nextShadow=0.;
  70463. #if defined(SHADOWPCF{X})
  70464. #if defined(SHADOWLOWQUALITY{X})
  70465. nextShadow=computeShadowWithCSMPCF1(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
  70466. #elif defined(SHADOWMEDIUMQUALITY{X})
  70467. nextShadow=computeShadowWithCSMPCF3(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
  70468. #else
  70469. nextShadow=computeShadowWithCSMPCF5(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
  70470. #endif
  70471. #elif defined(SHADOWPCSS{X})
  70472. #if defined(SHADOWLOWQUALITY{X})
  70473. nextShadow=computeShadowWithCSMPCSS16(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});
  70474. #elif defined(SHADOWMEDIUMQUALITY{X})
  70475. nextShadow=computeShadowWithCSMPCSS32(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});
  70476. #else
  70477. nextShadow=computeShadowWithCSMPCSS64(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});
  70478. #endif
  70479. #else
  70480. nextShadow=computeShadowCSM(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
  70481. #endif
  70482. shadow=mix(nextShadow,shadow,diffRatio);
  70483. #ifdef SHADOWCSMDEBUG{X}
  70484. shadowDebug{X}=mix(vec3(nextShadow)*vCascadeColorsMultiplier{X}[index{X}],shadowDebug{X},diffRatio);
  70485. #endif
  70486. }
  70487. #endif
  70488. }
  70489. #elif defined(SHADOWCLOSEESM{X})
  70490. #if defined(SHADOWCUBE{X})
  70491. shadow=computeShadowWithCloseESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);
  70492. #else
  70493. shadow=computeShadowWithCloseESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);
  70494. #endif
  70495. #elif defined(SHADOWESM{X})
  70496. #if defined(SHADOWCUBE{X})
  70497. shadow=computeShadowWithESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);
  70498. #else
  70499. shadow=computeShadowWithESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);
  70500. #endif
  70501. #elif defined(SHADOWPOISSON{X})
  70502. #if defined(SHADOWCUBE{X})
  70503. shadow=computeShadowWithPoissonSamplingCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.depthValues);
  70504. #else
  70505. shadow=computeShadowWithPoissonSampling(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
  70506. #endif
  70507. #elif defined(SHADOWPCF{X})
  70508. #if defined(SHADOWLOWQUALITY{X})
  70509. shadow=computeShadowWithPCF1(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
  70510. #elif defined(SHADOWMEDIUMQUALITY{X})
  70511. shadow=computeShadowWithPCF3(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
  70512. #else
  70513. shadow=computeShadowWithPCF5(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
  70514. #endif
  70515. #elif defined(SHADOWPCSS{X})
  70516. #if defined(SHADOWLOWQUALITY{X})
  70517. shadow=computeShadowWithPCSS16(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
  70518. #elif defined(SHADOWMEDIUMQUALITY{X})
  70519. shadow=computeShadowWithPCSS32(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
  70520. #else
  70521. shadow=computeShadowWithPCSS64(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
  70522. #endif
  70523. #else
  70524. #if defined(SHADOWCUBE{X})
  70525. shadow=computeShadowCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.depthValues);
  70526. #else
  70527. shadow=computeShadow(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
  70528. #endif
  70529. #endif
  70530. #ifdef SHADOWONLY
  70531. #ifndef SHADOWINUSE
  70532. #define SHADOWINUSE
  70533. #endif
  70534. globalShadow+=shadow;
  70535. shadowLightCount+=1.0;
  70536. #endif
  70537. #else
  70538. shadow=1.;
  70539. #endif
  70540. #ifndef SHADOWONLY
  70541. #ifdef CUSTOMUSERLIGHTING
  70542. diffuseBase+=computeCustomDiffuseLighting(info,diffuseBase,shadow);
  70543. #ifdef SPECULARTERM
  70544. specularBase+=computeCustomSpecularLighting(info,specularBase,shadow);
  70545. #endif
  70546. #elif defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X})
  70547. diffuseBase+=lightmapColor.rgb*shadow;
  70548. #ifdef SPECULARTERM
  70549. #ifndef LIGHTMAPNOSPECULAR{X}
  70550. specularBase+=info.specular*shadow*lightmapColor.rgb;
  70551. #endif
  70552. #endif
  70553. #ifdef CLEARCOAT
  70554. #ifndef LIGHTMAPNOSPECULAR{X}
  70555. clearCoatBase+=info.clearCoat.rgb*shadow*lightmapColor.rgb;
  70556. #endif
  70557. #endif
  70558. #ifdef SHEEN
  70559. #ifndef LIGHTMAPNOSPECULAR{X}
  70560. sheenBase+=info.sheen.rgb*shadow;
  70561. #endif
  70562. #endif
  70563. #else
  70564. #ifdef SHADOWCSMDEBUG{X}
  70565. diffuseBase+=info.diffuse*shadowDebug{X};
  70566. #else
  70567. diffuseBase+=info.diffuse*shadow;
  70568. #endif
  70569. #ifdef SPECULARTERM
  70570. specularBase+=info.specular*shadow;
  70571. #endif
  70572. #ifdef CLEARCOAT
  70573. clearCoatBase+=info.clearCoat.rgb*shadow;
  70574. #endif
  70575. #ifdef SHEEN
  70576. sheenBase+=info.sheen.rgb*shadow;
  70577. #endif
  70578. #endif
  70579. #endif
  70580. #endif`;
  70581. ShaderStore.IncludesShadersStore[name$1K] = shader$1K;
  70582. var name$1J = "logDepthFragment"
  70583. , shader$1J = `#ifdef LOGARITHMICDEPTH
  70584. gl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5;
  70585. #endif`;
  70586. ShaderStore.IncludesShadersStore[name$1J] = shader$1J;
  70587. var name$1I = "fogFragment"
  70588. , shader$1I = `#ifdef FOG
  70589. float fog=CalcFogFactor();
  70590. #ifdef PBR
  70591. fog=toLinearSpace(fog);
  70592. #endif
  70593. color.rgb=mix(vFogColor,color.rgb,fog);
  70594. #endif`;
  70595. ShaderStore.IncludesShadersStore[name$1I] = shader$1I;
  70596. var name$1H = "defaultPixelShader"
  70597. , shader$1H = `#include<__decl__defaultFragment>
  70598. #if defined(BUMP) || !defined(NORMAL)
  70599. #extension GL_OES_standard_derivatives : enable
  70600. #endif
  70601. #include<prePassDeclaration>[SCENE_MRT_COUNT]
  70602. #include<oitDeclaration>
  70603. #define CUSTOM_FRAGMENT_BEGIN
  70604. #ifdef LOGARITHMICDEPTH
  70605. #extension GL_EXT_frag_depth : enable
  70606. #endif
  70607. #define RECIPROCAL_PI2 0.15915494
  70608. varying vec3 vPositionW;
  70609. #ifdef NORMAL
  70610. varying vec3 vNormalW;
  70611. #endif
  70612. #ifdef VERTEXCOLOR
  70613. varying vec4 vColor;
  70614. #endif
  70615. #include<mainUVVaryingDeclaration>[1..7]
  70616. #include<helperFunctions>
  70617. #include<__decl__lightFragment>[0..maxSimultaneousLights]
  70618. #include<lightsFragmentFunctions>
  70619. #include<shadowsFragmentFunctions>
  70620. #include<samplerFragmentDeclaration>(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse,_SAMPLERNAME_,diffuse)
  70621. #include<samplerFragmentDeclaration>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_SAMPLERNAME_,ambient)
  70622. #include<samplerFragmentDeclaration>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_SAMPLERNAME_,opacity)
  70623. #include<samplerFragmentDeclaration>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_SAMPLERNAME_,emissive)
  70624. #include<samplerFragmentDeclaration>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_SAMPLERNAME_,lightmap)
  70625. #ifdef REFRACTION
  70626. #ifdef REFRACTIONMAP_3D
  70627. uniform samplerCube refractionCubeSampler;
  70628. #else
  70629. uniform sampler2D refraction2DSampler;
  70630. #endif
  70631. #endif
  70632. #if defined(SPECULARTERM)
  70633. #include<samplerFragmentDeclaration>(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular,_SAMPLERNAME_,specular)
  70634. #endif
  70635. #include<fresnelFunction>
  70636. #ifdef REFLECTION
  70637. #ifdef REFLECTIONMAP_3D
  70638. uniform samplerCube reflectionCubeSampler;
  70639. #else
  70640. uniform sampler2D reflection2DSampler;
  70641. #endif
  70642. #ifdef REFLECTIONMAP_SKYBOX
  70643. varying vec3 vPositionUVW;
  70644. #else
  70645. #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
  70646. varying vec3 vDirectionW;
  70647. #endif
  70648. #endif
  70649. #include<reflectionFunction>
  70650. #endif
  70651. #include<imageProcessingDeclaration>
  70652. #include<imageProcessingFunctions>
  70653. #include<bumpFragmentMainFunctions>
  70654. #include<bumpFragmentFunctions>
  70655. #include<clipPlaneFragmentDeclaration>
  70656. #include<logDepthDeclaration>
  70657. #include<fogFragmentDeclaration>
  70658. #define CUSTOM_FRAGMENT_DEFINITIONS
  70659. void main(void) {
  70660. #define CUSTOM_FRAGMENT_MAIN_BEGIN
  70661. #include<oitFragment>
  70662. #include<clipPlaneFragment>
  70663. vec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);
  70664. vec4 baseColor=vec4(1.,1.,1.,1.);
  70665. vec3 diffuseColor=vDiffuseColor.rgb;
  70666. float alpha=vDiffuseColor.a;
  70667. #ifdef NORMAL
  70668. vec3 normalW=normalize(vNormalW);
  70669. #else
  70670. vec3 normalW=normalize(-cross(dFdx(vPositionW),dFdy(vPositionW)));
  70671. #endif
  70672. #include<bumpFragment>
  70673. #ifdef TWOSIDEDLIGHTING
  70674. normalW=gl_FrontFacing ? normalW : -normalW;
  70675. #endif
  70676. #ifdef DIFFUSE
  70677. baseColor=texture2D(diffuseSampler,vDiffuseUV+uvOffset);
  70678. #if defined(ALPHATEST) && !defined(ALPHATEST_AFTERALLALPHACOMPUTATIONS)
  70679. if (baseColor.a<alphaCutOff)
  70680. discard;
  70681. #endif
  70682. #ifdef ALPHAFROMDIFFUSE
  70683. alpha*=baseColor.a;
  70684. #endif
  70685. #define CUSTOM_FRAGMENT_UPDATE_ALPHA
  70686. baseColor.rgb*=vDiffuseInfos.y;
  70687. #endif
  70688. #include<depthPrePass>
  70689. #ifdef VERTEXCOLOR
  70690. baseColor.rgb*=vColor.rgb;
  70691. #endif
  70692. #ifdef DETAIL
  70693. baseColor.rgb=baseColor.rgb*2.0*mix(0.5,detailColor.r,vDetailInfos.y);
  70694. #endif
  70695. #define CUSTOM_FRAGMENT_UPDATE_DIFFUSE
  70696. vec3 baseAmbientColor=vec3(1.,1.,1.);
  70697. #ifdef AMBIENT
  70698. baseAmbientColor=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;
  70699. #endif
  70700. #define CUSTOM_FRAGMENT_BEFORE_LIGHTS
  70701. #ifdef SPECULARTERM
  70702. float glossiness=vSpecularColor.a;
  70703. vec3 specularColor=vSpecularColor.rgb;
  70704. #ifdef SPECULAR
  70705. vec4 specularMapColor=texture2D(specularSampler,vSpecularUV+uvOffset);
  70706. specularColor=specularMapColor.rgb;
  70707. #ifdef GLOSSINESS
  70708. glossiness=glossiness*specularMapColor.a;
  70709. #endif
  70710. #endif
  70711. #else
  70712. float glossiness=0.;
  70713. #endif
  70714. vec3 diffuseBase=vec3(0.,0.,0.);
  70715. lightingInfo info;
  70716. #ifdef SPECULARTERM
  70717. vec3 specularBase=vec3(0.,0.,0.);
  70718. #endif
  70719. float shadow=1.;
  70720. #ifdef LIGHTMAP
  70721. vec4 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset);
  70722. #ifdef RGBDLIGHTMAP
  70723. lightmapColor.rgb=fromRGBD(lightmapColor);
  70724. #endif
  70725. lightmapColor.rgb*=vLightmapInfos.y;
  70726. #endif
  70727. #include<lightFragment>[0..maxSimultaneousLights]
  70728. vec4 refractionColor=vec4(0.,0.,0.,1.);
  70729. #ifdef REFRACTION
  70730. vec3 refractionVector=normalize(refract(-viewDirectionW,normalW,vRefractionInfos.y));
  70731. #ifdef REFRACTIONMAP_3D
  70732. #ifdef USE_LOCAL_REFRACTIONMAP_CUBIC
  70733. refractionVector=parallaxCorrectNormal(vPositionW,refractionVector,vRefractionSize,vRefractionPosition);
  70734. #endif
  70735. refractionVector.y=refractionVector.y*vRefractionInfos.w;
  70736. if (dot(refractionVector,viewDirectionW)<1.0) {
  70737. refractionColor=textureCube(refractionCubeSampler,refractionVector);
  70738. }
  70739. #else
  70740. vec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));
  70741. vec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;
  70742. refractionCoords.y=1.0-refractionCoords.y;
  70743. refractionColor=texture2D(refraction2DSampler,refractionCoords);
  70744. #endif
  70745. #ifdef RGBDREFRACTION
  70746. refractionColor.rgb=fromRGBD(refractionColor);
  70747. #endif
  70748. #ifdef IS_REFRACTION_LINEAR
  70749. refractionColor.rgb=toGammaSpace(refractionColor.rgb);
  70750. #endif
  70751. refractionColor.rgb*=vRefractionInfos.x;
  70752. #endif
  70753. vec4 reflectionColor=vec4(0.,0.,0.,1.);
  70754. #ifdef REFLECTION
  70755. vec3 vReflectionUVW=computeReflectionCoords(vec4(vPositionW,1.0),normalW);
  70756. #ifdef REFLECTIONMAP_OPPOSITEZ
  70757. vReflectionUVW.z*=-1.0;
  70758. #endif
  70759. #ifdef REFLECTIONMAP_3D
  70760. #ifdef ROUGHNESS
  70761. float bias=vReflectionInfos.y;
  70762. #ifdef SPECULARTERM
  70763. #ifdef SPECULAR
  70764. #ifdef GLOSSINESS
  70765. bias*=(1.0-specularMapColor.a);
  70766. #endif
  70767. #endif
  70768. #endif
  70769. reflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW,bias);
  70770. #else
  70771. reflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW);
  70772. #endif
  70773. #else
  70774. vec2 coords=vReflectionUVW.xy;
  70775. #ifdef REFLECTIONMAP_PROJECTION
  70776. coords/=vReflectionUVW.z;
  70777. #endif
  70778. coords.y=1.0-coords.y;
  70779. reflectionColor=texture2D(reflection2DSampler,coords);
  70780. #endif
  70781. #ifdef RGBDREFLECTION
  70782. reflectionColor.rgb=fromRGBD(reflectionColor);
  70783. #endif
  70784. #ifdef IS_REFLECTION_LINEAR
  70785. reflectionColor.rgb=toGammaSpace(reflectionColor.rgb);
  70786. #endif
  70787. reflectionColor.rgb*=vReflectionInfos.x;
  70788. #ifdef REFLECTIONFRESNEL
  70789. float reflectionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,reflectionRightColor.a,reflectionLeftColor.a);
  70790. #ifdef REFLECTIONFRESNELFROMSPECULAR
  70791. #ifdef SPECULARTERM
  70792. reflectionColor.rgb*=specularColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;
  70793. #else
  70794. reflectionColor.rgb*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;
  70795. #endif
  70796. #else
  70797. reflectionColor.rgb*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;
  70798. #endif
  70799. #endif
  70800. #endif
  70801. #ifdef REFRACTIONFRESNEL
  70802. float refractionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,refractionRightColor.a,refractionLeftColor.a);
  70803. refractionColor.rgb*=refractionLeftColor.rgb*(1.0-refractionFresnelTerm)+refractionFresnelTerm*refractionRightColor.rgb;
  70804. #endif
  70805. #ifdef OPACITY
  70806. vec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);
  70807. #ifdef OPACITYRGB
  70808. opacityMap.rgb=opacityMap.rgb*vec3(0.3,0.59,0.11);
  70809. alpha*=(opacityMap.x+opacityMap.y+opacityMap.z)* vOpacityInfos.y;
  70810. #else
  70811. alpha*=opacityMap.a*vOpacityInfos.y;
  70812. #endif
  70813. #endif
  70814. #ifdef VERTEXALPHA
  70815. alpha*=vColor.a;
  70816. #endif
  70817. #ifdef OPACITYFRESNEL
  70818. float opacityFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,opacityParts.z,opacityParts.w);
  70819. alpha+=opacityParts.x*(1.0-opacityFresnelTerm)+opacityFresnelTerm*opacityParts.y;
  70820. #endif
  70821. #ifdef ALPHATEST
  70822. #ifdef ALPHATEST_AFTERALLALPHACOMPUTATIONS
  70823. if (alpha<alphaCutOff)
  70824. discard;
  70825. #endif
  70826. #ifndef ALPHABLEND
  70827. alpha=1.0;
  70828. #endif
  70829. #endif
  70830. vec3 emissiveColor=vEmissiveColor;
  70831. #ifdef EMISSIVE
  70832. emissiveColor+=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb*vEmissiveInfos.y;
  70833. #endif
  70834. #ifdef EMISSIVEFRESNEL
  70835. float emissiveFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,emissiveRightColor.a,emissiveLeftColor.a);
  70836. emissiveColor*=emissiveLeftColor.rgb*(1.0-emissiveFresnelTerm)+emissiveFresnelTerm*emissiveRightColor.rgb;
  70837. #endif
  70838. #ifdef DIFFUSEFRESNEL
  70839. float diffuseFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,diffuseRightColor.a,diffuseLeftColor.a);
  70840. diffuseBase*=diffuseLeftColor.rgb*(1.0-diffuseFresnelTerm)+diffuseFresnelTerm*diffuseRightColor.rgb;
  70841. #endif
  70842. #ifdef EMISSIVEASILLUMINATION
  70843. vec3 finalDiffuse=clamp(diffuseBase*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;
  70844. #else
  70845. #ifdef LINKEMISSIVEWITHDIFFUSE
  70846. vec3 finalDiffuse=clamp((diffuseBase+emissiveColor)*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;
  70847. #else
  70848. vec3 finalDiffuse=clamp(diffuseBase*diffuseColor+emissiveColor+vAmbientColor,0.0,1.0)*baseColor.rgb;
  70849. #endif
  70850. #endif
  70851. #ifdef SPECULARTERM
  70852. vec3 finalSpecular=specularBase*specularColor;
  70853. #ifdef SPECULAROVERALPHA
  70854. alpha=clamp(alpha+dot(finalSpecular,vec3(0.3,0.59,0.11)),0.,1.);
  70855. #endif
  70856. #else
  70857. vec3 finalSpecular=vec3(0.0);
  70858. #endif
  70859. #ifdef REFLECTIONOVERALPHA
  70860. alpha=clamp(alpha+dot(reflectionColor.rgb,vec3(0.3,0.59,0.11)),0.,1.);
  70861. #endif
  70862. #ifdef EMISSIVEASILLUMINATION
  70863. vec4 color=vec4(clamp(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor.rgb+emissiveColor+refractionColor.rgb,0.0,1.0),alpha);
  70864. #else
  70865. vec4 color=vec4(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor.rgb+refractionColor.rgb,alpha);
  70866. #endif
  70867. #ifdef LIGHTMAP
  70868. #ifndef LIGHTMAPEXCLUDED
  70869. #ifdef USELIGHTMAPASSHADOWMAP
  70870. color.rgb*=lightmapColor.rgb;
  70871. #else
  70872. color.rgb+=lightmapColor.rgb;
  70873. #endif
  70874. #endif
  70875. #endif
  70876. #define CUSTOM_FRAGMENT_BEFORE_FOG
  70877. color.rgb=max(color.rgb,0.);
  70878. #include<logDepthFragment>
  70879. #include<fogFragment>
  70880. #ifdef IMAGEPROCESSINGPOSTPROCESS
  70881. color.rgb=toLinearSpace(color.rgb);
  70882. #else
  70883. #ifdef IMAGEPROCESSING
  70884. color.rgb=toLinearSpace(color.rgb);
  70885. color=applyImageProcessing(color);
  70886. #endif
  70887. #endif
  70888. color.a*=visibility;
  70889. #ifdef PREMULTIPLYALPHA
  70890. color.rgb*=color.a;
  70891. #endif
  70892. #define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR
  70893. #ifdef PREPASS
  70894. float writeGeometryInfo=color.a>0.4 ? 1.0 : 0.0;
  70895. gl_FragData[0]=color;
  70896. #ifdef PREPASS_POSITION
  70897. gl_FragData[PREPASS_POSITION_INDEX]=vec4(vPositionW,writeGeometryInfo);
  70898. #endif
  70899. #ifdef PREPASS_VELOCITY
  70900. vec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;
  70901. vec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;
  70902. vec2 velocity=abs(a-b);
  70903. velocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;
  70904. gl_FragData[PREPASS_VELOCITY_INDEX]=vec4(velocity,0.0,writeGeometryInfo);
  70905. #endif
  70906. #ifdef PREPASS_IRRADIANCE
  70907. gl_FragData[PREPASS_IRRADIANCE_INDEX]=vec4(0.0,0.0,0.0,writeGeometryInfo);
  70908. #endif
  70909. #ifdef PREPASS_DEPTH
  70910. gl_FragData[PREPASS_DEPTH_INDEX]=vec4(vViewPos.z,0.0,0.0,writeGeometryInfo);
  70911. #endif
  70912. #ifdef PREPASS_NORMAL
  70913. gl_FragData[PREPASS_NORMAL_INDEX]=vec4((view*vec4(normalW,0.0)).rgb,writeGeometryInfo);
  70914. #endif
  70915. #ifdef PREPASS_ALBEDO_SQRT
  70916. gl_FragData[PREPASS_ALBEDO_SQRT_INDEX]=vec4(0.0,0.0,0.0,writeGeometryInfo);
  70917. #endif
  70918. #ifdef PREPASS_REFLECTIVITY
  70919. #if defined(SPECULAR)
  70920. gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(specularMapColor.rgb,specularMapColor.a*writeGeometryInfo);
  70921. #else
  70922. gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(0.0,0.0,0.0,writeGeometryInfo);
  70923. #endif
  70924. #endif
  70925. #endif
  70926. #if !defined(PREPASS) || defined(WEBGL2)
  70927. gl_FragColor=color;
  70928. #endif
  70929. #if ORDER_INDEPENDENT_TRANSPARENCY
  70930. if (fragDepth == nearestDepth) {
  70931. frontColor.rgb+=color.rgb*color.a*alphaMultiplier;
  70932. frontColor.a=1.0-alphaMultiplier*(1.0-color.a);
  70933. } else {
  70934. backColor+=color;
  70935. }
  70936. #endif
  70937. }
  70938. `;
  70939. ShaderStore.ShadersStore[name$1H] = shader$1H;
  70940. var name$1G = "defaultVertexDeclaration"
  70941. , shader$1G = `
  70942. uniform mat4 viewProjection;
  70943. uniform mat4 view;
  70944. #ifdef DIFFUSE
  70945. uniform mat4 diffuseMatrix;
  70946. uniform vec2 vDiffuseInfos;
  70947. #endif
  70948. #ifdef AMBIENT
  70949. uniform mat4 ambientMatrix;
  70950. uniform vec2 vAmbientInfos;
  70951. #endif
  70952. #ifdef OPACITY
  70953. uniform mat4 opacityMatrix;
  70954. uniform vec2 vOpacityInfos;
  70955. #endif
  70956. #ifdef EMISSIVE
  70957. uniform vec2 vEmissiveInfos;
  70958. uniform mat4 emissiveMatrix;
  70959. #endif
  70960. #ifdef LIGHTMAP
  70961. uniform vec2 vLightmapInfos;
  70962. uniform mat4 lightmapMatrix;
  70963. #endif
  70964. #if defined(SPECULAR) && defined(SPECULARTERM)
  70965. uniform vec2 vSpecularInfos;
  70966. uniform mat4 specularMatrix;
  70967. #endif
  70968. #ifdef BUMP
  70969. uniform vec3 vBumpInfos;
  70970. uniform mat4 bumpMatrix;
  70971. #endif
  70972. #ifdef REFLECTION
  70973. uniform mat4 reflectionMatrix;
  70974. #endif
  70975. #ifdef POINTSIZE
  70976. uniform float pointSize;
  70977. #endif
  70978. #ifdef DETAIL
  70979. uniform vec4 vDetailInfos;
  70980. uniform mat4 detailMatrix;
  70981. #endif`;
  70982. ShaderStore.IncludesShadersStore[name$1G] = shader$1G;
  70983. var name$1F = "uvAttributeDeclaration"
  70984. , shader$1F = `#ifdef UV{X}
  70985. attribute vec2 uv{X};
  70986. #endif
  70987. `;
  70988. ShaderStore.IncludesShadersStore[name$1F] = shader$1F;
  70989. var name$1E = "instancesDeclaration"
  70990. , shader$1E = `#ifdef INSTANCES
  70991. attribute vec4 world0;
  70992. attribute vec4 world1;
  70993. attribute vec4 world2;
  70994. attribute vec4 world3;
  70995. #if defined(THIN_INSTANCES) && !defined(WORLD_UBO)
  70996. uniform mat4 world;
  70997. #endif
  70998. #if defined(VELOCITY) || defined(PREPASS_VELOCITY)
  70999. attribute vec4 previousWorld0;
  71000. attribute vec4 previousWorld1;
  71001. attribute vec4 previousWorld2;
  71002. attribute vec4 previousWorld3;
  71003. #ifdef THIN_INSTANCES
  71004. uniform mat4 previousWorld;
  71005. #endif
  71006. #endif
  71007. #else
  71008. #if !defined(WORLD_UBO)
  71009. uniform mat4 world;
  71010. #endif
  71011. #if defined(VELOCITY) || defined(PREPASS_VELOCITY)
  71012. uniform mat4 previousWorld;
  71013. #endif
  71014. #endif`;
  71015. ShaderStore.IncludesShadersStore[name$1E] = shader$1E;
  71016. var name$1D = "prePassVertexDeclaration"
  71017. , shader$1D = `#ifdef PREPASS
  71018. #ifdef PREPASS_DEPTH
  71019. varying vec3 vViewPos;
  71020. #endif
  71021. #ifdef PREPASS_VELOCITY
  71022. uniform mat4 previousViewProjection;
  71023. varying vec4 vCurrentPosition;
  71024. varying vec4 vPreviousPosition;
  71025. #endif
  71026. #endif`;
  71027. ShaderStore.IncludesShadersStore[name$1D] = shader$1D;
  71028. var name$1C = "samplerVertexDeclaration"
  71029. , shader$1C = `#if defined(_DEFINENAME_) && _DEFINENAME_DIRECTUV == 0
  71030. varying vec2 v_VARYINGNAME_UV;
  71031. #endif
  71032. `;
  71033. ShaderStore.IncludesShadersStore[name$1C] = shader$1C;
  71034. var name$1B = "bumpVertexDeclaration"
  71035. , shader$1B = `#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)
  71036. #if defined(TANGENT) && defined(NORMAL)
  71037. varying mat3 vTBN;
  71038. #endif
  71039. #endif
  71040. `;
  71041. ShaderStore.IncludesShadersStore[name$1B] = shader$1B;
  71042. var name$1A = "fogVertexDeclaration"
  71043. , shader$1A = `#ifdef FOG
  71044. varying vec3 vFogDistance;
  71045. #endif`;
  71046. ShaderStore.IncludesShadersStore[name$1A] = shader$1A;
  71047. var name$1z = "lightVxFragmentDeclaration"
  71048. , shader$1z = `#ifdef LIGHT{X}
  71049. uniform vec4 vLightData{X};
  71050. uniform vec4 vLightDiffuse{X};
  71051. #ifdef SPECULARTERM
  71052. uniform vec4 vLightSpecular{X};
  71053. #else
  71054. vec4 vLightSpecular{X}=vec4(0.);
  71055. #endif
  71056. #ifdef SHADOW{X}
  71057. #ifdef SHADOWCSM{X}
  71058. uniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];
  71059. varying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];
  71060. varying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];
  71061. varying vec4 vPositionFromCamera{X};
  71062. #elif defined(SHADOWCUBE{X})
  71063. #else
  71064. varying vec4 vPositionFromLight{X};
  71065. varying float vDepthMetric{X};
  71066. uniform mat4 lightMatrix{X};
  71067. #endif
  71068. uniform vec4 shadowsInfo{X};
  71069. uniform vec2 depthValues{X};
  71070. #endif
  71071. #ifdef SPOTLIGHT{X}
  71072. uniform vec4 vLightDirection{X};
  71073. uniform vec4 vLightFalloff{X};
  71074. #elif defined(POINTLIGHT{X})
  71075. uniform vec4 vLightFalloff{X};
  71076. #elif defined(HEMILIGHT{X})
  71077. uniform vec3 vLightGround{X};
  71078. #endif
  71079. #endif`;
  71080. ShaderStore.IncludesShadersStore[name$1z] = shader$1z;
  71081. var name$1y = "lightVxUboDeclaration"
  71082. , shader$1y = `#ifdef LIGHT{X}
  71083. uniform Light{X}
  71084. {
  71085. vec4 vLightData;
  71086. vec4 vLightDiffuse;
  71087. vec4 vLightSpecular;
  71088. #ifdef SPOTLIGHT{X}
  71089. vec4 vLightDirection;
  71090. vec4 vLightFalloff;
  71091. #elif defined(POINTLIGHT{X})
  71092. vec4 vLightFalloff;
  71093. #elif defined(HEMILIGHT{X})
  71094. vec3 vLightGround;
  71095. #endif
  71096. vec4 shadowsInfo;
  71097. vec2 depthValues;
  71098. } light{X};
  71099. #ifdef SHADOW{X}
  71100. #ifdef SHADOWCSM{X}
  71101. uniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];
  71102. varying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];
  71103. varying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];
  71104. varying vec4 vPositionFromCamera{X};
  71105. #elif defined(SHADOWCUBE{X})
  71106. #else
  71107. varying vec4 vPositionFromLight{X};
  71108. varying float vDepthMetric{X};
  71109. uniform mat4 lightMatrix{X};
  71110. #endif
  71111. #endif
  71112. #endif`;
  71113. ShaderStore.IncludesShadersStore[name$1y] = shader$1y;
  71114. var name$1x = "prePassVertex"
  71115. , shader$1x = `#ifdef PREPASS_DEPTH
  71116. vViewPos=(view*worldPos).rgb;
  71117. #endif
  71118. #if defined(PREPASS_VELOCITY) && defined(BONES_VELOCITY_ENABLED)
  71119. vCurrentPosition=viewProjection*worldPos;
  71120. #if NUM_BONE_INFLUENCERS>0
  71121. mat4 previousInfluence;
  71122. previousInfluence=mPreviousBones[int(matricesIndices[0])]*matricesWeights[0];
  71123. #if NUM_BONE_INFLUENCERS>1
  71124. previousInfluence+=mPreviousBones[int(matricesIndices[1])]*matricesWeights[1];
  71125. #endif
  71126. #if NUM_BONE_INFLUENCERS>2
  71127. previousInfluence+=mPreviousBones[int(matricesIndices[2])]*matricesWeights[2];
  71128. #endif
  71129. #if NUM_BONE_INFLUENCERS>3
  71130. previousInfluence+=mPreviousBones[int(matricesIndices[3])]*matricesWeights[3];
  71131. #endif
  71132. #if NUM_BONE_INFLUENCERS>4
  71133. previousInfluence+=mPreviousBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];
  71134. #endif
  71135. #if NUM_BONE_INFLUENCERS>5
  71136. previousInfluence+=mPreviousBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];
  71137. #endif
  71138. #if NUM_BONE_INFLUENCERS>6
  71139. previousInfluence+=mPreviousBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];
  71140. #endif
  71141. #if NUM_BONE_INFLUENCERS>7
  71142. previousInfluence+=mPreviousBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];
  71143. #endif
  71144. vPreviousPosition=previousViewProjection*previousWorld*previousInfluence*vec4(positionUpdated,1.0);
  71145. #else
  71146. vPreviousPosition=previousViewProjection*previousWorld*vec4(positionUpdated,1.0);
  71147. #endif
  71148. #endif`;
  71149. ShaderStore.IncludesShadersStore[name$1x] = shader$1x;
  71150. var name$1w = "uvVariableDeclaration"
  71151. , shader$1w = `#if !defined(UV{X}) && defined(MAINUV{X})
  71152. vec2 uv{X}=vec2(0.,0.);
  71153. #endif
  71154. #ifdef MAINUV{X}
  71155. vMainUV{X}=uv{X};
  71156. #endif
  71157. `;
  71158. ShaderStore.IncludesShadersStore[name$1w] = shader$1w;
  71159. var name$1v = "samplerVertexImplementation"
  71160. , shader$1v = `#if defined(_DEFINENAME_) && _DEFINENAME_DIRECTUV == 0
  71161. if (v_INFONAME_ == 0.)
  71162. {
  71163. v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uvUpdated,1.0,0.0));
  71164. }
  71165. #ifdef UV2
  71166. else if (v_INFONAME_ == 1.)
  71167. {
  71168. v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv2,1.0,0.0));
  71169. }
  71170. #endif
  71171. #ifdef UV3
  71172. else if (v_INFONAME_ == 2.)
  71173. {
  71174. v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv3,1.0,0.0));
  71175. }
  71176. #endif
  71177. #ifdef UV4
  71178. else if (v_INFONAME_ == 3.)
  71179. {
  71180. v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv4,1.0,0.0));
  71181. }
  71182. #endif
  71183. #ifdef UV5
  71184. else if (v_INFONAME_ == 4.)
  71185. {
  71186. v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv5,1.0,0.0));
  71187. }
  71188. #endif
  71189. #ifdef UV6
  71190. else if (v_INFONAME_ == 5.)
  71191. {
  71192. v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv6,1.0,0.0));
  71193. }
  71194. #endif
  71195. #endif
  71196. `;
  71197. ShaderStore.IncludesShadersStore[name$1v] = shader$1v;
  71198. var name$1u = "bumpVertex"
  71199. , shader$1u = `#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)
  71200. #if defined(TANGENT) && defined(NORMAL)
  71201. vec3 tbnNormal=normalize(normalUpdated);
  71202. vec3 tbnTangent=normalize(tangentUpdated.xyz);
  71203. vec3 tbnBitangent=cross(tbnNormal,tbnTangent)*tangentUpdated.w;
  71204. vTBN=mat3(finalWorld)*mat3(tbnTangent,tbnBitangent,tbnNormal);
  71205. #endif
  71206. #endif`;
  71207. ShaderStore.IncludesShadersStore[name$1u] = shader$1u;
  71208. var name$1t = "fogVertex"
  71209. , shader$1t = `#ifdef FOG
  71210. vFogDistance=(view*worldPos).xyz;
  71211. #endif`;
  71212. ShaderStore.IncludesShadersStore[name$1t] = shader$1t;
  71213. var name$1s = "shadowsVertex"
  71214. , shader$1s = `#ifdef SHADOWS
  71215. #if defined(SHADOWCSM{X})
  71216. vPositionFromCamera{X}=view*worldPos;
  71217. for (int i=0; i<SHADOWCSMNUM_CASCADES{X}; i++) {
  71218. vPositionFromLight{X}[i]=lightMatrix{X}[i]*worldPos;
  71219. #ifdef USE_REVERSE_DEPTHBUFFER
  71220. vDepthMetric{X}[i]=(-vPositionFromLight{X}[i].z+light{X}.depthValues.x)/light{X}.depthValues.y;
  71221. #else
  71222. vDepthMetric{X}[i]=(vPositionFromLight{X}[i].z+light{X}.depthValues.x)/light{X}.depthValues.y;
  71223. #endif
  71224. }
  71225. #elif defined(SHADOW{X}) && !defined(SHADOWCUBE{X})
  71226. vPositionFromLight{X}=lightMatrix{X}*worldPos;
  71227. #ifdef USE_REVERSE_DEPTHBUFFER
  71228. vDepthMetric{X}=(-vPositionFromLight{X}.z+light{X}.depthValues.x)/light{X}.depthValues.y;
  71229. #else
  71230. vDepthMetric{X}=(vPositionFromLight{X}.z+light{X}.depthValues.x)/light{X}.depthValues.y;
  71231. #endif
  71232. #endif
  71233. #endif`;
  71234. ShaderStore.IncludesShadersStore[name$1s] = shader$1s;
  71235. var name$1r = "pointCloudVertex"
  71236. , shader$1r = `#ifdef POINTSIZE
  71237. gl_PointSize=pointSize;
  71238. #endif`;
  71239. ShaderStore.IncludesShadersStore[name$1r] = shader$1r;
  71240. var name$1q = "logDepthVertex"
  71241. , shader$1q = `#ifdef LOGARITHMICDEPTH
  71242. vFragmentDepth=1.0+gl_Position.w;
  71243. gl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant;
  71244. #endif`;
  71245. ShaderStore.IncludesShadersStore[name$1q] = shader$1q;
  71246. var name$1p = "defaultVertexShader"
  71247. , shader$1p = `#include<__decl__defaultVertex>
  71248. #define CUSTOM_VERTEX_BEGIN
  71249. attribute vec3 position;
  71250. #ifdef NORMAL
  71251. attribute vec3 normal;
  71252. #endif
  71253. #ifdef TANGENT
  71254. attribute vec4 tangent;
  71255. #endif
  71256. #ifdef UV1
  71257. attribute vec2 uv;
  71258. #endif
  71259. #include<uvAttributeDeclaration>[2..7]
  71260. #ifdef VERTEXCOLOR
  71261. attribute vec4 color;
  71262. #endif
  71263. #include<helperFunctions>
  71264. #include<bonesDeclaration>
  71265. #include<bakedVertexAnimationDeclaration>
  71266. #include<instancesDeclaration>
  71267. #include<prePassVertexDeclaration>
  71268. #include<mainUVVaryingDeclaration>[1..7]
  71269. #include<samplerVertexDeclaration>(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse)
  71270. #include<samplerVertexDeclaration>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail)
  71271. #include<samplerVertexDeclaration>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient)
  71272. #include<samplerVertexDeclaration>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity)
  71273. #include<samplerVertexDeclaration>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive)
  71274. #include<samplerVertexDeclaration>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap)
  71275. #if defined(SPECULARTERM)
  71276. #include<samplerVertexDeclaration>(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular)
  71277. #endif
  71278. #include<samplerVertexDeclaration>(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump)
  71279. varying vec3 vPositionW;
  71280. #ifdef NORMAL
  71281. varying vec3 vNormalW;
  71282. #endif
  71283. #ifdef VERTEXCOLOR
  71284. varying vec4 vColor;
  71285. #endif
  71286. #include<bumpVertexDeclaration>
  71287. #include<clipPlaneVertexDeclaration>
  71288. #include<fogVertexDeclaration>
  71289. #include<__decl__lightVxFragment>[0..maxSimultaneousLights]
  71290. #include<morphTargetsVertexGlobalDeclaration>
  71291. #include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
  71292. #ifdef REFLECTIONMAP_SKYBOX
  71293. varying vec3 vPositionUVW;
  71294. #endif
  71295. #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
  71296. varying vec3 vDirectionW;
  71297. #endif
  71298. #include<logDepthDeclaration>
  71299. #define CUSTOM_VERTEX_DEFINITIONS
  71300. void main(void) {
  71301. #define CUSTOM_VERTEX_MAIN_BEGIN
  71302. vec3 positionUpdated=position;
  71303. #ifdef NORMAL
  71304. vec3 normalUpdated=normal;
  71305. #endif
  71306. #ifdef TANGENT
  71307. vec4 tangentUpdated=tangent;
  71308. #endif
  71309. #ifdef UV1
  71310. vec2 uvUpdated=uv;
  71311. #endif
  71312. #include<morphTargetsVertexGlobal>
  71313. #include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
  71314. #ifdef REFLECTIONMAP_SKYBOX
  71315. vPositionUVW=positionUpdated;
  71316. #endif
  71317. #define CUSTOM_VERTEX_UPDATE_POSITION
  71318. #define CUSTOM_VERTEX_UPDATE_NORMAL
  71319. #include<instancesVertex>
  71320. #if defined(PREPASS) && defined(PREPASS_VELOCITY) && !defined(BONES_VELOCITY_ENABLED)
  71321. vCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);
  71322. vPreviousPosition=previousViewProjection*finalPreviousWorld*vec4(positionUpdated,1.0);
  71323. #endif
  71324. #include<bonesVertex>
  71325. #include<bakedVertexAnimation>
  71326. vec4 worldPos=finalWorld*vec4(positionUpdated,1.0);
  71327. #ifdef NORMAL
  71328. mat3 normalWorld=mat3(finalWorld);
  71329. #if defined(INSTANCES) && defined(THIN_INSTANCES)
  71330. vNormalW=normalUpdated/vec3(dot(normalWorld[0],normalWorld[0]),dot(normalWorld[1],normalWorld[1]),dot(normalWorld[2],normalWorld[2]));
  71331. vNormalW=normalize(normalWorld*vNormalW);
  71332. #else
  71333. #ifdef NONUNIFORMSCALING
  71334. normalWorld=transposeMat3(inverseMat3(normalWorld));
  71335. #endif
  71336. vNormalW=normalize(normalWorld*normalUpdated);
  71337. #endif
  71338. #endif
  71339. #define CUSTOM_VERTEX_UPDATE_WORLDPOS
  71340. #ifdef MULTIVIEW
  71341. if (gl_ViewID_OVR == 0u) {
  71342. gl_Position=viewProjection*worldPos;
  71343. } else {
  71344. gl_Position=viewProjectionR*worldPos;
  71345. }
  71346. #else
  71347. gl_Position=viewProjection*worldPos;
  71348. #endif
  71349. vPositionW=vec3(worldPos);
  71350. #include<prePassVertex>
  71351. #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
  71352. vDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));
  71353. #endif
  71354. #ifndef UV1
  71355. vec2 uvUpdated=vec2(0.,0.);
  71356. #endif
  71357. #ifdef MAINUV1
  71358. vMainUV1=uvUpdated;
  71359. #endif
  71360. #include<uvVariableDeclaration>[2..7]
  71361. #include<samplerVertexImplementation>(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse,_MATRIXNAME_,diffuse,_INFONAME_,DiffuseInfos.x)
  71362. #include<samplerVertexImplementation>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_MATRIXNAME_,detail,_INFONAME_,DetailInfos.x)
  71363. #include<samplerVertexImplementation>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_MATRIXNAME_,ambient,_INFONAME_,AmbientInfos.x)
  71364. #include<samplerVertexImplementation>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_MATRIXNAME_,opacity,_INFONAME_,OpacityInfos.x)
  71365. #include<samplerVertexImplementation>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_MATRIXNAME_,emissive,_INFONAME_,EmissiveInfos.x)
  71366. #include<samplerVertexImplementation>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_MATRIXNAME_,lightmap,_INFONAME_,LightmapInfos.x)
  71367. #if defined(SPECULARTERM)
  71368. #include<samplerVertexImplementation>(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular,_MATRIXNAME_,specular,_INFONAME_,SpecularInfos.x)
  71369. #endif
  71370. #include<samplerVertexImplementation>(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_MATRIXNAME_,bump,_INFONAME_,BumpInfos.x)
  71371. #include<bumpVertex>
  71372. #include<clipPlaneVertex>
  71373. #include<fogVertex>
  71374. #include<shadowsVertex>[0..maxSimultaneousLights]
  71375. #ifdef VERTEXCOLOR
  71376. vColor=color;
  71377. #endif
  71378. #include<pointCloudVertex>
  71379. #include<logDepthVertex>
  71380. #define CUSTOM_VERTEX_MAIN_END
  71381. }
  71382. `;
  71383. ShaderStore.ShadersStore[name$1p] = shader$1p;
  71384. var DetailMapConfiguration = function() {
  71385. function a(e) {
  71386. this._texture = null,
  71387. this.diffuseBlendLevel = 1,
  71388. this.roughnessBlendLevel = 1,
  71389. this.bumpLevel = 1,
  71390. this._normalBlendMethod = Material.MATERIAL_NORMALBLENDMETHOD_WHITEOUT,
  71391. this._isEnabled = !1,
  71392. this.isEnabled = !1,
  71393. this._internalMarkAllSubMeshesAsTexturesDirty = e
  71394. }
  71395. return a.prototype._markAllSubMeshesAsTexturesDirty = function() {
  71396. this._internalMarkAllSubMeshesAsTexturesDirty()
  71397. }
  71398. ,
  71399. a.prototype.isReadyForSubMesh = function(e, i) {
  71400. if (!this._isEnabled)
  71401. return !0;
  71402. var o = i.getEngine();
  71403. return !(e._areTexturesDirty && i.texturesEnabled && o.getCaps().standardDerivatives && this._texture && MaterialFlags.DetailTextureEnabled && !this._texture.isReady())
  71404. }
  71405. ,
  71406. a.prototype.prepareDefines = function(e, i) {
  71407. if (this._isEnabled) {
  71408. e.DETAIL_NORMALBLENDMETHOD = this._normalBlendMethod;
  71409. var o = i.getEngine();
  71410. e._areTexturesDirty && (o.getCaps().standardDerivatives && this._texture && MaterialFlags.DetailTextureEnabled && this._isEnabled ? (MaterialHelper.PrepareDefinesForMergedUV(this._texture, e, "DETAIL"),
  71411. e.DETAIL_NORMALBLENDMETHOD = this._normalBlendMethod) : e.DETAIL = !1)
  71412. } else
  71413. e.DETAIL = !1
  71414. }
  71415. ,
  71416. a.prototype.bindForSubMesh = function(e, i, o) {
  71417. !this._isEnabled || ((!e.useUbo || !o || !e.isSync) && this._texture && MaterialFlags.DetailTextureEnabled && (e.updateFloat4("vDetailInfos", this._texture.coordinatesIndex, this.diffuseBlendLevel, this.bumpLevel, this.roughnessBlendLevel),
  71418. MaterialHelper.BindTextureMatrix(this._texture, e, "detail")),
  71419. i.texturesEnabled && this._texture && MaterialFlags.DetailTextureEnabled && e.setTexture("detailSampler", this._texture))
  71420. }
  71421. ,
  71422. a.prototype.hasTexture = function(e) {
  71423. return this._texture === e
  71424. }
  71425. ,
  71426. a.prototype.getActiveTextures = function(e) {
  71427. this._texture && e.push(this._texture)
  71428. }
  71429. ,
  71430. a.prototype.getAnimatables = function(e) {
  71431. this._texture && this._texture.animations && this._texture.animations.length > 0 && e.push(this._texture)
  71432. }
  71433. ,
  71434. a.prototype.dispose = function(e) {
  71435. var i;
  71436. e && ((i = this._texture) === null || i === void 0 || i.dispose())
  71437. }
  71438. ,
  71439. a.prototype.getClassName = function() {
  71440. return "DetailMapConfiguration"
  71441. }
  71442. ,
  71443. a.AddUniforms = function(e) {
  71444. e.push("vDetailInfos"),
  71445. e.push("detailMatrix")
  71446. }
  71447. ,
  71448. a.AddSamplers = function(e) {
  71449. e.push("detailSampler")
  71450. }
  71451. ,
  71452. a.PrepareUniformBuffer = function(e) {
  71453. e.addUniform("vDetailInfos", 4),
  71454. e.addUniform("detailMatrix", 16)
  71455. }
  71456. ,
  71457. a.prototype.copyTo = function(e) {
  71458. SerializationHelper.Clone(function() {
  71459. return e
  71460. }, this)
  71461. }
  71462. ,
  71463. a.prototype.serialize = function() {
  71464. return SerializationHelper.Serialize(this)
  71465. }
  71466. ,
  71467. a.prototype.parse = function(e, i, o) {
  71468. var s = this;
  71469. SerializationHelper.Parse(function() {
  71470. return s
  71471. }, e, i, o)
  71472. }
  71473. ,
  71474. __decorate([serializeAsTexture("detailTexture"), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "texture", void 0),
  71475. __decorate([serialize()], a.prototype, "diffuseBlendLevel", void 0),
  71476. __decorate([serialize()], a.prototype, "roughnessBlendLevel", void 0),
  71477. __decorate([serialize()], a.prototype, "bumpLevel", void 0),
  71478. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "normalBlendMethod", void 0),
  71479. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "isEnabled", void 0),
  71480. a
  71481. }()
  71482. , onCreatedEffectParameters$2 = {
  71483. effect: null,
  71484. subMesh: null
  71485. }
  71486. , StandardMaterialDefines = function(a) {
  71487. __extends(e, a);
  71488. function e() {
  71489. var i = a.call(this) || this;
  71490. return i.MAINUV1 = !1,
  71491. i.MAINUV2 = !1,
  71492. i.MAINUV3 = !1,
  71493. i.MAINUV4 = !1,
  71494. i.MAINUV5 = !1,
  71495. i.MAINUV6 = !1,
  71496. i.DIFFUSE = !1,
  71497. i.DIFFUSEDIRECTUV = 0,
  71498. i.DETAIL = !1,
  71499. i.DETAILDIRECTUV = 0,
  71500. i.DETAIL_NORMALBLENDMETHOD = 0,
  71501. i.BAKED_VERTEX_ANIMATION_TEXTURE = !1,
  71502. i.AMBIENT = !1,
  71503. i.AMBIENTDIRECTUV = 0,
  71504. i.OPACITY = !1,
  71505. i.OPACITYDIRECTUV = 0,
  71506. i.OPACITYRGB = !1,
  71507. i.REFLECTION = !1,
  71508. i.EMISSIVE = !1,
  71509. i.EMISSIVEDIRECTUV = 0,
  71510. i.SPECULAR = !1,
  71511. i.SPECULARDIRECTUV = 0,
  71512. i.BUMP = !1,
  71513. i.BUMPDIRECTUV = 0,
  71514. i.PARALLAX = !1,
  71515. i.PARALLAXOCCLUSION = !1,
  71516. i.SPECULAROVERALPHA = !1,
  71517. i.CLIPPLANE = !1,
  71518. i.CLIPPLANE2 = !1,
  71519. i.CLIPPLANE3 = !1,
  71520. i.CLIPPLANE4 = !1,
  71521. i.CLIPPLANE5 = !1,
  71522. i.CLIPPLANE6 = !1,
  71523. i.ALPHATEST = !1,
  71524. i.DEPTHPREPASS = !1,
  71525. i.ALPHAFROMDIFFUSE = !1,
  71526. i.POINTSIZE = !1,
  71527. i.FOG = !1,
  71528. i.SPECULARTERM = !1,
  71529. i.DIFFUSEFRESNEL = !1,
  71530. i.OPACITYFRESNEL = !1,
  71531. i.REFLECTIONFRESNEL = !1,
  71532. i.REFRACTIONFRESNEL = !1,
  71533. i.EMISSIVEFRESNEL = !1,
  71534. i.FRESNEL = !1,
  71535. i.NORMAL = !1,
  71536. i.TANGENT = !1,
  71537. i.UV1 = !1,
  71538. i.UV2 = !1,
  71539. i.UV3 = !1,
  71540. i.UV4 = !1,
  71541. i.UV5 = !1,
  71542. i.UV6 = !1,
  71543. i.VERTEXCOLOR = !1,
  71544. i.VERTEXALPHA = !1,
  71545. i.NUM_BONE_INFLUENCERS = 0,
  71546. i.BonesPerMesh = 0,
  71547. i.BONETEXTURE = !1,
  71548. i.BONES_VELOCITY_ENABLED = !1,
  71549. i.INSTANCES = !1,
  71550. i.THIN_INSTANCES = !1,
  71551. i.GLOSSINESS = !1,
  71552. i.ROUGHNESS = !1,
  71553. i.EMISSIVEASILLUMINATION = !1,
  71554. i.LINKEMISSIVEWITHDIFFUSE = !1,
  71555. i.REFLECTIONFRESNELFROMSPECULAR = !1,
  71556. i.LIGHTMAP = !1,
  71557. i.LIGHTMAPDIRECTUV = 0,
  71558. i.OBJECTSPACE_NORMALMAP = !1,
  71559. i.USELIGHTMAPASSHADOWMAP = !1,
  71560. i.REFLECTIONMAP_3D = !1,
  71561. i.REFLECTIONMAP_SPHERICAL = !1,
  71562. i.REFLECTIONMAP_PLANAR = !1,
  71563. i.REFLECTIONMAP_CUBIC = !1,
  71564. i.USE_LOCAL_REFLECTIONMAP_CUBIC = !1,
  71565. i.USE_LOCAL_REFRACTIONMAP_CUBIC = !1,
  71566. i.REFLECTIONMAP_PROJECTION = !1,
  71567. i.REFLECTIONMAP_SKYBOX = !1,
  71568. i.REFLECTIONMAP_EXPLICIT = !1,
  71569. i.REFLECTIONMAP_EQUIRECTANGULAR = !1,
  71570. i.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !1,
  71571. i.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !1,
  71572. i.REFLECTIONMAP_OPPOSITEZ = !1,
  71573. i.INVERTCUBICMAP = !1,
  71574. i.LOGARITHMICDEPTH = !1,
  71575. i.REFRACTION = !1,
  71576. i.REFRACTIONMAP_3D = !1,
  71577. i.REFLECTIONOVERALPHA = !1,
  71578. i.TWOSIDEDLIGHTING = !1,
  71579. i.SHADOWFLOAT = !1,
  71580. i.MORPHTARGETS = !1,
  71581. i.MORPHTARGETS_NORMAL = !1,
  71582. i.MORPHTARGETS_TANGENT = !1,
  71583. i.MORPHTARGETS_UV = !1,
  71584. i.NUM_MORPH_INFLUENCERS = 0,
  71585. i.MORPHTARGETS_TEXTURE = !1,
  71586. i.NONUNIFORMSCALING = !1,
  71587. i.PREMULTIPLYALPHA = !1,
  71588. i.ALPHATEST_AFTERALLALPHACOMPUTATIONS = !1,
  71589. i.ALPHABLEND = !0,
  71590. i.PREPASS = !1,
  71591. i.PREPASS_IRRADIANCE = !1,
  71592. i.PREPASS_IRRADIANCE_INDEX = -1,
  71593. i.PREPASS_ALBEDO_SQRT = !1,
  71594. i.PREPASS_ALBEDO_SQRT_INDEX = -1,
  71595. i.PREPASS_DEPTH = !1,
  71596. i.PREPASS_DEPTH_INDEX = -1,
  71597. i.PREPASS_NORMAL = !1,
  71598. i.PREPASS_NORMAL_INDEX = -1,
  71599. i.PREPASS_POSITION = !1,
  71600. i.PREPASS_POSITION_INDEX = -1,
  71601. i.PREPASS_VELOCITY = !1,
  71602. i.PREPASS_VELOCITY_INDEX = -1,
  71603. i.PREPASS_REFLECTIVITY = !1,
  71604. i.PREPASS_REFLECTIVITY_INDEX = -1,
  71605. i.SCENE_MRT_COUNT = 0,
  71606. i.RGBDLIGHTMAP = !1,
  71607. i.RGBDREFLECTION = !1,
  71608. i.RGBDREFRACTION = !1,
  71609. i.IMAGEPROCESSING = !1,
  71610. i.VIGNETTE = !1,
  71611. i.VIGNETTEBLENDMODEMULTIPLY = !1,
  71612. i.VIGNETTEBLENDMODEOPAQUE = !1,
  71613. i.TONEMAPPING = !1,
  71614. i.TONEMAPPING_ACES = !1,
  71615. i.CONTRAST = !1,
  71616. i.COLORCURVES = !1,
  71617. i.COLORGRADING = !1,
  71618. i.COLORGRADING3D = !1,
  71619. i.SAMPLER3DGREENDEPTH = !1,
  71620. i.SAMPLER3DBGRMAP = !1,
  71621. i.IMAGEPROCESSINGPOSTPROCESS = !1,
  71622. i.SKIPFINALCOLORCLAMP = !1,
  71623. i.MULTIVIEW = !1,
  71624. i.ORDER_INDEPENDENT_TRANSPARENCY = !1,
  71625. i.ORDER_INDEPENDENT_TRANSPARENCY_16BITS = !1,
  71626. i.IS_REFLECTION_LINEAR = !1,
  71627. i.IS_REFRACTION_LINEAR = !1,
  71628. i.EXPOSURE = !1,
  71629. i.rebuild(),
  71630. i
  71631. }
  71632. return e.prototype.setReflectionMode = function(i) {
  71633. for (var o = ["REFLECTIONMAP_CUBIC", "REFLECTIONMAP_EXPLICIT", "REFLECTIONMAP_PLANAR", "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_SKYBOX", "REFLECTIONMAP_SPHERICAL", "REFLECTIONMAP_EQUIRECTANGULAR", "REFLECTIONMAP_EQUIRECTANGULAR_FIXED", "REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"], s = 0, c = o; s < c.length; s++) {
  71634. var d = c[s];
  71635. this[d] = d === i
  71636. }
  71637. }
  71638. ,
  71639. e
  71640. }(MaterialDefines)
  71641. , StandardMaterial = function(a) {
  71642. __extends(e, a);
  71643. function e(i, o) {
  71644. var s = a.call(this, i, o) || this;
  71645. return s._diffuseTexture = null,
  71646. s._ambientTexture = null,
  71647. s._opacityTexture = null,
  71648. s._reflectionTexture = null,
  71649. s._emissiveTexture = null,
  71650. s._specularTexture = null,
  71651. s._bumpTexture = null,
  71652. s._lightmapTexture = null,
  71653. s._refractionTexture = null,
  71654. s.ambientColor = new Color3(0,0,0),
  71655. s.diffuseColor = new Color3(1,1,1),
  71656. s.specularColor = new Color3(1,1,1),
  71657. s.emissiveColor = new Color3(0,0,0),
  71658. s.specularPower = 64,
  71659. s._useAlphaFromDiffuseTexture = !1,
  71660. s._useEmissiveAsIllumination = !1,
  71661. s._linkEmissiveWithDiffuse = !1,
  71662. s._useSpecularOverAlpha = !1,
  71663. s._useReflectionOverAlpha = !1,
  71664. s._disableLighting = !1,
  71665. s._useObjectSpaceNormalMap = !1,
  71666. s._useParallax = !1,
  71667. s._useParallaxOcclusion = !1,
  71668. s.parallaxScaleBias = .05,
  71669. s._roughness = 0,
  71670. s.indexOfRefraction = .98,
  71671. s.invertRefractionY = !0,
  71672. s.alphaCutOff = .4,
  71673. s._useLightmapAsShadowmap = !1,
  71674. s._useReflectionFresnelFromSpecular = !1,
  71675. s._useGlossinessFromSpecularMapAlpha = !1,
  71676. s._maxSimultaneousLights = 4,
  71677. s._invertNormalMapX = !1,
  71678. s._invertNormalMapY = !1,
  71679. s._twoSidedLighting = !1,
  71680. s.detailMap = new DetailMapConfiguration(s._markAllSubMeshesAsTexturesDirty.bind(s)),
  71681. s._renderTargets = new SmartArray(16),
  71682. s._worldViewProjectionMatrix = Matrix.Zero(),
  71683. s._globalAmbientColor = new Color3(0,0,0),
  71684. s.buildUniformLayout(),
  71685. s._attachImageProcessingConfiguration(null),
  71686. s.prePassConfiguration = new PrePassConfiguration,
  71687. s.getRenderTargetTextures = function() {
  71688. return s._renderTargets.reset(),
  71689. e.ReflectionTextureEnabled && s._reflectionTexture && s._reflectionTexture.isRenderTarget && s._renderTargets.push(s._reflectionTexture),
  71690. e.RefractionTextureEnabled && s._refractionTexture && s._refractionTexture.isRenderTarget && s._renderTargets.push(s._refractionTexture),
  71691. s._renderTargets
  71692. }
  71693. ,
  71694. s
  71695. }
  71696. return Object.defineProperty(e.prototype, "imageProcessingConfiguration", {
  71697. get: function() {
  71698. return this._imageProcessingConfiguration
  71699. },
  71700. set: function(i) {
  71701. this._attachImageProcessingConfiguration(i),
  71702. this._markAllSubMeshesAsTexturesDirty()
  71703. },
  71704. enumerable: !1,
  71705. configurable: !0
  71706. }),
  71707. e.prototype._attachImageProcessingConfiguration = function(i) {
  71708. var o = this;
  71709. i !== this._imageProcessingConfiguration && (this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),
  71710. i ? this._imageProcessingConfiguration = i : this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration,
  71711. this._imageProcessingConfiguration && (this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function() {
  71712. o._markAllSubMeshesAsImageProcessingDirty()
  71713. })))
  71714. }
  71715. ,
  71716. Object.defineProperty(e.prototype, "isPrePassCapable", {
  71717. get: function() {
  71718. return !this.disableDepthWrite
  71719. },
  71720. enumerable: !1,
  71721. configurable: !0
  71722. }),
  71723. Object.defineProperty(e.prototype, "cameraColorCurvesEnabled", {
  71724. get: function() {
  71725. return this.imageProcessingConfiguration.colorCurvesEnabled
  71726. },
  71727. set: function(i) {
  71728. this.imageProcessingConfiguration.colorCurvesEnabled = i
  71729. },
  71730. enumerable: !1,
  71731. configurable: !0
  71732. }),
  71733. Object.defineProperty(e.prototype, "cameraColorGradingEnabled", {
  71734. get: function() {
  71735. return this.imageProcessingConfiguration.colorGradingEnabled
  71736. },
  71737. set: function(i) {
  71738. this.imageProcessingConfiguration.colorGradingEnabled = i
  71739. },
  71740. enumerable: !1,
  71741. configurable: !0
  71742. }),
  71743. Object.defineProperty(e.prototype, "cameraToneMappingEnabled", {
  71744. get: function() {
  71745. return this._imageProcessingConfiguration.toneMappingEnabled
  71746. },
  71747. set: function(i) {
  71748. this._imageProcessingConfiguration.toneMappingEnabled = i
  71749. },
  71750. enumerable: !1,
  71751. configurable: !0
  71752. }),
  71753. Object.defineProperty(e.prototype, "cameraExposure", {
  71754. get: function() {
  71755. return this._imageProcessingConfiguration.exposure
  71756. },
  71757. set: function(i) {
  71758. this._imageProcessingConfiguration.exposure = i
  71759. },
  71760. enumerable: !1,
  71761. configurable: !0
  71762. }),
  71763. Object.defineProperty(e.prototype, "cameraContrast", {
  71764. get: function() {
  71765. return this._imageProcessingConfiguration.contrast
  71766. },
  71767. set: function(i) {
  71768. this._imageProcessingConfiguration.contrast = i
  71769. },
  71770. enumerable: !1,
  71771. configurable: !0
  71772. }),
  71773. Object.defineProperty(e.prototype, "cameraColorGradingTexture", {
  71774. get: function() {
  71775. return this._imageProcessingConfiguration.colorGradingTexture
  71776. },
  71777. set: function(i) {
  71778. this._imageProcessingConfiguration.colorGradingTexture = i
  71779. },
  71780. enumerable: !1,
  71781. configurable: !0
  71782. }),
  71783. Object.defineProperty(e.prototype, "cameraColorCurves", {
  71784. get: function() {
  71785. return this._imageProcessingConfiguration.colorCurves
  71786. },
  71787. set: function(i) {
  71788. this._imageProcessingConfiguration.colorCurves = i
  71789. },
  71790. enumerable: !1,
  71791. configurable: !0
  71792. }),
  71793. Object.defineProperty(e.prototype, "canRenderToMRT", {
  71794. get: function() {
  71795. return !0
  71796. },
  71797. enumerable: !1,
  71798. configurable: !0
  71799. }),
  71800. Object.defineProperty(e.prototype, "hasRenderTargetTextures", {
  71801. get: function() {
  71802. return !!(e.ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget || e.RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget)
  71803. },
  71804. enumerable: !1,
  71805. configurable: !0
  71806. }),
  71807. e.prototype.getClassName = function() {
  71808. return "StandardMaterial"
  71809. }
  71810. ,
  71811. Object.defineProperty(e.prototype, "useLogarithmicDepth", {
  71812. get: function() {
  71813. return this._useLogarithmicDepth
  71814. },
  71815. set: function(i) {
  71816. this._useLogarithmicDepth = i && this.getScene().getEngine().getCaps().fragmentDepthSupported,
  71817. this._markAllSubMeshesAsMiscDirty()
  71818. },
  71819. enumerable: !1,
  71820. configurable: !0
  71821. }),
  71822. e.prototype.needAlphaBlending = function() {
  71823. return this._disableAlphaBlending ? !1 : this.alpha < 1 || this._opacityTexture != null || this._shouldUseAlphaFromDiffuseTexture() || this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled
  71824. }
  71825. ,
  71826. e.prototype.needAlphaTesting = function() {
  71827. return this._forceAlphaTest ? !0 : this._hasAlphaChannel() && (this._transparencyMode == null || this._transparencyMode === Material.MATERIAL_ALPHATEST)
  71828. }
  71829. ,
  71830. e.prototype._shouldUseAlphaFromDiffuseTexture = function() {
  71831. return this._diffuseTexture != null && this._diffuseTexture.hasAlpha && this._useAlphaFromDiffuseTexture && this._transparencyMode !== Material.MATERIAL_OPAQUE
  71832. }
  71833. ,
  71834. e.prototype._hasAlphaChannel = function() {
  71835. return this._diffuseTexture != null && this._diffuseTexture.hasAlpha || this._opacityTexture != null
  71836. }
  71837. ,
  71838. e.prototype.getAlphaTestTexture = function() {
  71839. return this._diffuseTexture
  71840. }
  71841. ,
  71842. e.prototype.isReadyForSubMesh = function(i, o, s) {
  71843. if (s === void 0 && (s = !1),
  71844. o.effect && this.isFrozen && o.effect._wasPreviouslyReady)
  71845. return !0;
  71846. o.materialDefines || (o.materialDefines = new StandardMaterialDefines);
  71847. var c = this.getScene()
  71848. , d = o.materialDefines;
  71849. if (this._isReadyForSubMesh(o))
  71850. return !0;
  71851. var _ = c.getEngine();
  71852. d._needNormals = MaterialHelper.PrepareDefinesForLights(c, i, d, !0, this._maxSimultaneousLights, this._disableLighting),
  71853. MaterialHelper.PrepareDefinesForMultiview(c, d);
  71854. var b = this.needAlphaBlendingForMesh(i) && this.getScene().useOrderIndependentTransparency;
  71855. if (MaterialHelper.PrepareDefinesForPrePass(c, d, this.canRenderToMRT && !b),
  71856. MaterialHelper.PrepareDefinesForOIT(c, d, b),
  71857. d._areTexturesDirty) {
  71858. d._needUVs = !1;
  71859. for (var k = 1; k <= 6; ++k)
  71860. d["MAINUV" + k] = !1;
  71861. if (c.texturesEnabled) {
  71862. if (this._diffuseTexture && e.DiffuseTextureEnabled)
  71863. if (this._diffuseTexture.isReadyOrNotBlocking())
  71864. MaterialHelper.PrepareDefinesForMergedUV(this._diffuseTexture, d, "DIFFUSE");
  71865. else
  71866. return !1;
  71867. else
  71868. d.DIFFUSE = !1;
  71869. if (this._ambientTexture && e.AmbientTextureEnabled)
  71870. if (this._ambientTexture.isReadyOrNotBlocking())
  71871. MaterialHelper.PrepareDefinesForMergedUV(this._ambientTexture, d, "AMBIENT");
  71872. else
  71873. return !1;
  71874. else
  71875. d.AMBIENT = !1;
  71876. if (this._opacityTexture && e.OpacityTextureEnabled)
  71877. if (this._opacityTexture.isReadyOrNotBlocking())
  71878. MaterialHelper.PrepareDefinesForMergedUV(this._opacityTexture, d, "OPACITY"),
  71879. d.OPACITYRGB = this._opacityTexture.getAlphaFromRGB;
  71880. else
  71881. return !1;
  71882. else
  71883. d.OPACITY = !1;
  71884. if (this._reflectionTexture && e.ReflectionTextureEnabled)
  71885. if (this._reflectionTexture.isReadyOrNotBlocking()) {
  71886. switch (d._needNormals = !0,
  71887. d.REFLECTION = !0,
  71888. d.ROUGHNESS = this._roughness > 0,
  71889. d.REFLECTIONOVERALPHA = this._useReflectionOverAlpha,
  71890. d.INVERTCUBICMAP = this._reflectionTexture.coordinatesMode === Texture.INVCUBIC_MODE,
  71891. d.REFLECTIONMAP_3D = this._reflectionTexture.isCube,
  71892. d.RGBDREFLECTION = this._reflectionTexture.isRGBD,
  71893. d.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !this._reflectionTexture.invertZ : this._reflectionTexture.invertZ,
  71894. this._reflectionTexture.coordinatesMode) {
  71895. case Texture.EXPLICIT_MODE:
  71896. d.setReflectionMode("REFLECTIONMAP_EXPLICIT");
  71897. break;
  71898. case Texture.PLANAR_MODE:
  71899. d.setReflectionMode("REFLECTIONMAP_PLANAR");
  71900. break;
  71901. case Texture.PROJECTION_MODE:
  71902. d.setReflectionMode("REFLECTIONMAP_PROJECTION");
  71903. break;
  71904. case Texture.SKYBOX_MODE:
  71905. d.setReflectionMode("REFLECTIONMAP_SKYBOX");
  71906. break;
  71907. case Texture.SPHERICAL_MODE:
  71908. d.setReflectionMode("REFLECTIONMAP_SPHERICAL");
  71909. break;
  71910. case Texture.EQUIRECTANGULAR_MODE:
  71911. d.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");
  71912. break;
  71913. case Texture.FIXED_EQUIRECTANGULAR_MODE:
  71914. d.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");
  71915. break;
  71916. case Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  71917. d.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED");
  71918. break;
  71919. case Texture.CUBIC_MODE:
  71920. case Texture.INVCUBIC_MODE:
  71921. default:
  71922. d.setReflectionMode("REFLECTIONMAP_CUBIC");
  71923. break
  71924. }
  71925. d.USE_LOCAL_REFLECTIONMAP_CUBIC = !!this._reflectionTexture.boundingBoxSize
  71926. } else
  71927. return !1;
  71928. else
  71929. d.REFLECTION = !1,
  71930. d.REFLECTIONMAP_OPPOSITEZ = !1;
  71931. if (this._emissiveTexture && e.EmissiveTextureEnabled)
  71932. if (this._emissiveTexture.isReadyOrNotBlocking())
  71933. MaterialHelper.PrepareDefinesForMergedUV(this._emissiveTexture, d, "EMISSIVE");
  71934. else
  71935. return !1;
  71936. else
  71937. d.EMISSIVE = !1;
  71938. if (this._lightmapTexture && e.LightmapTextureEnabled)
  71939. if (this._lightmapTexture.isReadyOrNotBlocking())
  71940. MaterialHelper.PrepareDefinesForMergedUV(this._lightmapTexture, d, "LIGHTMAP"),
  71941. d.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap,
  71942. d.RGBDLIGHTMAP = this._lightmapTexture.isRGBD;
  71943. else
  71944. return !1;
  71945. else
  71946. d.LIGHTMAP = !1;
  71947. if (this._specularTexture && e.SpecularTextureEnabled)
  71948. if (this._specularTexture.isReadyOrNotBlocking())
  71949. MaterialHelper.PrepareDefinesForMergedUV(this._specularTexture, d, "SPECULAR"),
  71950. d.GLOSSINESS = this._useGlossinessFromSpecularMapAlpha;
  71951. else
  71952. return !1;
  71953. else
  71954. d.SPECULAR = !1;
  71955. if (c.getEngine().getCaps().standardDerivatives && this._bumpTexture && e.BumpTextureEnabled) {
  71956. if (this._bumpTexture.isReady())
  71957. MaterialHelper.PrepareDefinesForMergedUV(this._bumpTexture, d, "BUMP"),
  71958. d.PARALLAX = this._useParallax,
  71959. d.PARALLAXOCCLUSION = this._useParallaxOcclusion;
  71960. else
  71961. return !1;
  71962. d.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap
  71963. } else
  71964. d.BUMP = !1;
  71965. if (this._refractionTexture && e.RefractionTextureEnabled)
  71966. if (this._refractionTexture.isReadyOrNotBlocking())
  71967. d._needUVs = !0,
  71968. d.REFRACTION = !0,
  71969. d.REFRACTIONMAP_3D = this._refractionTexture.isCube,
  71970. d.RGBDREFRACTION = this._refractionTexture.isRGBD,
  71971. d.USE_LOCAL_REFRACTIONMAP_CUBIC = !!this._refractionTexture.boundingBoxSize;
  71972. else
  71973. return !1;
  71974. else
  71975. d.REFRACTION = !1;
  71976. d.TWOSIDEDLIGHTING = !this._backFaceCulling && this._twoSidedLighting
  71977. } else
  71978. d.DIFFUSE = !1,
  71979. d.AMBIENT = !1,
  71980. d.OPACITY = !1,
  71981. d.REFLECTION = !1,
  71982. d.EMISSIVE = !1,
  71983. d.LIGHTMAP = !1,
  71984. d.BUMP = !1,
  71985. d.REFRACTION = !1;
  71986. d.ALPHAFROMDIFFUSE = this._shouldUseAlphaFromDiffuseTexture(),
  71987. d.EMISSIVEASILLUMINATION = this._useEmissiveAsIllumination,
  71988. d.LINKEMISSIVEWITHDIFFUSE = this._linkEmissiveWithDiffuse,
  71989. d.SPECULAROVERALPHA = this._useSpecularOverAlpha,
  71990. d.PREMULTIPLYALPHA = this.alphaMode === 7 || this.alphaMode === 8,
  71991. d.ALPHATEST_AFTERALLALPHACOMPUTATIONS = this.transparencyMode !== null,
  71992. d.ALPHABLEND = this.transparencyMode === null || this.needAlphaBlendingForMesh(i)
  71993. }
  71994. if (!this.detailMap.isReadyForSubMesh(d, c))
  71995. return !1;
  71996. if (d._areImageProcessingDirty && this._imageProcessingConfiguration) {
  71997. if (!this._imageProcessingConfiguration.isReady())
  71998. return !1;
  71999. this._imageProcessingConfiguration.prepareDefines(d),
  72000. d.IS_REFLECTION_LINEAR = this.reflectionTexture != null && !this.reflectionTexture.gammaSpace,
  72001. d.IS_REFRACTION_LINEAR = this.refractionTexture != null && !this.refractionTexture.gammaSpace
  72002. }
  72003. if (d._areFresnelDirty && (e.FresnelEnabled ? (this._diffuseFresnelParameters || this._opacityFresnelParameters || this._emissiveFresnelParameters || this._refractionFresnelParameters || this._reflectionFresnelParameters) && (d.DIFFUSEFRESNEL = this._diffuseFresnelParameters && this._diffuseFresnelParameters.isEnabled,
  72004. d.OPACITYFRESNEL = this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled,
  72005. d.REFLECTIONFRESNEL = this._reflectionFresnelParameters && this._reflectionFresnelParameters.isEnabled,
  72006. d.REFLECTIONFRESNELFROMSPECULAR = this._useReflectionFresnelFromSpecular,
  72007. d.REFRACTIONFRESNEL = this._refractionFresnelParameters && this._refractionFresnelParameters.isEnabled,
  72008. d.EMISSIVEFRESNEL = this._emissiveFresnelParameters && this._emissiveFresnelParameters.isEnabled,
  72009. d._needNormals = !0,
  72010. d.FRESNEL = !0) : d.FRESNEL = !1),
  72011. MaterialHelper.PrepareDefinesForMisc(i, c, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(i) || this._forceAlphaTest, d),
  72012. MaterialHelper.PrepareDefinesForAttributes(i, d, !0, !0, !0),
  72013. MaterialHelper.PrepareDefinesForFrameBoundValues(c, _, d, s, null, o.getRenderingMesh().hasThinInstances),
  72014. this.detailMap.prepareDefines(d, c),
  72015. d.isDirty) {
  72016. var j = d._areLightsDisposed;
  72017. d.markAsProcessed();
  72018. var $ = new EffectFallbacks;
  72019. d.REFLECTION && $.addFallback(0, "REFLECTION"),
  72020. d.SPECULAR && $.addFallback(0, "SPECULAR"),
  72021. d.BUMP && $.addFallback(0, "BUMP"),
  72022. d.PARALLAX && $.addFallback(1, "PARALLAX"),
  72023. d.PARALLAXOCCLUSION && $.addFallback(0, "PARALLAXOCCLUSION"),
  72024. d.SPECULAROVERALPHA && $.addFallback(0, "SPECULAROVERALPHA"),
  72025. d.FOG && $.addFallback(1, "FOG"),
  72026. d.POINTSIZE && $.addFallback(0, "POINTSIZE"),
  72027. d.LOGARITHMICDEPTH && $.addFallback(0, "LOGARITHMICDEPTH"),
  72028. MaterialHelper.HandleFallbacksForShadows(d, $, this._maxSimultaneousLights),
  72029. d.SPECULARTERM && $.addFallback(0, "SPECULARTERM"),
  72030. d.DIFFUSEFRESNEL && $.addFallback(1, "DIFFUSEFRESNEL"),
  72031. d.OPACITYFRESNEL && $.addFallback(2, "OPACITYFRESNEL"),
  72032. d.REFLECTIONFRESNEL && $.addFallback(3, "REFLECTIONFRESNEL"),
  72033. d.EMISSIVEFRESNEL && $.addFallback(4, "EMISSIVEFRESNEL"),
  72034. d.FRESNEL && $.addFallback(4, "FRESNEL"),
  72035. d.MULTIVIEW && $.addFallback(0, "MULTIVIEW");
  72036. var _e = [VertexBuffer.PositionKind];
  72037. d.NORMAL && _e.push(VertexBuffer.NormalKind),
  72038. d.TANGENT && _e.push(VertexBuffer.TangentKind);
  72039. for (var k = 1; k <= 6; ++k)
  72040. d["UV" + k] && _e.push("uv" + (k === 1 ? "" : k));
  72041. d.VERTEXCOLOR && _e.push(VertexBuffer.ColorKind),
  72042. MaterialHelper.PrepareAttributesForBones(_e, i, d, $),
  72043. MaterialHelper.PrepareAttributesForInstances(_e, d),
  72044. MaterialHelper.PrepareAttributesForMorphTargets(_e, i, d),
  72045. MaterialHelper.PrepareAttributesForBakedVertexAnimation(_e, i, d);
  72046. var et = "default"
  72047. , tt = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vDiffuseColor", "vSpecularColor", "vEmissiveColor", "visibility", "vFogInfos", "vFogColor", "pointSize", "vDiffuseInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vEmissiveInfos", "vSpecularInfos", "vBumpInfos", "vLightmapInfos", "vRefractionInfos", "mBones", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "diffuseMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "specularMatrix", "bumpMatrix", "normalMatrix", "lightmapMatrix", "refractionMatrix", "diffuseLeftColor", "diffuseRightColor", "opacityParts", "reflectionLeftColor", "reflectionRightColor", "emissiveLeftColor", "emissiveRightColor", "refractionLeftColor", "refractionRightColor", "vReflectionPosition", "vReflectionSize", "vRefractionPosition", "vRefractionSize", "logarithmicDepthConstant", "vTangentSpaceParams", "alphaCutOff", "boneTextureWidth", "morphTargetTextureInfo", "morphTargetTextureIndices"]
  72048. , rt = ["diffuseSampler", "ambientSampler", "opacitySampler", "reflectionCubeSampler", "reflection2DSampler", "emissiveSampler", "specularSampler", "bumpSampler", "lightmapSampler", "refractionCubeSampler", "refraction2DSampler", "boneSampler", "morphTargets", "oitDepthSampler", "oitFrontColorSampler"]
  72049. , it = ["Material", "Scene", "Mesh"];
  72050. DetailMapConfiguration.AddUniforms(tt),
  72051. DetailMapConfiguration.AddSamplers(rt),
  72052. PrePassConfiguration.AddUniforms(tt),
  72053. PrePassConfiguration.AddSamplers(rt),
  72054. ImageProcessingConfiguration && (ImageProcessingConfiguration.PrepareUniforms(tt, d),
  72055. ImageProcessingConfiguration.PrepareSamplers(rt, d)),
  72056. MaterialHelper.PrepareUniformsAndSamplersList({
  72057. uniformsNames: tt,
  72058. uniformBuffersNames: it,
  72059. samplers: rt,
  72060. defines: d,
  72061. maxSimultaneousLights: this._maxSimultaneousLights
  72062. });
  72063. var nt = {};
  72064. this.customShaderNameResolve && (et = this.customShaderNameResolve(et, tt, it, rt, d, _e, nt));
  72065. var ot = d.toString()
  72066. , at = o.effect
  72067. , st = c.getEngine().createEffect(et, {
  72068. attributes: _e,
  72069. uniformsNames: tt,
  72070. uniformBuffersNames: it,
  72071. samplers: rt,
  72072. defines: ot,
  72073. fallbacks: $,
  72074. onCompiled: this.onCompiled,
  72075. onError: this.onError,
  72076. indexParameters: {
  72077. maxSimultaneousLights: this._maxSimultaneousLights,
  72078. maxSimultaneousMorphTargets: d.NUM_MORPH_INFLUENCERS
  72079. },
  72080. processFinalCode: nt.processFinalCode,
  72081. multiTarget: d.PREPASS
  72082. }, _);
  72083. if (st)
  72084. if (this._onEffectCreatedObservable && (onCreatedEffectParameters$2.effect = st,
  72085. onCreatedEffectParameters$2.subMesh = o,
  72086. this._onEffectCreatedObservable.notifyObservers(onCreatedEffectParameters$2)),
  72087. this.allowShaderHotSwapping && at && !st.isReady()) {
  72088. if (st = at,
  72089. d.markAsUnprocessed(),
  72090. j)
  72091. return d._areLightsDisposed = !0,
  72092. !1
  72093. } else
  72094. c.resetCachedMaterial(),
  72095. o.setEffect(st, d, this._materialContext)
  72096. }
  72097. return !o.effect || !o.effect.isReady() ? !1 : (d._renderId = c.getRenderId(),
  72098. o.effect._wasPreviouslyReady = !0,
  72099. !0)
  72100. }
  72101. ,
  72102. e.prototype.buildUniformLayout = function() {
  72103. var i = this._uniformBuffer;
  72104. i.addUniform("diffuseLeftColor", 4),
  72105. i.addUniform("diffuseRightColor", 4),
  72106. i.addUniform("opacityParts", 4),
  72107. i.addUniform("reflectionLeftColor", 4),
  72108. i.addUniform("reflectionRightColor", 4),
  72109. i.addUniform("refractionLeftColor", 4),
  72110. i.addUniform("refractionRightColor", 4),
  72111. i.addUniform("emissiveLeftColor", 4),
  72112. i.addUniform("emissiveRightColor", 4),
  72113. i.addUniform("vDiffuseInfos", 2),
  72114. i.addUniform("vAmbientInfos", 2),
  72115. i.addUniform("vOpacityInfos", 2),
  72116. i.addUniform("vReflectionInfos", 2),
  72117. i.addUniform("vReflectionPosition", 3),
  72118. i.addUniform("vReflectionSize", 3),
  72119. i.addUniform("vEmissiveInfos", 2),
  72120. i.addUniform("vLightmapInfos", 2),
  72121. i.addUniform("vSpecularInfos", 2),
  72122. i.addUniform("vBumpInfos", 3),
  72123. i.addUniform("diffuseMatrix", 16),
  72124. i.addUniform("ambientMatrix", 16),
  72125. i.addUniform("opacityMatrix", 16),
  72126. i.addUniform("reflectionMatrix", 16),
  72127. i.addUniform("emissiveMatrix", 16),
  72128. i.addUniform("lightmapMatrix", 16),
  72129. i.addUniform("specularMatrix", 16),
  72130. i.addUniform("bumpMatrix", 16),
  72131. i.addUniform("vTangentSpaceParams", 2),
  72132. i.addUniform("pointSize", 1),
  72133. i.addUniform("alphaCutOff", 1),
  72134. i.addUniform("refractionMatrix", 16),
  72135. i.addUniform("vRefractionInfos", 4),
  72136. i.addUniform("vRefractionPosition", 3),
  72137. i.addUniform("vRefractionSize", 3),
  72138. i.addUniform("vSpecularColor", 4),
  72139. i.addUniform("vEmissiveColor", 3),
  72140. i.addUniform("vDiffuseColor", 4),
  72141. i.addUniform("vAmbientColor", 3),
  72142. DetailMapConfiguration.PrepareUniformBuffer(i),
  72143. i.create()
  72144. }
  72145. ,
  72146. e.prototype.unbind = function() {
  72147. if (this._activeEffect && !this.getScene().getEngine()._features.needToAlwaysBindUniformBuffers) {
  72148. var i = !1;
  72149. this._reflectionTexture && this._reflectionTexture.isRenderTarget && (this._activeEffect.setTexture("reflection2DSampler", null),
  72150. i = !0),
  72151. this._refractionTexture && this._refractionTexture.isRenderTarget && (this._activeEffect.setTexture("refraction2DSampler", null),
  72152. i = !0),
  72153. i && this._markAllSubMeshesAsTexturesDirty()
  72154. }
  72155. a.prototype.unbind.call(this)
  72156. }
  72157. ,
  72158. e.prototype.bindForSubMesh = function(i, o, s) {
  72159. var c, d = this.getScene(), _ = s.materialDefines;
  72160. if (!!_) {
  72161. var b = s.effect;
  72162. if (!!b) {
  72163. this._activeEffect = b,
  72164. o.getMeshUniformBuffer().bindToEffect(b, "Mesh"),
  72165. o.transferToEffect(i),
  72166. this.prePassConfiguration.bindForSubMesh(this._activeEffect, d, o, i, this.isFrozen),
  72167. _.OBJECTSPACE_NORMALMAP && (i.toNormalMatrix(this._normalMatrix),
  72168. this.bindOnlyNormalMatrix(this._normalMatrix));
  72169. var k = this._mustRebind(d, b, o.visibility);
  72170. MaterialHelper.BindBonesParameters(o, b);
  72171. var j = this._uniformBuffer;
  72172. if (k) {
  72173. if (j.bindToEffect(b, "Material"),
  72174. this.bindViewProjection(b),
  72175. !j.useUbo || !this.isFrozen || !j.isSync) {
  72176. if (e.FresnelEnabled && _.FRESNEL && (this.diffuseFresnelParameters && this.diffuseFresnelParameters.isEnabled && (j.updateColor4("diffuseLeftColor", this.diffuseFresnelParameters.leftColor, this.diffuseFresnelParameters.power),
  72177. j.updateColor4("diffuseRightColor", this.diffuseFresnelParameters.rightColor, this.diffuseFresnelParameters.bias)),
  72178. this.opacityFresnelParameters && this.opacityFresnelParameters.isEnabled && j.updateColor4("opacityParts", new Color3(this.opacityFresnelParameters.leftColor.toLuminance(),this.opacityFresnelParameters.rightColor.toLuminance(),this.opacityFresnelParameters.bias), this.opacityFresnelParameters.power),
  72179. this.reflectionFresnelParameters && this.reflectionFresnelParameters.isEnabled && (j.updateColor4("reflectionLeftColor", this.reflectionFresnelParameters.leftColor, this.reflectionFresnelParameters.power),
  72180. j.updateColor4("reflectionRightColor", this.reflectionFresnelParameters.rightColor, this.reflectionFresnelParameters.bias)),
  72181. this.refractionFresnelParameters && this.refractionFresnelParameters.isEnabled && (j.updateColor4("refractionLeftColor", this.refractionFresnelParameters.leftColor, this.refractionFresnelParameters.power),
  72182. j.updateColor4("refractionRightColor", this.refractionFresnelParameters.rightColor, this.refractionFresnelParameters.bias)),
  72183. this.emissiveFresnelParameters && this.emissiveFresnelParameters.isEnabled && (j.updateColor4("emissiveLeftColor", this.emissiveFresnelParameters.leftColor, this.emissiveFresnelParameters.power),
  72184. j.updateColor4("emissiveRightColor", this.emissiveFresnelParameters.rightColor, this.emissiveFresnelParameters.bias))),
  72185. d.texturesEnabled) {
  72186. if (this._diffuseTexture && e.DiffuseTextureEnabled && (j.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level),
  72187. MaterialHelper.BindTextureMatrix(this._diffuseTexture, j, "diffuse")),
  72188. this._ambientTexture && e.AmbientTextureEnabled && (j.updateFloat2("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level),
  72189. MaterialHelper.BindTextureMatrix(this._ambientTexture, j, "ambient")),
  72190. this._opacityTexture && e.OpacityTextureEnabled && (j.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level),
  72191. MaterialHelper.BindTextureMatrix(this._opacityTexture, j, "opacity")),
  72192. this._hasAlphaChannel() && j.updateFloat("alphaCutOff", this.alphaCutOff),
  72193. this._reflectionTexture && e.ReflectionTextureEnabled && (j.updateFloat2("vReflectionInfos", this._reflectionTexture.level, this.roughness),
  72194. j.updateMatrix("reflectionMatrix", this._reflectionTexture.getReflectionTextureMatrix()),
  72195. this._reflectionTexture.boundingBoxSize)) {
  72196. var $ = this._reflectionTexture;
  72197. j.updateVector3("vReflectionPosition", $.boundingBoxPosition),
  72198. j.updateVector3("vReflectionSize", $.boundingBoxSize)
  72199. }
  72200. if (this._emissiveTexture && e.EmissiveTextureEnabled && (j.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level),
  72201. MaterialHelper.BindTextureMatrix(this._emissiveTexture, j, "emissive")),
  72202. this._lightmapTexture && e.LightmapTextureEnabled && (j.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level),
  72203. MaterialHelper.BindTextureMatrix(this._lightmapTexture, j, "lightmap")),
  72204. this._specularTexture && e.SpecularTextureEnabled && (j.updateFloat2("vSpecularInfos", this._specularTexture.coordinatesIndex, this._specularTexture.level),
  72205. MaterialHelper.BindTextureMatrix(this._specularTexture, j, "specular")),
  72206. this._bumpTexture && d.getEngine().getCaps().standardDerivatives && e.BumpTextureEnabled && (j.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, 1 / this._bumpTexture.level, this.parallaxScaleBias),
  72207. MaterialHelper.BindTextureMatrix(this._bumpTexture, j, "bump"),
  72208. d._mirroredCameraPosition ? j.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1 : -1, this._invertNormalMapY ? 1 : -1) : j.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1 : 1, this._invertNormalMapY ? -1 : 1)),
  72209. this._refractionTexture && e.RefractionTextureEnabled) {
  72210. var _e = 1;
  72211. if (this._refractionTexture.isCube || (j.updateMatrix("refractionMatrix", this._refractionTexture.getReflectionTextureMatrix()),
  72212. this._refractionTexture.depth && (_e = this._refractionTexture.depth)),
  72213. j.updateFloat4("vRefractionInfos", this._refractionTexture.level, this.indexOfRefraction, _e, this.invertRefractionY ? -1 : 1),
  72214. this._refractionTexture.boundingBoxSize) {
  72215. var $ = this._refractionTexture;
  72216. j.updateVector3("vRefractionPosition", $.boundingBoxPosition),
  72217. j.updateVector3("vRefractionSize", $.boundingBoxSize)
  72218. }
  72219. }
  72220. }
  72221. this.pointsCloud && j.updateFloat("pointSize", this.pointSize),
  72222. _.SPECULARTERM && j.updateColor4("vSpecularColor", this.specularColor, this.specularPower),
  72223. j.updateColor3("vEmissiveColor", e.EmissiveTextureEnabled ? this.emissiveColor : Color3.BlackReadOnly),
  72224. j.updateColor4("vDiffuseColor", this.diffuseColor, this.alpha),
  72225. d.ambientColor.multiplyToRef(this.ambientColor, this._globalAmbientColor),
  72226. j.updateColor3("vAmbientColor", this._globalAmbientColor)
  72227. }
  72228. if (d.texturesEnabled && (this._diffuseTexture && e.DiffuseTextureEnabled && b.setTexture("diffuseSampler", this._diffuseTexture),
  72229. this._ambientTexture && e.AmbientTextureEnabled && b.setTexture("ambientSampler", this._ambientTexture),
  72230. this._opacityTexture && e.OpacityTextureEnabled && b.setTexture("opacitySampler", this._opacityTexture),
  72231. this._reflectionTexture && e.ReflectionTextureEnabled && (this._reflectionTexture.isCube ? b.setTexture("reflectionCubeSampler", this._reflectionTexture) : b.setTexture("reflection2DSampler", this._reflectionTexture)),
  72232. this._emissiveTexture && e.EmissiveTextureEnabled && b.setTexture("emissiveSampler", this._emissiveTexture),
  72233. this._lightmapTexture && e.LightmapTextureEnabled && b.setTexture("lightmapSampler", this._lightmapTexture),
  72234. this._specularTexture && e.SpecularTextureEnabled && b.setTexture("specularSampler", this._specularTexture),
  72235. this._bumpTexture && d.getEngine().getCaps().standardDerivatives && e.BumpTextureEnabled && b.setTexture("bumpSampler", this._bumpTexture),
  72236. this._refractionTexture && e.RefractionTextureEnabled)) {
  72237. var _e = 1;
  72238. this._refractionTexture.isCube ? b.setTexture("refractionCubeSampler", this._refractionTexture) : b.setTexture("refraction2DSampler", this._refractionTexture)
  72239. }
  72240. this.getScene().useOrderIndependentTransparency && this.needAlphaBlendingForMesh(o) && this.getScene().depthPeelingRenderer.bind(b),
  72241. this.detailMap.bindForSubMesh(j, d, this.isFrozen),
  72242. MaterialHelper.BindClipPlane(b, d),
  72243. this.bindEyePosition(b)
  72244. } else
  72245. d.getEngine()._features.needToAlwaysBindUniformBuffers && (j.bindToEffect(b, "Material"),
  72246. this._needToBindSceneUbo = !0);
  72247. (k || !this.isFrozen) && (d.lightsEnabled && !this._disableLighting && MaterialHelper.BindLights(d, o, b, _, this._maxSimultaneousLights),
  72248. (d.fogEnabled && o.applyFog && d.fogMode !== Scene.FOGMODE_NONE || this._reflectionTexture || this._refractionTexture || o.receiveShadows) && this.bindView(b),
  72249. MaterialHelper.BindFogParameters(d, o, b),
  72250. _.NUM_MORPH_INFLUENCERS && MaterialHelper.BindMorphTargetParameters(o, b),
  72251. _.BAKED_VERTEX_ANIMATION_TEXTURE && ((c = o.bakedVertexAnimationManager) === null || c === void 0 || c.bind(b, _.INSTANCES)),
  72252. this.useLogarithmicDepth && MaterialHelper.BindLogDepth(_, b, d),
  72253. this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess && this._imageProcessingConfiguration.bind(this._activeEffect)),
  72254. this._afterBind(o, this._activeEffect),
  72255. j.update()
  72256. }
  72257. }
  72258. }
  72259. ,
  72260. e.prototype.getAnimatables = function() {
  72261. var i = [];
  72262. return this._diffuseTexture && this._diffuseTexture.animations && this._diffuseTexture.animations.length > 0 && i.push(this._diffuseTexture),
  72263. this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0 && i.push(this._ambientTexture),
  72264. this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0 && i.push(this._opacityTexture),
  72265. this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0 && i.push(this._reflectionTexture),
  72266. this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0 && i.push(this._emissiveTexture),
  72267. this._specularTexture && this._specularTexture.animations && this._specularTexture.animations.length > 0 && i.push(this._specularTexture),
  72268. this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0 && i.push(this._bumpTexture),
  72269. this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0 && i.push(this._lightmapTexture),
  72270. this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0 && i.push(this._refractionTexture),
  72271. this.detailMap.getAnimatables(i),
  72272. i
  72273. }
  72274. ,
  72275. e.prototype.getActiveTextures = function() {
  72276. var i = a.prototype.getActiveTextures.call(this);
  72277. return this._diffuseTexture && i.push(this._diffuseTexture),
  72278. this._ambientTexture && i.push(this._ambientTexture),
  72279. this._opacityTexture && i.push(this._opacityTexture),
  72280. this._reflectionTexture && i.push(this._reflectionTexture),
  72281. this._emissiveTexture && i.push(this._emissiveTexture),
  72282. this._specularTexture && i.push(this._specularTexture),
  72283. this._bumpTexture && i.push(this._bumpTexture),
  72284. this._lightmapTexture && i.push(this._lightmapTexture),
  72285. this._refractionTexture && i.push(this._refractionTexture),
  72286. this.detailMap.getActiveTextures(i),
  72287. i
  72288. }
  72289. ,
  72290. e.prototype.hasTexture = function(i) {
  72291. return !!(a.prototype.hasTexture.call(this, i) || this._diffuseTexture === i || this._ambientTexture === i || this._opacityTexture === i || this._reflectionTexture === i || this._emissiveTexture === i || this._specularTexture === i || this._bumpTexture === i || this._lightmapTexture === i || this._refractionTexture === i || this.detailMap.hasTexture(i))
  72292. }
  72293. ,
  72294. e.prototype.dispose = function(i, o) {
  72295. var s, c, d, _, b, k, j, $, _e;
  72296. o && ((s = this._diffuseTexture) === null || s === void 0 || s.dispose(),
  72297. (c = this._ambientTexture) === null || c === void 0 || c.dispose(),
  72298. (d = this._opacityTexture) === null || d === void 0 || d.dispose(),
  72299. (_ = this._reflectionTexture) === null || _ === void 0 || _.dispose(),
  72300. (b = this._emissiveTexture) === null || b === void 0 || b.dispose(),
  72301. (k = this._specularTexture) === null || k === void 0 || k.dispose(),
  72302. (j = this._bumpTexture) === null || j === void 0 || j.dispose(),
  72303. ($ = this._lightmapTexture) === null || $ === void 0 || $.dispose(),
  72304. (_e = this._refractionTexture) === null || _e === void 0 || _e.dispose()),
  72305. this.detailMap.dispose(o),
  72306. this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),
  72307. a.prototype.dispose.call(this, i, o)
  72308. }
  72309. ,
  72310. e.prototype.clone = function(i) {
  72311. var o = this
  72312. , s = SerializationHelper.Clone(function() {
  72313. return new e(i,o.getScene())
  72314. }, this);
  72315. return s.name = i,
  72316. s.id = i,
  72317. this.stencil.copyTo(s.stencil),
  72318. s
  72319. }
  72320. ,
  72321. e.prototype.serialize = function() {
  72322. var i = SerializationHelper.Serialize(this);
  72323. return i.stencil = this.stencil.serialize(),
  72324. i
  72325. }
  72326. ,
  72327. e.Parse = function(i, o, s) {
  72328. var c = SerializationHelper.Parse(function() {
  72329. return new e(i.name,o)
  72330. }, i, o, s);
  72331. return i.stencil && c.stencil.parse(i.stencil, o, s),
  72332. c
  72333. }
  72334. ,
  72335. Object.defineProperty(e, "DiffuseTextureEnabled", {
  72336. get: function() {
  72337. return MaterialFlags.DiffuseTextureEnabled
  72338. },
  72339. set: function(i) {
  72340. MaterialFlags.DiffuseTextureEnabled = i
  72341. },
  72342. enumerable: !1,
  72343. configurable: !0
  72344. }),
  72345. Object.defineProperty(e, "DetailTextureEnabled", {
  72346. get: function() {
  72347. return MaterialFlags.DetailTextureEnabled
  72348. },
  72349. set: function(i) {
  72350. MaterialFlags.DetailTextureEnabled = i
  72351. },
  72352. enumerable: !1,
  72353. configurable: !0
  72354. }),
  72355. Object.defineProperty(e, "AmbientTextureEnabled", {
  72356. get: function() {
  72357. return MaterialFlags.AmbientTextureEnabled
  72358. },
  72359. set: function(i) {
  72360. MaterialFlags.AmbientTextureEnabled = i
  72361. },
  72362. enumerable: !1,
  72363. configurable: !0
  72364. }),
  72365. Object.defineProperty(e, "OpacityTextureEnabled", {
  72366. get: function() {
  72367. return MaterialFlags.OpacityTextureEnabled
  72368. },
  72369. set: function(i) {
  72370. MaterialFlags.OpacityTextureEnabled = i
  72371. },
  72372. enumerable: !1,
  72373. configurable: !0
  72374. }),
  72375. Object.defineProperty(e, "ReflectionTextureEnabled", {
  72376. get: function() {
  72377. return MaterialFlags.ReflectionTextureEnabled
  72378. },
  72379. set: function(i) {
  72380. MaterialFlags.ReflectionTextureEnabled = i
  72381. },
  72382. enumerable: !1,
  72383. configurable: !0
  72384. }),
  72385. Object.defineProperty(e, "EmissiveTextureEnabled", {
  72386. get: function() {
  72387. return MaterialFlags.EmissiveTextureEnabled
  72388. },
  72389. set: function(i) {
  72390. MaterialFlags.EmissiveTextureEnabled = i
  72391. },
  72392. enumerable: !1,
  72393. configurable: !0
  72394. }),
  72395. Object.defineProperty(e, "SpecularTextureEnabled", {
  72396. get: function() {
  72397. return MaterialFlags.SpecularTextureEnabled
  72398. },
  72399. set: function(i) {
  72400. MaterialFlags.SpecularTextureEnabled = i
  72401. },
  72402. enumerable: !1,
  72403. configurable: !0
  72404. }),
  72405. Object.defineProperty(e, "BumpTextureEnabled", {
  72406. get: function() {
  72407. return MaterialFlags.BumpTextureEnabled
  72408. },
  72409. set: function(i) {
  72410. MaterialFlags.BumpTextureEnabled = i
  72411. },
  72412. enumerable: !1,
  72413. configurable: !0
  72414. }),
  72415. Object.defineProperty(e, "LightmapTextureEnabled", {
  72416. get: function() {
  72417. return MaterialFlags.LightmapTextureEnabled
  72418. },
  72419. set: function(i) {
  72420. MaterialFlags.LightmapTextureEnabled = i
  72421. },
  72422. enumerable: !1,
  72423. configurable: !0
  72424. }),
  72425. Object.defineProperty(e, "RefractionTextureEnabled", {
  72426. get: function() {
  72427. return MaterialFlags.RefractionTextureEnabled
  72428. },
  72429. set: function(i) {
  72430. MaterialFlags.RefractionTextureEnabled = i
  72431. },
  72432. enumerable: !1,
  72433. configurable: !0
  72434. }),
  72435. Object.defineProperty(e, "ColorGradingTextureEnabled", {
  72436. get: function() {
  72437. return MaterialFlags.ColorGradingTextureEnabled
  72438. },
  72439. set: function(i) {
  72440. MaterialFlags.ColorGradingTextureEnabled = i
  72441. },
  72442. enumerable: !1,
  72443. configurable: !0
  72444. }),
  72445. Object.defineProperty(e, "FresnelEnabled", {
  72446. get: function() {
  72447. return MaterialFlags.FresnelEnabled
  72448. },
  72449. set: function(i) {
  72450. MaterialFlags.FresnelEnabled = i
  72451. },
  72452. enumerable: !1,
  72453. configurable: !0
  72454. }),
  72455. __decorate([serializeAsTexture("diffuseTexture")], e.prototype, "_diffuseTexture", void 0),
  72456. __decorate([expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")], e.prototype, "diffuseTexture", void 0),
  72457. __decorate([serializeAsTexture("ambientTexture")], e.prototype, "_ambientTexture", void 0),
  72458. __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "ambientTexture", void 0),
  72459. __decorate([serializeAsTexture("opacityTexture")], e.prototype, "_opacityTexture", void 0),
  72460. __decorate([expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")], e.prototype, "opacityTexture", void 0),
  72461. __decorate([serializeAsTexture("reflectionTexture")], e.prototype, "_reflectionTexture", void 0),
  72462. __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "reflectionTexture", void 0),
  72463. __decorate([serializeAsTexture("emissiveTexture")], e.prototype, "_emissiveTexture", void 0),
  72464. __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "emissiveTexture", void 0),
  72465. __decorate([serializeAsTexture("specularTexture")], e.prototype, "_specularTexture", void 0),
  72466. __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "specularTexture", void 0),
  72467. __decorate([serializeAsTexture("bumpTexture")], e.prototype, "_bumpTexture", void 0),
  72468. __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "bumpTexture", void 0),
  72469. __decorate([serializeAsTexture("lightmapTexture")], e.prototype, "_lightmapTexture", void 0),
  72470. __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "lightmapTexture", void 0),
  72471. __decorate([serializeAsTexture("refractionTexture")], e.prototype, "_refractionTexture", void 0),
  72472. __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "refractionTexture", void 0),
  72473. __decorate([serializeAsColor3("ambient")], e.prototype, "ambientColor", void 0),
  72474. __decorate([serializeAsColor3("diffuse")], e.prototype, "diffuseColor", void 0),
  72475. __decorate([serializeAsColor3("specular")], e.prototype, "specularColor", void 0),
  72476. __decorate([serializeAsColor3("emissive")], e.prototype, "emissiveColor", void 0),
  72477. __decorate([serialize()], e.prototype, "specularPower", void 0),
  72478. __decorate([serialize("useAlphaFromDiffuseTexture")], e.prototype, "_useAlphaFromDiffuseTexture", void 0),
  72479. __decorate([expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")], e.prototype, "useAlphaFromDiffuseTexture", void 0),
  72480. __decorate([serialize("useEmissiveAsIllumination")], e.prototype, "_useEmissiveAsIllumination", void 0),
  72481. __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useEmissiveAsIllumination", void 0),
  72482. __decorate([serialize("linkEmissiveWithDiffuse")], e.prototype, "_linkEmissiveWithDiffuse", void 0),
  72483. __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "linkEmissiveWithDiffuse", void 0),
  72484. __decorate([serialize("useSpecularOverAlpha")], e.prototype, "_useSpecularOverAlpha", void 0),
  72485. __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useSpecularOverAlpha", void 0),
  72486. __decorate([serialize("useReflectionOverAlpha")], e.prototype, "_useReflectionOverAlpha", void 0),
  72487. __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useReflectionOverAlpha", void 0),
  72488. __decorate([serialize("disableLighting")], e.prototype, "_disableLighting", void 0),
  72489. __decorate([expandToProperty("_markAllSubMeshesAsLightsDirty")], e.prototype, "disableLighting", void 0),
  72490. __decorate([serialize("useObjectSpaceNormalMap")], e.prototype, "_useObjectSpaceNormalMap", void 0),
  72491. __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useObjectSpaceNormalMap", void 0),
  72492. __decorate([serialize("useParallax")], e.prototype, "_useParallax", void 0),
  72493. __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useParallax", void 0),
  72494. __decorate([serialize("useParallaxOcclusion")], e.prototype, "_useParallaxOcclusion", void 0),
  72495. __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useParallaxOcclusion", void 0),
  72496. __decorate([serialize()], e.prototype, "parallaxScaleBias", void 0),
  72497. __decorate([serialize("roughness")], e.prototype, "_roughness", void 0),
  72498. __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "roughness", void 0),
  72499. __decorate([serialize()], e.prototype, "indexOfRefraction", void 0),
  72500. __decorate([serialize()], e.prototype, "invertRefractionY", void 0),
  72501. __decorate([serialize()], e.prototype, "alphaCutOff", void 0),
  72502. __decorate([serialize("useLightmapAsShadowmap")], e.prototype, "_useLightmapAsShadowmap", void 0),
  72503. __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useLightmapAsShadowmap", void 0),
  72504. __decorate([serializeAsFresnelParameters("diffuseFresnelParameters")], e.prototype, "_diffuseFresnelParameters", void 0),
  72505. __decorate([expandToProperty("_markAllSubMeshesAsFresnelDirty")], e.prototype, "diffuseFresnelParameters", void 0),
  72506. __decorate([serializeAsFresnelParameters("opacityFresnelParameters")], e.prototype, "_opacityFresnelParameters", void 0),
  72507. __decorate([expandToProperty("_markAllSubMeshesAsFresnelAndMiscDirty")], e.prototype, "opacityFresnelParameters", void 0),
  72508. __decorate([serializeAsFresnelParameters("reflectionFresnelParameters")], e.prototype, "_reflectionFresnelParameters", void 0),
  72509. __decorate([expandToProperty("_markAllSubMeshesAsFresnelDirty")], e.prototype, "reflectionFresnelParameters", void 0),
  72510. __decorate([serializeAsFresnelParameters("refractionFresnelParameters")], e.prototype, "_refractionFresnelParameters", void 0),
  72511. __decorate([expandToProperty("_markAllSubMeshesAsFresnelDirty")], e.prototype, "refractionFresnelParameters", void 0),
  72512. __decorate([serializeAsFresnelParameters("emissiveFresnelParameters")], e.prototype, "_emissiveFresnelParameters", void 0),
  72513. __decorate([expandToProperty("_markAllSubMeshesAsFresnelDirty")], e.prototype, "emissiveFresnelParameters", void 0),
  72514. __decorate([serialize("useReflectionFresnelFromSpecular")], e.prototype, "_useReflectionFresnelFromSpecular", void 0),
  72515. __decorate([expandToProperty("_markAllSubMeshesAsFresnelDirty")], e.prototype, "useReflectionFresnelFromSpecular", void 0),
  72516. __decorate([serialize("useGlossinessFromSpecularMapAlpha")], e.prototype, "_useGlossinessFromSpecularMapAlpha", void 0),
  72517. __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useGlossinessFromSpecularMapAlpha", void 0),
  72518. __decorate([serialize("maxSimultaneousLights")], e.prototype, "_maxSimultaneousLights", void 0),
  72519. __decorate([expandToProperty("_markAllSubMeshesAsLightsDirty")], e.prototype, "maxSimultaneousLights", void 0),
  72520. __decorate([serialize("invertNormalMapX")], e.prototype, "_invertNormalMapX", void 0),
  72521. __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "invertNormalMapX", void 0),
  72522. __decorate([serialize("invertNormalMapY")], e.prototype, "_invertNormalMapY", void 0),
  72523. __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "invertNormalMapY", void 0),
  72524. __decorate([serialize("twoSidedLighting")], e.prototype, "_twoSidedLighting", void 0),
  72525. __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "twoSidedLighting", void 0),
  72526. __decorate([serialize()], e.prototype, "useLogarithmicDepth", null),
  72527. e
  72528. }(PushMaterial);
  72529. RegisterClass("BABYLON.StandardMaterial", StandardMaterial);
  72530. Scene.DefaultMaterialFactory = function(a) {
  72531. return new StandardMaterial("default material",a)
  72532. }
  72533. ;
  72534. var CubeTexture = function(a) {
  72535. __extends(e, a);
  72536. function e(i, o, s, c, d, _, b, k, j, $, _e, et, tt, rt, it) {
  72537. s === void 0 && (s = null),
  72538. c === void 0 && (c = !1),
  72539. d === void 0 && (d = null),
  72540. _ === void 0 && (_ = null),
  72541. b === void 0 && (b = null),
  72542. k === void 0 && (k = 5),
  72543. j === void 0 && (j = !1),
  72544. $ === void 0 && ($ = null),
  72545. _e === void 0 && (_e = !1),
  72546. et === void 0 && (et = .8),
  72547. tt === void 0 && (tt = 0);
  72548. var nt, ot = a.call(this, o) || this;
  72549. return ot._lodScale = .8,
  72550. ot._lodOffset = 0,
  72551. ot.onLoadObservable = new Observable,
  72552. ot.boundingBoxPosition = Vector3.Zero(),
  72553. ot._rotationY = 0,
  72554. ot._files = null,
  72555. ot._forcedExtension = null,
  72556. ot._extensions = null,
  72557. ot.name = i,
  72558. ot.url = i,
  72559. ot._noMipmap = c,
  72560. ot.hasAlpha = !1,
  72561. ot._format = k,
  72562. ot.isCube = !0,
  72563. ot._textureMatrix = Matrix.Identity(),
  72564. ot._createPolynomials = _e,
  72565. ot.coordinatesMode = Texture.CUBIC_MODE,
  72566. ot._extensions = s,
  72567. ot._files = d,
  72568. ot._forcedExtension = $,
  72569. ot._loaderOptions = rt,
  72570. ot._useSRGBBuffer = it,
  72571. ot._lodScale = et,
  72572. ot._lodOffset = tt,
  72573. !i && !d || ot.updateURL(i, $, _, j, b, s, (nt = ot.getScene()) === null || nt === void 0 ? void 0 : nt.useDelayedTextureLoading, d),
  72574. ot
  72575. }
  72576. return Object.defineProperty(e.prototype, "boundingBoxSize", {
  72577. get: function() {
  72578. return this._boundingBoxSize
  72579. },
  72580. set: function(i) {
  72581. if (!(this._boundingBoxSize && this._boundingBoxSize.equals(i))) {
  72582. this._boundingBoxSize = i;
  72583. var o = this.getScene();
  72584. o && o.markAllMaterialsAsDirty(1)
  72585. }
  72586. },
  72587. enumerable: !1,
  72588. configurable: !0
  72589. }),
  72590. Object.defineProperty(e.prototype, "rotationY", {
  72591. get: function() {
  72592. return this._rotationY
  72593. },
  72594. set: function(i) {
  72595. this._rotationY = i,
  72596. this.setReflectionTextureMatrix(Matrix.RotationY(this._rotationY))
  72597. },
  72598. enumerable: !1,
  72599. configurable: !0
  72600. }),
  72601. Object.defineProperty(e.prototype, "noMipmap", {
  72602. get: function() {
  72603. return this._noMipmap
  72604. },
  72605. enumerable: !1,
  72606. configurable: !0
  72607. }),
  72608. Object.defineProperty(e.prototype, "forcedExtension", {
  72609. get: function() {
  72610. return this._forcedExtension
  72611. },
  72612. enumerable: !1,
  72613. configurable: !0
  72614. }),
  72615. e.CreateFromImages = function(i, o, s) {
  72616. var c = "";
  72617. return i.forEach(function(d) {
  72618. return c += d
  72619. }),
  72620. new e(c,o,null,s,i)
  72621. }
  72622. ,
  72623. e.CreateFromPrefilteredData = function(i, o, s, c) {
  72624. s === void 0 && (s = null),
  72625. c === void 0 && (c = !0);
  72626. var d = o.useDelayedTextureLoading;
  72627. o.useDelayedTextureLoading = !1;
  72628. var _ = new e(i,o,null,!1,null,null,null,void 0,!0,s,c);
  72629. return o.useDelayedTextureLoading = d,
  72630. _
  72631. }
  72632. ,
  72633. e.prototype.getClassName = function() {
  72634. return "CubeTexture"
  72635. }
  72636. ,
  72637. e.prototype.updateURL = function(i, o, s, c, d, _, b, k) {
  72638. s === void 0 && (s = null),
  72639. c === void 0 && (c = !1),
  72640. d === void 0 && (d = null),
  72641. _ === void 0 && (_ = null),
  72642. b === void 0 && (b = !1),
  72643. k === void 0 && (k = null),
  72644. (!this.name || StartsWith(this.name, "data:")) && (this.name = i),
  72645. this.url = i;
  72646. var j = i.lastIndexOf(".")
  72647. , $ = o || (j > -1 ? i.substring(j).toLowerCase() : "")
  72648. , _e = $.indexOf(".dds") === 0
  72649. , et = $.indexOf(".env") === 0;
  72650. if (et ? (this.gammaSpace = !1,
  72651. this._prefiltered = !1,
  72652. this.anisotropicFilteringLevel = 1) : (this._prefiltered = c,
  72653. c && (this.gammaSpace = !1,
  72654. this.anisotropicFilteringLevel = 1)),
  72655. k)
  72656. this._files = k;
  72657. else if (!et && !_e && !_ && (_ = ["_px.jpg", "_py.jpg", "_pz.jpg", "_nx.jpg", "_ny.jpg", "_nz.jpg"]),
  72658. this._files = this._files || [],
  72659. this._files.length = 0,
  72660. _) {
  72661. for (var tt = 0; tt < _.length; tt++)
  72662. this._files.push(i + _[tt]);
  72663. this._extensions = _
  72664. }
  72665. b ? (this.delayLoadState = 4,
  72666. this._delayedOnLoad = s,
  72667. this._delayedOnError = d) : this._loadTexture(s, d)
  72668. }
  72669. ,
  72670. e.prototype.delayLoad = function(i) {
  72671. this.delayLoadState === 4 && (i && (this._forcedExtension = i),
  72672. this.delayLoadState = 1,
  72673. this._loadTexture(this._delayedOnLoad, this._delayedOnError))
  72674. }
  72675. ,
  72676. e.prototype.getReflectionTextureMatrix = function() {
  72677. return this._textureMatrix
  72678. }
  72679. ,
  72680. e.prototype.setReflectionTextureMatrix = function(i) {
  72681. var o = this, s;
  72682. i.updateFlag !== this._textureMatrix.updateFlag && (i.isIdentity() !== this._textureMatrix.isIdentity() && ((s = this.getScene()) === null || s === void 0 || s.markAllMaterialsAsDirty(1, function(c) {
  72683. return c.getActiveTextures().indexOf(o) !== -1
  72684. })),
  72685. this._textureMatrix = i)
  72686. }
  72687. ,
  72688. e.prototype._loadTexture = function(i, o) {
  72689. var s = this, c;
  72690. i === void 0 && (i = null),
  72691. o === void 0 && (o = null);
  72692. var d = this.getScene()
  72693. , _ = this._texture;
  72694. this._texture = this._getFromCache(this.url, this._noMipmap, void 0, void 0, this._useSRGBBuffer);
  72695. var b = function() {
  72696. var j;
  72697. s.onLoadObservable.notifyObservers(s),
  72698. _ && (_.dispose(),
  72699. (j = s.getScene()) === null || j === void 0 || j.markAllMaterialsAsDirty(1)),
  72700. i && i()
  72701. }
  72702. , k = function(j, $) {
  72703. s._loadingError = !0,
  72704. s._errorObject = {
  72705. message: j,
  72706. exception: $
  72707. },
  72708. o && o(j, $),
  72709. Texture.OnTextureLoadErrorObservable.notifyObservers(s)
  72710. };
  72711. this._texture ? this._texture.isReady ? Tools.SetImmediate(function() {
  72712. return b()
  72713. }) : this._texture.onLoadedObservable.add(function() {
  72714. return b()
  72715. }) : (this._prefiltered ? this._texture = this._getEngine().createPrefilteredCubeTexture(this.url, d, this._lodScale, this._lodOffset, i, k, this._format, this._forcedExtension, this._createPolynomials) : this._texture = this._getEngine().createCubeTexture(this.url, d, this._files, this._noMipmap, i, k, this._format, this._forcedExtension, !1, this._lodScale, this._lodOffset, null, this._loaderOptions, !!this._useSRGBBuffer),
  72716. (c = this._texture) === null || c === void 0 || c.onLoadedObservable.add(function() {
  72717. return s.onLoadObservable.notifyObservers(s)
  72718. }))
  72719. }
  72720. ,
  72721. e.Parse = function(i, o, s) {
  72722. var c = SerializationHelper.Parse(function() {
  72723. var k = !1;
  72724. return i.prefiltered && (k = i.prefiltered),
  72725. new e(s + i.name,o,i.extensions,!1,i.files || null,null,null,void 0,k,i.forcedExtension)
  72726. }, i, o);
  72727. if (i.boundingBoxPosition && (c.boundingBoxPosition = Vector3.FromArray(i.boundingBoxPosition)),
  72728. i.boundingBoxSize && (c.boundingBoxSize = Vector3.FromArray(i.boundingBoxSize)),
  72729. i.animations)
  72730. for (var d = 0; d < i.animations.length; d++) {
  72731. var _ = i.animations[d]
  72732. , b = GetClass("BABYLON.Animation");
  72733. b && c.animations.push(b.Parse(_))
  72734. }
  72735. return c
  72736. }
  72737. ,
  72738. e.prototype.clone = function() {
  72739. var i = this
  72740. , o = 0
  72741. , s = SerializationHelper.Clone(function() {
  72742. var c = new e(i.url,i.getScene() || i._getEngine(),i._extensions,i._noMipmap,i._files);
  72743. return o = c.uniqueId,
  72744. c
  72745. }, this);
  72746. return s.uniqueId = o,
  72747. s
  72748. }
  72749. ,
  72750. __decorate([serialize()], e.prototype, "url", void 0),
  72751. __decorate([serialize("rotationY")], e.prototype, "rotationY", null),
  72752. __decorate([serialize("files")], e.prototype, "_files", void 0),
  72753. __decorate([serialize("forcedExtension")], e.prototype, "_forcedExtension", void 0),
  72754. __decorate([serialize("extensions")], e.prototype, "_extensions", void 0),
  72755. __decorate([serializeAsMatrix("textureMatrix")], e.prototype, "_textureMatrix", void 0),
  72756. e
  72757. }(BaseTexture);
  72758. Texture._CubeTextureParser = CubeTexture.Parse;
  72759. RegisterClass("BABYLON.CubeTexture", CubeTexture);
  72760. var DynamicTexture = function(a) {
  72761. __extends(e, a);
  72762. function e(i, o, s, c, d, _, b) {
  72763. s === void 0 && (s = null),
  72764. c === void 0 && (c = !1),
  72765. d === void 0 && (d = 3),
  72766. _ === void 0 && (_ = 5);
  72767. var k = a.call(this, null, s, !c, b, d, void 0, void 0, void 0, void 0, _) || this;
  72768. k.name = i,
  72769. k.wrapU = Texture.CLAMP_ADDRESSMODE,
  72770. k.wrapV = Texture.CLAMP_ADDRESSMODE,
  72771. k._generateMipMaps = c;
  72772. var j = k._getEngine();
  72773. if (!j)
  72774. return k;
  72775. o.getContext ? (k._canvas = o,
  72776. k._texture = j.createDynamicTexture(o.width, o.height, c, d)) : (k._canvas = j.createCanvas(1, 1),
  72777. o.width || o.width === 0 ? k._texture = j.createDynamicTexture(o.width, o.height, c, d) : k._texture = j.createDynamicTexture(o, o, c, d));
  72778. var $ = k.getSize();
  72779. return k._canvas.width !== $.width && (k._canvas.width = $.width),
  72780. k._canvas.height !== $.height && (k._canvas.height = $.height),
  72781. k._context = k._canvas.getContext("2d"),
  72782. k
  72783. }
  72784. return e.prototype.getClassName = function() {
  72785. return "DynamicTexture"
  72786. }
  72787. ,
  72788. Object.defineProperty(e.prototype, "canRescale", {
  72789. get: function() {
  72790. return !0
  72791. },
  72792. enumerable: !1,
  72793. configurable: !0
  72794. }),
  72795. e.prototype._recreate = function(i) {
  72796. this._canvas.width = i.width,
  72797. this._canvas.height = i.height,
  72798. this.releaseInternalTexture(),
  72799. this._texture = this._getEngine().createDynamicTexture(i.width, i.height, this._generateMipMaps, this.samplingMode)
  72800. }
  72801. ,
  72802. e.prototype.scale = function(i) {
  72803. var o = this.getSize();
  72804. o.width *= i,
  72805. o.height *= i,
  72806. this._recreate(o)
  72807. }
  72808. ,
  72809. e.prototype.scaleTo = function(i, o) {
  72810. var s = this.getSize();
  72811. s.width = i,
  72812. s.height = o,
  72813. this._recreate(s)
  72814. }
  72815. ,
  72816. e.prototype.getContext = function() {
  72817. return this._context
  72818. }
  72819. ,
  72820. e.prototype.clear = function() {
  72821. var i = this.getSize();
  72822. this._context.fillRect(0, 0, i.width, i.height)
  72823. }
  72824. ,
  72825. e.prototype.update = function(i, o, s) {
  72826. o === void 0 && (o = !1),
  72827. s === void 0 && (s = !1),
  72828. this._getEngine().updateDynamicTexture(this._texture, this._canvas, i === void 0 ? !0 : i, o, this._format || void 0, void 0, s)
  72829. }
  72830. ,
  72831. e.prototype.drawText = function(i, o, s, c, d, _, b, k) {
  72832. k === void 0 && (k = !0);
  72833. var j = this.getSize();
  72834. if (_ && (this._context.fillStyle = _,
  72835. this._context.fillRect(0, 0, j.width, j.height)),
  72836. this._context.font = c,
  72837. o == null) {
  72838. var $ = this._context.measureText(i);
  72839. o = (j.width - $.width) / 2
  72840. }
  72841. if (s == null) {
  72842. var _e = parseInt(c.replace(/\D/g, ""));
  72843. s = j.height / 2 + _e / 3.65
  72844. }
  72845. this._context.fillStyle = d || "",
  72846. this._context.fillText(i, o, s),
  72847. k && this.update(b)
  72848. }
  72849. ,
  72850. e.prototype.clone = function() {
  72851. var i = this.getScene();
  72852. if (!i)
  72853. return this;
  72854. var o = this.getSize()
  72855. , s = new e(this.name,o,i,this._generateMipMaps);
  72856. return s.hasAlpha = this.hasAlpha,
  72857. s.level = this.level,
  72858. s.wrapU = this.wrapU,
  72859. s.wrapV = this.wrapV,
  72860. s
  72861. }
  72862. ,
  72863. e.prototype.serialize = function() {
  72864. var i = this.getScene();
  72865. i && !i.isReady() && Logger$2.Warn("The scene must be ready before serializing the dynamic texture");
  72866. var o = a.prototype.serialize.call(this);
  72867. return this._IsCanvasElement(this._canvas) && (o.base64String = this._canvas.toDataURL()),
  72868. o.invertY = this._invertY,
  72869. o.samplingMode = this.samplingMode,
  72870. o
  72871. }
  72872. ,
  72873. e.prototype._IsCanvasElement = function(i) {
  72874. return i.toDataURL !== void 0
  72875. }
  72876. ,
  72877. e.prototype._rebuild = function() {
  72878. this.update()
  72879. }
  72880. ,
  72881. e
  72882. }(Texture)
  72883. , VideoTexture = function(a) {
  72884. __extends(e, a);
  72885. function e(i, o, s, c, d, _, b, k) {
  72886. c === void 0 && (c = !1),
  72887. d === void 0 && (d = !1),
  72888. _ === void 0 && (_ = Texture.TRILINEAR_SAMPLINGMODE);
  72889. var j = a.call(this, null, s, !c, d) || this;
  72890. j._onUserActionRequestedObservable = null,
  72891. j._stillImageCaptured = !1,
  72892. j._displayingPosterTexture = !1,
  72893. j._frameId = -1,
  72894. j._currentSrc = null,
  72895. j._errorFound = !1,
  72896. j._createInternalTexture = function() {
  72897. if (j._texture != null)
  72898. if (j._displayingPosterTexture)
  72899. j._texture.dispose(),
  72900. j._displayingPosterTexture = !1;
  72901. else
  72902. return;
  72903. if (!j._getEngine().needPOTTextures || Tools.IsExponentOfTwo(j.video.videoWidth) && Tools.IsExponentOfTwo(j.video.videoHeight) ? (j.wrapU = Texture.WRAP_ADDRESSMODE,
  72904. j.wrapV = Texture.WRAP_ADDRESSMODE) : (j.wrapU = Texture.CLAMP_ADDRESSMODE,
  72905. j.wrapV = Texture.CLAMP_ADDRESSMODE,
  72906. j._generateMipMaps = !1),
  72907. j._texture = j._getEngine().createDynamicTexture(j.video.videoWidth, j.video.videoHeight, j._generateMipMaps, j.samplingMode),
  72908. !j.video.autoplay && !j._settings.poster) {
  72909. var _e = j.video.onplaying
  72910. , et = j.video.muted;
  72911. j.video.muted = !0,
  72912. j.video.onplaying = function() {
  72913. j.video.muted = et,
  72914. j.video.onplaying = _e,
  72915. j._updateInternalTexture(),
  72916. j._errorFound || j.video.pause(),
  72917. j.onLoadObservable.hasObservers() && j.onLoadObservable.notifyObservers(j)
  72918. }
  72919. ,
  72920. j._handlePlay()
  72921. } else
  72922. j._updateInternalTexture(),
  72923. j.onLoadObservable.hasObservers() && j.onLoadObservable.notifyObservers(j)
  72924. }
  72925. ,
  72926. j.reset = function() {
  72927. j._texture != null && (j._displayingPosterTexture || (j._texture.dispose(),
  72928. j._texture = null))
  72929. }
  72930. ,
  72931. j._updateInternalTexture = function() {
  72932. if (j._texture != null && !(j.video.readyState < j.video.HAVE_CURRENT_DATA) && !j._displayingPosterTexture) {
  72933. var _e = j.getScene().getFrameId();
  72934. j._frameId !== _e && (j._frameId = _e,
  72935. j._getEngine().updateVideoTexture(j._texture, j.video, j._invertY))
  72936. }
  72937. }
  72938. ,
  72939. b || (b = {
  72940. autoPlay: !0,
  72941. loop: !0,
  72942. autoUpdateTexture: !0
  72943. }),
  72944. j._onError = k,
  72945. j._generateMipMaps = c,
  72946. j._initialSamplingMode = _,
  72947. j.autoUpdateTexture = b.autoUpdateTexture,
  72948. j._currentSrc = o,
  72949. j.name = i || j._getName(o),
  72950. j.video = j._getVideo(o),
  72951. j._settings = b,
  72952. b.poster && (j.video.poster = b.poster),
  72953. b.autoPlay !== void 0 && (j.video.autoplay = b.autoPlay),
  72954. b.loop !== void 0 && (j.video.loop = b.loop),
  72955. b.muted !== void 0 && (j.video.muted = b.muted),
  72956. j.video.setAttribute("playsinline", ""),
  72957. j.video.addEventListener("paused", j._updateInternalTexture),
  72958. j.video.addEventListener("seeked", j._updateInternalTexture),
  72959. j.video.addEventListener("emptied", j.reset),
  72960. j._createInternalTextureOnEvent = b.poster && !b.autoPlay ? "play" : "canplay",
  72961. j.video.addEventListener(j._createInternalTextureOnEvent, j._createInternalTexture),
  72962. b.autoPlay && j._handlePlay();
  72963. var $ = j.video.readyState >= j.video.HAVE_CURRENT_DATA;
  72964. return b.poster && (!b.autoPlay || !$) ? (j._texture = j._getEngine().createTexture(b.poster, !1, !j.invertY, s),
  72965. j._displayingPosterTexture = !0) : $ && j._createInternalTexture(),
  72966. j
  72967. }
  72968. return Object.defineProperty(e.prototype, "onUserActionRequestedObservable", {
  72969. get: function() {
  72970. return this._onUserActionRequestedObservable || (this._onUserActionRequestedObservable = new Observable),
  72971. this._onUserActionRequestedObservable
  72972. },
  72973. enumerable: !1,
  72974. configurable: !0
  72975. }),
  72976. e.prototype._processError = function(i) {
  72977. this._errorFound = !0,
  72978. this._onError ? this._onError(i == null ? void 0 : i.message) : Logger$2.Error(i == null ? void 0 : i.message)
  72979. }
  72980. ,
  72981. e.prototype._handlePlay = function() {
  72982. var i = this;
  72983. this._errorFound = !1,
  72984. this.video.play().catch(function(o) {
  72985. if ((o == null ? void 0 : o.name) === "NotAllowedError") {
  72986. if (i._onUserActionRequestedObservable && i._onUserActionRequestedObservable.hasObservers()) {
  72987. i._onUserActionRequestedObservable.notifyObservers(i);
  72988. return
  72989. } else if (!i.video.muted) {
  72990. Logger$2.Warn("Unable to autoplay a video with sound. Trying again with muted turned true"),
  72991. i.video.muted = !0,
  72992. i._errorFound = !1,
  72993. i.video.play().catch(function(s) {
  72994. i._processError(s)
  72995. });
  72996. return
  72997. }
  72998. }
  72999. i._processError(o)
  73000. })
  73001. }
  73002. ,
  73003. e.prototype.getClassName = function() {
  73004. return "VideoTexture"
  73005. }
  73006. ,
  73007. e.prototype._getName = function(i) {
  73008. return i instanceof HTMLVideoElement ? i.currentSrc : typeof i == "object" ? i.toString() : i
  73009. }
  73010. ,
  73011. e.prototype._getVideo = function(i) {
  73012. if (i.isNative)
  73013. return i;
  73014. if (i instanceof HTMLVideoElement)
  73015. return Tools.SetCorsBehavior(i.currentSrc, i),
  73016. i;
  73017. var o = document.createElement("video");
  73018. return typeof i == "string" ? (Tools.SetCorsBehavior(i, o),
  73019. o.src = i) : (Tools.SetCorsBehavior(i[0], o),
  73020. i.forEach(function(s) {
  73021. var c = document.createElement("source");
  73022. c.src = s,
  73023. o.appendChild(c)
  73024. })),
  73025. o
  73026. }
  73027. ,
  73028. e.prototype._rebuild = function() {
  73029. this.update()
  73030. }
  73031. ,
  73032. e.prototype.update = function() {
  73033. !this.autoUpdateTexture || this.updateTexture(!0)
  73034. }
  73035. ,
  73036. e.prototype.updateTexture = function(i) {
  73037. !i || this.video.paused && this._stillImageCaptured || (this._stillImageCaptured = !0,
  73038. this._updateInternalTexture())
  73039. }
  73040. ,
  73041. e.prototype.updateURL = function(i) {
  73042. this.video.src = i,
  73043. this._currentSrc = i
  73044. }
  73045. ,
  73046. e.prototype.clone = function() {
  73047. return new e(this.name,this._currentSrc,this.getScene(),this._generateMipMaps,this.invertY,this.samplingMode,this._settings)
  73048. }
  73049. ,
  73050. e.prototype.dispose = function() {
  73051. a.prototype.dispose.call(this),
  73052. this._currentSrc = null,
  73053. this._onUserActionRequestedObservable && (this._onUserActionRequestedObservable.clear(),
  73054. this._onUserActionRequestedObservable = null),
  73055. this.video.removeEventListener(this._createInternalTextureOnEvent, this._createInternalTexture),
  73056. this.video.removeEventListener("paused", this._updateInternalTexture),
  73057. this.video.removeEventListener("seeked", this._updateInternalTexture),
  73058. this.video.removeEventListener("emptied", this.reset),
  73059. this.video.pause()
  73060. }
  73061. ,
  73062. e.CreateFromStreamAsync = function(i, o, s, c) {
  73063. c === void 0 && (c = !0);
  73064. var d = i.getEngine().createVideoElement(s);
  73065. return i.getEngine()._badOS && (document.body.appendChild(d),
  73066. d.style.transform = "scale(0.0001, 0.0001)",
  73067. d.style.opacity = "0",
  73068. d.style.position = "fixed",
  73069. d.style.bottom = "0px",
  73070. d.style.right = "0px"),
  73071. d.setAttribute("autoplay", ""),
  73072. d.setAttribute("muted", "true"),
  73073. d.setAttribute("playsinline", ""),
  73074. d.muted = !0,
  73075. d.mozSrcObject !== void 0 ? d.mozSrcObject = o : typeof d.srcObject == "object" ? d.srcObject = o : (window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL,
  73076. d.src = window.URL && window.URL.createObjectURL(o)),
  73077. new Promise(function(_) {
  73078. var b = function() {
  73079. _(new e("video",d,i,!0,c)),
  73080. d.removeEventListener("playing", b)
  73081. };
  73082. d.addEventListener("playing", b),
  73083. d.play()
  73084. }
  73085. )
  73086. }
  73087. ,
  73088. e.CreateFromWebCamAsync = function(i, o, s, c) {
  73089. var d = this;
  73090. s === void 0 && (s = !1),
  73091. c === void 0 && (c = !0);
  73092. var _;
  73093. if (o && o.deviceId && (_ = {
  73094. exact: o.deviceId
  73095. }),
  73096. navigator.mediaDevices)
  73097. return navigator.mediaDevices.getUserMedia({
  73098. video: o,
  73099. audio: s
  73100. }).then(function(k) {
  73101. return d.CreateFromStreamAsync(i, k, o, c)
  73102. });
  73103. var b = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
  73104. return b && b({
  73105. video: {
  73106. deviceId: _,
  73107. width: {
  73108. min: o && o.minWidth || 256,
  73109. max: o && o.maxWidth || 640
  73110. },
  73111. height: {
  73112. min: o && o.minHeight || 256,
  73113. max: o && o.maxHeight || 480
  73114. }
  73115. },
  73116. audio: s
  73117. }, function(k) {
  73118. return d.CreateFromStreamAsync(i, k, o, c)
  73119. }, function(k) {
  73120. Logger$2.Error(k.name)
  73121. }),
  73122. Promise.reject("No support for userMedia on this device")
  73123. }
  73124. ,
  73125. e.CreateFromWebCam = function(i, o, s, c, d) {
  73126. c === void 0 && (c = !1),
  73127. d === void 0 && (d = !0),
  73128. this.CreateFromWebCamAsync(i, s, c, d).then(function(_) {
  73129. o && o(_)
  73130. }).catch(function(_) {
  73131. Logger$2.Error(_.name)
  73132. })
  73133. }
  73134. ,
  73135. e
  73136. }(Texture)
  73137. , Action = function() {
  73138. function a(e, i) {
  73139. this.triggerOptions = e,
  73140. this.onBeforeExecuteObservable = new Observable,
  73141. e.parameter ? (this.trigger = e.trigger,
  73142. this._triggerParameter = e.parameter) : e.trigger ? this.trigger = e.trigger : this.trigger = e,
  73143. this._nextActiveAction = this,
  73144. this._condition = i
  73145. }
  73146. return a.prototype._prepare = function() {}
  73147. ,
  73148. a.prototype.getTriggerParameter = function() {
  73149. return this._triggerParameter
  73150. }
  73151. ,
  73152. a.prototype.setTriggerParameter = function(e) {
  73153. this._triggerParameter = e
  73154. }
  73155. ,
  73156. a.prototype._evaluateConditionForCurrentFrame = function() {
  73157. var e = this._condition;
  73158. if (!e)
  73159. return !0;
  73160. var i = this._actionManager.getScene().getRenderId();
  73161. return e._evaluationId !== i && (e._evaluationId = i,
  73162. e._currentResult = e.isValid()),
  73163. e._currentResult
  73164. }
  73165. ,
  73166. a.prototype._executeCurrent = function(e) {
  73167. var i = this._evaluateConditionForCurrentFrame();
  73168. !i || (this.onBeforeExecuteObservable.notifyObservers(this),
  73169. this._nextActiveAction.execute(e),
  73170. this.skipToNextActiveAction())
  73171. }
  73172. ,
  73173. a.prototype.execute = function(e) {}
  73174. ,
  73175. a.prototype.skipToNextActiveAction = function() {
  73176. this._nextActiveAction._child ? (this._nextActiveAction._child._actionManager || (this._nextActiveAction._child._actionManager = this._actionManager),
  73177. this._nextActiveAction = this._nextActiveAction._child) : this._nextActiveAction = this
  73178. }
  73179. ,
  73180. a.prototype.then = function(e) {
  73181. return this._child = e,
  73182. e._actionManager = this._actionManager,
  73183. e._prepare(),
  73184. e
  73185. }
  73186. ,
  73187. a.prototype._getProperty = function(e) {
  73188. return this._actionManager._getProperty(e)
  73189. }
  73190. ,
  73191. a.prototype._getEffectiveTarget = function(e, i) {
  73192. return this._actionManager._getEffectiveTarget(e, i)
  73193. }
  73194. ,
  73195. a.prototype.serialize = function(e) {}
  73196. ,
  73197. a.prototype._serialize = function(e, i) {
  73198. var o = {
  73199. type: 1,
  73200. children: [],
  73201. name: e.name,
  73202. properties: e.properties || []
  73203. };
  73204. if (this._child && this._child.serialize(o),
  73205. this._condition) {
  73206. var s = this._condition.serialize();
  73207. return s.children.push(o),
  73208. i && i.children.push(s),
  73209. s
  73210. }
  73211. return i && i.children.push(o),
  73212. o
  73213. }
  73214. ,
  73215. a._SerializeValueAsString = function(e) {
  73216. return typeof e == "number" ? e.toString() : typeof e == "boolean" ? e ? "true" : "false" : e instanceof Vector2 ? e.x + ", " + e.y : e instanceof Vector3 ? e.x + ", " + e.y + ", " + e.z : e instanceof Color3 ? e.r + ", " + e.g + ", " + e.b : e instanceof Color4 ? e.r + ", " + e.g + ", " + e.b + ", " + e.a : e
  73217. }
  73218. ,
  73219. a._GetTargetProperty = function(e) {
  73220. return {
  73221. name: "target",
  73222. targetType: e._isMesh ? "MeshProperties" : e._isLight ? "LightProperties" : e._isCamera ? "CameraProperties" : "SceneProperties",
  73223. value: e._isScene ? "Scene" : e.name
  73224. }
  73225. }
  73226. ,
  73227. a
  73228. }();
  73229. RegisterClass("BABYLON.Action", Action);
  73230. var Condition = function() {
  73231. function a(e) {
  73232. this._actionManager = e
  73233. }
  73234. return a.prototype.isValid = function() {
  73235. return !0
  73236. }
  73237. ,
  73238. a.prototype._getProperty = function(e) {
  73239. return this._actionManager._getProperty(e)
  73240. }
  73241. ,
  73242. a.prototype._getEffectiveTarget = function(e, i) {
  73243. return this._actionManager._getEffectiveTarget(e, i)
  73244. }
  73245. ,
  73246. a.prototype.serialize = function() {}
  73247. ,
  73248. a.prototype._serialize = function(e) {
  73249. return {
  73250. type: 2,
  73251. children: [],
  73252. name: e.name,
  73253. properties: e.properties
  73254. }
  73255. }
  73256. ,
  73257. a
  73258. }()
  73259. , ValueCondition = function(a) {
  73260. __extends(e, a);
  73261. function e(i, o, s, c, d) {
  73262. d === void 0 && (d = e.IsEqual);
  73263. var _ = a.call(this, i) || this;
  73264. return _.propertyPath = s,
  73265. _.value = c,
  73266. _.operator = d,
  73267. _._target = o,
  73268. _._effectiveTarget = _._getEffectiveTarget(o, _.propertyPath),
  73269. _._property = _._getProperty(_.propertyPath),
  73270. _
  73271. }
  73272. return Object.defineProperty(e, "IsEqual", {
  73273. get: function() {
  73274. return e._IsEqual
  73275. },
  73276. enumerable: !1,
  73277. configurable: !0
  73278. }),
  73279. Object.defineProperty(e, "IsDifferent", {
  73280. get: function() {
  73281. return e._IsDifferent
  73282. },
  73283. enumerable: !1,
  73284. configurable: !0
  73285. }),
  73286. Object.defineProperty(e, "IsGreater", {
  73287. get: function() {
  73288. return e._IsGreater
  73289. },
  73290. enumerable: !1,
  73291. configurable: !0
  73292. }),
  73293. Object.defineProperty(e, "IsLesser", {
  73294. get: function() {
  73295. return e._IsLesser
  73296. },
  73297. enumerable: !1,
  73298. configurable: !0
  73299. }),
  73300. e.prototype.isValid = function() {
  73301. switch (this.operator) {
  73302. case e.IsGreater:
  73303. return this._effectiveTarget[this._property] > this.value;
  73304. case e.IsLesser:
  73305. return this._effectiveTarget[this._property] < this.value;
  73306. case e.IsEqual:
  73307. case e.IsDifferent:
  73308. var i;
  73309. return this.value.equals ? i = this.value.equals(this._effectiveTarget[this._property]) : i = this.value === this._effectiveTarget[this._property],
  73310. this.operator === e.IsEqual ? i : !i
  73311. }
  73312. return !1
  73313. }
  73314. ,
  73315. e.prototype.serialize = function() {
  73316. return this._serialize({
  73317. name: "ValueCondition",
  73318. properties: [Action._GetTargetProperty(this._target), {
  73319. name: "propertyPath",
  73320. value: this.propertyPath
  73321. }, {
  73322. name: "value",
  73323. value: Action._SerializeValueAsString(this.value)
  73324. }, {
  73325. name: "operator",
  73326. value: e.GetOperatorName(this.operator)
  73327. }]
  73328. })
  73329. }
  73330. ,
  73331. e.GetOperatorName = function(i) {
  73332. switch (i) {
  73333. case e._IsEqual:
  73334. return "IsEqual";
  73335. case e._IsDifferent:
  73336. return "IsDifferent";
  73337. case e._IsGreater:
  73338. return "IsGreater";
  73339. case e._IsLesser:
  73340. return "IsLesser";
  73341. default:
  73342. return ""
  73343. }
  73344. }
  73345. ,
  73346. e._IsEqual = 0,
  73347. e._IsDifferent = 1,
  73348. e._IsGreater = 2,
  73349. e._IsLesser = 3,
  73350. e
  73351. }(Condition)
  73352. , PredicateCondition = function(a) {
  73353. __extends(e, a);
  73354. function e(i, o) {
  73355. var s = a.call(this, i) || this;
  73356. return s.predicate = o,
  73357. s
  73358. }
  73359. return e.prototype.isValid = function() {
  73360. return this.predicate()
  73361. }
  73362. ,
  73363. e
  73364. }(Condition)
  73365. , StateCondition = function(a) {
  73366. __extends(e, a);
  73367. function e(i, o, s) {
  73368. var c = a.call(this, i) || this;
  73369. return c.value = s,
  73370. c._target = o,
  73371. c
  73372. }
  73373. return e.prototype.isValid = function() {
  73374. return this._target.state === this.value
  73375. }
  73376. ,
  73377. e.prototype.serialize = function() {
  73378. return this._serialize({
  73379. name: "StateCondition",
  73380. properties: [Action._GetTargetProperty(this._target), {
  73381. name: "value",
  73382. value: this.value
  73383. }]
  73384. })
  73385. }
  73386. ,
  73387. e
  73388. }(Condition);
  73389. RegisterClass("BABYLON.ValueCondition", ValueCondition);
  73390. RegisterClass("BABYLON.PredicateCondition", PredicateCondition);
  73391. RegisterClass("BABYLON.StateCondition", StateCondition);
  73392. (function(a) {
  73393. __extends(e, a);
  73394. function e(i, o, s, c) {
  73395. var d = a.call(this, i, c) || this;
  73396. return d.propertyPath = s,
  73397. d._target = d._effectiveTarget = o,
  73398. d
  73399. }
  73400. return e.prototype._prepare = function() {
  73401. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath),
  73402. this._property = this._getProperty(this.propertyPath)
  73403. }
  73404. ,
  73405. e.prototype.execute = function() {
  73406. this._effectiveTarget[this._property] = !this._effectiveTarget[this._property]
  73407. }
  73408. ,
  73409. e.prototype.serialize = function(i) {
  73410. return a.prototype._serialize.call(this, {
  73411. name: "SwitchBooleanAction",
  73412. properties: [Action._GetTargetProperty(this._target), {
  73413. name: "propertyPath",
  73414. value: this.propertyPath
  73415. }]
  73416. }, i)
  73417. }
  73418. ,
  73419. e
  73420. }
  73421. )(Action);
  73422. var SetStateAction = function(a) {
  73423. __extends(e, a);
  73424. function e(i, o, s, c) {
  73425. var d = a.call(this, i, c) || this;
  73426. return d.value = s,
  73427. d._target = o,
  73428. d
  73429. }
  73430. return e.prototype.execute = function() {
  73431. this._target.state = this.value
  73432. }
  73433. ,
  73434. e.prototype.serialize = function(i) {
  73435. return a.prototype._serialize.call(this, {
  73436. name: "SetStateAction",
  73437. properties: [Action._GetTargetProperty(this._target), {
  73438. name: "value",
  73439. value: this.value
  73440. }]
  73441. }, i)
  73442. }
  73443. ,
  73444. e
  73445. }(Action)
  73446. , SetValueAction = function(a) {
  73447. __extends(e, a);
  73448. function e(i, o, s, c, d) {
  73449. var _ = a.call(this, i, d) || this;
  73450. return _.propertyPath = s,
  73451. _.value = c,
  73452. _._target = _._effectiveTarget = o,
  73453. _
  73454. }
  73455. return e.prototype._prepare = function() {
  73456. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath),
  73457. this._property = this._getProperty(this.propertyPath)
  73458. }
  73459. ,
  73460. e.prototype.execute = function() {
  73461. this._effectiveTarget[this._property] = this.value,
  73462. this._target.markAsDirty && this._target.markAsDirty(this._property)
  73463. }
  73464. ,
  73465. e.prototype.serialize = function(i) {
  73466. return a.prototype._serialize.call(this, {
  73467. name: "SetValueAction",
  73468. properties: [Action._GetTargetProperty(this._target), {
  73469. name: "propertyPath",
  73470. value: this.propertyPath
  73471. }, {
  73472. name: "value",
  73473. value: Action._SerializeValueAsString(this.value)
  73474. }]
  73475. }, i)
  73476. }
  73477. ,
  73478. e
  73479. }(Action)
  73480. , IncrementValueAction = function(a) {
  73481. __extends(e, a);
  73482. function e(i, o, s, c, d) {
  73483. var _ = a.call(this, i, d) || this;
  73484. return _.propertyPath = s,
  73485. _.value = c,
  73486. _._target = _._effectiveTarget = o,
  73487. _
  73488. }
  73489. return e.prototype._prepare = function() {
  73490. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath),
  73491. this._property = this._getProperty(this.propertyPath),
  73492. typeof this._effectiveTarget[this._property] != "number" && Logger$2.Warn("Warning: IncrementValueAction can only be used with number values")
  73493. }
  73494. ,
  73495. e.prototype.execute = function() {
  73496. this._effectiveTarget[this._property] += this.value,
  73497. this._target.markAsDirty && this._target.markAsDirty(this._property)
  73498. }
  73499. ,
  73500. e.prototype.serialize = function(i) {
  73501. return a.prototype._serialize.call(this, {
  73502. name: "IncrementValueAction",
  73503. properties: [Action._GetTargetProperty(this._target), {
  73504. name: "propertyPath",
  73505. value: this.propertyPath
  73506. }, {
  73507. name: "value",
  73508. value: Action._SerializeValueAsString(this.value)
  73509. }]
  73510. }, i)
  73511. }
  73512. ,
  73513. e
  73514. }(Action)
  73515. , PlayAnimationAction = function(a) {
  73516. __extends(e, a);
  73517. function e(i, o, s, c, d, _) {
  73518. var b = a.call(this, i, _) || this;
  73519. return b.from = s,
  73520. b.to = c,
  73521. b.loop = d,
  73522. b._target = o,
  73523. b
  73524. }
  73525. return e.prototype._prepare = function() {}
  73526. ,
  73527. e.prototype.execute = function() {
  73528. var i = this._actionManager.getScene();
  73529. i.beginAnimation(this._target, this.from, this.to, this.loop)
  73530. }
  73531. ,
  73532. e.prototype.serialize = function(i) {
  73533. return a.prototype._serialize.call(this, {
  73534. name: "PlayAnimationAction",
  73535. properties: [Action._GetTargetProperty(this._target), {
  73536. name: "from",
  73537. value: String(this.from)
  73538. }, {
  73539. name: "to",
  73540. value: String(this.to)
  73541. }, {
  73542. name: "loop",
  73543. value: Action._SerializeValueAsString(this.loop) || !1
  73544. }]
  73545. }, i)
  73546. }
  73547. ,
  73548. e
  73549. }(Action)
  73550. , StopAnimationAction = function(a) {
  73551. __extends(e, a);
  73552. function e(i, o, s) {
  73553. var c = a.call(this, i, s) || this;
  73554. return c._target = o,
  73555. c
  73556. }
  73557. return e.prototype._prepare = function() {}
  73558. ,
  73559. e.prototype.execute = function() {
  73560. var i = this._actionManager.getScene();
  73561. i.stopAnimation(this._target)
  73562. }
  73563. ,
  73564. e.prototype.serialize = function(i) {
  73565. return a.prototype._serialize.call(this, {
  73566. name: "StopAnimationAction",
  73567. properties: [Action._GetTargetProperty(this._target)]
  73568. }, i)
  73569. }
  73570. ,
  73571. e
  73572. }(Action)
  73573. , DoNothingAction = function(a) {
  73574. __extends(e, a);
  73575. function e(i, o) {
  73576. return i === void 0 && (i = 0),
  73577. a.call(this, i, o) || this
  73578. }
  73579. return e.prototype.execute = function() {}
  73580. ,
  73581. e.prototype.serialize = function(i) {
  73582. return a.prototype._serialize.call(this, {
  73583. name: "DoNothingAction",
  73584. properties: []
  73585. }, i)
  73586. }
  73587. ,
  73588. e
  73589. }(Action);
  73590. (function(a) {
  73591. __extends(e, a);
  73592. function e(i, o, s, c) {
  73593. c === void 0 && (c = !0);
  73594. var d = a.call(this, i, s) || this;
  73595. return d.children = o,
  73596. d.enableChildrenConditions = c,
  73597. d
  73598. }
  73599. return e.prototype._prepare = function() {
  73600. for (var i = 0; i < this.children.length; i++)
  73601. this.children[i]._actionManager = this._actionManager,
  73602. this.children[i]._prepare()
  73603. }
  73604. ,
  73605. e.prototype.execute = function(i) {
  73606. for (var o = 0, s = this.children; o < s.length; o++) {
  73607. var c = s[o];
  73608. (!this.enableChildrenConditions || c._evaluateConditionForCurrentFrame()) && c.execute(i)
  73609. }
  73610. }
  73611. ,
  73612. e.prototype.serialize = function(i) {
  73613. for (var o = a.prototype._serialize.call(this, {
  73614. name: "CombineAction",
  73615. properties: [],
  73616. combine: []
  73617. }, i), s = 0; s < this.children.length; s++)
  73618. o.combine.push(this.children[s].serialize(null));
  73619. return o
  73620. }
  73621. ,
  73622. e
  73623. }
  73624. )(Action);
  73625. var ExecuteCodeAction = function(a) {
  73626. __extends(e, a);
  73627. function e(i, o, s) {
  73628. var c = a.call(this, i, s) || this;
  73629. return c.func = o,
  73630. c
  73631. }
  73632. return e.prototype.execute = function(i) {
  73633. this.func(i)
  73634. }
  73635. ,
  73636. e
  73637. }(Action)
  73638. , SetParentAction = function(a) {
  73639. __extends(e, a);
  73640. function e(i, o, s, c) {
  73641. var d = a.call(this, i, c) || this;
  73642. return d._target = o,
  73643. d._parent = s,
  73644. d
  73645. }
  73646. return e.prototype._prepare = function() {}
  73647. ,
  73648. e.prototype.execute = function() {
  73649. if (this._target.parent !== this._parent) {
  73650. var i = this._parent.getWorldMatrix().clone();
  73651. i.invert(),
  73652. this._target.position = Vector3.TransformCoordinates(this._target.position, i),
  73653. this._target.parent = this._parent
  73654. }
  73655. }
  73656. ,
  73657. e.prototype.serialize = function(i) {
  73658. return a.prototype._serialize.call(this, {
  73659. name: "SetParentAction",
  73660. properties: [Action._GetTargetProperty(this._target), Action._GetTargetProperty(this._parent)]
  73661. }, i)
  73662. }
  73663. ,
  73664. e
  73665. }(Action);
  73666. RegisterClass("BABYLON.SetParentAction", SetParentAction);
  73667. RegisterClass("BABYLON.ExecuteCodeAction", ExecuteCodeAction);
  73668. RegisterClass("BABYLON.DoNothingAction", DoNothingAction);
  73669. RegisterClass("BABYLON.StopAnimationAction", StopAnimationAction);
  73670. RegisterClass("BABYLON.PlayAnimationAction", PlayAnimationAction);
  73671. RegisterClass("BABYLON.IncrementValueAction", IncrementValueAction);
  73672. RegisterClass("BABYLON.SetValueAction", SetValueAction);
  73673. RegisterClass("BABYLON.SetStateAction", SetStateAction);
  73674. RegisterClass("BABYLON.SetParentAction", SetParentAction);
  73675. var ActionManager = function(a) {
  73676. __extends(e, a);
  73677. function e(i) {
  73678. var o = a.call(this) || this;
  73679. return o._scene = i || EngineStore.LastCreatedScene,
  73680. i.actionManagers.push(o),
  73681. o
  73682. }
  73683. return e.prototype.dispose = function() {
  73684. for (var i = this._scene.actionManagers.indexOf(this), o = 0; o < this.actions.length; o++) {
  73685. var s = this.actions[o];
  73686. e.Triggers[s.trigger]--,
  73687. e.Triggers[s.trigger] === 0 && delete e.Triggers[s.trigger]
  73688. }
  73689. i > -1 && this._scene.actionManagers.splice(i, 1)
  73690. }
  73691. ,
  73692. e.prototype.getScene = function() {
  73693. return this._scene
  73694. }
  73695. ,
  73696. e.prototype.hasSpecificTriggers = function(i) {
  73697. for (var o = 0; o < this.actions.length; o++) {
  73698. var s = this.actions[o];
  73699. if (i.indexOf(s.trigger) > -1)
  73700. return !0
  73701. }
  73702. return !1
  73703. }
  73704. ,
  73705. e.prototype.hasSpecificTriggers2 = function(i, o) {
  73706. for (var s = 0; s < this.actions.length; s++) {
  73707. var c = this.actions[s];
  73708. if (i == c.trigger || o == c.trigger)
  73709. return !0
  73710. }
  73711. return !1
  73712. }
  73713. ,
  73714. e.prototype.hasSpecificTrigger = function(i, o) {
  73715. for (var s = 0; s < this.actions.length; s++) {
  73716. var c = this.actions[s];
  73717. if (c.trigger === i)
  73718. if (o) {
  73719. if (o(c.getTriggerParameter()))
  73720. return !0
  73721. } else
  73722. return !0
  73723. }
  73724. return !1
  73725. }
  73726. ,
  73727. Object.defineProperty(e.prototype, "hasPointerTriggers", {
  73728. get: function() {
  73729. for (var i = 0; i < this.actions.length; i++) {
  73730. var o = this.actions[i];
  73731. if (o.trigger >= e.OnPickTrigger && o.trigger <= e.OnPointerOutTrigger)
  73732. return !0
  73733. }
  73734. return !1
  73735. },
  73736. enumerable: !1,
  73737. configurable: !0
  73738. }),
  73739. Object.defineProperty(e.prototype, "hasPickTriggers", {
  73740. get: function() {
  73741. for (var i = 0; i < this.actions.length; i++) {
  73742. var o = this.actions[i];
  73743. if (o.trigger >= e.OnPickTrigger && o.trigger <= e.OnPickUpTrigger)
  73744. return !0
  73745. }
  73746. return !1
  73747. },
  73748. enumerable: !1,
  73749. configurable: !0
  73750. }),
  73751. e.prototype.registerAction = function(i) {
  73752. return i.trigger === e.OnEveryFrameTrigger && this.getScene().actionManager !== this ? (Logger$2.Warn("OnEveryFrameTrigger can only be used with scene.actionManager"),
  73753. null) : (this.actions.push(i),
  73754. e.Triggers[i.trigger] ? e.Triggers[i.trigger]++ : e.Triggers[i.trigger] = 1,
  73755. i._actionManager = this,
  73756. i._prepare(),
  73757. i)
  73758. }
  73759. ,
  73760. e.prototype.unregisterAction = function(i) {
  73761. var o = this.actions.indexOf(i);
  73762. return o !== -1 ? (this.actions.splice(o, 1),
  73763. e.Triggers[i.trigger] -= 1,
  73764. e.Triggers[i.trigger] === 0 && delete e.Triggers[i.trigger],
  73765. i._actionManager = null,
  73766. !0) : !1
  73767. }
  73768. ,
  73769. e.prototype.processTrigger = function(i, o) {
  73770. for (var s = 0; s < this.actions.length; s++) {
  73771. var c = this.actions[s];
  73772. if (c.trigger === i) {
  73773. if (o && (i === e.OnKeyUpTrigger || i === e.OnKeyDownTrigger)) {
  73774. var d = c.getTriggerParameter();
  73775. if (d && d !== o.sourceEvent.keyCode) {
  73776. if (!d.toLowerCase)
  73777. continue;
  73778. var _ = d.toLowerCase();
  73779. if (_ !== o.sourceEvent.key) {
  73780. var b = o.sourceEvent.charCode ? o.sourceEvent.charCode : o.sourceEvent.keyCode
  73781. , k = String.fromCharCode(b).toLowerCase();
  73782. if (k !== _)
  73783. continue
  73784. }
  73785. }
  73786. }
  73787. c._executeCurrent(o)
  73788. }
  73789. }
  73790. }
  73791. ,
  73792. e.prototype._getEffectiveTarget = function(i, o) {
  73793. for (var s = o.split("."), c = 0; c < s.length - 1; c++)
  73794. i = i[s[c]];
  73795. return i
  73796. }
  73797. ,
  73798. e.prototype._getProperty = function(i) {
  73799. var o = i.split(".");
  73800. return o[o.length - 1]
  73801. }
  73802. ,
  73803. e.prototype.serialize = function(i) {
  73804. for (var o = {
  73805. children: new Array,
  73806. name: i,
  73807. type: 3,
  73808. properties: new Array
  73809. }, s = 0; s < this.actions.length; s++) {
  73810. var c = {
  73811. type: 0,
  73812. children: new Array,
  73813. name: e.GetTriggerName(this.actions[s].trigger),
  73814. properties: new Array
  73815. }
  73816. , d = this.actions[s].triggerOptions;
  73817. if (d && typeof d != "number")
  73818. if (d.parameter instanceof Node)
  73819. c.properties.push(Action._GetTargetProperty(d.parameter));
  73820. else {
  73821. var _ = {};
  73822. DeepCopier.DeepCopy(d.parameter, _, ["mesh"]),
  73823. d.parameter && d.parameter.mesh && (_._meshId = d.parameter.mesh.id),
  73824. c.properties.push({
  73825. name: "parameter",
  73826. targetType: null,
  73827. value: _
  73828. })
  73829. }
  73830. this.actions[s].serialize(c),
  73831. o.children.push(c)
  73832. }
  73833. return o
  73834. }
  73835. ,
  73836. e.Parse = function(i, o, s) {
  73837. var c = new e(s);
  73838. o === null ? s.actionManager = c : o.actionManager = c;
  73839. for (var d = function(rt, it) {
  73840. var nt = GetClass("BABYLON." + rt);
  73841. if (nt) {
  73842. var ot = Object.create(nt.prototype);
  73843. return ot.constructor.apply(ot, it),
  73844. ot
  73845. }
  73846. }, _ = function(rt, it, nt, ot) {
  73847. if (ot === null) {
  73848. var at = parseFloat(it);
  73849. return it === "true" || it === "false" ? it === "true" : isNaN(at) ? it : at
  73850. }
  73851. for (var st = ot.split("."), ut = it.split(","), ct = 0; ct < st.length; ct++)
  73852. nt = nt[st[ct]];
  73853. if (typeof nt == "boolean")
  73854. return ut[0] === "true";
  73855. if (typeof nt == "string")
  73856. return ut[0];
  73857. for (var lt = new Array, ct = 0; ct < ut.length; ct++)
  73858. lt.push(parseFloat(ut[ct]));
  73859. return nt instanceof Vector3 ? Vector3.FromArray(lt) : nt instanceof Vector4 ? Vector4.FromArray(lt) : nt instanceof Color3 ? Color3.FromArray(lt) : nt instanceof Color4 ? Color4.FromArray(lt) : parseFloat(ut[0])
  73860. }, b = function(rt, it, nt, ot, at) {
  73861. if (at === void 0 && (at = null),
  73862. !rt.detached) {
  73863. var st = new Array
  73864. , ut = null
  73865. , ct = null
  73866. , lt = rt.combine && rt.combine.length > 0;
  73867. if (rt.type === 2 ? st.push(c) : st.push(it),
  73868. lt) {
  73869. for (var ft = new Array, ht = 0; ht < rt.combine.length; ht++)
  73870. b(rt.combine[ht], e.NothingTrigger, nt, ot, ft);
  73871. st.push(ft)
  73872. } else
  73873. for (var pt = 0; pt < rt.properties.length; pt++) {
  73874. var dt = rt.properties[pt].value
  73875. , _t = rt.properties[pt].name
  73876. , mt = rt.properties[pt].targetType;
  73877. _t === "target" ? mt !== null && mt === "SceneProperties" ? dt = ut = s : dt = ut = s.getNodeByName(dt) : _t === "parent" ? dt = s.getNodeByName(dt) : _t === "sound" ? s.getSoundByName && (dt = s.getSoundByName(dt)) : _t !== "propertyPath" ? rt.type === 2 && _t === "operator" ? dt = ValueCondition[dt] : dt = _(_t, dt, ut, _t === "value" ? ct : null) : ct = dt,
  73878. st.push(dt)
  73879. }
  73880. if (at === null ? st.push(nt) : st.push(null),
  73881. rt.name === "InterpolateValueAction") {
  73882. var vt = st[st.length - 2];
  73883. st[st.length - 1] = vt,
  73884. st[st.length - 2] = nt
  73885. }
  73886. var yt = d(rt.name, st);
  73887. if (yt instanceof Condition && nt !== null) {
  73888. var Et = new DoNothingAction(it,nt);
  73889. ot ? ot.then(Et) : c.registerAction(Et),
  73890. ot = Et
  73891. }
  73892. at === null ? yt instanceof Condition ? (nt = yt,
  73893. yt = ot) : (nt = null,
  73894. ot ? ot.then(yt) : c.registerAction(yt)) : at.push(yt);
  73895. for (var pt = 0; pt < rt.children.length; pt++)
  73896. b(rt.children[pt], it, nt, yt, null)
  73897. }
  73898. }, k = 0; k < i.children.length; k++) {
  73899. var j, $ = i.children[k];
  73900. if ($.properties.length > 0) {
  73901. var _e = $.properties[0].value
  73902. , et = $.properties[0].targetType === null ? _e : s.getMeshByName(_e);
  73903. et._meshId && (et.mesh = s.getMeshById(et._meshId)),
  73904. j = {
  73905. trigger: e[$.name],
  73906. parameter: et
  73907. }
  73908. } else
  73909. j = e[$.name];
  73910. for (var tt = 0; tt < $.children.length; tt++)
  73911. $.detached || b($.children[tt], j, null, null)
  73912. }
  73913. }
  73914. ,
  73915. e.GetTriggerName = function(i) {
  73916. switch (i) {
  73917. case 0:
  73918. return "NothingTrigger";
  73919. case 1:
  73920. return "OnPickTrigger";
  73921. case 2:
  73922. return "OnLeftPickTrigger";
  73923. case 3:
  73924. return "OnRightPickTrigger";
  73925. case 4:
  73926. return "OnCenterPickTrigger";
  73927. case 5:
  73928. return "OnPickDownTrigger";
  73929. case 6:
  73930. return "OnPickUpTrigger";
  73931. case 7:
  73932. return "OnLongPressTrigger";
  73933. case 8:
  73934. return "OnPointerOverTrigger";
  73935. case 9:
  73936. return "OnPointerOutTrigger";
  73937. case 10:
  73938. return "OnEveryFrameTrigger";
  73939. case 11:
  73940. return "OnIntersectionEnterTrigger";
  73941. case 12:
  73942. return "OnIntersectionExitTrigger";
  73943. case 13:
  73944. return "OnKeyDownTrigger";
  73945. case 14:
  73946. return "OnKeyUpTrigger";
  73947. case 15:
  73948. return "OnPickOutTrigger";
  73949. default:
  73950. return ""
  73951. }
  73952. }
  73953. ,
  73954. e.NothingTrigger = 0,
  73955. e.OnPickTrigger = 1,
  73956. e.OnLeftPickTrigger = 2,
  73957. e.OnRightPickTrigger = 3,
  73958. e.OnCenterPickTrigger = 4,
  73959. e.OnPickDownTrigger = 5,
  73960. e.OnDoublePickTrigger = 6,
  73961. e.OnPickUpTrigger = 7,
  73962. e.OnPickOutTrigger = 16,
  73963. e.OnLongPressTrigger = 8,
  73964. e.OnPointerOverTrigger = 9,
  73965. e.OnPointerOutTrigger = 10,
  73966. e.OnEveryFrameTrigger = 11,
  73967. e.OnIntersectionEnterTrigger = 12,
  73968. e.OnIntersectionExitTrigger = 13,
  73969. e.OnKeyDownTrigger = 14,
  73970. e.OnKeyUpTrigger = 15,
  73971. e
  73972. }(AbstractActionManager);
  73973. Node$2.AddNodeConstructor("Light_Type_0", function(a, e) {
  73974. return function() {
  73975. return new PointLight(a,Vector3.Zero(),e)
  73976. }
  73977. });
  73978. var PointLight = function(a) {
  73979. __extends(e, a);
  73980. function e(i, o, s) {
  73981. var c = a.call(this, i, s) || this;
  73982. return c._shadowAngle = Math.PI / 2,
  73983. c.position = o,
  73984. c
  73985. }
  73986. return Object.defineProperty(e.prototype, "shadowAngle", {
  73987. get: function() {
  73988. return this._shadowAngle
  73989. },
  73990. set: function(i) {
  73991. this._shadowAngle = i,
  73992. this.forceProjectionMatrixCompute()
  73993. },
  73994. enumerable: !1,
  73995. configurable: !0
  73996. }),
  73997. Object.defineProperty(e.prototype, "direction", {
  73998. get: function() {
  73999. return this._direction
  74000. },
  74001. set: function(i) {
  74002. var o = this.needCube();
  74003. this._direction = i,
  74004. this.needCube() !== o && this._shadowGenerator && this._shadowGenerator.recreateShadowMap()
  74005. },
  74006. enumerable: !1,
  74007. configurable: !0
  74008. }),
  74009. e.prototype.getClassName = function() {
  74010. return "PointLight"
  74011. }
  74012. ,
  74013. e.prototype.getTypeID = function() {
  74014. return Light.LIGHTTYPEID_POINTLIGHT
  74015. }
  74016. ,
  74017. e.prototype.needCube = function() {
  74018. return !this.direction
  74019. }
  74020. ,
  74021. e.prototype.getShadowDirection = function(i) {
  74022. if (this.direction)
  74023. return a.prototype.getShadowDirection.call(this, i);
  74024. switch (i) {
  74025. case 0:
  74026. return new Vector3(1,0,0);
  74027. case 1:
  74028. return new Vector3(-1,0,0);
  74029. case 2:
  74030. return new Vector3(0,-1,0);
  74031. case 3:
  74032. return new Vector3(0,1,0);
  74033. case 4:
  74034. return new Vector3(0,0,1);
  74035. case 5:
  74036. return new Vector3(0,0,-1)
  74037. }
  74038. return Vector3.Zero()
  74039. }
  74040. ,
  74041. e.prototype._setDefaultShadowProjectionMatrix = function(i, o, s) {
  74042. var c = this.getScene().activeCamera;
  74043. if (!!c) {
  74044. var d = this.shadowMinZ !== void 0 ? this.shadowMinZ : c.minZ
  74045. , _ = this.shadowMaxZ !== void 0 ? this.shadowMaxZ : c.maxZ
  74046. , b = this.getScene().getEngine().useReverseDepthBuffer;
  74047. Matrix.PerspectiveFovLHToRef(this.shadowAngle, 1, b ? _ : d, b ? d : _, i, !0, this._scene.getEngine().isNDCHalfZRange, void 0, b)
  74048. }
  74049. }
  74050. ,
  74051. e.prototype._buildUniformLayout = function() {
  74052. this._uniformBuffer.addUniform("vLightData", 4),
  74053. this._uniformBuffer.addUniform("vLightDiffuse", 4),
  74054. this._uniformBuffer.addUniform("vLightSpecular", 4),
  74055. this._uniformBuffer.addUniform("vLightFalloff", 4),
  74056. this._uniformBuffer.addUniform("shadowsInfo", 3),
  74057. this._uniformBuffer.addUniform("depthValues", 2),
  74058. this._uniformBuffer.create()
  74059. }
  74060. ,
  74061. e.prototype.transferToEffect = function(i, o) {
  74062. return this.computeTransformedInformation() ? this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, 0, o) : this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, 0, o),
  74063. this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, 0, 0, o),
  74064. this
  74065. }
  74066. ,
  74067. e.prototype.transferToNodeMaterialEffect = function(i, o) {
  74068. return this.computeTransformedInformation() ? i.setFloat3(o, this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z) : i.setFloat3(o, this.position.x, this.position.y, this.position.z),
  74069. this
  74070. }
  74071. ,
  74072. e.prototype.prepareLightSpecificDefines = function(i, o) {
  74073. i["POINTLIGHT" + o] = !0
  74074. }
  74075. ,
  74076. __decorate([serialize()], e.prototype, "shadowAngle", null),
  74077. e
  74078. }(ShadowLight);
  74079. function CreateRibbonVertexData(a) {
  74080. var e = a.pathArray
  74081. , i = a.closeArray || !1
  74082. , o = a.closePath || !1
  74083. , s = a.invertUV || !1
  74084. , c = Math.floor(e[0].length / 2)
  74085. , d = a.offset || c;
  74086. d = d > c ? c : Math.floor(d);
  74087. var _ = a.sideOrientation === 0 ? 0 : a.sideOrientation || VertexData.DEFAULTSIDE, b = a.uvs, k = a.colors, j = [], $ = [], _e = [], et = [], tt = [], rt = [], it = [], nt = [], ot, at = [], st = [], ut, ct, lt;
  74088. if (e.length < 2) {
  74089. var ft = []
  74090. , ht = [];
  74091. for (ct = 0; ct < e[0].length - d; ct++)
  74092. ft.push(e[0][ct]),
  74093. ht.push(e[0][ct + d]);
  74094. e = [ft, ht]
  74095. }
  74096. var pt = 0, dt = o ? 1 : 0, _t, mt;
  74097. ot = e[0].length;
  74098. var vt, yt;
  74099. for (ut = 0; ut < e.length; ut++) {
  74100. for (it[ut] = 0,
  74101. tt[ut] = [0],
  74102. _t = e[ut],
  74103. mt = _t.length,
  74104. ot = ot < mt ? ot : mt,
  74105. lt = 0; lt < mt; )
  74106. j.push(_t[lt].x, _t[lt].y, _t[lt].z),
  74107. lt > 0 && (vt = _t[lt].subtract(_t[lt - 1]).length(),
  74108. yt = vt + it[ut],
  74109. tt[ut].push(yt),
  74110. it[ut] = yt),
  74111. lt++;
  74112. o && (lt--,
  74113. j.push(_t[0].x, _t[0].y, _t[0].z),
  74114. vt = _t[lt].subtract(_t[0]).length(),
  74115. yt = vt + it[ut],
  74116. tt[ut].push(yt),
  74117. it[ut] = yt),
  74118. at[ut] = mt + dt,
  74119. st[ut] = pt,
  74120. pt += mt + dt
  74121. }
  74122. var Et, At, gt = null, St = null;
  74123. for (ct = 0; ct < ot + dt; ct++) {
  74124. for (nt[ct] = 0,
  74125. rt[ct] = [0],
  74126. ut = 0; ut < e.length - 1; ut++)
  74127. Et = e[ut],
  74128. At = e[ut + 1],
  74129. ct === ot ? (gt = Et[0],
  74130. St = At[0]) : (gt = Et[ct],
  74131. St = At[ct]),
  74132. vt = St.subtract(gt).length(),
  74133. yt = vt + nt[ct],
  74134. rt[ct].push(yt),
  74135. nt[ct] = yt;
  74136. i && St && gt && (Et = e[ut],
  74137. At = e[0],
  74138. ct === ot && (St = At[0]),
  74139. vt = St.subtract(gt).length(),
  74140. yt = vt + nt[ct],
  74141. nt[ct] = yt)
  74142. }
  74143. var xt, bt;
  74144. if (b)
  74145. for (ut = 0; ut < b.length; ut++)
  74146. et.push(b[ut].x, b[ut].y);
  74147. else
  74148. for (ut = 0; ut < e.length; ut++)
  74149. for (ct = 0; ct < ot + dt; ct++)
  74150. xt = it[ut] != 0 ? tt[ut][ct] / it[ut] : 0,
  74151. bt = nt[ct] != 0 ? rt[ct][ut] / nt[ct] : 0,
  74152. s ? et.push(bt, xt) : et.push(xt, bt);
  74153. ut = 0;
  74154. for (var Rt = 0, Mt = at[ut] - 1, Pt = at[ut + 1] - 1, It = Mt < Pt ? Mt : Pt, Dt = st[1] - st[0], Ct = i ? at.length : at.length - 1; Rt <= It && ut < Ct; )
  74155. $.push(Rt, Rt + Dt, Rt + 1),
  74156. $.push(Rt + Dt + 1, Rt + 1, Rt + Dt),
  74157. Rt += 1,
  74158. Rt === It && (ut++,
  74159. ut === at.length - 1 ? (Dt = st[0] - st[ut],
  74160. Mt = at[ut] - 1,
  74161. Pt = at[0] - 1) : (Dt = st[ut + 1] - st[ut],
  74162. Mt = at[ut] - 1,
  74163. Pt = at[ut + 1] - 1),
  74164. Rt = st[ut],
  74165. It = Mt < Pt ? Mt + Rt : Pt + Rt);
  74166. if (VertexData.ComputeNormals(j, $, _e),
  74167. o) {
  74168. var Ot = 0
  74169. , wt = 0;
  74170. for (ut = 0; ut < e.length; ut++)
  74171. Ot = st[ut] * 3,
  74172. ut + 1 < e.length ? wt = (st[ut + 1] - 1) * 3 : wt = _e.length - 3,
  74173. _e[Ot] = (_e[Ot] + _e[wt]) * .5,
  74174. _e[Ot + 1] = (_e[Ot + 1] + _e[wt + 1]) * .5,
  74175. _e[Ot + 2] = (_e[Ot + 2] + _e[wt + 2]) * .5,
  74176. _e[wt] = _e[Ot],
  74177. _e[wt + 1] = _e[Ot + 1],
  74178. _e[wt + 2] = _e[Ot + 2]
  74179. }
  74180. VertexData._ComputeSides(_, j, $, _e, et, a.frontUVs, a.backUVs);
  74181. var Nt = null;
  74182. if (k) {
  74183. Nt = new Float32Array(k.length * 4);
  74184. for (var Ft = 0; Ft < k.length; Ft++)
  74185. Nt[Ft * 4] = k[Ft].r,
  74186. Nt[Ft * 4 + 1] = k[Ft].g,
  74187. Nt[Ft * 4 + 2] = k[Ft].b,
  74188. Nt[Ft * 4 + 3] = k[Ft].a
  74189. }
  74190. var Vt = new VertexData
  74191. , Lt = new Float32Array(j)
  74192. , kt = new Float32Array(_e)
  74193. , Bt = new Float32Array(et);
  74194. return Vt.indices = $,
  74195. Vt.positions = Lt,
  74196. Vt.normals = kt,
  74197. Vt.uvs = Bt,
  74198. Nt && Vt.set(Nt, VertexBuffer.ColorKind),
  74199. o && (Vt._idx = st),
  74200. Vt
  74201. }
  74202. function CreateRibbon(a, e, i) {
  74203. i === void 0 && (i = null);
  74204. var o = e.pathArray
  74205. , s = e.closeArray
  74206. , c = e.closePath
  74207. , d = Mesh._GetDefaultSideOrientation(e.sideOrientation)
  74208. , _ = e.instance
  74209. , b = e.updatable;
  74210. if (_) {
  74211. var k = TmpVectors.Vector3[0].setAll(Number.MAX_VALUE)
  74212. , j = TmpVectors.Vector3[1].setAll(-Number.MAX_VALUE)
  74213. , $ = function(dt) {
  74214. for (var _t = o[0].length, mt = _, vt = 0, yt = mt._originalBuilderSideOrientation === Mesh.DOUBLESIDE ? 2 : 1, Et = 1; Et <= yt; ++Et)
  74215. for (var At = 0; At < o.length; ++At) {
  74216. var gt = o[At]
  74217. , St = gt.length;
  74218. _t = _t < St ? _t : St;
  74219. for (var xt = 0; xt < _t; ++xt) {
  74220. var bt = gt[xt];
  74221. dt[vt] = bt.x,
  74222. dt[vt + 1] = bt.y,
  74223. dt[vt + 2] = bt.z,
  74224. k.minimizeInPlaceFromFloats(bt.x, bt.y, bt.z),
  74225. j.maximizeInPlaceFromFloats(bt.x, bt.y, bt.z),
  74226. vt += 3
  74227. }
  74228. if (mt._creationDataStorage && mt._creationDataStorage.closePath) {
  74229. var bt = gt[0];
  74230. dt[vt] = bt.x,
  74231. dt[vt + 1] = bt.y,
  74232. dt[vt + 2] = bt.z,
  74233. vt += 3
  74234. }
  74235. }
  74236. }
  74237. , _e = _.getVerticesData(VertexBuffer.PositionKind);
  74238. if ($(_e),
  74239. _.hasBoundingInfo ? _.getBoundingInfo().reConstruct(k, j, _._worldMatrix) : _.buildBoundingInfo(k, j, _._worldMatrix),
  74240. _.updateVerticesData(VertexBuffer.PositionKind, _e, !1, !1),
  74241. e.colors) {
  74242. for (var et = _.getVerticesData(VertexBuffer.ColorKind), tt = 0, rt = 0; tt < e.colors.length; tt++,
  74243. rt += 4) {
  74244. var it = e.colors[tt];
  74245. et[rt] = it.r,
  74246. et[rt + 1] = it.g,
  74247. et[rt + 2] = it.b,
  74248. et[rt + 3] = it.a
  74249. }
  74250. _.updateVerticesData(VertexBuffer.ColorKind, et, !1, !1)
  74251. }
  74252. if (e.uvs) {
  74253. for (var nt = _.getVerticesData(VertexBuffer.UVKind), ot = 0; ot < e.uvs.length; ot++)
  74254. nt[ot * 2] = e.uvs[ot].x,
  74255. nt[ot * 2 + 1] = e.uvs[ot].y;
  74256. _.updateVerticesData(VertexBuffer.UVKind, nt, !1, !1)
  74257. }
  74258. if (!_.areNormalsFrozen || _.isFacetDataEnabled) {
  74259. var at = _.getIndices()
  74260. , st = _.getVerticesData(VertexBuffer.NormalKind)
  74261. , ut = _.isFacetDataEnabled ? _.getFacetDataParameters() : null;
  74262. if (VertexData.ComputeNormals(_e, at, st, ut),
  74263. _._creationDataStorage && _._creationDataStorage.closePath)
  74264. for (var ct = 0, lt = 0, ft = 0; ft < o.length; ft++)
  74265. ct = _._creationDataStorage.idx[ft] * 3,
  74266. ft + 1 < o.length ? lt = (_._creationDataStorage.idx[ft + 1] - 1) * 3 : lt = st.length - 3,
  74267. st[ct] = (st[ct] + st[lt]) * .5,
  74268. st[ct + 1] = (st[ct + 1] + st[lt + 1]) * .5,
  74269. st[ct + 2] = (st[ct + 2] + st[lt + 2]) * .5,
  74270. st[lt] = st[ct],
  74271. st[lt + 1] = st[ct + 1],
  74272. st[lt + 2] = st[ct + 2];
  74273. _.areNormalsFrozen || _.updateVerticesData(VertexBuffer.NormalKind, st, !1, !1)
  74274. }
  74275. return _
  74276. } else {
  74277. var ht = new Mesh(a,i);
  74278. ht._originalBuilderSideOrientation = d,
  74279. ht._creationDataStorage = new _CreationDataStorage;
  74280. var pt = CreateRibbonVertexData(e);
  74281. return c && (ht._creationDataStorage.idx = pt._idx),
  74282. ht._creationDataStorage.closePath = c,
  74283. ht._creationDataStorage.closeArray = s,
  74284. pt.applyToMesh(ht, b),
  74285. ht
  74286. }
  74287. }
  74288. VertexData.CreateRibbon = CreateRibbonVertexData;
  74289. Mesh.CreateRibbon = function(a, e, i, o, s, c, d, _, b) {
  74290. return i === void 0 && (i = !1),
  74291. d === void 0 && (d = !1),
  74292. CreateRibbon(a, {
  74293. pathArray: e,
  74294. closeArray: i,
  74295. closePath: o,
  74296. offset: s,
  74297. updatable: d,
  74298. sideOrientation: _,
  74299. instance: b
  74300. }, c)
  74301. }
  74302. ;
  74303. function CreateDiscVertexData(a) {
  74304. var e = new Array
  74305. , i = new Array
  74306. , o = new Array
  74307. , s = new Array
  74308. , c = a.radius || .5
  74309. , d = a.tessellation || 64
  74310. , _ = a.arc && (a.arc <= 0 || a.arc > 1) ? 1 : a.arc || 1
  74311. , b = a.sideOrientation === 0 ? 0 : a.sideOrientation || VertexData.DEFAULTSIDE;
  74312. e.push(0, 0, 0),
  74313. s.push(.5, .5);
  74314. for (var k = Math.PI * 2 * _, j = _ === 1 ? k / d : k / (d - 1), $ = 0, _e = 0; _e < d; _e++) {
  74315. var et = Math.cos($)
  74316. , tt = Math.sin($)
  74317. , rt = (et + 1) / 2
  74318. , it = (1 - tt) / 2;
  74319. e.push(c * et, c * tt, 0),
  74320. s.push(rt, it),
  74321. $ += j
  74322. }
  74323. _ === 1 && (e.push(e[3], e[4], e[5]),
  74324. s.push(s[2], s[3]));
  74325. for (var nt = e.length / 3, ot = 1; ot < nt - 1; ot++)
  74326. i.push(ot + 1, 0, ot);
  74327. VertexData.ComputeNormals(e, i, o),
  74328. VertexData._ComputeSides(b, e, i, o, s, a.frontUVs, a.backUVs);
  74329. var at = new VertexData;
  74330. return at.indices = i,
  74331. at.positions = e,
  74332. at.normals = o,
  74333. at.uvs = s,
  74334. at
  74335. }
  74336. function CreateDisc(a, e, i) {
  74337. e === void 0 && (e = {}),
  74338. i === void 0 && (i = null);
  74339. var o = new Mesh(a,i);
  74340. e.sideOrientation = Mesh._GetDefaultSideOrientation(e.sideOrientation),
  74341. o._originalBuilderSideOrientation = e.sideOrientation;
  74342. var s = CreateDiscVertexData(e);
  74343. return s.applyToMesh(o, e.updatable),
  74344. o
  74345. }
  74346. VertexData.CreateDisc = CreateDiscVertexData;
  74347. Mesh.CreateDisc = function(a, e, i, o, s, c) {
  74348. o === void 0 && (o = null);
  74349. var d = {
  74350. radius: e,
  74351. tessellation: i,
  74352. sideOrientation: c,
  74353. updatable: s
  74354. };
  74355. return CreateDisc(a, d, o)
  74356. }
  74357. ;
  74358. function CreateBoxVertexData(a) {
  74359. var e = 6
  74360. , i = [0, 1, 2, 0, 2, 3, 4, 5, 6, 4, 6, 7, 8, 9, 10, 8, 10, 11, 12, 13, 14, 12, 14, 15, 16, 17, 18, 16, 18, 19, 20, 21, 22, 20, 22, 23]
  74361. , o = [0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0]
  74362. , s = []
  74363. , c = []
  74364. , d = a.width || a.size || 1
  74365. , _ = a.height || a.size || 1
  74366. , b = a.depth || a.size || 1
  74367. , k = a.wrap || !1
  74368. , j = a.topBaseAt === void 0 ? 1 : a.topBaseAt
  74369. , $ = a.bottomBaseAt === void 0 ? 0 : a.bottomBaseAt;
  74370. j = (j + 4) % 4,
  74371. $ = ($ + 4) % 4;
  74372. var _e = [2, 0, 3, 1]
  74373. , et = [2, 0, 1, 3]
  74374. , tt = _e[j]
  74375. , rt = et[$]
  74376. , it = [1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1];
  74377. if (k) {
  74378. i = [2, 3, 0, 2, 0, 1, 4, 5, 6, 4, 6, 7, 9, 10, 11, 9, 11, 8, 12, 14, 15, 12, 13, 14],
  74379. it = [-1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1];
  74380. for (var nt = [[1, 1, 1], [-1, 1, 1], [-1, 1, -1], [1, 1, -1]], ot = [[-1, -1, 1], [1, -1, 1], [1, -1, -1], [-1, -1, -1]], at = [17, 18, 19, 16], st = [22, 23, 20, 21]; tt > 0; )
  74381. nt.unshift(nt.pop()),
  74382. at.unshift(at.pop()),
  74383. tt--;
  74384. for (; rt > 0; )
  74385. ot.unshift(ot.pop()),
  74386. st.unshift(st.pop()),
  74387. rt--;
  74388. nt = nt.flat(),
  74389. ot = ot.flat(),
  74390. it = it.concat(nt).concat(ot),
  74391. i.push(at[0], at[2], at[3], at[0], at[1], at[2]),
  74392. i.push(st[0], st[2], st[3], st[0], st[1], st[2])
  74393. }
  74394. var ut = [d / 2, _ / 2, b / 2];
  74395. c = it.reduce(function(yt, Et, At) {
  74396. return yt.concat(Et * ut[At % 3])
  74397. }, []);
  74398. for (var ct = a.sideOrientation === 0 ? 0 : a.sideOrientation || VertexData.DEFAULTSIDE, lt = a.faceUV || new Array(6), ft = a.faceColors, ht = [], pt = 0; pt < 6; pt++)
  74399. lt[pt] === void 0 && (lt[pt] = new Vector4(0,0,1,1)),
  74400. ft && ft[pt] === void 0 && (ft[pt] = new Color4(1,1,1,1));
  74401. for (var dt = 0; dt < e; dt++)
  74402. if (s.push(lt[dt].z, lt[dt].w),
  74403. s.push(lt[dt].x, lt[dt].w),
  74404. s.push(lt[dt].x, lt[dt].y),
  74405. s.push(lt[dt].z, lt[dt].y),
  74406. ft)
  74407. for (var _t = 0; _t < 4; _t++)
  74408. ht.push(ft[dt].r, ft[dt].g, ft[dt].b, ft[dt].a);
  74409. VertexData._ComputeSides(ct, c, i, o, s, a.frontUVs, a.backUVs);
  74410. var mt = new VertexData;
  74411. if (mt.indices = i,
  74412. mt.positions = c,
  74413. mt.normals = o,
  74414. mt.uvs = s,
  74415. ft) {
  74416. var vt = ct === VertexData.DOUBLESIDE ? ht.concat(ht) : ht;
  74417. mt.colors = vt
  74418. }
  74419. return mt
  74420. }
  74421. function CreateBox(a, e, i) {
  74422. e === void 0 && (e = {}),
  74423. i === void 0 && (i = null);
  74424. var o = new Mesh(a,i);
  74425. e.sideOrientation = Mesh._GetDefaultSideOrientation(e.sideOrientation),
  74426. o._originalBuilderSideOrientation = e.sideOrientation;
  74427. var s = CreateBoxVertexData(e);
  74428. return s.applyToMesh(o, e.updatable),
  74429. o
  74430. }
  74431. VertexData.CreateBox = CreateBoxVertexData;
  74432. Mesh.CreateBox = function(a, e, i, o, s) {
  74433. i === void 0 && (i = null);
  74434. var c = {
  74435. size: e,
  74436. sideOrientation: s,
  74437. updatable: o
  74438. };
  74439. return CreateBox(a, c, i)
  74440. }
  74441. ;
  74442. function CreateTiledPlaneVertexData(a) {
  74443. var e = a.pattern || Mesh.NO_FLIP
  74444. , i = a.tileWidth || a.tileSize || 1
  74445. , o = a.tileHeight || a.tileSize || 1
  74446. , s = a.alignHorizontal || 0
  74447. , c = a.alignVertical || 0
  74448. , d = a.width || a.size || 1
  74449. , _ = Math.floor(d / i)
  74450. , b = d - _ * i
  74451. , k = a.height || a.size || 1
  74452. , j = Math.floor(k / o)
  74453. , $ = k - j * o
  74454. , _e = i * _ / 2
  74455. , et = o * j / 2
  74456. , tt = 0
  74457. , rt = 0
  74458. , it = 0
  74459. , nt = 0
  74460. , ot = 0
  74461. , at = 0;
  74462. if (b > 0 || $ > 0) {
  74463. it = -_e,
  74464. nt = -et;
  74465. var ot = _e
  74466. , at = et;
  74467. switch (s) {
  74468. case Mesh.CENTER:
  74469. b /= 2,
  74470. it -= b,
  74471. ot += b;
  74472. break;
  74473. case Mesh.LEFT:
  74474. ot += b,
  74475. tt = -b / 2;
  74476. break;
  74477. case Mesh.RIGHT:
  74478. it -= b,
  74479. tt = b / 2;
  74480. break
  74481. }
  74482. switch (c) {
  74483. case Mesh.CENTER:
  74484. $ /= 2,
  74485. nt -= $,
  74486. at += $;
  74487. break;
  74488. case Mesh.BOTTOM:
  74489. at += $,
  74490. rt = -$ / 2;
  74491. break;
  74492. case Mesh.TOP:
  74493. nt -= $,
  74494. rt = $ / 2;
  74495. break
  74496. }
  74497. }
  74498. var st = []
  74499. , ut = []
  74500. , ct = [];
  74501. ct[0] = [0, 0, 1, 0, 1, 1, 0, 1],
  74502. ct[1] = [0, 0, 1, 0, 1, 1, 0, 1],
  74503. (e === Mesh.ROTATE_TILE || e === Mesh.ROTATE_ROW) && (ct[1] = [1, 1, 0, 1, 0, 0, 1, 0]),
  74504. (e === Mesh.FLIP_TILE || e === Mesh.FLIP_ROW) && (ct[1] = [1, 0, 0, 0, 0, 1, 1, 1]),
  74505. (e === Mesh.FLIP_N_ROTATE_TILE || e === Mesh.FLIP_N_ROTATE_ROW) && (ct[1] = [0, 1, 1, 1, 1, 0, 0, 0]);
  74506. for (var lt = [], ft = [], ht = [], pt = 0, dt = 0; dt < j; dt++)
  74507. for (var _t = 0; _t < _; _t++)
  74508. st.push(-_e + _t * i + tt, -et + dt * o + rt, 0),
  74509. st.push(-_e + (_t + 1) * i + tt, -et + dt * o + rt, 0),
  74510. st.push(-_e + (_t + 1) * i + tt, -et + (dt + 1) * o + rt, 0),
  74511. st.push(-_e + _t * i + tt, -et + (dt + 1) * o + rt, 0),
  74512. ht.push(pt, pt + 1, pt + 3, pt + 1, pt + 2, pt + 3),
  74513. e === Mesh.FLIP_TILE || e === Mesh.ROTATE_TILE || e === Mesh.FLIP_N_ROTATE_TILE ? lt = lt.concat(ct[(_t % 2 + dt % 2) % 2]) : e === Mesh.FLIP_ROW || e === Mesh.ROTATE_ROW || e === Mesh.FLIP_N_ROTATE_ROW ? lt = lt.concat(ct[dt % 2]) : lt = lt.concat(ct[0]),
  74514. ft.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
  74515. ut.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1),
  74516. pt += 4;
  74517. if (b > 0 || $ > 0) {
  74518. var mt = $ > 0 && (c === Mesh.CENTER || c === Mesh.TOP), vt = $ > 0 && (c === Mesh.CENTER || c === Mesh.BOTTOM), yt = b > 0 && (s === Mesh.CENTER || s === Mesh.RIGHT), Et = b > 0 && (s === Mesh.CENTER || s === Mesh.LEFT), At = [], gt, St, xt, bt;
  74519. if (mt && yt && (st.push(it + tt, nt + rt, 0),
  74520. st.push(-_e + tt, nt + rt, 0),
  74521. st.push(-_e + tt, nt + $ + rt, 0),
  74522. st.push(it + tt, nt + $ + rt, 0),
  74523. ht.push(pt, pt + 1, pt + 3, pt + 1, pt + 2, pt + 3),
  74524. pt += 4,
  74525. gt = 1 - b / i,
  74526. St = 1 - $ / o,
  74527. xt = 1,
  74528. bt = 1,
  74529. At = [gt, St, xt, St, xt, bt, gt, bt],
  74530. e === Mesh.ROTATE_ROW && (At = [1 - gt, 1 - St, 1 - xt, 1 - St, 1 - xt, 1 - bt, 1 - gt, 1 - bt]),
  74531. e === Mesh.FLIP_ROW && (At = [1 - gt, St, 1 - xt, St, 1 - xt, bt, 1 - gt, bt]),
  74532. e === Mesh.FLIP_N_ROTATE_ROW && (At = [gt, 1 - St, xt, 1 - St, xt, 1 - bt, gt, 1 - bt]),
  74533. lt = lt.concat(At),
  74534. ft.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
  74535. ut.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1)),
  74536. mt && Et && (st.push(_e + tt, nt + rt, 0),
  74537. st.push(ot + tt, nt + rt, 0),
  74538. st.push(ot + tt, nt + $ + rt, 0),
  74539. st.push(_e + tt, nt + $ + rt, 0),
  74540. ht.push(pt, pt + 1, pt + 3, pt + 1, pt + 2, pt + 3),
  74541. pt += 4,
  74542. gt = 0,
  74543. St = 1 - $ / o,
  74544. xt = b / i,
  74545. bt = 1,
  74546. At = [gt, St, xt, St, xt, bt, gt, bt],
  74547. (e === Mesh.ROTATE_ROW || e === Mesh.ROTATE_TILE && _ % 2 === 0) && (At = [1 - gt, 1 - St, 1 - xt, 1 - St, 1 - xt, 1 - bt, 1 - gt, 1 - bt]),
  74548. (e === Mesh.FLIP_ROW || e === Mesh.FLIP_TILE && _ % 2 === 0) && (At = [1 - gt, St, 1 - xt, St, 1 - xt, bt, 1 - gt, bt]),
  74549. (e === Mesh.FLIP_N_ROTATE_ROW || e === Mesh.FLIP_N_ROTATE_TILE && _ % 2 === 0) && (At = [gt, 1 - St, xt, 1 - St, xt, 1 - bt, gt, 1 - bt]),
  74550. lt = lt.concat(At),
  74551. ft.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
  74552. ut.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1)),
  74553. vt && yt && (st.push(it + tt, et + rt, 0),
  74554. st.push(-_e + tt, et + rt, 0),
  74555. st.push(-_e + tt, at + rt, 0),
  74556. st.push(it + tt, at + rt, 0),
  74557. ht.push(pt, pt + 1, pt + 3, pt + 1, pt + 2, pt + 3),
  74558. pt += 4,
  74559. gt = 1 - b / i,
  74560. St = 0,
  74561. xt = 1,
  74562. bt = $ / o,
  74563. At = [gt, St, xt, St, xt, bt, gt, bt],
  74564. (e === Mesh.ROTATE_ROW && j % 2 === 1 || e === Mesh.ROTATE_TILE && j % 1 === 0) && (At = [1 - gt, 1 - St, 1 - xt, 1 - St, 1 - xt, 1 - bt, 1 - gt, 1 - bt]),
  74565. (e === Mesh.FLIP_ROW && j % 2 === 1 || e === Mesh.FLIP_TILE && j % 2 === 0) && (At = [1 - gt, St, 1 - xt, St, 1 - xt, bt, 1 - gt, bt]),
  74566. (e === Mesh.FLIP_N_ROTATE_ROW && j % 2 === 1 || e === Mesh.FLIP_N_ROTATE_TILE && j % 2 === 0) && (At = [gt, 1 - St, xt, 1 - St, xt, 1 - bt, gt, 1 - bt]),
  74567. lt = lt.concat(At),
  74568. ft.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
  74569. ut.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1)),
  74570. vt && Et && (st.push(_e + tt, et + rt, 0),
  74571. st.push(ot + tt, et + rt, 0),
  74572. st.push(ot + tt, at + rt, 0),
  74573. st.push(_e + tt, at + rt, 0),
  74574. ht.push(pt, pt + 1, pt + 3, pt + 1, pt + 2, pt + 3),
  74575. pt += 4,
  74576. gt = 0,
  74577. St = 0,
  74578. xt = b / i,
  74579. bt = $ / o,
  74580. At = [gt, St, xt, St, xt, bt, gt, bt],
  74581. (e === Mesh.ROTATE_ROW && j % 2 === 1 || e === Mesh.ROTATE_TILE && (j + _) % 2 === 1) && (At = [1 - gt, 1 - St, 1 - xt, 1 - St, 1 - xt, 1 - bt, 1 - gt, 1 - bt]),
  74582. (e === Mesh.FLIP_ROW && j % 2 === 1 || e === Mesh.FLIP_TILE && (j + _) % 2 === 1) && (At = [1 - gt, St, 1 - xt, St, 1 - xt, bt, 1 - gt, bt]),
  74583. (e === Mesh.FLIP_N_ROTATE_ROW && j % 2 === 1 || e === Mesh.FLIP_N_ROTATE_TILE && (j + _) % 2 === 1) && (At = [gt, 1 - St, xt, 1 - St, xt, 1 - bt, gt, 1 - bt]),
  74584. lt = lt.concat(At),
  74585. ft.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
  74586. ut.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1)),
  74587. mt) {
  74588. var Rt = [];
  74589. gt = 0,
  74590. St = 1 - $ / o,
  74591. xt = 1,
  74592. bt = 1,
  74593. Rt[0] = [gt, St, xt, St, xt, bt, gt, bt],
  74594. Rt[1] = [gt, St, xt, St, xt, bt, gt, bt],
  74595. (e === Mesh.ROTATE_TILE || e === Mesh.ROTATE_ROW) && (Rt[1] = [1 - gt, 1 - St, 1 - xt, 1 - St, 1 - xt, 1 - bt, 1 - gt, 1 - bt]),
  74596. (e === Mesh.FLIP_TILE || e === Mesh.FLIP_ROW) && (Rt[1] = [1 - gt, St, 1 - xt, St, 1 - xt, bt, 1 - gt, bt]),
  74597. (e === Mesh.FLIP_N_ROTATE_TILE || e === Mesh.FLIP_N_ROTATE_ROW) && (Rt[1] = [gt, 1 - St, xt, 1 - St, xt, 1 - bt, gt, 1 - bt]);
  74598. for (var _t = 0; _t < _; _t++)
  74599. st.push(-_e + _t * i + tt, nt + rt, 0),
  74600. st.push(-_e + (_t + 1) * i + tt, nt + rt, 0),
  74601. st.push(-_e + (_t + 1) * i + tt, nt + $ + rt, 0),
  74602. st.push(-_e + _t * i + tt, nt + $ + rt, 0),
  74603. ht.push(pt, pt + 1, pt + 3, pt + 1, pt + 2, pt + 3),
  74604. pt += 4,
  74605. e === Mesh.FLIP_TILE || e === Mesh.ROTATE_TILE || e === Mesh.FLIP_N_ROTATE_TILE ? lt = lt.concat(Rt[(_t + 1) % 2]) : e === Mesh.FLIP_ROW || e === Mesh.ROTATE_ROW || e === Mesh.FLIP_N_ROTATE_ROW ? lt = lt.concat(Rt[1]) : lt = lt.concat(Rt[0]),
  74606. ft.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
  74607. ut.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1)
  74608. }
  74609. if (vt) {
  74610. var Mt = [];
  74611. gt = 0,
  74612. St = 0,
  74613. xt = 1,
  74614. bt = $ / o,
  74615. Mt[0] = [gt, St, xt, St, xt, bt, gt, bt],
  74616. Mt[1] = [gt, St, xt, St, xt, bt, gt, bt],
  74617. (e === Mesh.ROTATE_TILE || e === Mesh.ROTATE_ROW) && (Mt[1] = [1 - gt, 1 - St, 1 - xt, 1 - St, 1 - xt, 1 - bt, 1 - gt, 1 - bt]),
  74618. (e === Mesh.FLIP_TILE || e === Mesh.FLIP_ROW) && (Mt[1] = [1 - gt, St, 1 - xt, St, 1 - xt, bt, 1 - gt, bt]),
  74619. (e === Mesh.FLIP_N_ROTATE_TILE || e === Mesh.FLIP_N_ROTATE_ROW) && (Mt[1] = [gt, 1 - St, xt, 1 - St, xt, 1 - bt, gt, 1 - bt]);
  74620. for (var _t = 0; _t < _; _t++)
  74621. st.push(-_e + _t * i + tt, at - $ + rt, 0),
  74622. st.push(-_e + (_t + 1) * i + tt, at - $ + rt, 0),
  74623. st.push(-_e + (_t + 1) * i + tt, at + rt, 0),
  74624. st.push(-_e + _t * i + tt, at + rt, 0),
  74625. ht.push(pt, pt + 1, pt + 3, pt + 1, pt + 2, pt + 3),
  74626. pt += 4,
  74627. e === Mesh.FLIP_TILE || e === Mesh.ROTATE_TILE || e === Mesh.FLIP_N_ROTATE_TILE ? lt = lt.concat(Mt[(_t + j) % 2]) : e === Mesh.FLIP_ROW || e === Mesh.ROTATE_ROW || e === Mesh.FLIP_N_ROTATE_ROW ? lt = lt.concat(Mt[j % 2]) : lt = lt.concat(Mt[0]),
  74628. ft.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
  74629. ut.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1)
  74630. }
  74631. if (yt) {
  74632. var Pt = [];
  74633. gt = 1 - b / i,
  74634. St = 0,
  74635. xt = 1,
  74636. bt = 1,
  74637. Pt[0] = [gt, St, xt, St, xt, bt, gt, bt],
  74638. Pt[1] = [gt, St, xt, St, xt, bt, gt, bt],
  74639. (e === Mesh.ROTATE_TILE || e === Mesh.ROTATE_ROW) && (Pt[1] = [1 - gt, 1 - St, 1 - xt, 1 - St, 1 - xt, 1 - bt, 1 - gt, 1 - bt]),
  74640. (e === Mesh.FLIP_TILE || e === Mesh.FLIP_ROW) && (Pt[1] = [1 - gt, St, 1 - xt, St, 1 - xt, bt, 1 - gt, bt]),
  74641. (e === Mesh.FLIP_N_ROTATE_TILE || e === Mesh.FLIP_N_ROTATE_ROW) && (Pt[1] = [gt, 1 - St, xt, 1 - St, xt, 1 - bt, gt, 1 - bt]);
  74642. for (var dt = 0; dt < j; dt++)
  74643. st.push(it + tt, -et + dt * o + rt, 0),
  74644. st.push(it + b + tt, -et + dt * o + rt, 0),
  74645. st.push(it + b + tt, -et + (dt + 1) * o + rt, 0),
  74646. st.push(it + tt, -et + (dt + 1) * o + rt, 0),
  74647. ht.push(pt, pt + 1, pt + 3, pt + 1, pt + 2, pt + 3),
  74648. pt += 4,
  74649. e === Mesh.FLIP_TILE || e === Mesh.ROTATE_TILE || e === Mesh.FLIP_N_ROTATE_TILE ? lt = lt.concat(Pt[(dt + 1) % 2]) : e === Mesh.FLIP_ROW || e === Mesh.ROTATE_ROW || e === Mesh.FLIP_N_ROTATE_ROW ? lt = lt.concat(Pt[dt % 2]) : lt = lt.concat(Pt[0]),
  74650. ft.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
  74651. ut.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1)
  74652. }
  74653. if (Et) {
  74654. var It = [];
  74655. gt = 0,
  74656. St = 0,
  74657. xt = b / o,
  74658. bt = 1,
  74659. It[0] = [gt, St, xt, St, xt, bt, gt, bt],
  74660. It[1] = [gt, St, xt, St, xt, bt, gt, bt],
  74661. (e === Mesh.ROTATE_TILE || e === Mesh.ROTATE_ROW) && (It[1] = [1 - gt, 1 - St, 1 - xt, 1 - St, 1 - xt, 1 - bt, 1 - gt, 1 - bt]),
  74662. (e === Mesh.FLIP_TILE || e === Mesh.FLIP_ROW) && (It[1] = [1 - gt, St, 1 - xt, St, 1 - xt, bt, 1 - gt, bt]),
  74663. (e === Mesh.FLIP_N_ROTATE_TILE || e === Mesh.FLIP_N_ROTATE_ROW) && (It[1] = [gt, 1 - St, xt, 1 - St, xt, 1 - bt, gt, 1 - bt]);
  74664. for (var dt = 0; dt < j; dt++)
  74665. st.push(ot - b + tt, -et + dt * o + rt, 0),
  74666. st.push(ot + tt, -et + dt * o + rt, 0),
  74667. st.push(ot + tt, -et + (dt + 1) * o + rt, 0),
  74668. st.push(ot - b + tt, -et + (dt + 1) * o + rt, 0),
  74669. ht.push(pt, pt + 1, pt + 3, pt + 1, pt + 2, pt + 3),
  74670. pt += 4,
  74671. e === Mesh.FLIP_TILE || e === Mesh.ROTATE_TILE || e === Mesh.FLIP_N_ROTATE_TILE ? lt = lt.concat(It[(dt + _) % 2]) : e === Mesh.FLIP_ROW || e === Mesh.ROTATE_ROW || e === Mesh.FLIP_N_ROTATE_ROW ? lt = lt.concat(It[dt % 2]) : lt = lt.concat(It[0]),
  74672. ft.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
  74673. ut.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1)
  74674. }
  74675. }
  74676. var Dt = a.sideOrientation === 0 ? 0 : a.sideOrientation || VertexData.DEFAULTSIDE;
  74677. VertexData._ComputeSides(Dt, st, ht, ut, lt, a.frontUVs, a.backUVs);
  74678. var Ct = new VertexData;
  74679. Ct.indices = ht,
  74680. Ct.positions = st,
  74681. Ct.normals = ut,
  74682. Ct.uvs = lt;
  74683. var Ot = Dt === VertexData.DOUBLESIDE ? ft.concat(ft) : ft;
  74684. return Ct.colors = Ot,
  74685. Ct
  74686. }
  74687. function CreateTiledPlane(a, e, i) {
  74688. i === void 0 && (i = null);
  74689. var o = new Mesh(a,i);
  74690. e.sideOrientation = Mesh._GetDefaultSideOrientation(e.sideOrientation),
  74691. o._originalBuilderSideOrientation = e.sideOrientation;
  74692. var s = CreateTiledPlaneVertexData(e);
  74693. return s.applyToMesh(o, e.updatable),
  74694. o
  74695. }
  74696. VertexData.CreateTiledPlane = CreateTiledPlaneVertexData;
  74697. function CreateTiledBoxVertexData(a) {
  74698. for (var e = 6, i = a.faceUV || new Array(6), o = a.faceColors, s = a.pattern || Mesh.NO_FLIP, c = a.width || a.size || 1, d = a.height || a.size || 1, _ = a.depth || a.size || 1, b = a.tileWidth || a.tileSize || 1, k = a.tileHeight || a.tileSize || 1, j = a.alignHorizontal || 0, $ = a.alignVertical || 0, _e = a.sideOrientation === 0 ? 0 : a.sideOrientation || VertexData.DEFAULTSIDE, et = 0; et < e; et++)
  74699. i[et] === void 0 && (i[et] = new Vector4(0,0,1,1)),
  74700. o && o[et] === void 0 && (o[et] = new Color4(1,1,1,1));
  74701. for (var tt = c / 2, rt = d / 2, it = _ / 2, nt = [], et = 0; et < 2; et++)
  74702. nt[et] = CreateTiledPlaneVertexData({
  74703. pattern: s,
  74704. tileWidth: b,
  74705. tileHeight: k,
  74706. width: c,
  74707. height: d,
  74708. alignVertical: $,
  74709. alignHorizontal: j,
  74710. sideOrientation: _e
  74711. });
  74712. for (var et = 2; et < 4; et++)
  74713. nt[et] = CreateTiledPlaneVertexData({
  74714. pattern: s,
  74715. tileWidth: b,
  74716. tileHeight: k,
  74717. width: _,
  74718. height: d,
  74719. alignVertical: $,
  74720. alignHorizontal: j,
  74721. sideOrientation: _e
  74722. });
  74723. var ot = $;
  74724. $ === Mesh.BOTTOM ? ot = Mesh.TOP : $ === Mesh.TOP && (ot = Mesh.BOTTOM);
  74725. for (var et = 4; et < 6; et++)
  74726. nt[et] = CreateTiledPlaneVertexData({
  74727. pattern: s,
  74728. tileWidth: b,
  74729. tileHeight: k,
  74730. width: c,
  74731. height: _,
  74732. alignVertical: ot,
  74733. alignHorizontal: j,
  74734. sideOrientation: _e
  74735. });
  74736. for (var at = [], st = [], ut = [], ct = [], lt = [], ft = [], ht = [], pt = [], dt = 0, _t = 0, mt = 0, et = 0; et < e; et++) {
  74737. var dt = nt[et].positions.length;
  74738. ft[et] = [],
  74739. ht[et] = [];
  74740. for (var vt = 0; vt < dt / 3; vt++)
  74741. ft[et].push(new Vector3(nt[et].positions[3 * vt],nt[et].positions[3 * vt + 1],nt[et].positions[3 * vt + 2])),
  74742. ht[et].push(new Vector3(nt[et].normals[3 * vt],nt[et].normals[3 * vt + 1],nt[et].normals[3 * vt + 2]));
  74743. _t = nt[et].uvs.length,
  74744. pt[et] = [];
  74745. for (var yt = 0; yt < _t; yt += 2)
  74746. pt[et][yt] = i[et].x + (i[et].z - i[et].x) * nt[et].uvs[yt],
  74747. pt[et][yt + 1] = i[et].y + (i[et].w - i[et].y) * nt[et].uvs[yt + 1];
  74748. if (ut = ut.concat(pt[et]),
  74749. ct = ct.concat(nt[et].indices.map(function(wt) {
  74750. return wt + mt
  74751. })),
  74752. mt += ft[et].length,
  74753. o)
  74754. for (var Et = 0; Et < 4; Et++)
  74755. lt.push(o[et].r, o[et].g, o[et].b, o[et].a)
  74756. }
  74757. var At = new Vector3(0,0,it)
  74758. , gt = Matrix.RotationY(Math.PI);
  74759. at = ft[0].map(function(Ct) {
  74760. return Vector3.TransformNormal(Ct, gt).add(At)
  74761. }).map(function(Ct) {
  74762. return [Ct.x, Ct.y, Ct.z]
  74763. }).reduce(function(Ct, Ot) {
  74764. return Ct.concat(Ot)
  74765. }, []),
  74766. st = ht[0].map(function(Ct) {
  74767. return Vector3.TransformNormal(Ct, gt)
  74768. }).map(function(Ct) {
  74769. return [Ct.x, Ct.y, Ct.z]
  74770. }).reduce(function(Ct, Ot) {
  74771. return Ct.concat(Ot)
  74772. }, []),
  74773. at = at.concat(ft[1].map(function(Ct) {
  74774. return Ct.subtract(At)
  74775. }).map(function(Ct) {
  74776. return [Ct.x, Ct.y, Ct.z]
  74777. }).reduce(function(Ct, Ot) {
  74778. return Ct.concat(Ot)
  74779. }, [])),
  74780. st = st.concat(ht[1].map(function(Ct) {
  74781. return [Ct.x, Ct.y, Ct.z]
  74782. }).reduce(function(Ct, Ot) {
  74783. return Ct.concat(Ot)
  74784. }, []));
  74785. var St = new Vector3(tt,0,0)
  74786. , xt = Matrix.RotationY(-Math.PI / 2);
  74787. at = at.concat(ft[2].map(function(Ct) {
  74788. return Vector3.TransformNormal(Ct, xt).add(St)
  74789. }).map(function(Ct) {
  74790. return [Ct.x, Ct.y, Ct.z]
  74791. }).reduce(function(Ct, Ot) {
  74792. return Ct.concat(Ot)
  74793. }, [])),
  74794. st = st.concat(ht[2].map(function(Ct) {
  74795. return Vector3.TransformNormal(Ct, xt)
  74796. }).map(function(Ct) {
  74797. return [Ct.x, Ct.y, Ct.z]
  74798. }).reduce(function(Ct, Ot) {
  74799. return Ct.concat(Ot)
  74800. }, []));
  74801. var bt = Matrix.RotationY(Math.PI / 2);
  74802. at = at.concat(ft[3].map(function(Ct) {
  74803. return Vector3.TransformNormal(Ct, bt).subtract(St)
  74804. }).map(function(Ct) {
  74805. return [Ct.x, Ct.y, Ct.z]
  74806. }).reduce(function(Ct, Ot) {
  74807. return Ct.concat(Ot)
  74808. }, [])),
  74809. st = st.concat(ht[3].map(function(Ct) {
  74810. return Vector3.TransformNormal(Ct, bt)
  74811. }).map(function(Ct) {
  74812. return [Ct.x, Ct.y, Ct.z]
  74813. }).reduce(function(Ct, Ot) {
  74814. return Ct.concat(Ot)
  74815. }, []));
  74816. var Rt = new Vector3(0,rt,0)
  74817. , Mt = Matrix.RotationX(Math.PI / 2);
  74818. at = at.concat(ft[4].map(function(Ct) {
  74819. return Vector3.TransformNormal(Ct, Mt).add(Rt)
  74820. }).map(function(Ct) {
  74821. return [Ct.x, Ct.y, Ct.z]
  74822. }).reduce(function(Ct, Ot) {
  74823. return Ct.concat(Ot)
  74824. }, [])),
  74825. st = st.concat(ht[4].map(function(Ct) {
  74826. return Vector3.TransformNormal(Ct, Mt)
  74827. }).map(function(Ct) {
  74828. return [Ct.x, Ct.y, Ct.z]
  74829. }).reduce(function(Ct, Ot) {
  74830. return Ct.concat(Ot)
  74831. }, []));
  74832. var Pt = Matrix.RotationX(-Math.PI / 2);
  74833. at = at.concat(ft[5].map(function(Ct) {
  74834. return Vector3.TransformNormal(Ct, Pt).subtract(Rt)
  74835. }).map(function(Ct) {
  74836. return [Ct.x, Ct.y, Ct.z]
  74837. }).reduce(function(Ct, Ot) {
  74838. return Ct.concat(Ot)
  74839. }, [])),
  74840. st = st.concat(ht[5].map(function(Ct) {
  74841. return Vector3.TransformNormal(Ct, Pt)
  74842. }).map(function(Ct) {
  74843. return [Ct.x, Ct.y, Ct.z]
  74844. }).reduce(function(Ct, Ot) {
  74845. return Ct.concat(Ot)
  74846. }, [])),
  74847. VertexData._ComputeSides(_e, at, ct, st, ut);
  74848. var It = new VertexData;
  74849. if (It.indices = ct,
  74850. It.positions = at,
  74851. It.normals = st,
  74852. It.uvs = ut,
  74853. o) {
  74854. var Dt = _e === VertexData.DOUBLESIDE ? lt.concat(lt) : lt;
  74855. It.colors = Dt
  74856. }
  74857. return It
  74858. }
  74859. function CreateTiledBox(a, e, i) {
  74860. i === void 0 && (i = null);
  74861. var o = new Mesh(a,i);
  74862. e.sideOrientation = Mesh._GetDefaultSideOrientation(e.sideOrientation),
  74863. o._originalBuilderSideOrientation = e.sideOrientation;
  74864. var s = CreateTiledBoxVertexData(e);
  74865. return s.applyToMesh(o, e.updatable),
  74866. o
  74867. }
  74868. VertexData.CreateTiledBox = CreateTiledBoxVertexData;
  74869. function CreateSphereVertexData(a) {
  74870. for (var e = a.segments || 32, i = a.diameterX || a.diameter || 1, o = a.diameterY || a.diameter || 1, s = a.diameterZ || a.diameter || 1, c = a.arc && (a.arc <= 0 || a.arc > 1) ? 1 : a.arc || 1, d = a.slice && a.slice <= 0 ? 1 : a.slice || 1, _ = a.sideOrientation === 0 ? 0 : a.sideOrientation || VertexData.DEFAULTSIDE, b = !!a.dedupTopBottomIndices, k = new Vector3(i / 2,o / 2,s / 2), j = 2 + e, $ = 2 * j, _e = [], et = [], tt = [], rt = [], it = 0; it <= j; it++) {
  74871. for (var nt = it / j, ot = nt * Math.PI * d, at = 0; at <= $; at++) {
  74872. var st = at / $
  74873. , ut = st * Math.PI * 2 * c
  74874. , ct = Matrix.RotationZ(-ot)
  74875. , lt = Matrix.RotationY(ut)
  74876. , ft = Vector3.TransformCoordinates(Vector3.Up(), ct)
  74877. , ht = Vector3.TransformCoordinates(ft, lt)
  74878. , pt = ht.multiply(k)
  74879. , dt = ht.divide(k).normalize();
  74880. et.push(pt.x, pt.y, pt.z),
  74881. tt.push(dt.x, dt.y, dt.z),
  74882. rt.push(st, nt)
  74883. }
  74884. if (it > 0)
  74885. for (var _t = et.length / 3, mt = _t - 2 * ($ + 1); mt + $ + 2 < _t; mt++)
  74886. b ? (it > 1 && (_e.push(mt),
  74887. _e.push(mt + 1),
  74888. _e.push(mt + $ + 1)),
  74889. (it < j || d < 1) && (_e.push(mt + $ + 1),
  74890. _e.push(mt + 1),
  74891. _e.push(mt + $ + 2))) : (_e.push(mt),
  74892. _e.push(mt + 1),
  74893. _e.push(mt + $ + 1),
  74894. _e.push(mt + $ + 1),
  74895. _e.push(mt + 1),
  74896. _e.push(mt + $ + 2))
  74897. }
  74898. VertexData._ComputeSides(_, et, _e, tt, rt, a.frontUVs, a.backUVs);
  74899. var vt = new VertexData;
  74900. return vt.indices = _e,
  74901. vt.positions = et,
  74902. vt.normals = tt,
  74903. vt.uvs = rt,
  74904. vt
  74905. }
  74906. function CreateSphere(a, e, i) {
  74907. e === void 0 && (e = {}),
  74908. i === void 0 && (i = null);
  74909. var o = new Mesh(a,i);
  74910. e.sideOrientation = Mesh._GetDefaultSideOrientation(e.sideOrientation),
  74911. o._originalBuilderSideOrientation = e.sideOrientation;
  74912. var s = CreateSphereVertexData(e);
  74913. return s.applyToMesh(o, e.updatable),
  74914. o
  74915. }
  74916. VertexData.CreateSphere = CreateSphereVertexData;
  74917. Mesh.CreateSphere = function(a, e, i, o, s, c) {
  74918. var d = {
  74919. segments: e,
  74920. diameterX: i,
  74921. diameterY: i,
  74922. diameterZ: i,
  74923. sideOrientation: c,
  74924. updatable: s
  74925. };
  74926. return CreateSphere(a, d, o)
  74927. }
  74928. ;
  74929. function CreateCylinderVertexData(a) {
  74930. var e = a.height || 2
  74931. , i = a.diameterTop === 0 ? 0 : a.diameterTop || a.diameter || 1
  74932. , o = a.diameterBottom === 0 ? 0 : a.diameterBottom || a.diameter || 1;
  74933. i = i || 1e-5,
  74934. o = o || 1e-5;
  74935. var s = a.tessellation || 24, c = a.subdivisions || 1, d = !!a.hasRings, _ = !!a.enclose, b = a.cap === 0 ? 0 : a.cap || Mesh.CAP_ALL, k = a.arc && (a.arc <= 0 || a.arc > 1) ? 1 : a.arc || 1, j = a.sideOrientation === 0 ? 0 : a.sideOrientation || VertexData.DEFAULTSIDE, $ = a.faceUV || new Array(3), _e = a.faceColors, et = k !== 1 && _ ? 2 : 0, tt = d ? c : 1, rt = 2 + (1 + et) * tt, it;
  74936. for (it = 0; it < rt; it++)
  74937. _e && _e[it] === void 0 && (_e[it] = new Color4(1,1,1,1));
  74938. for (it = 0; it < rt; it++)
  74939. $ && $[it] === void 0 && ($[it] = new Vector4(0,0,1,1));
  74940. var nt = new Array, ot = new Array, at = new Array, st = new Array, ut = new Array, ct = Math.PI * 2 * k / s, lt, ft, ht, pt = (o - i) / 2 / e, dt = Vector3.Zero(), _t = Vector3.Zero(), mt = Vector3.Zero(), vt = Vector3.Zero(), yt = Vector3.Zero(), Et = Axis.Y, At, gt, St, xt = 1, Pt = 1, bt = 0, Rt = 0;
  74941. for (At = 0; At <= c; At++)
  74942. for (ft = At / c,
  74943. ht = (ft * (i - o) + o) / 2,
  74944. xt = d && At !== 0 && At !== c ? 2 : 1,
  74945. St = 0; St < xt; St++) {
  74946. for (d && (Pt += St),
  74947. _ && (Pt += 2 * St),
  74948. gt = 0; gt <= s; gt++)
  74949. lt = gt * ct,
  74950. dt.x = Math.cos(-lt) * ht,
  74951. dt.y = -e / 2 + ft * e,
  74952. dt.z = Math.sin(-lt) * ht,
  74953. i === 0 && At === c ? (_t.x = at[at.length - (s + 1) * 3],
  74954. _t.y = at[at.length - (s + 1) * 3 + 1],
  74955. _t.z = at[at.length - (s + 1) * 3 + 2]) : (_t.x = dt.x,
  74956. _t.z = dt.z,
  74957. _t.y = Math.sqrt(_t.x * _t.x + _t.z * _t.z) * pt,
  74958. _t.normalize()),
  74959. gt === 0 && (mt.copyFrom(dt),
  74960. vt.copyFrom(_t)),
  74961. ot.push(dt.x, dt.y, dt.z),
  74962. at.push(_t.x, _t.y, _t.z),
  74963. d ? Rt = bt !== Pt ? $[Pt].y : $[Pt].w : Rt = $[Pt].y + ($[Pt].w - $[Pt].y) * ft,
  74964. st.push($[Pt].x + ($[Pt].z - $[Pt].x) * gt / s, Rt),
  74965. _e && ut.push(_e[Pt].r, _e[Pt].g, _e[Pt].b, _e[Pt].a);
  74966. k !== 1 && _ && (ot.push(dt.x, dt.y, dt.z),
  74967. ot.push(0, dt.y, 0),
  74968. ot.push(0, dt.y, 0),
  74969. ot.push(mt.x, mt.y, mt.z),
  74970. Vector3.CrossToRef(Et, _t, yt),
  74971. yt.normalize(),
  74972. at.push(yt.x, yt.y, yt.z, yt.x, yt.y, yt.z),
  74973. Vector3.CrossToRef(vt, Et, yt),
  74974. yt.normalize(),
  74975. at.push(yt.x, yt.y, yt.z, yt.x, yt.y, yt.z),
  74976. d ? Rt = bt !== Pt ? $[Pt + 1].y : $[Pt + 1].w : Rt = $[Pt + 1].y + ($[Pt + 1].w - $[Pt + 1].y) * ft,
  74977. st.push($[Pt + 1].x, Rt),
  74978. st.push($[Pt + 1].z, Rt),
  74979. d ? Rt = bt !== Pt ? $[Pt + 2].y : $[Pt + 2].w : Rt = $[Pt + 2].y + ($[Pt + 2].w - $[Pt + 2].y) * ft,
  74980. st.push($[Pt + 2].x, Rt),
  74981. st.push($[Pt + 2].z, Rt),
  74982. _e && (ut.push(_e[Pt + 1].r, _e[Pt + 1].g, _e[Pt + 1].b, _e[Pt + 1].a),
  74983. ut.push(_e[Pt + 1].r, _e[Pt + 1].g, _e[Pt + 1].b, _e[Pt + 1].a),
  74984. ut.push(_e[Pt + 2].r, _e[Pt + 2].g, _e[Pt + 2].b, _e[Pt + 2].a),
  74985. ut.push(_e[Pt + 2].r, _e[Pt + 2].g, _e[Pt + 2].b, _e[Pt + 2].a))),
  74986. bt !== Pt && (bt = Pt)
  74987. }
  74988. var Mt = k !== 1 && _ ? s + 4 : s, Pt;
  74989. for (At = 0,
  74990. Pt = 0; Pt < c; Pt++) {
  74991. var It = 0
  74992. , Dt = 0
  74993. , Ct = 0
  74994. , Ot = 0;
  74995. for (gt = 0; gt < s; gt++)
  74996. It = At * (Mt + 1) + gt,
  74997. Dt = (At + 1) * (Mt + 1) + gt,
  74998. Ct = At * (Mt + 1) + (gt + 1),
  74999. Ot = (At + 1) * (Mt + 1) + (gt + 1),
  75000. nt.push(It, Dt, Ct),
  75001. nt.push(Ot, Ct, Dt);
  75002. k !== 1 && _ && (nt.push(It + 2, Dt + 2, Ct + 2),
  75003. nt.push(Ot + 2, Ct + 2, Dt + 2),
  75004. nt.push(It + 4, Dt + 4, Ct + 4),
  75005. nt.push(Ot + 4, Ct + 4, Dt + 4)),
  75006. At = d ? At + 2 : At + 1
  75007. }
  75008. var wt = function(Ft) {
  75009. var Vt = Ft ? i / 2 : o / 2;
  75010. if (Vt !== 0) {
  75011. var Lt, kt, Bt, Ut = Ft ? $[rt - 1] : $[0], Gt = null;
  75012. _e && (Gt = Ft ? _e[rt - 1] : _e[0]);
  75013. var Ht = ot.length / 3
  75014. , zt = Ft ? e / 2 : -e / 2
  75015. , Wt = new Vector3(0,zt,0);
  75016. ot.push(Wt.x, Wt.y, Wt.z),
  75017. at.push(0, Ft ? 1 : -1, 0),
  75018. st.push(Ut.x + (Ut.z - Ut.x) * .5, Ut.y + (Ut.w - Ut.y) * .5),
  75019. Gt && ut.push(Gt.r, Gt.g, Gt.b, Gt.a);
  75020. var Kt = new Vector2(.5,.5);
  75021. for (Bt = 0; Bt <= s; Bt++) {
  75022. Lt = Math.PI * 2 * Bt * k / s;
  75023. var Qt = Math.cos(-Lt)
  75024. , qt = Math.sin(-Lt);
  75025. kt = new Vector3(Qt * Vt,zt,qt * Vt);
  75026. var Yt = new Vector2(Qt * Kt.x + .5,qt * Kt.y + .5);
  75027. ot.push(kt.x, kt.y, kt.z),
  75028. at.push(0, Ft ? 1 : -1, 0),
  75029. st.push(Ut.x + (Ut.z - Ut.x) * Yt.x, Ut.y + (Ut.w - Ut.y) * Yt.y),
  75030. Gt && ut.push(Gt.r, Gt.g, Gt.b, Gt.a)
  75031. }
  75032. for (Bt = 0; Bt < s; Bt++)
  75033. Ft ? (nt.push(Ht),
  75034. nt.push(Ht + (Bt + 2)),
  75035. nt.push(Ht + (Bt + 1))) : (nt.push(Ht),
  75036. nt.push(Ht + (Bt + 1)),
  75037. nt.push(Ht + (Bt + 2)))
  75038. }
  75039. };
  75040. (b === Mesh.CAP_START || b === Mesh.CAP_ALL) && wt(!1),
  75041. (b === Mesh.CAP_END || b === Mesh.CAP_ALL) && wt(!0),
  75042. VertexData._ComputeSides(j, ot, nt, at, st, a.frontUVs, a.backUVs);
  75043. var Nt = new VertexData;
  75044. return Nt.indices = nt,
  75045. Nt.positions = ot,
  75046. Nt.normals = at,
  75047. Nt.uvs = st,
  75048. _e && (Nt.colors = ut),
  75049. Nt
  75050. }
  75051. function CreateCylinder(a, e, i) {
  75052. e === void 0 && (e = {});
  75053. var o = new Mesh(a,i);
  75054. e.sideOrientation = Mesh._GetDefaultSideOrientation(e.sideOrientation),
  75055. o._originalBuilderSideOrientation = e.sideOrientation;
  75056. var s = CreateCylinderVertexData(e);
  75057. return s.applyToMesh(o, e.updatable),
  75058. o
  75059. }
  75060. VertexData.CreateCylinder = CreateCylinderVertexData;
  75061. Mesh.CreateCylinder = function(a, e, i, o, s, c, d, _, b) {
  75062. (d === void 0 || !(d instanceof Scene)) && (d !== void 0 && (b = _ || Mesh.DEFAULTSIDE,
  75063. _ = d),
  75064. d = c,
  75065. c = 1);
  75066. var k = {
  75067. height: e,
  75068. diameterTop: i,
  75069. diameterBottom: o,
  75070. tessellation: s,
  75071. subdivisions: c,
  75072. sideOrientation: b,
  75073. updatable: _
  75074. };
  75075. return CreateCylinder(a, k, d)
  75076. }
  75077. ;
  75078. function CreateTorusVertexData(a) {
  75079. for (var e = [], i = [], o = [], s = [], c = a.diameter || 1, d = a.thickness || .5, _ = a.tessellation || 16, b = a.sideOrientation === 0 ? 0 : a.sideOrientation || VertexData.DEFAULTSIDE, k = _ + 1, j = 0; j <= _; j++)
  75080. for (var $ = j / _, _e = j * Math.PI * 2 / _ - Math.PI / 2, et = Matrix.Translation(c / 2, 0, 0).multiply(Matrix.RotationY(_e)), tt = 0; tt <= _; tt++) {
  75081. var rt = 1 - tt / _
  75082. , it = tt * Math.PI * 2 / _ + Math.PI
  75083. , nt = Math.cos(it)
  75084. , ot = Math.sin(it)
  75085. , at = new Vector3(nt,ot,0)
  75086. , st = at.scale(d / 2)
  75087. , ut = new Vector2($,rt);
  75088. st = Vector3.TransformCoordinates(st, et),
  75089. at = Vector3.TransformNormal(at, et),
  75090. i.push(st.x, st.y, st.z),
  75091. o.push(at.x, at.y, at.z),
  75092. s.push(ut.x, ut.y);
  75093. var ct = (j + 1) % k
  75094. , lt = (tt + 1) % k;
  75095. e.push(j * k + tt),
  75096. e.push(j * k + lt),
  75097. e.push(ct * k + tt),
  75098. e.push(j * k + lt),
  75099. e.push(ct * k + lt),
  75100. e.push(ct * k + tt)
  75101. }
  75102. VertexData._ComputeSides(b, i, e, o, s, a.frontUVs, a.backUVs);
  75103. var ft = new VertexData;
  75104. return ft.indices = e,
  75105. ft.positions = i,
  75106. ft.normals = o,
  75107. ft.uvs = s,
  75108. ft
  75109. }
  75110. function CreateTorus(a, e, i) {
  75111. e === void 0 && (e = {});
  75112. var o = new Mesh(a,i);
  75113. e.sideOrientation = Mesh._GetDefaultSideOrientation(e.sideOrientation),
  75114. o._originalBuilderSideOrientation = e.sideOrientation;
  75115. var s = CreateTorusVertexData(e);
  75116. return s.applyToMesh(o, e.updatable),
  75117. o
  75118. }
  75119. VertexData.CreateTorus = CreateTorusVertexData;
  75120. Mesh.CreateTorus = function(a, e, i, o, s, c, d) {
  75121. var _ = {
  75122. diameter: e,
  75123. thickness: i,
  75124. tessellation: o,
  75125. sideOrientation: d,
  75126. updatable: c
  75127. };
  75128. return CreateTorus(a, _, s)
  75129. }
  75130. ;
  75131. function CreateTorusKnotVertexData(a) {
  75132. var e = new Array, i = new Array, o = new Array, s = new Array, c = a.radius || 2, d = a.tube || .5, _ = a.radialSegments || 32, b = a.tubularSegments || 32, k = a.p || 2, j = a.q || 3, $ = a.sideOrientation === 0 ? 0 : a.sideOrientation || VertexData.DEFAULTSIDE, _e = function(Et) {
  75133. var At = Math.cos(Et)
  75134. , gt = Math.sin(Et)
  75135. , St = j / k * Et
  75136. , xt = Math.cos(St)
  75137. , bt = c * (2 + xt) * .5 * At
  75138. , Rt = c * (2 + xt) * gt * .5
  75139. , Mt = c * Math.sin(St) * .5;
  75140. return new Vector3(bt,Rt,Mt)
  75141. }, et, tt;
  75142. for (et = 0; et <= _; et++) {
  75143. var rt = et % _
  75144. , it = rt / _ * 2 * k * Math.PI
  75145. , nt = _e(it)
  75146. , ot = _e(it + .01)
  75147. , at = ot.subtract(nt)
  75148. , st = ot.add(nt)
  75149. , ut = Vector3.Cross(at, st);
  75150. for (st = Vector3.Cross(ut, at),
  75151. ut.normalize(),
  75152. st.normalize(),
  75153. tt = 0; tt < b; tt++) {
  75154. var ct = tt % b
  75155. , lt = ct / b * 2 * Math.PI
  75156. , ft = -d * Math.cos(lt)
  75157. , ht = d * Math.sin(lt);
  75158. i.push(nt.x + ft * st.x + ht * ut.x),
  75159. i.push(nt.y + ft * st.y + ht * ut.y),
  75160. i.push(nt.z + ft * st.z + ht * ut.z),
  75161. s.push(et / _),
  75162. s.push(tt / b)
  75163. }
  75164. }
  75165. for (et = 0; et < _; et++)
  75166. for (tt = 0; tt < b; tt++) {
  75167. var pt = (tt + 1) % b
  75168. , dt = et * b + tt
  75169. , _t = (et + 1) * b + tt
  75170. , mt = (et + 1) * b + pt
  75171. , vt = et * b + pt;
  75172. e.push(vt),
  75173. e.push(_t),
  75174. e.push(dt),
  75175. e.push(vt),
  75176. e.push(mt),
  75177. e.push(_t)
  75178. }
  75179. VertexData.ComputeNormals(i, e, o),
  75180. VertexData._ComputeSides($, i, e, o, s, a.frontUVs, a.backUVs);
  75181. var yt = new VertexData;
  75182. return yt.indices = e,
  75183. yt.positions = i,
  75184. yt.normals = o,
  75185. yt.uvs = s,
  75186. yt
  75187. }
  75188. function CreateTorusKnot(a, e, i) {
  75189. e === void 0 && (e = {});
  75190. var o = new Mesh(a,i);
  75191. e.sideOrientation = Mesh._GetDefaultSideOrientation(e.sideOrientation),
  75192. o._originalBuilderSideOrientation = e.sideOrientation;
  75193. var s = CreateTorusKnotVertexData(e);
  75194. return s.applyToMesh(o, e.updatable),
  75195. o
  75196. }
  75197. VertexData.CreateTorusKnot = CreateTorusKnotVertexData;
  75198. Mesh.CreateTorusKnot = function(a, e, i, o, s, c, d, _, b, k) {
  75199. var j = {
  75200. radius: e,
  75201. tube: i,
  75202. radialSegments: o,
  75203. tubularSegments: s,
  75204. p: c,
  75205. q: d,
  75206. sideOrientation: k,
  75207. updatable: b
  75208. };
  75209. return CreateTorusKnot(a, j, _)
  75210. }
  75211. ;
  75212. Mesh._instancedMeshFactory = function(a, e) {
  75213. var i = new InstancedMesh(a,e);
  75214. if (e.instancedBuffers) {
  75215. i.instancedBuffers = {};
  75216. for (var o in e.instancedBuffers)
  75217. i.instancedBuffers[o] = e.instancedBuffers[o]
  75218. }
  75219. return i
  75220. }
  75221. ;
  75222. var InstancedMesh = function(a) {
  75223. __extends(e, a);
  75224. function e(i, o) {
  75225. var s = a.call(this, i, o.getScene()) || this;
  75226. s._indexInSourceMeshInstanceArray = -1,
  75227. s._distanceToCamera = 0,
  75228. o.addInstance(s),
  75229. s._sourceMesh = o,
  75230. s._unIndexed = o._unIndexed,
  75231. s.position.copyFrom(o.position),
  75232. s.rotation.copyFrom(o.rotation),
  75233. s.scaling.copyFrom(o.scaling),
  75234. o.rotationQuaternion && (s.rotationQuaternion = o.rotationQuaternion.clone()),
  75235. s.animations = Tools.Slice(o.animations);
  75236. for (var c = 0, d = o.getAnimationRanges(); c < d.length; c++) {
  75237. var _ = d[c];
  75238. _ != null && s.createAnimationRange(_.name, _.from, _.to)
  75239. }
  75240. return s.infiniteDistance = o.infiniteDistance,
  75241. s.setPivotMatrix(o.getPivotMatrix()),
  75242. s.refreshBoundingInfo(),
  75243. s._syncSubMeshes(),
  75244. s
  75245. }
  75246. return e.prototype.getClassName = function() {
  75247. return "InstancedMesh"
  75248. }
  75249. ,
  75250. Object.defineProperty(e.prototype, "lightSources", {
  75251. get: function() {
  75252. return this._sourceMesh._lightSources
  75253. },
  75254. enumerable: !1,
  75255. configurable: !0
  75256. }),
  75257. e.prototype._resyncLightSources = function() {}
  75258. ,
  75259. e.prototype._resyncLightSource = function(i) {}
  75260. ,
  75261. e.prototype._removeLightSource = function(i, o) {}
  75262. ,
  75263. Object.defineProperty(e.prototype, "receiveShadows", {
  75264. get: function() {
  75265. return this._sourceMesh.receiveShadows
  75266. },
  75267. enumerable: !1,
  75268. configurable: !0
  75269. }),
  75270. Object.defineProperty(e.prototype, "material", {
  75271. get: function() {
  75272. return this._sourceMesh.material
  75273. },
  75274. enumerable: !1,
  75275. configurable: !0
  75276. }),
  75277. Object.defineProperty(e.prototype, "visibility", {
  75278. get: function() {
  75279. return this._sourceMesh.visibility
  75280. },
  75281. enumerable: !1,
  75282. configurable: !0
  75283. }),
  75284. Object.defineProperty(e.prototype, "skeleton", {
  75285. get: function() {
  75286. return this._sourceMesh.skeleton
  75287. },
  75288. enumerable: !1,
  75289. configurable: !0
  75290. }),
  75291. Object.defineProperty(e.prototype, "renderingGroupId", {
  75292. get: function() {
  75293. return this._sourceMesh.renderingGroupId
  75294. },
  75295. set: function(i) {
  75296. !this._sourceMesh || i === this._sourceMesh.renderingGroupId || Logger$2.Warn("Note - setting renderingGroupId of an instanced mesh has no effect on the scene")
  75297. },
  75298. enumerable: !1,
  75299. configurable: !0
  75300. }),
  75301. e.prototype.getTotalVertices = function() {
  75302. return this._sourceMesh ? this._sourceMesh.getTotalVertices() : 0
  75303. }
  75304. ,
  75305. e.prototype.getTotalIndices = function() {
  75306. return this._sourceMesh.getTotalIndices()
  75307. }
  75308. ,
  75309. Object.defineProperty(e.prototype, "sourceMesh", {
  75310. get: function() {
  75311. return this._sourceMesh
  75312. },
  75313. enumerable: !1,
  75314. configurable: !0
  75315. }),
  75316. e.prototype.createInstance = function(i) {
  75317. return this._sourceMesh.createInstance(i)
  75318. }
  75319. ,
  75320. e.prototype.isReady = function(i) {
  75321. return i === void 0 && (i = !1),
  75322. this._sourceMesh.isReady(i, !0)
  75323. }
  75324. ,
  75325. e.prototype.getVerticesData = function(i, o) {
  75326. return this._sourceMesh.getVerticesData(i, o)
  75327. }
  75328. ,
  75329. e.prototype.setVerticesData = function(i, o, s, c) {
  75330. return this.sourceMesh && this.sourceMesh.setVerticesData(i, o, s, c),
  75331. this.sourceMesh
  75332. }
  75333. ,
  75334. e.prototype.updateVerticesData = function(i, o, s, c) {
  75335. return this.sourceMesh && this.sourceMesh.updateVerticesData(i, o, s, c),
  75336. this.sourceMesh
  75337. }
  75338. ,
  75339. e.prototype.setIndices = function(i, o) {
  75340. return o === void 0 && (o = null),
  75341. this.sourceMesh && this.sourceMesh.setIndices(i, o),
  75342. this.sourceMesh
  75343. }
  75344. ,
  75345. e.prototype.isVerticesDataPresent = function(i) {
  75346. return this._sourceMesh.isVerticesDataPresent(i)
  75347. }
  75348. ,
  75349. e.prototype.getIndices = function() {
  75350. return this._sourceMesh.getIndices()
  75351. }
  75352. ,
  75353. Object.defineProperty(e.prototype, "_positions", {
  75354. get: function() {
  75355. return this._sourceMesh._positions
  75356. },
  75357. enumerable: !1,
  75358. configurable: !0
  75359. }),
  75360. e.prototype.refreshBoundingInfo = function(i, o) {
  75361. if (i === void 0 && (i = !1),
  75362. o === void 0 && (o = !1),
  75363. this.hasBoundingInfo && this.getBoundingInfo().isLocked)
  75364. return this;
  75365. var s = this._sourceMesh.geometry ? this._sourceMesh.geometry.boundingBias : null;
  75366. return this._refreshBoundingInfo(this._sourceMesh._getPositionData(i, o), s),
  75367. this
  75368. }
  75369. ,
  75370. e.prototype._preActivate = function() {
  75371. return this._currentLOD && this._currentLOD._preActivate(),
  75372. this
  75373. }
  75374. ,
  75375. e.prototype._activate = function(i, o) {
  75376. if (this._sourceMesh.subMeshes || Logger$2.Warn("Instances should only be created for meshes with geometry."),
  75377. this._currentLOD) {
  75378. var s = this._currentLOD._getWorldMatrixDeterminant() > 0 != this._getWorldMatrixDeterminant() > 0;
  75379. if (s)
  75380. return this._internalAbstractMeshDataInfo._actAsRegularMesh = !0,
  75381. !0;
  75382. if (this._internalAbstractMeshDataInfo._actAsRegularMesh = !1,
  75383. this._currentLOD._registerInstanceForRenderId(this, i),
  75384. o) {
  75385. if (!this._currentLOD._internalAbstractMeshDataInfo._isActiveIntermediate)
  75386. return this._currentLOD._internalAbstractMeshDataInfo._onlyForInstancesIntermediate = !0,
  75387. !0
  75388. } else if (!this._currentLOD._internalAbstractMeshDataInfo._isActive)
  75389. return this._currentLOD._internalAbstractMeshDataInfo._onlyForInstances = !0,
  75390. !0
  75391. }
  75392. return !1
  75393. }
  75394. ,
  75395. e.prototype._postActivate = function() {
  75396. this._sourceMesh.edgesShareWithInstances && this._sourceMesh._edgesRenderer && this._sourceMesh._edgesRenderer.isEnabled && this._sourceMesh._renderingGroup ? (this._sourceMesh._renderingGroup._edgesRenderers.pushNoDuplicate(this._sourceMesh._edgesRenderer),
  75397. this._sourceMesh._edgesRenderer.customInstances.push(this.getWorldMatrix())) : this._edgesRenderer && this._edgesRenderer.isEnabled && this._sourceMesh._renderingGroup && this._sourceMesh._renderingGroup._edgesRenderers.push(this._edgesRenderer)
  75398. }
  75399. ,
  75400. e.prototype.getWorldMatrix = function() {
  75401. if (this._currentLOD && this._currentLOD.billboardMode !== TransformNode.BILLBOARDMODE_NONE && this._currentLOD._masterMesh !== this) {
  75402. this._billboardWorldMatrix || (this._billboardWorldMatrix = new Matrix);
  75403. var i = this._currentLOD._masterMesh;
  75404. return this._currentLOD._masterMesh = this,
  75405. TmpVectors.Vector3[7].copyFrom(this._currentLOD.position),
  75406. this._currentLOD.position.set(0, 0, 0),
  75407. this._billboardWorldMatrix.copyFrom(this._currentLOD.computeWorldMatrix(!0)),
  75408. this._currentLOD.position.copyFrom(TmpVectors.Vector3[7]),
  75409. this._currentLOD._masterMesh = i,
  75410. this._billboardWorldMatrix
  75411. }
  75412. return a.prototype.getWorldMatrix.call(this)
  75413. }
  75414. ,
  75415. Object.defineProperty(e.prototype, "isAnInstance", {
  75416. get: function() {
  75417. return !0
  75418. },
  75419. enumerable: !1,
  75420. configurable: !0
  75421. }),
  75422. e.prototype.getLOD = function(i) {
  75423. if (!i)
  75424. return this;
  75425. var o = this.getBoundingInfo();
  75426. return this._currentLOD = this.sourceMesh.getLOD(i, o.boundingSphere),
  75427. this._currentLOD === this.sourceMesh ? this.sourceMesh : this._currentLOD
  75428. }
  75429. ,
  75430. e.prototype._preActivateForIntermediateRendering = function(i) {
  75431. return this.sourceMesh._preActivateForIntermediateRendering(i)
  75432. }
  75433. ,
  75434. e.prototype._syncSubMeshes = function() {
  75435. if (this.releaseSubMeshes(),
  75436. this._sourceMesh.subMeshes)
  75437. for (var i = 0; i < this._sourceMesh.subMeshes.length; i++)
  75438. this._sourceMesh.subMeshes[i].clone(this, this._sourceMesh);
  75439. return this
  75440. }
  75441. ,
  75442. e.prototype._generatePointsArray = function() {
  75443. return this._sourceMesh._generatePointsArray()
  75444. }
  75445. ,
  75446. e.prototype._updateBoundingInfo = function() {
  75447. var i = this;
  75448. return this.hasBoundingInfo ? this.getBoundingInfo().update(i.worldMatrixFromCache) : this.buildBoundingInfo(this.absolutePosition, this.absolutePosition, i.worldMatrixFromCache),
  75449. this._updateSubMeshesBoundingInfo(i.worldMatrixFromCache),
  75450. this
  75451. }
  75452. ,
  75453. e.prototype.clone = function(i, o, s) {
  75454. o === void 0 && (o = null);
  75455. var c = this._sourceMesh.createInstance(i);
  75456. if (DeepCopier.DeepCopy(this, c, ["name", "subMeshes", "uniqueId", "parent", "lightSources", "receiveShadows", "material", "visibility", "skeleton", "sourceMesh", "isAnInstance", "facetNb", "isFacetDataEnabled", "isBlocked", "useBones", "hasInstances", "collider", "edgesRenderer", "forward", "up", "right", "absolutePosition", "absoluteScaling", "absoluteRotationQuaternion", "isWorldMatrixFrozen", "nonUniformScaling", "behaviors", "worldMatrixFromCache", "hasThinInstances"], []),
  75457. this.refreshBoundingInfo(),
  75458. o && (c.parent = o),
  75459. !s)
  75460. for (var d = 0; d < this.getScene().meshes.length; d++) {
  75461. var _ = this.getScene().meshes[d];
  75462. _.parent === this && _.clone(_.name, c)
  75463. }
  75464. return c.computeWorldMatrix(!0),
  75465. this.onClonedObservable.notifyObservers(c),
  75466. c
  75467. }
  75468. ,
  75469. e.prototype.dispose = function(i, o) {
  75470. o === void 0 && (o = !1),
  75471. this._sourceMesh.removeInstance(this),
  75472. a.prototype.dispose.call(this, i, o)
  75473. }
  75474. ,
  75475. e
  75476. }(AbstractMesh);
  75477. Mesh.prototype.edgesShareWithInstances = !1;
  75478. Mesh.prototype.registerInstancedBuffer = function(a, e) {
  75479. var i, o;
  75480. if ((o = (i = this._userInstancedBuffersStorage) === null || i === void 0 ? void 0 : i.vertexBuffers[a]) === null || o === void 0 || o.dispose(),
  75481. !this.instancedBuffers) {
  75482. this.instancedBuffers = {};
  75483. for (var s = 0, c = this.instances; s < c.length; s++) {
  75484. var d = c[s];
  75485. d.instancedBuffers = {}
  75486. }
  75487. this._userInstancedBuffersStorage = {
  75488. data: {},
  75489. vertexBuffers: {},
  75490. strides: {},
  75491. sizes: {},
  75492. vertexArrayObjects: this.getEngine().getCaps().vertexArrayObject ? {} : void 0
  75493. }
  75494. }
  75495. this.instancedBuffers[a] = null,
  75496. this._userInstancedBuffersStorage.strides[a] = e,
  75497. this._userInstancedBuffersStorage.sizes[a] = e * 32,
  75498. this._userInstancedBuffersStorage.data[a] = new Float32Array(this._userInstancedBuffersStorage.sizes[a]),
  75499. this._userInstancedBuffersStorage.vertexBuffers[a] = new VertexBuffer(this.getEngine(),this._userInstancedBuffersStorage.data[a],a,!0,!1,e,!0);
  75500. for (var _ = 0, b = this.instances; _ < b.length; _++) {
  75501. var d = b[_];
  75502. d.instancedBuffers[a] = null
  75503. }
  75504. this._invalidateInstanceVertexArrayObject()
  75505. }
  75506. ;
  75507. Mesh.prototype._processInstancedBuffers = function(a, e) {
  75508. var i = a.length;
  75509. for (var o in this.instancedBuffers) {
  75510. for (var s = this._userInstancedBuffersStorage.sizes[o], c = this._userInstancedBuffersStorage.strides[o], d = (i + 1) * c; s < d; )
  75511. s *= 2;
  75512. this._userInstancedBuffersStorage.data[o].length != s && (this._userInstancedBuffersStorage.data[o] = new Float32Array(s),
  75513. this._userInstancedBuffersStorage.sizes[o] = s,
  75514. this._userInstancedBuffersStorage.vertexBuffers[o] && (this._userInstancedBuffersStorage.vertexBuffers[o].dispose(),
  75515. this._userInstancedBuffersStorage.vertexBuffers[o] = null));
  75516. var _ = this._userInstancedBuffersStorage.data[o]
  75517. , b = 0;
  75518. if (e) {
  75519. var k = this.instancedBuffers[o];
  75520. k.toArray ? k.toArray(_, b) : k.copyToArray ? k.copyToArray(_, b) : _[b] = k,
  75521. b += c
  75522. }
  75523. for (var j = 0; j < i; j++) {
  75524. var $ = a[j]
  75525. , k = $.instancedBuffers[o];
  75526. k.toArray ? k.toArray(_, b) : k.copyToArray ? k.copyToArray(_, b) : _[b] = k,
  75527. b += c
  75528. }
  75529. this._userInstancedBuffersStorage.vertexBuffers[o] ? this._userInstancedBuffersStorage.vertexBuffers[o].updateDirectly(_, 0) : (this._userInstancedBuffersStorage.vertexBuffers[o] = new VertexBuffer(this.getEngine(),this._userInstancedBuffersStorage.data[o],o,!0,!1,c,!0),
  75530. this._invalidateInstanceVertexArrayObject())
  75531. }
  75532. }
  75533. ;
  75534. Mesh.prototype._invalidateInstanceVertexArrayObject = function() {
  75535. if (!(!this._userInstancedBuffersStorage || this._userInstancedBuffersStorage.vertexArrayObjects === void 0)) {
  75536. for (var a in this._userInstancedBuffersStorage.vertexArrayObjects)
  75537. this.getEngine().releaseVertexArrayObject(this._userInstancedBuffersStorage.vertexArrayObjects[a]);
  75538. this._userInstancedBuffersStorage.vertexArrayObjects = {}
  75539. }
  75540. }
  75541. ;
  75542. Mesh.prototype._disposeInstanceSpecificData = function() {
  75543. for (this._instanceDataStorage.instancesBuffer && (this._instanceDataStorage.instancesBuffer.dispose(),
  75544. this._instanceDataStorage.instancesBuffer = null); this.instances.length; )
  75545. this.instances[0].dispose();
  75546. for (var a in this.instancedBuffers)
  75547. this._userInstancedBuffersStorage.vertexBuffers[a] && this._userInstancedBuffersStorage.vertexBuffers[a].dispose();
  75548. this._invalidateInstanceVertexArrayObject(),
  75549. this.instancedBuffers = {}
  75550. }
  75551. ;
  75552. var name$1o = "colorPixelShader"
  75553. , shader$1o = `#ifdef VERTEXCOLOR
  75554. varying vec4 vColor;
  75555. #else
  75556. uniform vec4 color;
  75557. #endif
  75558. #include<clipPlaneFragmentDeclaration>
  75559. void main(void) {
  75560. #include<clipPlaneFragment>
  75561. #ifdef VERTEXCOLOR
  75562. gl_FragColor=vColor;
  75563. #else
  75564. gl_FragColor=color;
  75565. #endif
  75566. }`;
  75567. ShaderStore.ShadersStore[name$1o] = shader$1o;
  75568. var name$1n = "colorVertexShader"
  75569. , shader$1n = `
  75570. attribute vec3 position;
  75571. #ifdef VERTEXCOLOR
  75572. attribute vec4 color;
  75573. #endif
  75574. #include<bonesDeclaration>
  75575. #include<bakedVertexAnimationDeclaration>
  75576. #include<clipPlaneVertexDeclaration>
  75577. #include<instancesDeclaration>
  75578. uniform mat4 viewProjection;
  75579. #ifdef MULTIVIEW
  75580. uniform mat4 viewProjectionR;
  75581. #endif
  75582. #ifdef VERTEXCOLOR
  75583. varying vec4 vColor;
  75584. #endif
  75585. void main(void) {
  75586. #include<instancesVertex>
  75587. #include<bonesVertex>
  75588. #include<bakedVertexAnimation>
  75589. vec4 worldPos=finalWorld*vec4(position,1.0);
  75590. #ifdef MULTIVIEW
  75591. if (gl_ViewID_OVR == 0u) {
  75592. gl_Position=viewProjection*worldPos;
  75593. } else {
  75594. gl_Position=viewProjectionR*worldPos;
  75595. }
  75596. #else
  75597. gl_Position=viewProjection*worldPos;
  75598. #endif
  75599. #include<clipPlaneVertex>
  75600. #ifdef VERTEXCOLOR
  75601. vColor=color;
  75602. #endif
  75603. }`;
  75604. ShaderStore.ShadersStore[name$1n] = shader$1n;
  75605. Mesh._LinesMeshParser = function(a, e) {
  75606. return LinesMesh.Parse(a, e)
  75607. }
  75608. ;
  75609. var LinesMesh = function(a) {
  75610. __extends(e, a);
  75611. function e(i, o, s, c, d, _, b, k) {
  75612. o === void 0 && (o = null),
  75613. s === void 0 && (s = null),
  75614. c === void 0 && (c = null);
  75615. var j = a.call(this, i, o, s, c, d) || this;
  75616. j.useVertexColor = _,
  75617. j.useVertexAlpha = b,
  75618. j.color = new Color3(1,1,1),
  75619. j.alpha = 1,
  75620. c && (j.color = c.color.clone(),
  75621. j.alpha = c.alpha,
  75622. j.useVertexColor = c.useVertexColor,
  75623. j.useVertexAlpha = c.useVertexAlpha),
  75624. j.intersectionThreshold = .1;
  75625. var $ = []
  75626. , _e = {
  75627. attributes: [VertexBuffer.PositionKind],
  75628. uniforms: ["vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "world", "viewProjection"],
  75629. needAlphaBlending: !0,
  75630. defines: $,
  75631. useClipPlane: null
  75632. };
  75633. return b === !1 && (_e.needAlphaBlending = !1),
  75634. _ ? (_e.defines.push("#define VERTEXCOLOR"),
  75635. _e.attributes.push(VertexBuffer.ColorKind)) : (_e.uniforms.push("color"),
  75636. j.color4 = new Color4),
  75637. k ? j.material = k : j._lineMaterial = new ShaderMaterial("colorShader",j.getScene(),"color",_e,!1),
  75638. j
  75639. }
  75640. return e.prototype._isShaderMaterial = function(i) {
  75641. return i.getClassName() === "ShaderMaterial"
  75642. }
  75643. ,
  75644. e.prototype.isReady = function() {
  75645. return this._lineMaterial.isReady(this, !!this._userInstancedBuffersStorage) ? a.prototype.isReady.call(this) : !1
  75646. }
  75647. ,
  75648. e.prototype.getClassName = function() {
  75649. return "LinesMesh"
  75650. }
  75651. ,
  75652. Object.defineProperty(e.prototype, "material", {
  75653. get: function() {
  75654. return this._lineMaterial
  75655. },
  75656. set: function(i) {
  75657. this._lineMaterial = i
  75658. },
  75659. enumerable: !1,
  75660. configurable: !0
  75661. }),
  75662. Object.defineProperty(e.prototype, "checkCollisions", {
  75663. get: function() {
  75664. return !1
  75665. },
  75666. set: function(i) {},
  75667. enumerable: !1,
  75668. configurable: !0
  75669. }),
  75670. e.prototype._bind = function(i, o, s) {
  75671. if (!this._geometry)
  75672. return this;
  75673. var c = this._lineMaterial.getEffect()
  75674. , d = this.isUnIndexed ? null : this._geometry.getIndexBuffer();
  75675. if (this._userInstancedBuffersStorage ? this._geometry._bind(c, d, this._userInstancedBuffersStorage.vertexBuffers, this._userInstancedBuffersStorage.vertexArrayObjects) : this._geometry._bind(c, d),
  75676. !this.useVertexColor && this._isShaderMaterial(this._lineMaterial)) {
  75677. var _ = this.color
  75678. , b = _.r
  75679. , k = _.g
  75680. , j = _.b;
  75681. this.color4.set(b, k, j, this.alpha),
  75682. this._lineMaterial.setColor4("color", this.color4)
  75683. }
  75684. return this
  75685. }
  75686. ,
  75687. e.prototype._draw = function(i, o, s) {
  75688. if (!this._geometry || !this._geometry.getVertexBuffers() || !this._unIndexed && !this._geometry.getIndexBuffer())
  75689. return this;
  75690. var c = this.getScene().getEngine();
  75691. return this._unIndexed ? c.drawArraysType(Material.LineListDrawMode, i.verticesStart, i.verticesCount, s) : c.drawElementsType(Material.LineListDrawMode, i.indexStart, i.indexCount, s),
  75692. this
  75693. }
  75694. ,
  75695. e.prototype.dispose = function(i) {
  75696. this._lineMaterial.dispose(!1, !1, !0),
  75697. a.prototype.dispose.call(this, i)
  75698. }
  75699. ,
  75700. e.prototype.clone = function(i, o, s) {
  75701. return o === void 0 && (o = null),
  75702. new e(i,this.getScene(),o,this,s)
  75703. }
  75704. ,
  75705. e.prototype.createInstance = function(i) {
  75706. var o = new InstancedLinesMesh(i,this);
  75707. if (this.instancedBuffers) {
  75708. o.instancedBuffers = {};
  75709. for (var s in this.instancedBuffers)
  75710. o.instancedBuffers[s] = this.instancedBuffers[s]
  75711. }
  75712. return o
  75713. }
  75714. ,
  75715. e.prototype.serialize = function(i) {
  75716. a.prototype.serialize.call(this, i),
  75717. i.color = this.color.asArray(),
  75718. i.alpha = this.alpha
  75719. }
  75720. ,
  75721. e.Parse = function(i, o) {
  75722. var s = new e(i.name,o);
  75723. return s.color = Color3.FromArray(i.color),
  75724. s.alpha = i.alpha,
  75725. s
  75726. }
  75727. ,
  75728. e
  75729. }(Mesh)
  75730. , InstancedLinesMesh = function(a) {
  75731. __extends(e, a);
  75732. function e(i, o) {
  75733. var s = a.call(this, i, o) || this;
  75734. return s.intersectionThreshold = o.intersectionThreshold,
  75735. s
  75736. }
  75737. return e.prototype.getClassName = function() {
  75738. return "InstancedLinesMesh"
  75739. }
  75740. ,
  75741. e
  75742. }(InstancedMesh);
  75743. function CreateLineSystemVertexData(a) {
  75744. for (var e = [], i = [], o = a.lines, s = a.colors, c = [], d = 0, _ = 0; _ < o.length; _++)
  75745. for (var b = o[_], k = 0; k < b.length; k++) {
  75746. if (i.push(b[k].x, b[k].y, b[k].z),
  75747. s) {
  75748. var j = s[_];
  75749. c.push(j[k].r, j[k].g, j[k].b, j[k].a)
  75750. }
  75751. k > 0 && (e.push(d - 1),
  75752. e.push(d)),
  75753. d++
  75754. }
  75755. var $ = new VertexData;
  75756. return $.indices = e,
  75757. $.positions = i,
  75758. s && ($.colors = c),
  75759. $
  75760. }
  75761. function CreateDashedLinesVertexData(a) {
  75762. var e = a.dashSize || 3
  75763. , i = a.gapSize || 1
  75764. , o = a.dashNb || 200
  75765. , s = a.points
  75766. , c = new Array
  75767. , d = new Array
  75768. , _ = Vector3.Zero()
  75769. , b = 0
  75770. , k = 0
  75771. , j = 0
  75772. , $ = 0
  75773. , _e = 0
  75774. , et = 0
  75775. , tt = 0;
  75776. for (tt = 0; tt < s.length - 1; tt++)
  75777. s[tt + 1].subtractToRef(s[tt], _),
  75778. b += _.length();
  75779. for (j = b / o,
  75780. $ = e * j / (e + i),
  75781. tt = 0; tt < s.length - 1; tt++) {
  75782. s[tt + 1].subtractToRef(s[tt], _),
  75783. k = Math.floor(_.length() / j),
  75784. _.normalize();
  75785. for (var rt = 0; rt < k; rt++)
  75786. _e = j * rt,
  75787. c.push(s[tt].x + _e * _.x, s[tt].y + _e * _.y, s[tt].z + _e * _.z),
  75788. c.push(s[tt].x + (_e + $) * _.x, s[tt].y + (_e + $) * _.y, s[tt].z + (_e + $) * _.z),
  75789. d.push(et, et + 1),
  75790. et += 2
  75791. }
  75792. var it = new VertexData;
  75793. return it.positions = c,
  75794. it.indices = d,
  75795. it
  75796. }
  75797. function CreateLineSystem(a, e, i) {
  75798. var o = e.instance
  75799. , s = e.lines
  75800. , c = e.colors;
  75801. if (o) {
  75802. var d = o.getVerticesData(VertexBuffer.PositionKind), _, b;
  75803. c && (_ = o.getVerticesData(VertexBuffer.ColorKind));
  75804. for (var k = 0, j = 0, $ = 0; $ < s.length; $++)
  75805. for (var _e = s[$], et = 0; et < _e.length; et++)
  75806. d[k] = _e[et].x,
  75807. d[k + 1] = _e[et].y,
  75808. d[k + 2] = _e[et].z,
  75809. c && _ && (b = c[$],
  75810. _[j] = b[et].r,
  75811. _[j + 1] = b[et].g,
  75812. _[j + 2] = b[et].b,
  75813. _[j + 3] = b[et].a,
  75814. j += 4),
  75815. k += 3;
  75816. return o.updateVerticesData(VertexBuffer.PositionKind, d, !1, !1),
  75817. c && _ && o.updateVerticesData(VertexBuffer.ColorKind, _, !1, !1),
  75818. o
  75819. }
  75820. var tt = !!c
  75821. , rt = new LinesMesh(a,i,null,void 0,void 0,tt,e.useVertexAlpha,e.material)
  75822. , it = CreateLineSystemVertexData(e);
  75823. return it.applyToMesh(rt, e.updatable),
  75824. rt
  75825. }
  75826. function CreateLines(a, e, i) {
  75827. i === void 0 && (i = null);
  75828. var o = e.colors ? [e.colors] : null
  75829. , s = CreateLineSystem(a, {
  75830. lines: [e.points],
  75831. updatable: e.updatable,
  75832. instance: e.instance,
  75833. colors: o,
  75834. useVertexAlpha: e.useVertexAlpha,
  75835. material: e.material
  75836. }, i);
  75837. return s
  75838. }
  75839. function CreateDashedLines(a, e, i) {
  75840. i === void 0 && (i = null);
  75841. var o = e.points
  75842. , s = e.instance
  75843. , c = e.gapSize || 1
  75844. , d = e.dashSize || 3;
  75845. if (s) {
  75846. var _ = function(j) {
  75847. var $ = Vector3.Zero()
  75848. , _e = j.length / 6
  75849. , et = 0
  75850. , tt = 0
  75851. , rt = 0
  75852. , it = 0
  75853. , nt = 0
  75854. , ot = 0
  75855. , at = 0
  75856. , st = 0;
  75857. for (at = 0; at < o.length - 1; at++)
  75858. o[at + 1].subtractToRef(o[at], $),
  75859. et += $.length();
  75860. rt = et / _e;
  75861. var ut = s._creationDataStorage.dashSize
  75862. , ct = s._creationDataStorage.gapSize;
  75863. for (it = ut * rt / (ut + ct),
  75864. at = 0; at < o.length - 1; at++)
  75865. for (o[at + 1].subtractToRef(o[at], $),
  75866. tt = Math.floor($.length() / rt),
  75867. $.normalize(),
  75868. st = 0; st < tt && ot < j.length; )
  75869. nt = rt * st,
  75870. j[ot] = o[at].x + nt * $.x,
  75871. j[ot + 1] = o[at].y + nt * $.y,
  75872. j[ot + 2] = o[at].z + nt * $.z,
  75873. j[ot + 3] = o[at].x + (nt + it) * $.x,
  75874. j[ot + 4] = o[at].y + (nt + it) * $.y,
  75875. j[ot + 5] = o[at].z + (nt + it) * $.z,
  75876. ot += 6,
  75877. st++;
  75878. for (; ot < j.length; )
  75879. j[ot] = o[at].x,
  75880. j[ot + 1] = o[at].y,
  75881. j[ot + 2] = o[at].z,
  75882. ot += 3
  75883. };
  75884. return s.updateMeshPositions(_, !1),
  75885. s
  75886. }
  75887. var b = new LinesMesh(a,i,null,void 0,void 0,void 0,e.useVertexAlpha,e.material)
  75888. , k = CreateDashedLinesVertexData(e);
  75889. return k.applyToMesh(b, e.updatable),
  75890. b._creationDataStorage = new _CreationDataStorage,
  75891. b._creationDataStorage.dashSize = d,
  75892. b._creationDataStorage.gapSize = c,
  75893. b
  75894. }
  75895. VertexData.CreateLineSystem = CreateLineSystemVertexData;
  75896. VertexData.CreateDashedLines = CreateDashedLinesVertexData;
  75897. Mesh.CreateLines = function(a, e, i, o, s) {
  75898. i === void 0 && (i = null),
  75899. o === void 0 && (o = !1),
  75900. s === void 0 && (s = null);
  75901. var c = {
  75902. points: e,
  75903. updatable: o,
  75904. instance: s
  75905. };
  75906. return CreateLines(a, c, i)
  75907. }
  75908. ;
  75909. Mesh.CreateDashedLines = function(a, e, i, o, s, c, d, _) {
  75910. c === void 0 && (c = null);
  75911. var b = {
  75912. points: e,
  75913. dashSize: i,
  75914. gapSize: o,
  75915. dashNb: s,
  75916. updatable: d,
  75917. instance: _
  75918. };
  75919. return CreateDashedLines(a, b, c)
  75920. }
  75921. ;
  75922. var IndexedVector2 = function(a) {
  75923. __extends(e, a);
  75924. function e(i, o) {
  75925. var s = a.call(this, i.x, i.y) || this;
  75926. return s.index = o,
  75927. s
  75928. }
  75929. return e
  75930. }(Vector2)
  75931. , PolygonPoints = function() {
  75932. function a() {
  75933. this.elements = new Array
  75934. }
  75935. return a.prototype.add = function(e) {
  75936. var i = this
  75937. , o = new Array;
  75938. return e.forEach(function(s) {
  75939. var c = new IndexedVector2(s,i.elements.length);
  75940. o.push(c),
  75941. i.elements.push(c)
  75942. }),
  75943. o
  75944. }
  75945. ,
  75946. a.prototype.computeBounds = function() {
  75947. var e = new Vector2(this.elements[0].x,this.elements[0].y)
  75948. , i = new Vector2(this.elements[0].x,this.elements[0].y);
  75949. return this.elements.forEach(function(o) {
  75950. o.x < e.x ? e.x = o.x : o.x > i.x && (i.x = o.x),
  75951. o.y < e.y ? e.y = o.y : o.y > i.y && (i.y = o.y)
  75952. }),
  75953. {
  75954. min: e,
  75955. max: i,
  75956. width: i.x - e.x,
  75957. height: i.y - e.y
  75958. }
  75959. }
  75960. ,
  75961. a
  75962. }()
  75963. , PolygonMeshBuilder = function() {
  75964. function a(e, i, o, s) {
  75965. s === void 0 && (s = earcut),
  75966. this._points = new PolygonPoints,
  75967. this._outlinepoints = new PolygonPoints,
  75968. this._holes = new Array,
  75969. this._epoints = new Array,
  75970. this._eholes = new Array,
  75971. this.bjsEarcut = s,
  75972. this._name = e,
  75973. this._scene = o || Engine.LastCreatedScene;
  75974. var c;
  75975. i instanceof Path2 ? c = i.getPoints() : c = i,
  75976. this._addToepoint(c),
  75977. this._points.add(c),
  75978. this._outlinepoints.add(c),
  75979. typeof this.bjsEarcut == "undefined" && Logger$2.Warn("Earcut was not found, the polygon will not be built.")
  75980. }
  75981. return a.prototype._addToepoint = function(e) {
  75982. for (var i = 0, o = e; i < o.length; i++) {
  75983. var s = o[i];
  75984. this._epoints.push(s.x, s.y)
  75985. }
  75986. }
  75987. ,
  75988. a.prototype.addHole = function(e) {
  75989. this._points.add(e);
  75990. var i = new PolygonPoints;
  75991. return i.add(e),
  75992. this._holes.push(i),
  75993. this._eholes.push(this._epoints.length / 2),
  75994. this._addToepoint(e),
  75995. this
  75996. }
  75997. ,
  75998. a.prototype.build = function(e, i, o) {
  75999. e === void 0 && (e = !1),
  76000. i === void 0 && (i = 0),
  76001. o === void 0 && (o = 2);
  76002. var s = new Mesh(this._name,this._scene)
  76003. , c = this.buildVertexData(i, o);
  76004. return s.setVerticesData(VertexBuffer.PositionKind, c.positions, e),
  76005. s.setVerticesData(VertexBuffer.NormalKind, c.normals, e),
  76006. s.setVerticesData(VertexBuffer.UVKind, c.uvs, e),
  76007. s.setIndices(c.indices),
  76008. s
  76009. }
  76010. ,
  76011. a.prototype.buildVertexData = function(e, i) {
  76012. var o = this;
  76013. e === void 0 && (e = 0),
  76014. i === void 0 && (i = 2);
  76015. var s = new VertexData
  76016. , c = new Array
  76017. , d = new Array
  76018. , _ = new Array
  76019. , b = this._points.computeBounds();
  76020. this._points.elements.forEach(function(nt) {
  76021. c.push(0, 1, 0),
  76022. d.push(nt.x, 0, nt.y),
  76023. _.push((nt.x - b.min.x) / b.width, (nt.y - b.min.y) / b.height)
  76024. });
  76025. for (var k = new Array, j = this.bjsEarcut(this._epoints, this._eholes, 2), $ = 0; $ < j.length; $++)
  76026. k.push(j[$]);
  76027. if (e > 0) {
  76028. var _e = d.length / 3;
  76029. this._points.elements.forEach(function(nt) {
  76030. c.push(0, -1, 0),
  76031. d.push(nt.x, -e, nt.y),
  76032. _.push(1 - (nt.x - b.min.x) / b.width, 1 - (nt.y - b.min.y) / b.height)
  76033. });
  76034. for (var et = k.length, $ = 0; $ < et; $ += 3) {
  76035. var tt = k[$ + 0]
  76036. , rt = k[$ + 1]
  76037. , it = k[$ + 2];
  76038. k.push(it + _e),
  76039. k.push(rt + _e),
  76040. k.push(tt + _e)
  76041. }
  76042. this.addSide(d, c, _, k, b, this._outlinepoints, e, !1, i),
  76043. this._holes.forEach(function(nt) {
  76044. o.addSide(d, c, _, k, b, nt, e, !0, i)
  76045. })
  76046. }
  76047. return s.indices = k,
  76048. s.positions = d,
  76049. s.normals = c,
  76050. s.uvs = _,
  76051. s
  76052. }
  76053. ,
  76054. a.prototype.addSide = function(e, i, o, s, c, d, _, b, k) {
  76055. for (var j = e.length / 3, $ = 0, _e = 0; _e < d.elements.length; _e++) {
  76056. var et = d.elements[_e]
  76057. , tt = d.elements[(_e + 1) % d.elements.length];
  76058. e.push(et.x, 0, et.y),
  76059. e.push(et.x, -_, et.y),
  76060. e.push(tt.x, 0, tt.y),
  76061. e.push(tt.x, -_, tt.y);
  76062. var rt = d.elements[(_e + d.elements.length - 1) % d.elements.length]
  76063. , it = d.elements[(_e + 2) % d.elements.length]
  76064. , nt = new Vector3(-(tt.y - et.y),0,tt.x - et.x)
  76065. , ot = new Vector3(-(et.y - rt.y),0,et.x - rt.x)
  76066. , at = new Vector3(-(it.y - tt.y),0,it.x - tt.x);
  76067. b || (nt = nt.scale(-1),
  76068. ot = ot.scale(-1),
  76069. at = at.scale(-1));
  76070. var st = nt.normalizeToNew()
  76071. , ut = ot.normalizeToNew()
  76072. , ct = at.normalizeToNew()
  76073. , lt = Vector3.Dot(ut, st);
  76074. lt > k ? lt < Epsilon - 1 ? ut = new Vector3(et.x,0,et.y).subtract(new Vector3(tt.x,0,tt.y)).normalize() : ut = ot.add(nt).normalize() : ut = st;
  76075. var ft = Vector3.Dot(at, nt);
  76076. ft > k ? ft < Epsilon - 1 ? ct = new Vector3(tt.x,0,tt.y).subtract(new Vector3(et.x,0,et.y)).normalize() : ct = at.add(nt).normalize() : ct = st,
  76077. o.push($ / c.width, 0),
  76078. o.push($ / c.width, 1),
  76079. $ += nt.length(),
  76080. o.push($ / c.width, 0),
  76081. o.push($ / c.width, 1),
  76082. i.push(ut.x, ut.y, ut.z),
  76083. i.push(ut.x, ut.y, ut.z),
  76084. i.push(ct.x, ct.y, ct.z),
  76085. i.push(ct.x, ct.y, ct.z),
  76086. b ? (s.push(j),
  76087. s.push(j + 2),
  76088. s.push(j + 1),
  76089. s.push(j + 1),
  76090. s.push(j + 2),
  76091. s.push(j + 3)) : (s.push(j),
  76092. s.push(j + 1),
  76093. s.push(j + 2),
  76094. s.push(j + 1),
  76095. s.push(j + 3),
  76096. s.push(j + 2)),
  76097. j += 4
  76098. }
  76099. }
  76100. ,
  76101. a
  76102. }();
  76103. function CreatePolygonVertexData(a, e, i, o, s, c, d) {
  76104. for (var _ = i || new Array(3), b = o, k = [], j = d || !1, $ = 0; $ < 3; $++)
  76105. _[$] === void 0 && (_[$] = new Vector4(0,0,1,1)),
  76106. b && b[$] === void 0 && (b[$] = new Color4(1,1,1,1));
  76107. var _e = a.getVerticesData(VertexBuffer.PositionKind)
  76108. , et = a.getVerticesData(VertexBuffer.NormalKind)
  76109. , tt = a.getVerticesData(VertexBuffer.UVKind)
  76110. , rt = a.getIndices()
  76111. , it = _e.length / 9
  76112. , nt = 0
  76113. , ot = 0
  76114. , at = 0
  76115. , st = 0
  76116. , ut = 0
  76117. , ct = [0];
  76118. if (j)
  76119. for (var lt = it; lt < _e.length / 3; lt += 4)
  76120. ot = _e[3 * (lt + 2)] - _e[3 * lt],
  76121. at = _e[3 * (lt + 2) + 2] - _e[3 * lt + 2],
  76122. st = Math.sqrt(ot * ot + at * at),
  76123. ut += st,
  76124. ct.push(ut);
  76125. for (var lt = 0, ft = 0, ht = 0; ht < et.length; ht += 3)
  76126. Math.abs(et[ht + 1]) < .001 && (ft = 1),
  76127. Math.abs(et[ht + 1] - 1) < .001 && (ft = 0),
  76128. Math.abs(et[ht + 1] + 1) < .001 && (ft = 2),
  76129. lt = ht / 3,
  76130. ft === 1 ? (nt = lt - it,
  76131. nt % 4 < 1.5 ? j ? tt[2 * lt] = _[ft].x + (_[ft].z - _[ft].x) * ct[Math.floor(nt / 4)] / ut : tt[2 * lt] = _[ft].x : j ? tt[2 * lt] = _[ft].x + (_[ft].z - _[ft].x) * ct[Math.floor(nt / 4) + 1] / ut : tt[2 * lt] = _[ft].z,
  76132. nt % 2 === 0 ? tt[2 * lt + 1] = _[ft].w : tt[2 * lt + 1] = _[ft].y) : (tt[2 * lt] = (1 - tt[2 * lt]) * _[ft].x + tt[2 * lt] * _[ft].z,
  76133. tt[2 * lt + 1] = (1 - tt[2 * lt + 1]) * _[ft].y + tt[2 * lt + 1] * _[ft].w),
  76134. b && k.push(b[ft].r, b[ft].g, b[ft].b, b[ft].a);
  76135. VertexData._ComputeSides(e, _e, rt, et, tt, s, c);
  76136. var pt = new VertexData;
  76137. if (pt.indices = rt,
  76138. pt.positions = _e,
  76139. pt.normals = et,
  76140. pt.uvs = tt,
  76141. b) {
  76142. var dt = e === VertexData.DOUBLESIDE ? k.concat(k) : k;
  76143. pt.colors = dt
  76144. }
  76145. return pt
  76146. }
  76147. function CreatePolygon(a, e, i, o) {
  76148. i === void 0 && (i = null),
  76149. o === void 0 && (o = earcut),
  76150. e.sideOrientation = Mesh._GetDefaultSideOrientation(e.sideOrientation);
  76151. for (var s = e.shape, c = e.holes || [], d = e.depth || 0, _ = e.smoothingThreshold || 2, b = [], k = [], j = 0; j < s.length; j++)
  76152. b[j] = new Vector2(s[j].x,s[j].z);
  76153. var $ = 1e-8;
  76154. b[0].equalsWithEpsilon(b[b.length - 1], $) && b.pop();
  76155. for (var _e = new PolygonMeshBuilder(a,b,i || EngineStore.LastCreatedScene,o), et = 0; et < c.length; et++) {
  76156. k = [];
  76157. for (var tt = 0; tt < c[et].length; tt++)
  76158. k.push(new Vector2(c[et][tt].x,c[et][tt].z));
  76159. _e.addHole(k)
  76160. }
  76161. var rt = _e.build(e.updatable, d, _);
  76162. rt._originalBuilderSideOrientation = e.sideOrientation;
  76163. var it = CreatePolygonVertexData(rt, e.sideOrientation, e.faceUV, e.faceColors, e.frontUVs, e.backUVs, e.wrap);
  76164. return it.applyToMesh(rt, e.updatable),
  76165. rt
  76166. }
  76167. function ExtrudePolygon(a, e, i, o) {
  76168. return i === void 0 && (i = null),
  76169. o === void 0 && (o = earcut),
  76170. CreatePolygon(a, e, i, o)
  76171. }
  76172. VertexData.CreatePolygon = CreatePolygonVertexData;
  76173. Mesh.CreatePolygon = function(a, e, i, o, s, c, d) {
  76174. d === void 0 && (d = earcut);
  76175. var _ = {
  76176. shape: e,
  76177. holes: o,
  76178. updatable: s,
  76179. sideOrientation: c
  76180. };
  76181. return CreatePolygon(a, _, i, d)
  76182. }
  76183. ;
  76184. Mesh.ExtrudePolygon = function(a, e, i, o, s, c, d, _) {
  76185. _ === void 0 && (_ = earcut);
  76186. var b = {
  76187. shape: e,
  76188. holes: s,
  76189. depth: i,
  76190. updatable: c,
  76191. sideOrientation: d
  76192. };
  76193. return ExtrudePolygon(a, b, o, _)
  76194. }
  76195. ;
  76196. function ExtrudeShape(a, e, i) {
  76197. i === void 0 && (i = null);
  76198. var o = e.path
  76199. , s = e.shape
  76200. , c = e.scale || 1
  76201. , d = e.rotation || 0
  76202. , _ = e.cap === 0 ? 0 : e.cap || Mesh.NO_CAP
  76203. , b = e.updatable
  76204. , k = Mesh._GetDefaultSideOrientation(e.sideOrientation)
  76205. , j = e.instance || null
  76206. , $ = e.invertUV || !1;
  76207. return _ExtrudeShapeGeneric(a, s, o, c, d, null, null, !1, !1, _, !1, i, !!b, k, j, $, e.frontUVs || null, e.backUVs || null)
  76208. }
  76209. function ExtrudeShapeCustom(a, e, i) {
  76210. i === void 0 && (i = null);
  76211. var o = e.path
  76212. , s = e.shape
  76213. , c = e.scaleFunction || function() {
  76214. return 1
  76215. }
  76216. , d = e.rotationFunction || function() {
  76217. return 0
  76218. }
  76219. , _ = e.ribbonCloseArray || !1
  76220. , b = e.ribbonClosePath || !1
  76221. , k = e.cap === 0 ? 0 : e.cap || Mesh.NO_CAP
  76222. , j = e.updatable
  76223. , $ = Mesh._GetDefaultSideOrientation(e.sideOrientation)
  76224. , _e = e.instance
  76225. , et = e.invertUV || !1;
  76226. return _ExtrudeShapeGeneric(a, s, o, null, null, c, d, _, b, k, !0, i, !!j, $, _e || null, et, e.frontUVs || null, e.backUVs || null)
  76227. }
  76228. function _ExtrudeShapeGeneric(a, e, i, o, s, c, d, _, b, k, j, $, _e, et, tt, rt, it, nt) {
  76229. var ot = function(ft, ht, pt, dt, _t, mt, vt, yt, Et, At) {
  76230. for (var gt = pt.getTangents(), St = pt.getNormals(), xt = pt.getBinormals(), bt = pt.getDistances(), Rt = 0, Mt = function() {
  76231. return _t !== null ? _t : 1
  76232. }, Pt = function() {
  76233. return mt !== null ? mt : 0
  76234. }, It = At && yt ? yt : Pt, Dt = At && vt ? vt : Mt, Ct = Et === Mesh.NO_CAP || Et === Mesh.CAP_END ? 0 : 2, Ot = TmpVectors.Matrix[0], wt = 0; wt < ht.length; wt++) {
  76235. for (var Nt = new Array, Ft = It(wt, bt[wt]), Vt = Dt(wt, bt[wt]), Lt = 0; Lt < ft.length; Lt++) {
  76236. Matrix.RotationAxisToRef(gt[wt], Rt, Ot);
  76237. var kt = gt[wt].scale(ft[Lt].z).add(St[wt].scale(ft[Lt].x)).add(xt[wt].scale(ft[Lt].y))
  76238. , Bt = Nt[Lt] ? Nt[Lt] : Vector3.Zero();
  76239. Vector3.TransformCoordinatesToRef(kt, Ot, Bt),
  76240. Bt.scaleInPlace(Vt).addInPlace(ht[wt]),
  76241. Nt[Lt] = Bt
  76242. }
  76243. dt[Ct] = Nt,
  76244. Rt += Ft,
  76245. Ct++
  76246. }
  76247. var Ut = function(Gt) {
  76248. var Ht = Array(), zt = Vector3.Zero(), Wt;
  76249. for (Wt = 0; Wt < Gt.length; Wt++)
  76250. zt.addInPlace(Gt[Wt]);
  76251. for (zt.scaleInPlace(1 / Gt.length),
  76252. Wt = 0; Wt < Gt.length; Wt++)
  76253. Ht.push(zt);
  76254. return Ht
  76255. };
  76256. switch (Et) {
  76257. case Mesh.NO_CAP:
  76258. break;
  76259. case Mesh.CAP_START:
  76260. dt[0] = Ut(dt[2]),
  76261. dt[1] = dt[2];
  76262. break;
  76263. case Mesh.CAP_END:
  76264. dt[Ct] = dt[Ct - 1],
  76265. dt[Ct + 1] = Ut(dt[Ct - 1]);
  76266. break;
  76267. case Mesh.CAP_ALL:
  76268. dt[0] = Ut(dt[2]),
  76269. dt[1] = dt[2],
  76270. dt[Ct] = dt[Ct - 1],
  76271. dt[Ct + 1] = Ut(dt[Ct - 1]);
  76272. break
  76273. }
  76274. return dt
  76275. }, at, st;
  76276. if (tt) {
  76277. var ut = tt._creationDataStorage;
  76278. return at = ut.path3D.update(i),
  76279. st = ot(e, i, ut.path3D, ut.pathArray, o, s, c, d, ut.cap, j),
  76280. tt = CreateRibbon("", {
  76281. pathArray: st,
  76282. closeArray: !1,
  76283. closePath: !1,
  76284. offset: 0,
  76285. updatable: !1,
  76286. sideOrientation: 0,
  76287. instance: tt
  76288. }, $ || void 0),
  76289. tt
  76290. }
  76291. at = new Path3D(i);
  76292. var ct = new Array;
  76293. k = k < 0 || k > 3 ? 0 : k,
  76294. st = ot(e, i, at, ct, o, s, c, d, k, j);
  76295. var lt = CreateRibbon(a, {
  76296. pathArray: st,
  76297. closeArray: _,
  76298. closePath: b,
  76299. updatable: _e,
  76300. sideOrientation: et,
  76301. invertUV: rt,
  76302. frontUVs: it || void 0,
  76303. backUVs: nt || void 0
  76304. }, $);
  76305. return lt._creationDataStorage.pathArray = st,
  76306. lt._creationDataStorage.path3D = at,
  76307. lt._creationDataStorage.cap = k,
  76308. lt
  76309. }
  76310. Mesh.ExtrudeShape = function(a, e, i, o, s, c, d, _, b, k) {
  76311. d === void 0 && (d = null);
  76312. var j = {
  76313. shape: e,
  76314. path: i,
  76315. scale: o,
  76316. rotation: s,
  76317. cap: c === 0 ? 0 : c || Mesh.NO_CAP,
  76318. sideOrientation: b,
  76319. instance: k,
  76320. updatable: _
  76321. };
  76322. return ExtrudeShape(a, j, d)
  76323. }
  76324. ;
  76325. Mesh.ExtrudeShapeCustom = function(a, e, i, o, s, c, d, _, b, k, j, $) {
  76326. var _e = {
  76327. shape: e,
  76328. path: i,
  76329. scaleFunction: o,
  76330. rotationFunction: s,
  76331. ribbonCloseArray: c,
  76332. ribbonClosePath: d,
  76333. cap: _ === 0 ? 0 : _ || Mesh.NO_CAP,
  76334. sideOrientation: j,
  76335. instance: $,
  76336. updatable: k
  76337. };
  76338. return ExtrudeShapeCustom(a, _e, b)
  76339. }
  76340. ;
  76341. function CreateLathe(a, e, i) {
  76342. i === void 0 && (i = null);
  76343. var o = e.arc ? e.arc <= 0 || e.arc > 1 ? 1 : e.arc : 1, s = e.closed === void 0 ? !0 : e.closed, c = e.shape, d = e.radius || 1, _ = e.tessellation || 64, b = e.clip || 0, k = e.updatable, j = Mesh._GetDefaultSideOrientation(e.sideOrientation), $ = e.cap || Mesh.NO_CAP, _e = Math.PI * 2, et = new Array, tt = e.invertUV || !1, rt = 0, it = 0, nt = _e / _ * o, ot, at = new Array;
  76344. for (rt = 0; rt <= _ - b; rt++) {
  76345. var at = [];
  76346. for (($ == Mesh.CAP_START || $ == Mesh.CAP_ALL) && (at.push(new Vector3(0,c[0].y,0)),
  76347. at.push(new Vector3(Math.cos(rt * nt) * c[0].x * d,c[0].y,Math.sin(rt * nt) * c[0].x * d))),
  76348. it = 0; it < c.length; it++)
  76349. ot = new Vector3(Math.cos(rt * nt) * c[it].x * d,c[it].y,Math.sin(rt * nt) * c[it].x * d),
  76350. at.push(ot);
  76351. ($ == Mesh.CAP_END || $ == Mesh.CAP_ALL) && (at.push(new Vector3(Math.cos(rt * nt) * c[c.length - 1].x * d,c[c.length - 1].y,Math.sin(rt * nt) * c[c.length - 1].x * d)),
  76352. at.push(new Vector3(0,c[c.length - 1].y,0))),
  76353. et.push(at)
  76354. }
  76355. var st = CreateRibbon(a, {
  76356. pathArray: et,
  76357. closeArray: s,
  76358. sideOrientation: j,
  76359. updatable: k,
  76360. invertUV: tt,
  76361. frontUVs: e.frontUVs,
  76362. backUVs: e.backUVs
  76363. }, i);
  76364. return st
  76365. }
  76366. Mesh.CreateLathe = function(a, e, i, o, s, c, d) {
  76367. var _ = {
  76368. shape: e,
  76369. radius: i,
  76370. tessellation: o,
  76371. sideOrientation: d,
  76372. updatable: c
  76373. };
  76374. return CreateLathe(a, _, s)
  76375. }
  76376. ;
  76377. function CreatePlaneVertexData(a) {
  76378. var e = []
  76379. , i = []
  76380. , o = []
  76381. , s = []
  76382. , c = a.width || a.size || 1
  76383. , d = a.height || a.size || 1
  76384. , _ = a.sideOrientation === 0 ? 0 : a.sideOrientation || VertexData.DEFAULTSIDE
  76385. , b = c / 2
  76386. , k = d / 2;
  76387. i.push(-b, -k, 0),
  76388. o.push(0, 0, -1),
  76389. s.push(0, 0),
  76390. i.push(b, -k, 0),
  76391. o.push(0, 0, -1),
  76392. s.push(1, 0),
  76393. i.push(b, k, 0),
  76394. o.push(0, 0, -1),
  76395. s.push(1, 1),
  76396. i.push(-b, k, 0),
  76397. o.push(0, 0, -1),
  76398. s.push(0, 1),
  76399. e.push(0),
  76400. e.push(1),
  76401. e.push(2),
  76402. e.push(0),
  76403. e.push(2),
  76404. e.push(3),
  76405. VertexData._ComputeSides(_, i, e, o, s, a.frontUVs, a.backUVs);
  76406. var j = new VertexData;
  76407. return j.indices = e,
  76408. j.positions = i,
  76409. j.normals = o,
  76410. j.uvs = s,
  76411. j
  76412. }
  76413. function CreatePlane(a, e, i) {
  76414. e === void 0 && (e = {}),
  76415. i === void 0 && (i = null);
  76416. var o = new Mesh(a,i);
  76417. e.sideOrientation = Mesh._GetDefaultSideOrientation(e.sideOrientation),
  76418. o._originalBuilderSideOrientation = e.sideOrientation;
  76419. var s = CreatePlaneVertexData(e);
  76420. return s.applyToMesh(o, e.updatable),
  76421. e.sourcePlane && (o.translate(e.sourcePlane.normal, -e.sourcePlane.d),
  76422. o.setDirection(e.sourcePlane.normal.scale(-1))),
  76423. o
  76424. }
  76425. VertexData.CreatePlane = CreatePlaneVertexData;
  76426. Mesh.CreatePlane = function(a, e, i, o, s) {
  76427. var c = {
  76428. size: e,
  76429. width: e,
  76430. height: e,
  76431. sideOrientation: s,
  76432. updatable: o
  76433. };
  76434. return CreatePlane(a, c, i)
  76435. }
  76436. ;
  76437. Mesh._GroundMeshParser = function(a, e) {
  76438. return GroundMesh.Parse(a, e)
  76439. }
  76440. ;
  76441. var GroundMesh = function(a) {
  76442. __extends(e, a);
  76443. function e(i, o) {
  76444. var s = a.call(this, i, o) || this;
  76445. return s.generateOctree = !1,
  76446. s
  76447. }
  76448. return e.prototype.getClassName = function() {
  76449. return "GroundMesh"
  76450. }
  76451. ,
  76452. Object.defineProperty(e.prototype, "subdivisions", {
  76453. get: function() {
  76454. return Math.min(this._subdivisionsX, this._subdivisionsY)
  76455. },
  76456. enumerable: !1,
  76457. configurable: !0
  76458. }),
  76459. Object.defineProperty(e.prototype, "subdivisionsX", {
  76460. get: function() {
  76461. return this._subdivisionsX
  76462. },
  76463. enumerable: !1,
  76464. configurable: !0
  76465. }),
  76466. Object.defineProperty(e.prototype, "subdivisionsY", {
  76467. get: function() {
  76468. return this._subdivisionsY
  76469. },
  76470. enumerable: !1,
  76471. configurable: !0
  76472. }),
  76473. e.prototype.optimize = function(i, o) {
  76474. o === void 0 && (o = 32),
  76475. this._subdivisionsX = i,
  76476. this._subdivisionsY = i,
  76477. this.subdivide(i);
  76478. var s = this;
  76479. s.createOrUpdateSubmeshesOctree && s.createOrUpdateSubmeshesOctree(o)
  76480. }
  76481. ,
  76482. e.prototype.getHeightAtCoordinates = function(i, o) {
  76483. var s = this.getWorldMatrix()
  76484. , c = TmpVectors.Matrix[5];
  76485. s.invertToRef(c);
  76486. var d = TmpVectors.Vector3[8];
  76487. if (Vector3.TransformCoordinatesFromFloatsToRef(i, 0, o, c, d),
  76488. i = d.x,
  76489. o = d.z,
  76490. i < this._minX || i > this._maxX || o < this._minZ || o > this._maxZ)
  76491. return this.position.y;
  76492. (!this._heightQuads || this._heightQuads.length == 0) && (this._initHeightQuads(),
  76493. this._computeHeightQuads());
  76494. var _ = this._getFacetAt(i, o)
  76495. , b = -(_.x * i + _.z * o + _.w) / _.y;
  76496. return Vector3.TransformCoordinatesFromFloatsToRef(0, b, 0, s, d),
  76497. d.y
  76498. }
  76499. ,
  76500. e.prototype.getNormalAtCoordinates = function(i, o) {
  76501. var s = new Vector3(0,1,0);
  76502. return this.getNormalAtCoordinatesToRef(i, o, s),
  76503. s
  76504. }
  76505. ,
  76506. e.prototype.getNormalAtCoordinatesToRef = function(i, o, s) {
  76507. var c = this.getWorldMatrix()
  76508. , d = TmpVectors.Matrix[5];
  76509. c.invertToRef(d);
  76510. var _ = TmpVectors.Vector3[8];
  76511. if (Vector3.TransformCoordinatesFromFloatsToRef(i, 0, o, d, _),
  76512. i = _.x,
  76513. o = _.z,
  76514. i < this._minX || i > this._maxX || o < this._minZ || o > this._maxZ)
  76515. return this;
  76516. (!this._heightQuads || this._heightQuads.length == 0) && (this._initHeightQuads(),
  76517. this._computeHeightQuads());
  76518. var b = this._getFacetAt(i, o);
  76519. return Vector3.TransformNormalFromFloatsToRef(b.x, b.y, b.z, c, s),
  76520. this
  76521. }
  76522. ,
  76523. e.prototype.updateCoordinateHeights = function() {
  76524. return (!this._heightQuads || this._heightQuads.length == 0) && this._initHeightQuads(),
  76525. this._computeHeightQuads(),
  76526. this
  76527. }
  76528. ,
  76529. e.prototype._getFacetAt = function(i, o) {
  76530. var s = Math.floor((i + this._maxX) * this._subdivisionsX / this._width), c = Math.floor(-(o + this._maxZ) * this._subdivisionsY / this._height + this._subdivisionsY), d = this._heightQuads[c * this._subdivisionsX + s], _;
  76531. return o < d.slope.x * i + d.slope.y ? _ = d.facet1 : _ = d.facet2,
  76532. _
  76533. }
  76534. ,
  76535. e.prototype._initHeightQuads = function() {
  76536. var i = this._subdivisionsX
  76537. , o = this._subdivisionsY;
  76538. this._heightQuads = new Array;
  76539. for (var s = 0; s < o; s++)
  76540. for (var c = 0; c < i; c++) {
  76541. var d = {
  76542. slope: Vector2.Zero(),
  76543. facet1: new Vector4(0,0,0,0),
  76544. facet2: new Vector4(0,0,0,0)
  76545. };
  76546. this._heightQuads[s * i + c] = d
  76547. }
  76548. return this
  76549. }
  76550. ,
  76551. e.prototype._computeHeightQuads = function() {
  76552. var i = this.getVerticesData(VertexBuffer.PositionKind);
  76553. if (!i)
  76554. return this;
  76555. for (var o = TmpVectors.Vector3[3], s = TmpVectors.Vector3[2], c = TmpVectors.Vector3[1], d = TmpVectors.Vector3[0], _ = TmpVectors.Vector3[4], b = TmpVectors.Vector3[5], k = TmpVectors.Vector3[6], j = TmpVectors.Vector3[7], $ = TmpVectors.Vector3[8], _e = 0, et = 0, tt = 0, rt = 0, it = 0, nt = 0, ot = 0, at = this._subdivisionsX, st = this._subdivisionsY, ut = 0; ut < st; ut++)
  76556. for (var ct = 0; ct < at; ct++) {
  76557. _e = ct * 3,
  76558. et = ut * (at + 1) * 3,
  76559. tt = (ut + 1) * (at + 1) * 3,
  76560. o.x = i[et + _e],
  76561. o.y = i[et + _e + 1],
  76562. o.z = i[et + _e + 2],
  76563. s.x = i[et + _e + 3],
  76564. s.y = i[et + _e + 4],
  76565. s.z = i[et + _e + 5],
  76566. c.x = i[tt + _e],
  76567. c.y = i[tt + _e + 1],
  76568. c.z = i[tt + _e + 2],
  76569. d.x = i[tt + _e + 3],
  76570. d.y = i[tt + _e + 4],
  76571. d.z = i[tt + _e + 5],
  76572. rt = (d.z - o.z) / (d.x - o.x),
  76573. it = o.z - rt * o.x,
  76574. s.subtractToRef(o, _),
  76575. c.subtractToRef(o, b),
  76576. d.subtractToRef(o, k),
  76577. Vector3.CrossToRef(k, b, j),
  76578. Vector3.CrossToRef(_, k, $),
  76579. j.normalize(),
  76580. $.normalize(),
  76581. nt = -(j.x * o.x + j.y * o.y + j.z * o.z),
  76582. ot = -($.x * s.x + $.y * s.y + $.z * s.z);
  76583. var lt = this._heightQuads[ut * at + ct];
  76584. lt.slope.copyFromFloats(rt, it),
  76585. lt.facet1.copyFromFloats(j.x, j.y, j.z, nt),
  76586. lt.facet2.copyFromFloats($.x, $.y, $.z, ot)
  76587. }
  76588. return this
  76589. }
  76590. ,
  76591. e.prototype.serialize = function(i) {
  76592. a.prototype.serialize.call(this, i),
  76593. i.subdivisionsX = this._subdivisionsX,
  76594. i.subdivisionsY = this._subdivisionsY,
  76595. i.minX = this._minX,
  76596. i.maxX = this._maxX,
  76597. i.minZ = this._minZ,
  76598. i.maxZ = this._maxZ,
  76599. i.width = this._width,
  76600. i.height = this._height
  76601. }
  76602. ,
  76603. e.Parse = function(i, o) {
  76604. var s = new e(i.name,o);
  76605. return s._subdivisionsX = i.subdivisionsX || 1,
  76606. s._subdivisionsY = i.subdivisionsY || 1,
  76607. s._minX = i.minX,
  76608. s._maxX = i.maxX,
  76609. s._minZ = i.minZ,
  76610. s._maxZ = i.maxZ,
  76611. s._width = i.width,
  76612. s._height = i.height,
  76613. s
  76614. }
  76615. ,
  76616. e
  76617. }(Mesh);
  76618. function CreateGroundVertexData(a) {
  76619. var e = [], i = [], o = [], s = [], c, d, _ = a.width || 1, b = a.height || 1, k = a.subdivisionsX || a.subdivisions || 1, j = a.subdivisionsY || a.subdivisions || 1;
  76620. for (c = 0; c <= j; c++)
  76621. for (d = 0; d <= k; d++) {
  76622. var $ = new Vector3(d * _ / k - _ / 2,0,(j - c) * b / j - b / 2)
  76623. , _e = new Vector3(0,1,0);
  76624. i.push($.x, $.y, $.z),
  76625. o.push(_e.x, _e.y, _e.z),
  76626. s.push(d / k, 1 - c / j)
  76627. }
  76628. for (c = 0; c < j; c++)
  76629. for (d = 0; d < k; d++)
  76630. e.push(d + 1 + (c + 1) * (k + 1)),
  76631. e.push(d + 1 + c * (k + 1)),
  76632. e.push(d + c * (k + 1)),
  76633. e.push(d + (c + 1) * (k + 1)),
  76634. e.push(d + 1 + (c + 1) * (k + 1)),
  76635. e.push(d + c * (k + 1));
  76636. var et = new VertexData;
  76637. return et.indices = e,
  76638. et.positions = i,
  76639. et.normals = o,
  76640. et.uvs = s,
  76641. et
  76642. }
  76643. function CreateTiledGroundVertexData(a) {
  76644. var e = a.xmin !== void 0 && a.xmin !== null ? a.xmin : -1, i = a.zmin !== void 0 && a.zmin !== null ? a.zmin : -1, o = a.xmax !== void 0 && a.xmax !== null ? a.xmax : 1, s = a.zmax !== void 0 && a.zmax !== null ? a.zmax : 1, c = a.subdivisions || {
  76645. w: 1,
  76646. h: 1
  76647. }, d = a.precision || {
  76648. w: 1,
  76649. h: 1
  76650. }, _ = new Array, b = new Array, k = new Array, j = new Array, $, _e, et, tt;
  76651. c.h = c.h < 1 ? 1 : c.h,
  76652. c.w = c.w < 1 ? 1 : c.w,
  76653. d.w = d.w < 1 ? 1 : d.w,
  76654. d.h = d.h < 1 ? 1 : d.h;
  76655. var rt = {
  76656. w: (o - e) / c.w,
  76657. h: (s - i) / c.h
  76658. };
  76659. function it(ot, at, st, ut) {
  76660. var ct = b.length / 3
  76661. , lt = d.w + 1;
  76662. for ($ = 0; $ < d.h; $++)
  76663. for (_e = 0; _e < d.w; _e++) {
  76664. var ft = [ct + _e + $ * lt, ct + (_e + 1) + $ * lt, ct + (_e + 1) + ($ + 1) * lt, ct + _e + ($ + 1) * lt];
  76665. _.push(ft[1]),
  76666. _.push(ft[2]),
  76667. _.push(ft[3]),
  76668. _.push(ft[0]),
  76669. _.push(ft[1]),
  76670. _.push(ft[3])
  76671. }
  76672. var ht = Vector3.Zero()
  76673. , pt = new Vector3(0,1,0);
  76674. for ($ = 0; $ <= d.h; $++)
  76675. for (ht.z = $ * (ut - at) / d.h + at,
  76676. _e = 0; _e <= d.w; _e++)
  76677. ht.x = _e * (st - ot) / d.w + ot,
  76678. ht.y = 0,
  76679. b.push(ht.x, ht.y, ht.z),
  76680. k.push(pt.x, pt.y, pt.z),
  76681. j.push(_e / d.w, $ / d.h)
  76682. }
  76683. for (et = 0; et < c.h; et++)
  76684. for (tt = 0; tt < c.w; tt++)
  76685. it(e + tt * rt.w, i + et * rt.h, e + (tt + 1) * rt.w, i + (et + 1) * rt.h);
  76686. var nt = new VertexData;
  76687. return nt.indices = _,
  76688. nt.positions = b,
  76689. nt.normals = k,
  76690. nt.uvs = j,
  76691. nt
  76692. }
  76693. function CreateGroundFromHeightMapVertexData(a) {
  76694. var e = [], i = [], o = [], s = [], c, d, _ = a.colorFilter || new Color3(.3,.59,.11), b = a.alphaFilter || 0, k = !1;
  76695. if (a.minHeight > a.maxHeight) {
  76696. k = !0;
  76697. var j = a.maxHeight;
  76698. a.maxHeight = a.minHeight,
  76699. a.minHeight = j
  76700. }
  76701. for (c = 0; c <= a.subdivisions; c++)
  76702. for (d = 0; d <= a.subdivisions; d++) {
  76703. var $ = new Vector3(d * a.width / a.subdivisions - a.width / 2,0,(a.subdivisions - c) * a.height / a.subdivisions - a.height / 2)
  76704. , _e = ($.x + a.width / 2) / a.width * (a.bufferWidth - 1) | 0
  76705. , et = (1 - ($.z + a.height / 2) / a.height) * (a.bufferHeight - 1) | 0
  76706. , tt = (_e + et * a.bufferWidth) * 4
  76707. , rt = a.buffer[tt] / 255
  76708. , it = a.buffer[tt + 1] / 255
  76709. , nt = a.buffer[tt + 2] / 255
  76710. , ot = a.buffer[tt + 3] / 255;
  76711. k && (rt = 1 - rt,
  76712. it = 1 - it,
  76713. nt = 1 - nt);
  76714. var at = rt * _.r + it * _.g + nt * _.b;
  76715. ot >= b ? $.y = a.minHeight + (a.maxHeight - a.minHeight) * at : $.y = a.minHeight - Epsilon,
  76716. i.push($.x, $.y, $.z),
  76717. o.push(0, 0, 0),
  76718. s.push(d / a.subdivisions, 1 - c / a.subdivisions)
  76719. }
  76720. for (c = 0; c < a.subdivisions; c++)
  76721. for (d = 0; d < a.subdivisions; d++) {
  76722. var st = d + 1 + (c + 1) * (a.subdivisions + 1)
  76723. , ut = d + 1 + c * (a.subdivisions + 1)
  76724. , ct = d + c * (a.subdivisions + 1)
  76725. , lt = d + (c + 1) * (a.subdivisions + 1)
  76726. , ft = i[st * 3 + 1] >= a.minHeight
  76727. , ht = i[ut * 3 + 1] >= a.minHeight
  76728. , pt = i[ct * 3 + 1] >= a.minHeight;
  76729. ft && ht && pt && (e.push(st),
  76730. e.push(ut),
  76731. e.push(ct));
  76732. var dt = i[lt * 3 + 1] >= a.minHeight;
  76733. dt && ft && pt && (e.push(lt),
  76734. e.push(st),
  76735. e.push(ct))
  76736. }
  76737. VertexData.ComputeNormals(i, e, o);
  76738. var _t = new VertexData;
  76739. return _t.indices = e,
  76740. _t.positions = i,
  76741. _t.normals = o,
  76742. _t.uvs = s,
  76743. _t
  76744. }
  76745. function CreateGround(a, e, i) {
  76746. e === void 0 && (e = {});
  76747. var o = new GroundMesh(a,i);
  76748. o._setReady(!1),
  76749. o._subdivisionsX = e.subdivisionsX || e.subdivisions || 1,
  76750. o._subdivisionsY = e.subdivisionsY || e.subdivisions || 1,
  76751. o._width = e.width || 1,
  76752. o._height = e.height || 1,
  76753. o._maxX = o._width / 2,
  76754. o._maxZ = o._height / 2,
  76755. o._minX = -o._maxX,
  76756. o._minZ = -o._maxZ;
  76757. var s = CreateGroundVertexData(e);
  76758. return s.applyToMesh(o, e.updatable),
  76759. o._setReady(!0),
  76760. o
  76761. }
  76762. function CreateTiledGround(a, e, i) {
  76763. i === void 0 && (i = null);
  76764. var o = new Mesh(a,i)
  76765. , s = CreateTiledGroundVertexData(e);
  76766. return s.applyToMesh(o, e.updatable),
  76767. o
  76768. }
  76769. function CreateGroundFromHeightMap(a, e, i, o) {
  76770. i === void 0 && (i = {}),
  76771. o === void 0 && (o = null);
  76772. var s = i.width || 10
  76773. , c = i.height || 10
  76774. , d = i.subdivisions || 1
  76775. , _ = i.minHeight || 0
  76776. , b = i.maxHeight || 1
  76777. , k = i.colorFilter || new Color3(.3,.59,.11)
  76778. , j = i.alphaFilter || 0
  76779. , $ = i.updatable
  76780. , _e = i.onReady;
  76781. o = o || EngineStore.LastCreatedScene;
  76782. var et = new GroundMesh(a,o);
  76783. et._subdivisionsX = d,
  76784. et._subdivisionsY = d,
  76785. et._width = s,
  76786. et._height = c,
  76787. et._maxX = et._width / 2,
  76788. et._maxZ = et._height / 2,
  76789. et._minX = -et._maxX,
  76790. et._minZ = -et._maxZ,
  76791. et._setReady(!1);
  76792. var tt = function(rt) {
  76793. var it = rt.width
  76794. , nt = rt.height;
  76795. if (!o.isDisposed) {
  76796. var ot = o == null ? void 0 : o.getEngine().resizeImageBitmap(rt, it, nt)
  76797. , at = CreateGroundFromHeightMapVertexData({
  76798. width: s,
  76799. height: c,
  76800. subdivisions: d,
  76801. minHeight: _,
  76802. maxHeight: b,
  76803. colorFilter: k,
  76804. buffer: ot,
  76805. bufferWidth: it,
  76806. bufferHeight: nt,
  76807. alphaFilter: j
  76808. });
  76809. at.applyToMesh(et, $),
  76810. _e && _e(et),
  76811. et._setReady(!0)
  76812. }
  76813. };
  76814. return Tools.LoadImage(e, tt, function() {}, o.offlineProvider),
  76815. et
  76816. }
  76817. VertexData.CreateGround = CreateGroundVertexData;
  76818. VertexData.CreateTiledGround = CreateTiledGroundVertexData;
  76819. VertexData.CreateGroundFromHeightMap = CreateGroundFromHeightMapVertexData;
  76820. Mesh.CreateGround = function(a, e, i, o, s, c) {
  76821. var d = {
  76822. width: e,
  76823. height: i,
  76824. subdivisions: o,
  76825. updatable: c
  76826. };
  76827. return CreateGround(a, d, s)
  76828. }
  76829. ;
  76830. Mesh.CreateTiledGround = function(a, e, i, o, s, c, d, _, b) {
  76831. var k = {
  76832. xmin: e,
  76833. zmin: i,
  76834. xmax: o,
  76835. zmax: s,
  76836. subdivisions: c,
  76837. precision: d,
  76838. updatable: b
  76839. };
  76840. return CreateTiledGround(a, k, _)
  76841. }
  76842. ;
  76843. Mesh.CreateGroundFromHeightMap = function(a, e, i, o, s, c, d, _, b, k, j) {
  76844. var $ = {
  76845. width: i,
  76846. height: o,
  76847. subdivisions: s,
  76848. minHeight: c,
  76849. maxHeight: d,
  76850. updatable: b,
  76851. onReady: k,
  76852. alphaFilter: j
  76853. };
  76854. return CreateGroundFromHeightMap(a, e, $, _)
  76855. }
  76856. ;
  76857. function CreateTube(a, e, i) {
  76858. i === void 0 && (i = null);
  76859. var o = e.path
  76860. , s = e.instance
  76861. , c = 1;
  76862. e.radius !== void 0 ? c = e.radius : s && (c = s._creationDataStorage.radius);
  76863. var d = e.tessellation || 64
  76864. , _ = e.radiusFunction || null
  76865. , b = e.cap || Mesh.NO_CAP
  76866. , k = e.invertUV || !1
  76867. , j = e.updatable
  76868. , $ = Mesh._GetDefaultSideOrientation(e.sideOrientation);
  76869. e.arc = e.arc && (e.arc <= 0 || e.arc > 1) ? 1 : e.arc || 1;
  76870. var _e = function(at, st, ut, ct, lt, ft, ht, pt) {
  76871. for (var dt = st.getTangents(), _t = st.getNormals(), mt = st.getDistances(), vt = Math.PI * 2, yt = vt / lt * pt, Et = function() {
  76872. return ct
  76873. }, At = ft || Et, gt, St, xt, bt, Rt = TmpVectors.Matrix[0], Mt = ht === Mesh.NO_CAP || ht === Mesh.CAP_END ? 0 : 2, Pt = 0; Pt < at.length; Pt++) {
  76874. St = At(Pt, mt[Pt]),
  76875. gt = Array(),
  76876. xt = _t[Pt];
  76877. for (var It = 0; It < lt; It++)
  76878. Matrix.RotationAxisToRef(dt[Pt], yt * It, Rt),
  76879. bt = gt[It] ? gt[It] : Vector3.Zero(),
  76880. Vector3.TransformCoordinatesToRef(xt, Rt, bt),
  76881. bt.scaleInPlace(St).addInPlace(at[Pt]),
  76882. gt[It] = bt;
  76883. ut[Mt] = gt,
  76884. Mt++
  76885. }
  76886. var Dt = function(Ct, Ot) {
  76887. for (var wt = Array(), Nt = 0; Nt < Ct; Nt++)
  76888. wt.push(at[Ot]);
  76889. return wt
  76890. };
  76891. switch (ht) {
  76892. case Mesh.NO_CAP:
  76893. break;
  76894. case Mesh.CAP_START:
  76895. ut[0] = Dt(lt, 0),
  76896. ut[1] = ut[2].slice(0);
  76897. break;
  76898. case Mesh.CAP_END:
  76899. ut[Mt] = ut[Mt - 1].slice(0),
  76900. ut[Mt + 1] = Dt(lt, at.length - 1);
  76901. break;
  76902. case Mesh.CAP_ALL:
  76903. ut[0] = Dt(lt, 0),
  76904. ut[1] = ut[2].slice(0),
  76905. ut[Mt] = ut[Mt - 1].slice(0),
  76906. ut[Mt + 1] = Dt(lt, at.length - 1);
  76907. break
  76908. }
  76909. return ut
  76910. }, et, tt;
  76911. if (s) {
  76912. var rt = s._creationDataStorage
  76913. , it = e.arc || rt.arc;
  76914. return et = rt.path3D.update(o),
  76915. tt = _e(o, et, rt.pathArray, c, rt.tessellation, _, rt.cap, it),
  76916. s = CreateRibbon("", {
  76917. pathArray: tt,
  76918. instance: s
  76919. }),
  76920. rt.path3D = et,
  76921. rt.pathArray = tt,
  76922. rt.arc = it,
  76923. rt.radius = c,
  76924. s
  76925. }
  76926. et = new Path3D(o);
  76927. var nt = new Array;
  76928. b = b < 0 || b > 3 ? 0 : b,
  76929. tt = _e(o, et, nt, c, d, _, b, e.arc);
  76930. var ot = CreateRibbon(a, {
  76931. pathArray: tt,
  76932. closePath: !0,
  76933. closeArray: !1,
  76934. updatable: j,
  76935. sideOrientation: $,
  76936. invertUV: k,
  76937. frontUVs: e.frontUVs,
  76938. backUVs: e.backUVs
  76939. }, i);
  76940. return ot._creationDataStorage.pathArray = tt,
  76941. ot._creationDataStorage.path3D = et,
  76942. ot._creationDataStorage.tessellation = d,
  76943. ot._creationDataStorage.cap = b,
  76944. ot._creationDataStorage.arc = e.arc,
  76945. ot._creationDataStorage.radius = c,
  76946. ot
  76947. }
  76948. Mesh.CreateTube = function(a, e, i, o, s, c, d, _, b, k) {
  76949. var j = {
  76950. path: e,
  76951. radius: i,
  76952. tessellation: o,
  76953. radiusFunction: s,
  76954. arc: 1,
  76955. cap: c,
  76956. updatable: _,
  76957. sideOrientation: b,
  76958. instance: k
  76959. };
  76960. return CreateTube(a, j, d)
  76961. }
  76962. ;
  76963. function CreatePolyhedronVertexData(a) {
  76964. var e = [];
  76965. e[0] = {
  76966. vertex: [[0, 0, 1.732051], [1.632993, 0, -.5773503], [-.8164966, 1.414214, -.5773503], [-.8164966, -1.414214, -.5773503]],
  76967. face: [[0, 1, 2], [0, 2, 3], [0, 3, 1], [1, 3, 2]]
  76968. },
  76969. e[1] = {
  76970. vertex: [[0, 0, 1.414214], [1.414214, 0, 0], [0, 1.414214, 0], [-1.414214, 0, 0], [0, -1.414214, 0], [0, 0, -1.414214]],
  76971. face: [[0, 1, 2], [0, 2, 3], [0, 3, 4], [0, 4, 1], [1, 4, 5], [1, 5, 2], [2, 5, 3], [3, 5, 4]]
  76972. },
  76973. e[2] = {
  76974. vertex: [[0, 0, 1.070466], [.7136442, 0, .7978784], [-.3568221, .618034, .7978784], [-.3568221, -.618034, .7978784], [.7978784, .618034, .3568221], [.7978784, -.618034, .3568221], [-.9341724, .381966, .3568221], [.1362939, 1, .3568221], [.1362939, -1, .3568221], [-.9341724, -.381966, .3568221], [.9341724, .381966, -.3568221], [.9341724, -.381966, -.3568221], [-.7978784, .618034, -.3568221], [-.1362939, 1, -.3568221], [-.1362939, -1, -.3568221], [-.7978784, -.618034, -.3568221], [.3568221, .618034, -.7978784], [.3568221, -.618034, -.7978784], [-.7136442, 0, -.7978784], [0, 0, -1.070466]],
  76975. face: [[0, 1, 4, 7, 2], [0, 2, 6, 9, 3], [0, 3, 8, 5, 1], [1, 5, 11, 10, 4], [2, 7, 13, 12, 6], [3, 9, 15, 14, 8], [4, 10, 16, 13, 7], [5, 8, 14, 17, 11], [6, 12, 18, 15, 9], [10, 11, 17, 19, 16], [12, 13, 16, 19, 18], [14, 15, 18, 19, 17]]
  76976. },
  76977. e[3] = {
  76978. vertex: [[0, 0, 1.175571], [1.051462, 0, .5257311], [.3249197, 1, .5257311], [-.8506508, .618034, .5257311], [-.8506508, -.618034, .5257311], [.3249197, -1, .5257311], [.8506508, .618034, -.5257311], [.8506508, -.618034, -.5257311], [-.3249197, 1, -.5257311], [-1.051462, 0, -.5257311], [-.3249197, -1, -.5257311], [0, 0, -1.175571]],
  76979. face: [[0, 1, 2], [0, 2, 3], [0, 3, 4], [0, 4, 5], [0, 5, 1], [1, 5, 7], [1, 7, 6], [1, 6, 2], [2, 6, 8], [2, 8, 3], [3, 8, 9], [3, 9, 4], [4, 9, 10], [4, 10, 5], [5, 10, 7], [6, 7, 11], [6, 11, 8], [7, 10, 11], [8, 11, 9], [9, 11, 10]]
  76980. },
  76981. e[4] = {
  76982. vertex: [[0, 0, 1.070722], [.7148135, 0, .7971752], [-.104682, .7071068, .7971752], [-.6841528, .2071068, .7971752], [-.104682, -.7071068, .7971752], [.6101315, .7071068, .5236279], [1.04156, .2071068, .1367736], [.6101315, -.7071068, .5236279], [-.3574067, 1, .1367736], [-.7888348, -.5, .5236279], [-.9368776, .5, .1367736], [-.3574067, -1, .1367736], [.3574067, 1, -.1367736], [.9368776, -.5, -.1367736], [.7888348, .5, -.5236279], [.3574067, -1, -.1367736], [-.6101315, .7071068, -.5236279], [-1.04156, -.2071068, -.1367736], [-.6101315, -.7071068, -.5236279], [.104682, .7071068, -.7971752], [.6841528, -.2071068, -.7971752], [.104682, -.7071068, -.7971752], [-.7148135, 0, -.7971752], [0, 0, -1.070722]],
  76983. face: [[0, 2, 3], [1, 6, 5], [4, 9, 11], [7, 15, 13], [8, 16, 10], [12, 14, 19], [17, 22, 18], [20, 21, 23], [0, 1, 5, 2], [0, 3, 9, 4], [0, 4, 7, 1], [1, 7, 13, 6], [2, 5, 12, 8], [2, 8, 10, 3], [3, 10, 17, 9], [4, 11, 15, 7], [5, 6, 14, 12], [6, 13, 20, 14], [8, 12, 19, 16], [9, 17, 18, 11], [10, 16, 22, 17], [11, 18, 21, 15], [13, 15, 21, 20], [14, 20, 23, 19], [16, 19, 23, 22], [18, 22, 23, 21]]
  76984. },
  76985. e[5] = {
  76986. vertex: [[0, 0, 1.322876], [1.309307, 0, .1889822], [-.9819805, .8660254, .1889822], [.1636634, -1.299038, .1889822], [.3273268, .8660254, -.9449112], [-.8183171, -.4330127, -.9449112]],
  76987. face: [[0, 3, 1], [2, 4, 5], [0, 1, 4, 2], [0, 2, 5, 3], [1, 3, 5, 4]]
  76988. },
  76989. e[6] = {
  76990. vertex: [[0, 0, 1.159953], [1.013464, 0, .5642542], [-.3501431, .9510565, .5642542], [-.7715208, -.6571639, .5642542], [.6633206, .9510565, -.03144481], [.8682979, -.6571639, -.3996071], [-1.121664, .2938926, -.03144481], [-.2348831, -1.063314, -.3996071], [.5181548, .2938926, -.9953061], [-.5850262, -.112257, -.9953061]],
  76991. face: [[0, 1, 4, 2], [0, 2, 6, 3], [1, 5, 8, 4], [3, 6, 9, 7], [5, 7, 9, 8], [0, 3, 7, 5, 1], [2, 4, 8, 9, 6]]
  76992. },
  76993. e[7] = {
  76994. vertex: [[0, 0, 1.118034], [.8944272, 0, .6708204], [-.2236068, .8660254, .6708204], [-.7826238, -.4330127, .6708204], [.6708204, .8660254, .2236068], [1.006231, -.4330127, -.2236068], [-1.006231, .4330127, .2236068], [-.6708204, -.8660254, -.2236068], [.7826238, .4330127, -.6708204], [.2236068, -.8660254, -.6708204], [-.8944272, 0, -.6708204], [0, 0, -1.118034]],
  76995. face: [[0, 1, 4, 2], [0, 2, 6, 3], [1, 5, 8, 4], [3, 6, 10, 7], [5, 9, 11, 8], [7, 10, 11, 9], [0, 3, 7, 9, 5, 1], [2, 4, 8, 11, 10, 6]]
  76996. },
  76997. e[8] = {
  76998. vertex: [[-.729665, .670121, .319155], [-.655235, -.29213, -.754096], [-.093922, -.607123, .537818], [.702196, .595691, .485187], [.776626, -.36656, -.588064]],
  76999. face: [[1, 4, 2], [0, 1, 2], [3, 0, 2], [4, 3, 2], [4, 1, 0, 3]]
  77000. },
  77001. e[9] = {
  77002. vertex: [[-.868849, -.100041, .61257], [-.329458, .976099, .28078], [-.26629, -.013796, -.477654], [-.13392, -1.034115, .229829], [.738834, .707117, -.307018], [.859683, -.535264, -.338508]],
  77003. face: [[3, 0, 2], [5, 3, 2], [4, 5, 2], [1, 4, 2], [0, 1, 2], [0, 3, 5, 4, 1]]
  77004. },
  77005. e[10] = {
  77006. vertex: [[-.610389, .243975, .531213], [-.187812, -.48795, -.664016], [-.187812, .9759, -.664016], [.187812, -.9759, .664016], [.798201, .243975, .132803]],
  77007. face: [[1, 3, 0], [3, 4, 0], [3, 1, 4], [0, 2, 1], [0, 4, 2], [2, 4, 1]]
  77008. },
  77009. e[11] = {
  77010. vertex: [[-1.028778, .392027, -.048786], [-.640503, -.646161, .621837], [-.125162, -.395663, -.540059], [.004683, .888447, -.651988], [.125161, .395663, .540059], [.632925, -.791376, .433102], [1.031672, .157063, -.354165]],
  77011. face: [[3, 2, 0], [2, 1, 0], [2, 5, 1], [0, 4, 3], [0, 1, 4], [4, 1, 5], [2, 3, 6], [3, 4, 6], [5, 2, 6], [4, 5, 6]]
  77012. },
  77013. e[12] = {
  77014. vertex: [[-.669867, .334933, -.529576], [-.669867, .334933, .529577], [-.4043, 1.212901, 0], [-.334933, -.669867, -.529576], [-.334933, -.669867, .529577], [.334933, .669867, -.529576], [.334933, .669867, .529577], [.4043, -1.212901, 0], [.669867, -.334933, -.529576], [.669867, -.334933, .529577]],
  77015. face: [[8, 9, 7], [6, 5, 2], [3, 8, 7], [5, 0, 2], [4, 3, 7], [0, 1, 2], [9, 4, 7], [1, 6, 2], [9, 8, 5, 6], [8, 3, 0, 5], [3, 4, 1, 0], [4, 9, 6, 1]]
  77016. },
  77017. e[13] = {
  77018. vertex: [[-.931836, .219976, -.264632], [-.636706, .318353, .692816], [-.613483, -.735083, -.264632], [-.326545, .979634, 0], [-.318353, -.636706, .692816], [-.159176, .477529, -.856368], [.159176, -.477529, -.856368], [.318353, .636706, .692816], [.326545, -.979634, 0], [.613482, .735082, -.264632], [.636706, -.318353, .692816], [.931835, -.219977, -.264632]],
  77019. face: [[11, 10, 8], [7, 9, 3], [6, 11, 8], [9, 5, 3], [2, 6, 8], [5, 0, 3], [4, 2, 8], [0, 1, 3], [10, 4, 8], [1, 7, 3], [10, 11, 9, 7], [11, 6, 5, 9], [6, 2, 0, 5], [2, 4, 1, 0], [4, 10, 7, 1]]
  77020. },
  77021. e[14] = {
  77022. vertex: [[-.93465, .300459, -.271185], [-.838689, -.260219, -.516017], [-.711319, .717591, .128359], [-.710334, -.156922, .080946], [-.599799, .556003, -.725148], [-.503838, -.004675, -.969981], [-.487004, .26021, .48049], [-.460089, -.750282, -.512622], [-.376468, .973135, -.325605], [-.331735, -.646985, .084342], [-.254001, .831847, .530001], [-.125239, -.494738, -.966586], [.029622, .027949, .730817], [.056536, -.982543, -.262295], [.08085, 1.087391, .076037], [.125583, -.532729, .485984], [.262625, .599586, .780328], [.391387, -.726999, -.716259], [.513854, -.868287, .139347], [.597475, .85513, .326364], [.641224, .109523, .783723], [.737185, -.451155, .538891], [.848705, -.612742, -.314616], [.976075, .365067, .32976], [1.072036, -.19561, .084927]],
  77023. face: [[15, 18, 21], [12, 20, 16], [6, 10, 2], [3, 0, 1], [9, 7, 13], [2, 8, 4, 0], [0, 4, 5, 1], [1, 5, 11, 7], [7, 11, 17, 13], [13, 17, 22, 18], [18, 22, 24, 21], [21, 24, 23, 20], [20, 23, 19, 16], [16, 19, 14, 10], [10, 14, 8, 2], [15, 9, 13, 18], [12, 15, 21, 20], [6, 12, 16, 10], [3, 6, 2, 0], [9, 3, 1, 7], [9, 15, 12, 6, 3], [22, 17, 11, 5, 4, 8, 14, 19, 23, 24]]
  77024. };
  77025. var i = a.type && (a.type < 0 || a.type >= e.length) ? 0 : a.type || 0, o = a.size, s = a.sizeX || o || 1, c = a.sizeY || o || 1, d = a.sizeZ || o || 1, _ = a.custom || e[i], b = _.face.length, k = a.faceUV || new Array(b), j = a.faceColors, $ = a.flat === void 0 ? !0 : a.flat, _e = a.sideOrientation === 0 ? 0 : a.sideOrientation || VertexData.DEFAULTSIDE, et = new Array, tt = new Array, rt = new Array, it = new Array, nt = new Array, ot = 0, at = 0, st = new Array, ut = 0, ct = 0, lt, ft, ht, pt, dt, _t;
  77026. if ($)
  77027. for (ct = 0; ct < b; ct++)
  77028. j && j[ct] === void 0 && (j[ct] = new Color4(1,1,1,1)),
  77029. k && k[ct] === void 0 && (k[ct] = new Vector4(0,0,1,1));
  77030. if ($)
  77031. for (ct = 0; ct < b; ct++) {
  77032. var mt = _.face[ct].length;
  77033. for (ht = 2 * Math.PI / mt,
  77034. pt = .5 * Math.tan(ht / 2),
  77035. dt = .5,
  77036. ut = 0; ut < mt; ut++)
  77037. et.push(_.vertex[_.face[ct][ut]][0] * s, _.vertex[_.face[ct][ut]][1] * c, _.vertex[_.face[ct][ut]][2] * d),
  77038. st.push(ot),
  77039. ot++,
  77040. lt = k[ct].x + (k[ct].z - k[ct].x) * (.5 + pt),
  77041. ft = k[ct].y + (k[ct].w - k[ct].y) * (dt - .5),
  77042. it.push(lt, ft),
  77043. _t = pt * Math.cos(ht) - dt * Math.sin(ht),
  77044. dt = pt * Math.sin(ht) + dt * Math.cos(ht),
  77045. pt = _t,
  77046. j && nt.push(j[ct].r, j[ct].g, j[ct].b, j[ct].a);
  77047. for (ut = 0; ut < mt - 2; ut++)
  77048. tt.push(st[0 + at], st[ut + 2 + at], st[ut + 1 + at]);
  77049. at += mt
  77050. }
  77051. else {
  77052. for (ut = 0; ut < _.vertex.length; ut++)
  77053. et.push(_.vertex[ut][0] * s, _.vertex[ut][1] * c, _.vertex[ut][2] * d),
  77054. it.push(0, 0);
  77055. for (ct = 0; ct < b; ct++)
  77056. for (ut = 0; ut < _.face[ct].length - 2; ut++)
  77057. tt.push(_.face[ct][0], _.face[ct][ut + 2], _.face[ct][ut + 1])
  77058. }
  77059. VertexData.ComputeNormals(et, tt, rt),
  77060. VertexData._ComputeSides(_e, et, tt, rt, it, a.frontUVs, a.backUVs);
  77061. var vt = new VertexData;
  77062. return vt.positions = et,
  77063. vt.indices = tt,
  77064. vt.normals = rt,
  77065. vt.uvs = it,
  77066. j && $ && (vt.colors = nt),
  77067. vt
  77068. }
  77069. function CreatePolyhedron(a, e, i) {
  77070. e === void 0 && (e = {}),
  77071. i === void 0 && (i = null);
  77072. var o = new Mesh(a,i);
  77073. e.sideOrientation = Mesh._GetDefaultSideOrientation(e.sideOrientation),
  77074. o._originalBuilderSideOrientation = e.sideOrientation;
  77075. var s = CreatePolyhedronVertexData(e);
  77076. return s.applyToMesh(o, e.updatable),
  77077. o
  77078. }
  77079. VertexData.CreatePolyhedron = CreatePolyhedronVertexData;
  77080. Mesh.CreatePolyhedron = function(a, e, i) {
  77081. return CreatePolyhedron(a, e, i)
  77082. }
  77083. ;
  77084. function CreateIcoSphereVertexData(a) {
  77085. var e = a.sideOrientation || VertexData.DEFAULTSIDE, i = a.radius || 1, o = a.flat === void 0 ? !0 : a.flat, s = a.subdivisions || 4, c = a.radiusX || i, d = a.radiusY || i, _ = a.radiusZ || i, b = (1 + Math.sqrt(5)) / 2, k = [-1, b, -0, 1, b, 0, -1, -b, 0, 1, -b, 0, 0, -1, -b, 0, 1, -b, 0, -1, b, 0, 1, b, b, 0, 1, b, 0, -1, -b, 0, 1, -b, 0, -1], j = [0, 11, 5, 0, 5, 1, 0, 1, 7, 0, 7, 10, 12, 22, 23, 1, 5, 20, 5, 11, 4, 23, 22, 13, 22, 18, 6, 7, 1, 8, 14, 21, 4, 14, 4, 2, 16, 13, 6, 15, 6, 19, 3, 8, 9, 4, 21, 5, 13, 17, 23, 6, 13, 22, 19, 6, 18, 9, 8, 1], $ = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 2, 3, 3, 3, 4, 7, 8, 9, 9, 10, 11], _e = [5, 1, 3, 1, 6, 4, 0, 0, 5, 3, 4, 2, 2, 2, 4, 0, 2, 0, 1, 1, 6, 0, 6, 2, 0, 4, 3, 3, 4, 4, 3, 1, 4, 2, 4, 4, 0, 2, 1, 1, 2, 2, 3, 3, 1, 3, 2, 4], et = 138 / 1024, tt = 239 / 1024, rt = 60 / 1024, it = 26 / 1024, nt = -40 / 1024, ot = 20 / 1024, at = [0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0], st = new Array, ut = new Array, ct = new Array, lt = new Array, ft = 0, ht = new Array(3), pt = new Array(3), dt;
  77086. for (dt = 0; dt < 3; dt++)
  77087. ht[dt] = Vector3.Zero(),
  77088. pt[dt] = Vector2.Zero();
  77089. for (var _t = 0; _t < 20; _t++) {
  77090. for (dt = 0; dt < 3; dt++) {
  77091. var mt = j[3 * _t + dt];
  77092. ht[dt].copyFromFloats(k[3 * $[mt]], k[3 * $[mt] + 1], k[3 * $[mt] + 2]),
  77093. ht[dt].normalize().scaleInPlace(i),
  77094. pt[dt].copyFromFloats(_e[2 * mt] * et + rt + at[_t] * nt, _e[2 * mt + 1] * tt + it + at[_t] * ot)
  77095. }
  77096. for (var vt = function(gt, St, xt, bt) {
  77097. var Rt = Vector3.Lerp(ht[0], ht[2], St / s)
  77098. , Mt = Vector3.Lerp(ht[1], ht[2], St / s)
  77099. , Pt = s === St ? ht[2] : Vector3.Lerp(Rt, Mt, gt / (s - St));
  77100. Pt.normalize();
  77101. var It;
  77102. if (o) {
  77103. var Dt = Vector3.Lerp(ht[0], ht[2], bt / s)
  77104. , Ct = Vector3.Lerp(ht[1], ht[2], bt / s);
  77105. It = Vector3.Lerp(Dt, Ct, xt / (s - bt))
  77106. } else
  77107. It = new Vector3(Pt.x,Pt.y,Pt.z);
  77108. It.x /= c,
  77109. It.y /= d,
  77110. It.z /= _,
  77111. It.normalize();
  77112. var Ot = Vector2.Lerp(pt[0], pt[2], St / s)
  77113. , wt = Vector2.Lerp(pt[1], pt[2], St / s)
  77114. , Nt = s === St ? pt[2] : Vector2.Lerp(Ot, wt, gt / (s - St));
  77115. ut.push(Pt.x * c, Pt.y * d, Pt.z * _),
  77116. ct.push(It.x, It.y, It.z),
  77117. lt.push(Nt.x, Nt.y),
  77118. st.push(ft),
  77119. ft++
  77120. }, yt = 0; yt < s; yt++)
  77121. for (var Et = 0; Et + yt < s; Et++)
  77122. vt(Et, yt, Et + 1 / 3, yt + 1 / 3),
  77123. vt(Et + 1, yt, Et + 1 / 3, yt + 1 / 3),
  77124. vt(Et, yt + 1, Et + 1 / 3, yt + 1 / 3),
  77125. Et + yt + 1 < s && (vt(Et + 1, yt, Et + 2 / 3, yt + 2 / 3),
  77126. vt(Et + 1, yt + 1, Et + 2 / 3, yt + 2 / 3),
  77127. vt(Et, yt + 1, Et + 2 / 3, yt + 2 / 3))
  77128. }
  77129. VertexData._ComputeSides(e, ut, st, ct, lt, a.frontUVs, a.backUVs);
  77130. var At = new VertexData;
  77131. return At.indices = st,
  77132. At.positions = ut,
  77133. At.normals = ct,
  77134. At.uvs = lt,
  77135. At
  77136. }
  77137. function CreateIcoSphere(a, e, i) {
  77138. e === void 0 && (e = {}),
  77139. i === void 0 && (i = null);
  77140. var o = new Mesh(a,i);
  77141. e.sideOrientation = Mesh._GetDefaultSideOrientation(e.sideOrientation),
  77142. o._originalBuilderSideOrientation = e.sideOrientation;
  77143. var s = CreateIcoSphereVertexData(e);
  77144. return s.applyToMesh(o, e.updatable),
  77145. o
  77146. }
  77147. VertexData.CreateIcoSphere = CreateIcoSphereVertexData;
  77148. Mesh.CreateIcoSphere = function(a, e, i) {
  77149. return CreateIcoSphere(a, e, i)
  77150. }
  77151. ;
  77152. function CreateDecal(a, e, i) {
  77153. var o = e.getIndices()
  77154. , s = e.getVerticesData(VertexBuffer.PositionKind)
  77155. , c = e.getVerticesData(VertexBuffer.NormalKind)
  77156. , d = e.getVerticesData(VertexBuffer.UVKind)
  77157. , _ = i.position || Vector3.Zero()
  77158. , b = i.normal || Vector3.Up()
  77159. , k = i.size || Vector3.One()
  77160. , j = i.angle || 0;
  77161. if (!b) {
  77162. var $ = new Vector3(0,0,1)
  77163. , _e = e.getScene().activeCamera
  77164. , et = Vector3.TransformCoordinates($, _e.getWorldMatrix());
  77165. b = _e.globalPosition.subtract(et)
  77166. }
  77167. var tt = -Math.atan2(b.z, b.x) - Math.PI / 2
  77168. , rt = Math.sqrt(b.x * b.x + b.z * b.z)
  77169. , it = Math.atan2(b.y, rt)
  77170. , nt = Matrix.RotationYawPitchRoll(tt, it, j).multiply(Matrix.Translation(_.x, _.y, _.z))
  77171. , ot = Matrix.Invert(nt)
  77172. , at = e.getWorldMatrix()
  77173. , st = at.multiply(ot)
  77174. , ut = new VertexData;
  77175. ut.indices = [],
  77176. ut.positions = [],
  77177. ut.normals = [],
  77178. ut.uvs = [];
  77179. for (var ct = 0, lt = function(vt) {
  77180. var yt = new PositionNormalTextureVertex;
  77181. if (!o || !s || !c)
  77182. return yt;
  77183. var Et = o[vt];
  77184. return yt.position = new Vector3(s[Et * 3],s[Et * 3 + 1],s[Et * 3 + 2]),
  77185. yt.position = Vector3.TransformCoordinates(yt.position, st),
  77186. yt.normal = new Vector3(c[Et * 3],c[Et * 3 + 1],c[Et * 3 + 2]),
  77187. yt.normal = Vector3.TransformNormal(yt.normal, st),
  77188. i.captureUVS && d && (yt.uv = new Vector2(d[Et * 2],d[Et * 2 + 1])),
  77189. yt
  77190. }, ft = function(vt, yt) {
  77191. if (vt.length === 0)
  77192. return vt;
  77193. for (var Et = .5 * Math.abs(Vector3.Dot(k, yt)), At = function(Ft, Vt) {
  77194. var Lt = Vector3.GetClipFactor(Ft.position, Vt.position, yt, Et);
  77195. return new PositionNormalTextureVertex(Vector3.Lerp(Ft.position, Vt.position, Lt),Vector3.Lerp(Ft.normal, Vt.normal, Lt))
  77196. }, gt = new Array, St = 0; St < vt.length; St += 3) {
  77197. var xt, bt, Rt, Mt = 0, Pt = null, It = null, Dt = null, Ct = null, Ot = Vector3.Dot(vt[St].position, yt) - Et, wt = Vector3.Dot(vt[St + 1].position, yt) - Et, Nt = Vector3.Dot(vt[St + 2].position, yt) - Et;
  77198. switch (xt = Ot > 0,
  77199. bt = wt > 0,
  77200. Rt = Nt > 0,
  77201. Mt = (xt ? 1 : 0) + (bt ? 1 : 0) + (Rt ? 1 : 0),
  77202. Mt) {
  77203. case 0:
  77204. gt.push(vt[St]),
  77205. gt.push(vt[St + 1]),
  77206. gt.push(vt[St + 2]);
  77207. break;
  77208. case 1:
  77209. if (xt && (Pt = vt[St + 1],
  77210. It = vt[St + 2],
  77211. Dt = At(vt[St], Pt),
  77212. Ct = At(vt[St], It)),
  77213. bt) {
  77214. Pt = vt[St],
  77215. It = vt[St + 2],
  77216. Dt = At(vt[St + 1], Pt),
  77217. Ct = At(vt[St + 1], It),
  77218. gt.push(Dt),
  77219. gt.push(It.clone()),
  77220. gt.push(Pt.clone()),
  77221. gt.push(It.clone()),
  77222. gt.push(Dt.clone()),
  77223. gt.push(Ct);
  77224. break
  77225. }
  77226. Rt && (Pt = vt[St],
  77227. It = vt[St + 1],
  77228. Dt = At(vt[St + 2], Pt),
  77229. Ct = At(vt[St + 2], It)),
  77230. Pt && It && Dt && Ct && (gt.push(Pt.clone()),
  77231. gt.push(It.clone()),
  77232. gt.push(Dt),
  77233. gt.push(Ct),
  77234. gt.push(Dt.clone()),
  77235. gt.push(It.clone()));
  77236. break;
  77237. case 2:
  77238. xt || (Pt = vt[St].clone(),
  77239. It = At(Pt, vt[St + 1]),
  77240. Dt = At(Pt, vt[St + 2]),
  77241. gt.push(Pt),
  77242. gt.push(It),
  77243. gt.push(Dt)),
  77244. bt || (Pt = vt[St + 1].clone(),
  77245. It = At(Pt, vt[St + 2]),
  77246. Dt = At(Pt, vt[St]),
  77247. gt.push(Pt),
  77248. gt.push(It),
  77249. gt.push(Dt)),
  77250. Rt || (Pt = vt[St + 2].clone(),
  77251. It = At(Pt, vt[St]),
  77252. Dt = At(Pt, vt[St + 1]),
  77253. gt.push(Pt),
  77254. gt.push(It),
  77255. gt.push(Dt));
  77256. break
  77257. }
  77258. }
  77259. return gt
  77260. }, ht = 0; ht < o.length; ht += 3) {
  77261. var pt = new Array;
  77262. if (pt.push(lt(ht)),
  77263. pt.push(lt(ht + 1)),
  77264. pt.push(lt(ht + 2)),
  77265. pt = ft(pt, new Vector3(1,0,0)),
  77266. pt = ft(pt, new Vector3(-1,0,0)),
  77267. pt = ft(pt, new Vector3(0,1,0)),
  77268. pt = ft(pt, new Vector3(0,-1,0)),
  77269. pt = ft(pt, new Vector3(0,0,1)),
  77270. pt = ft(pt, new Vector3(0,0,-1)),
  77271. pt.length !== 0)
  77272. for (var dt = 0; dt < pt.length; dt++) {
  77273. var _t = pt[dt];
  77274. ut.indices.push(ct),
  77275. _t.position.toArray(ut.positions, ct * 3),
  77276. _t.normal.toArray(ut.normals, ct * 3),
  77277. i.captureUVS ? _t.uv.toArray(ut.uvs, ct * 2) : (ut.uvs.push(.5 + _t.position.x / k.x),
  77278. ut.uvs.push(.5 + _t.position.y / k.y)),
  77279. ct++
  77280. }
  77281. }
  77282. var mt = new Mesh(a,e.getScene());
  77283. return ut.applyToMesh(mt),
  77284. mt.position = _.clone(),
  77285. mt.rotation = new Vector3(it,tt,j),
  77286. mt
  77287. }
  77288. Mesh.CreateDecal = function(a, e, i, o, s, c) {
  77289. var d = {
  77290. position: i,
  77291. normal: o,
  77292. size: s,
  77293. angle: c
  77294. };
  77295. return CreateDecal(a, e, d)
  77296. }
  77297. ;
  77298. function CreateCapsuleVertexData(a) {
  77299. a === void 0 && (a = {
  77300. subdivisions: 2,
  77301. tessellation: 16,
  77302. height: 1,
  77303. radius: .25,
  77304. capSubdivisions: 6
  77305. });
  77306. var e = Math.max(a.subdivisions ? a.subdivisions : 2, 1), i = Math.max(a.tessellation ? a.tessellation : 16, 3), o = Math.max(a.height ? a.height : 1, 0), s = Math.max(a.radius ? a.radius : .25, 0), c = Math.max(a.capSubdivisions ? a.capSubdivisions : 6, 1), d = i, _ = e, b = Math.max(a.radiusTop ? a.radiusTop : s, 0), k = Math.max(a.radiusBottom ? a.radiusBottom : s, 0), j = o - (b + k), $ = 0, _e = 2 * Math.PI, et = Math.max(a.topCapSubdivisions ? a.topCapSubdivisions : c, 1), tt = Math.max(a.bottomCapSubdivisions ? a.bottomCapSubdivisions : c, 1), rt = Math.acos((k - b) / o), it = [], nt = [], ot = [], at = [], st = 0, ut = [], ct = j * .5, lt = Math.PI * .5, ft, ht, pt = Vector3.Zero(), dt = Vector3.Zero(), _t = Math.cos(rt), mt = Math.sin(rt), vt = new Vector2(b * mt,ct + b * _t).subtract(new Vector2(k * mt,-ct + k * _t)).length(), yt = b * rt + vt + k * (lt - rt), Et = 0;
  77307. for (ht = 0; ht <= et; ht++) {
  77308. var At = []
  77309. , gt = lt - rt * (ht / et);
  77310. Et += b * rt / et;
  77311. var St = Math.cos(gt)
  77312. , xt = Math.sin(gt)
  77313. , bt = St * b;
  77314. for (ft = 0; ft <= d; ft++) {
  77315. var Rt = ft / d
  77316. , Mt = Rt * _e + $
  77317. , Pt = Math.sin(Mt)
  77318. , It = Math.cos(Mt);
  77319. dt.x = bt * Pt,
  77320. dt.y = ct + xt * b,
  77321. dt.z = bt * It,
  77322. nt.push(dt.x, dt.y, dt.z),
  77323. pt.set(St * Pt, xt, St * It),
  77324. ot.push(pt.x, pt.y, pt.z),
  77325. at.push(Rt, 1 - Et / yt),
  77326. At.push(st),
  77327. st++
  77328. }
  77329. ut.push(At)
  77330. }
  77331. var Dt = o - b - k + _t * b - _t * k
  77332. , Ct = mt * (k - b) / Dt;
  77333. for (ht = 1; ht <= _; ht++) {
  77334. var At = [];
  77335. Et += vt / _;
  77336. var bt = mt * (ht * (k - b) / _ + b);
  77337. for (ft = 0; ft <= d; ft++) {
  77338. var Rt = ft / d
  77339. , Mt = Rt * _e + $
  77340. , Pt = Math.sin(Mt)
  77341. , It = Math.cos(Mt);
  77342. dt.x = bt * Pt,
  77343. dt.y = ct + _t * b - ht * Dt / _,
  77344. dt.z = bt * It,
  77345. nt.push(dt.x, dt.y, dt.z),
  77346. pt.set(Pt, Ct, It).normalize(),
  77347. ot.push(pt.x, pt.y, pt.z),
  77348. at.push(Rt, 1 - Et / yt),
  77349. At.push(st),
  77350. st++
  77351. }
  77352. ut.push(At)
  77353. }
  77354. for (ht = 1; ht <= tt; ht++) {
  77355. var At = []
  77356. , gt = lt - rt - (Math.PI - rt) * (ht / tt);
  77357. Et += k * rt / tt;
  77358. var St = Math.cos(gt)
  77359. , xt = Math.sin(gt)
  77360. , bt = St * k;
  77361. for (ft = 0; ft <= d; ft++) {
  77362. var Rt = ft / d
  77363. , Mt = Rt * _e + $
  77364. , Pt = Math.sin(Mt)
  77365. , It = Math.cos(Mt);
  77366. dt.x = bt * Pt,
  77367. dt.y = -ct + xt * k,
  77368. dt.z = bt * It,
  77369. nt.push(dt.x, dt.y, dt.z),
  77370. pt.set(St * Pt, xt, St * It),
  77371. ot.push(pt.x, pt.y, pt.z),
  77372. at.push(Rt, 1 - Et / yt),
  77373. At.push(st),
  77374. st++
  77375. }
  77376. ut.push(At)
  77377. }
  77378. for (ft = 0; ft < d; ft++)
  77379. for (ht = 0; ht < et + _ + tt; ht++) {
  77380. var Ot = ut[ht][ft]
  77381. , wt = ut[ht + 1][ft]
  77382. , Nt = ut[ht + 1][ft + 1]
  77383. , Ft = ut[ht][ft + 1];
  77384. it.push(Ot),
  77385. it.push(wt),
  77386. it.push(Ft),
  77387. it.push(wt),
  77388. it.push(Nt),
  77389. it.push(Ft)
  77390. }
  77391. if (it = it.reverse(),
  77392. a.orientation && !a.orientation.equals(Vector3.Up())) {
  77393. var Vt = new Matrix;
  77394. a.orientation.clone().scale(Math.PI * .5).cross(Vector3.Up()).toQuaternion().toRotationMatrix(Vt);
  77395. for (var Lt = Vector3.Zero(), kt = 0; kt < nt.length; kt += 3)
  77396. Lt.set(nt[kt], nt[kt + 1], nt[kt + 2]),
  77397. Vector3.TransformCoordinatesToRef(Lt.clone(), Vt, Lt),
  77398. nt[kt] = Lt.x,
  77399. nt[kt + 1] = Lt.y,
  77400. nt[kt + 2] = Lt.z
  77401. }
  77402. var Bt = new VertexData;
  77403. return Bt.positions = nt,
  77404. Bt.normals = ot,
  77405. Bt.uvs = at,
  77406. Bt.indices = it,
  77407. Bt
  77408. }
  77409. function CreateCapsule(a, e, i) {
  77410. e === void 0 && (e = {
  77411. orientation: Vector3.Up(),
  77412. subdivisions: 2,
  77413. tessellation: 16,
  77414. height: 1,
  77415. radius: .25,
  77416. capSubdivisions: 6,
  77417. updatable: !1
  77418. }),
  77419. i === void 0 && (i = null);
  77420. var o = new Mesh(a,i)
  77421. , s = CreateCapsuleVertexData(e);
  77422. return s.applyToMesh(o, e.updatable),
  77423. o
  77424. }
  77425. Mesh.CreateCapsule = function(a, e, i) {
  77426. return CreateCapsule(a, e, i)
  77427. }
  77428. ;
  77429. VertexData.CreateCapsule = CreateCapsuleVertexData;
  77430. var _IsoVector = function() {
  77431. function a(e, i) {
  77432. e === void 0 && (e = 0),
  77433. i === void 0 && (i = 0),
  77434. this.x = e,
  77435. this.y = i,
  77436. e !== Math.floor(e) && Logger$2.Warn("x is not an integer, floor(x) used"),
  77437. i !== Math.floor(i) && Logger$2.Warn("y is not an integer, floor(y) used")
  77438. }
  77439. return a.prototype.clone = function() {
  77440. return new a(this.x,this.y)
  77441. }
  77442. ,
  77443. a.prototype.rotate60About = function(e) {
  77444. var i = this.x;
  77445. return this.x = e.x + e.y - this.y,
  77446. this.y = i + this.y - e.x,
  77447. this
  77448. }
  77449. ,
  77450. a.prototype.rotateNeg60About = function(e) {
  77451. var i = this.x;
  77452. return this.x = i + this.y - e.y,
  77453. this.y = e.x + e.y - i,
  77454. this
  77455. }
  77456. ,
  77457. a.prototype.rotate120 = function(e, i) {
  77458. e !== Math.floor(e) && Logger$2.Warn("m not an integer only floor(m) used"),
  77459. i !== Math.floor(i) && Logger$2.Warn("n not an integer only floor(n) used");
  77460. var o = this.x;
  77461. return this.x = e - o - this.y,
  77462. this.y = i + o,
  77463. this
  77464. }
  77465. ,
  77466. a.prototype.rotateNeg120 = function(e, i) {
  77467. e !== Math.floor(e) && Logger$2.Warn("m is not an integer, floor(m) used"),
  77468. i !== Math.floor(i) && Logger$2.Warn("n is not an integer, floor(n) used");
  77469. var o = this.x;
  77470. return this.x = this.y - i,
  77471. this.y = e + i - o - this.y,
  77472. this
  77473. }
  77474. ,
  77475. a.prototype.toCartesianOrigin = function(e, i) {
  77476. var o = Vector3.Zero();
  77477. return o.x = e.x + 2 * this.x * i + this.y * i,
  77478. o.y = e.y + Math.sqrt(3) * this.y * i,
  77479. o
  77480. }
  77481. ,
  77482. a.Zero = function() {
  77483. return new a(0,0)
  77484. }
  77485. ,
  77486. a
  77487. }()
  77488. , _PrimaryIsoTriangle = function() {
  77489. function a() {
  77490. this.cartesian = [],
  77491. this.vertices = [],
  77492. this.max = [],
  77493. this.min = [],
  77494. this.closestTo = [],
  77495. this.innerFacets = [],
  77496. this.isoVecsABOB = [],
  77497. this.isoVecsOBOA = [],
  77498. this.isoVecsBAOA = [],
  77499. this.vertexTypes = [],
  77500. this.IDATA = new PolyhedronData("icosahedron","Regular",[[0, PHI, -1], [-PHI, 1, 0], [-1, 0, -PHI], [1, 0, -PHI], [PHI, 1, 0], [0, PHI, 1], [-1, 0, PHI], [-PHI, -1, 0], [0, -PHI, -1], [PHI, -1, 0], [1, 0, PHI], [0, -PHI, 1]],[[0, 2, 1], [0, 3, 2], [0, 4, 3], [0, 5, 4], [0, 1, 5], [7, 6, 1], [8, 7, 2], [9, 8, 3], [10, 9, 4], [6, 10, 5], [2, 7, 1], [3, 8, 2], [4, 9, 3], [5, 10, 4], [1, 6, 5], [11, 6, 7], [11, 7, 8], [11, 8, 9], [11, 9, 10], [11, 10, 6]])
  77501. }
  77502. return a.prototype.setIndices = function() {
  77503. var e = 12
  77504. , i = {}
  77505. , o = this.m
  77506. , s = this.n
  77507. , c = o
  77508. , d = 1
  77509. , _ = 0;
  77510. s !== 0 && (c = Scalar.HCF(o, s)),
  77511. d = o / c,
  77512. _ = s / c;
  77513. var b, k, j, $, _e, et = _IsoVector.Zero(), tt = new _IsoVector(o,s), rt = new _IsoVector(-s,o + s), it = _IsoVector.Zero(), nt = _IsoVector.Zero(), ot = _IsoVector.Zero(), at = [], st, ut, ct, lt, ft = [], ht = this.vertByDist;
  77514. this.IDATA.edgematch = [[1, "B"], [2, "B"], [3, "B"], [4, "B"], [0, "B"], [10, "O", 14, "A"], [11, "O", 10, "A"], [12, "O", 11, "A"], [13, "O", 12, "A"], [14, "O", 13, "A"], [0, "O"], [1, "O"], [2, "O"], [3, "O"], [4, "O"], [19, "B", 5, "A"], [15, "B", 6, "A"], [16, "B", 7, "A"], [17, "B", 8, "A"], [18, "B", 9, "A"]];
  77515. for (var pt = 0; pt < 20; pt++) {
  77516. if (at = this.IDATA.face[pt],
  77517. j = at[2],
  77518. $ = at[1],
  77519. _e = at[0],
  77520. ct = et.x + "|" + et.y,
  77521. st = pt + "|" + ct,
  77522. st in i || (i[st] = j,
  77523. ft[j] = [at[ht[ct][0]], ht[ct][1]]),
  77524. ct = tt.x + "|" + tt.y,
  77525. st = pt + "|" + ct,
  77526. st in i || (i[st] = $,
  77527. ft[$] = [at[ht[ct][0]], ht[ct][1]]),
  77528. ct = rt.x + "|" + rt.y,
  77529. st = pt + "|" + ct,
  77530. st in i || (i[st] = _e,
  77531. ft[_e] = [at[ht[ct][0]], ht[ct][1]]),
  77532. b = this.IDATA.edgematch[pt][0],
  77533. k = this.IDATA.edgematch[pt][1],
  77534. k === "B")
  77535. for (var dt = 1; dt < c; dt++)
  77536. nt.x = o - dt * (d + _),
  77537. nt.y = s + dt * d,
  77538. ot.x = -dt * _,
  77539. ot.y = dt * (d + _),
  77540. ct = nt.x + "|" + nt.y,
  77541. lt = ot.x + "|" + ot.y,
  77542. _t(pt, b, ct, lt);
  77543. if (k === "O")
  77544. for (var dt = 1; dt < c; dt++)
  77545. ot.x = -dt * _,
  77546. ot.y = dt * (d + _),
  77547. it.x = dt * d,
  77548. it.y = dt * _,
  77549. ct = ot.x + "|" + ot.y,
  77550. lt = it.x + "|" + it.y,
  77551. _t(pt, b, ct, lt);
  77552. if (b = this.IDATA.edgematch[pt][2],
  77553. k = this.IDATA.edgematch[pt][3],
  77554. k && k === "A")
  77555. for (var dt = 1; dt < c; dt++)
  77556. it.x = dt * d,
  77557. it.y = dt * _,
  77558. nt.x = o - (c - dt) * (d + _),
  77559. nt.y = s + (c - dt) * d,
  77560. ct = it.x + "|" + it.y,
  77561. lt = nt.x + "|" + nt.y,
  77562. _t(pt, b, ct, lt);
  77563. for (var dt = 0; dt < this.vertices.length; dt++)
  77564. ct = this.vertices[dt].x + "|" + this.vertices[dt].y,
  77565. st = pt + "|" + ct,
  77566. st in i || (i[st] = e++,
  77567. ht[ct][0] > 2 ? ft[i[st]] = [-ht[ct][0], ht[ct][1], i[st]] : ft[i[st]] = [at[ht[ct][0]], ht[ct][1], i[st]])
  77568. }
  77569. function _t(mt, vt, yt, Et) {
  77570. st = mt + "|" + yt,
  77571. ut = vt + "|" + Et,
  77572. st in i || ut in i ? st in i && !(ut in i) ? i[ut] = i[st] : ut in i && !(st in i) && (i[st] = i[ut]) : (i[st] = e,
  77573. i[ut] = e,
  77574. e++),
  77575. ht[yt][0] > 2 ? ft[i[st]] = [-ht[yt][0], ht[yt][1], i[st]] : ft[i[st]] = [at[ht[yt][0]], ht[yt][1], i[st]]
  77576. }
  77577. this.closestTo = ft,
  77578. this.vecToIdx = i
  77579. }
  77580. ,
  77581. a.prototype.calcCoeffs = function() {
  77582. var e = this.m
  77583. , i = this.n
  77584. , o = Math.sqrt(3) / 3
  77585. , s = e * e + i * i + e * i;
  77586. this.coau = (e + i) / s,
  77587. this.cobu = -i / s,
  77588. this.coav = -o * (e - i) / s,
  77589. this.cobv = o * (2 * e + i) / s
  77590. }
  77591. ,
  77592. a.prototype.createInnerFacets = function() {
  77593. for (var e = this.m, i = this.n, o = 0; o < i + e + 1; o++)
  77594. for (var s = this.min[o]; s < this.max[o] + 1; s++)
  77595. s < this.max[o] && s < this.max[o + 1] + 1 && this.innerFacets.push(["|" + s + "|" + o, "|" + s + "|" + (o + 1), "|" + (s + 1) + "|" + o]),
  77596. o > 0 && s < this.max[o - 1] && s + 1 < this.max[o] + 1 && this.innerFacets.push(["|" + s + "|" + o, "|" + (s + 1) + "|" + o, "|" + (s + 1) + "|" + (o - 1)])
  77597. }
  77598. ,
  77599. a.prototype.edgeVecsABOB = function() {
  77600. for (var e = this.m, i = this.n, o = new _IsoVector(-i,e + i), s = 1; s < e + i; s++) {
  77601. var c = new _IsoVector(this.min[s],s)
  77602. , d = new _IsoVector(this.min[s - 1],s - 1)
  77603. , _ = new _IsoVector(this.min[s + 1],s + 1)
  77604. , b = c.clone()
  77605. , k = d.clone()
  77606. , j = _.clone();
  77607. b.rotate60About(o),
  77608. k.rotate60About(o),
  77609. j.rotate60About(o);
  77610. var $ = new _IsoVector(this.max[b.y],b.y)
  77611. , _e = new _IsoVector(this.max[b.y - 1],b.y - 1)
  77612. , et = new _IsoVector(this.max[b.y - 1] - 1,b.y - 1);
  77613. (b.x !== $.x || b.y !== $.y) && (b.x !== _e.x ? (this.vertexTypes.push([1, 0, 0]),
  77614. this.isoVecsABOB.push([c, _e, et]),
  77615. this.vertexTypes.push([1, 0, 0]),
  77616. this.isoVecsABOB.push([c, et, $])) : b.y === j.y ? (this.vertexTypes.push([1, 1, 0]),
  77617. this.isoVecsABOB.push([c, d, _e]),
  77618. this.vertexTypes.push([1, 0, 1]),
  77619. this.isoVecsABOB.push([c, _e, _])) : (this.vertexTypes.push([1, 1, 0]),
  77620. this.isoVecsABOB.push([c, d, _e]),
  77621. this.vertexTypes.push([1, 0, 0]),
  77622. this.isoVecsABOB.push([c, _e, $])))
  77623. }
  77624. }
  77625. ,
  77626. a.prototype.mapABOBtoOBOA = function() {
  77627. for (var e = new _IsoVector(0,0), i = 0; i < this.isoVecsABOB.length; i++) {
  77628. for (var o = [], s = 0; s < 3; s++)
  77629. e.x = this.isoVecsABOB[i][s].x,
  77630. e.y = this.isoVecsABOB[i][s].y,
  77631. this.vertexTypes[i][s] === 0 && e.rotateNeg120(this.m, this.n),
  77632. o.push(e.clone());
  77633. this.isoVecsOBOA.push(o)
  77634. }
  77635. }
  77636. ,
  77637. a.prototype.mapABOBtoBAOA = function() {
  77638. for (var e = new _IsoVector(0,0), i = 0; i < this.isoVecsABOB.length; i++) {
  77639. for (var o = [], s = 0; s < 3; s++)
  77640. e.x = this.isoVecsABOB[i][s].x,
  77641. e.y = this.isoVecsABOB[i][s].y,
  77642. this.vertexTypes[i][s] === 1 && e.rotate120(this.m, this.n),
  77643. o.push(e.clone());
  77644. this.isoVecsBAOA.push(o)
  77645. }
  77646. }
  77647. ,
  77648. a.prototype.MapToFace = function(e, i) {
  77649. for (var o = this.IDATA.face[e], s = o[2], c = o[1], d = o[0], _ = Vector3.FromArray(this.IDATA.vertex[s]), b = Vector3.FromArray(this.IDATA.vertex[c]), k = Vector3.FromArray(this.IDATA.vertex[d]), j = b.subtract(_), $ = k.subtract(_), _e = j.scale(this.coau).add($.scale(this.cobu)), et = j.scale(this.coav).add($.scale(this.cobv)), tt = [], rt, it = TmpVectors.Vector3[0], nt = 0; nt < this.cartesian.length; nt++)
  77650. it = _e.scale(this.cartesian[nt].x).add(et.scale(this.cartesian[nt].y)).add(_),
  77651. tt[nt] = [it.x, it.y, it.z],
  77652. rt = e + "|" + this.vertices[nt].x + "|" + this.vertices[nt].y,
  77653. i.vertex[this.vecToIdx[rt]] = [it.x, it.y, it.z]
  77654. }
  77655. ,
  77656. a.prototype.build = function(e, i) {
  77657. var o = new Array
  77658. , s = _IsoVector.Zero()
  77659. , c = new _IsoVector(e,i)
  77660. , d = new _IsoVector(-i,e + i);
  77661. o.push(s, c, d);
  77662. for (var _ = i; _ < e + 1; _++)
  77663. for (var b = 0; b < e + 1 - _; b++)
  77664. o.push(new _IsoVector(b,_));
  77665. if (i > 0) {
  77666. for (var k = Scalar.HCF(e, i), j = e / k, $ = i / k, _e = 1; _e < k; _e++)
  77667. o.push(new _IsoVector(_e * j,_e * $)),
  77668. o.push(new _IsoVector(-_e * $,_e * (j + $))),
  77669. o.push(new _IsoVector(e - _e * (j + $),i + _e * j));
  77670. for (var et = e / i, tt = 1; tt < i; tt++)
  77671. for (var rt = 0; rt < tt * et; rt++)
  77672. o.push(new _IsoVector(rt,tt)),
  77673. o.push(new _IsoVector(rt,tt).rotate120(e, i)),
  77674. o.push(new _IsoVector(rt,tt).rotateNeg120(e, i))
  77675. }
  77676. o.sort(function(yt, Et) {
  77677. return yt.x - Et.x
  77678. }),
  77679. o.sort(function(yt, Et) {
  77680. return yt.y - Et.y
  77681. });
  77682. for (var it = new Array(e + i + 1), nt = new Array(e + i + 1), _e = 0; _e < it.length; _e++)
  77683. it[_e] = 1 / 0,
  77684. nt[_e] = -1 / 0;
  77685. for (var ot = 0, at = 0, st = o.length, _e = 0; _e < st; _e++)
  77686. at = o[_e].x,
  77687. ot = o[_e].y,
  77688. it[ot] = Math.min(at, it[ot]),
  77689. nt[ot] = Math.max(at, nt[ot]);
  77690. for (var ut = function(yt, Et) {
  77691. var At = yt.clone();
  77692. return Et === "A" && At.rotateNeg120(e, i),
  77693. Et === "B" && At.rotate120(e, i),
  77694. At.x < 0 ? At.y : At.x + At.y
  77695. }, ct = [], lt = [], ft = [], ht = [], pt = {}, dt = [], _t = -1, mt = -1, _e = 0; _e < st; _e++)
  77696. ct[_e] = o[_e].toCartesianOrigin(new _IsoVector(0,0), .5),
  77697. lt[_e] = ut(o[_e], "O"),
  77698. ft[_e] = ut(o[_e], "A"),
  77699. ht[_e] = ut(o[_e], "B"),
  77700. lt[_e] === ft[_e] && ft[_e] === ht[_e] ? (_t = 3,
  77701. mt = lt[_e]) : lt[_e] === ft[_e] ? (_t = 4,
  77702. mt = lt[_e]) : ft[_e] === ht[_e] ? (_t = 5,
  77703. mt = ft[_e]) : ht[_e] === lt[_e] && (_t = 6,
  77704. mt = lt[_e]),
  77705. lt[_e] < ft[_e] && lt[_e] < ht[_e] && (_t = 2,
  77706. mt = lt[_e]),
  77707. ft[_e] < lt[_e] && ft[_e] < ht[_e] && (_t = 1,
  77708. mt = ft[_e]),
  77709. ht[_e] < ft[_e] && ht[_e] < lt[_e] && (_t = 0,
  77710. mt = ht[_e]),
  77711. dt.push([_t, mt, o[_e].x, o[_e].y]);
  77712. dt.sort(function(yt, Et) {
  77713. return yt[2] - Et[2]
  77714. }),
  77715. dt.sort(function(yt, Et) {
  77716. return yt[3] - Et[3]
  77717. }),
  77718. dt.sort(function(yt, Et) {
  77719. return yt[1] - Et[1]
  77720. }),
  77721. dt.sort(function(yt, Et) {
  77722. return yt[0] - Et[0]
  77723. });
  77724. for (var vt = 0; vt < dt.length; vt++)
  77725. pt[dt[vt][2] + "|" + dt[vt][3]] = [dt[vt][0], dt[vt][1], vt];
  77726. return this.m = e,
  77727. this.n = i,
  77728. this.vertices = o,
  77729. this.vertByDist = pt,
  77730. this.cartesian = ct,
  77731. this.min = it,
  77732. this.max = nt,
  77733. this
  77734. }
  77735. ,
  77736. a
  77737. }()
  77738. , PolyhedronData = function() {
  77739. function a(e, i, o, s) {
  77740. this.name = e,
  77741. this.category = i,
  77742. this.vertex = o,
  77743. this.face = s
  77744. }
  77745. return a
  77746. }()
  77747. , GeodesicData = function(a) {
  77748. __extends(e, a);
  77749. function e() {
  77750. return a !== null && a.apply(this, arguments) || this
  77751. }
  77752. return e.prototype.innerToData = function(i, o) {
  77753. for (var s = 0; s < o.innerFacets.length; s++)
  77754. this.face.push(o.innerFacets[s].map(function(c) {
  77755. return o.vecToIdx[i + c]
  77756. }))
  77757. }
  77758. ,
  77759. e.prototype.mapABOBtoDATA = function(i, o) {
  77760. for (var s = o.IDATA.edgematch[i][0], c = 0; c < o.isoVecsABOB.length; c++) {
  77761. for (var d = [], _ = 0; _ < 3; _++)
  77762. o.vertexTypes[c][_] === 0 ? d.push(i + "|" + o.isoVecsABOB[c][_].x + "|" + o.isoVecsABOB[c][_].y) : d.push(s + "|" + o.isoVecsABOB[c][_].x + "|" + o.isoVecsABOB[c][_].y);
  77763. this.face.push([o.vecToIdx[d[0]], o.vecToIdx[d[1]], o.vecToIdx[d[2]]])
  77764. }
  77765. }
  77766. ,
  77767. e.prototype.mapOBOAtoDATA = function(i, o) {
  77768. for (var s = o.IDATA.edgematch[i][0], c = 0; c < o.isoVecsOBOA.length; c++) {
  77769. for (var d = [], _ = 0; _ < 3; _++)
  77770. o.vertexTypes[c][_] === 1 ? d.push(i + "|" + o.isoVecsOBOA[c][_].x + "|" + o.isoVecsOBOA[c][_].y) : d.push(s + "|" + o.isoVecsOBOA[c][_].x + "|" + o.isoVecsOBOA[c][_].y);
  77771. this.face.push([o.vecToIdx[d[0]], o.vecToIdx[d[1]], o.vecToIdx[d[2]]])
  77772. }
  77773. }
  77774. ,
  77775. e.prototype.mapBAOAtoDATA = function(i, o) {
  77776. for (var s = o.IDATA.edgematch[i][2], c = 0; c < o.isoVecsBAOA.length; c++) {
  77777. for (var d = [], _ = 0; _ < 3; _++)
  77778. o.vertexTypes[c][_] === 1 ? d.push(i + "|" + o.isoVecsBAOA[c][_].x + "|" + o.isoVecsBAOA[c][_].y) : d.push(s + "|" + o.isoVecsBAOA[c][_].x + "|" + o.isoVecsBAOA[c][_].y);
  77779. this.face.push([o.vecToIdx[d[0]], o.vecToIdx[d[1]], o.vecToIdx[d[2]]])
  77780. }
  77781. }
  77782. ,
  77783. e.prototype.orderData = function(i) {
  77784. for (var o = [], s = 0; s < 13; s++)
  77785. o[s] = [];
  77786. for (var c = i.closestTo, s = 0; s < c.length; s++)
  77787. c[s][0] > -1 ? c[s][1] > 0 && o[c[s][0]].push([s, c[s][1]]) : o[12].push([s, c[s][0]]);
  77788. for (var d = [], s = 0; s < 12; s++)
  77789. d[s] = s;
  77790. for (var _ = 12, s = 0; s < 12; s++) {
  77791. o[s].sort(function(j, $) {
  77792. return j[1] - $[1]
  77793. });
  77794. for (var b = 0; b < o[s].length; b++)
  77795. d[o[s][b][0]] = _++
  77796. }
  77797. for (var b = 0; b < o[12].length; b++)
  77798. d[o[12][b][0]] = _++;
  77799. for (var s = 0; s < this.vertex.length; s++)
  77800. this.vertex[s].push(d[s]);
  77801. this.vertex.sort(function(k, j) {
  77802. return k[3] - j[3]
  77803. });
  77804. for (var s = 0; s < this.vertex.length; s++)
  77805. this.vertex[s].pop();
  77806. for (var s = 0; s < this.face.length; s++)
  77807. for (var b = 0; b < this.face[s].length; b++)
  77808. this.face[s][b] = d[this.face[s][b]];
  77809. this.sharedNodes = o[12].length,
  77810. this.poleNodes = this.vertex.length - this.sharedNodes
  77811. }
  77812. ,
  77813. e.prototype.setOrder = function(i, o) {
  77814. var s = []
  77815. , c = []
  77816. , d = o.pop();
  77817. c.push(d);
  77818. var _ = this.face[d].indexOf(i);
  77819. _ = (_ + 2) % 3;
  77820. var b = this.face[d][_];
  77821. s.push(b);
  77822. for (var k = 0; o.length > 0; )
  77823. d = o[k],
  77824. this.face[d].indexOf(b) > -1 ? (_ = (this.face[d].indexOf(b) + 1) % 3,
  77825. b = this.face[d][_],
  77826. s.push(b),
  77827. c.push(d),
  77828. o.splice(k, 1),
  77829. k = 0) : k++;
  77830. return this.adjacentFaces.push(s),
  77831. c
  77832. }
  77833. ,
  77834. e.prototype.toGoldbergData = function() {
  77835. var i = this
  77836. , o = new PolyhedronData("GeoDual","Goldberg",[],[]);
  77837. o.name = "GD dual";
  77838. for (var s = this.vertex.length, c = new Array(s), d = 0; d < s; d++)
  77839. c[d] = [];
  77840. for (var _ = 0; _ < this.face.length; _++)
  77841. for (var b = 0; b < 3; b++)
  77842. c[this.face[_][b]].push(_);
  77843. var k = 0
  77844. , j = 0
  77845. , $ = 0
  77846. , _e = []
  77847. , et = [];
  77848. this.adjacentFaces = [];
  77849. for (var tt = 0; tt < c.length; tt++)
  77850. o.face[tt] = this.setOrder(tt, c[tt].concat([])),
  77851. c[tt].forEach(function(rt) {
  77852. k = 0,
  77853. j = 0,
  77854. $ = 0,
  77855. _e = i.face[rt];
  77856. for (var it = 0; it < 3; it++)
  77857. et = i.vertex[_e[it]],
  77858. k += et[0],
  77859. j += et[1],
  77860. $ += et[2];
  77861. o.vertex[rt] = [k / 3, j / 3, $ / 3]
  77862. });
  77863. return o
  77864. }
  77865. ,
  77866. e.BuildGeodesicData = function(i) {
  77867. var o = new e("Geodesic-m-n","Geodesic",[[0, PHI, -1], [-PHI, 1, 0], [-1, 0, -PHI], [1, 0, -PHI], [PHI, 1, 0], [0, PHI, 1], [-1, 0, PHI], [-PHI, -1, 0], [0, -PHI, -1], [PHI, -1, 0], [1, 0, PHI], [0, -PHI, 1]],[]);
  77868. i.setIndices(),
  77869. i.calcCoeffs(),
  77870. i.createInnerFacets(),
  77871. i.edgeVecsABOB(),
  77872. i.mapABOBtoOBOA(),
  77873. i.mapABOBtoBAOA();
  77874. for (var s = 0; s < i.IDATA.face.length; s++)
  77875. i.MapToFace(s, o),
  77876. o.innerToData(s, i),
  77877. i.IDATA.edgematch[s][1] === "B" && o.mapABOBtoDATA(s, i),
  77878. i.IDATA.edgematch[s][1] === "O" && o.mapOBOAtoDATA(s, i),
  77879. i.IDATA.edgematch[s][3] === "A" && o.mapBAOAtoDATA(s, i);
  77880. o.orderData(i);
  77881. var c = 1;
  77882. return o.vertex = o.vertex.map(function(d) {
  77883. var _ = d[0]
  77884. , b = d[1]
  77885. , k = d[2]
  77886. , j = Math.sqrt(_ * _ + b * b + k * k);
  77887. return d[0] *= c / j,
  77888. d[1] *= c / j,
  77889. d[2] *= c / j,
  77890. d
  77891. }),
  77892. o
  77893. }
  77894. ,
  77895. e
  77896. }(PolyhedronData);
  77897. function CreateGeodesic(a, e, i) {
  77898. i === void 0 && (i = null);
  77899. var o = e.m || 1;
  77900. o !== Math.floor(o) && Logger$2.Warn("m not an integer only floor(m) used");
  77901. var s = e.n || 0;
  77902. if (s !== Math.floor(s) && Logger$2.Warn("n not an integer only floor(n) used"),
  77903. s > o) {
  77904. var c = s;
  77905. s = o,
  77906. o = c,
  77907. Logger$2.Warn("n > m therefore m and n swapped")
  77908. }
  77909. var d = new _PrimaryIsoTriangle;
  77910. d.build(o, s);
  77911. var _ = GeodesicData.BuildGeodesicData(d)
  77912. , b = {
  77913. custom: _,
  77914. size: e.size,
  77915. sizeX: e.sizeX,
  77916. sizeY: e.sizeY,
  77917. sizeZ: e.sizeZ,
  77918. faceUV: e.faceUV,
  77919. faceColors: e.faceColors,
  77920. flat: e.flat,
  77921. updatable: e.updatable,
  77922. sideOrientation: e.sideOrientation,
  77923. frontUVs: e.frontUVs,
  77924. backUVs: e.backUVs
  77925. }
  77926. , k = CreatePolyhedron(a, b, i);
  77927. return k
  77928. }
  77929. function CreateGoldbergVertexData(a, e) {
  77930. for (var i = a.size, o = a.sizeX || i || 1, s = a.sizeY || i || 1, c = a.sizeZ || i || 1, d = a.sideOrientation === 0 ? 0 : a.sideOrientation || VertexData.DEFAULTSIDE, _ = new Array, b = new Array, k = new Array, j = new Array, $ = 1 / 0, _e = -1 / 0, et = 1 / 0, tt = -1 / 0, rt = 0; rt < e.vertex.length; rt++)
  77931. $ = Math.min($, e.vertex[rt][0] * o),
  77932. _e = Math.max(_e, e.vertex[rt][0] * o),
  77933. et = Math.min(et, e.vertex[rt][1] * s),
  77934. tt = Math.max(tt, e.vertex[rt][1] * s);
  77935. for (var it = 0, nt = 0; nt < e.face.length; nt++) {
  77936. for (var ot = e.face[nt], at = Vector3.FromArray(e.vertex[ot[0]]), st = Vector3.FromArray(e.vertex[ot[2]]), ut = Vector3.FromArray(e.vertex[ot[1]]), ct = st.subtract(at), lt = ut.subtract(at), ft = Vector3.Cross(lt, ct).normalize(), rt = 0; rt < ot.length; rt++) {
  77937. k.push(ft.x, ft.y, ft.z);
  77938. var ht = e.vertex[ot[rt]];
  77939. _.push(ht[0] * o, ht[1] * s, ht[2] * c),
  77940. j.push((ht[0] * o - $) / (_e - $), (ht[1] * s - et) / (tt - et))
  77941. }
  77942. for (var rt = 0; rt < ot.length - 2; rt++)
  77943. b.push(it, it + rt + 2, it + rt + 1);
  77944. it += ot.length
  77945. }
  77946. VertexData._ComputeSides(d, _, b, k, j);
  77947. var pt = new VertexData;
  77948. return pt.positions = _,
  77949. pt.indices = b,
  77950. pt.normals = k,
  77951. pt.uvs = j,
  77952. pt
  77953. }
  77954. function CreateGoldberg(a, e, i) {
  77955. var o = e.m || 1;
  77956. o !== Math.floor(o) && Logger$2.Warn("m not an integer only floor(m) used");
  77957. var s = e.n || 0;
  77958. if (s !== Math.floor(s) && Logger$2.Warn("n not an integer only floor(n) used"),
  77959. s > o) {
  77960. var c = s;
  77961. s = o,
  77962. o = c,
  77963. Logger$2.Warn("n > m therefore m and n swapped")
  77964. }
  77965. var d = new _PrimaryIsoTriangle;
  77966. d.build(o, s);
  77967. var _ = GeodesicData.BuildGeodesicData(d)
  77968. , b = _.toGoldbergData()
  77969. , k = new GoldbergMesh(a);
  77970. e.sideOrientation = Mesh._GetDefaultSideOrientation(e.sideOrientation),
  77971. k._originalBuilderSideOrientation = e.sideOrientation;
  77972. var j = CreateGoldbergVertexData(e, b);
  77973. j.applyToMesh(k, e.updatable),
  77974. k.nbSharedFaces = _.sharedNodes,
  77975. k.nbUnsharedFaces = _.poleNodes,
  77976. k.adjacentFaces = _.adjacentFaces,
  77977. k.nbFaces = k.nbSharedFaces + k.nbUnsharedFaces,
  77978. k.nbFacesAtPole = (k.nbUnsharedFaces - 12) / 12;
  77979. for (var $ = 0; $ < _.vertex.length; $++)
  77980. k.faceCenters.push(Vector3.FromArray(_.vertex[$])),
  77981. k.faceColors.push(new Color4(1,1,1,1));
  77982. for (var $ = 0; $ < b.face.length; $++) {
  77983. var _e = b.face[$]
  77984. , et = Vector3.FromArray(b.vertex[_e[0]])
  77985. , tt = Vector3.FromArray(b.vertex[_e[2]])
  77986. , rt = Vector3.FromArray(b.vertex[_e[1]])
  77987. , it = tt.subtract(et)
  77988. , nt = rt.subtract(et)
  77989. , ot = Vector3.Cross(nt, it).normalize()
  77990. , at = Vector3.Cross(nt, ot).normalize();
  77991. k.faceXaxis.push(nt.normalize()),
  77992. k.faceYaxis.push(ot),
  77993. k.faceZaxis.push(at)
  77994. }
  77995. return k.setMetadata(),
  77996. k
  77997. }
  77998. function GoldbergCreate(a) {
  77999. return function(e) {
  78000. __extends(i, e);
  78001. function i() {
  78002. var o = e !== null && e.apply(this, arguments) || this;
  78003. return o.faceColors = [],
  78004. o.faceCenters = [],
  78005. o.faceZaxis = [],
  78006. o.faceXaxis = [],
  78007. o.faceYaxis = [],
  78008. o
  78009. }
  78010. return i.prototype.setMetadata = function() {
  78011. this.metadata = {
  78012. nbSharedFaces: this.nbSharedFaces,
  78013. nbUnsharedFaces: this.nbUnsharedFaces,
  78014. nbFacesAtPole: this.nbFacesAtPole,
  78015. nbFaces: this.nbFaces,
  78016. faceCenters: this.faceCenters,
  78017. faceXaxis: this.faceXaxis,
  78018. faceYaxis: this.faceYaxis,
  78019. faceZaxis: this.faceZaxis,
  78020. adjacentFaces: this.adjacentFaces
  78021. }
  78022. }
  78023. ,
  78024. i.prototype.relFace = function(o, s) {
  78025. return s === void 0 ? (o > this.nbUnsharedFaces - 1 && (Logger$2.Warn("Maximum number of unshared faces used"),
  78026. o = this.nbUnsharedFaces - 1),
  78027. this.nbUnsharedFaces + o) : (o > 11 && (Logger$2.Warn("Last pole used"),
  78028. o = 11),
  78029. s > this.nbFacesAtPole - 1 && (Logger$2.Warn("Maximum number of faces at a pole used"),
  78030. s = this.nbFacesAtPole - 1),
  78031. 12 + o * this.nbFacesAtPole + s)
  78032. }
  78033. ,
  78034. i.prototype.refreshFaceData = function() {
  78035. this.nbSharedFaces = this.metadata.nbSharedFaces,
  78036. this.nbUnsharedFaces = this.metadata.nbUnsharedFaces,
  78037. this.nbFacesAtPole = this.metadata.nbFacesAtPole,
  78038. this.adjacentFaces = this.metadata.adjacentFaces,
  78039. this.nbFaces = this.metadata.nbFaces,
  78040. this.faceCenters = this.metadata.faceCenters,
  78041. this.faceXaxis = this.metadata.faceXaxis,
  78042. this.faceYaxis = this.metadata.faceYaxis,
  78043. this.faceZaxis = this.metadata.faceZaxis
  78044. }
  78045. ,
  78046. i.prototype.changeFaceColors = function(o) {
  78047. for (var s = 0; s < o.length; s++)
  78048. for (var c = o[s][0], d = o[s][1], _ = o[s][2], b = c; b < d + 1; b++)
  78049. this.faceColors[b] = _;
  78050. for (var k = [], b = 0; b < 12; b++)
  78051. for (var s = 0; s < 5; s++)
  78052. k.push(this.faceColors[b].r, this.faceColors[b].g, this.faceColors[b].b, this.faceColors[b].a);
  78053. for (var b = 12; b < this.faceColors.length; b++)
  78054. for (var s = 0; s < 6; s++)
  78055. k.push(this.faceColors[b].r, this.faceColors[b].g, this.faceColors[b].b, this.faceColors[b].a);
  78056. return k
  78057. }
  78058. ,
  78059. i.prototype.setFaceColors = function(o) {
  78060. var s = this.changeFaceColors(o);
  78061. this.setVerticesData(VertexBuffer.ColorKind, s)
  78062. }
  78063. ,
  78064. i.prototype.updateFaceColors = function(o) {
  78065. var s = this.changeFaceColors(o);
  78066. this.updateVerticesData(VertexBuffer.ColorKind, s)
  78067. }
  78068. ,
  78069. i.prototype.changeFaceUVs = function(o) {
  78070. for (var s = this.getVerticesData(VertexBuffer.UVKind), c = 0; c < o.length; c++) {
  78071. for (var d = o[c][0], _ = o[c][1], b = o[c][2], k = o[c][3], j = o[c][4], $ = [], _e = [], et = void 0, tt = void 0, rt = 0; rt < 5; rt++)
  78072. et = b.x + k * Math.cos(j + rt * Math.PI / 2.5),
  78073. tt = b.y + k * Math.sin(j + rt * Math.PI / 2.5),
  78074. et < 0 && (et = 0),
  78075. et > 1 && (et = 1),
  78076. $.push(et, tt);
  78077. for (var rt = 0; rt < 6; rt++)
  78078. et = b.x + k * Math.cos(j + rt * Math.PI / 3),
  78079. tt = b.y + k * Math.sin(j + rt * Math.PI / 3),
  78080. et < 0 && (et = 0),
  78081. et > 1 && (et = 1),
  78082. _e.push(et, tt);
  78083. for (var it = d; it < Math.min(12, _ + 1); it++)
  78084. for (var rt = 0; rt < 5; rt++)
  78085. s[10 * it + 2 * rt] = $[2 * rt],
  78086. s[10 * it + 2 * rt + 1] = $[2 * rt + 1];
  78087. for (var it = Math.max(12, d); it < _ + 1; it++)
  78088. for (var rt = 0; rt < 6; rt++)
  78089. s[12 * it - 24 + 2 * rt] = _e[2 * rt],
  78090. s[12 * it - 23 + 2 * rt] = _e[2 * rt + 1]
  78091. }
  78092. return s
  78093. }
  78094. ,
  78095. i.prototype.setFaceUVs = function(o) {
  78096. var s = this.changeFaceUVs(o);
  78097. this.setVerticesData(VertexBuffer.UVKind, s)
  78098. }
  78099. ,
  78100. i.prototype.updateFaceUVs = function(o) {
  78101. var s = this.changeFaceUVs(o);
  78102. this.updateVerticesData(VertexBuffer.UVKind, s)
  78103. }
  78104. ,
  78105. i.prototype.placeOnFaceAt = function(o, s, c) {
  78106. var d = Vector3.RotationFromAxis(this.faceXaxis[s], this.faceYaxis[s], this.faceZaxis[s]);
  78107. o.rotation = d,
  78108. o.position = this.faceCenters[s].add(this.faceXaxis[s].scale(c.x)).add(this.faceYaxis[s].scale(c.y)).add(this.faceZaxis[s].scale(c.z))
  78109. }
  78110. ,
  78111. i
  78112. }(a)
  78113. }
  78114. var GoldbergMesh = GoldbergCreate(Mesh)
  78115. , MeshBuilder = {
  78116. CreateBox,
  78117. CreateTiledBox,
  78118. CreateSphere,
  78119. CreateDisc,
  78120. CreateIcoSphere,
  78121. CreateRibbon,
  78122. CreateCylinder,
  78123. CreateTorus,
  78124. CreateTorusKnot,
  78125. CreateLineSystem,
  78126. CreateLines,
  78127. CreateDashedLines,
  78128. ExtrudeShape,
  78129. ExtrudeShapeCustom,
  78130. CreateLathe,
  78131. CreateTiledPlane,
  78132. CreatePlane,
  78133. CreateGround,
  78134. CreateTiledGround,
  78135. CreateGroundFromHeightMap,
  78136. CreatePolygon,
  78137. ExtrudePolygon,
  78138. CreateTube,
  78139. CreatePolyhedron,
  78140. CreateGeodesic,
  78141. CreateGoldberg,
  78142. CreateDecal,
  78143. CreateCapsule
  78144. }
  78145. , Ray = function() {
  78146. function a(e, i, o) {
  78147. o === void 0 && (o = Number.MAX_VALUE),
  78148. this.origin = e,
  78149. this.direction = i,
  78150. this.length = o
  78151. }
  78152. return a.prototype.clone = function() {
  78153. return new a(this.origin.clone(),this.direction.clone(),this.length)
  78154. }
  78155. ,
  78156. a.prototype.intersectsBoxMinMax = function(e, i, o) {
  78157. o === void 0 && (o = 0);
  78158. var s = a._TmpVector3[0].copyFromFloats(e.x - o, e.y - o, e.z - o), c = a._TmpVector3[1].copyFromFloats(i.x + o, i.y + o, i.z + o), d = 0, _ = Number.MAX_VALUE, b, k, j, $;
  78159. if (Math.abs(this.direction.x) < 1e-7) {
  78160. if (this.origin.x < s.x || this.origin.x > c.x)
  78161. return !1
  78162. } else if (b = 1 / this.direction.x,
  78163. k = (s.x - this.origin.x) * b,
  78164. j = (c.x - this.origin.x) * b,
  78165. j === -1 / 0 && (j = 1 / 0),
  78166. k > j && ($ = k,
  78167. k = j,
  78168. j = $),
  78169. d = Math.max(k, d),
  78170. _ = Math.min(j, _),
  78171. d > _)
  78172. return !1;
  78173. if (Math.abs(this.direction.y) < 1e-7) {
  78174. if (this.origin.y < s.y || this.origin.y > c.y)
  78175. return !1
  78176. } else if (b = 1 / this.direction.y,
  78177. k = (s.y - this.origin.y) * b,
  78178. j = (c.y - this.origin.y) * b,
  78179. j === -1 / 0 && (j = 1 / 0),
  78180. k > j && ($ = k,
  78181. k = j,
  78182. j = $),
  78183. d = Math.max(k, d),
  78184. _ = Math.min(j, _),
  78185. d > _)
  78186. return !1;
  78187. if (Math.abs(this.direction.z) < 1e-7) {
  78188. if (this.origin.z < s.z || this.origin.z > c.z)
  78189. return !1
  78190. } else if (b = 1 / this.direction.z,
  78191. k = (s.z - this.origin.z) * b,
  78192. j = (c.z - this.origin.z) * b,
  78193. j === -1 / 0 && (j = 1 / 0),
  78194. k > j && ($ = k,
  78195. k = j,
  78196. j = $),
  78197. d = Math.max(k, d),
  78198. _ = Math.min(j, _),
  78199. d > _)
  78200. return !1;
  78201. return !0
  78202. }
  78203. ,
  78204. a.prototype.intersectsBox = function(e, i) {
  78205. return i === void 0 && (i = 0),
  78206. this.intersectsBoxMinMax(e.minimum, e.maximum, i)
  78207. }
  78208. ,
  78209. a.prototype.intersectsSphere = function(e, i) {
  78210. i === void 0 && (i = 0);
  78211. var o = e.center.x - this.origin.x
  78212. , s = e.center.y - this.origin.y
  78213. , c = e.center.z - this.origin.z
  78214. , d = o * o + s * s + c * c
  78215. , _ = e.radius + i
  78216. , b = _ * _;
  78217. if (d <= b)
  78218. return !0;
  78219. var k = o * this.direction.x + s * this.direction.y + c * this.direction.z;
  78220. if (k < 0)
  78221. return !1;
  78222. var j = d - k * k;
  78223. return j <= b
  78224. }
  78225. ,
  78226. a.prototype.intersectsTriangle = function(e, i, o) {
  78227. var s = a._TmpVector3[0]
  78228. , c = a._TmpVector3[1]
  78229. , d = a._TmpVector3[2]
  78230. , _ = a._TmpVector3[3]
  78231. , b = a._TmpVector3[4];
  78232. i.subtractToRef(e, s),
  78233. o.subtractToRef(e, c),
  78234. Vector3.CrossToRef(this.direction, c, d);
  78235. var k = Vector3.Dot(s, d);
  78236. if (k === 0)
  78237. return null;
  78238. var j = 1 / k;
  78239. this.origin.subtractToRef(e, _);
  78240. var $ = Vector3.Dot(_, d) * j;
  78241. if ($ < 0 || $ > 1)
  78242. return null;
  78243. Vector3.CrossToRef(_, s, b);
  78244. var _e = Vector3.Dot(this.direction, b) * j;
  78245. if (_e < 0 || $ + _e > 1)
  78246. return null;
  78247. var et = Vector3.Dot(c, b) * j;
  78248. return et > this.length ? null : new IntersectionInfo(1 - $ - _e,$,et)
  78249. }
  78250. ,
  78251. a.prototype.intersectsPlane = function(e) {
  78252. var i, o = Vector3.Dot(e.normal, this.direction);
  78253. if (Math.abs(o) < 999999997475243e-21)
  78254. return null;
  78255. var s = Vector3.Dot(e.normal, this.origin);
  78256. return i = (-e.d - s) / o,
  78257. i < 0 ? i < -999999997475243e-21 ? null : 0 : i
  78258. }
  78259. ,
  78260. a.prototype.intersectsAxis = function(e, i) {
  78261. switch (i === void 0 && (i = 0),
  78262. e) {
  78263. case "y":
  78264. var o = (this.origin.y - i) / this.direction.y;
  78265. return o > 0 ? null : new Vector3(this.origin.x + this.direction.x * -o,i,this.origin.z + this.direction.z * -o);
  78266. case "x":
  78267. var o = (this.origin.x - i) / this.direction.x;
  78268. return o > 0 ? null : new Vector3(i,this.origin.y + this.direction.y * -o,this.origin.z + this.direction.z * -o);
  78269. case "z":
  78270. var o = (this.origin.z - i) / this.direction.z;
  78271. return o > 0 ? null : new Vector3(this.origin.x + this.direction.x * -o,this.origin.y + this.direction.y * -o,i);
  78272. default:
  78273. return null
  78274. }
  78275. }
  78276. ,
  78277. a.prototype.intersectsMesh = function(e, i) {
  78278. var o = TmpVectors.Matrix[0];
  78279. return e.getWorldMatrix().invertToRef(o),
  78280. this._tmpRay ? a.TransformToRef(this, o, this._tmpRay) : this._tmpRay = a.Transform(this, o),
  78281. e.intersects(this._tmpRay, i)
  78282. }
  78283. ,
  78284. a.prototype.intersectsMeshes = function(e, i, o) {
  78285. o ? o.length = 0 : o = [];
  78286. for (var s = 0; s < e.length; s++) {
  78287. var c = this.intersectsMesh(e[s], i);
  78288. c.hit && o.push(c)
  78289. }
  78290. return o.sort(this._comparePickingInfo),
  78291. o
  78292. }
  78293. ,
  78294. a.prototype._comparePickingInfo = function(e, i) {
  78295. return e.distance < i.distance ? -1 : e.distance > i.distance ? 1 : 0
  78296. }
  78297. ,
  78298. a.prototype.intersectionSegment = function(e, i, o) {
  78299. var s = this.origin
  78300. , c = TmpVectors.Vector3[0]
  78301. , d = TmpVectors.Vector3[1]
  78302. , _ = TmpVectors.Vector3[2]
  78303. , b = TmpVectors.Vector3[3];
  78304. i.subtractToRef(e, c),
  78305. this.direction.scaleToRef(a.rayl, _),
  78306. s.addToRef(_, d),
  78307. e.subtractToRef(s, b);
  78308. var k = Vector3.Dot(c, c), j = Vector3.Dot(c, _), $ = Vector3.Dot(_, _), _e = Vector3.Dot(c, b), et = Vector3.Dot(_, b), tt = k * $ - j * j, rt, it, nt = tt, ot, at, st = tt;
  78309. tt < a.smallnum ? (it = 0,
  78310. nt = 1,
  78311. at = et,
  78312. st = $) : (it = j * et - $ * _e,
  78313. at = k * et - j * _e,
  78314. it < 0 ? (it = 0,
  78315. at = et,
  78316. st = $) : it > nt && (it = nt,
  78317. at = et + j,
  78318. st = $)),
  78319. at < 0 ? (at = 0,
  78320. -_e < 0 ? it = 0 : -_e > k ? it = nt : (it = -_e,
  78321. nt = k)) : at > st && (at = st,
  78322. -_e + j < 0 ? it = 0 : -_e + j > k ? it = nt : (it = -_e + j,
  78323. nt = k)),
  78324. rt = Math.abs(it) < a.smallnum ? 0 : it / nt,
  78325. ot = Math.abs(at) < a.smallnum ? 0 : at / st;
  78326. var ut = TmpVectors.Vector3[4];
  78327. _.scaleToRef(ot, ut);
  78328. var ct = TmpVectors.Vector3[5];
  78329. c.scaleToRef(rt, ct),
  78330. ct.addInPlace(b);
  78331. var lt = TmpVectors.Vector3[6];
  78332. ct.subtractToRef(ut, lt);
  78333. var ft = ot > 0 && ot <= this.length && lt.lengthSquared() < o * o;
  78334. return ft ? ct.length() : -1
  78335. }
  78336. ,
  78337. a.prototype.update = function(e, i, o, s, c, d, _) {
  78338. return this.unprojectRayToRef(e, i, o, s, c, d, _),
  78339. this
  78340. }
  78341. ,
  78342. a.Zero = function() {
  78343. return new a(Vector3.Zero(),Vector3.Zero())
  78344. }
  78345. ,
  78346. a.CreateNew = function(e, i, o, s, c, d, _) {
  78347. var b = a.Zero();
  78348. return b.update(e, i, o, s, c, d, _)
  78349. }
  78350. ,
  78351. a.CreateNewFromTo = function(e, i, o) {
  78352. o === void 0 && (o = Matrix.IdentityReadOnly);
  78353. var s = i.subtract(e)
  78354. , c = Math.sqrt(s.x * s.x + s.y * s.y + s.z * s.z);
  78355. return s.normalize(),
  78356. a.Transform(new a(e,s,c), o)
  78357. }
  78358. ,
  78359. a.Transform = function(e, i) {
  78360. var o = new a(new Vector3(0,0,0),new Vector3(0,0,0));
  78361. return a.TransformToRef(e, i, o),
  78362. o
  78363. }
  78364. ,
  78365. a.TransformToRef = function(e, i, o) {
  78366. Vector3.TransformCoordinatesToRef(e.origin, i, o.origin),
  78367. Vector3.TransformNormalToRef(e.direction, i, o.direction),
  78368. o.length = e.length;
  78369. var s = o.direction
  78370. , c = s.length();
  78371. if (!(c === 0 || c === 1)) {
  78372. var d = 1 / c;
  78373. s.x *= d,
  78374. s.y *= d,
  78375. s.z *= d,
  78376. o.length *= c
  78377. }
  78378. }
  78379. ,
  78380. a.prototype.unprojectRayToRef = function(e, i, o, s, c, d, _) {
  78381. var b = TmpVectors.Matrix[0];
  78382. c.multiplyToRef(d, b),
  78383. b.multiplyToRef(_, b),
  78384. b.invert();
  78385. var k = TmpVectors.Vector3[0];
  78386. k.x = e / o * 2 - 1,
  78387. k.y = -(i / s * 2 - 1),
  78388. k.z = -1;
  78389. var j = TmpVectors.Vector3[1].copyFromFloats(k.x, k.y, 1)
  78390. , $ = TmpVectors.Vector3[2]
  78391. , _e = TmpVectors.Vector3[3];
  78392. Vector3._UnprojectFromInvertedMatrixToRef(k, b, $),
  78393. Vector3._UnprojectFromInvertedMatrixToRef(j, b, _e),
  78394. this.origin.copyFrom($),
  78395. _e.subtractToRef($, this.direction),
  78396. this.direction.normalize()
  78397. }
  78398. ,
  78399. a._TmpVector3 = ArrayTools.BuildArray(6, Vector3.Zero),
  78400. a.smallnum = 1e-8,
  78401. a.rayl = 1e9,
  78402. a
  78403. }();
  78404. Scene.prototype.createPickingRay = function(a, e, i, o, s) {
  78405. s === void 0 && (s = !1);
  78406. var c = Ray.Zero();
  78407. return this.createPickingRayToRef(a, e, i, c, o, s),
  78408. c
  78409. }
  78410. ;
  78411. Scene.prototype.createPickingRayToRef = function(a, e, i, o, s, c) {
  78412. c === void 0 && (c = !1);
  78413. var d = this.getEngine();
  78414. if (!s) {
  78415. if (!this.activeCamera)
  78416. return this;
  78417. s = this.activeCamera
  78418. }
  78419. var _ = s.viewport
  78420. , b = _.toGlobal(d.getRenderWidth(), d.getRenderHeight());
  78421. return a = a / d.getHardwareScalingLevel() - b.x,
  78422. e = e / d.getHardwareScalingLevel() - (d.getRenderHeight() - b.y - b.height),
  78423. o.update(a, e, b.width, b.height, i || Matrix.IdentityReadOnly, c ? Matrix.IdentityReadOnly : s.getViewMatrix(), s.getProjectionMatrix()),
  78424. this
  78425. }
  78426. ;
  78427. Scene.prototype.createPickingRayInCameraSpace = function(a, e, i) {
  78428. var o = Ray.Zero();
  78429. return this.createPickingRayInCameraSpaceToRef(a, e, o, i),
  78430. o
  78431. }
  78432. ;
  78433. Scene.prototype.createPickingRayInCameraSpaceToRef = function(a, e, i, o) {
  78434. if (!PickingInfo)
  78435. return this;
  78436. var s = this.getEngine();
  78437. if (!o) {
  78438. if (!this.activeCamera)
  78439. throw new Error("Active camera not set");
  78440. o = this.activeCamera
  78441. }
  78442. var c = o.viewport
  78443. , d = c.toGlobal(s.getRenderWidth(), s.getRenderHeight())
  78444. , _ = Matrix.Identity();
  78445. return a = a / s.getHardwareScalingLevel() - d.x,
  78446. e = e / s.getHardwareScalingLevel() - (s.getRenderHeight() - d.y - d.height),
  78447. i.update(a, e, d.width, d.height, _, _, o.getProjectionMatrix()),
  78448. this
  78449. }
  78450. ;
  78451. Scene.prototype._internalPickForMesh = function(a, e, i, o, s, c, d, _) {
  78452. var b = e(o)
  78453. , k = i.intersects(b, s, d, c, o, _);
  78454. return !k || !k.hit || !s && a != null && k.distance >= a.distance ? null : k
  78455. }
  78456. ;
  78457. Scene.prototype._internalPick = function(a, e, i, o, s) {
  78458. if (!PickingInfo)
  78459. return null;
  78460. for (var c = null, d = 0; d < this.meshes.length; d++) {
  78461. var _ = this.meshes[d];
  78462. if (e) {
  78463. if (!e(_))
  78464. continue
  78465. } else if (!_.isEnabled() || !_.isVisible || !_.isPickable)
  78466. continue;
  78467. var b = _.skeleton && _.skeleton.overrideMesh ? _.skeleton.overrideMesh.getWorldMatrix() : _.getWorldMatrix();
  78468. if (_.hasThinInstances && _.thinInstanceEnablePicking) {
  78469. var k = this._internalPickForMesh(c, a, _, b, !0, !0, s);
  78470. if (k) {
  78471. if (o)
  78472. return c;
  78473. for (var j = TmpVectors.Matrix[1], $ = _.thinInstanceGetWorldMatrices(), _e = 0; _e < $.length; _e++) {
  78474. var et = $[_e];
  78475. et.multiplyToRef(b, j);
  78476. var tt = this._internalPickForMesh(c, a, _, j, i, o, s, !0);
  78477. if (tt && (c = tt,
  78478. c.thinInstanceIndex = _e,
  78479. i))
  78480. return c
  78481. }
  78482. }
  78483. } else {
  78484. var k = this._internalPickForMesh(c, a, _, b, i, o, s);
  78485. if (k && (c = k,
  78486. i))
  78487. return c
  78488. }
  78489. }
  78490. return c || new PickingInfo
  78491. }
  78492. ;
  78493. Scene.prototype._internalMultiPick = function(a, e, i) {
  78494. if (!PickingInfo)
  78495. return null;
  78496. for (var o = new Array, s = 0; s < this.meshes.length; s++) {
  78497. var c = this.meshes[s];
  78498. if (e) {
  78499. if (!e(c))
  78500. continue
  78501. } else if (!c.isEnabled() || !c.isVisible || !c.isPickable)
  78502. continue;
  78503. var d = c.skeleton && c.skeleton.overrideMesh ? c.skeleton.overrideMesh.getWorldMatrix() : c.getWorldMatrix();
  78504. if (c.hasThinInstances && c.thinInstanceEnablePicking) {
  78505. var _ = this._internalPickForMesh(null, a, c, d, !0, !0, i);
  78506. if (_)
  78507. for (var b = TmpVectors.Matrix[1], k = c.thinInstanceGetWorldMatrices(), j = 0; j < k.length; j++) {
  78508. var $ = k[j];
  78509. $.multiplyToRef(d, b);
  78510. var _e = this._internalPickForMesh(null, a, c, b, !1, !1, i, !0);
  78511. _e && (_e.thinInstanceIndex = j,
  78512. o.push(_e))
  78513. }
  78514. } else {
  78515. var _ = this._internalPickForMesh(null, a, c, d, !1, !1, i);
  78516. _ && o.push(_)
  78517. }
  78518. }
  78519. return o
  78520. }
  78521. ;
  78522. Scene.prototype.pickWithBoundingInfo = function(a, e, i, o, s) {
  78523. var c = this;
  78524. if (!PickingInfo)
  78525. return null;
  78526. var d = this._internalPick(function(_) {
  78527. return c._tempPickingRay || (c._tempPickingRay = Ray.Zero()),
  78528. c.createPickingRayToRef(a, e, _, c._tempPickingRay, s || null),
  78529. c._tempPickingRay
  78530. }, i, o, !0);
  78531. return d && (d.ray = this.createPickingRay(a, e, Matrix.Identity(), s || null)),
  78532. d
  78533. }
  78534. ;
  78535. Scene.prototype.pick = function(a, e, i, o, s, c) {
  78536. var d = this;
  78537. if (!PickingInfo)
  78538. return null;
  78539. var _ = this._internalPick(function(b) {
  78540. return d._tempPickingRay || (d._tempPickingRay = Ray.Zero()),
  78541. d.createPickingRayToRef(a, e, b, d._tempPickingRay, s || null),
  78542. d._tempPickingRay
  78543. }, i, o, !1, c);
  78544. return _ && (_.ray = this.createPickingRay(a, e, Matrix.Identity(), s || null)),
  78545. _
  78546. }
  78547. ;
  78548. Scene.prototype.pickWithRay = function(a, e, i, o) {
  78549. var s = this
  78550. , c = this._internalPick(function(d) {
  78551. return s._pickWithRayInverseMatrix || (s._pickWithRayInverseMatrix = Matrix.Identity()),
  78552. d.invertToRef(s._pickWithRayInverseMatrix),
  78553. s._cachedRayForTransform || (s._cachedRayForTransform = Ray.Zero()),
  78554. Ray.TransformToRef(a, s._pickWithRayInverseMatrix, s._cachedRayForTransform),
  78555. s._cachedRayForTransform
  78556. }, e, i, !1, o);
  78557. return c && (c.ray = a),
  78558. c
  78559. }
  78560. ;
  78561. Scene.prototype.multiPick = function(a, e, i, o, s) {
  78562. var c = this;
  78563. return this._internalMultiPick(function(d) {
  78564. return c.createPickingRay(a, e, d, o || null)
  78565. }, i, s)
  78566. }
  78567. ;
  78568. Scene.prototype.multiPickWithRay = function(a, e, i) {
  78569. var o = this;
  78570. return this._internalMultiPick(function(s) {
  78571. return o._pickWithRayInverseMatrix || (o._pickWithRayInverseMatrix = Matrix.Identity()),
  78572. s.invertToRef(o._pickWithRayInverseMatrix),
  78573. o._cachedRayForTransform || (o._cachedRayForTransform = Ray.Zero()),
  78574. Ray.TransformToRef(a, o._pickWithRayInverseMatrix, o._cachedRayForTransform),
  78575. o._cachedRayForTransform
  78576. }, e, i)
  78577. }
  78578. ;
  78579. Camera$1.prototype.getForwardRay = function(a, e, i) {
  78580. return a === void 0 && (a = 100),
  78581. this.getForwardRayToRef(new Ray(Vector3.Zero(),Vector3.Zero(),a), a, e, i)
  78582. }
  78583. ;
  78584. Camera$1.prototype.getForwardRayToRef = function(a, e, i, o) {
  78585. return e === void 0 && (e = 100),
  78586. i || (i = this.getWorldMatrix()),
  78587. a.length = e,
  78588. o ? a.origin.copyFrom(o) : a.origin.copyFrom(this.position),
  78589. TmpVectors.Vector3[2].set(0, 0, this._scene.useRightHandedSystem ? -1 : 1),
  78590. Vector3.TransformNormalToRef(TmpVectors.Vector3[2], i, TmpVectors.Vector3[3]),
  78591. Vector3.NormalizeToRef(TmpVectors.Vector3[3], a.direction),
  78592. a
  78593. }
  78594. ;
  78595. var ColorGradient = function() {
  78596. function a(e, i, o) {
  78597. this.gradient = e,
  78598. this.color1 = i,
  78599. this.color2 = o
  78600. }
  78601. return a.prototype.getColorToRef = function(e) {
  78602. if (!this.color2) {
  78603. e.copyFrom(this.color1);
  78604. return
  78605. }
  78606. Color4.LerpToRef(this.color1, this.color2, Math.random(), e)
  78607. }
  78608. ,
  78609. a
  78610. }(), Color3Gradient = function() {
  78611. function a(e, i) {
  78612. this.gradient = e,
  78613. this.color = i
  78614. }
  78615. return a
  78616. }(), FactorGradient = function() {
  78617. function a(e, i, o) {
  78618. this.gradient = e,
  78619. this.factor1 = i,
  78620. this.factor2 = o
  78621. }
  78622. return a.prototype.getFactor = function() {
  78623. return this.factor2 === void 0 || this.factor2 === this.factor1 ? this.factor1 : this.factor1 + (this.factor2 - this.factor1) * Math.random()
  78624. }
  78625. ,
  78626. a
  78627. }(), GradientHelper = function() {
  78628. function a() {}
  78629. return a.GetCurrentGradient = function(e, i, o) {
  78630. if (i[0].gradient > e) {
  78631. o(i[0], i[0], 1);
  78632. return
  78633. }
  78634. for (var s = 0; s < i.length - 1; s++) {
  78635. var c = i[s]
  78636. , d = i[s + 1];
  78637. if (e >= c.gradient && e <= d.gradient) {
  78638. var _ = (e - c.gradient) / (d.gradient - c.gradient);
  78639. o(c, d, _);
  78640. return
  78641. }
  78642. }
  78643. var b = i.length - 1;
  78644. o(i[b], i[b], 1)
  78645. }
  78646. ,
  78647. a
  78648. }(), BoxParticleEmitter = function() {
  78649. function a() {
  78650. this.direction1 = new Vector3(0,1,0),
  78651. this.direction2 = new Vector3(0,1,0),
  78652. this.minEmitBox = new Vector3(-.5,-.5,-.5),
  78653. this.maxEmitBox = new Vector3(.5,.5,.5)
  78654. }
  78655. return a.prototype.startDirectionFunction = function(e, i, o, s) {
  78656. var c = Scalar.RandomRange(this.direction1.x, this.direction2.x)
  78657. , d = Scalar.RandomRange(this.direction1.y, this.direction2.y)
  78658. , _ = Scalar.RandomRange(this.direction1.z, this.direction2.z);
  78659. if (s) {
  78660. i.x = c,
  78661. i.y = d,
  78662. i.z = _;
  78663. return
  78664. }
  78665. Vector3.TransformNormalFromFloatsToRef(c, d, _, e, i)
  78666. }
  78667. ,
  78668. a.prototype.startPositionFunction = function(e, i, o, s) {
  78669. var c = Scalar.RandomRange(this.minEmitBox.x, this.maxEmitBox.x)
  78670. , d = Scalar.RandomRange(this.minEmitBox.y, this.maxEmitBox.y)
  78671. , _ = Scalar.RandomRange(this.minEmitBox.z, this.maxEmitBox.z);
  78672. if (s) {
  78673. i.x = c,
  78674. i.y = d,
  78675. i.z = _;
  78676. return
  78677. }
  78678. Vector3.TransformCoordinatesFromFloatsToRef(c, d, _, e, i)
  78679. }
  78680. ,
  78681. a.prototype.clone = function() {
  78682. var e = new a;
  78683. return DeepCopier.DeepCopy(this, e),
  78684. e
  78685. }
  78686. ,
  78687. a.prototype.applyToShader = function(e) {
  78688. e.setVector3("direction1", this.direction1),
  78689. e.setVector3("direction2", this.direction2),
  78690. e.setVector3("minEmitBox", this.minEmitBox),
  78691. e.setVector3("maxEmitBox", this.maxEmitBox)
  78692. }
  78693. ,
  78694. a.prototype.buildUniformLayout = function(e) {
  78695. e.addUniform("direction1", 3),
  78696. e.addUniform("direction2", 3),
  78697. e.addUniform("minEmitBox", 3),
  78698. e.addUniform("maxEmitBox", 3)
  78699. }
  78700. ,
  78701. a.prototype.getEffectDefines = function() {
  78702. return "#define BOXEMITTER"
  78703. }
  78704. ,
  78705. a.prototype.getClassName = function() {
  78706. return "BoxParticleEmitter"
  78707. }
  78708. ,
  78709. a.prototype.serialize = function() {
  78710. var e = {};
  78711. return e.type = this.getClassName(),
  78712. e.direction1 = this.direction1.asArray(),
  78713. e.direction2 = this.direction2.asArray(),
  78714. e.minEmitBox = this.minEmitBox.asArray(),
  78715. e.maxEmitBox = this.maxEmitBox.asArray(),
  78716. e
  78717. }
  78718. ,
  78719. a.prototype.parse = function(e) {
  78720. Vector3.FromArrayToRef(e.direction1, 0, this.direction1),
  78721. Vector3.FromArrayToRef(e.direction2, 0, this.direction2),
  78722. Vector3.FromArrayToRef(e.minEmitBox, 0, this.minEmitBox),
  78723. Vector3.FromArrayToRef(e.maxEmitBox, 0, this.maxEmitBox)
  78724. }
  78725. ,
  78726. a
  78727. }(), ConeParticleEmitter = function() {
  78728. function a(e, i, o) {
  78729. e === void 0 && (e = 1),
  78730. i === void 0 && (i = Math.PI),
  78731. o === void 0 && (o = 0),
  78732. this.directionRandomizer = o,
  78733. this.radiusRange = 1,
  78734. this.heightRange = 1,
  78735. this.emitFromSpawnPointOnly = !1,
  78736. this.angle = i,
  78737. this.radius = e
  78738. }
  78739. return Object.defineProperty(a.prototype, "radius", {
  78740. get: function() {
  78741. return this._radius
  78742. },
  78743. set: function(e) {
  78744. this._radius = e,
  78745. this._buildHeight()
  78746. },
  78747. enumerable: !1,
  78748. configurable: !0
  78749. }),
  78750. Object.defineProperty(a.prototype, "angle", {
  78751. get: function() {
  78752. return this._angle
  78753. },
  78754. set: function(e) {
  78755. this._angle = e,
  78756. this._buildHeight()
  78757. },
  78758. enumerable: !1,
  78759. configurable: !0
  78760. }),
  78761. a.prototype._buildHeight = function() {
  78762. this._angle !== 0 ? this._height = this._radius / Math.tan(this._angle / 2) : this._height = 1
  78763. }
  78764. ,
  78765. a.prototype.startDirectionFunction = function(e, i, o, s) {
  78766. s ? TmpVectors.Vector3[0].copyFrom(o._localPosition).normalize() : o.position.subtractToRef(e.getTranslation(), TmpVectors.Vector3[0]).normalize();
  78767. var c = Scalar.RandomRange(0, this.directionRandomizer)
  78768. , d = Scalar.RandomRange(0, this.directionRandomizer)
  78769. , _ = Scalar.RandomRange(0, this.directionRandomizer);
  78770. i.x = TmpVectors.Vector3[0].x + c,
  78771. i.y = TmpVectors.Vector3[0].y + d,
  78772. i.z = TmpVectors.Vector3[0].z + _,
  78773. i.normalize()
  78774. }
  78775. ,
  78776. a.prototype.startPositionFunction = function(e, i, o, s) {
  78777. var c = Scalar.RandomRange(0, Math.PI * 2), d;
  78778. this.emitFromSpawnPointOnly ? d = 1e-4 : (d = Scalar.RandomRange(0, this.heightRange),
  78779. d = 1 - d * d);
  78780. var _ = this._radius - Scalar.RandomRange(0, this._radius * this.radiusRange);
  78781. _ = _ * d;
  78782. var b = _ * Math.sin(c)
  78783. , k = _ * Math.cos(c)
  78784. , j = d * this._height;
  78785. if (s) {
  78786. i.x = b,
  78787. i.y = j,
  78788. i.z = k;
  78789. return
  78790. }
  78791. Vector3.TransformCoordinatesFromFloatsToRef(b, j, k, e, i)
  78792. }
  78793. ,
  78794. a.prototype.clone = function() {
  78795. var e = new a(this._radius,this._angle,this.directionRandomizer);
  78796. return DeepCopier.DeepCopy(this, e),
  78797. e
  78798. }
  78799. ,
  78800. a.prototype.applyToShader = function(e) {
  78801. e.setFloat2("radius", this._radius, this.radiusRange),
  78802. e.setFloat("coneAngle", this._angle),
  78803. e.setFloat2("height", this._height, this.heightRange),
  78804. e.setFloat("directionRandomizer", this.directionRandomizer)
  78805. }
  78806. ,
  78807. a.prototype.buildUniformLayout = function(e) {
  78808. e.addUniform("radius", 2),
  78809. e.addUniform("coneAngle", 1),
  78810. e.addUniform("height", 2),
  78811. e.addUniform("directionRandomizer", 1)
  78812. }
  78813. ,
  78814. a.prototype.getEffectDefines = function() {
  78815. var e = "#define CONEEMITTER";
  78816. return this.emitFromSpawnPointOnly && (e += `
  78817. #define CONEEMITTERSPAWNPOINT`),
  78818. e
  78819. }
  78820. ,
  78821. a.prototype.getClassName = function() {
  78822. return "ConeParticleEmitter"
  78823. }
  78824. ,
  78825. a.prototype.serialize = function() {
  78826. var e = {};
  78827. return e.type = this.getClassName(),
  78828. e.radius = this._radius,
  78829. e.angle = this._angle,
  78830. e.directionRandomizer = this.directionRandomizer,
  78831. e.radiusRange = this.radiusRange,
  78832. e.heightRange = this.heightRange,
  78833. e.emitFromSpawnPointOnly = this.emitFromSpawnPointOnly,
  78834. e
  78835. }
  78836. ,
  78837. a.prototype.parse = function(e) {
  78838. this.radius = e.radius,
  78839. this.angle = e.angle,
  78840. this.directionRandomizer = e.directionRandomizer,
  78841. this.radiusRange = e.radiusRange !== void 0 ? e.radiusRange : 1,
  78842. this.heightRange = e.radiusRange !== void 0 ? e.heightRange : 1,
  78843. this.emitFromSpawnPointOnly = e.emitFromSpawnPointOnly !== void 0 ? e.emitFromSpawnPointOnly : !1
  78844. }
  78845. ,
  78846. a
  78847. }(), CylinderParticleEmitter = function() {
  78848. function a(e, i, o, s) {
  78849. e === void 0 && (e = 1),
  78850. i === void 0 && (i = 1),
  78851. o === void 0 && (o = 1),
  78852. s === void 0 && (s = 0),
  78853. this.radius = e,
  78854. this.height = i,
  78855. this.radiusRange = o,
  78856. this.directionRandomizer = s,
  78857. this._tempVector = Vector3.Zero()
  78858. }
  78859. return a.prototype.startDirectionFunction = function(e, i, o, s, c) {
  78860. o.position.subtractToRef(e.getTranslation(), this._tempVector),
  78861. this._tempVector.normalize(),
  78862. Vector3.TransformNormalToRef(this._tempVector, c, this._tempVector);
  78863. var d = Scalar.RandomRange(-this.directionRandomizer / 2, this.directionRandomizer / 2)
  78864. , _ = Math.atan2(this._tempVector.x, this._tempVector.z);
  78865. if (_ += Scalar.RandomRange(-Math.PI / 2, Math.PI / 2) * this.directionRandomizer,
  78866. this._tempVector.y = d,
  78867. this._tempVector.x = Math.sin(_),
  78868. this._tempVector.z = Math.cos(_),
  78869. this._tempVector.normalize(),
  78870. s) {
  78871. i.copyFrom(this._tempVector);
  78872. return
  78873. }
  78874. Vector3.TransformNormalFromFloatsToRef(this._tempVector.x, this._tempVector.y, this._tempVector.z, e, i)
  78875. }
  78876. ,
  78877. a.prototype.startPositionFunction = function(e, i, o, s) {
  78878. var c = Scalar.RandomRange(-this.height / 2, this.height / 2)
  78879. , d = Scalar.RandomRange(0, 2 * Math.PI)
  78880. , _ = Scalar.RandomRange((1 - this.radiusRange) * (1 - this.radiusRange), 1)
  78881. , b = Math.sqrt(_) * this.radius
  78882. , k = b * Math.cos(d)
  78883. , j = b * Math.sin(d);
  78884. if (s) {
  78885. i.copyFromFloats(k, c, j);
  78886. return
  78887. }
  78888. Vector3.TransformCoordinatesFromFloatsToRef(k, c, j, e, i)
  78889. }
  78890. ,
  78891. a.prototype.clone = function() {
  78892. var e = new a(this.radius,this.directionRandomizer);
  78893. return DeepCopier.DeepCopy(this, e),
  78894. e
  78895. }
  78896. ,
  78897. a.prototype.applyToShader = function(e) {
  78898. e.setFloat("radius", this.radius),
  78899. e.setFloat("height", this.height),
  78900. e.setFloat("radiusRange", this.radiusRange),
  78901. e.setFloat("directionRandomizer", this.directionRandomizer)
  78902. }
  78903. ,
  78904. a.prototype.buildUniformLayout = function(e) {
  78905. e.addUniform("radius", 1),
  78906. e.addUniform("height", 1),
  78907. e.addUniform("radiusRange", 1),
  78908. e.addUniform("directionRandomizer", 1)
  78909. }
  78910. ,
  78911. a.prototype.getEffectDefines = function() {
  78912. return "#define CYLINDEREMITTER"
  78913. }
  78914. ,
  78915. a.prototype.getClassName = function() {
  78916. return "CylinderParticleEmitter"
  78917. }
  78918. ,
  78919. a.prototype.serialize = function() {
  78920. var e = {};
  78921. return e.type = this.getClassName(),
  78922. e.radius = this.radius,
  78923. e.height = this.height,
  78924. e.radiusRange = this.radiusRange,
  78925. e.directionRandomizer = this.directionRandomizer,
  78926. e
  78927. }
  78928. ,
  78929. a.prototype.parse = function(e) {
  78930. this.radius = e.radius,
  78931. this.height = e.height,
  78932. this.radiusRange = e.radiusRange,
  78933. this.directionRandomizer = e.directionRandomizer
  78934. }
  78935. ,
  78936. a
  78937. }(), CylinderDirectedParticleEmitter = function(a) {
  78938. __extends(e, a);
  78939. function e(i, o, s, c, d) {
  78940. i === void 0 && (i = 1),
  78941. o === void 0 && (o = 1),
  78942. s === void 0 && (s = 1),
  78943. c === void 0 && (c = new Vector3(0,1,0)),
  78944. d === void 0 && (d = new Vector3(0,1,0));
  78945. var _ = a.call(this, i, o, s) || this;
  78946. return _.direction1 = c,
  78947. _.direction2 = d,
  78948. _
  78949. }
  78950. return e.prototype.startDirectionFunction = function(i, o, s) {
  78951. var c = Scalar.RandomRange(this.direction1.x, this.direction2.x)
  78952. , d = Scalar.RandomRange(this.direction1.y, this.direction2.y)
  78953. , _ = Scalar.RandomRange(this.direction1.z, this.direction2.z);
  78954. Vector3.TransformNormalFromFloatsToRef(c, d, _, i, o)
  78955. }
  78956. ,
  78957. e.prototype.clone = function() {
  78958. var i = new e(this.radius,this.height,this.radiusRange,this.direction1,this.direction2);
  78959. return DeepCopier.DeepCopy(this, i),
  78960. i
  78961. }
  78962. ,
  78963. e.prototype.applyToShader = function(i) {
  78964. i.setFloat("radius", this.radius),
  78965. i.setFloat("height", this.height),
  78966. i.setFloat("radiusRange", this.radiusRange),
  78967. i.setVector3("direction1", this.direction1),
  78968. i.setVector3("direction2", this.direction2)
  78969. }
  78970. ,
  78971. e.prototype.buildUniformLayout = function(i) {
  78972. i.addUniform("radius", 1),
  78973. i.addUniform("height", 1),
  78974. i.addUniform("radiusRange", 1),
  78975. i.addUniform("direction1", 3),
  78976. i.addUniform("direction2", 3)
  78977. }
  78978. ,
  78979. e.prototype.getEffectDefines = function() {
  78980. return `#define CYLINDEREMITTER
  78981. #define DIRECTEDCYLINDEREMITTER`
  78982. }
  78983. ,
  78984. e.prototype.getClassName = function() {
  78985. return "CylinderDirectedParticleEmitter"
  78986. }
  78987. ,
  78988. e.prototype.serialize = function() {
  78989. var i = a.prototype.serialize.call(this);
  78990. return i.direction1 = this.direction1.asArray(),
  78991. i.direction2 = this.direction2.asArray(),
  78992. i
  78993. }
  78994. ,
  78995. e.prototype.parse = function(i) {
  78996. a.prototype.parse.call(this, i),
  78997. this.direction1.copyFrom(i.direction1),
  78998. this.direction2.copyFrom(i.direction2)
  78999. }
  79000. ,
  79001. e
  79002. }(CylinderParticleEmitter), HemisphericParticleEmitter = function() {
  79003. function a(e, i, o) {
  79004. e === void 0 && (e = 1),
  79005. i === void 0 && (i = 1),
  79006. o === void 0 && (o = 0),
  79007. this.radius = e,
  79008. this.radiusRange = i,
  79009. this.directionRandomizer = o
  79010. }
  79011. return a.prototype.startDirectionFunction = function(e, i, o, s) {
  79012. var c = o.position.subtract(e.getTranslation()).normalize()
  79013. , d = Scalar.RandomRange(0, this.directionRandomizer)
  79014. , _ = Scalar.RandomRange(0, this.directionRandomizer)
  79015. , b = Scalar.RandomRange(0, this.directionRandomizer);
  79016. if (c.x += d,
  79017. c.y += _,
  79018. c.z += b,
  79019. c.normalize(),
  79020. s) {
  79021. i.copyFrom(c);
  79022. return
  79023. }
  79024. Vector3.TransformNormalFromFloatsToRef(c.x, c.y, c.z, e, i)
  79025. }
  79026. ,
  79027. a.prototype.startPositionFunction = function(e, i, o, s) {
  79028. var c = this.radius - Scalar.RandomRange(0, this.radius * this.radiusRange)
  79029. , d = Scalar.RandomRange(0, 1)
  79030. , _ = Scalar.RandomRange(0, 2 * Math.PI)
  79031. , b = Math.acos(2 * d - 1)
  79032. , k = c * Math.cos(_) * Math.sin(b)
  79033. , j = c * Math.cos(b)
  79034. , $ = c * Math.sin(_) * Math.sin(b);
  79035. if (s) {
  79036. i.copyFromFloats(k, Math.abs(j), $);
  79037. return
  79038. }
  79039. Vector3.TransformCoordinatesFromFloatsToRef(k, Math.abs(j), $, e, i)
  79040. }
  79041. ,
  79042. a.prototype.clone = function() {
  79043. var e = new a(this.radius,this.directionRandomizer);
  79044. return DeepCopier.DeepCopy(this, e),
  79045. e
  79046. }
  79047. ,
  79048. a.prototype.applyToShader = function(e) {
  79049. e.setFloat("radius", this.radius),
  79050. e.setFloat("radiusRange", this.radiusRange),
  79051. e.setFloat("directionRandomizer", this.directionRandomizer)
  79052. }
  79053. ,
  79054. a.prototype.buildUniformLayout = function(e) {
  79055. e.addUniform("radius", 1),
  79056. e.addUniform("radiusRange", 1),
  79057. e.addUniform("directionRandomizer", 1)
  79058. }
  79059. ,
  79060. a.prototype.getEffectDefines = function() {
  79061. return "#define HEMISPHERICEMITTER"
  79062. }
  79063. ,
  79064. a.prototype.getClassName = function() {
  79065. return "HemisphericParticleEmitter"
  79066. }
  79067. ,
  79068. a.prototype.serialize = function() {
  79069. var e = {};
  79070. return e.type = this.getClassName(),
  79071. e.radius = this.radius,
  79072. e.radiusRange = this.radiusRange,
  79073. e.directionRandomizer = this.directionRandomizer,
  79074. e
  79075. }
  79076. ,
  79077. a.prototype.parse = function(e) {
  79078. this.radius = e.radius,
  79079. this.radiusRange = e.radiusRange,
  79080. this.directionRandomizer = e.directionRandomizer
  79081. }
  79082. ,
  79083. a
  79084. }(), PointParticleEmitter = function() {
  79085. function a() {
  79086. this.direction1 = new Vector3(0,1,0),
  79087. this.direction2 = new Vector3(0,1,0)
  79088. }
  79089. return a.prototype.startDirectionFunction = function(e, i, o, s) {
  79090. var c = Scalar.RandomRange(this.direction1.x, this.direction2.x)
  79091. , d = Scalar.RandomRange(this.direction1.y, this.direction2.y)
  79092. , _ = Scalar.RandomRange(this.direction1.z, this.direction2.z);
  79093. if (s) {
  79094. i.copyFromFloats(c, d, _);
  79095. return
  79096. }
  79097. Vector3.TransformNormalFromFloatsToRef(c, d, _, e, i)
  79098. }
  79099. ,
  79100. a.prototype.startPositionFunction = function(e, i, o, s) {
  79101. if (s) {
  79102. i.copyFromFloats(0, 0, 0);
  79103. return
  79104. }
  79105. Vector3.TransformCoordinatesFromFloatsToRef(0, 0, 0, e, i)
  79106. }
  79107. ,
  79108. a.prototype.clone = function() {
  79109. var e = new a;
  79110. return DeepCopier.DeepCopy(this, e),
  79111. e
  79112. }
  79113. ,
  79114. a.prototype.applyToShader = function(e) {
  79115. e.setVector3("direction1", this.direction1),
  79116. e.setVector3("direction2", this.direction2)
  79117. }
  79118. ,
  79119. a.prototype.buildUniformLayout = function(e) {
  79120. e.addUniform("direction1", 3),
  79121. e.addUniform("direction2", 3)
  79122. }
  79123. ,
  79124. a.prototype.getEffectDefines = function() {
  79125. return "#define POINTEMITTER"
  79126. }
  79127. ,
  79128. a.prototype.getClassName = function() {
  79129. return "PointParticleEmitter"
  79130. }
  79131. ,
  79132. a.prototype.serialize = function() {
  79133. var e = {};
  79134. return e.type = this.getClassName(),
  79135. e.direction1 = this.direction1.asArray(),
  79136. e.direction2 = this.direction2.asArray(),
  79137. e
  79138. }
  79139. ,
  79140. a.prototype.parse = function(e) {
  79141. Vector3.FromArrayToRef(e.direction1, 0, this.direction1),
  79142. Vector3.FromArrayToRef(e.direction2, 0, this.direction2)
  79143. }
  79144. ,
  79145. a
  79146. }(), SphereParticleEmitter = function() {
  79147. function a(e, i, o) {
  79148. e === void 0 && (e = 1),
  79149. i === void 0 && (i = 1),
  79150. o === void 0 && (o = 0),
  79151. this.radius = e,
  79152. this.radiusRange = i,
  79153. this.directionRandomizer = o
  79154. }
  79155. return a.prototype.startDirectionFunction = function(e, i, o, s) {
  79156. var c = o.position.subtract(e.getTranslation()).normalize()
  79157. , d = Scalar.RandomRange(0, this.directionRandomizer)
  79158. , _ = Scalar.RandomRange(0, this.directionRandomizer)
  79159. , b = Scalar.RandomRange(0, this.directionRandomizer);
  79160. if (c.x += d,
  79161. c.y += _,
  79162. c.z += b,
  79163. c.normalize(),
  79164. s) {
  79165. i.copyFrom(c);
  79166. return
  79167. }
  79168. Vector3.TransformNormalFromFloatsToRef(c.x, c.y, c.z, e, i)
  79169. }
  79170. ,
  79171. a.prototype.startPositionFunction = function(e, i, o, s) {
  79172. var c = this.radius - Scalar.RandomRange(0, this.radius * this.radiusRange)
  79173. , d = Scalar.RandomRange(0, 1)
  79174. , _ = Scalar.RandomRange(0, 2 * Math.PI)
  79175. , b = Math.acos(2 * d - 1)
  79176. , k = c * Math.cos(_) * Math.sin(b)
  79177. , j = c * Math.cos(b)
  79178. , $ = c * Math.sin(_) * Math.sin(b);
  79179. if (s) {
  79180. i.copyFromFloats(k, j, $);
  79181. return
  79182. }
  79183. Vector3.TransformCoordinatesFromFloatsToRef(k, j, $, e, i)
  79184. }
  79185. ,
  79186. a.prototype.clone = function() {
  79187. var e = new a(this.radius,this.directionRandomizer);
  79188. return DeepCopier.DeepCopy(this, e),
  79189. e
  79190. }
  79191. ,
  79192. a.prototype.applyToShader = function(e) {
  79193. e.setFloat("radius", this.radius),
  79194. e.setFloat("radiusRange", this.radiusRange),
  79195. e.setFloat("directionRandomizer", this.directionRandomizer)
  79196. }
  79197. ,
  79198. a.prototype.buildUniformLayout = function(e) {
  79199. e.addUniform("radius", 1),
  79200. e.addUniform("radiusRange", 1),
  79201. e.addUniform("directionRandomizer", 1)
  79202. }
  79203. ,
  79204. a.prototype.getEffectDefines = function() {
  79205. return "#define SPHEREEMITTER"
  79206. }
  79207. ,
  79208. a.prototype.getClassName = function() {
  79209. return "SphereParticleEmitter"
  79210. }
  79211. ,
  79212. a.prototype.serialize = function() {
  79213. var e = {};
  79214. return e.type = this.getClassName(),
  79215. e.radius = this.radius,
  79216. e.radiusRange = this.radiusRange,
  79217. e.directionRandomizer = this.directionRandomizer,
  79218. e
  79219. }
  79220. ,
  79221. a.prototype.parse = function(e) {
  79222. this.radius = e.radius,
  79223. this.radiusRange = e.radiusRange,
  79224. this.directionRandomizer = e.directionRandomizer
  79225. }
  79226. ,
  79227. a
  79228. }(), SphereDirectedParticleEmitter = function(a) {
  79229. __extends(e, a);
  79230. function e(i, o, s) {
  79231. i === void 0 && (i = 1),
  79232. o === void 0 && (o = new Vector3(0,1,0)),
  79233. s === void 0 && (s = new Vector3(0,1,0));
  79234. var c = a.call(this, i) || this;
  79235. return c.direction1 = o,
  79236. c.direction2 = s,
  79237. c
  79238. }
  79239. return e.prototype.startDirectionFunction = function(i, o, s) {
  79240. var c = Scalar.RandomRange(this.direction1.x, this.direction2.x)
  79241. , d = Scalar.RandomRange(this.direction1.y, this.direction2.y)
  79242. , _ = Scalar.RandomRange(this.direction1.z, this.direction2.z);
  79243. Vector3.TransformNormalFromFloatsToRef(c, d, _, i, o)
  79244. }
  79245. ,
  79246. e.prototype.clone = function() {
  79247. var i = new e(this.radius,this.direction1,this.direction2);
  79248. return DeepCopier.DeepCopy(this, i),
  79249. i
  79250. }
  79251. ,
  79252. e.prototype.applyToShader = function(i) {
  79253. i.setFloat("radius", this.radius),
  79254. i.setFloat("radiusRange", this.radiusRange),
  79255. i.setVector3("direction1", this.direction1),
  79256. i.setVector3("direction2", this.direction2)
  79257. }
  79258. ,
  79259. e.prototype.buildUniformLayout = function(i) {
  79260. i.addUniform("radius", 1),
  79261. i.addUniform("radiusRange", 1),
  79262. i.addUniform("direction1", 3),
  79263. i.addUniform("direction2", 3)
  79264. }
  79265. ,
  79266. e.prototype.getEffectDefines = function() {
  79267. return `#define SPHEREEMITTER
  79268. #define DIRECTEDSPHEREEMITTER`
  79269. }
  79270. ,
  79271. e.prototype.getClassName = function() {
  79272. return "SphereDirectedParticleEmitter"
  79273. }
  79274. ,
  79275. e.prototype.serialize = function() {
  79276. var i = a.prototype.serialize.call(this);
  79277. return i.direction1 = this.direction1.asArray(),
  79278. i.direction2 = this.direction2.asArray(),
  79279. i
  79280. }
  79281. ,
  79282. e.prototype.parse = function(i) {
  79283. a.prototype.parse.call(this, i),
  79284. this.direction1.copyFrom(i.direction1),
  79285. this.direction2.copyFrom(i.direction2)
  79286. }
  79287. ,
  79288. e
  79289. }(SphereParticleEmitter), CustomParticleEmitter = function() {
  79290. function a() {
  79291. this.particlePositionGenerator = function() {}
  79292. ,
  79293. this.particleDestinationGenerator = function() {}
  79294. }
  79295. return a.prototype.startDirectionFunction = function(e, i, o, s) {
  79296. var c = TmpVectors.Vector3[0];
  79297. if (this.particleDestinationGenerator) {
  79298. this.particleDestinationGenerator(-1, o, c);
  79299. var d = TmpVectors.Vector3[1];
  79300. c.subtractToRef(o.position, d),
  79301. d.scaleToRef(1 / o.lifeTime, c)
  79302. } else
  79303. c.set(0, 0, 0);
  79304. if (s) {
  79305. i.copyFrom(c);
  79306. return
  79307. }
  79308. Vector3.TransformNormalToRef(c, e, i)
  79309. }
  79310. ,
  79311. a.prototype.startPositionFunction = function(e, i, o, s) {
  79312. var c = TmpVectors.Vector3[0];
  79313. if (this.particlePositionGenerator ? this.particlePositionGenerator(-1, o, c) : c.set(0, 0, 0),
  79314. s) {
  79315. i.copyFrom(c);
  79316. return
  79317. }
  79318. Vector3.TransformCoordinatesToRef(c, e, i)
  79319. }
  79320. ,
  79321. a.prototype.clone = function() {
  79322. var e = new a;
  79323. return DeepCopier.DeepCopy(this, e),
  79324. e
  79325. }
  79326. ,
  79327. a.prototype.applyToShader = function(e) {}
  79328. ,
  79329. a.prototype.buildUniformLayout = function(e) {}
  79330. ,
  79331. a.prototype.getEffectDefines = function() {
  79332. return "#define CUSTOMEMITTER"
  79333. }
  79334. ,
  79335. a.prototype.getClassName = function() {
  79336. return "CustomParticleEmitter"
  79337. }
  79338. ,
  79339. a.prototype.serialize = function() {
  79340. var e = {};
  79341. return e.type = this.getClassName(),
  79342. e
  79343. }
  79344. ,
  79345. a.prototype.parse = function(e) {}
  79346. ,
  79347. a
  79348. }(), MeshParticleEmitter = function() {
  79349. function a(e) {
  79350. e === void 0 && (e = null),
  79351. this._indices = null,
  79352. this._positions = null,
  79353. this._normals = null,
  79354. this._storedNormal = Vector3.Zero(),
  79355. this._mesh = null,
  79356. this.direction1 = new Vector3(0,1,0),
  79357. this.direction2 = new Vector3(0,1,0),
  79358. this.useMeshNormalsForDirection = !0,
  79359. this.mesh = e
  79360. }
  79361. return Object.defineProperty(a.prototype, "mesh", {
  79362. get: function() {
  79363. return this._mesh
  79364. },
  79365. set: function(e) {
  79366. this._mesh !== e && (this._mesh = e,
  79367. e ? (this._indices = e.getIndices(),
  79368. this._positions = e.getVerticesData(VertexBuffer.PositionKind),
  79369. this._normals = e.getVerticesData(VertexBuffer.NormalKind)) : (this._indices = null,
  79370. this._positions = null,
  79371. this._normals = null))
  79372. },
  79373. enumerable: !1,
  79374. configurable: !0
  79375. }),
  79376. a.prototype.startDirectionFunction = function(e, i, o, s) {
  79377. if (this.useMeshNormalsForDirection && this._normals) {
  79378. Vector3.TransformNormalToRef(this._storedNormal, e, i);
  79379. return
  79380. }
  79381. var c = Scalar.RandomRange(this.direction1.x, this.direction2.x)
  79382. , d = Scalar.RandomRange(this.direction1.y, this.direction2.y)
  79383. , _ = Scalar.RandomRange(this.direction1.z, this.direction2.z);
  79384. if (s) {
  79385. i.copyFromFloats(c, d, _);
  79386. return
  79387. }
  79388. Vector3.TransformNormalFromFloatsToRef(c, d, _, e, i)
  79389. }
  79390. ,
  79391. a.prototype.startPositionFunction = function(e, i, o, s) {
  79392. if (!(!this._indices || !this._positions)) {
  79393. var c = 3 * Math.random() * (this._indices.length / 3) | 0
  79394. , d = Math.random()
  79395. , _ = Math.random() * (1 - d)
  79396. , b = 1 - d - _
  79397. , k = this._indices[c]
  79398. , j = this._indices[c + 1]
  79399. , $ = this._indices[c + 2]
  79400. , _e = TmpVectors.Vector3[0]
  79401. , et = TmpVectors.Vector3[1]
  79402. , tt = TmpVectors.Vector3[2]
  79403. , rt = TmpVectors.Vector3[3];
  79404. Vector3.FromArrayToRef(this._positions, k * 3, _e),
  79405. Vector3.FromArrayToRef(this._positions, j * 3, et),
  79406. Vector3.FromArrayToRef(this._positions, $ * 3, tt),
  79407. rt.x = d * _e.x + _ * et.x + b * tt.x,
  79408. rt.y = d * _e.y + _ * et.y + b * tt.y,
  79409. rt.z = d * _e.z + _ * et.z + b * tt.z,
  79410. s ? i.copyFromFloats(rt.x, rt.y, rt.z) : Vector3.TransformCoordinatesFromFloatsToRef(rt.x, rt.y, rt.z, e, i),
  79411. this.useMeshNormalsForDirection && this._normals && (Vector3.FromArrayToRef(this._normals, k * 3, _e),
  79412. Vector3.FromArrayToRef(this._normals, j * 3, et),
  79413. Vector3.FromArrayToRef(this._normals, $ * 3, tt),
  79414. this._storedNormal.x = d * _e.x + _ * et.x + b * tt.x,
  79415. this._storedNormal.y = d * _e.y + _ * et.y + b * tt.y,
  79416. this._storedNormal.z = d * _e.z + _ * et.z + b * tt.z)
  79417. }
  79418. }
  79419. ,
  79420. a.prototype.clone = function() {
  79421. var e = new a(this.mesh);
  79422. return DeepCopier.DeepCopy(this, e),
  79423. e
  79424. }
  79425. ,
  79426. a.prototype.applyToShader = function(e) {
  79427. e.setVector3("direction1", this.direction1),
  79428. e.setVector3("direction2", this.direction2)
  79429. }
  79430. ,
  79431. a.prototype.buildUniformLayout = function(e) {
  79432. e.addUniform("direction1", 3),
  79433. e.addUniform("direction2", 3)
  79434. }
  79435. ,
  79436. a.prototype.getEffectDefines = function() {
  79437. return ""
  79438. }
  79439. ,
  79440. a.prototype.getClassName = function() {
  79441. return "MeshParticleEmitter"
  79442. }
  79443. ,
  79444. a.prototype.serialize = function() {
  79445. var e, i = {};
  79446. return i.type = this.getClassName(),
  79447. i.direction1 = this.direction1.asArray(),
  79448. i.direction2 = this.direction2.asArray(),
  79449. i.meshId = (e = this.mesh) === null || e === void 0 ? void 0 : e.id,
  79450. i.useMeshNormalsForDirection = this.useMeshNormalsForDirection,
  79451. i
  79452. }
  79453. ,
  79454. a.prototype.parse = function(e, i) {
  79455. Vector3.FromArrayToRef(e.direction1, 0, this.direction1),
  79456. Vector3.FromArrayToRef(e.direction2, 0, this.direction2),
  79457. e.meshId && i && (this.mesh = i.getLastMeshById(e.meshId)),
  79458. this.useMeshNormalsForDirection = e.useMeshNormalsForDirection
  79459. }
  79460. ,
  79461. a
  79462. }(), BaseParticleSystem = function() {
  79463. function a(e) {
  79464. this.animations = [],
  79465. this.renderingGroupId = 0,
  79466. this.emitter = Vector3.Zero(),
  79467. this.emitRate = 10,
  79468. this.manualEmitCount = -1,
  79469. this.updateSpeed = .01,
  79470. this.targetStopDuration = 0,
  79471. this.disposeOnStop = !1,
  79472. this.minEmitPower = 1,
  79473. this.maxEmitPower = 1,
  79474. this.minLifeTime = 1,
  79475. this.maxLifeTime = 1,
  79476. this.minSize = 1,
  79477. this.maxSize = 1,
  79478. this.minScaleX = 1,
  79479. this.maxScaleX = 1,
  79480. this.minScaleY = 1,
  79481. this.maxScaleY = 1,
  79482. this.minInitialRotation = 0,
  79483. this.maxInitialRotation = 0,
  79484. this.minAngularSpeed = 0,
  79485. this.maxAngularSpeed = 0,
  79486. this.layerMask = 268435455,
  79487. this.customShader = null,
  79488. this.preventAutoStart = !1,
  79489. this._rootUrl = "",
  79490. this.noiseStrength = new Vector3(10,10,10),
  79491. this.onAnimationEnd = null,
  79492. this.blendMode = a.BLENDMODE_ONEONE,
  79493. this.forceDepthWrite = !1,
  79494. this.preWarmCycles = 0,
  79495. this.preWarmStepOffset = 1,
  79496. this.spriteCellChangeSpeed = 1,
  79497. this.startSpriteCellID = 0,
  79498. this.endSpriteCellID = 0,
  79499. this.spriteCellWidth = 0,
  79500. this.spriteCellHeight = 0,
  79501. this.spriteCellLoop = !0,
  79502. this.spriteRandomStartCell = !1,
  79503. this.translationPivot = new Vector2(0,0),
  79504. this.beginAnimationOnStart = !1,
  79505. this.beginAnimationFrom = 0,
  79506. this.beginAnimationTo = 60,
  79507. this.beginAnimationLoop = !1,
  79508. this.worldOffset = new Vector3(0,0,0),
  79509. this.gravity = Vector3.Zero(),
  79510. this._colorGradients = null,
  79511. this._sizeGradients = null,
  79512. this._lifeTimeGradients = null,
  79513. this._angularSpeedGradients = null,
  79514. this._velocityGradients = null,
  79515. this._limitVelocityGradients = null,
  79516. this._dragGradients = null,
  79517. this._emitRateGradients = null,
  79518. this._startSizeGradients = null,
  79519. this._rampGradients = null,
  79520. this._colorRemapGradients = null,
  79521. this._alphaRemapGradients = null,
  79522. this.startDelay = 0,
  79523. this.limitVelocityDamping = .4,
  79524. this.color1 = new Color4(1,1,1,1),
  79525. this.color2 = new Color4(1,1,1,1),
  79526. this.colorDead = new Color4(0,0,0,1),
  79527. this.textureMask = new Color4(1,1,1,1),
  79528. this._isSubEmitter = !1,
  79529. this.billboardMode = 7,
  79530. this._isBillboardBased = !0,
  79531. this._imageProcessingConfigurationDefines = new ImageProcessingConfigurationDefines,
  79532. this.id = e,
  79533. this.name = e
  79534. }
  79535. return Object.defineProperty(a.prototype, "noiseTexture", {
  79536. get: function() {
  79537. return this._noiseTexture
  79538. },
  79539. set: function(e) {
  79540. this._noiseTexture !== e && (this._noiseTexture = e,
  79541. this._reset())
  79542. },
  79543. enumerable: !1,
  79544. configurable: !0
  79545. }),
  79546. Object.defineProperty(a.prototype, "isAnimationSheetEnabled", {
  79547. get: function() {
  79548. return this._isAnimationSheetEnabled
  79549. },
  79550. set: function(e) {
  79551. this._isAnimationSheetEnabled != e && (this._isAnimationSheetEnabled = e,
  79552. this._reset())
  79553. },
  79554. enumerable: !1,
  79555. configurable: !0
  79556. }),
  79557. a.prototype.getScene = function() {
  79558. return this._scene
  79559. }
  79560. ,
  79561. a.prototype._hasTargetStopDurationDependantGradient = function() {
  79562. return this._startSizeGradients && this._startSizeGradients.length > 0 || this._emitRateGradients && this._emitRateGradients.length > 0 || this._lifeTimeGradients && this._lifeTimeGradients.length > 0
  79563. }
  79564. ,
  79565. a.prototype.getDragGradients = function() {
  79566. return this._dragGradients
  79567. }
  79568. ,
  79569. a.prototype.getLimitVelocityGradients = function() {
  79570. return this._limitVelocityGradients
  79571. }
  79572. ,
  79573. a.prototype.getColorGradients = function() {
  79574. return this._colorGradients
  79575. }
  79576. ,
  79577. a.prototype.getSizeGradients = function() {
  79578. return this._sizeGradients
  79579. }
  79580. ,
  79581. a.prototype.getColorRemapGradients = function() {
  79582. return this._colorRemapGradients
  79583. }
  79584. ,
  79585. a.prototype.getAlphaRemapGradients = function() {
  79586. return this._alphaRemapGradients
  79587. }
  79588. ,
  79589. a.prototype.getLifeTimeGradients = function() {
  79590. return this._lifeTimeGradients
  79591. }
  79592. ,
  79593. a.prototype.getAngularSpeedGradients = function() {
  79594. return this._angularSpeedGradients
  79595. }
  79596. ,
  79597. a.prototype.getVelocityGradients = function() {
  79598. return this._velocityGradients
  79599. }
  79600. ,
  79601. a.prototype.getStartSizeGradients = function() {
  79602. return this._startSizeGradients
  79603. }
  79604. ,
  79605. a.prototype.getEmitRateGradients = function() {
  79606. return this._emitRateGradients
  79607. }
  79608. ,
  79609. Object.defineProperty(a.prototype, "direction1", {
  79610. get: function() {
  79611. return this.particleEmitterType.direction1 ? this.particleEmitterType.direction1 : Vector3.Zero()
  79612. },
  79613. set: function(e) {
  79614. this.particleEmitterType.direction1 && (this.particleEmitterType.direction1 = e)
  79615. },
  79616. enumerable: !1,
  79617. configurable: !0
  79618. }),
  79619. Object.defineProperty(a.prototype, "direction2", {
  79620. get: function() {
  79621. return this.particleEmitterType.direction2 ? this.particleEmitterType.direction2 : Vector3.Zero()
  79622. },
  79623. set: function(e) {
  79624. this.particleEmitterType.direction2 && (this.particleEmitterType.direction2 = e)
  79625. },
  79626. enumerable: !1,
  79627. configurable: !0
  79628. }),
  79629. Object.defineProperty(a.prototype, "minEmitBox", {
  79630. get: function() {
  79631. return this.particleEmitterType.minEmitBox ? this.particleEmitterType.minEmitBox : Vector3.Zero()
  79632. },
  79633. set: function(e) {
  79634. this.particleEmitterType.minEmitBox && (this.particleEmitterType.minEmitBox = e)
  79635. },
  79636. enumerable: !1,
  79637. configurable: !0
  79638. }),
  79639. Object.defineProperty(a.prototype, "maxEmitBox", {
  79640. get: function() {
  79641. return this.particleEmitterType.maxEmitBox ? this.particleEmitterType.maxEmitBox : Vector3.Zero()
  79642. },
  79643. set: function(e) {
  79644. this.particleEmitterType.maxEmitBox && (this.particleEmitterType.maxEmitBox = e)
  79645. },
  79646. enumerable: !1,
  79647. configurable: !0
  79648. }),
  79649. Object.defineProperty(a.prototype, "isBillboardBased", {
  79650. get: function() {
  79651. return this._isBillboardBased
  79652. },
  79653. set: function(e) {
  79654. this._isBillboardBased !== e && (this._isBillboardBased = e,
  79655. this._reset())
  79656. },
  79657. enumerable: !1,
  79658. configurable: !0
  79659. }),
  79660. Object.defineProperty(a.prototype, "imageProcessingConfiguration", {
  79661. get: function() {
  79662. return this._imageProcessingConfiguration
  79663. },
  79664. set: function(e) {
  79665. this._attachImageProcessingConfiguration(e)
  79666. },
  79667. enumerable: !1,
  79668. configurable: !0
  79669. }),
  79670. a.prototype._attachImageProcessingConfiguration = function(e) {
  79671. e !== this._imageProcessingConfiguration && (!e && this._scene ? this._imageProcessingConfiguration = this._scene.imageProcessingConfiguration : this._imageProcessingConfiguration = e)
  79672. }
  79673. ,
  79674. a.prototype._reset = function() {}
  79675. ,
  79676. a.prototype._removeGradientAndTexture = function(e, i, o) {
  79677. if (!i)
  79678. return this;
  79679. for (var s = 0, c = 0, d = i; c < d.length; c++) {
  79680. var _ = d[c];
  79681. if (_.gradient === e) {
  79682. i.splice(s, 1);
  79683. break
  79684. }
  79685. s++
  79686. }
  79687. return o && o.dispose(),
  79688. this
  79689. }
  79690. ,
  79691. a.prototype.createPointEmitter = function(e, i) {
  79692. var o = new PointParticleEmitter;
  79693. return o.direction1 = e,
  79694. o.direction2 = i,
  79695. this.particleEmitterType = o,
  79696. o
  79697. }
  79698. ,
  79699. a.prototype.createHemisphericEmitter = function(e, i) {
  79700. e === void 0 && (e = 1),
  79701. i === void 0 && (i = 1);
  79702. var o = new HemisphericParticleEmitter(e,i);
  79703. return this.particleEmitterType = o,
  79704. o
  79705. }
  79706. ,
  79707. a.prototype.createSphereEmitter = function(e, i) {
  79708. e === void 0 && (e = 1),
  79709. i === void 0 && (i = 1);
  79710. var o = new SphereParticleEmitter(e,i);
  79711. return this.particleEmitterType = o,
  79712. o
  79713. }
  79714. ,
  79715. a.prototype.createDirectedSphereEmitter = function(e, i, o) {
  79716. e === void 0 && (e = 1),
  79717. i === void 0 && (i = new Vector3(0,1,0)),
  79718. o === void 0 && (o = new Vector3(0,1,0));
  79719. var s = new SphereDirectedParticleEmitter(e,i,o);
  79720. return this.particleEmitterType = s,
  79721. s
  79722. }
  79723. ,
  79724. a.prototype.createCylinderEmitter = function(e, i, o, s) {
  79725. e === void 0 && (e = 1),
  79726. i === void 0 && (i = 1),
  79727. o === void 0 && (o = 1),
  79728. s === void 0 && (s = 0);
  79729. var c = new CylinderParticleEmitter(e,i,o,s);
  79730. return this.particleEmitterType = c,
  79731. c
  79732. }
  79733. ,
  79734. a.prototype.createDirectedCylinderEmitter = function(e, i, o, s, c) {
  79735. e === void 0 && (e = 1),
  79736. i === void 0 && (i = 1),
  79737. o === void 0 && (o = 1),
  79738. s === void 0 && (s = new Vector3(0,1,0)),
  79739. c === void 0 && (c = new Vector3(0,1,0));
  79740. var d = new CylinderDirectedParticleEmitter(e,i,o,s,c);
  79741. return this.particleEmitterType = d,
  79742. d
  79743. }
  79744. ,
  79745. a.prototype.createConeEmitter = function(e, i) {
  79746. e === void 0 && (e = 1),
  79747. i === void 0 && (i = Math.PI / 4);
  79748. var o = new ConeParticleEmitter(e,i);
  79749. return this.particleEmitterType = o,
  79750. o
  79751. }
  79752. ,
  79753. a.prototype.createBoxEmitter = function(e, i, o, s) {
  79754. var c = new BoxParticleEmitter;
  79755. return this.particleEmitterType = c,
  79756. this.direction1 = e,
  79757. this.direction2 = i,
  79758. this.minEmitBox = o,
  79759. this.maxEmitBox = s,
  79760. c
  79761. }
  79762. ,
  79763. a.BLENDMODE_ONEONE = 0,
  79764. a.BLENDMODE_STANDARD = 1,
  79765. a.BLENDMODE_ADD = 2,
  79766. a.BLENDMODE_MULTIPLY = 3,
  79767. a.BLENDMODE_MULTIPLYADD = 4,
  79768. a
  79769. }(), Particle = function() {
  79770. function a(e) {
  79771. this.particleSystem = e,
  79772. this.position = Vector3.Zero(),
  79773. this.direction = Vector3.Zero(),
  79774. this.color = new Color4(0,0,0,0),
  79775. this.colorStep = new Color4(0,0,0,0),
  79776. this.lifeTime = 1,
  79777. this.age = 0,
  79778. this.size = 0,
  79779. this.scale = new Vector2(1,1),
  79780. this.angle = 0,
  79781. this.angularSpeed = 0,
  79782. this.cellIndex = 0,
  79783. this._attachedSubEmitters = null,
  79784. this._currentColor1 = new Color4(0,0,0,0),
  79785. this._currentColor2 = new Color4(0,0,0,0),
  79786. this._currentSize1 = 0,
  79787. this._currentSize2 = 0,
  79788. this._currentAngularSpeed1 = 0,
  79789. this._currentAngularSpeed2 = 0,
  79790. this._currentVelocity1 = 0,
  79791. this._currentVelocity2 = 0,
  79792. this._currentLimitVelocity1 = 0,
  79793. this._currentLimitVelocity2 = 0,
  79794. this._currentDrag1 = 0,
  79795. this._currentDrag2 = 0,
  79796. this.id = a._Count++,
  79797. this.particleSystem.isAnimationSheetEnabled && this.updateCellInfoFromSystem()
  79798. }
  79799. return a.prototype.updateCellInfoFromSystem = function() {
  79800. this.cellIndex = this.particleSystem.startSpriteCellID
  79801. }
  79802. ,
  79803. a.prototype.updateCellIndex = function() {
  79804. var e = this.age
  79805. , i = this.particleSystem.spriteCellChangeSpeed;
  79806. this.particleSystem.spriteRandomStartCell && (this._randomCellOffset === void 0 && (this._randomCellOffset = Math.random() * this.lifeTime),
  79807. i === 0 ? (i = 1,
  79808. e = this._randomCellOffset) : e += this._randomCellOffset);
  79809. var o = this._initialEndSpriteCellID - this._initialStartSpriteCellID, s;
  79810. this._initialSpriteCellLoop ? s = Scalar.Clamp(e * i % this.lifeTime / this.lifeTime) : s = Scalar.Clamp(e * i / this.lifeTime),
  79811. this.cellIndex = this._initialStartSpriteCellID + s * o | 0
  79812. }
  79813. ,
  79814. a.prototype._inheritParticleInfoToSubEmitter = function(e) {
  79815. if (e.particleSystem.emitter.position) {
  79816. var i = e.particleSystem.emitter;
  79817. if (i.position.copyFrom(this.position),
  79818. e.inheritDirection) {
  79819. var o = TmpVectors.Vector3[0];
  79820. this.direction.normalizeToRef(o),
  79821. i.setDirection(o, 0, Math.PI / 2)
  79822. }
  79823. } else {
  79824. var s = e.particleSystem.emitter;
  79825. s.copyFrom(this.position)
  79826. }
  79827. this.direction.scaleToRef(e.inheritedVelocityAmount / 2, TmpVectors.Vector3[0]),
  79828. e.particleSystem._inheritedVelocityOffset.copyFrom(TmpVectors.Vector3[0])
  79829. }
  79830. ,
  79831. a.prototype._inheritParticleInfoToSubEmitters = function() {
  79832. var e = this;
  79833. this._attachedSubEmitters && this._attachedSubEmitters.length > 0 && this._attachedSubEmitters.forEach(function(i) {
  79834. e._inheritParticleInfoToSubEmitter(i)
  79835. })
  79836. }
  79837. ,
  79838. a.prototype._reset = function() {
  79839. this.age = 0,
  79840. this.id = a._Count++,
  79841. this._currentColorGradient = null,
  79842. this._currentSizeGradient = null,
  79843. this._currentAngularSpeedGradient = null,
  79844. this._currentVelocityGradient = null,
  79845. this._currentLimitVelocityGradient = null,
  79846. this._currentDragGradient = null,
  79847. this.cellIndex = this.particleSystem.startSpriteCellID,
  79848. this._randomCellOffset = void 0
  79849. }
  79850. ,
  79851. a.prototype.copyTo = function(e) {
  79852. e.position.copyFrom(this.position),
  79853. this._initialDirection ? e._initialDirection ? e._initialDirection.copyFrom(this._initialDirection) : e._initialDirection = this._initialDirection.clone() : e._initialDirection = null,
  79854. e.direction.copyFrom(this.direction),
  79855. this._localPosition && (e._localPosition ? e._localPosition.copyFrom(this._localPosition) : e._localPosition = this._localPosition.clone()),
  79856. e.color.copyFrom(this.color),
  79857. e.colorStep.copyFrom(this.colorStep),
  79858. e.lifeTime = this.lifeTime,
  79859. e.age = this.age,
  79860. e._randomCellOffset = this._randomCellOffset,
  79861. e.size = this.size,
  79862. e.scale.copyFrom(this.scale),
  79863. e.angle = this.angle,
  79864. e.angularSpeed = this.angularSpeed,
  79865. e.particleSystem = this.particleSystem,
  79866. e.cellIndex = this.cellIndex,
  79867. e.id = this.id,
  79868. e._attachedSubEmitters = this._attachedSubEmitters,
  79869. this._currentColorGradient && (e._currentColorGradient = this._currentColorGradient,
  79870. e._currentColor1.copyFrom(this._currentColor1),
  79871. e._currentColor2.copyFrom(this._currentColor2)),
  79872. this._currentSizeGradient && (e._currentSizeGradient = this._currentSizeGradient,
  79873. e._currentSize1 = this._currentSize1,
  79874. e._currentSize2 = this._currentSize2),
  79875. this._currentAngularSpeedGradient && (e._currentAngularSpeedGradient = this._currentAngularSpeedGradient,
  79876. e._currentAngularSpeed1 = this._currentAngularSpeed1,
  79877. e._currentAngularSpeed2 = this._currentAngularSpeed2),
  79878. this._currentVelocityGradient && (e._currentVelocityGradient = this._currentVelocityGradient,
  79879. e._currentVelocity1 = this._currentVelocity1,
  79880. e._currentVelocity2 = this._currentVelocity2),
  79881. this._currentLimitVelocityGradient && (e._currentLimitVelocityGradient = this._currentLimitVelocityGradient,
  79882. e._currentLimitVelocity1 = this._currentLimitVelocity1,
  79883. e._currentLimitVelocity2 = this._currentLimitVelocity2),
  79884. this._currentDragGradient && (e._currentDragGradient = this._currentDragGradient,
  79885. e._currentDrag1 = this._currentDrag1,
  79886. e._currentDrag2 = this._currentDrag2),
  79887. this.particleSystem.isAnimationSheetEnabled && (e._initialStartSpriteCellID = this._initialStartSpriteCellID,
  79888. e._initialEndSpriteCellID = this._initialEndSpriteCellID,
  79889. e._initialSpriteCellLoop = this._initialSpriteCellLoop),
  79890. this.particleSystem.useRampGradients && (e.remapData && this.remapData ? e.remapData.copyFrom(this.remapData) : e.remapData = new Vector4(0,0,0,0)),
  79891. this._randomNoiseCoordinates1 && (e._randomNoiseCoordinates1 ? (e._randomNoiseCoordinates1.copyFrom(this._randomNoiseCoordinates1),
  79892. e._randomNoiseCoordinates2.copyFrom(this._randomNoiseCoordinates2)) : (e._randomNoiseCoordinates1 = this._randomNoiseCoordinates1.clone(),
  79893. e._randomNoiseCoordinates2 = this._randomNoiseCoordinates2.clone()))
  79894. }
  79895. ,
  79896. a._Count = 0,
  79897. a
  79898. }(), SubEmitterType;
  79899. (function(a) {
  79900. a[a.ATTACHED = 0] = "ATTACHED",
  79901. a[a.END = 1] = "END"
  79902. }
  79903. )(SubEmitterType || (SubEmitterType = {}));
  79904. var SubEmitter = function() {
  79905. function a(e) {
  79906. if (this.particleSystem = e,
  79907. this.type = SubEmitterType.END,
  79908. this.inheritDirection = !1,
  79909. this.inheritedVelocityAmount = 0,
  79910. !e.emitter || !e.emitter.dispose) {
  79911. var i = GetClass("BABYLON.AbstractMesh");
  79912. e.emitter = new i("SubemitterSystemEmitter",e.getScene()),
  79913. e._disposeEmitterOnDispose = !0
  79914. }
  79915. }
  79916. return a.prototype.clone = function() {
  79917. var e = this.particleSystem.emitter;
  79918. if (!e)
  79919. e = new Vector3;
  79920. else if (e instanceof Vector3)
  79921. e = e.clone();
  79922. else if (e.getClassName().indexOf("Mesh") !== -1) {
  79923. var i = GetClass("BABYLON.Mesh");
  79924. e = new i("",e.getScene()),
  79925. e.isVisible = !1
  79926. }
  79927. var o = new a(this.particleSystem.clone(this.particleSystem.name, e));
  79928. return o.particleSystem.name += "Clone",
  79929. o.type = this.type,
  79930. o.inheritDirection = this.inheritDirection,
  79931. o.inheritedVelocityAmount = this.inheritedVelocityAmount,
  79932. o.particleSystem._disposeEmitterOnDispose = !0,
  79933. o.particleSystem.disposeOnStop = !0,
  79934. o
  79935. }
  79936. ,
  79937. a.prototype.serialize = function(e) {
  79938. e === void 0 && (e = !1);
  79939. var i = {};
  79940. return i.type = this.type,
  79941. i.inheritDirection = this.inheritDirection,
  79942. i.inheritedVelocityAmount = this.inheritedVelocityAmount,
  79943. i.particleSystem = this.particleSystem.serialize(e),
  79944. i
  79945. }
  79946. ,
  79947. a._ParseParticleSystem = function(e, i, o, s) {
  79948. throw _WarnImport("ParseParticle")
  79949. }
  79950. ,
  79951. a.Parse = function(e, i, o) {
  79952. var s = e.particleSystem
  79953. , c = new a(a._ParseParticleSystem(s, i, o, !0));
  79954. return c.type = e.type,
  79955. c.inheritDirection = e.inheritDirection,
  79956. c.inheritedVelocityAmount = e.inheritedVelocityAmount,
  79957. c.particleSystem._isSubEmitter = !0,
  79958. c
  79959. }
  79960. ,
  79961. a.prototype.dispose = function() {
  79962. this.particleSystem.dispose()
  79963. }
  79964. ,
  79965. a
  79966. }()
  79967. , name$1m = "particlesPixelShader"
  79968. , shader$1m = `
  79969. varying vec2 vUV;
  79970. varying vec4 vColor;
  79971. uniform vec4 textureMask;
  79972. uniform sampler2D diffuseSampler;
  79973. #include<clipPlaneFragmentDeclaration>
  79974. #include<imageProcessingDeclaration>
  79975. #include<helperFunctions>
  79976. #include<imageProcessingFunctions>
  79977. #ifdef RAMPGRADIENT
  79978. varying vec4 remapRanges;
  79979. uniform sampler2D rampSampler;
  79980. #endif
  79981. void main(void) {
  79982. #include<clipPlaneFragment>
  79983. vec4 textureColor=texture2D(diffuseSampler,vUV);
  79984. vec4 baseColor=(textureColor*textureMask+(vec4(1.,1.,1.,1.)-textureMask))*vColor;
  79985. #ifdef RAMPGRADIENT
  79986. float alpha=baseColor.a;
  79987. float remappedColorIndex=clamp((alpha-remapRanges.x)/remapRanges.y,0.0,1.0);
  79988. vec4 rampColor=texture2D(rampSampler,vec2(1.0-remappedColorIndex,0.));
  79989. baseColor.rgb*=rampColor.rgb;
  79990. float finalAlpha=baseColor.a;
  79991. baseColor.a=clamp((alpha*rampColor.a-remapRanges.z)/remapRanges.w,0.0,1.0);
  79992. #endif
  79993. #ifdef BLENDMULTIPLYMODE
  79994. float sourceAlpha=vColor.a*textureColor.a;
  79995. baseColor.rgb=baseColor.rgb*sourceAlpha+vec3(1.0)*(1.0-sourceAlpha);
  79996. #endif
  79997. #ifdef IMAGEPROCESSINGPOSTPROCESS
  79998. baseColor.rgb=toLinearSpace(baseColor.rgb);
  79999. #else
  80000. #ifdef IMAGEPROCESSING
  80001. baseColor.rgb=toLinearSpace(baseColor.rgb);
  80002. baseColor=applyImageProcessing(baseColor);
  80003. #endif
  80004. #endif
  80005. gl_FragColor=baseColor;
  80006. }`;
  80007. ShaderStore.ShadersStore[name$1m] = shader$1m;
  80008. var name$1l = "particlesVertexShader"
  80009. , shader$1l = `
  80010. attribute vec3 position;
  80011. attribute vec4 color;
  80012. attribute float angle;
  80013. attribute vec2 size;
  80014. #ifdef ANIMATESHEET
  80015. attribute float cellIndex;
  80016. #endif
  80017. #ifndef BILLBOARD
  80018. attribute vec3 direction;
  80019. #endif
  80020. #ifdef BILLBOARDSTRETCHED
  80021. attribute vec3 direction;
  80022. #endif
  80023. #ifdef RAMPGRADIENT
  80024. attribute vec4 remapData;
  80025. #endif
  80026. attribute vec2 offset;
  80027. uniform mat4 view;
  80028. uniform mat4 projection;
  80029. uniform vec2 translationPivot;
  80030. #ifdef ANIMATESHEET
  80031. uniform vec3 particlesInfos;
  80032. #endif
  80033. varying vec2 vUV;
  80034. varying vec4 vColor;
  80035. varying vec3 vPositionW;
  80036. #ifdef RAMPGRADIENT
  80037. varying vec4 remapRanges;
  80038. #endif
  80039. #if defined(BILLBOARD) && !defined(BILLBOARDY) && !defined(BILLBOARDSTRETCHED)
  80040. uniform mat4 invView;
  80041. #endif
  80042. #include<clipPlaneVertexDeclaration>
  80043. #ifdef BILLBOARD
  80044. uniform vec3 eyePosition;
  80045. #endif
  80046. vec3 rotate(vec3 yaxis,vec3 rotatedCorner) {
  80047. vec3 xaxis=normalize(cross(vec3(0.,1.0,0.),yaxis));
  80048. vec3 zaxis=normalize(cross(yaxis,xaxis));
  80049. vec3 row0=vec3(xaxis.x,xaxis.y,xaxis.z);
  80050. vec3 row1=vec3(yaxis.x,yaxis.y,yaxis.z);
  80051. vec3 row2=vec3(zaxis.x,zaxis.y,zaxis.z);
  80052. mat3 rotMatrix=mat3(row0,row1,row2);
  80053. vec3 alignedCorner=rotMatrix*rotatedCorner;
  80054. return position+alignedCorner;
  80055. }
  80056. #ifdef BILLBOARDSTRETCHED
  80057. vec3 rotateAlign(vec3 toCamera,vec3 rotatedCorner) {
  80058. vec3 normalizedToCamera=normalize(toCamera);
  80059. vec3 normalizedCrossDirToCamera=normalize(cross(normalize(direction),normalizedToCamera));
  80060. vec3 crossProduct=normalize(cross(normalizedToCamera,normalizedCrossDirToCamera));
  80061. vec3 row0=vec3(normalizedCrossDirToCamera.x,normalizedCrossDirToCamera.y,normalizedCrossDirToCamera.z);
  80062. vec3 row1=vec3(crossProduct.x,crossProduct.y,crossProduct.z);
  80063. vec3 row2=vec3(normalizedToCamera.x,normalizedToCamera.y,normalizedToCamera.z);
  80064. mat3 rotMatrix=mat3(row0,row1,row2);
  80065. vec3 alignedCorner=rotMatrix*rotatedCorner;
  80066. return position+alignedCorner;
  80067. }
  80068. #endif
  80069. void main(void) {
  80070. vec2 cornerPos;
  80071. cornerPos=(vec2(offset.x-0.5,offset.y-0.5)-translationPivot)*size+translationPivot;
  80072. #ifdef BILLBOARD
  80073. vec3 rotatedCorner;
  80074. #ifdef BILLBOARDY
  80075. rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);
  80076. rotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);
  80077. rotatedCorner.y=0.;
  80078. vec3 yaxis=position-eyePosition;
  80079. yaxis.y=0.;
  80080. vPositionW=rotate(normalize(yaxis),rotatedCorner);
  80081. vec3 viewPos=(view*vec4(vPositionW,1.0)).xyz;
  80082. #elif defined(BILLBOARDSTRETCHED)
  80083. rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);
  80084. rotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);
  80085. rotatedCorner.z=0.;
  80086. vec3 toCamera=position-eyePosition;
  80087. vPositionW=rotateAlign(toCamera,rotatedCorner);
  80088. vec3 viewPos=(view*vec4(vPositionW,1.0)).xyz;
  80089. #else
  80090. rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);
  80091. rotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);
  80092. rotatedCorner.z=0.;
  80093. vec3 viewPos=(view*vec4(position,1.0)).xyz+rotatedCorner;
  80094. vPositionW=(invView*vec4(viewPos,1)).xyz;
  80095. #endif
  80096. #ifdef RAMPGRADIENT
  80097. remapRanges=remapData;
  80098. #endif
  80099. gl_Position=projection*vec4(viewPos,1.0);
  80100. #else
  80101. vec3 rotatedCorner;
  80102. rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);
  80103. rotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);
  80104. rotatedCorner.y=0.;
  80105. vec3 yaxis=normalize(direction);
  80106. vPositionW=rotate(yaxis,rotatedCorner);
  80107. gl_Position=projection*view*vec4(vPositionW,1.0);
  80108. #endif
  80109. vColor=color;
  80110. #ifdef ANIMATESHEET
  80111. float rowOffset=floor(cellIndex*particlesInfos.z);
  80112. float columnOffset=cellIndex-rowOffset/particlesInfos.z;
  80113. vec2 uvScale=particlesInfos.xy;
  80114. vec2 uvOffset=vec2(offset.x ,1.0-offset.y);
  80115. vUV=(uvOffset+vec2(columnOffset,rowOffset))*uvScale;
  80116. #else
  80117. vUV=offset;
  80118. #endif
  80119. #if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)
  80120. vec4 worldPos=vec4(vPositionW,1.0);
  80121. #endif
  80122. #include<clipPlaneVertex>
  80123. }`;
  80124. ShaderStore.ShadersStore[name$1l] = shader$1l;
  80125. var ParticleSystem = function(a) {
  80126. __extends(e, a);
  80127. function e(i, o, s, c, d, _) {
  80128. c === void 0 && (c = null),
  80129. d === void 0 && (d = !1),
  80130. _ === void 0 && (_ = .01);
  80131. var b = a.call(this, i) || this;
  80132. b._emitterInverseWorldMatrix = Matrix.Identity(),
  80133. b._inheritedVelocityOffset = new Vector3,
  80134. b.onDisposeObservable = new Observable,
  80135. b.onStoppedObservable = new Observable,
  80136. b._particles = new Array,
  80137. b._stockParticles = new Array,
  80138. b._newPartsExcess = 0,
  80139. b._vertexBuffers = {},
  80140. b._scaledColorStep = new Color4(0,0,0,0),
  80141. b._colorDiff = new Color4(0,0,0,0),
  80142. b._scaledDirection = Vector3.Zero(),
  80143. b._scaledGravity = Vector3.Zero(),
  80144. b._currentRenderId = -1,
  80145. b._useInstancing = !1,
  80146. b._started = !1,
  80147. b._stopped = !1,
  80148. b._actualFrame = 0,
  80149. b._currentEmitRate1 = 0,
  80150. b._currentEmitRate2 = 0,
  80151. b._currentStartSize1 = 0,
  80152. b._currentStartSize2 = 0,
  80153. b._rawTextureWidth = 256,
  80154. b._useRampGradients = !1,
  80155. b._disposeEmitterOnDispose = !1,
  80156. b.isLocal = !1,
  80157. b._onBeforeDrawParticlesObservable = null,
  80158. b.recycleParticle = function(j) {
  80159. var $ = b._particles.pop();
  80160. $ !== j && $.copyTo(j),
  80161. b._stockParticles.push($)
  80162. }
  80163. ,
  80164. b._createParticle = function() {
  80165. var j;
  80166. if (b._stockParticles.length !== 0 ? (j = b._stockParticles.pop(),
  80167. j._reset()) : j = new Particle(b),
  80168. b._subEmitters && b._subEmitters.length > 0) {
  80169. var $ = b._subEmitters[Math.floor(Math.random() * b._subEmitters.length)];
  80170. j._attachedSubEmitters = [],
  80171. $.forEach(function(_e) {
  80172. if (_e.type === SubEmitterType.ATTACHED) {
  80173. var et = _e.clone();
  80174. j._attachedSubEmitters.push(et),
  80175. et.particleSystem.start()
  80176. }
  80177. })
  80178. }
  80179. return j
  80180. }
  80181. ,
  80182. b._emitFromParticle = function(j) {
  80183. if (!(!b._subEmitters || b._subEmitters.length === 0)) {
  80184. var $ = Math.floor(Math.random() * b._subEmitters.length);
  80185. b._subEmitters[$].forEach(function(_e) {
  80186. if (_e.type === SubEmitterType.END) {
  80187. var et = _e.clone();
  80188. j._inheritParticleInfoToSubEmitter(et),
  80189. et.particleSystem._rootParticleSystem = b,
  80190. b.activeSubSystems.push(et.particleSystem),
  80191. et.particleSystem.start()
  80192. }
  80193. })
  80194. }
  80195. }
  80196. ,
  80197. b._capacity = o,
  80198. b._epsilon = _,
  80199. b._isAnimationSheetEnabled = d,
  80200. !s || s.getClassName() === "Scene" ? (b._scene = s || EngineStore.LastCreatedScene,
  80201. b._engine = b._scene.getEngine(),
  80202. b.uniqueId = b._scene.getUniqueId(),
  80203. b._scene.particleSystems.push(b)) : (b._engine = s,
  80204. b.defaultProjectionMatrix = Matrix.PerspectiveFovLH(.8, 1, .1, 100, b._engine.isNDCHalfZRange)),
  80205. b._engine.getCaps().vertexArrayObject && (b._vertexArrayObject = null),
  80206. b._attachImageProcessingConfiguration(null),
  80207. b._customWrappers = {
  80208. 0: new DrawWrapper(b._engine)
  80209. },
  80210. b._customWrappers[0].effect = c,
  80211. b._drawWrappers = [],
  80212. b._useInstancing = b._engine.getCaps().instancedArrays,
  80213. b._createIndexBuffer(),
  80214. b._createVertexBuffers(),
  80215. b.particleEmitterType = new BoxParticleEmitter;
  80216. var k = null;
  80217. return b.updateFunction = function(j) {
  80218. var $, _e = null;
  80219. b.noiseTexture && (_e = b.noiseTexture.getSize(),
  80220. ($ = b.noiseTexture.getContent()) === null || $ === void 0 || $.then(function(it) {
  80221. k = it
  80222. }));
  80223. for (var et = function() {
  80224. tt = j[rt];
  80225. var it = b._scaledUpdateSpeed
  80226. , nt = tt.age;
  80227. if (tt.age += it,
  80228. tt.age > tt.lifeTime) {
  80229. var ot = tt.age - nt
  80230. , at = tt.lifeTime - nt;
  80231. it = at * it / ot,
  80232. tt.age = tt.lifeTime
  80233. }
  80234. var st = tt.age / tt.lifeTime;
  80235. b._colorGradients && b._colorGradients.length > 0 ? GradientHelper.GetCurrentGradient(st, b._colorGradients, function(dt, _t, mt) {
  80236. dt !== tt._currentColorGradient && (tt._currentColor1.copyFrom(tt._currentColor2),
  80237. _t.getColorToRef(tt._currentColor2),
  80238. tt._currentColorGradient = dt),
  80239. Color4.LerpToRef(tt._currentColor1, tt._currentColor2, mt, tt.color)
  80240. }) : (tt.colorStep.scaleToRef(it, b._scaledColorStep),
  80241. tt.color.addInPlace(b._scaledColorStep),
  80242. tt.color.a < 0 && (tt.color.a = 0)),
  80243. b._angularSpeedGradients && b._angularSpeedGradients.length > 0 && GradientHelper.GetCurrentGradient(st, b._angularSpeedGradients, function(dt, _t, mt) {
  80244. dt !== tt._currentAngularSpeedGradient && (tt._currentAngularSpeed1 = tt._currentAngularSpeed2,
  80245. tt._currentAngularSpeed2 = _t.getFactor(),
  80246. tt._currentAngularSpeedGradient = dt),
  80247. tt.angularSpeed = Scalar.Lerp(tt._currentAngularSpeed1, tt._currentAngularSpeed2, mt)
  80248. }),
  80249. tt.angle += tt.angularSpeed * it;
  80250. var ut = it;
  80251. if (b._velocityGradients && b._velocityGradients.length > 0 && GradientHelper.GetCurrentGradient(st, b._velocityGradients, function(dt, _t, mt) {
  80252. dt !== tt._currentVelocityGradient && (tt._currentVelocity1 = tt._currentVelocity2,
  80253. tt._currentVelocity2 = _t.getFactor(),
  80254. tt._currentVelocityGradient = dt),
  80255. ut *= Scalar.Lerp(tt._currentVelocity1, tt._currentVelocity2, mt)
  80256. }),
  80257. tt.direction.scaleToRef(ut, b._scaledDirection),
  80258. b._limitVelocityGradients && b._limitVelocityGradients.length > 0 && GradientHelper.GetCurrentGradient(st, b._limitVelocityGradients, function(dt, _t, mt) {
  80259. dt !== tt._currentLimitVelocityGradient && (tt._currentLimitVelocity1 = tt._currentLimitVelocity2,
  80260. tt._currentLimitVelocity2 = _t.getFactor(),
  80261. tt._currentLimitVelocityGradient = dt);
  80262. var vt = Scalar.Lerp(tt._currentLimitVelocity1, tt._currentLimitVelocity2, mt)
  80263. , yt = tt.direction.length();
  80264. yt > vt && tt.direction.scaleInPlace(b.limitVelocityDamping)
  80265. }),
  80266. b._dragGradients && b._dragGradients.length > 0 && GradientHelper.GetCurrentGradient(st, b._dragGradients, function(dt, _t, mt) {
  80267. dt !== tt._currentDragGradient && (tt._currentDrag1 = tt._currentDrag2,
  80268. tt._currentDrag2 = _t.getFactor(),
  80269. tt._currentDragGradient = dt);
  80270. var vt = Scalar.Lerp(tt._currentDrag1, tt._currentDrag2, mt);
  80271. b._scaledDirection.scaleInPlace(1 - vt)
  80272. }),
  80273. b.isLocal && tt._localPosition ? (tt._localPosition.addInPlace(b._scaledDirection),
  80274. Vector3.TransformCoordinatesToRef(tt._localPosition, b._emitterWorldMatrix, tt.position)) : tt.position.addInPlace(b._scaledDirection),
  80275. k && _e && tt._randomNoiseCoordinates1) {
  80276. var ct = b._fetchR(tt._randomNoiseCoordinates1.x, tt._randomNoiseCoordinates1.y, _e.width, _e.height, k)
  80277. , lt = b._fetchR(tt._randomNoiseCoordinates1.z, tt._randomNoiseCoordinates2.x, _e.width, _e.height, k)
  80278. , ft = b._fetchR(tt._randomNoiseCoordinates2.y, tt._randomNoiseCoordinates2.z, _e.width, _e.height, k)
  80279. , ht = TmpVectors.Vector3[0]
  80280. , pt = TmpVectors.Vector3[1];
  80281. ht.copyFromFloats((2 * ct - 1) * b.noiseStrength.x, (2 * lt - 1) * b.noiseStrength.y, (2 * ft - 1) * b.noiseStrength.z),
  80282. ht.scaleToRef(it, pt),
  80283. tt.direction.addInPlace(pt)
  80284. }
  80285. if (b.gravity.scaleToRef(it, b._scaledGravity),
  80286. tt.direction.addInPlace(b._scaledGravity),
  80287. b._sizeGradients && b._sizeGradients.length > 0 && GradientHelper.GetCurrentGradient(st, b._sizeGradients, function(dt, _t, mt) {
  80288. dt !== tt._currentSizeGradient && (tt._currentSize1 = tt._currentSize2,
  80289. tt._currentSize2 = _t.getFactor(),
  80290. tt._currentSizeGradient = dt),
  80291. tt.size = Scalar.Lerp(tt._currentSize1, tt._currentSize2, mt)
  80292. }),
  80293. b._useRampGradients && (b._colorRemapGradients && b._colorRemapGradients.length > 0 && GradientHelper.GetCurrentGradient(st, b._colorRemapGradients, function(dt, _t, mt) {
  80294. var vt = Scalar.Lerp(dt.factor1, _t.factor1, mt)
  80295. , yt = Scalar.Lerp(dt.factor2, _t.factor2, mt);
  80296. tt.remapData.x = vt,
  80297. tt.remapData.y = yt - vt
  80298. }),
  80299. b._alphaRemapGradients && b._alphaRemapGradients.length > 0 && GradientHelper.GetCurrentGradient(st, b._alphaRemapGradients, function(dt, _t, mt) {
  80300. var vt = Scalar.Lerp(dt.factor1, _t.factor1, mt)
  80301. , yt = Scalar.Lerp(dt.factor2, _t.factor2, mt);
  80302. tt.remapData.z = vt,
  80303. tt.remapData.w = yt - vt
  80304. })),
  80305. b._isAnimationSheetEnabled && tt.updateCellIndex(),
  80306. tt._inheritParticleInfoToSubEmitters(),
  80307. tt.age >= tt.lifeTime)
  80308. return b._emitFromParticle(tt),
  80309. tt._attachedSubEmitters && (tt._attachedSubEmitters.forEach(function(dt) {
  80310. dt.particleSystem.disposeOnStop = !0,
  80311. dt.particleSystem.stop()
  80312. }),
  80313. tt._attachedSubEmitters = null),
  80314. b.recycleParticle(tt),
  80315. rt--,
  80316. "continue"
  80317. }, tt, rt = 0; rt < j.length; rt++)
  80318. et()
  80319. }
  80320. ,
  80321. b
  80322. }
  80323. return Object.defineProperty(e.prototype, "onDispose", {
  80324. set: function(i) {
  80325. this._onDisposeObserver && this.onDisposeObservable.remove(this._onDisposeObserver),
  80326. this._onDisposeObserver = this.onDisposeObservable.add(i)
  80327. },
  80328. enumerable: !1,
  80329. configurable: !0
  80330. }),
  80331. Object.defineProperty(e.prototype, "useRampGradients", {
  80332. get: function() {
  80333. return this._useRampGradients
  80334. },
  80335. set: function(i) {
  80336. this._useRampGradients !== i && (this._useRampGradients = i,
  80337. this._resetEffect())
  80338. },
  80339. enumerable: !1,
  80340. configurable: !0
  80341. }),
  80342. Object.defineProperty(e.prototype, "particles", {
  80343. get: function() {
  80344. return this._particles
  80345. },
  80346. enumerable: !1,
  80347. configurable: !0
  80348. }),
  80349. e.prototype.getActiveCount = function() {
  80350. return this._particles.length
  80351. }
  80352. ,
  80353. e.prototype.getClassName = function() {
  80354. return "ParticleSystem"
  80355. }
  80356. ,
  80357. e.prototype.isStopping = function() {
  80358. return this._stopped && this.isAlive()
  80359. }
  80360. ,
  80361. e.prototype.getCustomEffect = function(i) {
  80362. var o, s;
  80363. return i === void 0 && (i = 0),
  80364. (s = (o = this._customWrappers[i]) === null || o === void 0 ? void 0 : o.effect) !== null && s !== void 0 ? s : this._customWrappers[0].effect
  80365. }
  80366. ,
  80367. e.prototype._getCustomDrawWrapper = function(i) {
  80368. var o;
  80369. return i === void 0 && (i = 0),
  80370. (o = this._customWrappers[i]) !== null && o !== void 0 ? o : this._customWrappers[0]
  80371. }
  80372. ,
  80373. e.prototype.setCustomEffect = function(i, o) {
  80374. o === void 0 && (o = 0),
  80375. this._customWrappers[o] = new DrawWrapper(this._engine),
  80376. this._customWrappers[o].effect = i,
  80377. this._customWrappers[o].drawContext && (this._customWrappers[o].drawContext.useInstancing = this._useInstancing)
  80378. }
  80379. ,
  80380. Object.defineProperty(e.prototype, "onBeforeDrawParticlesObservable", {
  80381. get: function() {
  80382. return this._onBeforeDrawParticlesObservable || (this._onBeforeDrawParticlesObservable = new Observable),
  80383. this._onBeforeDrawParticlesObservable
  80384. },
  80385. enumerable: !1,
  80386. configurable: !0
  80387. }),
  80388. Object.defineProperty(e.prototype, "vertexShaderName", {
  80389. get: function() {
  80390. return "particles"
  80391. },
  80392. enumerable: !1,
  80393. configurable: !0
  80394. }),
  80395. e.prototype._addFactorGradient = function(i, o, s, c) {
  80396. var d = new FactorGradient(o,s,c);
  80397. i.push(d),
  80398. i.sort(function(_, b) {
  80399. return _.gradient < b.gradient ? -1 : _.gradient > b.gradient ? 1 : 0
  80400. })
  80401. }
  80402. ,
  80403. e.prototype._removeFactorGradient = function(i, o) {
  80404. if (!!i)
  80405. for (var s = 0, c = 0, d = i; c < d.length; c++) {
  80406. var _ = d[c];
  80407. if (_.gradient === o) {
  80408. i.splice(s, 1);
  80409. break
  80410. }
  80411. s++
  80412. }
  80413. }
  80414. ,
  80415. e.prototype.addLifeTimeGradient = function(i, o, s) {
  80416. return this._lifeTimeGradients || (this._lifeTimeGradients = []),
  80417. this._addFactorGradient(this._lifeTimeGradients, i, o, s),
  80418. this
  80419. }
  80420. ,
  80421. e.prototype.removeLifeTimeGradient = function(i) {
  80422. return this._removeFactorGradient(this._lifeTimeGradients, i),
  80423. this
  80424. }
  80425. ,
  80426. e.prototype.addSizeGradient = function(i, o, s) {
  80427. return this._sizeGradients || (this._sizeGradients = []),
  80428. this._addFactorGradient(this._sizeGradients, i, o, s),
  80429. this
  80430. }
  80431. ,
  80432. e.prototype.removeSizeGradient = function(i) {
  80433. return this._removeFactorGradient(this._sizeGradients, i),
  80434. this
  80435. }
  80436. ,
  80437. e.prototype.addColorRemapGradient = function(i, o, s) {
  80438. return this._colorRemapGradients || (this._colorRemapGradients = []),
  80439. this._addFactorGradient(this._colorRemapGradients, i, o, s),
  80440. this
  80441. }
  80442. ,
  80443. e.prototype.removeColorRemapGradient = function(i) {
  80444. return this._removeFactorGradient(this._colorRemapGradients, i),
  80445. this
  80446. }
  80447. ,
  80448. e.prototype.addAlphaRemapGradient = function(i, o, s) {
  80449. return this._alphaRemapGradients || (this._alphaRemapGradients = []),
  80450. this._addFactorGradient(this._alphaRemapGradients, i, o, s),
  80451. this
  80452. }
  80453. ,
  80454. e.prototype.removeAlphaRemapGradient = function(i) {
  80455. return this._removeFactorGradient(this._alphaRemapGradients, i),
  80456. this
  80457. }
  80458. ,
  80459. e.prototype.addAngularSpeedGradient = function(i, o, s) {
  80460. return this._angularSpeedGradients || (this._angularSpeedGradients = []),
  80461. this._addFactorGradient(this._angularSpeedGradients, i, o, s),
  80462. this
  80463. }
  80464. ,
  80465. e.prototype.removeAngularSpeedGradient = function(i) {
  80466. return this._removeFactorGradient(this._angularSpeedGradients, i),
  80467. this
  80468. }
  80469. ,
  80470. e.prototype.addVelocityGradient = function(i, o, s) {
  80471. return this._velocityGradients || (this._velocityGradients = []),
  80472. this._addFactorGradient(this._velocityGradients, i, o, s),
  80473. this
  80474. }
  80475. ,
  80476. e.prototype.removeVelocityGradient = function(i) {
  80477. return this._removeFactorGradient(this._velocityGradients, i),
  80478. this
  80479. }
  80480. ,
  80481. e.prototype.addLimitVelocityGradient = function(i, o, s) {
  80482. return this._limitVelocityGradients || (this._limitVelocityGradients = []),
  80483. this._addFactorGradient(this._limitVelocityGradients, i, o, s),
  80484. this
  80485. }
  80486. ,
  80487. e.prototype.removeLimitVelocityGradient = function(i) {
  80488. return this._removeFactorGradient(this._limitVelocityGradients, i),
  80489. this
  80490. }
  80491. ,
  80492. e.prototype.addDragGradient = function(i, o, s) {
  80493. return this._dragGradients || (this._dragGradients = []),
  80494. this._addFactorGradient(this._dragGradients, i, o, s),
  80495. this
  80496. }
  80497. ,
  80498. e.prototype.removeDragGradient = function(i) {
  80499. return this._removeFactorGradient(this._dragGradients, i),
  80500. this
  80501. }
  80502. ,
  80503. e.prototype.addEmitRateGradient = function(i, o, s) {
  80504. return this._emitRateGradients || (this._emitRateGradients = []),
  80505. this._addFactorGradient(this._emitRateGradients, i, o, s),
  80506. this
  80507. }
  80508. ,
  80509. e.prototype.removeEmitRateGradient = function(i) {
  80510. return this._removeFactorGradient(this._emitRateGradients, i),
  80511. this
  80512. }
  80513. ,
  80514. e.prototype.addStartSizeGradient = function(i, o, s) {
  80515. return this._startSizeGradients || (this._startSizeGradients = []),
  80516. this._addFactorGradient(this._startSizeGradients, i, o, s),
  80517. this
  80518. }
  80519. ,
  80520. e.prototype.removeStartSizeGradient = function(i) {
  80521. return this._removeFactorGradient(this._startSizeGradients, i),
  80522. this
  80523. }
  80524. ,
  80525. e.prototype._createRampGradientTexture = function() {
  80526. if (!(!this._rampGradients || !this._rampGradients.length || this._rampGradientsTexture || !this._scene)) {
  80527. for (var i = new Uint8Array(this._rawTextureWidth * 4), o = TmpColors.Color3[0], s = 0; s < this._rawTextureWidth; s++) {
  80528. var c = s / this._rawTextureWidth;
  80529. GradientHelper.GetCurrentGradient(c, this._rampGradients, function(d, _, b) {
  80530. Color3.LerpToRef(d.color, _.color, b, o),
  80531. i[s * 4] = o.r * 255,
  80532. i[s * 4 + 1] = o.g * 255,
  80533. i[s * 4 + 2] = o.b * 255,
  80534. i[s * 4 + 3] = 255
  80535. })
  80536. }
  80537. this._rampGradientsTexture = RawTexture.CreateRGBATexture(i, this._rawTextureWidth, 1, this._scene, !1, !1, 1)
  80538. }
  80539. }
  80540. ,
  80541. e.prototype.getRampGradients = function() {
  80542. return this._rampGradients
  80543. }
  80544. ,
  80545. e.prototype.forceRefreshGradients = function() {
  80546. this._syncRampGradientTexture()
  80547. }
  80548. ,
  80549. e.prototype._syncRampGradientTexture = function() {
  80550. !this._rampGradients || (this._rampGradients.sort(function(i, o) {
  80551. return i.gradient < o.gradient ? -1 : i.gradient > o.gradient ? 1 : 0
  80552. }),
  80553. this._rampGradientsTexture && (this._rampGradientsTexture.dispose(),
  80554. this._rampGradientsTexture = null),
  80555. this._createRampGradientTexture())
  80556. }
  80557. ,
  80558. e.prototype.addRampGradient = function(i, o) {
  80559. this._rampGradients || (this._rampGradients = []);
  80560. var s = new Color3Gradient(i,o);
  80561. return this._rampGradients.push(s),
  80562. this._syncRampGradientTexture(),
  80563. this
  80564. }
  80565. ,
  80566. e.prototype.removeRampGradient = function(i) {
  80567. return this._removeGradientAndTexture(i, this._rampGradients, this._rampGradientsTexture),
  80568. this._rampGradientsTexture = null,
  80569. this._rampGradients && this._rampGradients.length > 0 && this._createRampGradientTexture(),
  80570. this
  80571. }
  80572. ,
  80573. e.prototype.addColorGradient = function(i, o, s) {
  80574. this._colorGradients || (this._colorGradients = []);
  80575. var c = new ColorGradient(i,o,s);
  80576. return this._colorGradients.push(c),
  80577. this._colorGradients.sort(function(d, _) {
  80578. return d.gradient < _.gradient ? -1 : d.gradient > _.gradient ? 1 : 0
  80579. }),
  80580. this
  80581. }
  80582. ,
  80583. e.prototype.removeColorGradient = function(i) {
  80584. if (!this._colorGradients)
  80585. return this;
  80586. for (var o = 0, s = 0, c = this._colorGradients; s < c.length; s++) {
  80587. var d = c[s];
  80588. if (d.gradient === i) {
  80589. this._colorGradients.splice(o, 1);
  80590. break
  80591. }
  80592. o++
  80593. }
  80594. return this
  80595. }
  80596. ,
  80597. e.prototype.resetDrawCache = function() {
  80598. for (var i = 0, o = this._drawWrappers; i < o.length; i++) {
  80599. var s = o[i];
  80600. if (s)
  80601. for (var c = 0, d = s; c < d.length; c++) {
  80602. var _ = d[c];
  80603. _ == null || _.dispose()
  80604. }
  80605. }
  80606. this._drawWrappers = []
  80607. }
  80608. ,
  80609. e.prototype._fetchR = function(i, o, s, c, d) {
  80610. i = Math.abs(i) * .5 + .5,
  80611. o = Math.abs(o) * .5 + .5;
  80612. var _ = i * s % s | 0
  80613. , b = o * c % c | 0
  80614. , k = (_ + b * s) * 4;
  80615. return d[k] / 255
  80616. }
  80617. ,
  80618. e.prototype._reset = function() {
  80619. this._resetEffect()
  80620. }
  80621. ,
  80622. e.prototype._resetEffect = function() {
  80623. this._vertexBuffer && (this._vertexBuffer.dispose(),
  80624. this._vertexBuffer = null),
  80625. this._spriteBuffer && (this._spriteBuffer.dispose(),
  80626. this._spriteBuffer = null),
  80627. this._vertexArrayObject && (this._engine.releaseVertexArrayObject(this._vertexArrayObject),
  80628. this._vertexArrayObject = null),
  80629. this._createVertexBuffers()
  80630. }
  80631. ,
  80632. e.prototype._createVertexBuffers = function() {
  80633. this._vertexBufferSize = this._useInstancing ? 10 : 12,
  80634. this._isAnimationSheetEnabled && (this._vertexBufferSize += 1),
  80635. (!this._isBillboardBased || this.billboardMode === e.BILLBOARDMODE_STRETCHED) && (this._vertexBufferSize += 3),
  80636. this._useRampGradients && (this._vertexBufferSize += 4);
  80637. var i = this._engine;
  80638. this._vertexData = new Float32Array(this._capacity * this._vertexBufferSize * (this._useInstancing ? 1 : 4)),
  80639. this._vertexBuffer = new Buffer(i,this._vertexData,!0,this._vertexBufferSize);
  80640. var o = 0
  80641. , s = this._vertexBuffer.createVertexBuffer(VertexBuffer.PositionKind, o, 3, this._vertexBufferSize, this._useInstancing);
  80642. this._vertexBuffers[VertexBuffer.PositionKind] = s,
  80643. o += 3;
  80644. var c = this._vertexBuffer.createVertexBuffer(VertexBuffer.ColorKind, o, 4, this._vertexBufferSize, this._useInstancing);
  80645. this._vertexBuffers[VertexBuffer.ColorKind] = c,
  80646. o += 4;
  80647. var d = this._vertexBuffer.createVertexBuffer("angle", o, 1, this._vertexBufferSize, this._useInstancing);
  80648. this._vertexBuffers.angle = d,
  80649. o += 1;
  80650. var _ = this._vertexBuffer.createVertexBuffer("size", o, 2, this._vertexBufferSize, this._useInstancing);
  80651. if (this._vertexBuffers.size = _,
  80652. o += 2,
  80653. this._isAnimationSheetEnabled) {
  80654. var b = this._vertexBuffer.createVertexBuffer("cellIndex", o, 1, this._vertexBufferSize, this._useInstancing);
  80655. this._vertexBuffers.cellIndex = b,
  80656. o += 1
  80657. }
  80658. if (!this._isBillboardBased || this.billboardMode === e.BILLBOARDMODE_STRETCHED) {
  80659. var k = this._vertexBuffer.createVertexBuffer("direction", o, 3, this._vertexBufferSize, this._useInstancing);
  80660. this._vertexBuffers.direction = k,
  80661. o += 3
  80662. }
  80663. if (this._useRampGradients) {
  80664. var j = this._vertexBuffer.createVertexBuffer("remapData", o, 4, this._vertexBufferSize, this._useInstancing);
  80665. this._vertexBuffers.remapData = j,
  80666. o += 4
  80667. }
  80668. var $;
  80669. if (this._useInstancing) {
  80670. var _e = new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]);
  80671. this._spriteBuffer = new Buffer(i,_e,!1,2),
  80672. $ = this._spriteBuffer.createVertexBuffer("offset", 0, 2)
  80673. } else
  80674. $ = this._vertexBuffer.createVertexBuffer("offset", o, 2, this._vertexBufferSize, this._useInstancing),
  80675. o += 2;
  80676. this._vertexBuffers.offset = $,
  80677. this.resetDrawCache()
  80678. }
  80679. ,
  80680. e.prototype._createIndexBuffer = function() {
  80681. if (!this._useInstancing) {
  80682. for (var i = [], o = 0, s = 0; s < this._capacity; s++)
  80683. i.push(o),
  80684. i.push(o + 1),
  80685. i.push(o + 2),
  80686. i.push(o),
  80687. i.push(o + 2),
  80688. i.push(o + 3),
  80689. o += 4;
  80690. this._indexBuffer = this._engine.createIndexBuffer(i)
  80691. }
  80692. }
  80693. ,
  80694. e.prototype.getCapacity = function() {
  80695. return this._capacity
  80696. }
  80697. ,
  80698. e.prototype.isAlive = function() {
  80699. return this._alive
  80700. }
  80701. ,
  80702. e.prototype.isStarted = function() {
  80703. return this._started
  80704. }
  80705. ,
  80706. e.prototype._prepareSubEmitterInternalArray = function() {
  80707. var i = this;
  80708. this._subEmitters = new Array,
  80709. this.subEmitters && this.subEmitters.forEach(function(o) {
  80710. o instanceof e ? i._subEmitters.push([new SubEmitter(o)]) : o instanceof SubEmitter ? i._subEmitters.push([o]) : o instanceof Array && i._subEmitters.push(o)
  80711. })
  80712. }
  80713. ,
  80714. e.prototype.start = function(i) {
  80715. var o = this, s;
  80716. if (i === void 0 && (i = this.startDelay),
  80717. !this.targetStopDuration && this._hasTargetStopDurationDependantGradient())
  80718. throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
  80719. if (i) {
  80720. setTimeout(function() {
  80721. o.start(0)
  80722. }, i);
  80723. return
  80724. }
  80725. if (this._prepareSubEmitterInternalArray(),
  80726. this._started = !0,
  80727. this._stopped = !1,
  80728. this._actualFrame = 0,
  80729. this._subEmitters && this._subEmitters.length != 0 && (this.activeSubSystems = new Array),
  80730. this._emitRateGradients && (this._emitRateGradients.length > 0 && (this._currentEmitRateGradient = this._emitRateGradients[0],
  80731. this._currentEmitRate1 = this._currentEmitRateGradient.getFactor(),
  80732. this._currentEmitRate2 = this._currentEmitRate1),
  80733. this._emitRateGradients.length > 1 && (this._currentEmitRate2 = this._emitRateGradients[1].getFactor())),
  80734. this._startSizeGradients && (this._startSizeGradients.length > 0 && (this._currentStartSizeGradient = this._startSizeGradients[0],
  80735. this._currentStartSize1 = this._currentStartSizeGradient.getFactor(),
  80736. this._currentStartSize2 = this._currentStartSize1),
  80737. this._startSizeGradients.length > 1 && (this._currentStartSize2 = this._startSizeGradients[1].getFactor())),
  80738. this.preWarmCycles) {
  80739. ((s = this.emitter) === null || s === void 0 ? void 0 : s.getClassName().indexOf("Mesh")) !== -1 && this.emitter.computeWorldMatrix(!0);
  80740. var c = this.noiseTexture;
  80741. if (c && c.onGeneratedObservable)
  80742. c.onGeneratedObservable.addOnce(function() {
  80743. setTimeout(function() {
  80744. for (var _ = 0; _ < o.preWarmCycles; _++)
  80745. o.animate(!0),
  80746. c.render()
  80747. })
  80748. });
  80749. else
  80750. for (var d = 0; d < this.preWarmCycles; d++)
  80751. this.animate(!0)
  80752. }
  80753. this.beginAnimationOnStart && this.animations && this.animations.length > 0 && this._scene && this._scene.beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop)
  80754. }
  80755. ,
  80756. e.prototype.stop = function(i) {
  80757. i === void 0 && (i = !0),
  80758. !this._stopped && (this.onStoppedObservable.notifyObservers(this),
  80759. this._stopped = !0,
  80760. i && this._stopSubEmitters())
  80761. }
  80762. ,
  80763. e.prototype.reset = function() {
  80764. this._stockParticles = [],
  80765. this._particles = []
  80766. }
  80767. ,
  80768. e.prototype._appendParticleVertex = function(i, o, s, c) {
  80769. var d = i * this._vertexBufferSize;
  80770. if (this._vertexData[d++] = o.position.x + this.worldOffset.x,
  80771. this._vertexData[d++] = o.position.y + this.worldOffset.y,
  80772. this._vertexData[d++] = o.position.z + this.worldOffset.z,
  80773. this._vertexData[d++] = o.color.r,
  80774. this._vertexData[d++] = o.color.g,
  80775. this._vertexData[d++] = o.color.b,
  80776. this._vertexData[d++] = o.color.a,
  80777. this._vertexData[d++] = o.angle,
  80778. this._vertexData[d++] = o.scale.x * o.size,
  80779. this._vertexData[d++] = o.scale.y * o.size,
  80780. this._isAnimationSheetEnabled && (this._vertexData[d++] = o.cellIndex),
  80781. this._isBillboardBased)
  80782. this.billboardMode === e.BILLBOARDMODE_STRETCHED && (this._vertexData[d++] = o.direction.x,
  80783. this._vertexData[d++] = o.direction.y,
  80784. this._vertexData[d++] = o.direction.z);
  80785. else if (o._initialDirection) {
  80786. var _ = o._initialDirection;
  80787. this.isLocal && (Vector3.TransformNormalToRef(_, this._emitterWorldMatrix, TmpVectors.Vector3[0]),
  80788. _ = TmpVectors.Vector3[0]),
  80789. _.x === 0 && _.z === 0 && (_.x = .001),
  80790. this._vertexData[d++] = _.x,
  80791. this._vertexData[d++] = _.y,
  80792. this._vertexData[d++] = _.z
  80793. } else {
  80794. var b = o.direction;
  80795. this.isLocal && (Vector3.TransformNormalToRef(b, this._emitterWorldMatrix, TmpVectors.Vector3[0]),
  80796. b = TmpVectors.Vector3[0]),
  80797. b.x === 0 && b.z === 0 && (b.x = .001),
  80798. this._vertexData[d++] = b.x,
  80799. this._vertexData[d++] = b.y,
  80800. this._vertexData[d++] = b.z
  80801. }
  80802. this._useRampGradients && o.remapData && (this._vertexData[d++] = o.remapData.x,
  80803. this._vertexData[d++] = o.remapData.y,
  80804. this._vertexData[d++] = o.remapData.z,
  80805. this._vertexData[d++] = o.remapData.w),
  80806. this._useInstancing || (this._isAnimationSheetEnabled && (s === 0 ? s = this._epsilon : s === 1 && (s = 1 - this._epsilon),
  80807. c === 0 ? c = this._epsilon : c === 1 && (c = 1 - this._epsilon)),
  80808. this._vertexData[d++] = s,
  80809. this._vertexData[d++] = c)
  80810. }
  80811. ,
  80812. e.prototype._stopSubEmitters = function() {
  80813. !this.activeSubSystems || (this.activeSubSystems.forEach(function(i) {
  80814. i.stop(!0)
  80815. }),
  80816. this.activeSubSystems = new Array)
  80817. }
  80818. ,
  80819. e.prototype._removeFromRoot = function() {
  80820. if (!!this._rootParticleSystem) {
  80821. var i = this._rootParticleSystem.activeSubSystems.indexOf(this);
  80822. i !== -1 && this._rootParticleSystem.activeSubSystems.splice(i, 1),
  80823. this._rootParticleSystem = null
  80824. }
  80825. }
  80826. ,
  80827. e.prototype._update = function(i) {
  80828. var o = this;
  80829. if (this._alive = this._particles.length > 0,
  80830. this.emitter.position) {
  80831. var s = this.emitter;
  80832. this._emitterWorldMatrix = s.getWorldMatrix()
  80833. } else {
  80834. var c = this.emitter;
  80835. this._emitterWorldMatrix = Matrix.Translation(c.x, c.y, c.z)
  80836. }
  80837. this._emitterWorldMatrix.invertToRef(this._emitterInverseWorldMatrix),
  80838. this.updateFunction(this._particles);
  80839. for (var d, _ = function() {
  80840. if (b._particles.length === b._capacity)
  80841. return "break";
  80842. if (d = b._createParticle(),
  80843. b._particles.push(d),
  80844. b.targetStopDuration && b._lifeTimeGradients && b._lifeTimeGradients.length > 0) {
  80845. var _e = Scalar.Clamp(b._actualFrame / b.targetStopDuration);
  80846. GradientHelper.GetCurrentGradient(_e, b._lifeTimeGradients, function(rt, it) {
  80847. var nt = rt
  80848. , ot = it
  80849. , at = nt.getFactor()
  80850. , st = ot.getFactor()
  80851. , ut = (_e - nt.gradient) / (ot.gradient - nt.gradient);
  80852. d.lifeTime = Scalar.Lerp(at, st, ut)
  80853. })
  80854. } else
  80855. d.lifeTime = Scalar.RandomRange(b.minLifeTime, b.maxLifeTime);
  80856. var et = Scalar.RandomRange(b.minEmitPower, b.maxEmitPower);
  80857. if (b.startPositionFunction ? b.startPositionFunction(b._emitterWorldMatrix, d.position, d, b.isLocal) : b.particleEmitterType.startPositionFunction(b._emitterWorldMatrix, d.position, d, b.isLocal),
  80858. b.isLocal && (d._localPosition ? d._localPosition.copyFrom(d.position) : d._localPosition = d.position.clone(),
  80859. Vector3.TransformCoordinatesToRef(d._localPosition, b._emitterWorldMatrix, d.position)),
  80860. b.startDirectionFunction ? b.startDirectionFunction(b._emitterWorldMatrix, d.direction, d, b.isLocal) : b.particleEmitterType.startDirectionFunction(b._emitterWorldMatrix, d.direction, d, b.isLocal, b._emitterInverseWorldMatrix),
  80861. et === 0 ? d._initialDirection ? d._initialDirection.copyFrom(d.direction) : d._initialDirection = d.direction.clone() : d._initialDirection = null,
  80862. d.direction.scaleInPlace(et),
  80863. !b._sizeGradients || b._sizeGradients.length === 0 ? d.size = Scalar.RandomRange(b.minSize, b.maxSize) : (d._currentSizeGradient = b._sizeGradients[0],
  80864. d._currentSize1 = d._currentSizeGradient.getFactor(),
  80865. d.size = d._currentSize1,
  80866. b._sizeGradients.length > 1 ? d._currentSize2 = b._sizeGradients[1].getFactor() : d._currentSize2 = d._currentSize1),
  80867. d.scale.copyFromFloats(Scalar.RandomRange(b.minScaleX, b.maxScaleX), Scalar.RandomRange(b.minScaleY, b.maxScaleY)),
  80868. b._startSizeGradients && b._startSizeGradients[0] && b.targetStopDuration) {
  80869. var tt = b._actualFrame / b.targetStopDuration;
  80870. GradientHelper.GetCurrentGradient(tt, b._startSizeGradients, function(rt, it, nt) {
  80871. rt !== o._currentStartSizeGradient && (o._currentStartSize1 = o._currentStartSize2,
  80872. o._currentStartSize2 = it.getFactor(),
  80873. o._currentStartSizeGradient = rt);
  80874. var ot = Scalar.Lerp(o._currentStartSize1, o._currentStartSize2, nt);
  80875. d.scale.scaleInPlace(ot)
  80876. })
  80877. }
  80878. !b._angularSpeedGradients || b._angularSpeedGradients.length === 0 ? d.angularSpeed = Scalar.RandomRange(b.minAngularSpeed, b.maxAngularSpeed) : (d._currentAngularSpeedGradient = b._angularSpeedGradients[0],
  80879. d.angularSpeed = d._currentAngularSpeedGradient.getFactor(),
  80880. d._currentAngularSpeed1 = d.angularSpeed,
  80881. b._angularSpeedGradients.length > 1 ? d._currentAngularSpeed2 = b._angularSpeedGradients[1].getFactor() : d._currentAngularSpeed2 = d._currentAngularSpeed1),
  80882. d.angle = Scalar.RandomRange(b.minInitialRotation, b.maxInitialRotation),
  80883. b._velocityGradients && b._velocityGradients.length > 0 && (d._currentVelocityGradient = b._velocityGradients[0],
  80884. d._currentVelocity1 = d._currentVelocityGradient.getFactor(),
  80885. b._velocityGradients.length > 1 ? d._currentVelocity2 = b._velocityGradients[1].getFactor() : d._currentVelocity2 = d._currentVelocity1),
  80886. b._limitVelocityGradients && b._limitVelocityGradients.length > 0 && (d._currentLimitVelocityGradient = b._limitVelocityGradients[0],
  80887. d._currentLimitVelocity1 = d._currentLimitVelocityGradient.getFactor(),
  80888. b._limitVelocityGradients.length > 1 ? d._currentLimitVelocity2 = b._limitVelocityGradients[1].getFactor() : d._currentLimitVelocity2 = d._currentLimitVelocity1),
  80889. b._dragGradients && b._dragGradients.length > 0 && (d._currentDragGradient = b._dragGradients[0],
  80890. d._currentDrag1 = d._currentDragGradient.getFactor(),
  80891. b._dragGradients.length > 1 ? d._currentDrag2 = b._dragGradients[1].getFactor() : d._currentDrag2 = d._currentDrag1),
  80892. !b._colorGradients || b._colorGradients.length === 0 ? (k = Scalar.RandomRange(0, 1),
  80893. Color4.LerpToRef(b.color1, b.color2, k, d.color),
  80894. b.colorDead.subtractToRef(d.color, b._colorDiff),
  80895. b._colorDiff.scaleToRef(1 / d.lifeTime, d.colorStep)) : (d._currentColorGradient = b._colorGradients[0],
  80896. d._currentColorGradient.getColorToRef(d.color),
  80897. d._currentColor1.copyFrom(d.color),
  80898. b._colorGradients.length > 1 ? b._colorGradients[1].getColorToRef(d._currentColor2) : d._currentColor2.copyFrom(d.color)),
  80899. b._isAnimationSheetEnabled && (d._initialStartSpriteCellID = b.startSpriteCellID,
  80900. d._initialEndSpriteCellID = b.endSpriteCellID,
  80901. d._initialSpriteCellLoop = b.spriteCellLoop),
  80902. d.direction.addInPlace(b._inheritedVelocityOffset),
  80903. b._useRampGradients && (d.remapData = new Vector4(0,1,0,1)),
  80904. b.noiseTexture && (d._randomNoiseCoordinates1 ? (d._randomNoiseCoordinates1.copyFromFloats(Math.random(), Math.random(), Math.random()),
  80905. d._randomNoiseCoordinates2.copyFromFloats(Math.random(), Math.random(), Math.random())) : (d._randomNoiseCoordinates1 = new Vector3(Math.random(),Math.random(),Math.random()),
  80906. d._randomNoiseCoordinates2 = new Vector3(Math.random(),Math.random(),Math.random()))),
  80907. d._inheritParticleInfoToSubEmitters()
  80908. }, b = this, k, j = 0; j < i; j++) {
  80909. var $ = _();
  80910. if ($ === "break")
  80911. break
  80912. }
  80913. }
  80914. ,
  80915. e._GetAttributeNamesOrOptions = function(i, o, s) {
  80916. i === void 0 && (i = !1),
  80917. o === void 0 && (o = !1),
  80918. s === void 0 && (s = !1);
  80919. var c = [VertexBuffer.PositionKind, VertexBuffer.ColorKind, "angle", "offset", "size"];
  80920. return i && c.push("cellIndex"),
  80921. o || c.push("direction"),
  80922. s && c.push("remapData"),
  80923. c
  80924. }
  80925. ,
  80926. e._GetEffectCreationOptions = function(i) {
  80927. i === void 0 && (i = !1);
  80928. var o = ["invView", "view", "projection", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "textureMask", "translationPivot", "eyePosition"];
  80929. return i && o.push("particlesInfos"),
  80930. o
  80931. }
  80932. ,
  80933. e.prototype.fillDefines = function(i, o) {
  80934. if (this._scene && (this._scene.clipPlane && i.push("#define CLIPPLANE"),
  80935. this._scene.clipPlane2 && i.push("#define CLIPPLANE2"),
  80936. this._scene.clipPlane3 && i.push("#define CLIPPLANE3"),
  80937. this._scene.clipPlane4 && i.push("#define CLIPPLANE4"),
  80938. this._scene.clipPlane5 && i.push("#define CLIPPLANE5"),
  80939. this._scene.clipPlane6 && i.push("#define CLIPPLANE6")),
  80940. this._isAnimationSheetEnabled && i.push("#define ANIMATESHEET"),
  80941. o === e.BLENDMODE_MULTIPLY && i.push("#define BLENDMULTIPLYMODE"),
  80942. this._useRampGradients && i.push("#define RAMPGRADIENT"),
  80943. this._isBillboardBased)
  80944. switch (i.push("#define BILLBOARD"),
  80945. this.billboardMode) {
  80946. case e.BILLBOARDMODE_Y:
  80947. i.push("#define BILLBOARDY");
  80948. break;
  80949. case e.BILLBOARDMODE_STRETCHED:
  80950. i.push("#define BILLBOARDSTRETCHED");
  80951. break;
  80952. case e.BILLBOARDMODE_ALL:
  80953. i.push("#define BILLBOARDMODE_ALL");
  80954. break
  80955. }
  80956. this._imageProcessingConfiguration && (this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines),
  80957. i.push(this._imageProcessingConfigurationDefines.toString()))
  80958. }
  80959. ,
  80960. e.prototype.fillUniformsAttributesAndSamplerNames = function(i, o, s) {
  80961. o.push.apply(o, e._GetAttributeNamesOrOptions(this._isAnimationSheetEnabled, this._isBillboardBased && this.billboardMode !== e.BILLBOARDMODE_STRETCHED, this._useRampGradients)),
  80962. i.push.apply(i, e._GetEffectCreationOptions(this._isAnimationSheetEnabled)),
  80963. s.push("diffuseSampler", "rampSampler"),
  80964. this._imageProcessingConfiguration && (ImageProcessingConfiguration.PrepareUniforms(i, this._imageProcessingConfigurationDefines),
  80965. ImageProcessingConfiguration.PrepareSamplers(s, this._imageProcessingConfigurationDefines))
  80966. }
  80967. ,
  80968. e.prototype._getWrapper = function(i) {
  80969. var o = this._getCustomDrawWrapper(i);
  80970. if (o != null && o.effect)
  80971. return o;
  80972. var s = [];
  80973. this.fillDefines(s, i);
  80974. var c = this._engine._features.supportRenderPasses ? this._engine.currentRenderPassId : 0
  80975. , d = this._drawWrappers[c];
  80976. d || (d = this._drawWrappers[c] = []);
  80977. var _ = d[i];
  80978. _ || (_ = new DrawWrapper(this._engine),
  80979. _.drawContext && (_.drawContext.useInstancing = this._useInstancing),
  80980. d[i] = _);
  80981. var b = s.join(`
  80982. `);
  80983. if (_.defines !== b) {
  80984. var k = []
  80985. , j = []
  80986. , $ = [];
  80987. this.fillUniformsAttributesAndSamplerNames(j, k, $),
  80988. _.setEffect(this._engine.createEffect("particles", k, j, $, b), b)
  80989. }
  80990. return _
  80991. }
  80992. ,
  80993. e.prototype.animate = function(i) {
  80994. var o = this, s;
  80995. if (i === void 0 && (i = !1),
  80996. !!this._started) {
  80997. if (!i && this._scene) {
  80998. if (!this.isReady() || this._currentRenderId === this._scene.getFrameId())
  80999. return;
  81000. this._currentRenderId = this._scene.getFrameId()
  81001. }
  81002. this._scaledUpdateSpeed = this.updateSpeed * (i ? this.preWarmStepOffset : ((s = this._scene) === null || s === void 0 ? void 0 : s.getAnimationRatio()) || 1);
  81003. var c;
  81004. if (this.manualEmitCount > -1)
  81005. c = this.manualEmitCount,
  81006. this._newPartsExcess = 0,
  81007. this.manualEmitCount = 0;
  81008. else {
  81009. var d = this.emitRate;
  81010. if (this._emitRateGradients && this._emitRateGradients.length > 0 && this.targetStopDuration) {
  81011. var _ = this._actualFrame / this.targetStopDuration;
  81012. GradientHelper.GetCurrentGradient(_, this._emitRateGradients, function($, _e, et) {
  81013. $ !== o._currentEmitRateGradient && (o._currentEmitRate1 = o._currentEmitRate2,
  81014. o._currentEmitRate2 = _e.getFactor(),
  81015. o._currentEmitRateGradient = $),
  81016. d = Scalar.Lerp(o._currentEmitRate1, o._currentEmitRate2, et)
  81017. })
  81018. }
  81019. c = d * this._scaledUpdateSpeed >> 0,
  81020. this._newPartsExcess += d * this._scaledUpdateSpeed - c
  81021. }
  81022. if (this._newPartsExcess > 1 && (c += this._newPartsExcess >> 0,
  81023. this._newPartsExcess -= this._newPartsExcess >> 0),
  81024. this._alive = !1,
  81025. this._stopped ? c = 0 : (this._actualFrame += this._scaledUpdateSpeed,
  81026. this.targetStopDuration && this._actualFrame >= this.targetStopDuration && this.stop()),
  81027. this._update(c),
  81028. this._stopped && (this._alive || (this._started = !1,
  81029. this.onAnimationEnd && this.onAnimationEnd(),
  81030. this.disposeOnStop && this._scene && this._scene._toBeDisposed.push(this))),
  81031. !i) {
  81032. for (var b = 0, k = 0; k < this._particles.length; k++) {
  81033. var j = this._particles[k];
  81034. this._appendParticleVertices(b, j),
  81035. b += this._useInstancing ? 1 : 4
  81036. }
  81037. this._vertexBuffer && this._vertexBuffer.updateDirectly(this._vertexData, 0, this._particles.length)
  81038. }
  81039. this.manualEmitCount === 0 && this.disposeOnStop && this.stop()
  81040. }
  81041. }
  81042. ,
  81043. e.prototype._appendParticleVertices = function(i, o) {
  81044. this._appendParticleVertex(i++, o, 0, 0),
  81045. this._useInstancing || (this._appendParticleVertex(i++, o, 1, 0),
  81046. this._appendParticleVertex(i++, o, 1, 1),
  81047. this._appendParticleVertex(i++, o, 0, 1))
  81048. }
  81049. ,
  81050. e.prototype.rebuild = function() {
  81051. var i, o;
  81052. this._engine.getCaps().vertexArrayObject && (this._vertexArrayObject = null),
  81053. this._createIndexBuffer(),
  81054. (i = this._spriteBuffer) === null || i === void 0 || i._rebuild(),
  81055. (o = this._vertexBuffer) === null || o === void 0 || o._rebuild();
  81056. for (var s in this._vertexBuffers)
  81057. this._vertexBuffers[s]._rebuild();
  81058. this.resetDrawCache()
  81059. }
  81060. ,
  81061. e.prototype.isReady = function() {
  81062. if (!this.emitter || this._imageProcessingConfiguration && !this._imageProcessingConfiguration.isReady() || !this.particleTexture || !this.particleTexture.isReady())
  81063. return !1;
  81064. if (this.blendMode !== e.BLENDMODE_MULTIPLYADD) {
  81065. if (!this._getWrapper(this.blendMode).effect.isReady())
  81066. return !1
  81067. } else if (!this._getWrapper(e.BLENDMODE_MULTIPLY).effect.isReady() || !this._getWrapper(e.BLENDMODE_ADD).effect.isReady())
  81068. return !1;
  81069. return !0
  81070. }
  81071. ,
  81072. e.prototype._render = function(i) {
  81073. var o, s, c = this._getWrapper(i), d = c.effect, _ = this._engine;
  81074. _.enableEffect(c);
  81075. var b = (o = this.defaultViewMatrix) !== null && o !== void 0 ? o : this._scene.getViewMatrix();
  81076. if (d.setTexture("diffuseSampler", this.particleTexture),
  81077. d.setMatrix("view", b),
  81078. d.setMatrix("projection", (s = this.defaultProjectionMatrix) !== null && s !== void 0 ? s : this._scene.getProjectionMatrix()),
  81079. this._isAnimationSheetEnabled && this.particleTexture) {
  81080. var k = this.particleTexture.getBaseSize();
  81081. d.setFloat3("particlesInfos", this.spriteCellWidth / k.width, this.spriteCellHeight / k.height, this.spriteCellWidth / k.width)
  81082. }
  81083. if (d.setVector2("translationPivot", this.translationPivot),
  81084. d.setFloat4("textureMask", this.textureMask.r, this.textureMask.g, this.textureMask.b, this.textureMask.a),
  81085. this._isBillboardBased && this._scene) {
  81086. var j = this._scene.activeCamera;
  81087. d.setVector3("eyePosition", j.globalPosition)
  81088. }
  81089. this._rampGradientsTexture && ((!this._rampGradients || !this._rampGradients.length) && (this._rampGradientsTexture.dispose(),
  81090. this._rampGradientsTexture = null),
  81091. d.setTexture("rampSampler", this._rampGradientsTexture));
  81092. var $ = d.defines;
  81093. switch (this._scene && (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4 || this._scene.clipPlane5 || this._scene.clipPlane6) && ThinMaterialHelper.BindClipPlane(d, this._scene),
  81094. $.indexOf("#define BILLBOARDMODE_ALL") >= 0 && (b.invertToRef(TmpVectors.Matrix[0]),
  81095. d.setMatrix("invView", TmpVectors.Matrix[0])),
  81096. this._vertexArrayObject !== void 0 ? (this._vertexArrayObject || (this._vertexArrayObject = this._engine.recordVertexArrayObject(this._vertexBuffers, this._indexBuffer, d)),
  81097. this._engine.bindVertexArrayObject(this._vertexArrayObject, this._indexBuffer)) : _.bindBuffers(this._vertexBuffers, this._indexBuffer, d),
  81098. this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess && this._imageProcessingConfiguration.bind(d),
  81099. i) {
  81100. case e.BLENDMODE_ADD:
  81101. _.setAlphaMode(1);
  81102. break;
  81103. case e.BLENDMODE_ONEONE:
  81104. _.setAlphaMode(6);
  81105. break;
  81106. case e.BLENDMODE_STANDARD:
  81107. _.setAlphaMode(2);
  81108. break;
  81109. case e.BLENDMODE_MULTIPLY:
  81110. _.setAlphaMode(4);
  81111. break
  81112. }
  81113. return this._onBeforeDrawParticlesObservable && this._onBeforeDrawParticlesObservable.notifyObservers(d),
  81114. this._useInstancing ? _.drawArraysType(7, 0, 4, this._particles.length) : _.drawElementsType(0, 0, this._particles.length * 6),
  81115. this._particles.length
  81116. }
  81117. ,
  81118. e.prototype.render = function() {
  81119. if (!this.isReady() || !this._particles.length)
  81120. return 0;
  81121. var i = this._engine;
  81122. i.setState && (i.setState(!1),
  81123. this.forceDepthWrite && i.setDepthWrite(!0));
  81124. var o = 0;
  81125. return this.blendMode === e.BLENDMODE_MULTIPLYADD ? o = this._render(e.BLENDMODE_MULTIPLY) + this._render(e.BLENDMODE_ADD) : o = this._render(this.blendMode),
  81126. this._engine.unbindInstanceAttributes(),
  81127. this._engine.setAlphaMode(0),
  81128. o
  81129. }
  81130. ,
  81131. e.prototype.dispose = function(i) {
  81132. if (i === void 0 && (i = !0),
  81133. this.resetDrawCache(),
  81134. this._vertexBuffer && (this._vertexBuffer.dispose(),
  81135. this._vertexBuffer = null),
  81136. this._spriteBuffer && (this._spriteBuffer.dispose(),
  81137. this._spriteBuffer = null),
  81138. this._indexBuffer && (this._engine._releaseBuffer(this._indexBuffer),
  81139. this._indexBuffer = null),
  81140. this._vertexArrayObject && (this._engine.releaseVertexArrayObject(this._vertexArrayObject),
  81141. this._vertexArrayObject = null),
  81142. i && this.particleTexture && (this.particleTexture.dispose(),
  81143. this.particleTexture = null),
  81144. i && this.noiseTexture && (this.noiseTexture.dispose(),
  81145. this.noiseTexture = null),
  81146. this._rampGradientsTexture && (this._rampGradientsTexture.dispose(),
  81147. this._rampGradientsTexture = null),
  81148. this._removeFromRoot(),
  81149. this._subEmitters && this._subEmitters.length) {
  81150. for (var o = 0; o < this._subEmitters.length; o++)
  81151. for (var s = 0, c = this._subEmitters[o]; s < c.length; s++) {
  81152. var d = c[s];
  81153. d.dispose()
  81154. }
  81155. this._subEmitters = [],
  81156. this.subEmitters = []
  81157. }
  81158. if (this._disposeEmitterOnDispose && this.emitter && this.emitter.dispose && this.emitter.dispose(!0),
  81159. this._onBeforeDrawParticlesObservable && this._onBeforeDrawParticlesObservable.clear(),
  81160. this._scene) {
  81161. var o = this._scene.particleSystems.indexOf(this);
  81162. o > -1 && this._scene.particleSystems.splice(o, 1),
  81163. this._scene._activeParticleSystems.dispose()
  81164. }
  81165. this.onDisposeObservable.notifyObservers(this),
  81166. this.onDisposeObservable.clear(),
  81167. this.onStoppedObservable.clear(),
  81168. this.reset()
  81169. }
  81170. ,
  81171. e.prototype.clone = function(i, o) {
  81172. var s = __assign({}, this._customWrappers)
  81173. , c = null
  81174. , d = this._engine;
  81175. if (d.createEffectForParticles && this.customShader != null) {
  81176. c = this.customShader;
  81177. var _ = c.shaderOptions.defines.length > 0 ? c.shaderOptions.defines.join(`
  81178. `) : "";
  81179. s[0] = d.createEffectForParticles(c.shaderPath.fragmentElement, c.shaderOptions.uniforms, c.shaderOptions.samplers, _)
  81180. }
  81181. var b = this.serialize()
  81182. , k = e.Parse(b, this._scene || this._engine, this._rootUrl);
  81183. return k.name = i,
  81184. k.customShader = c,
  81185. k._customWrappers = s,
  81186. o === void 0 && (o = this.emitter),
  81187. this.noiseTexture && (k.noiseTexture = this.noiseTexture.clone()),
  81188. k.emitter = o,
  81189. this.preventAutoStart || k.start(),
  81190. k
  81191. }
  81192. ,
  81193. e.prototype.serialize = function(i) {
  81194. i === void 0 && (i = !1);
  81195. var o = {};
  81196. if (e._Serialize(o, this, i),
  81197. o.textureMask = this.textureMask.asArray(),
  81198. o.customShader = this.customShader,
  81199. o.preventAutoStart = this.preventAutoStart,
  81200. this.subEmitters) {
  81201. o.subEmitters = [],
  81202. this._subEmitters || this._prepareSubEmitterInternalArray();
  81203. for (var s = 0, c = this._subEmitters; s < c.length; s++) {
  81204. for (var d = c[s], _ = [], b = 0, k = d; b < k.length; b++) {
  81205. var j = k[b];
  81206. _.push(j.serialize(i))
  81207. }
  81208. o.subEmitters.push(_)
  81209. }
  81210. }
  81211. return o
  81212. }
  81213. ,
  81214. e._Serialize = function(i, o, s) {
  81215. if (i.name = o.name,
  81216. i.id = o.id,
  81217. i.capacity = o.getCapacity(),
  81218. i.disposeOnStop = o.disposeOnStop,
  81219. i.manualEmitCount = o.manualEmitCount,
  81220. o.emitter.position) {
  81221. var c = o.emitter;
  81222. i.emitterId = c.id
  81223. } else {
  81224. var d = o.emitter;
  81225. i.emitter = d.asArray()
  81226. }
  81227. o.particleEmitterType && (i.particleEmitterType = o.particleEmitterType.serialize()),
  81228. o.particleTexture && (s ? i.texture = o.particleTexture.serialize() : (i.textureName = o.particleTexture.name,
  81229. i.invertY = !!o.particleTexture._invertY)),
  81230. i.isLocal = o.isLocal,
  81231. SerializationHelper.AppendSerializedAnimations(o, i),
  81232. i.beginAnimationOnStart = o.beginAnimationOnStart,
  81233. i.beginAnimationFrom = o.beginAnimationFrom,
  81234. i.beginAnimationTo = o.beginAnimationTo,
  81235. i.beginAnimationLoop = o.beginAnimationLoop,
  81236. i.startDelay = o.startDelay,
  81237. i.renderingGroupId = o.renderingGroupId,
  81238. i.isBillboardBased = o.isBillboardBased,
  81239. i.billboardMode = o.billboardMode,
  81240. i.minAngularSpeed = o.minAngularSpeed,
  81241. i.maxAngularSpeed = o.maxAngularSpeed,
  81242. i.minSize = o.minSize,
  81243. i.maxSize = o.maxSize,
  81244. i.minScaleX = o.minScaleX,
  81245. i.maxScaleX = o.maxScaleX,
  81246. i.minScaleY = o.minScaleY,
  81247. i.maxScaleY = o.maxScaleY,
  81248. i.minEmitPower = o.minEmitPower,
  81249. i.maxEmitPower = o.maxEmitPower,
  81250. i.minLifeTime = o.minLifeTime,
  81251. i.maxLifeTime = o.maxLifeTime,
  81252. i.emitRate = o.emitRate,
  81253. i.gravity = o.gravity.asArray(),
  81254. i.noiseStrength = o.noiseStrength.asArray(),
  81255. i.color1 = o.color1.asArray(),
  81256. i.color2 = o.color2.asArray(),
  81257. i.colorDead = o.colorDead.asArray(),
  81258. i.updateSpeed = o.updateSpeed,
  81259. i.targetStopDuration = o.targetStopDuration,
  81260. i.blendMode = o.blendMode,
  81261. i.preWarmCycles = o.preWarmCycles,
  81262. i.preWarmStepOffset = o.preWarmStepOffset,
  81263. i.minInitialRotation = o.minInitialRotation,
  81264. i.maxInitialRotation = o.maxInitialRotation,
  81265. i.startSpriteCellID = o.startSpriteCellID,
  81266. i.spriteCellLoop = o.spriteCellLoop,
  81267. i.endSpriteCellID = o.endSpriteCellID,
  81268. i.spriteCellChangeSpeed = o.spriteCellChangeSpeed,
  81269. i.spriteCellWidth = o.spriteCellWidth,
  81270. i.spriteCellHeight = o.spriteCellHeight,
  81271. i.spriteRandomStartCell = o.spriteRandomStartCell,
  81272. i.isAnimationSheetEnabled = o.isAnimationSheetEnabled;
  81273. var _ = o.getColorGradients();
  81274. if (_) {
  81275. i.colorGradients = [];
  81276. for (var b = 0, k = _; b < k.length; b++) {
  81277. var j = k[b]
  81278. , $ = {
  81279. gradient: j.gradient,
  81280. color1: j.color1.asArray()
  81281. };
  81282. j.color2 ? $.color2 = j.color2.asArray() : $.color2 = j.color1.asArray(),
  81283. i.colorGradients.push($)
  81284. }
  81285. }
  81286. var _e = o.getRampGradients();
  81287. if (_e) {
  81288. i.rampGradients = [];
  81289. for (var et = 0, tt = _e; et < tt.length; et++) {
  81290. var rt = tt[et]
  81291. , $ = {
  81292. gradient: rt.gradient,
  81293. color: rt.color.asArray()
  81294. };
  81295. i.rampGradients.push($)
  81296. }
  81297. i.useRampGradients = o.useRampGradients
  81298. }
  81299. var it = o.getColorRemapGradients();
  81300. if (it) {
  81301. i.colorRemapGradients = [];
  81302. for (var nt = 0, ot = it; nt < ot.length; nt++) {
  81303. var at = ot[nt]
  81304. , $ = {
  81305. gradient: at.gradient,
  81306. factor1: at.factor1
  81307. };
  81308. at.factor2 !== void 0 ? $.factor2 = at.factor2 : $.factor2 = at.factor1,
  81309. i.colorRemapGradients.push($)
  81310. }
  81311. }
  81312. var st = o.getAlphaRemapGradients();
  81313. if (st) {
  81314. i.alphaRemapGradients = [];
  81315. for (var ut = 0, ct = st; ut < ct.length; ut++) {
  81316. var lt = ct[ut]
  81317. , $ = {
  81318. gradient: lt.gradient,
  81319. factor1: lt.factor1
  81320. };
  81321. lt.factor2 !== void 0 ? $.factor2 = lt.factor2 : $.factor2 = lt.factor1,
  81322. i.alphaRemapGradients.push($)
  81323. }
  81324. }
  81325. var ft = o.getSizeGradients();
  81326. if (ft) {
  81327. i.sizeGradients = [];
  81328. for (var ht = 0, pt = ft; ht < pt.length; ht++) {
  81329. var dt = pt[ht]
  81330. , $ = {
  81331. gradient: dt.gradient,
  81332. factor1: dt.factor1
  81333. };
  81334. dt.factor2 !== void 0 ? $.factor2 = dt.factor2 : $.factor2 = dt.factor1,
  81335. i.sizeGradients.push($)
  81336. }
  81337. }
  81338. var _t = o.getAngularSpeedGradients();
  81339. if (_t) {
  81340. i.angularSpeedGradients = [];
  81341. for (var mt = 0, vt = _t; mt < vt.length; mt++) {
  81342. var yt = vt[mt]
  81343. , $ = {
  81344. gradient: yt.gradient,
  81345. factor1: yt.factor1
  81346. };
  81347. yt.factor2 !== void 0 ? $.factor2 = yt.factor2 : $.factor2 = yt.factor1,
  81348. i.angularSpeedGradients.push($)
  81349. }
  81350. }
  81351. var Et = o.getVelocityGradients();
  81352. if (Et) {
  81353. i.velocityGradients = [];
  81354. for (var At = 0, gt = Et; At < gt.length; At++) {
  81355. var St = gt[At]
  81356. , $ = {
  81357. gradient: St.gradient,
  81358. factor1: St.factor1
  81359. };
  81360. St.factor2 !== void 0 ? $.factor2 = St.factor2 : $.factor2 = St.factor1,
  81361. i.velocityGradients.push($)
  81362. }
  81363. }
  81364. var xt = o.getDragGradients();
  81365. if (xt) {
  81366. i.dragGradients = [];
  81367. for (var bt = 0, Rt = xt; bt < Rt.length; bt++) {
  81368. var Mt = Rt[bt]
  81369. , $ = {
  81370. gradient: Mt.gradient,
  81371. factor1: Mt.factor1
  81372. };
  81373. Mt.factor2 !== void 0 ? $.factor2 = Mt.factor2 : $.factor2 = Mt.factor1,
  81374. i.dragGradients.push($)
  81375. }
  81376. }
  81377. var Pt = o.getEmitRateGradients();
  81378. if (Pt) {
  81379. i.emitRateGradients = [];
  81380. for (var It = 0, Dt = Pt; It < Dt.length; It++) {
  81381. var Ct = Dt[It]
  81382. , $ = {
  81383. gradient: Ct.gradient,
  81384. factor1: Ct.factor1
  81385. };
  81386. Ct.factor2 !== void 0 ? $.factor2 = Ct.factor2 : $.factor2 = Ct.factor1,
  81387. i.emitRateGradients.push($)
  81388. }
  81389. }
  81390. var Ot = o.getStartSizeGradients();
  81391. if (Ot) {
  81392. i.startSizeGradients = [];
  81393. for (var wt = 0, Nt = Ot; wt < Nt.length; wt++) {
  81394. var Ft = Nt[wt]
  81395. , $ = {
  81396. gradient: Ft.gradient,
  81397. factor1: Ft.factor1
  81398. };
  81399. Ft.factor2 !== void 0 ? $.factor2 = Ft.factor2 : $.factor2 = Ft.factor1,
  81400. i.startSizeGradients.push($)
  81401. }
  81402. }
  81403. var Vt = o.getLifeTimeGradients();
  81404. if (Vt) {
  81405. i.lifeTimeGradients = [];
  81406. for (var Lt = 0, kt = Vt; Lt < kt.length; Lt++) {
  81407. var Bt = kt[Lt]
  81408. , $ = {
  81409. gradient: Bt.gradient,
  81410. factor1: Bt.factor1
  81411. };
  81412. Bt.factor2 !== void 0 ? $.factor2 = Bt.factor2 : $.factor2 = Bt.factor1,
  81413. i.lifeTimeGradients.push($)
  81414. }
  81415. }
  81416. var Ut = o.getLimitVelocityGradients();
  81417. if (Ut) {
  81418. i.limitVelocityGradients = [];
  81419. for (var Gt = 0, Ht = Ut; Gt < Ht.length; Gt++) {
  81420. var zt = Ht[Gt]
  81421. , $ = {
  81422. gradient: zt.gradient,
  81423. factor1: zt.factor1
  81424. };
  81425. zt.factor2 !== void 0 ? $.factor2 = zt.factor2 : $.factor2 = zt.factor1,
  81426. i.limitVelocityGradients.push($)
  81427. }
  81428. i.limitVelocityDamping = o.limitVelocityDamping
  81429. }
  81430. o.noiseTexture && (i.noiseTexture = o.noiseTexture.serialize())
  81431. }
  81432. ,
  81433. e._Parse = function(i, o, s, c) {
  81434. var d, _, b, k;
  81435. s instanceof ThinEngine ? k = null : k = s;
  81436. var j = GetClass("BABYLON.Texture");
  81437. if (j && k && (i.texture ? o.particleTexture = j.Parse(i.texture, k, c) : i.textureName && (o.particleTexture = new j(c + i.textureName,k,!1,i.invertY !== void 0 ? i.invertY : !0),
  81438. o.particleTexture.name = i.textureName)),
  81439. !i.emitterId && i.emitterId !== 0 && i.emitter === void 0 ? o.emitter = Vector3.Zero() : i.emitterId && k ? o.emitter = k.getLastMeshById(i.emitterId) : o.emitter = Vector3.FromArray(i.emitter),
  81440. o.isLocal = !!i.isLocal,
  81441. i.renderingGroupId !== void 0 && (o.renderingGroupId = i.renderingGroupId),
  81442. i.isBillboardBased !== void 0 && (o.isBillboardBased = i.isBillboardBased),
  81443. i.billboardMode !== void 0 && (o.billboardMode = i.billboardMode),
  81444. i.animations) {
  81445. for (var $ = 0; $ < i.animations.length; $++) {
  81446. var _e = i.animations[$]
  81447. , et = GetClass("BABYLON.Animation");
  81448. et && o.animations.push(et.Parse(_e))
  81449. }
  81450. o.beginAnimationOnStart = i.beginAnimationOnStart,
  81451. o.beginAnimationFrom = i.beginAnimationFrom,
  81452. o.beginAnimationTo = i.beginAnimationTo,
  81453. o.beginAnimationLoop = i.beginAnimationLoop
  81454. }
  81455. if (i.autoAnimate && k && k.beginAnimation(o, i.autoAnimateFrom, i.autoAnimateTo, i.autoAnimateLoop, i.autoAnimateSpeed || 1),
  81456. o.startDelay = i.startDelay | 0,
  81457. o.minAngularSpeed = i.minAngularSpeed,
  81458. o.maxAngularSpeed = i.maxAngularSpeed,
  81459. o.minSize = i.minSize,
  81460. o.maxSize = i.maxSize,
  81461. i.minScaleX && (o.minScaleX = i.minScaleX,
  81462. o.maxScaleX = i.maxScaleX,
  81463. o.minScaleY = i.minScaleY,
  81464. o.maxScaleY = i.maxScaleY),
  81465. i.preWarmCycles !== void 0 && (o.preWarmCycles = i.preWarmCycles,
  81466. o.preWarmStepOffset = i.preWarmStepOffset),
  81467. i.minInitialRotation !== void 0 && (o.minInitialRotation = i.minInitialRotation,
  81468. o.maxInitialRotation = i.maxInitialRotation),
  81469. o.minLifeTime = i.minLifeTime,
  81470. o.maxLifeTime = i.maxLifeTime,
  81471. o.minEmitPower = i.minEmitPower,
  81472. o.maxEmitPower = i.maxEmitPower,
  81473. o.emitRate = i.emitRate,
  81474. o.gravity = Vector3.FromArray(i.gravity),
  81475. i.noiseStrength && (o.noiseStrength = Vector3.FromArray(i.noiseStrength)),
  81476. o.color1 = Color4.FromArray(i.color1),
  81477. o.color2 = Color4.FromArray(i.color2),
  81478. o.colorDead = Color4.FromArray(i.colorDead),
  81479. o.updateSpeed = i.updateSpeed,
  81480. o.targetStopDuration = i.targetStopDuration,
  81481. o.blendMode = i.blendMode,
  81482. i.colorGradients)
  81483. for (var tt = 0, rt = i.colorGradients; tt < rt.length; tt++) {
  81484. var it = rt[tt];
  81485. o.addColorGradient(it.gradient, Color4.FromArray(it.color1), it.color2 ? Color4.FromArray(it.color2) : void 0)
  81486. }
  81487. if (i.rampGradients) {
  81488. for (var nt = 0, ot = i.rampGradients; nt < ot.length; nt++) {
  81489. var at = ot[nt];
  81490. o.addRampGradient(at.gradient, Color3.FromArray(at.color))
  81491. }
  81492. o.useRampGradients = i.useRampGradients
  81493. }
  81494. if (i.colorRemapGradients)
  81495. for (var st = 0, ut = i.colorRemapGradients; st < ut.length; st++) {
  81496. var ct = ut[st];
  81497. o.addColorRemapGradient(ct.gradient, ct.factor1 !== void 0 ? ct.factor1 : ct.factor, ct.factor2)
  81498. }
  81499. if (i.alphaRemapGradients)
  81500. for (var lt = 0, ft = i.alphaRemapGradients; lt < ft.length; lt++) {
  81501. var ht = ft[lt];
  81502. o.addAlphaRemapGradient(ht.gradient, ht.factor1 !== void 0 ? ht.factor1 : ht.factor, ht.factor2)
  81503. }
  81504. if (i.sizeGradients)
  81505. for (var pt = 0, dt = i.sizeGradients; pt < dt.length; pt++) {
  81506. var _t = dt[pt];
  81507. o.addSizeGradient(_t.gradient, _t.factor1 !== void 0 ? _t.factor1 : _t.factor, _t.factor2)
  81508. }
  81509. if (i.angularSpeedGradients)
  81510. for (var mt = 0, vt = i.angularSpeedGradients; mt < vt.length; mt++) {
  81511. var yt = vt[mt];
  81512. o.addAngularSpeedGradient(yt.gradient, yt.factor1 !== void 0 ? yt.factor1 : yt.factor, yt.factor2)
  81513. }
  81514. if (i.velocityGradients)
  81515. for (var Et = 0, At = i.velocityGradients; Et < At.length; Et++) {
  81516. var gt = At[Et];
  81517. o.addVelocityGradient(gt.gradient, gt.factor1 !== void 0 ? gt.factor1 : gt.factor, gt.factor2)
  81518. }
  81519. if (i.dragGradients)
  81520. for (var St = 0, xt = i.dragGradients; St < xt.length; St++) {
  81521. var bt = xt[St];
  81522. o.addDragGradient(bt.gradient, bt.factor1 !== void 0 ? bt.factor1 : bt.factor, bt.factor2)
  81523. }
  81524. if (i.emitRateGradients)
  81525. for (var Rt = 0, Mt = i.emitRateGradients; Rt < Mt.length; Rt++) {
  81526. var Pt = Mt[Rt];
  81527. o.addEmitRateGradient(Pt.gradient, Pt.factor1 !== void 0 ? Pt.factor1 : Pt.factor, Pt.factor2)
  81528. }
  81529. if (i.startSizeGradients)
  81530. for (var It = 0, Dt = i.startSizeGradients; It < Dt.length; It++) {
  81531. var Ct = Dt[It];
  81532. o.addStartSizeGradient(Ct.gradient, Ct.factor1 !== void 0 ? Ct.factor1 : Ct.factor, Ct.factor2)
  81533. }
  81534. if (i.lifeTimeGradients)
  81535. for (var Ot = 0, wt = i.lifeTimeGradients; Ot < wt.length; Ot++) {
  81536. var Nt = wt[Ot];
  81537. o.addLifeTimeGradient(Nt.gradient, Nt.factor1 !== void 0 ? Nt.factor1 : Nt.factor, Nt.factor2)
  81538. }
  81539. if (i.limitVelocityGradients) {
  81540. for (var Ft = 0, Vt = i.limitVelocityGradients; Ft < Vt.length; Ft++) {
  81541. var Lt = Vt[Ft];
  81542. o.addLimitVelocityGradient(Lt.gradient, Lt.factor1 !== void 0 ? Lt.factor1 : Lt.factor, Lt.factor2)
  81543. }
  81544. o.limitVelocityDamping = i.limitVelocityDamping
  81545. }
  81546. if (i.noiseTexture && k) {
  81547. var kt = GetClass("BABYLON.ProceduralTexture");
  81548. o.noiseTexture = kt.Parse(i.noiseTexture, k, c)
  81549. }
  81550. var Bt;
  81551. if (i.particleEmitterType) {
  81552. switch (i.particleEmitterType.type) {
  81553. case "SphereParticleEmitter":
  81554. Bt = new SphereParticleEmitter;
  81555. break;
  81556. case "SphereDirectedParticleEmitter":
  81557. Bt = new SphereDirectedParticleEmitter;
  81558. break;
  81559. case "ConeEmitter":
  81560. case "ConeParticleEmitter":
  81561. Bt = new ConeParticleEmitter;
  81562. break;
  81563. case "CylinderParticleEmitter":
  81564. Bt = new CylinderParticleEmitter;
  81565. break;
  81566. case "CylinderDirectedParticleEmitter":
  81567. Bt = new CylinderDirectedParticleEmitter;
  81568. break;
  81569. case "HemisphericParticleEmitter":
  81570. Bt = new HemisphericParticleEmitter;
  81571. break;
  81572. case "PointParticleEmitter":
  81573. Bt = new PointParticleEmitter;
  81574. break;
  81575. case "MeshParticleEmitter":
  81576. Bt = new MeshParticleEmitter;
  81577. break;
  81578. case "BoxEmitter":
  81579. case "BoxParticleEmitter":
  81580. default:
  81581. Bt = new BoxParticleEmitter;
  81582. break
  81583. }
  81584. Bt.parse(i.particleEmitterType, k)
  81585. } else
  81586. Bt = new BoxParticleEmitter,
  81587. Bt.parse(i, k);
  81588. o.particleEmitterType = Bt,
  81589. o.startSpriteCellID = i.startSpriteCellID,
  81590. o.endSpriteCellID = i.endSpriteCellID,
  81591. o.spriteCellLoop = (d = i.spriteCellLoop) !== null && d !== void 0 ? d : !0,
  81592. o.spriteCellWidth = i.spriteCellWidth,
  81593. o.spriteCellHeight = i.spriteCellHeight,
  81594. o.spriteCellChangeSpeed = i.spriteCellChangeSpeed,
  81595. o.spriteRandomStartCell = i.spriteRandomStartCell,
  81596. o.disposeOnStop = (_ = i.disposeOnStop) !== null && _ !== void 0 ? _ : !1,
  81597. o.manualEmitCount = (b = i.manualEmitCount) !== null && b !== void 0 ? b : -1
  81598. }
  81599. ,
  81600. e.Parse = function(i, o, s, c, d) {
  81601. c === void 0 && (c = !1);
  81602. var _ = i.name, b = null, k = null, j, $;
  81603. if (o instanceof ThinEngine ? j = o : ($ = o,
  81604. j = $.getEngine()),
  81605. i.customShader && j.createEffectForParticles) {
  81606. k = i.customShader;
  81607. var _e = k.shaderOptions.defines.length > 0 ? k.shaderOptions.defines.join(`
  81608. `) : "";
  81609. b = j.createEffectForParticles(k.shaderPath.fragmentElement, k.shaderOptions.uniforms, k.shaderOptions.samplers, _e)
  81610. }
  81611. var et = new e(_,d || i.capacity,o,b,i.isAnimationSheetEnabled);
  81612. if (et.customShader = k,
  81613. et._rootUrl = s,
  81614. i.id && (et.id = i.id),
  81615. i.subEmitters) {
  81616. et.subEmitters = [];
  81617. for (var tt = 0, rt = i.subEmitters; tt < rt.length; tt++) {
  81618. for (var it = rt[tt], nt = [], ot = 0, at = it; ot < at.length; ot++) {
  81619. var st = at[ot];
  81620. nt.push(SubEmitter.Parse(st, o, s))
  81621. }
  81622. et.subEmitters.push(nt)
  81623. }
  81624. }
  81625. return e._Parse(i, et, o, s),
  81626. i.textureMask && (et.textureMask = Color4.FromArray(i.textureMask)),
  81627. i.preventAutoStart && (et.preventAutoStart = i.preventAutoStart),
  81628. !c && !et.preventAutoStart && et.start(),
  81629. et
  81630. }
  81631. ,
  81632. e.BILLBOARDMODE_Y = 2,
  81633. e.BILLBOARDMODE_ALL = 7,
  81634. e.BILLBOARDMODE_STRETCHED = 8,
  81635. e
  81636. }(BaseParticleSystem);
  81637. SubEmitter._ParseParticleSystem = ParticleSystem.Parse;
  81638. var name$1k = "clipPlaneFragmentDeclaration2"
  81639. , shader$1k = `#ifdef CLIPPLANE
  81640. in float fClipDistance;
  81641. #endif
  81642. #ifdef CLIPPLANE2
  81643. in float fClipDistance2;
  81644. #endif
  81645. #ifdef CLIPPLANE3
  81646. in float fClipDistance3;
  81647. #endif
  81648. #ifdef CLIPPLANE4
  81649. in float fClipDistance4;
  81650. #endif
  81651. #ifdef CLIPPLANE5
  81652. in float fClipDistance5;
  81653. #endif
  81654. #ifdef CLIPPLANE6
  81655. in float fClipDistance6;
  81656. #endif`;
  81657. ShaderStore.IncludesShadersStore[name$1k] = shader$1k;
  81658. var name$1j = "gpuRenderParticlesPixelShader"
  81659. , shader$1j = `precision highp float;
  81660. uniform sampler2D diffuseSampler;
  81661. varying vec2 vUV;
  81662. varying vec4 vColor;
  81663. #include<clipPlaneFragmentDeclaration2>
  81664. #include<imageProcessingDeclaration>
  81665. #include<helperFunctions>
  81666. #include<imageProcessingFunctions>
  81667. void main() {
  81668. #include<clipPlaneFragment>
  81669. vec4 textureColor=texture2D(diffuseSampler,vUV);
  81670. gl_FragColor=textureColor*vColor;
  81671. #ifdef BLENDMULTIPLYMODE
  81672. float alpha=vColor.a*textureColor.a;
  81673. gl_FragColor.rgb=gl_FragColor.rgb*alpha+vec3(1.0)*(1.0-alpha);
  81674. #endif
  81675. #ifdef IMAGEPROCESSINGPOSTPROCESS
  81676. gl_FragColor.rgb=toLinearSpace(gl_FragColor.rgb);
  81677. #else
  81678. #ifdef IMAGEPROCESSING
  81679. gl_FragColor.rgb=toLinearSpace(gl_FragColor.rgb);
  81680. gl_FragColor=applyImageProcessing(gl_FragColor);
  81681. #endif
  81682. #endif
  81683. }
  81684. `;
  81685. ShaderStore.ShadersStore[name$1j] = shader$1j;
  81686. var name$1i = "clipPlaneVertexDeclaration2"
  81687. , shader$1i = `#ifdef CLIPPLANE
  81688. uniform vec4 vClipPlane;
  81689. out float fClipDistance;
  81690. #endif
  81691. #ifdef CLIPPLANE2
  81692. uniform vec4 vClipPlane2;
  81693. out float fClipDistance2;
  81694. #endif
  81695. #ifdef CLIPPLANE3
  81696. uniform vec4 vClipPlane3;
  81697. out float fClipDistance3;
  81698. #endif
  81699. #ifdef CLIPPLANE4
  81700. uniform vec4 vClipPlane4;
  81701. out float fClipDistance4;
  81702. #endif
  81703. #ifdef CLIPPLANE5
  81704. uniform vec4 vClipPlane5;
  81705. out float fClipDistance5;
  81706. #endif
  81707. #ifdef CLIPPLANE6
  81708. uniform vec4 vClipPlane6;
  81709. out float fClipDistance6;
  81710. #endif`;
  81711. ShaderStore.IncludesShadersStore[name$1i] = shader$1i;
  81712. var name$1h = "gpuRenderParticlesVertexShader"
  81713. , shader$1h = `precision highp float;
  81714. uniform mat4 view;
  81715. uniform mat4 projection;
  81716. uniform vec2 translationPivot;
  81717. uniform vec3 worldOffset;
  81718. #ifdef LOCAL
  81719. uniform mat4 emitterWM;
  81720. #endif
  81721. attribute vec3 position;
  81722. attribute float age;
  81723. attribute float life;
  81724. attribute vec3 size;
  81725. #ifndef BILLBOARD
  81726. attribute vec3 initialDirection;
  81727. #endif
  81728. #ifdef BILLBOARDSTRETCHED
  81729. attribute vec3 direction;
  81730. #endif
  81731. attribute float angle;
  81732. #ifdef ANIMATESHEET
  81733. attribute float cellIndex;
  81734. #endif
  81735. attribute vec2 offset;
  81736. attribute vec2 uv;
  81737. varying vec2 vUV;
  81738. varying vec4 vColor;
  81739. varying vec3 vPositionW;
  81740. #if defined(BILLBOARD) && !defined(BILLBOARDY) && !defined(BILLBOARDSTRETCHED)
  81741. uniform mat4 invView;
  81742. #endif
  81743. #include<clipPlaneVertexDeclaration2>
  81744. #ifdef COLORGRADIENTS
  81745. uniform sampler2D colorGradientSampler;
  81746. #else
  81747. uniform vec4 colorDead;
  81748. attribute vec4 color;
  81749. #endif
  81750. #ifdef ANIMATESHEET
  81751. uniform vec3 sheetInfos;
  81752. #endif
  81753. #ifdef BILLBOARD
  81754. uniform vec3 eyePosition;
  81755. #endif
  81756. vec3 rotate(vec3 yaxis,vec3 rotatedCorner) {
  81757. vec3 xaxis=normalize(cross(vec3(0.,1.0,0.),yaxis));
  81758. vec3 zaxis=normalize(cross(yaxis,xaxis));
  81759. vec3 row0=vec3(xaxis.x,xaxis.y,xaxis.z);
  81760. vec3 row1=vec3(yaxis.x,yaxis.y,yaxis.z);
  81761. vec3 row2=vec3(zaxis.x,zaxis.y,zaxis.z);
  81762. mat3 rotMatrix=mat3(row0,row1,row2);
  81763. vec3 alignedCorner=rotMatrix*rotatedCorner;
  81764. #ifdef LOCAL
  81765. return ((emitterWM*vec4(position,1.0)).xyz+worldOffset)+alignedCorner;
  81766. #else
  81767. return (position+worldOffset)+alignedCorner;
  81768. #endif
  81769. }
  81770. #ifdef BILLBOARDSTRETCHED
  81771. vec3 rotateAlign(vec3 toCamera,vec3 rotatedCorner) {
  81772. vec3 normalizedToCamera=normalize(toCamera);
  81773. vec3 normalizedCrossDirToCamera=normalize(cross(normalize(direction),normalizedToCamera));
  81774. vec3 crossProduct=normalize(cross(normalizedToCamera,normalizedCrossDirToCamera));
  81775. vec3 row0=vec3(normalizedCrossDirToCamera.x,normalizedCrossDirToCamera.y,normalizedCrossDirToCamera.z);
  81776. vec3 row1=vec3(crossProduct.x,crossProduct.y,crossProduct.z);
  81777. vec3 row2=vec3(normalizedToCamera.x,normalizedToCamera.y,normalizedToCamera.z);
  81778. mat3 rotMatrix=mat3(row0,row1,row2);
  81779. vec3 alignedCorner=rotMatrix*rotatedCorner;
  81780. #ifdef LOCAL
  81781. return ((emitterWM*vec4(position,1.0)).xyz+worldOffset)+alignedCorner;
  81782. #else
  81783. return (position+worldOffset)+alignedCorner;
  81784. #endif
  81785. }
  81786. #endif
  81787. void main() {
  81788. #ifdef ANIMATESHEET
  81789. float rowOffset=floor(cellIndex/sheetInfos.z);
  81790. float columnOffset=cellIndex-rowOffset*sheetInfos.z;
  81791. vec2 uvScale=sheetInfos.xy;
  81792. vec2 uvOffset=vec2(uv.x ,1.0-uv.y);
  81793. vUV=(uvOffset+vec2(columnOffset,rowOffset))*uvScale;
  81794. #else
  81795. vUV=uv;
  81796. #endif
  81797. float ratio=age/life;
  81798. #ifdef COLORGRADIENTS
  81799. vColor=texture2D(colorGradientSampler,vec2(ratio,0));
  81800. #else
  81801. vColor=color*vec4(1.0-ratio)+colorDead*vec4(ratio);
  81802. #endif
  81803. vec2 cornerPos=(offset-translationPivot)*size.yz*size.x+translationPivot;
  81804. #ifdef BILLBOARD
  81805. vec4 rotatedCorner;
  81806. rotatedCorner.w=0.;
  81807. #ifdef BILLBOARDY
  81808. rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);
  81809. rotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);
  81810. rotatedCorner.y=0.;
  81811. vec3 yaxis=(position+worldOffset)-eyePosition;
  81812. yaxis.y=0.;
  81813. vPositionW=rotate(normalize(yaxis),rotatedCorner.xyz);
  81814. vec4 viewPosition=(view*vec4(vPositionW,1.0));
  81815. #elif defined(BILLBOARDSTRETCHED)
  81816. rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);
  81817. rotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);
  81818. rotatedCorner.z=0.;
  81819. vec3 toCamera=(position+worldOffset)-eyePosition;
  81820. vPositionW=rotateAlign(toCamera,rotatedCorner.xyz);
  81821. vec4 viewPosition=(view*vec4(vPositionW,1.0));
  81822. #else
  81823. rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);
  81824. rotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);
  81825. rotatedCorner.z=0.;
  81826. #ifdef LOCAL
  81827. vec4 viewPosition=view*vec4(((emitterWM*vec4(position,1.0)).xyz+worldOffset),1.0)+rotatedCorner;
  81828. #else
  81829. vec4 viewPosition=view*vec4((position+worldOffset),1.0)+rotatedCorner;
  81830. #endif
  81831. vPositionW=(invView*viewPosition).xyz;
  81832. #endif
  81833. #else
  81834. vec3 rotatedCorner;
  81835. rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);
  81836. rotatedCorner.y=0.;
  81837. rotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);
  81838. vec3 yaxis=normalize(initialDirection);
  81839. vPositionW=rotate(yaxis,rotatedCorner);
  81840. vec4 viewPosition=view*vec4(vPositionW,1.0);
  81841. #endif
  81842. gl_Position=projection*viewPosition;
  81843. #if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)
  81844. vec4 worldPos=vec4(vPositionW,1.0);
  81845. #endif
  81846. #include<clipPlaneVertex>
  81847. }`;
  81848. ShaderStore.ShadersStore[name$1h] = shader$1h;
  81849. var GPUParticleSystem = function(a) {
  81850. __extends(e, a);
  81851. function e(i, o, s, c, d) {
  81852. c === void 0 && (c = null),
  81853. d === void 0 && (d = !1);
  81854. var _ = a.call(this, i) || this;
  81855. if (_.layerMask = 268435455,
  81856. _._accumulatedCount = 0,
  81857. _._targetIndex = 0,
  81858. _._currentRenderId = -1,
  81859. _._currentRenderingCameraUniqueId = -1,
  81860. _._started = !1,
  81861. _._stopped = !1,
  81862. _._timeDelta = 0,
  81863. _._actualFrame = 0,
  81864. _._rawTextureWidth = 256,
  81865. _.onDisposeObservable = new Observable,
  81866. _.onStoppedObservable = new Observable,
  81867. _.forceDepthWrite = !1,
  81868. _._preWarmDone = !1,
  81869. _.isLocal = !1,
  81870. _._onBeforeDrawParticlesObservable = null,
  81871. !s || s.getClassName() === "Scene" ? (_._scene = s || EngineStore.LastCreatedScene,
  81872. _._engine = _._scene.getEngine(),
  81873. _.uniqueId = _._scene.getUniqueId(),
  81874. _._scene.particleSystems.push(_)) : (_._engine = s,
  81875. _.defaultProjectionMatrix = Matrix.PerspectiveFovLH(.8, 1, .1, 100, _._engine.isNDCHalfZRange)),
  81876. _._engine.getCaps().supportComputeShaders) {
  81877. if (!GetClass("BABYLON.ComputeShaderParticleSystem"))
  81878. throw new Error("The ComputeShaderParticleSystem class is not available! Make sure you have imported it.");
  81879. _._platform = new (GetClass("BABYLON.ComputeShaderParticleSystem"))(_,_._engine)
  81880. } else {
  81881. if (!GetClass("BABYLON.WebGL2ParticleSystem"))
  81882. throw new Error("The WebGL2ParticleSystem class is not available! Make sure you have imported it.");
  81883. _._platform = new (GetClass("BABYLON.WebGL2ParticleSystem"))(_,_._engine)
  81884. }
  81885. _._customWrappers = {
  81886. 0: new DrawWrapper(_._engine)
  81887. },
  81888. _._customWrappers[0].effect = c,
  81889. _._drawWrappers = {
  81890. 0: new DrawWrapper(_._engine)
  81891. },
  81892. _._drawWrappers[0].drawContext && (_._drawWrappers[0].drawContext.useInstancing = !0),
  81893. _._attachImageProcessingConfiguration(null),
  81894. o = o != null ? o : {},
  81895. o.randomTextureSize || delete o.randomTextureSize;
  81896. var b = __assign({
  81897. capacity: 5e4,
  81898. randomTextureSize: _._engine.getCaps().maxTextureSize
  81899. }, o)
  81900. , k = o;
  81901. isFinite(k) && (b.capacity = k),
  81902. _._capacity = b.capacity,
  81903. _._activeCount = b.capacity,
  81904. _._currentActiveCount = 0,
  81905. _._isAnimationSheetEnabled = d,
  81906. _.particleEmitterType = new BoxParticleEmitter;
  81907. for (var j = Math.min(_._engine.getCaps().maxTextureSize, b.randomTextureSize), $ = [], _e = 0; _e < j; ++_e)
  81908. $.push(Math.random()),
  81909. $.push(Math.random()),
  81910. $.push(Math.random()),
  81911. $.push(Math.random());
  81912. _._randomTexture = new RawTexture(new Float32Array($),j,1,5,s,!1,!1,1,1),
  81913. _._randomTexture.name = "GPUParticleSystem_random1",
  81914. _._randomTexture.wrapU = 1,
  81915. _._randomTexture.wrapV = 1,
  81916. $ = [];
  81917. for (var _e = 0; _e < j; ++_e)
  81918. $.push(Math.random()),
  81919. $.push(Math.random()),
  81920. $.push(Math.random()),
  81921. $.push(Math.random());
  81922. return _._randomTexture2 = new RawTexture(new Float32Array($),j,1,5,s,!1,!1,1,1),
  81923. _._randomTexture2.name = "GPUParticleSystem_random2",
  81924. _._randomTexture2.wrapU = 1,
  81925. _._randomTexture2.wrapV = 1,
  81926. _._randomTextureSize = j,
  81927. _
  81928. }
  81929. return Object.defineProperty(e, "IsSupported", {
  81930. get: function() {
  81931. return EngineStore.LastCreatedEngine ? EngineStore.LastCreatedEngine.name === "WebGL" && EngineStore.LastCreatedEngine.version > 1 || EngineStore.LastCreatedEngine.getCaps().supportComputeShaders : !1
  81932. },
  81933. enumerable: !1,
  81934. configurable: !0
  81935. }),
  81936. e.prototype.getCapacity = function() {
  81937. return this._capacity
  81938. }
  81939. ,
  81940. Object.defineProperty(e.prototype, "activeParticleCount", {
  81941. get: function() {
  81942. return this._activeCount
  81943. },
  81944. set: function(i) {
  81945. this._activeCount = Math.min(i, this._capacity)
  81946. },
  81947. enumerable: !1,
  81948. configurable: !0
  81949. }),
  81950. e.prototype.isReady = function() {
  81951. if (!this.emitter || this._imageProcessingConfiguration && !this._imageProcessingConfiguration.isReady() || !this.particleTexture || !this.particleTexture.isReady())
  81952. return !1;
  81953. if (this.blendMode !== ParticleSystem.BLENDMODE_MULTIPLYADD) {
  81954. if (!this._getWrapper(this.blendMode).effect.isReady())
  81955. return !1
  81956. } else if (!this._getWrapper(ParticleSystem.BLENDMODE_MULTIPLY).effect.isReady() || !this._getWrapper(ParticleSystem.BLENDMODE_ADD).effect.isReady())
  81957. return !1;
  81958. return this._platform.isUpdateBufferCreated() ? this._platform.isUpdateBufferReady() : (this._recreateUpdateEffect(),
  81959. !1)
  81960. }
  81961. ,
  81962. e.prototype.isStarted = function() {
  81963. return this._started
  81964. }
  81965. ,
  81966. e.prototype.isStopped = function() {
  81967. return this._stopped
  81968. }
  81969. ,
  81970. e.prototype.isStopping = function() {
  81971. return !1
  81972. }
  81973. ,
  81974. e.prototype.getActiveCount = function() {
  81975. return this._currentActiveCount
  81976. }
  81977. ,
  81978. e.prototype.start = function(i) {
  81979. var o = this;
  81980. if (i === void 0 && (i = this.startDelay),
  81981. !this.targetStopDuration && this._hasTargetStopDurationDependantGradient())
  81982. throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
  81983. if (i) {
  81984. setTimeout(function() {
  81985. o.start(0)
  81986. }, i);
  81987. return
  81988. }
  81989. this._started = !0,
  81990. this._stopped = !1,
  81991. this._preWarmDone = !1,
  81992. this.beginAnimationOnStart && this.animations && this.animations.length > 0 && this._scene && this._scene.beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop)
  81993. }
  81994. ,
  81995. e.prototype.stop = function() {
  81996. this._stopped || (this._stopped = !0)
  81997. }
  81998. ,
  81999. e.prototype.reset = function() {
  82000. this._releaseBuffers(),
  82001. this._platform.releaseVertexBuffers(),
  82002. this._currentActiveCount = 0,
  82003. this._targetIndex = 0
  82004. }
  82005. ,
  82006. e.prototype.getClassName = function() {
  82007. return "GPUParticleSystem"
  82008. }
  82009. ,
  82010. e.prototype.getCustomEffect = function(i) {
  82011. var o, s;
  82012. return i === void 0 && (i = 0),
  82013. (s = (o = this._customWrappers[i]) === null || o === void 0 ? void 0 : o.effect) !== null && s !== void 0 ? s : this._customWrappers[0].effect
  82014. }
  82015. ,
  82016. e.prototype._getCustomDrawWrapper = function(i) {
  82017. var o;
  82018. return i === void 0 && (i = 0),
  82019. (o = this._customWrappers[i]) !== null && o !== void 0 ? o : this._customWrappers[0]
  82020. }
  82021. ,
  82022. e.prototype.setCustomEffect = function(i, o) {
  82023. o === void 0 && (o = 0),
  82024. this._customWrappers[o] = new DrawWrapper(this._engine),
  82025. this._customWrappers[o].effect = i
  82026. }
  82027. ,
  82028. Object.defineProperty(e.prototype, "onBeforeDrawParticlesObservable", {
  82029. get: function() {
  82030. return this._onBeforeDrawParticlesObservable || (this._onBeforeDrawParticlesObservable = new Observable),
  82031. this._onBeforeDrawParticlesObservable
  82032. },
  82033. enumerable: !1,
  82034. configurable: !0
  82035. }),
  82036. Object.defineProperty(e.prototype, "vertexShaderName", {
  82037. get: function() {
  82038. return "gpuRenderParticles"
  82039. },
  82040. enumerable: !1,
  82041. configurable: !0
  82042. }),
  82043. e.prototype._removeGradientAndTexture = function(i, o, s) {
  82044. return a.prototype._removeGradientAndTexture.call(this, i, o, s),
  82045. this._releaseBuffers(),
  82046. this
  82047. }
  82048. ,
  82049. e.prototype.addColorGradient = function(i, o, s) {
  82050. this._colorGradients || (this._colorGradients = []);
  82051. var c = new ColorGradient(i,o);
  82052. return this._colorGradients.push(c),
  82053. this._refreshColorGradient(!0),
  82054. this._releaseBuffers(),
  82055. this
  82056. }
  82057. ,
  82058. e.prototype._refreshColorGradient = function(i) {
  82059. i === void 0 && (i = !1),
  82060. this._colorGradients && (i && this._colorGradients.sort(function(o, s) {
  82061. return o.gradient < s.gradient ? -1 : o.gradient > s.gradient ? 1 : 0
  82062. }),
  82063. this._colorGradientsTexture && (this._colorGradientsTexture.dispose(),
  82064. this._colorGradientsTexture = null))
  82065. }
  82066. ,
  82067. e.prototype.forceRefreshGradients = function() {
  82068. this._refreshColorGradient(),
  82069. this._refreshFactorGradient(this._sizeGradients, "_sizeGradientsTexture"),
  82070. this._refreshFactorGradient(this._angularSpeedGradients, "_angularSpeedGradientsTexture"),
  82071. this._refreshFactorGradient(this._velocityGradients, "_velocityGradientsTexture"),
  82072. this._refreshFactorGradient(this._limitVelocityGradients, "_limitVelocityGradientsTexture"),
  82073. this._refreshFactorGradient(this._dragGradients, "_dragGradientsTexture"),
  82074. this.reset()
  82075. }
  82076. ,
  82077. e.prototype.removeColorGradient = function(i) {
  82078. return this._removeGradientAndTexture(i, this._colorGradients, this._colorGradientsTexture),
  82079. this._colorGradientsTexture = null,
  82080. this
  82081. }
  82082. ,
  82083. e.prototype.resetDrawCache = function() {
  82084. var i;
  82085. for (var o in this._drawWrappers) {
  82086. var s = this._drawWrappers[o];
  82087. (i = s.drawContext) === null || i === void 0 || i.reset()
  82088. }
  82089. }
  82090. ,
  82091. e.prototype._addFactorGradient = function(i, o, s) {
  82092. var c = new FactorGradient(o,s);
  82093. i.push(c),
  82094. this._releaseBuffers()
  82095. }
  82096. ,
  82097. e.prototype.addSizeGradient = function(i, o) {
  82098. return this._sizeGradients || (this._sizeGradients = []),
  82099. this._addFactorGradient(this._sizeGradients, i, o),
  82100. this._refreshFactorGradient(this._sizeGradients, "_sizeGradientsTexture", !0),
  82101. this._releaseBuffers(),
  82102. this
  82103. }
  82104. ,
  82105. e.prototype.removeSizeGradient = function(i) {
  82106. return this._removeGradientAndTexture(i, this._sizeGradients, this._sizeGradientsTexture),
  82107. this._sizeGradientsTexture = null,
  82108. this
  82109. }
  82110. ,
  82111. e.prototype._refreshFactorGradient = function(i, o, s) {
  82112. if (s === void 0 && (s = !1),
  82113. !!i) {
  82114. s && i.sort(function(d, _) {
  82115. return d.gradient < _.gradient ? -1 : d.gradient > _.gradient ? 1 : 0
  82116. });
  82117. var c = this;
  82118. c[o] && (c[o].dispose(),
  82119. c[o] = null)
  82120. }
  82121. }
  82122. ,
  82123. e.prototype.addAngularSpeedGradient = function(i, o) {
  82124. return this._angularSpeedGradients || (this._angularSpeedGradients = []),
  82125. this._addFactorGradient(this._angularSpeedGradients, i, o),
  82126. this._refreshFactorGradient(this._angularSpeedGradients, "_angularSpeedGradientsTexture", !0),
  82127. this._releaseBuffers(),
  82128. this
  82129. }
  82130. ,
  82131. e.prototype.removeAngularSpeedGradient = function(i) {
  82132. return this._removeGradientAndTexture(i, this._angularSpeedGradients, this._angularSpeedGradientsTexture),
  82133. this._angularSpeedGradientsTexture = null,
  82134. this
  82135. }
  82136. ,
  82137. e.prototype.addVelocityGradient = function(i, o) {
  82138. return this._velocityGradients || (this._velocityGradients = []),
  82139. this._addFactorGradient(this._velocityGradients, i, o),
  82140. this._refreshFactorGradient(this._velocityGradients, "_velocityGradientsTexture", !0),
  82141. this._releaseBuffers(),
  82142. this
  82143. }
  82144. ,
  82145. e.prototype.removeVelocityGradient = function(i) {
  82146. return this._removeGradientAndTexture(i, this._velocityGradients, this._velocityGradientsTexture),
  82147. this._velocityGradientsTexture = null,
  82148. this
  82149. }
  82150. ,
  82151. e.prototype.addLimitVelocityGradient = function(i, o) {
  82152. return this._limitVelocityGradients || (this._limitVelocityGradients = []),
  82153. this._addFactorGradient(this._limitVelocityGradients, i, o),
  82154. this._refreshFactorGradient(this._limitVelocityGradients, "_limitVelocityGradientsTexture", !0),
  82155. this._releaseBuffers(),
  82156. this
  82157. }
  82158. ,
  82159. e.prototype.removeLimitVelocityGradient = function(i) {
  82160. return this._removeGradientAndTexture(i, this._limitVelocityGradients, this._limitVelocityGradientsTexture),
  82161. this._limitVelocityGradientsTexture = null,
  82162. this
  82163. }
  82164. ,
  82165. e.prototype.addDragGradient = function(i, o) {
  82166. return this._dragGradients || (this._dragGradients = []),
  82167. this._addFactorGradient(this._dragGradients, i, o),
  82168. this._refreshFactorGradient(this._dragGradients, "_dragGradientsTexture", !0),
  82169. this._releaseBuffers(),
  82170. this
  82171. }
  82172. ,
  82173. e.prototype.removeDragGradient = function(i) {
  82174. return this._removeGradientAndTexture(i, this._dragGradients, this._dragGradientsTexture),
  82175. this._dragGradientsTexture = null,
  82176. this
  82177. }
  82178. ,
  82179. e.prototype.addEmitRateGradient = function(i, o, s) {
  82180. return this
  82181. }
  82182. ,
  82183. e.prototype.removeEmitRateGradient = function(i) {
  82184. return this
  82185. }
  82186. ,
  82187. e.prototype.addStartSizeGradient = function(i, o, s) {
  82188. return this
  82189. }
  82190. ,
  82191. e.prototype.removeStartSizeGradient = function(i) {
  82192. return this
  82193. }
  82194. ,
  82195. e.prototype.addColorRemapGradient = function(i, o, s) {
  82196. return this
  82197. }
  82198. ,
  82199. e.prototype.removeColorRemapGradient = function() {
  82200. return this
  82201. }
  82202. ,
  82203. e.prototype.addAlphaRemapGradient = function(i, o, s) {
  82204. return this
  82205. }
  82206. ,
  82207. e.prototype.removeAlphaRemapGradient = function() {
  82208. return this
  82209. }
  82210. ,
  82211. e.prototype.addRampGradient = function(i, o) {
  82212. return this
  82213. }
  82214. ,
  82215. e.prototype.removeRampGradient = function() {
  82216. return this
  82217. }
  82218. ,
  82219. e.prototype.getRampGradients = function() {
  82220. return null
  82221. }
  82222. ,
  82223. Object.defineProperty(e.prototype, "useRampGradients", {
  82224. get: function() {
  82225. return !1
  82226. },
  82227. set: function(i) {},
  82228. enumerable: !1,
  82229. configurable: !0
  82230. }),
  82231. e.prototype.addLifeTimeGradient = function(i, o, s) {
  82232. return this
  82233. }
  82234. ,
  82235. e.prototype.removeLifeTimeGradient = function(i) {
  82236. return this
  82237. }
  82238. ,
  82239. e.prototype._reset = function() {
  82240. this._releaseBuffers()
  82241. }
  82242. ,
  82243. e.prototype._createVertexBuffers = function(i, o, s) {
  82244. var c = {};
  82245. c.position = o.createVertexBuffer("position", 0, 3, this._attributesStrideSize, !0);
  82246. var d = 3;
  82247. c.age = o.createVertexBuffer("age", d, 1, this._attributesStrideSize, !0),
  82248. d += 1,
  82249. c.size = o.createVertexBuffer("size", d, 3, this._attributesStrideSize, !0),
  82250. d += 3,
  82251. c.life = o.createVertexBuffer("life", d, 1, this._attributesStrideSize, !0),
  82252. d += 1,
  82253. d += 4,
  82254. this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED && (c.direction = o.createVertexBuffer("direction", d, 3, this._attributesStrideSize, !0)),
  82255. d += 3,
  82256. this._platform.alignDataInBuffer && (d += 1),
  82257. this.particleEmitterType instanceof CustomParticleEmitter && (d += 3,
  82258. this._platform.alignDataInBuffer && (d += 1)),
  82259. this._colorGradientsTexture || (c.color = o.createVertexBuffer("color", d, 4, this._attributesStrideSize, !0),
  82260. d += 4),
  82261. this._isBillboardBased || (c.initialDirection = o.createVertexBuffer("initialDirection", d, 3, this._attributesStrideSize, !0),
  82262. d += 3,
  82263. this._platform.alignDataInBuffer && (d += 1)),
  82264. this.noiseTexture && (c.noiseCoordinates1 = o.createVertexBuffer("noiseCoordinates1", d, 3, this._attributesStrideSize, !0),
  82265. d += 3,
  82266. this._platform.alignDataInBuffer && (d += 1),
  82267. c.noiseCoordinates2 = o.createVertexBuffer("noiseCoordinates2", d, 3, this._attributesStrideSize, !0),
  82268. d += 3,
  82269. this._platform.alignDataInBuffer && (d += 1)),
  82270. c.angle = o.createVertexBuffer("angle", d, 1, this._attributesStrideSize, !0),
  82271. this._angularSpeedGradientsTexture ? d++ : d += 2,
  82272. this._isAnimationSheetEnabled && (c.cellIndex = o.createVertexBuffer("cellIndex", d, 1, this._attributesStrideSize, !0),
  82273. d += 1,
  82274. this.spriteRandomStartCell && (c.cellStartOffset = o.createVertexBuffer("cellStartOffset", d, 1, this._attributesStrideSize, !0),
  82275. d += 1)),
  82276. c.offset = s.createVertexBuffer("offset", 0, 2),
  82277. c.uv = s.createVertexBuffer("uv", 2, 2),
  82278. this._platform.createVertexBuffers(i, c),
  82279. this.resetDrawCache()
  82280. }
  82281. ,
  82282. e.prototype._initialize = function(i) {
  82283. if (i === void 0 && (i = !1),
  82284. !(this._buffer0 && !i)) {
  82285. var o = this._engine
  82286. , s = new Array;
  82287. this._attributesStrideSize = 21,
  82288. this._targetIndex = 0,
  82289. this._platform.alignDataInBuffer && (this._attributesStrideSize += 1),
  82290. this.particleEmitterType instanceof CustomParticleEmitter && (this._attributesStrideSize += 3,
  82291. this._platform.alignDataInBuffer && (this._attributesStrideSize += 1)),
  82292. this.isBillboardBased || (this._attributesStrideSize += 3,
  82293. this._platform.alignDataInBuffer && (this._attributesStrideSize += 1)),
  82294. this._colorGradientsTexture && (this._attributesStrideSize -= 4),
  82295. this._angularSpeedGradientsTexture && (this._attributesStrideSize -= 1),
  82296. this._isAnimationSheetEnabled && (this._attributesStrideSize += 1,
  82297. this.spriteRandomStartCell && (this._attributesStrideSize += 1)),
  82298. this.noiseTexture && (this._attributesStrideSize += 6,
  82299. this._platform.alignDataInBuffer && (this._attributesStrideSize += 2)),
  82300. this._platform.alignDataInBuffer && (this._attributesStrideSize += 3 - (this._attributesStrideSize + 3 & 3));
  82301. for (var c = this.particleEmitterType instanceof CustomParticleEmitter, d = TmpVectors.Vector3[0], _ = 0, b = 0; b < this._capacity; b++)
  82302. if (s.push(0),
  82303. s.push(0),
  82304. s.push(0),
  82305. s.push(0),
  82306. s.push(0),
  82307. s.push(0),
  82308. s.push(0),
  82309. s.push(0),
  82310. s.push(Math.random()),
  82311. s.push(Math.random()),
  82312. s.push(Math.random()),
  82313. s.push(Math.random()),
  82314. c ? (this.particleEmitterType.particleDestinationGenerator(b, null, d),
  82315. s.push(d.x),
  82316. s.push(d.y),
  82317. s.push(d.z)) : (s.push(0),
  82318. s.push(0),
  82319. s.push(0)),
  82320. this._platform.alignDataInBuffer && s.push(0),
  82321. _ += 16,
  82322. c && (this.particleEmitterType.particlePositionGenerator(b, null, d),
  82323. s.push(d.x),
  82324. s.push(d.y),
  82325. s.push(d.z),
  82326. this._platform.alignDataInBuffer && s.push(0),
  82327. _ += 4),
  82328. this._colorGradientsTexture || (s.push(0),
  82329. s.push(0),
  82330. s.push(0),
  82331. s.push(0),
  82332. _ += 4),
  82333. this.isBillboardBased || (s.push(0),
  82334. s.push(0),
  82335. s.push(0),
  82336. this._platform.alignDataInBuffer && s.push(0),
  82337. _ += 4),
  82338. this.noiseTexture && (s.push(Math.random()),
  82339. s.push(Math.random()),
  82340. s.push(Math.random()),
  82341. this._platform.alignDataInBuffer && s.push(0),
  82342. s.push(Math.random()),
  82343. s.push(Math.random()),
  82344. s.push(Math.random()),
  82345. this._platform.alignDataInBuffer && s.push(0),
  82346. _ += 8),
  82347. s.push(0),
  82348. _ += 1,
  82349. this._angularSpeedGradientsTexture || (s.push(0),
  82350. _ += 1),
  82351. this._isAnimationSheetEnabled && (s.push(0),
  82352. _ += 1,
  82353. this.spriteRandomStartCell && (s.push(0),
  82354. _ += 1)),
  82355. this._platform.alignDataInBuffer) {
  82356. var k = 3 - (_ + 3 & 3);
  82357. for (_ += k; k-- > 0; )
  82358. s.push(0)
  82359. }
  82360. var j = new Float32Array([.5, .5, 1, 1, -.5, .5, 0, 1, .5, -.5, 1, 0, -.5, -.5, 0, 0])
  82361. , $ = this._platform.createParticleBuffer(s)
  82362. , _e = this._platform.createParticleBuffer(s);
  82363. this._buffer0 = new Buffer(o,$,!1,this._attributesStrideSize),
  82364. this._buffer1 = new Buffer(o,_e,!1,this._attributesStrideSize),
  82365. this._spriteBuffer = new Buffer(o,j,!1,4),
  82366. this._createVertexBuffers(this._buffer0, this._buffer1, this._spriteBuffer),
  82367. this._createVertexBuffers(this._buffer1, this._buffer0, this._spriteBuffer),
  82368. this._sourceBuffer = this._buffer0,
  82369. this._targetBuffer = this._buffer1
  82370. }
  82371. }
  82372. ,
  82373. e.prototype._recreateUpdateEffect = function() {
  82374. var i = this.particleEmitterType ? this.particleEmitterType.getEffectDefines() : "";
  82375. this._isBillboardBased && (i += `
  82376. #define BILLBOARD`),
  82377. this._colorGradientsTexture && (i += `
  82378. #define COLORGRADIENTS`),
  82379. this._sizeGradientsTexture && (i += `
  82380. #define SIZEGRADIENTS`),
  82381. this._angularSpeedGradientsTexture && (i += `
  82382. #define ANGULARSPEEDGRADIENTS`),
  82383. this._velocityGradientsTexture && (i += `
  82384. #define VELOCITYGRADIENTS`),
  82385. this._limitVelocityGradientsTexture && (i += `
  82386. #define LIMITVELOCITYGRADIENTS`),
  82387. this._dragGradientsTexture && (i += `
  82388. #define DRAGGRADIENTS`),
  82389. this.isAnimationSheetEnabled && (i += `
  82390. #define ANIMATESHEET`,
  82391. this.spriteRandomStartCell && (i += `
  82392. #define ANIMATESHEETRANDOMSTART`)),
  82393. this.noiseTexture && (i += `
  82394. #define NOISE`),
  82395. this.isLocal && (i += `
  82396. #define LOCAL`),
  82397. !(this._platform.isUpdateBufferCreated() && this._cachedUpdateDefines === i) && (this._cachedUpdateDefines = i,
  82398. this._updateBuffer = this._platform.createUpdateBuffer(i))
  82399. }
  82400. ,
  82401. e.prototype._getWrapper = function(i) {
  82402. var o = this._getCustomDrawWrapper(i);
  82403. if (o != null && o.effect)
  82404. return o;
  82405. var s = [];
  82406. this.fillDefines(s, i);
  82407. var c = this._drawWrappers[i];
  82408. c || (c = new DrawWrapper(this._engine),
  82409. c.drawContext && (c.drawContext.useInstancing = !0),
  82410. this._drawWrappers[i] = c);
  82411. var d = s.join(`
  82412. `);
  82413. if (c.defines !== d) {
  82414. var _ = []
  82415. , b = []
  82416. , k = [];
  82417. this.fillUniformsAttributesAndSamplerNames(b, _, k),
  82418. c.setEffect(this._engine.createEffect("gpuRenderParticles", _, b, k, d), d)
  82419. }
  82420. return c
  82421. }
  82422. ,
  82423. e._GetAttributeNamesOrOptions = function(i, o, s, c) {
  82424. i === void 0 && (i = !1),
  82425. o === void 0 && (o = !1),
  82426. s === void 0 && (s = !1),
  82427. c === void 0 && (c = !1);
  82428. var d = [VertexBuffer.PositionKind, "age", "life", "size", "angle"];
  82429. return i || d.push(VertexBuffer.ColorKind),
  82430. o && d.push("cellIndex"),
  82431. s || d.push("initialDirection"),
  82432. c || d.push("direction"),
  82433. d.push("offset", VertexBuffer.UVKind),
  82434. d
  82435. }
  82436. ,
  82437. e._GetEffectCreationOptions = function(i) {
  82438. i === void 0 && (i = !1);
  82439. var o = ["emitterWM", "worldOffset", "view", "projection", "colorDead", "invView", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "translationPivot", "eyePosition"];
  82440. return i && o.push("sheetInfos"),
  82441. o
  82442. }
  82443. ,
  82444. e.prototype.fillDefines = function(i, o) {
  82445. if (o === void 0 && (o = 0),
  82446. this._scene && (this._scene.clipPlane && i.push("#define CLIPPLANE"),
  82447. this._scene.clipPlane2 && i.push("#define CLIPPLANE2"),
  82448. this._scene.clipPlane3 && i.push("#define CLIPPLANE3"),
  82449. this._scene.clipPlane4 && i.push("#define CLIPPLANE4"),
  82450. this._scene.clipPlane5 && i.push("#define CLIPPLANE5"),
  82451. this._scene.clipPlane6 && i.push("#define CLIPPLANE6")),
  82452. o === ParticleSystem.BLENDMODE_MULTIPLY && i.push("#define BLENDMULTIPLYMODE"),
  82453. this.isLocal && i.push("#define LOCAL"),
  82454. this._isBillboardBased)
  82455. switch (i.push("#define BILLBOARD"),
  82456. this.billboardMode) {
  82457. case ParticleSystem.BILLBOARDMODE_Y:
  82458. i.push("#define BILLBOARDY");
  82459. break;
  82460. case ParticleSystem.BILLBOARDMODE_STRETCHED:
  82461. i.push("#define BILLBOARDSTRETCHED");
  82462. break;
  82463. case ParticleSystem.BILLBOARDMODE_ALL:
  82464. i.push("#define BILLBOARDMODE_ALL");
  82465. break
  82466. }
  82467. this._colorGradientsTexture && i.push("#define COLORGRADIENTS"),
  82468. this.isAnimationSheetEnabled && i.push("#define ANIMATESHEET"),
  82469. this._imageProcessingConfiguration && (this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines),
  82470. i.push("" + this._imageProcessingConfigurationDefines.toString()))
  82471. }
  82472. ,
  82473. e.prototype.fillUniformsAttributesAndSamplerNames = function(i, o, s) {
  82474. o.push.apply(o, e._GetAttributeNamesOrOptions(!!this._colorGradientsTexture, this._isAnimationSheetEnabled, this._isBillboardBased, this._isBillboardBased && this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED)),
  82475. i.push.apply(i, e._GetEffectCreationOptions(this._isAnimationSheetEnabled)),
  82476. s.push("diffuseSampler", "colorGradientSampler"),
  82477. this._imageProcessingConfiguration && (ImageProcessingConfiguration.PrepareUniforms(i, this._imageProcessingConfigurationDefines),
  82478. ImageProcessingConfiguration.PrepareSamplers(s, this._imageProcessingConfigurationDefines))
  82479. }
  82480. ,
  82481. e.prototype.animate = function(i) {
  82482. var o;
  82483. i === void 0 && (i = !1),
  82484. this._timeDelta = this.updateSpeed * (i ? this.preWarmStepOffset : ((o = this._scene) === null || o === void 0 ? void 0 : o.getAnimationRatio()) || 1),
  82485. this._actualFrame += this._timeDelta,
  82486. this._stopped || this.targetStopDuration && this._actualFrame >= this.targetStopDuration && this.stop()
  82487. }
  82488. ,
  82489. e.prototype._createFactorGradientTexture = function(i, o) {
  82490. var s = this[o];
  82491. if (!(!i || !i.length || s)) {
  82492. for (var c = new Float32Array(this._rawTextureWidth), d = 0; d < this._rawTextureWidth; d++) {
  82493. var _ = d / this._rawTextureWidth;
  82494. GradientHelper.GetCurrentGradient(_, i, function(b, k, j) {
  82495. c[d] = Scalar.Lerp(b.factor1, k.factor1, j)
  82496. })
  82497. }
  82498. this[o] = RawTexture.CreateRTexture(c, this._rawTextureWidth, 1, this._scene || this._engine, !1, !1, 1)
  82499. }
  82500. }
  82501. ,
  82502. e.prototype._createSizeGradientTexture = function() {
  82503. this._createFactorGradientTexture(this._sizeGradients, "_sizeGradientsTexture")
  82504. }
  82505. ,
  82506. e.prototype._createAngularSpeedGradientTexture = function() {
  82507. this._createFactorGradientTexture(this._angularSpeedGradients, "_angularSpeedGradientsTexture")
  82508. }
  82509. ,
  82510. e.prototype._createVelocityGradientTexture = function() {
  82511. this._createFactorGradientTexture(this._velocityGradients, "_velocityGradientsTexture")
  82512. }
  82513. ,
  82514. e.prototype._createLimitVelocityGradientTexture = function() {
  82515. this._createFactorGradientTexture(this._limitVelocityGradients, "_limitVelocityGradientsTexture")
  82516. }
  82517. ,
  82518. e.prototype._createDragGradientTexture = function() {
  82519. this._createFactorGradientTexture(this._dragGradients, "_dragGradientsTexture")
  82520. }
  82521. ,
  82522. e.prototype._createColorGradientTexture = function() {
  82523. if (!(!this._colorGradients || !this._colorGradients.length || this._colorGradientsTexture)) {
  82524. for (var i = new Uint8Array(this._rawTextureWidth * 4), o = TmpColors.Color4[0], s = 0; s < this._rawTextureWidth; s++) {
  82525. var c = s / this._rawTextureWidth;
  82526. GradientHelper.GetCurrentGradient(c, this._colorGradients, function(d, _, b) {
  82527. Color4.LerpToRef(d.color1, _.color1, b, o),
  82528. i[s * 4] = o.r * 255,
  82529. i[s * 4 + 1] = o.g * 255,
  82530. i[s * 4 + 2] = o.b * 255,
  82531. i[s * 4 + 3] = o.a * 255
  82532. })
  82533. }
  82534. this._colorGradientsTexture = RawTexture.CreateRGBATexture(i, this._rawTextureWidth, 1, this._scene, !1, !1, 1)
  82535. }
  82536. }
  82537. ,
  82538. e.prototype._render = function(i, o) {
  82539. var s, c, d = this._getWrapper(i), _ = d.effect;
  82540. this._engine.enableEffect(d);
  82541. var b = ((s = this._scene) === null || s === void 0 ? void 0 : s.getViewMatrix()) || Matrix.IdentityReadOnly;
  82542. if (_.setMatrix("view", b),
  82543. _.setMatrix("projection", (c = this.defaultProjectionMatrix) !== null && c !== void 0 ? c : this._scene.getProjectionMatrix()),
  82544. _.setTexture("diffuseSampler", this.particleTexture),
  82545. _.setVector2("translationPivot", this.translationPivot),
  82546. _.setVector3("worldOffset", this.worldOffset),
  82547. this.isLocal && _.setMatrix("emitterWM", o),
  82548. this._colorGradientsTexture ? _.setTexture("colorGradientSampler", this._colorGradientsTexture) : _.setDirectColor4("colorDead", this.colorDead),
  82549. this._isAnimationSheetEnabled && this.particleTexture) {
  82550. var k = this.particleTexture.getBaseSize();
  82551. _.setFloat3("sheetInfos", this.spriteCellWidth / k.width, this.spriteCellHeight / k.height, k.width / this.spriteCellWidth)
  82552. }
  82553. if (this._isBillboardBased && this._scene) {
  82554. var j = this._scene.activeCamera;
  82555. _.setVector3("eyePosition", j.globalPosition)
  82556. }
  82557. var $ = _.defines;
  82558. if (this._scene && (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4 || this._scene.clipPlane5 || this._scene.clipPlane6) && MaterialHelper.BindClipPlane(_, this._scene),
  82559. $.indexOf("#define BILLBOARDMODE_ALL") >= 0) {
  82560. var _e = b.clone();
  82561. _e.invert(),
  82562. _.setMatrix("invView", _e)
  82563. }
  82564. switch (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess && this._imageProcessingConfiguration.bind(_),
  82565. i) {
  82566. case ParticleSystem.BLENDMODE_ADD:
  82567. this._engine.setAlphaMode(1);
  82568. break;
  82569. case ParticleSystem.BLENDMODE_ONEONE:
  82570. this._engine.setAlphaMode(6);
  82571. break;
  82572. case ParticleSystem.BLENDMODE_STANDARD:
  82573. this._engine.setAlphaMode(2);
  82574. break;
  82575. case ParticleSystem.BLENDMODE_MULTIPLY:
  82576. this._engine.setAlphaMode(4);
  82577. break
  82578. }
  82579. return this._platform.bindDrawBuffers(this._targetIndex, _),
  82580. this._onBeforeDrawParticlesObservable && this._onBeforeDrawParticlesObservable.notifyObservers(_),
  82581. this._engine.drawArraysType(7, 0, 4, this._currentActiveCount),
  82582. this._engine.setAlphaMode(0),
  82583. this._currentActiveCount
  82584. }
  82585. ,
  82586. e.prototype.render = function(i, o) {
  82587. if (i === void 0 && (i = !1),
  82588. o === void 0 && (o = !1),
  82589. !this._started || (this._createColorGradientTexture(),
  82590. this._createSizeGradientTexture(),
  82591. this._createAngularSpeedGradientTexture(),
  82592. this._createVelocityGradientTexture(),
  82593. this._createLimitVelocityGradientTexture(),
  82594. this._createDragGradientTexture(),
  82595. this._recreateUpdateEffect(),
  82596. !this.isReady()))
  82597. return 0;
  82598. if (!i && this._scene) {
  82599. if (!this._preWarmDone && this.preWarmCycles) {
  82600. for (var s = 0; s < this.preWarmCycles; s++)
  82601. this.animate(!0),
  82602. this.render(!0, !0);
  82603. this._preWarmDone = !0
  82604. }
  82605. if (this._currentRenderId === this._scene.getFrameId() && (!this._scene.activeCamera || this._scene.activeCamera && this._currentRenderingCameraUniqueId === this._scene.activeCamera.uniqueId))
  82606. return 0;
  82607. this._currentRenderId = this._scene.getFrameId(),
  82608. this._scene.activeCamera && (this._currentRenderingCameraUniqueId = this._scene.activeCamera.uniqueId)
  82609. }
  82610. if (this._initialize(),
  82611. this._accumulatedCount += this.emitRate * this._timeDelta,
  82612. this._accumulatedCount > 1) {
  82613. var c = this._accumulatedCount | 0;
  82614. this._accumulatedCount -= c,
  82615. this._currentActiveCount = Math.min(this._activeCount, this._currentActiveCount + c)
  82616. }
  82617. if (!this._currentActiveCount)
  82618. return 0;
  82619. var d;
  82620. if (this.emitter.position) {
  82621. var _ = this.emitter;
  82622. d = _.getWorldMatrix()
  82623. } else {
  82624. var b = this.emitter;
  82625. d = Matrix.Translation(b.x, b.y, b.z)
  82626. }
  82627. var k = this._engine;
  82628. this._platform.preUpdateParticleBuffer(),
  82629. this._updateBuffer.setFloat("currentCount", this._currentActiveCount),
  82630. this._updateBuffer.setFloat("timeDelta", this._timeDelta),
  82631. this._updateBuffer.setFloat("stopFactor", this._stopped ? 0 : 1),
  82632. this._updateBuffer.setInt("randomTextureSize", this._randomTextureSize),
  82633. this._updateBuffer.setFloat2("lifeTime", this.minLifeTime, this.maxLifeTime),
  82634. this._updateBuffer.setFloat2("emitPower", this.minEmitPower, this.maxEmitPower),
  82635. this._colorGradientsTexture || (this._updateBuffer.setDirectColor4("color1", this.color1),
  82636. this._updateBuffer.setDirectColor4("color2", this.color2)),
  82637. this._updateBuffer.setFloat2("sizeRange", this.minSize, this.maxSize),
  82638. this._updateBuffer.setFloat4("scaleRange", this.minScaleX, this.maxScaleX, this.minScaleY, this.maxScaleY),
  82639. this._updateBuffer.setFloat4("angleRange", this.minAngularSpeed, this.maxAngularSpeed, this.minInitialRotation, this.maxInitialRotation),
  82640. this._updateBuffer.setVector3("gravity", this.gravity),
  82641. this._limitVelocityGradientsTexture && this._updateBuffer.setFloat("limitVelocityDamping", this.limitVelocityDamping),
  82642. this.particleEmitterType && this.particleEmitterType.applyToShader(this._updateBuffer),
  82643. this._isAnimationSheetEnabled && this._updateBuffer.setFloat4("cellInfos", this.startSpriteCellID, this.endSpriteCellID, this.spriteCellChangeSpeed, this.spriteCellLoop ? 1 : 0),
  82644. this.noiseTexture && this._updateBuffer.setVector3("noiseStrength", this.noiseStrength),
  82645. this.isLocal || this._updateBuffer.setMatrix("emitterWM", d),
  82646. this._platform.updateParticleBuffer(this._targetIndex, this._targetBuffer, this._currentActiveCount);
  82647. var j = 0;
  82648. !i && !o && (k.setState(!1),
  82649. this.forceDepthWrite && k.setDepthWrite(!0),
  82650. this.blendMode === ParticleSystem.BLENDMODE_MULTIPLYADD ? j = this._render(ParticleSystem.BLENDMODE_MULTIPLY, d) + this._render(ParticleSystem.BLENDMODE_ADD, d) : j = this._render(this.blendMode, d),
  82651. this._engine.setAlphaMode(0)),
  82652. this._targetIndex++,
  82653. this._targetIndex === 2 && (this._targetIndex = 0);
  82654. var $ = this._sourceBuffer;
  82655. return this._sourceBuffer = this._targetBuffer,
  82656. this._targetBuffer = $,
  82657. j
  82658. }
  82659. ,
  82660. e.prototype.rebuild = function() {
  82661. this._initialize(!0)
  82662. }
  82663. ,
  82664. e.prototype._releaseBuffers = function() {
  82665. this._buffer0 && (this._buffer0.dispose(),
  82666. this._buffer0 = null),
  82667. this._buffer1 && (this._buffer1.dispose(),
  82668. this._buffer1 = null),
  82669. this._spriteBuffer && (this._spriteBuffer.dispose(),
  82670. this._spriteBuffer = null),
  82671. this._platform.releaseBuffers()
  82672. }
  82673. ,
  82674. e.prototype.dispose = function(i) {
  82675. i === void 0 && (i = !0);
  82676. for (var o in this._drawWrappers) {
  82677. var s = this._drawWrappers[o];
  82678. s.dispose()
  82679. }
  82680. if (this._drawWrappers = {},
  82681. this._scene) {
  82682. var c = this._scene.particleSystems.indexOf(this);
  82683. c > -1 && this._scene.particleSystems.splice(c, 1)
  82684. }
  82685. this._releaseBuffers(),
  82686. this._platform.releaseVertexBuffers(),
  82687. this._colorGradientsTexture && (this._colorGradientsTexture.dispose(),
  82688. this._colorGradientsTexture = null),
  82689. this._sizeGradientsTexture && (this._sizeGradientsTexture.dispose(),
  82690. this._sizeGradientsTexture = null),
  82691. this._angularSpeedGradientsTexture && (this._angularSpeedGradientsTexture.dispose(),
  82692. this._angularSpeedGradientsTexture = null),
  82693. this._velocityGradientsTexture && (this._velocityGradientsTexture.dispose(),
  82694. this._velocityGradientsTexture = null),
  82695. this._limitVelocityGradientsTexture && (this._limitVelocityGradientsTexture.dispose(),
  82696. this._limitVelocityGradientsTexture = null),
  82697. this._dragGradientsTexture && (this._dragGradientsTexture.dispose(),
  82698. this._dragGradientsTexture = null),
  82699. this._randomTexture && (this._randomTexture.dispose(),
  82700. this._randomTexture = null),
  82701. this._randomTexture2 && (this._randomTexture2.dispose(),
  82702. this._randomTexture2 = null),
  82703. i && this.particleTexture && (this.particleTexture.dispose(),
  82704. this.particleTexture = null),
  82705. i && this.noiseTexture && (this.noiseTexture.dispose(),
  82706. this.noiseTexture = null),
  82707. this.onStoppedObservable.clear(),
  82708. this.onDisposeObservable.notifyObservers(this),
  82709. this.onDisposeObservable.clear()
  82710. }
  82711. ,
  82712. e.prototype.clone = function(i, o) {
  82713. var s = __assign({}, this._customWrappers)
  82714. , c = null
  82715. , d = this._engine;
  82716. if (d.createEffectForParticles && this.customShader != null) {
  82717. c = this.customShader;
  82718. var _ = c.shaderOptions.defines.length > 0 ? c.shaderOptions.defines.join(`
  82719. `) : "";
  82720. s[0] = d.createEffectForParticles(c.shaderPath.fragmentElement, c.shaderOptions.uniforms, c.shaderOptions.samplers, _, void 0, void 0, void 0, this)
  82721. }
  82722. var b = this.serialize()
  82723. , k = e.Parse(b, this._scene || this._engine, this._rootUrl);
  82724. return k.name = i,
  82725. k.customShader = c,
  82726. k._customWrappers = s,
  82727. o === void 0 && (o = this.emitter),
  82728. this.noiseTexture && (k.noiseTexture = this.noiseTexture.clone()),
  82729. k.emitter = o,
  82730. k
  82731. }
  82732. ,
  82733. e.prototype.serialize = function(i) {
  82734. i === void 0 && (i = !1);
  82735. var o = {};
  82736. return ParticleSystem._Serialize(o, this, i),
  82737. o.activeParticleCount = this.activeParticleCount,
  82738. o.randomTextureSize = this._randomTextureSize,
  82739. o.customShader = this.customShader,
  82740. o
  82741. }
  82742. ,
  82743. e.Parse = function(i, o, s, c, d) {
  82744. c === void 0 && (c = !1);
  82745. var _ = i.name, b, k;
  82746. o instanceof ThinEngine ? b = o : (k = o,
  82747. b = k.getEngine());
  82748. var j = new e(_,{
  82749. capacity: d || i.capacity,
  82750. randomTextureSize: i.randomTextureSize
  82751. },o,null,i.isAnimationSheetEnabled);
  82752. if (j._rootUrl = s,
  82753. i.customShader && b.createEffectForParticles) {
  82754. var $ = i.customShader
  82755. , _e = $.shaderOptions.defines.length > 0 ? $.shaderOptions.defines.join(`
  82756. `) : ""
  82757. , et = b.createEffectForParticles($.shaderPath.fragmentElement, $.shaderOptions.uniforms, $.shaderOptions.samplers, _e, void 0, void 0, void 0, j);
  82758. j.setCustomEffect(et, 0),
  82759. j.customShader = $
  82760. }
  82761. return i.id && (j.id = i.id),
  82762. i.activeParticleCount && (j.activeParticleCount = i.activeParticleCount),
  82763. ParticleSystem._Parse(i, j, o, s),
  82764. i.preventAutoStart && (j.preventAutoStart = i.preventAutoStart),
  82765. !c && !j.preventAutoStart && j.start(),
  82766. j
  82767. }
  82768. ,
  82769. e
  82770. }(BaseParticleSystem)
  82771. , ParticleSystemSet = function() {
  82772. function a() {
  82773. this._emitterNodeIsOwned = !0,
  82774. this.systems = new Array
  82775. }
  82776. return Object.defineProperty(a.prototype, "emitterNode", {
  82777. get: function() {
  82778. return this._emitterNode
  82779. },
  82780. set: function(e) {
  82781. this._emitterNodeIsOwned && this._emitterNode && (this._emitterNode.dispose && this._emitterNode.dispose(),
  82782. this._emitterNodeIsOwned = !1);
  82783. for (var i = 0, o = this.systems; i < o.length; i++) {
  82784. var s = o[i];
  82785. s.emitter = e
  82786. }
  82787. this._emitterNode = e
  82788. },
  82789. enumerable: !1,
  82790. configurable: !0
  82791. }),
  82792. a.prototype.setEmitterAsSphere = function(e, i, o) {
  82793. this._emitterNodeIsOwned && this._emitterNode && this._emitterNode.dispose && this._emitterNode.dispose(),
  82794. this._emitterNodeIsOwned = !0,
  82795. this._emitterCreationOptions = {
  82796. kind: "Sphere",
  82797. options: e,
  82798. renderingGroupId: i
  82799. };
  82800. var s = CreateSphere("emitterSphere", {
  82801. diameter: e.diameter,
  82802. segments: e.segments
  82803. }, o);
  82804. s.renderingGroupId = i;
  82805. var c = new StandardMaterial("emitterSphereMaterial",o);
  82806. c.emissiveColor = e.color,
  82807. s.material = c;
  82808. for (var d = 0, _ = this.systems; d < _.length; d++) {
  82809. var b = _[d];
  82810. b.emitter = s
  82811. }
  82812. this._emitterNode = s
  82813. }
  82814. ,
  82815. a.prototype.start = function(e) {
  82816. for (var i = 0, o = this.systems; i < o.length; i++) {
  82817. var s = o[i];
  82818. e && (s.emitter = e),
  82819. s.start()
  82820. }
  82821. }
  82822. ,
  82823. a.prototype.dispose = function() {
  82824. for (var e = 0, i = this.systems; e < i.length; e++) {
  82825. var o = i[e];
  82826. o.dispose()
  82827. }
  82828. this.systems = [],
  82829. this._emitterNode && (this._emitterNode.dispose && this._emitterNode.dispose(),
  82830. this._emitterNode = null)
  82831. }
  82832. ,
  82833. a.prototype.serialize = function(e) {
  82834. e === void 0 && (e = !1);
  82835. var i = {};
  82836. i.systems = [];
  82837. for (var o = 0, s = this.systems; o < s.length; o++) {
  82838. var c = s[o];
  82839. i.systems.push(c.serialize(e))
  82840. }
  82841. return this._emitterNode && (i.emitter = this._emitterCreationOptions),
  82842. i
  82843. }
  82844. ,
  82845. a.Parse = function(e, i, o, s) {
  82846. o === void 0 && (o = !1);
  82847. var c = new a
  82848. , d = this.BaseAssetsUrl + "/textures/";
  82849. i = i || EngineStore.LastCreatedScene;
  82850. for (var _ = 0, b = e.systems; _ < b.length; _++) {
  82851. var k = b[_];
  82852. c.systems.push(o ? GPUParticleSystem.Parse(k, i, d, !0, s) : ParticleSystem.Parse(k, i, d, !0, s))
  82853. }
  82854. if (e.emitter) {
  82855. var j = e.emitter.options;
  82856. switch (e.emitter.kind) {
  82857. case "Sphere":
  82858. c.setEmitterAsSphere({
  82859. diameter: j.diameter,
  82860. segments: j.segments,
  82861. color: Color3.FromArray(j.color)
  82862. }, e.emitter.renderingGroupId, i);
  82863. break
  82864. }
  82865. }
  82866. return c
  82867. }
  82868. ,
  82869. a.BaseAssetsUrl = "https://assets.babylonjs.com/particles",
  82870. a
  82871. }()
  82872. , ProceduralTextureSceneComponent = function() {
  82873. function a(e) {
  82874. this.name = SceneComponentConstants.NAME_PROCEDURALTEXTURE,
  82875. this.scene = e,
  82876. this.scene.proceduralTextures = new Array
  82877. }
  82878. return a.prototype.register = function() {
  82879. this.scene._beforeClearStage.registerStep(SceneComponentConstants.STEP_BEFORECLEAR_PROCEDURALTEXTURE, this, this._beforeClear)
  82880. }
  82881. ,
  82882. a.prototype.rebuild = function() {}
  82883. ,
  82884. a.prototype.dispose = function() {}
  82885. ,
  82886. a.prototype._beforeClear = function() {
  82887. if (this.scene.proceduralTexturesEnabled) {
  82888. Tools.StartPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
  82889. for (var e = 0; e < this.scene.proceduralTextures.length; e++) {
  82890. var i = this.scene.proceduralTextures[e];
  82891. i._shouldRender() && i.render()
  82892. }
  82893. Tools.EndPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0)
  82894. }
  82895. }
  82896. ,
  82897. a
  82898. }()
  82899. , name$1g = "proceduralVertexShader"
  82900. , shader$1g = `
  82901. attribute vec2 position;
  82902. varying vec2 vPosition;
  82903. varying vec2 vUV;
  82904. const vec2 madd=vec2(0.5,0.5);
  82905. void main(void) {
  82906. vPosition=position;
  82907. vUV=position*madd+madd;
  82908. gl_Position=vec4(position,0.0,1.0);
  82909. }`;
  82910. ShaderStore.ShadersStore[name$1g] = shader$1g;
  82911. var ProceduralTexture = function(a) {
  82912. __extends(e, a);
  82913. function e(i, o, s, c, d, _, b, k) {
  82914. d === void 0 && (d = null),
  82915. _ === void 0 && (_ = !0),
  82916. b === void 0 && (b = !1),
  82917. k === void 0 && (k = 0);
  82918. var j = a.call(this, null, c, !_) || this;
  82919. j.isEnabled = !0,
  82920. j.autoClear = !0,
  82921. j.onGeneratedObservable = new Observable,
  82922. j.onBeforeGenerationObservable = new Observable,
  82923. j.nodeMaterialSource = null,
  82924. j._textures = {},
  82925. j._currentRefreshId = -1,
  82926. j._frameId = -1,
  82927. j._refreshRate = 1,
  82928. j._vertexBuffers = {},
  82929. j._uniforms = new Array,
  82930. j._samplers = new Array,
  82931. j._floats = {},
  82932. j._ints = {},
  82933. j._floatsArrays = {},
  82934. j._colors3 = {},
  82935. j._colors4 = {},
  82936. j._vectors2 = {},
  82937. j._vectors3 = {},
  82938. j._matrices = {},
  82939. j._fallbackTextureUsed = !1,
  82940. j._cachedDefines = null,
  82941. j._contentUpdateId = -1,
  82942. j._rtWrapper = null,
  82943. c = j.getScene() || EngineStore.LastCreatedScene;
  82944. var $ = c._getComponent(SceneComponentConstants.NAME_PROCEDURALTEXTURE);
  82945. $ || ($ = new ProceduralTextureSceneComponent(c),
  82946. c._addComponent($)),
  82947. c.proceduralTextures.push(j),
  82948. j._fullEngine = c.getEngine(),
  82949. j.name = i,
  82950. j.isRenderTarget = !0,
  82951. j._size = o,
  82952. j._textureType = k,
  82953. j._generateMipMaps = _,
  82954. j._drawWrapper = new DrawWrapper(j._fullEngine),
  82955. j.setFragment(s),
  82956. j._fallbackTexture = d,
  82957. b ? (j._rtWrapper = j._fullEngine.createRenderTargetCubeTexture(o, {
  82958. generateMipMaps: _,
  82959. generateDepthBuffer: !1,
  82960. generateStencilBuffer: !1,
  82961. type: k
  82962. }),
  82963. j.setFloat("face", 0)) : j._rtWrapper = j._fullEngine.createRenderTargetTexture(o, {
  82964. generateMipMaps: _,
  82965. generateDepthBuffer: !1,
  82966. generateStencilBuffer: !1,
  82967. type: k
  82968. }),
  82969. j._texture = j._rtWrapper.texture;
  82970. var _e = [];
  82971. return _e.push(1, 1),
  82972. _e.push(-1, 1),
  82973. _e.push(-1, -1),
  82974. _e.push(1, -1),
  82975. j._vertexBuffers[VertexBuffer.PositionKind] = new VertexBuffer(j._fullEngine,_e,VertexBuffer.PositionKind,!1,!1,2),
  82976. j._createIndexBuffer(),
  82977. j
  82978. }
  82979. return e.prototype.getEffect = function() {
  82980. return this._drawWrapper.effect
  82981. }
  82982. ,
  82983. e.prototype._setEffect = function(i) {
  82984. this._drawWrapper.effect = i
  82985. }
  82986. ,
  82987. e.prototype.getContent = function() {
  82988. var i = this;
  82989. return this._contentData && this._frameId === this._contentUpdateId ? this._contentData : (this._contentData ? this._contentData.then(function(o) {
  82990. i._contentData = i.readPixels(0, 0, o),
  82991. i._contentUpdateId = i._frameId
  82992. }) : (this._contentData = this.readPixels(0, 0),
  82993. this._contentUpdateId = this._frameId),
  82994. this._contentData)
  82995. }
  82996. ,
  82997. e.prototype._createIndexBuffer = function() {
  82998. var i = this._fullEngine
  82999. , o = [];
  83000. o.push(0),
  83001. o.push(1),
  83002. o.push(2),
  83003. o.push(0),
  83004. o.push(2),
  83005. o.push(3),
  83006. this._indexBuffer = i.createIndexBuffer(o)
  83007. }
  83008. ,
  83009. e.prototype._rebuild = function() {
  83010. var i = this._vertexBuffers[VertexBuffer.PositionKind];
  83011. i && i._rebuild(),
  83012. this._createIndexBuffer(),
  83013. this.refreshRate === RenderTargetTexture.REFRESHRATE_RENDER_ONCE && (this.refreshRate = RenderTargetTexture.REFRESHRATE_RENDER_ONCE)
  83014. }
  83015. ,
  83016. e.prototype.reset = function() {
  83017. var i;
  83018. (i = this._drawWrapper.effect) === null || i === void 0 || i.dispose()
  83019. }
  83020. ,
  83021. e.prototype._getDefines = function() {
  83022. return ""
  83023. }
  83024. ,
  83025. e.prototype.isReady = function() {
  83026. var i = this, o = this._fullEngine, s;
  83027. if (this.nodeMaterialSource)
  83028. return this._drawWrapper.effect.isReady();
  83029. if (!this._fragment)
  83030. return !1;
  83031. if (this._fallbackTextureUsed)
  83032. return !0;
  83033. var c = this._getDefines();
  83034. return this._drawWrapper.effect && c === this._cachedDefines && this._drawWrapper.effect.isReady() ? !0 : (this._fragment.fragmentElement !== void 0 ? s = {
  83035. vertex: "procedural",
  83036. fragmentElement: this._fragment.fragmentElement
  83037. } : s = {
  83038. vertex: "procedural",
  83039. fragment: this._fragment
  83040. },
  83041. this._cachedDefines !== c && (this._cachedDefines = c,
  83042. this._drawWrapper.effect = o.createEffect(s, [VertexBuffer.PositionKind], this._uniforms, this._samplers, c, void 0, void 0, function() {
  83043. var d;
  83044. (d = i._rtWrapper) === null || d === void 0 || d.dispose(),
  83045. i._rtWrapper = i._texture = null,
  83046. i._fallbackTexture && (i._texture = i._fallbackTexture._texture,
  83047. i._texture && i._texture.incrementReferences()),
  83048. i._fallbackTextureUsed = !0
  83049. })),
  83050. this._drawWrapper.effect.isReady())
  83051. }
  83052. ,
  83053. e.prototype.resetRefreshCounter = function() {
  83054. this._currentRefreshId = -1
  83055. }
  83056. ,
  83057. e.prototype.setFragment = function(i) {
  83058. this._fragment = i
  83059. }
  83060. ,
  83061. Object.defineProperty(e.prototype, "refreshRate", {
  83062. get: function() {
  83063. return this._refreshRate
  83064. },
  83065. set: function(i) {
  83066. this._refreshRate = i,
  83067. this.resetRefreshCounter()
  83068. },
  83069. enumerable: !1,
  83070. configurable: !0
  83071. }),
  83072. e.prototype._shouldRender = function() {
  83073. return !this.isEnabled || !this.isReady() || !this._texture ? (this._texture && (this._texture.isReady = !1),
  83074. !1) : this._fallbackTextureUsed ? !1 : this._currentRefreshId === -1 ? (this._currentRefreshId = 1,
  83075. this._frameId++,
  83076. !0) : this.refreshRate === this._currentRefreshId ? (this._currentRefreshId = 1,
  83077. this._frameId++,
  83078. !0) : (this._currentRefreshId++,
  83079. !1)
  83080. }
  83081. ,
  83082. e.prototype.getRenderSize = function() {
  83083. return this._size
  83084. }
  83085. ,
  83086. e.prototype.resize = function(i, o) {
  83087. var s;
  83088. this._fallbackTextureUsed || ((s = this._rtWrapper) === null || s === void 0 || s.dispose(),
  83089. this._rtWrapper = this._fullEngine.createRenderTargetTexture(i, {
  83090. generateMipMaps: o,
  83091. generateDepthBuffer: !1,
  83092. generateStencilBuffer: !1,
  83093. type: this._textureType
  83094. }),
  83095. this._texture = this._rtWrapper.texture,
  83096. this._size = i,
  83097. this._generateMipMaps = o)
  83098. }
  83099. ,
  83100. e.prototype._checkUniform = function(i) {
  83101. this._uniforms.indexOf(i) === -1 && this._uniforms.push(i)
  83102. }
  83103. ,
  83104. e.prototype.setTexture = function(i, o) {
  83105. return this._samplers.indexOf(i) === -1 && this._samplers.push(i),
  83106. this._textures[i] = o,
  83107. this
  83108. }
  83109. ,
  83110. e.prototype.setFloat = function(i, o) {
  83111. return this._checkUniform(i),
  83112. this._floats[i] = o,
  83113. this
  83114. }
  83115. ,
  83116. e.prototype.setInt = function(i, o) {
  83117. return this._checkUniform(i),
  83118. this._ints[i] = o,
  83119. this
  83120. }
  83121. ,
  83122. e.prototype.setFloats = function(i, o) {
  83123. return this._checkUniform(i),
  83124. this._floatsArrays[i] = o,
  83125. this
  83126. }
  83127. ,
  83128. e.prototype.setColor3 = function(i, o) {
  83129. return this._checkUniform(i),
  83130. this._colors3[i] = o,
  83131. this
  83132. }
  83133. ,
  83134. e.prototype.setColor4 = function(i, o) {
  83135. return this._checkUniform(i),
  83136. this._colors4[i] = o,
  83137. this
  83138. }
  83139. ,
  83140. e.prototype.setVector2 = function(i, o) {
  83141. return this._checkUniform(i),
  83142. this._vectors2[i] = o,
  83143. this
  83144. }
  83145. ,
  83146. e.prototype.setVector3 = function(i, o) {
  83147. return this._checkUniform(i),
  83148. this._vectors3[i] = o,
  83149. this
  83150. }
  83151. ,
  83152. e.prototype.setMatrix = function(i, o) {
  83153. return this._checkUniform(i),
  83154. this._matrices[i] = o,
  83155. this
  83156. }
  83157. ,
  83158. e.prototype.render = function(i) {
  83159. var o, s, c = this.getScene();
  83160. if (!!c) {
  83161. var d = this._fullEngine;
  83162. if (d.enableEffect(this._drawWrapper),
  83163. this.onBeforeGenerationObservable.notifyObservers(this),
  83164. d.setState(!1),
  83165. !this.nodeMaterialSource) {
  83166. for (var _ in this._textures)
  83167. this._drawWrapper.effect.setTexture(_, this._textures[_]);
  83168. for (_ in this._ints)
  83169. this._drawWrapper.effect.setInt(_, this._ints[_]);
  83170. for (_ in this._floats)
  83171. this._drawWrapper.effect.setFloat(_, this._floats[_]);
  83172. for (_ in this._floatsArrays)
  83173. this._drawWrapper.effect.setArray(_, this._floatsArrays[_]);
  83174. for (_ in this._colors3)
  83175. this._drawWrapper.effect.setColor3(_, this._colors3[_]);
  83176. for (_ in this._colors4) {
  83177. var b = this._colors4[_];
  83178. this._drawWrapper.effect.setFloat4(_, b.r, b.g, b.b, b.a)
  83179. }
  83180. for (_ in this._vectors2)
  83181. this._drawWrapper.effect.setVector2(_, this._vectors2[_]);
  83182. for (_ in this._vectors3)
  83183. this._drawWrapper.effect.setVector3(_, this._vectors3[_]);
  83184. for (_ in this._matrices)
  83185. this._drawWrapper.effect.setMatrix(_, this._matrices[_])
  83186. }
  83187. if (!(!this._texture || !this._rtWrapper)) {
  83188. if ((o = d._debugPushGroup) === null || o === void 0 || o.call(d, "procedural texture generation for " + this.name, 1),
  83189. this.isCube)
  83190. for (var k = 0; k < 6; k++)
  83191. d.bindFramebuffer(this._rtWrapper, k, void 0, void 0, !0),
  83192. d.bindBuffers(this._vertexBuffers, this._indexBuffer, this._drawWrapper.effect),
  83193. this._drawWrapper.effect.setFloat("face", k),
  83194. this.autoClear && d.clear(c.clearColor, !0, !1, !1),
  83195. d.drawElementsType(Material.TriangleFillMode, 0, 6);
  83196. else
  83197. d.bindFramebuffer(this._rtWrapper, 0, void 0, void 0, !0),
  83198. d.bindBuffers(this._vertexBuffers, this._indexBuffer, this._drawWrapper.effect),
  83199. this.autoClear && d.clear(c.clearColor, !0, !1, !1),
  83200. d.drawElementsType(Material.TriangleFillMode, 0, 6);
  83201. d.unBindFramebuffer(this._rtWrapper, this.isCube),
  83202. this.isCube && d.generateMipMapsForCubemap(this._texture),
  83203. (s = d._debugPopGroup) === null || s === void 0 || s.call(d, 1),
  83204. this.onGenerated && this.onGenerated(),
  83205. this.onGeneratedObservable.notifyObservers(this)
  83206. }
  83207. }
  83208. }
  83209. ,
  83210. e.prototype.clone = function() {
  83211. var i = this.getSize()
  83212. , o = new e(this.name,i.width,this._fragment,this.getScene(),this._fallbackTexture,this._generateMipMaps);
  83213. return o.hasAlpha = this.hasAlpha,
  83214. o.level = this.level,
  83215. o.coordinatesMode = this.coordinatesMode,
  83216. o
  83217. }
  83218. ,
  83219. e.prototype.dispose = function() {
  83220. var i = this.getScene();
  83221. if (!!i) {
  83222. var o = i.proceduralTextures.indexOf(this);
  83223. o >= 0 && i.proceduralTextures.splice(o, 1);
  83224. var s = this._vertexBuffers[VertexBuffer.PositionKind];
  83225. s && (s.dispose(),
  83226. this._vertexBuffers[VertexBuffer.PositionKind] = null),
  83227. this._indexBuffer && this._fullEngine._releaseBuffer(this._indexBuffer) && (this._indexBuffer = null),
  83228. this.onGeneratedObservable.clear(),
  83229. this.onBeforeGenerationObservable.clear(),
  83230. a.prototype.dispose.call(this)
  83231. }
  83232. }
  83233. ,
  83234. __decorate([serialize()], e.prototype, "isEnabled", void 0),
  83235. __decorate([serialize()], e.prototype, "autoClear", void 0),
  83236. __decorate([serialize()], e.prototype, "_generateMipMaps", void 0),
  83237. __decorate([serialize()], e.prototype, "_size", void 0),
  83238. __decorate([serialize()], e.prototype, "refreshRate", null),
  83239. e
  83240. }(Texture);
  83241. RegisterClass("BABYLON.ProceduralTexture", ProceduralTexture);
  83242. var name$1f = "noisePixelShader"
  83243. , shader$1f = `
  83244. uniform float brightness;
  83245. uniform float persistence;
  83246. uniform float timeScale;
  83247. varying vec2 vUV;
  83248. vec2 hash22(vec2 p)
  83249. {
  83250. p=p*mat2(127.1,311.7,269.5,183.3);
  83251. p=-1.0+2.0*fract(sin(p)*43758.5453123);
  83252. return sin(p*6.283+timeScale);
  83253. }
  83254. float interpolationNoise(vec2 p)
  83255. {
  83256. vec2 pi=floor(p);
  83257. vec2 pf=p-pi;
  83258. vec2 w=pf*pf*(3.-2.*pf);
  83259. float f00=dot(hash22(pi+vec2(.0,.0)),pf-vec2(.0,.0));
  83260. float f01=dot(hash22(pi+vec2(.0,1.)),pf-vec2(.0,1.));
  83261. float f10=dot(hash22(pi+vec2(1.0,0.)),pf-vec2(1.0,0.));
  83262. float f11=dot(hash22(pi+vec2(1.0,1.)),pf-vec2(1.0,1.));
  83263. float xm1=mix(f00,f10,w.x);
  83264. float xm2=mix(f01,f11,w.x);
  83265. float ym=mix(xm1,xm2,w.y);
  83266. return ym;
  83267. }
  83268. float perlinNoise2D(float x,float y)
  83269. {
  83270. float sum=0.0;
  83271. float frequency=0.0;
  83272. float amplitude=0.0;
  83273. for(int i=0; i<OCTAVES; i++)
  83274. {
  83275. frequency=pow(2.0,float(i));
  83276. amplitude=pow(persistence,float(i));
  83277. sum=sum+interpolationNoise(vec2(x*frequency,y*frequency))*amplitude;
  83278. }
  83279. return sum;
  83280. }
  83281. void main(void)
  83282. {
  83283. float x=abs(vUV.x);
  83284. float y=abs(vUV.y);
  83285. float noise=brightness+(1.0-brightness)*perlinNoise2D(x,y);
  83286. gl_FragColor=vec4(noise,noise,noise,1.0);
  83287. }
  83288. `;
  83289. ShaderStore.ShadersStore[name$1f] = shader$1f;
  83290. var NoiseProceduralTexture = function(a) {
  83291. __extends(e, a);
  83292. function e(i, o, s, c, d) {
  83293. o === void 0 && (o = 256),
  83294. s === void 0 && (s = EngineStore.LastCreatedScene);
  83295. var _ = a.call(this, i, o, "noise", s, c, d) || this;
  83296. return _.time = 0,
  83297. _.brightness = .2,
  83298. _.octaves = 3,
  83299. _.persistence = .8,
  83300. _.animationSpeedFactor = 1,
  83301. _.autoClear = !1,
  83302. _._updateShaderUniforms(),
  83303. _
  83304. }
  83305. return e.prototype._updateShaderUniforms = function() {
  83306. var i = this.getScene();
  83307. !i || (this.time += i.getAnimationRatio() * this.animationSpeedFactor * .01,
  83308. this.setFloat("brightness", this.brightness),
  83309. this.setFloat("persistence", this.persistence),
  83310. this.setFloat("timeScale", this.time))
  83311. }
  83312. ,
  83313. e.prototype._getDefines = function() {
  83314. return "#define OCTAVES " + (this.octaves | 0)
  83315. }
  83316. ,
  83317. e.prototype.render = function(i) {
  83318. this._updateShaderUniforms(),
  83319. a.prototype.render.call(this, i)
  83320. }
  83321. ,
  83322. e.prototype.serialize = function() {
  83323. var i = {};
  83324. return i.customType = "BABYLON.NoiseProceduralTexture",
  83325. i.brightness = this.brightness,
  83326. i.octaves = this.octaves,
  83327. i.persistence = this.persistence,
  83328. i.animationSpeedFactor = this.animationSpeedFactor,
  83329. i.size = this.getSize().width,
  83330. i.generateMipMaps = this._generateMipMaps,
  83331. i.time = this.time,
  83332. i
  83333. }
  83334. ,
  83335. e.prototype.clone = function() {
  83336. var i = this.getSize()
  83337. , o = new e(this.name,i.width,this.getScene(),this._fallbackTexture ? this._fallbackTexture : void 0,this._generateMipMaps);
  83338. return o.hasAlpha = this.hasAlpha,
  83339. o.level = this.level,
  83340. o.coordinatesMode = this.coordinatesMode,
  83341. o.brightness = this.brightness,
  83342. o.octaves = this.octaves,
  83343. o.persistence = this.persistence,
  83344. o.animationSpeedFactor = this.animationSpeedFactor,
  83345. o.time = this.time,
  83346. o
  83347. }
  83348. ,
  83349. e.Parse = function(i, o) {
  83350. var s, c = new e(i.name,i.size,o,void 0,i.generateMipMaps);
  83351. return c.brightness = i.brightness,
  83352. c.octaves = i.octaves,
  83353. c.persistence = i.persistence,
  83354. c.animationSpeedFactor = i.animationSpeedFactor,
  83355. c.time = (s = i.time) !== null && s !== void 0 ? s : 0,
  83356. c
  83357. }
  83358. ,
  83359. e
  83360. }(ProceduralTexture);
  83361. RegisterClass("BABYLON.NoiseProceduralTexture", NoiseProceduralTexture);
  83362. var NodeMaterialBlockTargets;
  83363. (function(a) {
  83364. a[a.Vertex = 1] = "Vertex",
  83365. a[a.Fragment = 2] = "Fragment",
  83366. a[a.Neutral = 4] = "Neutral",
  83367. a[a.VertexAndFragment = 3] = "VertexAndFragment"
  83368. }
  83369. )(NodeMaterialBlockTargets || (NodeMaterialBlockTargets = {}));
  83370. var NodeMaterialBlockConnectionPointTypes;
  83371. (function(a) {
  83372. a[a.Float = 1] = "Float",
  83373. a[a.Int = 2] = "Int",
  83374. a[a.Vector2 = 4] = "Vector2",
  83375. a[a.Vector3 = 8] = "Vector3",
  83376. a[a.Vector4 = 16] = "Vector4",
  83377. a[a.Color3 = 32] = "Color3",
  83378. a[a.Color4 = 64] = "Color4",
  83379. a[a.Matrix = 128] = "Matrix",
  83380. a[a.Object = 256] = "Object",
  83381. a[a.AutoDetect = 1024] = "AutoDetect",
  83382. a[a.BasedOnInput = 2048] = "BasedOnInput"
  83383. }
  83384. )(NodeMaterialBlockConnectionPointTypes || (NodeMaterialBlockConnectionPointTypes = {}));
  83385. var NodeMaterialBlockConnectionPointMode;
  83386. (function(a) {
  83387. a[a.Uniform = 0] = "Uniform",
  83388. a[a.Attribute = 1] = "Attribute",
  83389. a[a.Varying = 2] = "Varying",
  83390. a[a.Undefined = 3] = "Undefined"
  83391. }
  83392. )(NodeMaterialBlockConnectionPointMode || (NodeMaterialBlockConnectionPointMode = {}));
  83393. var NodeMaterialSystemValues;
  83394. (function(a) {
  83395. a[a.World = 1] = "World",
  83396. a[a.View = 2] = "View",
  83397. a[a.Projection = 3] = "Projection",
  83398. a[a.ViewProjection = 4] = "ViewProjection",
  83399. a[a.WorldView = 5] = "WorldView",
  83400. a[a.WorldViewProjection = 6] = "WorldViewProjection",
  83401. a[a.CameraPosition = 7] = "CameraPosition",
  83402. a[a.FogColor = 8] = "FogColor",
  83403. a[a.DeltaTime = 9] = "DeltaTime",
  83404. a[a.CameraParameters = 10] = "CameraParameters"
  83405. }
  83406. )(NodeMaterialSystemValues || (NodeMaterialSystemValues = {}));
  83407. var NodeMaterialModes;
  83408. (function(a) {
  83409. a[a.Material = 0] = "Material",
  83410. a[a.PostProcess = 1] = "PostProcess",
  83411. a[a.Particle = 2] = "Particle",
  83412. a[a.ProceduralTexture = 3] = "ProceduralTexture"
  83413. }
  83414. )(NodeMaterialModes || (NodeMaterialModes = {}));
  83415. var NodeMaterialConnectionPointCompatibilityStates;
  83416. (function(a) {
  83417. a[a.Compatible = 0] = "Compatible",
  83418. a[a.TypeIncompatible = 1] = "TypeIncompatible",
  83419. a[a.TargetIncompatible = 2] = "TargetIncompatible",
  83420. a[a.HierarchyIssue = 3] = "HierarchyIssue"
  83421. }
  83422. )(NodeMaterialConnectionPointCompatibilityStates || (NodeMaterialConnectionPointCompatibilityStates = {}));
  83423. var NodeMaterialConnectionPointDirection;
  83424. (function(a) {
  83425. a[a.Input = 0] = "Input",
  83426. a[a.Output = 1] = "Output"
  83427. }
  83428. )(NodeMaterialConnectionPointDirection || (NodeMaterialConnectionPointDirection = {}));
  83429. var NodeMaterialConnectionPoint = function() {
  83430. function a(e, i, o) {
  83431. this._connectedPoint = null,
  83432. this._endpoints = new Array,
  83433. this._typeConnectionSource = null,
  83434. this._defaultConnectionPointType = null,
  83435. this._linkedConnectionSource = null,
  83436. this._acceptedConnectionPointType = null,
  83437. this._type = NodeMaterialBlockConnectionPointTypes.Float,
  83438. this._enforceAssociatedVariableName = !1,
  83439. this.needDualDirectionValidation = !1,
  83440. this.acceptedConnectionPointTypes = new Array,
  83441. this.excludedConnectionPointTypes = new Array,
  83442. this.onConnectionObservable = new Observable,
  83443. this.isExposedOnFrame = !1,
  83444. this.exposedPortPosition = -1,
  83445. this._prioritizeVertex = !1,
  83446. this._target = NodeMaterialBlockTargets.VertexAndFragment,
  83447. this._ownerBlock = i,
  83448. this.name = e,
  83449. this._direction = o
  83450. }
  83451. return a.AreEquivalentTypes = function(e, i) {
  83452. switch (e) {
  83453. case NodeMaterialBlockConnectionPointTypes.Vector3:
  83454. {
  83455. if (i === NodeMaterialBlockConnectionPointTypes.Color3)
  83456. return !0;
  83457. break
  83458. }
  83459. case NodeMaterialBlockConnectionPointTypes.Vector4:
  83460. {
  83461. if (i === NodeMaterialBlockConnectionPointTypes.Color4)
  83462. return !0;
  83463. break
  83464. }
  83465. case NodeMaterialBlockConnectionPointTypes.Color3:
  83466. {
  83467. if (i === NodeMaterialBlockConnectionPointTypes.Vector3)
  83468. return !0;
  83469. break
  83470. }
  83471. case NodeMaterialBlockConnectionPointTypes.Color4:
  83472. {
  83473. if (i === NodeMaterialBlockConnectionPointTypes.Vector4)
  83474. return !0;
  83475. break
  83476. }
  83477. }
  83478. return !1
  83479. }
  83480. ,
  83481. Object.defineProperty(a.prototype, "direction", {
  83482. get: function() {
  83483. return this._direction
  83484. },
  83485. enumerable: !1,
  83486. configurable: !0
  83487. }),
  83488. Object.defineProperty(a.prototype, "associatedVariableName", {
  83489. get: function() {
  83490. return this._ownerBlock.isInput ? this._ownerBlock.associatedVariableName : (!this._enforceAssociatedVariableName || !this._associatedVariableName) && this._connectedPoint ? this._connectedPoint.associatedVariableName : this._associatedVariableName
  83491. },
  83492. set: function(e) {
  83493. this._associatedVariableName = e
  83494. },
  83495. enumerable: !1,
  83496. configurable: !0
  83497. }),
  83498. Object.defineProperty(a.prototype, "innerType", {
  83499. get: function() {
  83500. return this._linkedConnectionSource && this._linkedConnectionSource.isConnected ? this.type : this._type
  83501. },
  83502. enumerable: !1,
  83503. configurable: !0
  83504. }),
  83505. Object.defineProperty(a.prototype, "type", {
  83506. get: function() {
  83507. if (this._type === NodeMaterialBlockConnectionPointTypes.AutoDetect) {
  83508. if (this._ownerBlock.isInput)
  83509. return this._ownerBlock.type;
  83510. if (this._connectedPoint)
  83511. return this._connectedPoint.type;
  83512. if (this._linkedConnectionSource && this._linkedConnectionSource.isConnected)
  83513. return this._linkedConnectionSource.type
  83514. }
  83515. if (this._type === NodeMaterialBlockConnectionPointTypes.BasedOnInput) {
  83516. if (this._typeConnectionSource)
  83517. return !this._typeConnectionSource.isConnected && this._defaultConnectionPointType ? this._defaultConnectionPointType : this._typeConnectionSource.type;
  83518. if (this._defaultConnectionPointType)
  83519. return this._defaultConnectionPointType
  83520. }
  83521. return this._type
  83522. },
  83523. set: function(e) {
  83524. this._type = e
  83525. },
  83526. enumerable: !1,
  83527. configurable: !0
  83528. }),
  83529. Object.defineProperty(a.prototype, "target", {
  83530. get: function() {
  83531. return !this._prioritizeVertex || !this._ownerBlock ? this._target : this._target !== NodeMaterialBlockTargets.VertexAndFragment ? this._target : this._ownerBlock.target === NodeMaterialBlockTargets.Fragment ? NodeMaterialBlockTargets.Fragment : NodeMaterialBlockTargets.Vertex
  83532. },
  83533. set: function(e) {
  83534. this._target = e
  83535. },
  83536. enumerable: !1,
  83537. configurable: !0
  83538. }),
  83539. Object.defineProperty(a.prototype, "isConnected", {
  83540. get: function() {
  83541. return this.connectedPoint !== null || this.hasEndpoints
  83542. },
  83543. enumerable: !1,
  83544. configurable: !0
  83545. }),
  83546. Object.defineProperty(a.prototype, "isConnectedToInputBlock", {
  83547. get: function() {
  83548. return this.connectedPoint !== null && this.connectedPoint.ownerBlock.isInput
  83549. },
  83550. enumerable: !1,
  83551. configurable: !0
  83552. }),
  83553. Object.defineProperty(a.prototype, "connectInputBlock", {
  83554. get: function() {
  83555. return this.isConnectedToInputBlock ? this.connectedPoint.ownerBlock : null
  83556. },
  83557. enumerable: !1,
  83558. configurable: !0
  83559. }),
  83560. Object.defineProperty(a.prototype, "connectedPoint", {
  83561. get: function() {
  83562. return this._connectedPoint
  83563. },
  83564. enumerable: !1,
  83565. configurable: !0
  83566. }),
  83567. Object.defineProperty(a.prototype, "ownerBlock", {
  83568. get: function() {
  83569. return this._ownerBlock
  83570. },
  83571. enumerable: !1,
  83572. configurable: !0
  83573. }),
  83574. Object.defineProperty(a.prototype, "sourceBlock", {
  83575. get: function() {
  83576. return this._connectedPoint ? this._connectedPoint.ownerBlock : null
  83577. },
  83578. enumerable: !1,
  83579. configurable: !0
  83580. }),
  83581. Object.defineProperty(a.prototype, "connectedBlocks", {
  83582. get: function() {
  83583. return this._endpoints.length === 0 ? [] : this._endpoints.map(function(e) {
  83584. return e.ownerBlock
  83585. })
  83586. },
  83587. enumerable: !1,
  83588. configurable: !0
  83589. }),
  83590. Object.defineProperty(a.prototype, "endpoints", {
  83591. get: function() {
  83592. return this._endpoints
  83593. },
  83594. enumerable: !1,
  83595. configurable: !0
  83596. }),
  83597. Object.defineProperty(a.prototype, "hasEndpoints", {
  83598. get: function() {
  83599. return this._endpoints && this._endpoints.length > 0
  83600. },
  83601. enumerable: !1,
  83602. configurable: !0
  83603. }),
  83604. Object.defineProperty(a.prototype, "isDirectlyConnectedToVertexOutput", {
  83605. get: function() {
  83606. if (!this.hasEndpoints)
  83607. return !1;
  83608. for (var e = 0, i = this._endpoints; e < i.length; e++) {
  83609. var o = i[e];
  83610. if (o.ownerBlock.target === NodeMaterialBlockTargets.Vertex || (o.ownerBlock.target === NodeMaterialBlockTargets.Neutral || o.ownerBlock.target === NodeMaterialBlockTargets.VertexAndFragment) && o.ownerBlock.outputs.some(function(s) {
  83611. return s.isDirectlyConnectedToVertexOutput
  83612. }))
  83613. return !0
  83614. }
  83615. return !1
  83616. },
  83617. enumerable: !1,
  83618. configurable: !0
  83619. }),
  83620. Object.defineProperty(a.prototype, "isConnectedInVertexShader", {
  83621. get: function() {
  83622. if (this.target === NodeMaterialBlockTargets.Vertex)
  83623. return !0;
  83624. if (!this.hasEndpoints)
  83625. return !1;
  83626. for (var e = 0, i = this._endpoints; e < i.length; e++) {
  83627. var o = i[e];
  83628. if (o.ownerBlock.target === NodeMaterialBlockTargets.Vertex || o.target === NodeMaterialBlockTargets.Vertex || (o.ownerBlock.target === NodeMaterialBlockTargets.Neutral || o.ownerBlock.target === NodeMaterialBlockTargets.VertexAndFragment) && o.ownerBlock.outputs.some(function(s) {
  83629. return s.isConnectedInVertexShader
  83630. }))
  83631. return !0
  83632. }
  83633. return !1
  83634. },
  83635. enumerable: !1,
  83636. configurable: !0
  83637. }),
  83638. Object.defineProperty(a.prototype, "isConnectedInFragmentShader", {
  83639. get: function() {
  83640. if (this.target === NodeMaterialBlockTargets.Fragment)
  83641. return !0;
  83642. if (!this.hasEndpoints)
  83643. return !1;
  83644. for (var e = 0, i = this._endpoints; e < i.length; e++) {
  83645. var o = i[e];
  83646. if (o.ownerBlock.target === NodeMaterialBlockTargets.Fragment || (o.ownerBlock.target === NodeMaterialBlockTargets.Neutral || o.ownerBlock.target === NodeMaterialBlockTargets.VertexAndFragment) && o.ownerBlock.outputs.some(function(s) {
  83647. return s.isConnectedInFragmentShader
  83648. }))
  83649. return !0
  83650. }
  83651. return !1
  83652. },
  83653. enumerable: !1,
  83654. configurable: !0
  83655. }),
  83656. a.prototype.createCustomInputBlock = function() {
  83657. return null
  83658. }
  83659. ,
  83660. a.prototype.getClassName = function() {
  83661. return "NodeMaterialConnectionPoint"
  83662. }
  83663. ,
  83664. a.prototype.canConnectTo = function(e) {
  83665. return this.checkCompatibilityState(e) === NodeMaterialConnectionPointCompatibilityStates.Compatible
  83666. }
  83667. ,
  83668. a.prototype.checkCompatibilityState = function(e) {
  83669. var i = this._ownerBlock
  83670. , o = e.ownerBlock;
  83671. if (i.target === NodeMaterialBlockTargets.Fragment) {
  83672. if (o.target === NodeMaterialBlockTargets.Vertex)
  83673. return NodeMaterialConnectionPointCompatibilityStates.TargetIncompatible;
  83674. for (var s = 0, c = o.outputs; s < c.length; s++) {
  83675. var d = c[s];
  83676. if (d.ownerBlock.target != NodeMaterialBlockTargets.Neutral && d.isConnectedInVertexShader)
  83677. return NodeMaterialConnectionPointCompatibilityStates.TargetIncompatible
  83678. }
  83679. }
  83680. if (this.type !== e.type && e.innerType !== NodeMaterialBlockConnectionPointTypes.AutoDetect)
  83681. return a.AreEquivalentTypes(this.type, e.type) || e.acceptedConnectionPointTypes && e.acceptedConnectionPointTypes.indexOf(this.type) !== -1 || e._acceptedConnectionPointType && a.AreEquivalentTypes(e._acceptedConnectionPointType.type, this.type) ? NodeMaterialConnectionPointCompatibilityStates.Compatible : NodeMaterialConnectionPointCompatibilityStates.TypeIncompatible;
  83682. if (e.excludedConnectionPointTypes && e.excludedConnectionPointTypes.indexOf(this.type) !== -1)
  83683. return NodeMaterialConnectionPointCompatibilityStates.TypeIncompatible;
  83684. var _ = o
  83685. , b = i;
  83686. return this.direction === NodeMaterialConnectionPointDirection.Input && (_ = i,
  83687. b = o),
  83688. _.isAnAncestorOf(b) ? NodeMaterialConnectionPointCompatibilityStates.HierarchyIssue : NodeMaterialConnectionPointCompatibilityStates.Compatible
  83689. }
  83690. ,
  83691. a.prototype.connectTo = function(e, i) {
  83692. if (i === void 0 && (i = !1),
  83693. !i && !this.canConnectTo(e))
  83694. throw "Cannot connect these two connectors.";
  83695. return this._endpoints.push(e),
  83696. e._connectedPoint = this,
  83697. this._enforceAssociatedVariableName = !1,
  83698. this.onConnectionObservable.notifyObservers(e),
  83699. e.onConnectionObservable.notifyObservers(this),
  83700. this
  83701. }
  83702. ,
  83703. a.prototype.disconnectFrom = function(e) {
  83704. var i = this._endpoints.indexOf(e);
  83705. return i === -1 ? this : (this._endpoints.splice(i, 1),
  83706. e._connectedPoint = null,
  83707. this._enforceAssociatedVariableName = !1,
  83708. e._enforceAssociatedVariableName = !1,
  83709. this)
  83710. }
  83711. ,
  83712. a.prototype.serialize = function(e) {
  83713. e === void 0 && (e = !0);
  83714. var i = {};
  83715. return i.name = this.name,
  83716. i.displayName = this.displayName,
  83717. e && this.connectedPoint && (i.inputName = this.name,
  83718. i.targetBlockId = this.connectedPoint.ownerBlock.uniqueId,
  83719. i.targetConnectionName = this.connectedPoint.name,
  83720. i.isExposedOnFrame = !0,
  83721. i.exposedPortPosition = this.exposedPortPosition),
  83722. (this.isExposedOnFrame || this.exposedPortPosition >= 0) && (i.isExposedOnFrame = !0,
  83723. i.exposedPortPosition = this.exposedPortPosition),
  83724. i
  83725. }
  83726. ,
  83727. a.prototype.dispose = function() {
  83728. this.onConnectionObservable.clear()
  83729. }
  83730. ,
  83731. a
  83732. }()
  83733. , NodeMaterialBlock = function() {
  83734. function a(e, i, o, s) {
  83735. i === void 0 && (i = NodeMaterialBlockTargets.Vertex),
  83736. o === void 0 && (o = !1),
  83737. s === void 0 && (s = !1),
  83738. this._isFinalMerger = !1,
  83739. this._isInput = !1,
  83740. this._name = "",
  83741. this._isUnique = !1,
  83742. this.inputsAreExclusive = !1,
  83743. this._codeVariableName = "",
  83744. this._inputs = new Array,
  83745. this._outputs = new Array,
  83746. this.comments = "",
  83747. this.visibleInInspector = !1,
  83748. this.visibleOnFrame = !1,
  83749. this._target = i,
  83750. this._originalTargetIsNeutral = i === NodeMaterialBlockTargets.Neutral,
  83751. this._isFinalMerger = o,
  83752. this._isInput = s,
  83753. this._name = e,
  83754. this.uniqueId = UniqueIdGenerator.UniqueId
  83755. }
  83756. return Object.defineProperty(a.prototype, "name", {
  83757. get: function() {
  83758. return this._name
  83759. },
  83760. set: function(e) {
  83761. !this.validateBlockName(e) || (this._name = e)
  83762. },
  83763. enumerable: !1,
  83764. configurable: !0
  83765. }),
  83766. Object.defineProperty(a.prototype, "isUnique", {
  83767. get: function() {
  83768. return this._isUnique
  83769. },
  83770. enumerable: !1,
  83771. configurable: !0
  83772. }),
  83773. Object.defineProperty(a.prototype, "isFinalMerger", {
  83774. get: function() {
  83775. return this._isFinalMerger
  83776. },
  83777. enumerable: !1,
  83778. configurable: !0
  83779. }),
  83780. Object.defineProperty(a.prototype, "isInput", {
  83781. get: function() {
  83782. return this._isInput
  83783. },
  83784. enumerable: !1,
  83785. configurable: !0
  83786. }),
  83787. Object.defineProperty(a.prototype, "buildId", {
  83788. get: function() {
  83789. return this._buildId
  83790. },
  83791. set: function(e) {
  83792. this._buildId = e
  83793. },
  83794. enumerable: !1,
  83795. configurable: !0
  83796. }),
  83797. Object.defineProperty(a.prototype, "target", {
  83798. get: function() {
  83799. return this._target
  83800. },
  83801. set: function(e) {
  83802. (this._target & e) === 0 && (this._target = e)
  83803. },
  83804. enumerable: !1,
  83805. configurable: !0
  83806. }),
  83807. Object.defineProperty(a.prototype, "inputs", {
  83808. get: function() {
  83809. return this._inputs
  83810. },
  83811. enumerable: !1,
  83812. configurable: !0
  83813. }),
  83814. Object.defineProperty(a.prototype, "outputs", {
  83815. get: function() {
  83816. return this._outputs
  83817. },
  83818. enumerable: !1,
  83819. configurable: !0
  83820. }),
  83821. a.prototype.getInputByName = function(e) {
  83822. var i = this._inputs.filter(function(o) {
  83823. return o.name === e
  83824. });
  83825. return i.length ? i[0] : null
  83826. }
  83827. ,
  83828. a.prototype.getOutputByName = function(e) {
  83829. var i = this._outputs.filter(function(o) {
  83830. return o.name === e
  83831. });
  83832. return i.length ? i[0] : null
  83833. }
  83834. ,
  83835. a.prototype.initialize = function(e) {}
  83836. ,
  83837. a.prototype.bind = function(e, i, o, s) {}
  83838. ,
  83839. a.prototype._declareOutput = function(e, i) {
  83840. return i._getGLType(e.type) + " " + e.associatedVariableName
  83841. }
  83842. ,
  83843. a.prototype._writeVariable = function(e) {
  83844. var i = e.connectedPoint;
  83845. return i ? "" + e.associatedVariableName : "0."
  83846. }
  83847. ,
  83848. a.prototype._writeFloat = function(e) {
  83849. var i = e.toString();
  83850. return i.indexOf(".") === -1 && (i += ".0"),
  83851. "" + i
  83852. }
  83853. ,
  83854. a.prototype.getClassName = function() {
  83855. return "NodeMaterialBlock"
  83856. }
  83857. ,
  83858. a.prototype.registerInput = function(e, i, o, s, c) {
  83859. return o === void 0 && (o = !1),
  83860. c = c != null ? c : new NodeMaterialConnectionPoint(e,this,NodeMaterialConnectionPointDirection.Input),
  83861. c.type = i,
  83862. c.isOptional = o,
  83863. s && (c.target = s),
  83864. this._inputs.push(c),
  83865. this
  83866. }
  83867. ,
  83868. a.prototype.registerOutput = function(e, i, o, s) {
  83869. return s = s != null ? s : new NodeMaterialConnectionPoint(e,this,NodeMaterialConnectionPointDirection.Output),
  83870. s.type = i,
  83871. o && (s.target = o),
  83872. this._outputs.push(s),
  83873. this
  83874. }
  83875. ,
  83876. a.prototype.getFirstAvailableInput = function(e) {
  83877. e === void 0 && (e = null);
  83878. for (var i = 0, o = this._inputs; i < o.length; i++) {
  83879. var s = o[i];
  83880. if (!s.connectedPoint && (!e || e.type === s.type || s.type === NodeMaterialBlockConnectionPointTypes.AutoDetect))
  83881. return s
  83882. }
  83883. return null
  83884. }
  83885. ,
  83886. a.prototype.getFirstAvailableOutput = function(e) {
  83887. e === void 0 && (e = null);
  83888. for (var i = 0, o = this._outputs; i < o.length; i++) {
  83889. var s = o[i];
  83890. if (!e || !e.target || e.target === NodeMaterialBlockTargets.Neutral || (e.target & s.target) !== 0)
  83891. return s
  83892. }
  83893. return null
  83894. }
  83895. ,
  83896. a.prototype.getSiblingOutput = function(e) {
  83897. var i = this._outputs.indexOf(e);
  83898. return i === -1 || i >= this._outputs.length ? null : this._outputs[i + 1]
  83899. }
  83900. ,
  83901. a.prototype.isAnAncestorOf = function(e) {
  83902. for (var i = 0, o = this._outputs; i < o.length; i++) {
  83903. var s = o[i];
  83904. if (!!s.hasEndpoints)
  83905. for (var c = 0, d = s.endpoints; c < d.length; c++) {
  83906. var _ = d[c];
  83907. if (_.ownerBlock === e || _.ownerBlock.isAnAncestorOf(e))
  83908. return !0
  83909. }
  83910. }
  83911. return !1
  83912. }
  83913. ,
  83914. a.prototype.connectTo = function(e, i) {
  83915. if (this._outputs.length !== 0) {
  83916. for (var o = i && i.output ? this.getOutputByName(i.output) : this.getFirstAvailableOutput(e), s = !0; s; ) {
  83917. var c = i && i.input ? e.getInputByName(i.input) : e.getFirstAvailableInput(o);
  83918. if (o && c && o.canConnectTo(c))
  83919. o.connectTo(c),
  83920. s = !1;
  83921. else if (o)
  83922. o = this.getSiblingOutput(o);
  83923. else
  83924. throw "Unable to find a compatible match"
  83925. }
  83926. return this
  83927. }
  83928. }
  83929. ,
  83930. a.prototype._buildBlock = function(e) {}
  83931. ,
  83932. a.prototype.updateUniformsAndSamples = function(e, i, o, s) {}
  83933. ,
  83934. a.prototype.provideFallbacks = function(e, i) {}
  83935. ,
  83936. a.prototype.initializeDefines = function(e, i, o, s) {}
  83937. ,
  83938. a.prototype.prepareDefines = function(e, i, o, s, c) {}
  83939. ,
  83940. a.prototype.autoConfigure = function(e) {}
  83941. ,
  83942. a.prototype.replaceRepeatableContent = function(e, i, o, s) {}
  83943. ,
  83944. Object.defineProperty(a.prototype, "willBeGeneratedIntoVertexShaderFromFragmentShader", {
  83945. get: function() {
  83946. return this.isInput || this.isFinalMerger || this._outputs.some(function(e) {
  83947. return e.isDirectlyConnectedToVertexOutput
  83948. }) ? !1 : !!(this.target === NodeMaterialBlockTargets.Vertex || (this.target === NodeMaterialBlockTargets.VertexAndFragment || this.target === NodeMaterialBlockTargets.Neutral) && this._outputs.some(function(e) {
  83949. return e.isConnectedInVertexShader
  83950. }))
  83951. },
  83952. enumerable: !1,
  83953. configurable: !0
  83954. }),
  83955. a.prototype.isReady = function(e, i, o, s) {
  83956. return !0
  83957. }
  83958. ,
  83959. a.prototype._linkConnectionTypes = function(e, i, o) {
  83960. o === void 0 && (o = !1),
  83961. o ? this._inputs[i]._acceptedConnectionPointType = this._inputs[e] : this._inputs[e]._linkedConnectionSource = this._inputs[i],
  83962. this._inputs[i]._linkedConnectionSource = this._inputs[e]
  83963. }
  83964. ,
  83965. a.prototype._processBuild = function(e, i, o, s) {
  83966. e.build(i, s);
  83967. var c = i._vertexState != null
  83968. , d = e._buildTarget === NodeMaterialBlockTargets.Vertex && e.target !== NodeMaterialBlockTargets.VertexAndFragment;
  83969. if (c && ((e.target & e._buildTarget) === 0 || (e.target & o.target) === 0 || this.target !== NodeMaterialBlockTargets.VertexAndFragment && d) && (!e.isInput && i.target !== e._buildTarget || e.isInput && e.isAttribute && !e._noContextSwitch)) {
  83970. var _ = o.connectedPoint;
  83971. i._vertexState._emitVaryingFromString("v_" + _.associatedVariableName, i._getGLType(_.type)) && (i._vertexState.compilationString += "v_" + _.associatedVariableName + " = " + _.associatedVariableName + `;\r
  83972. `),
  83973. o.associatedVariableName = "v_" + _.associatedVariableName,
  83974. o._enforceAssociatedVariableName = !0
  83975. }
  83976. }
  83977. ,
  83978. a.prototype.validateBlockName = function(e) {
  83979. for (var i = ["position", "normal", "tangent", "particle_positionw", "uv", "uv2", "uv3", "uv4", "uv5", "uv6", "position2d", "particle_uv", "matricesIndices", "matricesWeights", "world0", "world1", "world2", "world3", "particle_color", "particle_texturemask"], o = 0, s = i; o < s.length; o++) {
  83980. var c = s[o];
  83981. if (e === c)
  83982. return !1
  83983. }
  83984. return !0
  83985. }
  83986. ,
  83987. a.prototype.build = function(e, i) {
  83988. if (this._buildId === e.sharedData.buildId)
  83989. return !0;
  83990. if (!this.isInput)
  83991. for (var o = 0, s = this._outputs; o < s.length; o++) {
  83992. var c = s[o];
  83993. c.associatedVariableName || (c.associatedVariableName = e._getFreeVariableName(c.name))
  83994. }
  83995. for (var d = 0, _ = this._inputs; d < _.length; d++) {
  83996. var b = _[d];
  83997. if (!b.connectedPoint) {
  83998. b.isOptional || e.sharedData.checks.notConnectedNonOptionalInputs.push(b);
  83999. continue
  84000. }
  84001. if (!(this.target !== NodeMaterialBlockTargets.Neutral && ((b.target & this.target) === 0 || (b.target & e.target) === 0))) {
  84002. var k = b.connectedPoint.ownerBlock;
  84003. k && k !== this && this._processBuild(k, e, b, i)
  84004. }
  84005. }
  84006. if (this._buildId === e.sharedData.buildId)
  84007. return !0;
  84008. if (e.sharedData.verbose && console.log((e.target === NodeMaterialBlockTargets.Vertex ? "Vertex shader" : "Fragment shader") + ": Building " + this.name + " [" + this.getClassName() + "]"),
  84009. this.isFinalMerger)
  84010. switch (e.target) {
  84011. case NodeMaterialBlockTargets.Vertex:
  84012. e.sharedData.checks.emitVertex = !0;
  84013. break;
  84014. case NodeMaterialBlockTargets.Fragment:
  84015. e.sharedData.checks.emitFragment = !0;
  84016. break
  84017. }
  84018. !this.isInput && e.sharedData.emitComments && (e.compilationString += `\r
  84019. //` + this.name + `\r
  84020. `),
  84021. this._buildBlock(e),
  84022. this._buildId = e.sharedData.buildId,
  84023. this._buildTarget = e.target;
  84024. for (var j = 0, $ = this._outputs; j < $.length; j++) {
  84025. var c = $[j];
  84026. if ((c.target & e.target) !== 0)
  84027. for (var _e = 0, et = c.endpoints; _e < et.length; _e++) {
  84028. var tt = et[_e]
  84029. , k = tt.ownerBlock;
  84030. k && (k.target & e.target) !== 0 && i.indexOf(k) !== -1 && this._processBuild(k, e, tt, i)
  84031. }
  84032. }
  84033. return !1
  84034. }
  84035. ,
  84036. a.prototype._inputRename = function(e) {
  84037. return e
  84038. }
  84039. ,
  84040. a.prototype._outputRename = function(e) {
  84041. return e
  84042. }
  84043. ,
  84044. a.prototype._dumpPropertiesCode = function() {
  84045. var e = this._codeVariableName;
  84046. return e + ".visibleInInspector = " + this.visibleInInspector + `;\r
  84047. ` + e + ".visibleOnFrame = " + this.visibleOnFrame + `;\r
  84048. ` + e + ".target = " + this.target + `;\r
  84049. `
  84050. }
  84051. ,
  84052. a.prototype._dumpCode = function(e, i) {
  84053. i.push(this);
  84054. var o, s = this.name.replace(/[^A-Za-z_]+/g, "");
  84055. if (this._codeVariableName = s || this.getClassName() + "_" + this.uniqueId,
  84056. e.indexOf(this._codeVariableName) !== -1) {
  84057. var c = 0;
  84058. do
  84059. c++,
  84060. this._codeVariableName = s + c;
  84061. while (e.indexOf(this._codeVariableName) !== -1)
  84062. }
  84063. e.push(this._codeVariableName),
  84064. o = `\r
  84065. // ` + this.getClassName() + `\r
  84066. `,
  84067. this.comments && (o += "// " + this.comments + `\r
  84068. `),
  84069. o += "var " + this._codeVariableName + " = new BABYLON." + this.getClassName() + '("' + this.name + `");\r
  84070. `,
  84071. o += this._dumpPropertiesCode();
  84072. for (var d = 0, _ = this.inputs; d < _.length; d++) {
  84073. var b = _[d];
  84074. if (!!b.isConnected) {
  84075. var k = b.connectedPoint
  84076. , j = k.ownerBlock;
  84077. i.indexOf(j) === -1 && (o += j._dumpCode(e, i))
  84078. }
  84079. }
  84080. for (var $ = 0, _e = this.outputs; $ < _e.length; $++) {
  84081. var et = _e[$];
  84082. if (!!et.hasEndpoints)
  84083. for (var tt = 0, rt = et.endpoints; tt < rt.length; tt++) {
  84084. var it = rt[tt]
  84085. , j = it.ownerBlock;
  84086. j && i.indexOf(j) === -1 && (o += j._dumpCode(e, i))
  84087. }
  84088. }
  84089. return o
  84090. }
  84091. ,
  84092. a.prototype._dumpCodeForOutputConnections = function(e) {
  84093. var i = "";
  84094. if (e.indexOf(this) !== -1)
  84095. return i;
  84096. e.push(this);
  84097. for (var o = 0, s = this.inputs; o < s.length; o++) {
  84098. var c = s[o];
  84099. if (!!c.isConnected) {
  84100. var d = c.connectedPoint
  84101. , _ = d.ownerBlock;
  84102. i += _._dumpCodeForOutputConnections(e),
  84103. i += _._codeVariableName + "." + _._outputRename(d.name) + ".connectTo(" + this._codeVariableName + "." + this._inputRename(c.name) + `);\r
  84104. `
  84105. }
  84106. }
  84107. return i
  84108. }
  84109. ,
  84110. a.prototype.clone = function(e, i) {
  84111. i === void 0 && (i = "");
  84112. var o = this.serialize()
  84113. , s = GetClass(o.customType);
  84114. if (s) {
  84115. var c = new s;
  84116. return c._deserialize(o, e, i),
  84117. c
  84118. }
  84119. return null
  84120. }
  84121. ,
  84122. a.prototype.serialize = function() {
  84123. var e = {};
  84124. e.customType = "BABYLON." + this.getClassName(),
  84125. e.id = this.uniqueId,
  84126. e.name = this.name,
  84127. e.comments = this.comments,
  84128. e.visibleInInspector = this.visibleInInspector,
  84129. e.visibleOnFrame = this.visibleOnFrame,
  84130. e.target = this.target,
  84131. e.inputs = [],
  84132. e.outputs = [];
  84133. for (var i = 0, o = this.inputs; i < o.length; i++) {
  84134. var s = o[i];
  84135. e.inputs.push(s.serialize())
  84136. }
  84137. for (var c = 0, d = this.outputs; c < d.length; c++) {
  84138. var _ = d[c];
  84139. e.outputs.push(_.serialize(!1))
  84140. }
  84141. return e
  84142. }
  84143. ,
  84144. a.prototype._deserialize = function(e, i, o) {
  84145. var s;
  84146. this.name = e.name,
  84147. this.comments = e.comments,
  84148. this.visibleInInspector = !!e.visibleInInspector,
  84149. this.visibleOnFrame = !!e.visibleOnFrame,
  84150. this._target = (s = e.target) !== null && s !== void 0 ? s : this.target,
  84151. this._deserializePortDisplayNamesAndExposedOnFrame(e)
  84152. }
  84153. ,
  84154. a.prototype._deserializePortDisplayNamesAndExposedOnFrame = function(e) {
  84155. var i = this
  84156. , o = e.inputs
  84157. , s = e.outputs;
  84158. o && o.forEach(function(c, d) {
  84159. c.displayName && (i.inputs[d].displayName = c.displayName),
  84160. c.isExposedOnFrame && (i.inputs[d].isExposedOnFrame = c.isExposedOnFrame,
  84161. i.inputs[d].exposedPortPosition = c.exposedPortPosition)
  84162. }),
  84163. s && s.forEach(function(c, d) {
  84164. c.displayName && (i.outputs[d].displayName = c.displayName),
  84165. c.isExposedOnFrame && (i.outputs[d].isExposedOnFrame = c.isExposedOnFrame,
  84166. i.outputs[d].exposedPortPosition = c.exposedPortPosition)
  84167. })
  84168. }
  84169. ,
  84170. a.prototype.dispose = function() {
  84171. for (var e = 0, i = this.inputs; e < i.length; e++) {
  84172. var o = i[e];
  84173. o.dispose()
  84174. }
  84175. for (var s = 0, c = this.outputs; s < c.length; s++) {
  84176. var d = c[s];
  84177. d.dispose()
  84178. }
  84179. }
  84180. ,
  84181. a
  84182. }()
  84183. , NodeMaterialBuildState = function() {
  84184. function a() {
  84185. this.supportUniformBuffers = !1,
  84186. this.attributes = new Array,
  84187. this.uniforms = new Array,
  84188. this.constants = new Array,
  84189. this.samplers = new Array,
  84190. this.functions = {},
  84191. this.extensions = {},
  84192. this.counters = {},
  84193. this._attributeDeclaration = "",
  84194. this._uniformDeclaration = "",
  84195. this._constantDeclaration = "",
  84196. this._samplerDeclaration = "",
  84197. this._varyingTransfer = "",
  84198. this._injectAtEnd = "",
  84199. this._repeatableContentAnchorIndex = 0,
  84200. this._builtCompilationString = "",
  84201. this.compilationString = ""
  84202. }
  84203. return a.prototype.finalize = function(e) {
  84204. var i = e.sharedData.emitComments
  84205. , o = this.target === NodeMaterialBlockTargets.Fragment;
  84206. this.compilationString = `\r
  84207. ` + (i ? `//Entry point\r
  84208. ` : "") + `void main(void) {\r
  84209. ` + this.compilationString,
  84210. this._constantDeclaration && (this.compilationString = `\r
  84211. ` + (i ? `//Constants\r
  84212. ` : "") + this._constantDeclaration + `\r
  84213. ` + this.compilationString);
  84214. var s = "";
  84215. for (var c in this.functions)
  84216. s += this.functions[c] + `\r
  84217. `;
  84218. this.compilationString = `\r
  84219. ` + s + `\r
  84220. ` + this.compilationString,
  84221. !o && this._varyingTransfer && (this.compilationString = this.compilationString + `\r
  84222. ` + this._varyingTransfer),
  84223. this._injectAtEnd && (this.compilationString = this.compilationString + `\r
  84224. ` + this._injectAtEnd),
  84225. this.compilationString = this.compilationString + `\r
  84226. }`,
  84227. this.sharedData.varyingDeclaration && (this.compilationString = `\r
  84228. ` + (i ? `//Varyings\r
  84229. ` : "") + this.sharedData.varyingDeclaration + `\r
  84230. ` + this.compilationString),
  84231. this._samplerDeclaration && (this.compilationString = `\r
  84232. ` + (i ? `//Samplers\r
  84233. ` : "") + this._samplerDeclaration + `\r
  84234. ` + this.compilationString),
  84235. this._uniformDeclaration && (this.compilationString = `\r
  84236. ` + (i ? `//Uniforms\r
  84237. ` : "") + this._uniformDeclaration + `\r
  84238. ` + this.compilationString),
  84239. this._attributeDeclaration && !o && (this.compilationString = `\r
  84240. ` + (i ? `//Attributes\r
  84241. ` : "") + this._attributeDeclaration + `\r
  84242. ` + this.compilationString),
  84243. this.compilationString = `precision highp float;\r
  84244. ` + this.compilationString;
  84245. for (var d in this.extensions) {
  84246. var _ = this.extensions[d];
  84247. this.compilationString = `\r
  84248. ` + _ + `\r
  84249. ` + this.compilationString
  84250. }
  84251. this._builtCompilationString = this.compilationString
  84252. }
  84253. ,
  84254. Object.defineProperty(a.prototype, "_repeatableContentAnchor", {
  84255. get: function() {
  84256. return "###___ANCHOR" + this._repeatableContentAnchorIndex++ + "___###"
  84257. },
  84258. enumerable: !1,
  84259. configurable: !0
  84260. }),
  84261. a.prototype._getFreeVariableName = function(e) {
  84262. return e = e.replace(/[^a-zA-Z_]+/g, ""),
  84263. this.sharedData.variableNames[e] === void 0 ? (this.sharedData.variableNames[e] = 0,
  84264. e === "output" || e === "texture" ? e + this.sharedData.variableNames[e] : e) : (this.sharedData.variableNames[e]++,
  84265. e + this.sharedData.variableNames[e])
  84266. }
  84267. ,
  84268. a.prototype._getFreeDefineName = function(e) {
  84269. return this.sharedData.defineNames[e] === void 0 ? this.sharedData.defineNames[e] = 0 : this.sharedData.defineNames[e]++,
  84270. e + this.sharedData.defineNames[e]
  84271. }
  84272. ,
  84273. a.prototype._excludeVariableName = function(e) {
  84274. this.sharedData.variableNames[e] = 0
  84275. }
  84276. ,
  84277. a.prototype._emit2DSampler = function(e) {
  84278. this.samplers.indexOf(e) < 0 && (this._samplerDeclaration += "uniform sampler2D " + e + `;\r
  84279. `,
  84280. this.samplers.push(e))
  84281. }
  84282. ,
  84283. a.prototype._getGLType = function(e) {
  84284. switch (e) {
  84285. case NodeMaterialBlockConnectionPointTypes.Float:
  84286. return "float";
  84287. case NodeMaterialBlockConnectionPointTypes.Int:
  84288. return "int";
  84289. case NodeMaterialBlockConnectionPointTypes.Vector2:
  84290. return "vec2";
  84291. case NodeMaterialBlockConnectionPointTypes.Color3:
  84292. case NodeMaterialBlockConnectionPointTypes.Vector3:
  84293. return "vec3";
  84294. case NodeMaterialBlockConnectionPointTypes.Color4:
  84295. case NodeMaterialBlockConnectionPointTypes.Vector4:
  84296. return "vec4";
  84297. case NodeMaterialBlockConnectionPointTypes.Matrix:
  84298. return "mat4"
  84299. }
  84300. return ""
  84301. }
  84302. ,
  84303. a.prototype._emitExtension = function(e, i, o) {
  84304. o === void 0 && (o = ""),
  84305. !this.extensions[e] && (o && (i = "#if " + o + `\r
  84306. ` + i + `\r
  84307. #endif`),
  84308. this.extensions[e] = i)
  84309. }
  84310. ,
  84311. a.prototype._emitFunction = function(e, i, o) {
  84312. this.functions[e] || (this.sharedData.emitComments && (i = o + `\r
  84313. ` + i),
  84314. this.functions[e] = i)
  84315. }
  84316. ,
  84317. a.prototype._emitCodeFromInclude = function(e, i, o) {
  84318. if (o && o.repeatKey)
  84319. return "#include<" + e + ">[0.." + o.repeatKey + `]\r
  84320. `;
  84321. var s = Effect.IncludesShadersStore[e] + `\r
  84322. `;
  84323. if (this.sharedData.emitComments && (s = i + `\r
  84324. ` + s),
  84325. !o)
  84326. return s;
  84327. if (o.replaceStrings)
  84328. for (var c = 0; c < o.replaceStrings.length; c++) {
  84329. var d = o.replaceStrings[c];
  84330. s = s.replace(d.search, d.replace)
  84331. }
  84332. return s
  84333. }
  84334. ,
  84335. a.prototype._emitFunctionFromInclude = function(e, i, o, s) {
  84336. s === void 0 && (s = "");
  84337. var c = e + s;
  84338. if (!this.functions[c]) {
  84339. if (!o || !o.removeAttributes && !o.removeUniforms && !o.removeVaryings && !o.removeIfDef && !o.replaceStrings) {
  84340. o && o.repeatKey ? this.functions[c] = "#include<" + e + ">[0.." + o.repeatKey + `]\r
  84341. ` : this.functions[c] = "#include<" + e + `>\r
  84342. `,
  84343. this.sharedData.emitComments && (this.functions[c] = i + `\r
  84344. ` + this.functions[c]);
  84345. return
  84346. }
  84347. if (this.functions[c] = Effect.IncludesShadersStore[e],
  84348. this.sharedData.emitComments && (this.functions[c] = i + `\r
  84349. ` + this.functions[c]),
  84350. o.removeIfDef && (this.functions[c] = this.functions[c].replace(/^\s*?#ifdef.+$/gm, ""),
  84351. this.functions[c] = this.functions[c].replace(/^\s*?#endif.*$/gm, ""),
  84352. this.functions[c] = this.functions[c].replace(/^\s*?#else.*$/gm, ""),
  84353. this.functions[c] = this.functions[c].replace(/^\s*?#elif.*$/gm, "")),
  84354. o.removeAttributes && (this.functions[c] = this.functions[c].replace(/^\s*?attribute.+$/gm, "")),
  84355. o.removeUniforms && (this.functions[c] = this.functions[c].replace(/^\s*?uniform.+$/gm, "")),
  84356. o.removeVaryings && (this.functions[c] = this.functions[c].replace(/^\s*?varying.+$/gm, "")),
  84357. o.replaceStrings)
  84358. for (var d = 0; d < o.replaceStrings.length; d++) {
  84359. var _ = o.replaceStrings[d];
  84360. this.functions[c] = this.functions[c].replace(_.search, _.replace)
  84361. }
  84362. }
  84363. }
  84364. ,
  84365. a.prototype._registerTempVariable = function(e) {
  84366. return this.sharedData.temps.indexOf(e) !== -1 ? !1 : (this.sharedData.temps.push(e),
  84367. !0)
  84368. }
  84369. ,
  84370. a.prototype._emitVaryingFromString = function(e, i, o, s) {
  84371. return o === void 0 && (o = ""),
  84372. s === void 0 && (s = !1),
  84373. this.sharedData.varyings.indexOf(e) !== -1 ? !1 : (this.sharedData.varyings.push(e),
  84374. o && (StartsWith(o, "defined(") ? this.sharedData.varyingDeclaration += "#if " + o + `\r
  84375. ` : this.sharedData.varyingDeclaration += (s ? "#ifndef" : "#ifdef") + " " + o + `\r
  84376. `),
  84377. this.sharedData.varyingDeclaration += "varying " + i + " " + e + `;\r
  84378. `,
  84379. o && (this.sharedData.varyingDeclaration += `#endif\r
  84380. `),
  84381. !0)
  84382. }
  84383. ,
  84384. a.prototype._emitUniformFromString = function(e, i, o, s) {
  84385. o === void 0 && (o = ""),
  84386. s === void 0 && (s = !1),
  84387. this.uniforms.indexOf(e) === -1 && (this.uniforms.push(e),
  84388. o && (StartsWith(o, "defined(") ? this._uniformDeclaration += "#if " + o + `\r
  84389. ` : this._uniformDeclaration += (s ? "#ifndef" : "#ifdef") + " " + o + `\r
  84390. `),
  84391. this._uniformDeclaration += "uniform " + i + " " + e + `;\r
  84392. `,
  84393. o && (this._uniformDeclaration += `#endif\r
  84394. `))
  84395. }
  84396. ,
  84397. a.prototype._emitFloat = function(e) {
  84398. return e.toString() === e.toFixed(0) ? e + ".0" : e.toString()
  84399. }
  84400. ,
  84401. a
  84402. }()
  84403. , NodeMaterialBuildStateSharedData = function() {
  84404. function a() {
  84405. this.temps = new Array,
  84406. this.varyings = new Array,
  84407. this.varyingDeclaration = "",
  84408. this.inputBlocks = new Array,
  84409. this.textureBlocks = new Array,
  84410. this.bindableBlocks = new Array,
  84411. this.forcedBindableBlocks = new Array,
  84412. this.blocksWithFallbacks = new Array,
  84413. this.blocksWithDefines = new Array,
  84414. this.repeatableContentBlocks = new Array,
  84415. this.dynamicUniformBlocks = new Array,
  84416. this.blockingBlocks = new Array,
  84417. this.animatedInputs = new Array,
  84418. this.variableNames = {},
  84419. this.defineNames = {},
  84420. this.hints = {
  84421. needWorldViewMatrix: !1,
  84422. needWorldViewProjectionMatrix: !1,
  84423. needAlphaBlending: !1,
  84424. needAlphaTesting: !1
  84425. },
  84426. this.checks = {
  84427. emitVertex: !1,
  84428. emitFragment: !1,
  84429. notConnectedNonOptionalInputs: new Array
  84430. },
  84431. this.allowEmptyVertexProgram = !1,
  84432. this.variableNames.position = 0,
  84433. this.variableNames.normal = 0,
  84434. this.variableNames.tangent = 0,
  84435. this.variableNames.uv = 0,
  84436. this.variableNames.uv2 = 0,
  84437. this.variableNames.uv3 = 0,
  84438. this.variableNames.uv4 = 0,
  84439. this.variableNames.uv5 = 0,
  84440. this.variableNames.uv6 = 0,
  84441. this.variableNames.color = 0,
  84442. this.variableNames.matricesIndices = 0,
  84443. this.variableNames.matricesWeights = 0,
  84444. this.variableNames.matricesIndicesExtra = 0,
  84445. this.variableNames.matricesWeightsExtra = 0,
  84446. this.variableNames.diffuseBase = 0,
  84447. this.variableNames.specularBase = 0,
  84448. this.variableNames.worldPos = 0,
  84449. this.variableNames.shadow = 0,
  84450. this.variableNames.view = 0,
  84451. this.variableNames.vTBN = 0,
  84452. this.defineNames.MAINUV0 = 0,
  84453. this.defineNames.MAINUV1 = 0,
  84454. this.defineNames.MAINUV2 = 0,
  84455. this.defineNames.MAINUV3 = 0,
  84456. this.defineNames.MAINUV4 = 0,
  84457. this.defineNames.MAINUV5 = 0,
  84458. this.defineNames.MAINUV6 = 0,
  84459. this.defineNames.MAINUV7 = 0
  84460. }
  84461. return a.prototype.emitErrors = function() {
  84462. var e = "";
  84463. !this.checks.emitVertex && !this.allowEmptyVertexProgram && (e += `NodeMaterial does not have a vertex output. You need to at least add a block that generates a glPosition value.\r
  84464. `),
  84465. this.checks.emitFragment || (e += `NodeMaterial does not have a fragment output. You need to at least add a block that generates a glFragColor value.\r
  84466. `);
  84467. for (var i = 0, o = this.checks.notConnectedNonOptionalInputs; i < o.length; i++) {
  84468. var s = o[i];
  84469. e += "input " + s.name + " from block " + s.ownerBlock.name + "[" + s.ownerBlock.getClassName() + `] is not connected and is not optional.\r
  84470. `
  84471. }
  84472. if (e)
  84473. throw `Build of NodeMaterial failed:\r
  84474. ` + e
  84475. }
  84476. ,
  84477. a
  84478. }()
  84479. , TransformBlock = function(a) {
  84480. __extends(e, a);
  84481. function e(i) {
  84482. var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
  84483. return o.complementW = 1,
  84484. o.complementZ = 0,
  84485. o.target = NodeMaterialBlockTargets.Vertex,
  84486. o.registerInput("vector", NodeMaterialBlockConnectionPointTypes.AutoDetect),
  84487. o.registerInput("transform", NodeMaterialBlockConnectionPointTypes.Matrix),
  84488. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Vector4),
  84489. o.registerOutput("xyz", NodeMaterialBlockConnectionPointTypes.Vector3),
  84490. o._inputs[0].onConnectionObservable.add(function(s) {
  84491. if (s.ownerBlock.isInput) {
  84492. var c = s.ownerBlock;
  84493. (c.name === "normal" || c.name === "tangent") && (o.complementW = 0)
  84494. }
  84495. }),
  84496. o
  84497. }
  84498. return e.prototype.getClassName = function() {
  84499. return "TransformBlock"
  84500. }
  84501. ,
  84502. Object.defineProperty(e.prototype, "vector", {
  84503. get: function() {
  84504. return this._inputs[0]
  84505. },
  84506. enumerable: !1,
  84507. configurable: !0
  84508. }),
  84509. Object.defineProperty(e.prototype, "output", {
  84510. get: function() {
  84511. return this._outputs[0]
  84512. },
  84513. enumerable: !1,
  84514. configurable: !0
  84515. }),
  84516. Object.defineProperty(e.prototype, "xyz", {
  84517. get: function() {
  84518. return this._outputs[1]
  84519. },
  84520. enumerable: !1,
  84521. configurable: !0
  84522. }),
  84523. Object.defineProperty(e.prototype, "transform", {
  84524. get: function() {
  84525. return this._inputs[1]
  84526. },
  84527. enumerable: !1,
  84528. configurable: !0
  84529. }),
  84530. e.prototype._buildBlock = function(i) {
  84531. a.prototype._buildBlock.call(this, i);
  84532. var o = this.vector
  84533. , s = this.transform;
  84534. if (o.connectedPoint) {
  84535. if (this.complementW === 0) {
  84536. var c = "//" + this.name;
  84537. i._emitFunctionFromInclude("helperFunctions", c),
  84538. i.sharedData.blocksWithDefines.push(this);
  84539. var d = i._getFreeVariableName(s.associatedVariableName + "_NUS");
  84540. switch (i.compilationString += "mat3 " + d + " = mat3(" + s.associatedVariableName + `);\r
  84541. `,
  84542. i.compilationString += `#ifdef NONUNIFORMSCALING\r
  84543. `,
  84544. i.compilationString += d + " = transposeMat3(inverseMat3(" + d + `));\r
  84545. `,
  84546. i.compilationString += `#endif\r
  84547. `,
  84548. o.connectedPoint.type) {
  84549. case NodeMaterialBlockConnectionPointTypes.Vector2:
  84550. i.compilationString += this._declareOutput(this.output, i) + (" = vec4(" + d + " * vec3(" + o.associatedVariableName + ", " + this._writeFloat(this.complementZ) + "), " + this._writeFloat(this.complementW) + `);\r
  84551. `);
  84552. break;
  84553. case NodeMaterialBlockConnectionPointTypes.Vector3:
  84554. case NodeMaterialBlockConnectionPointTypes.Color3:
  84555. i.compilationString += this._declareOutput(this.output, i) + (" = vec4(" + d + " * " + o.associatedVariableName + ", " + this._writeFloat(this.complementW) + `);\r
  84556. `);
  84557. break;
  84558. default:
  84559. i.compilationString += this._declareOutput(this.output, i) + (" = vec4(" + d + " * " + o.associatedVariableName + ".xyz, " + this._writeFloat(this.complementW) + `);\r
  84560. `);
  84561. break
  84562. }
  84563. } else {
  84564. var d = s.associatedVariableName;
  84565. switch (o.connectedPoint.type) {
  84566. case NodeMaterialBlockConnectionPointTypes.Vector2:
  84567. i.compilationString += this._declareOutput(this.output, i) + (" = " + d + " * vec4(" + o.associatedVariableName + ", " + this._writeFloat(this.complementZ) + ", " + this._writeFloat(this.complementW) + `);\r
  84568. `);
  84569. break;
  84570. case NodeMaterialBlockConnectionPointTypes.Vector3:
  84571. case NodeMaterialBlockConnectionPointTypes.Color3:
  84572. i.compilationString += this._declareOutput(this.output, i) + (" = " + d + " * vec4(" + o.associatedVariableName + ", " + this._writeFloat(this.complementW) + `);\r
  84573. `);
  84574. break;
  84575. default:
  84576. i.compilationString += this._declareOutput(this.output, i) + (" = " + d + " * " + o.associatedVariableName + `;\r
  84577. `);
  84578. break
  84579. }
  84580. }
  84581. this.xyz.hasEndpoints && (i.compilationString += this._declareOutput(this.xyz, i) + (" = " + this.output.associatedVariableName + `.xyz;\r
  84582. `))
  84583. }
  84584. return this
  84585. }
  84586. ,
  84587. e.prototype.prepareDefines = function(i, o, s, c, d) {
  84588. i.nonUniformScaling && s.setValue("NONUNIFORMSCALING", !0)
  84589. }
  84590. ,
  84591. e.prototype.serialize = function() {
  84592. var i = a.prototype.serialize.call(this);
  84593. return i.complementZ = this.complementZ,
  84594. i.complementW = this.complementW,
  84595. i
  84596. }
  84597. ,
  84598. e.prototype._deserialize = function(i, o, s) {
  84599. a.prototype._deserialize.call(this, i, o, s),
  84600. this.complementZ = i.complementZ !== void 0 ? i.complementZ : 0,
  84601. this.complementW = i.complementW !== void 0 ? i.complementW : 1
  84602. }
  84603. ,
  84604. e.prototype._dumpPropertiesCode = function() {
  84605. var i = a.prototype._dumpPropertiesCode.call(this) + (this._codeVariableName + ".complementZ = " + this.complementZ + `;\r
  84606. `);
  84607. return i += this._codeVariableName + ".complementW = " + this.complementW + `;\r
  84608. `,
  84609. i
  84610. }
  84611. ,
  84612. e
  84613. }(NodeMaterialBlock);
  84614. RegisterClass("BABYLON.TransformBlock", TransformBlock);
  84615. var VertexOutputBlock = function(a) {
  84616. __extends(e, a);
  84617. function e(i) {
  84618. var o = a.call(this, i, NodeMaterialBlockTargets.Vertex, !0) || this;
  84619. return o.registerInput("vector", NodeMaterialBlockConnectionPointTypes.Vector4),
  84620. o
  84621. }
  84622. return e.prototype.getClassName = function() {
  84623. return "VertexOutputBlock"
  84624. }
  84625. ,
  84626. Object.defineProperty(e.prototype, "vector", {
  84627. get: function() {
  84628. return this._inputs[0]
  84629. },
  84630. enumerable: !1,
  84631. configurable: !0
  84632. }),
  84633. e.prototype._isLogarithmicDepthEnabled = function(i) {
  84634. for (var o = 0, s = i; o < s.length; o++) {
  84635. var c = s[o];
  84636. if (c.useLogarithmicDepth)
  84637. return !0
  84638. }
  84639. return !1
  84640. }
  84641. ,
  84642. e.prototype._buildBlock = function(i) {
  84643. a.prototype._buildBlock.call(this, i);
  84644. var o = this.vector;
  84645. return i.compilationString += "gl_Position = " + o.associatedVariableName + `;\r
  84646. `,
  84647. this._isLogarithmicDepthEnabled(i.sharedData.fragmentOutputNodes) && (i._emitUniformFromString("logarithmicDepthConstant", "float"),
  84648. i._emitVaryingFromString("vFragmentDepth", "float"),
  84649. i.compilationString += `vFragmentDepth = 1.0 + gl_Position.w;\r
  84650. `,
  84651. i.compilationString += `gl_Position.z = log2(max(0.000001, vFragmentDepth)) * logarithmicDepthConstant;\r
  84652. `),
  84653. this
  84654. }
  84655. ,
  84656. e
  84657. }(NodeMaterialBlock);
  84658. RegisterClass("BABYLON.VertexOutputBlock", VertexOutputBlock);
  84659. var PropertyTypeForEdition;
  84660. (function(a) {
  84661. a[a.Boolean = 0] = "Boolean",
  84662. a[a.Float = 1] = "Float",
  84663. a[a.Int = 2] = "Int",
  84664. a[a.Vector2 = 3] = "Vector2",
  84665. a[a.List = 4] = "List"
  84666. }
  84667. )(PropertyTypeForEdition || (PropertyTypeForEdition = {}));
  84668. function editableInPropertyPage(a, e, i, o) {
  84669. return e === void 0 && (e = PropertyTypeForEdition.Boolean),
  84670. i === void 0 && (i = "PROPERTIES"),
  84671. function(s, c) {
  84672. var d = s._propStore;
  84673. d || (d = [],
  84674. s._propStore = d),
  84675. d.push({
  84676. propertyName: c,
  84677. displayName: a,
  84678. type: e,
  84679. groupName: i,
  84680. options: o != null ? o : {}
  84681. })
  84682. }
  84683. }
  84684. var FragmentOutputBlock = function(a) {
  84685. __extends(e, a);
  84686. function e(i) {
  84687. var o = a.call(this, i, NodeMaterialBlockTargets.Fragment, !0) || this;
  84688. return o.convertToGammaSpace = !1,
  84689. o.convertToLinearSpace = !1,
  84690. o.useLogarithmicDepth = !1,
  84691. o.registerInput("rgba", NodeMaterialBlockConnectionPointTypes.Color4, !0),
  84692. o.registerInput("rgb", NodeMaterialBlockConnectionPointTypes.Color3, !0),
  84693. o.registerInput("a", NodeMaterialBlockConnectionPointTypes.Float, !0),
  84694. o.rgb.acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float),
  84695. o
  84696. }
  84697. return e.prototype.getClassName = function() {
  84698. return "FragmentOutputBlock"
  84699. }
  84700. ,
  84701. e.prototype.initialize = function(i) {
  84702. i._excludeVariableName("logarithmicDepthConstant"),
  84703. i._excludeVariableName("vFragmentDepth")
  84704. }
  84705. ,
  84706. Object.defineProperty(e.prototype, "rgba", {
  84707. get: function() {
  84708. return this._inputs[0]
  84709. },
  84710. enumerable: !1,
  84711. configurable: !0
  84712. }),
  84713. Object.defineProperty(e.prototype, "rgb", {
  84714. get: function() {
  84715. return this._inputs[1]
  84716. },
  84717. enumerable: !1,
  84718. configurable: !0
  84719. }),
  84720. Object.defineProperty(e.prototype, "a", {
  84721. get: function() {
  84722. return this._inputs[2]
  84723. },
  84724. enumerable: !1,
  84725. configurable: !0
  84726. }),
  84727. e.prototype.prepareDefines = function(i, o, s) {
  84728. s.setValue(this._linearDefineName, this.convertToLinearSpace, !0),
  84729. s.setValue(this._gammaDefineName, this.convertToGammaSpace, !0)
  84730. }
  84731. ,
  84732. e.prototype.bind = function(i, o, s) {
  84733. this.useLogarithmicDepth && s && MaterialHelper.BindLogDepth(void 0, i, s.getScene())
  84734. }
  84735. ,
  84736. e.prototype._buildBlock = function(i) {
  84737. a.prototype._buildBlock.call(this, i);
  84738. var o = this.rgba
  84739. , s = this.rgb
  84740. , c = this.a;
  84741. i.sharedData.hints.needAlphaBlending = o.isConnected || c.isConnected,
  84742. i.sharedData.blocksWithDefines.push(this),
  84743. this.useLogarithmicDepth && (i._emitUniformFromString("logarithmicDepthConstant", "float"),
  84744. i._emitVaryingFromString("vFragmentDepth", "float"),
  84745. i.sharedData.bindableBlocks.push(this)),
  84746. this._linearDefineName = i._getFreeDefineName("CONVERTTOLINEAR"),
  84747. this._gammaDefineName = i._getFreeDefineName("CONVERTTOGAMMA");
  84748. var d = "//" + this.name;
  84749. if (i._emitFunctionFromInclude("helperFunctions", d),
  84750. o.connectedPoint)
  84751. c.isConnected ? i.compilationString += "gl_FragColor = vec4(" + o.associatedVariableName + ".rgb, " + c.associatedVariableName + `);\r
  84752. ` : i.compilationString += "gl_FragColor = " + o.associatedVariableName + `;\r
  84753. `;
  84754. else if (s.connectedPoint) {
  84755. var _ = "1.0";
  84756. c.connectedPoint && (_ = c.associatedVariableName),
  84757. s.connectedPoint.type === NodeMaterialBlockConnectionPointTypes.Float ? i.compilationString += "gl_FragColor = vec4(" + s.associatedVariableName + ", " + s.associatedVariableName + ", " + s.associatedVariableName + ", " + _ + `);\r
  84758. ` : i.compilationString += "gl_FragColor = vec4(" + s.associatedVariableName + ", " + _ + `);\r
  84759. `
  84760. } else
  84761. i.sharedData.checks.notConnectedNonOptionalInputs.push(o);
  84762. return i.compilationString += "#ifdef " + this._linearDefineName + `\r
  84763. `,
  84764. i.compilationString += `gl_FragColor = toLinearSpace(gl_FragColor);\r
  84765. `,
  84766. i.compilationString += `#endif\r
  84767. `,
  84768. i.compilationString += "#ifdef " + this._gammaDefineName + `\r
  84769. `,
  84770. i.compilationString += `gl_FragColor = toGammaSpace(gl_FragColor);\r
  84771. `,
  84772. i.compilationString += `#endif\r
  84773. `,
  84774. this.useLogarithmicDepth && (i.compilationString += `gl_FragDepthEXT = log2(vFragmentDepth) * logarithmicDepthConstant * 0.5;\r
  84775. `),
  84776. this
  84777. }
  84778. ,
  84779. e.prototype._dumpPropertiesCode = function() {
  84780. var i = a.prototype._dumpPropertiesCode.call(this);
  84781. return i += this._codeVariableName + ".convertToGammaSpace = " + this.convertToGammaSpace + `;\r
  84782. `,
  84783. i += this._codeVariableName + ".convertToLinearSpace = " + this.convertToLinearSpace + `;\r
  84784. `,
  84785. i += this._codeVariableName + ".useLogarithmicDepth = " + this.useLogarithmicDepth + `;\r
  84786. `,
  84787. i
  84788. }
  84789. ,
  84790. e.prototype.serialize = function() {
  84791. var i = a.prototype.serialize.call(this);
  84792. return i.convertToGammaSpace = this.convertToGammaSpace,
  84793. i.convertToLinearSpace = this.convertToLinearSpace,
  84794. i.useLogarithmicDepth = this.useLogarithmicDepth,
  84795. i
  84796. }
  84797. ,
  84798. e.prototype._deserialize = function(i, o, s) {
  84799. var c;
  84800. a.prototype._deserialize.call(this, i, o, s),
  84801. this.convertToGammaSpace = i.convertToGammaSpace,
  84802. this.convertToLinearSpace = i.convertToLinearSpace,
  84803. this.useLogarithmicDepth = (c = i.useLogarithmicDepth) !== null && c !== void 0 ? c : !1
  84804. }
  84805. ,
  84806. __decorate([editableInPropertyPage("Convert to gamma space", PropertyTypeForEdition.Boolean, "PROPERTIES", {
  84807. notifiers: {
  84808. update: !0
  84809. }
  84810. })], e.prototype, "convertToGammaSpace", void 0),
  84811. __decorate([editableInPropertyPage("Convert to linear space", PropertyTypeForEdition.Boolean, "PROPERTIES", {
  84812. notifiers: {
  84813. update: !0
  84814. }
  84815. })], e.prototype, "convertToLinearSpace", void 0),
  84816. __decorate([editableInPropertyPage("Use logarithmic depth", PropertyTypeForEdition.Boolean, "PROPERTIES")], e.prototype, "useLogarithmicDepth", void 0),
  84817. e
  84818. }(NodeMaterialBlock);
  84819. RegisterClass("BABYLON.FragmentOutputBlock", FragmentOutputBlock);
  84820. var AnimatedInputBlockTypes;
  84821. (function(a) {
  84822. a[a.None = 0] = "None",
  84823. a[a.Time = 1] = "Time"
  84824. }
  84825. )(AnimatedInputBlockTypes || (AnimatedInputBlockTypes = {}));
  84826. var remapAttributeName = {
  84827. position2d: "position",
  84828. particle_uv: "vUV",
  84829. particle_color: "vColor",
  84830. particle_texturemask: "textureMask",
  84831. particle_positionw: "vPositionW"
  84832. }
  84833. , attributeInFragmentOnly = {
  84834. particle_uv: !0,
  84835. particle_color: !0,
  84836. particle_texturemask: !0,
  84837. particle_positionw: !0
  84838. }
  84839. , attributeAsUniform = {
  84840. particle_texturemask: !0
  84841. }
  84842. , InputBlock = function(a) {
  84843. __extends(e, a);
  84844. function e(i, o, s) {
  84845. o === void 0 && (o = NodeMaterialBlockTargets.Vertex),
  84846. s === void 0 && (s = NodeMaterialBlockConnectionPointTypes.AutoDetect);
  84847. var c = a.call(this, i, o, !1, !0) || this;
  84848. return c._mode = NodeMaterialBlockConnectionPointMode.Undefined,
  84849. c._animationType = AnimatedInputBlockTypes.None,
  84850. c.min = 0,
  84851. c.max = 0,
  84852. c.isBoolean = !1,
  84853. c.matrixMode = 0,
  84854. c._systemValue = null,
  84855. c.isConstant = !1,
  84856. c.groupInInspector = "",
  84857. c.onValueChangedObservable = new Observable,
  84858. c.convertToGammaSpace = !1,
  84859. c.convertToLinearSpace = !1,
  84860. c._type = s,
  84861. c.setDefaultValue(),
  84862. c.registerOutput("output", s),
  84863. c
  84864. }
  84865. return Object.defineProperty(e.prototype, "type", {
  84866. get: function() {
  84867. if (this._type === NodeMaterialBlockConnectionPointTypes.AutoDetect) {
  84868. if (this.isUniform && this.value != null) {
  84869. if (!isNaN(this.value))
  84870. return this._type = NodeMaterialBlockConnectionPointTypes.Float,
  84871. this._type;
  84872. switch (this.value.getClassName()) {
  84873. case "Vector2":
  84874. return this._type = NodeMaterialBlockConnectionPointTypes.Vector2,
  84875. this._type;
  84876. case "Vector3":
  84877. return this._type = NodeMaterialBlockConnectionPointTypes.Vector3,
  84878. this._type;
  84879. case "Vector4":
  84880. return this._type = NodeMaterialBlockConnectionPointTypes.Vector4,
  84881. this._type;
  84882. case "Color3":
  84883. return this._type = NodeMaterialBlockConnectionPointTypes.Color3,
  84884. this._type;
  84885. case "Color4":
  84886. return this._type = NodeMaterialBlockConnectionPointTypes.Color4,
  84887. this._type;
  84888. case "Matrix":
  84889. return this._type = NodeMaterialBlockConnectionPointTypes.Matrix,
  84890. this._type
  84891. }
  84892. }
  84893. if (this.isAttribute)
  84894. switch (this.name) {
  84895. case "position":
  84896. case "normal":
  84897. case "tangent":
  84898. case "particle_positionw":
  84899. return this._type = NodeMaterialBlockConnectionPointTypes.Vector3,
  84900. this._type;
  84901. case "uv":
  84902. case "uv2":
  84903. case "uv3":
  84904. case "uv4":
  84905. case "uv5":
  84906. case "uv6":
  84907. case "position2d":
  84908. case "particle_uv":
  84909. return this._type = NodeMaterialBlockConnectionPointTypes.Vector2,
  84910. this._type;
  84911. case "matricesIndices":
  84912. case "matricesWeights":
  84913. case "world0":
  84914. case "world1":
  84915. case "world2":
  84916. case "world3":
  84917. return this._type = NodeMaterialBlockConnectionPointTypes.Vector4,
  84918. this._type;
  84919. case "color":
  84920. case "particle_color":
  84921. case "particle_texturemask":
  84922. return this._type = NodeMaterialBlockConnectionPointTypes.Color4,
  84923. this._type
  84924. }
  84925. if (this.isSystemValue)
  84926. switch (this._systemValue) {
  84927. case NodeMaterialSystemValues.World:
  84928. case NodeMaterialSystemValues.WorldView:
  84929. case NodeMaterialSystemValues.WorldViewProjection:
  84930. case NodeMaterialSystemValues.View:
  84931. case NodeMaterialSystemValues.ViewProjection:
  84932. case NodeMaterialSystemValues.Projection:
  84933. return this._type = NodeMaterialBlockConnectionPointTypes.Matrix,
  84934. this._type;
  84935. case NodeMaterialSystemValues.CameraPosition:
  84936. return this._type = NodeMaterialBlockConnectionPointTypes.Vector3,
  84937. this._type;
  84938. case NodeMaterialSystemValues.FogColor:
  84939. return this._type = NodeMaterialBlockConnectionPointTypes.Color3,
  84940. this._type;
  84941. case NodeMaterialSystemValues.DeltaTime:
  84942. return this._type = NodeMaterialBlockConnectionPointTypes.Float,
  84943. this._type;
  84944. case NodeMaterialSystemValues.CameraParameters:
  84945. return this._type = NodeMaterialBlockConnectionPointTypes.Vector4,
  84946. this._type
  84947. }
  84948. }
  84949. return this._type
  84950. },
  84951. enumerable: !1,
  84952. configurable: !0
  84953. }),
  84954. e.prototype.validateBlockName = function(i) {
  84955. return this.isAttribute ? !0 : a.prototype.validateBlockName.call(this, i)
  84956. }
  84957. ,
  84958. Object.defineProperty(e.prototype, "output", {
  84959. get: function() {
  84960. return this._outputs[0]
  84961. },
  84962. enumerable: !1,
  84963. configurable: !0
  84964. }),
  84965. e.prototype.setAsAttribute = function(i) {
  84966. return this._mode = NodeMaterialBlockConnectionPointMode.Attribute,
  84967. i && (this.name = i),
  84968. this
  84969. }
  84970. ,
  84971. e.prototype.setAsSystemValue = function(i) {
  84972. return this.systemValue = i,
  84973. this
  84974. }
  84975. ,
  84976. Object.defineProperty(e.prototype, "value", {
  84977. get: function() {
  84978. return this._storedValue
  84979. },
  84980. set: function(i) {
  84981. this.type === NodeMaterialBlockConnectionPointTypes.Float && (this.isBoolean ? i = i ? 1 : 0 : this.min !== this.max && (i = Math.max(this.min, i),
  84982. i = Math.min(this.max, i))),
  84983. this._storedValue = i,
  84984. this._mode = NodeMaterialBlockConnectionPointMode.Uniform,
  84985. this.onValueChangedObservable.notifyObservers(this)
  84986. },
  84987. enumerable: !1,
  84988. configurable: !0
  84989. }),
  84990. Object.defineProperty(e.prototype, "valueCallback", {
  84991. get: function() {
  84992. return this._valueCallback
  84993. },
  84994. set: function(i) {
  84995. this._valueCallback = i,
  84996. this._mode = NodeMaterialBlockConnectionPointMode.Uniform
  84997. },
  84998. enumerable: !1,
  84999. configurable: !0
  85000. }),
  85001. Object.defineProperty(e.prototype, "associatedVariableName", {
  85002. get: function() {
  85003. return this._associatedVariableName
  85004. },
  85005. set: function(i) {
  85006. this._associatedVariableName = i
  85007. },
  85008. enumerable: !1,
  85009. configurable: !0
  85010. }),
  85011. Object.defineProperty(e.prototype, "animationType", {
  85012. get: function() {
  85013. return this._animationType
  85014. },
  85015. set: function(i) {
  85016. this._animationType = i
  85017. },
  85018. enumerable: !1,
  85019. configurable: !0
  85020. }),
  85021. Object.defineProperty(e.prototype, "isUndefined", {
  85022. get: function() {
  85023. return this._mode === NodeMaterialBlockConnectionPointMode.Undefined
  85024. },
  85025. enumerable: !1,
  85026. configurable: !0
  85027. }),
  85028. Object.defineProperty(e.prototype, "isUniform", {
  85029. get: function() {
  85030. return this._mode === NodeMaterialBlockConnectionPointMode.Uniform
  85031. },
  85032. set: function(i) {
  85033. this._mode = i ? NodeMaterialBlockConnectionPointMode.Uniform : NodeMaterialBlockConnectionPointMode.Undefined,
  85034. this.associatedVariableName = ""
  85035. },
  85036. enumerable: !1,
  85037. configurable: !0
  85038. }),
  85039. Object.defineProperty(e.prototype, "isAttribute", {
  85040. get: function() {
  85041. return this._mode === NodeMaterialBlockConnectionPointMode.Attribute
  85042. },
  85043. set: function(i) {
  85044. this._mode = i ? NodeMaterialBlockConnectionPointMode.Attribute : NodeMaterialBlockConnectionPointMode.Undefined,
  85045. this.associatedVariableName = ""
  85046. },
  85047. enumerable: !1,
  85048. configurable: !0
  85049. }),
  85050. Object.defineProperty(e.prototype, "isVarying", {
  85051. get: function() {
  85052. return this._mode === NodeMaterialBlockConnectionPointMode.Varying
  85053. },
  85054. set: function(i) {
  85055. this._mode = i ? NodeMaterialBlockConnectionPointMode.Varying : NodeMaterialBlockConnectionPointMode.Undefined,
  85056. this.associatedVariableName = ""
  85057. },
  85058. enumerable: !1,
  85059. configurable: !0
  85060. }),
  85061. Object.defineProperty(e.prototype, "isSystemValue", {
  85062. get: function() {
  85063. return this._systemValue != null
  85064. },
  85065. enumerable: !1,
  85066. configurable: !0
  85067. }),
  85068. Object.defineProperty(e.prototype, "systemValue", {
  85069. get: function() {
  85070. return this._systemValue
  85071. },
  85072. set: function(i) {
  85073. this._mode = NodeMaterialBlockConnectionPointMode.Uniform,
  85074. this.associatedVariableName = "",
  85075. this._systemValue = i
  85076. },
  85077. enumerable: !1,
  85078. configurable: !0
  85079. }),
  85080. e.prototype.getClassName = function() {
  85081. return "InputBlock"
  85082. }
  85083. ,
  85084. e.prototype.animate = function(i) {
  85085. switch (this._animationType) {
  85086. case AnimatedInputBlockTypes.Time:
  85087. {
  85088. this.type === NodeMaterialBlockConnectionPointTypes.Float && (this.value += i.getAnimationRatio() * .01);
  85089. break
  85090. }
  85091. }
  85092. }
  85093. ,
  85094. e.prototype._emitDefine = function(i) {
  85095. return i[0] === "!" ? "#ifndef " + i.substring(1) + `\r
  85096. ` : "#ifdef " + i + `\r
  85097. `
  85098. }
  85099. ,
  85100. e.prototype.initialize = function(i) {
  85101. this.associatedVariableName = ""
  85102. }
  85103. ,
  85104. e.prototype.setDefaultValue = function() {
  85105. switch (this.type) {
  85106. case NodeMaterialBlockConnectionPointTypes.Float:
  85107. this.value = 0;
  85108. break;
  85109. case NodeMaterialBlockConnectionPointTypes.Vector2:
  85110. this.value = Vector2.Zero();
  85111. break;
  85112. case NodeMaterialBlockConnectionPointTypes.Vector3:
  85113. this.value = Vector3.Zero();
  85114. break;
  85115. case NodeMaterialBlockConnectionPointTypes.Vector4:
  85116. this.value = Vector4.Zero();
  85117. break;
  85118. case NodeMaterialBlockConnectionPointTypes.Color3:
  85119. this.value = Color3.White();
  85120. break;
  85121. case NodeMaterialBlockConnectionPointTypes.Color4:
  85122. this.value = new Color4(1,1,1,1);
  85123. break;
  85124. case NodeMaterialBlockConnectionPointTypes.Matrix:
  85125. this.value = Matrix.Identity();
  85126. break
  85127. }
  85128. }
  85129. ,
  85130. e.prototype._emitConstant = function(i) {
  85131. switch (this.type) {
  85132. case NodeMaterialBlockConnectionPointTypes.Float:
  85133. return "" + i._emitFloat(this.value);
  85134. case NodeMaterialBlockConnectionPointTypes.Vector2:
  85135. return "vec2(" + this.value.x + ", " + this.value.y + ")";
  85136. case NodeMaterialBlockConnectionPointTypes.Vector3:
  85137. return "vec3(" + this.value.x + ", " + this.value.y + ", " + this.value.z + ")";
  85138. case NodeMaterialBlockConnectionPointTypes.Vector4:
  85139. return "vec4(" + this.value.x + ", " + this.value.y + ", " + this.value.z + ", " + this.value.w + ")";
  85140. case NodeMaterialBlockConnectionPointTypes.Color3:
  85141. return TmpColors.Color3[0].set(this.value.r, this.value.g, this.value.b),
  85142. this.convertToGammaSpace && TmpColors.Color3[0].toGammaSpaceToRef(TmpColors.Color3[0]),
  85143. this.convertToLinearSpace && TmpColors.Color3[0].toLinearSpaceToRef(TmpColors.Color3[0]),
  85144. "vec3(" + TmpColors.Color3[0].r + ", " + TmpColors.Color3[0].g + ", " + TmpColors.Color3[0].b + ")";
  85145. case NodeMaterialBlockConnectionPointTypes.Color4:
  85146. return TmpColors.Color4[0].set(this.value.r, this.value.g, this.value.b, this.value.a),
  85147. this.convertToGammaSpace && TmpColors.Color4[0].toGammaSpaceToRef(TmpColors.Color4[0]),
  85148. this.convertToLinearSpace && TmpColors.Color4[0].toLinearSpaceToRef(TmpColors.Color4[0]),
  85149. "vec4(" + TmpColors.Color4[0].r + ", " + TmpColors.Color4[0].g + ", " + TmpColors.Color4[0].b + ", " + TmpColors.Color4[0].a + ")"
  85150. }
  85151. return ""
  85152. }
  85153. ,
  85154. Object.defineProperty(e.prototype, "_noContextSwitch", {
  85155. get: function() {
  85156. return attributeInFragmentOnly[this.name]
  85157. },
  85158. enumerable: !1,
  85159. configurable: !0
  85160. }),
  85161. e.prototype._emit = function(i, o) {
  85162. var s;
  85163. if (this.isUniform) {
  85164. if (this.associatedVariableName || (this.associatedVariableName = i._getFreeVariableName("u_" + this.name)),
  85165. this.isConstant) {
  85166. if (i.constants.indexOf(this.associatedVariableName) !== -1)
  85167. return;
  85168. i.constants.push(this.associatedVariableName),
  85169. i._constantDeclaration += this._declareOutput(this.output, i) + (" = " + this._emitConstant(i) + `;\r
  85170. `);
  85171. return
  85172. }
  85173. if (i.uniforms.indexOf(this.associatedVariableName) !== -1)
  85174. return;
  85175. i.uniforms.push(this.associatedVariableName),
  85176. o && (i._uniformDeclaration += this._emitDefine(o)),
  85177. i._uniformDeclaration += "uniform " + i._getGLType(this.type) + " " + this.associatedVariableName + `;\r
  85178. `,
  85179. o && (i._uniformDeclaration += `#endif\r
  85180. `);
  85181. var c = i.sharedData.hints;
  85182. if (this._systemValue !== null && this._systemValue !== void 0)
  85183. switch (this._systemValue) {
  85184. case NodeMaterialSystemValues.WorldView:
  85185. c.needWorldViewMatrix = !0;
  85186. break;
  85187. case NodeMaterialSystemValues.WorldViewProjection:
  85188. c.needWorldViewProjectionMatrix = !0;
  85189. break
  85190. }
  85191. else
  85192. this._animationType !== AnimatedInputBlockTypes.None && i.sharedData.animatedInputs.push(this);
  85193. return
  85194. }
  85195. if (this.isAttribute) {
  85196. if (this.associatedVariableName = (s = remapAttributeName[this.name]) !== null && s !== void 0 ? s : this.name,
  85197. this.target === NodeMaterialBlockTargets.Vertex && i._vertexState) {
  85198. attributeInFragmentOnly[this.name] ? attributeAsUniform[this.name] ? i._emitUniformFromString(this.associatedVariableName, i._getGLType(this.type), o) : i._emitVaryingFromString(this.associatedVariableName, i._getGLType(this.type), o) : this._emit(i._vertexState, o);
  85199. return
  85200. }
  85201. if (i.attributes.indexOf(this.associatedVariableName) !== -1)
  85202. return;
  85203. i.attributes.push(this.associatedVariableName),
  85204. attributeInFragmentOnly[this.name] ? attributeAsUniform[this.name] ? i._emitUniformFromString(this.associatedVariableName, i._getGLType(this.type), o) : i._emitVaryingFromString(this.associatedVariableName, i._getGLType(this.type), o) : (o && (i._attributeDeclaration += this._emitDefine(o)),
  85205. i._attributeDeclaration += "attribute " + i._getGLType(this.type) + " " + this.associatedVariableName + `;\r
  85206. `,
  85207. o && (i._attributeDeclaration += `#endif\r
  85208. `))
  85209. }
  85210. }
  85211. ,
  85212. e.prototype._transmitWorld = function(i, o, s, c) {
  85213. if (!!this._systemValue) {
  85214. var d = this.associatedVariableName;
  85215. switch (this._systemValue) {
  85216. case NodeMaterialSystemValues.World:
  85217. i.setMatrix(d, o);
  85218. break;
  85219. case NodeMaterialSystemValues.WorldView:
  85220. i.setMatrix(d, s);
  85221. break;
  85222. case NodeMaterialSystemValues.WorldViewProjection:
  85223. i.setMatrix(d, c);
  85224. break
  85225. }
  85226. }
  85227. }
  85228. ,
  85229. e.prototype._transmit = function(i, o) {
  85230. if (!this.isAttribute) {
  85231. var s = this.associatedVariableName;
  85232. if (this._systemValue) {
  85233. switch (this._systemValue) {
  85234. case NodeMaterialSystemValues.World:
  85235. case NodeMaterialSystemValues.WorldView:
  85236. case NodeMaterialSystemValues.WorldViewProjection:
  85237. return;
  85238. case NodeMaterialSystemValues.View:
  85239. i.setMatrix(s, o.getViewMatrix());
  85240. break;
  85241. case NodeMaterialSystemValues.Projection:
  85242. i.setMatrix(s, o.getProjectionMatrix());
  85243. break;
  85244. case NodeMaterialSystemValues.ViewProjection:
  85245. i.setMatrix(s, o.getTransformMatrix());
  85246. break;
  85247. case NodeMaterialSystemValues.CameraPosition:
  85248. o.bindEyePosition(i, s, !0);
  85249. break;
  85250. case NodeMaterialSystemValues.FogColor:
  85251. i.setColor3(s, o.fogColor);
  85252. break;
  85253. case NodeMaterialSystemValues.DeltaTime:
  85254. i.setFloat(s, o.deltaTime / 1e3);
  85255. case NodeMaterialSystemValues.CameraParameters:
  85256. o.activeCamera && i.setFloat4(s, o.getEngine().hasOriginBottomLeft ? -1 : 1, o.activeCamera.minZ, o.activeCamera.maxZ, 1 / o.activeCamera.maxZ);
  85257. break
  85258. }
  85259. return
  85260. }
  85261. var c = this._valueCallback ? this._valueCallback() : this._storedValue;
  85262. if (c !== null)
  85263. switch (this.type) {
  85264. case NodeMaterialBlockConnectionPointTypes.Float:
  85265. i.setFloat(s, c);
  85266. break;
  85267. case NodeMaterialBlockConnectionPointTypes.Int:
  85268. i.setInt(s, c);
  85269. break;
  85270. case NodeMaterialBlockConnectionPointTypes.Color3:
  85271. TmpColors.Color3[0].set(this.value.r, this.value.g, this.value.b),
  85272. this.convertToGammaSpace && TmpColors.Color3[0].toGammaSpaceToRef(TmpColors.Color3[0]),
  85273. this.convertToLinearSpace && TmpColors.Color3[0].toLinearSpaceToRef(TmpColors.Color3[0]),
  85274. i.setColor3(s, TmpColors.Color3[0]);
  85275. break;
  85276. case NodeMaterialBlockConnectionPointTypes.Color4:
  85277. TmpColors.Color4[0].set(this.value.r, this.value.g, this.value.b, this.value.a),
  85278. this.convertToGammaSpace && TmpColors.Color4[0].toGammaSpaceToRef(TmpColors.Color4[0]),
  85279. this.convertToLinearSpace && TmpColors.Color4[0].toLinearSpaceToRef(TmpColors.Color4[0]),
  85280. i.setDirectColor4(s, TmpColors.Color4[0]);
  85281. break;
  85282. case NodeMaterialBlockConnectionPointTypes.Vector2:
  85283. i.setVector2(s, c);
  85284. break;
  85285. case NodeMaterialBlockConnectionPointTypes.Vector3:
  85286. i.setVector3(s, c);
  85287. break;
  85288. case NodeMaterialBlockConnectionPointTypes.Vector4:
  85289. i.setVector4(s, c);
  85290. break;
  85291. case NodeMaterialBlockConnectionPointTypes.Matrix:
  85292. i.setMatrix(s, c);
  85293. break
  85294. }
  85295. }
  85296. }
  85297. ,
  85298. e.prototype._buildBlock = function(i) {
  85299. a.prototype._buildBlock.call(this, i),
  85300. (this.isUniform || this.isSystemValue) && i.sharedData.inputBlocks.push(this),
  85301. this._emit(i)
  85302. }
  85303. ,
  85304. e.prototype._dumpPropertiesCode = function() {
  85305. var i = this._codeVariableName;
  85306. if (this.isAttribute)
  85307. return a.prototype._dumpPropertiesCode.call(this) + (i + '.setAsAttribute("' + this.name + `");\r
  85308. `);
  85309. if (this.isSystemValue)
  85310. return a.prototype._dumpPropertiesCode.call(this) + (i + ".setAsSystemValue(BABYLON.NodeMaterialSystemValues." + NodeMaterialSystemValues[this._systemValue] + `);\r
  85311. `);
  85312. if (this.isUniform) {
  85313. var o = []
  85314. , s = "";
  85315. switch (this.type) {
  85316. case NodeMaterialBlockConnectionPointTypes.Float:
  85317. s = "" + this.value;
  85318. break;
  85319. case NodeMaterialBlockConnectionPointTypes.Vector2:
  85320. s = "new BABYLON.Vector2(" + this.value.x + ", " + this.value.y + ")";
  85321. break;
  85322. case NodeMaterialBlockConnectionPointTypes.Vector3:
  85323. s = "new BABYLON.Vector3(" + this.value.x + ", " + this.value.y + ", " + this.value.z + ")";
  85324. break;
  85325. case NodeMaterialBlockConnectionPointTypes.Vector4:
  85326. s = "new BABYLON.Vector4(" + this.value.x + ", " + this.value.y + ", " + this.value.z + ", " + this.value.w + ")";
  85327. break;
  85328. case NodeMaterialBlockConnectionPointTypes.Color3:
  85329. s = "new BABYLON.Color3(" + this.value.r + ", " + this.value.g + ", " + this.value.b + ")",
  85330. this.convertToGammaSpace && (s += ".toGammaSpace()"),
  85331. this.convertToLinearSpace && (s += ".toLinearSpace()");
  85332. break;
  85333. case NodeMaterialBlockConnectionPointTypes.Color4:
  85334. s = "new BABYLON.Color4(" + this.value.r + ", " + this.value.g + ", " + this.value.b + ", " + this.value.a + ")",
  85335. this.convertToGammaSpace && (s += ".toGammaSpace()"),
  85336. this.convertToLinearSpace && (s += ".toLinearSpace()");
  85337. break;
  85338. case NodeMaterialBlockConnectionPointTypes.Matrix:
  85339. s = "BABYLON.Matrix.FromArray([" + this.value.m + "])";
  85340. break
  85341. }
  85342. return o.push(i + ".value = " + s),
  85343. this.type === NodeMaterialBlockConnectionPointTypes.Float && o.push(i + ".min = " + this.min, i + ".max = " + this.max, i + ".isBoolean = " + this.isBoolean, i + ".matrixMode = " + this.matrixMode, i + ".animationType = BABYLON.AnimatedInputBlockTypes." + AnimatedInputBlockTypes[this.animationType]),
  85344. o.push(i + ".isConstant = " + this.isConstant),
  85345. o.push(""),
  85346. a.prototype._dumpPropertiesCode.call(this) + o.join(`;\r
  85347. `)
  85348. }
  85349. return a.prototype._dumpPropertiesCode.call(this)
  85350. }
  85351. ,
  85352. e.prototype.dispose = function() {
  85353. this.onValueChangedObservable.clear(),
  85354. a.prototype.dispose.call(this)
  85355. }
  85356. ,
  85357. e.prototype.serialize = function() {
  85358. var i = a.prototype.serialize.call(this);
  85359. return i.type = this.type,
  85360. i.mode = this._mode,
  85361. i.systemValue = this._systemValue,
  85362. i.animationType = this._animationType,
  85363. i.min = this.min,
  85364. i.max = this.max,
  85365. i.isBoolean = this.isBoolean,
  85366. i.matrixMode = this.matrixMode,
  85367. i.isConstant = this.isConstant,
  85368. i.groupInInspector = this.groupInInspector,
  85369. i.convertToGammaSpace = this.convertToGammaSpace,
  85370. i.convertToLinearSpace = this.convertToLinearSpace,
  85371. this._storedValue != null && this._mode === NodeMaterialBlockConnectionPointMode.Uniform && (this._storedValue.asArray ? (i.valueType = "BABYLON." + this._storedValue.getClassName(),
  85372. i.value = this._storedValue.asArray()) : (i.valueType = "number",
  85373. i.value = this._storedValue)),
  85374. i
  85375. }
  85376. ,
  85377. e.prototype._deserialize = function(i, o, s) {
  85378. if (this._mode = i.mode,
  85379. a.prototype._deserialize.call(this, i, o, s),
  85380. this._type = i.type,
  85381. this._systemValue = i.systemValue || i.wellKnownValue,
  85382. this._animationType = i.animationType,
  85383. this.min = i.min || 0,
  85384. this.max = i.max || 0,
  85385. this.isBoolean = !!i.isBoolean,
  85386. this.matrixMode = i.matrixMode || 0,
  85387. this.isConstant = !!i.isConstant,
  85388. this.groupInInspector = i.groupInInspector || "",
  85389. this.convertToGammaSpace = !!i.convertToGammaSpace,
  85390. this.convertToLinearSpace = !!i.convertToLinearSpace,
  85391. !!i.valueType)
  85392. if (i.valueType === "number")
  85393. this._storedValue = i.value;
  85394. else {
  85395. var c = GetClass(i.valueType);
  85396. c && (this._storedValue = c.FromArray(i.value))
  85397. }
  85398. }
  85399. ,
  85400. e
  85401. }(NodeMaterialBlock);
  85402. RegisterClass("BABYLON.InputBlock", InputBlock);
  85403. var CurrentScreenBlock = function(a) {
  85404. __extends(e, a);
  85405. function e(i) {
  85406. var o = a.call(this, i, NodeMaterialBlockTargets.VertexAndFragment) || this;
  85407. return o._samplerName = "textureSampler",
  85408. o.convertToGammaSpace = !1,
  85409. o.convertToLinearSpace = !1,
  85410. o._isUnique = !1,
  85411. o.registerInput("uv", NodeMaterialBlockConnectionPointTypes.Vector2, !1, NodeMaterialBlockTargets.VertexAndFragment),
  85412. o.registerOutput("rgba", NodeMaterialBlockConnectionPointTypes.Color4, NodeMaterialBlockTargets.Neutral),
  85413. o.registerOutput("rgb", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Neutral),
  85414. o.registerOutput("r", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Neutral),
  85415. o.registerOutput("g", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Neutral),
  85416. o.registerOutput("b", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Neutral),
  85417. o.registerOutput("a", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Neutral),
  85418. o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector3),
  85419. o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector4),
  85420. o._inputs[0]._prioritizeVertex = !1,
  85421. o
  85422. }
  85423. return e.prototype.getClassName = function() {
  85424. return "CurrentScreenBlock"
  85425. }
  85426. ,
  85427. Object.defineProperty(e.prototype, "uv", {
  85428. get: function() {
  85429. return this._inputs[0]
  85430. },
  85431. enumerable: !1,
  85432. configurable: !0
  85433. }),
  85434. Object.defineProperty(e.prototype, "rgba", {
  85435. get: function() {
  85436. return this._outputs[0]
  85437. },
  85438. enumerable: !1,
  85439. configurable: !0
  85440. }),
  85441. Object.defineProperty(e.prototype, "rgb", {
  85442. get: function() {
  85443. return this._outputs[1]
  85444. },
  85445. enumerable: !1,
  85446. configurable: !0
  85447. }),
  85448. Object.defineProperty(e.prototype, "r", {
  85449. get: function() {
  85450. return this._outputs[2]
  85451. },
  85452. enumerable: !1,
  85453. configurable: !0
  85454. }),
  85455. Object.defineProperty(e.prototype, "g", {
  85456. get: function() {
  85457. return this._outputs[3]
  85458. },
  85459. enumerable: !1,
  85460. configurable: !0
  85461. }),
  85462. Object.defineProperty(e.prototype, "b", {
  85463. get: function() {
  85464. return this._outputs[4]
  85465. },
  85466. enumerable: !1,
  85467. configurable: !0
  85468. }),
  85469. Object.defineProperty(e.prototype, "a", {
  85470. get: function() {
  85471. return this._outputs[5]
  85472. },
  85473. enumerable: !1,
  85474. configurable: !0
  85475. }),
  85476. e.prototype.initialize = function(i) {
  85477. i._excludeVariableName("textureSampler")
  85478. }
  85479. ,
  85480. Object.defineProperty(e.prototype, "target", {
  85481. get: function() {
  85482. return !this.uv.isConnected || this.uv.sourceBlock.isInput ? NodeMaterialBlockTargets.VertexAndFragment : NodeMaterialBlockTargets.Fragment
  85483. },
  85484. enumerable: !1,
  85485. configurable: !0
  85486. }),
  85487. e.prototype.prepareDefines = function(i, o, s) {
  85488. s.setValue(this._linearDefineName, this.convertToGammaSpace, !0),
  85489. s.setValue(this._gammaDefineName, this.convertToLinearSpace, !0)
  85490. }
  85491. ,
  85492. e.prototype.isReady = function() {
  85493. return !(this.texture && !this.texture.isReadyOrNotBlocking())
  85494. }
  85495. ,
  85496. e.prototype._injectVertexCode = function(i) {
  85497. var o = this.uv;
  85498. if (o.connectedPoint.ownerBlock.isInput) {
  85499. var s = o.connectedPoint.ownerBlock;
  85500. s.isAttribute || i._emitUniformFromString(o.associatedVariableName, "vec2")
  85501. }
  85502. if (this._mainUVName = "vMain" + o.associatedVariableName,
  85503. i._emitVaryingFromString(this._mainUVName, "vec2"),
  85504. i.compilationString += this._mainUVName + " = " + o.associatedVariableName + `.xy;\r
  85505. `,
  85506. !!this._outputs.some(function(b) {
  85507. return b.isConnectedInVertexShader
  85508. })) {
  85509. this._writeTextureRead(i, !0);
  85510. for (var c = 0, d = this._outputs; c < d.length; c++) {
  85511. var _ = d[c];
  85512. _.hasEndpoints && this._writeOutput(i, _, _.name, !0)
  85513. }
  85514. }
  85515. }
  85516. ,
  85517. e.prototype._writeTextureRead = function(i, o) {
  85518. o === void 0 && (o = !1);
  85519. var s = this.uv;
  85520. if (o) {
  85521. if (i.target === NodeMaterialBlockTargets.Fragment)
  85522. return;
  85523. i.compilationString += "vec4 " + this._tempTextureRead + " = texture2D(" + this._samplerName + ", " + s.associatedVariableName + `);\r
  85524. `;
  85525. return
  85526. }
  85527. if (this.uv.ownerBlock.target === NodeMaterialBlockTargets.Fragment) {
  85528. i.compilationString += "vec4 " + this._tempTextureRead + " = texture2D(" + this._samplerName + ", " + s.associatedVariableName + `);\r
  85529. `;
  85530. return
  85531. }
  85532. i.compilationString += "vec4 " + this._tempTextureRead + " = texture2D(" + this._samplerName + ", " + this._mainUVName + `);\r
  85533. `
  85534. }
  85535. ,
  85536. e.prototype._writeOutput = function(i, o, s, c) {
  85537. if (c === void 0 && (c = !1),
  85538. c) {
  85539. if (i.target === NodeMaterialBlockTargets.Fragment)
  85540. return;
  85541. i.compilationString += this._declareOutput(o, i) + " = " + this._tempTextureRead + "." + s + `;\r
  85542. `;
  85543. return
  85544. }
  85545. if (this.uv.ownerBlock.target === NodeMaterialBlockTargets.Fragment) {
  85546. i.compilationString += this._declareOutput(o, i) + " = " + this._tempTextureRead + "." + s + `;\r
  85547. `;
  85548. return
  85549. }
  85550. i.compilationString += this._declareOutput(o, i) + " = " + this._tempTextureRead + "." + s + `;\r
  85551. `,
  85552. i.compilationString += "#ifdef " + this._linearDefineName + `\r
  85553. `,
  85554. i.compilationString += o.associatedVariableName + " = toGammaSpace(" + o.associatedVariableName + `);\r
  85555. `,
  85556. i.compilationString += `#endif\r
  85557. `,
  85558. i.compilationString += "#ifdef " + this._gammaDefineName + `\r
  85559. `,
  85560. i.compilationString += o.associatedVariableName + " = toLinearSpace(" + o.associatedVariableName + `);\r
  85561. `,
  85562. i.compilationString += `#endif\r
  85563. `
  85564. }
  85565. ,
  85566. e.prototype._buildBlock = function(i) {
  85567. if (a.prototype._buildBlock.call(this, i),
  85568. this._tempTextureRead = i._getFreeVariableName("tempTextureRead"),
  85569. i.sharedData.blockingBlocks.indexOf(this) < 0 && i.sharedData.blockingBlocks.push(this),
  85570. i.sharedData.textureBlocks.indexOf(this) < 0 && i.sharedData.textureBlocks.push(this),
  85571. i.sharedData.blocksWithDefines.indexOf(this) < 0 && i.sharedData.blocksWithDefines.push(this),
  85572. i.target !== NodeMaterialBlockTargets.Fragment) {
  85573. i._emit2DSampler(this._samplerName),
  85574. this._injectVertexCode(i);
  85575. return
  85576. }
  85577. if (!!this._outputs.some(function(_) {
  85578. return _.isConnectedInFragmentShader
  85579. })) {
  85580. i._emit2DSampler(this._samplerName),
  85581. this._linearDefineName = i._getFreeDefineName("ISLINEAR"),
  85582. this._gammaDefineName = i._getFreeDefineName("ISGAMMA");
  85583. var o = "//" + this.name;
  85584. i._emitFunctionFromInclude("helperFunctions", o),
  85585. this._writeTextureRead(i);
  85586. for (var s = 0, c = this._outputs; s < c.length; s++) {
  85587. var d = c[s];
  85588. d.hasEndpoints && this._writeOutput(i, d, d.name)
  85589. }
  85590. return this
  85591. }
  85592. }
  85593. ,
  85594. e.prototype.serialize = function() {
  85595. var i = a.prototype.serialize.call(this);
  85596. return i.convertToGammaSpace = this.convertToGammaSpace,
  85597. i.convertToLinearSpace = this.convertToLinearSpace,
  85598. this.texture && !this.texture.isRenderTarget && (i.texture = this.texture.serialize()),
  85599. i
  85600. }
  85601. ,
  85602. e.prototype._deserialize = function(i, o, s) {
  85603. a.prototype._deserialize.call(this, i, o, s),
  85604. this.convertToGammaSpace = i.convertToGammaSpace,
  85605. this.convertToLinearSpace = !!i.convertToLinearSpace,
  85606. i.texture && (s = i.texture.url.indexOf("data:") === 0 ? "" : s,
  85607. this.texture = Texture.Parse(i.texture, o, s))
  85608. }
  85609. ,
  85610. e
  85611. }(NodeMaterialBlock);
  85612. RegisterClass("BABYLON.CurrentScreenBlock", CurrentScreenBlock);
  85613. var ParticleTextureBlock = function(a) {
  85614. __extends(e, a);
  85615. function e(i) {
  85616. var o = a.call(this, i, NodeMaterialBlockTargets.Fragment) || this;
  85617. return o._samplerName = "diffuseSampler",
  85618. o.convertToGammaSpace = !1,
  85619. o.convertToLinearSpace = !1,
  85620. o._isUnique = !1,
  85621. o.registerInput("uv", NodeMaterialBlockConnectionPointTypes.Vector2, !1, NodeMaterialBlockTargets.VertexAndFragment),
  85622. o.registerOutput("rgba", NodeMaterialBlockConnectionPointTypes.Color4, NodeMaterialBlockTargets.Neutral),
  85623. o.registerOutput("rgb", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Neutral),
  85624. o.registerOutput("r", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Neutral),
  85625. o.registerOutput("g", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Neutral),
  85626. o.registerOutput("b", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Neutral),
  85627. o.registerOutput("a", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Neutral),
  85628. o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector3),
  85629. o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector4),
  85630. o
  85631. }
  85632. return e.prototype.getClassName = function() {
  85633. return "ParticleTextureBlock"
  85634. }
  85635. ,
  85636. Object.defineProperty(e.prototype, "uv", {
  85637. get: function() {
  85638. return this._inputs[0]
  85639. },
  85640. enumerable: !1,
  85641. configurable: !0
  85642. }),
  85643. Object.defineProperty(e.prototype, "rgba", {
  85644. get: function() {
  85645. return this._outputs[0]
  85646. },
  85647. enumerable: !1,
  85648. configurable: !0
  85649. }),
  85650. Object.defineProperty(e.prototype, "rgb", {
  85651. get: function() {
  85652. return this._outputs[1]
  85653. },
  85654. enumerable: !1,
  85655. configurable: !0
  85656. }),
  85657. Object.defineProperty(e.prototype, "r", {
  85658. get: function() {
  85659. return this._outputs[2]
  85660. },
  85661. enumerable: !1,
  85662. configurable: !0
  85663. }),
  85664. Object.defineProperty(e.prototype, "g", {
  85665. get: function() {
  85666. return this._outputs[3]
  85667. },
  85668. enumerable: !1,
  85669. configurable: !0
  85670. }),
  85671. Object.defineProperty(e.prototype, "b", {
  85672. get: function() {
  85673. return this._outputs[4]
  85674. },
  85675. enumerable: !1,
  85676. configurable: !0
  85677. }),
  85678. Object.defineProperty(e.prototype, "a", {
  85679. get: function() {
  85680. return this._outputs[5]
  85681. },
  85682. enumerable: !1,
  85683. configurable: !0
  85684. }),
  85685. e.prototype.initialize = function(i) {
  85686. i._excludeVariableName("diffuseSampler")
  85687. }
  85688. ,
  85689. e.prototype.autoConfigure = function(i) {
  85690. if (!this.uv.isConnected) {
  85691. var o = i.getInputBlockByPredicate(function(s) {
  85692. return s.isAttribute && s.name === "particle_uv"
  85693. });
  85694. o || (o = new InputBlock("uv"),
  85695. o.setAsAttribute("particle_uv")),
  85696. o.output.connectTo(this.uv)
  85697. }
  85698. }
  85699. ,
  85700. e.prototype.prepareDefines = function(i, o, s) {
  85701. s.setValue(this._linearDefineName, this.convertToGammaSpace, !0),
  85702. s.setValue(this._gammaDefineName, this.convertToLinearSpace, !0)
  85703. }
  85704. ,
  85705. e.prototype.isReady = function() {
  85706. return !(this.texture && !this.texture.isReadyOrNotBlocking())
  85707. }
  85708. ,
  85709. e.prototype._writeOutput = function(i, o, s) {
  85710. i.compilationString += this._declareOutput(o, i) + " = " + this._tempTextureRead + "." + s + `;\r
  85711. `,
  85712. i.compilationString += "#ifdef " + this._linearDefineName + `\r
  85713. `,
  85714. i.compilationString += o.associatedVariableName + " = toGammaSpace(" + o.associatedVariableName + `);\r
  85715. `,
  85716. i.compilationString += `#endif\r
  85717. `,
  85718. i.compilationString += "#ifdef " + this._gammaDefineName + `\r
  85719. `,
  85720. i.compilationString += o.associatedVariableName + " = toLinearSpace(" + o.associatedVariableName + `);\r
  85721. `,
  85722. i.compilationString += `#endif\r
  85723. `
  85724. }
  85725. ,
  85726. e.prototype._buildBlock = function(i) {
  85727. if (a.prototype._buildBlock.call(this, i),
  85728. i.target !== NodeMaterialBlockTargets.Vertex) {
  85729. this._tempTextureRead = i._getFreeVariableName("tempTextureRead"),
  85730. i._emit2DSampler(this._samplerName),
  85731. i.sharedData.blockingBlocks.push(this),
  85732. i.sharedData.textureBlocks.push(this),
  85733. i.sharedData.blocksWithDefines.push(this),
  85734. this._linearDefineName = i._getFreeDefineName("ISLINEAR"),
  85735. this._gammaDefineName = i._getFreeDefineName("ISGAMMA");
  85736. var o = "//" + this.name;
  85737. i._emitFunctionFromInclude("helperFunctions", o),
  85738. i.compilationString += "vec4 " + this._tempTextureRead + " = texture2D(" + this._samplerName + ", " + this.uv.associatedVariableName + `);\r
  85739. `;
  85740. for (var s = 0, c = this._outputs; s < c.length; s++) {
  85741. var d = c[s];
  85742. d.hasEndpoints && this._writeOutput(i, d, d.name)
  85743. }
  85744. return this
  85745. }
  85746. }
  85747. ,
  85748. e.prototype.serialize = function() {
  85749. var i = a.prototype.serialize.call(this);
  85750. return i.convertToGammaSpace = this.convertToGammaSpace,
  85751. i.convertToLinearSpace = this.convertToLinearSpace,
  85752. this.texture && !this.texture.isRenderTarget && (i.texture = this.texture.serialize()),
  85753. i
  85754. }
  85755. ,
  85756. e.prototype._deserialize = function(i, o, s) {
  85757. a.prototype._deserialize.call(this, i, o, s),
  85758. this.convertToGammaSpace = i.convertToGammaSpace,
  85759. this.convertToLinearSpace = !!i.convertToLinearSpace,
  85760. i.texture && (s = i.texture.url.indexOf("data:") === 0 ? "" : s,
  85761. this.texture = Texture.Parse(i.texture, o, s))
  85762. }
  85763. ,
  85764. e
  85765. }(NodeMaterialBlock);
  85766. RegisterClass("BABYLON.ParticleTextureBlock", ParticleTextureBlock);
  85767. var ParticleRampGradientBlock = function(a) {
  85768. __extends(e, a);
  85769. function e(i) {
  85770. var o = a.call(this, i, NodeMaterialBlockTargets.Fragment) || this;
  85771. return o._isUnique = !0,
  85772. o.registerInput("color", NodeMaterialBlockConnectionPointTypes.Color4, !1, NodeMaterialBlockTargets.Fragment),
  85773. o.registerOutput("rampColor", NodeMaterialBlockConnectionPointTypes.Color4, NodeMaterialBlockTargets.Fragment),
  85774. o
  85775. }
  85776. return e.prototype.getClassName = function() {
  85777. return "ParticleRampGradientBlock"
  85778. }
  85779. ,
  85780. Object.defineProperty(e.prototype, "color", {
  85781. get: function() {
  85782. return this._inputs[0]
  85783. },
  85784. enumerable: !1,
  85785. configurable: !0
  85786. }),
  85787. Object.defineProperty(e.prototype, "rampColor", {
  85788. get: function() {
  85789. return this._outputs[0]
  85790. },
  85791. enumerable: !1,
  85792. configurable: !0
  85793. }),
  85794. e.prototype.initialize = function(i) {
  85795. i._excludeVariableName("remapRanges"),
  85796. i._excludeVariableName("rampSampler"),
  85797. i._excludeVariableName("baseColor"),
  85798. i._excludeVariableName("alpha"),
  85799. i._excludeVariableName("remappedColorIndex"),
  85800. i._excludeVariableName("rampColor"),
  85801. i._excludeVariableName("finalAlpha")
  85802. }
  85803. ,
  85804. e.prototype._buildBlock = function(i) {
  85805. if (a.prototype._buildBlock.call(this, i),
  85806. i.target !== NodeMaterialBlockTargets.Vertex)
  85807. return i._emit2DSampler("rampSampler"),
  85808. i._emitVaryingFromString("remapRanges", "vec4", "RAMPGRADIENT"),
  85809. i.compilationString += `
  85810. #ifdef RAMPGRADIENT
  85811. vec4 baseColor = ` + this.color.associatedVariableName + `;
  85812. float alpha = ` + this.color.associatedVariableName + `.a;
  85813. float remappedColorIndex = clamp((alpha - remapRanges.x) / remapRanges.y, 0.0, 1.0);
  85814. vec4 rampColor = texture2D(rampSampler, vec2(1.0 - remappedColorIndex, 0.));
  85815. baseColor.rgb *= rampColor.rgb;
  85816. // Remapped alpha
  85817. float finalAlpha = baseColor.a;
  85818. baseColor.a = clamp((alpha * rampColor.a - remapRanges.z) / remapRanges.w, 0.0, 1.0);
  85819. ` + this._declareOutput(this.rampColor, i) + ` = baseColor;
  85820. #else
  85821. ` + this._declareOutput(this.rampColor, i) + " = " + this.color.associatedVariableName + `;
  85822. #endif
  85823. `,
  85824. this
  85825. }
  85826. ,
  85827. e
  85828. }(NodeMaterialBlock);
  85829. RegisterClass("BABYLON.ParticleRampGradientBlock", ParticleRampGradientBlock);
  85830. var ParticleBlendMultiplyBlock = function(a) {
  85831. __extends(e, a);
  85832. function e(i) {
  85833. var o = a.call(this, i, NodeMaterialBlockTargets.Fragment) || this;
  85834. return o._isUnique = !0,
  85835. o.registerInput("color", NodeMaterialBlockConnectionPointTypes.Color4, !1, NodeMaterialBlockTargets.Fragment),
  85836. o.registerInput("alphaTexture", NodeMaterialBlockConnectionPointTypes.Float, !1, NodeMaterialBlockTargets.Fragment),
  85837. o.registerInput("alphaColor", NodeMaterialBlockConnectionPointTypes.Float, !1, NodeMaterialBlockTargets.Fragment),
  85838. o.registerOutput("blendColor", NodeMaterialBlockConnectionPointTypes.Color4, NodeMaterialBlockTargets.Fragment),
  85839. o
  85840. }
  85841. return e.prototype.getClassName = function() {
  85842. return "ParticleBlendMultiplyBlock"
  85843. }
  85844. ,
  85845. Object.defineProperty(e.prototype, "color", {
  85846. get: function() {
  85847. return this._inputs[0]
  85848. },
  85849. enumerable: !1,
  85850. configurable: !0
  85851. }),
  85852. Object.defineProperty(e.prototype, "alphaTexture", {
  85853. get: function() {
  85854. return this._inputs[1]
  85855. },
  85856. enumerable: !1,
  85857. configurable: !0
  85858. }),
  85859. Object.defineProperty(e.prototype, "alphaColor", {
  85860. get: function() {
  85861. return this._inputs[2]
  85862. },
  85863. enumerable: !1,
  85864. configurable: !0
  85865. }),
  85866. Object.defineProperty(e.prototype, "blendColor", {
  85867. get: function() {
  85868. return this._outputs[0]
  85869. },
  85870. enumerable: !1,
  85871. configurable: !0
  85872. }),
  85873. e.prototype.initialize = function(i) {
  85874. i._excludeVariableName("sourceAlpha")
  85875. }
  85876. ,
  85877. e.prototype._buildBlock = function(i) {
  85878. if (a.prototype._buildBlock.call(this, i),
  85879. i.target !== NodeMaterialBlockTargets.Vertex)
  85880. return i.compilationString += `
  85881. #ifdef BLENDMULTIPLYMODE
  85882. ` + this._declareOutput(this.blendColor, i) + `;
  85883. float sourceAlpha = ` + this.alphaColor.associatedVariableName + " * " + this.alphaTexture.associatedVariableName + `;
  85884. ` + this.blendColor.associatedVariableName + ".rgb = " + this.color.associatedVariableName + `.rgb * sourceAlpha + vec3(1.0) * (1.0 - sourceAlpha);
  85885. ` + this.blendColor.associatedVariableName + ".a = " + this.color.associatedVariableName + `.a;
  85886. #else
  85887. ` + this._declareOutput(this.blendColor, i) + " = " + this.color.associatedVariableName + `;
  85888. #endif
  85889. `,
  85890. this
  85891. }
  85892. ,
  85893. e
  85894. }(NodeMaterialBlock);
  85895. RegisterClass("BABYLON.ParticleBlendMultiplyBlock", ParticleBlendMultiplyBlock);
  85896. var VectorMergerBlock = function(a) {
  85897. __extends(e, a);
  85898. function e(i) {
  85899. var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
  85900. return o.xSwizzle = "x",
  85901. o.ySwizzle = "y",
  85902. o.zSwizzle = "z",
  85903. o.wSwizzle = "w",
  85904. o.registerInput("xyzw ", NodeMaterialBlockConnectionPointTypes.Vector4, !0),
  85905. o.registerInput("xyz ", NodeMaterialBlockConnectionPointTypes.Vector3, !0),
  85906. o.registerInput("xy ", NodeMaterialBlockConnectionPointTypes.Vector2, !0),
  85907. o.registerInput("zw ", NodeMaterialBlockConnectionPointTypes.Vector2, !0),
  85908. o.registerInput("x", NodeMaterialBlockConnectionPointTypes.Float, !0),
  85909. o.registerInput("y", NodeMaterialBlockConnectionPointTypes.Float, !0),
  85910. o.registerInput("z", NodeMaterialBlockConnectionPointTypes.Float, !0),
  85911. o.registerInput("w", NodeMaterialBlockConnectionPointTypes.Float, !0),
  85912. o.registerOutput("xyzw", NodeMaterialBlockConnectionPointTypes.Vector4),
  85913. o.registerOutput("xyz", NodeMaterialBlockConnectionPointTypes.Vector3),
  85914. o.registerOutput("xy", NodeMaterialBlockConnectionPointTypes.Vector2),
  85915. o.registerOutput("zw", NodeMaterialBlockConnectionPointTypes.Vector2),
  85916. o
  85917. }
  85918. return e.prototype.getClassName = function() {
  85919. return "VectorMergerBlock"
  85920. }
  85921. ,
  85922. Object.defineProperty(e.prototype, "xyzwIn", {
  85923. get: function() {
  85924. return this._inputs[0]
  85925. },
  85926. enumerable: !1,
  85927. configurable: !0
  85928. }),
  85929. Object.defineProperty(e.prototype, "xyzIn", {
  85930. get: function() {
  85931. return this._inputs[1]
  85932. },
  85933. enumerable: !1,
  85934. configurable: !0
  85935. }),
  85936. Object.defineProperty(e.prototype, "xyIn", {
  85937. get: function() {
  85938. return this._inputs[2]
  85939. },
  85940. enumerable: !1,
  85941. configurable: !0
  85942. }),
  85943. Object.defineProperty(e.prototype, "zwIn", {
  85944. get: function() {
  85945. return this._inputs[3]
  85946. },
  85947. enumerable: !1,
  85948. configurable: !0
  85949. }),
  85950. Object.defineProperty(e.prototype, "x", {
  85951. get: function() {
  85952. return this._inputs[4]
  85953. },
  85954. enumerable: !1,
  85955. configurable: !0
  85956. }),
  85957. Object.defineProperty(e.prototype, "y", {
  85958. get: function() {
  85959. return this._inputs[5]
  85960. },
  85961. enumerable: !1,
  85962. configurable: !0
  85963. }),
  85964. Object.defineProperty(e.prototype, "z", {
  85965. get: function() {
  85966. return this._inputs[6]
  85967. },
  85968. enumerable: !1,
  85969. configurable: !0
  85970. }),
  85971. Object.defineProperty(e.prototype, "w", {
  85972. get: function() {
  85973. return this._inputs[7]
  85974. },
  85975. enumerable: !1,
  85976. configurable: !0
  85977. }),
  85978. Object.defineProperty(e.prototype, "xyzw", {
  85979. get: function() {
  85980. return this._outputs[0]
  85981. },
  85982. enumerable: !1,
  85983. configurable: !0
  85984. }),
  85985. Object.defineProperty(e.prototype, "xyzOut", {
  85986. get: function() {
  85987. return this._outputs[1]
  85988. },
  85989. enumerable: !1,
  85990. configurable: !0
  85991. }),
  85992. Object.defineProperty(e.prototype, "xyOut", {
  85993. get: function() {
  85994. return this._outputs[2]
  85995. },
  85996. enumerable: !1,
  85997. configurable: !0
  85998. }),
  85999. Object.defineProperty(e.prototype, "zwOut", {
  86000. get: function() {
  86001. return this._outputs[3]
  86002. },
  86003. enumerable: !1,
  86004. configurable: !0
  86005. }),
  86006. Object.defineProperty(e.prototype, "xy", {
  86007. get: function() {
  86008. return this.xyOut
  86009. },
  86010. enumerable: !1,
  86011. configurable: !0
  86012. }),
  86013. Object.defineProperty(e.prototype, "xyz", {
  86014. get: function() {
  86015. return this.xyzOut
  86016. },
  86017. enumerable: !1,
  86018. configurable: !0
  86019. }),
  86020. e.prototype._inputRename = function(i) {
  86021. return i === "xyzw " ? "xyzwIn" : i === "xyz " ? "xyzIn" : i === "xy " ? "xyIn" : i === "zw " ? "zwIn" : i
  86022. }
  86023. ,
  86024. e.prototype._buildSwizzle = function(i) {
  86025. var o = this.xSwizzle + this.ySwizzle + this.zSwizzle + this.wSwizzle;
  86026. return "." + o.substr(0, i)
  86027. }
  86028. ,
  86029. e.prototype._buildBlock = function(i) {
  86030. a.prototype._buildBlock.call(this, i);
  86031. var o = this.x
  86032. , s = this.y
  86033. , c = this.z
  86034. , d = this.w
  86035. , _ = this.xyIn
  86036. , b = this.zwIn
  86037. , k = this.xyzIn
  86038. , j = this.xyzwIn
  86039. , $ = this._outputs[0]
  86040. , _e = this._outputs[1]
  86041. , et = this._outputs[2]
  86042. , tt = this._outputs[3];
  86043. return j.isConnected ? ($.hasEndpoints && (i.compilationString += this._declareOutput($, i) + (" = " + j.associatedVariableName + this._buildSwizzle(4) + `;\r
  86044. `)),
  86045. _e.hasEndpoints && (i.compilationString += this._declareOutput(_e, i) + (" = " + j.associatedVariableName + this._buildSwizzle(3) + `;\r
  86046. `)),
  86047. et.hasEndpoints && (i.compilationString += this._declareOutput(et, i) + (" = " + j.associatedVariableName + this._buildSwizzle(2) + `;\r
  86048. `))) : k.isConnected ? ($.hasEndpoints && (i.compilationString += this._declareOutput($, i) + (" = vec4(" + k.associatedVariableName + ", " + (d.isConnected ? this._writeVariable(d) : "0.0") + ")" + this._buildSwizzle(4) + `;\r
  86049. `)),
  86050. _e.hasEndpoints && (i.compilationString += this._declareOutput(_e, i) + (" = " + k.associatedVariableName + this._buildSwizzle(3) + `;\r
  86051. `)),
  86052. et.hasEndpoints && (i.compilationString += this._declareOutput(et, i) + (" = " + k.associatedVariableName + this._buildSwizzle(2) + `;\r
  86053. `))) : _.isConnected ? ($.hasEndpoints && (b.isConnected ? i.compilationString += this._declareOutput($, i) + (" = vec4(" + _.associatedVariableName + ", " + b.associatedVariableName + ")" + this._buildSwizzle(4) + `;\r
  86054. `) : i.compilationString += this._declareOutput($, i) + (" = vec4(" + _.associatedVariableName + ", " + (c.isConnected ? this._writeVariable(c) : "0.0") + ", " + (d.isConnected ? this._writeVariable(d) : "0.0") + ")" + this._buildSwizzle(4) + `;\r
  86055. `)),
  86056. _e.hasEndpoints && (i.compilationString += this._declareOutput(_e, i) + (" = vec3(" + _.associatedVariableName + ", " + (c.isConnected ? this._writeVariable(c) : "0.0") + ")" + this._buildSwizzle(3) + `;\r
  86057. `)),
  86058. et.hasEndpoints && (i.compilationString += this._declareOutput(et, i) + (" = " + _.associatedVariableName + this._buildSwizzle(2) + `;\r
  86059. `)),
  86060. tt.hasEndpoints && (b.isConnected ? i.compilationString += this._declareOutput(tt, i) + (" = " + b.associatedVariableName + this._buildSwizzle(2) + `;\r
  86061. `) : i.compilationString += this._declareOutput(tt, i) + (" = vec2(" + (c.isConnected ? this._writeVariable(c) : "0.0") + ", " + (d.isConnected ? this._writeVariable(d) : "0.0") + ")" + this._buildSwizzle(2) + `;\r
  86062. `))) : ($.hasEndpoints && (b.isConnected ? i.compilationString += this._declareOutput($, i) + (" = vec4(" + (o.isConnected ? this._writeVariable(o) : "0.0") + ", " + (s.isConnected ? this._writeVariable(s) : "0.0") + ", " + b.associatedVariableName + ")" + this._buildSwizzle(4) + `;\r
  86063. `) : i.compilationString += this._declareOutput($, i) + (" = vec4(" + (o.isConnected ? this._writeVariable(o) : "0.0") + ", " + (s.isConnected ? this._writeVariable(s) : "0.0") + ", " + (c.isConnected ? this._writeVariable(c) : "0.0") + ", " + (d.isConnected ? this._writeVariable(d) : "0.0") + ")" + this._buildSwizzle(4) + `;\r
  86064. `)),
  86065. _e.hasEndpoints && (i.compilationString += this._declareOutput(_e, i) + (" = vec3(" + (o.isConnected ? this._writeVariable(o) : "0.0") + ", " + (s.isConnected ? this._writeVariable(s) : "0.0") + ", " + (c.isConnected ? this._writeVariable(c) : "0.0") + ")" + this._buildSwizzle(3) + `;\r
  86066. `)),
  86067. et.hasEndpoints && (i.compilationString += this._declareOutput(et, i) + (" = vec2(" + (o.isConnected ? this._writeVariable(o) : "0.0") + ", " + (s.isConnected ? this._writeVariable(s) : "0.0") + ")" + this._buildSwizzle(2) + `;\r
  86068. `)),
  86069. tt.hasEndpoints && (b.isConnected ? i.compilationString += this._declareOutput(tt, i) + (" = " + b.associatedVariableName + this._buildSwizzle(2) + `;\r
  86070. `) : i.compilationString += this._declareOutput(tt, i) + (" = vec2(" + (c.isConnected ? this._writeVariable(c) : "0.0") + ", " + (d.isConnected ? this._writeVariable(d) : "0.0") + ")" + this._buildSwizzle(2) + `;\r
  86071. `))),
  86072. this
  86073. }
  86074. ,
  86075. e.prototype.serialize = function() {
  86076. var i = a.prototype.serialize.call(this);
  86077. return i.xSwizzle = this.xSwizzle,
  86078. i.ySwizzle = this.ySwizzle,
  86079. i.zSwizzle = this.zSwizzle,
  86080. i.wSwizzle = this.wSwizzle,
  86081. i
  86082. }
  86083. ,
  86084. e.prototype._deserialize = function(i, o, s) {
  86085. var c, d, _, b;
  86086. a.prototype._deserialize.call(this, i, o, s),
  86087. this.xSwizzle = (c = i.xSwizzle) !== null && c !== void 0 ? c : "x",
  86088. this.ySwizzle = (d = i.ySwizzle) !== null && d !== void 0 ? d : "y",
  86089. this.zSwizzle = (_ = i.zSwizzle) !== null && _ !== void 0 ? _ : "z",
  86090. this.wSwizzle = (b = i.wSwizzle) !== null && b !== void 0 ? b : "w"
  86091. }
  86092. ,
  86093. e.prototype._dumpPropertiesCode = function() {
  86094. var i = a.prototype._dumpPropertiesCode.call(this);
  86095. return i += this._codeVariableName + '.xSwizzle = "' + this.xSwizzle + `";\r
  86096. `,
  86097. i += this._codeVariableName + '.ySwizzle = "' + this.ySwizzle + `";\r
  86098. `,
  86099. i += this._codeVariableName + '.zSwizzle = "' + this.zSwizzle + `";\r
  86100. `,
  86101. i += this._codeVariableName + '.wSwizzle = "' + this.wSwizzle + `";\r
  86102. `,
  86103. i
  86104. }
  86105. ,
  86106. e
  86107. }(NodeMaterialBlock);
  86108. RegisterClass("BABYLON.VectorMergerBlock", VectorMergerBlock);
  86109. var RemapBlock = function(a) {
  86110. __extends(e, a);
  86111. function e(i) {
  86112. var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
  86113. return o.sourceRange = new Vector2(-1,1),
  86114. o.targetRange = new Vector2(0,1),
  86115. o.registerInput("input", NodeMaterialBlockConnectionPointTypes.AutoDetect),
  86116. o.registerInput("sourceMin", NodeMaterialBlockConnectionPointTypes.Float, !0),
  86117. o.registerInput("sourceMax", NodeMaterialBlockConnectionPointTypes.Float, !0),
  86118. o.registerInput("targetMin", NodeMaterialBlockConnectionPointTypes.Float, !0),
  86119. o.registerInput("targetMax", NodeMaterialBlockConnectionPointTypes.Float, !0),
  86120. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
  86121. o._outputs[0]._typeConnectionSource = o._inputs[0],
  86122. o
  86123. }
  86124. return e.prototype.getClassName = function() {
  86125. return "RemapBlock"
  86126. }
  86127. ,
  86128. Object.defineProperty(e.prototype, "input", {
  86129. get: function() {
  86130. return this._inputs[0]
  86131. },
  86132. enumerable: !1,
  86133. configurable: !0
  86134. }),
  86135. Object.defineProperty(e.prototype, "sourceMin", {
  86136. get: function() {
  86137. return this._inputs[1]
  86138. },
  86139. enumerable: !1,
  86140. configurable: !0
  86141. }),
  86142. Object.defineProperty(e.prototype, "sourceMax", {
  86143. get: function() {
  86144. return this._inputs[2]
  86145. },
  86146. enumerable: !1,
  86147. configurable: !0
  86148. }),
  86149. Object.defineProperty(e.prototype, "targetMin", {
  86150. get: function() {
  86151. return this._inputs[3]
  86152. },
  86153. enumerable: !1,
  86154. configurable: !0
  86155. }),
  86156. Object.defineProperty(e.prototype, "targetMax", {
  86157. get: function() {
  86158. return this._inputs[4]
  86159. },
  86160. enumerable: !1,
  86161. configurable: !0
  86162. }),
  86163. Object.defineProperty(e.prototype, "output", {
  86164. get: function() {
  86165. return this._outputs[0]
  86166. },
  86167. enumerable: !1,
  86168. configurable: !0
  86169. }),
  86170. e.prototype._buildBlock = function(i) {
  86171. a.prototype._buildBlock.call(this, i);
  86172. var o = this._outputs[0]
  86173. , s = this.sourceMin.isConnected ? this.sourceMin.associatedVariableName : this._writeFloat(this.sourceRange.x)
  86174. , c = this.sourceMax.isConnected ? this.sourceMax.associatedVariableName : this._writeFloat(this.sourceRange.y)
  86175. , d = this.targetMin.isConnected ? this.targetMin.associatedVariableName : this._writeFloat(this.targetRange.x)
  86176. , _ = this.targetMax.isConnected ? this.targetMax.associatedVariableName : this._writeFloat(this.targetRange.y);
  86177. return i.compilationString += this._declareOutput(o, i) + (" = " + d + " + (" + this._inputs[0].associatedVariableName + " - " + s + ") * (" + _ + " - " + d + ") / (" + c + " - " + s + `);\r
  86178. `),
  86179. this
  86180. }
  86181. ,
  86182. e.prototype._dumpPropertiesCode = function() {
  86183. var i = a.prototype._dumpPropertiesCode.call(this) + (this._codeVariableName + ".sourceRange = new BABYLON.Vector2(" + this.sourceRange.x + ", " + this.sourceRange.y + `);\r
  86184. `);
  86185. return i += this._codeVariableName + ".targetRange = new BABYLON.Vector2(" + this.targetRange.x + ", " + this.targetRange.y + `);\r
  86186. `,
  86187. i
  86188. }
  86189. ,
  86190. e.prototype.serialize = function() {
  86191. var i = a.prototype.serialize.call(this);
  86192. return i.sourceRange = this.sourceRange.asArray(),
  86193. i.targetRange = this.targetRange.asArray(),
  86194. i
  86195. }
  86196. ,
  86197. e.prototype._deserialize = function(i, o, s) {
  86198. a.prototype._deserialize.call(this, i, o, s),
  86199. this.sourceRange = Vector2.FromArray(i.sourceRange),
  86200. this.targetRange = Vector2.FromArray(i.targetRange)
  86201. }
  86202. ,
  86203. __decorate([editableInPropertyPage("From", PropertyTypeForEdition.Vector2)], e.prototype, "sourceRange", void 0),
  86204. __decorate([editableInPropertyPage("To", PropertyTypeForEdition.Vector2)], e.prototype, "targetRange", void 0),
  86205. e
  86206. }(NodeMaterialBlock);
  86207. RegisterClass("BABYLON.RemapBlock", RemapBlock);
  86208. var MultiplyBlock = function(a) {
  86209. __extends(e, a);
  86210. function e(i) {
  86211. var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
  86212. return o.registerInput("left", NodeMaterialBlockConnectionPointTypes.AutoDetect),
  86213. o.registerInput("right", NodeMaterialBlockConnectionPointTypes.AutoDetect),
  86214. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
  86215. o._outputs[0]._typeConnectionSource = o._inputs[0],
  86216. o._linkConnectionTypes(0, 1),
  86217. o
  86218. }
  86219. return e.prototype.getClassName = function() {
  86220. return "MultiplyBlock"
  86221. }
  86222. ,
  86223. Object.defineProperty(e.prototype, "left", {
  86224. get: function() {
  86225. return this._inputs[0]
  86226. },
  86227. enumerable: !1,
  86228. configurable: !0
  86229. }),
  86230. Object.defineProperty(e.prototype, "right", {
  86231. get: function() {
  86232. return this._inputs[1]
  86233. },
  86234. enumerable: !1,
  86235. configurable: !0
  86236. }),
  86237. Object.defineProperty(e.prototype, "output", {
  86238. get: function() {
  86239. return this._outputs[0]
  86240. },
  86241. enumerable: !1,
  86242. configurable: !0
  86243. }),
  86244. e.prototype._buildBlock = function(i) {
  86245. a.prototype._buildBlock.call(this, i);
  86246. var o = this._outputs[0];
  86247. return i.compilationString += this._declareOutput(o, i) + (" = " + this.left.associatedVariableName + " * " + this.right.associatedVariableName + `;\r
  86248. `),
  86249. this
  86250. }
  86251. ,
  86252. e
  86253. }(NodeMaterialBlock);
  86254. RegisterClass("BABYLON.MultiplyBlock", MultiplyBlock);
  86255. var ColorSplitterBlock = function(a) {
  86256. __extends(e, a);
  86257. function e(i) {
  86258. var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
  86259. return o.registerInput("rgba", NodeMaterialBlockConnectionPointTypes.Color4, !0),
  86260. o.registerInput("rgb ", NodeMaterialBlockConnectionPointTypes.Color3, !0),
  86261. o.registerOutput("rgb", NodeMaterialBlockConnectionPointTypes.Color3),
  86262. o.registerOutput("r", NodeMaterialBlockConnectionPointTypes.Float),
  86263. o.registerOutput("g", NodeMaterialBlockConnectionPointTypes.Float),
  86264. o.registerOutput("b", NodeMaterialBlockConnectionPointTypes.Float),
  86265. o.registerOutput("a", NodeMaterialBlockConnectionPointTypes.Float),
  86266. o.inputsAreExclusive = !0,
  86267. o
  86268. }
  86269. return e.prototype.getClassName = function() {
  86270. return "ColorSplitterBlock"
  86271. }
  86272. ,
  86273. Object.defineProperty(e.prototype, "rgba", {
  86274. get: function() {
  86275. return this._inputs[0]
  86276. },
  86277. enumerable: !1,
  86278. configurable: !0
  86279. }),
  86280. Object.defineProperty(e.prototype, "rgbIn", {
  86281. get: function() {
  86282. return this._inputs[1]
  86283. },
  86284. enumerable: !1,
  86285. configurable: !0
  86286. }),
  86287. Object.defineProperty(e.prototype, "rgbOut", {
  86288. get: function() {
  86289. return this._outputs[0]
  86290. },
  86291. enumerable: !1,
  86292. configurable: !0
  86293. }),
  86294. Object.defineProperty(e.prototype, "r", {
  86295. get: function() {
  86296. return this._outputs[1]
  86297. },
  86298. enumerable: !1,
  86299. configurable: !0
  86300. }),
  86301. Object.defineProperty(e.prototype, "g", {
  86302. get: function() {
  86303. return this._outputs[2]
  86304. },
  86305. enumerable: !1,
  86306. configurable: !0
  86307. }),
  86308. Object.defineProperty(e.prototype, "b", {
  86309. get: function() {
  86310. return this._outputs[3]
  86311. },
  86312. enumerable: !1,
  86313. configurable: !0
  86314. }),
  86315. Object.defineProperty(e.prototype, "a", {
  86316. get: function() {
  86317. return this._outputs[4]
  86318. },
  86319. enumerable: !1,
  86320. configurable: !0
  86321. }),
  86322. e.prototype._inputRename = function(i) {
  86323. return i === "rgb " ? "rgbIn" : i
  86324. }
  86325. ,
  86326. e.prototype._outputRename = function(i) {
  86327. return i === "rgb" ? "rgbOut" : i
  86328. }
  86329. ,
  86330. e.prototype._buildBlock = function(i) {
  86331. a.prototype._buildBlock.call(this, i);
  86332. var o = this.rgba.isConnected ? this.rgba : this.rgbIn;
  86333. if (!!o.isConnected) {
  86334. var s = this._outputs[0]
  86335. , c = this._outputs[1]
  86336. , d = this._outputs[2]
  86337. , _ = this._outputs[3]
  86338. , b = this._outputs[4];
  86339. return s.hasEndpoints && (i.compilationString += this._declareOutput(s, i) + (" = " + o.associatedVariableName + `.rgb;\r
  86340. `)),
  86341. c.hasEndpoints && (i.compilationString += this._declareOutput(c, i) + (" = " + o.associatedVariableName + `.r;\r
  86342. `)),
  86343. d.hasEndpoints && (i.compilationString += this._declareOutput(d, i) + (" = " + o.associatedVariableName + `.g;\r
  86344. `)),
  86345. _.hasEndpoints && (i.compilationString += this._declareOutput(_, i) + (" = " + o.associatedVariableName + `.b;\r
  86346. `)),
  86347. b.hasEndpoints && (i.compilationString += this._declareOutput(b, i) + (" = " + o.associatedVariableName + `.a;\r
  86348. `)),
  86349. this
  86350. }
  86351. }
  86352. ,
  86353. e
  86354. }(NodeMaterialBlock);
  86355. RegisterClass("BABYLON.ColorSplitterBlock", ColorSplitterBlock);
  86356. var TrigonometryBlockOperations;
  86357. (function(a) {
  86358. a[a.Cos = 0] = "Cos",
  86359. a[a.Sin = 1] = "Sin",
  86360. a[a.Abs = 2] = "Abs",
  86361. a[a.Exp = 3] = "Exp",
  86362. a[a.Exp2 = 4] = "Exp2",
  86363. a[a.Round = 5] = "Round",
  86364. a[a.Floor = 6] = "Floor",
  86365. a[a.Ceiling = 7] = "Ceiling",
  86366. a[a.Sqrt = 8] = "Sqrt",
  86367. a[a.Log = 9] = "Log",
  86368. a[a.Tan = 10] = "Tan",
  86369. a[a.ArcTan = 11] = "ArcTan",
  86370. a[a.ArcCos = 12] = "ArcCos",
  86371. a[a.ArcSin = 13] = "ArcSin",
  86372. a[a.Fract = 14] = "Fract",
  86373. a[a.Sign = 15] = "Sign",
  86374. a[a.Radians = 16] = "Radians",
  86375. a[a.Degrees = 17] = "Degrees"
  86376. }
  86377. )(TrigonometryBlockOperations || (TrigonometryBlockOperations = {}));
  86378. var TrigonometryBlock = function(a) {
  86379. __extends(e, a);
  86380. function e(i) {
  86381. var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
  86382. return o.operation = TrigonometryBlockOperations.Cos,
  86383. o.registerInput("input", NodeMaterialBlockConnectionPointTypes.AutoDetect),
  86384. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
  86385. o._outputs[0]._typeConnectionSource = o._inputs[0],
  86386. o
  86387. }
  86388. return e.prototype.getClassName = function() {
  86389. return "TrigonometryBlock"
  86390. }
  86391. ,
  86392. Object.defineProperty(e.prototype, "input", {
  86393. get: function() {
  86394. return this._inputs[0]
  86395. },
  86396. enumerable: !1,
  86397. configurable: !0
  86398. }),
  86399. Object.defineProperty(e.prototype, "output", {
  86400. get: function() {
  86401. return this._outputs[0]
  86402. },
  86403. enumerable: !1,
  86404. configurable: !0
  86405. }),
  86406. e.prototype._buildBlock = function(i) {
  86407. a.prototype._buildBlock.call(this, i);
  86408. var o = this._outputs[0]
  86409. , s = "";
  86410. switch (this.operation) {
  86411. case TrigonometryBlockOperations.Cos:
  86412. {
  86413. s = "cos";
  86414. break
  86415. }
  86416. case TrigonometryBlockOperations.Sin:
  86417. {
  86418. s = "sin";
  86419. break
  86420. }
  86421. case TrigonometryBlockOperations.Abs:
  86422. {
  86423. s = "abs";
  86424. break
  86425. }
  86426. case TrigonometryBlockOperations.Exp:
  86427. {
  86428. s = "exp";
  86429. break
  86430. }
  86431. case TrigonometryBlockOperations.Exp2:
  86432. {
  86433. s = "exp2";
  86434. break
  86435. }
  86436. case TrigonometryBlockOperations.Round:
  86437. {
  86438. s = "round";
  86439. break
  86440. }
  86441. case TrigonometryBlockOperations.Floor:
  86442. {
  86443. s = "floor";
  86444. break
  86445. }
  86446. case TrigonometryBlockOperations.Ceiling:
  86447. {
  86448. s = "ceil";
  86449. break
  86450. }
  86451. case TrigonometryBlockOperations.Sqrt:
  86452. {
  86453. s = "sqrt";
  86454. break
  86455. }
  86456. case TrigonometryBlockOperations.Log:
  86457. {
  86458. s = "log";
  86459. break
  86460. }
  86461. case TrigonometryBlockOperations.Tan:
  86462. {
  86463. s = "tan";
  86464. break
  86465. }
  86466. case TrigonometryBlockOperations.ArcTan:
  86467. {
  86468. s = "atan";
  86469. break
  86470. }
  86471. case TrigonometryBlockOperations.ArcCos:
  86472. {
  86473. s = "acos";
  86474. break
  86475. }
  86476. case TrigonometryBlockOperations.ArcSin:
  86477. {
  86478. s = "asin";
  86479. break
  86480. }
  86481. case TrigonometryBlockOperations.Fract:
  86482. {
  86483. s = "fract";
  86484. break
  86485. }
  86486. case TrigonometryBlockOperations.Sign:
  86487. {
  86488. s = "sign";
  86489. break
  86490. }
  86491. case TrigonometryBlockOperations.Radians:
  86492. {
  86493. s = "radians";
  86494. break
  86495. }
  86496. case TrigonometryBlockOperations.Degrees:
  86497. {
  86498. s = "degrees";
  86499. break
  86500. }
  86501. }
  86502. return i.compilationString += this._declareOutput(o, i) + (" = " + s + "(" + this.input.associatedVariableName + `);\r
  86503. `),
  86504. this
  86505. }
  86506. ,
  86507. e.prototype.serialize = function() {
  86508. var i = a.prototype.serialize.call(this);
  86509. return i.operation = this.operation,
  86510. i
  86511. }
  86512. ,
  86513. e.prototype._deserialize = function(i, o, s) {
  86514. a.prototype._deserialize.call(this, i, o, s),
  86515. this.operation = i.operation
  86516. }
  86517. ,
  86518. e.prototype._dumpPropertiesCode = function() {
  86519. var i = a.prototype._dumpPropertiesCode.call(this) + (this._codeVariableName + ".operation = BABYLON.TrigonometryBlockOperations." + TrigonometryBlockOperations[this.operation] + `;\r
  86520. `);
  86521. return i
  86522. }
  86523. ,
  86524. e
  86525. }(NodeMaterialBlock);
  86526. RegisterClass("BABYLON.TrigonometryBlock", TrigonometryBlock);
  86527. var onCreatedEffectParameters$1 = {
  86528. effect: null,
  86529. subMesh: null
  86530. }
  86531. , NodeMaterialDefines = function(a) {
  86532. __extends(e, a);
  86533. function e() {
  86534. var i = a.call(this) || this;
  86535. return i.NORMAL = !1,
  86536. i.TANGENT = !1,
  86537. i.UV1 = !1,
  86538. i.UV2 = !1,
  86539. i.UV3 = !1,
  86540. i.UV4 = !1,
  86541. i.UV5 = !1,
  86542. i.UV6 = !1,
  86543. i.NUM_BONE_INFLUENCERS = 0,
  86544. i.BonesPerMesh = 0,
  86545. i.BONETEXTURE = !1,
  86546. i.MORPHTARGETS = !1,
  86547. i.MORPHTARGETS_NORMAL = !1,
  86548. i.MORPHTARGETS_TANGENT = !1,
  86549. i.MORPHTARGETS_UV = !1,
  86550. i.NUM_MORPH_INFLUENCERS = 0,
  86551. i.MORPHTARGETS_TEXTURE = !1,
  86552. i.IMAGEPROCESSING = !1,
  86553. i.VIGNETTE = !1,
  86554. i.VIGNETTEBLENDMODEMULTIPLY = !1,
  86555. i.VIGNETTEBLENDMODEOPAQUE = !1,
  86556. i.TONEMAPPING = !1,
  86557. i.TONEMAPPING_ACES = !1,
  86558. i.CONTRAST = !1,
  86559. i.EXPOSURE = !1,
  86560. i.COLORCURVES = !1,
  86561. i.COLORGRADING = !1,
  86562. i.COLORGRADING3D = !1,
  86563. i.SAMPLER3DGREENDEPTH = !1,
  86564. i.SAMPLER3DBGRMAP = !1,
  86565. i.IMAGEPROCESSINGPOSTPROCESS = !1,
  86566. i.SKIPFINALCOLORCLAMP = !1,
  86567. i.BUMPDIRECTUV = 0,
  86568. i.rebuild(),
  86569. i
  86570. }
  86571. return e.prototype.setValue = function(i, o, s) {
  86572. s === void 0 && (s = !1),
  86573. this[i] === void 0 && this._keys.push(i),
  86574. s && this[i] !== o && this.markAsUnprocessed(),
  86575. this[i] = o
  86576. }
  86577. ,
  86578. e
  86579. }(MaterialDefines)
  86580. , NodeMaterial = function(a) {
  86581. __extends(e, a);
  86582. function e(i, o, s) {
  86583. s === void 0 && (s = {});
  86584. var c = a.call(this, i, o || Engine.LastCreatedScene) || this;
  86585. return c._buildId = e._BuildIdGenerator++,
  86586. c._buildWasSuccessful = !1,
  86587. c._cachedWorldViewMatrix = new Matrix,
  86588. c._cachedWorldViewProjectionMatrix = new Matrix,
  86589. c._optimizers = new Array,
  86590. c._animationFrame = -1,
  86591. c.BJSNODEMATERIALEDITOR = c._getGlobalNodeMaterialEditor(),
  86592. c.editorData = null,
  86593. c.ignoreAlpha = !1,
  86594. c.maxSimultaneousLights = 4,
  86595. c.onBuildObservable = new Observable,
  86596. c._vertexOutputNodes = new Array,
  86597. c._fragmentOutputNodes = new Array,
  86598. c.attachedBlocks = new Array,
  86599. c._mode = NodeMaterialModes.Material,
  86600. c._options = __assign({
  86601. emitComments: !1
  86602. }, s),
  86603. c._attachImageProcessingConfiguration(null),
  86604. c
  86605. }
  86606. return e.prototype._getGlobalNodeMaterialEditor = function() {
  86607. if (typeof NODEEDITOR != "undefined")
  86608. return NODEEDITOR;
  86609. if (typeof BABYLON != "undefined" && typeof BABYLON.NodeEditor != "undefined")
  86610. return BABYLON
  86611. }
  86612. ,
  86613. Object.defineProperty(e.prototype, "options", {
  86614. get: function() {
  86615. return this._options
  86616. },
  86617. set: function(i) {
  86618. this._options = i
  86619. },
  86620. enumerable: !1,
  86621. configurable: !0
  86622. }),
  86623. Object.defineProperty(e.prototype, "imageProcessingConfiguration", {
  86624. get: function() {
  86625. return this._imageProcessingConfiguration
  86626. },
  86627. set: function(i) {
  86628. this._attachImageProcessingConfiguration(i),
  86629. this._markAllSubMeshesAsTexturesDirty()
  86630. },
  86631. enumerable: !1,
  86632. configurable: !0
  86633. }),
  86634. Object.defineProperty(e.prototype, "mode", {
  86635. get: function() {
  86636. return this._mode
  86637. },
  86638. set: function(i) {
  86639. this._mode = i
  86640. },
  86641. enumerable: !1,
  86642. configurable: !0
  86643. }),
  86644. Object.defineProperty(e.prototype, "buildId", {
  86645. get: function() {
  86646. return this._buildId
  86647. },
  86648. set: function(i) {
  86649. this._buildId = i
  86650. },
  86651. enumerable: !1,
  86652. configurable: !0
  86653. }),
  86654. e.prototype.getClassName = function() {
  86655. return "NodeMaterial"
  86656. }
  86657. ,
  86658. e.prototype._attachImageProcessingConfiguration = function(i) {
  86659. var o = this;
  86660. i !== this._imageProcessingConfiguration && (this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),
  86661. i ? this._imageProcessingConfiguration = i : this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration,
  86662. this._imageProcessingConfiguration && (this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function() {
  86663. o._markAllSubMeshesAsImageProcessingDirty()
  86664. })))
  86665. }
  86666. ,
  86667. e.prototype.getBlockByName = function(i) {
  86668. for (var o = null, s = 0, c = this.attachedBlocks; s < c.length; s++) {
  86669. var d = c[s];
  86670. if (d.name === i)
  86671. if (!o)
  86672. o = d;
  86673. else
  86674. return Tools.Warn("More than one block was found with the name `" + i + "`"),
  86675. o
  86676. }
  86677. return o
  86678. }
  86679. ,
  86680. e.prototype.getBlockByPredicate = function(i) {
  86681. for (var o = 0, s = this.attachedBlocks; o < s.length; o++) {
  86682. var c = s[o];
  86683. if (i(c))
  86684. return c
  86685. }
  86686. return null
  86687. }
  86688. ,
  86689. e.prototype.getInputBlockByPredicate = function(i) {
  86690. for (var o = 0, s = this.attachedBlocks; o < s.length; o++) {
  86691. var c = s[o];
  86692. if (c.isInput && i(c))
  86693. return c
  86694. }
  86695. return null
  86696. }
  86697. ,
  86698. e.prototype.getInputBlocks = function() {
  86699. for (var i = [], o = 0, s = this.attachedBlocks; o < s.length; o++) {
  86700. var c = s[o];
  86701. c.isInput && i.push(c)
  86702. }
  86703. return i
  86704. }
  86705. ,
  86706. e.prototype.registerOptimizer = function(i) {
  86707. var o = this._optimizers.indexOf(i);
  86708. if (!(o > -1))
  86709. return this._optimizers.push(i),
  86710. this
  86711. }
  86712. ,
  86713. e.prototype.unregisterOptimizer = function(i) {
  86714. var o = this._optimizers.indexOf(i);
  86715. if (o !== -1)
  86716. return this._optimizers.splice(o, 1),
  86717. this
  86718. }
  86719. ,
  86720. e.prototype.addOutputNode = function(i) {
  86721. if (i.target === null)
  86722. throw "This node is not meant to be an output node. You may want to explicitly set its target value.";
  86723. return (i.target & NodeMaterialBlockTargets.Vertex) !== 0 && this._addVertexOutputNode(i),
  86724. (i.target & NodeMaterialBlockTargets.Fragment) !== 0 && this._addFragmentOutputNode(i),
  86725. this
  86726. }
  86727. ,
  86728. e.prototype.removeOutputNode = function(i) {
  86729. return i.target === null ? this : ((i.target & NodeMaterialBlockTargets.Vertex) !== 0 && this._removeVertexOutputNode(i),
  86730. (i.target & NodeMaterialBlockTargets.Fragment) !== 0 && this._removeFragmentOutputNode(i),
  86731. this)
  86732. }
  86733. ,
  86734. e.prototype._addVertexOutputNode = function(i) {
  86735. if (this._vertexOutputNodes.indexOf(i) === -1)
  86736. return i.target = NodeMaterialBlockTargets.Vertex,
  86737. this._vertexOutputNodes.push(i),
  86738. this
  86739. }
  86740. ,
  86741. e.prototype._removeVertexOutputNode = function(i) {
  86742. var o = this._vertexOutputNodes.indexOf(i);
  86743. if (o !== -1)
  86744. return this._vertexOutputNodes.splice(o, 1),
  86745. this
  86746. }
  86747. ,
  86748. e.prototype._addFragmentOutputNode = function(i) {
  86749. if (this._fragmentOutputNodes.indexOf(i) === -1)
  86750. return i.target = NodeMaterialBlockTargets.Fragment,
  86751. this._fragmentOutputNodes.push(i),
  86752. this
  86753. }
  86754. ,
  86755. e.prototype._removeFragmentOutputNode = function(i) {
  86756. var o = this._fragmentOutputNodes.indexOf(i);
  86757. if (o !== -1)
  86758. return this._fragmentOutputNodes.splice(o, 1),
  86759. this
  86760. }
  86761. ,
  86762. e.prototype.needAlphaBlending = function() {
  86763. return this.ignoreAlpha ? !1 : this.alpha < 1 || this._sharedData && this._sharedData.hints.needAlphaBlending
  86764. }
  86765. ,
  86766. e.prototype.needAlphaTesting = function() {
  86767. return this._sharedData && this._sharedData.hints.needAlphaTesting
  86768. }
  86769. ,
  86770. e.prototype._initializeBlock = function(i, o, s, c) {
  86771. if (c === void 0 && (c = !0),
  86772. i.initialize(o),
  86773. c && i.autoConfigure(this),
  86774. i._preparationId = this._buildId,
  86775. this.attachedBlocks.indexOf(i) === -1) {
  86776. if (i.isUnique)
  86777. for (var d = i.getClassName(), _ = 0, b = this.attachedBlocks; _ < b.length; _++) {
  86778. var k = b[_];
  86779. if (k.getClassName() === d)
  86780. throw "Cannot have multiple blocks of type " + d + " in the same NodeMaterial"
  86781. }
  86782. this.attachedBlocks.push(i)
  86783. }
  86784. for (var j = 0, $ = i.inputs; j < $.length; j++) {
  86785. var _e = $[j];
  86786. _e.associatedVariableName = "";
  86787. var et = _e.connectedPoint;
  86788. if (et) {
  86789. var tt = et.ownerBlock;
  86790. tt !== i && ((tt.target === NodeMaterialBlockTargets.VertexAndFragment || o.target === NodeMaterialBlockTargets.Fragment && tt.target === NodeMaterialBlockTargets.Vertex && tt._preparationId !== this._buildId) && s.push(tt),
  86791. this._initializeBlock(tt, o, s, c))
  86792. }
  86793. }
  86794. for (var rt = 0, it = i.outputs; rt < it.length; rt++) {
  86795. var nt = it[rt];
  86796. nt.associatedVariableName = ""
  86797. }
  86798. }
  86799. ,
  86800. e.prototype._resetDualBlocks = function(i, o) {
  86801. i.target === NodeMaterialBlockTargets.VertexAndFragment && (i.buildId = o);
  86802. for (var s = 0, c = i.inputs; s < c.length; s++) {
  86803. var d = c[s]
  86804. , _ = d.connectedPoint;
  86805. if (_) {
  86806. var b = _.ownerBlock;
  86807. b !== i && this._resetDualBlocks(b, o)
  86808. }
  86809. }
  86810. }
  86811. ,
  86812. e.prototype.removeBlock = function(i) {
  86813. var o = this.attachedBlocks.indexOf(i);
  86814. o > -1 && this.attachedBlocks.splice(o, 1),
  86815. i.isFinalMerger && this.removeOutputNode(i)
  86816. }
  86817. ,
  86818. e.prototype.build = function(i, o, s) {
  86819. i === void 0 && (i = !1),
  86820. o === void 0 && (o = !0),
  86821. s === void 0 && (s = !0),
  86822. this._buildWasSuccessful = !1;
  86823. var c = this.getScene().getEngine()
  86824. , d = this._mode === NodeMaterialModes.Particle;
  86825. if (this._vertexOutputNodes.length === 0 && !d)
  86826. throw "You must define at least one vertexOutputNode";
  86827. if (this._fragmentOutputNodes.length === 0)
  86828. throw "You must define at least one fragmentOutputNode";
  86829. this._vertexCompilationState = new NodeMaterialBuildState,
  86830. this._vertexCompilationState.supportUniformBuffers = c.supportsUniformBuffers,
  86831. this._vertexCompilationState.target = NodeMaterialBlockTargets.Vertex,
  86832. this._fragmentCompilationState = new NodeMaterialBuildState,
  86833. this._fragmentCompilationState.supportUniformBuffers = c.supportsUniformBuffers,
  86834. this._fragmentCompilationState.target = NodeMaterialBlockTargets.Fragment,
  86835. this._sharedData = new NodeMaterialBuildStateSharedData,
  86836. this._sharedData.fragmentOutputNodes = this._fragmentOutputNodes,
  86837. this._vertexCompilationState.sharedData = this._sharedData,
  86838. this._fragmentCompilationState.sharedData = this._sharedData,
  86839. this._sharedData.buildId = this._buildId,
  86840. this._sharedData.emitComments = this._options.emitComments,
  86841. this._sharedData.verbose = i,
  86842. this._sharedData.scene = this.getScene(),
  86843. this._sharedData.allowEmptyVertexProgram = d;
  86844. for (var _ = [], b = [], k = 0, j = this._vertexOutputNodes; k < j.length; k++) {
  86845. var $ = j[k];
  86846. _.push($),
  86847. this._initializeBlock($, this._vertexCompilationState, b, s)
  86848. }
  86849. for (var _e = 0, et = this._fragmentOutputNodes; _e < et.length; _e++) {
  86850. var tt = et[_e];
  86851. b.push(tt),
  86852. this._initializeBlock(tt, this._fragmentCompilationState, _, s)
  86853. }
  86854. this.optimize();
  86855. for (var rt = 0, it = _; rt < it.length; rt++) {
  86856. var $ = it[rt];
  86857. $.build(this._vertexCompilationState, _)
  86858. }
  86859. this._fragmentCompilationState.uniforms = this._vertexCompilationState.uniforms.slice(0),
  86860. this._fragmentCompilationState._uniformDeclaration = this._vertexCompilationState._uniformDeclaration,
  86861. this._fragmentCompilationState._constantDeclaration = this._vertexCompilationState._constantDeclaration,
  86862. this._fragmentCompilationState._vertexState = this._vertexCompilationState;
  86863. for (var nt = 0, ot = b; nt < ot.length; nt++) {
  86864. var tt = ot[nt];
  86865. this._resetDualBlocks(tt, this._buildId - 1)
  86866. }
  86867. for (var at = 0, st = b; at < st.length; at++) {
  86868. var tt = st[at];
  86869. tt.build(this._fragmentCompilationState, b)
  86870. }
  86871. this._vertexCompilationState.finalize(this._vertexCompilationState),
  86872. this._fragmentCompilationState.finalize(this._fragmentCompilationState),
  86873. o && (this._buildId = e._BuildIdGenerator++),
  86874. this._sharedData.emitErrors(),
  86875. i && (console.log("Vertex shader:"),
  86876. console.log(this._vertexCompilationState.compilationString),
  86877. console.log("Fragment shader:"),
  86878. console.log(this._fragmentCompilationState.compilationString)),
  86879. this._buildWasSuccessful = !0,
  86880. this.onBuildObservable.notifyObservers(this);
  86881. for (var ut = this.getScene().meshes, ct = 0, lt = ut; ct < lt.length; ct++) {
  86882. var ft = lt[ct];
  86883. if (!!ft.subMeshes)
  86884. for (var ht = 0, pt = ft.subMeshes; ht < pt.length; ht++) {
  86885. var dt = pt[ht];
  86886. if (dt.getMaterial() === this && !!dt.materialDefines) {
  86887. var _t = dt.materialDefines;
  86888. _t.markAllAsDirty(),
  86889. _t.reset()
  86890. }
  86891. }
  86892. }
  86893. }
  86894. ,
  86895. e.prototype.optimize = function() {
  86896. for (var i = 0, o = this._optimizers; i < o.length; i++) {
  86897. var s = o[i];
  86898. s.optimize(this._vertexOutputNodes, this._fragmentOutputNodes)
  86899. }
  86900. }
  86901. ,
  86902. e.prototype._prepareDefinesForAttributes = function(i, o) {
  86903. var s = o.NORMAL
  86904. , c = o.TANGENT;
  86905. o.NORMAL = i.isVerticesDataPresent(VertexBuffer.NormalKind),
  86906. o.TANGENT = i.isVerticesDataPresent(VertexBuffer.TangentKind);
  86907. for (var d = !1, _ = 1; _ <= 6; ++_) {
  86908. var b = o["UV" + _];
  86909. o["UV" + _] = i.isVerticesDataPresent("uv" + (_ === 1 ? "" : _)),
  86910. d = d || o["UV" + _] !== b
  86911. }
  86912. (s !== o.NORMAL || c !== o.TANGENT || d) && o.markAsAttributesDirty()
  86913. }
  86914. ,
  86915. e.prototype.createPostProcess = function(i, o, s, c, d, _, b) {
  86916. return o === void 0 && (o = 1),
  86917. s === void 0 && (s = 1),
  86918. _ === void 0 && (_ = 0),
  86919. b === void 0 && (b = 5),
  86920. this.mode !== NodeMaterialModes.PostProcess ? (console.log("Incompatible material mode"),
  86921. null) : this._createEffectForPostProcess(null, i, o, s, c, d, _, b)
  86922. }
  86923. ,
  86924. e.prototype.createEffectForPostProcess = function(i) {
  86925. this._createEffectForPostProcess(i)
  86926. }
  86927. ,
  86928. e.prototype._createEffectForPostProcess = function(i, o, s, c, d, _, b, k) {
  86929. var j = this;
  86930. s === void 0 && (s = 1),
  86931. c === void 0 && (c = 1),
  86932. b === void 0 && (b = 0),
  86933. k === void 0 && (k = 5);
  86934. var $ = this.name + this._buildId
  86935. , _e = new NodeMaterialDefines
  86936. , et = new AbstractMesh($ + "PostProcess",this.getScene())
  86937. , tt = this._buildId;
  86938. return this._processDefines(et, _e),
  86939. Effect.RegisterShader($, this._fragmentCompilationState._builtCompilationString, this._vertexCompilationState._builtCompilationString),
  86940. i ? i.updateEffect(_e.toString(), this._fragmentCompilationState.uniforms, this._fragmentCompilationState.samplers, {
  86941. maxSimultaneousLights: this.maxSimultaneousLights
  86942. }, void 0, void 0, $, $) : i = new PostProcess(this.name + "PostProcess",$,this._fragmentCompilationState.uniforms,this._fragmentCompilationState.samplers,s,o,c,d,_,_e.toString(),b,$,{
  86943. maxSimultaneousLights: this.maxSimultaneousLights
  86944. },!1,k),
  86945. i.nodeMaterialSource = this,
  86946. i.onApplyObservable.add(function(rt) {
  86947. tt !== j._buildId && (delete Effect.ShadersStore[$ + "VertexShader"],
  86948. delete Effect.ShadersStore[$ + "PixelShader"],
  86949. $ = j.name + j._buildId,
  86950. _e.markAllAsDirty(),
  86951. tt = j._buildId);
  86952. var it = j._processDefines(et, _e);
  86953. it && (Effect.RegisterShader($, j._fragmentCompilationState._builtCompilationString, j._vertexCompilationState._builtCompilationString),
  86954. TimingTools.SetImmediate(function() {
  86955. return i.updateEffect(_e.toString(), j._fragmentCompilationState.uniforms, j._fragmentCompilationState.samplers, {
  86956. maxSimultaneousLights: j.maxSimultaneousLights
  86957. }, void 0, void 0, $, $)
  86958. })),
  86959. j._checkInternals(rt)
  86960. }),
  86961. i
  86962. }
  86963. ,
  86964. e.prototype.createProceduralTexture = function(i, o) {
  86965. var s = this;
  86966. if (this.mode !== NodeMaterialModes.ProceduralTexture)
  86967. return console.log("Incompatible material mode"),
  86968. null;
  86969. var c = this.name + this._buildId
  86970. , d = new ProceduralTexture(c,i,null,o)
  86971. , _ = new AbstractMesh(c + "Procedural",this.getScene());
  86972. _.reservedDataStore = {
  86973. hidden: !0
  86974. };
  86975. var b = new NodeMaterialDefines
  86976. , k = this._processDefines(_, b);
  86977. Effect.RegisterShader(c, this._fragmentCompilationState._builtCompilationString, this._vertexCompilationState._builtCompilationString);
  86978. var j = this.getScene().getEngine().createEffect({
  86979. vertexElement: c,
  86980. fragmentElement: c
  86981. }, [VertexBuffer.PositionKind], this._fragmentCompilationState.uniforms, this._fragmentCompilationState.samplers, b.toString(), k == null ? void 0 : k.fallbacks, void 0);
  86982. d.nodeMaterialSource = this,
  86983. d._setEffect(j);
  86984. var $ = this._buildId;
  86985. return d.onBeforeGenerationObservable.add(function() {
  86986. $ !== s._buildId && (delete Effect.ShadersStore[c + "VertexShader"],
  86987. delete Effect.ShadersStore[c + "PixelShader"],
  86988. c = s.name + s._buildId,
  86989. b.markAllAsDirty(),
  86990. $ = s._buildId);
  86991. var _e = s._processDefines(_, b);
  86992. _e && (Effect.RegisterShader(c, s._fragmentCompilationState._builtCompilationString, s._vertexCompilationState._builtCompilationString),
  86993. TimingTools.SetImmediate(function() {
  86994. j = s.getScene().getEngine().createEffect({
  86995. vertexElement: c,
  86996. fragmentElement: c
  86997. }, [VertexBuffer.PositionKind], s._fragmentCompilationState.uniforms, s._fragmentCompilationState.samplers, b.toString(), _e == null ? void 0 : _e.fallbacks, void 0),
  86998. d._setEffect(j)
  86999. })),
  87000. s._checkInternals(j)
  87001. }),
  87002. d
  87003. }
  87004. ,
  87005. e.prototype._createEffectForParticles = function(i, o, s, c, d, _, b, k) {
  87006. var j = this;
  87007. k === void 0 && (k = "");
  87008. var $ = this.name + this._buildId + "_" + o;
  87009. _ || (_ = new NodeMaterialDefines),
  87010. b || (b = this.getScene().getMeshByName(this.name + "Particle"),
  87011. b || (b = new AbstractMesh(this.name + "Particle",this.getScene()),
  87012. b.reservedDataStore = {
  87013. hidden: !0
  87014. }));
  87015. var _e = this._buildId
  87016. , et = []
  87017. , tt = k;
  87018. if (!d) {
  87019. var rt = this._processDefines(b, _);
  87020. Effect.RegisterShader($, this._fragmentCompilationState._builtCompilationString),
  87021. i.fillDefines(et, o),
  87022. tt = et.join(`
  87023. `),
  87024. d = this.getScene().getEngine().createEffectForParticles($, this._fragmentCompilationState.uniforms, this._fragmentCompilationState.samplers, _.toString() + `
  87025. ` + tt, rt == null ? void 0 : rt.fallbacks, s, c, i),
  87026. i.setCustomEffect(d, o)
  87027. }
  87028. d.onBindObservable.add(function(it) {
  87029. _e !== j._buildId && (delete Effect.ShadersStore[$ + "PixelShader"],
  87030. $ = j.name + j._buildId + "_" + o,
  87031. _.markAllAsDirty(),
  87032. _e = j._buildId),
  87033. et.length = 0,
  87034. i.fillDefines(et, o);
  87035. var nt = et.join(`
  87036. `);
  87037. nt !== tt && (_.markAllAsDirty(),
  87038. tt = nt);
  87039. var ot = j._processDefines(b, _);
  87040. if (ot) {
  87041. Effect.RegisterShader($, j._fragmentCompilationState._builtCompilationString),
  87042. it = j.getScene().getEngine().createEffectForParticles($, j._fragmentCompilationState.uniforms, j._fragmentCompilationState.samplers, _.toString() + `
  87043. ` + tt, ot == null ? void 0 : ot.fallbacks, s, c, i),
  87044. i.setCustomEffect(it, o),
  87045. j._createEffectForParticles(i, o, s, c, it, _, b, tt);
  87046. return
  87047. }
  87048. j._checkInternals(it)
  87049. })
  87050. }
  87051. ,
  87052. e.prototype._checkInternals = function(i) {
  87053. if (this._sharedData.animatedInputs) {
  87054. var o = this.getScene()
  87055. , s = o.getFrameId();
  87056. if (this._animationFrame !== s) {
  87057. for (var c = 0, d = this._sharedData.animatedInputs; c < d.length; c++) {
  87058. var _ = d[c];
  87059. _.animate(o)
  87060. }
  87061. this._animationFrame = s
  87062. }
  87063. }
  87064. for (var b = 0, k = this._sharedData.bindableBlocks; b < k.length; b++) {
  87065. var j = k[b];
  87066. j.bind(i, this)
  87067. }
  87068. for (var $ = 0, _e = this._sharedData.inputBlocks; $ < _e.length; $++) {
  87069. var et = _e[$];
  87070. et._transmit(i, this.getScene())
  87071. }
  87072. }
  87073. ,
  87074. e.prototype.createEffectForParticles = function(i, o, s) {
  87075. if (this.mode !== NodeMaterialModes.Particle) {
  87076. console.log("Incompatible material mode");
  87077. return
  87078. }
  87079. this._createEffectForParticles(i, BaseParticleSystem.BLENDMODE_ONEONE, o, s),
  87080. this._createEffectForParticles(i, BaseParticleSystem.BLENDMODE_MULTIPLY, o, s)
  87081. }
  87082. ,
  87083. e.prototype._processDefines = function(i, o, s, c) {
  87084. var d = this;
  87085. s === void 0 && (s = !1);
  87086. var _ = null;
  87087. if (this._sharedData.blocksWithDefines.forEach(function(et) {
  87088. et.initializeDefines(i, d, o, s)
  87089. }),
  87090. this._sharedData.blocksWithDefines.forEach(function(et) {
  87091. et.prepareDefines(i, d, o, s, c)
  87092. }),
  87093. o.isDirty) {
  87094. var b = o._areLightsDisposed;
  87095. o.markAsProcessed(),
  87096. this._vertexCompilationState.compilationString = this._vertexCompilationState._builtCompilationString,
  87097. this._fragmentCompilationState.compilationString = this._fragmentCompilationState._builtCompilationString,
  87098. this._sharedData.repeatableContentBlocks.forEach(function(et) {
  87099. et.replaceRepeatableContent(d._vertexCompilationState, d._fragmentCompilationState, i, o)
  87100. });
  87101. var k = [];
  87102. this._sharedData.dynamicUniformBlocks.forEach(function(et) {
  87103. et.updateUniformsAndSamples(d._vertexCompilationState, d, o, k)
  87104. });
  87105. var j = this._vertexCompilationState.uniforms;
  87106. this._fragmentCompilationState.uniforms.forEach(function(et) {
  87107. var tt = j.indexOf(et);
  87108. tt === -1 && j.push(et)
  87109. });
  87110. var $ = this._vertexCompilationState.samplers;
  87111. this._fragmentCompilationState.samplers.forEach(function(et) {
  87112. var tt = $.indexOf(et);
  87113. tt === -1 && $.push(et)
  87114. });
  87115. var _e = new EffectFallbacks;
  87116. this._sharedData.blocksWithFallbacks.forEach(function(et) {
  87117. et.provideFallbacks(i, _e)
  87118. }),
  87119. _ = {
  87120. lightDisposed: b,
  87121. uniformBuffers: k,
  87122. mergedUniforms: j,
  87123. mergedSamplers: $,
  87124. fallbacks: _e
  87125. }
  87126. }
  87127. return _
  87128. }
  87129. ,
  87130. e.prototype.isReadyForSubMesh = function(i, o, s) {
  87131. var c = this;
  87132. if (s === void 0 && (s = !1),
  87133. !this._buildWasSuccessful)
  87134. return !1;
  87135. var d = this.getScene();
  87136. if (this._sharedData.animatedInputs) {
  87137. var _ = d.getFrameId();
  87138. if (this._animationFrame !== _) {
  87139. for (var b = 0, k = this._sharedData.animatedInputs; b < k.length; b++) {
  87140. var j = k[b];
  87141. j.animate(d)
  87142. }
  87143. this._animationFrame = _
  87144. }
  87145. }
  87146. if (o.effect && this.isFrozen && o.effect._wasPreviouslyReady)
  87147. return !0;
  87148. o.materialDefines || (o.materialDefines = new NodeMaterialDefines);
  87149. var $ = o.materialDefines;
  87150. if (this._isReadyForSubMesh(o))
  87151. return !0;
  87152. var _e = d.getEngine();
  87153. if (this._prepareDefinesForAttributes(i, $),
  87154. this._sharedData.blockingBlocks.some(function(nt) {
  87155. return !nt.isReady(i, c, $, s)
  87156. }))
  87157. return !1;
  87158. var et = this._processDefines(i, $, s, o);
  87159. if (et) {
  87160. var tt = o.effect
  87161. , rt = $.toString()
  87162. , it = _e.createEffect({
  87163. vertex: "nodeMaterial" + this._buildId,
  87164. fragment: "nodeMaterial" + this._buildId,
  87165. vertexSource: this._vertexCompilationState.compilationString,
  87166. fragmentSource: this._fragmentCompilationState.compilationString
  87167. }, {
  87168. attributes: this._vertexCompilationState.attributes,
  87169. uniformsNames: et.mergedUniforms,
  87170. uniformBuffersNames: et.uniformBuffers,
  87171. samplers: et.mergedSamplers,
  87172. defines: rt,
  87173. fallbacks: et.fallbacks,
  87174. onCompiled: this.onCompiled,
  87175. onError: this.onError,
  87176. indexParameters: {
  87177. maxSimultaneousLights: this.maxSimultaneousLights,
  87178. maxSimultaneousMorphTargets: $.NUM_MORPH_INFLUENCERS
  87179. }
  87180. }, _e);
  87181. if (it)
  87182. if (this._onEffectCreatedObservable && (onCreatedEffectParameters$1.effect = it,
  87183. onCreatedEffectParameters$1.subMesh = o,
  87184. this._onEffectCreatedObservable.notifyObservers(onCreatedEffectParameters$1)),
  87185. this.allowShaderHotSwapping && tt && !it.isReady()) {
  87186. if (it = tt,
  87187. $.markAsUnprocessed(),
  87188. et.lightDisposed)
  87189. return $._areLightsDisposed = !0,
  87190. !1
  87191. } else
  87192. d.resetCachedMaterial(),
  87193. o.setEffect(it, $, this._materialContext)
  87194. }
  87195. return !o.effect || !o.effect.isReady() ? !1 : ($._renderId = d.getRenderId(),
  87196. o.effect._wasPreviouslyReady = !0,
  87197. !0)
  87198. }
  87199. ,
  87200. Object.defineProperty(e.prototype, "compiledShaders", {
  87201. get: function() {
  87202. return `// Vertex shader\r
  87203. ` + this._vertexCompilationState.compilationString + `\r
  87204. \r
  87205. // Fragment shader\r
  87206. ` + this._fragmentCompilationState.compilationString
  87207. },
  87208. enumerable: !1,
  87209. configurable: !0
  87210. }),
  87211. e.prototype.bindOnlyWorldMatrix = function(i) {
  87212. var o = this.getScene();
  87213. if (!!this._activeEffect) {
  87214. var s = this._sharedData.hints;
  87215. s.needWorldViewMatrix && i.multiplyToRef(o.getViewMatrix(), this._cachedWorldViewMatrix),
  87216. s.needWorldViewProjectionMatrix && i.multiplyToRef(o.getTransformMatrix(), this._cachedWorldViewProjectionMatrix);
  87217. for (var c = 0, d = this._sharedData.inputBlocks; c < d.length; c++) {
  87218. var _ = d[c];
  87219. _._transmitWorld(this._activeEffect, i, this._cachedWorldViewMatrix, this._cachedWorldViewProjectionMatrix)
  87220. }
  87221. }
  87222. }
  87223. ,
  87224. e.prototype.bindForSubMesh = function(i, o, s) {
  87225. var c = this.getScene()
  87226. , d = s.effect;
  87227. if (!!d) {
  87228. this._activeEffect = d,
  87229. this.bindOnlyWorldMatrix(i);
  87230. var _ = this._mustRebind(c, d, o.visibility)
  87231. , b = this._sharedData;
  87232. if (_) {
  87233. if (d) {
  87234. for (var k = 0, j = b.bindableBlocks; k < j.length; k++) {
  87235. var $ = j[k];
  87236. $.bind(d, this, o, s)
  87237. }
  87238. for (var _e = 0, et = b.forcedBindableBlocks; _e < et.length; _e++) {
  87239. var $ = et[_e];
  87240. $.bind(d, this, o, s)
  87241. }
  87242. for (var tt = 0, rt = b.inputBlocks; tt < rt.length; tt++) {
  87243. var it = rt[tt];
  87244. it._transmit(d, c)
  87245. }
  87246. }
  87247. } else if (!this.isFrozen)
  87248. for (var nt = 0, ot = b.forcedBindableBlocks; nt < ot.length; nt++) {
  87249. var $ = ot[nt];
  87250. $.bind(d, this, o, s)
  87251. }
  87252. this._afterBind(o, this._activeEffect)
  87253. }
  87254. }
  87255. ,
  87256. e.prototype.getActiveTextures = function() {
  87257. var i = a.prototype.getActiveTextures.call(this);
  87258. return this._sharedData && i.push.apply(i, this._sharedData.textureBlocks.filter(function(o) {
  87259. return o.texture
  87260. }).map(function(o) {
  87261. return o.texture
  87262. })),
  87263. i
  87264. }
  87265. ,
  87266. e.prototype.getTextureBlocks = function() {
  87267. return this._sharedData ? this._sharedData.textureBlocks : []
  87268. }
  87269. ,
  87270. e.prototype.hasTexture = function(i) {
  87271. if (a.prototype.hasTexture.call(this, i))
  87272. return !0;
  87273. if (!this._sharedData)
  87274. return !1;
  87275. for (var o = 0, s = this._sharedData.textureBlocks; o < s.length; o++) {
  87276. var c = s[o];
  87277. if (c.texture === i)
  87278. return !0
  87279. }
  87280. return !1
  87281. }
  87282. ,
  87283. e.prototype.dispose = function(i, o, s) {
  87284. if (o && this._sharedData)
  87285. for (var c = 0, d = this._sharedData.textureBlocks.filter(function($) {
  87286. return $.texture
  87287. }).map(function($) {
  87288. return $.texture
  87289. }); c < d.length; c++) {
  87290. var _ = d[c];
  87291. _.dispose()
  87292. }
  87293. for (var b = 0, k = this.attachedBlocks; b < k.length; b++) {
  87294. var j = k[b];
  87295. j.dispose()
  87296. }
  87297. this.attachedBlocks = [],
  87298. this._sharedData = null,
  87299. this._vertexCompilationState = null,
  87300. this._fragmentCompilationState = null,
  87301. this.attachedBlocks = [],
  87302. this._sharedData = null,
  87303. this._vertexCompilationState = null,
  87304. this._fragmentCompilationState = null,
  87305. this.onBuildObservable.clear(),
  87306. this._imageProcessingObserver && (this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),
  87307. this._imageProcessingObserver = null),
  87308. a.prototype.dispose.call(this, i, o, s)
  87309. }
  87310. ,
  87311. e.prototype._createNodeEditor = function() {
  87312. this.BJSNODEMATERIALEDITOR.NodeEditor.Show({
  87313. nodeMaterial: this
  87314. })
  87315. }
  87316. ,
  87317. e.prototype.edit = function(i) {
  87318. var o = this;
  87319. return new Promise(function(s, c) {
  87320. if (o.BJSNODEMATERIALEDITOR = o.BJSNODEMATERIALEDITOR || o._getGlobalNodeMaterialEditor(),
  87321. typeof o.BJSNODEMATERIALEDITOR == "undefined") {
  87322. var d = i && i.editorURL ? i.editorURL : e.EditorURL;
  87323. Tools.LoadScript(d, function() {
  87324. o.BJSNODEMATERIALEDITOR = o.BJSNODEMATERIALEDITOR || o._getGlobalNodeMaterialEditor(),
  87325. o._createNodeEditor(),
  87326. s()
  87327. })
  87328. } else
  87329. o._createNodeEditor(),
  87330. s()
  87331. }
  87332. )
  87333. }
  87334. ,
  87335. e.prototype.clear = function() {
  87336. this._vertexOutputNodes = [],
  87337. this._fragmentOutputNodes = [],
  87338. this.attachedBlocks = []
  87339. }
  87340. ,
  87341. e.prototype.setToDefault = function() {
  87342. this.clear(),
  87343. this.editorData = null;
  87344. var i = new InputBlock("Position");
  87345. i.setAsAttribute("position");
  87346. var o = new InputBlock("World");
  87347. o.setAsSystemValue(NodeMaterialSystemValues.World);
  87348. var s = new TransformBlock("WorldPos");
  87349. i.connectTo(s),
  87350. o.connectTo(s);
  87351. var c = new InputBlock("ViewProjection");
  87352. c.setAsSystemValue(NodeMaterialSystemValues.ViewProjection);
  87353. var d = new TransformBlock("WorldPos * ViewProjectionTransform");
  87354. s.connectTo(d),
  87355. c.connectTo(d);
  87356. var _ = new VertexOutputBlock("VertexOutput");
  87357. d.connectTo(_);
  87358. var b = new InputBlock("color");
  87359. b.value = new Color4(.8,.8,.8,1);
  87360. var k = new FragmentOutputBlock("FragmentOutput");
  87361. b.connectTo(k),
  87362. this.addOutputNode(_),
  87363. this.addOutputNode(k),
  87364. this._mode = NodeMaterialModes.Material
  87365. }
  87366. ,
  87367. e.prototype.setToDefaultPostProcess = function() {
  87368. this.clear(),
  87369. this.editorData = null;
  87370. var i = new InputBlock("Position");
  87371. i.setAsAttribute("position2d");
  87372. var o = new InputBlock("Constant1");
  87373. o.isConstant = !0,
  87374. o.value = 1;
  87375. var s = new VectorMergerBlock("Position3D");
  87376. i.connectTo(s),
  87377. o.connectTo(s, {
  87378. input: "w"
  87379. });
  87380. var c = new VertexOutputBlock("VertexOutput");
  87381. s.connectTo(c);
  87382. var d = new InputBlock("Scale");
  87383. d.visibleInInspector = !0,
  87384. d.value = new Vector2(1,1);
  87385. var _ = new RemapBlock("uv0");
  87386. i.connectTo(_);
  87387. var b = new MultiplyBlock("UV scale");
  87388. _.connectTo(b),
  87389. d.connectTo(b);
  87390. var k = new CurrentScreenBlock("CurrentScreen");
  87391. b.connectTo(k),
  87392. k.texture = new Texture("https://assets.babylonjs.com/nme/currentScreenPostProcess.png",this.getScene());
  87393. var j = new FragmentOutputBlock("FragmentOutput");
  87394. k.connectTo(j, {
  87395. output: "rgba"
  87396. }),
  87397. this.addOutputNode(c),
  87398. this.addOutputNode(j),
  87399. this._mode = NodeMaterialModes.PostProcess
  87400. }
  87401. ,
  87402. e.prototype.setToDefaultProceduralTexture = function() {
  87403. this.clear(),
  87404. this.editorData = null;
  87405. var i = new InputBlock("Position");
  87406. i.setAsAttribute("position2d");
  87407. var o = new InputBlock("Constant1");
  87408. o.isConstant = !0,
  87409. o.value = 1;
  87410. var s = new VectorMergerBlock("Position3D");
  87411. i.connectTo(s),
  87412. o.connectTo(s, {
  87413. input: "w"
  87414. });
  87415. var c = new VertexOutputBlock("VertexOutput");
  87416. s.connectTo(c);
  87417. var d = new InputBlock("Time");
  87418. d.value = 0,
  87419. d.min = 0,
  87420. d.max = 0,
  87421. d.isBoolean = !1,
  87422. d.matrixMode = 0,
  87423. d.animationType = AnimatedInputBlockTypes.Time,
  87424. d.isConstant = !1;
  87425. var _ = new InputBlock("Color3");
  87426. _.value = new Color3(1,1,1),
  87427. _.isConstant = !1;
  87428. var b = new FragmentOutputBlock("FragmentOutput")
  87429. , k = new VectorMergerBlock("VectorMerger");
  87430. k.visibleInInspector = !1;
  87431. var j = new TrigonometryBlock("Cos");
  87432. j.operation = TrigonometryBlockOperations.Cos,
  87433. i.connectTo(k),
  87434. d.output.connectTo(j.input),
  87435. j.output.connectTo(k.z),
  87436. k.xyzOut.connectTo(b.rgb),
  87437. this.addOutputNode(c),
  87438. this.addOutputNode(b),
  87439. this._mode = NodeMaterialModes.ProceduralTexture
  87440. }
  87441. ,
  87442. e.prototype.setToDefaultParticle = function() {
  87443. this.clear(),
  87444. this.editorData = null;
  87445. var i = new InputBlock("uv");
  87446. i.setAsAttribute("particle_uv");
  87447. var o = new ParticleTextureBlock("ParticleTexture");
  87448. i.connectTo(o);
  87449. var s = new InputBlock("Color");
  87450. s.setAsAttribute("particle_color");
  87451. var c = new MultiplyBlock("Texture * Color");
  87452. o.connectTo(c),
  87453. s.connectTo(c);
  87454. var d = new ParticleRampGradientBlock("ParticleRampGradient");
  87455. c.connectTo(d);
  87456. var _ = new ColorSplitterBlock("ColorSplitter");
  87457. s.connectTo(_);
  87458. var b = new ParticleBlendMultiplyBlock("ParticleBlendMultiply");
  87459. d.connectTo(b),
  87460. o.connectTo(b, {
  87461. output: "a"
  87462. }),
  87463. _.connectTo(b, {
  87464. output: "a"
  87465. });
  87466. var k = new FragmentOutputBlock("FragmentOutput");
  87467. b.connectTo(k),
  87468. this.addOutputNode(k),
  87469. this._mode = NodeMaterialModes.Particle
  87470. }
  87471. ,
  87472. e.prototype.loadAsync = function(i) {
  87473. var o = this;
  87474. return this.getScene()._loadFileAsync(i).then(function(s) {
  87475. var c = JSON.parse(s);
  87476. o.loadFromSerialization(c, "")
  87477. })
  87478. }
  87479. ,
  87480. e.prototype._gatherBlocks = function(i, o) {
  87481. if (o.indexOf(i) === -1) {
  87482. o.push(i);
  87483. for (var s = 0, c = i.inputs; s < c.length; s++) {
  87484. var d = c[s]
  87485. , _ = d.connectedPoint;
  87486. if (_) {
  87487. var b = _.ownerBlock;
  87488. b !== i && this._gatherBlocks(b, o)
  87489. }
  87490. }
  87491. }
  87492. }
  87493. ,
  87494. e.prototype.generateCode = function() {
  87495. for (var i = [], o = [], s = ["const", "var", "let"], c = 0, d = this._vertexOutputNodes; c < d.length; c++) {
  87496. var _ = d[c];
  87497. this._gatherBlocks(_, o)
  87498. }
  87499. for (var b = [], k = 0, j = this._fragmentOutputNodes; k < j.length; k++) {
  87500. var _ = j[k];
  87501. this._gatherBlocks(_, b)
  87502. }
  87503. for (var $ = 'var nodeMaterial = new BABYLON.NodeMaterial("' + (this.name || "node material") + `");\r
  87504. `, _e = 0, et = o; _e < et.length; _e++) {
  87505. var tt = et[_e];
  87506. tt.isInput && i.indexOf(tt) === -1 && ($ += tt._dumpCode(s, i))
  87507. }
  87508. for (var rt = 0, it = b; rt < it.length; rt++) {
  87509. var tt = it[rt];
  87510. tt.isInput && i.indexOf(tt) === -1 && ($ += tt._dumpCode(s, i))
  87511. }
  87512. i = [],
  87513. $ += `\r
  87514. // Connections\r
  87515. `;
  87516. for (var nt = 0, ot = this._vertexOutputNodes; nt < ot.length; nt++) {
  87517. var tt = ot[nt];
  87518. $ += tt._dumpCodeForOutputConnections(i)
  87519. }
  87520. for (var at = 0, st = this._fragmentOutputNodes; at < st.length; at++) {
  87521. var tt = st[at];
  87522. $ += tt._dumpCodeForOutputConnections(i)
  87523. }
  87524. $ += `\r
  87525. // Output nodes\r
  87526. `;
  87527. for (var ut = 0, ct = this._vertexOutputNodes; ut < ct.length; ut++) {
  87528. var tt = ct[ut];
  87529. $ += "nodeMaterial.addOutputNode(" + tt._codeVariableName + `);\r
  87530. `
  87531. }
  87532. for (var lt = 0, ft = this._fragmentOutputNodes; lt < ft.length; lt++) {
  87533. var tt = ft[lt];
  87534. $ += "nodeMaterial.addOutputNode(" + tt._codeVariableName + `);\r
  87535. `
  87536. }
  87537. return $ += `nodeMaterial.build();\r
  87538. `,
  87539. $
  87540. }
  87541. ,
  87542. e.prototype.serialize = function(i) {
  87543. var o = i ? {} : SerializationHelper.Serialize(this);
  87544. o.editorData = JSON.parse(JSON.stringify(this.editorData));
  87545. var s = [];
  87546. if (i)
  87547. s = i;
  87548. else {
  87549. o.customType = "BABYLON.NodeMaterial",
  87550. o.outputNodes = [];
  87551. for (var c = 0, d = this._vertexOutputNodes; c < d.length; c++) {
  87552. var _ = d[c];
  87553. this._gatherBlocks(_, s),
  87554. o.outputNodes.push(_.uniqueId)
  87555. }
  87556. for (var b = 0, k = this._fragmentOutputNodes; b < k.length; b++) {
  87557. var _ = k[b];
  87558. this._gatherBlocks(_, s),
  87559. o.outputNodes.indexOf(_.uniqueId) === -1 && o.outputNodes.push(_.uniqueId)
  87560. }
  87561. }
  87562. o.blocks = [];
  87563. for (var j = 0, $ = s; j < $.length; j++) {
  87564. var _e = $[j];
  87565. o.blocks.push(_e.serialize())
  87566. }
  87567. if (!i)
  87568. for (var et = 0, tt = this.attachedBlocks; et < tt.length; et++) {
  87569. var _e = tt[et];
  87570. s.indexOf(_e) === -1 && o.blocks.push(_e.serialize())
  87571. }
  87572. return o
  87573. }
  87574. ,
  87575. e.prototype._restoreConnections = function(i, o, s) {
  87576. for (var c = 0, d = i.outputs; c < d.length; c++)
  87577. for (var _ = d[c], b = 0, k = o.blocks; b < k.length; b++) {
  87578. var j = k[b]
  87579. , $ = s[j.id];
  87580. if (!!$)
  87581. for (var _e = 0, et = j.inputs; _e < et.length; _e++) {
  87582. var tt = et[_e];
  87583. if (s[tt.targetBlockId] === i && tt.targetConnectionName === _.name) {
  87584. var rt = $.getInputByName(tt.inputName);
  87585. if (!rt || rt.isConnected)
  87586. continue;
  87587. _.connectTo(rt, !0),
  87588. this._restoreConnections($, o, s);
  87589. continue
  87590. }
  87591. }
  87592. }
  87593. }
  87594. ,
  87595. e.prototype.loadFromSerialization = function(i, o, s) {
  87596. var c;
  87597. o === void 0 && (o = ""),
  87598. s === void 0 && (s = !1),
  87599. s || this.clear();
  87600. for (var d = {}, _ = 0, b = i.blocks; _ < b.length; _++) {
  87601. var k = b[_]
  87602. , j = GetClass(k.customType);
  87603. if (j) {
  87604. var $ = new j;
  87605. $._deserialize(k, this.getScene(), o),
  87606. d[k.id] = $,
  87607. this.attachedBlocks.push($)
  87608. }
  87609. }
  87610. for (var _e = 0; _e < i.blocks.length; _e++) {
  87611. var et = i.blocks[_e]
  87612. , $ = d[et.id];
  87613. !$ || $.inputs.length && !s || this._restoreConnections($, i, d)
  87614. }
  87615. if (i.outputNodes)
  87616. for (var tt = 0, rt = i.outputNodes; tt < rt.length; tt++) {
  87617. var it = rt[tt];
  87618. this.addOutputNode(d[it])
  87619. }
  87620. if (i.locations || i.editorData && i.editorData.locations) {
  87621. for (var nt = i.locations || i.editorData.locations, ot = 0, at = nt; ot < at.length; ot++) {
  87622. var st = at[ot];
  87623. d[st.blockId] && (st.blockId = d[st.blockId].uniqueId)
  87624. }
  87625. s && this.editorData && this.editorData.locations && nt.concat(this.editorData.locations),
  87626. i.locations ? this.editorData = {
  87627. locations: nt
  87628. } : (this.editorData = i.editorData,
  87629. this.editorData.locations = nt);
  87630. var ut = [];
  87631. for (var ct in d)
  87632. ut[ct] = d[ct].uniqueId;
  87633. this.editorData.map = ut
  87634. }
  87635. this.comment = i.comment,
  87636. s || (this._mode = (c = i.mode) !== null && c !== void 0 ? c : NodeMaterialModes.Material)
  87637. }
  87638. ,
  87639. e.prototype.clone = function(i, o) {
  87640. var s = this;
  87641. o === void 0 && (o = !1);
  87642. var c = this.serialize()
  87643. , d = SerializationHelper.Clone(function() {
  87644. return new e(i,s.getScene(),s.options)
  87645. }, this);
  87646. return d.id = i,
  87647. d.name = i,
  87648. d.loadFromSerialization(c),
  87649. d._buildId = this._buildId,
  87650. d.build(!1, !o),
  87651. d
  87652. }
  87653. ,
  87654. e.Parse = function(i, o, s) {
  87655. s === void 0 && (s = "");
  87656. var c = SerializationHelper.Parse(function() {
  87657. return new e(i.name,o)
  87658. }, i, o, s);
  87659. return c.loadFromSerialization(i, s),
  87660. c.build(),
  87661. c
  87662. }
  87663. ,
  87664. e.ParseFromFileAsync = function(i, o, s) {
  87665. var c = new e(i,s);
  87666. return new Promise(function(d, _) {
  87667. return c.loadAsync(o).then(function() {
  87668. c.build(),
  87669. d(c)
  87670. }).catch(_)
  87671. }
  87672. )
  87673. }
  87674. ,
  87675. e.ParseFromSnippetAsync = function(i, o, s, c) {
  87676. var d = this;
  87677. return s === void 0 && (s = ""),
  87678. i === "_BLANK" ? Promise.resolve(this.CreateDefault("blank", o)) : new Promise(function(_, b) {
  87679. var k = new WebRequest;
  87680. k.addEventListener("readystatechange", function() {
  87681. if (k.readyState == 4)
  87682. if (k.status == 200) {
  87683. var j = JSON.parse(JSON.parse(k.responseText).jsonPayload)
  87684. , $ = JSON.parse(j.nodeMaterial);
  87685. c || (c = SerializationHelper.Parse(function() {
  87686. return new e(i,o)
  87687. }, $, o, s),
  87688. c.uniqueId = o.getUniqueId()),
  87689. c.loadFromSerialization($),
  87690. c.snippetId = i;
  87691. try {
  87692. c.build(),
  87693. _(c)
  87694. } catch (_e) {
  87695. b(_e)
  87696. }
  87697. } else
  87698. b("Unable to load the snippet " + i)
  87699. }),
  87700. k.open("GET", d.SnippetUrl + "/" + i.replace(/#/g, "/")),
  87701. k.send()
  87702. }
  87703. )
  87704. }
  87705. ,
  87706. e.CreateDefault = function(i, o) {
  87707. var s = new e(i,o);
  87708. return s.setToDefault(),
  87709. s.build(),
  87710. s
  87711. }
  87712. ,
  87713. e._BuildIdGenerator = 0,
  87714. e.EditorURL = "https://unpkg.com/babylonjs-node-editor@" + Engine.Version + "/babylon.nodeEditor.js",
  87715. e.SnippetUrl = "https://snippet.babylonjs.com",
  87716. e.IgnoreTexturesAtLoadTime = !1,
  87717. __decorate([serialize()], e.prototype, "ignoreAlpha", void 0),
  87718. __decorate([serialize()], e.prototype, "maxSimultaneousLights", void 0),
  87719. __decorate([serialize("mode")], e.prototype, "_mode", void 0),
  87720. __decorate([serialize("comment")], e.prototype, "comment", void 0),
  87721. e
  87722. }(PushMaterial);
  87723. RegisterClass("BABYLON.NodeMaterial", NodeMaterial);
  87724. var BonesBlock = function(a) {
  87725. __extends(e, a);
  87726. function e(i) {
  87727. var o = a.call(this, i, NodeMaterialBlockTargets.Vertex) || this;
  87728. return o.registerInput("matricesIndices", NodeMaterialBlockConnectionPointTypes.Vector4),
  87729. o.registerInput("matricesWeights", NodeMaterialBlockConnectionPointTypes.Vector4),
  87730. o.registerInput("matricesIndicesExtra", NodeMaterialBlockConnectionPointTypes.Vector4, !0),
  87731. o.registerInput("matricesWeightsExtra", NodeMaterialBlockConnectionPointTypes.Vector4, !0),
  87732. o.registerInput("world", NodeMaterialBlockConnectionPointTypes.Matrix),
  87733. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Matrix),
  87734. o
  87735. }
  87736. return e.prototype.initialize = function(i) {
  87737. i._excludeVariableName("boneSampler"),
  87738. i._excludeVariableName("boneTextureWidth"),
  87739. i._excludeVariableName("mBones"),
  87740. i._excludeVariableName("BonesPerMesh")
  87741. }
  87742. ,
  87743. e.prototype.getClassName = function() {
  87744. return "BonesBlock"
  87745. }
  87746. ,
  87747. Object.defineProperty(e.prototype, "matricesIndices", {
  87748. get: function() {
  87749. return this._inputs[0]
  87750. },
  87751. enumerable: !1,
  87752. configurable: !0
  87753. }),
  87754. Object.defineProperty(e.prototype, "matricesWeights", {
  87755. get: function() {
  87756. return this._inputs[1]
  87757. },
  87758. enumerable: !1,
  87759. configurable: !0
  87760. }),
  87761. Object.defineProperty(e.prototype, "matricesIndicesExtra", {
  87762. get: function() {
  87763. return this._inputs[2]
  87764. },
  87765. enumerable: !1,
  87766. configurable: !0
  87767. }),
  87768. Object.defineProperty(e.prototype, "matricesWeightsExtra", {
  87769. get: function() {
  87770. return this._inputs[3]
  87771. },
  87772. enumerable: !1,
  87773. configurable: !0
  87774. }),
  87775. Object.defineProperty(e.prototype, "world", {
  87776. get: function() {
  87777. return this._inputs[4]
  87778. },
  87779. enumerable: !1,
  87780. configurable: !0
  87781. }),
  87782. Object.defineProperty(e.prototype, "output", {
  87783. get: function() {
  87784. return this._outputs[0]
  87785. },
  87786. enumerable: !1,
  87787. configurable: !0
  87788. }),
  87789. e.prototype.autoConfigure = function(i) {
  87790. if (!this.matricesIndices.isConnected) {
  87791. var o = i.getInputBlockByPredicate(function(d) {
  87792. return d.isAttribute && d.name === "matricesIndices"
  87793. });
  87794. o || (o = new InputBlock("matricesIndices"),
  87795. o.setAsAttribute("matricesIndices")),
  87796. o.output.connectTo(this.matricesIndices)
  87797. }
  87798. if (!this.matricesWeights.isConnected) {
  87799. var s = i.getInputBlockByPredicate(function(d) {
  87800. return d.isAttribute && d.name === "matricesWeights"
  87801. });
  87802. s || (s = new InputBlock("matricesWeights"),
  87803. s.setAsAttribute("matricesWeights")),
  87804. s.output.connectTo(this.matricesWeights)
  87805. }
  87806. if (!this.world.isConnected) {
  87807. var c = i.getInputBlockByPredicate(function(d) {
  87808. return d.systemValue === NodeMaterialSystemValues.World
  87809. });
  87810. c || (c = new InputBlock("world"),
  87811. c.setAsSystemValue(NodeMaterialSystemValues.World)),
  87812. c.output.connectTo(this.world)
  87813. }
  87814. }
  87815. ,
  87816. e.prototype.provideFallbacks = function(i, o) {
  87817. i && i.useBones && i.computeBonesUsingShaders && i.skeleton && o.addCPUSkinningFallback(0, i)
  87818. }
  87819. ,
  87820. e.prototype.bind = function(i, o, s) {
  87821. MaterialHelper.BindBonesParameters(s, i)
  87822. }
  87823. ,
  87824. e.prototype.prepareDefines = function(i, o, s) {
  87825. !s._areAttributesDirty || MaterialHelper.PrepareDefinesForBones(i, s)
  87826. }
  87827. ,
  87828. e.prototype._buildBlock = function(i) {
  87829. a.prototype._buildBlock.call(this, i),
  87830. i.sharedData.blocksWithFallbacks.push(this),
  87831. i.sharedData.bindableBlocks.push(this),
  87832. i.sharedData.blocksWithDefines.push(this),
  87833. i.uniforms.push("boneTextureWidth"),
  87834. i.uniforms.push("mBones"),
  87835. i.samplers.push("boneSampler");
  87836. var o = "//" + this.name;
  87837. i._emitFunctionFromInclude("bonesDeclaration", o, {
  87838. removeAttributes: !0,
  87839. removeUniforms: !1,
  87840. removeVaryings: !0,
  87841. removeIfDef: !1
  87842. });
  87843. var s = i._getFreeVariableName("influence");
  87844. i.compilationString += i._emitCodeFromInclude("bonesVertex", o, {
  87845. replaceStrings: [{
  87846. search: /finalWorld=finalWorld\*influence;/,
  87847. replace: ""
  87848. }, {
  87849. search: /influence/gm,
  87850. replace: s
  87851. }]
  87852. });
  87853. var c = this._outputs[0]
  87854. , d = this.world;
  87855. return i.compilationString += `#if NUM_BONE_INFLUENCERS>0\r
  87856. `,
  87857. i.compilationString += this._declareOutput(c, i) + (" = " + d.associatedVariableName + " * " + s + `;\r
  87858. `),
  87859. i.compilationString += `#else\r
  87860. `,
  87861. i.compilationString += this._declareOutput(c, i) + (" = " + d.associatedVariableName + `;\r
  87862. `),
  87863. i.compilationString += `#endif\r
  87864. `,
  87865. this
  87866. }
  87867. ,
  87868. e
  87869. }(NodeMaterialBlock);
  87870. RegisterClass("BABYLON.BonesBlock", BonesBlock);
  87871. var InstancesBlock = function(a) {
  87872. __extends(e, a);
  87873. function e(i) {
  87874. var o = a.call(this, i, NodeMaterialBlockTargets.Vertex) || this;
  87875. return o.registerInput("world0", NodeMaterialBlockConnectionPointTypes.Vector4),
  87876. o.registerInput("world1", NodeMaterialBlockConnectionPointTypes.Vector4),
  87877. o.registerInput("world2", NodeMaterialBlockConnectionPointTypes.Vector4),
  87878. o.registerInput("world3", NodeMaterialBlockConnectionPointTypes.Vector4),
  87879. o.registerInput("world", NodeMaterialBlockConnectionPointTypes.Matrix, !0),
  87880. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Matrix),
  87881. o.registerOutput("instanceID", NodeMaterialBlockConnectionPointTypes.Float),
  87882. o
  87883. }
  87884. return e.prototype.getClassName = function() {
  87885. return "InstancesBlock"
  87886. }
  87887. ,
  87888. Object.defineProperty(e.prototype, "world0", {
  87889. get: function() {
  87890. return this._inputs[0]
  87891. },
  87892. enumerable: !1,
  87893. configurable: !0
  87894. }),
  87895. Object.defineProperty(e.prototype, "world1", {
  87896. get: function() {
  87897. return this._inputs[1]
  87898. },
  87899. enumerable: !1,
  87900. configurable: !0
  87901. }),
  87902. Object.defineProperty(e.prototype, "world2", {
  87903. get: function() {
  87904. return this._inputs[2]
  87905. },
  87906. enumerable: !1,
  87907. configurable: !0
  87908. }),
  87909. Object.defineProperty(e.prototype, "world3", {
  87910. get: function() {
  87911. return this._inputs[3]
  87912. },
  87913. enumerable: !1,
  87914. configurable: !0
  87915. }),
  87916. Object.defineProperty(e.prototype, "world", {
  87917. get: function() {
  87918. return this._inputs[4]
  87919. },
  87920. enumerable: !1,
  87921. configurable: !0
  87922. }),
  87923. Object.defineProperty(e.prototype, "output", {
  87924. get: function() {
  87925. return this._outputs[0]
  87926. },
  87927. enumerable: !1,
  87928. configurable: !0
  87929. }),
  87930. Object.defineProperty(e.prototype, "instanceID", {
  87931. get: function() {
  87932. return this._outputs[1]
  87933. },
  87934. enumerable: !1,
  87935. configurable: !0
  87936. }),
  87937. e.prototype.autoConfigure = function(i) {
  87938. if (!this.world0.connectedPoint) {
  87939. var o = i.getInputBlockByPredicate(function(b) {
  87940. return b.isAttribute && b.name === "world0"
  87941. });
  87942. o || (o = new InputBlock("world0"),
  87943. o.setAsAttribute("world0")),
  87944. o.output.connectTo(this.world0)
  87945. }
  87946. if (!this.world1.connectedPoint) {
  87947. var s = i.getInputBlockByPredicate(function(b) {
  87948. return b.isAttribute && b.name === "world1"
  87949. });
  87950. s || (s = new InputBlock("world1"),
  87951. s.setAsAttribute("world1")),
  87952. s.output.connectTo(this.world1)
  87953. }
  87954. if (!this.world2.connectedPoint) {
  87955. var c = i.getInputBlockByPredicate(function(b) {
  87956. return b.isAttribute && b.name === "world2"
  87957. });
  87958. c || (c = new InputBlock("world2"),
  87959. c.setAsAttribute("world2")),
  87960. c.output.connectTo(this.world2)
  87961. }
  87962. if (!this.world3.connectedPoint) {
  87963. var d = i.getInputBlockByPredicate(function(b) {
  87964. return b.isAttribute && b.name === "world3"
  87965. });
  87966. d || (d = new InputBlock("world3"),
  87967. d.setAsAttribute("world3")),
  87968. d.output.connectTo(this.world3)
  87969. }
  87970. if (!this.world.connectedPoint) {
  87971. var _ = i.getInputBlockByPredicate(function(b) {
  87972. return b.isAttribute && b.name === "world"
  87973. });
  87974. _ || (_ = new InputBlock("world"),
  87975. _.setAsSystemValue(NodeMaterialSystemValues.World)),
  87976. _.output.connectTo(this.world)
  87977. }
  87978. this.world.define = "!INSTANCES || THIN_INSTANCES"
  87979. }
  87980. ,
  87981. e.prototype.prepareDefines = function(i, o, s, c, d) {
  87982. c === void 0 && (c = !1);
  87983. var _ = !1;
  87984. s.INSTANCES !== c && (s.setValue("INSTANCES", c),
  87985. _ = !0),
  87986. d && s.THIN_INSTANCES !== !!(d != null && d.getRenderingMesh().hasThinInstances) && (s.setValue("THIN_INSTANCES", !!(d != null && d.getRenderingMesh().hasThinInstances)),
  87987. _ = !0),
  87988. _ && s.markAsUnprocessed()
  87989. }
  87990. ,
  87991. e.prototype._buildBlock = function(i) {
  87992. a.prototype._buildBlock.call(this, i);
  87993. var o = i.sharedData.scene.getEngine();
  87994. i.sharedData.blocksWithDefines.push(this);
  87995. var s = this._outputs[0]
  87996. , c = this._outputs[1]
  87997. , d = this.world0
  87998. , _ = this.world1
  87999. , b = this.world2
  88000. , k = this.world3;
  88001. return i.compilationString += `#ifdef INSTANCES\r
  88002. `,
  88003. i.compilationString += this._declareOutput(s, i) + (" = mat4(" + d.associatedVariableName + ", " + _.associatedVariableName + ", " + b.associatedVariableName + ", " + k.associatedVariableName + `);\r
  88004. `),
  88005. i.compilationString += `#ifdef THIN_INSTANCES\r
  88006. `,
  88007. i.compilationString += s.associatedVariableName + " = " + this.world.associatedVariableName + " * " + s.associatedVariableName + `;\r
  88008. `,
  88009. i.compilationString += `#endif\r
  88010. `,
  88011. o._caps.canUseGLInstanceID ? i.compilationString += this._declareOutput(c, i) + ` = float(gl_InstanceID);\r
  88012. ` : i.compilationString += this._declareOutput(c, i) + ` = 0.0;\r
  88013. `,
  88014. i.compilationString += `#else\r
  88015. `,
  88016. i.compilationString += this._declareOutput(s, i) + (" = " + this.world.associatedVariableName + `;\r
  88017. `),
  88018. i.compilationString += this._declareOutput(c, i) + ` = 0.0;\r
  88019. `,
  88020. i.compilationString += `#endif\r
  88021. `,
  88022. this
  88023. }
  88024. ,
  88025. e
  88026. }(NodeMaterialBlock);
  88027. RegisterClass("BABYLON.InstancesBlock", InstancesBlock);
  88028. var MorphTargetsBlock = function(a) {
  88029. __extends(e, a);
  88030. function e(i) {
  88031. var o = a.call(this, i, NodeMaterialBlockTargets.Vertex) || this;
  88032. return o.registerInput("position", NodeMaterialBlockConnectionPointTypes.Vector3),
  88033. o.registerInput("normal", NodeMaterialBlockConnectionPointTypes.Vector3),
  88034. o.registerInput("tangent", NodeMaterialBlockConnectionPointTypes.Vector3),
  88035. o.registerInput("uv", NodeMaterialBlockConnectionPointTypes.Vector2),
  88036. o.registerOutput("positionOutput", NodeMaterialBlockConnectionPointTypes.Vector3),
  88037. o.registerOutput("normalOutput", NodeMaterialBlockConnectionPointTypes.Vector3),
  88038. o.registerOutput("tangentOutput", NodeMaterialBlockConnectionPointTypes.Vector3),
  88039. o.registerOutput("uvOutput", NodeMaterialBlockConnectionPointTypes.Vector2),
  88040. o
  88041. }
  88042. return e.prototype.getClassName = function() {
  88043. return "MorphTargetsBlock"
  88044. }
  88045. ,
  88046. Object.defineProperty(e.prototype, "position", {
  88047. get: function() {
  88048. return this._inputs[0]
  88049. },
  88050. enumerable: !1,
  88051. configurable: !0
  88052. }),
  88053. Object.defineProperty(e.prototype, "normal", {
  88054. get: function() {
  88055. return this._inputs[1]
  88056. },
  88057. enumerable: !1,
  88058. configurable: !0
  88059. }),
  88060. Object.defineProperty(e.prototype, "tangent", {
  88061. get: function() {
  88062. return this._inputs[2]
  88063. },
  88064. enumerable: !1,
  88065. configurable: !0
  88066. }),
  88067. Object.defineProperty(e.prototype, "uv", {
  88068. get: function() {
  88069. return this._inputs[3]
  88070. },
  88071. enumerable: !1,
  88072. configurable: !0
  88073. }),
  88074. Object.defineProperty(e.prototype, "positionOutput", {
  88075. get: function() {
  88076. return this._outputs[0]
  88077. },
  88078. enumerable: !1,
  88079. configurable: !0
  88080. }),
  88081. Object.defineProperty(e.prototype, "normalOutput", {
  88082. get: function() {
  88083. return this._outputs[1]
  88084. },
  88085. enumerable: !1,
  88086. configurable: !0
  88087. }),
  88088. Object.defineProperty(e.prototype, "tangentOutput", {
  88089. get: function() {
  88090. return this._outputs[2]
  88091. },
  88092. enumerable: !1,
  88093. configurable: !0
  88094. }),
  88095. Object.defineProperty(e.prototype, "uvOutput", {
  88096. get: function() {
  88097. return this._outputs[3]
  88098. },
  88099. enumerable: !1,
  88100. configurable: !0
  88101. }),
  88102. e.prototype.initialize = function(i) {
  88103. i._excludeVariableName("morphTargetInfluences")
  88104. }
  88105. ,
  88106. e.prototype.autoConfigure = function(i) {
  88107. if (!this.position.isConnected) {
  88108. var o = i.getInputBlockByPredicate(function(_) {
  88109. return _.isAttribute && _.name === "position"
  88110. });
  88111. o || (o = new InputBlock("position"),
  88112. o.setAsAttribute()),
  88113. o.output.connectTo(this.position)
  88114. }
  88115. if (!this.normal.isConnected) {
  88116. var s = i.getInputBlockByPredicate(function(_) {
  88117. return _.isAttribute && _.name === "normal"
  88118. });
  88119. s || (s = new InputBlock("normal"),
  88120. s.setAsAttribute("normal")),
  88121. s.output.connectTo(this.normal)
  88122. }
  88123. if (!this.tangent.isConnected) {
  88124. var c = i.getInputBlockByPredicate(function(_) {
  88125. return _.isAttribute && _.name === "tangent"
  88126. });
  88127. c || (c = new InputBlock("tangent"),
  88128. c.setAsAttribute("tangent")),
  88129. c.output.connectTo(this.tangent)
  88130. }
  88131. if (!this.uv.isConnected) {
  88132. var d = i.getInputBlockByPredicate(function(_) {
  88133. return _.isAttribute && _.name === "uv"
  88134. });
  88135. d || (d = new InputBlock("uv"),
  88136. d.setAsAttribute("uv")),
  88137. d.output.connectTo(this.uv)
  88138. }
  88139. }
  88140. ,
  88141. e.prototype.prepareDefines = function(i, o, s) {
  88142. if (i.morphTargetManager) {
  88143. var c = i.morphTargetManager;
  88144. (c == null ? void 0 : c.isUsingTextureForTargets) && c.numInfluencers !== s.NUM_MORPH_INFLUENCERS && s.markAsAttributesDirty()
  88145. }
  88146. !s._areAttributesDirty || MaterialHelper.PrepareDefinesForMorphTargets(i, s)
  88147. }
  88148. ,
  88149. e.prototype.bind = function(i, o, s) {
  88150. s && s.morphTargetManager && s.morphTargetManager.numInfluencers > 0 && (MaterialHelper.BindMorphTargetParameters(s, i),
  88151. s.morphTargetManager.isUsingTextureForTargets && s.morphTargetManager._bind(i))
  88152. }
  88153. ,
  88154. e.prototype.replaceRepeatableContent = function(i, o, s, c) {
  88155. var d = this.position
  88156. , _ = this.normal
  88157. , b = this.tangent
  88158. , k = this.uv
  88159. , j = this.positionOutput
  88160. , $ = this.normalOutput
  88161. , _e = this.tangentOutput
  88162. , et = this.uvOutput
  88163. , tt = i
  88164. , rt = c.NUM_MORPH_INFLUENCERS
  88165. , it = s.morphTargetManager
  88166. , nt = it && it.supportsNormals && c.NORMAL
  88167. , ot = it && it.supportsTangents && c.TANGENT
  88168. , at = it && it.supportsUVs && c.UV1
  88169. , st = "";
  88170. (it == null ? void 0 : it.isUsingTextureForTargets) && rt > 0 && (st += `float vertexID;\r
  88171. `);
  88172. for (var ut = 0; ut < rt; ut++)
  88173. st += `#ifdef MORPHTARGETS\r
  88174. `,
  88175. it != null && it.isUsingTextureForTargets ? (st += `vertexID = float(gl_VertexID) * morphTargetTextureInfo.x;\r
  88176. `,
  88177. st += j.associatedVariableName + " += (readVector3FromRawSampler(" + ut + ", vertexID) - " + d.associatedVariableName + ") * morphTargetInfluences[" + ut + `];\r
  88178. `,
  88179. st += `vertexID += 1.0;\r
  88180. `) : st += j.associatedVariableName + " += (position" + ut + " - " + d.associatedVariableName + ") * morphTargetInfluences[" + ut + `];\r
  88181. `,
  88182. nt && (st += `#ifdef MORPHTARGETS_NORMAL\r
  88183. `,
  88184. it != null && it.isUsingTextureForTargets ? (st += $.associatedVariableName + " += (readVector3FromRawSampler(" + ut + ", vertexID) - " + _.associatedVariableName + ") * morphTargetInfluences[" + ut + `];\r
  88185. `,
  88186. st += `vertexID += 1.0;\r
  88187. `) : st += $.associatedVariableName + " += (normal" + ut + " - " + _.associatedVariableName + ") * morphTargetInfluences[" + ut + `];\r
  88188. `,
  88189. st += `#endif\r
  88190. `),
  88191. at && (st += `#ifdef MORPHTARGETS_UV\r
  88192. `,
  88193. it != null && it.isUsingTextureForTargets ? (st += et.associatedVariableName + " += (readVector3FromRawSampler(" + ut + ", vertexID).xy - " + k.associatedVariableName + ") * morphTargetInfluences[" + ut + `];\r
  88194. `,
  88195. st += `vertexID += 1.0;\r
  88196. `) : st += et.associatedVariableName + ".xy += (uv_" + ut + " - " + k.associatedVariableName + ".xy) * morphTargetInfluences[" + ut + `];\r
  88197. `,
  88198. st += `#endif\r
  88199. `),
  88200. ot && (st += `#ifdef MORPHTARGETS_TANGENT\r
  88201. `,
  88202. it != null && it.isUsingTextureForTargets ? st += _e.associatedVariableName + " += (readVector3FromRawSampler(" + ut + ", vertexID) - " + b.associatedVariableName + ") * morphTargetInfluences[" + ut + `];\r
  88203. ` : st += _e.associatedVariableName + ".xyz += (tangent" + ut + " - " + b.associatedVariableName + ".xyz) * morphTargetInfluences[" + ut + `];\r
  88204. `,
  88205. st += `#endif\r
  88206. `),
  88207. st += `#endif\r
  88208. `;
  88209. if (tt.compilationString = tt.compilationString.replace(this._repeatableContentAnchor, st),
  88210. rt > 0)
  88211. for (var ut = 0; ut < rt; ut++)
  88212. tt.attributes.push(VertexBuffer.PositionKind + ut),
  88213. nt && tt.attributes.push(VertexBuffer.NormalKind + ut),
  88214. ot && tt.attributes.push(VertexBuffer.TangentKind + ut),
  88215. at && tt.attributes.push(VertexBuffer.UVKind + "_" + ut)
  88216. }
  88217. ,
  88218. e.prototype._buildBlock = function(i) {
  88219. a.prototype._buildBlock.call(this, i),
  88220. i.sharedData.blocksWithDefines.push(this),
  88221. i.sharedData.bindableBlocks.push(this),
  88222. i.sharedData.repeatableContentBlocks.push(this);
  88223. var o = this.position
  88224. , s = this.normal
  88225. , c = this.tangent
  88226. , d = this.uv
  88227. , _ = this.positionOutput
  88228. , b = this.normalOutput
  88229. , k = this.tangentOutput
  88230. , j = this.uvOutput
  88231. , $ = "//" + this.name;
  88232. return i.uniforms.push("morphTargetInfluences"),
  88233. i.uniforms.push("morphTargetTextureInfo"),
  88234. i.uniforms.push("morphTargetTextureIndices"),
  88235. i.samplers.push("morphTargets"),
  88236. i._emitFunctionFromInclude("morphTargetsVertexGlobalDeclaration", $),
  88237. i._emitFunctionFromInclude("morphTargetsVertexDeclaration", $, {
  88238. repeatKey: "maxSimultaneousMorphTargets"
  88239. }),
  88240. i.compilationString += this._declareOutput(_, i) + " = " + o.associatedVariableName + `;\r
  88241. `,
  88242. i.compilationString += `#ifdef NORMAL\r
  88243. `,
  88244. i.compilationString += this._declareOutput(b, i) + " = " + s.associatedVariableName + `;\r
  88245. `,
  88246. i.compilationString += `#else\r
  88247. `,
  88248. i.compilationString += this._declareOutput(b, i) + ` = vec3(0., 0., 0.);\r
  88249. `,
  88250. i.compilationString += `#endif\r
  88251. `,
  88252. i.compilationString += `#ifdef TANGENT\r
  88253. `,
  88254. i.compilationString += this._declareOutput(k, i) + " = " + c.associatedVariableName + `;\r
  88255. `,
  88256. i.compilationString += `#else\r
  88257. `,
  88258. i.compilationString += this._declareOutput(k, i) + ` = vec3(0., 0., 0.);\r
  88259. `,
  88260. i.compilationString += `#endif\r
  88261. `,
  88262. i.compilationString += `#ifdef UV1\r
  88263. `,
  88264. i.compilationString += this._declareOutput(j, i) + " = " + d.associatedVariableName + `;\r
  88265. `,
  88266. i.compilationString += `#else\r
  88267. `,
  88268. i.compilationString += this._declareOutput(j, i) + ` = vec2(0., 0.);\r
  88269. `,
  88270. i.compilationString += `#endif\r
  88271. `,
  88272. this._repeatableContentAnchor = i._repeatableContentAnchor,
  88273. i.compilationString += this._repeatableContentAnchor,
  88274. this
  88275. }
  88276. ,
  88277. e
  88278. }(NodeMaterialBlock);
  88279. RegisterClass("BABYLON.MorphTargetsBlock", MorphTargetsBlock);
  88280. var LightInformationBlock = function(a) {
  88281. __extends(e, a);
  88282. function e(i) {
  88283. var o = a.call(this, i, NodeMaterialBlockTargets.Vertex) || this;
  88284. return o.registerInput("worldPosition", NodeMaterialBlockConnectionPointTypes.Vector4, !1, NodeMaterialBlockTargets.Vertex),
  88285. o.registerOutput("direction", NodeMaterialBlockConnectionPointTypes.Vector3),
  88286. o.registerOutput("color", NodeMaterialBlockConnectionPointTypes.Color3),
  88287. o.registerOutput("intensity", NodeMaterialBlockConnectionPointTypes.Float),
  88288. o
  88289. }
  88290. return e.prototype.getClassName = function() {
  88291. return "LightInformationBlock"
  88292. }
  88293. ,
  88294. Object.defineProperty(e.prototype, "worldPosition", {
  88295. get: function() {
  88296. return this._inputs[0]
  88297. },
  88298. enumerable: !1,
  88299. configurable: !0
  88300. }),
  88301. Object.defineProperty(e.prototype, "direction", {
  88302. get: function() {
  88303. return this._outputs[0]
  88304. },
  88305. enumerable: !1,
  88306. configurable: !0
  88307. }),
  88308. Object.defineProperty(e.prototype, "color", {
  88309. get: function() {
  88310. return this._outputs[1]
  88311. },
  88312. enumerable: !1,
  88313. configurable: !0
  88314. }),
  88315. Object.defineProperty(e.prototype, "intensity", {
  88316. get: function() {
  88317. return this._outputs[2]
  88318. },
  88319. enumerable: !1,
  88320. configurable: !0
  88321. }),
  88322. e.prototype.bind = function(i, o, s) {
  88323. if (!!s) {
  88324. this.light && this.light.isDisposed && (this.light = null);
  88325. var c = this.light
  88326. , d = o.getScene();
  88327. if (!c && d.lights.length && (c = this.light = d.lights[0],
  88328. this._forcePrepareDefines = !0),
  88329. !c || !c.isEnabled) {
  88330. i.setFloat3(this._lightDataUniformName, 0, 0, 0),
  88331. i.setFloat4(this._lightColorUniformName, 0, 0, 0, 0);
  88332. return
  88333. }
  88334. c.transferToNodeMaterialEffect(i, this._lightDataUniformName),
  88335. i.setColor4(this._lightColorUniformName, c.diffuse, c.intensity)
  88336. }
  88337. }
  88338. ,
  88339. e.prototype.prepareDefines = function(i, o, s) {
  88340. if (!(!s._areLightsDirty && !this._forcePrepareDefines)) {
  88341. this._forcePrepareDefines = !1;
  88342. var c = this.light;
  88343. s.setValue(this._lightTypeDefineName, !!(c && c instanceof PointLight), !0)
  88344. }
  88345. }
  88346. ,
  88347. e.prototype._buildBlock = function(i) {
  88348. a.prototype._buildBlock.call(this, i),
  88349. i.sharedData.bindableBlocks.push(this),
  88350. i.sharedData.blocksWithDefines.push(this);
  88351. var o = this.direction
  88352. , s = this.color
  88353. , c = this.intensity;
  88354. return this._lightDataUniformName = i._getFreeVariableName("lightData"),
  88355. this._lightColorUniformName = i._getFreeVariableName("lightColor"),
  88356. this._lightTypeDefineName = i._getFreeDefineName("LIGHTPOINTTYPE"),
  88357. i._emitUniformFromString(this._lightDataUniformName, "vec3"),
  88358. i._emitUniformFromString(this._lightColorUniformName, "vec4"),
  88359. i.compilationString += "#ifdef " + this._lightTypeDefineName + `\r
  88360. `,
  88361. i.compilationString += this._declareOutput(o, i) + (" = normalize(" + this.worldPosition.associatedVariableName + ".xyz - " + this._lightDataUniformName + `);\r
  88362. `),
  88363. i.compilationString += `#else\r
  88364. `,
  88365. i.compilationString += this._declareOutput(o, i) + (" = " + this._lightDataUniformName + `;\r
  88366. `),
  88367. i.compilationString += `#endif\r
  88368. `,
  88369. i.compilationString += this._declareOutput(s, i) + (" = " + this._lightColorUniformName + `.rgb;\r
  88370. `),
  88371. i.compilationString += this._declareOutput(c, i) + (" = " + this._lightColorUniformName + `.a;\r
  88372. `),
  88373. this
  88374. }
  88375. ,
  88376. e.prototype.serialize = function() {
  88377. var i = a.prototype.serialize.call(this);
  88378. return this.light && (i.lightId = this.light.id),
  88379. i
  88380. }
  88381. ,
  88382. e.prototype._deserialize = function(i, o, s) {
  88383. a.prototype._deserialize.call(this, i, o, s),
  88384. i.lightId && (this.light = o.getLightById(i.lightId))
  88385. }
  88386. ,
  88387. e
  88388. }(NodeMaterialBlock);
  88389. RegisterClass("BABYLON.LightInformationBlock", LightInformationBlock);
  88390. var ImageProcessingBlock = function(a) {
  88391. __extends(e, a);
  88392. function e(i) {
  88393. var o = a.call(this, i, NodeMaterialBlockTargets.Fragment) || this;
  88394. return o.convertInputToLinearSpace = !0,
  88395. o.registerInput("color", NodeMaterialBlockConnectionPointTypes.Color4),
  88396. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Color4),
  88397. o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color3),
  88398. o
  88399. }
  88400. return e.prototype.getClassName = function() {
  88401. return "ImageProcessingBlock"
  88402. }
  88403. ,
  88404. Object.defineProperty(e.prototype, "color", {
  88405. get: function() {
  88406. return this._inputs[0]
  88407. },
  88408. enumerable: !1,
  88409. configurable: !0
  88410. }),
  88411. Object.defineProperty(e.prototype, "output", {
  88412. get: function() {
  88413. return this._outputs[0]
  88414. },
  88415. enumerable: !1,
  88416. configurable: !0
  88417. }),
  88418. e.prototype.initialize = function(i) {
  88419. i._excludeVariableName("exposureLinear"),
  88420. i._excludeVariableName("contrast"),
  88421. i._excludeVariableName("vInverseScreenSize"),
  88422. i._excludeVariableName("vignetteSettings1"),
  88423. i._excludeVariableName("vignetteSettings2"),
  88424. i._excludeVariableName("vCameraColorCurveNegative"),
  88425. i._excludeVariableName("vCameraColorCurveNeutral"),
  88426. i._excludeVariableName("vCameraColorCurvePositive"),
  88427. i._excludeVariableName("txColorTransform"),
  88428. i._excludeVariableName("colorTransformSettings")
  88429. }
  88430. ,
  88431. e.prototype.isReady = function(i, o, s) {
  88432. return !(s._areImageProcessingDirty && o.imageProcessingConfiguration && !o.imageProcessingConfiguration.isReady())
  88433. }
  88434. ,
  88435. e.prototype.prepareDefines = function(i, o, s) {
  88436. s._areImageProcessingDirty && o.imageProcessingConfiguration && o.imageProcessingConfiguration.prepareDefines(s)
  88437. }
  88438. ,
  88439. e.prototype.bind = function(i, o, s) {
  88440. !s || !o.imageProcessingConfiguration || o.imageProcessingConfiguration.bind(i)
  88441. }
  88442. ,
  88443. e.prototype._buildBlock = function(i) {
  88444. a.prototype._buildBlock.call(this, i),
  88445. i.sharedData.blocksWithDefines.push(this),
  88446. i.sharedData.blockingBlocks.push(this),
  88447. i.sharedData.bindableBlocks.push(this),
  88448. i.uniforms.push("exposureLinear"),
  88449. i.uniforms.push("contrast"),
  88450. i.uniforms.push("vInverseScreenSize"),
  88451. i.uniforms.push("vignetteSettings1"),
  88452. i.uniforms.push("vignetteSettings2"),
  88453. i.uniforms.push("vCameraColorCurveNegative"),
  88454. i.uniforms.push("vCameraColorCurveNeutral"),
  88455. i.uniforms.push("vCameraColorCurvePositive"),
  88456. i.uniforms.push("txColorTransform"),
  88457. i.uniforms.push("colorTransformSettings");
  88458. var o = this.color
  88459. , s = this._outputs[0]
  88460. , c = "//" + this.name;
  88461. return i._emitFunctionFromInclude("helperFunctions", c),
  88462. i._emitFunctionFromInclude("imageProcessingDeclaration", c),
  88463. i._emitFunctionFromInclude("imageProcessingFunctions", c),
  88464. o.connectedPoint.type === NodeMaterialBlockConnectionPointTypes.Color4 || o.connectedPoint.type === NodeMaterialBlockConnectionPointTypes.Vector4 ? i.compilationString += this._declareOutput(s, i) + " = " + o.associatedVariableName + `;\r
  88465. ` : i.compilationString += this._declareOutput(s, i) + " = vec4(" + o.associatedVariableName + `, 1.0);\r
  88466. `,
  88467. i.compilationString += `#ifdef IMAGEPROCESSINGPOSTPROCESS\r
  88468. `,
  88469. this.convertInputToLinearSpace && (i.compilationString += s.associatedVariableName + ".rgb = toLinearSpace(" + o.associatedVariableName + `.rgb);\r
  88470. `),
  88471. i.compilationString += `#else\r
  88472. `,
  88473. i.compilationString += `#ifdef IMAGEPROCESSING\r
  88474. `,
  88475. this.convertInputToLinearSpace && (i.compilationString += s.associatedVariableName + ".rgb = toLinearSpace(" + o.associatedVariableName + `.rgb);\r
  88476. `),
  88477. i.compilationString += s.associatedVariableName + " = applyImageProcessing(" + s.associatedVariableName + `);\r
  88478. `,
  88479. i.compilationString += `#endif\r
  88480. `,
  88481. i.compilationString += `#endif\r
  88482. `,
  88483. this
  88484. }
  88485. ,
  88486. e.prototype._dumpPropertiesCode = function() {
  88487. var i = a.prototype._dumpPropertiesCode.call(this);
  88488. return i += this._codeVariableName + ".convertInputToLinearSpace = " + this.convertInputToLinearSpace + `;\r
  88489. `,
  88490. i
  88491. }
  88492. ,
  88493. e.prototype.serialize = function() {
  88494. var i = a.prototype.serialize.call(this);
  88495. return i.convertInputToLinearSpace = this.convertInputToLinearSpace,
  88496. i
  88497. }
  88498. ,
  88499. e.prototype._deserialize = function(i, o, s) {
  88500. var c;
  88501. a.prototype._deserialize.call(this, i, o, s),
  88502. this.convertInputToLinearSpace = (c = i.convertInputToLinearSpace) !== null && c !== void 0 ? c : !0
  88503. }
  88504. ,
  88505. __decorate([editableInPropertyPage("Convert input to linear space", PropertyTypeForEdition.Boolean, "ADVANCED")], e.prototype, "convertInputToLinearSpace", void 0),
  88506. e
  88507. }(NodeMaterialBlock);
  88508. RegisterClass("BABYLON.ImageProcessingBlock", ImageProcessingBlock);
  88509. var PerturbNormalBlock = function(a) {
  88510. __extends(e, a);
  88511. function e(i) {
  88512. var o = a.call(this, i, NodeMaterialBlockTargets.Fragment) || this;
  88513. return o._tangentSpaceParameterName = "",
  88514. o.invertX = !1,
  88515. o.invertY = !1,
  88516. o.useParallaxOcclusion = !1,
  88517. o._isUnique = !0,
  88518. o.registerInput("worldPosition", NodeMaterialBlockConnectionPointTypes.Vector4, !1),
  88519. o.registerInput("worldNormal", NodeMaterialBlockConnectionPointTypes.Vector4, !1),
  88520. o.registerInput("worldTangent", NodeMaterialBlockConnectionPointTypes.Vector4, !0),
  88521. o.registerInput("uv", NodeMaterialBlockConnectionPointTypes.Vector2, !1),
  88522. o.registerInput("normalMapColor", NodeMaterialBlockConnectionPointTypes.Color3, !1),
  88523. o.registerInput("strength", NodeMaterialBlockConnectionPointTypes.Float, !1),
  88524. o.registerInput("viewDirection", NodeMaterialBlockConnectionPointTypes.Vector3, !0),
  88525. o.registerInput("parallaxScale", NodeMaterialBlockConnectionPointTypes.Float, !0),
  88526. o.registerInput("parallaxHeight", NodeMaterialBlockConnectionPointTypes.Float, !0),
  88527. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Vector4),
  88528. o.registerOutput("uvOffset", NodeMaterialBlockConnectionPointTypes.Vector2),
  88529. o
  88530. }
  88531. return e.prototype.getClassName = function() {
  88532. return "PerturbNormalBlock"
  88533. }
  88534. ,
  88535. Object.defineProperty(e.prototype, "worldPosition", {
  88536. get: function() {
  88537. return this._inputs[0]
  88538. },
  88539. enumerable: !1,
  88540. configurable: !0
  88541. }),
  88542. Object.defineProperty(e.prototype, "worldNormal", {
  88543. get: function() {
  88544. return this._inputs[1]
  88545. },
  88546. enumerable: !1,
  88547. configurable: !0
  88548. }),
  88549. Object.defineProperty(e.prototype, "worldTangent", {
  88550. get: function() {
  88551. return this._inputs[2]
  88552. },
  88553. enumerable: !1,
  88554. configurable: !0
  88555. }),
  88556. Object.defineProperty(e.prototype, "uv", {
  88557. get: function() {
  88558. return this._inputs[3]
  88559. },
  88560. enumerable: !1,
  88561. configurable: !0
  88562. }),
  88563. Object.defineProperty(e.prototype, "normalMapColor", {
  88564. get: function() {
  88565. return this._inputs[4]
  88566. },
  88567. enumerable: !1,
  88568. configurable: !0
  88569. }),
  88570. Object.defineProperty(e.prototype, "strength", {
  88571. get: function() {
  88572. return this._inputs[5]
  88573. },
  88574. enumerable: !1,
  88575. configurable: !0
  88576. }),
  88577. Object.defineProperty(e.prototype, "viewDirection", {
  88578. get: function() {
  88579. return this._inputs[6]
  88580. },
  88581. enumerable: !1,
  88582. configurable: !0
  88583. }),
  88584. Object.defineProperty(e.prototype, "parallaxScale", {
  88585. get: function() {
  88586. return this._inputs[7]
  88587. },
  88588. enumerable: !1,
  88589. configurable: !0
  88590. }),
  88591. Object.defineProperty(e.prototype, "parallaxHeight", {
  88592. get: function() {
  88593. return this._inputs[8]
  88594. },
  88595. enumerable: !1,
  88596. configurable: !0
  88597. }),
  88598. Object.defineProperty(e.prototype, "output", {
  88599. get: function() {
  88600. return this._outputs[0]
  88601. },
  88602. enumerable: !1,
  88603. configurable: !0
  88604. }),
  88605. Object.defineProperty(e.prototype, "uvOffset", {
  88606. get: function() {
  88607. return this._outputs[1]
  88608. },
  88609. enumerable: !1,
  88610. configurable: !0
  88611. }),
  88612. e.prototype.prepareDefines = function(i, o, s) {
  88613. var c = this.normalMapColor.connectedPoint._ownerBlock.samplerName
  88614. , d = this.viewDirection.isConnected && (this.useParallaxOcclusion && c || !this.useParallaxOcclusion && this.parallaxHeight.isConnected);
  88615. s.setValue("BUMP", !0),
  88616. s.setValue("PARALLAX", d, !0),
  88617. s.setValue("PARALLAXOCCLUSION", this.useParallaxOcclusion, !0)
  88618. }
  88619. ,
  88620. e.prototype.bind = function(i, o, s) {
  88621. o.getScene()._mirroredCameraPosition ? i.setFloat2(this._tangentSpaceParameterName, this.invertX ? 1 : -1, this.invertY ? 1 : -1) : i.setFloat2(this._tangentSpaceParameterName, this.invertX ? -1 : 1, this.invertY ? -1 : 1)
  88622. }
  88623. ,
  88624. e.prototype.autoConfigure = function(i) {
  88625. if (!this.uv.isConnected) {
  88626. var o = i.getInputBlockByPredicate(function(c) {
  88627. return c.isAttribute && c.name === "uv"
  88628. });
  88629. o || (o = new InputBlock("uv"),
  88630. o.setAsAttribute()),
  88631. o.output.connectTo(this.uv)
  88632. }
  88633. if (!this.strength.isConnected) {
  88634. var s = new InputBlock("strength");
  88635. s.value = 1,
  88636. s.output.connectTo(this.strength)
  88637. }
  88638. }
  88639. ,
  88640. e.prototype._buildBlock = function(i) {
  88641. a.prototype._buildBlock.call(this, i);
  88642. var o = "//" + this.name
  88643. , s = this.uv
  88644. , c = this.worldPosition
  88645. , d = this.worldNormal
  88646. , _ = this.worldTangent;
  88647. i.sharedData.blocksWithDefines.push(this),
  88648. i.sharedData.bindableBlocks.push(this),
  88649. this._tangentSpaceParameterName = i._getFreeDefineName("tangentSpaceParameter"),
  88650. i._emitUniformFromString(this._tangentSpaceParameterName, "vec2");
  88651. var b = this.normalMapColor.connectedPoint._ownerBlock.samplerName
  88652. , k = this.viewDirection.isConnected && (this.useParallaxOcclusion && b || !this.useParallaxOcclusion && this.parallaxHeight.isConnected)
  88653. , j = this.parallaxScale.isConnectedToInputBlock ? this.parallaxScale.connectInputBlock.isConstant ? i._emitFloat(this.parallaxScale.connectInputBlock.value) : this.parallaxScale.associatedVariableName : "0.05"
  88654. , $ = this.strength.isConnectedToInputBlock && this.strength.connectInputBlock.isConstant ? `\r
  88655. #if !defined(NORMALXYSCALE)\r
  88656. 1.0/\r
  88657. #endif\r
  88658. ` + i._emitFloat(this.strength.connectInputBlock.value) : `\r
  88659. #if !defined(NORMALXYSCALE)\r
  88660. 1.0/\r
  88661. #endif\r
  88662. ` + this.strength.associatedVariableName;
  88663. i._emitExtension("derivatives", "#extension GL_OES_standard_derivatives : enable");
  88664. var _e = {
  88665. search: /defined\(TANGENT\)/g,
  88666. replace: _.isConnected ? "defined(TANGENT)" : "defined(IGNORE)"
  88667. };
  88668. _.isConnected && (i.compilationString += "vec3 tbnNormal = normalize(" + d.associatedVariableName + `.xyz);\r
  88669. `,
  88670. i.compilationString += "vec3 tbnTangent = normalize(" + _.associatedVariableName + `.xyz);\r
  88671. `,
  88672. i.compilationString += `vec3 tbnBitangent = cross(tbnNormal, tbnTangent);\r
  88673. `,
  88674. i.compilationString += `mat3 vTBN = mat3(tbnTangent, tbnBitangent, tbnNormal);\r
  88675. `),
  88676. i._emitFunctionFromInclude("bumpFragmentMainFunctions", o, {
  88677. replaceStrings: [_e]
  88678. }),
  88679. i._emitFunctionFromInclude("bumpFragmentFunctions", o, {
  88680. replaceStrings: [{
  88681. search: /#include<samplerFragmentDeclaration>\(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_SAMPLERNAME_,bump\)/g,
  88682. replace: ""
  88683. }, {
  88684. search: /uniform sampler2D bumpSampler;/g,
  88685. replace: ""
  88686. }, {
  88687. search: /vec2 parallaxOcclusion\(vec3 vViewDirCoT,vec3 vNormalCoT,vec2 texCoord,float parallaxScale\)/g,
  88688. replace: `#define inline\r
  88689. vec2 parallaxOcclusion(vec3 vViewDirCoT, vec3 vNormalCoT, vec2 texCoord, float parallaxScale, sampler2D bumpSampler)`
  88690. }, {
  88691. search: /vec2 parallaxOffset\(vec3 viewDir,float heightScale\)/g,
  88692. replace: "vec2 parallaxOffset(vec3 viewDir, float heightScale, float height_)"
  88693. }, {
  88694. search: /texture2D\(bumpSampler,vBumpUV\)\.w/g,
  88695. replace: "height_"
  88696. }]
  88697. });
  88698. var et = !k || !b ? this.normalMapColor.associatedVariableName : "texture2D(" + b + ", " + s.associatedVariableName + " + uvOffset).xyz";
  88699. return i.compilationString += this._declareOutput(this.output, i) + ` = vec4(0.);\r
  88700. `,
  88701. i.compilationString += i._emitCodeFromInclude("bumpFragment", o, {
  88702. replaceStrings: [{
  88703. search: /perturbNormal\(TBN,texture2D\(bumpSampler,vBumpUV\+uvOffset\).xyz,vBumpInfos.y\)/g,
  88704. replace: "perturbNormal(TBN, " + et + ", vBumpInfos.y)"
  88705. }, {
  88706. search: /parallaxOcclusion\(invTBN\*-viewDirectionW,invTBN\*normalW,vBumpUV,vBumpInfos.z\)/g,
  88707. replace: "parallaxOcclusion((invTBN * -viewDirectionW), (invTBN * normalW), vBumpUV, vBumpInfos.z, " + (k && this.useParallaxOcclusion ? b : "bumpSampler") + ")"
  88708. }, {
  88709. search: /parallaxOffset\(invTBN\*viewDirectionW,vBumpInfos\.z\)/g,
  88710. replace: "parallaxOffset(invTBN * viewDirectionW, vBumpInfos.z, " + (k ? this.parallaxHeight.associatedVariableName : "0.") + ")"
  88711. }, {
  88712. search: /vTangentSpaceParams/g,
  88713. replace: this._tangentSpaceParameterName
  88714. }, {
  88715. search: /vBumpInfos.y/g,
  88716. replace: $
  88717. }, {
  88718. search: /vBumpInfos.z/g,
  88719. replace: j
  88720. }, {
  88721. search: /vBumpUV/g,
  88722. replace: s.associatedVariableName
  88723. }, {
  88724. search: /vPositionW/g,
  88725. replace: c.associatedVariableName + ".xyz"
  88726. }, {
  88727. search: /normalW=/g,
  88728. replace: this.output.associatedVariableName + ".xyz = "
  88729. }, {
  88730. search: /mat3\(normalMatrix\)\*normalW/g,
  88731. replace: "mat3(normalMatrix) * " + this.output.associatedVariableName + ".xyz"
  88732. }, {
  88733. search: /normalW/g,
  88734. replace: d.associatedVariableName + ".xyz"
  88735. }, {
  88736. search: /viewDirectionW/g,
  88737. replace: k ? this.viewDirection.associatedVariableName : "vec3(0.)"
  88738. }, _e]
  88739. }),
  88740. this
  88741. }
  88742. ,
  88743. e.prototype._dumpPropertiesCode = function() {
  88744. var i = a.prototype._dumpPropertiesCode.call(this) + (this._codeVariableName + ".invertX = " + this.invertX + `;\r
  88745. `);
  88746. return i += this._codeVariableName + ".invertY = " + this.invertY + `;\r
  88747. `,
  88748. i += this._codeVariableName + ".useParallaxOcclusion = " + this.useParallaxOcclusion + `;\r
  88749. `,
  88750. i
  88751. }
  88752. ,
  88753. e.prototype.serialize = function() {
  88754. var i = a.prototype.serialize.call(this);
  88755. return i.invertX = this.invertX,
  88756. i.invertY = this.invertY,
  88757. i.useParallaxOcclusion = this.useParallaxOcclusion,
  88758. i
  88759. }
  88760. ,
  88761. e.prototype._deserialize = function(i, o, s) {
  88762. a.prototype._deserialize.call(this, i, o, s),
  88763. this.invertX = i.invertX,
  88764. this.invertY = i.invertY,
  88765. this.useParallaxOcclusion = !!i.useParallaxOcclusion
  88766. }
  88767. ,
  88768. __decorate([editableInPropertyPage("Invert X axis", PropertyTypeForEdition.Boolean, "PROPERTIES", {
  88769. notifiers: {
  88770. update: !1
  88771. }
  88772. })], e.prototype, "invertX", void 0),
  88773. __decorate([editableInPropertyPage("Invert Y axis", PropertyTypeForEdition.Boolean, "PROPERTIES", {
  88774. notifiers: {
  88775. update: !1
  88776. }
  88777. })], e.prototype, "invertY", void 0),
  88778. __decorate([editableInPropertyPage("Use parallax occlusion", PropertyTypeForEdition.Boolean)], e.prototype, "useParallaxOcclusion", void 0),
  88779. e
  88780. }(NodeMaterialBlock);
  88781. RegisterClass("BABYLON.PerturbNormalBlock", PerturbNormalBlock);
  88782. var DiscardBlock = function(a) {
  88783. __extends(e, a);
  88784. function e(i) {
  88785. var o = a.call(this, i, NodeMaterialBlockTargets.Fragment, !0) || this;
  88786. return o.registerInput("value", NodeMaterialBlockConnectionPointTypes.Float, !0),
  88787. o.registerInput("cutoff", NodeMaterialBlockConnectionPointTypes.Float, !0),
  88788. o
  88789. }
  88790. return e.prototype.getClassName = function() {
  88791. return "DiscardBlock"
  88792. }
  88793. ,
  88794. Object.defineProperty(e.prototype, "value", {
  88795. get: function() {
  88796. return this._inputs[0]
  88797. },
  88798. enumerable: !1,
  88799. configurable: !0
  88800. }),
  88801. Object.defineProperty(e.prototype, "cutoff", {
  88802. get: function() {
  88803. return this._inputs[1]
  88804. },
  88805. enumerable: !1,
  88806. configurable: !0
  88807. }),
  88808. e.prototype._buildBlock = function(i) {
  88809. if (a.prototype._buildBlock.call(this, i),
  88810. i.sharedData.hints.needAlphaTesting = !0,
  88811. !(!this.cutoff.isConnected || !this.value.isConnected))
  88812. return i.compilationString += "if (" + this.value.associatedVariableName + " < " + this.cutoff.associatedVariableName + `) discard;\r
  88813. `,
  88814. this
  88815. }
  88816. ,
  88817. e
  88818. }(NodeMaterialBlock);
  88819. RegisterClass("BABYLON.DiscardBlock", DiscardBlock);
  88820. var FrontFacingBlock = function(a) {
  88821. __extends(e, a);
  88822. function e(i) {
  88823. var o = a.call(this, i, NodeMaterialBlockTargets.Fragment) || this;
  88824. return o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment),
  88825. o
  88826. }
  88827. return e.prototype.getClassName = function() {
  88828. return "FrontFacingBlock"
  88829. }
  88830. ,
  88831. Object.defineProperty(e.prototype, "output", {
  88832. get: function() {
  88833. return this._outputs[0]
  88834. },
  88835. enumerable: !1,
  88836. configurable: !0
  88837. }),
  88838. e.prototype._buildBlock = function(i) {
  88839. if (a.prototype._buildBlock.call(this, i),
  88840. i.target === NodeMaterialBlockTargets.Vertex)
  88841. throw "FrontFacingBlock must only be used in a fragment shader";
  88842. var o = this._outputs[0];
  88843. return i.compilationString += this._declareOutput(o, i) + ` = gl_FrontFacing ? 1.0 : 0.0;\r
  88844. `,
  88845. this
  88846. }
  88847. ,
  88848. e
  88849. }(NodeMaterialBlock);
  88850. RegisterClass("BABYLON.FrontFacingBlock", FrontFacingBlock);
  88851. var DerivativeBlock = function(a) {
  88852. __extends(e, a);
  88853. function e(i) {
  88854. var o = a.call(this, i, NodeMaterialBlockTargets.Fragment) || this;
  88855. return o.registerInput("input", NodeMaterialBlockConnectionPointTypes.AutoDetect, !1),
  88856. o.registerOutput("dx", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
  88857. o.registerOutput("dy", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
  88858. o._outputs[0]._typeConnectionSource = o._inputs[0],
  88859. o._outputs[1]._typeConnectionSource = o._inputs[0],
  88860. o
  88861. }
  88862. return e.prototype.getClassName = function() {
  88863. return "DerivativeBlock"
  88864. }
  88865. ,
  88866. Object.defineProperty(e.prototype, "input", {
  88867. get: function() {
  88868. return this._inputs[0]
  88869. },
  88870. enumerable: !1,
  88871. configurable: !0
  88872. }),
  88873. Object.defineProperty(e.prototype, "dx", {
  88874. get: function() {
  88875. return this._outputs[0]
  88876. },
  88877. enumerable: !1,
  88878. configurable: !0
  88879. }),
  88880. Object.defineProperty(e.prototype, "dy", {
  88881. get: function() {
  88882. return this._outputs[1]
  88883. },
  88884. enumerable: !1,
  88885. configurable: !0
  88886. }),
  88887. e.prototype._buildBlock = function(i) {
  88888. a.prototype._buildBlock.call(this, i);
  88889. var o = this._outputs[0]
  88890. , s = this._outputs[1];
  88891. return i._emitExtension("derivatives", "#extension GL_OES_standard_derivatives : enable"),
  88892. o.hasEndpoints && (i.compilationString += this._declareOutput(o, i) + (" = dFdx(" + this.input.associatedVariableName + `);\r
  88893. `)),
  88894. s.hasEndpoints && (i.compilationString += this._declareOutput(s, i) + (" = dFdy(" + this.input.associatedVariableName + `);\r
  88895. `)),
  88896. this
  88897. }
  88898. ,
  88899. e
  88900. }(NodeMaterialBlock);
  88901. RegisterClass("BABYLON.DerivativeBlock", DerivativeBlock);
  88902. var FragCoordBlock = function(a) {
  88903. __extends(e, a);
  88904. function e(i) {
  88905. var o = a.call(this, i, NodeMaterialBlockTargets.Fragment) || this;
  88906. return o.registerOutput("xy", NodeMaterialBlockConnectionPointTypes.Vector2, NodeMaterialBlockTargets.Fragment),
  88907. o.registerOutput("xyz", NodeMaterialBlockConnectionPointTypes.Vector3, NodeMaterialBlockTargets.Fragment),
  88908. o.registerOutput("xyzw", NodeMaterialBlockConnectionPointTypes.Vector4, NodeMaterialBlockTargets.Fragment),
  88909. o.registerOutput("x", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment),
  88910. o.registerOutput("y", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment),
  88911. o.registerOutput("z", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment),
  88912. o.registerOutput("w", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment),
  88913. o
  88914. }
  88915. return e.prototype.getClassName = function() {
  88916. return "FragCoordBlock"
  88917. }
  88918. ,
  88919. Object.defineProperty(e.prototype, "xy", {
  88920. get: function() {
  88921. return this._outputs[0]
  88922. },
  88923. enumerable: !1,
  88924. configurable: !0
  88925. }),
  88926. Object.defineProperty(e.prototype, "xyz", {
  88927. get: function() {
  88928. return this._outputs[1]
  88929. },
  88930. enumerable: !1,
  88931. configurable: !0
  88932. }),
  88933. Object.defineProperty(e.prototype, "xyzw", {
  88934. get: function() {
  88935. return this._outputs[2]
  88936. },
  88937. enumerable: !1,
  88938. configurable: !0
  88939. }),
  88940. Object.defineProperty(e.prototype, "x", {
  88941. get: function() {
  88942. return this._outputs[3]
  88943. },
  88944. enumerable: !1,
  88945. configurable: !0
  88946. }),
  88947. Object.defineProperty(e.prototype, "y", {
  88948. get: function() {
  88949. return this._outputs[4]
  88950. },
  88951. enumerable: !1,
  88952. configurable: !0
  88953. }),
  88954. Object.defineProperty(e.prototype, "z", {
  88955. get: function() {
  88956. return this._outputs[5]
  88957. },
  88958. enumerable: !1,
  88959. configurable: !0
  88960. }),
  88961. Object.defineProperty(e.prototype, "output", {
  88962. get: function() {
  88963. return this._outputs[6]
  88964. },
  88965. enumerable: !1,
  88966. configurable: !0
  88967. }),
  88968. e.prototype.writeOutputs = function(i) {
  88969. for (var o = "", s = 0, c = this._outputs; s < c.length; s++) {
  88970. var d = c[s];
  88971. d.hasEndpoints && (o += this._declareOutput(d, i) + " = gl_FragCoord." + d.name + `;\r
  88972. `)
  88973. }
  88974. return o
  88975. }
  88976. ,
  88977. e.prototype._buildBlock = function(i) {
  88978. if (a.prototype._buildBlock.call(this, i),
  88979. i.target === NodeMaterialBlockTargets.Vertex)
  88980. throw "FragCoordBlock must only be used in a fragment shader";
  88981. return i.compilationString += this.writeOutputs(i),
  88982. this
  88983. }
  88984. ,
  88985. e
  88986. }(NodeMaterialBlock);
  88987. RegisterClass("BABYLON.FragCoordBlock", FragCoordBlock);
  88988. var ScreenSizeBlock = function(a) {
  88989. __extends(e, a);
  88990. function e(i) {
  88991. var o = a.call(this, i, NodeMaterialBlockTargets.Fragment) || this;
  88992. return o.registerOutput("xy", NodeMaterialBlockConnectionPointTypes.Vector2, NodeMaterialBlockTargets.Fragment),
  88993. o.registerOutput("x", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment),
  88994. o.registerOutput("y", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment),
  88995. o
  88996. }
  88997. return e.prototype.getClassName = function() {
  88998. return "ScreenSizeBlock"
  88999. }
  89000. ,
  89001. Object.defineProperty(e.prototype, "xy", {
  89002. get: function() {
  89003. return this._outputs[0]
  89004. },
  89005. enumerable: !1,
  89006. configurable: !0
  89007. }),
  89008. Object.defineProperty(e.prototype, "x", {
  89009. get: function() {
  89010. return this._outputs[1]
  89011. },
  89012. enumerable: !1,
  89013. configurable: !0
  89014. }),
  89015. Object.defineProperty(e.prototype, "y", {
  89016. get: function() {
  89017. return this._outputs[2]
  89018. },
  89019. enumerable: !1,
  89020. configurable: !0
  89021. }),
  89022. e.prototype.bind = function(i, o, s) {
  89023. var c = this._scene.getEngine();
  89024. i.setFloat2(this._varName, c.getRenderWidth(), c.getRenderHeight())
  89025. }
  89026. ,
  89027. e.prototype.writeOutputs = function(i, o) {
  89028. for (var s = "", c = 0, d = this._outputs; c < d.length; c++) {
  89029. var _ = d[c];
  89030. _.hasEndpoints && (s += this._declareOutput(_, i) + " = " + o + "." + _.name + `;\r
  89031. `)
  89032. }
  89033. return s
  89034. }
  89035. ,
  89036. e.prototype._buildBlock = function(i) {
  89037. if (a.prototype._buildBlock.call(this, i),
  89038. this._scene = i.sharedData.scene,
  89039. i.target === NodeMaterialBlockTargets.Vertex)
  89040. throw "ScreenSizeBlock must only be used in a fragment shader";
  89041. return i.sharedData.bindableBlocks.push(this),
  89042. this._varName = i._getFreeVariableName("screenSize"),
  89043. i._emitUniformFromString(this._varName, "vec2"),
  89044. i.compilationString += this.writeOutputs(i, this._varName),
  89045. this
  89046. }
  89047. ,
  89048. e
  89049. }(NodeMaterialBlock);
  89050. RegisterClass("BABYLON.ScreenSizeBlock", ScreenSizeBlock);
  89051. var ScreenSpaceBlock = function(a) {
  89052. __extends(e, a);
  89053. function e(i) {
  89054. var o = a.call(this, i, NodeMaterialBlockTargets.Fragment) || this;
  89055. return o.registerInput("vector", NodeMaterialBlockConnectionPointTypes.Vector3),
  89056. o.registerInput("worldViewProjection", NodeMaterialBlockConnectionPointTypes.Matrix),
  89057. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Vector2),
  89058. o.registerOutput("x", NodeMaterialBlockConnectionPointTypes.Float),
  89059. o.registerOutput("y", NodeMaterialBlockConnectionPointTypes.Float),
  89060. o.inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector4),
  89061. o
  89062. }
  89063. return e.prototype.getClassName = function() {
  89064. return "ScreenSpaceBlock"
  89065. }
  89066. ,
  89067. Object.defineProperty(e.prototype, "vector", {
  89068. get: function() {
  89069. return this._inputs[0]
  89070. },
  89071. enumerable: !1,
  89072. configurable: !0
  89073. }),
  89074. Object.defineProperty(e.prototype, "worldViewProjection", {
  89075. get: function() {
  89076. return this._inputs[1]
  89077. },
  89078. enumerable: !1,
  89079. configurable: !0
  89080. }),
  89081. Object.defineProperty(e.prototype, "output", {
  89082. get: function() {
  89083. return this._outputs[0]
  89084. },
  89085. enumerable: !1,
  89086. configurable: !0
  89087. }),
  89088. Object.defineProperty(e.prototype, "x", {
  89089. get: function() {
  89090. return this._outputs[1]
  89091. },
  89092. enumerable: !1,
  89093. configurable: !0
  89094. }),
  89095. Object.defineProperty(e.prototype, "y", {
  89096. get: function() {
  89097. return this._outputs[2]
  89098. },
  89099. enumerable: !1,
  89100. configurable: !0
  89101. }),
  89102. e.prototype.autoConfigure = function(i) {
  89103. if (!this.worldViewProjection.isConnected) {
  89104. var o = i.getInputBlockByPredicate(function(s) {
  89105. return s.systemValue === NodeMaterialSystemValues.WorldViewProjection
  89106. });
  89107. o || (o = new InputBlock("worldViewProjection"),
  89108. o.setAsSystemValue(NodeMaterialSystemValues.WorldViewProjection)),
  89109. o.output.connectTo(this.worldViewProjection)
  89110. }
  89111. }
  89112. ,
  89113. e.prototype._buildBlock = function(i) {
  89114. a.prototype._buildBlock.call(this, i);
  89115. var o = this.vector
  89116. , s = this.worldViewProjection;
  89117. if (!!o.connectedPoint) {
  89118. var c = s.associatedVariableName
  89119. , d = i._getFreeVariableName("screenSpaceTemp");
  89120. switch (o.connectedPoint.type) {
  89121. case NodeMaterialBlockConnectionPointTypes.Vector3:
  89122. i.compilationString += "vec4 " + d + " = " + c + " * vec4(" + o.associatedVariableName + `, 1.0);\r
  89123. `;
  89124. break;
  89125. case NodeMaterialBlockConnectionPointTypes.Vector4:
  89126. i.compilationString += "vec4 " + d + " = " + c + " * " + o.associatedVariableName + `;\r
  89127. `;
  89128. break
  89129. }
  89130. return i.compilationString += d + ".xy /= " + d + ".w;",
  89131. i.compilationString += d + ".xy = " + d + ".xy * 0.5 + vec2(0.5, 0.5);",
  89132. this.output.hasEndpoints && (i.compilationString += this._declareOutput(this.output, i) + (" = " + d + `.xy;\r
  89133. `)),
  89134. this.x.hasEndpoints && (i.compilationString += this._declareOutput(this.x, i) + (" = " + d + `.x;\r
  89135. `)),
  89136. this.y.hasEndpoints && (i.compilationString += this._declareOutput(this.y, i) + (" = " + d + `.y;\r
  89137. `)),
  89138. this
  89139. }
  89140. }
  89141. ,
  89142. e
  89143. }(NodeMaterialBlock);
  89144. RegisterClass("BABYLON.ScreenSpaceBlock", ScreenSpaceBlock);
  89145. var TwirlBlock = function(a) {
  89146. __extends(e, a);
  89147. function e(i) {
  89148. var o = a.call(this, i, NodeMaterialBlockTargets.Fragment) || this;
  89149. return o.registerInput("input", NodeMaterialBlockConnectionPointTypes.Vector2),
  89150. o.registerInput("strength", NodeMaterialBlockConnectionPointTypes.Float),
  89151. o.registerInput("center", NodeMaterialBlockConnectionPointTypes.Vector2),
  89152. o.registerInput("offset", NodeMaterialBlockConnectionPointTypes.Vector2),
  89153. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Vector2),
  89154. o.registerOutput("x", NodeMaterialBlockConnectionPointTypes.Float),
  89155. o.registerOutput("y", NodeMaterialBlockConnectionPointTypes.Float),
  89156. o
  89157. }
  89158. return e.prototype.getClassName = function() {
  89159. return "TwirlBlock"
  89160. }
  89161. ,
  89162. Object.defineProperty(e.prototype, "input", {
  89163. get: function() {
  89164. return this._inputs[0]
  89165. },
  89166. enumerable: !1,
  89167. configurable: !0
  89168. }),
  89169. Object.defineProperty(e.prototype, "strength", {
  89170. get: function() {
  89171. return this._inputs[1]
  89172. },
  89173. enumerable: !1,
  89174. configurable: !0
  89175. }),
  89176. Object.defineProperty(e.prototype, "center", {
  89177. get: function() {
  89178. return this._inputs[2]
  89179. },
  89180. enumerable: !1,
  89181. configurable: !0
  89182. }),
  89183. Object.defineProperty(e.prototype, "offset", {
  89184. get: function() {
  89185. return this._inputs[3]
  89186. },
  89187. enumerable: !1,
  89188. configurable: !0
  89189. }),
  89190. Object.defineProperty(e.prototype, "output", {
  89191. get: function() {
  89192. return this._outputs[0]
  89193. },
  89194. enumerable: !1,
  89195. configurable: !0
  89196. }),
  89197. Object.defineProperty(e.prototype, "x", {
  89198. get: function() {
  89199. return this._outputs[1]
  89200. },
  89201. enumerable: !1,
  89202. configurable: !0
  89203. }),
  89204. Object.defineProperty(e.prototype, "y", {
  89205. get: function() {
  89206. return this._outputs[2]
  89207. },
  89208. enumerable: !1,
  89209. configurable: !0
  89210. }),
  89211. e.prototype.autoConfigure = function(i) {
  89212. if (!this.center.isConnected) {
  89213. var o = new InputBlock("center");
  89214. o.value = new Vector2(.5,.5),
  89215. o.output.connectTo(this.center)
  89216. }
  89217. if (!this.strength.isConnected) {
  89218. var s = new InputBlock("strength");
  89219. s.value = 1,
  89220. s.output.connectTo(this.strength)
  89221. }
  89222. if (!this.offset.isConnected) {
  89223. var c = new InputBlock("offset");
  89224. c.value = new Vector2(0,0),
  89225. c.output.connectTo(this.offset)
  89226. }
  89227. }
  89228. ,
  89229. e.prototype._buildBlock = function(i) {
  89230. a.prototype._buildBlock.call(this, i);
  89231. var o = i._getFreeVariableName("delta")
  89232. , s = i._getFreeVariableName("angle")
  89233. , c = i._getFreeVariableName("x")
  89234. , d = i._getFreeVariableName("y")
  89235. , _ = i._getFreeVariableName("result");
  89236. return i.compilationString += `
  89237. vec2 ` + o + " = " + this.input.associatedVariableName + " - " + this.center.associatedVariableName + `;
  89238. float ` + s + " = " + this.strength.associatedVariableName + " * length(" + o + `);
  89239. float ` + c + " = cos(" + s + ") * " + o + ".x - sin(" + s + ") * " + o + `.y;
  89240. float ` + d + " = sin(" + s + ") * " + o + ".x + cos(" + s + ") * " + o + `.y;
  89241. vec2 ` + _ + " = vec2(" + c + " + " + this.center.associatedVariableName + ".x + " + this.offset.associatedVariableName + ".x, " + d + " + " + this.center.associatedVariableName + ".y + " + this.offset.associatedVariableName + `.y);
  89242. `,
  89243. this.output.hasEndpoints && (i.compilationString += this._declareOutput(this.output, i) + (" = " + _ + `;\r
  89244. `)),
  89245. this.x.hasEndpoints && (i.compilationString += this._declareOutput(this.x, i) + (" = " + _ + `.x;\r
  89246. `)),
  89247. this.y.hasEndpoints && (i.compilationString += this._declareOutput(this.y, i) + (" = " + _ + `.y;\r
  89248. `)),
  89249. this
  89250. }
  89251. ,
  89252. e
  89253. }(NodeMaterialBlock);
  89254. RegisterClass("BABYLON.TwirlBlock", TwirlBlock);
  89255. var FogBlock = function(a) {
  89256. __extends(e, a);
  89257. function e(i) {
  89258. var o = a.call(this, i, NodeMaterialBlockTargets.VertexAndFragment, !1) || this;
  89259. return o.registerInput("worldPosition", NodeMaterialBlockConnectionPointTypes.Vector4, !1, NodeMaterialBlockTargets.Vertex),
  89260. o.registerInput("view", NodeMaterialBlockConnectionPointTypes.Matrix, !1, NodeMaterialBlockTargets.Vertex),
  89261. o.registerInput("input", NodeMaterialBlockConnectionPointTypes.Color3, !1, NodeMaterialBlockTargets.Fragment),
  89262. o.registerInput("fogColor", NodeMaterialBlockConnectionPointTypes.Color3, !1, NodeMaterialBlockTargets.Fragment),
  89263. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment),
  89264. o.input.acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color4),
  89265. o.fogColor.acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color4),
  89266. o
  89267. }
  89268. return e.prototype.getClassName = function() {
  89269. return "FogBlock"
  89270. }
  89271. ,
  89272. Object.defineProperty(e.prototype, "worldPosition", {
  89273. get: function() {
  89274. return this._inputs[0]
  89275. },
  89276. enumerable: !1,
  89277. configurable: !0
  89278. }),
  89279. Object.defineProperty(e.prototype, "view", {
  89280. get: function() {
  89281. return this._inputs[1]
  89282. },
  89283. enumerable: !1,
  89284. configurable: !0
  89285. }),
  89286. Object.defineProperty(e.prototype, "input", {
  89287. get: function() {
  89288. return this._inputs[2]
  89289. },
  89290. enumerable: !1,
  89291. configurable: !0
  89292. }),
  89293. Object.defineProperty(e.prototype, "fogColor", {
  89294. get: function() {
  89295. return this._inputs[3]
  89296. },
  89297. enumerable: !1,
  89298. configurable: !0
  89299. }),
  89300. Object.defineProperty(e.prototype, "output", {
  89301. get: function() {
  89302. return this._outputs[0]
  89303. },
  89304. enumerable: !1,
  89305. configurable: !0
  89306. }),
  89307. e.prototype.autoConfigure = function(i) {
  89308. if (!this.view.isConnected) {
  89309. var o = i.getInputBlockByPredicate(function(c) {
  89310. return c.systemValue === NodeMaterialSystemValues.View
  89311. });
  89312. o || (o = new InputBlock("view"),
  89313. o.setAsSystemValue(NodeMaterialSystemValues.View)),
  89314. o.output.connectTo(this.view)
  89315. }
  89316. if (!this.fogColor.isConnected) {
  89317. var s = i.getInputBlockByPredicate(function(c) {
  89318. return c.systemValue === NodeMaterialSystemValues.FogColor
  89319. });
  89320. s || (s = new InputBlock("fogColor",void 0,NodeMaterialBlockConnectionPointTypes.Color3),
  89321. s.setAsSystemValue(NodeMaterialSystemValues.FogColor)),
  89322. s.output.connectTo(this.fogColor)
  89323. }
  89324. }
  89325. ,
  89326. e.prototype.prepareDefines = function(i, o, s) {
  89327. var c = i.getScene();
  89328. s.setValue("FOG", o.fogEnabled && MaterialHelper.GetFogState(i, c))
  89329. }
  89330. ,
  89331. e.prototype.bind = function(i, o, s) {
  89332. if (!!s) {
  89333. var c = s.getScene();
  89334. i.setFloat4(this._fogParameters, c.fogMode, c.fogStart, c.fogEnd, c.fogDensity)
  89335. }
  89336. }
  89337. ,
  89338. e.prototype._buildBlock = function(i) {
  89339. if (a.prototype._buildBlock.call(this, i),
  89340. i.target === NodeMaterialBlockTargets.Fragment) {
  89341. i.sharedData.blocksWithDefines.push(this),
  89342. i.sharedData.bindableBlocks.push(this),
  89343. i._emitFunctionFromInclude("fogFragmentDeclaration", "//" + this.name, {
  89344. removeUniforms: !0,
  89345. removeVaryings: !0,
  89346. removeIfDef: !1,
  89347. replaceStrings: [{
  89348. search: /float CalcFogFactor\(\)/,
  89349. replace: "float CalcFogFactor(vec3 vFogDistance, vec4 vFogInfos)"
  89350. }]
  89351. });
  89352. var o = i._getFreeVariableName("fog")
  89353. , s = this.input
  89354. , c = this.fogColor;
  89355. this._fogParameters = i._getFreeVariableName("fogParameters");
  89356. var d = this._outputs[0];
  89357. i._emitUniformFromString(this._fogParameters, "vec4"),
  89358. i.compilationString += `#ifdef FOG\r
  89359. `,
  89360. i.compilationString += "float " + o + " = CalcFogFactor(" + this._fogDistanceName + ", " + this._fogParameters + `);\r
  89361. `,
  89362. i.compilationString += this._declareOutput(d, i) + (" = " + o + " * " + s.associatedVariableName + ".rgb + (1.0 - " + o + ") * " + c.associatedVariableName + `.rgb;\r
  89363. `),
  89364. i.compilationString += `#else\r
  89365. ` + this._declareOutput(d, i) + " = " + s.associatedVariableName + `.rgb;\r
  89366. `,
  89367. i.compilationString += `#endif\r
  89368. `
  89369. } else {
  89370. var _ = this.worldPosition
  89371. , b = this.view;
  89372. this._fogDistanceName = i._getFreeVariableName("vFogDistance"),
  89373. i._emitVaryingFromString(this._fogDistanceName, "vec3"),
  89374. i.compilationString += this._fogDistanceName + " = (" + b.associatedVariableName + " * " + _.associatedVariableName + `).xyz;\r
  89375. `
  89376. }
  89377. return this
  89378. }
  89379. ,
  89380. e
  89381. }(NodeMaterialBlock);
  89382. RegisterClass("BABYLON.FogBlock", FogBlock);
  89383. var LightBlock = function(a) {
  89384. __extends(e, a);
  89385. function e(i) {
  89386. var o = a.call(this, i, NodeMaterialBlockTargets.VertexAndFragment) || this;
  89387. return o._isUnique = !0,
  89388. o.registerInput("worldPosition", NodeMaterialBlockConnectionPointTypes.Vector4, !1, NodeMaterialBlockTargets.Vertex),
  89389. o.registerInput("worldNormal", NodeMaterialBlockConnectionPointTypes.Vector4, !1, NodeMaterialBlockTargets.Fragment),
  89390. o.registerInput("cameraPosition", NodeMaterialBlockConnectionPointTypes.Vector3, !1, NodeMaterialBlockTargets.Fragment),
  89391. o.registerInput("glossiness", NodeMaterialBlockConnectionPointTypes.Float, !0, NodeMaterialBlockTargets.Fragment),
  89392. o.registerInput("glossPower", NodeMaterialBlockConnectionPointTypes.Float, !0, NodeMaterialBlockTargets.Fragment),
  89393. o.registerInput("diffuseColor", NodeMaterialBlockConnectionPointTypes.Color3, !0, NodeMaterialBlockTargets.Fragment),
  89394. o.registerInput("specularColor", NodeMaterialBlockConnectionPointTypes.Color3, !0, NodeMaterialBlockTargets.Fragment),
  89395. o.registerInput("view", NodeMaterialBlockConnectionPointTypes.Matrix, !0),
  89396. o.registerOutput("diffuseOutput", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment),
  89397. o.registerOutput("specularOutput", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment),
  89398. o.registerOutput("shadow", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment),
  89399. o
  89400. }
  89401. return e.prototype.getClassName = function() {
  89402. return "LightBlock"
  89403. }
  89404. ,
  89405. Object.defineProperty(e.prototype, "worldPosition", {
  89406. get: function() {
  89407. return this._inputs[0]
  89408. },
  89409. enumerable: !1,
  89410. configurable: !0
  89411. }),
  89412. Object.defineProperty(e.prototype, "worldNormal", {
  89413. get: function() {
  89414. return this._inputs[1]
  89415. },
  89416. enumerable: !1,
  89417. configurable: !0
  89418. }),
  89419. Object.defineProperty(e.prototype, "cameraPosition", {
  89420. get: function() {
  89421. return this._inputs[2]
  89422. },
  89423. enumerable: !1,
  89424. configurable: !0
  89425. }),
  89426. Object.defineProperty(e.prototype, "glossiness", {
  89427. get: function() {
  89428. return this._inputs[3]
  89429. },
  89430. enumerable: !1,
  89431. configurable: !0
  89432. }),
  89433. Object.defineProperty(e.prototype, "glossPower", {
  89434. get: function() {
  89435. return this._inputs[4]
  89436. },
  89437. enumerable: !1,
  89438. configurable: !0
  89439. }),
  89440. Object.defineProperty(e.prototype, "diffuseColor", {
  89441. get: function() {
  89442. return this._inputs[5]
  89443. },
  89444. enumerable: !1,
  89445. configurable: !0
  89446. }),
  89447. Object.defineProperty(e.prototype, "specularColor", {
  89448. get: function() {
  89449. return this._inputs[6]
  89450. },
  89451. enumerable: !1,
  89452. configurable: !0
  89453. }),
  89454. Object.defineProperty(e.prototype, "view", {
  89455. get: function() {
  89456. return this._inputs[7]
  89457. },
  89458. enumerable: !1,
  89459. configurable: !0
  89460. }),
  89461. Object.defineProperty(e.prototype, "diffuseOutput", {
  89462. get: function() {
  89463. return this._outputs[0]
  89464. },
  89465. enumerable: !1,
  89466. configurable: !0
  89467. }),
  89468. Object.defineProperty(e.prototype, "specularOutput", {
  89469. get: function() {
  89470. return this._outputs[1]
  89471. },
  89472. enumerable: !1,
  89473. configurable: !0
  89474. }),
  89475. Object.defineProperty(e.prototype, "shadow", {
  89476. get: function() {
  89477. return this._outputs[2]
  89478. },
  89479. enumerable: !1,
  89480. configurable: !0
  89481. }),
  89482. e.prototype.autoConfigure = function(i) {
  89483. if (!this.cameraPosition.isConnected) {
  89484. var o = i.getInputBlockByPredicate(function(s) {
  89485. return s.systemValue === NodeMaterialSystemValues.CameraPosition
  89486. });
  89487. o || (o = new InputBlock("cameraPosition"),
  89488. o.setAsSystemValue(NodeMaterialSystemValues.CameraPosition)),
  89489. o.output.connectTo(this.cameraPosition)
  89490. }
  89491. }
  89492. ,
  89493. e.prototype.prepareDefines = function(i, o, s) {
  89494. if (!!s._areLightsDirty) {
  89495. var c = i.getScene();
  89496. if (!this.light)
  89497. MaterialHelper.PrepareDefinesForLights(c, i, s, !0, o.maxSimultaneousLights);
  89498. else {
  89499. var d = {
  89500. needNormals: !1,
  89501. needRebuild: !1,
  89502. lightmapMode: !1,
  89503. shadowEnabled: !1,
  89504. specularEnabled: !1
  89505. };
  89506. MaterialHelper.PrepareDefinesForLight(c, i, this.light, this._lightId, s, !0, d),
  89507. d.needRebuild && s.rebuild()
  89508. }
  89509. }
  89510. }
  89511. ,
  89512. e.prototype.updateUniformsAndSamples = function(i, o, s, c) {
  89513. for (var d = 0; d < o.maxSimultaneousLights && s["LIGHT" + d]; d++) {
  89514. var _ = i.uniforms.indexOf("vLightData" + d) >= 0;
  89515. MaterialHelper.PrepareUniformsAndSamplersForLight(d, i.uniforms, i.samplers, s["PROJECTEDLIGHTTEXTURE" + d], c, _)
  89516. }
  89517. }
  89518. ,
  89519. e.prototype.bind = function(i, o, s) {
  89520. if (!!s) {
  89521. var c = s.getScene();
  89522. this.light ? MaterialHelper.BindLight(this.light, this._lightId, c, i, !0) : MaterialHelper.BindLights(c, s, i, !0, o.maxSimultaneousLights)
  89523. }
  89524. }
  89525. ,
  89526. e.prototype._injectVertexCode = function(i) {
  89527. var o = this.worldPosition
  89528. , s = "//" + this.name;
  89529. this.light ? (this._lightId = (i.counters.lightCounter !== void 0 ? i.counters.lightCounter : -1) + 1,
  89530. i.counters.lightCounter = this._lightId,
  89531. i._emitFunctionFromInclude(i.supportUniformBuffers ? "lightVxUboDeclaration" : "lightVxFragmentDeclaration", s, {
  89532. replaceStrings: [{
  89533. search: /{X}/g,
  89534. replace: this._lightId.toString()
  89535. }]
  89536. }, this._lightId.toString())) : (i._emitFunctionFromInclude(i.supportUniformBuffers ? "lightVxUboDeclaration" : "lightVxFragmentDeclaration", s, {
  89537. repeatKey: "maxSimultaneousLights"
  89538. }),
  89539. this._lightId = 0,
  89540. i.sharedData.dynamicUniformBlocks.push(this));
  89541. var c = "v_" + o.associatedVariableName;
  89542. i._emitVaryingFromString(c, "vec4") && (i.compilationString += c + " = " + o.associatedVariableName + `;\r
  89543. `),
  89544. this.light ? i.compilationString += i._emitCodeFromInclude("shadowsVertex", s, {
  89545. replaceStrings: [{
  89546. search: /{X}/g,
  89547. replace: this._lightId.toString()
  89548. }, {
  89549. search: /worldPos/g,
  89550. replace: o.associatedVariableName
  89551. }]
  89552. }) : (i.compilationString += "vec4 worldPos = " + o.associatedVariableName + `;\r
  89553. `,
  89554. this.view.isConnected && (i.compilationString += "mat4 view = " + this.view.associatedVariableName + `;\r
  89555. `),
  89556. i.compilationString += i._emitCodeFromInclude("shadowsVertex", s, {
  89557. repeatKey: "maxSimultaneousLights"
  89558. }))
  89559. }
  89560. ,
  89561. e.prototype._buildBlock = function(i) {
  89562. if (a.prototype._buildBlock.call(this, i),
  89563. i.target !== NodeMaterialBlockTargets.Fragment) {
  89564. this._injectVertexCode(i);
  89565. return
  89566. }
  89567. i.sharedData.forcedBindableBlocks.push(this),
  89568. i.sharedData.blocksWithDefines.push(this);
  89569. var o = "//" + this.name
  89570. , s = this.worldPosition;
  89571. i._emitFunctionFromInclude("helperFunctions", o),
  89572. i._emitFunctionFromInclude("lightsFragmentFunctions", o, {
  89573. replaceStrings: [{
  89574. search: /vPositionW/g,
  89575. replace: "v_" + s.associatedVariableName + ".xyz"
  89576. }]
  89577. }),
  89578. i._emitFunctionFromInclude("shadowsFragmentFunctions", o, {
  89579. replaceStrings: [{
  89580. search: /vPositionW/g,
  89581. replace: "v_" + s.associatedVariableName + ".xyz"
  89582. }]
  89583. }),
  89584. this.light ? i._emitFunctionFromInclude(i.supportUniformBuffers ? "lightUboDeclaration" : "lightFragmentDeclaration", o, {
  89585. replaceStrings: [{
  89586. search: /{X}/g,
  89587. replace: this._lightId.toString()
  89588. }]
  89589. }, this._lightId.toString()) : i._emitFunctionFromInclude(i.supportUniformBuffers ? "lightUboDeclaration" : "lightFragmentDeclaration", o, {
  89590. repeatKey: "maxSimultaneousLights"
  89591. }),
  89592. this._lightId === 0 && (i._registerTempVariable("viewDirectionW") && (i.compilationString += "vec3 viewDirectionW = normalize(" + this.cameraPosition.associatedVariableName + " - " + ("v_" + s.associatedVariableName) + `.xyz);\r
  89593. `),
  89594. i.compilationString += `lightingInfo info;\r
  89595. `,
  89596. i.compilationString += `float shadow = 1.;\r
  89597. `,
  89598. i.compilationString += "float glossiness = " + (this.glossiness.isConnected ? this.glossiness.associatedVariableName : "1.0") + " * " + (this.glossPower.isConnected ? this.glossPower.associatedVariableName : "1024.0") + `;\r
  89599. `,
  89600. i.compilationString += `vec3 diffuseBase = vec3(0., 0., 0.);\r
  89601. `,
  89602. i.compilationString += `vec3 specularBase = vec3(0., 0., 0.);\r
  89603. `,
  89604. i.compilationString += "vec3 normalW = " + this.worldNormal.associatedVariableName + `.xyz;\r
  89605. `),
  89606. this.light ? i.compilationString += i._emitCodeFromInclude("lightFragment", o, {
  89607. replaceStrings: [{
  89608. search: /{X}/g,
  89609. replace: this._lightId.toString()
  89610. }]
  89611. }) : i.compilationString += i._emitCodeFromInclude("lightFragment", o, {
  89612. repeatKey: "maxSimultaneousLights"
  89613. });
  89614. var c = this.diffuseOutput
  89615. , d = this.specularOutput;
  89616. return i.compilationString += this._declareOutput(c, i) + (" = diffuseBase" + (this.diffuseColor.isConnected ? " * " + this.diffuseColor.associatedVariableName : "") + `;\r
  89617. `),
  89618. d.hasEndpoints && (i.compilationString += this._declareOutput(d, i) + (" = specularBase" + (this.specularColor.isConnected ? " * " + this.specularColor.associatedVariableName : "") + `;\r
  89619. `)),
  89620. this.shadow.hasEndpoints && (i.compilationString += this._declareOutput(this.shadow, i) + ` = shadow;\r
  89621. `),
  89622. this
  89623. }
  89624. ,
  89625. e.prototype.serialize = function() {
  89626. var i = a.prototype.serialize.call(this);
  89627. return this.light && (i.lightId = this.light.id),
  89628. i
  89629. }
  89630. ,
  89631. e.prototype._deserialize = function(i, o, s) {
  89632. a.prototype._deserialize.call(this, i, o, s),
  89633. i.lightId && (this.light = o.getLightById(i.lightId))
  89634. }
  89635. ,
  89636. e
  89637. }(NodeMaterialBlock);
  89638. RegisterClass("BABYLON.LightBlock", LightBlock);
  89639. var NodeMaterialConnectionPointCustomObject = function(a) {
  89640. __extends(e, a);
  89641. function e(i, o, s, c, d, _) {
  89642. var b = a.call(this, i, o, s) || this;
  89643. return b._blockType = c,
  89644. b._blockName = d,
  89645. b._nameForCheking = _,
  89646. b._nameForCheking || (b._nameForCheking = i),
  89647. b.needDualDirectionValidation = !0,
  89648. b
  89649. }
  89650. return e.prototype.checkCompatibilityState = function(i) {
  89651. return i instanceof e && i.name === this._nameForCheking ? NodeMaterialConnectionPointCompatibilityStates.Compatible : NodeMaterialConnectionPointCompatibilityStates.TypeIncompatible
  89652. }
  89653. ,
  89654. e.prototype.createCustomInputBlock = function() {
  89655. return [new this._blockType(this._blockName), this.name]
  89656. }
  89657. ,
  89658. e
  89659. }(NodeMaterialConnectionPoint)
  89660. , ImageSourceBlock = function(a) {
  89661. __extends(e, a);
  89662. function e(i) {
  89663. var o = a.call(this, i, NodeMaterialBlockTargets.VertexAndFragment) || this;
  89664. return o.registerOutput("source", NodeMaterialBlockConnectionPointTypes.Object, NodeMaterialBlockTargets.VertexAndFragment, new NodeMaterialConnectionPointCustomObject("source",o,NodeMaterialConnectionPointDirection.Output,e,"ImageSourceBlock")),
  89665. o
  89666. }
  89667. return Object.defineProperty(e.prototype, "texture", {
  89668. get: function() {
  89669. return this._texture
  89670. },
  89671. set: function(i) {
  89672. var o = this, s;
  89673. if (this._texture !== i) {
  89674. var c = (s = i == null ? void 0 : i.getScene()) !== null && s !== void 0 ? s : Engine.LastCreatedScene;
  89675. !i && c && c.markAllMaterialsAsDirty(1, function(d) {
  89676. return d.hasTexture(o._texture)
  89677. }),
  89678. this._texture = i,
  89679. i && c && c.markAllMaterialsAsDirty(1, function(d) {
  89680. return d.hasTexture(i)
  89681. })
  89682. }
  89683. },
  89684. enumerable: !1,
  89685. configurable: !0
  89686. }),
  89687. Object.defineProperty(e.prototype, "samplerName", {
  89688. get: function() {
  89689. return this._samplerName
  89690. },
  89691. enumerable: !1,
  89692. configurable: !0
  89693. }),
  89694. e.prototype.bind = function(i, o, s) {
  89695. !this.texture || i.setTexture(this._samplerName, this.texture)
  89696. }
  89697. ,
  89698. e.prototype.isReady = function() {
  89699. return !(this.texture && !this.texture.isReadyOrNotBlocking())
  89700. }
  89701. ,
  89702. e.prototype.getClassName = function() {
  89703. return "ImageSourceBlock"
  89704. }
  89705. ,
  89706. Object.defineProperty(e.prototype, "source", {
  89707. get: function() {
  89708. return this._outputs[0]
  89709. },
  89710. enumerable: !1,
  89711. configurable: !0
  89712. }),
  89713. e.prototype._buildBlock = function(i) {
  89714. return a.prototype._buildBlock.call(this, i),
  89715. i.target === NodeMaterialBlockTargets.Vertex && (this._samplerName = i._getFreeVariableName(this.name + "Sampler"),
  89716. i.sharedData.blockingBlocks.push(this),
  89717. i.sharedData.textureBlocks.push(this),
  89718. i.sharedData.bindableBlocks.push(this)),
  89719. i._emit2DSampler(this._samplerName),
  89720. this
  89721. }
  89722. ,
  89723. e.prototype._dumpPropertiesCode = function() {
  89724. var i = a.prototype._dumpPropertiesCode.call(this);
  89725. return this.texture && (i += this._codeVariableName + '.texture = new BABYLON.Texture("' + this.texture.name + '", null, ' + this.texture.noMipmap + ", " + this.texture.invertY + ", " + this.texture.samplingMode + `);\r
  89726. `,
  89727. i += this._codeVariableName + ".texture.wrapU = " + this.texture.wrapU + `;\r
  89728. `,
  89729. i += this._codeVariableName + ".texture.wrapV = " + this.texture.wrapV + `;\r
  89730. `,
  89731. i += this._codeVariableName + ".texture.uAng = " + this.texture.uAng + `;\r
  89732. `,
  89733. i += this._codeVariableName + ".texture.vAng = " + this.texture.vAng + `;\r
  89734. `,
  89735. i += this._codeVariableName + ".texture.wAng = " + this.texture.wAng + `;\r
  89736. `,
  89737. i += this._codeVariableName + ".texture.uOffset = " + this.texture.uOffset + `;\r
  89738. `,
  89739. i += this._codeVariableName + ".texture.vOffset = " + this.texture.vOffset + `;\r
  89740. `,
  89741. i += this._codeVariableName + ".texture.uScale = " + this.texture.uScale + `;\r
  89742. `,
  89743. i += this._codeVariableName + ".texture.vScale = " + this.texture.vScale + `;\r
  89744. `,
  89745. i += this._codeVariableName + ".texture.coordinatesMode = " + this.texture.coordinatesMode + `;\r
  89746. `),
  89747. i
  89748. }
  89749. ,
  89750. e.prototype.serialize = function() {
  89751. var i = a.prototype.serialize.call(this);
  89752. return this.texture && !this.texture.isRenderTarget && this.texture.getClassName() !== "VideoTexture" && (i.texture = this.texture.serialize()),
  89753. i
  89754. }
  89755. ,
  89756. e.prototype._deserialize = function(i, o, s) {
  89757. a.prototype._deserialize.call(this, i, o, s),
  89758. i.texture && !NodeMaterial.IgnoreTexturesAtLoadTime && i.texture.url !== void 0 && (s = i.texture.url.indexOf("data:") === 0 ? "" : s,
  89759. this.texture = Texture.Parse(i.texture, o, s))
  89760. }
  89761. ,
  89762. e
  89763. }(NodeMaterialBlock);
  89764. RegisterClass("BABYLON.ImageSourceBlock", ImageSourceBlock);
  89765. var TextureBlock = function(a) {
  89766. __extends(e, a);
  89767. function e(i, o) {
  89768. o === void 0 && (o = !1);
  89769. var s = a.call(this, i, o ? NodeMaterialBlockTargets.Fragment : NodeMaterialBlockTargets.VertexAndFragment) || this;
  89770. return s.convertToGammaSpace = !1,
  89771. s.convertToLinearSpace = !1,
  89772. s.disableLevelMultiplication = !1,
  89773. s._fragmentOnly = o,
  89774. s.registerInput("uv", NodeMaterialBlockConnectionPointTypes.Vector2, !1, NodeMaterialBlockTargets.VertexAndFragment),
  89775. s.registerInput("source", NodeMaterialBlockConnectionPointTypes.Object, !0, NodeMaterialBlockTargets.VertexAndFragment, new NodeMaterialConnectionPointCustomObject("source",s,NodeMaterialConnectionPointDirection.Input,ImageSourceBlock,"ImageSourceBlock")),
  89776. s.registerOutput("rgba", NodeMaterialBlockConnectionPointTypes.Color4, NodeMaterialBlockTargets.Neutral),
  89777. s.registerOutput("rgb", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Neutral),
  89778. s.registerOutput("r", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Neutral),
  89779. s.registerOutput("g", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Neutral),
  89780. s.registerOutput("b", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Neutral),
  89781. s.registerOutput("a", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Neutral),
  89782. s.registerOutput("level", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Neutral),
  89783. s._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector3),
  89784. s._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector4),
  89785. s._inputs[0]._prioritizeVertex = !o,
  89786. s
  89787. }
  89788. return Object.defineProperty(e.prototype, "texture", {
  89789. get: function() {
  89790. var i;
  89791. return this.source.isConnected ? ((i = this.source.connectedPoint) === null || i === void 0 ? void 0 : i.ownerBlock).texture : this._texture
  89792. },
  89793. set: function(i) {
  89794. var o = this, s;
  89795. if (this._texture !== i) {
  89796. var c = (s = i == null ? void 0 : i.getScene()) !== null && s !== void 0 ? s : Engine.LastCreatedScene;
  89797. !i && c && c.markAllMaterialsAsDirty(1, function(d) {
  89798. return d.hasTexture(o._texture)
  89799. }),
  89800. this._texture = i,
  89801. i && c && c.markAllMaterialsAsDirty(1, function(d) {
  89802. return d.hasTexture(i)
  89803. })
  89804. }
  89805. },
  89806. enumerable: !1,
  89807. configurable: !0
  89808. }),
  89809. Object.defineProperty(e.prototype, "samplerName", {
  89810. get: function() {
  89811. return this._imageSource ? this._imageSource.samplerName : this._samplerName
  89812. },
  89813. enumerable: !1,
  89814. configurable: !0
  89815. }),
  89816. Object.defineProperty(e.prototype, "hasImageSource", {
  89817. get: function() {
  89818. return !!this._imageSource
  89819. },
  89820. enumerable: !1,
  89821. configurable: !0
  89822. }),
  89823. e.prototype.getClassName = function() {
  89824. return "TextureBlock"
  89825. }
  89826. ,
  89827. Object.defineProperty(e.prototype, "uv", {
  89828. get: function() {
  89829. return this._inputs[0]
  89830. },
  89831. enumerable: !1,
  89832. configurable: !0
  89833. }),
  89834. Object.defineProperty(e.prototype, "source", {
  89835. get: function() {
  89836. return this._inputs[1]
  89837. },
  89838. enumerable: !1,
  89839. configurable: !0
  89840. }),
  89841. Object.defineProperty(e.prototype, "rgba", {
  89842. get: function() {
  89843. return this._outputs[0]
  89844. },
  89845. enumerable: !1,
  89846. configurable: !0
  89847. }),
  89848. Object.defineProperty(e.prototype, "rgb", {
  89849. get: function() {
  89850. return this._outputs[1]
  89851. },
  89852. enumerable: !1,
  89853. configurable: !0
  89854. }),
  89855. Object.defineProperty(e.prototype, "r", {
  89856. get: function() {
  89857. return this._outputs[2]
  89858. },
  89859. enumerable: !1,
  89860. configurable: !0
  89861. }),
  89862. Object.defineProperty(e.prototype, "g", {
  89863. get: function() {
  89864. return this._outputs[3]
  89865. },
  89866. enumerable: !1,
  89867. configurable: !0
  89868. }),
  89869. Object.defineProperty(e.prototype, "b", {
  89870. get: function() {
  89871. return this._outputs[4]
  89872. },
  89873. enumerable: !1,
  89874. configurable: !0
  89875. }),
  89876. Object.defineProperty(e.prototype, "a", {
  89877. get: function() {
  89878. return this._outputs[5]
  89879. },
  89880. enumerable: !1,
  89881. configurable: !0
  89882. }),
  89883. Object.defineProperty(e.prototype, "level", {
  89884. get: function() {
  89885. return this._outputs[6]
  89886. },
  89887. enumerable: !1,
  89888. configurable: !0
  89889. }),
  89890. Object.defineProperty(e.prototype, "target", {
  89891. get: function() {
  89892. if (this._fragmentOnly)
  89893. return NodeMaterialBlockTargets.Fragment;
  89894. if (!this.uv.isConnected || this.uv.sourceBlock.isInput)
  89895. return NodeMaterialBlockTargets.VertexAndFragment;
  89896. for (var i = this.uv.connectedPoint; i; ) {
  89897. if (i.target === NodeMaterialBlockTargets.Fragment)
  89898. return NodeMaterialBlockTargets.Fragment;
  89899. if (i.target === NodeMaterialBlockTargets.Vertex)
  89900. return NodeMaterialBlockTargets.VertexAndFragment;
  89901. if (i.target === NodeMaterialBlockTargets.Neutral || i.target === NodeMaterialBlockTargets.VertexAndFragment) {
  89902. var o = i.ownerBlock;
  89903. if (o.target === NodeMaterialBlockTargets.Fragment)
  89904. return NodeMaterialBlockTargets.Fragment;
  89905. i = null;
  89906. for (var s = 0, c = o.inputs; s < c.length; s++) {
  89907. var d = c[s];
  89908. if (d.connectedPoint) {
  89909. i = d.connectedPoint;
  89910. break
  89911. }
  89912. }
  89913. }
  89914. }
  89915. return NodeMaterialBlockTargets.VertexAndFragment
  89916. },
  89917. set: function(i) {},
  89918. enumerable: !1,
  89919. configurable: !0
  89920. }),
  89921. e.prototype.autoConfigure = function(i) {
  89922. if (!this.uv.isConnected)
  89923. if (i.mode === NodeMaterialModes.PostProcess) {
  89924. var o = i.getBlockByPredicate(function(c) {
  89925. return c.name === "uv"
  89926. });
  89927. o && o.connectTo(this)
  89928. } else {
  89929. var s = i.mode === NodeMaterialModes.Particle ? "particle_uv" : "uv"
  89930. , o = i.getInputBlockByPredicate(function(d) {
  89931. return d.isAttribute && d.name === s
  89932. });
  89933. o || (o = new InputBlock("uv"),
  89934. o.setAsAttribute(s)),
  89935. o.output.connectTo(this.uv)
  89936. }
  89937. }
  89938. ,
  89939. e.prototype.initializeDefines = function(i, o, s, c) {
  89940. !s._areTexturesDirty || this._mainUVDefineName !== void 0 && s.setValue(this._mainUVDefineName, !1, !0)
  89941. }
  89942. ,
  89943. e.prototype.prepareDefines = function(i, o, s) {
  89944. if (!!s._areTexturesDirty) {
  89945. if (!this.texture || !this.texture.getTextureMatrix) {
  89946. this._isMixed && (s.setValue(this._defineName, !1, !0),
  89947. s.setValue(this._mainUVDefineName, !0, !0));
  89948. return
  89949. }
  89950. s.setValue(this._linearDefineName, this.convertToGammaSpace, !0),
  89951. s.setValue(this._gammaDefineName, this.convertToLinearSpace, !0),
  89952. this._isMixed && (this.texture.getTextureMatrix().isIdentityAs3x2() ? (s.setValue(this._defineName, !1, !0),
  89953. s.setValue(this._mainUVDefineName, !0, !0)) : (s.setValue(this._defineName, !0),
  89954. s[this._mainUVDefineName] == null && s.setValue(this._mainUVDefineName, !1, !0)))
  89955. }
  89956. }
  89957. ,
  89958. e.prototype.isReady = function() {
  89959. return !(this.texture && !this.texture.isReadyOrNotBlocking())
  89960. }
  89961. ,
  89962. e.prototype.bind = function(i, o, s) {
  89963. !this.texture || (this._isMixed && (i.setFloat(this._textureInfoName, this.texture.level),
  89964. i.setMatrix(this._textureTransformName, this.texture.getTextureMatrix())),
  89965. this._imageSource || i.setTexture(this._samplerName, this.texture))
  89966. }
  89967. ,
  89968. Object.defineProperty(e.prototype, "_isMixed", {
  89969. get: function() {
  89970. return this.target !== NodeMaterialBlockTargets.Fragment
  89971. },
  89972. enumerable: !1,
  89973. configurable: !0
  89974. }),
  89975. e.prototype._injectVertexCode = function(i) {
  89976. var o = this.uv;
  89977. if (this._defineName = i._getFreeDefineName("UVTRANSFORM"),
  89978. this._mainUVDefineName = "VMAIN" + o.associatedVariableName.toUpperCase(),
  89979. this._mainUVName = "vMain" + o.associatedVariableName,
  89980. this._transformedUVName = i._getFreeVariableName("transformedUV"),
  89981. this._textureTransformName = i._getFreeVariableName("textureTransform"),
  89982. this._textureInfoName = i._getFreeVariableName("textureInfoName"),
  89983. this.level.associatedVariableName = this._textureInfoName,
  89984. i._emitVaryingFromString(this._transformedUVName, "vec2", this._defineName),
  89985. i._emitVaryingFromString(this._mainUVName, "vec2", this._mainUVDefineName),
  89986. i._emitUniformFromString(this._textureTransformName, "mat4", this._defineName),
  89987. i.compilationString += "#ifdef " + this._defineName + `\r
  89988. `,
  89989. i.compilationString += this._transformedUVName + " = vec2(" + this._textureTransformName + " * vec4(" + o.associatedVariableName + `.xy, 1.0, 0.0));\r
  89990. `,
  89991. i.compilationString += "#elif defined(" + this._mainUVDefineName + `)\r
  89992. `,
  89993. i.compilationString += this._mainUVName + " = " + o.associatedVariableName + `.xy;\r
  89994. `,
  89995. i.compilationString += `#endif\r
  89996. `,
  89997. !!this._outputs.some(function(_) {
  89998. return _.isConnectedInVertexShader
  89999. })) {
  90000. this._writeTextureRead(i, !0);
  90001. for (var s = 0, c = this._outputs; s < c.length; s++) {
  90002. var d = c[s];
  90003. d.hasEndpoints && d.name !== "level" && this._writeOutput(i, d, d.name, !0)
  90004. }
  90005. }
  90006. }
  90007. ,
  90008. e.prototype._generateTextureLookup = function(i) {
  90009. var o = this.samplerName;
  90010. i.compilationString += "#ifdef " + this._defineName + `\r
  90011. `,
  90012. i.compilationString += "vec4 " + this._tempTextureRead + " = texture2D(" + o + ", " + this._transformedUVName + `);\r
  90013. `,
  90014. i.compilationString += "#elif defined(" + this._mainUVDefineName + `)\r
  90015. `,
  90016. i.compilationString += "vec4 " + this._tempTextureRead + " = texture2D(" + o + ", " + (this._mainUVName ? this._mainUVName : this.uv.associatedVariableName) + `);\r
  90017. `,
  90018. i.compilationString += `#endif\r
  90019. `
  90020. }
  90021. ,
  90022. e.prototype._writeTextureRead = function(i, o) {
  90023. o === void 0 && (o = !1);
  90024. var s = this.uv;
  90025. if (o) {
  90026. if (i.target === NodeMaterialBlockTargets.Fragment)
  90027. return;
  90028. this._generateTextureLookup(i);
  90029. return
  90030. }
  90031. if (this.uv.ownerBlock.target === NodeMaterialBlockTargets.Fragment) {
  90032. i.compilationString += "vec4 " + this._tempTextureRead + " = texture2D(" + this.samplerName + ", " + s.associatedVariableName + `);\r
  90033. `;
  90034. return
  90035. }
  90036. this._generateTextureLookup(i)
  90037. }
  90038. ,
  90039. e.prototype._generateConversionCode = function(i, o, s) {
  90040. s !== "a" && ((!this.texture || !this.texture.gammaSpace) && (i.compilationString += "#ifdef " + this._linearDefineName + `
  90041. ` + o.associatedVariableName + " = toGammaSpace(" + o.associatedVariableName + `);
  90042. #endif
  90043. `),
  90044. (!this.texture || this.texture.gammaSpace) && (i.compilationString += "#ifdef " + this._gammaDefineName + `
  90045. ` + o.associatedVariableName + " = toLinearSpace(" + o.associatedVariableName + `);
  90046. #endif
  90047. `))
  90048. }
  90049. ,
  90050. e.prototype._writeOutput = function(i, o, s, c) {
  90051. if (c === void 0 && (c = !1),
  90052. c) {
  90053. if (i.target === NodeMaterialBlockTargets.Fragment)
  90054. return;
  90055. i.compilationString += this._declareOutput(o, i) + " = " + this._tempTextureRead + "." + s + `;\r
  90056. `,
  90057. this._generateConversionCode(i, o, s);
  90058. return
  90059. }
  90060. if (this.uv.ownerBlock.target === NodeMaterialBlockTargets.Fragment) {
  90061. i.compilationString += this._declareOutput(o, i) + " = " + this._tempTextureRead + "." + s + `;\r
  90062. `,
  90063. this._generateConversionCode(i, o, s);
  90064. return
  90065. }
  90066. var d = "";
  90067. this.disableLevelMultiplication || (d = " * " + this._textureInfoName),
  90068. i.compilationString += this._declareOutput(o, i) + " = " + this._tempTextureRead + "." + s + d + `;\r
  90069. `,
  90070. this._generateConversionCode(i, o, s)
  90071. }
  90072. ,
  90073. e.prototype._buildBlock = function(i) {
  90074. if (a.prototype._buildBlock.call(this, i),
  90075. this.source.isConnected ? this._imageSource = this.source.connectedPoint.ownerBlock : this._imageSource = null,
  90076. (i.target === NodeMaterialBlockTargets.Vertex || this._fragmentOnly || i.target === NodeMaterialBlockTargets.Fragment && this._tempTextureRead === void 0) && (this._tempTextureRead = i._getFreeVariableName("tempTextureRead"),
  90077. this._linearDefineName = i._getFreeDefineName("ISLINEAR"),
  90078. this._gammaDefineName = i._getFreeDefineName("ISGAMMA")),
  90079. (!this._isMixed && i.target === NodeMaterialBlockTargets.Fragment || this._isMixed && i.target === NodeMaterialBlockTargets.Vertex) && (this._imageSource || (this._samplerName = i._getFreeVariableName(this.name + "Sampler"),
  90080. i._emit2DSampler(this._samplerName)),
  90081. i.sharedData.blockingBlocks.push(this),
  90082. i.sharedData.textureBlocks.push(this),
  90083. i.sharedData.blocksWithDefines.push(this),
  90084. i.sharedData.bindableBlocks.push(this)),
  90085. i.target !== NodeMaterialBlockTargets.Fragment) {
  90086. this._injectVertexCode(i);
  90087. return
  90088. }
  90089. if (!!this._outputs.some(function(_) {
  90090. return _.isConnectedInFragmentShader
  90091. })) {
  90092. this._isMixed && !this._imageSource && i._emit2DSampler(this._samplerName);
  90093. var o = "//" + this.name;
  90094. i._emitFunctionFromInclude("helperFunctions", o),
  90095. this._isMixed && i._emitUniformFromString(this._textureInfoName, "float"),
  90096. this._writeTextureRead(i);
  90097. for (var s = 0, c = this._outputs; s < c.length; s++) {
  90098. var d = c[s];
  90099. d.hasEndpoints && d.name !== "level" && this._writeOutput(i, d, d.name)
  90100. }
  90101. return this
  90102. }
  90103. }
  90104. ,
  90105. e.prototype._dumpPropertiesCode = function() {
  90106. var i = a.prototype._dumpPropertiesCode.call(this);
  90107. return i += this._codeVariableName + ".convertToGammaSpace = " + this.convertToGammaSpace + `;\r
  90108. `,
  90109. i += this._codeVariableName + ".convertToLinearSpace = " + this.convertToLinearSpace + `;\r
  90110. `,
  90111. i += this._codeVariableName + ".disableLevelMultiplication = " + this.disableLevelMultiplication + `;\r
  90112. `,
  90113. this.texture && (i += this._codeVariableName + '.texture = new BABYLON.Texture("' + this.texture.name + '", null, ' + this.texture.noMipmap + ", " + this.texture.invertY + ", " + this.texture.samplingMode + `);\r
  90114. `,
  90115. i += this._codeVariableName + ".texture.wrapU = " + this.texture.wrapU + `;\r
  90116. `,
  90117. i += this._codeVariableName + ".texture.wrapV = " + this.texture.wrapV + `;\r
  90118. `,
  90119. i += this._codeVariableName + ".texture.uAng = " + this.texture.uAng + `;\r
  90120. `,
  90121. i += this._codeVariableName + ".texture.vAng = " + this.texture.vAng + `;\r
  90122. `,
  90123. i += this._codeVariableName + ".texture.wAng = " + this.texture.wAng + `;\r
  90124. `,
  90125. i += this._codeVariableName + ".texture.uOffset = " + this.texture.uOffset + `;\r
  90126. `,
  90127. i += this._codeVariableName + ".texture.vOffset = " + this.texture.vOffset + `;\r
  90128. `,
  90129. i += this._codeVariableName + ".texture.uScale = " + this.texture.uScale + `;\r
  90130. `,
  90131. i += this._codeVariableName + ".texture.vScale = " + this.texture.vScale + `;\r
  90132. `,
  90133. i += this._codeVariableName + ".texture.coordinatesMode = " + this.texture.coordinatesMode + `;\r
  90134. `),
  90135. i
  90136. }
  90137. ,
  90138. e.prototype.serialize = function() {
  90139. var i = a.prototype.serialize.call(this);
  90140. return i.convertToGammaSpace = this.convertToGammaSpace,
  90141. i.convertToLinearSpace = this.convertToLinearSpace,
  90142. i.fragmentOnly = this._fragmentOnly,
  90143. i.disableLevelMultiplication = this.disableLevelMultiplication,
  90144. !this.hasImageSource && this.texture && !this.texture.isRenderTarget && this.texture.getClassName() !== "VideoTexture" && (i.texture = this.texture.serialize()),
  90145. i
  90146. }
  90147. ,
  90148. e.prototype._deserialize = function(i, o, s) {
  90149. a.prototype._deserialize.call(this, i, o, s),
  90150. this.convertToGammaSpace = i.convertToGammaSpace,
  90151. this.convertToLinearSpace = !!i.convertToLinearSpace,
  90152. this._fragmentOnly = !!i.fragmentOnly,
  90153. this.disableLevelMultiplication = !!i.disableLevelMultiplication,
  90154. i.texture && !NodeMaterial.IgnoreTexturesAtLoadTime && i.texture.url !== void 0 && (s = i.texture.url.indexOf("data:") === 0 ? "" : s,
  90155. this.texture = Texture.Parse(i.texture, o, s))
  90156. }
  90157. ,
  90158. e
  90159. }(NodeMaterialBlock);
  90160. RegisterClass("BABYLON.TextureBlock", TextureBlock);
  90161. var ReflectionTextureBaseBlock = function(a) {
  90162. __extends(e, a);
  90163. function e(i) {
  90164. return a.call(this, i, NodeMaterialBlockTargets.VertexAndFragment) || this
  90165. }
  90166. return Object.defineProperty(e.prototype, "texture", {
  90167. get: function() {
  90168. return this._texture
  90169. },
  90170. set: function(i) {
  90171. var o = this, s;
  90172. if (this._texture !== i) {
  90173. var c = (s = i == null ? void 0 : i.getScene()) !== null && s !== void 0 ? s : Engine.LastCreatedScene;
  90174. !i && c && c.markAllMaterialsAsDirty(1, function(d) {
  90175. return d.hasTexture(o._texture)
  90176. }),
  90177. this._texture = i,
  90178. i && c && c.markAllMaterialsAsDirty(1, function(d) {
  90179. return d.hasTexture(i)
  90180. })
  90181. }
  90182. },
  90183. enumerable: !1,
  90184. configurable: !0
  90185. }),
  90186. e.prototype.getClassName = function() {
  90187. return "ReflectionTextureBaseBlock"
  90188. }
  90189. ,
  90190. e.prototype._getTexture = function() {
  90191. return this.texture
  90192. }
  90193. ,
  90194. e.prototype.autoConfigure = function(i) {
  90195. if (!this.position.isConnected) {
  90196. var o = i.getInputBlockByPredicate(function(d) {
  90197. return d.isAttribute && d.name === "position"
  90198. });
  90199. o || (o = new InputBlock("position"),
  90200. o.setAsAttribute()),
  90201. o.output.connectTo(this.position)
  90202. }
  90203. if (!this.world.isConnected) {
  90204. var s = i.getInputBlockByPredicate(function(d) {
  90205. return d.systemValue === NodeMaterialSystemValues.World
  90206. });
  90207. s || (s = new InputBlock("world"),
  90208. s.setAsSystemValue(NodeMaterialSystemValues.World)),
  90209. s.output.connectTo(this.world)
  90210. }
  90211. if (this.view && !this.view.isConnected) {
  90212. var c = i.getInputBlockByPredicate(function(d) {
  90213. return d.systemValue === NodeMaterialSystemValues.View
  90214. });
  90215. c || (c = new InputBlock("view"),
  90216. c.setAsSystemValue(NodeMaterialSystemValues.View)),
  90217. c.output.connectTo(this.view)
  90218. }
  90219. }
  90220. ,
  90221. e.prototype.prepareDefines = function(i, o, s) {
  90222. if (!!s._areTexturesDirty) {
  90223. var c = this._getTexture();
  90224. !c || !c.getTextureMatrix || (s.setValue(this._define3DName, c.isCube, !0),
  90225. s.setValue(this._defineLocalCubicName, !!c.boundingBoxSize, !0),
  90226. s.setValue(this._defineExplicitName, c.coordinatesMode === 0, !0),
  90227. s.setValue(this._defineSkyboxName, c.coordinatesMode === 5, !0),
  90228. s.setValue(this._defineCubicName, c.coordinatesMode === 3 || c.coordinatesMode === 6, !0),
  90229. s.setValue("INVERTCUBICMAP", c.coordinatesMode === 6, !0),
  90230. s.setValue(this._defineSphericalName, c.coordinatesMode === 1, !0),
  90231. s.setValue(this._definePlanarName, c.coordinatesMode === 2, !0),
  90232. s.setValue(this._defineProjectionName, c.coordinatesMode === 4, !0),
  90233. s.setValue(this._defineEquirectangularName, c.coordinatesMode === 7, !0),
  90234. s.setValue(this._defineEquirectangularFixedName, c.coordinatesMode === 8, !0),
  90235. s.setValue(this._defineMirroredEquirectangularFixedName, c.coordinatesMode === 9, !0))
  90236. }
  90237. }
  90238. ,
  90239. e.prototype.isReady = function() {
  90240. var i = this._getTexture();
  90241. return !(i && !i.isReadyOrNotBlocking())
  90242. }
  90243. ,
  90244. e.prototype.bind = function(i, o, s) {
  90245. var c = this._getTexture();
  90246. if (!(!s || !c) && (i.setMatrix(this._reflectionMatrixName, c.getReflectionTextureMatrix()),
  90247. c.isCube ? i.setTexture(this._cubeSamplerName, c) : i.setTexture(this._2DSamplerName, c),
  90248. c.boundingBoxSize)) {
  90249. var d = c;
  90250. i.setVector3(this._reflectionPositionName, d.boundingBoxPosition),
  90251. i.setVector3(this._reflectionSizeName, d.boundingBoxSize)
  90252. }
  90253. }
  90254. ,
  90255. e.prototype.handleVertexSide = function(i) {
  90256. this._define3DName = i._getFreeDefineName("REFLECTIONMAP_3D"),
  90257. this._defineCubicName = i._getFreeDefineName("REFLECTIONMAP_CUBIC"),
  90258. this._defineSphericalName = i._getFreeDefineName("REFLECTIONMAP_SPHERICAL"),
  90259. this._definePlanarName = i._getFreeDefineName("REFLECTIONMAP_PLANAR"),
  90260. this._defineProjectionName = i._getFreeDefineName("REFLECTIONMAP_PROJECTION"),
  90261. this._defineExplicitName = i._getFreeDefineName("REFLECTIONMAP_EXPLICIT"),
  90262. this._defineEquirectangularName = i._getFreeDefineName("REFLECTIONMAP_EQUIRECTANGULAR"),
  90263. this._defineLocalCubicName = i._getFreeDefineName("USE_LOCAL_REFLECTIONMAP_CUBIC"),
  90264. this._defineMirroredEquirectangularFixedName = i._getFreeDefineName("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"),
  90265. this._defineEquirectangularFixedName = i._getFreeDefineName("REFLECTIONMAP_EQUIRECTANGULAR_FIXED"),
  90266. this._defineSkyboxName = i._getFreeDefineName("REFLECTIONMAP_SKYBOX"),
  90267. this._defineOppositeZ = i._getFreeDefineName("REFLECTIONMAP_OPPOSITEZ"),
  90268. this._reflectionMatrixName = i._getFreeVariableName("reflectionMatrix"),
  90269. i._emitUniformFromString(this._reflectionMatrixName, "mat4");
  90270. var o = ""
  90271. , s = "v_" + this.worldPosition.associatedVariableName;
  90272. return i._emitVaryingFromString(s, "vec4") && (o += s + " = " + this.worldPosition.associatedVariableName + `;\r
  90273. `),
  90274. this._positionUVWName = i._getFreeVariableName("positionUVW"),
  90275. this._directionWName = i._getFreeVariableName("directionW"),
  90276. i._emitVaryingFromString(this._positionUVWName, "vec3", this._defineSkyboxName) && (o += "#ifdef " + this._defineSkyboxName + `\r
  90277. `,
  90278. o += this._positionUVWName + " = " + this.position.associatedVariableName + `.xyz;\r
  90279. `,
  90280. o += `#endif\r
  90281. `),
  90282. i._emitVaryingFromString(this._directionWName, "vec3", "defined(" + this._defineEquirectangularFixedName + ") || defined(" + this._defineMirroredEquirectangularFixedName + ")") && (o += "#if defined(" + this._defineEquirectangularFixedName + ") || defined(" + this._defineMirroredEquirectangularFixedName + `)\r
  90283. `,
  90284. o += this._directionWName + " = normalize(vec3(" + this.world.associatedVariableName + " * vec4(" + this.position.associatedVariableName + `.xyz, 0.0)));\r
  90285. `,
  90286. o += `#endif\r
  90287. `),
  90288. o
  90289. }
  90290. ,
  90291. e.prototype.handleFragmentSideInits = function(i) {
  90292. i.sharedData.blockingBlocks.push(this),
  90293. i.sharedData.textureBlocks.push(this),
  90294. this._cubeSamplerName = i._getFreeVariableName(this.name + "CubeSampler"),
  90295. i.samplers.push(this._cubeSamplerName),
  90296. this._2DSamplerName = i._getFreeVariableName(this.name + "2DSampler"),
  90297. i.samplers.push(this._2DSamplerName),
  90298. i._samplerDeclaration += "#ifdef " + this._define3DName + `\r
  90299. `,
  90300. i._samplerDeclaration += "uniform samplerCube " + this._cubeSamplerName + `;\r
  90301. `,
  90302. i._samplerDeclaration += `#else\r
  90303. `,
  90304. i._samplerDeclaration += "uniform sampler2D " + this._2DSamplerName + `;\r
  90305. `,
  90306. i._samplerDeclaration += `#endif\r
  90307. `,
  90308. i.sharedData.blocksWithDefines.push(this),
  90309. i.sharedData.bindableBlocks.push(this);
  90310. var o = "//" + this.name;
  90311. i._emitFunction("ReciprocalPI", "#define RECIPROCAL_PI2 0.15915494", ""),
  90312. i._emitFunctionFromInclude("helperFunctions", o),
  90313. i._emitFunctionFromInclude("reflectionFunction", o, {
  90314. replaceStrings: [{
  90315. search: /vec3 computeReflectionCoords/g,
  90316. replace: "void DUMMYFUNC"
  90317. }]
  90318. }),
  90319. this._reflectionColorName = i._getFreeVariableName("reflectionColor"),
  90320. this._reflectionVectorName = i._getFreeVariableName("reflectionUVW"),
  90321. this._reflectionCoordsName = i._getFreeVariableName("reflectionCoords"),
  90322. this._reflectionPositionName = i._getFreeVariableName("vReflectionPosition"),
  90323. i._emitUniformFromString(this._reflectionPositionName, "vec3"),
  90324. this._reflectionSizeName = i._getFreeVariableName("vReflectionPosition"),
  90325. i._emitUniformFromString(this._reflectionSizeName, "vec3")
  90326. }
  90327. ,
  90328. e.prototype.handleFragmentSideCodeReflectionCoords = function(i, o, s) {
  90329. s === void 0 && (s = !1),
  90330. o || (o = "v_" + this.worldPosition.associatedVariableName);
  90331. var c = this._reflectionMatrixName
  90332. , d = "normalize(" + this._directionWName + ")"
  90333. , _ = "" + this._positionUVWName
  90334. , b = "" + this.cameraPosition.associatedVariableName
  90335. , k = "" + this.view.associatedVariableName;
  90336. i += ".xyz";
  90337. var j = `
  90338. #ifdef ` + this._defineMirroredEquirectangularFixedName + `
  90339. vec3 ` + this._reflectionVectorName + " = computeMirroredFixedEquirectangularCoords(" + o + ", " + i + ", " + d + `);
  90340. #endif
  90341. #ifdef ` + this._defineEquirectangularFixedName + `
  90342. vec3 ` + this._reflectionVectorName + " = computeFixedEquirectangularCoords(" + o + ", " + i + ", " + d + `);
  90343. #endif
  90344. #ifdef ` + this._defineEquirectangularName + `
  90345. vec3 ` + this._reflectionVectorName + " = computeEquirectangularCoords(" + o + ", " + i + ", " + b + ".xyz, " + c + `);
  90346. #endif
  90347. #ifdef ` + this._defineSphericalName + `
  90348. vec3 ` + this._reflectionVectorName + " = computeSphericalCoords(" + o + ", " + i + ", " + k + ", " + c + `);
  90349. #endif
  90350. #ifdef ` + this._definePlanarName + `
  90351. vec3 ` + this._reflectionVectorName + " = computePlanarCoords(" + o + ", " + i + ", " + b + ".xyz, " + c + `);
  90352. #endif
  90353. #ifdef ` + this._defineCubicName + `
  90354. #ifdef ` + this._defineLocalCubicName + `
  90355. vec3 ` + this._reflectionVectorName + " = computeCubicLocalCoords(" + o + ", " + i + ", " + b + ".xyz, " + c + ", " + this._reflectionSizeName + ", " + this._reflectionPositionName + `);
  90356. #else
  90357. vec3 ` + this._reflectionVectorName + " = computeCubicCoords(" + o + ", " + i + ", " + b + ".xyz, " + c + `);
  90358. #endif
  90359. #endif
  90360. #ifdef ` + this._defineProjectionName + `
  90361. vec3 ` + this._reflectionVectorName + " = computeProjectionCoords(" + o + ", " + k + ", " + c + `);
  90362. #endif
  90363. #ifdef ` + this._defineSkyboxName + `
  90364. vec3 ` + this._reflectionVectorName + " = computeSkyBoxCoords(" + _ + ", " + c + `);
  90365. #endif
  90366. #ifdef ` + this._defineExplicitName + `
  90367. vec3 ` + this._reflectionVectorName + ` = vec3(0, 0, 0);
  90368. #endif
  90369. #ifdef ` + this._defineOppositeZ + `
  90370. ` + this._reflectionVectorName + `.z *= -1.0;
  90371. #endif\r
  90372. `;
  90373. return s || (j += `
  90374. #ifdef ` + this._define3DName + `
  90375. vec3 ` + this._reflectionCoordsName + " = " + this._reflectionVectorName + `;
  90376. #else
  90377. vec2 ` + this._reflectionCoordsName + " = " + this._reflectionVectorName + `.xy;
  90378. #ifdef ` + this._defineProjectionName + `
  90379. ` + this._reflectionCoordsName + " /= " + this._reflectionVectorName + `.z;
  90380. #endif
  90381. ` + this._reflectionCoordsName + ".y = 1.0 - " + this._reflectionCoordsName + `.y;
  90382. #endif\r
  90383. `),
  90384. j
  90385. }
  90386. ,
  90387. e.prototype.handleFragmentSideCodeReflectionColor = function(i, o) {
  90388. o === void 0 && (o = ".rgb");
  90389. var s = "vec" + (o.length === 0 ? "4" : o.length - 1)
  90390. , c = s + " " + this._reflectionColorName + `;
  90391. #ifdef ` + this._define3DName + `\r
  90392. `;
  90393. return i ? c += this._reflectionColorName + " = textureCubeLodEXT(" + this._cubeSamplerName + ", " + this._reflectionVectorName + ", " + i + ")" + o + `;\r
  90394. ` : c += this._reflectionColorName + " = textureCube(" + this._cubeSamplerName + ", " + this._reflectionVectorName + ")" + o + `;\r
  90395. `,
  90396. c += `
  90397. #else\r
  90398. `,
  90399. i ? c += this._reflectionColorName + " = texture2DLodEXT(" + this._2DSamplerName + ", " + this._reflectionCoordsName + ", " + i + ")" + o + `;\r
  90400. ` : c += this._reflectionColorName + " = texture2D(" + this._2DSamplerName + ", " + this._reflectionCoordsName + ")" + o + `;\r
  90401. `,
  90402. c += `#endif\r
  90403. `,
  90404. c
  90405. }
  90406. ,
  90407. e.prototype.writeOutputs = function(i, o) {
  90408. var s = "";
  90409. if (i.target === NodeMaterialBlockTargets.Fragment)
  90410. for (var c = 0, d = this._outputs; c < d.length; c++) {
  90411. var _ = d[c];
  90412. _.hasEndpoints && (s += this._declareOutput(_, i) + " = " + o + "." + _.name + `;\r
  90413. `)
  90414. }
  90415. return s
  90416. }
  90417. ,
  90418. e.prototype._buildBlock = function(i) {
  90419. return a.prototype._buildBlock.call(this, i),
  90420. this
  90421. }
  90422. ,
  90423. e.prototype._dumpPropertiesCode = function() {
  90424. var i = a.prototype._dumpPropertiesCode.call(this);
  90425. if (!this.texture)
  90426. return i;
  90427. if (this.texture.isCube) {
  90428. var o = this.texture.forcedExtension;
  90429. i += this._codeVariableName + '.texture = new BABYLON.CubeTexture("' + this.texture.name + '", undefined, undefined, ' + this.texture.noMipmap + ", null, undefined, undefined, undefined, " + this.texture._prefiltered + ", " + (o ? '"' + o + '"' : "null") + `);\r
  90430. `
  90431. } else
  90432. i += this._codeVariableName + '.texture = new BABYLON.Texture("' + this.texture.name + `", null);\r
  90433. `;
  90434. return i += this._codeVariableName + ".texture.coordinatesMode = " + this.texture.coordinatesMode + `;\r
  90435. `,
  90436. i
  90437. }
  90438. ,
  90439. e.prototype.serialize = function() {
  90440. var i = a.prototype.serialize.call(this);
  90441. return this.texture && !this.texture.isRenderTarget && (i.texture = this.texture.serialize()),
  90442. i
  90443. }
  90444. ,
  90445. e.prototype._deserialize = function(i, o, s) {
  90446. a.prototype._deserialize.call(this, i, o, s),
  90447. i.texture && (s = i.texture.url.indexOf("data:") === 0 ? "" : s,
  90448. i.texture.isCube ? this.texture = CubeTexture.Parse(i.texture, o, s) : this.texture = Texture.Parse(i.texture, o, s))
  90449. }
  90450. ,
  90451. e
  90452. }(NodeMaterialBlock);
  90453. RegisterClass("BABYLON.ReflectionTextureBaseBlock", ReflectionTextureBaseBlock);
  90454. var ReflectionTextureBlock = function(a) {
  90455. __extends(e, a);
  90456. function e(i) {
  90457. var o = a.call(this, i) || this;
  90458. return o.registerInput("position", NodeMaterialBlockConnectionPointTypes.Vector3, !1, NodeMaterialBlockTargets.Vertex),
  90459. o.registerInput("worldPosition", NodeMaterialBlockConnectionPointTypes.Vector4, !1, NodeMaterialBlockTargets.Vertex),
  90460. o.registerInput("worldNormal", NodeMaterialBlockConnectionPointTypes.Vector4, !1, NodeMaterialBlockTargets.Fragment),
  90461. o.registerInput("world", NodeMaterialBlockConnectionPointTypes.Matrix, !1, NodeMaterialBlockTargets.Vertex),
  90462. o.registerInput("cameraPosition", NodeMaterialBlockConnectionPointTypes.Vector3, !1, NodeMaterialBlockTargets.Fragment),
  90463. o.registerInput("view", NodeMaterialBlockConnectionPointTypes.Matrix, !1, NodeMaterialBlockTargets.Fragment),
  90464. o.registerOutput("rgb", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment),
  90465. o.registerOutput("rgba", NodeMaterialBlockConnectionPointTypes.Color4, NodeMaterialBlockTargets.Fragment),
  90466. o.registerOutput("r", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment),
  90467. o.registerOutput("g", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment),
  90468. o.registerOutput("b", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment),
  90469. o.registerOutput("a", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment),
  90470. o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector4),
  90471. o
  90472. }
  90473. return e.prototype.getClassName = function() {
  90474. return "ReflectionTextureBlock"
  90475. }
  90476. ,
  90477. Object.defineProperty(e.prototype, "position", {
  90478. get: function() {
  90479. return this._inputs[0]
  90480. },
  90481. enumerable: !1,
  90482. configurable: !0
  90483. }),
  90484. Object.defineProperty(e.prototype, "worldPosition", {
  90485. get: function() {
  90486. return this._inputs[1]
  90487. },
  90488. enumerable: !1,
  90489. configurable: !0
  90490. }),
  90491. Object.defineProperty(e.prototype, "worldNormal", {
  90492. get: function() {
  90493. return this._inputs[2]
  90494. },
  90495. enumerable: !1,
  90496. configurable: !0
  90497. }),
  90498. Object.defineProperty(e.prototype, "world", {
  90499. get: function() {
  90500. return this._inputs[3]
  90501. },
  90502. enumerable: !1,
  90503. configurable: !0
  90504. }),
  90505. Object.defineProperty(e.prototype, "cameraPosition", {
  90506. get: function() {
  90507. return this._inputs[4]
  90508. },
  90509. enumerable: !1,
  90510. configurable: !0
  90511. }),
  90512. Object.defineProperty(e.prototype, "view", {
  90513. get: function() {
  90514. return this._inputs[5]
  90515. },
  90516. enumerable: !1,
  90517. configurable: !0
  90518. }),
  90519. Object.defineProperty(e.prototype, "rgb", {
  90520. get: function() {
  90521. return this._outputs[0]
  90522. },
  90523. enumerable: !1,
  90524. configurable: !0
  90525. }),
  90526. Object.defineProperty(e.prototype, "rgba", {
  90527. get: function() {
  90528. return this._outputs[1]
  90529. },
  90530. enumerable: !1,
  90531. configurable: !0
  90532. }),
  90533. Object.defineProperty(e.prototype, "r", {
  90534. get: function() {
  90535. return this._outputs[2]
  90536. },
  90537. enumerable: !1,
  90538. configurable: !0
  90539. }),
  90540. Object.defineProperty(e.prototype, "g", {
  90541. get: function() {
  90542. return this._outputs[3]
  90543. },
  90544. enumerable: !1,
  90545. configurable: !0
  90546. }),
  90547. Object.defineProperty(e.prototype, "b", {
  90548. get: function() {
  90549. return this._outputs[4]
  90550. },
  90551. enumerable: !1,
  90552. configurable: !0
  90553. }),
  90554. Object.defineProperty(e.prototype, "a", {
  90555. get: function() {
  90556. return this._outputs[5]
  90557. },
  90558. enumerable: !1,
  90559. configurable: !0
  90560. }),
  90561. e.prototype.autoConfigure = function(i) {
  90562. if (a.prototype.autoConfigure.call(this, i),
  90563. !this.cameraPosition.isConnected) {
  90564. var o = i.getInputBlockByPredicate(function(s) {
  90565. return s.systemValue === NodeMaterialSystemValues.CameraPosition
  90566. });
  90567. o || (o = new InputBlock("cameraPosition"),
  90568. o.setAsSystemValue(NodeMaterialSystemValues.CameraPosition)),
  90569. o.output.connectTo(this.cameraPosition)
  90570. }
  90571. }
  90572. ,
  90573. e.prototype._buildBlock = function(i) {
  90574. if (a.prototype._buildBlock.call(this, i),
  90575. !this.texture)
  90576. return i.compilationString += this.writeOutputs(i, "vec3(0.)"),
  90577. this;
  90578. if (i.target !== NodeMaterialBlockTargets.Fragment)
  90579. return i.compilationString += this.handleVertexSide(i),
  90580. this;
  90581. this.handleFragmentSideInits(i);
  90582. var o = i._getFreeVariableName("normalWUnit");
  90583. return i.compilationString += "vec4 " + o + " = normalize(" + this.worldNormal.associatedVariableName + `);\r
  90584. `,
  90585. i.compilationString += this.handleFragmentSideCodeReflectionCoords(o),
  90586. i.compilationString += this.handleFragmentSideCodeReflectionColor(void 0, ""),
  90587. i.compilationString += this.writeOutputs(i, this._reflectionColorName),
  90588. this
  90589. }
  90590. ,
  90591. e
  90592. }(ReflectionTextureBaseBlock);
  90593. RegisterClass("BABYLON.ReflectionTextureBlock", ReflectionTextureBlock);
  90594. var SceneDepthBlock = function(a) {
  90595. __extends(e, a);
  90596. function e(i) {
  90597. var o = a.call(this, i, NodeMaterialBlockTargets.VertexAndFragment) || this;
  90598. return o._samplerName = "textureSampler",
  90599. o.useNonLinearDepth = !1,
  90600. o.force32itsFloat = !1,
  90601. o._isUnique = !0,
  90602. o.registerInput("uv", NodeMaterialBlockConnectionPointTypes.Vector2, !1, NodeMaterialBlockTargets.VertexAndFragment),
  90603. o.registerOutput("depth", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Neutral),
  90604. o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector3),
  90605. o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector4),
  90606. o._inputs[0]._prioritizeVertex = !1,
  90607. o
  90608. }
  90609. return e.prototype.getClassName = function() {
  90610. return "SceneDepthBlock"
  90611. }
  90612. ,
  90613. Object.defineProperty(e.prototype, "uv", {
  90614. get: function() {
  90615. return this._inputs[0]
  90616. },
  90617. enumerable: !1,
  90618. configurable: !0
  90619. }),
  90620. Object.defineProperty(e.prototype, "depth", {
  90621. get: function() {
  90622. return this._outputs[0]
  90623. },
  90624. enumerable: !1,
  90625. configurable: !0
  90626. }),
  90627. e.prototype.initialize = function(i) {
  90628. i._excludeVariableName("textureSampler")
  90629. }
  90630. ,
  90631. Object.defineProperty(e.prototype, "target", {
  90632. get: function() {
  90633. return !this.uv.isConnected || this.uv.sourceBlock.isInput ? NodeMaterialBlockTargets.VertexAndFragment : NodeMaterialBlockTargets.Fragment
  90634. },
  90635. enumerable: !1,
  90636. configurable: !0
  90637. }),
  90638. e.prototype._getTexture = function(i) {
  90639. var o = i.enableDepthRenderer(void 0, this.useNonLinearDepth, this.force32itsFloat);
  90640. return o.getDepthMap()
  90641. }
  90642. ,
  90643. e.prototype.bind = function(i, o, s) {
  90644. var c = this._getTexture(o.getScene());
  90645. i.setTexture(this._samplerName, c)
  90646. }
  90647. ,
  90648. e.prototype._injectVertexCode = function(i) {
  90649. var o = this.uv;
  90650. if (o.connectedPoint.ownerBlock.isInput) {
  90651. var s = o.connectedPoint.ownerBlock;
  90652. s.isAttribute || i._emitUniformFromString(o.associatedVariableName, "vec" + (o.type === NodeMaterialBlockConnectionPointTypes.Vector3 ? "3" : o.type === NodeMaterialBlockConnectionPointTypes.Vector4 ? "4" : "2"))
  90653. }
  90654. if (this._mainUVName = "vMain" + o.associatedVariableName,
  90655. i._emitVaryingFromString(this._mainUVName, "vec2"),
  90656. i.compilationString += this._mainUVName + " = " + o.associatedVariableName + `.xy;\r
  90657. `,
  90658. !!this._outputs.some(function(b) {
  90659. return b.isConnectedInVertexShader
  90660. })) {
  90661. this._writeTextureRead(i, !0);
  90662. for (var c = 0, d = this._outputs; c < d.length; c++) {
  90663. var _ = d[c];
  90664. _.hasEndpoints && this._writeOutput(i, _, "r", !0)
  90665. }
  90666. }
  90667. }
  90668. ,
  90669. e.prototype._writeTextureRead = function(i, o) {
  90670. o === void 0 && (o = !1);
  90671. var s = this.uv;
  90672. if (o) {
  90673. if (i.target === NodeMaterialBlockTargets.Fragment)
  90674. return;
  90675. i.compilationString += "vec4 " + this._tempTextureRead + " = texture2D(" + this._samplerName + ", " + s.associatedVariableName + `.xy);\r
  90676. `;
  90677. return
  90678. }
  90679. if (this.uv.ownerBlock.target === NodeMaterialBlockTargets.Fragment) {
  90680. i.compilationString += "vec4 " + this._tempTextureRead + " = texture2D(" + this._samplerName + ", " + s.associatedVariableName + `.xy);\r
  90681. `;
  90682. return
  90683. }
  90684. i.compilationString += "vec4 " + this._tempTextureRead + " = texture2D(" + this._samplerName + ", " + this._mainUVName + `);\r
  90685. `
  90686. }
  90687. ,
  90688. e.prototype._writeOutput = function(i, o, s, c) {
  90689. if (c === void 0 && (c = !1),
  90690. c) {
  90691. if (i.target === NodeMaterialBlockTargets.Fragment)
  90692. return;
  90693. i.compilationString += this._declareOutput(o, i) + " = " + this._tempTextureRead + "." + s + `;\r
  90694. `;
  90695. return
  90696. }
  90697. if (this.uv.ownerBlock.target === NodeMaterialBlockTargets.Fragment) {
  90698. i.compilationString += this._declareOutput(o, i) + " = " + this._tempTextureRead + "." + s + `;\r
  90699. `;
  90700. return
  90701. }
  90702. i.compilationString += this._declareOutput(o, i) + " = " + this._tempTextureRead + "." + s + `;\r
  90703. `
  90704. }
  90705. ,
  90706. e.prototype._buildBlock = function(i) {
  90707. if (a.prototype._buildBlock.call(this, i),
  90708. this._tempTextureRead = i._getFreeVariableName("tempTextureRead"),
  90709. i.sharedData.bindableBlocks.indexOf(this) < 0 && i.sharedData.bindableBlocks.push(this),
  90710. i.target !== NodeMaterialBlockTargets.Fragment) {
  90711. i._emit2DSampler(this._samplerName),
  90712. this._injectVertexCode(i);
  90713. return
  90714. }
  90715. if (!!this._outputs.some(function(d) {
  90716. return d.isConnectedInFragmentShader
  90717. })) {
  90718. i._emit2DSampler(this._samplerName),
  90719. this._writeTextureRead(i);
  90720. for (var o = 0, s = this._outputs; o < s.length; o++) {
  90721. var c = s[o];
  90722. c.hasEndpoints && this._writeOutput(i, c, "r")
  90723. }
  90724. return this
  90725. }
  90726. }
  90727. ,
  90728. e.prototype.serialize = function() {
  90729. var i = a.prototype.serialize.call(this);
  90730. return i.useNonLinearDepth = this.useNonLinearDepth,
  90731. i.force32itsFloat = this.force32itsFloat,
  90732. i
  90733. }
  90734. ,
  90735. e.prototype._deserialize = function(i, o, s) {
  90736. a.prototype._deserialize.call(this, i, o, s),
  90737. this.useNonLinearDepth = i.useNonLinearDepth,
  90738. this.force32itsFloat = i.force32itsFloat
  90739. }
  90740. ,
  90741. __decorate([editableInPropertyPage("Use non linear depth", PropertyTypeForEdition.Boolean, "ADVANCED", {
  90742. notifiers: {
  90743. activatePreviewCommand: !0,
  90744. callback: function(i) {
  90745. return i.disableDepthRenderer()
  90746. }
  90747. }
  90748. })], e.prototype, "useNonLinearDepth", void 0),
  90749. __decorate([editableInPropertyPage("Force 32 bits float", PropertyTypeForEdition.Boolean, "ADVANCED", {
  90750. notifiers: {
  90751. activatePreviewCommand: !0,
  90752. callback: function(i) {
  90753. return i.disableDepthRenderer()
  90754. }
  90755. }
  90756. })], e.prototype, "force32itsFloat", void 0),
  90757. e
  90758. }(NodeMaterialBlock);
  90759. RegisterClass("BABYLON.SceneDepthBlock", SceneDepthBlock);
  90760. var AddBlock = function(a) {
  90761. __extends(e, a);
  90762. function e(i) {
  90763. var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
  90764. return o.registerInput("left", NodeMaterialBlockConnectionPointTypes.AutoDetect),
  90765. o.registerInput("right", NodeMaterialBlockConnectionPointTypes.AutoDetect),
  90766. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
  90767. o._outputs[0]._typeConnectionSource = o._inputs[0],
  90768. o._linkConnectionTypes(0, 1),
  90769. o
  90770. }
  90771. return e.prototype.getClassName = function() {
  90772. return "AddBlock"
  90773. }
  90774. ,
  90775. Object.defineProperty(e.prototype, "left", {
  90776. get: function() {
  90777. return this._inputs[0]
  90778. },
  90779. enumerable: !1,
  90780. configurable: !0
  90781. }),
  90782. Object.defineProperty(e.prototype, "right", {
  90783. get: function() {
  90784. return this._inputs[1]
  90785. },
  90786. enumerable: !1,
  90787. configurable: !0
  90788. }),
  90789. Object.defineProperty(e.prototype, "output", {
  90790. get: function() {
  90791. return this._outputs[0]
  90792. },
  90793. enumerable: !1,
  90794. configurable: !0
  90795. }),
  90796. e.prototype._buildBlock = function(i) {
  90797. a.prototype._buildBlock.call(this, i);
  90798. var o = this._outputs[0];
  90799. return i.compilationString += this._declareOutput(o, i) + (" = " + this.left.associatedVariableName + " + " + this.right.associatedVariableName + `;\r
  90800. `),
  90801. this
  90802. }
  90803. ,
  90804. e
  90805. }(NodeMaterialBlock);
  90806. RegisterClass("BABYLON.AddBlock", AddBlock);
  90807. var ScaleBlock = function(a) {
  90808. __extends(e, a);
  90809. function e(i) {
  90810. var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
  90811. return o.registerInput("input", NodeMaterialBlockConnectionPointTypes.AutoDetect),
  90812. o.registerInput("factor", NodeMaterialBlockConnectionPointTypes.Float),
  90813. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
  90814. o._outputs[0]._typeConnectionSource = o._inputs[0],
  90815. o
  90816. }
  90817. return e.prototype.getClassName = function() {
  90818. return "ScaleBlock"
  90819. }
  90820. ,
  90821. Object.defineProperty(e.prototype, "input", {
  90822. get: function() {
  90823. return this._inputs[0]
  90824. },
  90825. enumerable: !1,
  90826. configurable: !0
  90827. }),
  90828. Object.defineProperty(e.prototype, "factor", {
  90829. get: function() {
  90830. return this._inputs[1]
  90831. },
  90832. enumerable: !1,
  90833. configurable: !0
  90834. }),
  90835. Object.defineProperty(e.prototype, "output", {
  90836. get: function() {
  90837. return this._outputs[0]
  90838. },
  90839. enumerable: !1,
  90840. configurable: !0
  90841. }),
  90842. e.prototype._buildBlock = function(i) {
  90843. a.prototype._buildBlock.call(this, i);
  90844. var o = this._outputs[0];
  90845. return i.compilationString += this._declareOutput(o, i) + (" = " + this.input.associatedVariableName + " * " + this.factor.associatedVariableName + `;\r
  90846. `),
  90847. this
  90848. }
  90849. ,
  90850. e
  90851. }(NodeMaterialBlock);
  90852. RegisterClass("BABYLON.ScaleBlock", ScaleBlock);
  90853. var ClampBlock = function(a) {
  90854. __extends(e, a);
  90855. function e(i) {
  90856. var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
  90857. return o.minimum = 0,
  90858. o.maximum = 1,
  90859. o.registerInput("value", NodeMaterialBlockConnectionPointTypes.AutoDetect),
  90860. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
  90861. o._outputs[0]._typeConnectionSource = o._inputs[0],
  90862. o
  90863. }
  90864. return e.prototype.getClassName = function() {
  90865. return "ClampBlock"
  90866. }
  90867. ,
  90868. Object.defineProperty(e.prototype, "value", {
  90869. get: function() {
  90870. return this._inputs[0]
  90871. },
  90872. enumerable: !1,
  90873. configurable: !0
  90874. }),
  90875. Object.defineProperty(e.prototype, "output", {
  90876. get: function() {
  90877. return this._outputs[0]
  90878. },
  90879. enumerable: !1,
  90880. configurable: !0
  90881. }),
  90882. e.prototype._buildBlock = function(i) {
  90883. a.prototype._buildBlock.call(this, i);
  90884. var o = this._outputs[0];
  90885. return i.compilationString += this._declareOutput(o, i) + (" = clamp(" + this.value.associatedVariableName + ", " + this._writeFloat(this.minimum) + ", " + this._writeFloat(this.maximum) + `);\r
  90886. `),
  90887. this
  90888. }
  90889. ,
  90890. e.prototype._dumpPropertiesCode = function() {
  90891. var i = a.prototype._dumpPropertiesCode.call(this) + (this._codeVariableName + ".minimum = " + this.minimum + `;\r
  90892. `);
  90893. return i += this._codeVariableName + ".maximum = " + this.maximum + `;\r
  90894. `,
  90895. i
  90896. }
  90897. ,
  90898. e.prototype.serialize = function() {
  90899. var i = a.prototype.serialize.call(this);
  90900. return i.minimum = this.minimum,
  90901. i.maximum = this.maximum,
  90902. i
  90903. }
  90904. ,
  90905. e.prototype._deserialize = function(i, o, s) {
  90906. a.prototype._deserialize.call(this, i, o, s),
  90907. this.minimum = i.minimum,
  90908. this.maximum = i.maximum
  90909. }
  90910. ,
  90911. __decorate([editableInPropertyPage("Minimum", PropertyTypeForEdition.Float)], e.prototype, "minimum", void 0),
  90912. __decorate([editableInPropertyPage("Maximum", PropertyTypeForEdition.Float)], e.prototype, "maximum", void 0),
  90913. e
  90914. }(NodeMaterialBlock);
  90915. RegisterClass("BABYLON.ClampBlock", ClampBlock);
  90916. var CrossBlock = function(a) {
  90917. __extends(e, a);
  90918. function e(i) {
  90919. var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
  90920. return o.registerInput("left", NodeMaterialBlockConnectionPointTypes.AutoDetect),
  90921. o.registerInput("right", NodeMaterialBlockConnectionPointTypes.AutoDetect),
  90922. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Vector3),
  90923. o._linkConnectionTypes(0, 1),
  90924. o._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float),
  90925. o._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix),
  90926. o._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector2),
  90927. o._inputs[1].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float),
  90928. o._inputs[1].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix),
  90929. o._inputs[1].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector2),
  90930. o
  90931. }
  90932. return e.prototype.getClassName = function() {
  90933. return "CrossBlock"
  90934. }
  90935. ,
  90936. Object.defineProperty(e.prototype, "left", {
  90937. get: function() {
  90938. return this._inputs[0]
  90939. },
  90940. enumerable: !1,
  90941. configurable: !0
  90942. }),
  90943. Object.defineProperty(e.prototype, "right", {
  90944. get: function() {
  90945. return this._inputs[1]
  90946. },
  90947. enumerable: !1,
  90948. configurable: !0
  90949. }),
  90950. Object.defineProperty(e.prototype, "output", {
  90951. get: function() {
  90952. return this._outputs[0]
  90953. },
  90954. enumerable: !1,
  90955. configurable: !0
  90956. }),
  90957. e.prototype._buildBlock = function(i) {
  90958. a.prototype._buildBlock.call(this, i);
  90959. var o = this._outputs[0];
  90960. return i.compilationString += this._declareOutput(o, i) + (" = cross(" + this.left.associatedVariableName + ".xyz, " + this.right.associatedVariableName + `.xyz);\r
  90961. `),
  90962. this
  90963. }
  90964. ,
  90965. e
  90966. }(NodeMaterialBlock);
  90967. RegisterClass("BABYLON.CrossBlock", CrossBlock);
  90968. var CustomBlock = function(a) {
  90969. __extends(e, a);
  90970. function e(i) {
  90971. return a.call(this, i) || this
  90972. }
  90973. return Object.defineProperty(e.prototype, "options", {
  90974. get: function() {
  90975. return this._options
  90976. },
  90977. set: function(i) {
  90978. this._deserializeOptions(i)
  90979. },
  90980. enumerable: !1,
  90981. configurable: !0
  90982. }),
  90983. e.prototype.getClassName = function() {
  90984. return "CustomBlock"
  90985. }
  90986. ,
  90987. e.prototype._buildBlock = function(i) {
  90988. var o = this;
  90989. a.prototype._buildBlock.call(this, i);
  90990. var s = this._code
  90991. , c = this._options.functionName;
  90992. this._inputs.forEach(function(_) {
  90993. var b = new RegExp("\\{TYPE_" + _.name + "\\}","gm")
  90994. , k = i._getGLType(_.type);
  90995. s = s.replace(b, k),
  90996. c = c.replace(b, k)
  90997. }),
  90998. this._outputs.forEach(function(_) {
  90999. var b = new RegExp("\\{TYPE_" + _.name + "\\}","gm")
  91000. , k = i._getGLType(_.type);
  91001. s = s.replace(b, k),
  91002. c = c.replace(b, k)
  91003. }),
  91004. i._emitFunction(c, s, ""),
  91005. this._outputs.forEach(function(_) {
  91006. i.compilationString += o._declareOutput(_, i) + `;\r
  91007. `
  91008. }),
  91009. i.compilationString += c + "(";
  91010. var d = !1;
  91011. return this._inputs.forEach(function(_, b) {
  91012. b > 0 && (i.compilationString += ", "),
  91013. i.compilationString += _.associatedVariableName,
  91014. d = !0
  91015. }),
  91016. this._outputs.forEach(function(_, b) {
  91017. (b > 0 || d) && (i.compilationString += ", "),
  91018. i.compilationString += _.associatedVariableName
  91019. }),
  91020. i.compilationString += `);\r
  91021. `,
  91022. this
  91023. }
  91024. ,
  91025. e.prototype._dumpPropertiesCode = function() {
  91026. var i = a.prototype._dumpPropertiesCode.call(this);
  91027. return i += this._codeVariableName + ".options = " + JSON.stringify(this._options) + `;\r
  91028. `,
  91029. i
  91030. }
  91031. ,
  91032. e.prototype.serialize = function() {
  91033. var i = a.prototype.serialize.call(this);
  91034. return i.options = this._options,
  91035. i
  91036. }
  91037. ,
  91038. e.prototype._deserialize = function(i, o, s) {
  91039. this._deserializeOptions(i.options),
  91040. a.prototype._deserialize.call(this, i, o, s)
  91041. }
  91042. ,
  91043. e.prototype._deserializeOptions = function(i) {
  91044. var o = this, s, c, d;
  91045. this._options = i,
  91046. this._code = i.code.join(`\r
  91047. `) + `\r
  91048. `,
  91049. this.name = this.name || i.name,
  91050. this.target = NodeMaterialBlockTargets[i.target],
  91051. (s = i.inParameters) === null || s === void 0 || s.forEach(function(_, b) {
  91052. var k = NodeMaterialBlockConnectionPointTypes[_.type];
  91053. o.registerInput(_.name, k),
  91054. Object.defineProperty(o, _.name, {
  91055. get: function() {
  91056. return this._inputs[b]
  91057. },
  91058. enumerable: !0,
  91059. configurable: !0
  91060. })
  91061. }),
  91062. (c = i.outParameters) === null || c === void 0 || c.forEach(function(_, b) {
  91063. o.registerOutput(_.name, NodeMaterialBlockConnectionPointTypes[_.type]),
  91064. Object.defineProperty(o, _.name, {
  91065. get: function() {
  91066. return this._outputs[b]
  91067. },
  91068. enumerable: !0,
  91069. configurable: !0
  91070. }),
  91071. _.type === "BasedOnInput" && (o._outputs[b]._typeConnectionSource = o._findInputByName(_.typeFromInput)[0])
  91072. }),
  91073. (d = i.inLinkedConnectionTypes) === null || d === void 0 || d.forEach(function(_) {
  91074. o._linkConnectionTypes(o._findInputByName(_.input1)[1], o._findInputByName(_.input2)[1])
  91075. })
  91076. }
  91077. ,
  91078. e.prototype._findInputByName = function(i) {
  91079. if (!i)
  91080. return null;
  91081. for (var o = 0; o < this._inputs.length; o++)
  91082. if (this._inputs[o].name === i)
  91083. return [this._inputs[o], o];
  91084. return null
  91085. }
  91086. ,
  91087. e
  91088. }(NodeMaterialBlock);
  91089. RegisterClass("BABYLON.CustomBlock", CustomBlock);
  91090. var DotBlock = function(a) {
  91091. __extends(e, a);
  91092. function e(i) {
  91093. var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
  91094. return o.registerInput("left", NodeMaterialBlockConnectionPointTypes.AutoDetect),
  91095. o.registerInput("right", NodeMaterialBlockConnectionPointTypes.AutoDetect),
  91096. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Float),
  91097. o._linkConnectionTypes(0, 1),
  91098. o._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float),
  91099. o._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix),
  91100. o._inputs[1].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float),
  91101. o._inputs[1].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix),
  91102. o
  91103. }
  91104. return e.prototype.getClassName = function() {
  91105. return "DotBlock"
  91106. }
  91107. ,
  91108. Object.defineProperty(e.prototype, "left", {
  91109. get: function() {
  91110. return this._inputs[0]
  91111. },
  91112. enumerable: !1,
  91113. configurable: !0
  91114. }),
  91115. Object.defineProperty(e.prototype, "right", {
  91116. get: function() {
  91117. return this._inputs[1]
  91118. },
  91119. enumerable: !1,
  91120. configurable: !0
  91121. }),
  91122. Object.defineProperty(e.prototype, "output", {
  91123. get: function() {
  91124. return this._outputs[0]
  91125. },
  91126. enumerable: !1,
  91127. configurable: !0
  91128. }),
  91129. e.prototype._buildBlock = function(i) {
  91130. a.prototype._buildBlock.call(this, i);
  91131. var o = this._outputs[0];
  91132. return i.compilationString += this._declareOutput(o, i) + (" = dot(" + this.left.associatedVariableName + ", " + this.right.associatedVariableName + `);\r
  91133. `),
  91134. this
  91135. }
  91136. ,
  91137. e
  91138. }(NodeMaterialBlock);
  91139. RegisterClass("BABYLON.DotBlock", DotBlock);
  91140. var NormalizeBlock = function(a) {
  91141. __extends(e, a);
  91142. function e(i) {
  91143. var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
  91144. return o.registerInput("input", NodeMaterialBlockConnectionPointTypes.AutoDetect),
  91145. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
  91146. o._outputs[0]._typeConnectionSource = o._inputs[0],
  91147. o._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float),
  91148. o._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix),
  91149. o
  91150. }
  91151. return e.prototype.getClassName = function() {
  91152. return "NormalizeBlock"
  91153. }
  91154. ,
  91155. Object.defineProperty(e.prototype, "input", {
  91156. get: function() {
  91157. return this._inputs[0]
  91158. },
  91159. enumerable: !1,
  91160. configurable: !0
  91161. }),
  91162. Object.defineProperty(e.prototype, "output", {
  91163. get: function() {
  91164. return this._outputs[0]
  91165. },
  91166. enumerable: !1,
  91167. configurable: !0
  91168. }),
  91169. e.prototype._buildBlock = function(i) {
  91170. a.prototype._buildBlock.call(this, i);
  91171. var o = this._outputs[0]
  91172. , s = this._inputs[0];
  91173. return i.compilationString += this._declareOutput(o, i) + (" = normalize(" + s.associatedVariableName + `);\r
  91174. `),
  91175. this
  91176. }
  91177. ,
  91178. e
  91179. }(NodeMaterialBlock);
  91180. RegisterClass("BABYLON.NormalizeBlock", NormalizeBlock);
  91181. var ColorMergerBlock = function(a) {
  91182. __extends(e, a);
  91183. function e(i) {
  91184. var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
  91185. return o.rSwizzle = "r",
  91186. o.gSwizzle = "g",
  91187. o.bSwizzle = "b",
  91188. o.aSwizzle = "a",
  91189. o.registerInput("rgb ", NodeMaterialBlockConnectionPointTypes.Color3, !0),
  91190. o.registerInput("r", NodeMaterialBlockConnectionPointTypes.Float, !0),
  91191. o.registerInput("g", NodeMaterialBlockConnectionPointTypes.Float, !0),
  91192. o.registerInput("b", NodeMaterialBlockConnectionPointTypes.Float, !0),
  91193. o.registerInput("a", NodeMaterialBlockConnectionPointTypes.Float, !0),
  91194. o.registerOutput("rgba", NodeMaterialBlockConnectionPointTypes.Color4),
  91195. o.registerOutput("rgb", NodeMaterialBlockConnectionPointTypes.Color3),
  91196. o
  91197. }
  91198. return e.prototype.getClassName = function() {
  91199. return "ColorMergerBlock"
  91200. }
  91201. ,
  91202. Object.defineProperty(e.prototype, "rgbIn", {
  91203. get: function() {
  91204. return this._inputs[0]
  91205. },
  91206. enumerable: !1,
  91207. configurable: !0
  91208. }),
  91209. Object.defineProperty(e.prototype, "r", {
  91210. get: function() {
  91211. return this._inputs[1]
  91212. },
  91213. enumerable: !1,
  91214. configurable: !0
  91215. }),
  91216. Object.defineProperty(e.prototype, "g", {
  91217. get: function() {
  91218. return this._inputs[2]
  91219. },
  91220. enumerable: !1,
  91221. configurable: !0
  91222. }),
  91223. Object.defineProperty(e.prototype, "b", {
  91224. get: function() {
  91225. return this._inputs[3]
  91226. },
  91227. enumerable: !1,
  91228. configurable: !0
  91229. }),
  91230. Object.defineProperty(e.prototype, "a", {
  91231. get: function() {
  91232. return this._inputs[4]
  91233. },
  91234. enumerable: !1,
  91235. configurable: !0
  91236. }),
  91237. Object.defineProperty(e.prototype, "rgba", {
  91238. get: function() {
  91239. return this._outputs[0]
  91240. },
  91241. enumerable: !1,
  91242. configurable: !0
  91243. }),
  91244. Object.defineProperty(e.prototype, "rgbOut", {
  91245. get: function() {
  91246. return this._outputs[1]
  91247. },
  91248. enumerable: !1,
  91249. configurable: !0
  91250. }),
  91251. Object.defineProperty(e.prototype, "rgb", {
  91252. get: function() {
  91253. return this.rgbOut
  91254. },
  91255. enumerable: !1,
  91256. configurable: !0
  91257. }),
  91258. e.prototype._inputRename = function(i) {
  91259. return i === "rgb " ? "rgbIn" : i
  91260. }
  91261. ,
  91262. e.prototype._buildSwizzle = function(i) {
  91263. var o = this.rSwizzle + this.gSwizzle + this.bSwizzle + this.aSwizzle;
  91264. return "." + o.substr(0, i)
  91265. }
  91266. ,
  91267. e.prototype._buildBlock = function(i) {
  91268. a.prototype._buildBlock.call(this, i);
  91269. var o = this.r
  91270. , s = this.g
  91271. , c = this.b
  91272. , d = this.a
  91273. , _ = this.rgbIn
  91274. , b = this._outputs[0]
  91275. , k = this._outputs[1];
  91276. return _.isConnected ? (b.hasEndpoints && (i.compilationString += this._declareOutput(b, i) + (" = vec4(" + _.associatedVariableName + ", " + (d.isConnected ? this._writeVariable(d) : "0.0") + ")" + this._buildSwizzle(4) + `;\r
  91277. `)),
  91278. k.hasEndpoints && (i.compilationString += this._declareOutput(k, i) + (" = " + _.associatedVariableName + this._buildSwizzle(3) + `;\r
  91279. `))) : (b.hasEndpoints && (i.compilationString += this._declareOutput(b, i) + (" = vec4(" + (o.isConnected ? this._writeVariable(o) : "0.0") + ", " + (s.isConnected ? this._writeVariable(s) : "0.0") + ", " + (c.isConnected ? this._writeVariable(c) : "0.0") + ", " + (d.isConnected ? this._writeVariable(d) : "0.0") + ")" + this._buildSwizzle(4) + `;\r
  91280. `)),
  91281. k.hasEndpoints && (i.compilationString += this._declareOutput(k, i) + (" = vec3(" + (o.isConnected ? this._writeVariable(o) : "0.0") + ", " + (s.isConnected ? this._writeVariable(s) : "0.0") + ", " + (c.isConnected ? this._writeVariable(c) : "0.0") + ")" + this._buildSwizzle(3) + `;\r
  91282. `))),
  91283. this
  91284. }
  91285. ,
  91286. e.prototype.serialize = function() {
  91287. var i = a.prototype.serialize.call(this);
  91288. return i.rSwizzle = this.rSwizzle,
  91289. i.gSwizzle = this.gSwizzle,
  91290. i.bSwizzle = this.bSwizzle,
  91291. i.aSwizzle = this.aSwizzle,
  91292. i
  91293. }
  91294. ,
  91295. e.prototype._deserialize = function(i, o, s) {
  91296. var c, d, _, b;
  91297. a.prototype._deserialize.call(this, i, o, s),
  91298. this.rSwizzle = (c = i.rSwizzle) !== null && c !== void 0 ? c : "r",
  91299. this.gSwizzle = (d = i.gSwizzle) !== null && d !== void 0 ? d : "g",
  91300. this.bSwizzle = (_ = i.bSwizzle) !== null && _ !== void 0 ? _ : "b",
  91301. this.aSwizzle = (b = i.aSwizzle) !== null && b !== void 0 ? b : "a"
  91302. }
  91303. ,
  91304. e.prototype._dumpPropertiesCode = function() {
  91305. var i = a.prototype._dumpPropertiesCode.call(this);
  91306. return i += this._codeVariableName + ".rSwizzle = " + this.rSwizzle + `};\r
  91307. `,
  91308. i += this._codeVariableName + ".gSwizzle = " + this.gSwizzle + `};\r
  91309. `,
  91310. i += this._codeVariableName + ".bSwizzle = " + this.bSwizzle + `};\r
  91311. `,
  91312. i += this._codeVariableName + ".aSwizzle = " + this.aSwizzle + `};\r
  91313. `,
  91314. i
  91315. }
  91316. ,
  91317. e
  91318. }(NodeMaterialBlock);
  91319. RegisterClass("BABYLON.ColorMergerBlock", ColorMergerBlock);
  91320. var VectorSplitterBlock = function(a) {
  91321. __extends(e, a);
  91322. function e(i) {
  91323. var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
  91324. return o.registerInput("xyzw", NodeMaterialBlockConnectionPointTypes.Vector4, !0),
  91325. o.registerInput("xyz ", NodeMaterialBlockConnectionPointTypes.Vector3, !0),
  91326. o.registerInput("xy ", NodeMaterialBlockConnectionPointTypes.Vector2, !0),
  91327. o.registerOutput("xyz", NodeMaterialBlockConnectionPointTypes.Vector3),
  91328. o.registerOutput("xy", NodeMaterialBlockConnectionPointTypes.Vector2),
  91329. o.registerOutput("zw", NodeMaterialBlockConnectionPointTypes.Vector2),
  91330. o.registerOutput("x", NodeMaterialBlockConnectionPointTypes.Float),
  91331. o.registerOutput("y", NodeMaterialBlockConnectionPointTypes.Float),
  91332. o.registerOutput("z", NodeMaterialBlockConnectionPointTypes.Float),
  91333. o.registerOutput("w", NodeMaterialBlockConnectionPointTypes.Float),
  91334. o.inputsAreExclusive = !0,
  91335. o
  91336. }
  91337. return e.prototype.getClassName = function() {
  91338. return "VectorSplitterBlock"
  91339. }
  91340. ,
  91341. Object.defineProperty(e.prototype, "xyzw", {
  91342. get: function() {
  91343. return this._inputs[0]
  91344. },
  91345. enumerable: !1,
  91346. configurable: !0
  91347. }),
  91348. Object.defineProperty(e.prototype, "xyzIn", {
  91349. get: function() {
  91350. return this._inputs[1]
  91351. },
  91352. enumerable: !1,
  91353. configurable: !0
  91354. }),
  91355. Object.defineProperty(e.prototype, "xyIn", {
  91356. get: function() {
  91357. return this._inputs[2]
  91358. },
  91359. enumerable: !1,
  91360. configurable: !0
  91361. }),
  91362. Object.defineProperty(e.prototype, "xyzOut", {
  91363. get: function() {
  91364. return this._outputs[0]
  91365. },
  91366. enumerable: !1,
  91367. configurable: !0
  91368. }),
  91369. Object.defineProperty(e.prototype, "xyOut", {
  91370. get: function() {
  91371. return this._outputs[1]
  91372. },
  91373. enumerable: !1,
  91374. configurable: !0
  91375. }),
  91376. Object.defineProperty(e.prototype, "zw", {
  91377. get: function() {
  91378. return this._outputs[2]
  91379. },
  91380. enumerable: !1,
  91381. configurable: !0
  91382. }),
  91383. Object.defineProperty(e.prototype, "x", {
  91384. get: function() {
  91385. return this._outputs[3]
  91386. },
  91387. enumerable: !1,
  91388. configurable: !0
  91389. }),
  91390. Object.defineProperty(e.prototype, "y", {
  91391. get: function() {
  91392. return this._outputs[4]
  91393. },
  91394. enumerable: !1,
  91395. configurable: !0
  91396. }),
  91397. Object.defineProperty(e.prototype, "z", {
  91398. get: function() {
  91399. return this._outputs[5]
  91400. },
  91401. enumerable: !1,
  91402. configurable: !0
  91403. }),
  91404. Object.defineProperty(e.prototype, "w", {
  91405. get: function() {
  91406. return this._outputs[6]
  91407. },
  91408. enumerable: !1,
  91409. configurable: !0
  91410. }),
  91411. e.prototype._inputRename = function(i) {
  91412. switch (i) {
  91413. case "xy ":
  91414. return "xyIn";
  91415. case "xyz ":
  91416. return "xyzIn";
  91417. default:
  91418. return i
  91419. }
  91420. }
  91421. ,
  91422. e.prototype._outputRename = function(i) {
  91423. switch (i) {
  91424. case "xy":
  91425. return "xyOut";
  91426. case "xyz":
  91427. return "xyzOut";
  91428. default:
  91429. return i
  91430. }
  91431. }
  91432. ,
  91433. e.prototype._buildBlock = function(i) {
  91434. a.prototype._buildBlock.call(this, i);
  91435. var o = this.xyzw.isConnected ? this.xyzw : this.xyzIn.isConnected ? this.xyzIn : this.xyIn
  91436. , s = this._outputs[0]
  91437. , c = this._outputs[1]
  91438. , d = this._outputs[2]
  91439. , _ = this._outputs[3]
  91440. , b = this._outputs[4]
  91441. , k = this._outputs[5]
  91442. , j = this._outputs[6];
  91443. return s.hasEndpoints && (o === this.xyIn ? i.compilationString += this._declareOutput(s, i) + (" = vec3(" + o.associatedVariableName + `, 0.0);\r
  91444. `) : i.compilationString += this._declareOutput(s, i) + (" = " + o.associatedVariableName + `.xyz;\r
  91445. `)),
  91446. d.hasEndpoints && this.xyzw.isConnected && (i.compilationString += this._declareOutput(d, i) + (" = " + this.xyzw.associatedVariableName + `.zw;\r
  91447. `)),
  91448. c.hasEndpoints && (i.compilationString += this._declareOutput(c, i) + (" = " + o.associatedVariableName + `.xy;\r
  91449. `)),
  91450. _.hasEndpoints && (i.compilationString += this._declareOutput(_, i) + (" = " + o.associatedVariableName + `.x;\r
  91451. `)),
  91452. b.hasEndpoints && (i.compilationString += this._declareOutput(b, i) + (" = " + o.associatedVariableName + `.y;\r
  91453. `)),
  91454. k.hasEndpoints && (i.compilationString += this._declareOutput(k, i) + (" = " + o.associatedVariableName + `.z;\r
  91455. `)),
  91456. j.hasEndpoints && (i.compilationString += this._declareOutput(j, i) + (" = " + o.associatedVariableName + `.w;\r
  91457. `)),
  91458. this
  91459. }
  91460. ,
  91461. e
  91462. }(NodeMaterialBlock);
  91463. RegisterClass("BABYLON.VectorSplitterBlock", VectorSplitterBlock);
  91464. var LerpBlock = function(a) {
  91465. __extends(e, a);
  91466. function e(i) {
  91467. var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
  91468. return o.registerInput("left", NodeMaterialBlockConnectionPointTypes.AutoDetect),
  91469. o.registerInput("right", NodeMaterialBlockConnectionPointTypes.AutoDetect),
  91470. o.registerInput("gradient", NodeMaterialBlockConnectionPointTypes.AutoDetect),
  91471. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
  91472. o._outputs[0]._typeConnectionSource = o._inputs[0],
  91473. o._linkConnectionTypes(0, 1),
  91474. o._linkConnectionTypes(1, 2, !0),
  91475. o._inputs[2].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float),
  91476. o
  91477. }
  91478. return e.prototype.getClassName = function() {
  91479. return "LerpBlock"
  91480. }
  91481. ,
  91482. Object.defineProperty(e.prototype, "left", {
  91483. get: function() {
  91484. return this._inputs[0]
  91485. },
  91486. enumerable: !1,
  91487. configurable: !0
  91488. }),
  91489. Object.defineProperty(e.prototype, "right", {
  91490. get: function() {
  91491. return this._inputs[1]
  91492. },
  91493. enumerable: !1,
  91494. configurable: !0
  91495. }),
  91496. Object.defineProperty(e.prototype, "gradient", {
  91497. get: function() {
  91498. return this._inputs[2]
  91499. },
  91500. enumerable: !1,
  91501. configurable: !0
  91502. }),
  91503. Object.defineProperty(e.prototype, "output", {
  91504. get: function() {
  91505. return this._outputs[0]
  91506. },
  91507. enumerable: !1,
  91508. configurable: !0
  91509. }),
  91510. e.prototype._buildBlock = function(i) {
  91511. a.prototype._buildBlock.call(this, i);
  91512. var o = this._outputs[0];
  91513. return i.compilationString += this._declareOutput(o, i) + (" = mix(" + this.left.associatedVariableName + " , " + this.right.associatedVariableName + ", " + this.gradient.associatedVariableName + `);\r
  91514. `),
  91515. this
  91516. }
  91517. ,
  91518. e
  91519. }(NodeMaterialBlock);
  91520. RegisterClass("BABYLON.LerpBlock", LerpBlock);
  91521. var DivideBlock = function(a) {
  91522. __extends(e, a);
  91523. function e(i) {
  91524. var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
  91525. return o.registerInput("left", NodeMaterialBlockConnectionPointTypes.AutoDetect),
  91526. o.registerInput("right", NodeMaterialBlockConnectionPointTypes.AutoDetect),
  91527. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
  91528. o._outputs[0]._typeConnectionSource = o._inputs[0],
  91529. o._linkConnectionTypes(0, 1),
  91530. o
  91531. }
  91532. return e.prototype.getClassName = function() {
  91533. return "DivideBlock"
  91534. }
  91535. ,
  91536. Object.defineProperty(e.prototype, "left", {
  91537. get: function() {
  91538. return this._inputs[0]
  91539. },
  91540. enumerable: !1,
  91541. configurable: !0
  91542. }),
  91543. Object.defineProperty(e.prototype, "right", {
  91544. get: function() {
  91545. return this._inputs[1]
  91546. },
  91547. enumerable: !1,
  91548. configurable: !0
  91549. }),
  91550. Object.defineProperty(e.prototype, "output", {
  91551. get: function() {
  91552. return this._outputs[0]
  91553. },
  91554. enumerable: !1,
  91555. configurable: !0
  91556. }),
  91557. e.prototype._buildBlock = function(i) {
  91558. a.prototype._buildBlock.call(this, i);
  91559. var o = this._outputs[0];
  91560. return i.compilationString += this._declareOutput(o, i) + (" = " + this.left.associatedVariableName + " / " + this.right.associatedVariableName + `;\r
  91561. `),
  91562. this
  91563. }
  91564. ,
  91565. e
  91566. }(NodeMaterialBlock);
  91567. RegisterClass("BABYLON.DivideBlock", DivideBlock);
  91568. var SubtractBlock = function(a) {
  91569. __extends(e, a);
  91570. function e(i) {
  91571. var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
  91572. return o.registerInput("left", NodeMaterialBlockConnectionPointTypes.AutoDetect),
  91573. o.registerInput("right", NodeMaterialBlockConnectionPointTypes.AutoDetect),
  91574. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
  91575. o._outputs[0]._typeConnectionSource = o._inputs[0],
  91576. o._linkConnectionTypes(0, 1),
  91577. o
  91578. }
  91579. return e.prototype.getClassName = function() {
  91580. return "SubtractBlock"
  91581. }
  91582. ,
  91583. Object.defineProperty(e.prototype, "left", {
  91584. get: function() {
  91585. return this._inputs[0]
  91586. },
  91587. enumerable: !1,
  91588. configurable: !0
  91589. }),
  91590. Object.defineProperty(e.prototype, "right", {
  91591. get: function() {
  91592. return this._inputs[1]
  91593. },
  91594. enumerable: !1,
  91595. configurable: !0
  91596. }),
  91597. Object.defineProperty(e.prototype, "output", {
  91598. get: function() {
  91599. return this._outputs[0]
  91600. },
  91601. enumerable: !1,
  91602. configurable: !0
  91603. }),
  91604. e.prototype._buildBlock = function(i) {
  91605. a.prototype._buildBlock.call(this, i);
  91606. var o = this._outputs[0];
  91607. return i.compilationString += this._declareOutput(o, i) + (" = " + this.left.associatedVariableName + " - " + this.right.associatedVariableName + `;\r
  91608. `),
  91609. this
  91610. }
  91611. ,
  91612. e
  91613. }(NodeMaterialBlock);
  91614. RegisterClass("BABYLON.SubtractBlock", SubtractBlock);
  91615. var StepBlock = function(a) {
  91616. __extends(e, a);
  91617. function e(i) {
  91618. var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
  91619. return o.registerInput("value", NodeMaterialBlockConnectionPointTypes.Float),
  91620. o.registerInput("edge", NodeMaterialBlockConnectionPointTypes.Float),
  91621. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Float),
  91622. o
  91623. }
  91624. return e.prototype.getClassName = function() {
  91625. return "StepBlock"
  91626. }
  91627. ,
  91628. Object.defineProperty(e.prototype, "value", {
  91629. get: function() {
  91630. return this._inputs[0]
  91631. },
  91632. enumerable: !1,
  91633. configurable: !0
  91634. }),
  91635. Object.defineProperty(e.prototype, "edge", {
  91636. get: function() {
  91637. return this._inputs[1]
  91638. },
  91639. enumerable: !1,
  91640. configurable: !0
  91641. }),
  91642. Object.defineProperty(e.prototype, "output", {
  91643. get: function() {
  91644. return this._outputs[0]
  91645. },
  91646. enumerable: !1,
  91647. configurable: !0
  91648. }),
  91649. e.prototype._buildBlock = function(i) {
  91650. a.prototype._buildBlock.call(this, i);
  91651. var o = this._outputs[0];
  91652. return i.compilationString += this._declareOutput(o, i) + (" = step(" + this.edge.associatedVariableName + ", " + this.value.associatedVariableName + `);\r
  91653. `),
  91654. this
  91655. }
  91656. ,
  91657. e
  91658. }(NodeMaterialBlock);
  91659. RegisterClass("BABYLON.StepBlock", StepBlock);
  91660. var OneMinusBlock = function(a) {
  91661. __extends(e, a);
  91662. function e(i) {
  91663. var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
  91664. return o.registerInput("input", NodeMaterialBlockConnectionPointTypes.AutoDetect),
  91665. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
  91666. o._outputs[0]._typeConnectionSource = o._inputs[0],
  91667. o._outputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix),
  91668. o
  91669. }
  91670. return e.prototype.getClassName = function() {
  91671. return "OneMinusBlock"
  91672. }
  91673. ,
  91674. Object.defineProperty(e.prototype, "input", {
  91675. get: function() {
  91676. return this._inputs[0]
  91677. },
  91678. enumerable: !1,
  91679. configurable: !0
  91680. }),
  91681. Object.defineProperty(e.prototype, "output", {
  91682. get: function() {
  91683. return this._outputs[0]
  91684. },
  91685. enumerable: !1,
  91686. configurable: !0
  91687. }),
  91688. e.prototype._buildBlock = function(i) {
  91689. a.prototype._buildBlock.call(this, i);
  91690. var o = this._outputs[0];
  91691. return i.compilationString += this._declareOutput(o, i) + (" = 1. - " + this.input.associatedVariableName + `;\r
  91692. `),
  91693. this
  91694. }
  91695. ,
  91696. e
  91697. }(NodeMaterialBlock);
  91698. RegisterClass("BABYLON.OneMinusBlock", OneMinusBlock);
  91699. RegisterClass("BABYLON.OppositeBlock", OneMinusBlock);
  91700. var ViewDirectionBlock = function(a) {
  91701. __extends(e, a);
  91702. function e(i) {
  91703. var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
  91704. return o.registerInput("worldPosition", NodeMaterialBlockConnectionPointTypes.Vector4),
  91705. o.registerInput("cameraPosition", NodeMaterialBlockConnectionPointTypes.Vector3),
  91706. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Vector3),
  91707. o
  91708. }
  91709. return e.prototype.getClassName = function() {
  91710. return "ViewDirectionBlock"
  91711. }
  91712. ,
  91713. Object.defineProperty(e.prototype, "worldPosition", {
  91714. get: function() {
  91715. return this._inputs[0]
  91716. },
  91717. enumerable: !1,
  91718. configurable: !0
  91719. }),
  91720. Object.defineProperty(e.prototype, "cameraPosition", {
  91721. get: function() {
  91722. return this._inputs[1]
  91723. },
  91724. enumerable: !1,
  91725. configurable: !0
  91726. }),
  91727. Object.defineProperty(e.prototype, "output", {
  91728. get: function() {
  91729. return this._outputs[0]
  91730. },
  91731. enumerable: !1,
  91732. configurable: !0
  91733. }),
  91734. e.prototype.autoConfigure = function(i) {
  91735. if (!this.cameraPosition.isConnected) {
  91736. var o = i.getInputBlockByPredicate(function(s) {
  91737. return s.systemValue === NodeMaterialSystemValues.CameraPosition
  91738. });
  91739. o || (o = new InputBlock("cameraPosition"),
  91740. o.setAsSystemValue(NodeMaterialSystemValues.CameraPosition)),
  91741. o.output.connectTo(this.cameraPosition)
  91742. }
  91743. }
  91744. ,
  91745. e.prototype._buildBlock = function(i) {
  91746. a.prototype._buildBlock.call(this, i);
  91747. var o = this._outputs[0];
  91748. return i.compilationString += this._declareOutput(o, i) + (" = normalize(" + this.cameraPosition.associatedVariableName + " - " + this.worldPosition.associatedVariableName + `.xyz);\r
  91749. `),
  91750. this
  91751. }
  91752. ,
  91753. e
  91754. }(NodeMaterialBlock);
  91755. RegisterClass("BABYLON.ViewDirectionBlock", ViewDirectionBlock);
  91756. var FresnelBlock = function(a) {
  91757. __extends(e, a);
  91758. function e(i) {
  91759. var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
  91760. return o.registerInput("worldNormal", NodeMaterialBlockConnectionPointTypes.Vector4),
  91761. o.registerInput("viewDirection", NodeMaterialBlockConnectionPointTypes.Vector3),
  91762. o.registerInput("bias", NodeMaterialBlockConnectionPointTypes.Float),
  91763. o.registerInput("power", NodeMaterialBlockConnectionPointTypes.Float),
  91764. o.registerOutput("fresnel", NodeMaterialBlockConnectionPointTypes.Float),
  91765. o
  91766. }
  91767. return e.prototype.getClassName = function() {
  91768. return "FresnelBlock"
  91769. }
  91770. ,
  91771. Object.defineProperty(e.prototype, "worldNormal", {
  91772. get: function() {
  91773. return this._inputs[0]
  91774. },
  91775. enumerable: !1,
  91776. configurable: !0
  91777. }),
  91778. Object.defineProperty(e.prototype, "viewDirection", {
  91779. get: function() {
  91780. return this._inputs[1]
  91781. },
  91782. enumerable: !1,
  91783. configurable: !0
  91784. }),
  91785. Object.defineProperty(e.prototype, "bias", {
  91786. get: function() {
  91787. return this._inputs[2]
  91788. },
  91789. enumerable: !1,
  91790. configurable: !0
  91791. }),
  91792. Object.defineProperty(e.prototype, "power", {
  91793. get: function() {
  91794. return this._inputs[3]
  91795. },
  91796. enumerable: !1,
  91797. configurable: !0
  91798. }),
  91799. Object.defineProperty(e.prototype, "fresnel", {
  91800. get: function() {
  91801. return this._outputs[0]
  91802. },
  91803. enumerable: !1,
  91804. configurable: !0
  91805. }),
  91806. e.prototype.autoConfigure = function(i) {
  91807. if (!this.viewDirection.isConnected) {
  91808. var o = new ViewDirectionBlock("View direction");
  91809. o.output.connectTo(this.viewDirection),
  91810. o.autoConfigure(i)
  91811. }
  91812. if (!this.bias.isConnected) {
  91813. var s = new InputBlock("bias");
  91814. s.value = 0,
  91815. s.output.connectTo(this.bias)
  91816. }
  91817. if (!this.power.isConnected) {
  91818. var c = new InputBlock("power");
  91819. c.value = 1,
  91820. c.output.connectTo(this.power)
  91821. }
  91822. }
  91823. ,
  91824. e.prototype._buildBlock = function(i) {
  91825. a.prototype._buildBlock.call(this, i);
  91826. var o = "//" + this.name;
  91827. return i._emitFunctionFromInclude("fresnelFunction", o, {
  91828. removeIfDef: !0
  91829. }),
  91830. i.compilationString += this._declareOutput(this.fresnel, i) + (" = computeFresnelTerm(" + this.viewDirection.associatedVariableName + ".xyz, " + this.worldNormal.associatedVariableName + ".xyz, " + this.bias.associatedVariableName + ", " + this.power.associatedVariableName + `);\r
  91831. `),
  91832. this
  91833. }
  91834. ,
  91835. e
  91836. }(NodeMaterialBlock);
  91837. RegisterClass("BABYLON.FresnelBlock", FresnelBlock);
  91838. var MaxBlock = function(a) {
  91839. __extends(e, a);
  91840. function e(i) {
  91841. var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
  91842. return o.registerInput("left", NodeMaterialBlockConnectionPointTypes.AutoDetect),
  91843. o.registerInput("right", NodeMaterialBlockConnectionPointTypes.AutoDetect),
  91844. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
  91845. o._outputs[0]._typeConnectionSource = o._inputs[0],
  91846. o._linkConnectionTypes(0, 1),
  91847. o
  91848. }
  91849. return e.prototype.getClassName = function() {
  91850. return "MaxBlock"
  91851. }
  91852. ,
  91853. Object.defineProperty(e.prototype, "left", {
  91854. get: function() {
  91855. return this._inputs[0]
  91856. },
  91857. enumerable: !1,
  91858. configurable: !0
  91859. }),
  91860. Object.defineProperty(e.prototype, "right", {
  91861. get: function() {
  91862. return this._inputs[1]
  91863. },
  91864. enumerable: !1,
  91865. configurable: !0
  91866. }),
  91867. Object.defineProperty(e.prototype, "output", {
  91868. get: function() {
  91869. return this._outputs[0]
  91870. },
  91871. enumerable: !1,
  91872. configurable: !0
  91873. }),
  91874. e.prototype._buildBlock = function(i) {
  91875. a.prototype._buildBlock.call(this, i);
  91876. var o = this._outputs[0];
  91877. return i.compilationString += this._declareOutput(o, i) + (" = max(" + this.left.associatedVariableName + ", " + this.right.associatedVariableName + `);\r
  91878. `),
  91879. this
  91880. }
  91881. ,
  91882. e
  91883. }(NodeMaterialBlock);
  91884. RegisterClass("BABYLON.MaxBlock", MaxBlock);
  91885. var MinBlock = function(a) {
  91886. __extends(e, a);
  91887. function e(i) {
  91888. var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
  91889. return o.registerInput("left", NodeMaterialBlockConnectionPointTypes.AutoDetect),
  91890. o.registerInput("right", NodeMaterialBlockConnectionPointTypes.AutoDetect),
  91891. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
  91892. o._outputs[0]._typeConnectionSource = o._inputs[0],
  91893. o._linkConnectionTypes(0, 1),
  91894. o
  91895. }
  91896. return e.prototype.getClassName = function() {
  91897. return "MinBlock"
  91898. }
  91899. ,
  91900. Object.defineProperty(e.prototype, "left", {
  91901. get: function() {
  91902. return this._inputs[0]
  91903. },
  91904. enumerable: !1,
  91905. configurable: !0
  91906. }),
  91907. Object.defineProperty(e.prototype, "right", {
  91908. get: function() {
  91909. return this._inputs[1]
  91910. },
  91911. enumerable: !1,
  91912. configurable: !0
  91913. }),
  91914. Object.defineProperty(e.prototype, "output", {
  91915. get: function() {
  91916. return this._outputs[0]
  91917. },
  91918. enumerable: !1,
  91919. configurable: !0
  91920. }),
  91921. e.prototype._buildBlock = function(i) {
  91922. a.prototype._buildBlock.call(this, i);
  91923. var o = this._outputs[0];
  91924. return i.compilationString += this._declareOutput(o, i) + (" = min(" + this.left.associatedVariableName + ", " + this.right.associatedVariableName + `);\r
  91925. `),
  91926. this
  91927. }
  91928. ,
  91929. e
  91930. }(NodeMaterialBlock);
  91931. RegisterClass("BABYLON.MinBlock", MinBlock);
  91932. var DistanceBlock = function(a) {
  91933. __extends(e, a);
  91934. function e(i) {
  91935. var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
  91936. return o.registerInput("left", NodeMaterialBlockConnectionPointTypes.AutoDetect),
  91937. o.registerInput("right", NodeMaterialBlockConnectionPointTypes.AutoDetect),
  91938. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Float),
  91939. o._linkConnectionTypes(0, 1),
  91940. o._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float),
  91941. o._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix),
  91942. o._inputs[1].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float),
  91943. o._inputs[1].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix),
  91944. o
  91945. }
  91946. return e.prototype.getClassName = function() {
  91947. return "DistanceBlock"
  91948. }
  91949. ,
  91950. Object.defineProperty(e.prototype, "left", {
  91951. get: function() {
  91952. return this._inputs[0]
  91953. },
  91954. enumerable: !1,
  91955. configurable: !0
  91956. }),
  91957. Object.defineProperty(e.prototype, "right", {
  91958. get: function() {
  91959. return this._inputs[1]
  91960. },
  91961. enumerable: !1,
  91962. configurable: !0
  91963. }),
  91964. Object.defineProperty(e.prototype, "output", {
  91965. get: function() {
  91966. return this._outputs[0]
  91967. },
  91968. enumerable: !1,
  91969. configurable: !0
  91970. }),
  91971. e.prototype._buildBlock = function(i) {
  91972. a.prototype._buildBlock.call(this, i);
  91973. var o = this._outputs[0];
  91974. return i.compilationString += this._declareOutput(o, i) + (" = length(" + this.left.associatedVariableName + " - " + this.right.associatedVariableName + `);\r
  91975. `),
  91976. this
  91977. }
  91978. ,
  91979. e
  91980. }(NodeMaterialBlock);
  91981. RegisterClass("BABYLON.DistanceBlock", DistanceBlock);
  91982. var LengthBlock = function(a) {
  91983. __extends(e, a);
  91984. function e(i) {
  91985. var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
  91986. return o.registerInput("value", NodeMaterialBlockConnectionPointTypes.AutoDetect),
  91987. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Float),
  91988. o._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float),
  91989. o._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix),
  91990. o
  91991. }
  91992. return e.prototype.getClassName = function() {
  91993. return "LengthBlock"
  91994. }
  91995. ,
  91996. Object.defineProperty(e.prototype, "value", {
  91997. get: function() {
  91998. return this._inputs[0]
  91999. },
  92000. enumerable: !1,
  92001. configurable: !0
  92002. }),
  92003. Object.defineProperty(e.prototype, "output", {
  92004. get: function() {
  92005. return this._outputs[0]
  92006. },
  92007. enumerable: !1,
  92008. configurable: !0
  92009. }),
  92010. e.prototype._buildBlock = function(i) {
  92011. a.prototype._buildBlock.call(this, i);
  92012. var o = this._outputs[0];
  92013. return i.compilationString += this._declareOutput(o, i) + (" = length(" + this.value.associatedVariableName + `);\r
  92014. `),
  92015. this
  92016. }
  92017. ,
  92018. e
  92019. }(NodeMaterialBlock);
  92020. RegisterClass("BABYLON.LengthBlock", LengthBlock);
  92021. var NegateBlock = function(a) {
  92022. __extends(e, a);
  92023. function e(i) {
  92024. var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
  92025. return o.registerInput("value", NodeMaterialBlockConnectionPointTypes.AutoDetect),
  92026. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
  92027. o._outputs[0]._typeConnectionSource = o._inputs[0],
  92028. o
  92029. }
  92030. return e.prototype.getClassName = function() {
  92031. return "NegateBlock"
  92032. }
  92033. ,
  92034. Object.defineProperty(e.prototype, "value", {
  92035. get: function() {
  92036. return this._inputs[0]
  92037. },
  92038. enumerable: !1,
  92039. configurable: !0
  92040. }),
  92041. Object.defineProperty(e.prototype, "output", {
  92042. get: function() {
  92043. return this._outputs[0]
  92044. },
  92045. enumerable: !1,
  92046. configurable: !0
  92047. }),
  92048. e.prototype._buildBlock = function(i) {
  92049. a.prototype._buildBlock.call(this, i);
  92050. var o = this._outputs[0];
  92051. return i.compilationString += this._declareOutput(o, i) + (" = -1.0 * " + this.value.associatedVariableName + `;\r
  92052. `),
  92053. this
  92054. }
  92055. ,
  92056. e
  92057. }(NodeMaterialBlock);
  92058. RegisterClass("BABYLON.NegateBlock", NegateBlock);
  92059. var PowBlock = function(a) {
  92060. __extends(e, a);
  92061. function e(i) {
  92062. var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
  92063. return o.registerInput("value", NodeMaterialBlockConnectionPointTypes.AutoDetect),
  92064. o.registerInput("power", NodeMaterialBlockConnectionPointTypes.AutoDetect),
  92065. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
  92066. o._outputs[0]._typeConnectionSource = o._inputs[0],
  92067. o._linkConnectionTypes(0, 1),
  92068. o
  92069. }
  92070. return e.prototype.getClassName = function() {
  92071. return "PowBlock"
  92072. }
  92073. ,
  92074. Object.defineProperty(e.prototype, "value", {
  92075. get: function() {
  92076. return this._inputs[0]
  92077. },
  92078. enumerable: !1,
  92079. configurable: !0
  92080. }),
  92081. Object.defineProperty(e.prototype, "power", {
  92082. get: function() {
  92083. return this._inputs[1]
  92084. },
  92085. enumerable: !1,
  92086. configurable: !0
  92087. }),
  92088. Object.defineProperty(e.prototype, "output", {
  92089. get: function() {
  92090. return this._outputs[0]
  92091. },
  92092. enumerable: !1,
  92093. configurable: !0
  92094. }),
  92095. e.prototype._buildBlock = function(i) {
  92096. a.prototype._buildBlock.call(this, i);
  92097. var o = this._outputs[0];
  92098. return i.compilationString += this._declareOutput(o, i) + (" = pow(" + this.value.associatedVariableName + ", " + this.power.associatedVariableName + `);\r
  92099. `),
  92100. this
  92101. }
  92102. ,
  92103. e
  92104. }(NodeMaterialBlock);
  92105. RegisterClass("BABYLON.PowBlock", PowBlock);
  92106. var RandomNumberBlock = function(a) {
  92107. __extends(e, a);
  92108. function e(i) {
  92109. var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
  92110. return o.registerInput("seed", NodeMaterialBlockConnectionPointTypes.Vector2),
  92111. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Float),
  92112. o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector3),
  92113. o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector4),
  92114. o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color3),
  92115. o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color4),
  92116. o
  92117. }
  92118. return e.prototype.getClassName = function() {
  92119. return "RandomNumberBlock"
  92120. }
  92121. ,
  92122. Object.defineProperty(e.prototype, "seed", {
  92123. get: function() {
  92124. return this._inputs[0]
  92125. },
  92126. enumerable: !1,
  92127. configurable: !0
  92128. }),
  92129. Object.defineProperty(e.prototype, "output", {
  92130. get: function() {
  92131. return this._outputs[0]
  92132. },
  92133. enumerable: !1,
  92134. configurable: !0
  92135. }),
  92136. e.prototype._buildBlock = function(i) {
  92137. a.prototype._buildBlock.call(this, i);
  92138. var o = this._outputs[0]
  92139. , s = "//" + this.name;
  92140. return i._emitFunctionFromInclude("helperFunctions", s),
  92141. i.compilationString += this._declareOutput(o, i) + (" = getRand(" + this.seed.associatedVariableName + `.xy);\r
  92142. `),
  92143. this
  92144. }
  92145. ,
  92146. e
  92147. }(NodeMaterialBlock);
  92148. RegisterClass("BABYLON.RandomNumberBlock", RandomNumberBlock);
  92149. var ArcTan2Block = function(a) {
  92150. __extends(e, a);
  92151. function e(i) {
  92152. var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
  92153. return o.registerInput("x", NodeMaterialBlockConnectionPointTypes.Float),
  92154. o.registerInput("y", NodeMaterialBlockConnectionPointTypes.Float),
  92155. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Float),
  92156. o
  92157. }
  92158. return e.prototype.getClassName = function() {
  92159. return "ArcTan2Block"
  92160. }
  92161. ,
  92162. Object.defineProperty(e.prototype, "x", {
  92163. get: function() {
  92164. return this._inputs[0]
  92165. },
  92166. enumerable: !1,
  92167. configurable: !0
  92168. }),
  92169. Object.defineProperty(e.prototype, "y", {
  92170. get: function() {
  92171. return this._inputs[1]
  92172. },
  92173. enumerable: !1,
  92174. configurable: !0
  92175. }),
  92176. Object.defineProperty(e.prototype, "output", {
  92177. get: function() {
  92178. return this._outputs[0]
  92179. },
  92180. enumerable: !1,
  92181. configurable: !0
  92182. }),
  92183. e.prototype._buildBlock = function(i) {
  92184. a.prototype._buildBlock.call(this, i);
  92185. var o = this._outputs[0];
  92186. return i.compilationString += this._declareOutput(o, i) + (" = atan(" + this.x.associatedVariableName + ", " + this.y.associatedVariableName + `);\r
  92187. `),
  92188. this
  92189. }
  92190. ,
  92191. e
  92192. }(NodeMaterialBlock);
  92193. RegisterClass("BABYLON.ArcTan2Block", ArcTan2Block);
  92194. var SmoothStepBlock = function(a) {
  92195. __extends(e, a);
  92196. function e(i) {
  92197. var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
  92198. return o.registerInput("value", NodeMaterialBlockConnectionPointTypes.AutoDetect),
  92199. o.registerInput("edge0", NodeMaterialBlockConnectionPointTypes.Float),
  92200. o.registerInput("edge1", NodeMaterialBlockConnectionPointTypes.Float),
  92201. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
  92202. o._outputs[0]._typeConnectionSource = o._inputs[0],
  92203. o
  92204. }
  92205. return e.prototype.getClassName = function() {
  92206. return "SmoothStepBlock"
  92207. }
  92208. ,
  92209. Object.defineProperty(e.prototype, "value", {
  92210. get: function() {
  92211. return this._inputs[0]
  92212. },
  92213. enumerable: !1,
  92214. configurable: !0
  92215. }),
  92216. Object.defineProperty(e.prototype, "edge0", {
  92217. get: function() {
  92218. return this._inputs[1]
  92219. },
  92220. enumerable: !1,
  92221. configurable: !0
  92222. }),
  92223. Object.defineProperty(e.prototype, "edge1", {
  92224. get: function() {
  92225. return this._inputs[2]
  92226. },
  92227. enumerable: !1,
  92228. configurable: !0
  92229. }),
  92230. Object.defineProperty(e.prototype, "output", {
  92231. get: function() {
  92232. return this._outputs[0]
  92233. },
  92234. enumerable: !1,
  92235. configurable: !0
  92236. }),
  92237. e.prototype._buildBlock = function(i) {
  92238. a.prototype._buildBlock.call(this, i);
  92239. var o = this._outputs[0];
  92240. return i.compilationString += this._declareOutput(o, i) + (" = smoothstep(" + this.edge0.associatedVariableName + ", " + this.edge1.associatedVariableName + ", " + this.value.associatedVariableName + `);\r
  92241. `),
  92242. this
  92243. }
  92244. ,
  92245. e
  92246. }(NodeMaterialBlock);
  92247. RegisterClass("BABYLON.SmoothStepBlock", SmoothStepBlock);
  92248. var ReciprocalBlock = function(a) {
  92249. __extends(e, a);
  92250. function e(i) {
  92251. var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
  92252. return o.registerInput("input", NodeMaterialBlockConnectionPointTypes.AutoDetect),
  92253. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
  92254. o._outputs[0]._typeConnectionSource = o._inputs[0],
  92255. o._outputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix),
  92256. o
  92257. }
  92258. return e.prototype.getClassName = function() {
  92259. return "ReciprocalBlock"
  92260. }
  92261. ,
  92262. Object.defineProperty(e.prototype, "input", {
  92263. get: function() {
  92264. return this._inputs[0]
  92265. },
  92266. enumerable: !1,
  92267. configurable: !0
  92268. }),
  92269. Object.defineProperty(e.prototype, "output", {
  92270. get: function() {
  92271. return this._outputs[0]
  92272. },
  92273. enumerable: !1,
  92274. configurable: !0
  92275. }),
  92276. e.prototype._buildBlock = function(i) {
  92277. a.prototype._buildBlock.call(this, i);
  92278. var o = this._outputs[0];
  92279. return i.compilationString += this._declareOutput(o, i) + (" = 1. / " + this.input.associatedVariableName + `;\r
  92280. `),
  92281. this
  92282. }
  92283. ,
  92284. e
  92285. }(NodeMaterialBlock);
  92286. RegisterClass("BABYLON.ReciprocalBlock", ReciprocalBlock);
  92287. var ReplaceColorBlock = function(a) {
  92288. __extends(e, a);
  92289. function e(i) {
  92290. var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
  92291. return o.registerInput("value", NodeMaterialBlockConnectionPointTypes.AutoDetect),
  92292. o.registerInput("reference", NodeMaterialBlockConnectionPointTypes.AutoDetect),
  92293. o.registerInput("distance", NodeMaterialBlockConnectionPointTypes.Float),
  92294. o.registerInput("replacement", NodeMaterialBlockConnectionPointTypes.AutoDetect),
  92295. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
  92296. o._outputs[0]._typeConnectionSource = o._inputs[0],
  92297. o._linkConnectionTypes(0, 1),
  92298. o._linkConnectionTypes(0, 3),
  92299. o._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float),
  92300. o._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix),
  92301. o._inputs[1].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float),
  92302. o._inputs[1].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix),
  92303. o._inputs[3].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float),
  92304. o._inputs[3].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix),
  92305. o
  92306. }
  92307. return e.prototype.getClassName = function() {
  92308. return "ReplaceColorBlock"
  92309. }
  92310. ,
  92311. Object.defineProperty(e.prototype, "value", {
  92312. get: function() {
  92313. return this._inputs[0]
  92314. },
  92315. enumerable: !1,
  92316. configurable: !0
  92317. }),
  92318. Object.defineProperty(e.prototype, "reference", {
  92319. get: function() {
  92320. return this._inputs[1]
  92321. },
  92322. enumerable: !1,
  92323. configurable: !0
  92324. }),
  92325. Object.defineProperty(e.prototype, "distance", {
  92326. get: function() {
  92327. return this._inputs[2]
  92328. },
  92329. enumerable: !1,
  92330. configurable: !0
  92331. }),
  92332. Object.defineProperty(e.prototype, "replacement", {
  92333. get: function() {
  92334. return this._inputs[3]
  92335. },
  92336. enumerable: !1,
  92337. configurable: !0
  92338. }),
  92339. Object.defineProperty(e.prototype, "output", {
  92340. get: function() {
  92341. return this._outputs[0]
  92342. },
  92343. enumerable: !1,
  92344. configurable: !0
  92345. }),
  92346. e.prototype._buildBlock = function(i) {
  92347. a.prototype._buildBlock.call(this, i);
  92348. var o = this._outputs[0];
  92349. return i.compilationString += this._declareOutput(o, i) + `;\r
  92350. `,
  92351. i.compilationString += "if (length(" + this.value.associatedVariableName + " - " + this.reference.associatedVariableName + ") < " + this.distance.associatedVariableName + `) {\r
  92352. `,
  92353. i.compilationString += o.associatedVariableName + " = " + this.replacement.associatedVariableName + `;\r
  92354. `,
  92355. i.compilationString += `} else {\r
  92356. `,
  92357. i.compilationString += o.associatedVariableName + " = " + this.value.associatedVariableName + `;\r
  92358. `,
  92359. i.compilationString += `}\r
  92360. `,
  92361. this
  92362. }
  92363. ,
  92364. e
  92365. }(NodeMaterialBlock);
  92366. RegisterClass("BABYLON.ReplaceColorBlock", ReplaceColorBlock);
  92367. var PosterizeBlock = function(a) {
  92368. __extends(e, a);
  92369. function e(i) {
  92370. var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
  92371. return o.registerInput("value", NodeMaterialBlockConnectionPointTypes.AutoDetect),
  92372. o.registerInput("steps", NodeMaterialBlockConnectionPointTypes.AutoDetect),
  92373. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
  92374. o._outputs[0]._typeConnectionSource = o._inputs[0],
  92375. o._linkConnectionTypes(0, 1),
  92376. o._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix),
  92377. o._inputs[1].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix),
  92378. o
  92379. }
  92380. return e.prototype.getClassName = function() {
  92381. return "PosterizeBlock"
  92382. }
  92383. ,
  92384. Object.defineProperty(e.prototype, "value", {
  92385. get: function() {
  92386. return this._inputs[0]
  92387. },
  92388. enumerable: !1,
  92389. configurable: !0
  92390. }),
  92391. Object.defineProperty(e.prototype, "steps", {
  92392. get: function() {
  92393. return this._inputs[1]
  92394. },
  92395. enumerable: !1,
  92396. configurable: !0
  92397. }),
  92398. Object.defineProperty(e.prototype, "output", {
  92399. get: function() {
  92400. return this._outputs[0]
  92401. },
  92402. enumerable: !1,
  92403. configurable: !0
  92404. }),
  92405. e.prototype._buildBlock = function(i) {
  92406. a.prototype._buildBlock.call(this, i);
  92407. var o = this._outputs[0];
  92408. return i.compilationString += this._declareOutput(o, i) + (" = floor(" + this.value.associatedVariableName + " / (1.0 / " + this.steps.associatedVariableName + ")) * (1.0 / " + this.steps.associatedVariableName + `);\r
  92409. `),
  92410. this
  92411. }
  92412. ,
  92413. e
  92414. }(NodeMaterialBlock);
  92415. RegisterClass("BABYLON.PosterizeBlock", PosterizeBlock);
  92416. var WaveBlockKind;
  92417. (function(a) {
  92418. a[a.SawTooth = 0] = "SawTooth",
  92419. a[a.Square = 1] = "Square",
  92420. a[a.Triangle = 2] = "Triangle"
  92421. }
  92422. )(WaveBlockKind || (WaveBlockKind = {}));
  92423. var WaveBlock = function(a) {
  92424. __extends(e, a);
  92425. function e(i) {
  92426. var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
  92427. return o.kind = WaveBlockKind.SawTooth,
  92428. o.registerInput("input", NodeMaterialBlockConnectionPointTypes.AutoDetect),
  92429. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
  92430. o._outputs[0]._typeConnectionSource = o._inputs[0],
  92431. o._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix),
  92432. o
  92433. }
  92434. return e.prototype.getClassName = function() {
  92435. return "WaveBlock"
  92436. }
  92437. ,
  92438. Object.defineProperty(e.prototype, "input", {
  92439. get: function() {
  92440. return this._inputs[0]
  92441. },
  92442. enumerable: !1,
  92443. configurable: !0
  92444. }),
  92445. Object.defineProperty(e.prototype, "output", {
  92446. get: function() {
  92447. return this._outputs[0]
  92448. },
  92449. enumerable: !1,
  92450. configurable: !0
  92451. }),
  92452. e.prototype._buildBlock = function(i) {
  92453. a.prototype._buildBlock.call(this, i);
  92454. var o = this._outputs[0];
  92455. switch (this.kind) {
  92456. case WaveBlockKind.SawTooth:
  92457. {
  92458. i.compilationString += this._declareOutput(o, i) + (" = " + this.input.associatedVariableName + " - floor(0.5 + " + this.input.associatedVariableName + `);\r
  92459. `);
  92460. break
  92461. }
  92462. case WaveBlockKind.Square:
  92463. {
  92464. i.compilationString += this._declareOutput(o, i) + (" = 1.0 - 2.0 * round(fract(" + this.input.associatedVariableName + `));\r
  92465. `);
  92466. break
  92467. }
  92468. case WaveBlockKind.Triangle:
  92469. {
  92470. i.compilationString += this._declareOutput(o, i) + (" = 2.0 * abs(2.0 * (" + this.input.associatedVariableName + " - floor(0.5 + " + this.input.associatedVariableName + `))) - 1.0;\r
  92471. `);
  92472. break
  92473. }
  92474. }
  92475. return this
  92476. }
  92477. ,
  92478. e.prototype.serialize = function() {
  92479. var i = a.prototype.serialize.call(this);
  92480. return i.kind = this.kind,
  92481. i
  92482. }
  92483. ,
  92484. e.prototype._deserialize = function(i, o, s) {
  92485. a.prototype._deserialize.call(this, i, o, s),
  92486. this.kind = i.kind
  92487. }
  92488. ,
  92489. e
  92490. }(NodeMaterialBlock);
  92491. RegisterClass("BABYLON.WaveBlock", WaveBlock);
  92492. var GradientBlockColorStep = function() {
  92493. function a(e, i) {
  92494. this.step = e,
  92495. this.color = i
  92496. }
  92497. return Object.defineProperty(a.prototype, "step", {
  92498. get: function() {
  92499. return this._step
  92500. },
  92501. set: function(e) {
  92502. this._step = e
  92503. },
  92504. enumerable: !1,
  92505. configurable: !0
  92506. }),
  92507. Object.defineProperty(a.prototype, "color", {
  92508. get: function() {
  92509. return this._color
  92510. },
  92511. set: function(e) {
  92512. this._color = e
  92513. },
  92514. enumerable: !1,
  92515. configurable: !0
  92516. }),
  92517. a
  92518. }()
  92519. , GradientBlock = function(a) {
  92520. __extends(e, a);
  92521. function e(i) {
  92522. var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
  92523. return o.colorSteps = [new GradientBlockColorStep(0,Color3.Black()), new GradientBlockColorStep(1,Color3.White())],
  92524. o.onValueChangedObservable = new Observable,
  92525. o.registerInput("gradient", NodeMaterialBlockConnectionPointTypes.Float),
  92526. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Color3),
  92527. o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector2),
  92528. o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector3),
  92529. o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector4),
  92530. o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color3),
  92531. o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color4),
  92532. o
  92533. }
  92534. return e.prototype.colorStepsUpdated = function() {
  92535. this.onValueChangedObservable.notifyObservers(this)
  92536. }
  92537. ,
  92538. e.prototype.getClassName = function() {
  92539. return "GradientBlock"
  92540. }
  92541. ,
  92542. Object.defineProperty(e.prototype, "gradient", {
  92543. get: function() {
  92544. return this._inputs[0]
  92545. },
  92546. enumerable: !1,
  92547. configurable: !0
  92548. }),
  92549. Object.defineProperty(e.prototype, "output", {
  92550. get: function() {
  92551. return this._outputs[0]
  92552. },
  92553. enumerable: !1,
  92554. configurable: !0
  92555. }),
  92556. e.prototype._writeColorConstant = function(i) {
  92557. var o = this.colorSteps[i];
  92558. return "vec3(" + o.color.r + ", " + o.color.g + ", " + o.color.b + ")"
  92559. }
  92560. ,
  92561. e.prototype._buildBlock = function(i) {
  92562. a.prototype._buildBlock.call(this, i);
  92563. var o = this._outputs[0];
  92564. if (!this.colorSteps.length || !this.gradient.connectedPoint) {
  92565. i.compilationString += this._declareOutput(o, i) + ` = vec3(0., 0., 0.);\r
  92566. `;
  92567. return
  92568. }
  92569. var s = i._getFreeVariableName("gradientTempColor")
  92570. , c = i._getFreeVariableName("gradientTempPosition");
  92571. i.compilationString += "vec3 " + s + " = " + this._writeColorConstant(0) + `;\r
  92572. `,
  92573. i.compilationString += "float " + c + `;\r
  92574. `;
  92575. var d = this.gradient.associatedVariableName;
  92576. this.gradient.connectedPoint.type !== NodeMaterialBlockConnectionPointTypes.Float && (d += ".x");
  92577. for (var _ = 1; _ < this.colorSteps.length; _++) {
  92578. var b = this.colorSteps[_]
  92579. , k = this.colorSteps[_ - 1];
  92580. i.compilationString += c + " = clamp((" + d + " - " + i._emitFloat(k.step) + ") / (" + i._emitFloat(b.step) + " - " + i._emitFloat(k.step) + "), 0.0, 1.0) * step(" + i._emitFloat(_) + ", " + i._emitFloat(this.colorSteps.length - 1) + `);\r
  92581. `,
  92582. i.compilationString += s + " = mix(" + s + ", " + this._writeColorConstant(_) + ", " + c + `);\r
  92583. `
  92584. }
  92585. return i.compilationString += this._declareOutput(o, i) + (" = " + s + `;\r
  92586. `),
  92587. this
  92588. }
  92589. ,
  92590. e.prototype.serialize = function() {
  92591. var i = a.prototype.serialize.call(this);
  92592. i.colorSteps = [];
  92593. for (var o = 0, s = this.colorSteps; o < s.length; o++) {
  92594. var c = s[o];
  92595. i.colorSteps.push({
  92596. step: c.step,
  92597. color: {
  92598. r: c.color.r,
  92599. g: c.color.g,
  92600. b: c.color.b
  92601. }
  92602. })
  92603. }
  92604. return i
  92605. }
  92606. ,
  92607. e.prototype._deserialize = function(i, o, s) {
  92608. a.prototype._deserialize.call(this, i, o, s),
  92609. this.colorSteps = [];
  92610. for (var c = 0, d = i.colorSteps; c < d.length; c++) {
  92611. var _ = d[c];
  92612. this.colorSteps.push(new GradientBlockColorStep(_.step,new Color3(_.color.r,_.color.g,_.color.b)))
  92613. }
  92614. }
  92615. ,
  92616. e.prototype._dumpPropertiesCode = function() {
  92617. var i = a.prototype._dumpPropertiesCode.call(this);
  92618. i += this._codeVariableName + `.colorSteps = [];\r
  92619. `;
  92620. for (var o = 0, s = this.colorSteps; o < s.length; o++) {
  92621. var c = s[o];
  92622. i += this._codeVariableName + ".colorSteps.push(new BABYLON.GradientBlockColorStep(" + c.step + ", new BABYLON.Color3(" + c.color.r + ", " + c.color.g + ", " + c.color.b + `)));\r
  92623. `
  92624. }
  92625. return i
  92626. }
  92627. ,
  92628. e
  92629. }(NodeMaterialBlock);
  92630. RegisterClass("BABYLON.GradientBlock", GradientBlock);
  92631. var NLerpBlock = function(a) {
  92632. __extends(e, a);
  92633. function e(i) {
  92634. var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
  92635. return o.registerInput("left", NodeMaterialBlockConnectionPointTypes.AutoDetect),
  92636. o.registerInput("right", NodeMaterialBlockConnectionPointTypes.AutoDetect),
  92637. o.registerInput("gradient", NodeMaterialBlockConnectionPointTypes.AutoDetect),
  92638. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
  92639. o._outputs[0]._typeConnectionSource = o._inputs[0],
  92640. o._linkConnectionTypes(0, 1),
  92641. o._linkConnectionTypes(1, 2, !0),
  92642. o._inputs[2].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float),
  92643. o
  92644. }
  92645. return e.prototype.getClassName = function() {
  92646. return "NLerpBlock"
  92647. }
  92648. ,
  92649. Object.defineProperty(e.prototype, "left", {
  92650. get: function() {
  92651. return this._inputs[0]
  92652. },
  92653. enumerable: !1,
  92654. configurable: !0
  92655. }),
  92656. Object.defineProperty(e.prototype, "right", {
  92657. get: function() {
  92658. return this._inputs[1]
  92659. },
  92660. enumerable: !1,
  92661. configurable: !0
  92662. }),
  92663. Object.defineProperty(e.prototype, "gradient", {
  92664. get: function() {
  92665. return this._inputs[2]
  92666. },
  92667. enumerable: !1,
  92668. configurable: !0
  92669. }),
  92670. Object.defineProperty(e.prototype, "output", {
  92671. get: function() {
  92672. return this._outputs[0]
  92673. },
  92674. enumerable: !1,
  92675. configurable: !0
  92676. }),
  92677. e.prototype._buildBlock = function(i) {
  92678. a.prototype._buildBlock.call(this, i);
  92679. var o = this._outputs[0];
  92680. return i.compilationString += this._declareOutput(o, i) + (" = normalize(mix(" + this.left.associatedVariableName + " , " + this.right.associatedVariableName + ", " + this.gradient.associatedVariableName + `));\r
  92681. `),
  92682. this
  92683. }
  92684. ,
  92685. e
  92686. }(NodeMaterialBlock);
  92687. RegisterClass("BABYLON.NLerpBlock", NLerpBlock);
  92688. var WorleyNoise3DBlock = function(a) {
  92689. __extends(e, a);
  92690. function e(i) {
  92691. var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
  92692. return o.manhattanDistance = !1,
  92693. o.registerInput("seed", NodeMaterialBlockConnectionPointTypes.Vector3),
  92694. o.registerInput("jitter", NodeMaterialBlockConnectionPointTypes.Float),
  92695. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Vector2),
  92696. o.registerOutput("x", NodeMaterialBlockConnectionPointTypes.Float),
  92697. o.registerOutput("y", NodeMaterialBlockConnectionPointTypes.Float),
  92698. o
  92699. }
  92700. return e.prototype.getClassName = function() {
  92701. return "WorleyNoise3DBlock"
  92702. }
  92703. ,
  92704. Object.defineProperty(e.prototype, "seed", {
  92705. get: function() {
  92706. return this._inputs[0]
  92707. },
  92708. enumerable: !1,
  92709. configurable: !0
  92710. }),
  92711. Object.defineProperty(e.prototype, "jitter", {
  92712. get: function() {
  92713. return this._inputs[1]
  92714. },
  92715. enumerable: !1,
  92716. configurable: !0
  92717. }),
  92718. Object.defineProperty(e.prototype, "output", {
  92719. get: function() {
  92720. return this._outputs[0]
  92721. },
  92722. enumerable: !1,
  92723. configurable: !0
  92724. }),
  92725. Object.defineProperty(e.prototype, "x", {
  92726. get: function() {
  92727. return this._outputs[1]
  92728. },
  92729. enumerable: !1,
  92730. configurable: !0
  92731. }),
  92732. Object.defineProperty(e.prototype, "y", {
  92733. get: function() {
  92734. return this._outputs[2]
  92735. },
  92736. enumerable: !1,
  92737. configurable: !0
  92738. }),
  92739. e.prototype._buildBlock = function(i) {
  92740. if (a.prototype._buildBlock.call(this, i),
  92741. !!this.seed.isConnected && !(!this.output.hasEndpoints && !this.x.hasEndpoints && !this.y.hasEndpoints)) {
  92742. var o = `vec3 permute(vec3 x){\r
  92743. `;
  92744. o += ` return mod((34.0 * x + 1.0) * x, 289.0);\r
  92745. `,
  92746. o += `}\r
  92747. \r
  92748. `,
  92749. o += `vec3 dist(vec3 x, vec3 y, vec3 z, bool manhattanDistance){\r
  92750. `,
  92751. o += ` return manhattanDistance ? abs(x) + abs(y) + abs(z) : (x * x + y * y + z * z);\r
  92752. `,
  92753. o += `}\r
  92754. \r
  92755. `,
  92756. o += `vec2 worley(vec3 P, float jitter, bool manhattanDistance){\r
  92757. `,
  92758. o += ` float K = 0.142857142857; // 1/7\r
  92759. `,
  92760. o += ` float Ko = 0.428571428571; // 1/2-K/2\r
  92761. `,
  92762. o += ` float K2 = 0.020408163265306; // 1/(7*7)\r
  92763. `,
  92764. o += ` float Kz = 0.166666666667; // 1/6\r
  92765. `,
  92766. o += ` float Kzo = 0.416666666667; // 1/2-1/6*2\r
  92767. `,
  92768. o += `\r
  92769. `,
  92770. o += ` vec3 Pi = mod(floor(P), 289.0);\r
  92771. `,
  92772. o += ` vec3 Pf = fract(P) - 0.5;\r
  92773. `,
  92774. o += `\r
  92775. `,
  92776. o += ` vec3 Pfx = Pf.x + vec3(1.0, 0.0, -1.0);\r
  92777. `,
  92778. o += ` vec3 Pfy = Pf.y + vec3(1.0, 0.0, -1.0);\r
  92779. `,
  92780. o += ` vec3 Pfz = Pf.z + vec3(1.0, 0.0, -1.0);\r
  92781. `,
  92782. o += `\r
  92783. `,
  92784. o += ` vec3 p = permute(Pi.x + vec3(-1.0, 0.0, 1.0));\r
  92785. `,
  92786. o += ` vec3 p1 = permute(p + Pi.y - 1.0);\r
  92787. `,
  92788. o += ` vec3 p2 = permute(p + Pi.y);\r
  92789. `,
  92790. o += ` vec3 p3 = permute(p + Pi.y + 1.0);\r
  92791. `,
  92792. o += `\r
  92793. `,
  92794. o += ` vec3 p11 = permute(p1 + Pi.z - 1.0);\r
  92795. `,
  92796. o += ` vec3 p12 = permute(p1 + Pi.z);\r
  92797. `,
  92798. o += ` vec3 p13 = permute(p1 + Pi.z + 1.0);\r
  92799. `,
  92800. o += `\r
  92801. `,
  92802. o += ` vec3 p21 = permute(p2 + Pi.z - 1.0);\r
  92803. `,
  92804. o += ` vec3 p22 = permute(p2 + Pi.z);\r
  92805. `,
  92806. o += ` vec3 p23 = permute(p2 + Pi.z + 1.0);\r
  92807. `,
  92808. o += `\r
  92809. `,
  92810. o += ` vec3 p31 = permute(p3 + Pi.z - 1.0);\r
  92811. `,
  92812. o += ` vec3 p32 = permute(p3 + Pi.z);\r
  92813. `,
  92814. o += ` vec3 p33 = permute(p3 + Pi.z + 1.0);\r
  92815. `,
  92816. o += `\r
  92817. `,
  92818. o += ` vec3 ox11 = fract(p11*K) - Ko;\r
  92819. `,
  92820. o += ` vec3 oy11 = mod(floor(p11*K), 7.0)*K - Ko;\r
  92821. `,
  92822. o += ` vec3 oz11 = floor(p11*K2)*Kz - Kzo; // p11 < 289 guaranteed\r
  92823. `,
  92824. o += `\r
  92825. `,
  92826. o += ` vec3 ox12 = fract(p12*K) - Ko;\r
  92827. `,
  92828. o += ` vec3 oy12 = mod(floor(p12*K), 7.0)*K - Ko;\r
  92829. `,
  92830. o += ` vec3 oz12 = floor(p12*K2)*Kz - Kzo;\r
  92831. `,
  92832. o += `\r
  92833. `,
  92834. o += ` vec3 ox13 = fract(p13*K) - Ko;\r
  92835. `,
  92836. o += ` vec3 oy13 = mod(floor(p13*K), 7.0)*K - Ko;\r
  92837. `,
  92838. o += ` vec3 oz13 = floor(p13*K2)*Kz - Kzo;\r
  92839. `,
  92840. o += `\r
  92841. `,
  92842. o += ` vec3 ox21 = fract(p21*K) - Ko;\r
  92843. `,
  92844. o += ` vec3 oy21 = mod(floor(p21*K), 7.0)*K - Ko;\r
  92845. `,
  92846. o += ` vec3 oz21 = floor(p21*K2)*Kz - Kzo;\r
  92847. `,
  92848. o += `\r
  92849. `,
  92850. o += ` vec3 ox22 = fract(p22*K) - Ko;\r
  92851. `,
  92852. o += ` vec3 oy22 = mod(floor(p22*K), 7.0)*K - Ko;\r
  92853. `,
  92854. o += ` vec3 oz22 = floor(p22*K2)*Kz - Kzo;\r
  92855. `,
  92856. o += `\r
  92857. `,
  92858. o += ` vec3 ox23 = fract(p23*K) - Ko;\r
  92859. `,
  92860. o += ` vec3 oy23 = mod(floor(p23*K), 7.0)*K - Ko;\r
  92861. `,
  92862. o += ` vec3 oz23 = floor(p23*K2)*Kz - Kzo;\r
  92863. `,
  92864. o += `\r
  92865. `,
  92866. o += ` vec3 ox31 = fract(p31*K) - Ko;\r
  92867. `,
  92868. o += ` vec3 oy31 = mod(floor(p31*K), 7.0)*K - Ko;\r
  92869. `,
  92870. o += ` vec3 oz31 = floor(p31*K2)*Kz - Kzo;\r
  92871. `,
  92872. o += `\r
  92873. `,
  92874. o += ` vec3 ox32 = fract(p32*K) - Ko;\r
  92875. `,
  92876. o += ` vec3 oy32 = mod(floor(p32*K), 7.0)*K - Ko;\r
  92877. `,
  92878. o += ` vec3 oz32 = floor(p32*K2)*Kz - Kzo;\r
  92879. `,
  92880. o += `\r
  92881. `,
  92882. o += ` vec3 ox33 = fract(p33*K) - Ko;\r
  92883. `,
  92884. o += ` vec3 oy33 = mod(floor(p33*K), 7.0)*K - Ko;\r
  92885. `,
  92886. o += ` vec3 oz33 = floor(p33*K2)*Kz - Kzo;\r
  92887. `,
  92888. o += `\r
  92889. `,
  92890. o += ` vec3 dx11 = Pfx + jitter*ox11;\r
  92891. `,
  92892. o += ` vec3 dy11 = Pfy.x + jitter*oy11;\r
  92893. `,
  92894. o += ` vec3 dz11 = Pfz.x + jitter*oz11;\r
  92895. `,
  92896. o += `\r
  92897. `,
  92898. o += ` vec3 dx12 = Pfx + jitter*ox12;\r
  92899. `,
  92900. o += ` vec3 dy12 = Pfy.x + jitter*oy12;\r
  92901. `,
  92902. o += ` vec3 dz12 = Pfz.y + jitter*oz12;\r
  92903. `,
  92904. o += `\r
  92905. `,
  92906. o += ` vec3 dx13 = Pfx + jitter*ox13;\r
  92907. `,
  92908. o += ` vec3 dy13 = Pfy.x + jitter*oy13;\r
  92909. `,
  92910. o += ` vec3 dz13 = Pfz.z + jitter*oz13;\r
  92911. `,
  92912. o += `\r
  92913. `,
  92914. o += ` vec3 dx21 = Pfx + jitter*ox21;\r
  92915. `,
  92916. o += ` vec3 dy21 = Pfy.y + jitter*oy21;\r
  92917. `,
  92918. o += ` vec3 dz21 = Pfz.x + jitter*oz21;\r
  92919. `,
  92920. o += `\r
  92921. `,
  92922. o += ` vec3 dx22 = Pfx + jitter*ox22;\r
  92923. `,
  92924. o += ` vec3 dy22 = Pfy.y + jitter*oy22;\r
  92925. `,
  92926. o += ` vec3 dz22 = Pfz.y + jitter*oz22;\r
  92927. `,
  92928. o += `\r
  92929. `,
  92930. o += ` vec3 dx23 = Pfx + jitter*ox23;\r
  92931. `,
  92932. o += ` vec3 dy23 = Pfy.y + jitter*oy23;\r
  92933. `,
  92934. o += ` vec3 dz23 = Pfz.z + jitter*oz23;\r
  92935. `,
  92936. o += `\r
  92937. `,
  92938. o += ` vec3 dx31 = Pfx + jitter*ox31;\r
  92939. `,
  92940. o += ` vec3 dy31 = Pfy.z + jitter*oy31;\r
  92941. `,
  92942. o += ` vec3 dz31 = Pfz.x + jitter*oz31;\r
  92943. `,
  92944. o += `\r
  92945. `,
  92946. o += ` vec3 dx32 = Pfx + jitter*ox32;\r
  92947. `,
  92948. o += ` vec3 dy32 = Pfy.z + jitter*oy32;\r
  92949. `,
  92950. o += ` vec3 dz32 = Pfz.y + jitter*oz32;\r
  92951. `,
  92952. o += `\r
  92953. `,
  92954. o += ` vec3 dx33 = Pfx + jitter*ox33;\r
  92955. `,
  92956. o += ` vec3 dy33 = Pfy.z + jitter*oy33;\r
  92957. `,
  92958. o += ` vec3 dz33 = Pfz.z + jitter*oz33;\r
  92959. `,
  92960. o += `\r
  92961. `,
  92962. o += ` vec3 d11 = dist(dx11, dy11, dz11, manhattanDistance);\r
  92963. `,
  92964. o += ` vec3 d12 =dist(dx12, dy12, dz12, manhattanDistance);\r
  92965. `,
  92966. o += ` vec3 d13 = dist(dx13, dy13, dz13, manhattanDistance);\r
  92967. `,
  92968. o += ` vec3 d21 = dist(dx21, dy21, dz21, manhattanDistance);\r
  92969. `,
  92970. o += ` vec3 d22 = dist(dx22, dy22, dz22, manhattanDistance);\r
  92971. `,
  92972. o += ` vec3 d23 = dist(dx23, dy23, dz23, manhattanDistance);\r
  92973. `,
  92974. o += ` vec3 d31 = dist(dx31, dy31, dz31, manhattanDistance);\r
  92975. `,
  92976. o += ` vec3 d32 = dist(dx32, dy32, dz32, manhattanDistance);\r
  92977. `,
  92978. o += ` vec3 d33 = dist(dx33, dy33, dz33, manhattanDistance);\r
  92979. `,
  92980. o += `\r
  92981. `,
  92982. o += ` vec3 d1a = min(d11, d12);\r
  92983. `,
  92984. o += ` d12 = max(d11, d12);\r
  92985. `,
  92986. o += ` d11 = min(d1a, d13); // Smallest now not in d12 or d13\r
  92987. `,
  92988. o += ` d13 = max(d1a, d13);\r
  92989. `,
  92990. o += ` d12 = min(d12, d13); // 2nd smallest now not in d13\r
  92991. `,
  92992. o += ` vec3 d2a = min(d21, d22);\r
  92993. `,
  92994. o += ` d22 = max(d21, d22);\r
  92995. `,
  92996. o += ` d21 = min(d2a, d23); // Smallest now not in d22 or d23\r
  92997. `,
  92998. o += ` d23 = max(d2a, d23);\r
  92999. `,
  93000. o += ` d22 = min(d22, d23); // 2nd smallest now not in d23\r
  93001. `,
  93002. o += ` vec3 d3a = min(d31, d32);\r
  93003. `,
  93004. o += ` d32 = max(d31, d32);\r
  93005. `,
  93006. o += ` d31 = min(d3a, d33); // Smallest now not in d32 or d33\r
  93007. `,
  93008. o += ` d33 = max(d3a, d33);\r
  93009. `,
  93010. o += ` d32 = min(d32, d33); // 2nd smallest now not in d33\r
  93011. `,
  93012. o += ` vec3 da = min(d11, d21);\r
  93013. `,
  93014. o += ` d21 = max(d11, d21);\r
  93015. `,
  93016. o += ` d11 = min(da, d31); // Smallest now in d11\r
  93017. `,
  93018. o += ` d31 = max(da, d31); // 2nd smallest now not in d31\r
  93019. `,
  93020. o += ` d11.xy = (d11.x < d11.y) ? d11.xy : d11.yx;\r
  93021. `,
  93022. o += ` d11.xz = (d11.x < d11.z) ? d11.xz : d11.zx; // d11.x now smallest\r
  93023. `,
  93024. o += ` d12 = min(d12, d21); // 2nd smallest now not in d21\r
  93025. `,
  93026. o += ` d12 = min(d12, d22); // nor in d22\r
  93027. `,
  93028. o += ` d12 = min(d12, d31); // nor in d31\r
  93029. `,
  93030. o += ` d12 = min(d12, d32); // nor in d32\r
  93031. `,
  93032. o += ` d11.yz = min(d11.yz,d12.xy); // nor in d12.yz\r
  93033. `,
  93034. o += ` d11.y = min(d11.y,d12.z); // Only two more to go\r
  93035. `,
  93036. o += ` d11.y = min(d11.y,d11.z); // Done! (Phew!)\r
  93037. `,
  93038. o += ` return sqrt(d11.xy); // F1, F2\r
  93039. `,
  93040. o += `}\r
  93041. \r
  93042. `,
  93043. i._emitFunction("worley3D", o, "// Worley3D");
  93044. var s = i._getFreeVariableName("worleyTemp");
  93045. return i.compilationString += "vec2 " + s + " = worley(" + this.seed.associatedVariableName + ", " + this.jitter.associatedVariableName + ", " + this.manhattanDistance + `);\r
  93046. `,
  93047. this.output.hasEndpoints && (i.compilationString += this._declareOutput(this.output, i) + (" = " + s + `;\r
  93048. `)),
  93049. this.x.hasEndpoints && (i.compilationString += this._declareOutput(this.x, i) + (" = " + s + `.x;\r
  93050. `)),
  93051. this.y.hasEndpoints && (i.compilationString += this._declareOutput(this.y, i) + (" = " + s + `.y;\r
  93052. `)),
  93053. this
  93054. }
  93055. }
  93056. ,
  93057. e.prototype._dumpPropertiesCode = function() {
  93058. var i = a.prototype._dumpPropertiesCode.call(this) + (this._codeVariableName + ".manhattanDistance = " + this.manhattanDistance + `;\r
  93059. `);
  93060. return i
  93061. }
  93062. ,
  93063. e.prototype.serialize = function() {
  93064. var i = a.prototype.serialize.call(this);
  93065. return i.manhattanDistance = this.manhattanDistance,
  93066. i
  93067. }
  93068. ,
  93069. e.prototype._deserialize = function(i, o, s) {
  93070. a.prototype._deserialize.call(this, i, o, s),
  93071. this.manhattanDistance = i.manhattanDistance
  93072. }
  93073. ,
  93074. __decorate([editableInPropertyPage("Use Manhattan Distance", PropertyTypeForEdition.Boolean, "PROPERTIES", {
  93075. notifiers: {
  93076. update: !1
  93077. }
  93078. })], e.prototype, "manhattanDistance", void 0),
  93079. e
  93080. }(NodeMaterialBlock);
  93081. RegisterClass("BABYLON.WorleyNoise3DBlock", WorleyNoise3DBlock);
  93082. var SimplexPerlin3DBlock = function(a) {
  93083. __extends(e, a);
  93084. function e(i) {
  93085. var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
  93086. return o.registerInput("seed", NodeMaterialBlockConnectionPointTypes.Vector3),
  93087. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Float),
  93088. o
  93089. }
  93090. return e.prototype.getClassName = function() {
  93091. return "SimplexPerlin3DBlock"
  93092. }
  93093. ,
  93094. Object.defineProperty(e.prototype, "seed", {
  93095. get: function() {
  93096. return this._inputs[0]
  93097. },
  93098. enumerable: !1,
  93099. configurable: !0
  93100. }),
  93101. Object.defineProperty(e.prototype, "output", {
  93102. get: function() {
  93103. return this._outputs[0]
  93104. },
  93105. enumerable: !1,
  93106. configurable: !0
  93107. }),
  93108. e.prototype._buildBlock = function(i) {
  93109. if (a.prototype._buildBlock.call(this, i),
  93110. !!this.seed.isConnected && !!this._outputs[0].hasEndpoints) {
  93111. var o = `const float SKEWFACTOR = 1.0/3.0;\r
  93112. `;
  93113. return o += `const float UNSKEWFACTOR = 1.0/6.0;\r
  93114. `,
  93115. o += `const float SIMPLEX_CORNER_POS = 0.5;\r
  93116. `,
  93117. o += `const float SIMPLEX_TETRAHADRON_HEIGHT = 0.70710678118654752440084436210485;\r
  93118. `,
  93119. o += `float SimplexPerlin3D( vec3 P ){\r
  93120. `,
  93121. o += ` P *= SIMPLEX_TETRAHADRON_HEIGHT;\r
  93122. `,
  93123. o += " vec3 Pi = floor( P + dot( P, vec3( SKEWFACTOR) ) );",
  93124. o += ` vec3 x0 = P - Pi + dot(Pi, vec3( UNSKEWFACTOR ) );\r
  93125. `,
  93126. o += ` vec3 g = step(x0.yzx, x0.xyz);\r
  93127. `,
  93128. o += ` vec3 l = 1.0 - g;\r
  93129. `,
  93130. o += ` vec3 Pi_1 = min( g.xyz, l.zxy );\r
  93131. `,
  93132. o += ` vec3 Pi_2 = max( g.xyz, l.zxy );\r
  93133. `,
  93134. o += ` vec3 x1 = x0 - Pi_1 + UNSKEWFACTOR;\r
  93135. `,
  93136. o += ` vec3 x2 = x0 - Pi_2 + SKEWFACTOR;\r
  93137. `,
  93138. o += ` vec3 x3 = x0 - SIMPLEX_CORNER_POS;\r
  93139. `,
  93140. o += ` vec4 v1234_x = vec4( x0.x, x1.x, x2.x, x3.x );\r
  93141. `,
  93142. o += ` vec4 v1234_y = vec4( x0.y, x1.y, x2.y, x3.y );\r
  93143. `,
  93144. o += ` vec4 v1234_z = vec4( x0.z, x1.z, x2.z, x3.z );\r
  93145. `,
  93146. o += ` Pi.xyz = Pi.xyz - floor(Pi.xyz * ( 1.0 / 69.0 )) * 69.0;\r
  93147. `,
  93148. o += ` vec3 Pi_inc1 = step( Pi, vec3( 69.0 - 1.5 ) ) * ( Pi + 1.0 );\r
  93149. `,
  93150. o += ` vec4 Pt = vec4( Pi.xy, Pi_inc1.xy ) + vec2( 50.0, 161.0 ).xyxy;\r
  93151. `,
  93152. o += ` Pt *= Pt;\r
  93153. `,
  93154. o += ` vec4 V1xy_V2xy = mix( Pt.xyxy, Pt.zwzw, vec4( Pi_1.xy, Pi_2.xy ) );\r
  93155. `,
  93156. o += ` Pt = vec4( Pt.x, V1xy_V2xy.xz, Pt.z ) * vec4( Pt.y, V1xy_V2xy.yw, Pt.w );\r
  93157. `,
  93158. o += ` const vec3 SOMELARGEFLOATS = vec3( 635.298681, 682.357502, 668.926525 );\r
  93159. `,
  93160. o += ` const vec3 ZINC = vec3( 48.500388, 65.294118, 63.934599 );\r
  93161. `,
  93162. o += ` vec3 lowz_mods = vec3( 1.0 / ( SOMELARGEFLOATS.xyz + Pi.zzz * ZINC.xyz ) );\r
  93163. `,
  93164. o += ` vec3 highz_mods = vec3( 1.0 / ( SOMELARGEFLOATS.xyz + Pi_inc1.zzz * ZINC.xyz ) );\r
  93165. `,
  93166. o += ` Pi_1 = ( Pi_1.z < 0.5 ) ? lowz_mods : highz_mods;\r
  93167. `,
  93168. o += ` Pi_2 = ( Pi_2.z < 0.5 ) ? lowz_mods : highz_mods;\r
  93169. `,
  93170. o += ` vec4 hash_0 = fract( Pt * vec4( lowz_mods.x, Pi_1.x, Pi_2.x, highz_mods.x ) ) - 0.49999;\r
  93171. `,
  93172. o += ` vec4 hash_1 = fract( Pt * vec4( lowz_mods.y, Pi_1.y, Pi_2.y, highz_mods.y ) ) - 0.49999;\r
  93173. `,
  93174. o += ` vec4 hash_2 = fract( Pt * vec4( lowz_mods.z, Pi_1.z, Pi_2.z, highz_mods.z ) ) - 0.49999;\r
  93175. `,
  93176. o += ` vec4 grad_results = inversesqrt( hash_0 * hash_0 + hash_1 * hash_1 + hash_2 * hash_2 ) * ( hash_0 * v1234_x + hash_1 * v1234_y + hash_2 * v1234_z );\r
  93177. `,
  93178. o += ` const float FINAL_NORMALIZATION = 37.837227241611314102871574478976;\r
  93179. `,
  93180. o += ` vec4 kernel_weights = v1234_x * v1234_x + v1234_y * v1234_y + v1234_z * v1234_z;\r
  93181. `,
  93182. o += ` kernel_weights = max(0.5 - kernel_weights, 0.0);\r
  93183. `,
  93184. o += ` kernel_weights = kernel_weights*kernel_weights*kernel_weights;\r
  93185. `,
  93186. o += ` return dot( kernel_weights, grad_results ) * FINAL_NORMALIZATION;\r
  93187. `,
  93188. o += `}\r
  93189. `,
  93190. i._emitFunction("SimplexPerlin3D", o, "// SimplexPerlin3D"),
  93191. i.compilationString += this._declareOutput(this._outputs[0], i) + (" = SimplexPerlin3D(" + this.seed.associatedVariableName + `);\r
  93192. `),
  93193. this
  93194. }
  93195. }
  93196. ,
  93197. e
  93198. }(NodeMaterialBlock);
  93199. RegisterClass("BABYLON.SimplexPerlin3DBlock", SimplexPerlin3DBlock);
  93200. var NormalBlendBlock = function(a) {
  93201. __extends(e, a);
  93202. function e(i) {
  93203. var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
  93204. return o.registerInput("normalMap0", NodeMaterialBlockConnectionPointTypes.Vector3),
  93205. o.registerInput("normalMap1", NodeMaterialBlockConnectionPointTypes.Vector3),
  93206. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Vector3),
  93207. o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color3),
  93208. o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color4),
  93209. o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector4),
  93210. o._inputs[1].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color3),
  93211. o._inputs[1].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color4),
  93212. o._inputs[1].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector4),
  93213. o
  93214. }
  93215. return e.prototype.getClassName = function() {
  93216. return "NormalBlendBlock"
  93217. }
  93218. ,
  93219. Object.defineProperty(e.prototype, "normalMap0", {
  93220. get: function() {
  93221. return this._inputs[0]
  93222. },
  93223. enumerable: !1,
  93224. configurable: !0
  93225. }),
  93226. Object.defineProperty(e.prototype, "normalMap1", {
  93227. get: function() {
  93228. return this._inputs[1]
  93229. },
  93230. enumerable: !1,
  93231. configurable: !0
  93232. }),
  93233. Object.defineProperty(e.prototype, "output", {
  93234. get: function() {
  93235. return this._outputs[0]
  93236. },
  93237. enumerable: !1,
  93238. configurable: !0
  93239. }),
  93240. e.prototype._buildBlock = function(i) {
  93241. a.prototype._buildBlock.call(this, i);
  93242. var o = this._outputs[0]
  93243. , s = this._inputs[0]
  93244. , c = this._inputs[1]
  93245. , d = i._getFreeVariableName("stepR")
  93246. , _ = i._getFreeVariableName("stepG");
  93247. return i.compilationString += "float " + d + " = step(0.5, " + s.associatedVariableName + `.r);\r
  93248. `,
  93249. i.compilationString += "float " + _ + " = step(0.5, " + s.associatedVariableName + `.g);\r
  93250. `,
  93251. i.compilationString += this._declareOutput(o, i) + `;\r
  93252. `,
  93253. i.compilationString += o.associatedVariableName + ".r = (1.0 - " + d + ") * " + s.associatedVariableName + ".r * " + c.associatedVariableName + ".r * 2.0 + " + d + " * (1.0 - (1.0 - " + s.associatedVariableName + ".r) * (1.0 - " + c.associatedVariableName + `.r) * 2.0);\r
  93254. `,
  93255. i.compilationString += o.associatedVariableName + ".g = (1.0 - " + _ + ") * " + s.associatedVariableName + ".g * " + c.associatedVariableName + ".g * 2.0 + " + _ + " * (1.0 - (1.0 - " + s.associatedVariableName + ".g) * (1.0 - " + c.associatedVariableName + `.g) * 2.0);\r
  93256. `,
  93257. i.compilationString += o.associatedVariableName + ".b = " + s.associatedVariableName + ".b * " + c.associatedVariableName + `.b;\r
  93258. `,
  93259. this
  93260. }
  93261. ,
  93262. e
  93263. }(NodeMaterialBlock);
  93264. RegisterClass("BABYLON.NormalBlendBlock", NormalBlendBlock);
  93265. var Rotate2dBlock = function(a) {
  93266. __extends(e, a);
  93267. function e(i) {
  93268. var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
  93269. return o.registerInput("input", NodeMaterialBlockConnectionPointTypes.Vector2),
  93270. o.registerInput("angle", NodeMaterialBlockConnectionPointTypes.Float),
  93271. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Vector2),
  93272. o
  93273. }
  93274. return e.prototype.getClassName = function() {
  93275. return "Rotate2dBlock"
  93276. }
  93277. ,
  93278. Object.defineProperty(e.prototype, "input", {
  93279. get: function() {
  93280. return this._inputs[0]
  93281. },
  93282. enumerable: !1,
  93283. configurable: !0
  93284. }),
  93285. Object.defineProperty(e.prototype, "angle", {
  93286. get: function() {
  93287. return this._inputs[1]
  93288. },
  93289. enumerable: !1,
  93290. configurable: !0
  93291. }),
  93292. Object.defineProperty(e.prototype, "output", {
  93293. get: function() {
  93294. return this._outputs[0]
  93295. },
  93296. enumerable: !1,
  93297. configurable: !0
  93298. }),
  93299. e.prototype.autoConfigure = function(i) {
  93300. if (!this.angle.isConnected) {
  93301. var o = new InputBlock("angle");
  93302. o.value = 0,
  93303. o.output.connectTo(this.angle)
  93304. }
  93305. }
  93306. ,
  93307. e.prototype._buildBlock = function(i) {
  93308. a.prototype._buildBlock.call(this, i);
  93309. var o = this._outputs[0]
  93310. , s = this.angle
  93311. , c = this.input;
  93312. return i.compilationString += this._declareOutput(o, i) + (" = vec2(cos(" + s.associatedVariableName + ") * " + c.associatedVariableName + ".x - sin(" + s.associatedVariableName + ") * " + c.associatedVariableName + ".y, sin(" + s.associatedVariableName + ") * " + c.associatedVariableName + ".x + cos(" + s.associatedVariableName + ") * " + c.associatedVariableName + `.y);\r
  93313. `),
  93314. this
  93315. }
  93316. ,
  93317. e
  93318. }(NodeMaterialBlock);
  93319. RegisterClass("BABYLON.Rotate2dBlock", Rotate2dBlock);
  93320. var ReflectBlock = function(a) {
  93321. __extends(e, a);
  93322. function e(i) {
  93323. var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
  93324. return o.registerInput("incident", NodeMaterialBlockConnectionPointTypes.Vector3),
  93325. o.registerInput("normal", NodeMaterialBlockConnectionPointTypes.Vector3),
  93326. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Vector3),
  93327. o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector4),
  93328. o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color3),
  93329. o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color4),
  93330. o._inputs[1].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector4),
  93331. o._inputs[1].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color3),
  93332. o._inputs[1].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color4),
  93333. o
  93334. }
  93335. return e.prototype.getClassName = function() {
  93336. return "ReflectBlock"
  93337. }
  93338. ,
  93339. Object.defineProperty(e.prototype, "incident", {
  93340. get: function() {
  93341. return this._inputs[0]
  93342. },
  93343. enumerable: !1,
  93344. configurable: !0
  93345. }),
  93346. Object.defineProperty(e.prototype, "normal", {
  93347. get: function() {
  93348. return this._inputs[1]
  93349. },
  93350. enumerable: !1,
  93351. configurable: !0
  93352. }),
  93353. Object.defineProperty(e.prototype, "output", {
  93354. get: function() {
  93355. return this._outputs[0]
  93356. },
  93357. enumerable: !1,
  93358. configurable: !0
  93359. }),
  93360. e.prototype._buildBlock = function(i) {
  93361. a.prototype._buildBlock.call(this, i);
  93362. var o = this._outputs[0];
  93363. return i.compilationString += this._declareOutput(o, i) + (" = reflect(" + this.incident.associatedVariableName + ".xyz, " + this.normal.associatedVariableName + `.xyz);\r
  93364. `),
  93365. this
  93366. }
  93367. ,
  93368. e
  93369. }(NodeMaterialBlock);
  93370. RegisterClass("BABYLON.ReflectBlock", ReflectBlock);
  93371. var RefractBlock = function(a) {
  93372. __extends(e, a);
  93373. function e(i) {
  93374. var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
  93375. return o.registerInput("incident", NodeMaterialBlockConnectionPointTypes.Vector3),
  93376. o.registerInput("normal", NodeMaterialBlockConnectionPointTypes.Vector3),
  93377. o.registerInput("ior", NodeMaterialBlockConnectionPointTypes.Float),
  93378. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Vector3),
  93379. o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector4),
  93380. o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color3),
  93381. o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color4),
  93382. o._inputs[1].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector4),
  93383. o._inputs[1].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color3),
  93384. o._inputs[1].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color4),
  93385. o
  93386. }
  93387. return e.prototype.getClassName = function() {
  93388. return "RefractBlock"
  93389. }
  93390. ,
  93391. Object.defineProperty(e.prototype, "incident", {
  93392. get: function() {
  93393. return this._inputs[0]
  93394. },
  93395. enumerable: !1,
  93396. configurable: !0
  93397. }),
  93398. Object.defineProperty(e.prototype, "normal", {
  93399. get: function() {
  93400. return this._inputs[1]
  93401. },
  93402. enumerable: !1,
  93403. configurable: !0
  93404. }),
  93405. Object.defineProperty(e.prototype, "ior", {
  93406. get: function() {
  93407. return this._inputs[2]
  93408. },
  93409. enumerable: !1,
  93410. configurable: !0
  93411. }),
  93412. Object.defineProperty(e.prototype, "output", {
  93413. get: function() {
  93414. return this._outputs[0]
  93415. },
  93416. enumerable: !1,
  93417. configurable: !0
  93418. }),
  93419. e.prototype._buildBlock = function(i) {
  93420. a.prototype._buildBlock.call(this, i);
  93421. var o = this._outputs[0];
  93422. return i.compilationString += this._declareOutput(o, i) + (" = refract(" + this.incident.associatedVariableName + ".xyz, " + this.normal.associatedVariableName + ".xyz, " + this.ior.associatedVariableName + `);\r
  93423. `),
  93424. this
  93425. }
  93426. ,
  93427. e
  93428. }(NodeMaterialBlock);
  93429. RegisterClass("BABYLON.RefractBlock", RefractBlock);
  93430. var DesaturateBlock = function(a) {
  93431. __extends(e, a);
  93432. function e(i) {
  93433. var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
  93434. return o.registerInput("color", NodeMaterialBlockConnectionPointTypes.Color3),
  93435. o.registerInput("level", NodeMaterialBlockConnectionPointTypes.Float),
  93436. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Color3),
  93437. o
  93438. }
  93439. return e.prototype.getClassName = function() {
  93440. return "DesaturateBlock"
  93441. }
  93442. ,
  93443. Object.defineProperty(e.prototype, "color", {
  93444. get: function() {
  93445. return this._inputs[0]
  93446. },
  93447. enumerable: !1,
  93448. configurable: !0
  93449. }),
  93450. Object.defineProperty(e.prototype, "level", {
  93451. get: function() {
  93452. return this._inputs[1]
  93453. },
  93454. enumerable: !1,
  93455. configurable: !0
  93456. }),
  93457. Object.defineProperty(e.prototype, "output", {
  93458. get: function() {
  93459. return this._outputs[0]
  93460. },
  93461. enumerable: !1,
  93462. configurable: !0
  93463. }),
  93464. e.prototype._buildBlock = function(i) {
  93465. a.prototype._buildBlock.call(this, i);
  93466. var o = this._outputs[0]
  93467. , s = this.color
  93468. , c = s.associatedVariableName
  93469. , d = i._getFreeVariableName("colorMin")
  93470. , _ = i._getFreeVariableName("colorMax")
  93471. , b = i._getFreeVariableName("colorMerge");
  93472. return i.compilationString += "float " + d + " = min(min(" + c + ".x, " + c + ".y), " + c + `.z);\r
  93473. `,
  93474. i.compilationString += "float " + _ + " = max(max(" + c + ".x, " + c + ".y), " + c + `.z);\r
  93475. `,
  93476. i.compilationString += "float " + b + " = 0.5 * (" + d + " + " + _ + `);\r
  93477. `,
  93478. i.compilationString += this._declareOutput(o, i) + (" = mix(" + c + ", vec3(" + b + ", " + b + ", " + b + "), " + this.level.associatedVariableName + `);\r
  93479. `),
  93480. this
  93481. }
  93482. ,
  93483. e
  93484. }(NodeMaterialBlock);
  93485. RegisterClass("BABYLON.DesaturateBlock", DesaturateBlock);
  93486. var _environmentBRDFBase64Texture = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAgAElEQVR42u29yY5tWXIlZnbuiSaTbZFUkZRKrCKhElASQA0EoQABgn6hJvoXzfUP+gP9hWb6Bg00IgRoQJaKqUxmZmTEe8/v0uB2u7Fm2T7HIyIrnz88uPvt3f2a2WrMbOvf/u3PvvzP/sUf/N6//i8vf/lv/3v5H//d//Sb//Uq/5u8yf8hV/m/5Cp/L1f5hVzlG7nKJ7mKyJuIXN/hPwqXI/g++zq6rPI5u8z+WqfLre+zy7PrVv9L8brsMiGvk8XLmM/sdfHXal4e3ad6GXPdyu2ij8u/+uv/5cuf/OSLfdtEfvUr+dnf/d0X//t3H/7bf/hP//N/928h/0Yg/4VA/kogfyGQP5Wr/IFAvhbIlwK5CGQTPP+9z5uPeePJSW+yo2+s/GtN30Rnv1E+f5zxof9R/lSXv/nr//mrr3+i+5dfyX7ZZQP07Tffys//8R/l/9TtX7790T/7r/8G8pdy+/8XAvnnAvkzgfwzgfyxQP5AIL8vkJ8K5KsmMVzu1U7p5PA5AXxOAJ8TwPf7sX/51ZeXfcemqnp9w/W77/S7X/6T/vzf/7383RWCX3/z05/9i3/13/0PX//eX/2FyP8tIv+PiPy9iPy/IvIzEfm5iPxCRH4lIt/c/393//9BRD6KyKf7f488fP74/PH544dJAF9cLl98IZfLBZtuqterXr/7Dt9982v95S9+Lv+gF/3i7Spv/8lf/vnf/vGf/dF/JfKnIvLnIvLvReQ/NEngn0TklyLy6/v/34jIt00iGJOBlxAsdvv54/PH5493SQCXy9t2ueh2ueimKorrFbjq9eNH+fDtb+TXv/ol/vHyhX4Fxfbx7euPf/Lnf/PfiPyeiPyhiPxxkwB+fk8AvxzQgJcIrGTwFsiAEXH4/PH54/PHUgLY7whgu2C7bLqpQgHB2xvePn6SDx8+6G9+84384vKF/IPu8iVU9Y/+7C/+jWxffiHytYj8VER+X0T+oEEBvxqQwCMJeIngo5EI3goIwVMIPn98/vj8ESaAbbtu2ybbvl8u2ybbdtluSECA65u8ffqIDx8+6G++/VZ/efkV/sO261dQXP7wT/7kX8vl8qXIFyLylbySwe/dE0CLAr65B/9vGn0gQwRMMqgmhM/J4fPH548eAezbZd/lsm3YtssNAYiqiogAAkCvb5/k46cP8u2HD/rrb7+R/2/b9Wu9yJe//8d/9Ney6S5yEZFdRL68/38khG/uKOCnAwoYkcCoEXwkEgGDDq7CeQfyOTl8/vhd1QCum26ybZtu2yabbrKpQvXue1yvuF6v+vbpTT5+/CDffviAX1++1V9sO77WXb/66R/+4V/dgkbllQi+aBLBV/dE8LWRALwkYCWCNyMZXElkwLTMeMkga/P4/PH547ccAVwuctkvdxSw6bbdtYDbTfSZBN7e8PHTR/3u4wf55vKd/nL7DX6mu3791U9//5+/gkNFZGuSgZUQvnKowKgLWLTAQgRtEniTuEfwaELw0MJvf3LQzynud+53uG+X6y3gN9kul+2y6XVT1U27JCDAFVc8ksAn/e7jR/nN5YP+avtWfq6Xy9f7Vz/9w1dgRYngiyYhfNkkgzYBWHTg44AEMmqQUYQKOmDaiCIa8TmsfmzB+DnZDQjgcpGLbti2y3bZHjRAdRMVvb/dcYU8kcDbPQlsH/CrbddfbF98+RPZfvLFnAQeieCRDC5DMvju/vmD4JkEvjRQgKULeGggowdHkAHTYxihg89vu88I5UeGAPSOAFTlrgPopiqbKPSmCKreUoAAkCcSePukHz590m8vH+WbD9/JP335k6/+tA86KxFchv8jMvhiogE4JQm8XhfKqOAqx5qRPyeGzx8/cgSwbXcUoLJtim27C4Oi93+4v6VxQwKAvl2v+Hj9pB8+fZJvt4/yzfbF9lPdv/wJnsE2BogmyeCRED40tGFvksIXiSbgiYSRRpDNDZ6BDI6ghM+J4fPHeyKAO+zX7cb9t4tedMMNAQju5V+f1uAtBSiu1zsduMrHy5t8ePsk3376KN98sX/xE5FPAnm7/782o0DiUINXMkCXCB7/P94/e87AWUmARQWVvgMuKej9t1RLBp+Tw+ePgwngsutFFdu26WXbbl+rSvdfbnqAiuA23QcBgCugV1zl7e1NPm5v+LC96XfbJ/1W9y++fgXjA3bDYXV+MuhRwSPwL3JLMFYC+HS/LU8HYrGwIhwyNOF12SvgM4SgztdifP85MXz+KGsA2C6X7aJ6bXSAOwrY5OYIqGy3d5uq4P5GhABXuV6veLvRAf10fZMPb2/y3b7vX7+g+9v98/WOBq7GG7RNAlYy+Dgkhhb+Xxp0sE8IAC4SGAP/TbgVJK/PoJPBnAiwPKxsXfbbnRg+i3s/JAK4Q/4b9NfLtomBAqCickMBjy7BuywAUVyv8na94tMjCVzf9KNcLl/0SeA6oAEYb1i9g+FtSALb/bKL8/+t+wxXFMyswqiHoK4ToIgKqslgpg1qUC0QoYbvJZg/B/q5v4szHmPX7YEAsD0CX25OwEUVm9xag1+agKg+nxQArnKjAtDr9U0+Xd/k4/UqH7bL5YsewrcBBiMJZPRAp6TwQgWfjM9vgRbgUYGL8AvLWH2gqhesCokeUmCSwPsnhs8fP2YNYMO2XeSmAWxy2VQaXeDmDIhApf33rD4PTUCuV+DtCn27XuXT5ir8VmCJ2G5BpBM8/r/dEcJb8/0lEQMtJHA5TAlqNuLRhJChhEpSqFabH3di+G1AGj+W1/dyAR4IYJNNnuLf6+tWC9CHHiAtFhAIFLjK2/Uqn65X+SS67aK+3QeTDoy/IG2ogQ7fb/dAtz5vBgrYGqrwNtCHsVfgIvwK07OTQBURVNCBFpKCOjqCHn5L/67TgTN+fpySAC56nwSUi256kXsSuFGAVyLoUIDo8/Pz7fdoErr/v17lk162HbgHvFpIYDfoAJJfW4sGPjkU4VNAF8ZEcLmLhdc7kljdY1y1Dq9yLiI4IiRqcLujb138KIPn80ejATwRwIbtBvn1cqv+2J78/5EI5N4cJA8qIPcmwRsKAHDF9WYP6mV7VmrgLuTpxYTcMEW0LAmoQxFsuvAI8tv/a/C5fV2ZMMiKg++FCM7RDPRu8ebWY7VG6VJi+Bzk35MI2LsAckMAgwvQ0gC5DQjd3ABg2HQLAPpEAlZ1Bu7VV7MGHDFRAbo3VKsTbAY9sPWC/uvx86gBbDK3D1eEQS8pbAeSgSwmhepnJb6uBv/o/PzHLzxWA/X7TH77De5j6AGQi6o0CUGfCOD2X7cXAlCFQABtEsGLDtxuOyQB2UTQBKZe5GUPXgkUYCUAbZJRhBDeuq8xBf+bgwbehDm+BFQi2IJksOocvA8ysIMfxluVcRsY/eB3JzH8GFDAXQO48X/dcIf9jyDHptIigDsFkEe066tBSETQUYF7ElDdYEBytN4+rk9UcBPfrKaZqFHWcw3i4J8/X4ev2//bSXqAhwTay6OEIPLD2Ipt8OtAGzxkwLw9WVFRjTc/qC6H3+YK/b1oAA0KuOizHfieCLaHHiAb5NYTIC9EMEbZrVEQt1xwhVy1UfBh8PUOquMizwaap3tQXfY5B//tea/NZdfhsvbz+PURQTDSGWB87VX/7WSd4KxjUqrIgE0IUkoKGnhIvwvawpGf6eECXJ7tv4qbA7DJgwpsKthEmmYgfaAAffYF3HLxo0vwNjJ0SwRWMG4db4eh1gPNm18vQ+us/0eGmxDemu/fnM/X4evq/8342ksGHgLY5LyT/zg0wM8lcMjgGFXwqIOVFJBQw99eCvF9oZL9Mfl3QwAvIXDsBRC9R+fz8x0FPBLB0xJEpwUobrfAkARgIAF41h3wQgP6QAmX5E/7eI43IxGwwf/moIkRyWRJQIPgt9CA9b39nzt4bYUWjAlCjWDPgv8IEjgLJfzuaAsrv9VdVG4OwOXW/fdoA35qAdL0BDwvf6AAUVHd8LIEu94A3K+Q+2YxaB84MOH62P//qoo38fCRDERE2zf0JfmDa+MieElAjcDPKz+mRKCOtdgGtXaBjgNJ4H2owSpNeAW/rRH4CaHSpMwnBYYycjgSJwfie9CR6mPu20Uv8kABF206AvXlBMiIBPSlB9wjBW1fwEuSb94296VCqgMaGCt/G1BbExi3IG+r3a3J6P48Gv/J0YmEYoiGY7V/SxwFCwGoE/xa0AJ0CEiV9QPCJb1OJ5F1VTjEY2/MO9AEJvj1BJTQpqLfTlGwjABuzT962e4IoKnyrdh3+/6mzDVJ4PHOxj0JqGKoy20+wBMN6D1gLWi9NQHfVP5MEEPzjGYy8BMAOnTAJgEr8HUIejRo5xrA5xkR5AngmiSHs+zDDAmMgWzTg55GSJEmHE8IvWPAoYTfhWak/Wn/bQ0CGLSAjv83SUEfKp5q24LXuQICpzrjrgWoza8xVE00CQCORdhMJuTUT/rjuls0gO4Iby8BIEgK6gS7BsGuTtDrScH/fR68biUHNVGBnxjeNyHEvQe/ve3LZQqgG3rof6cEclsNflG9J4KtaQ8WHcVBHS1BtHE4QP9OBMS98mpbKTeDW7dJwRsnHpMBTFJpV4I+b0kY/NqInVFSyBLANbnMSgBM8F+Fqfxq/h657/Up+GaBnwV9hRqc9bZ/vA6vu+T9E8KPJWns94UfTeCj2QXwCHS9dNL8Xf3Ho/rfewSeFODGDV69AU0y6NFAE1DP3qK++rdB7/1HRxf86gT376zOr99T/h/ioBiXWQkgQgVeIrCC/WomhDmQK+hASI2ARQZKooHMLdCJwGEBBXC3+uERwg+VOHZ9ioAt9H80AI06wGgJ3nQA3BoCut6AhxYwgcPOFnxuFnrphk+NIKIGrWPQtgz3b0i7Y6D5rs1GKqTop0nQX52vmQC4BkjA+r4a7Kx9WLENGeegkhSETBCrNXIMdi/444Rw1n6E96ry7OPuj8UfLxtQ78NA2iSBbg7gIiIbdDLsb5agPhLC3RkYKv8NDbS2YGsatNRAG2oQwf9ZIOydgy1MAzBkAw8UwEEIDzSAqdPQ6za0PkeJAMH3Z0wXniUSZoHvBXU2mcjQgv56TedIKglCpIoQfgwCIjOytd8WgN0bfxoR8Fn9Gx0Aj5Zgq0lIZbsH/ibSJoFnS+C98g9ooHEELI3gliy25yONIiE6pb0NfBlyNEYyENoodkKwgl6I6s8kARgJ4ZoEfuYWHLEJa0LhSBXm7kImGeSfVdoJ1DO2G7WXsehAptupSOoyrCSF904k+6vt98X/ZcM98Hsd4JYIXhQAIg3/f9AAUYhsLQKAtkHVBnzjCKhOoYl2ym+iBtvzDzQ2DLXJ4PUmbJHAVnBQX4jkxfvHhNDqAdHXGQJgv0aSDGItgOseHIU+K9hXnIJzkoGlEKzNHagTdJ6VWEUH4iCKH4fd2AwDPaYBm4Wgng4gQ9V/CoGiuNmD04AQtNGMGzSAAQ2I2pzfogY9LRh7BrbOh4+D30sAencljFu2CUFrwY8UAWRfWwGvVOVfbx2uIILM0pwDv082dUTw8hYs8L+uIWiHGpWgClnAa1lMPJogovvvbePPs/q3Xr++kgCsfgB5oQF9WYKPJqEn6G+OE3i5AqouF59FQOmahQC8rlPLj38kg1c2f30vw+XaoIX24/pMGIgSBoZqoH3wo0sIIGlA9PWcCPrAtpPB8eBf6x1o6cHra+2+tpIFP4PgBfxZtZUJfo4qxELT948D9ucK8Mt9+ccjIQw6QJcEbrD/1g340ATuDgDkFfx6twSf1f9xvuBECYxq/7ythQQGm+5JDx6Brw4CkMGT3wgscCUoQ4sU2t6DR2ciBjTgtcpenQoZVX9NuL4Owc+dVaDursYVkVALX+shjSBKBuvCYDUZjE5BdNkxdHAUBexyHwB6NP7Iyw7sxUDViwge1t+mz8B/LAvVx/c3PeBBCToB8IUGOgqA3iV4yUg6UAOxaUFHDx6CYS8SorMOue0CCJGAf5YfRhoAI+A1CvwxqNkAY5yAIx2EQmkFfeWOXi+nEdSQQA0ZHMEItiagJArQxDXIrj8nCfQi4HZPAttrIahso9oPQ/2/JwV5JQU8zw+7I4D7/sBn4EO6rjw0FR+i3Z9fHtahzsFvJgM0X+tmVH5vaYiNDGAigewAz+gyNLThnjCURQFR1b9d3lZvnVqmj9mEPDKIUIC4KCCjBXywS4N+otp/Hk3QVthOkwEKlV9PQwXjT7s/zwF4Qf9toAAzFdjuaEB6S7D1//U5FIQu2MevO0rQQH8ZmoXE6B/IkgE60XCjVoq8gt2iCG0S8L5GdxkM1cGsfsCMArSCAnrr7dzAZxCEEpepvB8tqHJ/q+bmJGGts/AcAXFOMMeTwC7Pw0B6CtCtA2vWgonqBQJFSwH0JQK29OB2kvgj2HHXAoyeAIsCQO0kMNECAhFMqCBf8mElAkyBbX1tJQP2RJ/ha0gpAfS9l+/5n00CkrQpq0MZbOdAuxmMvHswog62jZj7BnYQe19b14kxNq2D/ehX/p68HEcF+x3yP7z/V/A/q/5DA3i5A/dzA5pdgbKp3v3/wQF4Bb70WkCTHGRAA6+KL0bFl6FJaFw0ImZwm6igSwbbwPn9RMBWf3sN2JgA/BVh/Rg0kQBgePf6HglAHLFQwqQQOwDjbdVxNZjR4iM6Qa3WxwvNxh0JFb3g/WzFQQS8b/ttKcDWoABtUMAd8j9hf0MB2uDXhzX4CHj03L9DBU3Qjz0C0l4mLSLQPicOOwZoVCB6P6dA7nDbGkVuxcNr8PU2JQO4wX5trEqmccZaHU4q8oCDFOpzAnOwqyMIMktNNNAHouDGxO37DgArQZzlmp/14W1QlqHTMaIIx7SCx0+5yza7AKJ3IXBrNAHVDcMZAU/BT/vgv/ULPOA+XiLggAREDF2g0ci6xNDRglegd7P7TWWH5oJfayliEg7bScQRBVgI4Ookg/F6rvpLWP29swREqA3CaG8/FpKqS8DTAV4TiBqIqtxfzaQRLys5I0XEFIFrPbZRQb+16Fgi2LvJv8EFUPW1gGfQv1T/F/d/HBnccP7rAwnIIyHI4ArgWeGbU4eHy6Tx/EeTZIb5bo/BsMBjmjBE08f/RB0PHYBd9eVRAGY7cHRwiBf8WeCPHY1bgBTa9xKTELzEkQX9CPtl0gJiqsAmCT7I8xbjivh3JGFI+D2nBcSJQJ8agDX+O9iBL7UfG4bzAkcaICrbtYHz1ycSmGmAjJfL3CMgT3tQpmrfB7gxSzC1DnvdhQMieG47u75+kTouKNkM8c/+vq/Q7ZYjO/hhVvRq8F/9gGfhP8aqE9EIdR6LTwJ1h0BItyDqB8iFwuNqASscRnYioxOg9ApvnYA35f8e9Ohbfe8J4rknoFkO0lmA2gmAG0YK0DkB4ieEjiLoMD8wBzom27ANZkzIoU8EMHk/uo1mzeVoEoRWKn8L/62EYAX/lsB7D/LXg74uAMr9oGivJ0CNJCGD6i9DhZdQF+gtOp4S+NODRzsDVbhdgv4BqTMNyIL9SCKwL9/FGPp5oQKxIf8A/UX6r231H7YIqLML0Ae2GtrADOvRQH5b/MPE9dt9BGLNG8jVTAQvIaK5TtvvvWQgDvyXIClUA78S9Nfg7VtIBlO7cbsEYkQDMot+ygQ7QwmOawTHnAM2XUSnJvPIYRYMmYPS+sv3J+cfP3d04JYIXsF/EwMbBKB9Q9AY+BiSwFj9mzrSXmcJhFPVHySTbgHJCPvRQ/z7G/SVUETsg0ZF+i3CRoCjhf7y1A9mOiDD7TwdwEoEXjLwAv+avLE2B7Jnb+OqDpBoAchoQJskxKnss0vu7Q2YhcDv4ySeLOg9GsCKiUIihP7yfW7zbTsBh0TQfN0iAWn9f72Z56/Ax9P7j5OAH/Qvv3/QxKfk0DgDuP+R3USg3bzBC7bO/QT9Eeh9QvDPG7glBQzJwK740lAFFgFk8P88CqDGAa223YckWYhr+c0BPdwetl2ocnsfzePAWcVnnAIp6gDVhDLyfV4nqFEDPxHsbWD3k4BDkN+pARqKMLYBPzYEvxp9xmCHQQdgWH/9EtH2TIFpu3AH/cdGydv1j0TQbRrq+D/mLcX3ZACZ15bF378CG0My6Kq/zoGOQwhASDFwFbxyNGBuSxbCEhQ/uEPe/6gAERWQObCVVfjPpQX+rexxYhYFxIkgpgX7Y/vPs+Pvxf9vwt8kAs7i32t3QCP+3SPaTwIytQXP38u0PESm+YER+o9B3vr8mETAUfDrEkPI80ck0FZ0dXh9U+HRbhey0cAc2H7A4y4egoD6y8JfkBiigLdFP8v2W00E8deT2IeAKujZ/QAVKpAtKI20gLWksHedfgPcb+0+NEHefd9vB9rayi8h7J91gBbaw20MsnWAF5xHkyDUCOoXp+yrOwwxcKj0aL6fFppaaKDv6OpHR5sgx5BAlK/+fYhuP1D196o8e7lFBaKqv5YIMnFQpd0FGVR35RJCnCDaABaXBtgbiSwtICMtalKC+1JQ6bx/PLcDPQL91QFodQNKpwOgF/9eqcBxBBqRcKAAVk+ArQOMx1RYGgB6naDhlK+uQQwJYx4meQbxtNnYQwMjt/d4f3M9ZE4UOld1LAh99fbfzOxiEkKFCkTJIUIMUeVnJ/9sDt8/e1NEJOi9oVHDGYhgnSLss9DX2IAqw1zALUncKcDr0FB5NP+0cBQNrEezDiyiADPkt9qGpwoPdL0AGPx/NOKeyf3b9WJNdfcFv6bKd2cLMJVfJ6Y3B6wB9WFUfWWEwKMfGiQL+3bz9XGQz2EHKhF41GCtZyDi/gUCsNhYoAr3UNJ58YidHKqnMb/6AB5J4N73/4L+t7mAkeeP3P+1LNSB/l0SkMEd8DcEuUlguEw6t2AU/PCE/q++Akw6QFf1u6SBrj1ZnnhG50AfkoGIdf7gJv1KcSfgzWWkQ9U33Z3tHXYASKJ9e/YhU90rvD+q9Ej69/wxYJVs506Eg/r3DkMDzEdDBRGgcZay49XihLA30P+l8N+hf1f57/0AoxbQbwYaan/rBMirE9Dk+sBzTkC8JNDEUlv5McB8PP19Y01Gayep+hC/2zvQ/2HGLAurowsNGlA1cnqGGzeH5weiYLZm7h3QQC4O2tXdhvMMk1ZS5ebpgI8eMrPvPGkwaxayk8Yc6PMOBPEdC1XZ+2UfbfOPtxLMQQAG9BcZFoF0gp/RKjxe7+oAw9T7ZPWhgedodgz0gf5KBtrtIZhQAZpAV1Bi36w6t98qVfH7hqGI318lLCjLCUFlxRHwqYEH9a2qb4XjWvDT7kBwfbZA5P0+PNuRuW1yf4yNQH3zzwv6b70QOJ0G9OT/dhoYRUGT15uQH/71MjQLtQlxfDuiCXrtM+SkA+icQdH6sU/xz7Ze7FlubV4TpoTQ2osdpaEjtqADmEU7OkBEFoLeC3IWFFeswJXKXzkboNL+wzcFHU8hTGKIboO7CLi1/P+5F+gydQhuvRbwEgxvtACmANikhLTbj0gCYk8KdlYgmj+4Ymaod7TwahwadICuX0Cm2fE5iNHPK0x/CDV66Kyg1MnqjNFBnhBoLQCgUULfaVe5nq/6EQWY67bXCszUb+7232fVPz51iGB12owK9peyP1T4raMFF/OEYJP792mgXYfZ04GHMAhBkCSmSj+dKqRPgVFGHbpLEGMiGFeQWfSgrY52VxaeDUPSNJI0P7NoisG729HHl78z6hxfs9rV3m4JjgM/lsui2qmThjCfDFSb+I9vwUqG5wwL55U7C+6ot8B+7N2o6r3q37T9trfpjgmTvv7PSQATLLeRAOZhIJHBQfDQQJPBdUwEbVW3+L08EcEE/9G4ANrCeWcnPKRHDupbNynMx5AA9IRYLmrc/YLSiD5EaEBS/s/TgnU9ILcH19n+CpHwegLejx7Mn/d25fdN+e9U/1vgb7bqf08MOtf8EXxaoh+GY8L6gDfhvs4i6HQ7seYI2sv1GchdMsBIG3xlvxcCRzdgCPTn+6q/TW00VE8Q9FaFv+R2VlOM1vm/hhjhDCdgNflVKME5B47I9xT8z0YgPAJ8myb/LqHy36j/Mwqw9AALxuO1JVjiuQAYLcFzIhiEPe05fk8tRjGw7yWQbsfuLAT2VqOId1osnr0F49VM8INACPHDoBz4B5mqqSnUgyh3ArjXxfQH5BbgUS8gP7aU+w0zHD9GGD0CGHf+P1p/DeivlhU4BbxR9a2kYFR58YaDZCUR2P0DMmgED2eg77puegy6PgDphEB0CwlG/i9d+/Hs34pBEQrBn0W51mqGnJAk3ACCHeiqkQ1XFQA5AlKH7Lk8yJKWY3/nym14h2C3JvxeMwD9ZVMz0BPMi1n1RbKl1cYhIVblF3G0ATsRiCMUvoK9//OgcwYMoe+ZKOLlC6/Xk50br9NFz9fanqA8UIYSpCwlBO4kHc4WLLBfBHVaKwKgLQjmP4Un61Vq+3s7Bsyi0WztmLjJwJwFeE0I2vD/1Q6MVwefxfUf32skCPbCnxQqf+QMPEUDHZ7vGeyj020JgkPXXwsldA7SYR1RE3h94NvNtugswcgxXEkIcBPCGZ1rmrgDC0A4K88nm2fn/eTnpQtWyZfybRoK8Dro4zYDIMGsf7saTBzvX0SMbkAD6o9CYbsfMK38cJKD9l2FJt9/VGs0h5Gib33pxMKWNsigFUh3G2un+/N1WUglI/EEx8fq27vUNnwsiOoKecL7kQS8VnWAGCFUgn6dBtQhv40CmIYggwK0uwDHRGAuBXVdfwzHUjZzATLMAoyJ4FmBhzaWBlrHld9CCWpPHRqofBqMReMGTJ78q9rDes1Tv7/0m0v0AFHXNR6P6g30SHivin7V1BOhh3iWPwvps/yE836L2XiwnUT8x2iHgfqhnwn667QHEE8oLQjEvtEW7GYBZDrDVkwNIO4G5GiBDf9fGoFM6n+vbEtzXwP6u9AduaWnGYSLAlVdl/AU+ikrSeEIKgwdaZ4AACAASURBVKj4/wtgHcHtdO2nWKcBkPfxcvnNQvsj2Me9f02r76T8q0IBn9OLKfz1HX8yVXQYGoAB/2UeBQ5/5kCL6+H/OGGoRnLSwdd3oH8r7KkGTbgIxEwVWvnF8KOpHnyzfF9Jod5Px+IF1h8owyitDw/XEgRb5bPqbt1uvn7qBIQ16vtS/u+DP3cR7CH0WWJgd5mTJKYgNzoGjQrfvu99NDBC+bnyW1x/qhTatv2OaMKgJWPvv5kwnMgxHYGFRtJW8VMl3uP+MgoqSZyWFKr7+KIDw1d6+IiOgZI4+d5iYL3imzbgyO+tph9t2oSBxOM3ugHtPoFZ1LM0hF4kXNEBssvVgPdjdXZWK7uKvyS3q1Xb1WQwtVDqSUggq+Vw3t56JA2cz7PXOwGNW1ecwxPhfe3QEUsDsFaAz8jg0nf+iZMAHNg/XSazDuC18Iq1HBRrOsAQ8NLB+16g614jmuSgs3bROxE55D+WDDQNA4ivdMJ9M1b309UqknaDU8ObV9/PwmMPATvTMAxpABLBzugUtV9bLdhNDQA+7B9tQJ06/7QNDHGSwtgZOCIA47InIoDdROQGtt0U1HI3GaoUnCnC/rzBMQJteN17+VaAzYNA7e+PFqHQUyXPUYB7iQYa5ZFjq1Zqpx8Uqu/XT7+6BWC1Xaj0GlBIwMoHu7UzcI/6/Acb8KIq+hzmGWmAYnADrIpvKP7TZeLaf0LAeQkGgebbq9FToI44p654F47tekKkI0L5PQNZPsDwPBpy/ni+wKMN76Vav4+2cFZFf8+JwAraMt0DFB7beA/u4Zz/a+RXx0M/ct4/jwaNAS8G17eSwmta0Fhx0VRxJkHMivso+onMXr+YwdWKbgioy1jp4x4AzIKg5lEA7wvHEYCRmdx11TAuT6lDLVl4KvXkAET9P4RT8H2u+lg9EPQIpw+/NpJ7RwE8HaDv/Mu4f3OdNkq/EfAiEiOANjEALvcWL9gfFV4NZbgbQc6qPky4Pm35QZxtH1f4j+P/jXuaYPcWwIEH/fmEPBoAO4m4LGxV3txOQqDU+dXgey+UwSzuqP++uImO/u/6ogCb7wTc1n61sL+vZi87rxnrNas+giTg6QLzaUCjIp6JfhwtGI7AjBBB9JjDY4ePYVR6ZPgN4owVv6Q2N5hhVHwNeYrM+w6dN6K1sMHZm/Ce7bHe3dzKr1xw1w4JrSQMZtgnoQHlr18fzunAszD4qurNUg/TDqzx/lfCaO6t4tACMUQ6P6htWjDPC1hCoZ8kpODzJ70MUR9AODcgwyqyPhmE+wfHYB/hvSqt6qeXUShhXH+d9SR8DzrDaZZdpSp/HxqLMQuATgDU/qDPRgOIeT8cvz/h/XC6BtE7ACLOWPE0KIS4UUjmZaJ2grBphiWgT41BUVWZfP3AnEIT6OrfoF122l2rMycBoU5i/OXoUZ4/aglsXwLzHNU++FVF3qikOj5HXm2PBitT1WuvJRAB+6O//W0/PY8vQH5IrAsMs/WuVmAdHBrQgrbOxJShXwRSsu08h8JMBpo0+aDTALwV4tbswgzHrftG/dJKIAQb5h9KCssWIMeto+GYqG12/HWGjx8kzqNJaa0noMWOr2KwW01AMwJoNvhMQda2/RKQP/3ecABM3g9uD6BY68Ntz9+nDOMb5iV+hIE+dP/Zs/wwJhJ9mgBnohBuStABUXjugF3hkXF9ZZJAjefKdHZCc389LoStKvIl7QIEb1d9RyciQgFDI9Cjyccc/23Aam7/PZJBhgDgin5CtQvbCzX8ip9YgIFtOAt+w0owp/hOiCWgEGbVHuYjRigPGR/YOnEoqPDoV5z5YqB3mRq2ox5ICmSSgAP1Ne+XV2NE+/vuFbCTRADxtS70VRBCjgBk2OyDUQiUgfl77b7DwaHm2rAZ7osRSOOUoHgKfNBSLI767+oDYrfwZvqChSpGfj3pFwZFsCJg2jeIQQBUiyI4WgD68ww4qO8khuWkkIuDrxWv2nv+UTBpJYiPd0KemTA8qqFiuUF1jWS3BoG6pADJq751JqBI0wvAVPyMQvjcX1zbELltKK+zBiXRFiRxG+b7q3M9xuLdzR8g0gCGNzSM5gNYfqGO9CBT8OHct6oB3KsSDBisUnwsFuISQaRHxDSv0vptt2oeLHMERfRn/FG/Cx01EpgIQG8LP+/i37PKw53xn6sYCM4/JwSRrCnIeB1ZkLsawDhaPKv/njU3wnZ/dBdGE8+YTHSG8+ofGgIjsC19YnwdM/KAnTSsqj6ig7uGgIPw3nYFzhhIIvriAxFP9CQd4HSlnzgxONIdrE7A8ZDPx9fjib8ifgegNIliRgdx95+E1T7+3nQVNNhEzDgGA3T2rEDLduwtPpuuouPcs8swwXFjdTaMKt+jA5gUAQPcf95KJQxYU0cYxEDvsBSmYuukp7AwnqniC9Afa5z8vboI68ImT0t26CvwBzSggkj447r9IojvCn7U92J/Hw0QSdwZKNNjxPCfSxRqnATkdwpOwh88oc4J8KTSm/wdbZjrc+4iFP8YO0/5JJDCfaijK5xVXevqfg6zGRrQf83chvX4aRfAE//6vv5+6490U4ADdO7QgM/5bcHP/n4OtCQhBEFeDWSvos8DPq8/IwzLzjpa8/U6MMSkBklDm8e0mn3QIY7XG1Om8wzN48y7HwhOK3P0/ZwUQHHv4psbdoVeb9VlAjChBCdtDDpOKTh9ZfcagOYq31RFjN4/gwBYzp8lAwYNwBELhZoxECeZxMlAzWGdCRV0fQWGHo8+8Kx+AAxnCIzowAxy9KvNepWfsfp4RR9kUrD88CPVTuXRybhqqTHcnxEGndsgub1Gdug8yz9fHt3Hpl57x/mfCOC29FOSQ7/noAZR5W3Ob24UMpuPYAYiQrQgk1gnFoUIKr4vKFpV15pHUJO3Y5rfH3UFHU4bGkU+NKJ9f2hJyOMxDBDpjAgwiYqvk5TqNl9EH2Arb6fA3yaA4cBtPWewhkEcIQJBlGzYp6zRmr1v+e3Fv27xpzvyI44NGDkCIi7CGNV9Dw0M8NtHC2vUwHINumCGNG8erxOwtQINsW88Tlwdoc+F85nI559ngEDpt2F/Uu3hiXYrkN/pBFS26hYDAkFgErMK67y9mGBA3L5ore5izf8b3n805MOq/t7XU4WHv1DUF/5gugCSOAIW/59uMwl6CHWAib8bvfxWl9/rBGEMTTwDfG+ezEYG4yk6FvRPuPwE+wvc39IRjENWM+/cm5b0W4Pf4WuKUnw/vD6eDbB1ETs5vl77Dhnm/51g6wPWwQAqxnivgQaeS3gy/u/1H4hpTPrIgHAN0mSgXUX13YP5PMIuQAfBr/f70cdeE+QoCX3i8nFMLcAjInBoAIYqt1LhC1WdtvmSab28AYffaeivCB+ohdYQgfUa/WS4ToMsNLHLc9nnvPZLwn1/EefPVf+U/xvnCVSEQEkEQEnEQJO7S7RvYDxNeNYKrG7DKMhtsQ8cMmhgPKKKj+F7CiHYFR5KIIPxOmg5IVAtu3ACQSPh7CzUQOgAej5CWEkIe3vgxz0ROGO//qYfz/dnLT+ZxDr4QW0eNCJBorCFOVC312Ec2TiY5Bk0cAaQmiA1VH1MOwDHQ0kHdEDDf+2UTWhS4Z8diQMicLx8MLBfverLcP/jQzF0P8EJj5+NGK9RCz755S6F/f1+X/gxeP+Wsedv+vF8/54aSPJYFjIQd624MDz/UDLQnr8HU3ztKHRf8Qeno1vyAQJBaLcMtTV3cvgP56COCqd/QP9xLgBkH4BxO13n4hNUDtACC6G1S3zqooZ6Ba4lp/zcAFb7iERKQwQcF39IFJjdXECGADw0IE4gg674pYAnk4HoHPx54tD5daO5vxrugSkMjgiiqc7TVKAT6AT8R4ckbHEQCYR/IZBxJgA+XZjsR7vaoRpIxWqeqfXuGC2CxwudicwePEB1kNkaZCuwyF0DuKv/4sz9mzP/Qxdg3BDkBTMC8Q+loD6UGBzx0Kz6eAX/KArOQTlPHFoI4vVtf4rNuLrca9edRn4xBP7k8w+9AgZCgBfEUZWfEs8iFNZ3UO7TqmkjCO/rWdgco/yIqHcQWaC2EGTzgz5y/iXQAvyx3riyxxV/JeBriaGB9OrTA5g9/eokM+37GszqfA/UZk9iW5UnCtBqBl3XoNN6Ag/+zy6A5evPAp+TIFDn15gQw9rjrOzFX0s2JBVAxa/nP1a6AsNWYGjPNGPLTQgBsNUFvOA3Ht9o/rGDN0tWOCcxJGp+f7++kkP7PxcGv1+GjkaLt/fawpwwerQxBJNW4b+PJsYEgiAYYdEAGIlDNaAbRkIgK3ut0jKByp+8yz23X6GttmBmjwDvChgiYLP5V/zhH6/110sGcKo5CkggCngxnIPoPja0j2B+1BRkiYJiviaLJqghDI63G2nAgAxMCuDdnoD0wIQm+urMB3VuAwbBrFGgGgnhAFqg9+ujKsLxB3qGCQNEEtPinIQlAj4WgIw7/iXc9V/x/yUWFs2KH504bAh4aYWf4TrTLGTy9YbftyLeVOWNfYNyt/ji29mQnqMAltU3ioTtbX343yv/1u0YPUBz6zB702tQucnX0gWaFh6DgPdmhXaapGotw0SFz1qDiTMdd8h45HfcqCPRUhA3+NmKz1l9teCPaMd4urGaewRitNBDdahR5c3AfQmDCFT9vmtQEwqAYXX4XI2n23Z9B/Yb1FL+LWox6wHGbZSo6FR1LzyG+3hriSZvWT6jfXhl2cmQZJDrAbuYAqAHo1GA/EOgD8eGcU7A8eDvH4fQBuAhBL/Zp/vamPTrRENDGLTV/7E1WEPLDlP/PwzU4YhusIMUgfIPAr6Dhv5R4y2r8ldFwiFoYHnmr8TAHbhRQSZOctH598ZYhqt6wP7q/ouqe77RJxvzFYaji/z4vna4v5cUMDXqDAJ5ytktqtBDckyjvJg04hl16LB0xFfyMfD77PZjErGQRRjYIfSvoAXntks0ok8MsUC4KARWnYPlJBeIgLeFrUgDOHYCag0/XNAbWgRwQuLAsaQwIhC1g7+jCNKuT38JfnYSyTi+QQEwwHeT4/dWHYxJPxfOj5oAnRQqgU3YgGZSOaDyK3n/qkDYBKptzR3oD6B4fyRKjp2AzSl80YR/3P+/1vBjX18Jbu+YsrMRgbqPP8zrDLTAaupphfeZtyPs9BPztpLSBZjowF3woYRwBwOWaqbev15b7X4RWsiqYiY6ZkFEIoUwUA2OrkeEQE8HYNyD/rl3m88jCGgO/nPW3xy8x4Q/HBcM1dYg5q8N+B/SBSYhtD0EY1PRGLDoKIBHF3yLz4H/gSYQJRETgqeB2d4vC8L2NVnQn4PoVJJAcP0inahAfdXVI8CFszjRagCTtRdV7Sr895NBpRKXIT64RMFw/iw5eChhEvmmyUIH+k+Qu3cLzOAN6ILlFvgWnx3YWFDz0f38ze9GlfP6UQ3ojEY0gtqRIEbA5/WgQFhsEuIeL75uTzvqHktAWfj/OD6sQXssROcGiRgFn0QVkld7OznMDT7CJKzhMIqxW9B+LCOQdH4uyxIcE49VTSeLj0wKjzcp2oDXQA8YoDEGBLMW0BJw+eAxXejPV/IXd59/tp5rVyYXDw5BlRetSpQAcvgfOwVM8ObzBq/AQ2wX4lwkQV3vNhYFfn2LFgaoDU1ogqsfqGkJYmrj9Tr22KQwBLzbLuzDeA9yzyJjVRfwegWq0H+FThDPA6ZhZwX2M2Kh4waovCzAWJTzD/qY00c+6PM8coz08VNqglzx54LfHuTJK7z2rwX35ABLg1DzsZ7Qv7l/f2yXDlbf4C/irg0MJ0aCuD0wP74MrxfdFlX7tq+vtRdCpvt599EG9Yz3V+P+Oj/n4zLruZHcJ7oMt/MNp9eD6HEeFb6/TMfbWo85Pb79HJo8t3371/PuIAZqMvjPC34nVV6ZB4hEuA7AzA5cfU0y2n6ux89D/35/n2/vWY5Bf0qwf3tPLISO1Tap9qzFB6eap/beqI94NCCbGwgqOItY3CGl446CaQ8i2Q9g0AvmgJOnBoAA0gu17tsKtKS7D4udgCYERy2QIceCX/P7mBW+g/7D9S6Mn50CS0eAoQPDcBjopIA5+EcxEjLweRjXq0UbLIjcBxsGx2IZvlf0ATjz/6qypAmY7bhrk4ahsIis6ccXKHdueAfUgk+RWPCLh42c6zEeKyJpRTdRAOqBbl/Wq/uT+q+Fx3FoTIuCzc6+hN8j4veGjuAnhSE5gKnco3A3XwYlq2sq+lmP4yEOpqEoG0M+mGDYuYT0pKCFHgLHKt3T7T9p8GcWH+n1UwGa8X6kQt2x4CeqPexegT6o/Z4Cr313PHdgrsS2ZReLfpKIf+IMFnmVmwxQ9AhithYT73+p2s+JIVfrjwiHnpAZrSsr9CMstQXP1+1+510N/q8E/YoekMN9OMFvi5LvkRDsy9rgFCOoPdpgaQIWBZjf5KCSQszZJ1ivTvLokpen6tsJAVND0NFqb6GUGg2Im4Dyx9Pn7/0dm4pADAslJzTv+dKNrAPQ0wyySm7bj1RQgbAXsRa4R+mBJzpaQmHLmy0BLoL+Nh2ZRca8uUc6P37k97n451fvTieAE8BdZ2ItqFEK6oOJIYPsiU4woo140Oh+H/UC++gatHYcOFT+2y3AYvD1rM/fpxdUcsAi70c0OxAEP45X/hymE9XeoC0zfYhbcqfbhs09HpwnKMDR6g0mmYyKth/UcLl9ITGQ8N1S6s+gA1HvQCc2pluPvN2Br8SyZyfyxPP/VhCi1L1HWX2CQCuAE8TIq/sBYdANZmTIwqq0sb0HIzhhugBeUpBZLFyA8y+EErsBUYDZHYN9QAAooQwOws+uQlhdESSSqk5Qsh8LSYI6LDS1AbmOvLlRBqQIeITvM36+TP63VfE5hFClCTr9zEyVFwS3STQBy66DMHB+PJWIrfgGnYBx2dTboPa2X49GaBVlePA7CFx4iaGi4ns0aLVjMGvtPTDtmO4XEE8E5Kb/8qYai+NHl60LgAICcUCoJPVeiYG6Pxw/X9VFNVbFn9FNPzXoIRDTyzcpREYB5Fm1EQQn3KRi9wKApR8Tz48SwxnV3qM0q7ZhpdKvr0zfY+gO4oQf+EGPFYW/Xf5hwWsUgxiBbShGoGIx+D2eH1h2EeR3UQMH4zMaUKr4033nzkSkfQADelFbLOQCalxdxvN8mInhPas9bxtGJw29Fx3Y8429MAS0fL33Oeo7qFZeiToCC3B/VSNYuU0fgDnkhxGgMFdxiYEY7MYel+OHPH30IMeVFK1C79l+QdXVpFqHlMAXEf3EYDyfkkGdNvJ8f3RAXU0jpgM7jMNA5yCrtfzOicKG/M9bgEkEjqqPPDEcDfqVwGZv6zcO9avDfOhf4OmLFd9OLBHHdxp51HvOBlnAoQksYjASA1xnIhPsapTCPjbsGB2YevpPpgM73EYeSYIftgPgte6CWesVBB9QEgfnWYMgoeC8ql69bWoRIqYHvSIv/u26bj/jdqZ9KSGk74JRo6QS9PuTiSHm6Z62kLUGH0UO4rwWrhtRETkR4iKRdI8giJ2D2nUCMjsA0TXiVDb98NAf/rCMlajA9wesWHZrAe1dlwRyVI2jx4KkyUHSx7YDe6YD4tOC6XW01puEdAJwaEJzf1uATHi6ZlSCpBQscsh6C1xRcWEG4bCFeKcAVhVlDu54JQIkTT21hptIT/Afk0kMcS9BKfjBJozcDXCrtgbWXxbMAw3INQIxtQJPAGwXmYaBbYh4SCsuKwLOAQ5awKskCMmRg8P3xwlBfbosQaDqyZqBkyQe1CLQACoTgN4qbyHsPwkTiF2pYaj6MAXBmUosQHnUEYCsBL3MW39SNKMJ5PfoBsT33DVJCEbFnBCMOkHfvj6Xq8uw+dgRIhGgAiUqf5QgKDFyhe8nnYrlqn9sG1GoAfirubygX4H+8IM1CmQrMFAJ5ExzKIp54nPoVU2Auh6eBShDlTV4u5c4HE/fVvjFrsII0Ik6QX+Iq68jB19ziLoKC27FYe0gC+j1RSS+BgB7AvAM3m8HLdy5fV60C8RMVuhD1ieQB32MCCq0QPJuvuw5IHF/geMKwOPdpmsxBwVEfGEOgeincJqNmuSFIPhPq/xM81CWIIi+gCFBqDX3QPYd2OcCRo6GZBoA3AM+00aesAOQ7/2Pe/vBCXoguD4OBD1WfPwClzcui12AuH+gC0gEwW72KfjBCQRBr05D0IQc7N8PzOCMehPWK384MPVDJQim7yDdoiRTItzzFV/ZOX9sYFetP0fsQzb6O7wOoFjxk89YoQXv+BmSN+yYHYO+BsDRAXHhuJXsEFbdIEGZQWUkNVNzGA9NZUVBIQL7jASR0AclE4Pb7JN3BO72mG92+o8UG3nybj+mASh0FsLKn9GPxDrEcS2Au35BzHO1BksriIJdpqWjKR1wlpR4fN977rZqI+XbYjYDgVDpcYQalOYKMiuQbB3G6Pu/HlMbi9a0EMkksXtjvvXTfgMKAEZRN/i/O7yD8Da2S2Bdh3ICWfp8yuMkYl5a4df4vVWt4UF0yyqEnaT6swYyWB8/j111Y1ERS9oB0SLMtBGDEBD1PEHwtdjUEAHnqmoHU4wCDAoAS+lHwtu9eQLUAgmxVvAuMB9cELMV3m8EUtcBYYI9nkNIEEJYrQeUHfnzzRyC39j8CgSkir/E0P2odnAmAqDnDIhqrtV9BDNS2POjv/0pwKr6z1h/PMz3uf9ykFYq9TtoAXSwpz0HljdvBCVAPY6t7osv6gFhMpkX13rcfXQMIpuTsfTibkfOPRAC2meLRipI4mDPwMD5x+v3+Ey+qEfACwoUEkKQSMZxYJDz9R68PyP43yvo2aYf881rNQbZgRU/jp80QnW/hdXqJxMvCFxXQSNHpE8QiF4XI+wFfQcw7VL2Md7RRajsKgh2D+6SLAKPF356+/7yXYBTUgFy/38StUjFHweD+iiHh8/LV/i/TSvGk4L5x7F6AsIKbgb4C0YjgdGRIToGUx7cgS3JKP8pRcgak95BJGQbjaJdBYQ1qHYnYHL8F45QgHx2gLMQ2cDxBD/4SeR0LSDi5XzPQNjM4ySE/HGG6g+ugltLNSARn281BPtNO72eJLjdX4ITSEgpQvJYFEUg24f1qAYQNQdxx6Q/RcB85j9f+03zf2QV33IDPHegNgPABTfqFR8cZK9TA7/ll0EQbUUHW8Gr1d+MSadia+LRHwhunv87yWoJ3h/pRDwJAbDNQQFd2P2mH4kP/wDT/ZeN3CK3+ZjvgVpw4r20AMafb58j4N1UMknuj6iCx883PU9g2VHVH5JX2eEcPghSgRBCKPzK0Q3fknwPN0Hk0CyC0zBkz//7duEetgFjVtypASDI4CsknYJgYDhqsBxxy29+eyxrAZX75EEf8f+CkOcijMDDHx4ASYGGu8WHgPwpHJc0qOG8FgFTuVk0cRZVePFwHEIUEu8xSHoL5qWg4I7/HgOKXe2dcnu2SSdCGIDTA+AcxY1zYL6Q6AAFu+/1GvjKPSeEoJV3NiM4Dz9C6oWkEav+NWjPWXNOIkKgNTi2I8LeBgaZHJxqrC4oNXoB9pzzMws/OW3ghSyQJgjbygOVEDhoj4nHLld8HPD6UUMFVLIgKrTL7cFoBRLQgEdXIseZ2/HhFPKbk4d5tYWwwR0nIFQSD2P5gQhs6meVfB+Bkyz2fOIvX/zxqsSODuAGIOLtPNnmIPCrv6Kqvgz3q4tCwNl9lWYfnsdHj2HTgQw5IBHwULmfSu1jEV3gDFSxTBmqSEVqiYK2IkWcRiAkwV/cyW9YhqHXDw9dkNQAcO6HFNJT7oChfrPUYc3KY17zAd+evAwF2w5SCKLV4EuCEKsKfjBVWHu9Q9Arh4CoBqEMWYBsNX7YgKP/69uC3M7/mOOz232QT+ox4iCyJGEFP4oBHd+GVvXBwX35nqp7qeIbV6L6tdZub3ueJ+gBIKgC6S5gOQFxDoGr+Bv2nzqbknd7ph/EmXzO0o+kZdc/wqvQkAOUffVMzKtYgx5Vob1/+HAfCdzHSiXHenX35/2JTr3KZ9Ruj2lYiMhLIFoNyMq9hFroeYMTE0bSLbhb4l3YlFPa6hMd2jk8dmrDgdQCnC4/+ANFlYTB6ATlx2GDGXP1rvL+SnWHw+cJes5/rRWt4H2pw9GklD4uSMpwasIQiaYR92gIyFX5S8dtRZt/nCAH48VXW3hRE/HKOsGquj8EM85Q9cfeAV4XwNGAlmIFIwPYrfLKuxV476RRetzcdeAsRSZhiHizCKEIOHn3EMOWy5X4uIJnXX6sFiBFLaBm/THOQAkVJK9j6TKwiSDTBWpwHkSPQJX7U959uAkoaTUuug6oQCBz1Zlxm0OJSIoIw04M+7zCGuYiznCfHww9AN6Ir+HXA7lfn2oBSJ2FOOh8SzINfmcAyITq8JX/sOMPx6A9LeYtVfwgCBZhdu25OB9/XmWWNPUEPD5dUuJ68wd1AqD2+w1PI9KxE9BW5t3z/igdYGWiL7L+wPv9jgVY8f0ZcbCKCuLAHN+c5wa69Zpr0J9t2KnpAGzyiAIPiFalJ8/xXrrA6Y+/8NoDnWCPNwFJzf5DpVkHte8hx76P+HU1+HEytEeSEIzAsu5r6wPJGu6oLz8VrKofXLce+ywIHhNa/Dmw8LrptWXZ4NKZm4pr/QQ7Qk8ehMrPtAF7PQCD309QgRgRZMKgAbFREAfBBXNalbHA9cEHMo4IgIUuPjjBWEUFEQpYTkhVO43eRiynJw9Jjj8TOUIlJExK+0wA4gWgQvcFBHAc7P4/u78/Ff4CC5ATB3P3oUwFClYgcALcxzp/B9Ez4DUV8RjBbsCBrMH4dLNwIDaCGhA6o3pXksdBvYBsktrXDgNJKAFy1Z+ZGIy5NXgXoBT8a3ZgVSPIUAMV6DjLxhsV8wX4n4ibbONObHNyCr8Z4FinNFjg8ziiF5zSV8A99u7Zdf5OisvVaAAAG3VJREFU/kIPAJLWX3hUIFD6o7MD4WkHIMXBk4IftSrPNBJVk0OoC7ice8HGS8XBKDoz/YFBLaQi392lGpCMJfhD9xVkx5Xbj73P9V4m1j0v73x9FjDDPlYvATkgFAVWcdNvJBamliOjAwRV0EpeRymAe717kMYRyy/j5FwFBX0fP7Dyx8gq8wn2ZXi8GfGYR+lFcGJSxa3Y84WgzBHetlU4cvKY44Ps4iP9fsgsPGEhQTAcHqwwGCj61SoPexKwasXFqtxq8qhD9SixoBBYcJEDNzmIoi3J7QkoJActVHocTVpPBCDhElAvMDK1PT/Sq3DwB/ygmyB9GNhYDH4so4Foy48kkPtZfZEv1PQTxYpyX0EI3Bu+/5krcN8fgwVdwWu2JNVNWAk+PcOOPMNdGFyAZ5Aj6gicgzNfwuHZg0HrLxBWfjSRl88fVCo/apX/IBrIvf65ZxtEoK9Bec4KZIPLe76osQns46NwW0pUPCPAyMc4A/KXOwZzFLGbAqD5xhhbgBcWfoJBAlarcCSQgdQJ+Movnih4gjZQTw51rz588y/ZgxVUEAQ8soCfX8OR26JwujCLGFAMsOjnwGrlPuQw9D/PPv8BYVR7pG/eeFtQpsLzR2KFI8SwKj9KlX++HeLOPuSBKrKeHBi7L4b+Kx184+ptAp4Trcscv69oARVYzWgaK01H1X0K3zNSmARKtxXYHvwJuT+8gLGGWgpHcWOmBeljFB2Ckg6wiAYOqfxEK3GMCAj6kIiTWdCBCXhkjUKMgJcLk271N9uLSbtvvK0S69OXAvoA5z94VsFubbmZvx4QAnXgBnJxENyQjy38wef81uPhxMpPJIQzr5ckuUTKe0wZyN57iFTWga8GvCwlh5UqvYgmaNV9XSxEVWs40kkosFwA70RgNOu8mLZfR6wDiwRa35y7j08NksqPQhcfkRBK/J8R75Iz+9C8gJpqzwiIeZII3QnYOkJWbVEI5jNuA+o2BwK82ifwnpSgHwaC+GNAdmW2VXfC+vPu6wR6lBj84C9WfvivZyUhZMJlJhjSukDlFJ3g4AvGJfC1iEpQJ/CaEd7G9wds7p71+odruKrHip/C7RdsxeVjzIxhoNkFGOW/+sk/YVAGtltfzZAIfzix8gcHhZCXpcGN2u69qWqD9OlRFAy7x2fQBhHUiETB+DocqvArYt98f+AEAXApsEmEcNLC0t2uPHCqPQIXwHYDfI4/9+8LMpchqr5HK39MJSrBXwnutNqjovjHFdq+fcHLp7YLR4mGgduW5hFpAXUoL4cTTuW5HJSkB5PC0S7A+8c+837DyoM1J9iv/po/o3BunlDqPjOSO/YbLFd+FGy9sxKFeT8b+nLNPrkAyD53FtT27yUS32yqUaEGTMBiASGcZ0FmK8nWxbvjC1q6WQC4VdWdAcBY8eFoAzIrC0b7Wt8wlPcIdE1FhUWeKU1Igv8Q/0dl4k/NnYSxdlDon8diUDeuQB4c8XVzcahRgyyZmNC+LAgeCfSVALde8/t1DCYawNoePGT83wlOpFUdOZKwxn89OsMEf0X8CxJCBN/dwKbFwkSMgx0ACJJDJD4iC1JEYh6XcEqVHpx4+J4I4UiAl26r5x64sttvSlAn3LBuQCz6edU8C+J5epBrC4YP52EFDgHrCw1B0eU9bOaTgh3wmYvQV3Oqqcf53XnVNXUBELX1xtSgFrirlII5d3HFulxBCNEfZx0h7K2f34XwdHpuYQcguN189Ow/nPXclaUcqMH5leCXjKOjbv3F0a7i2ZaRHmBe5zwnhA9S736ZC8AH8LHkg/T5znYgmES1dtuzGo92qwHIquiWX+4KgVLd8utv9Ml1BQNhEJW/FOgweiTguCUoQHkEwYhjfQIgm8eAzPKzHqAG5xGiiPyxeGRRaYetUpDVpHVC1T9bHGyaknb/TQTnuG7rDYwYCUT7/cMjtILzA+Go/FPw581F/mWeTkDuBsBCAK8ki+A29nMzPn4Rzjv6QV7xWW4fzQFUxb9jQQ1qc28kMi4mDl1NBr4usIsz5ltZqNm7AeJXfuTHd7nioLEyPBISU+8/tP1AC4Il/n+YGmjg2NiBRdl6yCw//zG5ph7bqaBuz8B4VMU/TqSsNPbwCeZA1cdxyG9SgKzRZPL+GXFOiH1/SFZ9wX8M3zUgvH8a4rMBjZj/h1W9MrwTiN6MlsCKiI4gycBzgV/xUaQGjGDHwHiYi0VIzeEAasCpNuL76AC7BIEl7i4AIxnAfoMxk35eJbZ68wWEUChs8IPz/EEE9BkUoNA4RCWSLJkY1h0Y/dG9bVCtUVPe7QRhtStXG4nOECDfUxc4Uw/Ik8JkA9o9+a83IrfHH11EdFUWc4phNgVFWkPsIHBnCvCCYBSgqEN9qtoXuwHhByYoJJA7BxIkkRwpDGgAHo+vQ3ZGOwCFJCJKUAx4MBpFZWvReeLgtBBkDDQu2OJxXa7SE/P4ZiUPHABjY1DsFIhPAaygWewiXK72hHjow/k8gCL6gKES8qcDZ7A+EhYlWCPGCX1wXIwzkQEKt8cP6iqkC0FEhFj/ZYtvXCtwuBLcDT5wXN+9H6ZEIkTwV/x/s78fXFX3siWHEKrC3tw7EFZ31Ll7ttknQyEMGgAqCaVe1bGk8r8nFWCQQR0h7CY0dsU/mIeIuA1AGCo02Q0YVXxub36sG1Qgfo0CBBUXxap+ECFEycQVyViBEBFPt14TK9rZHB9EwMG7DPXOv0OVHkdtx7OSCXfb3av4CFZGTwQBwT7/hKPHE4PzpJ4L4+FM9r1n8B+B+9R9I4Fu9brYUZgCunZWNxdQgIs8mASBQ4F8hJpEiaf4GPihk8FdAxin/kybjZjTj+mAQy6ihZ9whDvHAWB6BKrBXQr+5SBfqPaINwiz12UIwoTmbPACZY/fshBBBKNlW8ZCHwH/cVKSOZMm4Mxk4OwE9JeB+EFkn1IzcPQoiSB4vGgNeJSoik1A7m0TCmE/HrggB+/1M12C1Z18ACGoIeH1pH2IhAqFWgBq+kDFEWAvA3X8tpW0cnSD5WAOriOHhnYraF1eLTkS8P/QsHUBdtMPnOrMaANJE9AZiaKWII5Ue/8PTHn/UcCSTgIF2xN4zdmAQYIAKeBFl6FiO0aKfq5jcImHfPwTxcEdRmD3LcFoAva1Hdjm9UgGggI9YOoPkOBYLsT8HlG3nucMDGkOOJ8CkNOELdSO7D5qqAeJYBb2GpABgRi2gxLITgrOQ9C937HgB+0i7MeRx3gfPWCXLtgbLJAu/gCFBPzRX8eADJqCvA3FViC/BlOQC4LZyrBq8BdQAOUKoKjqR7v7EFfVFMojPgEoSlJesNIePyLHwW9NRgq7E6HvUN8A0yj0wyWDHRZ3J2A1jHdMyu3hCGwSDwdRir7h9VP7AKLgPoMCgKziOFLtrUm8aIFHlgxYfz8WBYUU55iAXauo+evJaIK/NTgRJM9sUcZRzcCnMdNKMJc7usnAyrpxHYkTRHK+n1HxS01LheAHqRWwKIDqLvQC0+PupHZgBawfVGsiniTVHwZHRqbUI/D4Cd+ftgyLAR1ehkIiqaKFw7MJEwUIuK5zsu4svoFYCFKgBJZACBuppOId2RDkPZas8H9kULcA9a0KTCQDGtpnzT+RMJiOGseHl4BQ1C29AWUXIIf/OIwwqoNEK3SCuA7FRiBrE9B4/PcrGJ1OQNj83F4Xbol/TgVHfMiIZLAdcaVkgh8sLrd+liNQH/FqsNTfj15m1J0X+ffZuq/gTY7QnvIfJz6UzBJLs83ItQpt3RfZz5iuGfNPajpngUm0R8DoA5jDlzsOTAwZjzsC3Jjxg7H914PjlcskGdghgx9HG4OOQH34uwQyzz61/0qiYNQjXxECuWYbGM/DrjtPH/Mw/K+gBLLSA+cEfPr4MroArzcDuybbr8Zc72i2UnzeHnTgzD4Ug78SzIvCoARVOQxaFFR3TzWnkkHUVFShEuqKxZnKz4p4YYcf8ZhYhuu8wFgSHcuuwCJagI4bgchJQK/qe9c/RT6nGcg6KGREJpb+MI0EY/b0jcsni3AJBeCQNsBOFVYoApcM2Aom4VFgIRdHpeIG8D3YaxBD+qCiQ+rBOSVnci8hzkAG1t/pgHA4uwDzmu8xFKkkkIqCfkIRs204r/hiDgutoAAcowBMZ9+KS0CcXVBOHCvJw2jMQSJyeoeExF2DuTuRcuWAo9sefyUQ6/oBaIjPtiRH1KvQKvygAHb171d+vc4GRMDPoxN/kL5pwlVh1mBQ1quQJAJ5j0TgOAis+h8d3mnC8xTKE34+8sDNjyVXE6nFMN+H39TQDmocHScENvN74LoGScGU4f7g6IG3n3C3qnG6JBS+Z5tHOOzRYQx+u7MZmAl0OSsRLAS/VIKfRAWU92+12aaVPksGDBWQuCMvgNy2M2Mt8EwqbjosZAec5xLEAmXmcFTHiOWARWglpNpjdEtBQRxJJU5VL5/7F1X86XntXgUK4q+KggsUoIIK8oA+kgy4+zLaACqQGTVOX6MBWdehL6BxHn+tlyBMDGAqufd7WOX5WTJwKYDfXJJP2GXDPk7Tj5Ed7BOG7DMFaBRAJgI/+H2Ngeb2SKb0zkoGlQBHkefDr7xMA5HZeJPtKIzyApI9gmnPgf1c3mulfhe0gFekDCdNFnrOwi4Gs6eTACNjB+Uegcgojog4V25P8bctRYY6RL8AJklE9ACFAGZdBEahd4d4CmghFhbzcwaXYH5qTlS6DY+KfNH5Avzjo2JJ0poDkSCMxLn73H/eB+ifvgvyIFCWAji7BWC8hd0qj0FziMdrS70BlVbgamIgcmotGZDNPwm0L9l5iHv7WRoAFx57ScFS2r2iwot8oKu8l+TOCOg2mZ2nFdjTgOFQENzKkJ8OjEnsE8f6AzyXwT6MNF3RDRnuj0Lwo6wTlBMDIyqaz6G+RiLJMg/KUrQV/rh9uH0tWduwoxmky0kSMQ+rnXxZsGadgnxfgk1pCnsIsGYltvfdzTOBIclIsN8MLAGcz5gBwj94AE8DuC9Molip/JGwB57nRyJiyD3pyk6q5ij+3TzRLohcqyqCEQBTepF15+WVmW8SEr5jMUUkx3oMIsrH3ndwAQganKzyMpOJNxMQooGBYwcByw7axIhgPRGEr6GSGJhkAELoQ1YRg+dPeD5IIRDIqq5PA2Jh0Rq0YcS8XBi0ghGRFpCtWTdum5+yLOsQf2EuYY8AfnbQZDgCjHxBSKwTGpt8QCIDVH3/4H5OwEvldhliINwAFLsEyyIfGKV+vm3eEehVqKTdNxtDiPoLHCRiuwTJxCECxMDqDjTvZ63KaPKvRgV2i/F3ohm88V8LN8hgJcXD5pVGIPPNn9EBqSQC0I4AMxBUcQNCkarkFgSn/oCs9GCVep4eUG5BRAOcQOCWlGSc3If0IFqRfURQGRrKewPKEJ9sLnIowKCcw+f48N6UHjqYtgInaCCkBbPSj8VEkCr2g8U43wY1xX/BNkwreQrzg+oaJghOCGTU8RBxuIp6VFOGoEXgEsBLIgV6gBgxoLSI5CgiYNT+GBHsU01GthrceiMUtv9KgAYktgVNeGrBbtiOQVi9x8WjiAW7UNUnm4Vet7WtsFgDCDYEwQ/EVL1PnQf/xCDLTowTh4c4HPRDoQaiwhKIAae4B7xgCBydI/CDPOrevK0FR4p6w3VfoXgQiB3T1N8Y1PCD0X19JqcHGfzB5WkQE4p/kdeXBcEVUXEIFqSij82lMyrWq/7c+LFHA7z5/dwOHHg8s/Y8C2CmhbmALtare+4UWLfb25BmXABKABTniC8gRAP2yvDAiUAsElnrxFzITQa/sAFecAOY7zPV/8jMQHSbWAiUPGkQNABhw85xrSCv+mMSzFR8+7mjw01A8f4F8S/td4jnDHYxpT8/OEyV3gz2+GTfdAeAszswfJNGlQhEIjB0Bls0BKn4Iw7WKu9f1gmSagmvqleEwJwnZwjO7npz1HdCJ1hS/mlBcRXyF3i/M7NxqJFoeH27z7nnJaBmpUZKHsTbGUc1ALEoIGsGYl9ixS50gjAT/VhB8IzvGTrBVfWEz1MzAkRFTtecW731VdjNQPukVdhdn0Y8d/a7WYH6i/TBPBzUFwAlHwtGHOQISrgb1AMUgDETTA3+THAdeRJhg59V/Ektofa9I8wxVICkC7QQSAd2O3cftzPzdMK6aA4iZI4ILfYRbb9RgqICt2AxVnYZ4kkBvHOBxT/zN9ybHx/f5Ql2fkGCX6ANm6F8WCfqAS+Eq5AGcHJd2IFHagTMHAAj+mWBnDXuc81CjhsAi5dL2K8QCYI1aJ/PJtSSxEFXASv7C2I3ZB9/a0j/7nDn/j1pHsz9Jr8fNpxPBUAUUYD4wz5GBlmyAiORjtAIGDFwzSUwqiNZ1d1tPiB7/Q9VeI9KeJU16/knkEeQJEALjY4rkp74fCZiMDSA/PgvT/aT2gYgp5E/P29AKBQAo6TRth5T4VesQFb0i4K7RA2MZpgyFXCEQHCOixuYMPgy2L7+45ezSSKt2oUkURlpXkEMOLSiXPuDQZjk63N5bmzOSxQdLHX7AhwUEA0BAeQPJIQzkAuFlOK/GtyLdiGDKEBdllQ7YouxV2Xdwza9So4Kp5Z0yAgUhTlJgFzSFrznIHYIwKcCu2/L3LsCg6UI1b1/CA+ApIV5/32HqOIjdQusE4azip5Wc1b0q/QGIAlaWEJbXP3r/L+AEipw/+BtkQVY9fIM2i/ZhgVEgJO6DZ1ksVtlYdoQAPhVO0oKmYBmnAYco4DRCRB3TwCziptaE0auER9/VzRqKNOEYINOQg2m1l9GpGNQAhh1v6UmxNQh2M4+LmlUzll0OTjYQOaGlZAEMCrdhmBphaMBwBADrSQQc3//He8KgFETT7p6BHnjj2X9EXsDjrgBS6ihoAmcSQVYmE4JgYWFpp1waAQRoqDzxDhU+HxSnZHz/9JEY6Y5MJA+cwoWrt99+U3Mc/9g/NQTFaigAEtwB1yBzwzucZSX7RZEILhR1d5GDCsBLVUdIQvsldZfEJt5i/MHx2hGJZFkVVyK242iFeh58oBUFqIQbkfp2DV2X0CkAYgv1sU+P+I/HmBu8nErugdRnUWhfp+A/ddlbEH3uQlBsNobUEMHasK1HOYn8BEEvCUaiuigXRIKj+sGOPA4KAWz9/s7WxcgB4+a6/fI2osEwv4yOENAiPf+wQhbc/5f0gGisWuQaRFmGoIqguARWsBQgTTocDLMT5OJUQnhqdCEig+/EShKSEgTVV0MBMnz04BcshPnLk/+OaV0/dwKzB4QUt1NB6uTDfGOP+cNm9mEsBAFiM7AQh9AKVEU75vy68jeOxrUC4mDEuYO0oLqoSdHaEF2eXYYSm0V+oEOwpLmYFOF3Z4CmAeBTIGueiIw2xoKPzDBJVBXQ5g5O8/twwA+QguIjJt3+g0NQEcDfUXgO5gsqlTBLkQLdl86K3CWneitQ8sg/5oWAUJP2C3V3RoEyji5n4b9lB4t9pz2CA+cAFn1Z9I/uzYsU/ELtEBOCHYQQqGcFejV+yeuRJX31zsKV5IGjway9z6PLDxKwNEPsBuOEiqw57jGgOtZ1Y++T50AuMFl7hPIbhskiOwsATtRoc7rS7dXrpcgrMCGJca6ELJo+Y0be0BW5ZKGcFz4y8W9BduwcDnK9iO5fagsKpp9ANnvDPxeP8THNyIVFo1AMas8Qk5v2Ytm0LCCYAXqn+wQsPTBh/5Bcnne14Os3uCQt28vsK1WUESJFviBgAW//3u9PLxusXchcCR2WsNzv/ImvgZzzkUByDUAIrjTvmSHAowpJBQE4SUlxMxnARlQbIqkArVAJ6pBBvELCCKlkyCDAP45BYfEPfcUpfMch3Vn4bheYK4E66BxAxHSVd5INgEPgU/NBCDfNQ8Ho1CoINAPQAW/QT8OCIZlNFCB84XhoDChFByHGjx35v9BLgyhmojqHYb5QYXnuAecvua0hZe6BV9f7v4ibvgvamrmAc1TmaEir0LQ9h97eYAYVoM/nWA60i8Q3Ifezha9BqaaL3zvqd6IAuwwLSCCuCLuJWch4h30giPtyiAphKEBcCu9BV5wwzkMxID8rhMwdwMhcSFgrBT3RUTQboAUg3+p+Qe1IGarOioVnazmefV3lHpwA0AcLWCahUiXwePHWJsP+GH1gnp/we5KfOhJAbsj0H/BIEb04TbrTPsAyb2LLu93KwfCvn5PLAwrOXAa72eEQRo1CNdw5IprsAZ3hApy9zlcITG2vpCihsRSYxNS+J4vdBZ6B52eqRcQ/QXmSjAWSfa/5GA5qEg4iJFtm624AqXLrSA2gx8p1Mdqcghv41S0lSp/xAYs9gakQc4Ie2RTUYwYgt748mV+FU1Xgp14eW3XYZ6cdqGTNHwHICTwEeTPl0jEZwIgP9gDEaogeg5IHWCF+1eoAhvEKPB/EAeTRsM/pSAP5wjWEUMM1/NJRhwJbpJSgK7S7zF3EOsI5jBQBK9DV80Z8Y0COzvmWzJXgDl40KEC6cqvqgi4OB5cpgLFYK/1CvDiItXqC6/S87wfAUfPtxqfGNzlYaOjlf1IsHPPvffHgDAoEeEST4ZLZUd/RSo91/BjXY5ggWgQ4In3fyj4mUqPrInHOCLKO3wUwRsfyXpt1nEIRLrqcWeTuk7bigsbid1zD4iDRQtnIdQsyIXnFCn1I9D7ADgxEhOvR5AJosoUbu1FkJyYCi9OhQERoIx+4AX/YqUXQhtYEwKN4Cy1HntLMmtaAQpqfrT/UCoLSxeswjA5UWPPi0mjajUWxMTdVusNvt/ChMdmILK5IRMFu90BMEzFYHdg2GAgeYVHMMJIBTA7EFTx/5fpgTFXz9w/en0ZjD8kCDoKPNGwlB01BmoWQbh+AxR689mBponGJOr9OwmMu3dtJ/ylW1Tik4ElUPmR9RqII+pVhD9ychABMQ51gOIZg+/G+5mGIzLB1JJC5WhzYjhJ7IWmLDpA8jzsAafUPkB2WnFBF4iSxkq1ty7f25rv/+EQLOxs2oUdTSA9HIR9swdBlCcFe9owPC3XWDDC0ISVzsEVbSCF/sWdA5Fu4HJqankp2SeQCYYrImNalfmhpVxYrGkUS4LeSUjg8dD7+D7w/ybIfy7vlB9/HJ978zr7/45Qgajzj+4EjIK/ULHPRAOlKr/aG0AFcqCyu0GcW45Igh6JMJmhA49/U+cEssHNJhtXDC1MOya3j/sAiAGcrEtqtgjBD6wEzSDc7D8o6C8rIqAZyPk+NQoNLAZ1hR64Yl1FBY648smUYKnSg1Xwk/0DyRyArByMUobyByhCcPnOaPyoegREFS4jNfYAw+IHCjdC1J2WDZBke/OyN85J24WiXwDYPoJyYuCD238ulvuzwt6KgHf0shWKsqCFFGjB/w8HU8eeTED9wAAAAABJRU5ErkJggg=="
  93487. , _instanceNumber = 0
  93488. , GetEnvironmentBRDFTexture = function(a) {
  93489. if (!a.environmentBRDFTexture) {
  93490. var e = a.useDelayedTextureLoading;
  93491. a.useDelayedTextureLoading = !1;
  93492. var i = a._blockEntityCollection;
  93493. a._blockEntityCollection = !1;
  93494. var o = Texture.CreateFromBase64String(_environmentBRDFBase64Texture, "EnvironmentBRDFTexture" + _instanceNumber++, a, !0, !1, Texture.BILINEAR_SAMPLINGMODE);
  93495. a._blockEntityCollection = i;
  93496. var s = a.getEngine().getLoadedTexturesCache()
  93497. , c = s.indexOf(o.getInternalTexture());
  93498. c !== -1 && s.splice(c, 1),
  93499. o.isRGBD = !0,
  93500. o.wrapU = Texture.CLAMP_ADDRESSMODE,
  93501. o.wrapV = Texture.CLAMP_ADDRESSMODE,
  93502. a.environmentBRDFTexture = o,
  93503. a.useDelayedTextureLoading = e,
  93504. RGBDTextureTools.ExpandRGBDTexture(o),
  93505. a.getEngine().onContextRestoredObservable.add(function() {
  93506. o.isRGBD = !0;
  93507. var d = function() {
  93508. o.isReady() ? RGBDTextureTools.ExpandRGBDTexture(o) : Tools.SetImmediate(d)
  93509. };
  93510. d()
  93511. })
  93512. }
  93513. return a.environmentBRDFTexture
  93514. }
  93515. , PBRClearCoatConfiguration = function() {
  93516. function a(e) {
  93517. this._isEnabled = !1,
  93518. this.isEnabled = !1,
  93519. this.intensity = 1,
  93520. this.roughness = 0,
  93521. this._indexOfRefraction = a._DefaultIndexOfRefraction,
  93522. this.indexOfRefraction = a._DefaultIndexOfRefraction,
  93523. this._texture = null,
  93524. this.texture = null,
  93525. this._useRoughnessFromMainTexture = !0,
  93526. this.useRoughnessFromMainTexture = !0,
  93527. this._textureRoughness = null,
  93528. this.textureRoughness = null,
  93529. this._remapF0OnInterfaceChange = !0,
  93530. this.remapF0OnInterfaceChange = !0,
  93531. this._bumpTexture = null,
  93532. this.bumpTexture = null,
  93533. this._isTintEnabled = !1,
  93534. this.isTintEnabled = !1,
  93535. this.tintColor = Color3.White(),
  93536. this.tintColorAtDistance = 1,
  93537. this.tintThickness = 1,
  93538. this._tintTexture = null,
  93539. this.tintTexture = null,
  93540. this._internalMarkAllSubMeshesAsTexturesDirty = e
  93541. }
  93542. return a.prototype._markAllSubMeshesAsTexturesDirty = function() {
  93543. this._internalMarkAllSubMeshesAsTexturesDirty()
  93544. }
  93545. ,
  93546. a.prototype.isReadyForSubMesh = function(e, i, o, s) {
  93547. return this._isEnabled ? !(e._areTexturesDirty && i.texturesEnabled && (this._texture && MaterialFlags.ClearCoatTextureEnabled && !this._texture.isReadyOrNotBlocking() || this._textureRoughness && MaterialFlags.ClearCoatTextureEnabled && !this._textureRoughness.isReadyOrNotBlocking() || o.getCaps().standardDerivatives && this._bumpTexture && MaterialFlags.ClearCoatBumpTextureEnabled && !s && !this._bumpTexture.isReady() || this._isTintEnabled && this._tintTexture && MaterialFlags.ClearCoatTintTextureEnabled && !this._tintTexture.isReadyOrNotBlocking())) : !0
  93548. }
  93549. ,
  93550. a.prototype.prepareDefines = function(e, i) {
  93551. var o;
  93552. this._isEnabled ? (e.CLEARCOAT = !0,
  93553. e.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE = this._useRoughnessFromMainTexture,
  93554. e.CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL = this._texture !== null && this._texture._texture === ((o = this._textureRoughness) === null || o === void 0 ? void 0 : o._texture) && this._texture.checkTransformsAreIdentical(this._textureRoughness),
  93555. e.CLEARCOAT_REMAP_F0 = this._remapF0OnInterfaceChange,
  93556. e._areTexturesDirty && i.texturesEnabled && (this._texture && MaterialFlags.ClearCoatTextureEnabled ? MaterialHelper.PrepareDefinesForMergedUV(this._texture, e, "CLEARCOAT_TEXTURE") : e.CLEARCOAT_TEXTURE = !1,
  93557. this._textureRoughness && MaterialFlags.ClearCoatTextureEnabled ? MaterialHelper.PrepareDefinesForMergedUV(this._textureRoughness, e, "CLEARCOAT_TEXTURE_ROUGHNESS") : e.CLEARCOAT_TEXTURE_ROUGHNESS = !1,
  93558. this._bumpTexture && MaterialFlags.ClearCoatBumpTextureEnabled ? MaterialHelper.PrepareDefinesForMergedUV(this._bumpTexture, e, "CLEARCOAT_BUMP") : e.CLEARCOAT_BUMP = !1,
  93559. e.CLEARCOAT_DEFAULTIOR = this._indexOfRefraction === a._DefaultIndexOfRefraction,
  93560. this._isTintEnabled ? (e.CLEARCOAT_TINT = !0,
  93561. this._tintTexture && MaterialFlags.ClearCoatTintTextureEnabled ? (MaterialHelper.PrepareDefinesForMergedUV(this._tintTexture, e, "CLEARCOAT_TINT_TEXTURE"),
  93562. e.CLEARCOAT_TINT_GAMMATEXTURE = this._tintTexture.gammaSpace) : e.CLEARCOAT_TINT_TEXTURE = !1) : (e.CLEARCOAT_TINT = !1,
  93563. e.CLEARCOAT_TINT_TEXTURE = !1))) : (e.CLEARCOAT = !1,
  93564. e.CLEARCOAT_TEXTURE = !1,
  93565. e.CLEARCOAT_TEXTURE_ROUGHNESS = !1,
  93566. e.CLEARCOAT_BUMP = !1,
  93567. e.CLEARCOAT_TINT = !1,
  93568. e.CLEARCOAT_TINT_TEXTURE = !1,
  93569. e.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE = !1,
  93570. e.CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL = !1)
  93571. }
  93572. ,
  93573. a.prototype.bindForSubMesh = function(e, i, o, s, c, d, _, b) {
  93574. var k, j, $, _e, et, tt, rt, it;
  93575. if (!!this._isEnabled) {
  93576. var nt = b.materialDefines
  93577. , ot = nt.CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL;
  93578. if (!e.useUbo || !c || !e.isSync) {
  93579. ot && MaterialFlags.ClearCoatTextureEnabled ? (e.updateFloat4("vClearCoatInfos", this._texture.coordinatesIndex, this._texture.level, -1, -1),
  93580. MaterialHelper.BindTextureMatrix(this._texture, e, "clearCoat")) : (this._texture || this._textureRoughness) && MaterialFlags.ClearCoatTextureEnabled && (e.updateFloat4("vClearCoatInfos", (j = (k = this._texture) === null || k === void 0 ? void 0 : k.coordinatesIndex) !== null && j !== void 0 ? j : 0, (_e = ($ = this._texture) === null || $ === void 0 ? void 0 : $.level) !== null && _e !== void 0 ? _e : 0, (tt = (et = this._textureRoughness) === null || et === void 0 ? void 0 : et.coordinatesIndex) !== null && tt !== void 0 ? tt : 0, (it = (rt = this._textureRoughness) === null || rt === void 0 ? void 0 : rt.level) !== null && it !== void 0 ? it : 0),
  93581. this._texture && MaterialHelper.BindTextureMatrix(this._texture, e, "clearCoat"),
  93582. this._textureRoughness && !ot && !nt.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE && MaterialHelper.BindTextureMatrix(this._textureRoughness, e, "clearCoatRoughness")),
  93583. this._bumpTexture && o.getCaps().standardDerivatives && MaterialFlags.ClearCoatTextureEnabled && !s && (e.updateFloat2("vClearCoatBumpInfos", this._bumpTexture.coordinatesIndex, this._bumpTexture.level),
  93584. MaterialHelper.BindTextureMatrix(this._bumpTexture, e, "clearCoatBump"),
  93585. i._mirroredCameraPosition ? e.updateFloat2("vClearCoatTangentSpaceParams", d ? 1 : -1, _ ? 1 : -1) : e.updateFloat2("vClearCoatTangentSpaceParams", d ? -1 : 1, _ ? -1 : 1)),
  93586. this._tintTexture && MaterialFlags.ClearCoatTintTextureEnabled && (e.updateFloat2("vClearCoatTintInfos", this._tintTexture.coordinatesIndex, this._tintTexture.level),
  93587. MaterialHelper.BindTextureMatrix(this._tintTexture, e, "clearCoatTint")),
  93588. e.updateFloat2("vClearCoatParams", this.intensity, this.roughness);
  93589. var at = 1 - this._indexOfRefraction
  93590. , st = 1 + this._indexOfRefraction
  93591. , ut = Math.pow(-at / st, 2)
  93592. , ct = 1 / this._indexOfRefraction;
  93593. e.updateFloat4("vClearCoatRefractionParams", ut, ct, at, st),
  93594. this._isTintEnabled && (e.updateFloat4("vClearCoatTintParams", this.tintColor.r, this.tintColor.g, this.tintColor.b, Math.max(1e-5, this.tintThickness)),
  93595. e.updateFloat("clearCoatColorAtDistance", Math.max(1e-5, this.tintColorAtDistance)))
  93596. }
  93597. i.texturesEnabled && (this._texture && MaterialFlags.ClearCoatTextureEnabled && e.setTexture("clearCoatSampler", this._texture),
  93598. this._textureRoughness && !ot && !nt.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE && MaterialFlags.ClearCoatTextureEnabled && e.setTexture("clearCoatRoughnessSampler", this._textureRoughness),
  93599. this._bumpTexture && o.getCaps().standardDerivatives && MaterialFlags.ClearCoatBumpTextureEnabled && !s && e.setTexture("clearCoatBumpSampler", this._bumpTexture),
  93600. this._isTintEnabled && this._tintTexture && MaterialFlags.ClearCoatTintTextureEnabled && e.setTexture("clearCoatTintSampler", this._tintTexture))
  93601. }
  93602. }
  93603. ,
  93604. a.prototype.hasTexture = function(e) {
  93605. return this._texture === e || this._textureRoughness === e || this._bumpTexture === e || this._tintTexture === e
  93606. }
  93607. ,
  93608. a.prototype.getActiveTextures = function(e) {
  93609. this._texture && e.push(this._texture),
  93610. this._textureRoughness && e.push(this._textureRoughness),
  93611. this._bumpTexture && e.push(this._bumpTexture),
  93612. this._tintTexture && e.push(this._tintTexture)
  93613. }
  93614. ,
  93615. a.prototype.getAnimatables = function(e) {
  93616. this._texture && this._texture.animations && this._texture.animations.length > 0 && e.push(this._texture),
  93617. this._textureRoughness && this._textureRoughness.animations && this._textureRoughness.animations.length > 0 && e.push(this._textureRoughness),
  93618. this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0 && e.push(this._bumpTexture),
  93619. this._tintTexture && this._tintTexture.animations && this._tintTexture.animations.length > 0 && e.push(this._tintTexture)
  93620. }
  93621. ,
  93622. a.prototype.dispose = function(e) {
  93623. var i, o, s, c;
  93624. e && ((i = this._texture) === null || i === void 0 || i.dispose(),
  93625. (o = this._textureRoughness) === null || o === void 0 || o.dispose(),
  93626. (s = this._bumpTexture) === null || s === void 0 || s.dispose(),
  93627. (c = this._tintTexture) === null || c === void 0 || c.dispose())
  93628. }
  93629. ,
  93630. a.prototype.getClassName = function() {
  93631. return "PBRClearCoatConfiguration"
  93632. }
  93633. ,
  93634. a.AddFallbacks = function(e, i, o) {
  93635. return e.CLEARCOAT_BUMP && i.addFallback(o++, "CLEARCOAT_BUMP"),
  93636. e.CLEARCOAT_TINT && i.addFallback(o++, "CLEARCOAT_TINT"),
  93637. e.CLEARCOAT && i.addFallback(o++, "CLEARCOAT"),
  93638. o
  93639. }
  93640. ,
  93641. a.AddUniforms = function(e) {
  93642. e.push("vClearCoatTangentSpaceParams", "vClearCoatParams", "vClearCoatRefractionParams", "vClearCoatTintParams", "clearCoatColorAtDistance", "clearCoatMatrix", "clearCoatRoughnessMatrix", "clearCoatBumpMatrix", "clearCoatTintMatrix", "vClearCoatInfos", "vClearCoatBumpInfos", "vClearCoatTintInfos")
  93643. }
  93644. ,
  93645. a.AddSamplers = function(e) {
  93646. e.push("clearCoatSampler", "clearCoatRoughnessSampler", "clearCoatBumpSampler", "clearCoatTintSampler")
  93647. }
  93648. ,
  93649. a.PrepareUniformBuffer = function(e) {
  93650. e.addUniform("vClearCoatParams", 2),
  93651. e.addUniform("vClearCoatRefractionParams", 4),
  93652. e.addUniform("vClearCoatInfos", 4),
  93653. e.addUniform("clearCoatMatrix", 16),
  93654. e.addUniform("clearCoatRoughnessMatrix", 16),
  93655. e.addUniform("vClearCoatBumpInfos", 2),
  93656. e.addUniform("vClearCoatTangentSpaceParams", 2),
  93657. e.addUniform("clearCoatBumpMatrix", 16),
  93658. e.addUniform("vClearCoatTintParams", 4),
  93659. e.addUniform("clearCoatColorAtDistance", 1),
  93660. e.addUniform("vClearCoatTintInfos", 2),
  93661. e.addUniform("clearCoatTintMatrix", 16)
  93662. }
  93663. ,
  93664. a.prototype.copyTo = function(e) {
  93665. SerializationHelper.Clone(function() {
  93666. return e
  93667. }, this)
  93668. }
  93669. ,
  93670. a.prototype.serialize = function() {
  93671. return SerializationHelper.Serialize(this)
  93672. }
  93673. ,
  93674. a.prototype.parse = function(e, i, o) {
  93675. var s = this;
  93676. SerializationHelper.Parse(function() {
  93677. return s
  93678. }, e, i, o)
  93679. }
  93680. ,
  93681. a._DefaultIndexOfRefraction = 1.5,
  93682. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "isEnabled", void 0),
  93683. __decorate([serialize()], a.prototype, "intensity", void 0),
  93684. __decorate([serialize()], a.prototype, "roughness", void 0),
  93685. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "indexOfRefraction", void 0),
  93686. __decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "texture", void 0),
  93687. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "useRoughnessFromMainTexture", void 0),
  93688. __decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "textureRoughness", void 0),
  93689. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "remapF0OnInterfaceChange", void 0),
  93690. __decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "bumpTexture", void 0),
  93691. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "isTintEnabled", void 0),
  93692. __decorate([serializeAsColor3()], a.prototype, "tintColor", void 0),
  93693. __decorate([serialize()], a.prototype, "tintColorAtDistance", void 0),
  93694. __decorate([serialize()], a.prototype, "tintThickness", void 0),
  93695. __decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "tintTexture", void 0),
  93696. a
  93697. }()
  93698. , PBRAnisotropicConfiguration = function() {
  93699. function a(e) {
  93700. this._isEnabled = !1,
  93701. this.isEnabled = !1,
  93702. this.intensity = 1,
  93703. this.direction = new Vector2(1,0),
  93704. this._texture = null,
  93705. this.texture = null,
  93706. this._internalMarkAllSubMeshesAsTexturesDirty = e
  93707. }
  93708. return a.prototype._markAllSubMeshesAsTexturesDirty = function() {
  93709. this._internalMarkAllSubMeshesAsTexturesDirty()
  93710. }
  93711. ,
  93712. a.prototype.isReadyForSubMesh = function(e, i) {
  93713. return this._isEnabled ? !(e._areTexturesDirty && i.texturesEnabled && this._texture && MaterialFlags.AnisotropicTextureEnabled && !this._texture.isReadyOrNotBlocking()) : !0
  93714. }
  93715. ,
  93716. a.prototype.prepareDefines = function(e, i, o) {
  93717. this._isEnabled ? (e.ANISOTROPIC = this._isEnabled,
  93718. this._isEnabled && !i.isVerticesDataPresent(VertexBuffer.TangentKind) && (e._needUVs = !0,
  93719. e.MAINUV1 = !0),
  93720. e._areTexturesDirty && o.texturesEnabled && (this._texture && MaterialFlags.AnisotropicTextureEnabled ? MaterialHelper.PrepareDefinesForMergedUV(this._texture, e, "ANISOTROPIC_TEXTURE") : e.ANISOTROPIC_TEXTURE = !1)) : (e.ANISOTROPIC = !1,
  93721. e.ANISOTROPIC_TEXTURE = !1)
  93722. }
  93723. ,
  93724. a.prototype.bindForSubMesh = function(e, i, o) {
  93725. !this._isEnabled || ((!e.useUbo || !o || !e.isSync) && (this._texture && MaterialFlags.AnisotropicTextureEnabled && (e.updateFloat2("vAnisotropyInfos", this._texture.coordinatesIndex, this._texture.level),
  93726. MaterialHelper.BindTextureMatrix(this._texture, e, "anisotropy")),
  93727. e.updateFloat3("vAnisotropy", this.direction.x, this.direction.y, this.intensity)),
  93728. i.texturesEnabled && this._texture && MaterialFlags.AnisotropicTextureEnabled && e.setTexture("anisotropySampler", this._texture))
  93729. }
  93730. ,
  93731. a.prototype.hasTexture = function(e) {
  93732. return this._texture === e
  93733. }
  93734. ,
  93735. a.prototype.getActiveTextures = function(e) {
  93736. this._texture && e.push(this._texture)
  93737. }
  93738. ,
  93739. a.prototype.getAnimatables = function(e) {
  93740. this._texture && this._texture.animations && this._texture.animations.length > 0 && e.push(this._texture)
  93741. }
  93742. ,
  93743. a.prototype.dispose = function(e) {
  93744. e && this._texture && this._texture.dispose()
  93745. }
  93746. ,
  93747. a.prototype.getClassName = function() {
  93748. return "PBRAnisotropicConfiguration"
  93749. }
  93750. ,
  93751. a.AddFallbacks = function(e, i, o) {
  93752. return e.ANISOTROPIC && i.addFallback(o++, "ANISOTROPIC"),
  93753. o
  93754. }
  93755. ,
  93756. a.AddUniforms = function(e) {
  93757. e.push("vAnisotropy", "vAnisotropyInfos", "anisotropyMatrix")
  93758. }
  93759. ,
  93760. a.PrepareUniformBuffer = function(e) {
  93761. e.addUniform("vAnisotropy", 3),
  93762. e.addUniform("vAnisotropyInfos", 2),
  93763. e.addUniform("anisotropyMatrix", 16)
  93764. }
  93765. ,
  93766. a.AddSamplers = function(e) {
  93767. e.push("anisotropySampler")
  93768. }
  93769. ,
  93770. a.prototype.copyTo = function(e) {
  93771. SerializationHelper.Clone(function() {
  93772. return e
  93773. }, this)
  93774. }
  93775. ,
  93776. a.prototype.serialize = function() {
  93777. return SerializationHelper.Serialize(this)
  93778. }
  93779. ,
  93780. a.prototype.parse = function(e, i, o) {
  93781. var s = this;
  93782. SerializationHelper.Parse(function() {
  93783. return s
  93784. }, e, i, o)
  93785. }
  93786. ,
  93787. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "isEnabled", void 0),
  93788. __decorate([serialize()], a.prototype, "intensity", void 0),
  93789. __decorate([serializeAsVector2()], a.prototype, "direction", void 0),
  93790. __decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "texture", void 0),
  93791. a
  93792. }()
  93793. , PBRBRDFConfiguration = function() {
  93794. function a(e) {
  93795. this._useEnergyConservation = a.DEFAULT_USE_ENERGY_CONSERVATION,
  93796. this.useEnergyConservation = a.DEFAULT_USE_ENERGY_CONSERVATION,
  93797. this._useSmithVisibilityHeightCorrelated = a.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED,
  93798. this.useSmithVisibilityHeightCorrelated = a.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED,
  93799. this._useSphericalHarmonics = a.DEFAULT_USE_SPHERICAL_HARMONICS,
  93800. this.useSphericalHarmonics = a.DEFAULT_USE_SPHERICAL_HARMONICS,
  93801. this._useSpecularGlossinessInputEnergyConservation = a.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION,
  93802. this.useSpecularGlossinessInputEnergyConservation = a.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION,
  93803. this._internalMarkAllSubMeshesAsMiscDirty = e
  93804. }
  93805. return a.prototype._markAllSubMeshesAsMiscDirty = function() {
  93806. this._internalMarkAllSubMeshesAsMiscDirty()
  93807. }
  93808. ,
  93809. a.prototype.prepareDefines = function(e) {
  93810. e.BRDF_V_HEIGHT_CORRELATED = this._useSmithVisibilityHeightCorrelated,
  93811. e.MS_BRDF_ENERGY_CONSERVATION = this._useEnergyConservation && this._useSmithVisibilityHeightCorrelated,
  93812. e.SPHERICAL_HARMONICS = this._useSphericalHarmonics,
  93813. e.SPECULAR_GLOSSINESS_ENERGY_CONSERVATION = this._useSpecularGlossinessInputEnergyConservation
  93814. }
  93815. ,
  93816. a.prototype.getClassName = function() {
  93817. return "PBRBRDFConfiguration"
  93818. }
  93819. ,
  93820. a.prototype.copyTo = function(e) {
  93821. SerializationHelper.Clone(function() {
  93822. return e
  93823. }, this)
  93824. }
  93825. ,
  93826. a.prototype.serialize = function() {
  93827. return SerializationHelper.Serialize(this)
  93828. }
  93829. ,
  93830. a.prototype.parse = function(e, i, o) {
  93831. var s = this;
  93832. SerializationHelper.Parse(function() {
  93833. return s
  93834. }, e, i, o)
  93835. }
  93836. ,
  93837. a.DEFAULT_USE_ENERGY_CONSERVATION = !0,
  93838. a.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED = !0,
  93839. a.DEFAULT_USE_SPHERICAL_HARMONICS = !0,
  93840. a.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION = !0,
  93841. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsMiscDirty")], a.prototype, "useEnergyConservation", void 0),
  93842. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsMiscDirty")], a.prototype, "useSmithVisibilityHeightCorrelated", void 0),
  93843. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsMiscDirty")], a.prototype, "useSphericalHarmonics", void 0),
  93844. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsMiscDirty")], a.prototype, "useSpecularGlossinessInputEnergyConservation", void 0),
  93845. a
  93846. }()
  93847. , PBRSheenConfiguration = function() {
  93848. function a(e) {
  93849. this._isEnabled = !1,
  93850. this.isEnabled = !1,
  93851. this._linkSheenWithAlbedo = !1,
  93852. this.linkSheenWithAlbedo = !1,
  93853. this.intensity = 1,
  93854. this.color = Color3.White(),
  93855. this._texture = null,
  93856. this.texture = null,
  93857. this._useRoughnessFromMainTexture = !0,
  93858. this.useRoughnessFromMainTexture = !0,
  93859. this._roughness = null,
  93860. this.roughness = null,
  93861. this._textureRoughness = null,
  93862. this.textureRoughness = null,
  93863. this._albedoScaling = !1,
  93864. this.albedoScaling = !1,
  93865. this._internalMarkAllSubMeshesAsTexturesDirty = e
  93866. }
  93867. return a.prototype._markAllSubMeshesAsTexturesDirty = function() {
  93868. this._internalMarkAllSubMeshesAsTexturesDirty()
  93869. }
  93870. ,
  93871. a.prototype.isReadyForSubMesh = function(e, i) {
  93872. return this._isEnabled ? !(e._areTexturesDirty && i.texturesEnabled && (this._texture && MaterialFlags.SheenTextureEnabled && !this._texture.isReadyOrNotBlocking() || this._textureRoughness && MaterialFlags.SheenTextureEnabled && !this._textureRoughness.isReadyOrNotBlocking())) : !0
  93873. }
  93874. ,
  93875. a.prototype.prepareDefines = function(e, i) {
  93876. var o;
  93877. this._isEnabled ? (e.SHEEN = this._isEnabled,
  93878. e.SHEEN_LINKWITHALBEDO = this._linkSheenWithAlbedo,
  93879. e.SHEEN_ROUGHNESS = this._roughness !== null,
  93880. e.SHEEN_ALBEDOSCALING = this._albedoScaling,
  93881. e.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE = this._useRoughnessFromMainTexture,
  93882. e.SHEEN_TEXTURE_ROUGHNESS_IDENTICAL = this._texture !== null && this._texture._texture === ((o = this._textureRoughness) === null || o === void 0 ? void 0 : o._texture) && this._texture.checkTransformsAreIdentical(this._textureRoughness),
  93883. e._areTexturesDirty && i.texturesEnabled && (this._texture && MaterialFlags.SheenTextureEnabled ? (MaterialHelper.PrepareDefinesForMergedUV(this._texture, e, "SHEEN_TEXTURE"),
  93884. e.SHEEN_GAMMATEXTURE = this._texture.gammaSpace) : e.SHEEN_TEXTURE = !1,
  93885. this._textureRoughness && MaterialFlags.SheenTextureEnabled ? MaterialHelper.PrepareDefinesForMergedUV(this._textureRoughness, e, "SHEEN_TEXTURE_ROUGHNESS") : e.SHEEN_TEXTURE_ROUGHNESS = !1)) : (e.SHEEN = !1,
  93886. e.SHEEN_TEXTURE = !1,
  93887. e.SHEEN_TEXTURE_ROUGHNESS = !1,
  93888. e.SHEEN_LINKWITHALBEDO = !1,
  93889. e.SHEEN_ROUGHNESS = !1,
  93890. e.SHEEN_ALBEDOSCALING = !1,
  93891. e.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE = !1,
  93892. e.SHEEN_TEXTURE_ROUGHNESS_IDENTICAL = !1)
  93893. }
  93894. ,
  93895. a.prototype.bindForSubMesh = function(e, i, o, s) {
  93896. var c, d, _, b, k, j, $, _e;
  93897. if (!!this._isEnabled) {
  93898. var et = s.materialDefines
  93899. , tt = et.SHEEN_TEXTURE_ROUGHNESS_IDENTICAL;
  93900. (!e.useUbo || !o || !e.isSync) && (tt && MaterialFlags.SheenTextureEnabled ? (e.updateFloat4("vSheenInfos", this._texture.coordinatesIndex, this._texture.level, -1, -1),
  93901. MaterialHelper.BindTextureMatrix(this._texture, e, "sheen")) : (this._texture || this._textureRoughness) && MaterialFlags.SheenTextureEnabled && (e.updateFloat4("vSheenInfos", (d = (c = this._texture) === null || c === void 0 ? void 0 : c.coordinatesIndex) !== null && d !== void 0 ? d : 0, (b = (_ = this._texture) === null || _ === void 0 ? void 0 : _.level) !== null && b !== void 0 ? b : 0, (j = (k = this._textureRoughness) === null || k === void 0 ? void 0 : k.coordinatesIndex) !== null && j !== void 0 ? j : 0, (_e = ($ = this._textureRoughness) === null || $ === void 0 ? void 0 : $.level) !== null && _e !== void 0 ? _e : 0),
  93902. this._texture && MaterialHelper.BindTextureMatrix(this._texture, e, "sheen"),
  93903. this._textureRoughness && !tt && !et.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE && MaterialHelper.BindTextureMatrix(this._textureRoughness, e, "sheenRoughness")),
  93904. e.updateFloat4("vSheenColor", this.color.r, this.color.g, this.color.b, this.intensity),
  93905. this._roughness !== null && e.updateFloat("vSheenRoughness", this._roughness)),
  93906. i.texturesEnabled && (this._texture && MaterialFlags.SheenTextureEnabled && e.setTexture("sheenSampler", this._texture),
  93907. this._textureRoughness && !tt && !et.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE && MaterialFlags.SheenTextureEnabled && e.setTexture("sheenRoughnessSampler", this._textureRoughness))
  93908. }
  93909. }
  93910. ,
  93911. a.prototype.hasTexture = function(e) {
  93912. return this._texture === e || this._textureRoughness === e
  93913. }
  93914. ,
  93915. a.prototype.getActiveTextures = function(e) {
  93916. this._texture && e.push(this._texture),
  93917. this._textureRoughness && e.push(this._textureRoughness)
  93918. }
  93919. ,
  93920. a.prototype.getAnimatables = function(e) {
  93921. this._texture && this._texture.animations && this._texture.animations.length > 0 && e.push(this._texture),
  93922. this._textureRoughness && this._textureRoughness.animations && this._textureRoughness.animations.length > 0 && e.push(this._textureRoughness)
  93923. }
  93924. ,
  93925. a.prototype.dispose = function(e) {
  93926. var i, o;
  93927. e && ((i = this._texture) === null || i === void 0 || i.dispose(),
  93928. (o = this._textureRoughness) === null || o === void 0 || o.dispose())
  93929. }
  93930. ,
  93931. a.prototype.getClassName = function() {
  93932. return "PBRSheenConfiguration"
  93933. }
  93934. ,
  93935. a.AddFallbacks = function(e, i, o) {
  93936. return e.SHEEN && i.addFallback(o++, "SHEEN"),
  93937. o
  93938. }
  93939. ,
  93940. a.AddUniforms = function(e) {
  93941. e.push("vSheenColor", "vSheenRoughness", "vSheenInfos", "sheenMatrix", "sheenRoughnessMatrix")
  93942. }
  93943. ,
  93944. a.PrepareUniformBuffer = function(e) {
  93945. e.addUniform("vSheenColor", 4),
  93946. e.addUniform("vSheenRoughness", 1),
  93947. e.addUniform("vSheenInfos", 4),
  93948. e.addUniform("sheenMatrix", 16),
  93949. e.addUniform("sheenRoughnessMatrix", 16)
  93950. }
  93951. ,
  93952. a.AddSamplers = function(e) {
  93953. e.push("sheenSampler"),
  93954. e.push("sheenRoughnessSampler")
  93955. }
  93956. ,
  93957. a.prototype.copyTo = function(e) {
  93958. SerializationHelper.Clone(function() {
  93959. return e
  93960. }, this)
  93961. }
  93962. ,
  93963. a.prototype.serialize = function() {
  93964. return SerializationHelper.Serialize(this)
  93965. }
  93966. ,
  93967. a.prototype.parse = function(e, i, o) {
  93968. var s = this;
  93969. SerializationHelper.Parse(function() {
  93970. return s
  93971. }, e, i, o)
  93972. }
  93973. ,
  93974. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "isEnabled", void 0),
  93975. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "linkSheenWithAlbedo", void 0),
  93976. __decorate([serialize()], a.prototype, "intensity", void 0),
  93977. __decorate([serializeAsColor3()], a.prototype, "color", void 0),
  93978. __decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "texture", void 0),
  93979. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "useRoughnessFromMainTexture", void 0),
  93980. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "roughness", void 0),
  93981. __decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "textureRoughness", void 0),
  93982. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "albedoScaling", void 0),
  93983. a
  93984. }()
  93985. , PBRSubSurfaceConfiguration = function() {
  93986. function a(e, i, o) {
  93987. this._isRefractionEnabled = !1,
  93988. this.isRefractionEnabled = !1,
  93989. this._isTranslucencyEnabled = !1,
  93990. this.isTranslucencyEnabled = !1,
  93991. this._isScatteringEnabled = !1,
  93992. this.isScatteringEnabled = !1,
  93993. this._scatteringDiffusionProfileIndex = 0,
  93994. this.refractionIntensity = 1,
  93995. this.translucencyIntensity = 1,
  93996. this.useAlbedoToTintRefraction = !1,
  93997. this.useAlbedoToTintTranslucency = !1,
  93998. this._thicknessTexture = null,
  93999. this.thicknessTexture = null,
  94000. this._refractionTexture = null,
  94001. this.refractionTexture = null,
  94002. this._indexOfRefraction = 1.5,
  94003. this.indexOfRefraction = 1.5,
  94004. this._volumeIndexOfRefraction = -1,
  94005. this._invertRefractionY = !1,
  94006. this.invertRefractionY = !1,
  94007. this._linkRefractionWithTransparency = !1,
  94008. this.linkRefractionWithTransparency = !1,
  94009. this.minimumThickness = 0,
  94010. this.maximumThickness = 1,
  94011. this.useThicknessAsDepth = !1,
  94012. this.tintColor = Color3.White(),
  94013. this.tintColorAtDistance = 1,
  94014. this.diffusionDistance = Color3.White(),
  94015. this._useMaskFromThicknessTexture = !1,
  94016. this.useMaskFromThicknessTexture = !1,
  94017. this._refractionIntensityTexture = null,
  94018. this.refractionIntensityTexture = null,
  94019. this._translucencyIntensityTexture = null,
  94020. this.translucencyIntensityTexture = null,
  94021. this._useGltfStyleTextures = !1,
  94022. this.useGltfStyleTextures = !1,
  94023. this._internalMarkAllSubMeshesAsTexturesDirty = e,
  94024. this._internalMarkScenePrePassDirty = i,
  94025. this._scene = o
  94026. }
  94027. return Object.defineProperty(a.prototype, "scatteringDiffusionProfile", {
  94028. get: function() {
  94029. return this._scene.subSurfaceConfiguration ? this._scene.subSurfaceConfiguration.ssDiffusionProfileColors[this._scatteringDiffusionProfileIndex] : null
  94030. },
  94031. set: function(e) {
  94032. !this._scene.enableSubSurfaceForPrePass() || e && (this._scatteringDiffusionProfileIndex = this._scene.subSurfaceConfiguration.addDiffusionProfile(e))
  94033. },
  94034. enumerable: !1,
  94035. configurable: !0
  94036. }),
  94037. Object.defineProperty(a.prototype, "volumeIndexOfRefraction", {
  94038. get: function() {
  94039. return this._volumeIndexOfRefraction >= 1 ? this._volumeIndexOfRefraction : this._indexOfRefraction
  94040. },
  94041. set: function(e) {
  94042. e >= 1 ? this._volumeIndexOfRefraction = e : this._volumeIndexOfRefraction = -1
  94043. },
  94044. enumerable: !1,
  94045. configurable: !0
  94046. }),
  94047. a.prototype._markAllSubMeshesAsTexturesDirty = function() {
  94048. this._internalMarkAllSubMeshesAsTexturesDirty()
  94049. }
  94050. ,
  94051. a.prototype._markScenePrePassDirty = function() {
  94052. this._internalMarkAllSubMeshesAsTexturesDirty(),
  94053. this._internalMarkScenePrePassDirty()
  94054. }
  94055. ,
  94056. a.prototype.isReadyForSubMesh = function(e, i) {
  94057. if (!this._isRefractionEnabled && !this._isTranslucencyEnabled && !this._isScatteringEnabled)
  94058. return !0;
  94059. if (e._areTexturesDirty && i.texturesEnabled) {
  94060. if (this._thicknessTexture && MaterialFlags.ThicknessTextureEnabled && !this._thicknessTexture.isReadyOrNotBlocking())
  94061. return !1;
  94062. var o = this._getRefractionTexture(i);
  94063. if (o && MaterialFlags.RefractionTextureEnabled && !o.isReadyOrNotBlocking())
  94064. return !1
  94065. }
  94066. return !0
  94067. }
  94068. ,
  94069. a.prototype.prepareDefines = function(e, i) {
  94070. if (!this._isRefractionEnabled && !this._isTranslucencyEnabled && !this._isScatteringEnabled) {
  94071. e.SUBSURFACE = !1,
  94072. e.SS_TRANSLUCENCY = !1,
  94073. e.SS_SCATTERING = !1,
  94074. e.SS_REFRACTION = !1;
  94075. return
  94076. }
  94077. if (e._areTexturesDirty) {
  94078. if (e.SUBSURFACE = !1,
  94079. e.SS_TRANSLUCENCY = this._isTranslucencyEnabled,
  94080. e.SS_TRANSLUCENCY_USE_INTENSITY_FROM_TEXTURE = !1,
  94081. e.SS_SCATTERING = this._isScatteringEnabled,
  94082. e.SS_THICKNESSANDMASK_TEXTURE = !1,
  94083. e.SS_REFRACTIONINTENSITY_TEXTURE = !1,
  94084. e.SS_TRANSLUCENCYINTENSITY_TEXTURE = !1,
  94085. e.SS_HAS_THICKNESS = !1,
  94086. e.SS_MASK_FROM_THICKNESS_TEXTURE = !1,
  94087. e.SS_USE_GLTF_TEXTURES = !1,
  94088. e.SS_REFRACTION = !1,
  94089. e.SS_REFRACTION_USE_INTENSITY_FROM_TEXTURE = !1,
  94090. e.SS_REFRACTIONMAP_3D = !1,
  94091. e.SS_GAMMAREFRACTION = !1,
  94092. e.SS_RGBDREFRACTION = !1,
  94093. e.SS_LINEARSPECULARREFRACTION = !1,
  94094. e.SS_REFRACTIONMAP_OPPOSITEZ = !1,
  94095. e.SS_LODINREFRACTIONALPHA = !1,
  94096. e.SS_LINKREFRACTIONTOTRANSPARENCY = !1,
  94097. e.SS_ALBEDOFORREFRACTIONTINT = !1,
  94098. e.SS_ALBEDOFORTRANSLUCENCYTINT = !1,
  94099. e.SS_USE_LOCAL_REFRACTIONMAP_CUBIC = !1,
  94100. e.SS_USE_THICKNESS_AS_DEPTH = !1,
  94101. this._isRefractionEnabled || this._isTranslucencyEnabled || this._isScatteringEnabled) {
  94102. e.SUBSURFACE = !0;
  94103. var o = !!this._thicknessTexture && !!this._refractionIntensityTexture && this._refractionIntensityTexture.checkTransformsAreIdentical(this._thicknessTexture) && this._refractionIntensityTexture._texture === this._thicknessTexture._texture
  94104. , s = !!this._thicknessTexture && !!this._translucencyIntensityTexture && this._translucencyIntensityTexture.checkTransformsAreIdentical(this._thicknessTexture) && this._translucencyIntensityTexture._texture === this._thicknessTexture._texture
  94105. , c = (o || !this._refractionIntensityTexture) && (s || !this._translucencyIntensityTexture);
  94106. e._areTexturesDirty && i.texturesEnabled && (this._thicknessTexture && MaterialFlags.ThicknessTextureEnabled && MaterialHelper.PrepareDefinesForMergedUV(this._thicknessTexture, e, "SS_THICKNESSANDMASK_TEXTURE"),
  94107. this._refractionIntensityTexture && MaterialFlags.RefractionIntensityTextureEnabled && !c && MaterialHelper.PrepareDefinesForMergedUV(this._refractionIntensityTexture, e, "SS_REFRACTIONINTENSITY_TEXTURE"),
  94108. this._translucencyIntensityTexture && MaterialFlags.TranslucencyIntensityTextureEnabled && !c && MaterialHelper.PrepareDefinesForMergedUV(this._translucencyIntensityTexture, e, "SS_TRANSLUCENCYINTENSITY_TEXTURE")),
  94109. e.SS_HAS_THICKNESS = this.maximumThickness - this.minimumThickness !== 0,
  94110. e.SS_MASK_FROM_THICKNESS_TEXTURE = (this._useMaskFromThicknessTexture || !!this._refractionIntensityTexture || !!this._translucencyIntensityTexture) && c,
  94111. e.SS_USE_GLTF_TEXTURES = this._useGltfStyleTextures,
  94112. e.SS_REFRACTION_USE_INTENSITY_FROM_TEXTURE = (this._useMaskFromThicknessTexture || !!this._refractionIntensityTexture) && c,
  94113. e.SS_TRANSLUCENCY_USE_INTENSITY_FROM_TEXTURE = (this._useMaskFromThicknessTexture || !!this._translucencyIntensityTexture) && c
  94114. }
  94115. if (this._isRefractionEnabled && i.texturesEnabled) {
  94116. var d = this._getRefractionTexture(i);
  94117. d && MaterialFlags.RefractionTextureEnabled && (e.SS_REFRACTION = !0,
  94118. e.SS_REFRACTIONMAP_3D = d.isCube,
  94119. e.SS_GAMMAREFRACTION = d.gammaSpace,
  94120. e.SS_RGBDREFRACTION = d.isRGBD,
  94121. e.SS_LINEARSPECULARREFRACTION = d.linearSpecularLOD,
  94122. e.SS_REFRACTIONMAP_OPPOSITEZ = d.invertZ,
  94123. e.SS_LODINREFRACTIONALPHA = d.lodLevelInAlpha,
  94124. e.SS_LINKREFRACTIONTOTRANSPARENCY = this._linkRefractionWithTransparency,
  94125. e.SS_ALBEDOFORREFRACTIONTINT = this.useAlbedoToTintRefraction,
  94126. e.SS_USE_LOCAL_REFRACTIONMAP_CUBIC = d.isCube && d.boundingBoxSize,
  94127. e.SS_USE_THICKNESS_AS_DEPTH = this.useThicknessAsDepth)
  94128. }
  94129. this._isTranslucencyEnabled && (e.SS_ALBEDOFORTRANSLUCENCYTINT = this.useAlbedoToTintTranslucency)
  94130. }
  94131. }
  94132. ,
  94133. a.prototype.hardBindForSubMesh = function(e, i, o, s, c, d, _) {
  94134. if (!(!this._isRefractionEnabled && !this._isTranslucencyEnabled && !this._isScatteringEnabled)) {
  94135. _.getRenderingMesh().getWorldMatrix().decompose(TmpVectors.Vector3[0]);
  94136. var b = Math.max(Math.abs(TmpVectors.Vector3[0].x), Math.abs(TmpVectors.Vector3[0].y), Math.abs(TmpVectors.Vector3[0].z));
  94137. e.updateFloat2("vThicknessParam", this.minimumThickness * b, (this.maximumThickness - this.minimumThickness) * b)
  94138. }
  94139. }
  94140. ,
  94141. a.prototype.bindForSubMesh = function(e, i, o, s, c, d, _) {
  94142. if (!(!this._isRefractionEnabled && !this._isTranslucencyEnabled && !this._isScatteringEnabled)) {
  94143. var b = _.materialDefines
  94144. , k = this._getRefractionTexture(i);
  94145. if (!e.useUbo || !s || !e.isSync) {
  94146. if (this._thicknessTexture && MaterialFlags.ThicknessTextureEnabled && (e.updateFloat2("vThicknessInfos", this._thicknessTexture.coordinatesIndex, this._thicknessTexture.level),
  94147. MaterialHelper.BindTextureMatrix(this._thicknessTexture, e, "thickness")),
  94148. this._refractionIntensityTexture && MaterialFlags.RefractionIntensityTextureEnabled && b.SS_REFRACTIONINTENSITY_TEXTURE && (e.updateFloat2("vRefractionIntensityInfos", this._refractionIntensityTexture.coordinatesIndex, this._refractionIntensityTexture.level),
  94149. MaterialHelper.BindTextureMatrix(this._refractionIntensityTexture, e, "refractionIntensity")),
  94150. this._translucencyIntensityTexture && MaterialFlags.TranslucencyIntensityTextureEnabled && b.SS_TRANSLUCENCYINTENSITY_TEXTURE && (e.updateFloat2("vTranslucencyIntensityInfos", this._translucencyIntensityTexture.coordinatesIndex, this._translucencyIntensityTexture.level),
  94151. MaterialHelper.BindTextureMatrix(this._translucencyIntensityTexture, e, "translucencyIntensity")),
  94152. k && MaterialFlags.RefractionTextureEnabled) {
  94153. e.updateMatrix("refractionMatrix", k.getReflectionTextureMatrix());
  94154. var j = 1;
  94155. k.isCube || k.depth && (j = k.depth);
  94156. var $ = k.getSize().width
  94157. , _e = this.volumeIndexOfRefraction;
  94158. if (e.updateFloat4("vRefractionInfos", k.level, 1 / _e, j, this._invertRefractionY ? -1 : 1),
  94159. e.updateFloat4("vRefractionMicrosurfaceInfos", $, k.lodGenerationScale, k.lodGenerationOffset, 1 / this.indexOfRefraction),
  94160. d && e.updateFloat2("vRefractionFilteringInfo", $, Scalar.Log2($)),
  94161. k.boundingBoxSize) {
  94162. var et = k;
  94163. e.updateVector3("vRefractionPosition", et.boundingBoxPosition),
  94164. e.updateVector3("vRefractionSize", et.boundingBoxSize)
  94165. }
  94166. }
  94167. this.isScatteringEnabled && e.updateFloat("scatteringDiffusionProfile", this._scatteringDiffusionProfileIndex),
  94168. e.updateColor3("vDiffusionDistance", this.diffusionDistance),
  94169. e.updateFloat4("vTintColor", this.tintColor.r, this.tintColor.g, this.tintColor.b, Math.max(1e-5, this.tintColorAtDistance)),
  94170. e.updateFloat3("vSubSurfaceIntensity", this.refractionIntensity, this.translucencyIntensity, 0)
  94171. }
  94172. i.texturesEnabled && (this._thicknessTexture && MaterialFlags.ThicknessTextureEnabled && e.setTexture("thicknessSampler", this._thicknessTexture),
  94173. this._refractionIntensityTexture && MaterialFlags.RefractionIntensityTextureEnabled && b.SS_REFRACTIONINTENSITY_TEXTURE && e.setTexture("refractionIntensitySampler", this._refractionIntensityTexture),
  94174. this._translucencyIntensityTexture && MaterialFlags.TranslucencyIntensityTextureEnabled && b.SS_TRANSLUCENCYINTENSITY_TEXTURE && e.setTexture("translucencyIntensitySampler", this._translucencyIntensityTexture),
  94175. k && MaterialFlags.RefractionTextureEnabled && (c ? e.setTexture("refractionSampler", k) : (e.setTexture("refractionSampler", k._lodTextureMid || k),
  94176. e.setTexture("refractionSamplerLow", k._lodTextureLow || k),
  94177. e.setTexture("refractionSamplerHigh", k._lodTextureHigh || k))))
  94178. }
  94179. }
  94180. ,
  94181. a.prototype.unbind = function(e) {
  94182. return this._refractionTexture && this._refractionTexture.isRenderTarget ? (e.setTexture("refractionSampler", null),
  94183. !0) : !1
  94184. }
  94185. ,
  94186. a.prototype._getRefractionTexture = function(e) {
  94187. return this._refractionTexture ? this._refractionTexture : this._isRefractionEnabled ? e.environmentTexture : null
  94188. }
  94189. ,
  94190. Object.defineProperty(a.prototype, "disableAlphaBlending", {
  94191. get: function() {
  94192. return this.isRefractionEnabled && this._linkRefractionWithTransparency
  94193. },
  94194. enumerable: !1,
  94195. configurable: !0
  94196. }),
  94197. a.prototype.fillRenderTargetTextures = function(e) {
  94198. MaterialFlags.RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget && e.push(this._refractionTexture)
  94199. }
  94200. ,
  94201. a.prototype.hasTexture = function(e) {
  94202. return this._thicknessTexture === e || this._refractionTexture === e
  94203. }
  94204. ,
  94205. a.prototype.hasRenderTargetTextures = function() {
  94206. return !!(MaterialFlags.RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget)
  94207. }
  94208. ,
  94209. a.prototype.getActiveTextures = function(e) {
  94210. this._thicknessTexture && e.push(this._thicknessTexture),
  94211. this._refractionTexture && e.push(this._refractionTexture)
  94212. }
  94213. ,
  94214. a.prototype.getAnimatables = function(e) {
  94215. this._thicknessTexture && this._thicknessTexture.animations && this._thicknessTexture.animations.length > 0 && e.push(this._thicknessTexture),
  94216. this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0 && e.push(this._refractionTexture)
  94217. }
  94218. ,
  94219. a.prototype.dispose = function(e) {
  94220. e && (this._thicknessTexture && this._thicknessTexture.dispose(),
  94221. this._refractionTexture && this._refractionTexture.dispose())
  94222. }
  94223. ,
  94224. a.prototype.getClassName = function() {
  94225. return "PBRSubSurfaceConfiguration"
  94226. }
  94227. ,
  94228. a.AddFallbacks = function(e, i, o) {
  94229. return e.SS_SCATTERING && i.addFallback(o++, "SS_SCATTERING"),
  94230. e.SS_TRANSLUCENCY && i.addFallback(o++, "SS_TRANSLUCENCY"),
  94231. o
  94232. }
  94233. ,
  94234. a.AddUniforms = function(e) {
  94235. e.push("vDiffusionDistance", "vTintColor", "vSubSurfaceIntensity", "vRefractionMicrosurfaceInfos", "vRefractionFilteringInfo", "vRefractionInfos", "vThicknessInfos", "vRefractionIntensityInfos", "vTranslucencyIntensityInfos", "vThicknessParam", "vRefractionPosition", "vRefractionSize", "refractionMatrix", "thicknessMatrix", "refractionIntensityMatrix", "translucencyIntensityMatrix", "scatteringDiffusionProfile")
  94236. }
  94237. ,
  94238. a.AddSamplers = function(e) {
  94239. e.push("thicknessSampler", "refractionIntensitySampler", "translucencyIntensitySampler", "refractionSampler", "refractionSamplerLow", "refractionSamplerHigh")
  94240. }
  94241. ,
  94242. a.PrepareUniformBuffer = function(e) {
  94243. e.addUniform("vRefractionMicrosurfaceInfos", 4),
  94244. e.addUniform("vRefractionFilteringInfo", 2),
  94245. e.addUniform("vTranslucencyIntensityInfos", 2),
  94246. e.addUniform("vRefractionInfos", 4),
  94247. e.addUniform("refractionMatrix", 16),
  94248. e.addUniform("vThicknessInfos", 2),
  94249. e.addUniform("vRefractionIntensityInfos", 2),
  94250. e.addUniform("thicknessMatrix", 16),
  94251. e.addUniform("refractionIntensityMatrix", 16),
  94252. e.addUniform("translucencyIntensityMatrix", 16),
  94253. e.addUniform("vThicknessParam", 2),
  94254. e.addUniform("vDiffusionDistance", 3),
  94255. e.addUniform("vTintColor", 4),
  94256. e.addUniform("vSubSurfaceIntensity", 3),
  94257. e.addUniform("vRefractionPosition", 3),
  94258. e.addUniform("vRefractionSize", 3),
  94259. e.addUniform("scatteringDiffusionProfile", 1)
  94260. }
  94261. ,
  94262. a.prototype.copyTo = function(e) {
  94263. SerializationHelper.Clone(function() {
  94264. return e
  94265. }, this)
  94266. }
  94267. ,
  94268. a.prototype.serialize = function() {
  94269. return SerializationHelper.Serialize(this)
  94270. }
  94271. ,
  94272. a.prototype.parse = function(e, i, o) {
  94273. var s = this;
  94274. SerializationHelper.Parse(function() {
  94275. return s
  94276. }, e, i, o)
  94277. }
  94278. ,
  94279. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "isRefractionEnabled", void 0),
  94280. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "isTranslucencyEnabled", void 0),
  94281. __decorate([serialize(), expandToProperty("_markScenePrePassDirty")], a.prototype, "isScatteringEnabled", void 0),
  94282. __decorate([serialize()], a.prototype, "_scatteringDiffusionProfileIndex", void 0),
  94283. __decorate([serialize()], a.prototype, "refractionIntensity", void 0),
  94284. __decorate([serialize()], a.prototype, "translucencyIntensity", void 0),
  94285. __decorate([serialize()], a.prototype, "useAlbedoToTintRefraction", void 0),
  94286. __decorate([serialize()], a.prototype, "useAlbedoToTintTranslucency", void 0),
  94287. __decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "thicknessTexture", void 0),
  94288. __decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "refractionTexture", void 0),
  94289. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "indexOfRefraction", void 0),
  94290. __decorate([serialize()], a.prototype, "_volumeIndexOfRefraction", void 0),
  94291. __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "volumeIndexOfRefraction", null),
  94292. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "invertRefractionY", void 0),
  94293. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "linkRefractionWithTransparency", void 0),
  94294. __decorate([serialize()], a.prototype, "minimumThickness", void 0),
  94295. __decorate([serialize()], a.prototype, "maximumThickness", void 0),
  94296. __decorate([serialize()], a.prototype, "useThicknessAsDepth", void 0),
  94297. __decorate([serializeAsColor3()], a.prototype, "tintColor", void 0),
  94298. __decorate([serialize()], a.prototype, "tintColorAtDistance", void 0),
  94299. __decorate([serializeAsColor3()], a.prototype, "diffusionDistance", void 0),
  94300. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "useMaskFromThicknessTexture", void 0),
  94301. __decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "refractionIntensityTexture", void 0),
  94302. __decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "translucencyIntensityTexture", void 0),
  94303. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "useGltfStyleTextures", void 0),
  94304. a
  94305. }()
  94306. , name$1e = "pbrFragmentDeclaration"
  94307. , shader$1e = `uniform vec4 vEyePosition;
  94308. uniform vec3 vReflectionColor;
  94309. uniform vec4 vAlbedoColor;
  94310. uniform vec4 vLightingIntensity;
  94311. uniform vec4 vReflectivityColor;
  94312. uniform vec4 vMetallicReflectanceFactors;
  94313. uniform vec3 vEmissiveColor;
  94314. uniform float visibility;
  94315. uniform vec3 vAmbientColor;
  94316. #ifdef ALBEDO
  94317. uniform vec2 vAlbedoInfos;
  94318. #endif
  94319. #ifdef AMBIENT
  94320. uniform vec4 vAmbientInfos;
  94321. #endif
  94322. #ifdef BUMP
  94323. uniform vec3 vBumpInfos;
  94324. uniform vec2 vTangentSpaceParams;
  94325. #endif
  94326. #ifdef OPACITY
  94327. uniform vec2 vOpacityInfos;
  94328. #endif
  94329. #ifdef EMISSIVE
  94330. uniform vec2 vEmissiveInfos;
  94331. #endif
  94332. #ifdef LIGHTMAP
  94333. uniform vec2 vLightmapInfos;
  94334. #endif
  94335. #ifdef REFLECTIVITY
  94336. uniform vec3 vReflectivityInfos;
  94337. #endif
  94338. #ifdef MICROSURFACEMAP
  94339. uniform vec2 vMicroSurfaceSamplerInfos;
  94340. #endif
  94341. #if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(SS_REFRACTION) || defined(PREPASS)
  94342. uniform mat4 view;
  94343. #endif
  94344. #ifdef REFLECTION
  94345. uniform vec2 vReflectionInfos;
  94346. #ifdef REALTIME_FILTERING
  94347. uniform vec2 vReflectionFilteringInfo;
  94348. #endif
  94349. uniform mat4 reflectionMatrix;
  94350. uniform vec3 vReflectionMicrosurfaceInfos;
  94351. #if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)
  94352. uniform vec3 vReflectionPosition;
  94353. uniform vec3 vReflectionSize;
  94354. #endif
  94355. #endif
  94356. #if defined(SS_REFRACTION) && defined(SS_USE_LOCAL_REFRACTIONMAP_CUBIC)
  94357. uniform vec3 vRefractionPosition;
  94358. uniform vec3 vRefractionSize;
  94359. #endif
  94360. #ifdef CLEARCOAT
  94361. uniform vec2 vClearCoatParams;
  94362. uniform vec4 vClearCoatRefractionParams;
  94363. #if defined(CLEARCOAT_TEXTURE) || defined(CLEARCOAT_TEXTURE_ROUGHNESS)
  94364. uniform vec4 vClearCoatInfos;
  94365. #endif
  94366. #ifdef CLEARCOAT_TEXTURE
  94367. uniform mat4 clearCoatMatrix;
  94368. #endif
  94369. #ifdef CLEARCOAT_TEXTURE_ROUGHNESS
  94370. uniform mat4 clearCoatRoughnessMatrix;
  94371. #endif
  94372. #ifdef CLEARCOAT_BUMP
  94373. uniform vec2 vClearCoatBumpInfos;
  94374. uniform vec2 vClearCoatTangentSpaceParams;
  94375. uniform mat4 clearCoatBumpMatrix;
  94376. #endif
  94377. #ifdef CLEARCOAT_TINT
  94378. uniform vec4 vClearCoatTintParams;
  94379. uniform float clearCoatColorAtDistance;
  94380. #ifdef CLEARCOAT_TINT_TEXTURE
  94381. uniform vec2 vClearCoatTintInfos;
  94382. uniform mat4 clearCoatTintMatrix;
  94383. #endif
  94384. #endif
  94385. #endif
  94386. #ifdef ANISOTROPIC
  94387. uniform vec3 vAnisotropy;
  94388. #ifdef ANISOTROPIC_TEXTURE
  94389. uniform vec2 vAnisotropyInfos;
  94390. uniform mat4 anisotropyMatrix;
  94391. #endif
  94392. #endif
  94393. #ifdef SHEEN
  94394. uniform vec4 vSheenColor;
  94395. #ifdef SHEEN_ROUGHNESS
  94396. uniform float vSheenRoughness;
  94397. #endif
  94398. #if defined(SHEEN_TEXTURE) || defined(SHEEN_TEXTURE_ROUGHNESS)
  94399. uniform vec4 vSheenInfos;
  94400. #endif
  94401. #ifdef SHEEN_TEXTURE
  94402. uniform mat4 sheenMatrix;
  94403. #endif
  94404. #ifdef SHEEN_TEXTURE_ROUGHNESS
  94405. uniform mat4 sheenRoughnessMatrix;
  94406. #endif
  94407. #endif
  94408. #ifdef SUBSURFACE
  94409. #ifdef SS_REFRACTION
  94410. uniform vec4 vRefractionMicrosurfaceInfos;
  94411. uniform vec4 vRefractionInfos;
  94412. uniform mat4 refractionMatrix;
  94413. #ifdef REALTIME_FILTERING
  94414. uniform vec2 vRefractionFilteringInfo;
  94415. #endif
  94416. #endif
  94417. #ifdef SS_THICKNESSANDMASK_TEXTURE
  94418. uniform vec2 vThicknessInfos;
  94419. uniform mat4 thicknessMatrix;
  94420. #endif
  94421. #ifdef SS_REFRACTIONINTENSITY_TEXTURE
  94422. uniform vec2 vRefractionIntensityInfos;
  94423. uniform mat4 refractionIntensityMatrix;
  94424. #endif
  94425. #ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
  94426. uniform vec2 vTranslucencyIntensityInfos;
  94427. uniform mat4 translucencyIntensityMatrix;
  94428. #endif
  94429. uniform vec2 vThicknessParam;
  94430. uniform vec3 vDiffusionDistance;
  94431. uniform vec4 vTintColor;
  94432. uniform vec3 vSubSurfaceIntensity;
  94433. #endif
  94434. #ifdef PREPASS
  94435. #ifdef SS_SCATTERING
  94436. uniform float scatteringDiffusionProfile;
  94437. #endif
  94438. #endif
  94439. #if DEBUGMODE>0
  94440. uniform vec2 vDebugMode;
  94441. #endif
  94442. #ifdef DETAIL
  94443. uniform vec4 vDetailInfos;
  94444. #endif
  94445. #ifdef USESPHERICALFROMREFLECTIONMAP
  94446. #ifdef SPHERICAL_HARMONICS
  94447. uniform vec3 vSphericalL00;
  94448. uniform vec3 vSphericalL1_1;
  94449. uniform vec3 vSphericalL10;
  94450. uniform vec3 vSphericalL11;
  94451. uniform vec3 vSphericalL2_2;
  94452. uniform vec3 vSphericalL2_1;
  94453. uniform vec3 vSphericalL20;
  94454. uniform vec3 vSphericalL21;
  94455. uniform vec3 vSphericalL22;
  94456. #else
  94457. uniform vec3 vSphericalX;
  94458. uniform vec3 vSphericalY;
  94459. uniform vec3 vSphericalZ;
  94460. uniform vec3 vSphericalXX_ZZ;
  94461. uniform vec3 vSphericalYY_ZZ;
  94462. uniform vec3 vSphericalZZ;
  94463. uniform vec3 vSphericalXY;
  94464. uniform vec3 vSphericalYZ;
  94465. uniform vec3 vSphericalZX;
  94466. #endif
  94467. #endif
  94468. `;
  94469. ShaderStore.IncludesShadersStore[name$1e] = shader$1e;
  94470. var name$1d = "pbrUboDeclaration"
  94471. , shader$1d = `layout(std140,column_major) uniform;
  94472. uniform Material {
  94473. vec2 vAlbedoInfos;
  94474. vec4 vAmbientInfos;
  94475. vec2 vOpacityInfos;
  94476. vec2 vEmissiveInfos;
  94477. vec2 vLightmapInfos;
  94478. vec3 vReflectivityInfos;
  94479. vec2 vMicroSurfaceSamplerInfos;
  94480. vec2 vReflectionInfos;
  94481. vec2 vReflectionFilteringInfo;
  94482. vec3 vReflectionPosition;
  94483. vec3 vReflectionSize;
  94484. vec3 vBumpInfos;
  94485. mat4 albedoMatrix;
  94486. mat4 ambientMatrix;
  94487. mat4 opacityMatrix;
  94488. mat4 emissiveMatrix;
  94489. mat4 lightmapMatrix;
  94490. mat4 reflectivityMatrix;
  94491. mat4 microSurfaceSamplerMatrix;
  94492. mat4 bumpMatrix;
  94493. vec2 vTangentSpaceParams;
  94494. mat4 reflectionMatrix;
  94495. vec3 vReflectionColor;
  94496. vec4 vAlbedoColor;
  94497. vec4 vLightingIntensity;
  94498. vec3 vReflectionMicrosurfaceInfos;
  94499. float pointSize;
  94500. vec4 vReflectivityColor;
  94501. vec3 vEmissiveColor;
  94502. vec3 vAmbientColor;
  94503. vec2 vDebugMode;
  94504. vec4 vMetallicReflectanceFactors;
  94505. vec2 vMetallicReflectanceInfos;
  94506. mat4 metallicReflectanceMatrix;
  94507. vec2 vReflectanceInfos;
  94508. mat4 reflectanceMatrix;
  94509. vec2 vClearCoatParams;
  94510. vec4 vClearCoatRefractionParams;
  94511. vec4 vClearCoatInfos;
  94512. mat4 clearCoatMatrix;
  94513. mat4 clearCoatRoughnessMatrix;
  94514. vec2 vClearCoatBumpInfos;
  94515. vec2 vClearCoatTangentSpaceParams;
  94516. mat4 clearCoatBumpMatrix;
  94517. vec4 vClearCoatTintParams;
  94518. float clearCoatColorAtDistance;
  94519. vec2 vClearCoatTintInfos;
  94520. mat4 clearCoatTintMatrix;
  94521. vec3 vAnisotropy;
  94522. vec2 vAnisotropyInfos;
  94523. mat4 anisotropyMatrix;
  94524. vec4 vSheenColor;
  94525. float vSheenRoughness;
  94526. vec4 vSheenInfos;
  94527. mat4 sheenMatrix;
  94528. mat4 sheenRoughnessMatrix;
  94529. vec4 vRefractionMicrosurfaceInfos;
  94530. vec2 vRefractionFilteringInfo;
  94531. vec2 vTranslucencyIntensityInfos;
  94532. vec4 vRefractionInfos;
  94533. mat4 refractionMatrix;
  94534. vec2 vThicknessInfos;
  94535. vec2 vRefractionIntensityInfos;
  94536. mat4 thicknessMatrix;
  94537. mat4 refractionIntensityMatrix;
  94538. mat4 translucencyIntensityMatrix;
  94539. vec2 vThicknessParam;
  94540. vec3 vDiffusionDistance;
  94541. vec4 vTintColor;
  94542. vec3 vSubSurfaceIntensity;
  94543. vec3 vRefractionPosition;
  94544. vec3 vRefractionSize;
  94545. float scatteringDiffusionProfile;
  94546. vec4 vDetailInfos;
  94547. mat4 detailMatrix;
  94548. vec3 vSphericalL00;
  94549. vec3 vSphericalL1_1;
  94550. vec3 vSphericalL10;
  94551. vec3 vSphericalL11;
  94552. vec3 vSphericalL2_2;
  94553. vec3 vSphericalL2_1;
  94554. vec3 vSphericalL20;
  94555. vec3 vSphericalL21;
  94556. vec3 vSphericalL22;
  94557. vec3 vSphericalX;
  94558. vec3 vSphericalY;
  94559. vec3 vSphericalZ;
  94560. vec3 vSphericalXX_ZZ;
  94561. vec3 vSphericalYY_ZZ;
  94562. vec3 vSphericalZZ;
  94563. vec3 vSphericalXY;
  94564. vec3 vSphericalYZ;
  94565. vec3 vSphericalZX;
  94566. };
  94567. #include<sceneUboDeclaration>
  94568. #include<meshUboDeclaration>
  94569. `;
  94570. ShaderStore.IncludesShadersStore[name$1d] = shader$1d;
  94571. var name$1c = "pbrFragmentExtraDeclaration"
  94572. , shader$1c = `
  94573. varying vec3 vPositionW;
  94574. #if DEBUGMODE>0
  94575. varying vec4 vClipSpacePosition;
  94576. #endif
  94577. #include<mainUVVaryingDeclaration>[1..7]
  94578. #ifdef NORMAL
  94579. varying vec3 vNormalW;
  94580. #if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)
  94581. varying vec3 vEnvironmentIrradiance;
  94582. #endif
  94583. #endif
  94584. #ifdef VERTEXCOLOR
  94585. varying vec4 vColor;
  94586. #endif`;
  94587. ShaderStore.IncludesShadersStore[name$1c] = shader$1c;
  94588. var name$1b = "samplerFragmentAlternateDeclaration"
  94589. , shader$1b = `#ifdef _DEFINENAME_
  94590. #if _DEFINENAME_DIRECTUV == 1
  94591. #define v_VARYINGNAME_UV vMainUV1
  94592. #elif _DEFINENAME_DIRECTUV == 2
  94593. #define v_VARYINGNAME_UV vMainUV2
  94594. #elif _DEFINENAME_DIRECTUV == 3
  94595. #define v_VARYINGNAME_UV vMainUV3
  94596. #elif _DEFINENAME_DIRECTUV == 4
  94597. #define v_VARYINGNAME_UV vMainUV4
  94598. #elif _DEFINENAME_DIRECTUV == 5
  94599. #define v_VARYINGNAME_UV vMainUV5
  94600. #elif _DEFINENAME_DIRECTUV == 6
  94601. #define v_VARYINGNAME_UV vMainUV6
  94602. #else
  94603. varying vec2 v_VARYINGNAME_UV;
  94604. #endif
  94605. #endif
  94606. `;
  94607. ShaderStore.IncludesShadersStore[name$1b] = shader$1b;
  94608. var name$1a = "pbrFragmentSamplersDeclaration"
  94609. , shader$1a = `#include<samplerFragmentDeclaration>(_DEFINENAME_,ALBEDO,_VARYINGNAME_,Albedo,_SAMPLERNAME_,albedo)
  94610. #include<samplerFragmentDeclaration>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_SAMPLERNAME_,ambient)
  94611. #include<samplerFragmentDeclaration>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_SAMPLERNAME_,opacity)
  94612. #include<samplerFragmentDeclaration>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_SAMPLERNAME_,emissive)
  94613. #include<samplerFragmentDeclaration>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_SAMPLERNAME_,lightmap)
  94614. #include<samplerFragmentDeclaration>(_DEFINENAME_,REFLECTIVITY,_VARYINGNAME_,Reflectivity,_SAMPLERNAME_,reflectivity)
  94615. #include<samplerFragmentDeclaration>(_DEFINENAME_,MICROSURFACEMAP,_VARYINGNAME_,MicroSurfaceSampler,_SAMPLERNAME_,microSurface)
  94616. #include<samplerFragmentDeclaration>(_DEFINENAME_,METALLIC_REFLECTANCE,_VARYINGNAME_,MetallicReflectance,_SAMPLERNAME_,metallicReflectance)
  94617. #include<samplerFragmentDeclaration>(_DEFINENAME_,REFLECTANCE,_VARYINGNAME_,Reflectance,_SAMPLERNAME_,reflectance)
  94618. #ifdef CLEARCOAT
  94619. #include<samplerFragmentDeclaration>(_DEFINENAME_,CLEARCOAT_TEXTURE,_VARYINGNAME_,ClearCoat,_SAMPLERNAME_,clearCoat)
  94620. #include<samplerFragmentAlternateDeclaration>(_DEFINENAME_,CLEARCOAT_TEXTURE_ROUGHNESS,_VARYINGNAME_,ClearCoatRoughness)
  94621. #if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL)
  94622. uniform sampler2D clearCoatRoughnessSampler;
  94623. #endif
  94624. #include<samplerFragmentDeclaration>(_DEFINENAME_,CLEARCOAT_BUMP,_VARYINGNAME_,ClearCoatBump,_SAMPLERNAME_,clearCoatBump)
  94625. #include<samplerFragmentDeclaration>(_DEFINENAME_,CLEARCOAT_TINT_TEXTURE,_VARYINGNAME_,ClearCoatTint,_SAMPLERNAME_,clearCoatTint)
  94626. #endif
  94627. #ifdef SHEEN
  94628. #include<samplerFragmentDeclaration>(_DEFINENAME_,SHEEN_TEXTURE,_VARYINGNAME_,Sheen,_SAMPLERNAME_,sheen)
  94629. #include<samplerFragmentAlternateDeclaration>(_DEFINENAME_,SHEEN_TEXTURE_ROUGHNESS,_VARYINGNAME_,SheenRoughness)
  94630. #if defined(SHEEN_ROUGHNESS) && defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_TEXTURE_ROUGHNESS_IDENTICAL)
  94631. uniform sampler2D sheenRoughnessSampler;
  94632. #endif
  94633. #endif
  94634. #ifdef ANISOTROPIC
  94635. #include<samplerFragmentDeclaration>(_DEFINENAME_,ANISOTROPIC_TEXTURE,_VARYINGNAME_,Anisotropy,_SAMPLERNAME_,anisotropy)
  94636. #endif
  94637. #ifdef REFLECTION
  94638. #ifdef REFLECTIONMAP_3D
  94639. #define sampleReflection(s,c) textureCube(s,c)
  94640. uniform samplerCube reflectionSampler;
  94641. #ifdef LODBASEDMICROSFURACE
  94642. #define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)
  94643. #else
  94644. uniform samplerCube reflectionSamplerLow;
  94645. uniform samplerCube reflectionSamplerHigh;
  94646. #endif
  94647. #ifdef USEIRRADIANCEMAP
  94648. uniform samplerCube irradianceSampler;
  94649. #endif
  94650. #else
  94651. #define sampleReflection(s,c) texture2D(s,c)
  94652. uniform sampler2D reflectionSampler;
  94653. #ifdef LODBASEDMICROSFURACE
  94654. #define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)
  94655. #else
  94656. uniform sampler2D reflectionSamplerLow;
  94657. uniform sampler2D reflectionSamplerHigh;
  94658. #endif
  94659. #ifdef USEIRRADIANCEMAP
  94660. uniform sampler2D irradianceSampler;
  94661. #endif
  94662. #endif
  94663. #ifdef REFLECTIONMAP_SKYBOX
  94664. varying vec3 vPositionUVW;
  94665. #else
  94666. #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
  94667. varying vec3 vDirectionW;
  94668. #endif
  94669. #endif
  94670. #endif
  94671. #ifdef ENVIRONMENTBRDF
  94672. uniform sampler2D environmentBrdfSampler;
  94673. #endif
  94674. #ifdef SUBSURFACE
  94675. #ifdef SS_REFRACTION
  94676. #ifdef SS_REFRACTIONMAP_3D
  94677. #define sampleRefraction(s,c) textureCube(s,c)
  94678. uniform samplerCube refractionSampler;
  94679. #ifdef LODBASEDMICROSFURACE
  94680. #define sampleRefractionLod(s,c,l) textureCubeLodEXT(s,c,l)
  94681. #else
  94682. uniform samplerCube refractionSamplerLow;
  94683. uniform samplerCube refractionSamplerHigh;
  94684. #endif
  94685. #else
  94686. #define sampleRefraction(s,c) texture2D(s,c)
  94687. uniform sampler2D refractionSampler;
  94688. #ifdef LODBASEDMICROSFURACE
  94689. #define sampleRefractionLod(s,c,l) texture2DLodEXT(s,c,l)
  94690. #else
  94691. uniform sampler2D refractionSamplerLow;
  94692. uniform sampler2D refractionSamplerHigh;
  94693. #endif
  94694. #endif
  94695. #endif
  94696. #include<samplerFragmentDeclaration>(_DEFINENAME_,SS_THICKNESSANDMASK_TEXTURE,_VARYINGNAME_,Thickness,_SAMPLERNAME_,thickness)
  94697. #include<samplerFragmentDeclaration>(_DEFINENAME_,SS_REFRACTIONINTENSITY_TEXTURE,_VARYINGNAME_,RefractionIntensity,_SAMPLERNAME_,refractionIntensity)
  94698. #include<samplerFragmentDeclaration>(_DEFINENAME_,SS_TRANSLUCENCYINTENSITY_TEXTURE,_VARYINGNAME_,TranslucencyIntensity,_SAMPLERNAME_,translucencyIntensity)
  94699. #endif`;
  94700. ShaderStore.IncludesShadersStore[name$1a] = shader$1a;
  94701. var name$19 = "subSurfaceScatteringFunctions"
  94702. , shader$19 = `bool testLightingForSSS(float diffusionProfile)
  94703. {
  94704. return diffusionProfile<1.;
  94705. }`;
  94706. ShaderStore.IncludesShadersStore[name$19] = shader$19;
  94707. var name$18 = "importanceSampling"
  94708. , shader$18 = `
  94709. vec3 hemisphereCosSample(vec2 u) {
  94710. float phi=2.*PI*u.x;
  94711. float cosTheta2=1.-u.y;
  94712. float cosTheta=sqrt(cosTheta2);
  94713. float sinTheta=sqrt(1.-cosTheta2);
  94714. return vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);
  94715. }
  94716. vec3 hemisphereImportanceSampleDggx(vec2 u,float a) {
  94717. float phi=2.*PI*u.x;
  94718. float cosTheta2=(1.-u.y)/(1.+(a+1.)*((a-1.)*u.y));
  94719. float cosTheta=sqrt(cosTheta2);
  94720. float sinTheta=sqrt(1.-cosTheta2);
  94721. return vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);
  94722. }
  94723. vec3 hemisphereImportanceSampleDCharlie(vec2 u,float a) {
  94724. float phi=2.*PI*u.x;
  94725. float sinTheta=pow(u.y,a/(2.*a+1.));
  94726. float cosTheta=sqrt(1.-sinTheta*sinTheta);
  94727. return vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);
  94728. }`;
  94729. ShaderStore.IncludesShadersStore[name$18] = shader$18;
  94730. var name$17 = "pbrHelperFunctions"
  94731. , shader$17 = `
  94732. #define RECIPROCAL_PI2 0.15915494
  94733. #define RECIPROCAL_PI 0.31830988618
  94734. #define MINIMUMVARIANCE 0.0005
  94735. float convertRoughnessToAverageSlope(float roughness)
  94736. {
  94737. return square(roughness)+MINIMUMVARIANCE;
  94738. }
  94739. float fresnelGrazingReflectance(float reflectance0) {
  94740. float reflectance90=saturate(reflectance0*25.0);
  94741. return reflectance90;
  94742. }
  94743. vec2 getAARoughnessFactors(vec3 normalVector) {
  94744. #ifdef SPECULARAA
  94745. vec3 nDfdx=dFdx(normalVector.xyz);
  94746. vec3 nDfdy=dFdy(normalVector.xyz);
  94747. float slopeSquare=max(dot(nDfdx,nDfdx),dot(nDfdy,nDfdy));
  94748. float geometricRoughnessFactor=pow(saturate(slopeSquare),0.333);
  94749. float geometricAlphaGFactor=sqrt(slopeSquare);
  94750. geometricAlphaGFactor*=0.75;
  94751. return vec2(geometricRoughnessFactor,geometricAlphaGFactor);
  94752. #else
  94753. return vec2(0.);
  94754. #endif
  94755. }
  94756. #ifdef ANISOTROPIC
  94757. vec2 getAnisotropicRoughness(float alphaG,float anisotropy) {
  94758. float alphaT=max(alphaG*(1.0+anisotropy),MINIMUMVARIANCE);
  94759. float alphaB=max(alphaG*(1.0-anisotropy),MINIMUMVARIANCE);
  94760. return vec2(alphaT,alphaB);
  94761. }
  94762. vec3 getAnisotropicBentNormals(const vec3 T,const vec3 B,const vec3 N,const vec3 V,float anisotropy) {
  94763. vec3 anisotropicFrameDirection=anisotropy>=0.0 ? B : T;
  94764. vec3 anisotropicFrameTangent=cross(normalize(anisotropicFrameDirection),V);
  94765. vec3 anisotropicFrameNormal=cross(anisotropicFrameTangent,anisotropicFrameDirection);
  94766. vec3 anisotropicNormal=normalize(mix(N,anisotropicFrameNormal,abs(anisotropy)));
  94767. return anisotropicNormal;
  94768. }
  94769. #endif
  94770. #if defined(CLEARCOAT) || defined(SS_REFRACTION)
  94771. vec3 cocaLambert(vec3 alpha,float distance) {
  94772. return exp(-alpha*distance);
  94773. }
  94774. vec3 cocaLambert(float NdotVRefract,float NdotLRefract,vec3 alpha,float thickness) {
  94775. return cocaLambert(alpha,(thickness*((NdotLRefract+NdotVRefract)/(NdotLRefract*NdotVRefract))));
  94776. }
  94777. vec3 computeColorAtDistanceInMedia(vec3 color,float distance) {
  94778. return -log(color)/distance;
  94779. }
  94780. vec3 computeClearCoatAbsorption(float NdotVRefract,float NdotLRefract,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {
  94781. vec3 clearCoatAbsorption=mix(vec3(1.0),
  94782. cocaLambert(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness),
  94783. clearCoatIntensity);
  94784. return clearCoatAbsorption;
  94785. }
  94786. #endif
  94787. #ifdef MICROSURFACEAUTOMATIC
  94788. float computeDefaultMicroSurface(float microSurface,vec3 reflectivityColor)
  94789. {
  94790. const float kReflectivityNoAlphaWorkflow_SmoothnessMax=0.95;
  94791. float reflectivityLuminance=getLuminance(reflectivityColor);
  94792. float reflectivityLuma=sqrt(reflectivityLuminance);
  94793. microSurface=reflectivityLuma*kReflectivityNoAlphaWorkflow_SmoothnessMax;
  94794. return microSurface;
  94795. }
  94796. #endif`;
  94797. ShaderStore.IncludesShadersStore[name$17] = shader$17;
  94798. var name$16 = "harmonicsFunctions"
  94799. , shader$16 = `#ifdef USESPHERICALFROMREFLECTIONMAP
  94800. #ifdef SPHERICAL_HARMONICS
  94801. vec3 computeEnvironmentIrradiance(vec3 normal) {
  94802. return vSphericalL00
  94803. +vSphericalL1_1*(normal.y)
  94804. +vSphericalL10*(normal.z)
  94805. +vSphericalL11*(normal.x)
  94806. +vSphericalL2_2*(normal.y*normal.x)
  94807. +vSphericalL2_1*(normal.y*normal.z)
  94808. +vSphericalL20*((3.0*normal.z*normal.z)-1.0)
  94809. +vSphericalL21*(normal.z*normal.x)
  94810. +vSphericalL22*(normal.x*normal.x-(normal.y*normal.y));
  94811. }
  94812. #else
  94813. vec3 computeEnvironmentIrradiance(vec3 normal) {
  94814. float Nx=normal.x;
  94815. float Ny=normal.y;
  94816. float Nz=normal.z;
  94817. vec3 C1=vSphericalZZ.rgb;
  94818. vec3 Cx=vSphericalX.rgb;
  94819. vec3 Cy=vSphericalY.rgb;
  94820. vec3 Cz=vSphericalZ.rgb;
  94821. vec3 Cxx_zz=vSphericalXX_ZZ.rgb;
  94822. vec3 Cyy_zz=vSphericalYY_ZZ.rgb;
  94823. vec3 Cxy=vSphericalXY.rgb;
  94824. vec3 Cyz=vSphericalYZ.rgb;
  94825. vec3 Czx=vSphericalZX.rgb;
  94826. vec3 a1=Cyy_zz*Ny+Cy;
  94827. vec3 a2=Cyz*Nz+a1;
  94828. vec3 b1=Czx*Nz+Cx;
  94829. vec3 b2=Cxy*Ny+b1;
  94830. vec3 b3=Cxx_zz*Nx+b2;
  94831. vec3 t1=Cz*Nz+C1;
  94832. vec3 t2=a2*Ny+t1;
  94833. vec3 t3=b3*Nx+t2;
  94834. return t3;
  94835. }
  94836. #endif
  94837. #endif`;
  94838. ShaderStore.IncludesShadersStore[name$16] = shader$16;
  94839. var name$15 = "pbrDirectLightingSetupFunctions"
  94840. , shader$15 = `
  94841. struct preLightingInfo
  94842. {
  94843. vec3 lightOffset;
  94844. float lightDistanceSquared;
  94845. float lightDistance;
  94846. float attenuation;
  94847. vec3 L;
  94848. vec3 H;
  94849. float NdotV;
  94850. float NdotLUnclamped;
  94851. float NdotL;
  94852. float VdotH;
  94853. float roughness;
  94854. };
  94855. preLightingInfo computePointAndSpotPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {
  94856. preLightingInfo result;
  94857. result.lightOffset=lightData.xyz-vPositionW;
  94858. result.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);
  94859. result.lightDistance=sqrt(result.lightDistanceSquared);
  94860. result.L=normalize(result.lightOffset);
  94861. result.H=normalize(V+result.L);
  94862. result.VdotH=saturate(dot(V,result.H));
  94863. result.NdotLUnclamped=dot(N,result.L);
  94864. result.NdotL=saturateEps(result.NdotLUnclamped);
  94865. return result;
  94866. }
  94867. preLightingInfo computeDirectionalPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {
  94868. preLightingInfo result;
  94869. result.lightDistance=length(-lightData.xyz);
  94870. result.L=normalize(-lightData.xyz);
  94871. result.H=normalize(V+result.L);
  94872. result.VdotH=saturate(dot(V,result.H));
  94873. result.NdotLUnclamped=dot(N,result.L);
  94874. result.NdotL=saturateEps(result.NdotLUnclamped);
  94875. return result;
  94876. }
  94877. preLightingInfo computeHemisphericPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {
  94878. preLightingInfo result;
  94879. result.NdotL=dot(N,lightData.xyz)*0.5+0.5;
  94880. result.NdotL=saturateEps(result.NdotL);
  94881. result.NdotLUnclamped=result.NdotL;
  94882. #ifdef SPECULARTERM
  94883. result.L=normalize(lightData.xyz);
  94884. result.H=normalize(V+result.L);
  94885. result.VdotH=saturate(dot(V,result.H));
  94886. #endif
  94887. return result;
  94888. }`;
  94889. ShaderStore.IncludesShadersStore[name$15] = shader$15;
  94890. var name$14 = "pbrDirectLightingFalloffFunctions"
  94891. , shader$14 = `float computeDistanceLightFalloff_Standard(vec3 lightOffset,float range)
  94892. {
  94893. return max(0.,1.0-length(lightOffset)/range);
  94894. }
  94895. float computeDistanceLightFalloff_Physical(float lightDistanceSquared)
  94896. {
  94897. return 1.0/maxEps(lightDistanceSquared);
  94898. }
  94899. float computeDistanceLightFalloff_GLTF(float lightDistanceSquared,float inverseSquaredRange)
  94900. {
  94901. float lightDistanceFalloff=1.0/maxEps(lightDistanceSquared);
  94902. float factor=lightDistanceSquared*inverseSquaredRange;
  94903. float attenuation=saturate(1.0-factor*factor);
  94904. attenuation*=attenuation;
  94905. lightDistanceFalloff*=attenuation;
  94906. return lightDistanceFalloff;
  94907. }
  94908. float computeDistanceLightFalloff(vec3 lightOffset,float lightDistanceSquared,float range,float inverseSquaredRange)
  94909. {
  94910. #ifdef USEPHYSICALLIGHTFALLOFF
  94911. return computeDistanceLightFalloff_Physical(lightDistanceSquared);
  94912. #elif defined(USEGLTFLIGHTFALLOFF)
  94913. return computeDistanceLightFalloff_GLTF(lightDistanceSquared,inverseSquaredRange);
  94914. #else
  94915. return computeDistanceLightFalloff_Standard(lightOffset,range);
  94916. #endif
  94917. }
  94918. float computeDirectionalLightFalloff_Standard(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent)
  94919. {
  94920. float falloff=0.0;
  94921. float cosAngle=maxEps(dot(-lightDirection,directionToLightCenterW));
  94922. if (cosAngle>=cosHalfAngle)
  94923. {
  94924. falloff=max(0.,pow(cosAngle,exponent));
  94925. }
  94926. return falloff;
  94927. }
  94928. float computeDirectionalLightFalloff_Physical(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle)
  94929. {
  94930. const float kMinusLog2ConeAngleIntensityRatio=6.64385618977;
  94931. float concentrationKappa=kMinusLog2ConeAngleIntensityRatio/(1.0-cosHalfAngle);
  94932. vec4 lightDirectionSpreadSG=vec4(-lightDirection*concentrationKappa,-concentrationKappa);
  94933. float falloff=exp2(dot(vec4(directionToLightCenterW,1.0),lightDirectionSpreadSG));
  94934. return falloff;
  94935. }
  94936. float computeDirectionalLightFalloff_GLTF(vec3 lightDirection,vec3 directionToLightCenterW,float lightAngleScale,float lightAngleOffset)
  94937. {
  94938. float cd=dot(-lightDirection,directionToLightCenterW);
  94939. float falloff=saturate(cd*lightAngleScale+lightAngleOffset);
  94940. falloff*=falloff;
  94941. return falloff;
  94942. }
  94943. float computeDirectionalLightFalloff(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent,float lightAngleScale,float lightAngleOffset)
  94944. {
  94945. #ifdef USEPHYSICALLIGHTFALLOFF
  94946. return computeDirectionalLightFalloff_Physical(lightDirection,directionToLightCenterW,cosHalfAngle);
  94947. #elif defined(USEGLTFLIGHTFALLOFF)
  94948. return computeDirectionalLightFalloff_GLTF(lightDirection,directionToLightCenterW,lightAngleScale,lightAngleOffset);
  94949. #else
  94950. return computeDirectionalLightFalloff_Standard(lightDirection,directionToLightCenterW,cosHalfAngle,exponent);
  94951. #endif
  94952. }`;
  94953. ShaderStore.IncludesShadersStore[name$14] = shader$14;
  94954. var name$13 = "pbrBRDFFunctions"
  94955. , shader$13 = `
  94956. #define FRESNEL_MAXIMUM_ON_ROUGH 0.25
  94957. #ifdef MS_BRDF_ENERGY_CONSERVATION
  94958. vec3 getEnergyConservationFactor(const vec3 specularEnvironmentR0,const vec3 environmentBrdf) {
  94959. return 1.0+specularEnvironmentR0*(1.0/environmentBrdf.y-1.0);
  94960. }
  94961. #endif
  94962. #ifdef ENVIRONMENTBRDF
  94963. vec3 getBRDFLookup(float NdotV,float perceptualRoughness) {
  94964. vec2 UV=vec2(NdotV,perceptualRoughness);
  94965. vec4 brdfLookup=texture2D(environmentBrdfSampler,UV);
  94966. #ifdef ENVIRONMENTBRDF_RGBD
  94967. brdfLookup.rgb=fromRGBD(brdfLookup.rgba);
  94968. #endif
  94969. return brdfLookup.rgb;
  94970. }
  94971. vec3 getReflectanceFromBRDFLookup(const vec3 specularEnvironmentR0,const vec3 specularEnvironmentR90,const vec3 environmentBrdf) {
  94972. #ifdef BRDF_V_HEIGHT_CORRELATED
  94973. vec3 reflectance=(specularEnvironmentR90-specularEnvironmentR0)*environmentBrdf.x+specularEnvironmentR0*environmentBrdf.y;
  94974. #else
  94975. vec3 reflectance=specularEnvironmentR0*environmentBrdf.x+specularEnvironmentR90*environmentBrdf.y;
  94976. #endif
  94977. return reflectance;
  94978. }
  94979. vec3 getReflectanceFromBRDFLookup(const vec3 specularEnvironmentR0,const vec3 environmentBrdf) {
  94980. #ifdef BRDF_V_HEIGHT_CORRELATED
  94981. vec3 reflectance=mix(environmentBrdf.xxx,environmentBrdf.yyy,specularEnvironmentR0);
  94982. #else
  94983. vec3 reflectance=specularEnvironmentR0*environmentBrdf.x+environmentBrdf.y;
  94984. #endif
  94985. return reflectance;
  94986. }
  94987. #endif
  94988. #if !defined(ENVIRONMENTBRDF) || defined(REFLECTIONMAP_SKYBOX) || defined(ALPHAFRESNEL)
  94989. vec3 getReflectanceFromAnalyticalBRDFLookup_Jones(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)
  94990. {
  94991. float weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);
  94992. return reflectance0+weight*(reflectance90-reflectance0)*pow5(saturate(1.0-VdotN));
  94993. }
  94994. #endif
  94995. #if defined(SHEEN) && defined(ENVIRONMENTBRDF)
  94996. vec3 getSheenReflectanceFromBRDFLookup(const vec3 reflectance0,const vec3 environmentBrdf) {
  94997. vec3 sheenEnvironmentReflectance=reflectance0*environmentBrdf.b;
  94998. return sheenEnvironmentReflectance;
  94999. }
  95000. #endif
  95001. vec3 fresnelSchlickGGX(float VdotH,vec3 reflectance0,vec3 reflectance90)
  95002. {
  95003. return reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);
  95004. }
  95005. float fresnelSchlickGGX(float VdotH,float reflectance0,float reflectance90)
  95006. {
  95007. return reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);
  95008. }
  95009. #ifdef CLEARCOAT
  95010. vec3 getR0RemappedForClearCoat(vec3 f0) {
  95011. #ifdef CLEARCOAT_DEFAULTIOR
  95012. #ifdef MOBILE
  95013. return saturate(f0*(f0*0.526868+0.529324)-0.0482256);
  95014. #else
  95015. return saturate(f0*(f0*(0.941892-0.263008*f0)+0.346479)-0.0285998);
  95016. #endif
  95017. #else
  95018. vec3 s=sqrt(f0);
  95019. vec3 t=(vClearCoatRefractionParams.z+vClearCoatRefractionParams.w*s)/(vClearCoatRefractionParams.w+vClearCoatRefractionParams.z*s);
  95020. return t*t;
  95021. #endif
  95022. }
  95023. #endif
  95024. float normalDistributionFunction_TrowbridgeReitzGGX(float NdotH,float alphaG)
  95025. {
  95026. float a2=square(alphaG);
  95027. float d=NdotH*NdotH*(a2-1.0)+1.0;
  95028. return a2/(PI*d*d);
  95029. }
  95030. #ifdef SHEEN
  95031. float normalDistributionFunction_CharlieSheen(float NdotH,float alphaG)
  95032. {
  95033. float invR=1./alphaG;
  95034. float cos2h=NdotH*NdotH;
  95035. float sin2h=1.-cos2h;
  95036. return (2.+invR)*pow(sin2h,invR*.5)/(2.*PI);
  95037. }
  95038. #endif
  95039. #ifdef ANISOTROPIC
  95040. float normalDistributionFunction_BurleyGGX_Anisotropic(float NdotH,float TdotH,float BdotH,const vec2 alphaTB) {
  95041. float a2=alphaTB.x*alphaTB.y;
  95042. vec3 v=vec3(alphaTB.y*TdotH,alphaTB.x*BdotH,a2*NdotH);
  95043. float v2=dot(v,v);
  95044. float w2=a2/v2;
  95045. return a2*w2*w2*RECIPROCAL_PI;
  95046. }
  95047. #endif
  95048. #ifdef BRDF_V_HEIGHT_CORRELATED
  95049. float smithVisibility_GGXCorrelated(float NdotL,float NdotV,float alphaG) {
  95050. #ifdef MOBILE
  95051. float GGXV=NdotL*(NdotV*(1.0-alphaG)+alphaG);
  95052. float GGXL=NdotV*(NdotL*(1.0-alphaG)+alphaG);
  95053. return 0.5/(GGXV+GGXL);
  95054. #else
  95055. float a2=alphaG*alphaG;
  95056. float GGXV=NdotL*sqrt(NdotV*(NdotV-a2*NdotV)+a2);
  95057. float GGXL=NdotV*sqrt(NdotL*(NdotL-a2*NdotL)+a2);
  95058. return 0.5/(GGXV+GGXL);
  95059. #endif
  95060. }
  95061. #else
  95062. float smithVisibilityG1_TrowbridgeReitzGGXFast(float dot,float alphaG)
  95063. {
  95064. #ifdef MOBILE
  95065. return 1.0/(dot+alphaG+(1.0-alphaG)*dot ));
  95066. #else
  95067. float alphaSquared=alphaG*alphaG;
  95068. return 1.0/(dot+sqrt(alphaSquared+(1.0-alphaSquared)*dot*dot));
  95069. #endif
  95070. }
  95071. float smithVisibility_TrowbridgeReitzGGXFast(float NdotL,float NdotV,float alphaG)
  95072. {
  95073. float visibility=smithVisibilityG1_TrowbridgeReitzGGXFast(NdotL,alphaG)*smithVisibilityG1_TrowbridgeReitzGGXFast(NdotV,alphaG);
  95074. return visibility;
  95075. }
  95076. #endif
  95077. #ifdef ANISOTROPIC
  95078. float smithVisibility_GGXCorrelated_Anisotropic(float NdotL,float NdotV,float TdotV,float BdotV,float TdotL,float BdotL,const vec2 alphaTB) {
  95079. float lambdaV=NdotL*length(vec3(alphaTB.x*TdotV,alphaTB.y*BdotV,NdotV));
  95080. float lambdaL=NdotV*length(vec3(alphaTB.x*TdotL,alphaTB.y*BdotL,NdotL));
  95081. float v=0.5/(lambdaV+lambdaL);
  95082. return v;
  95083. }
  95084. #endif
  95085. #ifdef CLEARCOAT
  95086. float visibility_Kelemen(float VdotH) {
  95087. return 0.25/(VdotH*VdotH);
  95088. }
  95089. #endif
  95090. #ifdef SHEEN
  95091. float visibility_Ashikhmin(float NdotL,float NdotV)
  95092. {
  95093. return 1./(4.*(NdotL+NdotV-NdotL*NdotV));
  95094. }
  95095. #endif
  95096. float diffuseBRDF_Burley(float NdotL,float NdotV,float VdotH,float roughness) {
  95097. float diffuseFresnelNV=pow5(saturateEps(1.0-NdotL));
  95098. float diffuseFresnelNL=pow5(saturateEps(1.0-NdotV));
  95099. float diffuseFresnel90=0.5+2.0*VdotH*VdotH*roughness;
  95100. float fresnel =
  95101. (1.0+(diffuseFresnel90-1.0)*diffuseFresnelNL) *
  95102. (1.0+(diffuseFresnel90-1.0)*diffuseFresnelNV);
  95103. return fresnel/PI;
  95104. }
  95105. #ifdef SS_TRANSLUCENCY
  95106. vec3 transmittanceBRDF_Burley(const vec3 tintColor,const vec3 diffusionDistance,float thickness) {
  95107. vec3 S=1./maxEps(diffusionDistance);
  95108. vec3 temp=exp((-0.333333333*thickness)*S);
  95109. return tintColor.rgb*0.25*(temp*temp*temp+3.0*temp);
  95110. }
  95111. float computeWrappedDiffuseNdotL(float NdotL,float w) {
  95112. float t=1.0+w;
  95113. float invt2=1.0/square(t);
  95114. return saturate((NdotL+w)*invt2);
  95115. }
  95116. #endif
  95117. `;
  95118. ShaderStore.IncludesShadersStore[name$13] = shader$13;
  95119. var name$12 = "hdrFilteringFunctions"
  95120. , shader$12 = `#ifdef NUM_SAMPLES
  95121. #if NUM_SAMPLES>0
  95122. #if defined(WEBGL2) || defined(WEBGPU)
  95123. float radicalInverse_VdC(uint bits)
  95124. {
  95125. bits=(bits << 16u) | (bits >> 16u);
  95126. bits=((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
  95127. bits=((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
  95128. bits=((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
  95129. bits=((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
  95130. return float(bits)*2.3283064365386963e-10;
  95131. }
  95132. vec2 hammersley(uint i,uint N)
  95133. {
  95134. return vec2(float(i)/float(N),radicalInverse_VdC(i));
  95135. }
  95136. #else
  95137. float vanDerCorpus(int n,int base)
  95138. {
  95139. float invBase=1.0/float(base);
  95140. float denom=1.0;
  95141. float result=0.0;
  95142. for(int i=0; i<32; ++i)
  95143. {
  95144. if(n>0)
  95145. {
  95146. denom=mod(float(n),2.0);
  95147. result+=denom*invBase;
  95148. invBase=invBase/2.0;
  95149. n=int(float(n)/2.0);
  95150. }
  95151. }
  95152. return result;
  95153. }
  95154. vec2 hammersley(int i,int N)
  95155. {
  95156. return vec2(float(i)/float(N),vanDerCorpus(i,2));
  95157. }
  95158. #endif
  95159. float log4(float x) {
  95160. return log2(x)/2.;
  95161. }
  95162. const float NUM_SAMPLES_FLOAT=float(NUM_SAMPLES);
  95163. const float NUM_SAMPLES_FLOAT_INVERSED=1./NUM_SAMPLES_FLOAT;
  95164. const float K=4.;
  95165. #define inline
  95166. vec3 irradiance(samplerCube inputTexture,vec3 inputN,vec2 filteringInfo)
  95167. {
  95168. vec3 n=normalize(inputN);
  95169. vec3 result=vec3(0.0);
  95170. vec3 tangent=abs(n.z)<0.999 ? vec3(0.,0.,1.) : vec3(1.,0.,0.);
  95171. tangent=normalize(cross(tangent,n));
  95172. vec3 bitangent=cross(n,tangent);
  95173. mat3 tbn=mat3(tangent,bitangent,n);
  95174. float maxLevel=filteringInfo.y;
  95175. float dim0=filteringInfo.x;
  95176. float omegaP=(4.*PI)/(6.*dim0*dim0);
  95177. #if defined(WEBGL2) || defined(WEBGPU)
  95178. for(uint i=0u; i<NUM_SAMPLES; ++i)
  95179. #else
  95180. for(int i=0; i<NUM_SAMPLES; ++i)
  95181. #endif
  95182. {
  95183. vec2 Xi=hammersley(i,NUM_SAMPLES);
  95184. vec3 Ls=hemisphereCosSample(Xi);
  95185. Ls=normalize(Ls);
  95186. vec3 Ns=vec3(0.,0.,1.);
  95187. float NoL=dot(Ns,Ls);
  95188. if (NoL>0.) {
  95189. float pdf_inversed=PI/NoL;
  95190. float omegaS=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;
  95191. float l=log4(omegaS)-log4(omegaP)+log4(K);
  95192. float mipLevel=clamp(l,0.0,maxLevel);
  95193. vec3 c=textureCubeLodEXT(inputTexture,tbn*Ls,mipLevel).rgb;
  95194. #ifdef GAMMA_INPUT
  95195. c=toLinearSpace(c);
  95196. #endif
  95197. result+=c;
  95198. }
  95199. }
  95200. result=result*NUM_SAMPLES_FLOAT_INVERSED;
  95201. return result;
  95202. }
  95203. #define inline
  95204. vec3 radiance(float alphaG,samplerCube inputTexture,vec3 inputN,vec2 filteringInfo)
  95205. {
  95206. vec3 n=normalize(inputN);
  95207. if (alphaG == 0.) {
  95208. vec3 c=textureCube(inputTexture,n).rgb;
  95209. #ifdef GAMMA_INPUT
  95210. c=toLinearSpace(c);
  95211. #endif
  95212. return c;
  95213. } else {
  95214. vec3 result=vec3(0.);
  95215. vec3 tangent=abs(n.z)<0.999 ? vec3(0.,0.,1.) : vec3(1.,0.,0.);
  95216. tangent=normalize(cross(tangent,n));
  95217. vec3 bitangent=cross(n,tangent);
  95218. mat3 tbn=mat3(tangent,bitangent,n);
  95219. float maxLevel=filteringInfo.y;
  95220. float dim0=filteringInfo.x;
  95221. float omegaP=(4.*PI)/(6.*dim0*dim0);
  95222. float weight=0.;
  95223. #if defined(WEBGL2) || defined(WEBGPU)
  95224. for(uint i=0u; i<NUM_SAMPLES; ++i)
  95225. #else
  95226. for(int i=0; i<NUM_SAMPLES; ++i)
  95227. #endif
  95228. {
  95229. vec2 Xi=hammersley(i,NUM_SAMPLES);
  95230. vec3 H=hemisphereImportanceSampleDggx(Xi,alphaG);
  95231. float NoV=1.;
  95232. float NoH=H.z;
  95233. float NoH2=H.z*H.z;
  95234. float NoL=2.*NoH2-1.;
  95235. vec3 L=vec3(2.*NoH*H.x,2.*NoH*H.y,NoL);
  95236. L=normalize(L);
  95237. if (NoL>0.) {
  95238. float pdf_inversed=4./normalDistributionFunction_TrowbridgeReitzGGX(NoH,alphaG);
  95239. float omegaS=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;
  95240. float l=log4(omegaS)-log4(omegaP)+log4(K);
  95241. float mipLevel=clamp(float(l),0.0,maxLevel);
  95242. weight+=NoL;
  95243. vec3 c=textureCubeLodEXT(inputTexture,tbn*L,mipLevel).rgb;
  95244. #ifdef GAMMA_INPUT
  95245. c=toLinearSpace(c);
  95246. #endif
  95247. result+=c*NoL;
  95248. }
  95249. }
  95250. result=result/weight;
  95251. return result;
  95252. }
  95253. }
  95254. #endif
  95255. #endif`;
  95256. ShaderStore.IncludesShadersStore[name$12] = shader$12;
  95257. var name$11 = "pbrDirectLightingFunctions"
  95258. , shader$11 = `#define CLEARCOATREFLECTANCE90 1.0
  95259. struct lightingInfo
  95260. {
  95261. vec3 diffuse;
  95262. #ifdef SPECULARTERM
  95263. vec3 specular;
  95264. #endif
  95265. #ifdef CLEARCOAT
  95266. vec4 clearCoat;
  95267. #endif
  95268. #ifdef SHEEN
  95269. vec3 sheen;
  95270. #endif
  95271. };
  95272. float adjustRoughnessFromLightProperties(float roughness,float lightRadius,float lightDistance) {
  95273. #if defined(USEPHYSICALLIGHTFALLOFF) || defined(USEGLTFLIGHTFALLOFF)
  95274. float lightRoughness=lightRadius/lightDistance;
  95275. float totalRoughness=saturate(lightRoughness+roughness);
  95276. return totalRoughness;
  95277. #else
  95278. return roughness;
  95279. #endif
  95280. }
  95281. vec3 computeHemisphericDiffuseLighting(preLightingInfo info,vec3 lightColor,vec3 groundColor) {
  95282. return mix(groundColor,lightColor,info.NdotL);
  95283. }
  95284. vec3 computeDiffuseLighting(preLightingInfo info,vec3 lightColor) {
  95285. float diffuseTerm=diffuseBRDF_Burley(info.NdotL,info.NdotV,info.VdotH,info.roughness);
  95286. return diffuseTerm*info.attenuation*info.NdotL*lightColor;
  95287. }
  95288. #define inline
  95289. vec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix){
  95290. vec4 strq=textureProjectionMatrix*vec4(vPositionW,1.0);
  95291. strq/=strq.w;
  95292. vec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;
  95293. return toLinearSpace(textureColor);
  95294. }
  95295. #ifdef SS_TRANSLUCENCY
  95296. vec3 computeDiffuseAndTransmittedLighting(preLightingInfo info,vec3 lightColor,vec3 transmittance) {
  95297. float NdotL=absEps(info.NdotLUnclamped);
  95298. float wrapNdotL=computeWrappedDiffuseNdotL(NdotL,0.02);
  95299. float trAdapt=step(0.,info.NdotLUnclamped);
  95300. vec3 transmittanceNdotL=mix(transmittance*wrapNdotL,vec3(wrapNdotL),trAdapt);
  95301. float diffuseTerm=diffuseBRDF_Burley(NdotL,info.NdotV,info.VdotH,info.roughness);
  95302. return diffuseTerm*transmittanceNdotL*info.attenuation*lightColor;
  95303. }
  95304. #endif
  95305. #ifdef SPECULARTERM
  95306. vec3 computeSpecularLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {
  95307. float NdotH=saturateEps(dot(N,info.H));
  95308. float roughness=max(info.roughness,geometricRoughnessFactor);
  95309. float alphaG=convertRoughnessToAverageSlope(roughness);
  95310. vec3 fresnel=fresnelSchlickGGX(info.VdotH,reflectance0,reflectance90);
  95311. float distribution=normalDistributionFunction_TrowbridgeReitzGGX(NdotH,alphaG);
  95312. #ifdef BRDF_V_HEIGHT_CORRELATED
  95313. float smithVisibility=smithVisibility_GGXCorrelated(info.NdotL,info.NdotV,alphaG);
  95314. #else
  95315. float smithVisibility=smithVisibility_TrowbridgeReitzGGXFast(info.NdotL,info.NdotV,alphaG);
  95316. #endif
  95317. vec3 specTerm=fresnel*distribution*smithVisibility;
  95318. return specTerm*info.attenuation*info.NdotL*lightColor;
  95319. }
  95320. #endif
  95321. #ifdef ANISOTROPIC
  95322. vec3 computeAnisotropicSpecularLighting(preLightingInfo info,vec3 V,vec3 N,vec3 T,vec3 B,float anisotropy,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {
  95323. float NdotH=saturateEps(dot(N,info.H));
  95324. float TdotH=dot(T,info.H);
  95325. float BdotH=dot(B,info.H);
  95326. float TdotV=dot(T,V);
  95327. float BdotV=dot(B,V);
  95328. float TdotL=dot(T,info.L);
  95329. float BdotL=dot(B,info.L);
  95330. float alphaG=convertRoughnessToAverageSlope(info.roughness);
  95331. vec2 alphaTB=getAnisotropicRoughness(alphaG,anisotropy);
  95332. alphaTB=max(alphaTB,square(geometricRoughnessFactor));
  95333. vec3 fresnel=fresnelSchlickGGX(info.VdotH,reflectance0,reflectance90);
  95334. float distribution=normalDistributionFunction_BurleyGGX_Anisotropic(NdotH,TdotH,BdotH,alphaTB);
  95335. float smithVisibility=smithVisibility_GGXCorrelated_Anisotropic(info.NdotL,info.NdotV,TdotV,BdotV,TdotL,BdotL,alphaTB);
  95336. vec3 specTerm=fresnel*distribution*smithVisibility;
  95337. return specTerm*info.attenuation*info.NdotL*lightColor;
  95338. }
  95339. #endif
  95340. #ifdef CLEARCOAT
  95341. vec4 computeClearCoatLighting(preLightingInfo info,vec3 Ncc,float geometricRoughnessFactor,float clearCoatIntensity,vec3 lightColor) {
  95342. float NccdotL=saturateEps(dot(Ncc,info.L));
  95343. float NccdotH=saturateEps(dot(Ncc,info.H));
  95344. float clearCoatRoughness=max(info.roughness,geometricRoughnessFactor);
  95345. float alphaG=convertRoughnessToAverageSlope(clearCoatRoughness);
  95346. float fresnel=fresnelSchlickGGX(info.VdotH,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);
  95347. fresnel*=clearCoatIntensity;
  95348. float distribution=normalDistributionFunction_TrowbridgeReitzGGX(NccdotH,alphaG);
  95349. float kelemenVisibility=visibility_Kelemen(info.VdotH);
  95350. float clearCoatTerm=fresnel*distribution*kelemenVisibility;
  95351. return vec4(
  95352. clearCoatTerm*info.attenuation*NccdotL*lightColor,
  95353. 1.0-fresnel
  95354. );
  95355. }
  95356. vec3 computeClearCoatLightingAbsorption(float NdotVRefract,vec3 L,vec3 Ncc,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {
  95357. vec3 LRefract=-refract(L,Ncc,vClearCoatRefractionParams.y);
  95358. float NdotLRefract=saturateEps(dot(Ncc,LRefract));
  95359. vec3 absorption=computeClearCoatAbsorption(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness,clearCoatIntensity);
  95360. return absorption;
  95361. }
  95362. #endif
  95363. #ifdef SHEEN
  95364. vec3 computeSheenLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {
  95365. float NdotH=saturateEps(dot(N,info.H));
  95366. float roughness=max(info.roughness,geometricRoughnessFactor);
  95367. float alphaG=convertRoughnessToAverageSlope(roughness);
  95368. float fresnel=1.;
  95369. float distribution=normalDistributionFunction_CharlieSheen(NdotH,alphaG);
  95370. float visibility=visibility_Ashikhmin(info.NdotL,info.NdotV);
  95371. float sheenTerm=fresnel*distribution*visibility;
  95372. return sheenTerm*info.attenuation*info.NdotL*lightColor;
  95373. }
  95374. #endif
  95375. `;
  95376. ShaderStore.IncludesShadersStore[name$11] = shader$11;
  95377. var name$10 = "pbrIBLFunctions"
  95378. , shader$10 = `#if defined(REFLECTION) || defined(SS_REFRACTION)
  95379. float getLodFromAlphaG(float cubeMapDimensionPixels,float microsurfaceAverageSlope) {
  95380. float microsurfaceAverageSlopeTexels=cubeMapDimensionPixels*microsurfaceAverageSlope;
  95381. float lod=log2(microsurfaceAverageSlopeTexels);
  95382. return lod;
  95383. }
  95384. float getLinearLodFromRoughness(float cubeMapDimensionPixels,float roughness) {
  95385. float lod=log2(cubeMapDimensionPixels)*roughness;
  95386. return lod;
  95387. }
  95388. #endif
  95389. #if defined(ENVIRONMENTBRDF) && defined(RADIANCEOCCLUSION)
  95390. float environmentRadianceOcclusion(float ambientOcclusion,float NdotVUnclamped) {
  95391. float temp=NdotVUnclamped+ambientOcclusion;
  95392. return saturate(square(temp)-1.0+ambientOcclusion);
  95393. }
  95394. #endif
  95395. #if defined(ENVIRONMENTBRDF) && defined(HORIZONOCCLUSION)
  95396. float environmentHorizonOcclusion(vec3 view,vec3 normal,vec3 geometricNormal) {
  95397. vec3 reflection=reflect(view,normal);
  95398. float temp=saturate(1.0+1.1*dot(reflection,geometricNormal));
  95399. return square(temp);
  95400. }
  95401. #endif
  95402. #if defined(LODINREFLECTIONALPHA) || defined(SS_LODINREFRACTIONALPHA)
  95403. #define UNPACK_LOD(x) (1.0-x)*255.0
  95404. float getLodFromAlphaG(float cubeMapDimensionPixels,float alphaG,float NdotV) {
  95405. float microsurfaceAverageSlope=alphaG;
  95406. microsurfaceAverageSlope*=sqrt(abs(NdotV));
  95407. return getLodFromAlphaG(cubeMapDimensionPixels,microsurfaceAverageSlope);
  95408. }
  95409. #endif`;
  95410. ShaderStore.IncludesShadersStore[name$10] = shader$10;
  95411. var name$$ = "pbrBlockAlbedoOpacity"
  95412. , shader$$ = `struct albedoOpacityOutParams
  95413. {
  95414. vec3 surfaceAlbedo;
  95415. float alpha;
  95416. };
  95417. #define pbr_inline
  95418. void albedoOpacityBlock(
  95419. in vec4 vAlbedoColor,
  95420. #ifdef ALBEDO
  95421. in vec4 albedoTexture,
  95422. in vec2 albedoInfos,
  95423. #endif
  95424. #ifdef OPACITY
  95425. in vec4 opacityMap,
  95426. in vec2 vOpacityInfos,
  95427. #endif
  95428. #ifdef DETAIL
  95429. in vec4 detailColor,
  95430. in vec4 vDetailInfos,
  95431. #endif
  95432. out albedoOpacityOutParams outParams
  95433. )
  95434. {
  95435. vec3 surfaceAlbedo=vAlbedoColor.rgb;
  95436. float alpha=vAlbedoColor.a;
  95437. #ifdef ALBEDO
  95438. #if defined(ALPHAFROMALBEDO) || defined(ALPHATEST)
  95439. alpha*=albedoTexture.a;
  95440. #endif
  95441. #ifdef GAMMAALBEDO
  95442. surfaceAlbedo*=toLinearSpace(albedoTexture.rgb);
  95443. #else
  95444. surfaceAlbedo*=albedoTexture.rgb;
  95445. #endif
  95446. surfaceAlbedo*=albedoInfos.y;
  95447. #endif
  95448. #ifdef VERTEXCOLOR
  95449. surfaceAlbedo*=vColor.rgb;
  95450. #endif
  95451. #ifdef DETAIL
  95452. float detailAlbedo=2.0*mix(0.5,detailColor.r,vDetailInfos.y);
  95453. surfaceAlbedo.rgb=surfaceAlbedo.rgb*detailAlbedo*detailAlbedo;
  95454. #endif
  95455. #define CUSTOM_FRAGMENT_UPDATE_ALBEDO
  95456. #ifdef OPACITY
  95457. #ifdef OPACITYRGB
  95458. alpha=getLuminance(opacityMap.rgb);
  95459. #else
  95460. alpha*=opacityMap.a;
  95461. #endif
  95462. alpha*=vOpacityInfos.y;
  95463. #endif
  95464. #ifdef VERTEXALPHA
  95465. alpha*=vColor.a;
  95466. #endif
  95467. #if !defined(SS_LINKREFRACTIONTOTRANSPARENCY) && !defined(ALPHAFRESNEL)
  95468. #ifdef ALPHATEST
  95469. if (alpha<ALPHATESTVALUE)
  95470. discard;
  95471. #ifndef ALPHABLEND
  95472. alpha=1.0;
  95473. #endif
  95474. #endif
  95475. #endif
  95476. outParams.surfaceAlbedo=surfaceAlbedo;
  95477. outParams.alpha=alpha;
  95478. }
  95479. `;
  95480. ShaderStore.IncludesShadersStore[name$$] = shader$$;
  95481. var name$_ = "pbrBlockReflectivity"
  95482. , shader$_ = `struct reflectivityOutParams
  95483. {
  95484. float microSurface;
  95485. float roughness;
  95486. vec3 surfaceReflectivityColor;
  95487. #ifdef METALLICWORKFLOW
  95488. vec3 surfaceAlbedo;
  95489. #endif
  95490. #if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
  95491. vec3 ambientOcclusionColor;
  95492. #endif
  95493. #if DEBUGMODE>0
  95494. vec4 surfaceMetallicColorMap;
  95495. vec4 surfaceReflectivityColorMap;
  95496. vec2 metallicRoughness;
  95497. vec3 metallicF0;
  95498. #endif
  95499. };
  95500. #define pbr_inline
  95501. void reflectivityBlock(
  95502. in vec4 vReflectivityColor,
  95503. #ifdef METALLICWORKFLOW
  95504. in vec3 surfaceAlbedo,
  95505. in vec4 metallicReflectanceFactors,
  95506. #endif
  95507. #ifdef REFLECTIVITY
  95508. in vec3 reflectivityInfos,
  95509. in vec4 surfaceMetallicOrReflectivityColorMap,
  95510. #endif
  95511. #if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
  95512. in vec3 ambientOcclusionColorIn,
  95513. #endif
  95514. #ifdef MICROSURFACEMAP
  95515. in vec4 microSurfaceTexel,
  95516. #endif
  95517. #ifdef DETAIL
  95518. in vec4 detailColor,
  95519. in vec4 vDetailInfos,
  95520. #endif
  95521. out reflectivityOutParams outParams
  95522. )
  95523. {
  95524. float microSurface=vReflectivityColor.a;
  95525. vec3 surfaceReflectivityColor=vReflectivityColor.rgb;
  95526. #ifdef METALLICWORKFLOW
  95527. vec2 metallicRoughness=surfaceReflectivityColor.rg;
  95528. #ifdef REFLECTIVITY
  95529. #if DEBUGMODE>0
  95530. outParams.surfaceMetallicColorMap=surfaceMetallicOrReflectivityColorMap;
  95531. #endif
  95532. #ifdef AOSTOREINMETALMAPRED
  95533. vec3 aoStoreInMetalMap=vec3(surfaceMetallicOrReflectivityColorMap.r,surfaceMetallicOrReflectivityColorMap.r,surfaceMetallicOrReflectivityColorMap.r);
  95534. outParams.ambientOcclusionColor=mix(ambientOcclusionColorIn,aoStoreInMetalMap,reflectivityInfos.z);
  95535. #endif
  95536. #ifdef METALLNESSSTOREINMETALMAPBLUE
  95537. metallicRoughness.r*=surfaceMetallicOrReflectivityColorMap.b;
  95538. #else
  95539. metallicRoughness.r*=surfaceMetallicOrReflectivityColorMap.r;
  95540. #endif
  95541. #ifdef ROUGHNESSSTOREINMETALMAPALPHA
  95542. metallicRoughness.g*=surfaceMetallicOrReflectivityColorMap.a;
  95543. #else
  95544. #ifdef ROUGHNESSSTOREINMETALMAPGREEN
  95545. metallicRoughness.g*=surfaceMetallicOrReflectivityColorMap.g;
  95546. #endif
  95547. #endif
  95548. #endif
  95549. #ifdef DETAIL
  95550. float detailRoughness=mix(0.5,detailColor.b,vDetailInfos.w);
  95551. float loLerp=mix(0.,metallicRoughness.g,detailRoughness*2.);
  95552. float hiLerp=mix(metallicRoughness.g,1.,(detailRoughness-0.5)*2.);
  95553. metallicRoughness.g=mix(loLerp,hiLerp,step(detailRoughness,0.5));
  95554. #endif
  95555. #ifdef MICROSURFACEMAP
  95556. metallicRoughness.g*=microSurfaceTexel.r;
  95557. #endif
  95558. #if DEBUGMODE>0
  95559. outParams.metallicRoughness=metallicRoughness;
  95560. #endif
  95561. #define CUSTOM_FRAGMENT_UPDATE_METALLICROUGHNESS
  95562. microSurface=1.0-metallicRoughness.g;
  95563. vec3 baseColor=surfaceAlbedo;
  95564. #ifdef FROSTBITE_REFLECTANCE
  95565. outParams.surfaceAlbedo=baseColor.rgb*(1.0-metallicRoughness.r);
  95566. surfaceReflectivityColor=mix(0.16*reflectance*reflectance,baseColor,metallicRoughness.r);
  95567. #else
  95568. vec3 metallicF0=metallicReflectanceFactors.rgb;
  95569. #if DEBUGMODE>0
  95570. outParams.metallicF0=metallicF0;
  95571. #endif
  95572. outParams.surfaceAlbedo=mix(baseColor.rgb*(1.0-metallicF0),vec3(0.,0.,0.),metallicRoughness.r);
  95573. surfaceReflectivityColor=mix(metallicF0,baseColor,metallicRoughness.r);
  95574. #endif
  95575. #else
  95576. #ifdef REFLECTIVITY
  95577. surfaceReflectivityColor*=surfaceMetallicOrReflectivityColorMap.rgb;
  95578. #if DEBUGMODE>0
  95579. outParams.surfaceReflectivityColorMap=surfaceMetallicOrReflectivityColorMap;
  95580. #endif
  95581. #ifdef MICROSURFACEFROMREFLECTIVITYMAP
  95582. microSurface*=surfaceMetallicOrReflectivityColorMap.a;
  95583. microSurface*=reflectivityInfos.z;
  95584. #else
  95585. #ifdef MICROSURFACEAUTOMATIC
  95586. microSurface*=computeDefaultMicroSurface(microSurface,surfaceReflectivityColor);
  95587. #endif
  95588. #ifdef MICROSURFACEMAP
  95589. microSurface*=microSurfaceTexel.r;
  95590. #endif
  95591. #define CUSTOM_FRAGMENT_UPDATE_MICROSURFACE
  95592. #endif
  95593. #endif
  95594. #endif
  95595. microSurface=saturate(microSurface);
  95596. float roughness=1.-microSurface;
  95597. outParams.microSurface=microSurface;
  95598. outParams.roughness=roughness;
  95599. outParams.surfaceReflectivityColor=surfaceReflectivityColor;
  95600. }
  95601. `;
  95602. ShaderStore.IncludesShadersStore[name$_] = shader$_;
  95603. var name$Z = "pbrBlockAmbientOcclusion"
  95604. , shader$Z = `struct ambientOcclusionOutParams
  95605. {
  95606. vec3 ambientOcclusionColor;
  95607. #if DEBUGMODE>0
  95608. vec3 ambientOcclusionColorMap;
  95609. #endif
  95610. };
  95611. #define pbr_inline
  95612. void ambientOcclusionBlock(
  95613. #ifdef AMBIENT
  95614. in vec3 ambientOcclusionColorMap_,
  95615. in vec4 vAmbientInfos,
  95616. #endif
  95617. out ambientOcclusionOutParams outParams
  95618. )
  95619. {
  95620. vec3 ambientOcclusionColor=vec3(1.,1.,1.);
  95621. #ifdef AMBIENT
  95622. vec3 ambientOcclusionColorMap=ambientOcclusionColorMap_*vAmbientInfos.y;
  95623. #ifdef AMBIENTINGRAYSCALE
  95624. ambientOcclusionColorMap=vec3(ambientOcclusionColorMap.r,ambientOcclusionColorMap.r,ambientOcclusionColorMap.r);
  95625. #endif
  95626. ambientOcclusionColor=mix(ambientOcclusionColor,ambientOcclusionColorMap,vAmbientInfos.z);
  95627. #if DEBUGMODE>0
  95628. outParams.ambientOcclusionColorMap=ambientOcclusionColorMap;
  95629. #endif
  95630. #endif
  95631. outParams.ambientOcclusionColor=ambientOcclusionColor;
  95632. }
  95633. `;
  95634. ShaderStore.IncludesShadersStore[name$Z] = shader$Z;
  95635. var name$Y = "pbrBlockAlphaFresnel"
  95636. , shader$Y = `#ifdef ALPHAFRESNEL
  95637. #if defined(ALPHATEST) || defined(ALPHABLEND)
  95638. struct alphaFresnelOutParams
  95639. {
  95640. float alpha;
  95641. };
  95642. #define pbr_inline
  95643. void alphaFresnelBlock(
  95644. in vec3 normalW,
  95645. in vec3 viewDirectionW,
  95646. in float alpha,
  95647. in float microSurface,
  95648. out alphaFresnelOutParams outParams
  95649. )
  95650. {
  95651. float opacityPerceptual=alpha;
  95652. #ifdef LINEARALPHAFRESNEL
  95653. float opacity0=opacityPerceptual;
  95654. #else
  95655. float opacity0=opacityPerceptual*opacityPerceptual;
  95656. #endif
  95657. float opacity90=fresnelGrazingReflectance(opacity0);
  95658. vec3 normalForward=faceforward(normalW,-viewDirectionW,normalW);
  95659. outParams.alpha=getReflectanceFromAnalyticalBRDFLookup_Jones(saturate(dot(viewDirectionW,normalForward)),vec3(opacity0),vec3(opacity90),sqrt(microSurface)).x;
  95660. #ifdef ALPHATEST
  95661. if (outParams.alpha<ALPHATESTVALUE)
  95662. discard;
  95663. #ifndef ALPHABLEND
  95664. outParams.alpha=1.0;
  95665. #endif
  95666. #endif
  95667. }
  95668. #endif
  95669. #endif
  95670. `;
  95671. ShaderStore.IncludesShadersStore[name$Y] = shader$Y;
  95672. var name$X = "pbrBlockAnisotropic"
  95673. , shader$X = `#ifdef ANISOTROPIC
  95674. struct anisotropicOutParams
  95675. {
  95676. float anisotropy;
  95677. vec3 anisotropicTangent;
  95678. vec3 anisotropicBitangent;
  95679. vec3 anisotropicNormal;
  95680. #if DEBUGMODE>0
  95681. vec3 anisotropyMapData;
  95682. #endif
  95683. };
  95684. #define pbr_inline
  95685. void anisotropicBlock(
  95686. in vec3 vAnisotropy,
  95687. #ifdef ANISOTROPIC_TEXTURE
  95688. in vec3 anisotropyMapData,
  95689. #endif
  95690. in mat3 TBN,
  95691. in vec3 normalW,
  95692. in vec3 viewDirectionW,
  95693. out anisotropicOutParams outParams
  95694. )
  95695. {
  95696. float anisotropy=vAnisotropy.b;
  95697. vec3 anisotropyDirection=vec3(vAnisotropy.xy,0.);
  95698. #ifdef ANISOTROPIC_TEXTURE
  95699. anisotropy*=anisotropyMapData.b;
  95700. anisotropyDirection.rg*=anisotropyMapData.rg*2.0-1.0;
  95701. #if DEBUGMODE>0
  95702. outParams.anisotropyMapData=anisotropyMapData;
  95703. #endif
  95704. #endif
  95705. mat3 anisoTBN=mat3(normalize(TBN[0]),normalize(TBN[1]),normalize(TBN[2]));
  95706. vec3 anisotropicTangent=normalize(anisoTBN*anisotropyDirection);
  95707. vec3 anisotropicBitangent=normalize(cross(anisoTBN[2],anisotropicTangent));
  95708. outParams.anisotropy=anisotropy;
  95709. outParams.anisotropicTangent=anisotropicTangent;
  95710. outParams.anisotropicBitangent=anisotropicBitangent;
  95711. outParams.anisotropicNormal=getAnisotropicBentNormals(anisotropicTangent,anisotropicBitangent,normalW,viewDirectionW,anisotropy);
  95712. }
  95713. #endif
  95714. `;
  95715. ShaderStore.IncludesShadersStore[name$X] = shader$X;
  95716. var name$W = "pbrBlockReflection"
  95717. , shader$W = `#ifdef REFLECTION
  95718. struct reflectionOutParams
  95719. {
  95720. vec4 environmentRadiance;
  95721. vec3 environmentIrradiance;
  95722. #ifdef REFLECTIONMAP_3D
  95723. vec3 reflectionCoords;
  95724. #else
  95725. vec2 reflectionCoords;
  95726. #endif
  95727. #ifdef SS_TRANSLUCENCY
  95728. #ifdef USESPHERICALFROMREFLECTIONMAP
  95729. #if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
  95730. vec3 irradianceVector;
  95731. #endif
  95732. #endif
  95733. #endif
  95734. };
  95735. #define pbr_inline
  95736. void createReflectionCoords(
  95737. in vec3 vPositionW,
  95738. in vec3 normalW,
  95739. #ifdef ANISOTROPIC
  95740. in anisotropicOutParams anisotropicOut,
  95741. #endif
  95742. #ifdef REFLECTIONMAP_3D
  95743. out vec3 reflectionCoords
  95744. #else
  95745. out vec2 reflectionCoords
  95746. #endif
  95747. )
  95748. {
  95749. #ifdef ANISOTROPIC
  95750. vec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),anisotropicOut.anisotropicNormal);
  95751. #else
  95752. vec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);
  95753. #endif
  95754. #ifdef REFLECTIONMAP_OPPOSITEZ
  95755. reflectionVector.z*=-1.0;
  95756. #endif
  95757. #ifdef REFLECTIONMAP_3D
  95758. reflectionCoords=reflectionVector;
  95759. #else
  95760. reflectionCoords=reflectionVector.xy;
  95761. #ifdef REFLECTIONMAP_PROJECTION
  95762. reflectionCoords/=reflectionVector.z;
  95763. #endif
  95764. reflectionCoords.y=1.0-reflectionCoords.y;
  95765. #endif
  95766. }
  95767. #define pbr_inline
  95768. #define inline
  95769. void sampleReflectionTexture(
  95770. in float alphaG,
  95771. in vec3 vReflectionMicrosurfaceInfos,
  95772. in vec2 vReflectionInfos,
  95773. in vec3 vReflectionColor,
  95774. #if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
  95775. in float NdotVUnclamped,
  95776. #endif
  95777. #ifdef LINEARSPECULARREFLECTION
  95778. in float roughness,
  95779. #endif
  95780. #ifdef REFLECTIONMAP_3D
  95781. in samplerCube reflectionSampler,
  95782. const vec3 reflectionCoords,
  95783. #else
  95784. in sampler2D reflectionSampler,
  95785. const vec2 reflectionCoords,
  95786. #endif
  95787. #ifndef LODBASEDMICROSFURACE
  95788. #ifdef REFLECTIONMAP_3D
  95789. in samplerCube reflectionSamplerLow,
  95790. in samplerCube reflectionSamplerHigh,
  95791. #else
  95792. in sampler2D reflectionSamplerLow,
  95793. in sampler2D reflectionSamplerHigh,
  95794. #endif
  95795. #endif
  95796. #ifdef REALTIME_FILTERING
  95797. in vec2 vReflectionFilteringInfo,
  95798. #endif
  95799. out vec4 environmentRadiance
  95800. )
  95801. {
  95802. #if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
  95803. float reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);
  95804. #elif defined(LINEARSPECULARREFLECTION)
  95805. float reflectionLOD=getLinearLodFromRoughness(vReflectionMicrosurfaceInfos.x,roughness);
  95806. #else
  95807. float reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG);
  95808. #endif
  95809. #ifdef LODBASEDMICROSFURACE
  95810. reflectionLOD=reflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;
  95811. #ifdef LODINREFLECTIONALPHA
  95812. float automaticReflectionLOD=UNPACK_LOD(sampleReflection(reflectionSampler,reflectionCoords).a);
  95813. float requestedReflectionLOD=max(automaticReflectionLOD,reflectionLOD);
  95814. #else
  95815. float requestedReflectionLOD=reflectionLOD;
  95816. #endif
  95817. #ifdef REALTIME_FILTERING
  95818. environmentRadiance=vec4(radiance(alphaG,reflectionSampler,reflectionCoords,vReflectionFilteringInfo),1.0);
  95819. #else
  95820. environmentRadiance=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD);
  95821. #endif
  95822. #else
  95823. float lodReflectionNormalized=saturate(reflectionLOD/log2(vReflectionMicrosurfaceInfos.x));
  95824. float lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;
  95825. vec4 environmentMid=sampleReflection(reflectionSampler,reflectionCoords);
  95826. if (lodReflectionNormalizedDoubled<1.0){
  95827. environmentRadiance=mix(
  95828. sampleReflection(reflectionSamplerHigh,reflectionCoords),
  95829. environmentMid,
  95830. lodReflectionNormalizedDoubled
  95831. );
  95832. } else {
  95833. environmentRadiance=mix(
  95834. environmentMid,
  95835. sampleReflection(reflectionSamplerLow,reflectionCoords),
  95836. lodReflectionNormalizedDoubled-1.0
  95837. );
  95838. }
  95839. #endif
  95840. #ifdef RGBDREFLECTION
  95841. environmentRadiance.rgb=fromRGBD(environmentRadiance);
  95842. #endif
  95843. #ifdef GAMMAREFLECTION
  95844. environmentRadiance.rgb=toLinearSpace(environmentRadiance.rgb);
  95845. #endif
  95846. environmentRadiance.rgb*=vReflectionInfos.x;
  95847. environmentRadiance.rgb*=vReflectionColor.rgb;
  95848. }
  95849. #define pbr_inline
  95850. #define inline
  95851. void reflectionBlock(
  95852. in vec3 vPositionW,
  95853. in vec3 normalW,
  95854. in float alphaG,
  95855. in vec3 vReflectionMicrosurfaceInfos,
  95856. in vec2 vReflectionInfos,
  95857. in vec3 vReflectionColor,
  95858. #ifdef ANISOTROPIC
  95859. in anisotropicOutParams anisotropicOut,
  95860. #endif
  95861. #if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
  95862. in float NdotVUnclamped,
  95863. #endif
  95864. #ifdef LINEARSPECULARREFLECTION
  95865. in float roughness,
  95866. #endif
  95867. #ifdef REFLECTIONMAP_3D
  95868. in samplerCube reflectionSampler,
  95869. #else
  95870. in sampler2D reflectionSampler,
  95871. #endif
  95872. #if defined(NORMAL) && defined(USESPHERICALINVERTEX)
  95873. in vec3 vEnvironmentIrradiance,
  95874. #endif
  95875. #ifdef USESPHERICALFROMREFLECTIONMAP
  95876. #if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
  95877. in mat4 reflectionMatrix,
  95878. #endif
  95879. #endif
  95880. #ifdef USEIRRADIANCEMAP
  95881. #ifdef REFLECTIONMAP_3D
  95882. in samplerCube irradianceSampler,
  95883. #else
  95884. in sampler2D irradianceSampler,
  95885. #endif
  95886. #endif
  95887. #ifndef LODBASEDMICROSFURACE
  95888. #ifdef REFLECTIONMAP_3D
  95889. in samplerCube reflectionSamplerLow,
  95890. in samplerCube reflectionSamplerHigh,
  95891. #else
  95892. in sampler2D reflectionSamplerLow,
  95893. in sampler2D reflectionSamplerHigh,
  95894. #endif
  95895. #endif
  95896. #ifdef REALTIME_FILTERING
  95897. in vec2 vReflectionFilteringInfo,
  95898. #endif
  95899. out reflectionOutParams outParams
  95900. )
  95901. {
  95902. vec4 environmentRadiance=vec4(0.,0.,0.,0.);
  95903. #ifdef REFLECTIONMAP_3D
  95904. vec3 reflectionCoords=vec3(0.);
  95905. #else
  95906. vec2 reflectionCoords=vec2(0.);
  95907. #endif
  95908. createReflectionCoords(
  95909. vPositionW,
  95910. normalW,
  95911. #ifdef ANISOTROPIC
  95912. anisotropicOut,
  95913. #endif
  95914. reflectionCoords
  95915. );
  95916. sampleReflectionTexture(
  95917. alphaG,
  95918. vReflectionMicrosurfaceInfos,
  95919. vReflectionInfos,
  95920. vReflectionColor,
  95921. #if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
  95922. NdotVUnclamped,
  95923. #endif
  95924. #ifdef LINEARSPECULARREFLECTION
  95925. roughness,
  95926. #endif
  95927. #ifdef REFLECTIONMAP_3D
  95928. reflectionSampler,
  95929. reflectionCoords,
  95930. #else
  95931. reflectionSampler,
  95932. reflectionCoords,
  95933. #endif
  95934. #ifndef LODBASEDMICROSFURACE
  95935. reflectionSamplerLow,
  95936. reflectionSamplerHigh,
  95937. #endif
  95938. #ifdef REALTIME_FILTERING
  95939. vReflectionFilteringInfo,
  95940. #endif
  95941. environmentRadiance
  95942. );
  95943. vec3 environmentIrradiance=vec3(0.,0.,0.);
  95944. #ifdef USESPHERICALFROMREFLECTIONMAP
  95945. #if defined(NORMAL) && defined(USESPHERICALINVERTEX)
  95946. environmentIrradiance=vEnvironmentIrradiance;
  95947. #else
  95948. #ifdef ANISOTROPIC
  95949. vec3 irradianceVector=vec3(reflectionMatrix*vec4(anisotropicOut.anisotropicNormal,0)).xyz;
  95950. #else
  95951. vec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;
  95952. #endif
  95953. #ifdef REFLECTIONMAP_OPPOSITEZ
  95954. irradianceVector.z*=-1.0;
  95955. #endif
  95956. #ifdef INVERTCUBICMAP
  95957. irradianceVector.y*=-1.0;
  95958. #endif
  95959. #if defined(REALTIME_FILTERING)
  95960. environmentIrradiance=irradiance(reflectionSampler,irradianceVector,vReflectionFilteringInfo);
  95961. #else
  95962. environmentIrradiance=computeEnvironmentIrradiance(irradianceVector);
  95963. #endif
  95964. #ifdef SS_TRANSLUCENCY
  95965. outParams.irradianceVector=irradianceVector;
  95966. #endif
  95967. #endif
  95968. #elif defined(USEIRRADIANCEMAP)
  95969. vec4 environmentIrradiance4=sampleReflection(irradianceSampler,reflectionCoords);
  95970. environmentIrradiance=environmentIrradiance4.rgb;
  95971. #ifdef RGBDREFLECTION
  95972. environmentIrradiance.rgb=fromRGBD(environmentIrradiance4);
  95973. #endif
  95974. #ifdef GAMMAREFLECTION
  95975. environmentIrradiance.rgb=toLinearSpace(environmentIrradiance.rgb);
  95976. #endif
  95977. #endif
  95978. environmentIrradiance*=vReflectionColor.rgb;
  95979. outParams.environmentRadiance=environmentRadiance;
  95980. outParams.environmentIrradiance=environmentIrradiance;
  95981. outParams.reflectionCoords=reflectionCoords;
  95982. }
  95983. #endif
  95984. `;
  95985. ShaderStore.IncludesShadersStore[name$W] = shader$W;
  95986. var name$V = "pbrBlockSheen"
  95987. , shader$V = `#ifdef SHEEN
  95988. struct sheenOutParams
  95989. {
  95990. float sheenIntensity;
  95991. vec3 sheenColor;
  95992. float sheenRoughness;
  95993. #ifdef SHEEN_LINKWITHALBEDO
  95994. vec3 surfaceAlbedo;
  95995. #endif
  95996. #if defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
  95997. float sheenAlbedoScaling;
  95998. #endif
  95999. #if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
  96000. vec3 finalSheenRadianceScaled;
  96001. #endif
  96002. #if DEBUGMODE>0
  96003. vec4 sheenMapData;
  96004. vec3 sheenEnvironmentReflectance;
  96005. #endif
  96006. };
  96007. #define pbr_inline
  96008. #define inline
  96009. void sheenBlock(
  96010. in vec4 vSheenColor,
  96011. #ifdef SHEEN_ROUGHNESS
  96012. in float vSheenRoughness,
  96013. #if defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)
  96014. in vec4 sheenMapRoughnessData,
  96015. #endif
  96016. #endif
  96017. in float roughness,
  96018. #ifdef SHEEN_TEXTURE
  96019. in vec4 sheenMapData,
  96020. in float sheenMapLevel,
  96021. #endif
  96022. in float reflectance,
  96023. #ifdef SHEEN_LINKWITHALBEDO
  96024. in vec3 baseColor,
  96025. in vec3 surfaceAlbedo,
  96026. #endif
  96027. #ifdef ENVIRONMENTBRDF
  96028. in float NdotV,
  96029. in vec3 environmentBrdf,
  96030. #endif
  96031. #if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
  96032. in vec2 AARoughnessFactors,
  96033. in vec3 vReflectionMicrosurfaceInfos,
  96034. in vec2 vReflectionInfos,
  96035. in vec3 vReflectionColor,
  96036. in vec4 vLightingIntensity,
  96037. #ifdef REFLECTIONMAP_3D
  96038. in samplerCube reflectionSampler,
  96039. in vec3 reflectionCoords,
  96040. #else
  96041. in sampler2D reflectionSampler,
  96042. in vec2 reflectionCoords,
  96043. #endif
  96044. in float NdotVUnclamped,
  96045. #ifndef LODBASEDMICROSFURACE
  96046. #ifdef REFLECTIONMAP_3D
  96047. in samplerCube reflectionSamplerLow,
  96048. in samplerCube reflectionSamplerHigh,
  96049. #else
  96050. in sampler2D reflectionSamplerLow,
  96051. in sampler2D reflectionSamplerHigh,
  96052. #endif
  96053. #endif
  96054. #ifdef REALTIME_FILTERING
  96055. in vec2 vReflectionFilteringInfo,
  96056. #endif
  96057. #if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)
  96058. in float seo,
  96059. #endif
  96060. #if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
  96061. in float eho,
  96062. #endif
  96063. #endif
  96064. out sheenOutParams outParams
  96065. )
  96066. {
  96067. float sheenIntensity=vSheenColor.a;
  96068. #ifdef SHEEN_TEXTURE
  96069. #if DEBUGMODE>0
  96070. outParams.sheenMapData=sheenMapData;
  96071. #endif
  96072. #endif
  96073. #ifdef SHEEN_LINKWITHALBEDO
  96074. float sheenFactor=pow5(1.0-sheenIntensity);
  96075. vec3 sheenColor=baseColor.rgb*(1.0-sheenFactor);
  96076. float sheenRoughness=sheenIntensity;
  96077. outParams.surfaceAlbedo=surfaceAlbedo*sheenFactor;
  96078. #ifdef SHEEN_TEXTURE
  96079. sheenIntensity*=sheenMapData.a;
  96080. #endif
  96081. #else
  96082. vec3 sheenColor=vSheenColor.rgb;
  96083. #ifdef SHEEN_TEXTURE
  96084. #ifdef SHEEN_GAMMATEXTURE
  96085. sheenColor.rgb*=toLinearSpace(sheenMapData.rgb);
  96086. #else
  96087. sheenColor.rgb*=sheenMapData.rgb;
  96088. #endif
  96089. sheenColor.rgb*=sheenMapLevel;
  96090. #endif
  96091. #ifdef SHEEN_ROUGHNESS
  96092. float sheenRoughness=vSheenRoughness;
  96093. #ifdef SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE
  96094. #if defined(SHEEN_TEXTURE)
  96095. sheenRoughness*=sheenMapData.a;
  96096. #endif
  96097. #elif defined(SHEEN_TEXTURE_ROUGHNESS)
  96098. #ifdef SHEEN_TEXTURE_ROUGHNESS_IDENTICAL
  96099. sheenRoughness*=sheenMapData.a;
  96100. #else
  96101. sheenRoughness*=sheenMapRoughnessData.a;
  96102. #endif
  96103. #endif
  96104. #else
  96105. float sheenRoughness=roughness;
  96106. #ifdef SHEEN_TEXTURE
  96107. sheenIntensity*=sheenMapData.a;
  96108. #endif
  96109. #endif
  96110. #if !defined(SHEEN_ALBEDOSCALING)
  96111. sheenIntensity*=(1.-reflectance);
  96112. #endif
  96113. sheenColor*=sheenIntensity;
  96114. #endif
  96115. #ifdef ENVIRONMENTBRDF
  96116. #ifdef SHEEN_ROUGHNESS
  96117. vec3 environmentSheenBrdf=getBRDFLookup(NdotV,sheenRoughness);
  96118. #else
  96119. vec3 environmentSheenBrdf=environmentBrdf;
  96120. #endif
  96121. #endif
  96122. #if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
  96123. float sheenAlphaG=convertRoughnessToAverageSlope(sheenRoughness);
  96124. #ifdef SPECULARAA
  96125. sheenAlphaG+=AARoughnessFactors.y;
  96126. #endif
  96127. vec4 environmentSheenRadiance=vec4(0.,0.,0.,0.);
  96128. sampleReflectionTexture(
  96129. sheenAlphaG,
  96130. vReflectionMicrosurfaceInfos,
  96131. vReflectionInfos,
  96132. vReflectionColor,
  96133. #if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
  96134. NdotVUnclamped,
  96135. #endif
  96136. #ifdef LINEARSPECULARREFLECTION
  96137. sheenRoughness,
  96138. #endif
  96139. reflectionSampler,
  96140. reflectionCoords,
  96141. #ifndef LODBASEDMICROSFURACE
  96142. reflectionSamplerLow,
  96143. reflectionSamplerHigh,
  96144. #endif
  96145. #ifdef REALTIME_FILTERING
  96146. vReflectionFilteringInfo,
  96147. #endif
  96148. environmentSheenRadiance
  96149. );
  96150. vec3 sheenEnvironmentReflectance=getSheenReflectanceFromBRDFLookup(sheenColor,environmentSheenBrdf);
  96151. #if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)
  96152. sheenEnvironmentReflectance*=seo;
  96153. #endif
  96154. #if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
  96155. sheenEnvironmentReflectance*=eho;
  96156. #endif
  96157. #if DEBUGMODE>0
  96158. outParams.sheenEnvironmentReflectance=sheenEnvironmentReflectance;
  96159. #endif
  96160. outParams.finalSheenRadianceScaled=
  96161. environmentSheenRadiance.rgb *
  96162. sheenEnvironmentReflectance *
  96163. vLightingIntensity.z;
  96164. #endif
  96165. #if defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
  96166. outParams.sheenAlbedoScaling=1.0-sheenIntensity*max(max(sheenColor.r,sheenColor.g),sheenColor.b)*environmentSheenBrdf.b;
  96167. #endif
  96168. outParams.sheenIntensity=sheenIntensity;
  96169. outParams.sheenColor=sheenColor;
  96170. outParams.sheenRoughness=sheenRoughness;
  96171. }
  96172. #endif
  96173. `;
  96174. ShaderStore.IncludesShadersStore[name$V] = shader$V;
  96175. var name$U = "pbrBlockClearcoat"
  96176. , shader$U = `struct clearcoatOutParams
  96177. {
  96178. vec3 specularEnvironmentR0;
  96179. float conservationFactor;
  96180. vec3 clearCoatNormalW;
  96181. vec2 clearCoatAARoughnessFactors;
  96182. float clearCoatIntensity;
  96183. float clearCoatRoughness;
  96184. #ifdef REFLECTION
  96185. vec3 finalClearCoatRadianceScaled;
  96186. #endif
  96187. #ifdef CLEARCOAT_TINT
  96188. vec3 absorption;
  96189. float clearCoatNdotVRefract;
  96190. vec3 clearCoatColor;
  96191. float clearCoatThickness;
  96192. #endif
  96193. #if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
  96194. vec3 energyConservationFactorClearCoat;
  96195. #endif
  96196. #if DEBUGMODE>0
  96197. mat3 TBNClearCoat;
  96198. vec2 clearCoatMapData;
  96199. vec4 clearCoatTintMapData;
  96200. vec4 environmentClearCoatRadiance;
  96201. float clearCoatNdotV;
  96202. vec3 clearCoatEnvironmentReflectance;
  96203. #endif
  96204. };
  96205. #ifdef CLEARCOAT
  96206. #define pbr_inline
  96207. #define inline
  96208. void clearcoatBlock(
  96209. in vec3 vPositionW,
  96210. in vec3 geometricNormalW,
  96211. in vec3 viewDirectionW,
  96212. in vec2 vClearCoatParams,
  96213. #if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
  96214. in vec4 clearCoatMapRoughnessData,
  96215. #endif
  96216. in vec3 specularEnvironmentR0,
  96217. #ifdef CLEARCOAT_TEXTURE
  96218. in vec2 clearCoatMapData,
  96219. #endif
  96220. #ifdef CLEARCOAT_TINT
  96221. in vec4 vClearCoatTintParams,
  96222. in float clearCoatColorAtDistance,
  96223. in vec4 vClearCoatRefractionParams,
  96224. #ifdef CLEARCOAT_TINT_TEXTURE
  96225. in vec4 clearCoatTintMapData,
  96226. #endif
  96227. #endif
  96228. #ifdef CLEARCOAT_BUMP
  96229. in vec2 vClearCoatBumpInfos,
  96230. in vec4 clearCoatBumpMapData,
  96231. in vec2 vClearCoatBumpUV,
  96232. #if defined(TANGENT) && defined(NORMAL)
  96233. in mat3 vTBN,
  96234. #else
  96235. in vec2 vClearCoatTangentSpaceParams,
  96236. #endif
  96237. #ifdef OBJECTSPACE_NORMALMAP
  96238. in mat4 normalMatrix,
  96239. #endif
  96240. #endif
  96241. #if defined(FORCENORMALFORWARD) && defined(NORMAL)
  96242. in vec3 faceNormal,
  96243. #endif
  96244. #ifdef REFLECTION
  96245. in vec3 vReflectionMicrosurfaceInfos,
  96246. in vec2 vReflectionInfos,
  96247. in vec3 vReflectionColor,
  96248. in vec4 vLightingIntensity,
  96249. #ifdef REFLECTIONMAP_3D
  96250. in samplerCube reflectionSampler,
  96251. #else
  96252. in sampler2D reflectionSampler,
  96253. #endif
  96254. #ifndef LODBASEDMICROSFURACE
  96255. #ifdef REFLECTIONMAP_3D
  96256. in samplerCube reflectionSamplerLow,
  96257. in samplerCube reflectionSamplerHigh,
  96258. #else
  96259. in sampler2D reflectionSamplerLow,
  96260. in sampler2D reflectionSamplerHigh,
  96261. #endif
  96262. #endif
  96263. #ifdef REALTIME_FILTERING
  96264. in vec2 vReflectionFilteringInfo,
  96265. #endif
  96266. #endif
  96267. #if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
  96268. #ifdef RADIANCEOCCLUSION
  96269. in float ambientMonochrome,
  96270. #endif
  96271. #endif
  96272. #if defined(CLEARCOAT_BUMP) || defined(TWOSIDEDLIGHTING)
  96273. in float frontFacingMultiplier,
  96274. #endif
  96275. out clearcoatOutParams outParams
  96276. )
  96277. {
  96278. float clearCoatIntensity=vClearCoatParams.x;
  96279. float clearCoatRoughness=vClearCoatParams.y;
  96280. #ifdef CLEARCOAT_TEXTURE
  96281. clearCoatIntensity*=clearCoatMapData.x;
  96282. #ifdef CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE
  96283. clearCoatRoughness*=clearCoatMapData.y;
  96284. #endif
  96285. #if DEBUGMODE>0
  96286. outParams.clearCoatMapData=clearCoatMapData;
  96287. #endif
  96288. #endif
  96289. #if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
  96290. #ifdef CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL
  96291. clearCoatRoughness*=clearCoatMapData.y;
  96292. #else
  96293. clearCoatRoughness*=clearCoatMapRoughnessData.y;
  96294. #endif
  96295. #endif
  96296. outParams.clearCoatIntensity=clearCoatIntensity;
  96297. outParams.clearCoatRoughness=clearCoatRoughness;
  96298. #ifdef CLEARCOAT_TINT
  96299. vec3 clearCoatColor=vClearCoatTintParams.rgb;
  96300. float clearCoatThickness=vClearCoatTintParams.a;
  96301. #ifdef CLEARCOAT_TINT_TEXTURE
  96302. #ifdef CLEARCOAT_TINT_GAMMATEXTURE
  96303. clearCoatColor*=toLinearSpace(clearCoatTintMapData.rgb);
  96304. #else
  96305. clearCoatColor*=clearCoatTintMapData.rgb;
  96306. #endif
  96307. clearCoatThickness*=clearCoatTintMapData.a;
  96308. #if DEBUGMODE>0
  96309. outParams.clearCoatTintMapData=clearCoatTintMapData;
  96310. #endif
  96311. #endif
  96312. outParams.clearCoatColor=computeColorAtDistanceInMedia(clearCoatColor,clearCoatColorAtDistance);
  96313. outParams.clearCoatThickness=clearCoatThickness;
  96314. #endif
  96315. #ifdef CLEARCOAT_REMAP_F0
  96316. vec3 specularEnvironmentR0Updated=getR0RemappedForClearCoat(specularEnvironmentR0);
  96317. #else
  96318. vec3 specularEnvironmentR0Updated=specularEnvironmentR0;
  96319. #endif
  96320. outParams.specularEnvironmentR0=mix(specularEnvironmentR0,specularEnvironmentR0Updated,clearCoatIntensity);
  96321. vec3 clearCoatNormalW=geometricNormalW;
  96322. #ifdef CLEARCOAT_BUMP
  96323. #ifdef NORMALXYSCALE
  96324. float clearCoatNormalScale=1.0;
  96325. #else
  96326. float clearCoatNormalScale=vClearCoatBumpInfos.y;
  96327. #endif
  96328. #if defined(TANGENT) && defined(NORMAL)
  96329. mat3 TBNClearCoat=vTBN;
  96330. #else
  96331. vec2 TBNClearCoatUV=vClearCoatBumpUV*frontFacingMultiplier;
  96332. mat3 TBNClearCoat=cotangent_frame(clearCoatNormalW*clearCoatNormalScale,vPositionW,TBNClearCoatUV,vClearCoatTangentSpaceParams);
  96333. #endif
  96334. #if DEBUGMODE>0
  96335. outParams.TBNClearCoat=TBNClearCoat;
  96336. #endif
  96337. #ifdef OBJECTSPACE_NORMALMAP
  96338. clearCoatNormalW=normalize(clearCoatBumpMapData.xyz*2.0-1.0);
  96339. clearCoatNormalW=normalize(mat3(normalMatrix)*clearCoatNormalW);
  96340. #else
  96341. clearCoatNormalW=perturbNormal(TBNClearCoat,clearCoatBumpMapData.xyz,vClearCoatBumpInfos.y);
  96342. #endif
  96343. #endif
  96344. #if defined(FORCENORMALFORWARD) && defined(NORMAL)
  96345. clearCoatNormalW*=sign(dot(clearCoatNormalW,faceNormal));
  96346. #endif
  96347. #if defined(TWOSIDEDLIGHTING) && defined(NORMAL)
  96348. clearCoatNormalW=clearCoatNormalW*frontFacingMultiplier;
  96349. #endif
  96350. outParams.clearCoatNormalW=clearCoatNormalW;
  96351. outParams.clearCoatAARoughnessFactors=getAARoughnessFactors(clearCoatNormalW.xyz);
  96352. float clearCoatNdotVUnclamped=dot(clearCoatNormalW,viewDirectionW);
  96353. float clearCoatNdotV=absEps(clearCoatNdotVUnclamped);
  96354. #if DEBUGMODE>0
  96355. outParams.clearCoatNdotV=clearCoatNdotV;
  96356. #endif
  96357. #ifdef CLEARCOAT_TINT
  96358. vec3 clearCoatVRefract=-refract(vPositionW,clearCoatNormalW,vClearCoatRefractionParams.y);
  96359. outParams.clearCoatNdotVRefract=absEps(dot(clearCoatNormalW,clearCoatVRefract));
  96360. #endif
  96361. #if defined(ENVIRONMENTBRDF) && (!defined(REFLECTIONMAP_SKYBOX) || defined(MS_BRDF_ENERGY_CONSERVATION))
  96362. vec3 environmentClearCoatBrdf=getBRDFLookup(clearCoatNdotV,clearCoatRoughness);
  96363. #endif
  96364. #if defined(REFLECTION)
  96365. float clearCoatAlphaG=convertRoughnessToAverageSlope(clearCoatRoughness);
  96366. #ifdef SPECULARAA
  96367. clearCoatAlphaG+=outParams.clearCoatAARoughnessFactors.y;
  96368. #endif
  96369. vec4 environmentClearCoatRadiance=vec4(0.,0.,0.,0.);
  96370. vec3 clearCoatReflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),clearCoatNormalW);
  96371. #ifdef REFLECTIONMAP_OPPOSITEZ
  96372. clearCoatReflectionVector.z*=-1.0;
  96373. #endif
  96374. #ifdef REFLECTIONMAP_3D
  96375. vec3 clearCoatReflectionCoords=clearCoatReflectionVector;
  96376. #else
  96377. vec2 clearCoatReflectionCoords=clearCoatReflectionVector.xy;
  96378. #ifdef REFLECTIONMAP_PROJECTION
  96379. clearCoatReflectionCoords/=clearCoatReflectionVector.z;
  96380. #endif
  96381. clearCoatReflectionCoords.y=1.0-clearCoatReflectionCoords.y;
  96382. #endif
  96383. sampleReflectionTexture(
  96384. clearCoatAlphaG,
  96385. vReflectionMicrosurfaceInfos,
  96386. vReflectionInfos,
  96387. vReflectionColor,
  96388. #if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
  96389. clearCoatNdotVUnclamped,
  96390. #endif
  96391. #ifdef LINEARSPECULARREFLECTION
  96392. clearCoatRoughness,
  96393. #endif
  96394. reflectionSampler,
  96395. clearCoatReflectionCoords,
  96396. #ifndef LODBASEDMICROSFURACE
  96397. reflectionSamplerLow,
  96398. reflectionSamplerHigh,
  96399. #endif
  96400. #ifdef REALTIME_FILTERING
  96401. vReflectionFilteringInfo,
  96402. #endif
  96403. environmentClearCoatRadiance
  96404. );
  96405. #if DEBUGMODE>0
  96406. outParams.environmentClearCoatRadiance=environmentClearCoatRadiance;
  96407. #endif
  96408. #if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
  96409. vec3 clearCoatEnvironmentReflectance=getReflectanceFromBRDFLookup(vec3(vClearCoatRefractionParams.x),environmentClearCoatBrdf);
  96410. #ifdef RADIANCEOCCLUSION
  96411. float clearCoatSeo=environmentRadianceOcclusion(ambientMonochrome,clearCoatNdotVUnclamped);
  96412. clearCoatEnvironmentReflectance*=clearCoatSeo;
  96413. #endif
  96414. #ifdef HORIZONOCCLUSION
  96415. #ifdef BUMP
  96416. #ifdef REFLECTIONMAP_3D
  96417. float clearCoatEho=environmentHorizonOcclusion(-viewDirectionW,clearCoatNormalW,geometricNormalW);
  96418. clearCoatEnvironmentReflectance*=clearCoatEho;
  96419. #endif
  96420. #endif
  96421. #endif
  96422. #else
  96423. vec3 clearCoatEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(clearCoatNdotV,vec3(1.),vec3(1.),sqrt(1.-clearCoatRoughness));
  96424. #endif
  96425. clearCoatEnvironmentReflectance*=clearCoatIntensity;
  96426. #if DEBUGMODE>0
  96427. outParams.clearCoatEnvironmentReflectance=clearCoatEnvironmentReflectance;
  96428. #endif
  96429. outParams.finalClearCoatRadianceScaled=
  96430. environmentClearCoatRadiance.rgb *
  96431. clearCoatEnvironmentReflectance *
  96432. vLightingIntensity.z;
  96433. #endif
  96434. #if defined(CLEARCOAT_TINT)
  96435. outParams.absorption=computeClearCoatAbsorption(outParams.clearCoatNdotVRefract,outParams.clearCoatNdotVRefract,outParams.clearCoatColor,clearCoatThickness,clearCoatIntensity);
  96436. #endif
  96437. float fresnelIBLClearCoat=fresnelSchlickGGX(clearCoatNdotV,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);
  96438. fresnelIBLClearCoat*=clearCoatIntensity;
  96439. outParams.conservationFactor=(1.-fresnelIBLClearCoat);
  96440. #if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
  96441. outParams.energyConservationFactorClearCoat=getEnergyConservationFactor(outParams.specularEnvironmentR0,environmentClearCoatBrdf);
  96442. #endif
  96443. }
  96444. #endif
  96445. `;
  96446. ShaderStore.IncludesShadersStore[name$U] = shader$U;
  96447. var name$T = "pbrBlockSubSurface"
  96448. , shader$T = `struct subSurfaceOutParams
  96449. {
  96450. vec3 specularEnvironmentReflectance;
  96451. #ifdef SS_REFRACTION
  96452. vec3 finalRefraction;
  96453. vec3 surfaceAlbedo;
  96454. #ifdef SS_LINKREFRACTIONTOTRANSPARENCY
  96455. float alpha;
  96456. #endif
  96457. #ifdef REFLECTION
  96458. float refractionFactorForIrradiance;
  96459. #endif
  96460. #endif
  96461. #ifdef SS_TRANSLUCENCY
  96462. vec3 transmittance;
  96463. float translucencyIntensity;
  96464. #ifdef REFLECTION
  96465. vec3 refractionIrradiance;
  96466. #endif
  96467. #endif
  96468. #if DEBUGMODE>0
  96469. vec4 thicknessMap;
  96470. vec4 environmentRefraction;
  96471. vec3 refractionTransmittance;
  96472. #endif
  96473. };
  96474. #ifdef SUBSURFACE
  96475. #define pbr_inline
  96476. #define inline
  96477. void subSurfaceBlock(
  96478. in vec3 vSubSurfaceIntensity,
  96479. in vec2 vThicknessParam,
  96480. in vec4 vTintColor,
  96481. in vec3 normalW,
  96482. in vec3 specularEnvironmentReflectance,
  96483. #ifdef SS_THICKNESSANDMASK_TEXTURE
  96484. in vec4 thicknessMap,
  96485. #endif
  96486. #ifdef SS_REFRACTIONINTENSITY_TEXTURE
  96487. in vec4 refractionIntensityMap,
  96488. #endif
  96489. #ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
  96490. in vec4 translucencyIntensityMap,
  96491. #endif
  96492. #ifdef REFLECTION
  96493. #ifdef SS_TRANSLUCENCY
  96494. in mat4 reflectionMatrix,
  96495. #ifdef USESPHERICALFROMREFLECTIONMAP
  96496. #if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
  96497. in vec3 irradianceVector_,
  96498. #endif
  96499. #if defined(REALTIME_FILTERING)
  96500. in samplerCube reflectionSampler,
  96501. in vec2 vReflectionFilteringInfo,
  96502. #endif
  96503. #endif
  96504. #ifdef USEIRRADIANCEMAP
  96505. #ifdef REFLECTIONMAP_3D
  96506. in samplerCube irradianceSampler,
  96507. #else
  96508. in sampler2D irradianceSampler,
  96509. #endif
  96510. #endif
  96511. #endif
  96512. #endif
  96513. #if defined(SS_REFRACTION) || defined(SS_TRANSLUCENCY)
  96514. in vec3 surfaceAlbedo,
  96515. #endif
  96516. #ifdef SS_REFRACTION
  96517. in vec3 vPositionW,
  96518. in vec3 viewDirectionW,
  96519. in mat4 view,
  96520. in vec4 vRefractionInfos,
  96521. in mat4 refractionMatrix,
  96522. in vec4 vRefractionMicrosurfaceInfos,
  96523. in vec4 vLightingIntensity,
  96524. #ifdef SS_LINKREFRACTIONTOTRANSPARENCY
  96525. in float alpha,
  96526. #endif
  96527. #ifdef SS_LODINREFRACTIONALPHA
  96528. in float NdotVUnclamped,
  96529. #endif
  96530. #ifdef SS_LINEARSPECULARREFRACTION
  96531. in float roughness,
  96532. #endif
  96533. in float alphaG,
  96534. #ifdef SS_REFRACTIONMAP_3D
  96535. in samplerCube refractionSampler,
  96536. #ifndef LODBASEDMICROSFURACE
  96537. in samplerCube refractionSamplerLow,
  96538. in samplerCube refractionSamplerHigh,
  96539. #endif
  96540. #else
  96541. in sampler2D refractionSampler,
  96542. #ifndef LODBASEDMICROSFURACE
  96543. in sampler2D refractionSamplerLow,
  96544. in sampler2D refractionSamplerHigh,
  96545. #endif
  96546. #endif
  96547. #ifdef ANISOTROPIC
  96548. in anisotropicOutParams anisotropicOut,
  96549. #endif
  96550. #ifdef REALTIME_FILTERING
  96551. in vec2 vRefractionFilteringInfo,
  96552. #endif
  96553. #ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
  96554. in vec3 refractionPosition,
  96555. in vec3 refractionSize,
  96556. #endif
  96557. #endif
  96558. #ifdef SS_TRANSLUCENCY
  96559. in vec3 vDiffusionDistance,
  96560. #endif
  96561. out subSurfaceOutParams outParams
  96562. )
  96563. {
  96564. outParams.specularEnvironmentReflectance=specularEnvironmentReflectance;
  96565. #ifdef SS_REFRACTION
  96566. float refractionIntensity=vSubSurfaceIntensity.x;
  96567. #ifdef SS_LINKREFRACTIONTOTRANSPARENCY
  96568. refractionIntensity*=(1.0-alpha);
  96569. outParams.alpha=1.0;
  96570. #endif
  96571. #endif
  96572. #ifdef SS_TRANSLUCENCY
  96573. float translucencyIntensity=vSubSurfaceIntensity.y;
  96574. #endif
  96575. #ifdef SS_THICKNESSANDMASK_TEXTURE
  96576. #if defined(SS_USE_GLTF_TEXTURES)
  96577. float thickness=thicknessMap.g*vThicknessParam.y+vThicknessParam.x;
  96578. #else
  96579. float thickness=thicknessMap.r*vThicknessParam.y+vThicknessParam.x;
  96580. #endif
  96581. #if DEBUGMODE>0
  96582. outParams.thicknessMap=thicknessMap;
  96583. #endif
  96584. #ifdef SS_MASK_FROM_THICKNESS_TEXTURE
  96585. #if defined(SS_REFRACTION) && defined(SS_REFRACTION_USE_INTENSITY_FROM_TEXTURE)
  96586. #if defined(SS_USE_GLTF_TEXTURES)
  96587. refractionIntensity*=thicknessMap.r;
  96588. #else
  96589. refractionIntensity*=thicknessMap.g;
  96590. #endif
  96591. #endif
  96592. #if defined(SS_TRANSLUCENCY) && defined(SS_TRANSLUCENCY_USE_INTENSITY_FROM_TEXTURE)
  96593. translucencyIntensity*=thicknessMap.b;
  96594. #endif
  96595. #endif
  96596. #else
  96597. float thickness=vThicknessParam.y;
  96598. #endif
  96599. #ifdef SS_REFRACTIONINTENSITY_TEXTURE
  96600. #ifdef SS_USE_GLTF_TEXTURES
  96601. refractionIntensity*=refractionIntensityMap.r;
  96602. #else
  96603. refractionIntensity*=refractionIntensityMap.g;
  96604. #endif
  96605. #endif
  96606. #ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
  96607. translucencyIntensity*=translucencyIntensityMap.b;
  96608. #endif
  96609. #ifdef SS_TRANSLUCENCY
  96610. thickness=maxEps(thickness);
  96611. vec3 transmittance=transmittanceBRDF_Burley(vTintColor.rgb,vDiffusionDistance,thickness);
  96612. transmittance*=translucencyIntensity;
  96613. outParams.transmittance=transmittance;
  96614. outParams.translucencyIntensity=translucencyIntensity;
  96615. #endif
  96616. #ifdef SS_REFRACTION
  96617. vec4 environmentRefraction=vec4(0.,0.,0.,0.);
  96618. #ifdef ANISOTROPIC
  96619. vec3 refractionVector=refract(-viewDirectionW,anisotropicOut.anisotropicNormal,vRefractionInfos.y);
  96620. #else
  96621. vec3 refractionVector=refract(-viewDirectionW,normalW,vRefractionInfos.y);
  96622. #endif
  96623. #ifdef SS_REFRACTIONMAP_OPPOSITEZ
  96624. refractionVector.z*=-1.0;
  96625. #endif
  96626. #ifdef SS_REFRACTIONMAP_3D
  96627. #ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
  96628. refractionVector=parallaxCorrectNormal(vPositionW,refractionVector,refractionSize,refractionPosition);
  96629. #endif
  96630. refractionVector.y=refractionVector.y*vRefractionInfos.w;
  96631. vec3 refractionCoords=refractionVector;
  96632. refractionCoords=vec3(refractionMatrix*vec4(refractionCoords,0));
  96633. #else
  96634. #ifdef SS_USE_THICKNESS_AS_DEPTH
  96635. vec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*thickness,1.0)));
  96636. #else
  96637. vec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));
  96638. #endif
  96639. vec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;
  96640. refractionCoords.y=1.0-refractionCoords.y;
  96641. #endif
  96642. #ifdef SS_HAS_THICKNESS
  96643. float ior=vRefractionInfos.y;
  96644. #else
  96645. float ior=vRefractionMicrosurfaceInfos.w;
  96646. #endif
  96647. #ifdef SS_LODINREFRACTIONALPHA
  96648. float refractionAlphaG=alphaG;
  96649. refractionAlphaG=mix(alphaG,0.0,clamp(ior*3.0-2.0,0.0,1.0));
  96650. float refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,refractionAlphaG,NdotVUnclamped);
  96651. #elif defined(SS_LINEARSPECULARREFRACTION)
  96652. float refractionRoughness=alphaG;
  96653. refractionRoughness=mix(alphaG,0.0,clamp(ior*3.0-2.0,0.0,1.0));
  96654. float refractionLOD=getLinearLodFromRoughness(vRefractionMicrosurfaceInfos.x,refractionRoughness);
  96655. #else
  96656. float refractionAlphaG=alphaG;
  96657. refractionAlphaG=mix(alphaG,0.0,clamp(ior*3.0-2.0,0.0,1.0));
  96658. float refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,refractionAlphaG);
  96659. #endif
  96660. #ifdef LODBASEDMICROSFURACE
  96661. refractionLOD=refractionLOD*vRefractionMicrosurfaceInfos.y+vRefractionMicrosurfaceInfos.z;
  96662. #ifdef SS_LODINREFRACTIONALPHA
  96663. float automaticRefractionLOD=UNPACK_LOD(sampleRefraction(refractionSampler,refractionCoords).a);
  96664. float requestedRefractionLOD=max(automaticRefractionLOD,refractionLOD);
  96665. #else
  96666. float requestedRefractionLOD=refractionLOD;
  96667. #endif
  96668. #ifdef REALTIME_FILTERING
  96669. environmentRefraction=vec4(radiance(alphaG,refractionSampler,refractionCoords,vRefractionFilteringInfo),1.0);
  96670. #else
  96671. environmentRefraction=sampleRefractionLod(refractionSampler,refractionCoords,requestedRefractionLOD);
  96672. #endif
  96673. #else
  96674. float lodRefractionNormalized=saturate(refractionLOD/log2(vRefractionMicrosurfaceInfos.x));
  96675. float lodRefractionNormalizedDoubled=lodRefractionNormalized*2.0;
  96676. vec4 environmentRefractionMid=sampleRefraction(refractionSampler,refractionCoords);
  96677. if (lodRefractionNormalizedDoubled<1.0){
  96678. environmentRefraction=mix(
  96679. sampleRefraction(refractionSamplerHigh,refractionCoords),
  96680. environmentRefractionMid,
  96681. lodRefractionNormalizedDoubled
  96682. );
  96683. } else {
  96684. environmentRefraction=mix(
  96685. environmentRefractionMid,
  96686. sampleRefraction(refractionSamplerLow,refractionCoords),
  96687. lodRefractionNormalizedDoubled-1.0
  96688. );
  96689. }
  96690. #endif
  96691. #ifdef SS_RGBDREFRACTION
  96692. environmentRefraction.rgb=fromRGBD(environmentRefraction);
  96693. #endif
  96694. #ifdef SS_GAMMAREFRACTION
  96695. environmentRefraction.rgb=toLinearSpace(environmentRefraction.rgb);
  96696. #endif
  96697. environmentRefraction.rgb*=vRefractionInfos.x;
  96698. #endif
  96699. #ifdef SS_REFRACTION
  96700. vec3 refractionTransmittance=vec3(refractionIntensity);
  96701. #ifdef SS_THICKNESSANDMASK_TEXTURE
  96702. vec3 volumeAlbedo=computeColorAtDistanceInMedia(vTintColor.rgb,vTintColor.w);
  96703. refractionTransmittance*=cocaLambert(volumeAlbedo,thickness);
  96704. #elif defined(SS_LINKREFRACTIONTOTRANSPARENCY)
  96705. float maxChannel=max(max(surfaceAlbedo.r,surfaceAlbedo.g),surfaceAlbedo.b);
  96706. vec3 volumeAlbedo=saturate(maxChannel*surfaceAlbedo);
  96707. environmentRefraction.rgb*=volumeAlbedo;
  96708. #else
  96709. vec3 volumeAlbedo=computeColorAtDistanceInMedia(vTintColor.rgb,vTintColor.w);
  96710. refractionTransmittance*=cocaLambert(volumeAlbedo,vThicknessParam.y);
  96711. #endif
  96712. #ifdef SS_ALBEDOFORREFRACTIONTINT
  96713. environmentRefraction.rgb*=surfaceAlbedo.rgb;
  96714. #endif
  96715. outParams.surfaceAlbedo=surfaceAlbedo*(1.-refractionIntensity);
  96716. #ifdef REFLECTION
  96717. outParams.refractionFactorForIrradiance=(1.-refractionIntensity);
  96718. #endif
  96719. #ifdef UNUSED_MULTIPLEBOUNCES
  96720. vec3 bounceSpecularEnvironmentReflectance=(2.0*specularEnvironmentReflectance)/(1.0+specularEnvironmentReflectance);
  96721. outParams.specularEnvironmentReflectance=mix(bounceSpecularEnvironmentReflectance,specularEnvironmentReflectance,refractionIntensity);
  96722. #endif
  96723. refractionTransmittance*=1.0-outParams.specularEnvironmentReflectance;
  96724. #if DEBUGMODE>0
  96725. outParams.refractionTransmittance=refractionTransmittance;
  96726. #endif
  96727. outParams.finalRefraction=environmentRefraction.rgb*refractionTransmittance*vLightingIntensity.z;
  96728. #if DEBUGMODE>0
  96729. outParams.environmentRefraction=environmentRefraction;
  96730. #endif
  96731. #endif
  96732. #if defined(REFLECTION) && defined(SS_TRANSLUCENCY)
  96733. #if defined(NORMAL) && defined(USESPHERICALINVERTEX) || !defined(USESPHERICALFROMREFLECTIONMAP)
  96734. vec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;
  96735. #ifdef REFLECTIONMAP_OPPOSITEZ
  96736. irradianceVector.z*=-1.0;
  96737. #endif
  96738. #ifdef INVERTCUBICMAP
  96739. irradianceVector.y*=-1.0;
  96740. #endif
  96741. #else
  96742. vec3 irradianceVector=irradianceVector_;
  96743. #endif
  96744. #if defined(USESPHERICALFROMREFLECTIONMAP)
  96745. #if defined(REALTIME_FILTERING)
  96746. vec3 refractionIrradiance=irradiance(reflectionSampler,-irradianceVector,vReflectionFilteringInfo);
  96747. #else
  96748. vec3 refractionIrradiance=computeEnvironmentIrradiance(-irradianceVector);
  96749. #endif
  96750. #elif defined(USEIRRADIANCEMAP)
  96751. #ifdef REFLECTIONMAP_3D
  96752. vec3 irradianceCoords=irradianceVector;
  96753. #else
  96754. vec2 irradianceCoords=irradianceVector.xy;
  96755. #ifdef REFLECTIONMAP_PROJECTION
  96756. irradianceCoords/=irradianceVector.z;
  96757. #endif
  96758. irradianceCoords.y=1.0-irradianceCoords.y;
  96759. #endif
  96760. vec4 refractionIrradiance=sampleReflection(irradianceSampler,-irradianceCoords);
  96761. #ifdef RGBDREFLECTION
  96762. refractionIrradiance.rgb=fromRGBD(refractionIrradiance);
  96763. #endif
  96764. #ifdef GAMMAREFLECTION
  96765. refractionIrradiance.rgb=toLinearSpace(refractionIrradiance.rgb);
  96766. #endif
  96767. #else
  96768. vec4 refractionIrradiance=vec4(0.);
  96769. #endif
  96770. refractionIrradiance.rgb*=transmittance;
  96771. #ifdef SS_ALBEDOFORTRANSLUCENCYTINT
  96772. refractionIrradiance.rgb*=surfaceAlbedo.rgb;
  96773. #endif
  96774. outParams.refractionIrradiance=refractionIrradiance.rgb;
  96775. #endif
  96776. }
  96777. #endif
  96778. `;
  96779. ShaderStore.IncludesShadersStore[name$T] = shader$T;
  96780. var name$S = "pbrBlockNormalGeometric"
  96781. , shader$S = `vec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);
  96782. #ifdef NORMAL
  96783. vec3 normalW=normalize(vNormalW);
  96784. #else
  96785. vec3 normalW=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;
  96786. #endif
  96787. vec3 geometricNormalW=normalW;
  96788. #if defined(TWOSIDEDLIGHTING) && defined(NORMAL)
  96789. geometricNormalW=gl_FrontFacing ? geometricNormalW : -geometricNormalW;
  96790. #endif
  96791. `;
  96792. ShaderStore.IncludesShadersStore[name$S] = shader$S;
  96793. var name$R = "pbrBlockNormalFinal"
  96794. , shader$R = `#if defined(FORCENORMALFORWARD) && defined(NORMAL)
  96795. vec3 faceNormal=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;
  96796. #if defined(TWOSIDEDLIGHTING)
  96797. faceNormal=gl_FrontFacing ? faceNormal : -faceNormal;
  96798. #endif
  96799. normalW*=sign(dot(normalW,faceNormal));
  96800. #endif
  96801. #if defined(TWOSIDEDLIGHTING) && defined(NORMAL)
  96802. normalW=gl_FrontFacing ? normalW : -normalW;
  96803. #endif
  96804. `;
  96805. ShaderStore.IncludesShadersStore[name$R] = shader$R;
  96806. var name$Q = "pbrBlockLightmapInit"
  96807. , shader$Q = `#ifdef LIGHTMAP
  96808. vec4 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset);
  96809. #ifdef RGBDLIGHTMAP
  96810. lightmapColor.rgb=fromRGBD(lightmapColor);
  96811. #endif
  96812. #ifdef GAMMALIGHTMAP
  96813. lightmapColor.rgb=toLinearSpace(lightmapColor.rgb);
  96814. #endif
  96815. lightmapColor.rgb*=vLightmapInfos.y;
  96816. #endif
  96817. `;
  96818. ShaderStore.IncludesShadersStore[name$Q] = shader$Q;
  96819. var name$P = "pbrBlockGeometryInfo"
  96820. , shader$P = `float NdotVUnclamped=dot(normalW,viewDirectionW);
  96821. float NdotV=absEps(NdotVUnclamped);
  96822. float alphaG=convertRoughnessToAverageSlope(roughness);
  96823. vec2 AARoughnessFactors=getAARoughnessFactors(normalW.xyz);
  96824. #ifdef SPECULARAA
  96825. alphaG+=AARoughnessFactors.y;
  96826. #endif
  96827. #if defined(ENVIRONMENTBRDF)
  96828. vec3 environmentBrdf=getBRDFLookup(NdotV,roughness);
  96829. #endif
  96830. #if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
  96831. #ifdef RADIANCEOCCLUSION
  96832. #ifdef AMBIENTINGRAYSCALE
  96833. float ambientMonochrome=aoOut.ambientOcclusionColor.r;
  96834. #else
  96835. float ambientMonochrome=getLuminance(aoOut.ambientOcclusionColor);
  96836. #endif
  96837. float seo=environmentRadianceOcclusion(ambientMonochrome,NdotVUnclamped);
  96838. #endif
  96839. #ifdef HORIZONOCCLUSION
  96840. #ifdef BUMP
  96841. #ifdef REFLECTIONMAP_3D
  96842. float eho=environmentHorizonOcclusion(-viewDirectionW,normalW,geometricNormalW);
  96843. #endif
  96844. #endif
  96845. #endif
  96846. #endif
  96847. `;
  96848. ShaderStore.IncludesShadersStore[name$P] = shader$P;
  96849. var name$O = "pbrBlockReflectance0"
  96850. , shader$O = `float reflectance=max(max(reflectivityOut.surfaceReflectivityColor.r,reflectivityOut.surfaceReflectivityColor.g),reflectivityOut.surfaceReflectivityColor.b);
  96851. vec3 specularEnvironmentR0=reflectivityOut.surfaceReflectivityColor.rgb;
  96852. #ifdef METALLICWORKFLOW
  96853. vec3 specularEnvironmentR90=vec3(metallicReflectanceFactors.a);
  96854. #else
  96855. vec3 specularEnvironmentR90=vec3(1.0,1.0,1.0);
  96856. #endif
  96857. #ifdef ALPHAFRESNEL
  96858. float reflectance90=fresnelGrazingReflectance(reflectance);
  96859. specularEnvironmentR90=specularEnvironmentR90*reflectance90;
  96860. #endif
  96861. `;
  96862. ShaderStore.IncludesShadersStore[name$O] = shader$O;
  96863. var name$N = "pbrBlockReflectance"
  96864. , shader$N = `#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
  96865. vec3 specularEnvironmentReflectance=getReflectanceFromBRDFLookup(clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,environmentBrdf);
  96866. #ifdef RADIANCEOCCLUSION
  96867. specularEnvironmentReflectance*=seo;
  96868. #endif
  96869. #ifdef HORIZONOCCLUSION
  96870. #ifdef BUMP
  96871. #ifdef REFLECTIONMAP_3D
  96872. specularEnvironmentReflectance*=eho;
  96873. #endif
  96874. #endif
  96875. #endif
  96876. #else
  96877. vec3 specularEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(NdotV,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,sqrt(microSurface));
  96878. #endif
  96879. #ifdef CLEARCOAT
  96880. specularEnvironmentReflectance*=clearcoatOut.conservationFactor;
  96881. #if defined(CLEARCOAT_TINT)
  96882. specularEnvironmentReflectance*=clearcoatOut.absorption;
  96883. #endif
  96884. #endif
  96885. `;
  96886. ShaderStore.IncludesShadersStore[name$N] = shader$N;
  96887. var name$M = "pbrBlockDirectLighting"
  96888. , shader$M = `vec3 diffuseBase=vec3(0.,0.,0.);
  96889. #ifdef SPECULARTERM
  96890. vec3 specularBase=vec3(0.,0.,0.);
  96891. #endif
  96892. #ifdef CLEARCOAT
  96893. vec3 clearCoatBase=vec3(0.,0.,0.);
  96894. #endif
  96895. #ifdef SHEEN
  96896. vec3 sheenBase=vec3(0.,0.,0.);
  96897. #endif
  96898. preLightingInfo preInfo;
  96899. lightingInfo info;
  96900. float shadow=1.;
  96901. #if defined(CLEARCOAT) && defined(CLEARCOAT_TINT)
  96902. vec3 absorption=vec3(0.);
  96903. #endif
  96904. `;
  96905. ShaderStore.IncludesShadersStore[name$M] = shader$M;
  96906. var name$L = "pbrBlockFinalLitComponents"
  96907. , shader$L = `
  96908. #if defined(ENVIRONMENTBRDF)
  96909. #ifdef MS_BRDF_ENERGY_CONSERVATION
  96910. vec3 energyConservationFactor=getEnergyConservationFactor(clearcoatOut.specularEnvironmentR0,environmentBrdf);
  96911. #endif
  96912. #endif
  96913. #ifndef METALLICWORKFLOW
  96914. #ifdef SPECULAR_GLOSSINESS_ENERGY_CONSERVATION
  96915. surfaceAlbedo.rgb=(1.-reflectance)*surfaceAlbedo.rgb;
  96916. #endif
  96917. #endif
  96918. #if defined(SHEEN) && defined(SHEEN_ALBEDOSCALING) && defined(ENVIRONMENTBRDF)
  96919. surfaceAlbedo.rgb=sheenOut.sheenAlbedoScaling*surfaceAlbedo.rgb;
  96920. #endif
  96921. #ifdef REFLECTION
  96922. vec3 finalIrradiance=reflectionOut.environmentIrradiance;
  96923. #if defined(CLEARCOAT)
  96924. finalIrradiance*=clearcoatOut.conservationFactor;
  96925. #if defined(CLEARCOAT_TINT)
  96926. finalIrradiance*=clearcoatOut.absorption;
  96927. #endif
  96928. #endif
  96929. #if defined(SS_REFRACTION)
  96930. finalIrradiance*=subSurfaceOut.refractionFactorForIrradiance;
  96931. #endif
  96932. #if defined(SS_TRANSLUCENCY)
  96933. finalIrradiance*=(1.0-subSurfaceOut.translucencyIntensity);
  96934. finalIrradiance+=subSurfaceOut.refractionIrradiance;
  96935. #endif
  96936. finalIrradiance*=surfaceAlbedo.rgb;
  96937. finalIrradiance*=vLightingIntensity.z;
  96938. finalIrradiance*=aoOut.ambientOcclusionColor;
  96939. #endif
  96940. #ifdef SPECULARTERM
  96941. vec3 finalSpecular=specularBase;
  96942. finalSpecular=max(finalSpecular,0.0);
  96943. vec3 finalSpecularScaled=finalSpecular*vLightingIntensity.x*vLightingIntensity.w;
  96944. #if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
  96945. finalSpecularScaled*=energyConservationFactor;
  96946. #endif
  96947. #if defined(SHEEN) && defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
  96948. finalSpecularScaled*=sheenOut.sheenAlbedoScaling;
  96949. #endif
  96950. #endif
  96951. #ifdef REFLECTION
  96952. vec3 finalRadiance=reflectionOut.environmentRadiance.rgb;
  96953. finalRadiance*=subSurfaceOut.specularEnvironmentReflectance;
  96954. vec3 finalRadianceScaled=finalRadiance*vLightingIntensity.z;
  96955. #if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
  96956. finalRadianceScaled*=energyConservationFactor;
  96957. #endif
  96958. #if defined(SHEEN) && defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
  96959. finalRadianceScaled*=sheenOut.sheenAlbedoScaling;
  96960. #endif
  96961. #endif
  96962. #ifdef SHEEN
  96963. vec3 finalSheen=sheenBase*sheenOut.sheenColor;
  96964. finalSheen=max(finalSheen,0.0);
  96965. vec3 finalSheenScaled=finalSheen*vLightingIntensity.x*vLightingIntensity.w;
  96966. #if defined(CLEARCOAT) && defined(REFLECTION) && defined(ENVIRONMENTBRDF)
  96967. sheenOut.finalSheenRadianceScaled*=clearcoatOut.conservationFactor;
  96968. #if defined(CLEARCOAT_TINT)
  96969. sheenOut.finalSheenRadianceScaled*=clearcoatOut.absorption;
  96970. #endif
  96971. #endif
  96972. #endif
  96973. #ifdef CLEARCOAT
  96974. vec3 finalClearCoat=clearCoatBase;
  96975. finalClearCoat=max(finalClearCoat,0.0);
  96976. vec3 finalClearCoatScaled=finalClearCoat*vLightingIntensity.x*vLightingIntensity.w;
  96977. #if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
  96978. finalClearCoatScaled*=clearcoatOut.energyConservationFactorClearCoat;
  96979. #endif
  96980. #ifdef SS_REFRACTION
  96981. subSurfaceOut.finalRefraction*=clearcoatOut.conservationFactor;
  96982. #ifdef CLEARCOAT_TINT
  96983. subSurfaceOut.finalRefraction*=clearcoatOut.absorption;
  96984. #endif
  96985. #endif
  96986. #endif
  96987. #ifdef ALPHABLEND
  96988. float luminanceOverAlpha=0.0;
  96989. #if defined(REFLECTION) && defined(RADIANCEOVERALPHA)
  96990. luminanceOverAlpha+=getLuminance(finalRadianceScaled);
  96991. #if defined(CLEARCOAT)
  96992. luminanceOverAlpha+=getLuminance(clearcoatOut.finalClearCoatRadianceScaled);
  96993. #endif
  96994. #endif
  96995. #if defined(SPECULARTERM) && defined(SPECULAROVERALPHA)
  96996. luminanceOverAlpha+=getLuminance(finalSpecularScaled);
  96997. #endif
  96998. #if defined(CLEARCOAT) && defined(CLEARCOATOVERALPHA)
  96999. luminanceOverAlpha+=getLuminance(finalClearCoatScaled);
  97000. #endif
  97001. #if defined(RADIANCEOVERALPHA) || defined(SPECULAROVERALPHA) || defined(CLEARCOATOVERALPHA)
  97002. alpha=saturate(alpha+luminanceOverAlpha*luminanceOverAlpha);
  97003. #endif
  97004. #endif
  97005. `;
  97006. ShaderStore.IncludesShadersStore[name$L] = shader$L;
  97007. var name$K = "pbrBlockFinalUnlitComponents"
  97008. , shader$K = `
  97009. vec3 finalDiffuse=diffuseBase;
  97010. finalDiffuse*=surfaceAlbedo.rgb;
  97011. finalDiffuse=max(finalDiffuse,0.0);
  97012. finalDiffuse*=vLightingIntensity.x;
  97013. vec3 finalAmbient=vAmbientColor;
  97014. finalAmbient*=surfaceAlbedo.rgb;
  97015. vec3 finalEmissive=vEmissiveColor;
  97016. #ifdef EMISSIVE
  97017. vec3 emissiveColorTex=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb;
  97018. #ifdef GAMMAEMISSIVE
  97019. finalEmissive*=toLinearSpace(emissiveColorTex.rgb);
  97020. #else
  97021. finalEmissive*=emissiveColorTex.rgb;
  97022. #endif
  97023. finalEmissive*=vEmissiveInfos.y;
  97024. #endif
  97025. finalEmissive*=vLightingIntensity.y;
  97026. #ifdef AMBIENT
  97027. vec3 ambientOcclusionForDirectDiffuse=mix(vec3(1.),aoOut.ambientOcclusionColor,vAmbientInfos.w);
  97028. #else
  97029. vec3 ambientOcclusionForDirectDiffuse=aoOut.ambientOcclusionColor;
  97030. #endif
  97031. finalAmbient*=aoOut.ambientOcclusionColor;
  97032. finalDiffuse*=ambientOcclusionForDirectDiffuse;
  97033. `;
  97034. ShaderStore.IncludesShadersStore[name$K] = shader$K;
  97035. var name$J = "pbrBlockFinalColorComposition"
  97036. , shader$J = `vec4 finalColor=vec4(
  97037. finalAmbient +
  97038. finalDiffuse +
  97039. #ifndef UNLIT
  97040. #ifdef REFLECTION
  97041. finalIrradiance +
  97042. #endif
  97043. #ifdef SPECULARTERM
  97044. finalSpecularScaled +
  97045. #endif
  97046. #ifdef SHEEN
  97047. finalSheenScaled +
  97048. #endif
  97049. #ifdef CLEARCOAT
  97050. finalClearCoatScaled +
  97051. #endif
  97052. #ifdef REFLECTION
  97053. finalRadianceScaled +
  97054. #if defined(SHEEN) && defined(ENVIRONMENTBRDF)
  97055. sheenOut.finalSheenRadianceScaled +
  97056. #endif
  97057. #ifdef CLEARCOAT
  97058. clearcoatOut.finalClearCoatRadianceScaled +
  97059. #endif
  97060. #endif
  97061. #ifdef SS_REFRACTION
  97062. subSurfaceOut.finalRefraction +
  97063. #endif
  97064. #endif
  97065. finalEmissive,
  97066. alpha);
  97067. #ifdef LIGHTMAP
  97068. #ifndef LIGHTMAPEXCLUDED
  97069. #ifdef USELIGHTMAPASSHADOWMAP
  97070. finalColor.rgb*=lightmapColor.rgb;
  97071. #else
  97072. finalColor.rgb+=lightmapColor.rgb;
  97073. #endif
  97074. #endif
  97075. #endif
  97076. #define CUSTOM_FRAGMENT_BEFORE_FOG
  97077. finalColor=max(finalColor,0.0);
  97078. `;
  97079. ShaderStore.IncludesShadersStore[name$J] = shader$J;
  97080. var name$I = "pbrBlockImageProcessing"
  97081. , shader$I = `#if defined(IMAGEPROCESSINGPOSTPROCESS) || defined(SS_SCATTERING)
  97082. #if !defined(SKIPFINALCOLORCLAMP)
  97083. finalColor.rgb=clamp(finalColor.rgb,0.,30.0);
  97084. #endif
  97085. #else
  97086. finalColor=applyImageProcessing(finalColor);
  97087. #endif
  97088. finalColor.a*=visibility;
  97089. #ifdef PREMULTIPLYALPHA
  97090. finalColor.rgb*=finalColor.a;
  97091. #endif
  97092. `;
  97093. ShaderStore.IncludesShadersStore[name$I] = shader$I;
  97094. var name$H = "pbrDebug"
  97095. , shader$H = `#if DEBUGMODE>0
  97096. if (vClipSpacePosition.x/vClipSpacePosition.w>=vDebugMode.x) {
  97097. #if DEBUGMODE == 1
  97098. gl_FragColor.rgb=vPositionW.rgb;
  97099. #define DEBUGMODE_NORMALIZE
  97100. #elif DEBUGMODE == 2 && defined(NORMAL)
  97101. gl_FragColor.rgb=vNormalW.rgb;
  97102. #define DEBUGMODE_NORMALIZE
  97103. #elif DEBUGMODE == 3 && defined(BUMP) || DEBUGMODE == 3 && defined(PARALLAX) || DEBUGMODE == 3 && defined(ANISOTROPIC)
  97104. gl_FragColor.rgb=TBN[0];
  97105. #define DEBUGMODE_NORMALIZE
  97106. #elif DEBUGMODE == 4 && defined(BUMP) || DEBUGMODE == 4 && defined(PARALLAX) || DEBUGMODE == 4 && defined(ANISOTROPIC)
  97107. gl_FragColor.rgb=TBN[1];
  97108. #define DEBUGMODE_NORMALIZE
  97109. #elif DEBUGMODE == 5
  97110. gl_FragColor.rgb=normalW;
  97111. #define DEBUGMODE_NORMALIZE
  97112. #elif DEBUGMODE == 6 && defined(MAINUV1)
  97113. gl_FragColor.rgb=vec3(vMainUV1,0.0);
  97114. #elif DEBUGMODE == 7 && defined(MAINUV2)
  97115. gl_FragColor.rgb=vec3(vMainUV2,0.0);
  97116. #elif DEBUGMODE == 8 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)
  97117. gl_FragColor.rgb=clearcoatOut.TBNClearCoat[0];
  97118. #define DEBUGMODE_NORMALIZE
  97119. #elif DEBUGMODE == 9 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)
  97120. gl_FragColor.rgb=clearcoatOut.TBNClearCoat[1];
  97121. #define DEBUGMODE_NORMALIZE
  97122. #elif DEBUGMODE == 10 && defined(CLEARCOAT)
  97123. gl_FragColor.rgb=clearcoatOut.clearCoatNormalW;
  97124. #define DEBUGMODE_NORMALIZE
  97125. #elif DEBUGMODE == 11 && defined(ANISOTROPIC)
  97126. gl_FragColor.rgb=anisotropicOut.anisotropicNormal;
  97127. #define DEBUGMODE_NORMALIZE
  97128. #elif DEBUGMODE == 12 && defined(ANISOTROPIC)
  97129. gl_FragColor.rgb=anisotropicOut.anisotropicTangent;
  97130. #define DEBUGMODE_NORMALIZE
  97131. #elif DEBUGMODE == 13 && defined(ANISOTROPIC)
  97132. gl_FragColor.rgb=anisotropicOut.anisotropicBitangent;
  97133. #define DEBUGMODE_NORMALIZE
  97134. #elif DEBUGMODE == 20 && defined(ALBEDO)
  97135. gl_FragColor.rgb=albedoTexture.rgb;
  97136. #elif DEBUGMODE == 21 && defined(AMBIENT)
  97137. gl_FragColor.rgb=aoOut.ambientOcclusionColorMap.rgb;
  97138. #elif DEBUGMODE == 22 && defined(OPACITY)
  97139. gl_FragColor.rgb=opacityMap.rgb;
  97140. #elif DEBUGMODE == 23 && defined(EMISSIVE)
  97141. gl_FragColor.rgb=emissiveColorTex.rgb;
  97142. #define DEBUGMODE_GAMMA
  97143. #elif DEBUGMODE == 24 && defined(LIGHTMAP)
  97144. gl_FragColor.rgb=lightmapColor.rgb;
  97145. #define DEBUGMODE_GAMMA
  97146. #elif DEBUGMODE == 25 && defined(REFLECTIVITY) && defined(METALLICWORKFLOW)
  97147. gl_FragColor.rgb=reflectivityOut.surfaceMetallicColorMap.rgb;
  97148. #elif DEBUGMODE == 26 && defined(REFLECTIVITY) && !defined(METALLICWORKFLOW)
  97149. gl_FragColor.rgb=reflectivityOut.surfaceReflectivityColorMap.rgb;
  97150. #define DEBUGMODE_GAMMA
  97151. #elif DEBUGMODE == 27 && defined(CLEARCOAT) && defined(CLEARCOAT_TEXTURE)
  97152. gl_FragColor.rgb=vec3(clearcoatOut.clearCoatMapData.rg,0.0);
  97153. #elif DEBUGMODE == 28 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)
  97154. gl_FragColor.rgb=clearcoatOut.clearCoatTintMapData.rgb;
  97155. #elif DEBUGMODE == 29 && defined(SHEEN) && defined(SHEEN_TEXTURE)
  97156. gl_FragColor.rgb=sheenOut.sheenMapData.rgb;
  97157. #elif DEBUGMODE == 30 && defined(ANISOTROPIC) && defined(ANISOTROPIC_TEXTURE)
  97158. gl_FragColor.rgb=anisotropicOut.anisotropyMapData.rgb;
  97159. #elif DEBUGMODE == 31 && defined(SUBSURFACE) && defined(SS_THICKNESSANDMASK_TEXTURE)
  97160. gl_FragColor.rgb=subSurfaceOut.thicknessMap.rgb;
  97161. #elif DEBUGMODE == 40 && defined(SS_REFRACTION)
  97162. gl_FragColor.rgb=subSurfaceOut.environmentRefraction.rgb;
  97163. #define DEBUGMODE_GAMMA
  97164. #elif DEBUGMODE == 41 && defined(REFLECTION)
  97165. gl_FragColor.rgb=reflectionOut.environmentRadiance.rgb;
  97166. #define DEBUGMODE_GAMMA
  97167. #elif DEBUGMODE == 42 && defined(CLEARCOAT) && defined(REFLECTION)
  97168. gl_FragColor.rgb=clearcoatOut.environmentClearCoatRadiance.rgb;
  97169. #define DEBUGMODE_GAMMA
  97170. #elif DEBUGMODE == 50
  97171. gl_FragColor.rgb=diffuseBase.rgb;
  97172. #define DEBUGMODE_GAMMA
  97173. #elif DEBUGMODE == 51 && defined(SPECULARTERM)
  97174. gl_FragColor.rgb=specularBase.rgb;
  97175. #define DEBUGMODE_GAMMA
  97176. #elif DEBUGMODE == 52 && defined(CLEARCOAT)
  97177. gl_FragColor.rgb=clearCoatBase.rgb;
  97178. #define DEBUGMODE_GAMMA
  97179. #elif DEBUGMODE == 53 && defined(SHEEN)
  97180. gl_FragColor.rgb=sheenBase.rgb;
  97181. #define DEBUGMODE_GAMMA
  97182. #elif DEBUGMODE == 54 && defined(REFLECTION)
  97183. gl_FragColor.rgb=reflectionOut.environmentIrradiance.rgb;
  97184. #define DEBUGMODE_GAMMA
  97185. #elif DEBUGMODE == 60
  97186. gl_FragColor.rgb=surfaceAlbedo.rgb;
  97187. #define DEBUGMODE_GAMMA
  97188. #elif DEBUGMODE == 61
  97189. gl_FragColor.rgb=clearcoatOut.specularEnvironmentR0;
  97190. #define DEBUGMODE_GAMMA
  97191. #elif DEBUGMODE == 62 && defined(METALLICWORKFLOW)
  97192. gl_FragColor.rgb=vec3(reflectivityOut.metallicRoughness.r);
  97193. #elif DEBUGMODE == 71 && defined(METALLICWORKFLOW)
  97194. gl_FragColor.rgb=reflectivityOut.metallicF0;
  97195. #elif DEBUGMODE == 63
  97196. gl_FragColor.rgb=vec3(roughness);
  97197. #elif DEBUGMODE == 64
  97198. gl_FragColor.rgb=vec3(alphaG);
  97199. #elif DEBUGMODE == 65
  97200. gl_FragColor.rgb=vec3(NdotV);
  97201. #elif DEBUGMODE == 66 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT)
  97202. gl_FragColor.rgb=clearcoatOut.clearCoatColor.rgb;
  97203. #define DEBUGMODE_GAMMA
  97204. #elif DEBUGMODE == 67 && defined(CLEARCOAT)
  97205. gl_FragColor.rgb=vec3(clearcoatOut.clearCoatRoughness);
  97206. #elif DEBUGMODE == 68 && defined(CLEARCOAT)
  97207. gl_FragColor.rgb=vec3(clearcoatOut.clearCoatNdotV);
  97208. #elif DEBUGMODE == 69 && defined(SUBSURFACE) && defined(SS_TRANSLUCENCY)
  97209. gl_FragColor.rgb=subSurfaceOut.transmittance;
  97210. #elif DEBUGMODE == 70 && defined(SUBSURFACE) && defined(SS_REFRACTION)
  97211. gl_FragColor.rgb=subSurfaceOut.refractionTransmittance;
  97212. #elif DEBUGMODE == 80 && defined(RADIANCEOCCLUSION)
  97213. gl_FragColor.rgb=vec3(seo);
  97214. #elif DEBUGMODE == 81 && defined(HORIZONOCCLUSION)
  97215. gl_FragColor.rgb=vec3(eho);
  97216. #elif DEBUGMODE == 82 && defined(MS_BRDF_ENERGY_CONSERVATION)
  97217. gl_FragColor.rgb=vec3(energyConservationFactor);
  97218. #elif DEBUGMODE == 83 && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
  97219. gl_FragColor.rgb=specularEnvironmentReflectance;
  97220. #define DEBUGMODE_GAMMA
  97221. #elif DEBUGMODE == 84 && defined(CLEARCOAT) && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
  97222. gl_FragColor.rgb=clearcoatOut.clearCoatEnvironmentReflectance;
  97223. #define DEBUGMODE_GAMMA
  97224. #elif DEBUGMODE == 85 && defined(SHEEN) && defined(REFLECTION)
  97225. gl_FragColor.rgb=sheenOut.sheenEnvironmentReflectance;
  97226. #define DEBUGMODE_GAMMA
  97227. #elif DEBUGMODE == 86 && defined(ALPHABLEND)
  97228. gl_FragColor.rgb=vec3(luminanceOverAlpha);
  97229. #elif DEBUGMODE == 87
  97230. gl_FragColor.rgb=vec3(alpha);
  97231. #endif
  97232. gl_FragColor.rgb*=vDebugMode.y;
  97233. #ifdef DEBUGMODE_NORMALIZE
  97234. gl_FragColor.rgb=normalize(gl_FragColor.rgb)*0.5+0.5;
  97235. #endif
  97236. #ifdef DEBUGMODE_GAMMA
  97237. gl_FragColor.rgb=toGammaSpace(gl_FragColor.rgb);
  97238. #endif
  97239. gl_FragColor.a=1.0;
  97240. #ifdef PREPASS
  97241. gl_FragData[0]=toLinearSpace(gl_FragColor);
  97242. gl_FragData[1]=vec4(0.,0.,0.,0.);
  97243. #endif
  97244. return;
  97245. }
  97246. #endif`;
  97247. ShaderStore.IncludesShadersStore[name$H] = shader$H;
  97248. var name$G = "pbrPixelShader"
  97249. , shader$G = `#if defined(BUMP) || !defined(NORMAL) || defined(FORCENORMALFORWARD) || defined(SPECULARAA) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)
  97250. #extension GL_OES_standard_derivatives : enable
  97251. #endif
  97252. #ifdef LODBASEDMICROSFURACE
  97253. #extension GL_EXT_shader_texture_lod : enable
  97254. #endif
  97255. #define CUSTOM_FRAGMENT_BEGIN
  97256. #ifdef LOGARITHMICDEPTH
  97257. #extension GL_EXT_frag_depth : enable
  97258. #endif
  97259. #include<prePassDeclaration>[SCENE_MRT_COUNT]
  97260. precision highp float;
  97261. #include<oitDeclaration>
  97262. #ifndef FROMLINEARSPACE
  97263. #define FROMLINEARSPACE
  97264. #endif
  97265. #include<__decl__pbrFragment>
  97266. #include<pbrFragmentExtraDeclaration>
  97267. #include<__decl__lightFragment>[0..maxSimultaneousLights]
  97268. #include<pbrFragmentSamplersDeclaration>
  97269. #include<imageProcessingDeclaration>
  97270. #include<clipPlaneFragmentDeclaration>
  97271. #include<logDepthDeclaration>
  97272. #include<fogFragmentDeclaration>
  97273. #include<helperFunctions>
  97274. #include<subSurfaceScatteringFunctions>
  97275. #include<importanceSampling>
  97276. #include<pbrHelperFunctions>
  97277. #include<imageProcessingFunctions>
  97278. #include<shadowsFragmentFunctions>
  97279. #include<harmonicsFunctions>
  97280. #include<pbrDirectLightingSetupFunctions>
  97281. #include<pbrDirectLightingFalloffFunctions>
  97282. #include<pbrBRDFFunctions>
  97283. #include<hdrFilteringFunctions>
  97284. #include<pbrDirectLightingFunctions>
  97285. #include<pbrIBLFunctions>
  97286. #include<bumpFragmentMainFunctions>
  97287. #include<bumpFragmentFunctions>
  97288. #ifdef REFLECTION
  97289. #include<reflectionFunction>
  97290. #endif
  97291. #define CUSTOM_FRAGMENT_DEFINITIONS
  97292. #include<pbrBlockAlbedoOpacity>
  97293. #include<pbrBlockReflectivity>
  97294. #include<pbrBlockAmbientOcclusion>
  97295. #include<pbrBlockAlphaFresnel>
  97296. #include<pbrBlockAnisotropic>
  97297. #include<pbrBlockReflection>
  97298. #include<pbrBlockSheen>
  97299. #include<pbrBlockClearcoat>
  97300. #include<pbrBlockSubSurface>
  97301. void main(void) {
  97302. #define CUSTOM_FRAGMENT_MAIN_BEGIN
  97303. #include<oitFragment>
  97304. #include<clipPlaneFragment>
  97305. #include<pbrBlockNormalGeometric>
  97306. #include<bumpFragment>
  97307. #include<pbrBlockNormalFinal>
  97308. albedoOpacityOutParams albedoOpacityOut;
  97309. #ifdef ALBEDO
  97310. vec4 albedoTexture=texture2D(albedoSampler,vAlbedoUV+uvOffset);
  97311. #endif
  97312. #ifdef OPACITY
  97313. vec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);
  97314. #endif
  97315. albedoOpacityBlock(
  97316. vAlbedoColor,
  97317. #ifdef ALBEDO
  97318. albedoTexture,
  97319. vAlbedoInfos,
  97320. #endif
  97321. #ifdef OPACITY
  97322. opacityMap,
  97323. vOpacityInfos,
  97324. #endif
  97325. #ifdef DETAIL
  97326. detailColor,
  97327. vDetailInfos,
  97328. #endif
  97329. albedoOpacityOut
  97330. );
  97331. vec3 surfaceAlbedo=albedoOpacityOut.surfaceAlbedo;
  97332. float alpha=albedoOpacityOut.alpha;
  97333. #define CUSTOM_FRAGMENT_UPDATE_ALPHA
  97334. #include<depthPrePass>
  97335. #define CUSTOM_FRAGMENT_BEFORE_LIGHTS
  97336. ambientOcclusionOutParams aoOut;
  97337. #ifdef AMBIENT
  97338. vec3 ambientOcclusionColorMap=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb;
  97339. #endif
  97340. ambientOcclusionBlock(
  97341. #ifdef AMBIENT
  97342. ambientOcclusionColorMap,
  97343. vAmbientInfos,
  97344. #endif
  97345. aoOut
  97346. );
  97347. #include<pbrBlockLightmapInit>
  97348. #ifdef UNLIT
  97349. vec3 diffuseBase=vec3(1.,1.,1.);
  97350. #else
  97351. vec3 baseColor=surfaceAlbedo;
  97352. reflectivityOutParams reflectivityOut;
  97353. #if defined(REFLECTIVITY)
  97354. vec4 surfaceMetallicOrReflectivityColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);
  97355. vec4 baseReflectivity=surfaceMetallicOrReflectivityColorMap;
  97356. #ifndef METALLICWORKFLOW
  97357. #ifdef REFLECTIVITY_GAMMA
  97358. surfaceMetallicOrReflectivityColorMap=toLinearSpace(surfaceMetallicOrReflectivityColorMap);
  97359. #endif
  97360. surfaceMetallicOrReflectivityColorMap.rgb*=vReflectivityInfos.y;
  97361. #endif
  97362. #endif
  97363. #if defined(MICROSURFACEMAP)
  97364. vec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;
  97365. #endif
  97366. #ifdef METALLICWORKFLOW
  97367. vec4 metallicReflectanceFactors=vMetallicReflectanceFactors;
  97368. #ifdef REFLECTANCE
  97369. vec4 reflectanceFactorsMap=texture2D(reflectanceSampler,vReflectanceUV+uvOffset);
  97370. #ifdef REFLECTANCE_GAMMA
  97371. reflectanceFactorsMap=toLinearSpace(reflectanceFactorsMap);
  97372. #endif
  97373. metallicReflectanceFactors.rgb*=reflectanceFactorsMap.rgb;
  97374. #endif
  97375. #ifdef METALLIC_REFLECTANCE
  97376. vec4 metallicReflectanceFactorsMap=texture2D(metallicReflectanceSampler,vMetallicReflectanceUV+uvOffset);
  97377. #ifdef METALLIC_REFLECTANCE_GAMMA
  97378. metallicReflectanceFactorsMap=toLinearSpace(metallicReflectanceFactorsMap);
  97379. #endif
  97380. #ifndef METALLIC_REFLECTANCE_USE_ALPHA_ONLY
  97381. metallicReflectanceFactors.rgb*=metallicReflectanceFactorsMap.rgb;
  97382. #endif
  97383. metallicReflectanceFactors*=metallicReflectanceFactorsMap.a;
  97384. #endif
  97385. #endif
  97386. reflectivityBlock(
  97387. vReflectivityColor,
  97388. #ifdef METALLICWORKFLOW
  97389. surfaceAlbedo,
  97390. metallicReflectanceFactors,
  97391. #endif
  97392. #ifdef REFLECTIVITY
  97393. vReflectivityInfos,
  97394. surfaceMetallicOrReflectivityColorMap,
  97395. #endif
  97396. #if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
  97397. aoOut.ambientOcclusionColor,
  97398. #endif
  97399. #ifdef MICROSURFACEMAP
  97400. microSurfaceTexel,
  97401. #endif
  97402. #ifdef DETAIL
  97403. detailColor,
  97404. vDetailInfos,
  97405. #endif
  97406. reflectivityOut
  97407. );
  97408. float microSurface=reflectivityOut.microSurface;
  97409. float roughness=reflectivityOut.roughness;
  97410. #ifdef METALLICWORKFLOW
  97411. surfaceAlbedo=reflectivityOut.surfaceAlbedo;
  97412. #endif
  97413. #if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
  97414. aoOut.ambientOcclusionColor=reflectivityOut.ambientOcclusionColor;
  97415. #endif
  97416. #ifdef ALPHAFRESNEL
  97417. #if defined(ALPHATEST) || defined(ALPHABLEND)
  97418. alphaFresnelOutParams alphaFresnelOut;
  97419. alphaFresnelBlock(
  97420. normalW,
  97421. viewDirectionW,
  97422. alpha,
  97423. microSurface,
  97424. alphaFresnelOut
  97425. );
  97426. alpha=alphaFresnelOut.alpha;
  97427. #endif
  97428. #endif
  97429. #include<pbrBlockGeometryInfo>
  97430. #ifdef ANISOTROPIC
  97431. anisotropicOutParams anisotropicOut;
  97432. #ifdef ANISOTROPIC_TEXTURE
  97433. vec3 anisotropyMapData=texture2D(anisotropySampler,vAnisotropyUV+uvOffset).rgb*vAnisotropyInfos.y;
  97434. #endif
  97435. anisotropicBlock(
  97436. vAnisotropy,
  97437. #ifdef ANISOTROPIC_TEXTURE
  97438. anisotropyMapData,
  97439. #endif
  97440. TBN,
  97441. normalW,
  97442. viewDirectionW,
  97443. anisotropicOut
  97444. );
  97445. #endif
  97446. #ifdef REFLECTION
  97447. reflectionOutParams reflectionOut;
  97448. reflectionBlock(
  97449. vPositionW,
  97450. normalW,
  97451. alphaG,
  97452. vReflectionMicrosurfaceInfos,
  97453. vReflectionInfos,
  97454. vReflectionColor,
  97455. #ifdef ANISOTROPIC
  97456. anisotropicOut,
  97457. #endif
  97458. #if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
  97459. NdotVUnclamped,
  97460. #endif
  97461. #ifdef LINEARSPECULARREFLECTION
  97462. roughness,
  97463. #endif
  97464. reflectionSampler,
  97465. #if defined(NORMAL) && defined(USESPHERICALINVERTEX)
  97466. vEnvironmentIrradiance,
  97467. #endif
  97468. #ifdef USESPHERICALFROMREFLECTIONMAP
  97469. #if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
  97470. reflectionMatrix,
  97471. #endif
  97472. #endif
  97473. #ifdef USEIRRADIANCEMAP
  97474. irradianceSampler,
  97475. #endif
  97476. #ifndef LODBASEDMICROSFURACE
  97477. reflectionSamplerLow,
  97478. reflectionSamplerHigh,
  97479. #endif
  97480. #ifdef REALTIME_FILTERING
  97481. vReflectionFilteringInfo,
  97482. #endif
  97483. reflectionOut
  97484. );
  97485. #endif
  97486. #include<pbrBlockReflectance0>
  97487. #ifdef SHEEN
  97488. sheenOutParams sheenOut;
  97489. #ifdef SHEEN_TEXTURE
  97490. vec4 sheenMapData=texture2D(sheenSampler,vSheenUV+uvOffset);
  97491. #endif
  97492. #if defined(SHEEN_ROUGHNESS) && defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)
  97493. vec4 sheenMapRoughnessData=texture2D(sheenRoughnessSampler,vSheenRoughnessUV+uvOffset)*vSheenInfos.w;
  97494. #endif
  97495. sheenBlock(
  97496. vSheenColor,
  97497. #ifdef SHEEN_ROUGHNESS
  97498. vSheenRoughness,
  97499. #if defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)
  97500. sheenMapRoughnessData,
  97501. #endif
  97502. #endif
  97503. roughness,
  97504. #ifdef SHEEN_TEXTURE
  97505. sheenMapData,
  97506. vSheenInfos.y,
  97507. #endif
  97508. reflectance,
  97509. #ifdef SHEEN_LINKWITHALBEDO
  97510. baseColor,
  97511. surfaceAlbedo,
  97512. #endif
  97513. #ifdef ENVIRONMENTBRDF
  97514. NdotV,
  97515. environmentBrdf,
  97516. #endif
  97517. #if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
  97518. AARoughnessFactors,
  97519. vReflectionMicrosurfaceInfos,
  97520. vReflectionInfos,
  97521. vReflectionColor,
  97522. vLightingIntensity,
  97523. reflectionSampler,
  97524. reflectionOut.reflectionCoords,
  97525. NdotVUnclamped,
  97526. #ifndef LODBASEDMICROSFURACE
  97527. reflectionSamplerLow,
  97528. reflectionSamplerHigh,
  97529. #endif
  97530. #ifdef REALTIME_FILTERING
  97531. vReflectionFilteringInfo,
  97532. #endif
  97533. #if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)
  97534. seo,
  97535. #endif
  97536. #if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
  97537. eho,
  97538. #endif
  97539. #endif
  97540. sheenOut
  97541. );
  97542. #ifdef SHEEN_LINKWITHALBEDO
  97543. surfaceAlbedo=sheenOut.surfaceAlbedo;
  97544. #endif
  97545. #endif
  97546. clearcoatOutParams clearcoatOut;
  97547. #ifdef CLEARCOAT
  97548. #ifdef CLEARCOAT_TEXTURE
  97549. vec2 clearCoatMapData=texture2D(clearCoatSampler,vClearCoatUV+uvOffset).rg*vClearCoatInfos.y;
  97550. #endif
  97551. #if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
  97552. vec4 clearCoatMapRoughnessData=texture2D(clearCoatRoughnessSampler,vClearCoatRoughnessUV+uvOffset)*vClearCoatInfos.w;
  97553. #endif
  97554. #if defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)
  97555. vec4 clearCoatTintMapData=texture2D(clearCoatTintSampler,vClearCoatTintUV+uvOffset);
  97556. #endif
  97557. #ifdef CLEARCOAT_BUMP
  97558. vec4 clearCoatBumpMapData=texture2D(clearCoatBumpSampler,vClearCoatBumpUV+uvOffset);
  97559. #endif
  97560. clearcoatBlock(
  97561. vPositionW,
  97562. geometricNormalW,
  97563. viewDirectionW,
  97564. vClearCoatParams,
  97565. #if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
  97566. clearCoatMapRoughnessData,
  97567. #endif
  97568. specularEnvironmentR0,
  97569. #ifdef CLEARCOAT_TEXTURE
  97570. clearCoatMapData,
  97571. #endif
  97572. #ifdef CLEARCOAT_TINT
  97573. vClearCoatTintParams,
  97574. clearCoatColorAtDistance,
  97575. vClearCoatRefractionParams,
  97576. #ifdef CLEARCOAT_TINT_TEXTURE
  97577. clearCoatTintMapData,
  97578. #endif
  97579. #endif
  97580. #ifdef CLEARCOAT_BUMP
  97581. vClearCoatBumpInfos,
  97582. clearCoatBumpMapData,
  97583. vClearCoatBumpUV,
  97584. #if defined(TANGENT) && defined(NORMAL)
  97585. vTBN,
  97586. #else
  97587. vClearCoatTangentSpaceParams,
  97588. #endif
  97589. #ifdef OBJECTSPACE_NORMALMAP
  97590. normalMatrix,
  97591. #endif
  97592. #endif
  97593. #if defined(FORCENORMALFORWARD) && defined(NORMAL)
  97594. faceNormal,
  97595. #endif
  97596. #ifdef REFLECTION
  97597. vReflectionMicrosurfaceInfos,
  97598. vReflectionInfos,
  97599. vReflectionColor,
  97600. vLightingIntensity,
  97601. reflectionSampler,
  97602. #ifndef LODBASEDMICROSFURACE
  97603. reflectionSamplerLow,
  97604. reflectionSamplerHigh,
  97605. #endif
  97606. #ifdef REALTIME_FILTERING
  97607. vReflectionFilteringInfo,
  97608. #endif
  97609. #endif
  97610. #if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
  97611. #ifdef RADIANCEOCCLUSION
  97612. ambientMonochrome,
  97613. #endif
  97614. #endif
  97615. #if defined(CLEARCOAT_BUMP) || defined(TWOSIDEDLIGHTING)
  97616. (gl_FrontFacing ? 1. : -1.),
  97617. #endif
  97618. clearcoatOut
  97619. );
  97620. #else
  97621. clearcoatOut.specularEnvironmentR0=specularEnvironmentR0;
  97622. #endif
  97623. #include<pbrBlockReflectance>
  97624. subSurfaceOutParams subSurfaceOut;
  97625. #ifdef SUBSURFACE
  97626. #ifdef SS_THICKNESSANDMASK_TEXTURE
  97627. vec4 thicknessMap=texture2D(thicknessSampler,vThicknessUV+uvOffset);
  97628. #endif
  97629. #ifdef SS_REFRACTIONINTENSITY_TEXTURE
  97630. vec4 refractionIntensityMap=texture2D(refractionIntensitySampler,vRefractionIntensityUV+uvOffset);
  97631. #endif
  97632. #ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
  97633. vec4 translucencyIntensityMap=texture2D(translucencyIntensitySampler,vTranslucencyIntensityUV+uvOffset);
  97634. #endif
  97635. subSurfaceBlock(
  97636. vSubSurfaceIntensity,
  97637. vThicknessParam,
  97638. vTintColor,
  97639. normalW,
  97640. specularEnvironmentReflectance,
  97641. #ifdef SS_THICKNESSANDMASK_TEXTURE
  97642. thicknessMap,
  97643. #endif
  97644. #ifdef SS_REFRACTIONINTENSITY_TEXTURE
  97645. refractionIntensityMap,
  97646. #endif
  97647. #ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
  97648. translucencyIntensityMap,
  97649. #endif
  97650. #ifdef REFLECTION
  97651. #ifdef SS_TRANSLUCENCY
  97652. reflectionMatrix,
  97653. #ifdef USESPHERICALFROMREFLECTIONMAP
  97654. #if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
  97655. reflectionOut.irradianceVector,
  97656. #endif
  97657. #if defined(REALTIME_FILTERING)
  97658. reflectionSampler,
  97659. vReflectionFilteringInfo,
  97660. #endif
  97661. #endif
  97662. #ifdef USEIRRADIANCEMAP
  97663. irradianceSampler,
  97664. #endif
  97665. #endif
  97666. #endif
  97667. #if defined(SS_REFRACTION) || defined(SS_TRANSLUCENCY)
  97668. surfaceAlbedo,
  97669. #endif
  97670. #ifdef SS_REFRACTION
  97671. vPositionW,
  97672. viewDirectionW,
  97673. view,
  97674. vRefractionInfos,
  97675. refractionMatrix,
  97676. vRefractionMicrosurfaceInfos,
  97677. vLightingIntensity,
  97678. #ifdef SS_LINKREFRACTIONTOTRANSPARENCY
  97679. alpha,
  97680. #endif
  97681. #ifdef SS_LODINREFRACTIONALPHA
  97682. NdotVUnclamped,
  97683. #endif
  97684. #ifdef SS_LINEARSPECULARREFRACTION
  97685. roughness,
  97686. #endif
  97687. alphaG,
  97688. refractionSampler,
  97689. #ifndef LODBASEDMICROSFURACE
  97690. refractionSamplerLow,
  97691. refractionSamplerHigh,
  97692. #endif
  97693. #ifdef ANISOTROPIC
  97694. anisotropicOut,
  97695. #endif
  97696. #ifdef REALTIME_FILTERING
  97697. vRefractionFilteringInfo,
  97698. #endif
  97699. #ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
  97700. vRefractionPosition,
  97701. vRefractionSize,
  97702. #endif
  97703. #endif
  97704. #ifdef SS_TRANSLUCENCY
  97705. vDiffusionDistance,
  97706. #endif
  97707. subSurfaceOut
  97708. );
  97709. #ifdef SS_REFRACTION
  97710. surfaceAlbedo=subSurfaceOut.surfaceAlbedo;
  97711. #ifdef SS_LINKREFRACTIONTOTRANSPARENCY
  97712. alpha=subSurfaceOut.alpha;
  97713. #endif
  97714. #endif
  97715. #else
  97716. subSurfaceOut.specularEnvironmentReflectance=specularEnvironmentReflectance;
  97717. #endif
  97718. #include<pbrBlockDirectLighting>
  97719. #include<lightFragment>[0..maxSimultaneousLights]
  97720. #include<pbrBlockFinalLitComponents>
  97721. #endif
  97722. #include<pbrBlockFinalUnlitComponents>
  97723. #define CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION
  97724. #include<pbrBlockFinalColorComposition>
  97725. #include<logDepthFragment>
  97726. #include<fogFragment>(color,finalColor)
  97727. #include<pbrBlockImageProcessing>
  97728. #define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR
  97729. #ifdef PREPASS
  97730. float writeGeometryInfo=finalColor.a>0.4 ? 1.0 : 0.0;
  97731. #ifdef PREPASS_POSITION
  97732. gl_FragData[PREPASS_POSITION_INDEX]=vec4(vPositionW,writeGeometryInfo);
  97733. #endif
  97734. #ifdef PREPASS_VELOCITY
  97735. vec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;
  97736. vec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;
  97737. vec2 velocity=abs(a-b);
  97738. velocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;
  97739. gl_FragData[PREPASS_VELOCITY_INDEX]=vec4(velocity,0.0,writeGeometryInfo);
  97740. #endif
  97741. #ifdef PREPASS_ALBEDO_SQRT
  97742. vec3 sqAlbedo=sqrt(surfaceAlbedo);
  97743. #endif
  97744. #ifdef PREPASS_IRRADIANCE
  97745. vec3 irradiance=finalDiffuse;
  97746. #ifndef UNLIT
  97747. #ifdef REFLECTION
  97748. irradiance+=finalIrradiance;
  97749. #endif
  97750. #endif
  97751. #ifdef SS_SCATTERING
  97752. gl_FragData[0]=vec4(finalColor.rgb-irradiance,finalColor.a);
  97753. irradiance/=sqAlbedo;
  97754. #else
  97755. gl_FragData[0]=finalColor;
  97756. float scatteringDiffusionProfile=255.;
  97757. #endif
  97758. gl_FragData[PREPASS_IRRADIANCE_INDEX]=vec4(clamp(irradiance,vec3(0.),vec3(1.)),writeGeometryInfo*scatteringDiffusionProfile/255.);
  97759. #else
  97760. gl_FragData[0]=vec4(finalColor.rgb,finalColor.a);
  97761. #endif
  97762. #ifdef PREPASS_DEPTH
  97763. gl_FragData[PREPASS_DEPTH_INDEX]=vec4(vViewPos.z,0.0,0.0,writeGeometryInfo);
  97764. #endif
  97765. #ifdef PREPASS_NORMAL
  97766. gl_FragData[PREPASS_NORMAL_INDEX]=vec4((view*vec4(normalW,0.0)).rgb,writeGeometryInfo);
  97767. #endif
  97768. #ifdef PREPASS_ALBEDO_SQRT
  97769. gl_FragData[PREPASS_ALBEDO_SQRT_INDEX]=vec4(sqAlbedo,writeGeometryInfo);
  97770. #endif
  97771. #ifdef PREPASS_REFLECTIVITY
  97772. #if defined(REFLECTIVITY)
  97773. gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(baseReflectivity.rgb,baseReflectivity.a*writeGeometryInfo);
  97774. #else
  97775. gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(0.0,0.0,0.0,writeGeometryInfo);
  97776. #endif
  97777. #endif
  97778. #endif
  97779. #if !defined(PREPASS) || defined(WEBGL2)
  97780. gl_FragColor=finalColor;
  97781. #endif
  97782. #if ORDER_INDEPENDENT_TRANSPARENCY
  97783. if (fragDepth == nearestDepth) {
  97784. frontColor.rgb+=finalColor.rgb*finalColor.a*alphaMultiplier;
  97785. frontColor.a=1.0-alphaMultiplier*(1.0-finalColor.a);
  97786. } else {
  97787. backColor+=finalColor;
  97788. }
  97789. #endif
  97790. #include<pbrDebug>
  97791. }
  97792. `;
  97793. ShaderStore.ShadersStore[name$G] = shader$G;
  97794. var name$F = "pbrVertexDeclaration"
  97795. , shader$F = `uniform mat4 view;
  97796. uniform mat4 viewProjection;
  97797. #ifdef ALBEDO
  97798. uniform mat4 albedoMatrix;
  97799. uniform vec2 vAlbedoInfos;
  97800. #endif
  97801. #ifdef AMBIENT
  97802. uniform mat4 ambientMatrix;
  97803. uniform vec4 vAmbientInfos;
  97804. #endif
  97805. #ifdef OPACITY
  97806. uniform mat4 opacityMatrix;
  97807. uniform vec2 vOpacityInfos;
  97808. #endif
  97809. #ifdef EMISSIVE
  97810. uniform vec2 vEmissiveInfos;
  97811. uniform mat4 emissiveMatrix;
  97812. #endif
  97813. #ifdef LIGHTMAP
  97814. uniform vec2 vLightmapInfos;
  97815. uniform mat4 lightmapMatrix;
  97816. #endif
  97817. #ifdef REFLECTIVITY
  97818. uniform vec3 vReflectivityInfos;
  97819. uniform mat4 reflectivityMatrix;
  97820. #endif
  97821. #ifdef METALLIC_REFLECTANCE
  97822. uniform vec2 vMetallicReflectanceInfos;
  97823. uniform mat4 metallicReflectanceMatrix;
  97824. #endif
  97825. #ifdef REFLECTANCE
  97826. uniform vec2 vReflectanceInfos;
  97827. uniform mat4 reflectanceMatrix;
  97828. #endif
  97829. #ifdef MICROSURFACEMAP
  97830. uniform vec2 vMicroSurfaceSamplerInfos;
  97831. uniform mat4 microSurfaceSamplerMatrix;
  97832. #endif
  97833. #ifdef BUMP
  97834. uniform vec3 vBumpInfos;
  97835. uniform mat4 bumpMatrix;
  97836. #endif
  97837. #ifdef POINTSIZE
  97838. uniform float pointSize;
  97839. #endif
  97840. #ifdef REFLECTION
  97841. uniform vec2 vReflectionInfos;
  97842. uniform mat4 reflectionMatrix;
  97843. #endif
  97844. #ifdef CLEARCOAT
  97845. #if defined(CLEARCOAT_TEXTURE) || defined(CLEARCOAT_TEXTURE_ROUGHNESS)
  97846. uniform vec4 vClearCoatInfos;
  97847. #endif
  97848. #ifdef CLEARCOAT_TEXTURE
  97849. uniform mat4 clearCoatMatrix;
  97850. #endif
  97851. #ifdef CLEARCOAT_TEXTURE_ROUGHNESS
  97852. uniform mat4 clearCoatRoughnessMatrix;
  97853. #endif
  97854. #ifdef CLEARCOAT_BUMP
  97855. uniform vec2 vClearCoatBumpInfos;
  97856. uniform mat4 clearCoatBumpMatrix;
  97857. #endif
  97858. #ifdef CLEARCOAT_TINT_TEXTURE
  97859. uniform vec2 vClearCoatTintInfos;
  97860. uniform mat4 clearCoatTintMatrix;
  97861. #endif
  97862. #endif
  97863. #ifdef ANISOTROPIC
  97864. #ifdef ANISOTROPIC_TEXTURE
  97865. uniform vec2 vAnisotropyInfos;
  97866. uniform mat4 anisotropyMatrix;
  97867. #endif
  97868. #endif
  97869. #ifdef SHEEN
  97870. #if defined(SHEEN_TEXTURE) || defined(SHEEN_TEXTURE_ROUGHNESS)
  97871. uniform vec4 vSheenInfos;
  97872. #endif
  97873. #ifdef SHEEN_TEXTURE
  97874. uniform mat4 sheenMatrix;
  97875. #endif
  97876. #ifdef SHEEN_TEXTURE_ROUGHNESS
  97877. uniform mat4 sheenRoughnessMatrix;
  97878. #endif
  97879. #endif
  97880. #ifdef SUBSURFACE
  97881. #ifdef SS_REFRACTION
  97882. uniform vec4 vRefractionInfos;
  97883. uniform mat4 refractionMatrix;
  97884. #endif
  97885. #ifdef SS_THICKNESSANDMASK_TEXTURE
  97886. uniform vec2 vThicknessInfos;
  97887. uniform mat4 thicknessMatrix;
  97888. #endif
  97889. #ifdef SS_REFRACTIONINTENSITY_TEXTURE
  97890. uniform vec2 vRefractionIntensityInfos;
  97891. uniform mat4 refractionIntensityMatrix;
  97892. #endif
  97893. #ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
  97894. uniform vec2 vTranslucencyIntensityInfos;
  97895. uniform mat4 translucencyIntensityMatrix;
  97896. #endif
  97897. #endif
  97898. #ifdef NORMAL
  97899. #if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)
  97900. #ifdef USESPHERICALFROMREFLECTIONMAP
  97901. #ifdef SPHERICAL_HARMONICS
  97902. uniform vec3 vSphericalL00;
  97903. uniform vec3 vSphericalL1_1;
  97904. uniform vec3 vSphericalL10;
  97905. uniform vec3 vSphericalL11;
  97906. uniform vec3 vSphericalL2_2;
  97907. uniform vec3 vSphericalL2_1;
  97908. uniform vec3 vSphericalL20;
  97909. uniform vec3 vSphericalL21;
  97910. uniform vec3 vSphericalL22;
  97911. #else
  97912. uniform vec3 vSphericalX;
  97913. uniform vec3 vSphericalY;
  97914. uniform vec3 vSphericalZ;
  97915. uniform vec3 vSphericalXX_ZZ;
  97916. uniform vec3 vSphericalYY_ZZ;
  97917. uniform vec3 vSphericalZZ;
  97918. uniform vec3 vSphericalXY;
  97919. uniform vec3 vSphericalYZ;
  97920. uniform vec3 vSphericalZX;
  97921. #endif
  97922. #endif
  97923. #endif
  97924. #endif
  97925. #ifdef DETAIL
  97926. uniform vec4 vDetailInfos;
  97927. uniform mat4 detailMatrix;
  97928. #endif`;
  97929. ShaderStore.IncludesShadersStore[name$F] = shader$F;
  97930. var name$E = "pbrVertexShader"
  97931. , shader$E = `precision highp float;
  97932. #include<__decl__pbrVertex>
  97933. #define CUSTOM_VERTEX_BEGIN
  97934. attribute vec3 position;
  97935. #ifdef NORMAL
  97936. attribute vec3 normal;
  97937. #endif
  97938. #ifdef TANGENT
  97939. attribute vec4 tangent;
  97940. #endif
  97941. #ifdef UV1
  97942. attribute vec2 uv;
  97943. #endif
  97944. #include<uvAttributeDeclaration>[2..7]
  97945. #include<mainUVVaryingDeclaration>[1..7]
  97946. #ifdef VERTEXCOLOR
  97947. attribute vec4 color;
  97948. #endif
  97949. #include<helperFunctions>
  97950. #include<bonesDeclaration>
  97951. #include<bakedVertexAnimationDeclaration>
  97952. #include<instancesDeclaration>
  97953. #include<prePassVertexDeclaration>
  97954. #include<samplerVertexDeclaration>(_DEFINENAME_,ALBEDO,_VARYINGNAME_,Albedo)
  97955. #include<samplerVertexDeclaration>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail)
  97956. #include<samplerVertexDeclaration>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient)
  97957. #include<samplerVertexDeclaration>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity)
  97958. #include<samplerVertexDeclaration>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive)
  97959. #include<samplerVertexDeclaration>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap)
  97960. #include<samplerVertexDeclaration>(_DEFINENAME_,REFLECTIVITY,_VARYINGNAME_,Reflectivity)
  97961. #include<samplerVertexDeclaration>(_DEFINENAME_,MICROSURFACEMAP,_VARYINGNAME_,MicroSurfaceSampler)
  97962. #include<samplerVertexDeclaration>(_DEFINENAME_,METALLIC_REFLECTANCE,_VARYINGNAME_,MetallicReflectance)
  97963. #include<samplerVertexDeclaration>(_DEFINENAME_,REFLECTANCE,_VARYINGNAME_,Reflectance)
  97964. #include<samplerVertexDeclaration>(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump)
  97965. #ifdef CLEARCOAT
  97966. #include<samplerVertexDeclaration>(_DEFINENAME_,CLEARCOAT_TEXTURE,_VARYINGNAME_,ClearCoat)
  97967. #include<samplerVertexDeclaration>(_DEFINENAME_,CLEARCOAT_TEXTURE_ROUGHNESS,_VARYINGNAME_,ClearCoatRoughness)
  97968. #include<samplerVertexDeclaration>(_DEFINENAME_,CLEARCOAT_BUMP,_VARYINGNAME_,ClearCoatBump)
  97969. #include<samplerVertexDeclaration>(_DEFINENAME_,CLEARCOAT_TINT_TEXTURE,_VARYINGNAME_,ClearCoatTint)
  97970. #endif
  97971. #ifdef SHEEN
  97972. #include<samplerVertexDeclaration>(_DEFINENAME_,SHEEN_TEXTURE,_VARYINGNAME_,Sheen)
  97973. #include<samplerVertexDeclaration>(_DEFINENAME_,SHEEN_TEXTURE_ROUGHNESS,_VARYINGNAME_,SheenRoughness)
  97974. #endif
  97975. #ifdef ANISOTROPIC
  97976. #include<samplerVertexDeclaration>(_DEFINENAME_,ANISOTROPIC_TEXTURE,_VARYINGNAME_,Anisotropy)
  97977. #endif
  97978. #ifdef SUBSURFACE
  97979. #include<samplerVertexDeclaration>(_DEFINENAME_,SS_THICKNESSANDMASK_TEXTURE,_VARYINGNAME_,Thickness)
  97980. #include<samplerVertexDeclaration>(_DEFINENAME_,SS_REFRACTIONINTENSITY_TEXTURE,_VARYINGNAME_,RefractionIntensity)
  97981. #include<samplerVertexDeclaration>(_DEFINENAME_,SS_TRANSLUCENCYINTENSITY_TEXTURE,_VARYINGNAME_,TranslucencyIntensity)
  97982. #endif
  97983. varying vec3 vPositionW;
  97984. #if DEBUGMODE>0
  97985. varying vec4 vClipSpacePosition;
  97986. #endif
  97987. #ifdef NORMAL
  97988. varying vec3 vNormalW;
  97989. #if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)
  97990. varying vec3 vEnvironmentIrradiance;
  97991. #include<harmonicsFunctions>
  97992. #endif
  97993. #endif
  97994. #ifdef VERTEXCOLOR
  97995. varying vec4 vColor;
  97996. #endif
  97997. #include<bumpVertexDeclaration>
  97998. #include<clipPlaneVertexDeclaration>
  97999. #include<fogVertexDeclaration>
  98000. #include<__decl__lightVxFragment>[0..maxSimultaneousLights]
  98001. #include<morphTargetsVertexGlobalDeclaration>
  98002. #include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
  98003. #ifdef REFLECTIONMAP_SKYBOX
  98004. varying vec3 vPositionUVW;
  98005. #endif
  98006. #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
  98007. varying vec3 vDirectionW;
  98008. #endif
  98009. #include<logDepthDeclaration>
  98010. #define CUSTOM_VERTEX_DEFINITIONS
  98011. void main(void) {
  98012. #define CUSTOM_VERTEX_MAIN_BEGIN
  98013. vec3 positionUpdated=position;
  98014. #ifdef NORMAL
  98015. vec3 normalUpdated=normal;
  98016. #endif
  98017. #ifdef TANGENT
  98018. vec4 tangentUpdated=tangent;
  98019. #endif
  98020. #ifdef UV1
  98021. vec2 uvUpdated=uv;
  98022. #endif
  98023. #include<morphTargetsVertexGlobal>
  98024. #include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
  98025. #ifdef REFLECTIONMAP_SKYBOX
  98026. vPositionUVW=positionUpdated;
  98027. #endif
  98028. #define CUSTOM_VERTEX_UPDATE_POSITION
  98029. #define CUSTOM_VERTEX_UPDATE_NORMAL
  98030. #include<instancesVertex>
  98031. #if defined(PREPASS) && defined(PREPASS_VELOCITY) && !defined(BONES_VELOCITY_ENABLED)
  98032. vCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);
  98033. vPreviousPosition=previousViewProjection*previousWorld*vec4(positionUpdated,1.0);
  98034. #endif
  98035. #include<bonesVertex>
  98036. #include<bakedVertexAnimation>
  98037. vec4 worldPos=finalWorld*vec4(positionUpdated,1.0);
  98038. vPositionW=vec3(worldPos);
  98039. #include<prePassVertex>
  98040. #ifdef NORMAL
  98041. mat3 normalWorld=mat3(finalWorld);
  98042. #if defined(INSTANCES) && defined(THIN_INSTANCES)
  98043. vNormalW=normalUpdated/vec3(dot(normalWorld[0],normalWorld[0]),dot(normalWorld[1],normalWorld[1]),dot(normalWorld[2],normalWorld[2]));
  98044. vNormalW=normalize(normalWorld*vNormalW);
  98045. #else
  98046. #ifdef NONUNIFORMSCALING
  98047. normalWorld=transposeMat3(inverseMat3(normalWorld));
  98048. #endif
  98049. vNormalW=normalize(normalWorld*normalUpdated);
  98050. #endif
  98051. #if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)
  98052. vec3 reflectionVector=vec3(reflectionMatrix*vec4(vNormalW,0)).xyz;
  98053. #ifdef REFLECTIONMAP_OPPOSITEZ
  98054. reflectionVector.z*=-1.0;
  98055. #endif
  98056. vEnvironmentIrradiance=computeEnvironmentIrradiance(reflectionVector);
  98057. #endif
  98058. #endif
  98059. #define CUSTOM_VERTEX_UPDATE_WORLDPOS
  98060. #ifdef MULTIVIEW
  98061. if (gl_ViewID_OVR == 0u) {
  98062. gl_Position=viewProjection*worldPos;
  98063. } else {
  98064. gl_Position=viewProjectionR*worldPos;
  98065. }
  98066. #else
  98067. gl_Position=viewProjection*worldPos;
  98068. #endif
  98069. #if DEBUGMODE>0
  98070. vClipSpacePosition=gl_Position;
  98071. #endif
  98072. #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
  98073. vDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));
  98074. #endif
  98075. #ifndef UV1
  98076. vec2 uvUpdated=vec2(0.,0.);
  98077. #endif
  98078. #ifdef MAINUV1
  98079. vMainUV1=uvUpdated;
  98080. #endif
  98081. #include<uvVariableDeclaration>[2..7]
  98082. #include<samplerVertexImplementation>(_DEFINENAME_,ALBEDO,_VARYINGNAME_,Albedo,_MATRIXNAME_,albedo,_INFONAME_,AlbedoInfos.x)
  98083. #include<samplerVertexImplementation>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_MATRIXNAME_,detail,_INFONAME_,DetailInfos.x)
  98084. #include<samplerVertexImplementation>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_MATRIXNAME_,ambient,_INFONAME_,AmbientInfos.x)
  98085. #include<samplerVertexImplementation>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_MATRIXNAME_,opacity,_INFONAME_,OpacityInfos.x)
  98086. #include<samplerVertexImplementation>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_MATRIXNAME_,emissive,_INFONAME_,EmissiveInfos.x)
  98087. #include<samplerVertexImplementation>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_MATRIXNAME_,lightmap,_INFONAME_,LightmapInfos.x)
  98088. #include<samplerVertexImplementation>(_DEFINENAME_,REFLECTIVITY,_VARYINGNAME_,Reflectivity,_MATRIXNAME_,reflectivity,_INFONAME_,ReflectivityInfos.x)
  98089. #include<samplerVertexImplementation>(_DEFINENAME_,MICROSURFACEMAP,_VARYINGNAME_,MicroSurfaceSampler,_MATRIXNAME_,microSurfaceSampler,_INFONAME_,MicroSurfaceSamplerInfos.x)
  98090. #include<samplerVertexImplementation>(_DEFINENAME_,METALLIC_REFLECTANCE,_VARYINGNAME_,MetallicReflectance,_MATRIXNAME_,metallicReflectance,_INFONAME_,MetallicReflectanceInfos.x)
  98091. #include<samplerVertexImplementation>(_DEFINENAME_,REFLECTANCE,_VARYINGNAME_,Reflectance,_MATRIXNAME_,reflectance,_INFONAME_,ReflectanceInfos.x)
  98092. #include<samplerVertexImplementation>(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_MATRIXNAME_,bump,_INFONAME_,BumpInfos.x)
  98093. #ifdef CLEARCOAT
  98094. #include<samplerVertexImplementation>(_DEFINENAME_,CLEARCOAT_TEXTURE,_VARYINGNAME_,ClearCoat,_MATRIXNAME_,clearCoat,_INFONAME_,ClearCoatInfos.x)
  98095. #include<samplerVertexImplementation>(_DEFINENAME_,CLEARCOAT_TEXTURE_ROUGHNESS,_VARYINGNAME_,ClearCoatRoughness,_MATRIXNAME_,clearCoatRoughness,_INFONAME_,ClearCoatInfos.z)
  98096. #include<samplerVertexImplementation>(_DEFINENAME_,CLEARCOAT_BUMP,_VARYINGNAME_,ClearCoatBump,_MATRIXNAME_,clearCoatBump,_INFONAME_,ClearCoatBumpInfos.x)
  98097. #include<samplerVertexImplementation>(_DEFINENAME_,CLEARCOAT_TINT_TEXTURE,_VARYINGNAME_,ClearCoatTint,_MATRIXNAME_,clearCoatTint,_INFONAME_,ClearCoatTintInfos.x)
  98098. #endif
  98099. #ifdef SHEEN
  98100. #include<samplerVertexImplementation>(_DEFINENAME_,SHEEN_TEXTURE,_VARYINGNAME_,Sheen,_MATRIXNAME_,sheen,_INFONAME_,SheenInfos.x)
  98101. #include<samplerVertexImplementation>(_DEFINENAME_,SHEEN_TEXTURE_ROUGHNESS,_VARYINGNAME_,SheenRoughness,_MATRIXNAME_,sheen,_INFONAME_,SheenInfos.z)
  98102. #endif
  98103. #ifdef ANISOTROPIC
  98104. #include<samplerVertexImplementation>(_DEFINENAME_,ANISOTROPIC_TEXTURE,_VARYINGNAME_,Anisotropy,_MATRIXNAME_,anisotropy,_INFONAME_,AnisotropyInfos.x)
  98105. #endif
  98106. #ifdef SUBSURFACE
  98107. #include<samplerVertexImplementation>(_DEFINENAME_,SS_THICKNESSANDMASK_TEXTURE,_VARYINGNAME_,Thickness,_MATRIXNAME_,thickness,_INFONAME_,ThicknessInfos.x)
  98108. #include<samplerVertexImplementation>(_DEFINENAME_,SS_REFRACTIONINTENSITY_TEXTURE,_VARYINGNAME_,RefractionIntensity,_MATRIXNAME_,refractionIntensity,_INFONAME_,RefractionIntensityInfos.x)
  98109. #include<samplerVertexImplementation>(_DEFINENAME_,SS_TRANSLUCENCYINTENSITY_TEXTURE,_VARYINGNAME_,TranslucencyIntensity,_MATRIXNAME_,translucencyIntensity,_INFONAME_,TranslucencyIntensityInfos.x)
  98110. #endif
  98111. #include<bumpVertex>
  98112. #include<clipPlaneVertex>
  98113. #include<fogVertex>
  98114. #include<shadowsVertex>[0..maxSimultaneousLights]
  98115. #ifdef VERTEXCOLOR
  98116. vColor=color;
  98117. #endif
  98118. #ifdef POINTSIZE
  98119. gl_PointSize=pointSize;
  98120. #endif
  98121. #include<logDepthVertex>
  98122. #define CUSTOM_VERTEX_MAIN_END
  98123. }`;
  98124. ShaderStore.ShadersStore[name$E] = shader$E;
  98125. var onCreatedEffectParameters = {
  98126. effect: null,
  98127. subMesh: null
  98128. }
  98129. , PBRMaterialDefines = function(a) {
  98130. __extends(e, a);
  98131. function e() {
  98132. var i = a.call(this) || this;
  98133. return i.PBR = !0,
  98134. i.NUM_SAMPLES = "0",
  98135. i.REALTIME_FILTERING = !1,
  98136. i.MAINUV1 = !1,
  98137. i.MAINUV2 = !1,
  98138. i.MAINUV3 = !1,
  98139. i.MAINUV4 = !1,
  98140. i.MAINUV5 = !1,
  98141. i.MAINUV6 = !1,
  98142. i.UV1 = !1,
  98143. i.UV2 = !1,
  98144. i.UV3 = !1,
  98145. i.UV4 = !1,
  98146. i.UV5 = !1,
  98147. i.UV6 = !1,
  98148. i.ALBEDO = !1,
  98149. i.GAMMAALBEDO = !1,
  98150. i.ALBEDODIRECTUV = 0,
  98151. i.VERTEXCOLOR = !1,
  98152. i.DETAIL = !1,
  98153. i.DETAILDIRECTUV = 0,
  98154. i.DETAIL_NORMALBLENDMETHOD = 0,
  98155. i.BAKED_VERTEX_ANIMATION_TEXTURE = !1,
  98156. i.AMBIENT = !1,
  98157. i.AMBIENTDIRECTUV = 0,
  98158. i.AMBIENTINGRAYSCALE = !1,
  98159. i.OPACITY = !1,
  98160. i.VERTEXALPHA = !1,
  98161. i.OPACITYDIRECTUV = 0,
  98162. i.OPACITYRGB = !1,
  98163. i.ALPHATEST = !1,
  98164. i.DEPTHPREPASS = !1,
  98165. i.ALPHABLEND = !1,
  98166. i.ALPHAFROMALBEDO = !1,
  98167. i.ALPHATESTVALUE = "0.5",
  98168. i.SPECULAROVERALPHA = !1,
  98169. i.RADIANCEOVERALPHA = !1,
  98170. i.ALPHAFRESNEL = !1,
  98171. i.LINEARALPHAFRESNEL = !1,
  98172. i.PREMULTIPLYALPHA = !1,
  98173. i.EMISSIVE = !1,
  98174. i.EMISSIVEDIRECTUV = 0,
  98175. i.GAMMAEMISSIVE = !1,
  98176. i.REFLECTIVITY = !1,
  98177. i.REFLECTIVITY_GAMMA = !1,
  98178. i.REFLECTIVITYDIRECTUV = 0,
  98179. i.SPECULARTERM = !1,
  98180. i.MICROSURFACEFROMREFLECTIVITYMAP = !1,
  98181. i.MICROSURFACEAUTOMATIC = !1,
  98182. i.LODBASEDMICROSFURACE = !1,
  98183. i.MICROSURFACEMAP = !1,
  98184. i.MICROSURFACEMAPDIRECTUV = 0,
  98185. i.METALLICWORKFLOW = !1,
  98186. i.ROUGHNESSSTOREINMETALMAPALPHA = !1,
  98187. i.ROUGHNESSSTOREINMETALMAPGREEN = !1,
  98188. i.METALLNESSSTOREINMETALMAPBLUE = !1,
  98189. i.AOSTOREINMETALMAPRED = !1,
  98190. i.METALLIC_REFLECTANCE = !1,
  98191. i.METALLIC_REFLECTANCE_GAMMA = !1,
  98192. i.METALLIC_REFLECTANCEDIRECTUV = 0,
  98193. i.METALLIC_REFLECTANCE_USE_ALPHA_ONLY = !1,
  98194. i.REFLECTANCE = !1,
  98195. i.REFLECTANCE_GAMMA = !1,
  98196. i.REFLECTANCEDIRECTUV = 0,
  98197. i.ENVIRONMENTBRDF = !1,
  98198. i.ENVIRONMENTBRDF_RGBD = !1,
  98199. i.NORMAL = !1,
  98200. i.TANGENT = !1,
  98201. i.BUMP = !1,
  98202. i.BUMPDIRECTUV = 0,
  98203. i.OBJECTSPACE_NORMALMAP = !1,
  98204. i.PARALLAX = !1,
  98205. i.PARALLAXOCCLUSION = !1,
  98206. i.NORMALXYSCALE = !0,
  98207. i.LIGHTMAP = !1,
  98208. i.LIGHTMAPDIRECTUV = 0,
  98209. i.USELIGHTMAPASSHADOWMAP = !1,
  98210. i.GAMMALIGHTMAP = !1,
  98211. i.RGBDLIGHTMAP = !1,
  98212. i.REFLECTION = !1,
  98213. i.REFLECTIONMAP_3D = !1,
  98214. i.REFLECTIONMAP_SPHERICAL = !1,
  98215. i.REFLECTIONMAP_PLANAR = !1,
  98216. i.REFLECTIONMAP_CUBIC = !1,
  98217. i.USE_LOCAL_REFLECTIONMAP_CUBIC = !1,
  98218. i.REFLECTIONMAP_PROJECTION = !1,
  98219. i.REFLECTIONMAP_SKYBOX = !1,
  98220. i.REFLECTIONMAP_EXPLICIT = !1,
  98221. i.REFLECTIONMAP_EQUIRECTANGULAR = !1,
  98222. i.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !1,
  98223. i.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !1,
  98224. i.INVERTCUBICMAP = !1,
  98225. i.USESPHERICALFROMREFLECTIONMAP = !1,
  98226. i.USEIRRADIANCEMAP = !1,
  98227. i.SPHERICAL_HARMONICS = !1,
  98228. i.USESPHERICALINVERTEX = !1,
  98229. i.REFLECTIONMAP_OPPOSITEZ = !1,
  98230. i.LODINREFLECTIONALPHA = !1,
  98231. i.GAMMAREFLECTION = !1,
  98232. i.RGBDREFLECTION = !1,
  98233. i.LINEARSPECULARREFLECTION = !1,
  98234. i.RADIANCEOCCLUSION = !1,
  98235. i.HORIZONOCCLUSION = !1,
  98236. i.INSTANCES = !1,
  98237. i.THIN_INSTANCES = !1,
  98238. i.PREPASS = !1,
  98239. i.PREPASS_IRRADIANCE = !1,
  98240. i.PREPASS_IRRADIANCE_INDEX = -1,
  98241. i.PREPASS_ALBEDO_SQRT = !1,
  98242. i.PREPASS_ALBEDO_SQRT_INDEX = -1,
  98243. i.PREPASS_DEPTH = !1,
  98244. i.PREPASS_DEPTH_INDEX = -1,
  98245. i.PREPASS_NORMAL = !1,
  98246. i.PREPASS_NORMAL_INDEX = -1,
  98247. i.PREPASS_POSITION = !1,
  98248. i.PREPASS_POSITION_INDEX = -1,
  98249. i.PREPASS_VELOCITY = !1,
  98250. i.PREPASS_VELOCITY_INDEX = -1,
  98251. i.PREPASS_REFLECTIVITY = !1,
  98252. i.PREPASS_REFLECTIVITY_INDEX = -1,
  98253. i.SCENE_MRT_COUNT = 0,
  98254. i.NUM_BONE_INFLUENCERS = 0,
  98255. i.BonesPerMesh = 0,
  98256. i.BONETEXTURE = !1,
  98257. i.BONES_VELOCITY_ENABLED = !1,
  98258. i.NONUNIFORMSCALING = !1,
  98259. i.MORPHTARGETS = !1,
  98260. i.MORPHTARGETS_NORMAL = !1,
  98261. i.MORPHTARGETS_TANGENT = !1,
  98262. i.MORPHTARGETS_UV = !1,
  98263. i.NUM_MORPH_INFLUENCERS = 0,
  98264. i.MORPHTARGETS_TEXTURE = !1,
  98265. i.IMAGEPROCESSING = !1,
  98266. i.VIGNETTE = !1,
  98267. i.VIGNETTEBLENDMODEMULTIPLY = !1,
  98268. i.VIGNETTEBLENDMODEOPAQUE = !1,
  98269. i.TONEMAPPING = !1,
  98270. i.TONEMAPPING_ACES = !1,
  98271. i.CONTRAST = !1,
  98272. i.COLORCURVES = !1,
  98273. i.COLORGRADING = !1,
  98274. i.COLORGRADING3D = !1,
  98275. i.SAMPLER3DGREENDEPTH = !1,
  98276. i.SAMPLER3DBGRMAP = !1,
  98277. i.IMAGEPROCESSINGPOSTPROCESS = !1,
  98278. i.SKIPFINALCOLORCLAMP = !1,
  98279. i.EXPOSURE = !1,
  98280. i.MULTIVIEW = !1,
  98281. i.ORDER_INDEPENDENT_TRANSPARENCY = !1,
  98282. i.ORDER_INDEPENDENT_TRANSPARENCY_16BITS = !1,
  98283. i.USEPHYSICALLIGHTFALLOFF = !1,
  98284. i.USEGLTFLIGHTFALLOFF = !1,
  98285. i.TWOSIDEDLIGHTING = !1,
  98286. i.SHADOWFLOAT = !1,
  98287. i.CLIPPLANE = !1,
  98288. i.CLIPPLANE2 = !1,
  98289. i.CLIPPLANE3 = !1,
  98290. i.CLIPPLANE4 = !1,
  98291. i.CLIPPLANE5 = !1,
  98292. i.CLIPPLANE6 = !1,
  98293. i.POINTSIZE = !1,
  98294. i.FOG = !1,
  98295. i.LOGARITHMICDEPTH = !1,
  98296. i.FORCENORMALFORWARD = !1,
  98297. i.SPECULARAA = !1,
  98298. i.CLEARCOAT = !1,
  98299. i.CLEARCOAT_DEFAULTIOR = !1,
  98300. i.CLEARCOAT_TEXTURE = !1,
  98301. i.CLEARCOAT_TEXTURE_ROUGHNESS = !1,
  98302. i.CLEARCOAT_TEXTUREDIRECTUV = 0,
  98303. i.CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV = 0,
  98304. i.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE = !1,
  98305. i.CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL = !1,
  98306. i.CLEARCOAT_BUMP = !1,
  98307. i.CLEARCOAT_BUMPDIRECTUV = 0,
  98308. i.CLEARCOAT_REMAP_F0 = !0,
  98309. i.CLEARCOAT_TINT = !1,
  98310. i.CLEARCOAT_TINT_TEXTURE = !1,
  98311. i.CLEARCOAT_TINT_GAMMATEXTURE = !1,
  98312. i.CLEARCOAT_TINT_TEXTUREDIRECTUV = 0,
  98313. i.ANISOTROPIC = !1,
  98314. i.ANISOTROPIC_TEXTURE = !1,
  98315. i.ANISOTROPIC_TEXTUREDIRECTUV = 0,
  98316. i.BRDF_V_HEIGHT_CORRELATED = !1,
  98317. i.MS_BRDF_ENERGY_CONSERVATION = !1,
  98318. i.SPECULAR_GLOSSINESS_ENERGY_CONSERVATION = !1,
  98319. i.SHEEN = !1,
  98320. i.SHEEN_TEXTURE = !1,
  98321. i.SHEEN_GAMMATEXTURE = !1,
  98322. i.SHEEN_TEXTURE_ROUGHNESS = !1,
  98323. i.SHEEN_TEXTUREDIRECTUV = 0,
  98324. i.SHEEN_TEXTURE_ROUGHNESSDIRECTUV = 0,
  98325. i.SHEEN_LINKWITHALBEDO = !1,
  98326. i.SHEEN_ROUGHNESS = !1,
  98327. i.SHEEN_ALBEDOSCALING = !1,
  98328. i.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE = !1,
  98329. i.SHEEN_TEXTURE_ROUGHNESS_IDENTICAL = !1,
  98330. i.SUBSURFACE = !1,
  98331. i.SS_REFRACTION = !1,
  98332. i.SS_REFRACTION_USE_INTENSITY_FROM_TEXTURE = !1,
  98333. i.SS_TRANSLUCENCY = !1,
  98334. i.SS_TRANSLUCENCY_USE_INTENSITY_FROM_TEXTURE = !1,
  98335. i.SS_SCATTERING = !1,
  98336. i.SS_THICKNESSANDMASK_TEXTURE = !1,
  98337. i.SS_THICKNESSANDMASK_TEXTUREDIRECTUV = 0,
  98338. i.SS_HAS_THICKNESS = !1,
  98339. i.SS_REFRACTIONINTENSITY_TEXTURE = !1,
  98340. i.SS_REFRACTIONINTENSITY_TEXTUREDIRECTUV = 0,
  98341. i.SS_TRANSLUCENCYINTENSITY_TEXTURE = !1,
  98342. i.SS_TRANSLUCENCYINTENSITY_TEXTUREDIRECTUV = 0,
  98343. i.SS_REFRACTIONMAP_3D = !1,
  98344. i.SS_REFRACTIONMAP_OPPOSITEZ = !1,
  98345. i.SS_LODINREFRACTIONALPHA = !1,
  98346. i.SS_GAMMAREFRACTION = !1,
  98347. i.SS_RGBDREFRACTION = !1,
  98348. i.SS_LINEARSPECULARREFRACTION = !1,
  98349. i.SS_LINKREFRACTIONTOTRANSPARENCY = !1,
  98350. i.SS_ALBEDOFORREFRACTIONTINT = !1,
  98351. i.SS_ALBEDOFORTRANSLUCENCYTINT = !1,
  98352. i.SS_USE_LOCAL_REFRACTIONMAP_CUBIC = !1,
  98353. i.SS_USE_THICKNESS_AS_DEPTH = !1,
  98354. i.SS_MASK_FROM_THICKNESS_TEXTURE = !1,
  98355. i.SS_USE_GLTF_TEXTURES = !1,
  98356. i.UNLIT = !1,
  98357. i.DEBUGMODE = 0,
  98358. i.rebuild(),
  98359. i
  98360. }
  98361. return e.prototype.reset = function() {
  98362. a.prototype.reset.call(this),
  98363. this.ALPHATESTVALUE = "0.5",
  98364. this.PBR = !0,
  98365. this.NORMALXYSCALE = !0
  98366. }
  98367. ,
  98368. e
  98369. }(MaterialDefines)
  98370. , PBRBaseMaterial = function(a) {
  98371. __extends(e, a);
  98372. function e(i, o) {
  98373. var s = a.call(this, i, o) || this;
  98374. return s._directIntensity = 1,
  98375. s._emissiveIntensity = 1,
  98376. s._environmentIntensity = 1,
  98377. s._specularIntensity = 1,
  98378. s._lightingInfos = new Vector4(s._directIntensity,s._emissiveIntensity,s._environmentIntensity,s._specularIntensity),
  98379. s._disableBumpMap = !1,
  98380. s._albedoTexture = null,
  98381. s._ambientTexture = null,
  98382. s._ambientTextureStrength = 1,
  98383. s._ambientTextureImpactOnAnalyticalLights = e.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,
  98384. s._opacityTexture = null,
  98385. s._reflectionTexture = null,
  98386. s._emissiveTexture = null,
  98387. s._reflectivityTexture = null,
  98388. s._metallicTexture = null,
  98389. s._metallic = null,
  98390. s._roughness = null,
  98391. s._metallicF0Factor = 1,
  98392. s._metallicReflectanceColor = Color3.White(),
  98393. s._useOnlyMetallicFromMetallicReflectanceTexture = !1,
  98394. s._metallicReflectanceTexture = null,
  98395. s._reflectanceTexture = null,
  98396. s._microSurfaceTexture = null,
  98397. s._bumpTexture = null,
  98398. s._lightmapTexture = null,
  98399. s._ambientColor = new Color3(0,0,0),
  98400. s._albedoColor = new Color3(1,1,1),
  98401. s._reflectivityColor = new Color3(1,1,1),
  98402. s._reflectionColor = new Color3(1,1,1),
  98403. s._emissiveColor = new Color3(0,0,0),
  98404. s._microSurface = .9,
  98405. s._useLightmapAsShadowmap = !1,
  98406. s._useHorizonOcclusion = !0,
  98407. s._useRadianceOcclusion = !0,
  98408. s._useAlphaFromAlbedoTexture = !1,
  98409. s._useSpecularOverAlpha = !0,
  98410. s._useMicroSurfaceFromReflectivityMapAlpha = !1,
  98411. s._useRoughnessFromMetallicTextureAlpha = !0,
  98412. s._useRoughnessFromMetallicTextureGreen = !1,
  98413. s._useMetallnessFromMetallicTextureBlue = !1,
  98414. s._useAmbientOcclusionFromMetallicTextureRed = !1,
  98415. s._useAmbientInGrayScale = !1,
  98416. s._useAutoMicroSurfaceFromReflectivityMap = !1,
  98417. s._lightFalloff = e.LIGHTFALLOFF_PHYSICAL,
  98418. s._useRadianceOverAlpha = !0,
  98419. s._useObjectSpaceNormalMap = !1,
  98420. s._useParallax = !1,
  98421. s._useParallaxOcclusion = !1,
  98422. s._parallaxScaleBias = .05,
  98423. s._disableLighting = !1,
  98424. s._maxSimultaneousLights = 4,
  98425. s._invertNormalMapX = !1,
  98426. s._invertNormalMapY = !1,
  98427. s._twoSidedLighting = !1,
  98428. s._alphaCutOff = .4,
  98429. s._forceAlphaTest = !1,
  98430. s._useAlphaFresnel = !1,
  98431. s._useLinearAlphaFresnel = !1,
  98432. s._environmentBRDFTexture = null,
  98433. s._forceIrradianceInFragment = !1,
  98434. s._realTimeFiltering = !1,
  98435. s._realTimeFilteringQuality = 8,
  98436. s._forceNormalForward = !1,
  98437. s._enableSpecularAntiAliasing = !1,
  98438. s._imageProcessingObserver = null,
  98439. s._renderTargets = new SmartArray(16),
  98440. s._globalAmbientColor = new Color3(0,0,0),
  98441. s._useLogarithmicDepth = !1,
  98442. s._unlit = !1,
  98443. s._debugMode = 0,
  98444. s.debugMode = 0,
  98445. s.debugLimit = -1,
  98446. s.debugFactor = 1,
  98447. s.clearCoat = new PBRClearCoatConfiguration(s._markAllSubMeshesAsTexturesDirty.bind(s)),
  98448. s.anisotropy = new PBRAnisotropicConfiguration(s._markAllSubMeshesAsTexturesDirty.bind(s)),
  98449. s.brdf = new PBRBRDFConfiguration(s._markAllSubMeshesAsMiscDirty.bind(s)),
  98450. s.sheen = new PBRSheenConfiguration(s._markAllSubMeshesAsTexturesDirty.bind(s)),
  98451. s.detailMap = new DetailMapConfiguration(s._markAllSubMeshesAsTexturesDirty.bind(s)),
  98452. s.buildUniformLayout(),
  98453. s._attachImageProcessingConfiguration(null),
  98454. s.getRenderTargetTextures = function() {
  98455. return s._renderTargets.reset(),
  98456. MaterialFlags.ReflectionTextureEnabled && s._reflectionTexture && s._reflectionTexture.isRenderTarget && s._renderTargets.push(s._reflectionTexture),
  98457. s.subSurface.fillRenderTargetTextures(s._renderTargets),
  98458. s._renderTargets
  98459. }
  98460. ,
  98461. s._environmentBRDFTexture = GetEnvironmentBRDFTexture(o),
  98462. s.subSurface = new PBRSubSurfaceConfiguration(s._markAllSubMeshesAsTexturesDirty.bind(s),s._markScenePrePassDirty.bind(s),o),
  98463. s.prePassConfiguration = new PrePassConfiguration,
  98464. s
  98465. }
  98466. return Object.defineProperty(e.prototype, "realTimeFiltering", {
  98467. get: function() {
  98468. return this._realTimeFiltering
  98469. },
  98470. set: function(i) {
  98471. this._realTimeFiltering = i,
  98472. this.markAsDirty(1)
  98473. },
  98474. enumerable: !1,
  98475. configurable: !0
  98476. }),
  98477. Object.defineProperty(e.prototype, "realTimeFilteringQuality", {
  98478. get: function() {
  98479. return this._realTimeFilteringQuality
  98480. },
  98481. set: function(i) {
  98482. this._realTimeFilteringQuality = i,
  98483. this.markAsDirty(1)
  98484. },
  98485. enumerable: !1,
  98486. configurable: !0
  98487. }),
  98488. Object.defineProperty(e.prototype, "canRenderToMRT", {
  98489. get: function() {
  98490. return !0
  98491. },
  98492. enumerable: !1,
  98493. configurable: !0
  98494. }),
  98495. e.prototype._attachImageProcessingConfiguration = function(i) {
  98496. var o = this;
  98497. i !== this._imageProcessingConfiguration && (this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),
  98498. i ? this._imageProcessingConfiguration = i : this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration,
  98499. this._imageProcessingConfiguration && (this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function() {
  98500. o._markAllSubMeshesAsImageProcessingDirty()
  98501. })))
  98502. }
  98503. ,
  98504. Object.defineProperty(e.prototype, "hasRenderTargetTextures", {
  98505. get: function() {
  98506. return MaterialFlags.ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget ? !0 : this.subSurface.hasRenderTargetTextures()
  98507. },
  98508. enumerable: !1,
  98509. configurable: !0
  98510. }),
  98511. Object.defineProperty(e.prototype, "isPrePassCapable", {
  98512. get: function() {
  98513. return !this.disableDepthWrite
  98514. },
  98515. enumerable: !1,
  98516. configurable: !0
  98517. }),
  98518. e.prototype.getClassName = function() {
  98519. return "PBRBaseMaterial"
  98520. }
  98521. ,
  98522. Object.defineProperty(e.prototype, "useLogarithmicDepth", {
  98523. get: function() {
  98524. return this._useLogarithmicDepth
  98525. },
  98526. set: function(i) {
  98527. this._useLogarithmicDepth = i && this.getScene().getEngine().getCaps().fragmentDepthSupported
  98528. },
  98529. enumerable: !1,
  98530. configurable: !0
  98531. }),
  98532. Object.defineProperty(e.prototype, "_disableAlphaBlending", {
  98533. get: function() {
  98534. return this.subSurface.disableAlphaBlending || this._transparencyMode === e.PBRMATERIAL_OPAQUE || this._transparencyMode === e.PBRMATERIAL_ALPHATEST
  98535. },
  98536. enumerable: !1,
  98537. configurable: !0
  98538. }),
  98539. e.prototype.needAlphaBlending = function() {
  98540. return this._disableAlphaBlending ? !1 : this.alpha < 1 || this._opacityTexture != null || this._shouldUseAlphaFromAlbedoTexture()
  98541. }
  98542. ,
  98543. e.prototype.needAlphaTesting = function() {
  98544. return this._forceAlphaTest ? !0 : this.subSurface.disableAlphaBlending ? !1 : this._hasAlphaChannel() && (this._transparencyMode == null || this._transparencyMode === e.PBRMATERIAL_ALPHATEST)
  98545. }
  98546. ,
  98547. e.prototype._shouldUseAlphaFromAlbedoTexture = function() {
  98548. return this._albedoTexture != null && this._albedoTexture.hasAlpha && this._useAlphaFromAlbedoTexture && this._transparencyMode !== e.PBRMATERIAL_OPAQUE
  98549. }
  98550. ,
  98551. e.prototype._hasAlphaChannel = function() {
  98552. return this._albedoTexture != null && this._albedoTexture.hasAlpha || this._opacityTexture != null
  98553. }
  98554. ,
  98555. e.prototype.getAlphaTestTexture = function() {
  98556. return this._albedoTexture
  98557. }
  98558. ,
  98559. e.prototype.isReadyForSubMesh = function(i, o, s) {
  98560. if (o.effect && this.isFrozen && o.effect._wasPreviouslyReady)
  98561. return !0;
  98562. o.materialDefines || (o.materialDefines = new PBRMaterialDefines);
  98563. var c = o.materialDefines;
  98564. if (this._isReadyForSubMesh(o))
  98565. return !0;
  98566. var d = this.getScene()
  98567. , _ = d.getEngine();
  98568. if (c._areTexturesDirty && d.texturesEnabled) {
  98569. if (this._albedoTexture && MaterialFlags.DiffuseTextureEnabled && !this._albedoTexture.isReadyOrNotBlocking() || this._ambientTexture && MaterialFlags.AmbientTextureEnabled && !this._ambientTexture.isReadyOrNotBlocking() || this._opacityTexture && MaterialFlags.OpacityTextureEnabled && !this._opacityTexture.isReadyOrNotBlocking())
  98570. return !1;
  98571. var b = this._getReflectionTexture();
  98572. if (b && MaterialFlags.ReflectionTextureEnabled && (!b.isReadyOrNotBlocking() || b.irradianceTexture && !b.irradianceTexture.isReadyOrNotBlocking()) || this._lightmapTexture && MaterialFlags.LightmapTextureEnabled && !this._lightmapTexture.isReadyOrNotBlocking() || this._emissiveTexture && MaterialFlags.EmissiveTextureEnabled && !this._emissiveTexture.isReadyOrNotBlocking())
  98573. return !1;
  98574. if (MaterialFlags.SpecularTextureEnabled) {
  98575. if (this._metallicTexture) {
  98576. if (!this._metallicTexture.isReadyOrNotBlocking())
  98577. return !1
  98578. } else if (this._reflectivityTexture && !this._reflectivityTexture.isReadyOrNotBlocking())
  98579. return !1;
  98580. if (this._metallicReflectanceTexture && !this._metallicReflectanceTexture.isReadyOrNotBlocking() || this._reflectanceTexture && !this._reflectanceTexture.isReadyOrNotBlocking() || this._microSurfaceTexture && !this._microSurfaceTexture.isReadyOrNotBlocking())
  98581. return !1
  98582. }
  98583. if (_.getCaps().standardDerivatives && this._bumpTexture && MaterialFlags.BumpTextureEnabled && !this._disableBumpMap && !this._bumpTexture.isReady() || this._environmentBRDFTexture && MaterialFlags.ReflectionTextureEnabled && !this._environmentBRDFTexture.isReady())
  98584. return !1
  98585. }
  98586. if (!this.subSurface.isReadyForSubMesh(c, d) || !this.clearCoat.isReadyForSubMesh(c, d, _, this._disableBumpMap) || !this.sheen.isReadyForSubMesh(c, d) || !this.anisotropy.isReadyForSubMesh(c, d) || !this.detailMap.isReadyForSubMesh(c, d) || c._areImageProcessingDirty && this._imageProcessingConfiguration && !this._imageProcessingConfiguration.isReady())
  98587. return !1;
  98588. !_.getCaps().standardDerivatives && !i.isVerticesDataPresent(VertexBuffer.NormalKind) && (i.createNormals(!0),
  98589. Logger$2.Warn("PBRMaterial: Normals have been created for the mesh: " + i.name));
  98590. var k = o.effect
  98591. , j = c._areLightsDisposed
  98592. , $ = this._prepareEffect(i, c, this.onCompiled, this.onError, s, null, o.getRenderingMesh().hasThinInstances);
  98593. if ($)
  98594. if (this._onEffectCreatedObservable && (onCreatedEffectParameters.effect = $,
  98595. onCreatedEffectParameters.subMesh = o,
  98596. this._onEffectCreatedObservable.notifyObservers(onCreatedEffectParameters)),
  98597. this.allowShaderHotSwapping && k && !$.isReady()) {
  98598. if ($ = k,
  98599. c.markAsUnprocessed(),
  98600. j)
  98601. return c._areLightsDisposed = !0,
  98602. !1
  98603. } else
  98604. d.resetCachedMaterial(),
  98605. o.setEffect($, c, this._materialContext);
  98606. return !o.effect || !o.effect.isReady() ? !1 : (c._renderId = d.getRenderId(),
  98607. o.effect._wasPreviouslyReady = !0,
  98608. !0)
  98609. }
  98610. ,
  98611. e.prototype.isMetallicWorkflow = function() {
  98612. return !!(this._metallic != null || this._roughness != null || this._metallicTexture)
  98613. }
  98614. ,
  98615. e.prototype._prepareEffect = function(i, o, s, c, d, _, b) {
  98616. if (s === void 0 && (s = null),
  98617. c === void 0 && (c = null),
  98618. d === void 0 && (d = null),
  98619. _ === void 0 && (_ = null),
  98620. this._prepareDefines(i, o, d, _, b),
  98621. !o.isDirty)
  98622. return null;
  98623. o.markAsProcessed();
  98624. var k = this.getScene()
  98625. , j = k.getEngine()
  98626. , $ = new EffectFallbacks
  98627. , _e = 0;
  98628. o.USESPHERICALINVERTEX && $.addFallback(_e++, "USESPHERICALINVERTEX"),
  98629. o.FOG && $.addFallback(_e, "FOG"),
  98630. o.SPECULARAA && $.addFallback(_e, "SPECULARAA"),
  98631. o.POINTSIZE && $.addFallback(_e, "POINTSIZE"),
  98632. o.LOGARITHMICDEPTH && $.addFallback(_e, "LOGARITHMICDEPTH"),
  98633. o.PARALLAX && $.addFallback(_e, "PARALLAX"),
  98634. o.PARALLAXOCCLUSION && $.addFallback(_e++, "PARALLAXOCCLUSION"),
  98635. _e = PBRClearCoatConfiguration.AddFallbacks(o, $, _e),
  98636. _e = PBRAnisotropicConfiguration.AddFallbacks(o, $, _e),
  98637. _e = PBRSubSurfaceConfiguration.AddFallbacks(o, $, _e),
  98638. _e = PBRSheenConfiguration.AddFallbacks(o, $, _e),
  98639. o.ENVIRONMENTBRDF && $.addFallback(_e++, "ENVIRONMENTBRDF"),
  98640. o.TANGENT && $.addFallback(_e++, "TANGENT"),
  98641. o.BUMP && $.addFallback(_e++, "BUMP"),
  98642. _e = MaterialHelper.HandleFallbacksForShadows(o, $, this._maxSimultaneousLights, _e++),
  98643. o.SPECULARTERM && $.addFallback(_e++, "SPECULARTERM"),
  98644. o.USESPHERICALFROMREFLECTIONMAP && $.addFallback(_e++, "USESPHERICALFROMREFLECTIONMAP"),
  98645. o.USEIRRADIANCEMAP && $.addFallback(_e++, "USEIRRADIANCEMAP"),
  98646. o.LIGHTMAP && $.addFallback(_e++, "LIGHTMAP"),
  98647. o.NORMAL && $.addFallback(_e++, "NORMAL"),
  98648. o.AMBIENT && $.addFallback(_e++, "AMBIENT"),
  98649. o.EMISSIVE && $.addFallback(_e++, "EMISSIVE"),
  98650. o.VERTEXCOLOR && $.addFallback(_e++, "VERTEXCOLOR"),
  98651. o.MORPHTARGETS && $.addFallback(_e++, "MORPHTARGETS"),
  98652. o.MULTIVIEW && $.addFallback(0, "MULTIVIEW");
  98653. var et = [VertexBuffer.PositionKind];
  98654. o.NORMAL && et.push(VertexBuffer.NormalKind),
  98655. o.TANGENT && et.push(VertexBuffer.TangentKind);
  98656. for (var tt = 1; tt <= 6; ++tt)
  98657. o["UV" + tt] && et.push("uv" + (tt === 1 ? "" : tt));
  98658. o.VERTEXCOLOR && et.push(VertexBuffer.ColorKind),
  98659. MaterialHelper.PrepareAttributesForBones(et, i, o, $),
  98660. MaterialHelper.PrepareAttributesForInstances(et, o),
  98661. MaterialHelper.PrepareAttributesForMorphTargets(et, i, o),
  98662. MaterialHelper.PrepareAttributesForBakedVertexAnimation(et, i, o);
  98663. var rt = "pbr"
  98664. , it = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vAlbedoColor", "vReflectivityColor", "vMetallicReflectanceFactors", "vEmissiveColor", "visibility", "vReflectionColor", "vFogInfos", "vFogColor", "pointSize", "vAlbedoInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vReflectionPosition", "vReflectionSize", "vEmissiveInfos", "vReflectivityInfos", "vReflectionFilteringInfo", "vMetallicReflectanceInfos", "vReflectanceInfos", "vMicroSurfaceSamplerInfos", "vBumpInfos", "vLightmapInfos", "mBones", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "albedoMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "reflectivityMatrix", "normalMatrix", "microSurfaceSamplerMatrix", "bumpMatrix", "lightmapMatrix", "metallicReflectanceMatrix", "reflectanceMatrix", "vLightingIntensity", "logarithmicDepthConstant", "vSphericalX", "vSphericalY", "vSphericalZ", "vSphericalXX_ZZ", "vSphericalYY_ZZ", "vSphericalZZ", "vSphericalXY", "vSphericalYZ", "vSphericalZX", "vSphericalL00", "vSphericalL1_1", "vSphericalL10", "vSphericalL11", "vSphericalL2_2", "vSphericalL2_1", "vSphericalL20", "vSphericalL21", "vSphericalL22", "vReflectionMicrosurfaceInfos", "vTangentSpaceParams", "boneTextureWidth", "vDebugMode", "morphTargetTextureInfo", "morphTargetTextureIndices"]
  98665. , nt = ["albedoSampler", "reflectivitySampler", "ambientSampler", "emissiveSampler", "bumpSampler", "lightmapSampler", "opacitySampler", "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh", "irradianceSampler", "microSurfaceSampler", "environmentBrdfSampler", "boneSampler", "metallicReflectanceSampler", "reflectanceSampler", "morphTargets", "oitDepthSampler", "oitFrontColorSampler"]
  98666. , ot = ["Material", "Scene", "Mesh"];
  98667. DetailMapConfiguration.AddUniforms(it),
  98668. DetailMapConfiguration.AddSamplers(nt),
  98669. PBRSubSurfaceConfiguration.AddUniforms(it),
  98670. PBRSubSurfaceConfiguration.AddSamplers(nt),
  98671. PBRClearCoatConfiguration.AddUniforms(it),
  98672. PBRClearCoatConfiguration.AddSamplers(nt),
  98673. PBRAnisotropicConfiguration.AddUniforms(it),
  98674. PBRAnisotropicConfiguration.AddSamplers(nt),
  98675. PBRSheenConfiguration.AddUniforms(it),
  98676. PBRSheenConfiguration.AddSamplers(nt),
  98677. PrePassConfiguration.AddUniforms(it),
  98678. PrePassConfiguration.AddSamplers(nt),
  98679. ImageProcessingConfiguration && (ImageProcessingConfiguration.PrepareUniforms(it, o),
  98680. ImageProcessingConfiguration.PrepareSamplers(nt, o)),
  98681. MaterialHelper.PrepareUniformsAndSamplersList({
  98682. uniformsNames: it,
  98683. uniformBuffersNames: ot,
  98684. samplers: nt,
  98685. defines: o,
  98686. maxSimultaneousLights: this._maxSimultaneousLights
  98687. });
  98688. var at = {};
  98689. this.customShaderNameResolve && (rt = this.customShaderNameResolve(rt, it, ot, nt, o, et, at));
  98690. var st = o.toString();
  98691. return j.createEffect(rt, {
  98692. attributes: et,
  98693. uniformsNames: it,
  98694. uniformBuffersNames: ot,
  98695. samplers: nt,
  98696. defines: st,
  98697. fallbacks: $,
  98698. onCompiled: s,
  98699. onError: c,
  98700. indexParameters: {
  98701. maxSimultaneousLights: this._maxSimultaneousLights,
  98702. maxSimultaneousMorphTargets: o.NUM_MORPH_INFLUENCERS
  98703. },
  98704. processFinalCode: at.processFinalCode,
  98705. multiTarget: o.PREPASS
  98706. }, j)
  98707. }
  98708. ,
  98709. e.prototype._prepareDefines = function(i, o, s, c, d) {
  98710. var _;
  98711. s === void 0 && (s = null),
  98712. c === void 0 && (c = null),
  98713. d === void 0 && (d = !1);
  98714. var b = this.getScene()
  98715. , k = b.getEngine();
  98716. MaterialHelper.PrepareDefinesForLights(b, i, o, !0, this._maxSimultaneousLights, this._disableLighting),
  98717. o._needNormals = !0,
  98718. MaterialHelper.PrepareDefinesForMultiview(b, o);
  98719. var j = this.needAlphaBlendingForMesh(i) && this.getScene().useOrderIndependentTransparency;
  98720. if (MaterialHelper.PrepareDefinesForPrePass(b, o, this.canRenderToMRT && !j),
  98721. MaterialHelper.PrepareDefinesForOIT(b, o, j),
  98722. o.METALLICWORKFLOW = this.isMetallicWorkflow(),
  98723. o._areTexturesDirty) {
  98724. if (o._needUVs = !1,
  98725. b.texturesEnabled) {
  98726. b.getEngine().getCaps().textureLOD && (o.LODBASEDMICROSFURACE = !0),
  98727. this._albedoTexture && MaterialFlags.DiffuseTextureEnabled ? (MaterialHelper.PrepareDefinesForMergedUV(this._albedoTexture, o, "ALBEDO"),
  98728. o.GAMMAALBEDO = this._albedoTexture.gammaSpace) : o.ALBEDO = !1,
  98729. this._ambientTexture && MaterialFlags.AmbientTextureEnabled ? (MaterialHelper.PrepareDefinesForMergedUV(this._ambientTexture, o, "AMBIENT"),
  98730. o.AMBIENTINGRAYSCALE = this._useAmbientInGrayScale) : o.AMBIENT = !1,
  98731. this._opacityTexture && MaterialFlags.OpacityTextureEnabled ? (MaterialHelper.PrepareDefinesForMergedUV(this._opacityTexture, o, "OPACITY"),
  98732. o.OPACITYRGB = this._opacityTexture.getAlphaFromRGB) : o.OPACITY = !1;
  98733. var $ = this._getReflectionTexture();
  98734. if ($ && MaterialFlags.ReflectionTextureEnabled) {
  98735. switch (o.REFLECTION = !0,
  98736. o.GAMMAREFLECTION = $.gammaSpace,
  98737. o.RGBDREFLECTION = $.isRGBD,
  98738. o.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !$.invertZ : $.invertZ,
  98739. o.LODINREFLECTIONALPHA = $.lodLevelInAlpha,
  98740. o.LINEARSPECULARREFLECTION = $.linearSpecularLOD,
  98741. this.realTimeFiltering && this.realTimeFilteringQuality > 0 ? (o.NUM_SAMPLES = "" + this.realTimeFilteringQuality,
  98742. k._features.needTypeSuffixInShaderConstants && (o.NUM_SAMPLES = o.NUM_SAMPLES + "u"),
  98743. o.REALTIME_FILTERING = !0) : o.REALTIME_FILTERING = !1,
  98744. $.coordinatesMode === Texture.INVCUBIC_MODE && (o.INVERTCUBICMAP = !0),
  98745. o.REFLECTIONMAP_3D = $.isCube,
  98746. o.REFLECTIONMAP_CUBIC = !1,
  98747. o.REFLECTIONMAP_EXPLICIT = !1,
  98748. o.REFLECTIONMAP_PLANAR = !1,
  98749. o.REFLECTIONMAP_PROJECTION = !1,
  98750. o.REFLECTIONMAP_SKYBOX = !1,
  98751. o.REFLECTIONMAP_SPHERICAL = !1,
  98752. o.REFLECTIONMAP_EQUIRECTANGULAR = !1,
  98753. o.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !1,
  98754. o.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !1,
  98755. $.coordinatesMode) {
  98756. case Texture.EXPLICIT_MODE:
  98757. o.REFLECTIONMAP_EXPLICIT = !0;
  98758. break;
  98759. case Texture.PLANAR_MODE:
  98760. o.REFLECTIONMAP_PLANAR = !0;
  98761. break;
  98762. case Texture.PROJECTION_MODE:
  98763. o.REFLECTIONMAP_PROJECTION = !0;
  98764. break;
  98765. case Texture.SKYBOX_MODE:
  98766. o.REFLECTIONMAP_SKYBOX = !0;
  98767. break;
  98768. case Texture.SPHERICAL_MODE:
  98769. o.REFLECTIONMAP_SPHERICAL = !0;
  98770. break;
  98771. case Texture.EQUIRECTANGULAR_MODE:
  98772. o.REFLECTIONMAP_EQUIRECTANGULAR = !0;
  98773. break;
  98774. case Texture.FIXED_EQUIRECTANGULAR_MODE:
  98775. o.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !0;
  98776. break;
  98777. case Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  98778. o.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !0;
  98779. break;
  98780. case Texture.CUBIC_MODE:
  98781. case Texture.INVCUBIC_MODE:
  98782. default:
  98783. o.REFLECTIONMAP_CUBIC = !0,
  98784. o.USE_LOCAL_REFLECTIONMAP_CUBIC = !!$.boundingBoxSize;
  98785. break
  98786. }
  98787. $.coordinatesMode !== Texture.SKYBOX_MODE && ($.irradianceTexture ? (o.USEIRRADIANCEMAP = !0,
  98788. o.USESPHERICALFROMREFLECTIONMAP = !1) : $.isCube && (o.USESPHERICALFROMREFLECTIONMAP = !0,
  98789. o.USEIRRADIANCEMAP = !1,
  98790. this._forceIrradianceInFragment || this.realTimeFiltering || b.getEngine().getCaps().maxVaryingVectors <= 8 ? o.USESPHERICALINVERTEX = !1 : o.USESPHERICALINVERTEX = !0))
  98791. } else
  98792. o.REFLECTION = !1,
  98793. o.REFLECTIONMAP_3D = !1,
  98794. o.REFLECTIONMAP_SPHERICAL = !1,
  98795. o.REFLECTIONMAP_PLANAR = !1,
  98796. o.REFLECTIONMAP_CUBIC = !1,
  98797. o.USE_LOCAL_REFLECTIONMAP_CUBIC = !1,
  98798. o.REFLECTIONMAP_PROJECTION = !1,
  98799. o.REFLECTIONMAP_SKYBOX = !1,
  98800. o.REFLECTIONMAP_EXPLICIT = !1,
  98801. o.REFLECTIONMAP_EQUIRECTANGULAR = !1,
  98802. o.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !1,
  98803. o.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !1,
  98804. o.INVERTCUBICMAP = !1,
  98805. o.USESPHERICALFROMREFLECTIONMAP = !1,
  98806. o.USEIRRADIANCEMAP = !1,
  98807. o.USESPHERICALINVERTEX = !1,
  98808. o.REFLECTIONMAP_OPPOSITEZ = !1,
  98809. o.LODINREFLECTIONALPHA = !1,
  98810. o.GAMMAREFLECTION = !1,
  98811. o.RGBDREFLECTION = !1,
  98812. o.LINEARSPECULARREFLECTION = !1;
  98813. if (this._lightmapTexture && MaterialFlags.LightmapTextureEnabled ? (MaterialHelper.PrepareDefinesForMergedUV(this._lightmapTexture, o, "LIGHTMAP"),
  98814. o.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap,
  98815. o.GAMMALIGHTMAP = this._lightmapTexture.gammaSpace,
  98816. o.RGBDLIGHTMAP = this._lightmapTexture.isRGBD) : o.LIGHTMAP = !1,
  98817. this._emissiveTexture && MaterialFlags.EmissiveTextureEnabled ? (MaterialHelper.PrepareDefinesForMergedUV(this._emissiveTexture, o, "EMISSIVE"),
  98818. o.GAMMAEMISSIVE = this._emissiveTexture.gammaSpace) : o.EMISSIVE = !1,
  98819. MaterialFlags.SpecularTextureEnabled) {
  98820. if (this._metallicTexture ? (MaterialHelper.PrepareDefinesForMergedUV(this._metallicTexture, o, "REFLECTIVITY"),
  98821. o.ROUGHNESSSTOREINMETALMAPALPHA = this._useRoughnessFromMetallicTextureAlpha,
  98822. o.ROUGHNESSSTOREINMETALMAPGREEN = !this._useRoughnessFromMetallicTextureAlpha && this._useRoughnessFromMetallicTextureGreen,
  98823. o.METALLNESSSTOREINMETALMAPBLUE = this._useMetallnessFromMetallicTextureBlue,
  98824. o.AOSTOREINMETALMAPRED = this._useAmbientOcclusionFromMetallicTextureRed,
  98825. o.REFLECTIVITY_GAMMA = !1) : this._reflectivityTexture ? (MaterialHelper.PrepareDefinesForMergedUV(this._reflectivityTexture, o, "REFLECTIVITY"),
  98826. o.MICROSURFACEFROMREFLECTIVITYMAP = this._useMicroSurfaceFromReflectivityMapAlpha,
  98827. o.MICROSURFACEAUTOMATIC = this._useAutoMicroSurfaceFromReflectivityMap,
  98828. o.REFLECTIVITY_GAMMA = this._reflectivityTexture.gammaSpace) : o.REFLECTIVITY = !1,
  98829. this._metallicReflectanceTexture || this._reflectanceTexture) {
  98830. var _e = this._metallicReflectanceTexture !== null && this._metallicReflectanceTexture._texture === ((_ = this._reflectanceTexture) === null || _ === void 0 ? void 0 : _._texture) && this._metallicReflectanceTexture.checkTransformsAreIdentical(this._reflectanceTexture);
  98831. o.METALLIC_REFLECTANCE_USE_ALPHA_ONLY = this._useOnlyMetallicFromMetallicReflectanceTexture && !_e,
  98832. this._metallicReflectanceTexture ? (MaterialHelper.PrepareDefinesForMergedUV(this._metallicReflectanceTexture, o, "METALLIC_REFLECTANCE"),
  98833. o.METALLIC_REFLECTANCE_GAMMA = this._metallicReflectanceTexture.gammaSpace) : o.METALLIC_REFLECTANCE = !1,
  98834. this._reflectanceTexture && !_e && (!this._metallicReflectanceTexture || this._metallicReflectanceTexture && this._useOnlyMetallicFromMetallicReflectanceTexture) ? (MaterialHelper.PrepareDefinesForMergedUV(this._reflectanceTexture, o, "REFLECTANCE"),
  98835. o.REFLECTANCE_GAMMA = this._reflectanceTexture.gammaSpace) : o.REFLECTANCE = !1
  98836. } else
  98837. o.METALLIC_REFLECTANCE = !1,
  98838. o.REFLECTANCE = !1;
  98839. this._microSurfaceTexture ? MaterialHelper.PrepareDefinesForMergedUV(this._microSurfaceTexture, o, "MICROSURFACEMAP") : o.MICROSURFACEMAP = !1
  98840. } else
  98841. o.REFLECTIVITY = !1,
  98842. o.MICROSURFACEMAP = !1;
  98843. b.getEngine().getCaps().standardDerivatives && this._bumpTexture && MaterialFlags.BumpTextureEnabled && !this._disableBumpMap ? (MaterialHelper.PrepareDefinesForMergedUV(this._bumpTexture, o, "BUMP"),
  98844. this._useParallax && this._albedoTexture && MaterialFlags.DiffuseTextureEnabled ? (o.PARALLAX = !0,
  98845. o.PARALLAXOCCLUSION = !!this._useParallaxOcclusion) : o.PARALLAX = !1,
  98846. o.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap) : o.BUMP = !1,
  98847. this._environmentBRDFTexture && MaterialFlags.ReflectionTextureEnabled ? (o.ENVIRONMENTBRDF = !0,
  98848. o.ENVIRONMENTBRDF_RGBD = this._environmentBRDFTexture.isRGBD) : (o.ENVIRONMENTBRDF = !1,
  98849. o.ENVIRONMENTBRDF_RGBD = !1),
  98850. this._shouldUseAlphaFromAlbedoTexture() ? o.ALPHAFROMALBEDO = !0 : o.ALPHAFROMALBEDO = !1
  98851. }
  98852. o.SPECULAROVERALPHA = this._useSpecularOverAlpha,
  98853. this._lightFalloff === e.LIGHTFALLOFF_STANDARD ? (o.USEPHYSICALLIGHTFALLOFF = !1,
  98854. o.USEGLTFLIGHTFALLOFF = !1) : this._lightFalloff === e.LIGHTFALLOFF_GLTF ? (o.USEPHYSICALLIGHTFALLOFF = !1,
  98855. o.USEGLTFLIGHTFALLOFF = !0) : (o.USEPHYSICALLIGHTFALLOFF = !0,
  98856. o.USEGLTFLIGHTFALLOFF = !1),
  98857. o.RADIANCEOVERALPHA = this._useRadianceOverAlpha,
  98858. !this.backFaceCulling && this._twoSidedLighting ? o.TWOSIDEDLIGHTING = !0 : o.TWOSIDEDLIGHTING = !1,
  98859. o.SPECULARAA = b.getEngine().getCaps().standardDerivatives && this._enableSpecularAntiAliasing
  98860. }
  98861. (o._areTexturesDirty || o._areMiscDirty) && (o.ALPHATESTVALUE = "" + this._alphaCutOff + (this._alphaCutOff % 1 === 0 ? "." : ""),
  98862. o.PREMULTIPLYALPHA = this.alphaMode === 7 || this.alphaMode === 8,
  98863. o.ALPHABLEND = this.needAlphaBlendingForMesh(i),
  98864. o.ALPHAFRESNEL = this._useAlphaFresnel || this._useLinearAlphaFresnel,
  98865. o.LINEARALPHAFRESNEL = this._useLinearAlphaFresnel),
  98866. o._areImageProcessingDirty && this._imageProcessingConfiguration && this._imageProcessingConfiguration.prepareDefines(o),
  98867. o.FORCENORMALFORWARD = this._forceNormalForward,
  98868. o.RADIANCEOCCLUSION = this._useRadianceOcclusion,
  98869. o.HORIZONOCCLUSION = this._useHorizonOcclusion,
  98870. o._areMiscDirty && (MaterialHelper.PrepareDefinesForMisc(i, b, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(i) || this._forceAlphaTest, o),
  98871. o.UNLIT = this._unlit || (this.pointsCloud || this.wireframe) && !i.isVerticesDataPresent(VertexBuffer.NormalKind),
  98872. o.DEBUGMODE = this._debugMode),
  98873. this.detailMap.prepareDefines(o, b),
  98874. this.subSurface.prepareDefines(o, b),
  98875. this.clearCoat.prepareDefines(o, b),
  98876. this.anisotropy.prepareDefines(o, i, b),
  98877. this.brdf.prepareDefines(o),
  98878. this.sheen.prepareDefines(o, b),
  98879. MaterialHelper.PrepareDefinesForFrameBoundValues(b, k, o, !!s, c, d),
  98880. MaterialHelper.PrepareDefinesForAttributes(i, o, !0, !0, !0, this._transparencyMode !== e.PBRMATERIAL_OPAQUE)
  98881. }
  98882. ,
  98883. e.prototype.forceCompilation = function(i, o, s) {
  98884. var c = this
  98885. , d = __assign({
  98886. clipPlane: !1,
  98887. useInstances: !1
  98888. }, s)
  98889. , _ = new PBRMaterialDefines
  98890. , b = this._prepareEffect(i, _, void 0, void 0, d.useInstances, d.clipPlane, i.hasThinInstances);
  98891. this._onEffectCreatedObservable && (onCreatedEffectParameters.effect = b,
  98892. onCreatedEffectParameters.subMesh = null,
  98893. this._onEffectCreatedObservable.notifyObservers(onCreatedEffectParameters)),
  98894. b.isReady() ? o && o(this) : b.onCompileObservable.add(function() {
  98895. o && o(c)
  98896. })
  98897. }
  98898. ,
  98899. e.prototype.buildUniformLayout = function() {
  98900. var i = this._uniformBuffer;
  98901. i.addUniform("vAlbedoInfos", 2),
  98902. i.addUniform("vAmbientInfos", 4),
  98903. i.addUniform("vOpacityInfos", 2),
  98904. i.addUniform("vEmissiveInfos", 2),
  98905. i.addUniform("vLightmapInfos", 2),
  98906. i.addUniform("vReflectivityInfos", 3),
  98907. i.addUniform("vMicroSurfaceSamplerInfos", 2),
  98908. i.addUniform("vReflectionInfos", 2),
  98909. i.addUniform("vReflectionFilteringInfo", 2),
  98910. i.addUniform("vReflectionPosition", 3),
  98911. i.addUniform("vReflectionSize", 3),
  98912. i.addUniform("vBumpInfos", 3),
  98913. i.addUniform("albedoMatrix", 16),
  98914. i.addUniform("ambientMatrix", 16),
  98915. i.addUniform("opacityMatrix", 16),
  98916. i.addUniform("emissiveMatrix", 16),
  98917. i.addUniform("lightmapMatrix", 16),
  98918. i.addUniform("reflectivityMatrix", 16),
  98919. i.addUniform("microSurfaceSamplerMatrix", 16),
  98920. i.addUniform("bumpMatrix", 16),
  98921. i.addUniform("vTangentSpaceParams", 2),
  98922. i.addUniform("reflectionMatrix", 16),
  98923. i.addUniform("vReflectionColor", 3),
  98924. i.addUniform("vAlbedoColor", 4),
  98925. i.addUniform("vLightingIntensity", 4),
  98926. i.addUniform("vReflectionMicrosurfaceInfos", 3),
  98927. i.addUniform("pointSize", 1),
  98928. i.addUniform("vReflectivityColor", 4),
  98929. i.addUniform("vEmissiveColor", 3),
  98930. i.addUniform("vAmbientColor", 3),
  98931. i.addUniform("vDebugMode", 2),
  98932. i.addUniform("vMetallicReflectanceFactors", 4),
  98933. i.addUniform("vMetallicReflectanceInfos", 2),
  98934. i.addUniform("metallicReflectanceMatrix", 16),
  98935. i.addUniform("vReflectanceInfos", 2),
  98936. i.addUniform("reflectanceMatrix", 16),
  98937. PBRClearCoatConfiguration.PrepareUniformBuffer(i),
  98938. PBRAnisotropicConfiguration.PrepareUniformBuffer(i),
  98939. PBRSheenConfiguration.PrepareUniformBuffer(i),
  98940. PBRSubSurfaceConfiguration.PrepareUniformBuffer(i),
  98941. DetailMapConfiguration.PrepareUniformBuffer(i),
  98942. i.addUniform("vSphericalL00", 3),
  98943. i.addUniform("vSphericalL1_1", 3),
  98944. i.addUniform("vSphericalL10", 3),
  98945. i.addUniform("vSphericalL11", 3),
  98946. i.addUniform("vSphericalL2_2", 3),
  98947. i.addUniform("vSphericalL2_1", 3),
  98948. i.addUniform("vSphericalL20", 3),
  98949. i.addUniform("vSphericalL21", 3),
  98950. i.addUniform("vSphericalL22", 3),
  98951. i.addUniform("vSphericalX", 3),
  98952. i.addUniform("vSphericalY", 3),
  98953. i.addUniform("vSphericalZ", 3),
  98954. i.addUniform("vSphericalXX_ZZ", 3),
  98955. i.addUniform("vSphericalYY_ZZ", 3),
  98956. i.addUniform("vSphericalZZ", 3),
  98957. i.addUniform("vSphericalXY", 3),
  98958. i.addUniform("vSphericalYZ", 3),
  98959. i.addUniform("vSphericalZX", 3),
  98960. i.create()
  98961. }
  98962. ,
  98963. e.prototype.unbind = function() {
  98964. if (this._activeEffect && !this.getScene().getEngine()._features.needToAlwaysBindUniformBuffers) {
  98965. var i = !1;
  98966. this._reflectionTexture && this._reflectionTexture.isRenderTarget && (this._activeEffect.setTexture("reflection2DSampler", null),
  98967. i = !0),
  98968. this.subSurface.unbind(this._activeEffect) && (i = !0),
  98969. i && this._markAllSubMeshesAsTexturesDirty()
  98970. }
  98971. a.prototype.unbind.call(this)
  98972. }
  98973. ,
  98974. e.prototype.bindForSubMesh = function(i, o, s) {
  98975. var c, d = this.getScene(), _ = s.materialDefines;
  98976. if (!!_) {
  98977. var b = s.effect;
  98978. if (!!b) {
  98979. this._activeEffect = b,
  98980. o.getMeshUniformBuffer().bindToEffect(b, "Mesh"),
  98981. o.transferToEffect(i);
  98982. var k = d.getEngine();
  98983. this._uniformBuffer.bindToEffect(b, "Material"),
  98984. this.subSurface.hardBindForSubMesh(this._uniformBuffer, d, k, this.isFrozen, _.LODBASEDMICROSFURACE, this.realTimeFiltering, s),
  98985. this.prePassConfiguration.bindForSubMesh(this._activeEffect, d, o, i, this.isFrozen),
  98986. _.OBJECTSPACE_NORMALMAP && (i.toNormalMatrix(this._normalMatrix),
  98987. this.bindOnlyNormalMatrix(this._normalMatrix));
  98988. var j = this._mustRebind(d, b, o.visibility);
  98989. MaterialHelper.BindBonesParameters(o, this._activeEffect, this.prePassConfiguration);
  98990. var $ = null
  98991. , _e = this._uniformBuffer;
  98992. if (j) {
  98993. if (this.bindViewProjection(b),
  98994. $ = this._getReflectionTexture(),
  98995. !_e.useUbo || !this.isFrozen || !_e.isSync) {
  98996. if (d.texturesEnabled) {
  98997. if (this._albedoTexture && MaterialFlags.DiffuseTextureEnabled && (_e.updateFloat2("vAlbedoInfos", this._albedoTexture.coordinatesIndex, this._albedoTexture.level),
  98998. MaterialHelper.BindTextureMatrix(this._albedoTexture, _e, "albedo")),
  98999. this._ambientTexture && MaterialFlags.AmbientTextureEnabled && (_e.updateFloat4("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level, this._ambientTextureStrength, this._ambientTextureImpactOnAnalyticalLights),
  99000. MaterialHelper.BindTextureMatrix(this._ambientTexture, _e, "ambient")),
  99001. this._opacityTexture && MaterialFlags.OpacityTextureEnabled && (_e.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level),
  99002. MaterialHelper.BindTextureMatrix(this._opacityTexture, _e, "opacity")),
  99003. $ && MaterialFlags.ReflectionTextureEnabled) {
  99004. if (_e.updateMatrix("reflectionMatrix", $.getReflectionTextureMatrix()),
  99005. _e.updateFloat2("vReflectionInfos", $.level, 0),
  99006. $.boundingBoxSize) {
  99007. var et = $;
  99008. _e.updateVector3("vReflectionPosition", et.boundingBoxPosition),
  99009. _e.updateVector3("vReflectionSize", et.boundingBoxSize)
  99010. }
  99011. if (this.realTimeFiltering) {
  99012. var tt = $.getSize().width;
  99013. _e.updateFloat2("vReflectionFilteringInfo", tt, Scalar.Log2(tt))
  99014. }
  99015. if (!_.USEIRRADIANCEMAP) {
  99016. var rt = $.sphericalPolynomial;
  99017. if (_.USESPHERICALFROMREFLECTIONMAP && rt)
  99018. if (_.SPHERICAL_HARMONICS) {
  99019. var it = rt.preScaledHarmonics;
  99020. _e.updateVector3("vSphericalL00", it.l00),
  99021. _e.updateVector3("vSphericalL1_1", it.l1_1),
  99022. _e.updateVector3("vSphericalL10", it.l10),
  99023. _e.updateVector3("vSphericalL11", it.l11),
  99024. _e.updateVector3("vSphericalL2_2", it.l2_2),
  99025. _e.updateVector3("vSphericalL2_1", it.l2_1),
  99026. _e.updateVector3("vSphericalL20", it.l20),
  99027. _e.updateVector3("vSphericalL21", it.l21),
  99028. _e.updateVector3("vSphericalL22", it.l22)
  99029. } else
  99030. _e.updateFloat3("vSphericalX", rt.x.x, rt.x.y, rt.x.z),
  99031. _e.updateFloat3("vSphericalY", rt.y.x, rt.y.y, rt.y.z),
  99032. _e.updateFloat3("vSphericalZ", rt.z.x, rt.z.y, rt.z.z),
  99033. _e.updateFloat3("vSphericalXX_ZZ", rt.xx.x - rt.zz.x, rt.xx.y - rt.zz.y, rt.xx.z - rt.zz.z),
  99034. _e.updateFloat3("vSphericalYY_ZZ", rt.yy.x - rt.zz.x, rt.yy.y - rt.zz.y, rt.yy.z - rt.zz.z),
  99035. _e.updateFloat3("vSphericalZZ", rt.zz.x, rt.zz.y, rt.zz.z),
  99036. _e.updateFloat3("vSphericalXY", rt.xy.x, rt.xy.y, rt.xy.z),
  99037. _e.updateFloat3("vSphericalYZ", rt.yz.x, rt.yz.y, rt.yz.z),
  99038. _e.updateFloat3("vSphericalZX", rt.zx.x, rt.zx.y, rt.zx.z)
  99039. }
  99040. _e.updateFloat3("vReflectionMicrosurfaceInfos", $.getSize().width, $.lodGenerationScale, $.lodGenerationOffset)
  99041. }
  99042. this._emissiveTexture && MaterialFlags.EmissiveTextureEnabled && (_e.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level),
  99043. MaterialHelper.BindTextureMatrix(this._emissiveTexture, _e, "emissive")),
  99044. this._lightmapTexture && MaterialFlags.LightmapTextureEnabled && (_e.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level),
  99045. MaterialHelper.BindTextureMatrix(this._lightmapTexture, _e, "lightmap")),
  99046. MaterialFlags.SpecularTextureEnabled && (this._metallicTexture ? (_e.updateFloat3("vReflectivityInfos", this._metallicTexture.coordinatesIndex, this._metallicTexture.level, this._ambientTextureStrength),
  99047. MaterialHelper.BindTextureMatrix(this._metallicTexture, _e, "reflectivity")) : this._reflectivityTexture && (_e.updateFloat3("vReflectivityInfos", this._reflectivityTexture.coordinatesIndex, this._reflectivityTexture.level, 1),
  99048. MaterialHelper.BindTextureMatrix(this._reflectivityTexture, _e, "reflectivity")),
  99049. this._metallicReflectanceTexture && (_e.updateFloat2("vMetallicReflectanceInfos", this._metallicReflectanceTexture.coordinatesIndex, this._metallicReflectanceTexture.level),
  99050. MaterialHelper.BindTextureMatrix(this._metallicReflectanceTexture, _e, "metallicReflectance")),
  99051. this._reflectanceTexture && _.REFLECTANCE && (_e.updateFloat2("vReflectanceInfos", this._reflectanceTexture.coordinatesIndex, this._reflectanceTexture.level),
  99052. MaterialHelper.BindTextureMatrix(this._reflectanceTexture, _e, "reflectance")),
  99053. this._microSurfaceTexture && (_e.updateFloat2("vMicroSurfaceSamplerInfos", this._microSurfaceTexture.coordinatesIndex, this._microSurfaceTexture.level),
  99054. MaterialHelper.BindTextureMatrix(this._microSurfaceTexture, _e, "microSurfaceSampler"))),
  99055. this._bumpTexture && k.getCaps().standardDerivatives && MaterialFlags.BumpTextureEnabled && !this._disableBumpMap && (_e.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, this._bumpTexture.level, this._parallaxScaleBias),
  99056. MaterialHelper.BindTextureMatrix(this._bumpTexture, _e, "bump"),
  99057. d._mirroredCameraPosition ? _e.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1 : -1, this._invertNormalMapY ? 1 : -1) : _e.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1 : 1, this._invertNormalMapY ? -1 : 1))
  99058. }
  99059. if (this.pointsCloud && _e.updateFloat("pointSize", this.pointSize),
  99060. _.METALLICWORKFLOW) {
  99061. TmpColors.Color3[0].r = this._metallic === void 0 || this._metallic === null ? 1 : this._metallic,
  99062. TmpColors.Color3[0].g = this._roughness === void 0 || this._roughness === null ? 1 : this._roughness,
  99063. _e.updateColor4("vReflectivityColor", TmpColors.Color3[0], 1);
  99064. var nt = this.subSurface.indexOfRefraction
  99065. , ot = 1
  99066. , at = Math.pow((nt - ot) / (nt + ot), 2);
  99067. this._metallicReflectanceColor.scaleToRef(at * this._metallicF0Factor, TmpColors.Color3[0]);
  99068. var st = this._metallicF0Factor;
  99069. _e.updateColor4("vMetallicReflectanceFactors", TmpColors.Color3[0], st)
  99070. } else
  99071. _e.updateColor4("vReflectivityColor", this._reflectivityColor, this._microSurface);
  99072. _e.updateColor3("vEmissiveColor", MaterialFlags.EmissiveTextureEnabled ? this._emissiveColor : Color3.BlackReadOnly),
  99073. _e.updateColor3("vReflectionColor", this._reflectionColor),
  99074. !_.SS_REFRACTION && this.subSurface.linkRefractionWithTransparency ? _e.updateColor4("vAlbedoColor", this._albedoColor, 1) : _e.updateColor4("vAlbedoColor", this._albedoColor, this.alpha),
  99075. this._lightingInfos.x = this._directIntensity,
  99076. this._lightingInfos.y = this._emissiveIntensity,
  99077. this._lightingInfos.z = this._environmentIntensity * d.environmentIntensity,
  99078. this._lightingInfos.w = this._specularIntensity,
  99079. _e.updateVector4("vLightingIntensity", this._lightingInfos),
  99080. d.ambientColor.multiplyToRef(this._ambientColor, this._globalAmbientColor),
  99081. _e.updateColor3("vAmbientColor", this._globalAmbientColor),
  99082. _e.updateFloat2("vDebugMode", this.debugLimit, this.debugFactor)
  99083. }
  99084. d.texturesEnabled && (this._albedoTexture && MaterialFlags.DiffuseTextureEnabled && _e.setTexture("albedoSampler", this._albedoTexture),
  99085. this._ambientTexture && MaterialFlags.AmbientTextureEnabled && _e.setTexture("ambientSampler", this._ambientTexture),
  99086. this._opacityTexture && MaterialFlags.OpacityTextureEnabled && _e.setTexture("opacitySampler", this._opacityTexture),
  99087. $ && MaterialFlags.ReflectionTextureEnabled && (_.LODBASEDMICROSFURACE ? _e.setTexture("reflectionSampler", $) : (_e.setTexture("reflectionSampler", $._lodTextureMid || $),
  99088. _e.setTexture("reflectionSamplerLow", $._lodTextureLow || $),
  99089. _e.setTexture("reflectionSamplerHigh", $._lodTextureHigh || $)),
  99090. _.USEIRRADIANCEMAP && _e.setTexture("irradianceSampler", $.irradianceTexture)),
  99091. _.ENVIRONMENTBRDF && _e.setTexture("environmentBrdfSampler", this._environmentBRDFTexture),
  99092. this._emissiveTexture && MaterialFlags.EmissiveTextureEnabled && _e.setTexture("emissiveSampler", this._emissiveTexture),
  99093. this._lightmapTexture && MaterialFlags.LightmapTextureEnabled && _e.setTexture("lightmapSampler", this._lightmapTexture),
  99094. MaterialFlags.SpecularTextureEnabled && (this._metallicTexture ? _e.setTexture("reflectivitySampler", this._metallicTexture) : this._reflectivityTexture && _e.setTexture("reflectivitySampler", this._reflectivityTexture),
  99095. this._metallicReflectanceTexture && _e.setTexture("metallicReflectanceSampler", this._metallicReflectanceTexture),
  99096. this._reflectanceTexture && _.REFLECTANCE && _e.setTexture("reflectanceSampler", this._reflectanceTexture),
  99097. this._microSurfaceTexture && _e.setTexture("microSurfaceSampler", this._microSurfaceTexture)),
  99098. this._bumpTexture && k.getCaps().standardDerivatives && MaterialFlags.BumpTextureEnabled && !this._disableBumpMap && _e.setTexture("bumpSampler", this._bumpTexture)),
  99099. this.getScene().useOrderIndependentTransparency && this.needAlphaBlendingForMesh(o) && this.getScene().depthPeelingRenderer.bind(b),
  99100. this.detailMap.bindForSubMesh(_e, d, this.isFrozen),
  99101. this.subSurface.bindForSubMesh(_e, d, k, this.isFrozen, _.LODBASEDMICROSFURACE, this.realTimeFiltering, s),
  99102. this.clearCoat.bindForSubMesh(_e, d, k, this._disableBumpMap, this.isFrozen, this._invertNormalMapX, this._invertNormalMapY, s),
  99103. this.anisotropy.bindForSubMesh(_e, d, this.isFrozen),
  99104. this.sheen.bindForSubMesh(_e, d, this.isFrozen, s),
  99105. MaterialHelper.BindClipPlane(this._activeEffect, d),
  99106. this.bindEyePosition(b)
  99107. } else
  99108. d.getEngine()._features.needToAlwaysBindUniformBuffers && (this._needToBindSceneUbo = !0);
  99109. (j || !this.isFrozen) && (d.lightsEnabled && !this._disableLighting && MaterialHelper.BindLights(d, o, this._activeEffect, _, this._maxSimultaneousLights),
  99110. (d.fogEnabled && o.applyFog && d.fogMode !== Scene.FOGMODE_NONE || $ || o.receiveShadows) && this.bindView(b),
  99111. MaterialHelper.BindFogParameters(d, o, this._activeEffect, !0),
  99112. _.NUM_MORPH_INFLUENCERS && MaterialHelper.BindMorphTargetParameters(o, this._activeEffect),
  99113. _.BAKED_VERTEX_ANIMATION_TEXTURE && ((c = o.bakedVertexAnimationManager) === null || c === void 0 || c.bind(b, _.INSTANCES)),
  99114. this._imageProcessingConfiguration.bind(this._activeEffect),
  99115. MaterialHelper.BindLogDepth(_, this._activeEffect, d)),
  99116. this._afterBind(o, this._activeEffect),
  99117. _e.update()
  99118. }
  99119. }
  99120. }
  99121. ,
  99122. e.prototype.getAnimatables = function() {
  99123. var i = [];
  99124. return this._albedoTexture && this._albedoTexture.animations && this._albedoTexture.animations.length > 0 && i.push(this._albedoTexture),
  99125. this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0 && i.push(this._ambientTexture),
  99126. this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0 && i.push(this._opacityTexture),
  99127. this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0 && i.push(this._reflectionTexture),
  99128. this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0 && i.push(this._emissiveTexture),
  99129. this._metallicTexture && this._metallicTexture.animations && this._metallicTexture.animations.length > 0 ? i.push(this._metallicTexture) : this._reflectivityTexture && this._reflectivityTexture.animations && this._reflectivityTexture.animations.length > 0 && i.push(this._reflectivityTexture),
  99130. this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0 && i.push(this._bumpTexture),
  99131. this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0 && i.push(this._lightmapTexture),
  99132. this.detailMap.getAnimatables(i),
  99133. this.subSurface.getAnimatables(i),
  99134. this.clearCoat.getAnimatables(i),
  99135. this.sheen.getAnimatables(i),
  99136. this.anisotropy.getAnimatables(i),
  99137. i
  99138. }
  99139. ,
  99140. e.prototype._getReflectionTexture = function() {
  99141. return this._reflectionTexture ? this._reflectionTexture : this.getScene().environmentTexture
  99142. }
  99143. ,
  99144. e.prototype.getActiveTextures = function() {
  99145. var i = a.prototype.getActiveTextures.call(this);
  99146. return this._albedoTexture && i.push(this._albedoTexture),
  99147. this._ambientTexture && i.push(this._ambientTexture),
  99148. this._opacityTexture && i.push(this._opacityTexture),
  99149. this._reflectionTexture && i.push(this._reflectionTexture),
  99150. this._emissiveTexture && i.push(this._emissiveTexture),
  99151. this._reflectivityTexture && i.push(this._reflectivityTexture),
  99152. this._metallicTexture && i.push(this._metallicTexture),
  99153. this._metallicReflectanceTexture && i.push(this._metallicReflectanceTexture),
  99154. this._reflectanceTexture && i.push(this._reflectanceTexture),
  99155. this._microSurfaceTexture && i.push(this._microSurfaceTexture),
  99156. this._bumpTexture && i.push(this._bumpTexture),
  99157. this._lightmapTexture && i.push(this._lightmapTexture),
  99158. this.detailMap.getActiveTextures(i),
  99159. this.subSurface.getActiveTextures(i),
  99160. this.clearCoat.getActiveTextures(i),
  99161. this.sheen.getActiveTextures(i),
  99162. this.anisotropy.getActiveTextures(i),
  99163. i
  99164. }
  99165. ,
  99166. e.prototype.hasTexture = function(i) {
  99167. return a.prototype.hasTexture.call(this, i) || this._albedoTexture === i || this._ambientTexture === i || this._opacityTexture === i || this._reflectionTexture === i || this._reflectivityTexture === i || this._metallicTexture === i || this._metallicReflectanceTexture === i || this._reflectanceTexture === i || this._microSurfaceTexture === i || this._bumpTexture === i || this._lightmapTexture === i ? !0 : this.detailMap.hasTexture(i) || this.subSurface.hasTexture(i) || this.clearCoat.hasTexture(i) || this.sheen.hasTexture(i) || this.anisotropy.hasTexture(i)
  99168. }
  99169. ,
  99170. e.prototype.setPrePassRenderer = function(i) {
  99171. if (this.subSurface.isScatteringEnabled) {
  99172. var o = this.getScene().enableSubSurfaceForPrePass();
  99173. return o && (o.enabled = !0),
  99174. !0
  99175. }
  99176. return !1
  99177. }
  99178. ,
  99179. e.prototype.dispose = function(i, o) {
  99180. var s, c, d, _, b, k, j, $, _e, et, tt, rt;
  99181. o && (this._environmentBRDFTexture && this.getScene().environmentBRDFTexture !== this._environmentBRDFTexture && this._environmentBRDFTexture.dispose(),
  99182. (s = this._albedoTexture) === null || s === void 0 || s.dispose(),
  99183. (c = this._ambientTexture) === null || c === void 0 || c.dispose(),
  99184. (d = this._opacityTexture) === null || d === void 0 || d.dispose(),
  99185. (_ = this._reflectionTexture) === null || _ === void 0 || _.dispose(),
  99186. (b = this._emissiveTexture) === null || b === void 0 || b.dispose(),
  99187. (k = this._metallicTexture) === null || k === void 0 || k.dispose(),
  99188. (j = this._reflectivityTexture) === null || j === void 0 || j.dispose(),
  99189. ($ = this._bumpTexture) === null || $ === void 0 || $.dispose(),
  99190. (_e = this._lightmapTexture) === null || _e === void 0 || _e.dispose(),
  99191. (et = this._metallicReflectanceTexture) === null || et === void 0 || et.dispose(),
  99192. (tt = this._reflectanceTexture) === null || tt === void 0 || tt.dispose(),
  99193. (rt = this._microSurfaceTexture) === null || rt === void 0 || rt.dispose()),
  99194. this.detailMap.dispose(o),
  99195. this.subSurface.dispose(o),
  99196. this.clearCoat.dispose(o),
  99197. this.sheen.dispose(o),
  99198. this.anisotropy.dispose(o),
  99199. this._renderTargets.dispose(),
  99200. this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),
  99201. a.prototype.dispose.call(this, i, o)
  99202. }
  99203. ,
  99204. e.PBRMATERIAL_OPAQUE = Material.MATERIAL_OPAQUE,
  99205. e.PBRMATERIAL_ALPHATEST = Material.MATERIAL_ALPHATEST,
  99206. e.PBRMATERIAL_ALPHABLEND = Material.MATERIAL_ALPHABLEND,
  99207. e.PBRMATERIAL_ALPHATESTANDBLEND = Material.MATERIAL_ALPHATESTANDBLEND,
  99208. e.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = 0,
  99209. e.LIGHTFALLOFF_PHYSICAL = 0,
  99210. e.LIGHTFALLOFF_GLTF = 1,
  99211. e.LIGHTFALLOFF_STANDARD = 2,
  99212. __decorate([serializeAsImageProcessingConfiguration()], e.prototype, "_imageProcessingConfiguration", void 0),
  99213. __decorate([expandToProperty("_markAllSubMeshesAsMiscDirty")], e.prototype, "debugMode", void 0),
  99214. __decorate([serialize()], e.prototype, "useLogarithmicDepth", null),
  99215. e
  99216. }(PushMaterial)
  99217. , SheenBlock = function(a) {
  99218. __extends(e, a);
  99219. function e(i) {
  99220. var o = a.call(this, i, NodeMaterialBlockTargets.Fragment) || this;
  99221. return o.albedoScaling = !1,
  99222. o.linkSheenWithAlbedo = !1,
  99223. o._isUnique = !0,
  99224. o.registerInput("intensity", NodeMaterialBlockConnectionPointTypes.Float, !0, NodeMaterialBlockTargets.Fragment),
  99225. o.registerInput("color", NodeMaterialBlockConnectionPointTypes.Color3, !0, NodeMaterialBlockTargets.Fragment),
  99226. o.registerInput("roughness", NodeMaterialBlockConnectionPointTypes.Float, !0, NodeMaterialBlockTargets.Fragment),
  99227. o.registerOutput("sheen", NodeMaterialBlockConnectionPointTypes.Object, NodeMaterialBlockTargets.Fragment, new NodeMaterialConnectionPointCustomObject("sheen",o,NodeMaterialConnectionPointDirection.Output,e,"SheenBlock")),
  99228. o
  99229. }
  99230. return e.prototype.initialize = function(i) {
  99231. i._excludeVariableName("sheenOut"),
  99232. i._excludeVariableName("sheenMapData"),
  99233. i._excludeVariableName("vSheenColor"),
  99234. i._excludeVariableName("vSheenRoughness")
  99235. }
  99236. ,
  99237. e.prototype.getClassName = function() {
  99238. return "SheenBlock"
  99239. }
  99240. ,
  99241. Object.defineProperty(e.prototype, "intensity", {
  99242. get: function() {
  99243. return this._inputs[0]
  99244. },
  99245. enumerable: !1,
  99246. configurable: !0
  99247. }),
  99248. Object.defineProperty(e.prototype, "color", {
  99249. get: function() {
  99250. return this._inputs[1]
  99251. },
  99252. enumerable: !1,
  99253. configurable: !0
  99254. }),
  99255. Object.defineProperty(e.prototype, "roughness", {
  99256. get: function() {
  99257. return this._inputs[2]
  99258. },
  99259. enumerable: !1,
  99260. configurable: !0
  99261. }),
  99262. Object.defineProperty(e.prototype, "sheen", {
  99263. get: function() {
  99264. return this._outputs[0]
  99265. },
  99266. enumerable: !1,
  99267. configurable: !0
  99268. }),
  99269. e.prototype.prepareDefines = function(i, o, s) {
  99270. a.prototype.prepareDefines.call(this, i, o, s),
  99271. s.setValue("SHEEN", !0),
  99272. s.setValue("SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE", !0, !0),
  99273. s.setValue("SHEEN_LINKWITHALBEDO", this.linkSheenWithAlbedo, !0),
  99274. s.setValue("SHEEN_ROUGHNESS", this.roughness.isConnected, !0),
  99275. s.setValue("SHEEN_ALBEDOSCALING", this.albedoScaling, !0)
  99276. }
  99277. ,
  99278. e.prototype.getCode = function(i) {
  99279. var o = ""
  99280. , s = this.color.isConnected ? this.color.associatedVariableName : "vec3(1.)"
  99281. , c = this.intensity.isConnected ? this.intensity.associatedVariableName : "1."
  99282. , d = this.roughness.isConnected ? this.roughness.associatedVariableName : "0."
  99283. , _ = "vec4(0.)";
  99284. return o = `#ifdef SHEEN
  99285. sheenOutParams sheenOut;
  99286. vec4 vSheenColor = vec4(` + s + ", " + c + `);
  99287. sheenBlock(
  99288. vSheenColor,
  99289. #ifdef SHEEN_ROUGHNESS
  99290. ` + d + `,
  99291. #endif
  99292. roughness,
  99293. #ifdef SHEEN_TEXTURE
  99294. ` + _ + `,
  99295. 1.0,
  99296. #endif
  99297. reflectance,
  99298. #ifdef SHEEN_LINKWITHALBEDO
  99299. baseColor,
  99300. surfaceAlbedo,
  99301. #endif
  99302. #ifdef ENVIRONMENTBRDF
  99303. NdotV,
  99304. environmentBrdf,
  99305. #endif
  99306. #if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
  99307. AARoughnessFactors,
  99308. ` + (i == null ? void 0 : i._vReflectionMicrosurfaceInfosName) + `,
  99309. ` + (i == null ? void 0 : i._vReflectionInfosName) + `,
  99310. ` + (i == null ? void 0 : i.reflectionColor) + `,
  99311. vLightingIntensity,
  99312. #ifdef ` + (i == null ? void 0 : i._define3DName) + `
  99313. ` + (i == null ? void 0 : i._cubeSamplerName) + `,
  99314. #else
  99315. ` + (i == null ? void 0 : i._2DSamplerName) + `,
  99316. #endif
  99317. reflectionOut.reflectionCoords,
  99318. NdotVUnclamped,
  99319. #ifndef LODBASEDMICROSFURACE
  99320. #ifdef ` + (i == null ? void 0 : i._define3DName) + `
  99321. ` + (i == null ? void 0 : i._cubeSamplerName) + `,
  99322. ` + (i == null ? void 0 : i._cubeSamplerName) + `,
  99323. #else
  99324. ` + (i == null ? void 0 : i._2DSamplerName) + `,
  99325. ` + (i == null ? void 0 : i._2DSamplerName) + `,
  99326. #endif
  99327. #endif
  99328. #if !defined(` + (i == null ? void 0 : i._defineSkyboxName) + `) && defined(RADIANCEOCCLUSION)
  99329. seo,
  99330. #endif
  99331. #if !defined(` + (i == null ? void 0 : i._defineSkyboxName) + ") && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(" + (i == null ? void 0 : i._define3DName) + `)
  99332. eho,
  99333. #endif
  99334. #endif
  99335. sheenOut
  99336. );
  99337. #ifdef SHEEN_LINKWITHALBEDO
  99338. surfaceAlbedo = sheenOut.surfaceAlbedo;
  99339. #endif
  99340. #endif\r
  99341. `,
  99342. o
  99343. }
  99344. ,
  99345. e.prototype._buildBlock = function(i) {
  99346. return i.target === NodeMaterialBlockTargets.Fragment && i.sharedData.blocksWithDefines.push(this),
  99347. this
  99348. }
  99349. ,
  99350. e.prototype._dumpPropertiesCode = function() {
  99351. var i = a.prototype._dumpPropertiesCode.call(this);
  99352. return i += this._codeVariableName + ".albedoScaling = " + this.albedoScaling + `;\r
  99353. `,
  99354. i += this._codeVariableName + ".linkSheenWithAlbedo = " + this.linkSheenWithAlbedo + `;\r
  99355. `,
  99356. i
  99357. }
  99358. ,
  99359. e.prototype.serialize = function() {
  99360. var i = a.prototype.serialize.call(this);
  99361. return i.albedoScaling = this.albedoScaling,
  99362. i.linkSheenWithAlbedo = this.linkSheenWithAlbedo,
  99363. i
  99364. }
  99365. ,
  99366. e.prototype._deserialize = function(i, o, s) {
  99367. a.prototype._deserialize.call(this, i, o, s),
  99368. this.albedoScaling = i.albedoScaling,
  99369. this.linkSheenWithAlbedo = i.linkSheenWithAlbedo
  99370. }
  99371. ,
  99372. __decorate([editableInPropertyPage("Albedo scaling", PropertyTypeForEdition.Boolean, "PROPERTIES", {
  99373. notifiers: {
  99374. update: !0
  99375. }
  99376. })], e.prototype, "albedoScaling", void 0),
  99377. __decorate([editableInPropertyPage("Link sheen with albedo", PropertyTypeForEdition.Boolean, "PROPERTIES", {
  99378. notifiers: {
  99379. update: !0
  99380. }
  99381. })], e.prototype, "linkSheenWithAlbedo", void 0),
  99382. e
  99383. }(NodeMaterialBlock);
  99384. RegisterClass("BABYLON.SheenBlock", SheenBlock);
  99385. var AnisotropyBlock = function(a) {
  99386. __extends(e, a);
  99387. function e(i) {
  99388. var o = a.call(this, i, NodeMaterialBlockTargets.Fragment) || this;
  99389. return o._isUnique = !0,
  99390. o.registerInput("intensity", NodeMaterialBlockConnectionPointTypes.Float, !0, NodeMaterialBlockTargets.Fragment),
  99391. o.registerInput("direction", NodeMaterialBlockConnectionPointTypes.Vector2, !0, NodeMaterialBlockTargets.Fragment),
  99392. o.registerInput("uv", NodeMaterialBlockConnectionPointTypes.Vector2, !0),
  99393. o.registerInput("worldTangent", NodeMaterialBlockConnectionPointTypes.Vector4, !0),
  99394. o.registerOutput("anisotropy", NodeMaterialBlockConnectionPointTypes.Object, NodeMaterialBlockTargets.Fragment, new NodeMaterialConnectionPointCustomObject("anisotropy",o,NodeMaterialConnectionPointDirection.Output,e,"AnisotropyBlock")),
  99395. o
  99396. }
  99397. return e.prototype.initialize = function(i) {
  99398. i._excludeVariableName("anisotropicOut"),
  99399. i._excludeVariableName("TBN")
  99400. }
  99401. ,
  99402. e.prototype.getClassName = function() {
  99403. return "AnisotropyBlock"
  99404. }
  99405. ,
  99406. Object.defineProperty(e.prototype, "intensity", {
  99407. get: function() {
  99408. return this._inputs[0]
  99409. },
  99410. enumerable: !1,
  99411. configurable: !0
  99412. }),
  99413. Object.defineProperty(e.prototype, "direction", {
  99414. get: function() {
  99415. return this._inputs[1]
  99416. },
  99417. enumerable: !1,
  99418. configurable: !0
  99419. }),
  99420. Object.defineProperty(e.prototype, "uv", {
  99421. get: function() {
  99422. return this._inputs[2]
  99423. },
  99424. enumerable: !1,
  99425. configurable: !0
  99426. }),
  99427. Object.defineProperty(e.prototype, "worldTangent", {
  99428. get: function() {
  99429. return this._inputs[3]
  99430. },
  99431. enumerable: !1,
  99432. configurable: !0
  99433. }),
  99434. Object.defineProperty(e.prototype, "anisotropy", {
  99435. get: function() {
  99436. return this._outputs[0]
  99437. },
  99438. enumerable: !1,
  99439. configurable: !0
  99440. }),
  99441. e.prototype._generateTBNSpace = function(i) {
  99442. var o = ""
  99443. , s = "//" + this.name
  99444. , c = this.uv
  99445. , d = this.worldPositionConnectionPoint
  99446. , _ = this.worldNormalConnectionPoint
  99447. , b = this.worldTangent;
  99448. c.isConnected || console.error("You must connect the 'uv' input of the Anisotropy block!"),
  99449. i._emitExtension("derivatives", "#extension GL_OES_standard_derivatives : enable");
  99450. var k = {
  99451. search: /defined\(TANGENT\)/g,
  99452. replace: b.isConnected ? "defined(TANGENT)" : "defined(IGNORE)"
  99453. };
  99454. return b.isConnected && (o += "vec3 tbnNormal = normalize(" + _.associatedVariableName + `.xyz);\r
  99455. `,
  99456. o += "vec3 tbnTangent = normalize(" + b.associatedVariableName + `.xyz);\r
  99457. `,
  99458. o += `vec3 tbnBitangent = cross(tbnNormal, tbnTangent);\r
  99459. `,
  99460. o += `mat3 vTBN = mat3(tbnTangent, tbnBitangent, tbnNormal);\r
  99461. `),
  99462. o += `
  99463. #if defined(` + (b.isConnected ? "TANGENT" : "IGNORE") + `) && defined(NORMAL)
  99464. mat3 TBN = vTBN;
  99465. #else
  99466. mat3 TBN = cotangent_frame(` + (_.associatedVariableName + ".xyz") + ", " + ("v_" + d.associatedVariableName + ".xyz") + ", " + (c.isConnected ? c.associatedVariableName : "vec2(0.)") + `, vec2(1., 1.));
  99467. #endif\r
  99468. `,
  99469. i._emitFunctionFromInclude("bumpFragmentMainFunctions", s, {
  99470. replaceStrings: [k]
  99471. }),
  99472. o
  99473. }
  99474. ,
  99475. e.prototype.getCode = function(i, o) {
  99476. o === void 0 && (o = !1);
  99477. var s = "";
  99478. o && (s += this._generateTBNSpace(i));
  99479. var c = this.intensity.isConnected ? this.intensity.associatedVariableName : "1.0"
  99480. , d = this.direction.isConnected ? this.direction.associatedVariableName : "vec2(1., 0.)";
  99481. return s += `anisotropicOutParams anisotropicOut;
  99482. anisotropicBlock(
  99483. vec3(` + d + ", " + c + `),
  99484. #ifdef ANISOTROPIC_TEXTURE
  99485. vec3(0.),
  99486. #endif
  99487. TBN,
  99488. normalW,
  99489. viewDirectionW,
  99490. anisotropicOut
  99491. );\r
  99492. `,
  99493. s
  99494. }
  99495. ,
  99496. e.prototype.prepareDefines = function(i, o, s) {
  99497. a.prototype.prepareDefines.call(this, i, o, s),
  99498. s.setValue("ANISOTROPIC", !0),
  99499. s.setValue("ANISOTROPIC_TEXTURE", !1, !0)
  99500. }
  99501. ,
  99502. e.prototype._buildBlock = function(i) {
  99503. return i.target === NodeMaterialBlockTargets.Fragment && i.sharedData.blocksWithDefines.push(this),
  99504. this
  99505. }
  99506. ,
  99507. e
  99508. }(NodeMaterialBlock);
  99509. RegisterClass("BABYLON.AnisotropyBlock", AnisotropyBlock);
  99510. var ReflectionBlock = function(a) {
  99511. __extends(e, a);
  99512. function e(i) {
  99513. var o = a.call(this, i) || this;
  99514. return o.useSphericalHarmonics = !0,
  99515. o.forceIrradianceInFragment = !1,
  99516. o._isUnique = !0,
  99517. o.registerInput("position", NodeMaterialBlockConnectionPointTypes.Vector3, !1, NodeMaterialBlockTargets.Vertex),
  99518. o.registerInput("world", NodeMaterialBlockConnectionPointTypes.Matrix, !1, NodeMaterialBlockTargets.Vertex),
  99519. o.registerInput("color", NodeMaterialBlockConnectionPointTypes.Color3, !0, NodeMaterialBlockTargets.Fragment),
  99520. o.registerOutput("reflection", NodeMaterialBlockConnectionPointTypes.Object, NodeMaterialBlockTargets.Fragment, new NodeMaterialConnectionPointCustomObject("reflection",o,NodeMaterialConnectionPointDirection.Output,e,"ReflectionBlock")),
  99521. o
  99522. }
  99523. return e.prototype.getClassName = function() {
  99524. return "ReflectionBlock"
  99525. }
  99526. ,
  99527. Object.defineProperty(e.prototype, "position", {
  99528. get: function() {
  99529. return this._inputs[0]
  99530. },
  99531. enumerable: !1,
  99532. configurable: !0
  99533. }),
  99534. Object.defineProperty(e.prototype, "worldPosition", {
  99535. get: function() {
  99536. return this.worldPositionConnectionPoint
  99537. },
  99538. enumerable: !1,
  99539. configurable: !0
  99540. }),
  99541. Object.defineProperty(e.prototype, "worldNormal", {
  99542. get: function() {
  99543. return this.worldNormalConnectionPoint
  99544. },
  99545. enumerable: !1,
  99546. configurable: !0
  99547. }),
  99548. Object.defineProperty(e.prototype, "world", {
  99549. get: function() {
  99550. return this._inputs[1]
  99551. },
  99552. enumerable: !1,
  99553. configurable: !0
  99554. }),
  99555. Object.defineProperty(e.prototype, "cameraPosition", {
  99556. get: function() {
  99557. return this.cameraPositionConnectionPoint
  99558. },
  99559. enumerable: !1,
  99560. configurable: !0
  99561. }),
  99562. Object.defineProperty(e.prototype, "view", {
  99563. get: function() {
  99564. return this.viewConnectionPoint
  99565. },
  99566. enumerable: !1,
  99567. configurable: !0
  99568. }),
  99569. Object.defineProperty(e.prototype, "color", {
  99570. get: function() {
  99571. return this._inputs[2]
  99572. },
  99573. enumerable: !1,
  99574. configurable: !0
  99575. }),
  99576. Object.defineProperty(e.prototype, "reflection", {
  99577. get: function() {
  99578. return this._outputs[0]
  99579. },
  99580. enumerable: !1,
  99581. configurable: !0
  99582. }),
  99583. Object.defineProperty(e.prototype, "hasTexture", {
  99584. get: function() {
  99585. return !!this._getTexture()
  99586. },
  99587. enumerable: !1,
  99588. configurable: !0
  99589. }),
  99590. Object.defineProperty(e.prototype, "reflectionColor", {
  99591. get: function() {
  99592. return this.color.isConnected ? this.color.associatedVariableName : "vec3(1., 1., 1.)"
  99593. },
  99594. enumerable: !1,
  99595. configurable: !0
  99596. }),
  99597. e.prototype._getTexture = function() {
  99598. return this.texture ? this.texture : this._scene.environmentTexture
  99599. }
  99600. ,
  99601. e.prototype.prepareDefines = function(i, o, s) {
  99602. a.prototype.prepareDefines.call(this, i, o, s);
  99603. var c = this._getTexture()
  99604. , d = c && c.getTextureMatrix;
  99605. s.setValue("REFLECTION", d, !0),
  99606. d && (s.setValue(this._defineLODReflectionAlpha, c.lodLevelInAlpha, !0),
  99607. s.setValue(this._defineLinearSpecularReflection, c.linearSpecularLOD, !0),
  99608. s.setValue(this._defineOppositeZ, this._scene.useRightHandedSystem ? !c.invertZ : c.invertZ, !0),
  99609. s.setValue("SPHERICAL_HARMONICS", this.useSphericalHarmonics, !0),
  99610. s.setValue("GAMMAREFLECTION", c.gammaSpace, !0),
  99611. s.setValue("RGBDREFLECTION", c.isRGBD, !0),
  99612. c && c.coordinatesMode !== Texture.SKYBOX_MODE && c.isCube && (s.setValue("USESPHERICALFROMREFLECTIONMAP", !0),
  99613. s.setValue("USEIRRADIANCEMAP", !1),
  99614. this.forceIrradianceInFragment || this._scene.getEngine().getCaps().maxVaryingVectors <= 8 ? s.setValue("USESPHERICALINVERTEX", !1) : s.setValue("USESPHERICALINVERTEX", !0)))
  99615. }
  99616. ,
  99617. e.prototype.bind = function(i, o, s, c) {
  99618. a.prototype.bind.call(this, i, o, s);
  99619. var d = this._getTexture();
  99620. if (!(!d || !c)) {
  99621. d.isCube ? i.setTexture(this._cubeSamplerName, d) : i.setTexture(this._2DSamplerName, d);
  99622. var _ = d.getSize().width;
  99623. i.setFloat3(this._vReflectionMicrosurfaceInfosName, _, d.lodGenerationScale, d.lodGenerationOffset),
  99624. i.setFloat2(this._vReflectionFilteringInfoName, _, Scalar.Log2(_));
  99625. var b = c.materialDefines
  99626. , k = d.sphericalPolynomial;
  99627. if (b.USESPHERICALFROMREFLECTIONMAP && k)
  99628. if (b.SPHERICAL_HARMONICS) {
  99629. var j = k.preScaledHarmonics;
  99630. i.setVector3("vSphericalL00", j.l00),
  99631. i.setVector3("vSphericalL1_1", j.l1_1),
  99632. i.setVector3("vSphericalL10", j.l10),
  99633. i.setVector3("vSphericalL11", j.l11),
  99634. i.setVector3("vSphericalL2_2", j.l2_2),
  99635. i.setVector3("vSphericalL2_1", j.l2_1),
  99636. i.setVector3("vSphericalL20", j.l20),
  99637. i.setVector3("vSphericalL21", j.l21),
  99638. i.setVector3("vSphericalL22", j.l22)
  99639. } else
  99640. i.setFloat3("vSphericalX", k.x.x, k.x.y, k.x.z),
  99641. i.setFloat3("vSphericalY", k.y.x, k.y.y, k.y.z),
  99642. i.setFloat3("vSphericalZ", k.z.x, k.z.y, k.z.z),
  99643. i.setFloat3("vSphericalXX_ZZ", k.xx.x - k.zz.x, k.xx.y - k.zz.y, k.xx.z - k.zz.z),
  99644. i.setFloat3("vSphericalYY_ZZ", k.yy.x - k.zz.x, k.yy.y - k.zz.y, k.yy.z - k.zz.z),
  99645. i.setFloat3("vSphericalZZ", k.zz.x, k.zz.y, k.zz.z),
  99646. i.setFloat3("vSphericalXY", k.xy.x, k.xy.y, k.xy.z),
  99647. i.setFloat3("vSphericalYZ", k.yz.x, k.yz.y, k.yz.z),
  99648. i.setFloat3("vSphericalZX", k.zx.x, k.zx.y, k.zx.z)
  99649. }
  99650. }
  99651. ,
  99652. e.prototype.handleVertexSide = function(i) {
  99653. var o = a.prototype.handleVertexSide.call(this, i);
  99654. i._emitFunctionFromInclude("harmonicsFunctions", "//" + this.name, {
  99655. replaceStrings: [{
  99656. search: /uniform vec3 vSphericalL00;[\s\S]*?uniform vec3 vSphericalL22;/g,
  99657. replace: ""
  99658. }, {
  99659. search: /uniform vec3 vSphericalX;[\s\S]*?uniform vec3 vSphericalZX;/g,
  99660. replace: ""
  99661. }]
  99662. });
  99663. var s = i._getFreeVariableName("reflectionVector");
  99664. return this._vEnvironmentIrradianceName = i._getFreeVariableName("vEnvironmentIrradiance"),
  99665. i._emitVaryingFromString(this._vEnvironmentIrradianceName, "vec3", "defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)"),
  99666. i._emitUniformFromString("vSphericalL00", "vec3", "SPHERICAL_HARMONICS"),
  99667. i._emitUniformFromString("vSphericalL1_1", "vec3", "SPHERICAL_HARMONICS"),
  99668. i._emitUniformFromString("vSphericalL10", "vec3", "SPHERICAL_HARMONICS"),
  99669. i._emitUniformFromString("vSphericalL11", "vec3", "SPHERICAL_HARMONICS"),
  99670. i._emitUniformFromString("vSphericalL2_2", "vec3", "SPHERICAL_HARMONICS"),
  99671. i._emitUniformFromString("vSphericalL2_1", "vec3", "SPHERICAL_HARMONICS"),
  99672. i._emitUniformFromString("vSphericalL20", "vec3", "SPHERICAL_HARMONICS"),
  99673. i._emitUniformFromString("vSphericalL21", "vec3", "SPHERICAL_HARMONICS"),
  99674. i._emitUniformFromString("vSphericalL22", "vec3", "SPHERICAL_HARMONICS"),
  99675. i._emitUniformFromString("vSphericalX", "vec3", "SPHERICAL_HARMONICS", !0),
  99676. i._emitUniformFromString("vSphericalY", "vec3", "SPHERICAL_HARMONICS", !0),
  99677. i._emitUniformFromString("vSphericalZ", "vec3", "SPHERICAL_HARMONICS", !0),
  99678. i._emitUniformFromString("vSphericalXX_ZZ", "vec3", "SPHERICAL_HARMONICS", !0),
  99679. i._emitUniformFromString("vSphericalYY_ZZ", "vec3", "SPHERICAL_HARMONICS", !0),
  99680. i._emitUniformFromString("vSphericalZZ", "vec3", "SPHERICAL_HARMONICS", !0),
  99681. i._emitUniformFromString("vSphericalXY", "vec3", "SPHERICAL_HARMONICS", !0),
  99682. i._emitUniformFromString("vSphericalYZ", "vec3", "SPHERICAL_HARMONICS", !0),
  99683. i._emitUniformFromString("vSphericalZX", "vec3", "SPHERICAL_HARMONICS", !0),
  99684. o += `#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)
  99685. vec3 ` + s + " = vec3(" + this._reflectionMatrixName + " * vec4(normalize(" + this.worldNormal.associatedVariableName + `).xyz, 0)).xyz;
  99686. #ifdef ` + this._defineOppositeZ + `
  99687. ` + s + `.z *= -1.0;
  99688. #endif
  99689. ` + this._vEnvironmentIrradianceName + " = computeEnvironmentIrradiance(" + s + `);
  99690. #endif\r
  99691. `,
  99692. o
  99693. }
  99694. ,
  99695. e.prototype.getCode = function(i, o) {
  99696. var s = "";
  99697. this.handleFragmentSideInits(i),
  99698. i._emitFunctionFromInclude("harmonicsFunctions", "//" + this.name, {
  99699. replaceStrings: [{
  99700. search: /uniform vec3 vSphericalL00;[\s\S]*?uniform vec3 vSphericalL22;/g,
  99701. replace: ""
  99702. }, {
  99703. search: /uniform vec3 vSphericalX;[\s\S]*?uniform vec3 vSphericalZX;/g,
  99704. replace: ""
  99705. }]
  99706. }),
  99707. i._emitFunction("sampleReflection", `
  99708. #ifdef ` + this._define3DName + `
  99709. #define sampleReflection(s, c) textureCube(s, c)
  99710. #else
  99711. #define sampleReflection(s, c) texture2D(s, c)
  99712. #endif\r
  99713. `, "//" + this.name),
  99714. i._emitFunction("sampleReflectionLod", `
  99715. #ifdef ` + this._define3DName + `
  99716. #define sampleReflectionLod(s, c, l) textureCubeLodEXT(s, c, l)
  99717. #else
  99718. #define sampleReflectionLod(s, c, l) texture2DLodEXT(s, c, l)
  99719. #endif\r
  99720. `, "//" + this.name);
  99721. var c = `
  99722. vec3 computeReflectionCoordsPBR(vec4 worldPos, vec3 worldNormal) {
  99723. ` + this.handleFragmentSideCodeReflectionCoords("worldNormal", "worldPos", !0) + `
  99724. return ` + this._reflectionVectorName + `;
  99725. }\r
  99726. `;
  99727. return i._emitFunction("computeReflectionCoordsPBR", c, "//" + this.name),
  99728. this._vReflectionMicrosurfaceInfosName = i._getFreeVariableName("vReflectionMicrosurfaceInfos"),
  99729. i._emitUniformFromString(this._vReflectionMicrosurfaceInfosName, "vec3"),
  99730. this._vReflectionInfosName = i._getFreeVariableName("vReflectionInfos"),
  99731. this._vReflectionFilteringInfoName = i._getFreeVariableName("vReflectionFilteringInfo"),
  99732. i._emitUniformFromString(this._vReflectionFilteringInfoName, "vec2"),
  99733. s += `#ifdef REFLECTION
  99734. vec2 ` + this._vReflectionInfosName + ` = vec2(1., 0.);
  99735. reflectionOutParams reflectionOut;
  99736. reflectionBlock(
  99737. ` + ("v_" + this.worldPosition.associatedVariableName + ".xyz") + `,
  99738. ` + o + `,
  99739. alphaG,
  99740. ` + this._vReflectionMicrosurfaceInfosName + `,
  99741. ` + this._vReflectionInfosName + `,
  99742. ` + this.reflectionColor + `,
  99743. #ifdef ANISOTROPIC
  99744. anisotropicOut,
  99745. #endif
  99746. #if defined(` + this._defineLODReflectionAlpha + ") && !defined(" + this._defineSkyboxName + `)
  99747. NdotVUnclamped,
  99748. #endif
  99749. #ifdef ` + this._defineLinearSpecularReflection + `
  99750. roughness,
  99751. #endif
  99752. #ifdef ` + this._define3DName + `
  99753. ` + this._cubeSamplerName + `,
  99754. #else
  99755. ` + this._2DSamplerName + `,
  99756. #endif
  99757. #if defined(NORMAL) && defined(USESPHERICALINVERTEX)
  99758. ` + this._vEnvironmentIrradianceName + `,
  99759. #endif
  99760. #ifdef USESPHERICALFROMREFLECTIONMAP
  99761. #if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
  99762. ` + this._reflectionMatrixName + `,
  99763. #endif
  99764. #endif
  99765. #ifdef USEIRRADIANCEMAP
  99766. irradianceSampler, // ** not handled **
  99767. #endif
  99768. #ifndef LODBASEDMICROSFURACE
  99769. #ifdef ` + this._define3DName + `
  99770. ` + this._cubeSamplerName + `,
  99771. ` + this._cubeSamplerName + `,
  99772. #else
  99773. ` + this._2DSamplerName + `,
  99774. ` + this._2DSamplerName + `,
  99775. #endif
  99776. #endif
  99777. #ifdef REALTIME_FILTERING
  99778. ` + this._vReflectionFilteringInfoName + `,
  99779. #endif
  99780. reflectionOut
  99781. );
  99782. #endif\r
  99783. `,
  99784. s
  99785. }
  99786. ,
  99787. e.prototype._buildBlock = function(i) {
  99788. return this._scene = i.sharedData.scene,
  99789. i.target !== NodeMaterialBlockTargets.Fragment && (this._defineLODReflectionAlpha = i._getFreeDefineName("LODINREFLECTIONALPHA"),
  99790. this._defineLinearSpecularReflection = i._getFreeDefineName("LINEARSPECULARREFLECTION")),
  99791. this
  99792. }
  99793. ,
  99794. e.prototype._dumpPropertiesCode = function() {
  99795. var i = a.prototype._dumpPropertiesCode.call(this);
  99796. return this.texture && (i += this._codeVariableName + ".texture.gammaSpace = " + this.texture.gammaSpace + `;\r
  99797. `),
  99798. i += this._codeVariableName + ".useSphericalHarmonics = " + this.useSphericalHarmonics + `;\r
  99799. `,
  99800. i += this._codeVariableName + ".forceIrradianceInFragment = " + this.forceIrradianceInFragment + `;\r
  99801. `,
  99802. i
  99803. }
  99804. ,
  99805. e.prototype.serialize = function() {
  99806. var i, o, s = a.prototype.serialize.call(this);
  99807. return s.useSphericalHarmonics = this.useSphericalHarmonics,
  99808. s.forceIrradianceInFragment = this.forceIrradianceInFragment,
  99809. s.gammaSpace = (o = (i = this.texture) === null || i === void 0 ? void 0 : i.gammaSpace) !== null && o !== void 0 ? o : !0,
  99810. s
  99811. }
  99812. ,
  99813. e.prototype._deserialize = function(i, o, s) {
  99814. a.prototype._deserialize.call(this, i, o, s),
  99815. this.useSphericalHarmonics = i.useSphericalHarmonics,
  99816. this.forceIrradianceInFragment = i.forceIrradianceInFragment,
  99817. this.texture && (this.texture.gammaSpace = i.gammaSpace)
  99818. }
  99819. ,
  99820. __decorate([editableInPropertyPage("Spherical Harmonics", PropertyTypeForEdition.Boolean, "ADVANCED", {
  99821. notifiers: {
  99822. update: !0
  99823. }
  99824. })], e.prototype, "useSphericalHarmonics", void 0),
  99825. __decorate([editableInPropertyPage("Force irradiance in fragment", PropertyTypeForEdition.Boolean, "ADVANCED", {
  99826. notifiers: {
  99827. update: !0
  99828. }
  99829. })], e.prototype, "forceIrradianceInFragment", void 0),
  99830. e
  99831. }(ReflectionTextureBaseBlock);
  99832. RegisterClass("BABYLON.ReflectionBlock", ReflectionBlock);
  99833. var ClearCoatBlock = function(a) {
  99834. __extends(e, a);
  99835. function e(i) {
  99836. var o = a.call(this, i, NodeMaterialBlockTargets.Fragment) || this;
  99837. return o.remapF0OnInterfaceChange = !0,
  99838. o._isUnique = !0,
  99839. o.registerInput("intensity", NodeMaterialBlockConnectionPointTypes.Float, !1, NodeMaterialBlockTargets.Fragment),
  99840. o.registerInput("roughness", NodeMaterialBlockConnectionPointTypes.Float, !0, NodeMaterialBlockTargets.Fragment),
  99841. o.registerInput("indexOfRefraction", NodeMaterialBlockConnectionPointTypes.Float, !0, NodeMaterialBlockTargets.Fragment),
  99842. o.registerInput("normalMapColor", NodeMaterialBlockConnectionPointTypes.Color3, !0, NodeMaterialBlockTargets.Fragment),
  99843. o.registerInput("uv", NodeMaterialBlockConnectionPointTypes.Vector2, !0, NodeMaterialBlockTargets.Fragment),
  99844. o.registerInput("tintColor", NodeMaterialBlockConnectionPointTypes.Color3, !0, NodeMaterialBlockTargets.Fragment),
  99845. o.registerInput("tintAtDistance", NodeMaterialBlockConnectionPointTypes.Float, !0, NodeMaterialBlockTargets.Fragment),
  99846. o.registerInput("tintThickness", NodeMaterialBlockConnectionPointTypes.Float, !0, NodeMaterialBlockTargets.Fragment),
  99847. o.registerInput("worldTangent", NodeMaterialBlockConnectionPointTypes.Vector4, !0),
  99848. o.registerOutput("clearcoat", NodeMaterialBlockConnectionPointTypes.Object, NodeMaterialBlockTargets.Fragment, new NodeMaterialConnectionPointCustomObject("clearcoat",o,NodeMaterialConnectionPointDirection.Output,e,"ClearCoatBlock")),
  99849. o
  99850. }
  99851. return e.prototype.initialize = function(i) {
  99852. i._excludeVariableName("clearcoatOut"),
  99853. i._excludeVariableName("vClearCoatParams"),
  99854. i._excludeVariableName("vClearCoatTintParams"),
  99855. i._excludeVariableName("vClearCoatRefractionParams"),
  99856. i._excludeVariableName("vClearCoatTangentSpaceParams")
  99857. }
  99858. ,
  99859. e.prototype.getClassName = function() {
  99860. return "ClearCoatBlock"
  99861. }
  99862. ,
  99863. Object.defineProperty(e.prototype, "intensity", {
  99864. get: function() {
  99865. return this._inputs[0]
  99866. },
  99867. enumerable: !1,
  99868. configurable: !0
  99869. }),
  99870. Object.defineProperty(e.prototype, "roughness", {
  99871. get: function() {
  99872. return this._inputs[1]
  99873. },
  99874. enumerable: !1,
  99875. configurable: !0
  99876. }),
  99877. Object.defineProperty(e.prototype, "indexOfRefraction", {
  99878. get: function() {
  99879. return this._inputs[2]
  99880. },
  99881. enumerable: !1,
  99882. configurable: !0
  99883. }),
  99884. Object.defineProperty(e.prototype, "normalMapColor", {
  99885. get: function() {
  99886. return this._inputs[3]
  99887. },
  99888. enumerable: !1,
  99889. configurable: !0
  99890. }),
  99891. Object.defineProperty(e.prototype, "uv", {
  99892. get: function() {
  99893. return this._inputs[4]
  99894. },
  99895. enumerable: !1,
  99896. configurable: !0
  99897. }),
  99898. Object.defineProperty(e.prototype, "tintColor", {
  99899. get: function() {
  99900. return this._inputs[5]
  99901. },
  99902. enumerable: !1,
  99903. configurable: !0
  99904. }),
  99905. Object.defineProperty(e.prototype, "tintAtDistance", {
  99906. get: function() {
  99907. return this._inputs[6]
  99908. },
  99909. enumerable: !1,
  99910. configurable: !0
  99911. }),
  99912. Object.defineProperty(e.prototype, "tintThickness", {
  99913. get: function() {
  99914. return this._inputs[7]
  99915. },
  99916. enumerable: !1,
  99917. configurable: !0
  99918. }),
  99919. Object.defineProperty(e.prototype, "worldTangent", {
  99920. get: function() {
  99921. return this._inputs[8]
  99922. },
  99923. enumerable: !1,
  99924. configurable: !0
  99925. }),
  99926. Object.defineProperty(e.prototype, "clearcoat", {
  99927. get: function() {
  99928. return this._outputs[0]
  99929. },
  99930. enumerable: !1,
  99931. configurable: !0
  99932. }),
  99933. e.prototype.autoConfigure = function(i) {
  99934. if (!this.intensity.isConnected) {
  99935. var o = new InputBlock("ClearCoat intensity",NodeMaterialBlockTargets.Fragment,NodeMaterialBlockConnectionPointTypes.Float);
  99936. o.value = 1,
  99937. o.output.connectTo(this.intensity)
  99938. }
  99939. }
  99940. ,
  99941. e.prototype.prepareDefines = function(i, o, s) {
  99942. a.prototype.prepareDefines.call(this, i, o, s),
  99943. s.setValue("CLEARCOAT", !0),
  99944. s.setValue("CLEARCOAT_TEXTURE", !1, !0),
  99945. s.setValue("CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE", !0, !0),
  99946. s.setValue("CLEARCOAT_TINT", this.tintColor.isConnected || this.tintThickness.isConnected || this.tintAtDistance.isConnected, !0),
  99947. s.setValue("CLEARCOAT_BUMP", this.normalMapColor.isConnected, !0),
  99948. s.setValue("CLEARCOAT_DEFAULTIOR", this.indexOfRefraction.isConnected ? this.indexOfRefraction.connectInputBlock.value === PBRClearCoatConfiguration._DefaultIndexOfRefraction : !0, !0),
  99949. s.setValue("CLEARCOAT_REMAP_F0", this.remapF0OnInterfaceChange, !0)
  99950. }
  99951. ,
  99952. e.prototype.bind = function(i, o, s, c) {
  99953. var d, _;
  99954. a.prototype.bind.call(this, i, o, s);
  99955. var b = (_ = (d = this.indexOfRefraction.connectInputBlock) === null || d === void 0 ? void 0 : d.value) !== null && _ !== void 0 ? _ : PBRClearCoatConfiguration._DefaultIndexOfRefraction
  99956. , k = 1 - b
  99957. , j = 1 + b
  99958. , $ = Math.pow(-k / j, 2)
  99959. , _e = 1 / b;
  99960. i.setFloat4("vClearCoatRefractionParams", $, _e, k, j);
  99961. var et = this.clearcoat.hasEndpoints ? this.clearcoat.endpoints[0].ownerBlock : null
  99962. , tt = et != null && et.perturbedNormal.isConnected ? et.perturbedNormal.connectedPoint.ownerBlock : null;
  99963. this._scene._mirroredCameraPosition ? i.setFloat2("vClearCoatTangentSpaceParams", tt != null && tt.invertX ? 1 : -1, tt != null && tt.invertY ? 1 : -1) : i.setFloat2("vClearCoatTangentSpaceParams", tt != null && tt.invertX ? -1 : 1, tt != null && tt.invertY ? -1 : 1)
  99964. }
  99965. ,
  99966. e.prototype._generateTBNSpace = function(i, o, s) {
  99967. var c = ""
  99968. , d = "//" + this.name
  99969. , _ = this.worldTangent;
  99970. i._emitExtension("derivatives", "#extension GL_OES_standard_derivatives : enable");
  99971. var b = {
  99972. search: /defined\(TANGENT\)/g,
  99973. replace: _.isConnected ? "defined(TANGENT)" : "defined(IGNORE)"
  99974. };
  99975. return _.isConnected && (c += "vec3 tbnNormal = normalize(" + s + `.xyz);\r
  99976. `,
  99977. c += "vec3 tbnTangent = normalize(" + _.associatedVariableName + `.xyz);\r
  99978. `,
  99979. c += `vec3 tbnBitangent = cross(tbnNormal, tbnTangent);\r
  99980. `,
  99981. c += `mat3 vTBN = mat3(tbnTangent, tbnBitangent, tbnNormal);\r
  99982. `),
  99983. i._emitFunctionFromInclude("bumpFragmentMainFunctions", d, {
  99984. replaceStrings: [b]
  99985. }),
  99986. c
  99987. }
  99988. ,
  99989. e.GetCode = function(i, o, s, c, d, _, b) {
  99990. var k = ""
  99991. , j = o != null && o.intensity.isConnected ? o.intensity.associatedVariableName : "1."
  99992. , $ = o != null && o.roughness.isConnected ? o.roughness.associatedVariableName : "0."
  99993. , _e = o != null && o.normalMapColor.isConnected ? o.normalMapColor.associatedVariableName : "vec3(0.)"
  99994. , et = o != null && o.uv.isConnected ? o.uv.associatedVariableName : "vec2(0.)"
  99995. , tt = o != null && o.tintColor.isConnected ? o.tintColor.associatedVariableName : "vec3(1.)"
  99996. , rt = o != null && o.tintThickness.isConnected ? o.tintThickness.associatedVariableName : "1."
  99997. , it = o != null && o.tintAtDistance.isConnected ? o.tintAtDistance.associatedVariableName : "1."
  99998. , nt = "vec4(0.)";
  99999. return o && (i._emitUniformFromString("vClearCoatRefractionParams", "vec4"),
  100000. i._emitUniformFromString("vClearCoatTangentSpaceParams", "vec2")),
  100001. d && o && (k += o._generateTBNSpace(i, c, b),
  100002. _ = o.worldTangent.isConnected),
  100003. k += `clearcoatOutParams clearcoatOut;
  100004. #ifdef CLEARCOAT
  100005. vec2 vClearCoatParams = vec2(` + j + ", " + $ + `);
  100006. vec4 vClearCoatTintParams = vec4(` + tt + ", " + rt + `);
  100007. clearcoatBlock(
  100008. ` + c + `.xyz,
  100009. geometricNormalW,
  100010. viewDirectionW,
  100011. vClearCoatParams,
  100012. specularEnvironmentR0,
  100013. #ifdef CLEARCOAT_TEXTURE
  100014. vec2(0.),
  100015. #endif
  100016. #ifdef CLEARCOAT_TINT
  100017. vClearCoatTintParams,
  100018. ` + it + `,
  100019. vClearCoatRefractionParams,
  100020. #ifdef CLEARCOAT_TINT_TEXTURE
  100021. ` + nt + `,
  100022. #endif
  100023. #endif
  100024. #ifdef CLEARCOAT_BUMP
  100025. vec2(0., 1.),
  100026. vec4(` + _e + `, 0.),
  100027. ` + et + `,
  100028. #if defined(` + (_ ? "TANGENT" : "IGNORE") + `) && defined(NORMAL)
  100029. vTBN,
  100030. #else
  100031. vClearCoatTangentSpaceParams,
  100032. #endif
  100033. #ifdef OBJECTSPACE_NORMALMAP
  100034. normalMatrix,
  100035. #endif
  100036. #endif
  100037. #if defined(FORCENORMALFORWARD) && defined(NORMAL)
  100038. faceNormal,
  100039. #endif
  100040. #ifdef REFLECTION
  100041. ` + (s == null ? void 0 : s._vReflectionMicrosurfaceInfosName) + `,
  100042. ` + (s == null ? void 0 : s._vReflectionInfosName) + `,
  100043. ` + (s == null ? void 0 : s.reflectionColor) + `,
  100044. vLightingIntensity,
  100045. #ifdef ` + (s == null ? void 0 : s._define3DName) + `
  100046. ` + (s == null ? void 0 : s._cubeSamplerName) + `,
  100047. #else
  100048. ` + (s == null ? void 0 : s._2DSamplerName) + `,
  100049. #endif
  100050. #ifndef LODBASEDMICROSFURACE
  100051. #ifdef ` + (s == null ? void 0 : s._define3DName) + `
  100052. ` + (s == null ? void 0 : s._cubeSamplerName) + `,
  100053. ` + (s == null ? void 0 : s._cubeSamplerName) + `,
  100054. #else
  100055. ` + (s == null ? void 0 : s._2DSamplerName) + `,
  100056. ` + (s == null ? void 0 : s._2DSamplerName) + `,
  100057. #endif
  100058. #endif
  100059. #endif
  100060. #if defined(ENVIRONMENTBRDF) && !defined(` + (s == null ? void 0 : s._defineSkyboxName) + `)
  100061. #ifdef RADIANCEOCCLUSION
  100062. ambientMonochrome,
  100063. #endif
  100064. #endif
  100065. #if defined(CLEARCOAT_BUMP) || defined(TWOSIDEDLIGHTING)
  100066. (gl_FrontFacing ? 1. : -1.),
  100067. #endif
  100068. clearcoatOut
  100069. );
  100070. #else
  100071. clearcoatOut.specularEnvironmentR0 = specularEnvironmentR0;
  100072. #endif\r
  100073. `,
  100074. k
  100075. }
  100076. ,
  100077. e.prototype._buildBlock = function(i) {
  100078. return this._scene = i.sharedData.scene,
  100079. i.target === NodeMaterialBlockTargets.Fragment && (i.sharedData.bindableBlocks.push(this),
  100080. i.sharedData.blocksWithDefines.push(this)),
  100081. this
  100082. }
  100083. ,
  100084. e.prototype._dumpPropertiesCode = function() {
  100085. var i = a.prototype._dumpPropertiesCode.call(this);
  100086. return i += this._codeVariableName + ".remapF0OnInterfaceChange = " + this.remapF0OnInterfaceChange + `;\r
  100087. `,
  100088. i
  100089. }
  100090. ,
  100091. e.prototype.serialize = function() {
  100092. var i = a.prototype.serialize.call(this);
  100093. return i.remapF0OnInterfaceChange = this.remapF0OnInterfaceChange,
  100094. i
  100095. }
  100096. ,
  100097. e.prototype._deserialize = function(i, o, s) {
  100098. var c;
  100099. a.prototype._deserialize.call(this, i, o, s),
  100100. this.remapF0OnInterfaceChange = (c = i.remapF0OnInterfaceChange) !== null && c !== void 0 ? c : !0
  100101. }
  100102. ,
  100103. __decorate([editableInPropertyPage("Remap F0 on interface change", PropertyTypeForEdition.Boolean, "ADVANCED")], e.prototype, "remapF0OnInterfaceChange", void 0),
  100104. e
  100105. }(NodeMaterialBlock);
  100106. RegisterClass("BABYLON.ClearCoatBlock", ClearCoatBlock);
  100107. var RefractionBlock = function(a) {
  100108. __extends(e, a);
  100109. function e(i) {
  100110. var o = a.call(this, i, NodeMaterialBlockTargets.Fragment) || this;
  100111. return o.linkRefractionWithTransparency = !1,
  100112. o.invertRefractionY = !1,
  100113. o.useThicknessAsDepth = !1,
  100114. o._isUnique = !0,
  100115. o.registerInput("intensity", NodeMaterialBlockConnectionPointTypes.Float, !1, NodeMaterialBlockTargets.Fragment),
  100116. o.registerInput("tintAtDistance", NodeMaterialBlockConnectionPointTypes.Float, !0, NodeMaterialBlockTargets.Fragment),
  100117. o.registerInput("volumeIndexOfRefraction", NodeMaterialBlockConnectionPointTypes.Float, !0, NodeMaterialBlockTargets.Fragment),
  100118. o.registerOutput("refraction", NodeMaterialBlockConnectionPointTypes.Object, NodeMaterialBlockTargets.Fragment, new NodeMaterialConnectionPointCustomObject("refraction",o,NodeMaterialConnectionPointDirection.Output,e,"RefractionBlock")),
  100119. o
  100120. }
  100121. return e.prototype.initialize = function(i) {
  100122. i._excludeVariableName("vRefractionPosition"),
  100123. i._excludeVariableName("vRefractionSize")
  100124. }
  100125. ,
  100126. e.prototype.getClassName = function() {
  100127. return "RefractionBlock"
  100128. }
  100129. ,
  100130. Object.defineProperty(e.prototype, "intensity", {
  100131. get: function() {
  100132. return this._inputs[0]
  100133. },
  100134. enumerable: !1,
  100135. configurable: !0
  100136. }),
  100137. Object.defineProperty(e.prototype, "tintAtDistance", {
  100138. get: function() {
  100139. return this._inputs[1]
  100140. },
  100141. enumerable: !1,
  100142. configurable: !0
  100143. }),
  100144. Object.defineProperty(e.prototype, "volumeIndexOfRefraction", {
  100145. get: function() {
  100146. return this._inputs[2]
  100147. },
  100148. enumerable: !1,
  100149. configurable: !0
  100150. }),
  100151. Object.defineProperty(e.prototype, "view", {
  100152. get: function() {
  100153. return this.viewConnectionPoint
  100154. },
  100155. enumerable: !1,
  100156. configurable: !0
  100157. }),
  100158. Object.defineProperty(e.prototype, "refraction", {
  100159. get: function() {
  100160. return this._outputs[0]
  100161. },
  100162. enumerable: !1,
  100163. configurable: !0
  100164. }),
  100165. Object.defineProperty(e.prototype, "hasTexture", {
  100166. get: function() {
  100167. return !!this._getTexture()
  100168. },
  100169. enumerable: !1,
  100170. configurable: !0
  100171. }),
  100172. e.prototype._getTexture = function() {
  100173. return this.texture ? this.texture : this._scene.environmentTexture
  100174. }
  100175. ,
  100176. e.prototype.autoConfigure = function(i) {
  100177. if (!this.intensity.isConnected) {
  100178. var o = new InputBlock("Refraction intensity",NodeMaterialBlockTargets.Fragment,NodeMaterialBlockConnectionPointTypes.Float);
  100179. o.value = 1,
  100180. o.output.connectTo(this.intensity)
  100181. }
  100182. if (this.view && !this.view.isConnected) {
  100183. var s = i.getInputBlockByPredicate(function(c) {
  100184. return c.systemValue === NodeMaterialSystemValues.View
  100185. });
  100186. s || (s = new InputBlock("view"),
  100187. s.setAsSystemValue(NodeMaterialSystemValues.View)),
  100188. s.output.connectTo(this.view)
  100189. }
  100190. }
  100191. ,
  100192. e.prototype.prepareDefines = function(i, o, s) {
  100193. a.prototype.prepareDefines.call(this, i, o, s);
  100194. var c = this._getTexture()
  100195. , d = c && c.getTextureMatrix;
  100196. s.setValue("SS_REFRACTION", d, !0),
  100197. d && (s.setValue(this._define3DName, c.isCube, !0),
  100198. s.setValue(this._defineLODRefractionAlpha, c.lodLevelInAlpha, !0),
  100199. s.setValue(this._defineLinearSpecularRefraction, c.linearSpecularLOD, !0),
  100200. s.setValue(this._defineOppositeZ, this._scene.useRightHandedSystem ? !c.invertZ : c.invertZ, !0),
  100201. s.setValue("SS_LINKREFRACTIONTOTRANSPARENCY", this.linkRefractionWithTransparency, !0),
  100202. s.setValue("SS_GAMMAREFRACTION", c.gammaSpace, !0),
  100203. s.setValue("SS_RGBDREFRACTION", c.isRGBD, !0),
  100204. s.setValue("SS_USE_LOCAL_REFRACTIONMAP_CUBIC", !!c.boundingBoxSize, !0),
  100205. s.setValue("SS_USE_THICKNESS_AS_DEPTH", this.useThicknessAsDepth, !0))
  100206. }
  100207. ,
  100208. e.prototype.isReady = function() {
  100209. var i = this._getTexture();
  100210. return !(i && !i.isReadyOrNotBlocking())
  100211. }
  100212. ,
  100213. e.prototype.bind = function(i, o, s, c) {
  100214. var d, _, b, k;
  100215. a.prototype.bind.call(this, i, o, s);
  100216. var j = this._getTexture();
  100217. if (!!j) {
  100218. j.isCube ? i.setTexture(this._cubeSamplerName, j) : i.setTexture(this._2DSamplerName, j),
  100219. i.setMatrix(this._refractionMatrixName, j.getReflectionTextureMatrix());
  100220. var $ = 1;
  100221. j.isCube || j.depth && ($ = j.depth);
  100222. var _e = (k = (_ = (d = this.volumeIndexOfRefraction.connectInputBlock) === null || d === void 0 ? void 0 : d.value) !== null && _ !== void 0 ? _ : (b = this.indexOfRefractionConnectionPoint.connectInputBlock) === null || b === void 0 ? void 0 : b.value) !== null && k !== void 0 ? k : 1.5;
  100223. i.setFloat4(this._vRefractionInfosName, j.level, 1 / _e, $, this.invertRefractionY ? -1 : 1),
  100224. i.setFloat4(this._vRefractionMicrosurfaceInfosName, j.getSize().width, j.lodGenerationScale, j.lodGenerationOffset, 1 / _e);
  100225. var et = j.getSize().width;
  100226. if (i.setFloat2(this._vRefractionFilteringInfoName, et, Scalar.Log2(et)),
  100227. j.boundingBoxSize) {
  100228. var tt = j;
  100229. i.setVector3("vRefractionPosition", tt.boundingBoxPosition),
  100230. i.setVector3("vRefractionSize", tt.boundingBoxSize)
  100231. }
  100232. }
  100233. }
  100234. ,
  100235. e.prototype.getCode = function(i) {
  100236. var o = "";
  100237. return i.sharedData.blockingBlocks.push(this),
  100238. i.sharedData.textureBlocks.push(this),
  100239. this._cubeSamplerName = i._getFreeVariableName(this.name + "CubeSampler"),
  100240. i.samplers.push(this._cubeSamplerName),
  100241. this._2DSamplerName = i._getFreeVariableName(this.name + "2DSampler"),
  100242. i.samplers.push(this._2DSamplerName),
  100243. this._define3DName = i._getFreeDefineName("SS_REFRACTIONMAP_3D"),
  100244. i._samplerDeclaration += "#ifdef " + this._define3DName + `\r
  100245. `,
  100246. i._samplerDeclaration += "uniform samplerCube " + this._cubeSamplerName + `;\r
  100247. `,
  100248. i._samplerDeclaration += `#else\r
  100249. `,
  100250. i._samplerDeclaration += "uniform sampler2D " + this._2DSamplerName + `;\r
  100251. `,
  100252. i._samplerDeclaration += `#endif\r
  100253. `,
  100254. i.sharedData.blocksWithDefines.push(this),
  100255. i.sharedData.bindableBlocks.push(this),
  100256. this._defineLODRefractionAlpha = i._getFreeDefineName("SS_LODINREFRACTIONALPHA"),
  100257. this._defineLinearSpecularRefraction = i._getFreeDefineName("SS_LINEARSPECULARREFRACTION"),
  100258. this._defineOppositeZ = i._getFreeDefineName("SS_REFRACTIONMAP_OPPOSITEZ"),
  100259. this._refractionMatrixName = i._getFreeVariableName("refractionMatrix"),
  100260. i._emitUniformFromString(this._refractionMatrixName, "mat4"),
  100261. i._emitFunction("sampleRefraction", `
  100262. #ifdef ` + this._define3DName + `
  100263. #define sampleRefraction(s, c) textureCube(s, c)
  100264. #else
  100265. #define sampleRefraction(s, c) texture2D(s, c)
  100266. #endif\r
  100267. `, "//" + this.name),
  100268. i._emitFunction("sampleRefractionLod", `
  100269. #ifdef ` + this._define3DName + `
  100270. #define sampleRefractionLod(s, c, l) textureCubeLodEXT(s, c, l)
  100271. #else
  100272. #define sampleRefractionLod(s, c, l) texture2DLodEXT(s, c, l)
  100273. #endif\r
  100274. `, "//" + this.name),
  100275. this._vRefractionMicrosurfaceInfosName = i._getFreeVariableName("vRefractionMicrosurfaceInfos"),
  100276. i._emitUniformFromString(this._vRefractionMicrosurfaceInfosName, "vec4"),
  100277. this._vRefractionInfosName = i._getFreeVariableName("vRefractionInfos"),
  100278. i._emitUniformFromString(this._vRefractionInfosName, "vec4"),
  100279. this._vRefractionFilteringInfoName = i._getFreeVariableName("vRefractionFilteringInfo"),
  100280. i._emitUniformFromString(this._vRefractionFilteringInfoName, "vec2"),
  100281. i._emitUniformFromString("vRefractionPosition", "vec3"),
  100282. i._emitUniformFromString("vRefractionSize", "vec3"),
  100283. o
  100284. }
  100285. ,
  100286. e.prototype._buildBlock = function(i) {
  100287. return this._scene = i.sharedData.scene,
  100288. this
  100289. }
  100290. ,
  100291. e.prototype._dumpPropertiesCode = function() {
  100292. var i = a.prototype._dumpPropertiesCode.call(this);
  100293. return this.texture && (this.texture.isCube ? i = this._codeVariableName + '.texture = new BABYLON.CubeTexture("' + this.texture.name + `");\r
  100294. ` : i = this._codeVariableName + '.texture = new BABYLON.Texture("' + this.texture.name + `");\r
  100295. `,
  100296. i += this._codeVariableName + ".texture.coordinatesMode = " + this.texture.coordinatesMode + `;\r
  100297. `),
  100298. i += this._codeVariableName + ".linkRefractionWithTransparency = " + this.linkRefractionWithTransparency + `;\r
  100299. `,
  100300. i += this._codeVariableName + ".invertRefractionY = " + this.invertRefractionY + `;\r
  100301. `,
  100302. i += this._codeVariableName + ".useThicknessAsDepth = " + this.useThicknessAsDepth + `;\r
  100303. `,
  100304. i
  100305. }
  100306. ,
  100307. e.prototype.serialize = function() {
  100308. var i = a.prototype.serialize.call(this);
  100309. return this.texture && !this.texture.isRenderTarget && (i.texture = this.texture.serialize()),
  100310. i.linkRefractionWithTransparency = this.linkRefractionWithTransparency,
  100311. i.invertRefractionY = this.invertRefractionY,
  100312. i.useThicknessAsDepth = this.useThicknessAsDepth,
  100313. i
  100314. }
  100315. ,
  100316. e.prototype._deserialize = function(i, o, s) {
  100317. a.prototype._deserialize.call(this, i, o, s),
  100318. i.texture && (s = i.texture.url.indexOf("data:") === 0 ? "" : s,
  100319. i.texture.isCube ? this.texture = CubeTexture.Parse(i.texture, o, s) : this.texture = Texture.Parse(i.texture, o, s)),
  100320. this.linkRefractionWithTransparency = i.linkRefractionWithTransparency,
  100321. this.invertRefractionY = i.invertRefractionY,
  100322. this.useThicknessAsDepth = !!i.useThicknessAsDepth
  100323. }
  100324. ,
  100325. __decorate([editableInPropertyPage("Link refraction to transparency", PropertyTypeForEdition.Boolean, "ADVANCED", {
  100326. notifiers: {
  100327. update: !0
  100328. }
  100329. })], e.prototype, "linkRefractionWithTransparency", void 0),
  100330. __decorate([editableInPropertyPage("Invert refraction Y", PropertyTypeForEdition.Boolean, "ADVANCED", {
  100331. notifiers: {
  100332. update: !0
  100333. }
  100334. })], e.prototype, "invertRefractionY", void 0),
  100335. __decorate([editableInPropertyPage("Use thickness as depth", PropertyTypeForEdition.Boolean, "ADVANCED", {
  100336. notifiers: {
  100337. update: !0
  100338. }
  100339. })], e.prototype, "useThicknessAsDepth", void 0),
  100340. e
  100341. }(NodeMaterialBlock);
  100342. RegisterClass("BABYLON.RefractionBlock", RefractionBlock);
  100343. var SubSurfaceBlock = function(a) {
  100344. __extends(e, a);
  100345. function e(i) {
  100346. var o = a.call(this, i, NodeMaterialBlockTargets.Fragment) || this;
  100347. return o._isUnique = !0,
  100348. o.registerInput("thickness", NodeMaterialBlockConnectionPointTypes.Float, !1, NodeMaterialBlockTargets.Fragment),
  100349. o.registerInput("tintColor", NodeMaterialBlockConnectionPointTypes.Color3, !0, NodeMaterialBlockTargets.Fragment),
  100350. o.registerInput("translucencyIntensity", NodeMaterialBlockConnectionPointTypes.Float, !0, NodeMaterialBlockTargets.Fragment),
  100351. o.registerInput("translucencyDiffusionDist", NodeMaterialBlockConnectionPointTypes.Color3, !0, NodeMaterialBlockTargets.Fragment),
  100352. o.registerInput("refraction", NodeMaterialBlockConnectionPointTypes.Object, !0, NodeMaterialBlockTargets.Fragment, new NodeMaterialConnectionPointCustomObject("refraction",o,NodeMaterialConnectionPointDirection.Input,RefractionBlock,"RefractionBlock")),
  100353. o.registerOutput("subsurface", NodeMaterialBlockConnectionPointTypes.Object, NodeMaterialBlockTargets.Fragment, new NodeMaterialConnectionPointCustomObject("subsurface",o,NodeMaterialConnectionPointDirection.Output,e,"SubSurfaceBlock")),
  100354. o
  100355. }
  100356. return e.prototype.initialize = function(i) {
  100357. i._excludeVariableName("subSurfaceOut"),
  100358. i._excludeVariableName("vThicknessParam"),
  100359. i._excludeVariableName("vTintColor"),
  100360. i._excludeVariableName("vSubSurfaceIntensity")
  100361. }
  100362. ,
  100363. e.prototype.getClassName = function() {
  100364. return "SubSurfaceBlock"
  100365. }
  100366. ,
  100367. Object.defineProperty(e.prototype, "thickness", {
  100368. get: function() {
  100369. return this._inputs[0]
  100370. },
  100371. enumerable: !1,
  100372. configurable: !0
  100373. }),
  100374. Object.defineProperty(e.prototype, "tintColor", {
  100375. get: function() {
  100376. return this._inputs[1]
  100377. },
  100378. enumerable: !1,
  100379. configurable: !0
  100380. }),
  100381. Object.defineProperty(e.prototype, "translucencyIntensity", {
  100382. get: function() {
  100383. return this._inputs[2]
  100384. },
  100385. enumerable: !1,
  100386. configurable: !0
  100387. }),
  100388. Object.defineProperty(e.prototype, "translucencyDiffusionDist", {
  100389. get: function() {
  100390. return this._inputs[3]
  100391. },
  100392. enumerable: !1,
  100393. configurable: !0
  100394. }),
  100395. Object.defineProperty(e.prototype, "refraction", {
  100396. get: function() {
  100397. return this._inputs[4]
  100398. },
  100399. enumerable: !1,
  100400. configurable: !0
  100401. }),
  100402. Object.defineProperty(e.prototype, "subsurface", {
  100403. get: function() {
  100404. return this._outputs[0]
  100405. },
  100406. enumerable: !1,
  100407. configurable: !0
  100408. }),
  100409. e.prototype.autoConfigure = function(i) {
  100410. if (!this.thickness.isConnected) {
  100411. var o = new InputBlock("SubSurface thickness",NodeMaterialBlockTargets.Fragment,NodeMaterialBlockConnectionPointTypes.Float);
  100412. o.value = 0,
  100413. o.output.connectTo(this.thickness)
  100414. }
  100415. }
  100416. ,
  100417. e.prototype.prepareDefines = function(i, o, s) {
  100418. a.prototype.prepareDefines.call(this, i, o, s);
  100419. var c = this.translucencyDiffusionDist.isConnected || this.translucencyIntensity.isConnected;
  100420. s.setValue("SUBSURFACE", c || this.refraction.isConnected, !0),
  100421. s.setValue("SS_TRANSLUCENCY", c, !0),
  100422. s.setValue("SS_THICKNESSANDMASK_TEXTURE", !1, !0),
  100423. s.setValue("SS_REFRACTIONINTENSITY_TEXTURE", !1, !0),
  100424. s.setValue("SS_TRANSLUCENCYINTENSITY_TEXTURE", !1, !0),
  100425. s.setValue("SS_MASK_FROM_THICKNESS_TEXTURE", !1, !0),
  100426. s.setValue("SS_USE_GLTF_TEXTURES", !1, !0)
  100427. }
  100428. ,
  100429. e.GetCode = function(i, o, s, c) {
  100430. var d, _, b, k, j, $, _e, et, tt, rt, it, nt, ot, at, st, ut, ct = "", lt = o != null && o.thickness.isConnected ? o.thickness.associatedVariableName : "0.", ft = o != null && o.tintColor.isConnected ? o.tintColor.associatedVariableName : "vec3(1.)", ht = o != null && o.translucencyIntensity.isConnected ? o == null ? void 0 : o.translucencyIntensity.associatedVariableName : "1.", pt = o != null && o.translucencyDiffusionDist.isConnected ? o == null ? void 0 : o.translucencyDiffusionDist.associatedVariableName : "vec3(1.)", dt = o != null && o.refraction.isConnected ? (d = o == null ? void 0 : o.refraction.connectedPoint) === null || d === void 0 ? void 0 : d.ownerBlock : null, _t = dt != null && dt.tintAtDistance.isConnected ? dt.tintAtDistance.associatedVariableName : "1.", mt = dt != null && dt.intensity.isConnected ? dt.intensity.associatedVariableName : "1.", vt = dt != null && dt.view.isConnected ? dt.view.associatedVariableName : "";
  100431. return ct += (_ = dt == null ? void 0 : dt.getCode(i)) !== null && _ !== void 0 ? _ : "",
  100432. ct += `subSurfaceOutParams subSurfaceOut;
  100433. #ifdef SUBSURFACE
  100434. vec2 vThicknessParam = vec2(0., ` + lt + `);
  100435. vec4 vTintColor = vec4(` + ft + ", " + _t + `);
  100436. vec3 vSubSurfaceIntensity = vec3(` + mt + ", " + ht + `, 0.);
  100437. subSurfaceBlock(
  100438. vSubSurfaceIntensity,
  100439. vThicknessParam,
  100440. vTintColor,
  100441. normalW,
  100442. specularEnvironmentReflectance,
  100443. #ifdef SS_THICKNESSANDMASK_TEXTURE
  100444. vec4(0.),
  100445. #endif
  100446. #ifdef REFLECTION
  100447. #ifdef SS_TRANSLUCENCY
  100448. ` + (s == null ? void 0 : s._reflectionMatrixName) + `,
  100449. #ifdef USESPHERICALFROMREFLECTIONMAP
  100450. #if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
  100451. reflectionOut.irradianceVector,
  100452. #endif
  100453. #if defined(REALTIME_FILTERING)
  100454. ` + (s == null ? void 0 : s._cubeSamplerName) + `,
  100455. ` + (s == null ? void 0 : s._vReflectionFilteringInfoName) + `,
  100456. #endif
  100457. #endif
  100458. #ifdef USEIRRADIANCEMAP
  100459. irradianceSampler,
  100460. #endif
  100461. #endif
  100462. #endif
  100463. #if defined(SS_REFRACTION) || defined(SS_TRANSLUCENCY)
  100464. surfaceAlbedo,
  100465. #endif
  100466. #ifdef SS_REFRACTION
  100467. ` + c + `.xyz,
  100468. viewDirectionW,
  100469. ` + vt + `,
  100470. ` + ((b = dt == null ? void 0 : dt._vRefractionInfosName) !== null && b !== void 0 ? b : "") + `,
  100471. ` + ((k = dt == null ? void 0 : dt._refractionMatrixName) !== null && k !== void 0 ? k : "") + `,
  100472. ` + ((j = dt == null ? void 0 : dt._vRefractionMicrosurfaceInfosName) !== null && j !== void 0 ? j : "") + `,
  100473. vLightingIntensity,
  100474. #ifdef SS_LINKREFRACTIONTOTRANSPARENCY
  100475. alpha,
  100476. #endif
  100477. #ifdef ` + (($ = dt == null ? void 0 : dt._defineLODRefractionAlpha) !== null && $ !== void 0 ? $ : "IGNORE") + `
  100478. NdotVUnclamped,
  100479. #endif
  100480. #ifdef ` + ((_e = dt == null ? void 0 : dt._defineLinearSpecularRefraction) !== null && _e !== void 0 ? _e : "IGNORE") + `
  100481. roughness,
  100482. #endif
  100483. alphaG,
  100484. #ifdef ` + ((et = dt == null ? void 0 : dt._define3DName) !== null && et !== void 0 ? et : "IGNORE") + `
  100485. ` + ((tt = dt == null ? void 0 : dt._cubeSamplerName) !== null && tt !== void 0 ? tt : "") + `,
  100486. #else
  100487. ` + ((rt = dt == null ? void 0 : dt._2DSamplerName) !== null && rt !== void 0 ? rt : "") + `,
  100488. #endif
  100489. #ifndef LODBASEDMICROSFURACE
  100490. #ifdef ` + ((it = dt == null ? void 0 : dt._define3DName) !== null && it !== void 0 ? it : "IGNORE") + `
  100491. ` + ((nt = dt == null ? void 0 : dt._cubeSamplerName) !== null && nt !== void 0 ? nt : "") + `,
  100492. ` + ((ot = dt == null ? void 0 : dt._cubeSamplerName) !== null && ot !== void 0 ? ot : "") + `,
  100493. #else
  100494. ` + ((at = dt == null ? void 0 : dt._2DSamplerName) !== null && at !== void 0 ? at : "") + `,
  100495. ` + ((st = dt == null ? void 0 : dt._2DSamplerName) !== null && st !== void 0 ? st : "") + `,
  100496. #endif
  100497. #endif
  100498. #ifdef ANISOTROPIC
  100499. anisotropicOut,
  100500. #endif
  100501. #ifdef REALTIME_FILTERING
  100502. ` + ((ut = dt == null ? void 0 : dt._vRefractionFilteringInfoName) !== null && ut !== void 0 ? ut : "") + `,
  100503. #endif
  100504. #ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
  100505. vRefractionPosition,
  100506. vRefractionSize,
  100507. #endif
  100508. #endif
  100509. #ifdef SS_TRANSLUCENCY
  100510. ` + pt + `,
  100511. #endif
  100512. subSurfaceOut
  100513. );
  100514. #ifdef SS_REFRACTION
  100515. surfaceAlbedo = subSurfaceOut.surfaceAlbedo;
  100516. #ifdef SS_LINKREFRACTIONTOTRANSPARENCY
  100517. alpha = subSurfaceOut.alpha;
  100518. #endif
  100519. #endif
  100520. #else
  100521. subSurfaceOut.specularEnvironmentReflectance = specularEnvironmentReflectance;
  100522. #endif\r
  100523. `,
  100524. ct
  100525. }
  100526. ,
  100527. e.prototype._buildBlock = function(i) {
  100528. return i.target === NodeMaterialBlockTargets.Fragment && i.sharedData.blocksWithDefines.push(this),
  100529. this
  100530. }
  100531. ,
  100532. e
  100533. }(NodeMaterialBlock);
  100534. RegisterClass("BABYLON.SubSurfaceBlock", SubSurfaceBlock);
  100535. var mapOutputToVariable = {
  100536. ambientClr: ["finalAmbient", ""],
  100537. diffuseDir: ["finalDiffuse", ""],
  100538. specularDir: ["finalSpecularScaled", "!defined(UNLIT) && defined(SPECULARTERM)"],
  100539. clearcoatDir: ["finalClearCoatScaled", "!defined(UNLIT) && defined(CLEARCOAT)"],
  100540. sheenDir: ["finalSheenScaled", "!defined(UNLIT) && defined(SHEEN)"],
  100541. diffuseInd: ["finalIrradiance", "!defined(UNLIT) && defined(REFLECTION)"],
  100542. specularInd: ["finalRadianceScaled", "!defined(UNLIT) && defined(REFLECTION)"],
  100543. clearcoatInd: ["clearcoatOut.finalClearCoatRadianceScaled", "!defined(UNLIT) && defined(REFLECTION) && defined(CLEARCOAT)"],
  100544. sheenInd: ["sheenOut.finalSheenRadianceScaled", "!defined(UNLIT) && defined(REFLECTION) && defined(SHEEN) && defined(ENVIRONMENTBRDF)"],
  100545. refraction: ["subSurfaceOut.finalRefraction", "!defined(UNLIT) && defined(SS_REFRACTION)"],
  100546. lighting: ["finalColor.rgb", ""],
  100547. shadow: ["shadow", ""],
  100548. alpha: ["alpha", ""]
  100549. }
  100550. , PBRMetallicRoughnessBlock = function(a) {
  100551. __extends(e, a);
  100552. function e(i) {
  100553. var o = a.call(this, i, NodeMaterialBlockTargets.VertexAndFragment) || this;
  100554. return o._environmentBRDFTexture = null,
  100555. o._metallicReflectanceColor = Color3.White(),
  100556. o._metallicF0Factor = 1,
  100557. o.directIntensity = 1,
  100558. o.environmentIntensity = 1,
  100559. o.specularIntensity = 1,
  100560. o.lightFalloff = 0,
  100561. o.useAlphaTest = !1,
  100562. o.alphaTestCutoff = .5,
  100563. o.useAlphaBlending = !1,
  100564. o.useRadianceOverAlpha = !0,
  100565. o.useSpecularOverAlpha = !0,
  100566. o.enableSpecularAntiAliasing = !1,
  100567. o.realTimeFiltering = !1,
  100568. o.realTimeFilteringQuality = 8,
  100569. o.useEnergyConservation = !0,
  100570. o.useRadianceOcclusion = !0,
  100571. o.useHorizonOcclusion = !0,
  100572. o.unlit = !1,
  100573. o.forceNormalForward = !1,
  100574. o.debugMode = 0,
  100575. o.debugLimit = 0,
  100576. o.debugFactor = 1,
  100577. o._isUnique = !0,
  100578. o.registerInput("worldPosition", NodeMaterialBlockConnectionPointTypes.Vector4, !1, NodeMaterialBlockTargets.Vertex),
  100579. o.registerInput("worldNormal", NodeMaterialBlockConnectionPointTypes.Vector4, !1, NodeMaterialBlockTargets.Fragment),
  100580. o.registerInput("view", NodeMaterialBlockConnectionPointTypes.Matrix, !1),
  100581. o.registerInput("cameraPosition", NodeMaterialBlockConnectionPointTypes.Vector3, !1, NodeMaterialBlockTargets.Fragment),
  100582. o.registerInput("perturbedNormal", NodeMaterialBlockConnectionPointTypes.Vector4, !0, NodeMaterialBlockTargets.Fragment),
  100583. o.registerInput("baseColor", NodeMaterialBlockConnectionPointTypes.Color3, !0, NodeMaterialBlockTargets.Fragment),
  100584. o.registerInput("metallic", NodeMaterialBlockConnectionPointTypes.Float, !1, NodeMaterialBlockTargets.Fragment),
  100585. o.registerInput("roughness", NodeMaterialBlockConnectionPointTypes.Float, !1, NodeMaterialBlockTargets.Fragment),
  100586. o.registerInput("ambientOcc", NodeMaterialBlockConnectionPointTypes.Float, !0, NodeMaterialBlockTargets.Fragment),
  100587. o.registerInput("opacity", NodeMaterialBlockConnectionPointTypes.Float, !0, NodeMaterialBlockTargets.Fragment),
  100588. o.registerInput("indexOfRefraction", NodeMaterialBlockConnectionPointTypes.Float, !0, NodeMaterialBlockTargets.Fragment),
  100589. o.registerInput("ambientColor", NodeMaterialBlockConnectionPointTypes.Color3, !0, NodeMaterialBlockTargets.Fragment),
  100590. o.registerInput("reflection", NodeMaterialBlockConnectionPointTypes.Object, !0, NodeMaterialBlockTargets.Fragment, new NodeMaterialConnectionPointCustomObject("reflection",o,NodeMaterialConnectionPointDirection.Input,ReflectionBlock,"ReflectionBlock")),
  100591. o.registerInput("clearcoat", NodeMaterialBlockConnectionPointTypes.Object, !0, NodeMaterialBlockTargets.Fragment, new NodeMaterialConnectionPointCustomObject("clearcoat",o,NodeMaterialConnectionPointDirection.Input,ClearCoatBlock,"ClearCoatBlock")),
  100592. o.registerInput("sheen", NodeMaterialBlockConnectionPointTypes.Object, !0, NodeMaterialBlockTargets.Fragment, new NodeMaterialConnectionPointCustomObject("sheen",o,NodeMaterialConnectionPointDirection.Input,SheenBlock,"SheenBlock")),
  100593. o.registerInput("subsurface", NodeMaterialBlockConnectionPointTypes.Object, !0, NodeMaterialBlockTargets.Fragment, new NodeMaterialConnectionPointCustomObject("subsurface",o,NodeMaterialConnectionPointDirection.Input,SubSurfaceBlock,"SubSurfaceBlock")),
  100594. o.registerInput("anisotropy", NodeMaterialBlockConnectionPointTypes.Object, !0, NodeMaterialBlockTargets.Fragment, new NodeMaterialConnectionPointCustomObject("anisotropy",o,NodeMaterialConnectionPointDirection.Input,AnisotropyBlock,"AnisotropyBlock")),
  100595. o.registerOutput("ambientClr", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment),
  100596. o.registerOutput("diffuseDir", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment),
  100597. o.registerOutput("specularDir", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment),
  100598. o.registerOutput("clearcoatDir", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment),
  100599. o.registerOutput("sheenDir", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment),
  100600. o.registerOutput("diffuseInd", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment),
  100601. o.registerOutput("specularInd", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment),
  100602. o.registerOutput("clearcoatInd", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment),
  100603. o.registerOutput("sheenInd", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment),
  100604. o.registerOutput("refraction", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment),
  100605. o.registerOutput("lighting", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment),
  100606. o.registerOutput("shadow", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment),
  100607. o.registerOutput("alpha", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment),
  100608. o
  100609. }
  100610. return e.prototype.initialize = function(i) {
  100611. i._excludeVariableName("vLightingIntensity"),
  100612. i._excludeVariableName("geometricNormalW"),
  100613. i._excludeVariableName("normalW"),
  100614. i._excludeVariableName("faceNormal"),
  100615. i._excludeVariableName("albedoOpacityOut"),
  100616. i._excludeVariableName("surfaceAlbedo"),
  100617. i._excludeVariableName("alpha"),
  100618. i._excludeVariableName("aoOut"),
  100619. i._excludeVariableName("baseColor"),
  100620. i._excludeVariableName("reflectivityOut"),
  100621. i._excludeVariableName("microSurface"),
  100622. i._excludeVariableName("roughness"),
  100623. i._excludeVariableName("NdotVUnclamped"),
  100624. i._excludeVariableName("NdotV"),
  100625. i._excludeVariableName("alphaG"),
  100626. i._excludeVariableName("AARoughnessFactors"),
  100627. i._excludeVariableName("environmentBrdf"),
  100628. i._excludeVariableName("ambientMonochrome"),
  100629. i._excludeVariableName("seo"),
  100630. i._excludeVariableName("eho"),
  100631. i._excludeVariableName("environmentRadiance"),
  100632. i._excludeVariableName("irradianceVector"),
  100633. i._excludeVariableName("environmentIrradiance"),
  100634. i._excludeVariableName("diffuseBase"),
  100635. i._excludeVariableName("specularBase"),
  100636. i._excludeVariableName("preInfo"),
  100637. i._excludeVariableName("info"),
  100638. i._excludeVariableName("shadow"),
  100639. i._excludeVariableName("finalDiffuse"),
  100640. i._excludeVariableName("finalAmbient"),
  100641. i._excludeVariableName("ambientOcclusionForDirectDiffuse"),
  100642. i._excludeVariableName("finalColor"),
  100643. i._excludeVariableName("vClipSpacePosition"),
  100644. i._excludeVariableName("vDebugMode")
  100645. }
  100646. ,
  100647. e.prototype.getClassName = function() {
  100648. return "PBRMetallicRoughnessBlock"
  100649. }
  100650. ,
  100651. Object.defineProperty(e.prototype, "worldPosition", {
  100652. get: function() {
  100653. return this._inputs[0]
  100654. },
  100655. enumerable: !1,
  100656. configurable: !0
  100657. }),
  100658. Object.defineProperty(e.prototype, "worldNormal", {
  100659. get: function() {
  100660. return this._inputs[1]
  100661. },
  100662. enumerable: !1,
  100663. configurable: !0
  100664. }),
  100665. Object.defineProperty(e.prototype, "view", {
  100666. get: function() {
  100667. return this._inputs[2]
  100668. },
  100669. enumerable: !1,
  100670. configurable: !0
  100671. }),
  100672. Object.defineProperty(e.prototype, "cameraPosition", {
  100673. get: function() {
  100674. return this._inputs[3]
  100675. },
  100676. enumerable: !1,
  100677. configurable: !0
  100678. }),
  100679. Object.defineProperty(e.prototype, "perturbedNormal", {
  100680. get: function() {
  100681. return this._inputs[4]
  100682. },
  100683. enumerable: !1,
  100684. configurable: !0
  100685. }),
  100686. Object.defineProperty(e.prototype, "baseColor", {
  100687. get: function() {
  100688. return this._inputs[5]
  100689. },
  100690. enumerable: !1,
  100691. configurable: !0
  100692. }),
  100693. Object.defineProperty(e.prototype, "metallic", {
  100694. get: function() {
  100695. return this._inputs[6]
  100696. },
  100697. enumerable: !1,
  100698. configurable: !0
  100699. }),
  100700. Object.defineProperty(e.prototype, "roughness", {
  100701. get: function() {
  100702. return this._inputs[7]
  100703. },
  100704. enumerable: !1,
  100705. configurable: !0
  100706. }),
  100707. Object.defineProperty(e.prototype, "ambientOcc", {
  100708. get: function() {
  100709. return this._inputs[8]
  100710. },
  100711. enumerable: !1,
  100712. configurable: !0
  100713. }),
  100714. Object.defineProperty(e.prototype, "opacity", {
  100715. get: function() {
  100716. return this._inputs[9]
  100717. },
  100718. enumerable: !1,
  100719. configurable: !0
  100720. }),
  100721. Object.defineProperty(e.prototype, "indexOfRefraction", {
  100722. get: function() {
  100723. return this._inputs[10]
  100724. },
  100725. enumerable: !1,
  100726. configurable: !0
  100727. }),
  100728. Object.defineProperty(e.prototype, "ambientColor", {
  100729. get: function() {
  100730. return this._inputs[11]
  100731. },
  100732. enumerable: !1,
  100733. configurable: !0
  100734. }),
  100735. Object.defineProperty(e.prototype, "reflection", {
  100736. get: function() {
  100737. return this._inputs[12]
  100738. },
  100739. enumerable: !1,
  100740. configurable: !0
  100741. }),
  100742. Object.defineProperty(e.prototype, "clearcoat", {
  100743. get: function() {
  100744. return this._inputs[13]
  100745. },
  100746. enumerable: !1,
  100747. configurable: !0
  100748. }),
  100749. Object.defineProperty(e.prototype, "sheen", {
  100750. get: function() {
  100751. return this._inputs[14]
  100752. },
  100753. enumerable: !1,
  100754. configurable: !0
  100755. }),
  100756. Object.defineProperty(e.prototype, "subsurface", {
  100757. get: function() {
  100758. return this._inputs[15]
  100759. },
  100760. enumerable: !1,
  100761. configurable: !0
  100762. }),
  100763. Object.defineProperty(e.prototype, "anisotropy", {
  100764. get: function() {
  100765. return this._inputs[16]
  100766. },
  100767. enumerable: !1,
  100768. configurable: !0
  100769. }),
  100770. Object.defineProperty(e.prototype, "ambientClr", {
  100771. get: function() {
  100772. return this._outputs[0]
  100773. },
  100774. enumerable: !1,
  100775. configurable: !0
  100776. }),
  100777. Object.defineProperty(e.prototype, "diffuseDir", {
  100778. get: function() {
  100779. return this._outputs[1]
  100780. },
  100781. enumerable: !1,
  100782. configurable: !0
  100783. }),
  100784. Object.defineProperty(e.prototype, "specularDir", {
  100785. get: function() {
  100786. return this._outputs[2]
  100787. },
  100788. enumerable: !1,
  100789. configurable: !0
  100790. }),
  100791. Object.defineProperty(e.prototype, "clearcoatDir", {
  100792. get: function() {
  100793. return this._outputs[3]
  100794. },
  100795. enumerable: !1,
  100796. configurable: !0
  100797. }),
  100798. Object.defineProperty(e.prototype, "sheenDir", {
  100799. get: function() {
  100800. return this._outputs[4]
  100801. },
  100802. enumerable: !1,
  100803. configurable: !0
  100804. }),
  100805. Object.defineProperty(e.prototype, "diffuseInd", {
  100806. get: function() {
  100807. return this._outputs[5]
  100808. },
  100809. enumerable: !1,
  100810. configurable: !0
  100811. }),
  100812. Object.defineProperty(e.prototype, "specularInd", {
  100813. get: function() {
  100814. return this._outputs[6]
  100815. },
  100816. enumerable: !1,
  100817. configurable: !0
  100818. }),
  100819. Object.defineProperty(e.prototype, "clearcoatInd", {
  100820. get: function() {
  100821. return this._outputs[7]
  100822. },
  100823. enumerable: !1,
  100824. configurable: !0
  100825. }),
  100826. Object.defineProperty(e.prototype, "sheenInd", {
  100827. get: function() {
  100828. return this._outputs[8]
  100829. },
  100830. enumerable: !1,
  100831. configurable: !0
  100832. }),
  100833. Object.defineProperty(e.prototype, "refraction", {
  100834. get: function() {
  100835. return this._outputs[9]
  100836. },
  100837. enumerable: !1,
  100838. configurable: !0
  100839. }),
  100840. Object.defineProperty(e.prototype, "lighting", {
  100841. get: function() {
  100842. return this._outputs[10]
  100843. },
  100844. enumerable: !1,
  100845. configurable: !0
  100846. }),
  100847. Object.defineProperty(e.prototype, "shadow", {
  100848. get: function() {
  100849. return this._outputs[11]
  100850. },
  100851. enumerable: !1,
  100852. configurable: !0
  100853. }),
  100854. Object.defineProperty(e.prototype, "alpha", {
  100855. get: function() {
  100856. return this._outputs[12]
  100857. },
  100858. enumerable: !1,
  100859. configurable: !0
  100860. }),
  100861. e.prototype.autoConfigure = function(i) {
  100862. if (!this.cameraPosition.isConnected) {
  100863. var o = i.getInputBlockByPredicate(function(c) {
  100864. return c.systemValue === NodeMaterialSystemValues.CameraPosition
  100865. });
  100866. o || (o = new InputBlock("cameraPosition"),
  100867. o.setAsSystemValue(NodeMaterialSystemValues.CameraPosition)),
  100868. o.output.connectTo(this.cameraPosition)
  100869. }
  100870. if (!this.view.isConnected) {
  100871. var s = i.getInputBlockByPredicate(function(c) {
  100872. return c.systemValue === NodeMaterialSystemValues.View
  100873. });
  100874. s || (s = new InputBlock("view"),
  100875. s.setAsSystemValue(NodeMaterialSystemValues.View)),
  100876. s.output.connectTo(this.view)
  100877. }
  100878. }
  100879. ,
  100880. e.prototype.prepareDefines = function(i, o, s) {
  100881. s.setValue("PBR", !0),
  100882. s.setValue("METALLICWORKFLOW", !0),
  100883. s.setValue("DEBUGMODE", this.debugMode, !0),
  100884. s.setValue("NORMALXYSCALE", !0),
  100885. s.setValue("BUMP", this.perturbedNormal.isConnected, !0),
  100886. s.setValue("LODBASEDMICROSFURACE", this._scene.getEngine().getCaps().textureLOD),
  100887. s.setValue("ALBEDO", !1, !0),
  100888. s.setValue("OPACITY", this.opacity.isConnected, !0),
  100889. s.setValue("AMBIENT", !0, !0),
  100890. s.setValue("AMBIENTINGRAYSCALE", !1, !0),
  100891. s.setValue("REFLECTIVITY", !1, !0),
  100892. s.setValue("AOSTOREINMETALMAPRED", !1, !0),
  100893. s.setValue("METALLNESSSTOREINMETALMAPBLUE", !1, !0),
  100894. s.setValue("ROUGHNESSSTOREINMETALMAPALPHA", !1, !0),
  100895. s.setValue("ROUGHNESSSTOREINMETALMAPGREEN", !1, !0),
  100896. this.lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_STANDARD ? (s.setValue("USEPHYSICALLIGHTFALLOFF", !1),
  100897. s.setValue("USEGLTFLIGHTFALLOFF", !1)) : this.lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_GLTF ? (s.setValue("USEPHYSICALLIGHTFALLOFF", !1),
  100898. s.setValue("USEGLTFLIGHTFALLOFF", !0)) : (s.setValue("USEPHYSICALLIGHTFALLOFF", !0),
  100899. s.setValue("USEGLTFLIGHTFALLOFF", !1));
  100900. var c = this.alphaTestCutoff.toString();
  100901. s.setValue("ALPHABLEND", this.useAlphaBlending, !0),
  100902. s.setValue("ALPHAFROMALBEDO", !1, !0),
  100903. s.setValue("ALPHATEST", this.useAlphaTest, !0),
  100904. s.setValue("ALPHATESTVALUE", c.indexOf(".") < 0 ? c + "." : c, !0),
  100905. s.setValue("OPACITYRGB", !1, !0),
  100906. s.setValue("RADIANCEOVERALPHA", this.useRadianceOverAlpha, !0),
  100907. s.setValue("SPECULAROVERALPHA", this.useSpecularOverAlpha, !0),
  100908. s.setValue("SPECULARAA", this._scene.getEngine().getCaps().standardDerivatives && this.enableSpecularAntiAliasing, !0),
  100909. s.setValue("REALTIME_FILTERING", this.realTimeFiltering, !0);
  100910. var d = i.getScene();
  100911. if (d.getEngine()._features.needTypeSuffixInShaderConstants ? s.setValue("NUM_SAMPLES", this.realTimeFilteringQuality + "u", !0) : s.setValue("NUM_SAMPLES", "" + this.realTimeFilteringQuality, !0),
  100912. s.setValue("BRDF_V_HEIGHT_CORRELATED", !0),
  100913. s.setValue("MS_BRDF_ENERGY_CONSERVATION", this.useEnergyConservation, !0),
  100914. s.setValue("RADIANCEOCCLUSION", this.useRadianceOcclusion, !0),
  100915. s.setValue("HORIZONOCCLUSION", this.useHorizonOcclusion, !0),
  100916. s.setValue("UNLIT", this.unlit, !0),
  100917. s.setValue("FORCENORMALFORWARD", this.forceNormalForward, !0),
  100918. this._environmentBRDFTexture && MaterialFlags.ReflectionTextureEnabled ? (s.setValue("ENVIRONMENTBRDF", !0),
  100919. s.setValue("ENVIRONMENTBRDF_RGBD", this._environmentBRDFTexture.isRGBD, !0)) : (s.setValue("ENVIRONMENTBRDF", !1),
  100920. s.setValue("ENVIRONMENTBRDF_RGBD", !1)),
  100921. s._areImageProcessingDirty && o.imageProcessingConfiguration && o.imageProcessingConfiguration.prepareDefines(s),
  100922. !!s._areLightsDirty)
  100923. if (!this.light)
  100924. MaterialHelper.PrepareDefinesForLights(d, i, s, !0, o.maxSimultaneousLights),
  100925. s._needNormals = !0,
  100926. MaterialHelper.PrepareDefinesForMultiview(d, s);
  100927. else {
  100928. var _ = {
  100929. needNormals: !1,
  100930. needRebuild: !1,
  100931. lightmapMode: !1,
  100932. shadowEnabled: !1,
  100933. specularEnabled: !1
  100934. };
  100935. MaterialHelper.PrepareDefinesForLight(d, i, this.light, this._lightId, s, !0, _),
  100936. _.needRebuild && s.rebuild()
  100937. }
  100938. }
  100939. ,
  100940. e.prototype.updateUniformsAndSamples = function(i, o, s, c) {
  100941. for (var d = 0; d < o.maxSimultaneousLights && s["LIGHT" + d]; d++) {
  100942. var _ = i.uniforms.indexOf("vLightData" + d) >= 0;
  100943. MaterialHelper.PrepareUniformsAndSamplersForLight(d, i.uniforms, i.samplers, s["PROJECTEDLIGHTTEXTURE" + d], c, _)
  100944. }
  100945. }
  100946. ,
  100947. e.prototype.isReady = function(i, o, s) {
  100948. return !(this._environmentBRDFTexture && !this._environmentBRDFTexture.isReady() || s._areImageProcessingDirty && o.imageProcessingConfiguration && !o.imageProcessingConfiguration.isReady())
  100949. }
  100950. ,
  100951. e.prototype.bind = function(i, o, s) {
  100952. var c, d;
  100953. if (!!s) {
  100954. var _ = s.getScene();
  100955. this.light ? MaterialHelper.BindLight(this.light, this._lightId, _, i, !0) : MaterialHelper.BindLights(_, s, i, !0, o.maxSimultaneousLights),
  100956. i.setTexture(this._environmentBrdfSamplerName, this._environmentBRDFTexture),
  100957. i.setFloat2("vDebugMode", this.debugLimit, this.debugFactor);
  100958. var b = this._scene.ambientColor;
  100959. b && i.setColor3("ambientFromScene", b);
  100960. var k = _.useRightHandedSystem === (_._mirroredCameraPosition != null);
  100961. i.setFloat(this._invertNormalName, k ? -1 : 1),
  100962. i.setFloat4("vLightingIntensity", this.directIntensity, 1, this.environmentIntensity * this._scene.environmentIntensity, this.specularIntensity);
  100963. var j = 1
  100964. , $ = (d = (c = this.indexOfRefraction.connectInputBlock) === null || c === void 0 ? void 0 : c.value) !== null && d !== void 0 ? d : 1.5
  100965. , _e = Math.pow(($ - j) / ($ + j), 2);
  100966. this._metallicReflectanceColor.scaleToRef(_e * this._metallicF0Factor, TmpColors.Color3[0]);
  100967. var et = this._metallicF0Factor;
  100968. i.setColor4(this._vMetallicReflectanceFactorsName, TmpColors.Color3[0], et),
  100969. o.imageProcessingConfiguration && o.imageProcessingConfiguration.bind(i)
  100970. }
  100971. }
  100972. ,
  100973. e.prototype._injectVertexCode = function(i) {
  100974. var o, s, c = this.worldPosition, d = "//" + this.name;
  100975. this.light ? (this._lightId = (i.counters.lightCounter !== void 0 ? i.counters.lightCounter : -1) + 1,
  100976. i.counters.lightCounter = this._lightId,
  100977. i._emitFunctionFromInclude(i.supportUniformBuffers ? "lightVxUboDeclaration" : "lightVxFragmentDeclaration", d, {
  100978. replaceStrings: [{
  100979. search: /{X}/g,
  100980. replace: this._lightId.toString()
  100981. }]
  100982. }, this._lightId.toString())) : (i._emitFunctionFromInclude(i.supportUniformBuffers ? "lightVxUboDeclaration" : "lightVxFragmentDeclaration", d, {
  100983. repeatKey: "maxSimultaneousLights"
  100984. }),
  100985. this._lightId = 0,
  100986. i.sharedData.dynamicUniformBlocks.push(this));
  100987. var _ = "v_" + c.associatedVariableName;
  100988. i._emitVaryingFromString(_, "vec4") && (i.compilationString += _ + " = " + c.associatedVariableName + `;\r
  100989. `);
  100990. var b = this.reflection.isConnected ? (o = this.reflection.connectedPoint) === null || o === void 0 ? void 0 : o.ownerBlock : null;
  100991. b && (b.viewConnectionPoint = this.view),
  100992. i.compilationString += (s = b == null ? void 0 : b.handleVertexSide(i)) !== null && s !== void 0 ? s : "",
  100993. i._emitUniformFromString("vDebugMode", "vec2", "defined(IGNORE) || DEBUGMODE > 0"),
  100994. i._emitUniformFromString("ambientFromScene", "vec3"),
  100995. i._emitVaryingFromString("vClipSpacePosition", "vec4", "defined(IGNORE) || DEBUGMODE > 0") && (i._injectAtEnd += `#if DEBUGMODE > 0\r
  100996. `,
  100997. i._injectAtEnd += `vClipSpacePosition = gl_Position;\r
  100998. `,
  100999. i._injectAtEnd += `#endif\r
  101000. `),
  101001. this.light ? i.compilationString += i._emitCodeFromInclude("shadowsVertex", d, {
  101002. replaceStrings: [{
  101003. search: /{X}/g,
  101004. replace: this._lightId.toString()
  101005. }, {
  101006. search: /worldPos/g,
  101007. replace: c.associatedVariableName
  101008. }]
  101009. }) : (i.compilationString += "vec4 worldPos = " + c.associatedVariableName + `;\r
  101010. `,
  101011. this.view.isConnected && (i.compilationString += "mat4 view = " + this.view.associatedVariableName + `;\r
  101012. `),
  101013. i.compilationString += i._emitCodeFromInclude("shadowsVertex", d, {
  101014. repeatKey: "maxSimultaneousLights"
  101015. }))
  101016. }
  101017. ,
  101018. e.prototype._getAlbedoOpacityCode = function() {
  101019. var i = `albedoOpacityOutParams albedoOpacityOut;\r
  101020. `
  101021. , o = this.baseColor.isConnected ? this.baseColor.associatedVariableName : "vec3(1.)"
  101022. , s = this.opacity.isConnected ? this.opacity.associatedVariableName : "1.";
  101023. return i += `albedoOpacityBlock(
  101024. vec4(` + o + `, 1.),
  101025. #ifdef ALBEDO
  101026. vec4(1.),
  101027. vec2(1., 1.),
  101028. #endif
  101029. #ifdef OPACITY
  101030. vec4(` + s + `),
  101031. vec2(1., 1.),
  101032. #endif
  101033. albedoOpacityOut
  101034. );
  101035. vec3 surfaceAlbedo = albedoOpacityOut.surfaceAlbedo;
  101036. float alpha = albedoOpacityOut.alpha;\r
  101037. `,
  101038. i
  101039. }
  101040. ,
  101041. e.prototype._getAmbientOcclusionCode = function() {
  101042. var i = `ambientOcclusionOutParams aoOut;\r
  101043. `
  101044. , o = this.ambientOcc.isConnected ? this.ambientOcc.associatedVariableName : "1.";
  101045. return i += `ambientOcclusionBlock(
  101046. #ifdef AMBIENT
  101047. vec3(` + o + `),
  101048. vec4(0., 1.0, 1.0, 0.),
  101049. #endif
  101050. aoOut
  101051. );\r
  101052. `,
  101053. i
  101054. }
  101055. ,
  101056. e.prototype._getReflectivityCode = function(i) {
  101057. var o = `reflectivityOutParams reflectivityOut;\r
  101058. `
  101059. , s = "1.";
  101060. return this._vMetallicReflectanceFactorsName = i._getFreeVariableName("vMetallicReflectanceFactors"),
  101061. i._emitUniformFromString(this._vMetallicReflectanceFactorsName, "vec4"),
  101062. o += `vec3 baseColor = surfaceAlbedo;
  101063. reflectivityBlock(
  101064. vec4(` + this.metallic.associatedVariableName + ", " + this.roughness.associatedVariableName + `, 0., 0.),
  101065. #ifdef METALLICWORKFLOW
  101066. surfaceAlbedo,
  101067. ` + this._vMetallicReflectanceFactorsName + `,
  101068. #endif
  101069. #ifdef REFLECTIVITY
  101070. vec3(0., 0., ` + s + `),
  101071. vec4(1.),
  101072. #endif
  101073. #if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
  101074. aoOut.ambientOcclusionColor,
  101075. #endif
  101076. #ifdef MICROSURFACEMAP
  101077. microSurfaceTexel, <== not handled!
  101078. #endif
  101079. reflectivityOut
  101080. );
  101081. float microSurface = reflectivityOut.microSurface;
  101082. float roughness = reflectivityOut.roughness;
  101083. #ifdef METALLICWORKFLOW
  101084. surfaceAlbedo = reflectivityOut.surfaceAlbedo;
  101085. #endif
  101086. #if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
  101087. aoOut.ambientOcclusionColor = reflectivityOut.ambientOcclusionColor;
  101088. #endif\r
  101089. `,
  101090. o
  101091. }
  101092. ,
  101093. e.prototype._buildBlock = function(i) {
  101094. var o, s, c, d, _, b, k, j, $, _e, et, tt, rt, it, nt, ot, at, st, ut, ct, lt, ft, ht, pt, dt, _t, mt, vt, yt, Et, At, gt, St, xt, bt, Rt, Mt, Pt, It, Dt;
  101095. a.prototype._buildBlock.call(this, i),
  101096. this._scene = i.sharedData.scene,
  101097. this._environmentBRDFTexture || (this._environmentBRDFTexture = GetEnvironmentBRDFTexture(this._scene));
  101098. var Ct = this.reflection.isConnected ? (o = this.reflection.connectedPoint) === null || o === void 0 ? void 0 : o.ownerBlock : null;
  101099. if (Ct && (Ct.worldPositionConnectionPoint = this.worldPosition,
  101100. Ct.cameraPositionConnectionPoint = this.cameraPosition,
  101101. Ct.worldNormalConnectionPoint = this.worldNormal),
  101102. i.target !== NodeMaterialBlockTargets.Fragment)
  101103. return this._injectVertexCode(i),
  101104. this;
  101105. i.sharedData.forcedBindableBlocks.push(this),
  101106. i.sharedData.blocksWithDefines.push(this),
  101107. i.sharedData.blockingBlocks.push(this);
  101108. var Ot = "//" + this.name
  101109. , wt = "v_" + this.worldPosition.associatedVariableName
  101110. , Nt = this.perturbedNormal;
  101111. this._environmentBrdfSamplerName = i._getFreeVariableName("environmentBrdfSampler"),
  101112. i._emit2DSampler(this._environmentBrdfSamplerName),
  101113. i.sharedData.hints.needAlphaBlending = i.sharedData.hints.needAlphaBlending || this.useAlphaBlending,
  101114. i.sharedData.hints.needAlphaTesting = i.sharedData.hints.needAlphaTesting || this.useAlphaTest,
  101115. i._emitExtension("lod", "#extension GL_EXT_shader_texture_lod : enable", "defined(LODBASEDMICROSFURACE)"),
  101116. i._emitExtension("derivatives", "#extension GL_OES_standard_derivatives : enable"),
  101117. i.uniforms.push("exposureLinear"),
  101118. i.uniforms.push("contrast"),
  101119. i.uniforms.push("vInverseScreenSize"),
  101120. i.uniforms.push("vignetteSettings1"),
  101121. i.uniforms.push("vignetteSettings2"),
  101122. i.uniforms.push("vCameraColorCurveNegative"),
  101123. i.uniforms.push("vCameraColorCurveNeutral"),
  101124. i.uniforms.push("vCameraColorCurvePositive"),
  101125. i.uniforms.push("txColorTransform"),
  101126. i.uniforms.push("colorTransformSettings"),
  101127. this.light ? i._emitFunctionFromInclude(i.supportUniformBuffers ? "lightUboDeclaration" : "lightFragmentDeclaration", Ot, {
  101128. replaceStrings: [{
  101129. search: /{X}/g,
  101130. replace: this._lightId.toString()
  101131. }]
  101132. }, this._lightId.toString()) : i._emitFunctionFromInclude(i.supportUniformBuffers ? "lightUboDeclaration" : "lightFragmentDeclaration", Ot, {
  101133. repeatKey: "maxSimultaneousLights"
  101134. }),
  101135. i._emitFunctionFromInclude("helperFunctions", Ot),
  101136. i._emitFunctionFromInclude("importanceSampling", Ot),
  101137. i._emitFunctionFromInclude("pbrHelperFunctions", Ot),
  101138. i._emitFunctionFromInclude("imageProcessingDeclaration", Ot),
  101139. i._emitFunctionFromInclude("imageProcessingFunctions", Ot),
  101140. i._emitFunctionFromInclude("shadowsFragmentFunctions", Ot, {
  101141. replaceStrings: [{
  101142. search: /vPositionW/g,
  101143. replace: wt + ".xyz"
  101144. }]
  101145. }),
  101146. i._emitFunctionFromInclude("pbrDirectLightingSetupFunctions", Ot, {
  101147. replaceStrings: [{
  101148. search: /vPositionW/g,
  101149. replace: wt + ".xyz"
  101150. }]
  101151. }),
  101152. i._emitFunctionFromInclude("pbrDirectLightingFalloffFunctions", Ot),
  101153. i._emitFunctionFromInclude("pbrBRDFFunctions", Ot, {
  101154. replaceStrings: [{
  101155. search: /REFLECTIONMAP_SKYBOX/g,
  101156. replace: (s = Ct == null ? void 0 : Ct._defineSkyboxName) !== null && s !== void 0 ? s : "REFLECTIONMAP_SKYBOX"
  101157. }]
  101158. }),
  101159. i._emitFunctionFromInclude("hdrFilteringFunctions", Ot),
  101160. i._emitFunctionFromInclude("pbrDirectLightingFunctions", Ot, {
  101161. replaceStrings: [{
  101162. search: /vPositionW/g,
  101163. replace: wt + ".xyz"
  101164. }]
  101165. }),
  101166. i._emitFunctionFromInclude("pbrIBLFunctions", Ot),
  101167. i._emitFunctionFromInclude("pbrBlockAlbedoOpacity", Ot),
  101168. i._emitFunctionFromInclude("pbrBlockReflectivity", Ot),
  101169. i._emitFunctionFromInclude("pbrBlockAmbientOcclusion", Ot),
  101170. i._emitFunctionFromInclude("pbrBlockAlphaFresnel", Ot),
  101171. i._emitFunctionFromInclude("pbrBlockAnisotropic", Ot),
  101172. i._emitUniformFromString("vLightingIntensity", "vec4"),
  101173. this._vNormalWName = i._getFreeVariableName("vNormalW"),
  101174. i.compilationString += "vec4 " + this._vNormalWName + " = normalize(" + this.worldNormal.associatedVariableName + `);\r
  101175. `,
  101176. i._registerTempVariable("viewDirectionW") && (i.compilationString += "vec3 viewDirectionW = normalize(" + this.cameraPosition.associatedVariableName + " - " + wt + `.xyz);\r
  101177. `),
  101178. i.compilationString += "vec3 geometricNormalW = " + this._vNormalWName + `.xyz;\r
  101179. `,
  101180. i.compilationString += "vec3 normalW = " + (Nt.isConnected ? "normalize(" + Nt.associatedVariableName + ".xyz)" : "geometricNormalW") + `;\r
  101181. `,
  101182. this._invertNormalName = i._getFreeVariableName("invertNormal"),
  101183. i._emitUniformFromString(this._invertNormalName, "float"),
  101184. i.compilationString += i._emitCodeFromInclude("pbrBlockNormalFinal", Ot, {
  101185. replaceStrings: [{
  101186. search: /vPositionW/g,
  101187. replace: wt + ".xyz"
  101188. }, {
  101189. search: /vEyePosition.w/g,
  101190. replace: this._invertNormalName
  101191. }]
  101192. }),
  101193. i.compilationString += this._getAlbedoOpacityCode(),
  101194. i.compilationString += i._emitCodeFromInclude("depthPrePass", Ot),
  101195. i.compilationString += this._getAmbientOcclusionCode(),
  101196. i.compilationString += i._emitCodeFromInclude("pbrBlockLightmapInit", Ot),
  101197. i.compilationString += `#ifdef UNLIT
  101198. vec3 diffuseBase = vec3(1., 1., 1.);
  101199. #else\r
  101200. `,
  101201. i.compilationString += this._getReflectivityCode(i),
  101202. i.compilationString += i._emitCodeFromInclude("pbrBlockGeometryInfo", Ot, {
  101203. replaceStrings: [{
  101204. search: /REFLECTIONMAP_SKYBOX/g,
  101205. replace: (c = Ct == null ? void 0 : Ct._defineSkyboxName) !== null && c !== void 0 ? c : "REFLECTIONMAP_SKYBOX"
  101206. }, {
  101207. search: /REFLECTIONMAP_3D/g,
  101208. replace: (d = Ct == null ? void 0 : Ct._define3DName) !== null && d !== void 0 ? d : "REFLECTIONMAP_3D"
  101209. }]
  101210. });
  101211. var Ft = this.anisotropy.isConnected ? (_ = this.anisotropy.connectedPoint) === null || _ === void 0 ? void 0 : _.ownerBlock : null;
  101212. Ft && (Ft.worldPositionConnectionPoint = this.worldPosition,
  101213. Ft.worldNormalConnectionPoint = this.worldNormal,
  101214. i.compilationString += Ft.getCode(i, !this.perturbedNormal.isConnected)),
  101215. Ct && Ct.hasTexture && (i.compilationString += Ct.getCode(i, Ft ? "anisotropicOut.anisotropicNormal" : "normalW")),
  101216. i._emitFunctionFromInclude("pbrBlockReflection", Ot, {
  101217. replaceStrings: [{
  101218. search: /computeReflectionCoords/g,
  101219. replace: "computeReflectionCoordsPBR"
  101220. }, {
  101221. search: /REFLECTIONMAP_3D/g,
  101222. replace: (b = Ct == null ? void 0 : Ct._define3DName) !== null && b !== void 0 ? b : "REFLECTIONMAP_3D"
  101223. }, {
  101224. search: /REFLECTIONMAP_OPPOSITEZ/g,
  101225. replace: (k = Ct == null ? void 0 : Ct._defineOppositeZ) !== null && k !== void 0 ? k : "REFLECTIONMAP_OPPOSITEZ"
  101226. }, {
  101227. search: /REFLECTIONMAP_PROJECTION/g,
  101228. replace: (j = Ct == null ? void 0 : Ct._defineProjectionName) !== null && j !== void 0 ? j : "REFLECTIONMAP_PROJECTION"
  101229. }, {
  101230. search: /REFLECTIONMAP_SKYBOX/g,
  101231. replace: ($ = Ct == null ? void 0 : Ct._defineSkyboxName) !== null && $ !== void 0 ? $ : "REFLECTIONMAP_SKYBOX"
  101232. }, {
  101233. search: /LODINREFLECTIONALPHA/g,
  101234. replace: (_e = Ct == null ? void 0 : Ct._defineLODReflectionAlpha) !== null && _e !== void 0 ? _e : "LODINREFLECTIONALPHA"
  101235. }, {
  101236. search: /LINEARSPECULARREFLECTION/g,
  101237. replace: (et = Ct == null ? void 0 : Ct._defineLinearSpecularReflection) !== null && et !== void 0 ? et : "LINEARSPECULARREFLECTION"
  101238. }, {
  101239. search: /vReflectionFilteringInfo/g,
  101240. replace: (tt = Ct == null ? void 0 : Ct._vReflectionFilteringInfoName) !== null && tt !== void 0 ? tt : "vReflectionFilteringInfo"
  101241. }]
  101242. }),
  101243. i.compilationString += i._emitCodeFromInclude("pbrBlockReflectance0", Ot, {
  101244. replaceStrings: [{
  101245. search: /metallicReflectanceFactors/g,
  101246. replace: this._vMetallicReflectanceFactorsName
  101247. }]
  101248. });
  101249. var Vt = this.sheen.isConnected ? (rt = this.sheen.connectedPoint) === null || rt === void 0 ? void 0 : rt.ownerBlock : null;
  101250. Vt && (i.compilationString += Vt.getCode(Ct)),
  101251. i._emitFunctionFromInclude("pbrBlockSheen", Ot, {
  101252. replaceStrings: [{
  101253. search: /REFLECTIONMAP_3D/g,
  101254. replace: (it = Ct == null ? void 0 : Ct._define3DName) !== null && it !== void 0 ? it : "REFLECTIONMAP_3D"
  101255. }, {
  101256. search: /REFLECTIONMAP_SKYBOX/g,
  101257. replace: (nt = Ct == null ? void 0 : Ct._defineSkyboxName) !== null && nt !== void 0 ? nt : "REFLECTIONMAP_SKYBOX"
  101258. }, {
  101259. search: /LODINREFLECTIONALPHA/g,
  101260. replace: (ot = Ct == null ? void 0 : Ct._defineLODReflectionAlpha) !== null && ot !== void 0 ? ot : "LODINREFLECTIONALPHA"
  101261. }, {
  101262. search: /LINEARSPECULARREFLECTION/g,
  101263. replace: (at = Ct == null ? void 0 : Ct._defineLinearSpecularReflection) !== null && at !== void 0 ? at : "LINEARSPECULARREFLECTION"
  101264. }]
  101265. });
  101266. var Lt = this.clearcoat.isConnected ? (st = this.clearcoat.connectedPoint) === null || st === void 0 ? void 0 : st.ownerBlock : null
  101267. , kt = !this.perturbedNormal.isConnected && !this.anisotropy.isConnected
  101268. , Bt = this.perturbedNormal.isConnected && ((ct = ((ut = this.perturbedNormal.connectedPoint) === null || ut === void 0 ? void 0 : ut.ownerBlock).worldTangent) === null || ct === void 0 ? void 0 : ct.isConnected)
  101269. , Ut = this.anisotropy.isConnected && ((lt = this.anisotropy.connectedPoint) === null || lt === void 0 ? void 0 : lt.ownerBlock).worldTangent.isConnected
  101270. , Gt = Bt || !this.perturbedNormal.isConnected && Ut;
  101271. i.compilationString += ClearCoatBlock.GetCode(i, Lt, Ct, wt, kt, Gt, this.worldNormal.associatedVariableName),
  101272. kt && (Gt = (ft = Lt == null ? void 0 : Lt.worldTangent.isConnected) !== null && ft !== void 0 ? ft : !1),
  101273. i._emitFunctionFromInclude("pbrBlockClearcoat", Ot, {
  101274. replaceStrings: [{
  101275. search: /computeReflectionCoords/g,
  101276. replace: "computeReflectionCoordsPBR"
  101277. }, {
  101278. search: /REFLECTIONMAP_3D/g,
  101279. replace: (ht = Ct == null ? void 0 : Ct._define3DName) !== null && ht !== void 0 ? ht : "REFLECTIONMAP_3D"
  101280. }, {
  101281. search: /REFLECTIONMAP_OPPOSITEZ/g,
  101282. replace: (pt = Ct == null ? void 0 : Ct._defineOppositeZ) !== null && pt !== void 0 ? pt : "REFLECTIONMAP_OPPOSITEZ"
  101283. }, {
  101284. search: /REFLECTIONMAP_PROJECTION/g,
  101285. replace: (dt = Ct == null ? void 0 : Ct._defineProjectionName) !== null && dt !== void 0 ? dt : "REFLECTIONMAP_PROJECTION"
  101286. }, {
  101287. search: /REFLECTIONMAP_SKYBOX/g,
  101288. replace: (_t = Ct == null ? void 0 : Ct._defineSkyboxName) !== null && _t !== void 0 ? _t : "REFLECTIONMAP_SKYBOX"
  101289. }, {
  101290. search: /LODINREFLECTIONALPHA/g,
  101291. replace: (mt = Ct == null ? void 0 : Ct._defineLODReflectionAlpha) !== null && mt !== void 0 ? mt : "LODINREFLECTIONALPHA"
  101292. }, {
  101293. search: /LINEARSPECULARREFLECTION/g,
  101294. replace: (vt = Ct == null ? void 0 : Ct._defineLinearSpecularReflection) !== null && vt !== void 0 ? vt : "LINEARSPECULARREFLECTION"
  101295. }, {
  101296. search: /defined\(TANGENT\)/g,
  101297. replace: Gt ? "defined(TANGENT)" : "defined(IGNORE)"
  101298. }]
  101299. }),
  101300. i.compilationString += i._emitCodeFromInclude("pbrBlockReflectance", Ot, {
  101301. replaceStrings: [{
  101302. search: /REFLECTIONMAP_SKYBOX/g,
  101303. replace: (yt = Ct == null ? void 0 : Ct._defineSkyboxName) !== null && yt !== void 0 ? yt : "REFLECTIONMAP_SKYBOX"
  101304. }, {
  101305. search: /REFLECTIONMAP_3D/g,
  101306. replace: (Et = Ct == null ? void 0 : Ct._define3DName) !== null && Et !== void 0 ? Et : "REFLECTIONMAP_3D"
  101307. }]
  101308. });
  101309. var Ht = this.subsurface.isConnected ? (At = this.subsurface.connectedPoint) === null || At === void 0 ? void 0 : At.ownerBlock : null
  101310. , zt = this.subsurface.isConnected ? (St = ((gt = this.subsurface.connectedPoint) === null || gt === void 0 ? void 0 : gt.ownerBlock).refraction.connectedPoint) === null || St === void 0 ? void 0 : St.ownerBlock : null;
  101311. zt && (zt.viewConnectionPoint = this.view,
  101312. zt.indexOfRefractionConnectionPoint = this.indexOfRefraction),
  101313. i.compilationString += SubSurfaceBlock.GetCode(i, Ht, Ct, wt),
  101314. i._emitFunctionFromInclude("pbrBlockSubSurface", Ot, {
  101315. replaceStrings: [{
  101316. search: /REFLECTIONMAP_3D/g,
  101317. replace: (xt = Ct == null ? void 0 : Ct._define3DName) !== null && xt !== void 0 ? xt : "REFLECTIONMAP_3D"
  101318. }, {
  101319. search: /REFLECTIONMAP_OPPOSITEZ/g,
  101320. replace: (bt = Ct == null ? void 0 : Ct._defineOppositeZ) !== null && bt !== void 0 ? bt : "REFLECTIONMAP_OPPOSITEZ"
  101321. }, {
  101322. search: /REFLECTIONMAP_PROJECTION/g,
  101323. replace: (Rt = Ct == null ? void 0 : Ct._defineProjectionName) !== null && Rt !== void 0 ? Rt : "REFLECTIONMAP_PROJECTION"
  101324. }, {
  101325. search: /SS_REFRACTIONMAP_3D/g,
  101326. replace: (Mt = zt == null ? void 0 : zt._define3DName) !== null && Mt !== void 0 ? Mt : "SS_REFRACTIONMAP_3D"
  101327. }, {
  101328. search: /SS_LODINREFRACTIONALPHA/g,
  101329. replace: (Pt = zt == null ? void 0 : zt._defineLODRefractionAlpha) !== null && Pt !== void 0 ? Pt : "SS_LODINREFRACTIONALPHA"
  101330. }, {
  101331. search: /SS_LINEARSPECULARREFRACTION/g,
  101332. replace: (It = zt == null ? void 0 : zt._defineLinearSpecularRefraction) !== null && It !== void 0 ? It : "SS_LINEARSPECULARREFRACTION"
  101333. }, {
  101334. search: /SS_REFRACTIONMAP_OPPOSITEZ/g,
  101335. replace: (Dt = zt == null ? void 0 : zt._defineOppositeZ) !== null && Dt !== void 0 ? Dt : "SS_REFRACTIONMAP_OPPOSITEZ"
  101336. }]
  101337. }),
  101338. i.compilationString += i._emitCodeFromInclude("pbrBlockDirectLighting", Ot),
  101339. this.light ? i.compilationString += i._emitCodeFromInclude("lightFragment", Ot, {
  101340. replaceStrings: [{
  101341. search: /{X}/g,
  101342. replace: this._lightId.toString()
  101343. }]
  101344. }) : i.compilationString += i._emitCodeFromInclude("lightFragment", Ot, {
  101345. repeatKey: "maxSimultaneousLights"
  101346. }),
  101347. i.compilationString += i._emitCodeFromInclude("pbrBlockFinalLitComponents", Ot),
  101348. i.compilationString += `#endif\r
  101349. `;
  101350. var Wt = this.ambientColor.isConnected ? this.ambientColor.associatedVariableName : "vec3(0., 0., 0.)"
  101351. , Kt = PBRBaseMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS.toString();
  101352. Kt.indexOf(".") === -1 && (Kt += "."),
  101353. i.compilationString += i._emitCodeFromInclude("pbrBlockFinalUnlitComponents", Ot, {
  101354. replaceStrings: [{
  101355. search: /vec3 finalEmissive[\s\S]*?finalEmissive\*=vLightingIntensity\.y;/g,
  101356. replace: ""
  101357. }, {
  101358. search: /vAmbientColor/g,
  101359. replace: Wt + " * ambientFromScene"
  101360. }, {
  101361. search: /vAmbientInfos\.w/g,
  101362. replace: Kt
  101363. }]
  101364. }),
  101365. i.compilationString += i._emitCodeFromInclude("pbrBlockFinalColorComposition", Ot, {
  101366. replaceStrings: [{
  101367. search: /finalEmissive/g,
  101368. replace: "vec3(0.)"
  101369. }]
  101370. }),
  101371. i.compilationString += i._emitCodeFromInclude("pbrBlockImageProcessing", Ot, {
  101372. replaceStrings: [{
  101373. search: /visibility/g,
  101374. replace: "1."
  101375. }]
  101376. }),
  101377. i.compilationString += i._emitCodeFromInclude("pbrDebug", Ot, {
  101378. replaceStrings: [{
  101379. search: /vNormalW/g,
  101380. replace: this._vNormalWName
  101381. }, {
  101382. search: /vPositionW/g,
  101383. replace: wt
  101384. }, {
  101385. search: /albedoTexture\.rgb;/g,
  101386. replace: `vec3(1.);\r
  101387. gl_FragColor.rgb = toGammaSpace(gl_FragColor.rgb);\r
  101388. `
  101389. }]
  101390. });
  101391. for (var Qt = 0, qt = this._outputs; Qt < qt.length; Qt++) {
  101392. var Yt = qt[Qt];
  101393. if (Yt.hasEndpoints) {
  101394. var Jt = mapOutputToVariable[Yt.name];
  101395. if (Jt) {
  101396. var jt = Jt[0]
  101397. , Xt = Jt[1];
  101398. Xt && (i.compilationString += "#if " + Xt + `\r
  101399. `),
  101400. i.compilationString += this._declareOutput(Yt, i) + " = " + jt + `;\r
  101401. `,
  101402. Xt && (i.compilationString += `#else\r
  101403. `,
  101404. i.compilationString += this._declareOutput(Yt, i) + ` = vec3(0.);\r
  101405. `,
  101406. i.compilationString += `#endif\r
  101407. `)
  101408. } else
  101409. console.error("There's no remapping for the " + Yt.name + " end point! No code generated")
  101410. }
  101411. }
  101412. return this
  101413. }
  101414. ,
  101415. e.prototype._dumpPropertiesCode = function() {
  101416. var i = a.prototype._dumpPropertiesCode.call(this);
  101417. return i += this._codeVariableName + ".lightFalloff = " + this.lightFalloff + `;\r
  101418. `,
  101419. i += this._codeVariableName + ".useAlphaTest = " + this.useAlphaTest + `;\r
  101420. `,
  101421. i += this._codeVariableName + ".alphaTestCutoff = " + this.alphaTestCutoff + `;\r
  101422. `,
  101423. i += this._codeVariableName + ".useAlphaBlending = " + this.useAlphaBlending + `;\r
  101424. `,
  101425. i += this._codeVariableName + ".useRadianceOverAlpha = " + this.useRadianceOverAlpha + `;\r
  101426. `,
  101427. i += this._codeVariableName + ".useSpecularOverAlpha = " + this.useSpecularOverAlpha + `;\r
  101428. `,
  101429. i += this._codeVariableName + ".enableSpecularAntiAliasing = " + this.enableSpecularAntiAliasing + `;\r
  101430. `,
  101431. i += this._codeVariableName + ".realTimeFiltering = " + this.realTimeFiltering + `;\r
  101432. `,
  101433. i += this._codeVariableName + ".realTimeFilteringQuality = " + this.realTimeFilteringQuality + `;\r
  101434. `,
  101435. i += this._codeVariableName + ".useEnergyConservation = " + this.useEnergyConservation + `;\r
  101436. `,
  101437. i += this._codeVariableName + ".useRadianceOcclusion = " + this.useRadianceOcclusion + `;\r
  101438. `,
  101439. i += this._codeVariableName + ".useHorizonOcclusion = " + this.useHorizonOcclusion + `;\r
  101440. `,
  101441. i += this._codeVariableName + ".unlit = " + this.unlit + `;\r
  101442. `,
  101443. i += this._codeVariableName + ".forceNormalForward = " + this.forceNormalForward + `;\r
  101444. `,
  101445. i += this._codeVariableName + ".debugMode = " + this.debugMode + `;\r
  101446. `,
  101447. i += this._codeVariableName + ".debugLimit = " + this.debugLimit + `;\r
  101448. `,
  101449. i += this._codeVariableName + ".debugFactor = " + this.debugFactor + `;\r
  101450. `,
  101451. i
  101452. }
  101453. ,
  101454. e.prototype.serialize = function() {
  101455. var i = a.prototype.serialize.call(this);
  101456. return this.light && (i.lightId = this.light.id),
  101457. i.lightFalloff = this.lightFalloff,
  101458. i.useAlphaTest = this.useAlphaTest,
  101459. i.alphaTestCutoff = this.alphaTestCutoff,
  101460. i.useAlphaBlending = this.useAlphaBlending,
  101461. i.useRadianceOverAlpha = this.useRadianceOverAlpha,
  101462. i.useSpecularOverAlpha = this.useSpecularOverAlpha,
  101463. i.enableSpecularAntiAliasing = this.enableSpecularAntiAliasing,
  101464. i.realTimeFiltering = this.realTimeFiltering,
  101465. i.realTimeFilteringQuality = this.realTimeFilteringQuality,
  101466. i.useEnergyConservation = this.useEnergyConservation,
  101467. i.useRadianceOcclusion = this.useRadianceOcclusion,
  101468. i.useHorizonOcclusion = this.useHorizonOcclusion,
  101469. i.unlit = this.unlit,
  101470. i.forceNormalForward = this.forceNormalForward,
  101471. i.debugMode = this.debugMode,
  101472. i.debugLimit = this.debugLimit,
  101473. i.debugFactor = this.debugFactor,
  101474. i
  101475. }
  101476. ,
  101477. e.prototype._deserialize = function(i, o, s) {
  101478. var c, d;
  101479. a.prototype._deserialize.call(this, i, o, s),
  101480. i.lightId && (this.light = o.getLightById(i.lightId)),
  101481. this.lightFalloff = (c = i.lightFalloff) !== null && c !== void 0 ? c : 0,
  101482. this.useAlphaTest = i.useAlphaTest,
  101483. this.alphaTestCutoff = i.alphaTestCutoff,
  101484. this.useAlphaBlending = i.useAlphaBlending,
  101485. this.useRadianceOverAlpha = i.useRadianceOverAlpha,
  101486. this.useSpecularOverAlpha = i.useSpecularOverAlpha,
  101487. this.enableSpecularAntiAliasing = i.enableSpecularAntiAliasing,
  101488. this.realTimeFiltering = !!i.realTimeFiltering,
  101489. this.realTimeFilteringQuality = (d = i.realTimeFilteringQuality) !== null && d !== void 0 ? d : 8,
  101490. this.useEnergyConservation = i.useEnergyConservation,
  101491. this.useRadianceOcclusion = i.useRadianceOcclusion,
  101492. this.useHorizonOcclusion = i.useHorizonOcclusion,
  101493. this.unlit = i.unlit,
  101494. this.forceNormalForward = !!i.forceNormalForward,
  101495. this.debugMode = i.debugMode,
  101496. this.debugLimit = i.debugLimit,
  101497. this.debugFactor = i.debugFactor
  101498. }
  101499. ,
  101500. __decorate([editableInPropertyPage("Direct lights", PropertyTypeForEdition.Float, "INTENSITY", {
  101501. min: 0,
  101502. max: 1,
  101503. notifiers: {
  101504. update: !0
  101505. }
  101506. })], e.prototype, "directIntensity", void 0),
  101507. __decorate([editableInPropertyPage("Environment lights", PropertyTypeForEdition.Float, "INTENSITY", {
  101508. min: 0,
  101509. max: 1,
  101510. notifiers: {
  101511. update: !0
  101512. }
  101513. })], e.prototype, "environmentIntensity", void 0),
  101514. __decorate([editableInPropertyPage("Specular highlights", PropertyTypeForEdition.Float, "INTENSITY", {
  101515. min: 0,
  101516. max: 1,
  101517. notifiers: {
  101518. update: !0
  101519. }
  101520. })], e.prototype, "specularIntensity", void 0),
  101521. __decorate([editableInPropertyPage("Light falloff", PropertyTypeForEdition.List, "LIGHTING & COLORS", {
  101522. notifiers: {
  101523. update: !0
  101524. },
  101525. options: [{
  101526. label: "Physical",
  101527. value: PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL
  101528. }, {
  101529. label: "GLTF",
  101530. value: PBRBaseMaterial.LIGHTFALLOFF_GLTF
  101531. }, {
  101532. label: "Standard",
  101533. value: PBRBaseMaterial.LIGHTFALLOFF_STANDARD
  101534. }]
  101535. })], e.prototype, "lightFalloff", void 0),
  101536. __decorate([editableInPropertyPage("Alpha Testing", PropertyTypeForEdition.Boolean, "OPACITY")], e.prototype, "useAlphaTest", void 0),
  101537. __decorate([editableInPropertyPage("Alpha CutOff", PropertyTypeForEdition.Float, "OPACITY", {
  101538. min: 0,
  101539. max: 1,
  101540. notifiers: {
  101541. update: !0
  101542. }
  101543. })], e.prototype, "alphaTestCutoff", void 0),
  101544. __decorate([editableInPropertyPage("Alpha blending", PropertyTypeForEdition.Boolean, "OPACITY")], e.prototype, "useAlphaBlending", void 0),
  101545. __decorate([editableInPropertyPage("Radiance over alpha", PropertyTypeForEdition.Boolean, "RENDERING", {
  101546. notifiers: {
  101547. update: !0
  101548. }
  101549. })], e.prototype, "useRadianceOverAlpha", void 0),
  101550. __decorate([editableInPropertyPage("Specular over alpha", PropertyTypeForEdition.Boolean, "RENDERING", {
  101551. notifiers: {
  101552. update: !0
  101553. }
  101554. })], e.prototype, "useSpecularOverAlpha", void 0),
  101555. __decorate([editableInPropertyPage("Specular anti-aliasing", PropertyTypeForEdition.Boolean, "RENDERING", {
  101556. notifiers: {
  101557. update: !0
  101558. }
  101559. })], e.prototype, "enableSpecularAntiAliasing", void 0),
  101560. __decorate([editableInPropertyPage("Realtime filtering", PropertyTypeForEdition.Boolean, "RENDERING", {
  101561. notifiers: {
  101562. update: !0
  101563. }
  101564. })], e.prototype, "realTimeFiltering", void 0),
  101565. __decorate([editableInPropertyPage("Realtime filtering quality", PropertyTypeForEdition.List, "RENDERING", {
  101566. notifiers: {
  101567. update: !0
  101568. },
  101569. options: [{
  101570. label: "Low",
  101571. value: 8
  101572. }, {
  101573. label: "Medium",
  101574. value: 16
  101575. }, {
  101576. label: "High",
  101577. value: 64
  101578. }]
  101579. })], e.prototype, "realTimeFilteringQuality", void 0),
  101580. __decorate([editableInPropertyPage("Energy Conservation", PropertyTypeForEdition.Boolean, "ADVANCED", {
  101581. notifiers: {
  101582. update: !0
  101583. }
  101584. })], e.prototype, "useEnergyConservation", void 0),
  101585. __decorate([editableInPropertyPage("Radiance occlusion", PropertyTypeForEdition.Boolean, "ADVANCED", {
  101586. notifiers: {
  101587. update: !0
  101588. }
  101589. })], e.prototype, "useRadianceOcclusion", void 0),
  101590. __decorate([editableInPropertyPage("Horizon occlusion", PropertyTypeForEdition.Boolean, "ADVANCED", {
  101591. notifiers: {
  101592. update: !0
  101593. }
  101594. })], e.prototype, "useHorizonOcclusion", void 0),
  101595. __decorate([editableInPropertyPage("Unlit", PropertyTypeForEdition.Boolean, "ADVANCED", {
  101596. notifiers: {
  101597. update: !0
  101598. }
  101599. })], e.prototype, "unlit", void 0),
  101600. __decorate([editableInPropertyPage("Force normal forward", PropertyTypeForEdition.Boolean, "ADVANCED", {
  101601. notifiers: {
  101602. update: !0
  101603. }
  101604. })], e.prototype, "forceNormalForward", void 0),
  101605. __decorate([editableInPropertyPage("Debug mode", PropertyTypeForEdition.List, "DEBUG", {
  101606. notifiers: {
  101607. update: !0
  101608. },
  101609. options: [{
  101610. label: "None",
  101611. value: 0
  101612. }, {
  101613. label: "Normalized position",
  101614. value: 1
  101615. }, {
  101616. label: "Normals",
  101617. value: 2
  101618. }, {
  101619. label: "Tangents",
  101620. value: 3
  101621. }, {
  101622. label: "Bitangents",
  101623. value: 4
  101624. }, {
  101625. label: "Bump Normals",
  101626. value: 5
  101627. }, {
  101628. label: "ClearCoat Normals",
  101629. value: 8
  101630. }, {
  101631. label: "ClearCoat Tangents",
  101632. value: 9
  101633. }, {
  101634. label: "ClearCoat Bitangents",
  101635. value: 10
  101636. }, {
  101637. label: "Anisotropic Normals",
  101638. value: 11
  101639. }, {
  101640. label: "Anisotropic Tangents",
  101641. value: 12
  101642. }, {
  101643. label: "Anisotropic Bitangents",
  101644. value: 13
  101645. }, {
  101646. label: "Env Refraction",
  101647. value: 40
  101648. }, {
  101649. label: "Env Reflection",
  101650. value: 41
  101651. }, {
  101652. label: "Env Clear Coat",
  101653. value: 42
  101654. }, {
  101655. label: "Direct Diffuse",
  101656. value: 50
  101657. }, {
  101658. label: "Direct Specular",
  101659. value: 51
  101660. }, {
  101661. label: "Direct Clear Coat",
  101662. value: 52
  101663. }, {
  101664. label: "Direct Sheen",
  101665. value: 53
  101666. }, {
  101667. label: "Env Irradiance",
  101668. value: 54
  101669. }, {
  101670. label: "Surface Albedo",
  101671. value: 60
  101672. }, {
  101673. label: "Reflectance 0",
  101674. value: 61
  101675. }, {
  101676. label: "Metallic",
  101677. value: 62
  101678. }, {
  101679. label: "Metallic F0",
  101680. value: 71
  101681. }, {
  101682. label: "Roughness",
  101683. value: 63
  101684. }, {
  101685. label: "AlphaG",
  101686. value: 64
  101687. }, {
  101688. label: "NdotV",
  101689. value: 65
  101690. }, {
  101691. label: "ClearCoat Color",
  101692. value: 66
  101693. }, {
  101694. label: "ClearCoat Roughness",
  101695. value: 67
  101696. }, {
  101697. label: "ClearCoat NdotV",
  101698. value: 68
  101699. }, {
  101700. label: "Transmittance",
  101701. value: 69
  101702. }, {
  101703. label: "Refraction Transmittance",
  101704. value: 70
  101705. }, {
  101706. label: "SEO",
  101707. value: 80
  101708. }, {
  101709. label: "EHO",
  101710. value: 81
  101711. }, {
  101712. label: "Energy Factor",
  101713. value: 82
  101714. }, {
  101715. label: "Specular Reflectance",
  101716. value: 83
  101717. }, {
  101718. label: "Clear Coat Reflectance",
  101719. value: 84
  101720. }, {
  101721. label: "Sheen Reflectance",
  101722. value: 85
  101723. }, {
  101724. label: "Luminance Over Alpha",
  101725. value: 86
  101726. }, {
  101727. label: "Alpha",
  101728. value: 87
  101729. }]
  101730. })], e.prototype, "debugMode", void 0),
  101731. __decorate([editableInPropertyPage("Split position", PropertyTypeForEdition.Float, "DEBUG", {
  101732. min: -1,
  101733. max: 1,
  101734. notifiers: {
  101735. update: !0
  101736. }
  101737. })], e.prototype, "debugLimit", void 0),
  101738. __decorate([editableInPropertyPage("Output factor", PropertyTypeForEdition.Float, "DEBUG", {
  101739. min: 0,
  101740. max: 5,
  101741. notifiers: {
  101742. update: !0
  101743. }
  101744. })], e.prototype, "debugFactor", void 0),
  101745. e
  101746. }(NodeMaterialBlock);
  101747. RegisterClass("BABYLON.PBRMetallicRoughnessBlock", PBRMetallicRoughnessBlock);
  101748. var ModBlock = function(a) {
  101749. __extends(e, a);
  101750. function e(i) {
  101751. var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
  101752. return o.registerInput("left", NodeMaterialBlockConnectionPointTypes.AutoDetect),
  101753. o.registerInput("right", NodeMaterialBlockConnectionPointTypes.AutoDetect),
  101754. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
  101755. o._outputs[0]._typeConnectionSource = o._inputs[0],
  101756. o._linkConnectionTypes(0, 1),
  101757. o
  101758. }
  101759. return e.prototype.getClassName = function() {
  101760. return "ModBlock"
  101761. }
  101762. ,
  101763. Object.defineProperty(e.prototype, "left", {
  101764. get: function() {
  101765. return this._inputs[0]
  101766. },
  101767. enumerable: !1,
  101768. configurable: !0
  101769. }),
  101770. Object.defineProperty(e.prototype, "right", {
  101771. get: function() {
  101772. return this._inputs[1]
  101773. },
  101774. enumerable: !1,
  101775. configurable: !0
  101776. }),
  101777. Object.defineProperty(e.prototype, "output", {
  101778. get: function() {
  101779. return this._outputs[0]
  101780. },
  101781. enumerable: !1,
  101782. configurable: !0
  101783. }),
  101784. e.prototype._buildBlock = function(i) {
  101785. a.prototype._buildBlock.call(this, i);
  101786. var o = this._outputs[0];
  101787. return i.compilationString += this._declareOutput(o, i) + (" = mod(" + this.left.associatedVariableName + ", " + this.right.associatedVariableName + `);\r
  101788. `),
  101789. this
  101790. }
  101791. ,
  101792. e
  101793. }(NodeMaterialBlock);
  101794. RegisterClass("BABYLON.ModBlock", ModBlock);
  101795. var MatrixBuilderBlock = function(a) {
  101796. __extends(e, a);
  101797. function e(i) {
  101798. var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
  101799. return o.registerInput("row0", NodeMaterialBlockConnectionPointTypes.Vector4),
  101800. o.registerInput("row1", NodeMaterialBlockConnectionPointTypes.Vector4),
  101801. o.registerInput("row2", NodeMaterialBlockConnectionPointTypes.Vector4),
  101802. o.registerInput("row3", NodeMaterialBlockConnectionPointTypes.Vector4),
  101803. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Matrix),
  101804. o
  101805. }
  101806. return e.prototype.getClassName = function() {
  101807. return "MatrixBuilder"
  101808. }
  101809. ,
  101810. Object.defineProperty(e.prototype, "row0", {
  101811. get: function() {
  101812. return this._inputs[0]
  101813. },
  101814. enumerable: !1,
  101815. configurable: !0
  101816. }),
  101817. Object.defineProperty(e.prototype, "row1", {
  101818. get: function() {
  101819. return this._inputs[1]
  101820. },
  101821. enumerable: !1,
  101822. configurable: !0
  101823. }),
  101824. Object.defineProperty(e.prototype, "row2", {
  101825. get: function() {
  101826. return this._inputs[2]
  101827. },
  101828. enumerable: !1,
  101829. configurable: !0
  101830. }),
  101831. Object.defineProperty(e.prototype, "row3", {
  101832. get: function() {
  101833. return this._inputs[3]
  101834. },
  101835. enumerable: !1,
  101836. configurable: !0
  101837. }),
  101838. Object.defineProperty(e.prototype, "output", {
  101839. get: function() {
  101840. return this._outputs[0]
  101841. },
  101842. enumerable: !1,
  101843. configurable: !0
  101844. }),
  101845. e.prototype.autoConfigure = function(i) {
  101846. if (!this.row0.isConnected) {
  101847. var o = new InputBlock("row0");
  101848. o.value = new Vector4(1,0,0,0),
  101849. o.output.connectTo(this.row0)
  101850. }
  101851. if (!this.row1.isConnected) {
  101852. var s = new InputBlock("row1");
  101853. s.value = new Vector4(0,1,0,0),
  101854. s.output.connectTo(this.row1)
  101855. }
  101856. if (!this.row2.isConnected) {
  101857. var c = new InputBlock("row2");
  101858. c.value = new Vector4(0,0,1,0),
  101859. c.output.connectTo(this.row2)
  101860. }
  101861. if (!this.row3.isConnected) {
  101862. var d = new InputBlock("row3");
  101863. d.value = new Vector4(0,0,0,1),
  101864. d.output.connectTo(this.row3)
  101865. }
  101866. }
  101867. ,
  101868. e.prototype._buildBlock = function(i) {
  101869. a.prototype._buildBlock.call(this, i);
  101870. var o = this._outputs[0]
  101871. , s = this.row0
  101872. , c = this.row1
  101873. , d = this.row2
  101874. , _ = this.row3;
  101875. return i.compilationString += this._declareOutput(o, i) + (" = mat4(" + s.associatedVariableName + ", " + c.associatedVariableName + ", " + d.associatedVariableName + ", " + _.associatedVariableName + `);\r
  101876. `),
  101877. this
  101878. }
  101879. ,
  101880. e
  101881. }(NodeMaterialBlock);
  101882. RegisterClass("BABYLON.MatrixBuilder", MatrixBuilderBlock);
  101883. var ConditionalBlockConditions;
  101884. (function(a) {
  101885. a[a.Equal = 0] = "Equal",
  101886. a[a.NotEqual = 1] = "NotEqual",
  101887. a[a.LessThan = 2] = "LessThan",
  101888. a[a.GreaterThan = 3] = "GreaterThan",
  101889. a[a.LessOrEqual = 4] = "LessOrEqual",
  101890. a[a.GreaterOrEqual = 5] = "GreaterOrEqual",
  101891. a[a.Xor = 6] = "Xor",
  101892. a[a.Or = 7] = "Or",
  101893. a[a.And = 8] = "And"
  101894. }
  101895. )(ConditionalBlockConditions || (ConditionalBlockConditions = {}));
  101896. var ConditionalBlock = function(a) {
  101897. __extends(e, a);
  101898. function e(i) {
  101899. var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
  101900. return o.condition = ConditionalBlockConditions.LessThan,
  101901. o.registerInput("a", NodeMaterialBlockConnectionPointTypes.Float),
  101902. o.registerInput("b", NodeMaterialBlockConnectionPointTypes.Float),
  101903. o.registerInput("true", NodeMaterialBlockConnectionPointTypes.AutoDetect, !0),
  101904. o.registerInput("false", NodeMaterialBlockConnectionPointTypes.AutoDetect, !0),
  101905. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
  101906. o._linkConnectionTypes(2, 3),
  101907. o._outputs[0]._typeConnectionSource = o._inputs[2],
  101908. o._outputs[0]._defaultConnectionPointType = NodeMaterialBlockConnectionPointTypes.Float,
  101909. o
  101910. }
  101911. return e.prototype.getClassName = function() {
  101912. return "ConditionalBlock"
  101913. }
  101914. ,
  101915. Object.defineProperty(e.prototype, "a", {
  101916. get: function() {
  101917. return this._inputs[0]
  101918. },
  101919. enumerable: !1,
  101920. configurable: !0
  101921. }),
  101922. Object.defineProperty(e.prototype, "b", {
  101923. get: function() {
  101924. return this._inputs[1]
  101925. },
  101926. enumerable: !1,
  101927. configurable: !0
  101928. }),
  101929. Object.defineProperty(e.prototype, "true", {
  101930. get: function() {
  101931. return this._inputs[2]
  101932. },
  101933. enumerable: !1,
  101934. configurable: !0
  101935. }),
  101936. Object.defineProperty(e.prototype, "false", {
  101937. get: function() {
  101938. return this._inputs[3]
  101939. },
  101940. enumerable: !1,
  101941. configurable: !0
  101942. }),
  101943. Object.defineProperty(e.prototype, "output", {
  101944. get: function() {
  101945. return this._outputs[0]
  101946. },
  101947. enumerable: !1,
  101948. configurable: !0
  101949. }),
  101950. e.prototype._buildBlock = function(i) {
  101951. a.prototype._buildBlock.call(this, i);
  101952. var o = this._outputs[0]
  101953. , s = this.true.isConnected ? this.true.associatedVariableName : "1.0"
  101954. , c = this.false.isConnected ? this.false.associatedVariableName : "0.0";
  101955. switch (this.condition) {
  101956. case ConditionalBlockConditions.Equal:
  101957. {
  101958. i.compilationString += this._declareOutput(o, i) + (" = " + this.a.associatedVariableName + " == " + this.b.associatedVariableName + " ? " + s + " : " + c + `;\r
  101959. `);
  101960. break
  101961. }
  101962. case ConditionalBlockConditions.NotEqual:
  101963. {
  101964. i.compilationString += this._declareOutput(o, i) + (" = " + this.a.associatedVariableName + " != " + this.b.associatedVariableName + " ? " + s + " : " + c + `;\r
  101965. `);
  101966. break
  101967. }
  101968. case ConditionalBlockConditions.LessThan:
  101969. {
  101970. i.compilationString += this._declareOutput(o, i) + (" = " + this.a.associatedVariableName + " < " + this.b.associatedVariableName + " ? " + s + " : " + c + `;\r
  101971. `);
  101972. break
  101973. }
  101974. case ConditionalBlockConditions.LessOrEqual:
  101975. {
  101976. i.compilationString += this._declareOutput(o, i) + (" = " + this.a.associatedVariableName + " <= " + this.b.associatedVariableName + " ? " + s + " : " + c + `;\r
  101977. `);
  101978. break
  101979. }
  101980. case ConditionalBlockConditions.GreaterThan:
  101981. {
  101982. i.compilationString += this._declareOutput(o, i) + (" = " + this.a.associatedVariableName + " > " + this.b.associatedVariableName + " ? " + s + " : " + c + `;\r
  101983. `);
  101984. break
  101985. }
  101986. case ConditionalBlockConditions.GreaterOrEqual:
  101987. {
  101988. i.compilationString += this._declareOutput(o, i) + (" = " + this.a.associatedVariableName + " >= " + this.b.associatedVariableName + " ? " + s + " : " + c + `;\r
  101989. `);
  101990. break
  101991. }
  101992. case ConditionalBlockConditions.Xor:
  101993. {
  101994. i.compilationString += this._declareOutput(o, i) + (" = (mod(" + this.a.associatedVariableName + " + " + this.b.associatedVariableName + ", 2.0) > 0.0) ? " + s + " : " + c + `;\r
  101995. `);
  101996. break
  101997. }
  101998. case ConditionalBlockConditions.Or:
  101999. {
  102000. i.compilationString += this._declareOutput(o, i) + (" = (min(" + this.a.associatedVariableName + " + " + this.b.associatedVariableName + ", 1.0) > 0.0) ? " + s + " : " + c + `;\r
  102001. `);
  102002. break
  102003. }
  102004. case ConditionalBlockConditions.And:
  102005. {
  102006. i.compilationString += this._declareOutput(o, i) + (" = (" + this.a.associatedVariableName + " * " + this.b.associatedVariableName + " > 0.0) ? " + s + " : " + c + `;\r
  102007. `);
  102008. break
  102009. }
  102010. }
  102011. return this
  102012. }
  102013. ,
  102014. e.prototype.serialize = function() {
  102015. var i = a.prototype.serialize.call(this);
  102016. return i.condition = this.condition,
  102017. i
  102018. }
  102019. ,
  102020. e.prototype._deserialize = function(i, o, s) {
  102021. a.prototype._deserialize.call(this, i, o, s),
  102022. this.condition = i.condition
  102023. }
  102024. ,
  102025. e.prototype._dumpPropertiesCode = function() {
  102026. var i = a.prototype._dumpPropertiesCode.call(this) + (this._codeVariableName + ".condition = BABYLON.ConditionalBlockConditions." + ConditionalBlockConditions[this.condition] + `;\r
  102027. `);
  102028. return i
  102029. }
  102030. ,
  102031. e
  102032. }(NodeMaterialBlock);
  102033. RegisterClass("BABYLON.ConditionalBlock", ConditionalBlock);
  102034. var CloudBlock = function(a) {
  102035. __extends(e, a);
  102036. function e(i) {
  102037. var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
  102038. return o.octaves = 6,
  102039. o.registerInput("seed", NodeMaterialBlockConnectionPointTypes.AutoDetect),
  102040. o.registerInput("chaos", NodeMaterialBlockConnectionPointTypes.AutoDetect, !0),
  102041. o.registerInput("offsetX", NodeMaterialBlockConnectionPointTypes.Float, !0),
  102042. o.registerInput("offsetY", NodeMaterialBlockConnectionPointTypes.Float, !0),
  102043. o.registerInput("offsetZ", NodeMaterialBlockConnectionPointTypes.Float, !0),
  102044. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Float),
  102045. o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector2),
  102046. o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector3),
  102047. o._linkConnectionTypes(0, 1),
  102048. o
  102049. }
  102050. return e.prototype.getClassName = function() {
  102051. return "CloudBlock"
  102052. }
  102053. ,
  102054. Object.defineProperty(e.prototype, "seed", {
  102055. get: function() {
  102056. return this._inputs[0]
  102057. },
  102058. enumerable: !1,
  102059. configurable: !0
  102060. }),
  102061. Object.defineProperty(e.prototype, "chaos", {
  102062. get: function() {
  102063. return this._inputs[1]
  102064. },
  102065. enumerable: !1,
  102066. configurable: !0
  102067. }),
  102068. Object.defineProperty(e.prototype, "offsetX", {
  102069. get: function() {
  102070. return this._inputs[2]
  102071. },
  102072. enumerable: !1,
  102073. configurable: !0
  102074. }),
  102075. Object.defineProperty(e.prototype, "offsetY", {
  102076. get: function() {
  102077. return this._inputs[3]
  102078. },
  102079. enumerable: !1,
  102080. configurable: !0
  102081. }),
  102082. Object.defineProperty(e.prototype, "offsetZ", {
  102083. get: function() {
  102084. return this._inputs[4]
  102085. },
  102086. enumerable: !1,
  102087. configurable: !0
  102088. }),
  102089. Object.defineProperty(e.prototype, "output", {
  102090. get: function() {
  102091. return this._outputs[0]
  102092. },
  102093. enumerable: !1,
  102094. configurable: !0
  102095. }),
  102096. e.prototype._buildBlock = function(i) {
  102097. var o, s;
  102098. if (a.prototype._buildBlock.call(this, i),
  102099. !!this.seed.isConnected && !!this._outputs[0].hasEndpoints) {
  102100. var c = `
  102101. float cloudRandom(in float p) { p = fract(p * 0.011); p *= p + 7.5; p *= p + p; return fract(p); }
  102102. // Based on Morgan McGuire @morgan3d
  102103. // https://www.shadertoy.com/view/4dS3Wd
  102104. float cloudNoise(in vec2 x, in vec2 chaos) {
  102105. vec2 step = chaos * vec2(75., 120.) + vec2(75., 120.);
  102106. vec2 i = floor(x);
  102107. vec2 f = fract(x);
  102108. float n = dot(i, step);
  102109. vec2 u = f * f * (3.0 - 2.0 * f);
  102110. return mix(
  102111. mix(cloudRandom(n + dot(step, vec2(0, 0))), cloudRandom(n + dot(step, vec2(1, 0))), u.x),
  102112. mix(cloudRandom(n + dot(step, vec2(0, 1))), cloudRandom(n + dot(step, vec2(1, 1))), u.x),
  102113. u.y
  102114. );
  102115. }
  102116. float cloudNoise(in vec3 x, in vec3 chaos) {
  102117. vec3 step = chaos * vec3(60., 120., 75.) + vec3(60., 120., 75.);
  102118. vec3 i = floor(x);
  102119. vec3 f = fract(x);
  102120. float n = dot(i, step);
  102121. vec3 u = f * f * (3.0 - 2.0 * f);
  102122. return mix(mix(mix( cloudRandom(n + dot(step, vec3(0, 0, 0))), cloudRandom(n + dot(step, vec3(1, 0, 0))), u.x),
  102123. mix( cloudRandom(n + dot(step, vec3(0, 1, 0))), cloudRandom(n + dot(step, vec3(1, 1, 0))), u.x), u.y),
  102124. mix(mix( cloudRandom(n + dot(step, vec3(0, 0, 1))), cloudRandom(n + dot(step, vec3(1, 0, 1))), u.x),
  102125. mix( cloudRandom(n + dot(step, vec3(0, 1, 1))), cloudRandom(n + dot(step, vec3(1, 1, 1))), u.x), u.y), u.z);
  102126. }`
  102127. , d = `
  102128. float fbm(in vec2 st, in vec2 chaos) {
  102129. // Initial values
  102130. float value = 0.0;
  102131. float amplitude = .5;
  102132. float frequency = 0.;
  102133. // Loop of octaves
  102134. for (int i = 0; i < OCTAVES; i++) {
  102135. value += amplitude * cloudNoise(st, chaos);
  102136. st *= 2.0;
  102137. amplitude *= 0.5;
  102138. }
  102139. return value;
  102140. }
  102141. float fbm(in vec3 x, in vec3 chaos) {
  102142. // Initial values
  102143. float value = 0.0;
  102144. float amplitude = 0.5;
  102145. for (int i = 0; i < OCTAVES; ++i) {
  102146. value += amplitude * cloudNoise(x, chaos);
  102147. x = x * 2.0;
  102148. amplitude *= 0.5;
  102149. }
  102150. return value;
  102151. }`
  102152. , _ = "fbm" + this.octaves;
  102153. i._emitFunction("CloudBlockCode", c, "// CloudBlockCode"),
  102154. i._emitFunction("CloudBlockCodeFBM" + this.octaves, d.replace(/fbm/gi, _).replace(/OCTAVES/gi, (this.octaves | 0).toString()), "// CloudBlockCode FBM");
  102155. var b = i._getFreeVariableName("st")
  102156. , k = ((o = this.seed.connectedPoint) === null || o === void 0 ? void 0 : o.type) === NodeMaterialBlockConnectionPointTypes.Vector2 ? "vec2" : "vec3";
  102157. i.compilationString += k + " " + b + " = " + this.seed.associatedVariableName + `;\r
  102158. `,
  102159. this.offsetX.isConnected && (i.compilationString += b + ".x += 0.1 * " + this.offsetX.associatedVariableName + `;\r
  102160. `),
  102161. this.offsetY.isConnected && (i.compilationString += b + ".y += 0.1 * " + this.offsetY.associatedVariableName + `;\r
  102162. `),
  102163. this.offsetZ.isConnected && k === "vec3" && (i.compilationString += b + ".z += 0.1 * " + this.offsetZ.associatedVariableName + `;\r
  102164. `);
  102165. var j = "";
  102166. return this.chaos.isConnected ? j = this.chaos.associatedVariableName : j = ((s = this.seed.connectedPoint) === null || s === void 0 ? void 0 : s.type) === NodeMaterialBlockConnectionPointTypes.Vector2 ? "vec2(0., 0.)" : "vec3(0., 0., 0.)",
  102167. i.compilationString += this._declareOutput(this._outputs[0], i) + (" = " + _ + "(" + b + ", " + j + `);\r
  102168. `),
  102169. this
  102170. }
  102171. }
  102172. ,
  102173. e.prototype._dumpPropertiesCode = function() {
  102174. var i = a.prototype._dumpPropertiesCode.call(this) + (this._codeVariableName + ".octaves = " + this.octaves + `;\r
  102175. `);
  102176. return i
  102177. }
  102178. ,
  102179. e.prototype.serialize = function() {
  102180. var i = a.prototype.serialize.call(this);
  102181. return i.octaves = this.octaves,
  102182. i
  102183. }
  102184. ,
  102185. e.prototype._deserialize = function(i, o, s) {
  102186. a.prototype._deserialize.call(this, i, o, s),
  102187. this.octaves = i.octaves
  102188. }
  102189. ,
  102190. __decorate([editableInPropertyPage("Octaves", PropertyTypeForEdition.Int)], e.prototype, "octaves", void 0),
  102191. e
  102192. }(NodeMaterialBlock);
  102193. RegisterClass("BABYLON.CloudBlock", CloudBlock);
  102194. var VoronoiNoiseBlock = function(a) {
  102195. __extends(e, a);
  102196. function e(i) {
  102197. var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
  102198. return o.registerInput("seed", NodeMaterialBlockConnectionPointTypes.Vector2),
  102199. o.registerInput("offset", NodeMaterialBlockConnectionPointTypes.Float),
  102200. o.registerInput("density", NodeMaterialBlockConnectionPointTypes.Float),
  102201. o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Float),
  102202. o.registerOutput("cells", NodeMaterialBlockConnectionPointTypes.Float),
  102203. o
  102204. }
  102205. return e.prototype.getClassName = function() {
  102206. return "VoronoiNoiseBlock"
  102207. }
  102208. ,
  102209. Object.defineProperty(e.prototype, "seed", {
  102210. get: function() {
  102211. return this._inputs[0]
  102212. },
  102213. enumerable: !1,
  102214. configurable: !0
  102215. }),
  102216. Object.defineProperty(e.prototype, "offset", {
  102217. get: function() {
  102218. return this._inputs[1]
  102219. },
  102220. enumerable: !1,
  102221. configurable: !0
  102222. }),
  102223. Object.defineProperty(e.prototype, "density", {
  102224. get: function() {
  102225. return this._inputs[2]
  102226. },
  102227. enumerable: !1,
  102228. configurable: !0
  102229. }),
  102230. Object.defineProperty(e.prototype, "output", {
  102231. get: function() {
  102232. return this._outputs[0]
  102233. },
  102234. enumerable: !1,
  102235. configurable: !0
  102236. }),
  102237. Object.defineProperty(e.prototype, "cells", {
  102238. get: function() {
  102239. return this._outputs[1]
  102240. },
  102241. enumerable: !1,
  102242. configurable: !0
  102243. }),
  102244. e.prototype._buildBlock = function(i) {
  102245. if (a.prototype._buildBlock.call(this, i),
  102246. !!this.seed.isConnected) {
  102247. var o = `vec2 voronoiRandom(vec2 seed, float offset){
  102248. mat2 m = mat2(15.27, 47.63, 99.41, 89.98);
  102249. vec2 uv = fract(sin(m * seed) * 46839.32);
  102250. return vec2(sin(uv.y * offset) * 0.5 + 0.5, cos(uv.x * offset) * 0.5 + 0.5);
  102251. }
  102252. `;
  102253. i._emitFunction("voronoiRandom", o, "// Voronoi random generator"),
  102254. o = `void voronoi(vec2 seed, float offset, float density, out float outValue, out float cells){
  102255. vec2 g = floor(seed * density);
  102256. vec2 f = fract(seed * density);
  102257. float t = 8.0;
  102258. vec3 res = vec3(8.0, 0.0, 0.0);
  102259. for(int y=-1; y<=1; y++)
  102260. {
  102261. for(int x=-1; x<=1; x++)
  102262. {
  102263. vec2 lattice = vec2(x,y);
  102264. vec2 randomOffset = voronoiRandom(lattice + g, offset);
  102265. float d = distance(lattice + randomOffset, f);
  102266. if(d < res.x)
  102267. {
  102268. res = vec3(d, randomOffset.x, randomOffset.y);
  102269. outValue = res.x;
  102270. cells = res.y;
  102271. }
  102272. }
  102273. }
  102274. }
  102275. `,
  102276. i._emitFunction("voronoi", o, "// Voronoi");
  102277. var s = i._getFreeVariableName("tempOutput")
  102278. , c = i._getFreeVariableName("tempCells");
  102279. return i.compilationString += "float " + s + ` = 0.0;\r
  102280. `,
  102281. i.compilationString += "float " + c + ` = 0.0;\r
  102282. `,
  102283. i.compilationString += "voronoi(" + this.seed.associatedVariableName + ", " + this.offset.associatedVariableName + ", " + this.density.associatedVariableName + ", " + s + ", " + c + `);\r
  102284. `,
  102285. this.output.hasEndpoints && (i.compilationString += this._declareOutput(this.output, i) + (" = " + s + `;\r
  102286. `)),
  102287. this.cells.hasEndpoints && (i.compilationString += this._declareOutput(this.cells, i) + (" = " + c + `;\r
  102288. `)),
  102289. this
  102290. }
  102291. }
  102292. ,
  102293. e
  102294. }(NodeMaterialBlock);
  102295. RegisterClass("BABYLON.VoronoiNoiseBlock", VoronoiNoiseBlock);
  102296. Node$2.AddNodeConstructor("Light_Type_2", function(a, e) {
  102297. return function() {
  102298. return new SpotLight(a,Vector3.Zero(),Vector3.Zero(),0,0,e)
  102299. }
  102300. });
  102301. var SpotLight = function(a) {
  102302. __extends(e, a);
  102303. function e(i, o, s, c, d, _) {
  102304. var b = a.call(this, i, _) || this;
  102305. return b._innerAngle = 0,
  102306. b._projectionTextureMatrix = Matrix.Zero(),
  102307. b._projectionTextureLightNear = 1e-6,
  102308. b._projectionTextureLightFar = 1e3,
  102309. b._projectionTextureUpDirection = Vector3.Up(),
  102310. b._projectionTextureViewLightDirty = !0,
  102311. b._projectionTextureProjectionLightDirty = !0,
  102312. b._projectionTextureDirty = !0,
  102313. b._projectionTextureViewTargetVector = Vector3.Zero(),
  102314. b._projectionTextureViewLightMatrix = Matrix.Zero(),
  102315. b._projectionTextureProjectionLightMatrix = Matrix.Zero(),
  102316. b._projectionTextureScalingMatrix = Matrix.FromValues(.5, 0, 0, 0, 0, .5, 0, 0, 0, 0, .5, 0, .5, .5, .5, 1),
  102317. b.position = o,
  102318. b.direction = s,
  102319. b.angle = c,
  102320. b.exponent = d,
  102321. b
  102322. }
  102323. return Object.defineProperty(e.prototype, "angle", {
  102324. get: function() {
  102325. return this._angle
  102326. },
  102327. set: function(i) {
  102328. this._angle = i,
  102329. this._cosHalfAngle = Math.cos(i * .5),
  102330. this._projectionTextureProjectionLightDirty = !0,
  102331. this.forceProjectionMatrixCompute(),
  102332. this._computeAngleValues()
  102333. },
  102334. enumerable: !1,
  102335. configurable: !0
  102336. }),
  102337. Object.defineProperty(e.prototype, "innerAngle", {
  102338. get: function() {
  102339. return this._innerAngle
  102340. },
  102341. set: function(i) {
  102342. this._innerAngle = i,
  102343. this._computeAngleValues()
  102344. },
  102345. enumerable: !1,
  102346. configurable: !0
  102347. }),
  102348. Object.defineProperty(e.prototype, "shadowAngleScale", {
  102349. get: function() {
  102350. return this._shadowAngleScale
  102351. },
  102352. set: function(i) {
  102353. this._shadowAngleScale = i,
  102354. this.forceProjectionMatrixCompute()
  102355. },
  102356. enumerable: !1,
  102357. configurable: !0
  102358. }),
  102359. Object.defineProperty(e.prototype, "projectionTextureMatrix", {
  102360. get: function() {
  102361. return this._projectionTextureMatrix
  102362. },
  102363. enumerable: !1,
  102364. configurable: !0
  102365. }),
  102366. Object.defineProperty(e.prototype, "projectionTextureLightNear", {
  102367. get: function() {
  102368. return this._projectionTextureLightNear
  102369. },
  102370. set: function(i) {
  102371. this._projectionTextureLightNear = i,
  102372. this._projectionTextureProjectionLightDirty = !0
  102373. },
  102374. enumerable: !1,
  102375. configurable: !0
  102376. }),
  102377. Object.defineProperty(e.prototype, "projectionTextureLightFar", {
  102378. get: function() {
  102379. return this._projectionTextureLightFar
  102380. },
  102381. set: function(i) {
  102382. this._projectionTextureLightFar = i,
  102383. this._projectionTextureProjectionLightDirty = !0
  102384. },
  102385. enumerable: !1,
  102386. configurable: !0
  102387. }),
  102388. Object.defineProperty(e.prototype, "projectionTextureUpDirection", {
  102389. get: function() {
  102390. return this._projectionTextureUpDirection
  102391. },
  102392. set: function(i) {
  102393. this._projectionTextureUpDirection = i,
  102394. this._projectionTextureProjectionLightDirty = !0
  102395. },
  102396. enumerable: !1,
  102397. configurable: !0
  102398. }),
  102399. Object.defineProperty(e.prototype, "projectionTexture", {
  102400. get: function() {
  102401. return this._projectionTexture
  102402. },
  102403. set: function(i) {
  102404. var o = this;
  102405. this._projectionTexture !== i && (this._projectionTexture = i,
  102406. this._projectionTextureDirty = !0,
  102407. this._projectionTexture && !this._projectionTexture.isReady() && (e._IsProceduralTexture(this._projectionTexture) ? this._projectionTexture.getEffect().executeWhenCompiled(function() {
  102408. o._markMeshesAsLightDirty()
  102409. }) : e._IsTexture(this._projectionTexture) && this._projectionTexture.onLoadObservable.addOnce(function() {
  102410. o._markMeshesAsLightDirty()
  102411. })))
  102412. },
  102413. enumerable: !1,
  102414. configurable: !0
  102415. }),
  102416. e._IsProceduralTexture = function(i) {
  102417. return i.onGeneratedObservable !== void 0
  102418. }
  102419. ,
  102420. e._IsTexture = function(i) {
  102421. return i.onLoadObservable !== void 0
  102422. }
  102423. ,
  102424. Object.defineProperty(e.prototype, "projectionTextureProjectionLightMatrix", {
  102425. get: function() {
  102426. return this._projectionTextureProjectionLightMatrix
  102427. },
  102428. set: function(i) {
  102429. this._projectionTextureProjectionLightMatrix = i,
  102430. this._projectionTextureProjectionLightDirty = !1,
  102431. this._projectionTextureDirty = !0
  102432. },
  102433. enumerable: !1,
  102434. configurable: !0
  102435. }),
  102436. e.prototype.getClassName = function() {
  102437. return "SpotLight"
  102438. }
  102439. ,
  102440. e.prototype.getTypeID = function() {
  102441. return Light.LIGHTTYPEID_SPOTLIGHT
  102442. }
  102443. ,
  102444. e.prototype._setDirection = function(i) {
  102445. a.prototype._setDirection.call(this, i),
  102446. this._projectionTextureViewLightDirty = !0
  102447. }
  102448. ,
  102449. e.prototype._setPosition = function(i) {
  102450. a.prototype._setPosition.call(this, i),
  102451. this._projectionTextureViewLightDirty = !0
  102452. }
  102453. ,
  102454. e.prototype._setDefaultShadowProjectionMatrix = function(i, o, s) {
  102455. var c = this.getScene().activeCamera;
  102456. if (!!c) {
  102457. this._shadowAngleScale = this._shadowAngleScale || 1;
  102458. var d = this._shadowAngleScale * this._angle
  102459. , _ = this.shadowMinZ !== void 0 ? this.shadowMinZ : c.minZ
  102460. , b = this.shadowMaxZ !== void 0 ? this.shadowMaxZ : c.maxZ
  102461. , k = this.getScene().getEngine().useReverseDepthBuffer;
  102462. Matrix.PerspectiveFovLHToRef(d, 1, k ? b : _, k ? _ : b, i, !0, this._scene.getEngine().isNDCHalfZRange, void 0, k)
  102463. }
  102464. }
  102465. ,
  102466. e.prototype._computeProjectionTextureViewLightMatrix = function() {
  102467. this._projectionTextureViewLightDirty = !1,
  102468. this._projectionTextureDirty = !0,
  102469. this.position.addToRef(this.direction, this._projectionTextureViewTargetVector),
  102470. Matrix.LookAtLHToRef(this.position, this._projectionTextureViewTargetVector, this._projectionTextureUpDirection, this._projectionTextureViewLightMatrix)
  102471. }
  102472. ,
  102473. e.prototype._computeProjectionTextureProjectionLightMatrix = function() {
  102474. this._projectionTextureProjectionLightDirty = !1,
  102475. this._projectionTextureDirty = !0;
  102476. var i = this.projectionTextureLightFar
  102477. , o = this.projectionTextureLightNear
  102478. , s = i / (i - o)
  102479. , c = -s * o
  102480. , d = 1 / Math.tan(this._angle / 2)
  102481. , _ = 1;
  102482. Matrix.FromValuesToRef(d / _, 0, 0, 0, 0, d, 0, 0, 0, 0, s, 1, 0, 0, c, 0, this._projectionTextureProjectionLightMatrix)
  102483. }
  102484. ,
  102485. e.prototype._computeProjectionTextureMatrix = function() {
  102486. if (this._projectionTextureDirty = !1,
  102487. this._projectionTextureViewLightMatrix.multiplyToRef(this._projectionTextureProjectionLightMatrix, this._projectionTextureMatrix),
  102488. this._projectionTexture instanceof Texture) {
  102489. var i = this._projectionTexture.uScale / 2
  102490. , o = this._projectionTexture.vScale / 2;
  102491. Matrix.FromValuesToRef(i, 0, 0, 0, 0, o, 0, 0, 0, 0, .5, 0, .5, .5, .5, 1, this._projectionTextureScalingMatrix)
  102492. }
  102493. this._projectionTextureMatrix.multiplyToRef(this._projectionTextureScalingMatrix, this._projectionTextureMatrix)
  102494. }
  102495. ,
  102496. e.prototype._buildUniformLayout = function() {
  102497. this._uniformBuffer.addUniform("vLightData", 4),
  102498. this._uniformBuffer.addUniform("vLightDiffuse", 4),
  102499. this._uniformBuffer.addUniform("vLightSpecular", 4),
  102500. this._uniformBuffer.addUniform("vLightDirection", 3),
  102501. this._uniformBuffer.addUniform("vLightFalloff", 4),
  102502. this._uniformBuffer.addUniform("shadowsInfo", 3),
  102503. this._uniformBuffer.addUniform("depthValues", 2),
  102504. this._uniformBuffer.create()
  102505. }
  102506. ,
  102507. e.prototype._computeAngleValues = function() {
  102508. this._lightAngleScale = 1 / Math.max(.001, Math.cos(this._innerAngle * .5) - this._cosHalfAngle),
  102509. this._lightAngleOffset = -this._cosHalfAngle * this._lightAngleScale
  102510. }
  102511. ,
  102512. e.prototype.transferTexturesToEffect = function(i, o) {
  102513. return this.projectionTexture && this.projectionTexture.isReady() && (this._projectionTextureViewLightDirty && this._computeProjectionTextureViewLightMatrix(),
  102514. this._projectionTextureProjectionLightDirty && this._computeProjectionTextureProjectionLightMatrix(),
  102515. this._projectionTextureDirty && this._computeProjectionTextureMatrix(),
  102516. i.setMatrix("textureProjectionMatrix" + o, this._projectionTextureMatrix),
  102517. i.setTexture("projectionLightSampler" + o, this.projectionTexture)),
  102518. this
  102519. }
  102520. ,
  102521. e.prototype.transferToEffect = function(i, o) {
  102522. var s;
  102523. return this.computeTransformedInformation() ? (this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, this.exponent, o),
  102524. s = Vector3.Normalize(this.transformedDirection)) : (this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, this.exponent, o),
  102525. s = Vector3.Normalize(this.direction)),
  102526. this._uniformBuffer.updateFloat4("vLightDirection", s.x, s.y, s.z, this._cosHalfAngle, o),
  102527. this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, this._lightAngleScale, this._lightAngleOffset, o),
  102528. this
  102529. }
  102530. ,
  102531. e.prototype.transferToNodeMaterialEffect = function(i, o) {
  102532. var s;
  102533. return this.computeTransformedInformation() ? s = Vector3.Normalize(this.transformedDirection) : s = Vector3.Normalize(this.direction),
  102534. this.getScene().useRightHandedSystem ? i.setFloat3(o, -s.x, -s.y, -s.z) : i.setFloat3(o, s.x, s.y, s.z),
  102535. this
  102536. }
  102537. ,
  102538. e.prototype.dispose = function() {
  102539. a.prototype.dispose.call(this),
  102540. this._projectionTexture && this._projectionTexture.dispose()
  102541. }
  102542. ,
  102543. e.prototype.getDepthMinZ = function(i) {
  102544. var o = this._scene.getEngine()
  102545. , s = this.shadowMinZ !== void 0 ? this.shadowMinZ : i.minZ;
  102546. return o.useReverseDepthBuffer && o.isNDCHalfZRange ? s : this._scene.getEngine().isNDCHalfZRange ? 0 : s
  102547. }
  102548. ,
  102549. e.prototype.getDepthMaxZ = function(i) {
  102550. var o = this._scene.getEngine()
  102551. , s = this.shadowMaxZ !== void 0 ? this.shadowMaxZ : i.maxZ;
  102552. return o.useReverseDepthBuffer && o.isNDCHalfZRange ? 0 : s
  102553. }
  102554. ,
  102555. e.prototype.prepareLightSpecificDefines = function(i, o) {
  102556. i["SPOTLIGHT" + o] = !0,
  102557. i["PROJECTEDLIGHTTEXTURE" + o] = !!(this.projectionTexture && this.projectionTexture.isReady())
  102558. }
  102559. ,
  102560. __decorate([serialize()], e.prototype, "angle", null),
  102561. __decorate([serialize()], e.prototype, "innerAngle", null),
  102562. __decorate([serialize()], e.prototype, "shadowAngleScale", null),
  102563. __decorate([serialize()], e.prototype, "exponent", void 0),
  102564. __decorate([serialize()], e.prototype, "projectionTextureLightNear", null),
  102565. __decorate([serialize()], e.prototype, "projectionTextureLightFar", null),
  102566. __decorate([serialize()], e.prototype, "projectionTextureUpDirection", null),
  102567. __decorate([serializeAsTexture("projectedLightTexture")], e.prototype, "_projectionTexture", void 0),
  102568. e
  102569. }(ShadowLight)
  102570. , name$D = "glowMapGenerationPixelShader"
  102571. , shader$D = `#if defined(DIFFUSE_ISLINEAR) || defined(EMISSIVE_ISLINEAR)
  102572. #include<helperFunctions>
  102573. #endif
  102574. #ifdef DIFFUSE
  102575. varying vec2 vUVDiffuse;
  102576. uniform sampler2D diffuseSampler;
  102577. #endif
  102578. #ifdef OPACITY
  102579. varying vec2 vUVOpacity;
  102580. uniform sampler2D opacitySampler;
  102581. uniform float opacityIntensity;
  102582. #endif
  102583. #ifdef EMISSIVE
  102584. varying vec2 vUVEmissive;
  102585. uniform sampler2D emissiveSampler;
  102586. #endif
  102587. #ifdef VERTEXALPHA
  102588. varying vec4 vColor;
  102589. #endif
  102590. uniform vec4 glowColor;
  102591. void main(void)
  102592. {
  102593. vec4 finalColor=glowColor;
  102594. #ifdef DIFFUSE
  102595. vec4 albedoTexture=texture2D(diffuseSampler,vUVDiffuse);
  102596. #ifdef DIFFUSE_ISLINEAR
  102597. albedoTexture=toGammaSpace(albedoTexture);
  102598. #endif
  102599. #ifdef GLOW
  102600. finalColor.a*=albedoTexture.a;
  102601. #endif
  102602. #ifdef HIGHLIGHT
  102603. finalColor.a=albedoTexture.a;
  102604. #endif
  102605. #endif
  102606. #ifdef OPACITY
  102607. vec4 opacityMap=texture2D(opacitySampler,vUVOpacity);
  102608. #ifdef OPACITYRGB
  102609. finalColor.a*=getLuminance(opacityMap.rgb);
  102610. #else
  102611. finalColor.a*=opacityMap.a;
  102612. #endif
  102613. finalColor.a*=opacityIntensity;
  102614. #endif
  102615. #ifdef VERTEXALPHA
  102616. finalColor.a*=vColor.a;
  102617. #endif
  102618. #ifdef ALPHATEST
  102619. if (finalColor.a<ALPHATESTVALUE)
  102620. discard;
  102621. #endif
  102622. #ifdef EMISSIVE
  102623. vec4 emissive=texture2D(emissiveSampler,vUVEmissive);
  102624. #ifdef EMISSIVE_ISLINEAR
  102625. emissive=toGammaSpace(emissive);
  102626. #endif
  102627. gl_FragColor=emissive*finalColor;
  102628. #else
  102629. gl_FragColor=finalColor;
  102630. #endif
  102631. #ifdef HIGHLIGHT
  102632. gl_FragColor.a=glowColor.a;
  102633. #endif
  102634. }`;
  102635. ShaderStore.ShadersStore[name$D] = shader$D;
  102636. var name$C = "glowMapGenerationVertexShader"
  102637. , shader$C = `
  102638. attribute vec3 position;
  102639. #include<bonesDeclaration>
  102640. #include<bakedVertexAnimationDeclaration>
  102641. #include<morphTargetsVertexGlobalDeclaration>
  102642. #include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
  102643. #include<instancesDeclaration>
  102644. uniform mat4 viewProjection;
  102645. varying vec4 vPosition;
  102646. #ifdef UV1
  102647. attribute vec2 uv;
  102648. #endif
  102649. #ifdef UV2
  102650. attribute vec2 uv2;
  102651. #endif
  102652. #ifdef DIFFUSE
  102653. varying vec2 vUVDiffuse;
  102654. uniform mat4 diffuseMatrix;
  102655. #endif
  102656. #ifdef OPACITY
  102657. varying vec2 vUVOpacity;
  102658. uniform mat4 opacityMatrix;
  102659. #endif
  102660. #ifdef EMISSIVE
  102661. varying vec2 vUVEmissive;
  102662. uniform mat4 emissiveMatrix;
  102663. #endif
  102664. #ifdef VERTEXALPHA
  102665. attribute vec4 color;
  102666. varying vec4 vColor;
  102667. #endif
  102668. void main(void)
  102669. {
  102670. vec3 positionUpdated=position;
  102671. #ifdef UV1
  102672. vec2 uvUpdated=uv;
  102673. #endif
  102674. #include<morphTargetsVertexGlobal>
  102675. #include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
  102676. #include<instancesVertex>
  102677. #include<bonesVertex>
  102678. #include<bakedVertexAnimation>
  102679. #ifdef CUBEMAP
  102680. vPosition=finalWorld*vec4(positionUpdated,1.0);
  102681. gl_Position=viewProjection*finalWorld*vec4(position,1.0);
  102682. #else
  102683. vPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);
  102684. gl_Position=vPosition;
  102685. #endif
  102686. #ifdef DIFFUSE
  102687. #ifdef DIFFUSEUV1
  102688. vUVDiffuse=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));
  102689. #endif
  102690. #ifdef DIFFUSEUV2
  102691. vUVDiffuse=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));
  102692. #endif
  102693. #endif
  102694. #ifdef OPACITY
  102695. #ifdef OPACITYUV1
  102696. vUVOpacity=vec2(opacityMatrix*vec4(uvUpdated,1.0,0.0));
  102697. #endif
  102698. #ifdef OPACITYUV2
  102699. vUVOpacity=vec2(opacityMatrix*vec4(uv2,1.0,0.0));
  102700. #endif
  102701. #endif
  102702. #ifdef EMISSIVE
  102703. #ifdef EMISSIVEUV1
  102704. vUVEmissive=vec2(emissiveMatrix*vec4(uvUpdated,1.0,0.0));
  102705. #endif
  102706. #ifdef EMISSIVEUV2
  102707. vUVEmissive=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));
  102708. #endif
  102709. #endif
  102710. #ifdef VERTEXALPHA
  102711. vColor=color;
  102712. #endif
  102713. }`;
  102714. ShaderStore.ShadersStore[name$C] = shader$C;
  102715. var EffectLayer = function() {
  102716. function a(e, i) {
  102717. this._vertexBuffers = {},
  102718. this._maxSize = 0,
  102719. this._mainTextureDesiredSize = {
  102720. width: 0,
  102721. height: 0
  102722. },
  102723. this._shouldRender = !0,
  102724. this._postProcesses = [],
  102725. this._textures = [],
  102726. this._emissiveTextureAndColor = {
  102727. texture: null,
  102728. color: new Color4
  102729. },
  102730. this.neutralColor = new Color4,
  102731. this.isEnabled = !0,
  102732. this.disableBoundingBoxesFromEffectLayer = !1,
  102733. this.onDisposeObservable = new Observable,
  102734. this.onBeforeRenderMainTextureObservable = new Observable,
  102735. this.onBeforeComposeObservable = new Observable,
  102736. this.onBeforeRenderMeshToEffect = new Observable,
  102737. this.onAfterRenderMeshToEffect = new Observable,
  102738. this.onAfterComposeObservable = new Observable,
  102739. this.onSizeChangedObservable = new Observable,
  102740. this.name = e,
  102741. this._scene = i || EngineStore.LastCreatedScene,
  102742. a._SceneComponentInitialization(this._scene),
  102743. this._engine = this._scene.getEngine(),
  102744. this._maxSize = this._engine.getCaps().maxTextureSize,
  102745. this._scene.effectLayers.push(this),
  102746. this._mergeDrawWrapper = [],
  102747. this._generateIndexBuffer(),
  102748. this._generateVertexBuffer()
  102749. }
  102750. return Object.defineProperty(a.prototype, "camera", {
  102751. get: function() {
  102752. return this._effectLayerOptions.camera
  102753. },
  102754. enumerable: !1,
  102755. configurable: !0
  102756. }),
  102757. Object.defineProperty(a.prototype, "renderingGroupId", {
  102758. get: function() {
  102759. return this._effectLayerOptions.renderingGroupId
  102760. },
  102761. set: function(e) {
  102762. this._effectLayerOptions.renderingGroupId = e
  102763. },
  102764. enumerable: !1,
  102765. configurable: !0
  102766. }),
  102767. a.prototype.setMaterialForRendering = function(e, i) {
  102768. this._mainTexture.setMaterialForRendering(e, i)
  102769. }
  102770. ,
  102771. a.prototype._numInternalDraws = function() {
  102772. return 1
  102773. }
  102774. ,
  102775. a.prototype._init = function(e) {
  102776. this._effectLayerOptions = __assign({
  102777. mainTextureRatio: .5,
  102778. alphaBlendingMode: 2,
  102779. camera: null,
  102780. renderingGroupId: -1
  102781. }, e),
  102782. this._setMainTextureSize(),
  102783. this._createMainTexture(),
  102784. this._createTextureAndPostProcesses()
  102785. }
  102786. ,
  102787. a.prototype._generateIndexBuffer = function() {
  102788. var e = [];
  102789. e.push(0),
  102790. e.push(1),
  102791. e.push(2),
  102792. e.push(0),
  102793. e.push(2),
  102794. e.push(3),
  102795. this._indexBuffer = this._engine.createIndexBuffer(e)
  102796. }
  102797. ,
  102798. a.prototype._generateVertexBuffer = function() {
  102799. var e = [];
  102800. e.push(1, 1),
  102801. e.push(-1, 1),
  102802. e.push(-1, -1),
  102803. e.push(1, -1);
  102804. var i = new VertexBuffer(this._engine,e,VertexBuffer.PositionKind,!1,!1,2);
  102805. this._vertexBuffers[VertexBuffer.PositionKind] = i
  102806. }
  102807. ,
  102808. a.prototype._setMainTextureSize = function() {
  102809. this._effectLayerOptions.mainTextureFixedSize ? (this._mainTextureDesiredSize.width = this._effectLayerOptions.mainTextureFixedSize,
  102810. this._mainTextureDesiredSize.height = this._effectLayerOptions.mainTextureFixedSize) : (this._mainTextureDesiredSize.width = this._engine.getRenderWidth() * this._effectLayerOptions.mainTextureRatio,
  102811. this._mainTextureDesiredSize.height = this._engine.getRenderHeight() * this._effectLayerOptions.mainTextureRatio,
  102812. this._mainTextureDesiredSize.width = this._engine.needPOTTextures ? Engine.GetExponentOfTwo(this._mainTextureDesiredSize.width, this._maxSize) : this._mainTextureDesiredSize.width,
  102813. this._mainTextureDesiredSize.height = this._engine.needPOTTextures ? Engine.GetExponentOfTwo(this._mainTextureDesiredSize.height, this._maxSize) : this._mainTextureDesiredSize.height),
  102814. this._mainTextureDesiredSize.width = Math.floor(this._mainTextureDesiredSize.width),
  102815. this._mainTextureDesiredSize.height = Math.floor(this._mainTextureDesiredSize.height)
  102816. }
  102817. ,
  102818. a.prototype._createMainTexture = function() {
  102819. var e = this;
  102820. if (this._mainTexture = new RenderTargetTexture("EffectLayerMainRTT",{
  102821. width: this._mainTextureDesiredSize.width,
  102822. height: this._mainTextureDesiredSize.height
  102823. },this._scene,!1,!0,0),
  102824. this._mainTexture.activeCamera = this._effectLayerOptions.camera,
  102825. this._mainTexture.wrapU = Texture.CLAMP_ADDRESSMODE,
  102826. this._mainTexture.wrapV = Texture.CLAMP_ADDRESSMODE,
  102827. this._mainTexture.anisotropicFilteringLevel = 1,
  102828. this._mainTexture.updateSamplingMode(Texture.BILINEAR_SAMPLINGMODE),
  102829. this._mainTexture.renderParticles = !1,
  102830. this._mainTexture.renderList = null,
  102831. this._mainTexture.ignoreCameraViewport = !0,
  102832. this._mainTexture.customRenderFunction = function(o, s, c, d) {
  102833. e.onBeforeRenderMainTextureObservable.notifyObservers(e);
  102834. var _, b = e._scene.getEngine();
  102835. if (d.length) {
  102836. for (b.setColorWrite(!1),
  102837. _ = 0; _ < d.length; _++)
  102838. e._renderSubMesh(d.data[_]);
  102839. b.setColorWrite(!0)
  102840. }
  102841. for (_ = 0; _ < o.length; _++)
  102842. e._renderSubMesh(o.data[_]);
  102843. for (_ = 0; _ < s.length; _++)
  102844. e._renderSubMesh(s.data[_]);
  102845. var k = b.getAlphaMode();
  102846. for (_ = 0; _ < c.length; _++)
  102847. e._renderSubMesh(c.data[_], !0);
  102848. b.setAlphaMode(k)
  102849. }
  102850. ,
  102851. this._mainTexture.onClearObservable.add(function(o) {
  102852. o.clear(e.neutralColor, !0, !0, !0)
  102853. }),
  102854. this._scene.getBoundingBoxRenderer) {
  102855. var i = this._scene.getBoundingBoxRenderer().enabled;
  102856. this._mainTexture.onBeforeBindObservable.add(function() {
  102857. e._scene.getBoundingBoxRenderer().enabled = !e.disableBoundingBoxesFromEffectLayer && i
  102858. }),
  102859. this._mainTexture.onAfterUnbindObservable.add(function() {
  102860. e._scene.getBoundingBoxRenderer().enabled = i
  102861. })
  102862. }
  102863. }
  102864. ,
  102865. a.prototype._addCustomEffectDefines = function(e) {}
  102866. ,
  102867. a.prototype._isReady = function(e, i, o) {
  102868. var s, c = this._scene.getEngine(), d = e.getMesh(), _ = (s = d._internalAbstractMeshDataInfo._materialForRenderPass) === null || s === void 0 ? void 0 : s[c.currentRenderPassId];
  102869. if (_)
  102870. return _.isReadyForSubMesh(d, e, i);
  102871. var b = e.getMaterial();
  102872. if (!b)
  102873. return !1;
  102874. if (this._useMeshMaterial(e.getRenderingMesh()))
  102875. return b.isReadyForSubMesh(e.getMesh(), e, i);
  102876. var k = []
  102877. , j = [VertexBuffer.PositionKind]
  102878. , $ = !1
  102879. , _e = !1;
  102880. if (b) {
  102881. var et = b.needAlphaTesting()
  102882. , tt = b.getAlphaTestTexture()
  102883. , rt = tt && tt.hasAlpha && (b.useAlphaFromDiffuseTexture || b._useAlphaFromAlbedoTexture);
  102884. tt && (et || rt) && (k.push("#define DIFFUSE"),
  102885. d.isVerticesDataPresent(VertexBuffer.UV2Kind) && tt.coordinatesIndex === 1 ? (k.push("#define DIFFUSEUV2"),
  102886. _e = !0) : d.isVerticesDataPresent(VertexBuffer.UVKind) && (k.push("#define DIFFUSEUV1"),
  102887. $ = !0),
  102888. et && (k.push("#define ALPHATEST"),
  102889. k.push("#define ALPHATESTVALUE 0.4")),
  102890. tt.gammaSpace || k.push("#define DIFFUSE_ISLINEAR"));
  102891. var it = b.opacityTexture;
  102892. it && (k.push("#define OPACITY"),
  102893. d.isVerticesDataPresent(VertexBuffer.UV2Kind) && it.coordinatesIndex === 1 ? (k.push("#define OPACITYUV2"),
  102894. _e = !0) : d.isVerticesDataPresent(VertexBuffer.UVKind) && (k.push("#define OPACITYUV1"),
  102895. $ = !0))
  102896. }
  102897. o && (k.push("#define EMISSIVE"),
  102898. d.isVerticesDataPresent(VertexBuffer.UV2Kind) && o.coordinatesIndex === 1 ? (k.push("#define EMISSIVEUV2"),
  102899. _e = !0) : d.isVerticesDataPresent(VertexBuffer.UVKind) && (k.push("#define EMISSIVEUV1"),
  102900. $ = !0),
  102901. o.gammaSpace || k.push("#define EMISSIVE_ISLINEAR")),
  102902. d.isVerticesDataPresent(VertexBuffer.ColorKind) && d.hasVertexAlpha && (j.push(VertexBuffer.ColorKind),
  102903. k.push("#define VERTEXALPHA")),
  102904. $ && (j.push(VertexBuffer.UVKind),
  102905. k.push("#define UV1")),
  102906. _e && (j.push(VertexBuffer.UV2Kind),
  102907. k.push("#define UV2"));
  102908. var nt = new EffectFallbacks;
  102909. if (d.useBones && d.computeBonesUsingShaders) {
  102910. j.push(VertexBuffer.MatricesIndicesKind),
  102911. j.push(VertexBuffer.MatricesWeightsKind),
  102912. d.numBoneInfluencers > 4 && (j.push(VertexBuffer.MatricesIndicesExtraKind),
  102913. j.push(VertexBuffer.MatricesWeightsExtraKind)),
  102914. k.push("#define NUM_BONE_INFLUENCERS " + d.numBoneInfluencers);
  102915. var ot = d.skeleton;
  102916. ot && ot.isUsingTextureForMatrices ? k.push("#define BONETEXTURE") : k.push("#define BonesPerMesh " + (ot ? ot.bones.length + 1 : 0)),
  102917. d.numBoneInfluencers > 0 && nt.addCPUSkinningFallback(0, d)
  102918. } else
  102919. k.push("#define NUM_BONE_INFLUENCERS 0");
  102920. var at = d.morphTargetManager
  102921. , st = 0;
  102922. at && at.numInfluencers > 0 && (k.push("#define MORPHTARGETS"),
  102923. st = at.numInfluencers,
  102924. k.push("#define NUM_MORPH_INFLUENCERS " + st),
  102925. at.isUsingTextureForTargets && k.push("#define MORPHTARGETS_TEXTURE"),
  102926. MaterialHelper.PrepareAttributesForMorphTargetsInfluencers(j, d, st)),
  102927. i && (k.push("#define INSTANCES"),
  102928. MaterialHelper.PushAttributesForInstances(j),
  102929. e.getRenderingMesh().hasThinInstances && k.push("#define THIN_INSTANCES")),
  102930. this._addCustomEffectDefines(k);
  102931. var ut = e._getDrawWrapper(void 0, !0)
  102932. , ct = ut.defines
  102933. , lt = k.join(`
  102934. `);
  102935. return ct !== lt && ut.setEffect(this._engine.createEffect("glowMapGeneration", j, ["world", "mBones", "viewProjection", "glowColor", "morphTargetInfluences", "boneTextureWidth", "diffuseMatrix", "emissiveMatrix", "opacityMatrix", "opacityIntensity", "morphTargetTextureInfo", "morphTargetTextureIndices"], ["diffuseSampler", "emissiveSampler", "opacitySampler", "boneSampler", "morphTargets"], lt, nt, void 0, void 0, {
  102936. maxSimultaneousMorphTargets: st
  102937. }), lt),
  102938. ut.effect.isReady()
  102939. }
  102940. ,
  102941. a.prototype.render = function() {
  102942. for (var e = 0; e < this._postProcesses.length; e++)
  102943. if (!this._postProcesses[e].isReady())
  102944. return;
  102945. for (var i = this._scene.getEngine(), o = this._numInternalDraws(), s = !0, c = 0; c < o; ++c) {
  102946. var d = this._mergeDrawWrapper[c];
  102947. d || (d = this._mergeDrawWrapper[c] = new DrawWrapper(this._engine),
  102948. d.setEffect(this._createMergeEffect())),
  102949. s = s && d.effect.isReady()
  102950. }
  102951. if (!!s) {
  102952. this.onBeforeComposeObservable.notifyObservers(this);
  102953. for (var _ = i.getAlphaMode(), b = 0; b < o; ++b) {
  102954. var d = this._mergeDrawWrapper[b];
  102955. i.enableEffect(d),
  102956. i.setState(!1),
  102957. i.bindBuffers(this._vertexBuffers, this._indexBuffer, d.effect),
  102958. i.setAlphaMode(this._effectLayerOptions.alphaBlendingMode),
  102959. this._internalRender(d.effect, b)
  102960. }
  102961. i.setAlphaMode(_),
  102962. this.onAfterComposeObservable.notifyObservers(this);
  102963. var k = this._mainTexture.getSize();
  102964. this._setMainTextureSize(),
  102965. (k.width !== this._mainTextureDesiredSize.width || k.height !== this._mainTextureDesiredSize.height) && this._mainTextureDesiredSize.width !== 0 && this._mainTextureDesiredSize.height !== 0 && (this.onSizeChangedObservable.notifyObservers(this),
  102966. this._disposeTextureAndPostProcesses(),
  102967. this._createMainTexture(),
  102968. this._createTextureAndPostProcesses())
  102969. }
  102970. }
  102971. ,
  102972. a.prototype.hasMesh = function(e) {
  102973. return this.renderingGroupId === -1 || e.renderingGroupId === this.renderingGroupId
  102974. }
  102975. ,
  102976. a.prototype.shouldRender = function() {
  102977. return this.isEnabled && this._shouldRender
  102978. }
  102979. ,
  102980. a.prototype._shouldRenderMesh = function(e) {
  102981. return !0
  102982. }
  102983. ,
  102984. a.prototype._canRenderMesh = function(e, i) {
  102985. return !i.needAlphaBlendingForMesh(e)
  102986. }
  102987. ,
  102988. a.prototype._shouldRenderEmissiveTextureForMesh = function() {
  102989. return !0
  102990. }
  102991. ,
  102992. a.prototype._renderSubMesh = function(e, i) {
  102993. var o, s;
  102994. if (i === void 0 && (i = !1),
  102995. !!this.shouldRender()) {
  102996. var c = e.getMaterial()
  102997. , d = e.getMesh()
  102998. , _ = e.getReplacementMesh()
  102999. , b = e.getRenderingMesh()
  103000. , k = e.getEffectiveMesh()
  103001. , j = this._scene
  103002. , $ = j.getEngine();
  103003. if (k._internalAbstractMeshDataInfo._isActiveIntermediate = !1,
  103004. !!c && !!this._canRenderMesh(b, c)) {
  103005. var _e = (o = b.overrideMaterialSideOrientation) !== null && o !== void 0 ? o : c.sideOrientation
  103006. , et = b._getWorldMatrixDeterminant();
  103007. et < 0 && (_e = _e === Material.ClockWiseSideOrientation ? Material.CounterClockWiseSideOrientation : Material.ClockWiseSideOrientation);
  103008. var tt = _e === Material.ClockWiseSideOrientation;
  103009. $.setState(c.backFaceCulling, c.zOffset, void 0, tt, c.cullBackFaces, void 0, c.zOffsetUnits);
  103010. var rt = b._getInstancesRenderList(e._id, !!_);
  103011. if (!rt.mustReturn && !!this._shouldRenderMesh(b)) {
  103012. var it = rt.hardwareInstancedRendering[e._id] || b.hasThinInstances;
  103013. if (this._setEmissiveTextureAndColor(b, e, c),
  103014. this.onBeforeRenderMeshToEffect.notifyObservers(d),
  103015. this._useMeshMaterial(b))
  103016. b.render(e, it, _ || void 0);
  103017. else if (this._isReady(e, it, this._emissiveTextureAndColor.texture)) {
  103018. var nt = (s = k._internalAbstractMeshDataInfo._materialForRenderPass) === null || s === void 0 ? void 0 : s[$.currentRenderPassId]
  103019. , ot = e._getDrawWrapper();
  103020. if (!ot && nt && (ot = nt._getDrawWrapper()),
  103021. !ot)
  103022. return;
  103023. var at = ot.effect;
  103024. if ($.enableEffect(ot),
  103025. !it) {
  103026. var st = j.forcePointsCloud ? Material.PointFillMode : j.forceWireframe ? Material.WireFrameFillMode : c.fillMode;
  103027. b._bind(e, at, st)
  103028. }
  103029. if (nt ? nt.bindForSubMesh(k.getWorldMatrix(), k, e) : (at.setMatrix("viewProjection", j.getTransformMatrix()),
  103030. at.setMatrix("world", k.getWorldMatrix()),
  103031. at.setFloat4("glowColor", this._emissiveTextureAndColor.color.r, this._emissiveTextureAndColor.color.g, this._emissiveTextureAndColor.color.b, this._emissiveTextureAndColor.color.a)),
  103032. !nt) {
  103033. var ut = c.needAlphaTesting()
  103034. , ct = c.getAlphaTestTexture()
  103035. , lt = ct && ct.hasAlpha && (c.useAlphaFromDiffuseTexture || c._useAlphaFromAlbedoTexture);
  103036. if (ct && (ut || lt)) {
  103037. at.setTexture("diffuseSampler", ct);
  103038. var ft = ct.getTextureMatrix();
  103039. ft && at.setMatrix("diffuseMatrix", ft)
  103040. }
  103041. var ht = c.opacityTexture;
  103042. if (ht) {
  103043. at.setTexture("opacitySampler", ht),
  103044. at.setFloat("opacityIntensity", ht.level);
  103045. var ft = ht.getTextureMatrix();
  103046. ft && at.setMatrix("opacityMatrix", ft)
  103047. }
  103048. if (this._emissiveTextureAndColor.texture && (at.setTexture("emissiveSampler", this._emissiveTextureAndColor.texture),
  103049. at.setMatrix("emissiveMatrix", this._emissiveTextureAndColor.texture.getTextureMatrix())),
  103050. b.useBones && b.computeBonesUsingShaders && b.skeleton) {
  103051. var pt = b.skeleton;
  103052. if (pt.isUsingTextureForMatrices) {
  103053. var dt = pt.getTransformMatrixTexture(b);
  103054. if (!dt)
  103055. return;
  103056. at.setTexture("boneSampler", dt),
  103057. at.setFloat("boneTextureWidth", 4 * (pt.bones.length + 1))
  103058. } else
  103059. at.setMatrices("mBones", pt.getTransformMatrices(b))
  103060. }
  103061. MaterialHelper.BindMorphTargetParameters(b, at),
  103062. b.morphTargetManager && b.morphTargetManager.isUsingTextureForTargets && b.morphTargetManager._bind(at),
  103063. i && $.setAlphaMode(c.alphaMode)
  103064. }
  103065. b._processRendering(k, e, at, c.fillMode, rt, it, function(_t, mt) {
  103066. return at.setMatrix("world", mt)
  103067. })
  103068. } else
  103069. this._mainTexture.resetRefreshCounter();
  103070. this.onAfterRenderMeshToEffect.notifyObservers(d)
  103071. }
  103072. }
  103073. }
  103074. }
  103075. ,
  103076. a.prototype._useMeshMaterial = function(e) {
  103077. return !1
  103078. }
  103079. ,
  103080. a.prototype._rebuild = function() {
  103081. var e = this._vertexBuffers[VertexBuffer.PositionKind];
  103082. e && e._rebuild(),
  103083. this._generateIndexBuffer()
  103084. }
  103085. ,
  103086. a.prototype._disposeTextureAndPostProcesses = function() {
  103087. this._mainTexture.dispose();
  103088. for (var e = 0; e < this._postProcesses.length; e++)
  103089. this._postProcesses[e] && this._postProcesses[e].dispose();
  103090. this._postProcesses = [];
  103091. for (var e = 0; e < this._textures.length; e++)
  103092. this._textures[e] && this._textures[e].dispose();
  103093. this._textures = []
  103094. }
  103095. ,
  103096. a.prototype.dispose = function() {
  103097. var e = this._vertexBuffers[VertexBuffer.PositionKind];
  103098. e && (e.dispose(),
  103099. this._vertexBuffers[VertexBuffer.PositionKind] = null),
  103100. this._indexBuffer && (this._scene.getEngine()._releaseBuffer(this._indexBuffer),
  103101. this._indexBuffer = null);
  103102. for (var i = 0, o = this._mergeDrawWrapper; i < o.length; i++) {
  103103. var s = o[i];
  103104. s.dispose()
  103105. }
  103106. this._mergeDrawWrapper = [],
  103107. this._disposeTextureAndPostProcesses();
  103108. var c = this._scene.effectLayers.indexOf(this, 0);
  103109. c > -1 && this._scene.effectLayers.splice(c, 1),
  103110. this.onDisposeObservable.notifyObservers(this),
  103111. this.onDisposeObservable.clear(),
  103112. this.onBeforeRenderMainTextureObservable.clear(),
  103113. this.onBeforeComposeObservable.clear(),
  103114. this.onBeforeRenderMeshToEffect.clear(),
  103115. this.onAfterRenderMeshToEffect.clear(),
  103116. this.onAfterComposeObservable.clear(),
  103117. this.onSizeChangedObservable.clear()
  103118. }
  103119. ,
  103120. a.prototype.getClassName = function() {
  103121. return "EffectLayer"
  103122. }
  103123. ,
  103124. a.Parse = function(e, i, o) {
  103125. var s = Tools.Instantiate(e.customType);
  103126. return s.Parse(e, i, o)
  103127. }
  103128. ,
  103129. a._SceneComponentInitialization = function(e) {
  103130. throw _WarnImport("EffectLayerSceneComponent")
  103131. }
  103132. ,
  103133. __decorate([serialize()], a.prototype, "name", void 0),
  103134. __decorate([serializeAsColor4()], a.prototype, "neutralColor", void 0),
  103135. __decorate([serialize()], a.prototype, "isEnabled", void 0),
  103136. __decorate([serializeAsCameraReference()], a.prototype, "camera", null),
  103137. __decorate([serialize()], a.prototype, "renderingGroupId", null),
  103138. __decorate([serialize()], a.prototype, "disableBoundingBoxesFromEffectLayer", void 0),
  103139. a
  103140. }()
  103141. , name$B = "glowMapMergePixelShader"
  103142. , shader$B = `
  103143. varying vec2 vUV;
  103144. uniform sampler2D textureSampler;
  103145. #ifdef EMISSIVE
  103146. uniform sampler2D textureSampler2;
  103147. #endif
  103148. uniform float offset;
  103149. void main(void) {
  103150. vec4 baseColor=texture2D(textureSampler,vUV);
  103151. #ifdef EMISSIVE
  103152. baseColor+=texture2D(textureSampler2,vUV);
  103153. baseColor*=offset;
  103154. #else
  103155. baseColor.a=abs(offset-baseColor.a);
  103156. #ifdef STROKE
  103157. float alpha=smoothstep(.0,.1,baseColor.a);
  103158. baseColor.a=alpha;
  103159. baseColor.rgb=baseColor.rgb*alpha;
  103160. #endif
  103161. #endif
  103162. #if LDR
  103163. baseColor=clamp(baseColor,0.,1.0);
  103164. #endif
  103165. gl_FragColor=baseColor;
  103166. }`;
  103167. ShaderStore.ShadersStore[name$B] = shader$B;
  103168. var name$A = "glowMapMergeVertexShader"
  103169. , shader$A = `
  103170. attribute vec2 position;
  103171. varying vec2 vUV;
  103172. const vec2 madd=vec2(0.5,0.5);
  103173. void main(void) {
  103174. vUV=position*madd+madd;
  103175. gl_Position=vec4(position,0.0,1.0);
  103176. }`;
  103177. ShaderStore.ShadersStore[name$A] = shader$A;
  103178. AbstractScene.AddParser(SceneComponentConstants.NAME_EFFECTLAYER, function(a, e, i, o) {
  103179. if (a.effectLayers) {
  103180. i.effectLayers || (i.effectLayers = new Array);
  103181. for (var s = 0; s < a.effectLayers.length; s++) {
  103182. var c = EffectLayer.Parse(a.effectLayers[s], e, o);
  103183. i.effectLayers.push(c)
  103184. }
  103185. }
  103186. });
  103187. AbstractScene.prototype.removeEffectLayer = function(a) {
  103188. var e = this.effectLayers.indexOf(a);
  103189. return e !== -1 && this.effectLayers.splice(e, 1),
  103190. e
  103191. }
  103192. ;
  103193. AbstractScene.prototype.addEffectLayer = function(a) {
  103194. this.effectLayers.push(a)
  103195. }
  103196. ;
  103197. var EffectLayerSceneComponent = function() {
  103198. function a(e) {
  103199. this.name = SceneComponentConstants.NAME_EFFECTLAYER,
  103200. this._renderEffects = !1,
  103201. this._needStencil = !1,
  103202. this._previousStencilState = !1,
  103203. this.scene = e,
  103204. this._engine = e.getEngine(),
  103205. e.effectLayers = new Array
  103206. }
  103207. return a.prototype.register = function() {
  103208. this.scene._isReadyForMeshStage.registerStep(SceneComponentConstants.STEP_ISREADYFORMESH_EFFECTLAYER, this, this._isReadyForMesh),
  103209. this.scene._cameraDrawRenderTargetStage.registerStep(SceneComponentConstants.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER, this, this._renderMainTexture),
  103210. this.scene._beforeCameraDrawStage.registerStep(SceneComponentConstants.STEP_BEFORECAMERADRAW_EFFECTLAYER, this, this._setStencil),
  103211. this.scene._afterRenderingGroupDrawStage.registerStep(SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW, this, this._drawRenderingGroup),
  103212. this.scene._afterCameraDrawStage.registerStep(SceneComponentConstants.STEP_AFTERCAMERADRAW_EFFECTLAYER, this, this._setStencilBack),
  103213. this.scene._afterCameraDrawStage.registerStep(SceneComponentConstants.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW, this, this._drawCamera)
  103214. }
  103215. ,
  103216. a.prototype.rebuild = function() {
  103217. for (var e = this.scene.effectLayers, i = 0, o = e; i < o.length; i++) {
  103218. var s = o[i];
  103219. s._rebuild()
  103220. }
  103221. }
  103222. ,
  103223. a.prototype.serialize = function(e) {
  103224. e.effectLayers = [];
  103225. for (var i = this.scene.effectLayers, o = 0, s = i; o < s.length; o++) {
  103226. var c = s[o];
  103227. c.serialize && e.effectLayers.push(c.serialize())
  103228. }
  103229. }
  103230. ,
  103231. a.prototype.addFromContainer = function(e) {
  103232. var i = this;
  103233. !e.effectLayers || e.effectLayers.forEach(function(o) {
  103234. i.scene.addEffectLayer(o)
  103235. })
  103236. }
  103237. ,
  103238. a.prototype.removeFromContainer = function(e, i) {
  103239. var o = this;
  103240. !e.effectLayers || e.effectLayers.forEach(function(s) {
  103241. o.scene.removeEffectLayer(s),
  103242. i && s.dispose()
  103243. })
  103244. }
  103245. ,
  103246. a.prototype.dispose = function() {
  103247. for (var e = this.scene.effectLayers; e.length; )
  103248. e[0].dispose()
  103249. }
  103250. ,
  103251. a.prototype._isReadyForMesh = function(e, i) {
  103252. for (var o = this._engine.currentRenderPassId, s = this.scene.effectLayers, c = 0, d = s; c < d.length; c++) {
  103253. var _ = d[c];
  103254. if (!!_.hasMesh(e)) {
  103255. var b = _._mainTexture;
  103256. this._engine.currentRenderPassId = b.renderPassId;
  103257. for (var k = 0, j = e.subMeshes; k < j.length; k++) {
  103258. var $ = j[k];
  103259. if (!_.isReady($, i))
  103260. return this._engine.currentRenderPassId = o,
  103261. !1
  103262. }
  103263. }
  103264. }
  103265. return this._engine.currentRenderPassId = o,
  103266. !0
  103267. }
  103268. ,
  103269. a.prototype._renderMainTexture = function(e) {
  103270. this._renderEffects = !1,
  103271. this._needStencil = !1;
  103272. var i = !1
  103273. , o = this.scene.effectLayers;
  103274. if (o && o.length > 0) {
  103275. this._previousStencilState = this._engine.getStencilBuffer();
  103276. for (var s = 0, c = o; s < c.length; s++) {
  103277. var d = c[s];
  103278. if (d.shouldRender() && (!d.camera || d.camera.cameraRigMode === Camera$1.RIG_MODE_NONE && e === d.camera || d.camera.cameraRigMode !== Camera$1.RIG_MODE_NONE && d.camera._rigCameras.indexOf(e) > -1)) {
  103279. this._renderEffects = !0,
  103280. this._needStencil = this._needStencil || d.needStencil();
  103281. var _ = d._mainTexture;
  103282. _._shouldRender() && (this.scene.incrementRenderId(),
  103283. _.render(!1, !1),
  103284. i = !0)
  103285. }
  103286. }
  103287. this.scene.incrementRenderId()
  103288. }
  103289. return i
  103290. }
  103291. ,
  103292. a.prototype._setStencil = function() {
  103293. this._needStencil && this._engine.setStencilBuffer(!0)
  103294. }
  103295. ,
  103296. a.prototype._setStencilBack = function() {
  103297. this._needStencil && this._engine.setStencilBuffer(this._previousStencilState)
  103298. }
  103299. ,
  103300. a.prototype._draw = function(e) {
  103301. if (this._renderEffects) {
  103302. this._engine.setDepthBuffer(!1);
  103303. for (var i = this.scene.effectLayers, o = 0; o < i.length; o++) {
  103304. var s = i[o];
  103305. s.renderingGroupId === e && s.shouldRender() && s.render()
  103306. }
  103307. this._engine.setDepthBuffer(!0)
  103308. }
  103309. }
  103310. ,
  103311. a.prototype._drawCamera = function() {
  103312. this._renderEffects && this._draw(-1)
  103313. }
  103314. ,
  103315. a.prototype._drawRenderingGroup = function(e) {
  103316. !this.scene._isInIntermediateRendering() && this._renderEffects && this._draw(e)
  103317. }
  103318. ,
  103319. a
  103320. }();
  103321. EffectLayer._SceneComponentInitialization = function(a) {
  103322. var e = a._getComponent(SceneComponentConstants.NAME_EFFECTLAYER);
  103323. e || (e = new EffectLayerSceneComponent(a),
  103324. a._addComponent(e))
  103325. }
  103326. ;
  103327. AbstractScene.prototype.getGlowLayerByName = function(a) {
  103328. for (var e = 0; e < this.effectLayers.length; e++)
  103329. if (this.effectLayers[e].name === a && this.effectLayers[e].getEffectName() === GlowLayer.EffectName)
  103330. return this.effectLayers[e];
  103331. return null
  103332. }
  103333. ;
  103334. var GlowLayer = function(a) {
  103335. __extends(e, a);
  103336. function e(i, o, s) {
  103337. var c = a.call(this, i, o) || this;
  103338. return c._intensity = 1,
  103339. c._includedOnlyMeshes = [],
  103340. c._excludedMeshes = [],
  103341. c._meshesUsingTheirOwnMaterials = [],
  103342. c.neutralColor = new Color4(0,0,0,1),
  103343. c._options = __assign({
  103344. mainTextureRatio: e.DefaultTextureRatio,
  103345. blurKernelSize: 32,
  103346. mainTextureFixedSize: void 0,
  103347. camera: null,
  103348. mainTextureSamples: 1,
  103349. renderingGroupId: -1,
  103350. ldrMerge: !1,
  103351. alphaBlendingMode: 1
  103352. }, s),
  103353. c._init({
  103354. alphaBlendingMode: c._options.alphaBlendingMode,
  103355. camera: c._options.camera,
  103356. mainTextureFixedSize: c._options.mainTextureFixedSize,
  103357. mainTextureRatio: c._options.mainTextureRatio,
  103358. renderingGroupId: c._options.renderingGroupId
  103359. }),
  103360. c
  103361. }
  103362. return Object.defineProperty(e.prototype, "blurKernelSize", {
  103363. get: function() {
  103364. return this._horizontalBlurPostprocess1.kernel
  103365. },
  103366. set: function(i) {
  103367. this._horizontalBlurPostprocess1.kernel = i,
  103368. this._verticalBlurPostprocess1.kernel = i,
  103369. this._horizontalBlurPostprocess2.kernel = i,
  103370. this._verticalBlurPostprocess2.kernel = i
  103371. },
  103372. enumerable: !1,
  103373. configurable: !0
  103374. }),
  103375. Object.defineProperty(e.prototype, "intensity", {
  103376. get: function() {
  103377. return this._intensity
  103378. },
  103379. set: function(i) {
  103380. this._intensity = i
  103381. },
  103382. enumerable: !1,
  103383. configurable: !0
  103384. }),
  103385. e.prototype.getEffectName = function() {
  103386. return e.EffectName
  103387. }
  103388. ,
  103389. e.prototype._createMergeEffect = function() {
  103390. var i = `#define EMISSIVE
  103391. `;
  103392. return this._options.ldrMerge && (i += `#define LDR
  103393. `),
  103394. this._engine.createEffect("glowMapMerge", [VertexBuffer.PositionKind], ["offset"], ["textureSampler", "textureSampler2"], i)
  103395. }
  103396. ,
  103397. e.prototype._createTextureAndPostProcesses = function() {
  103398. var i = this
  103399. , o = this._mainTextureDesiredSize.width
  103400. , s = this._mainTextureDesiredSize.height;
  103401. o = this._engine.needPOTTextures ? Engine.GetExponentOfTwo(o, this._maxSize) : o,
  103402. s = this._engine.needPOTTextures ? Engine.GetExponentOfTwo(s, this._maxSize) : s;
  103403. var c = 0;
  103404. this._engine.getCaps().textureHalfFloatRender ? c = 2 : c = 0,
  103405. this._blurTexture1 = new RenderTargetTexture("GlowLayerBlurRTT",{
  103406. width: o,
  103407. height: s
  103408. },this._scene,!1,!0,c),
  103409. this._blurTexture1.wrapU = Texture.CLAMP_ADDRESSMODE,
  103410. this._blurTexture1.wrapV = Texture.CLAMP_ADDRESSMODE,
  103411. this._blurTexture1.updateSamplingMode(Texture.BILINEAR_SAMPLINGMODE),
  103412. this._blurTexture1.renderParticles = !1,
  103413. this._blurTexture1.ignoreCameraViewport = !0;
  103414. var d = Math.floor(o / 2)
  103415. , _ = Math.floor(s / 2);
  103416. this._blurTexture2 = new RenderTargetTexture("GlowLayerBlurRTT2",{
  103417. width: d,
  103418. height: _
  103419. },this._scene,!1,!0,c),
  103420. this._blurTexture2.wrapU = Texture.CLAMP_ADDRESSMODE,
  103421. this._blurTexture2.wrapV = Texture.CLAMP_ADDRESSMODE,
  103422. this._blurTexture2.updateSamplingMode(Texture.BILINEAR_SAMPLINGMODE),
  103423. this._blurTexture2.renderParticles = !1,
  103424. this._blurTexture2.ignoreCameraViewport = !0,
  103425. this._textures = [this._blurTexture1, this._blurTexture2],
  103426. this._horizontalBlurPostprocess1 = new BlurPostProcess("GlowLayerHBP1",new Vector2(1,0),this._options.blurKernelSize / 2,{
  103427. width: o,
  103428. height: s
  103429. },null,Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,c),
  103430. this._horizontalBlurPostprocess1.width = o,
  103431. this._horizontalBlurPostprocess1.height = s,
  103432. this._horizontalBlurPostprocess1.externalTextureSamplerBinding = !0,
  103433. this._horizontalBlurPostprocess1.onApplyObservable.add(function(b) {
  103434. b.setTexture("textureSampler", i._mainTexture)
  103435. }),
  103436. this._verticalBlurPostprocess1 = new BlurPostProcess("GlowLayerVBP1",new Vector2(0,1),this._options.blurKernelSize / 2,{
  103437. width: o,
  103438. height: s
  103439. },null,Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,c),
  103440. this._horizontalBlurPostprocess2 = new BlurPostProcess("GlowLayerHBP2",new Vector2(1,0),this._options.blurKernelSize / 2,{
  103441. width: d,
  103442. height: _
  103443. },null,Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,c),
  103444. this._horizontalBlurPostprocess2.width = d,
  103445. this._horizontalBlurPostprocess2.height = _,
  103446. this._horizontalBlurPostprocess2.externalTextureSamplerBinding = !0,
  103447. this._horizontalBlurPostprocess2.onApplyObservable.add(function(b) {
  103448. b.setTexture("textureSampler", i._blurTexture1)
  103449. }),
  103450. this._verticalBlurPostprocess2 = new BlurPostProcess("GlowLayerVBP2",new Vector2(0,1),this._options.blurKernelSize / 2,{
  103451. width: d,
  103452. height: _
  103453. },null,Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,c),
  103454. this._postProcesses = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1, this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2],
  103455. this._postProcesses1 = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1],
  103456. this._postProcesses2 = [this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2],
  103457. this._mainTexture.samples = this._options.mainTextureSamples,
  103458. this._mainTexture.onAfterUnbindObservable.add(function() {
  103459. var b = i._blurTexture1.renderTarget;
  103460. if (b) {
  103461. i._scene.postProcessManager.directRender(i._postProcesses1, b, !0);
  103462. var k = i._blurTexture2.renderTarget;
  103463. k && i._scene.postProcessManager.directRender(i._postProcesses2, k, !0),
  103464. i._engine.unBindFramebuffer(k != null ? k : b, !0)
  103465. }
  103466. }),
  103467. this._postProcesses.map(function(b) {
  103468. b.autoClear = !1
  103469. })
  103470. }
  103471. ,
  103472. e.prototype.isReady = function(i, o) {
  103473. var s = i.getMaterial()
  103474. , c = i.getRenderingMesh();
  103475. if (!s || !c)
  103476. return !1;
  103477. var d = s.emissiveTexture;
  103478. return a.prototype._isReady.call(this, i, o, d)
  103479. }
  103480. ,
  103481. e.prototype.needStencil = function() {
  103482. return !1
  103483. }
  103484. ,
  103485. e.prototype._canRenderMesh = function(i, o) {
  103486. return !0
  103487. }
  103488. ,
  103489. e.prototype._internalRender = function(i) {
  103490. i.setTexture("textureSampler", this._blurTexture1),
  103491. i.setTexture("textureSampler2", this._blurTexture2),
  103492. i.setFloat("offset", this._intensity);
  103493. var o = this._engine
  103494. , s = o.getStencilBuffer();
  103495. o.setStencilBuffer(!1),
  103496. o.drawElementsType(Material.TriangleFillMode, 0, 6),
  103497. o.setStencilBuffer(s)
  103498. }
  103499. ,
  103500. e.prototype._setEmissiveTextureAndColor = function(i, o, s) {
  103501. var c, d = 1;
  103502. if (this.customEmissiveTextureSelector ? this._emissiveTextureAndColor.texture = this.customEmissiveTextureSelector(i, o, s) : s ? (this._emissiveTextureAndColor.texture = s.emissiveTexture,
  103503. this._emissiveTextureAndColor.texture && (d = this._emissiveTextureAndColor.texture.level)) : this._emissiveTextureAndColor.texture = null,
  103504. this.customEmissiveColorSelector)
  103505. this.customEmissiveColorSelector(i, o, s, this._emissiveTextureAndColor.color);
  103506. else if (s.emissiveColor) {
  103507. var _ = (c = s.emissiveIntensity) !== null && c !== void 0 ? c : 1;
  103508. d *= _,
  103509. this._emissiveTextureAndColor.color.set(s.emissiveColor.r * d, s.emissiveColor.g * d, s.emissiveColor.b * d, s.alpha)
  103510. } else
  103511. this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a)
  103512. }
  103513. ,
  103514. e.prototype._shouldRenderMesh = function(i) {
  103515. return this.hasMesh(i)
  103516. }
  103517. ,
  103518. e.prototype._addCustomEffectDefines = function(i) {
  103519. i.push("#define GLOW")
  103520. }
  103521. ,
  103522. e.prototype.addExcludedMesh = function(i) {
  103523. this._excludedMeshes.indexOf(i.uniqueId) === -1 && this._excludedMeshes.push(i.uniqueId)
  103524. }
  103525. ,
  103526. e.prototype.removeExcludedMesh = function(i) {
  103527. var o = this._excludedMeshes.indexOf(i.uniqueId);
  103528. o !== -1 && this._excludedMeshes.splice(o, 1)
  103529. }
  103530. ,
  103531. e.prototype.addIncludedOnlyMesh = function(i) {
  103532. this._includedOnlyMeshes.indexOf(i.uniqueId) === -1 && this._includedOnlyMeshes.push(i.uniqueId)
  103533. }
  103534. ,
  103535. e.prototype.removeIncludedOnlyMesh = function(i) {
  103536. var o = this._includedOnlyMeshes.indexOf(i.uniqueId);
  103537. o !== -1 && this._includedOnlyMeshes.splice(o, 1)
  103538. }
  103539. ,
  103540. e.prototype.hasMesh = function(i) {
  103541. return a.prototype.hasMesh.call(this, i) ? this._includedOnlyMeshes.length ? this._includedOnlyMeshes.indexOf(i.uniqueId) !== -1 : this._excludedMeshes.length ? this._excludedMeshes.indexOf(i.uniqueId) === -1 : !0 : !1
  103542. }
  103543. ,
  103544. e.prototype._useMeshMaterial = function(i) {
  103545. return this._meshesUsingTheirOwnMaterials.length == 0 ? !1 : this._meshesUsingTheirOwnMaterials.indexOf(i.uniqueId) > -1
  103546. }
  103547. ,
  103548. e.prototype.referenceMeshToUseItsOwnMaterial = function(i) {
  103549. var o = this;
  103550. this._meshesUsingTheirOwnMaterials.push(i.uniqueId),
  103551. i.onDisposeObservable.add(function() {
  103552. o._disposeMesh(i)
  103553. })
  103554. }
  103555. ,
  103556. e.prototype.unReferenceMeshFromUsingItsOwnMaterial = function(i) {
  103557. for (var o = this._meshesUsingTheirOwnMaterials.indexOf(i.uniqueId); o >= 0; )
  103558. this._meshesUsingTheirOwnMaterials.splice(o, 1),
  103559. o = this._meshesUsingTheirOwnMaterials.indexOf(i.uniqueId)
  103560. }
  103561. ,
  103562. e.prototype._disposeMesh = function(i) {
  103563. this.removeIncludedOnlyMesh(i),
  103564. this.removeExcludedMesh(i)
  103565. }
  103566. ,
  103567. e.prototype.getClassName = function() {
  103568. return "GlowLayer"
  103569. }
  103570. ,
  103571. e.prototype.serialize = function() {
  103572. var i = SerializationHelper.Serialize(this);
  103573. i.customType = "BABYLON.GlowLayer";
  103574. var o;
  103575. if (i.includedMeshes = [],
  103576. this._includedOnlyMeshes.length)
  103577. for (o = 0; o < this._includedOnlyMeshes.length; o++) {
  103578. var s = this._scene.getMeshByUniqueId(this._includedOnlyMeshes[o]);
  103579. s && i.includedMeshes.push(s.id)
  103580. }
  103581. if (i.excludedMeshes = [],
  103582. this._excludedMeshes.length)
  103583. for (o = 0; o < this._excludedMeshes.length; o++) {
  103584. var s = this._scene.getMeshByUniqueId(this._excludedMeshes[o]);
  103585. s && i.excludedMeshes.push(s.id)
  103586. }
  103587. return i
  103588. }
  103589. ,
  103590. e.Parse = function(i, o, s) {
  103591. var c = SerializationHelper.Parse(function() {
  103592. return new e(i.name,o,i.options)
  103593. }, i, o, s), d;
  103594. for (d = 0; d < i.excludedMeshes.length; d++) {
  103595. var _ = o.getMeshById(i.excludedMeshes[d]);
  103596. _ && c.addExcludedMesh(_)
  103597. }
  103598. for (d = 0; d < i.includedMeshes.length; d++) {
  103599. var _ = o.getMeshById(i.includedMeshes[d]);
  103600. _ && c.addIncludedOnlyMesh(_)
  103601. }
  103602. return c
  103603. }
  103604. ,
  103605. e.EffectName = "GlowLayer",
  103606. e.DefaultBlurKernelSize = 32,
  103607. e.DefaultTextureRatio = .5,
  103608. __decorate([serialize()], e.prototype, "blurKernelSize", null),
  103609. __decorate([serialize()], e.prototype, "intensity", null),
  103610. __decorate([serialize("options")], e.prototype, "_options", void 0),
  103611. e
  103612. }(EffectLayer);
  103613. RegisterClass("BABYLON.GlowLayer", GlowLayer);
  103614. var name$z = "glowBlurPostProcessPixelShader"
  103615. , shader$z = `
  103616. varying vec2 vUV;
  103617. uniform sampler2D textureSampler;
  103618. uniform vec2 screenSize;
  103619. uniform vec2 direction;
  103620. uniform float blurWidth;
  103621. float getLuminance(vec3 color)
  103622. {
  103623. return dot(color,vec3(0.2126,0.7152,0.0722));
  103624. }
  103625. void main(void)
  103626. {
  103627. float weights[7];
  103628. weights[0]=0.05;
  103629. weights[1]=0.1;
  103630. weights[2]=0.2;
  103631. weights[3]=0.3;
  103632. weights[4]=0.2;
  103633. weights[5]=0.1;
  103634. weights[6]=0.05;
  103635. vec2 texelSize=vec2(1.0/screenSize.x,1.0/screenSize.y);
  103636. vec2 texelStep=texelSize*direction*blurWidth;
  103637. vec2 start=vUV-3.0*texelStep;
  103638. vec4 baseColor=vec4(0.,0.,0.,0.);
  103639. vec2 texelOffset=vec2(0.,0.);
  103640. for (int i=0; i<7; i++)
  103641. {
  103642. vec4 texel=texture2D(textureSampler,start+texelOffset);
  103643. baseColor.a+=texel.a*weights[i];
  103644. float luminance=getLuminance(baseColor.rgb);
  103645. float luminanceTexel=getLuminance(texel.rgb);
  103646. float choice=step(luminanceTexel,luminance);
  103647. baseColor.rgb=choice*baseColor.rgb+(1.0-choice)*texel.rgb;
  103648. texelOffset+=texelStep;
  103649. }
  103650. gl_FragColor=baseColor;
  103651. }`;
  103652. ShaderStore.ShadersStore[name$z] = shader$z;
  103653. AbstractScene.prototype.getHighlightLayerByName = function(a) {
  103654. for (var e = 0; e < this.effectLayers.length; e++)
  103655. if (this.effectLayers[e].name === a && this.effectLayers[e].getEffectName() === HighlightLayer.EffectName)
  103656. return this.effectLayers[e];
  103657. return null
  103658. }
  103659. ;
  103660. var GlowBlurPostProcess = function(a) {
  103661. __extends(e, a);
  103662. function e(i, o, s, c, d, _, b, k) {
  103663. _ === void 0 && (_ = Texture.BILINEAR_SAMPLINGMODE);
  103664. var j = a.call(this, i, "glowBlurPostProcess", ["screenSize", "direction", "blurWidth"], null, c, d, _, b, k) || this;
  103665. return j.direction = o,
  103666. j.kernel = s,
  103667. j.onApplyObservable.add(function($) {
  103668. $.setFloat2("screenSize", j.width, j.height),
  103669. $.setVector2("direction", j.direction),
  103670. $.setFloat("blurWidth", j.kernel)
  103671. }),
  103672. j
  103673. }
  103674. return e
  103675. }(PostProcess)
  103676. , HighlightLayer = function(a) {
  103677. __extends(e, a);
  103678. function e(i, o, s) {
  103679. var c = a.call(this, i, o) || this;
  103680. return c.name = i,
  103681. c.innerGlow = !0,
  103682. c.outerGlow = !0,
  103683. c.onBeforeBlurObservable = new Observable,
  103684. c.onAfterBlurObservable = new Observable,
  103685. c._instanceGlowingMeshStencilReference = e.GlowingMeshStencilReference++,
  103686. c._meshes = {},
  103687. c._excludedMeshes = {},
  103688. c.neutralColor = e.NeutralColor,
  103689. c._engine.isStencilEnable || Logger$2.Warn("Rendering the Highlight Layer requires the stencil to be active on the canvas. var engine = new Engine(canvas, antialias, { stencil: true }"),
  103690. c._options = __assign({
  103691. mainTextureRatio: .5,
  103692. blurTextureSizeRatio: .5,
  103693. blurHorizontalSize: 1,
  103694. blurVerticalSize: 1,
  103695. alphaBlendingMode: 2,
  103696. camera: null,
  103697. renderingGroupId: -1
  103698. }, s),
  103699. c._init({
  103700. alphaBlendingMode: c._options.alphaBlendingMode,
  103701. camera: c._options.camera,
  103702. mainTextureFixedSize: c._options.mainTextureFixedSize,
  103703. mainTextureRatio: c._options.mainTextureRatio,
  103704. renderingGroupId: c._options.renderingGroupId
  103705. }),
  103706. c._shouldRender = !1,
  103707. c
  103708. }
  103709. return Object.defineProperty(e.prototype, "blurHorizontalSize", {
  103710. get: function() {
  103711. return this._horizontalBlurPostprocess.kernel
  103712. },
  103713. set: function(i) {
  103714. this._horizontalBlurPostprocess.kernel = i
  103715. },
  103716. enumerable: !1,
  103717. configurable: !0
  103718. }),
  103719. Object.defineProperty(e.prototype, "blurVerticalSize", {
  103720. get: function() {
  103721. return this._verticalBlurPostprocess.kernel
  103722. },
  103723. set: function(i) {
  103724. this._verticalBlurPostprocess.kernel = i
  103725. },
  103726. enumerable: !1,
  103727. configurable: !0
  103728. }),
  103729. e.prototype.getEffectName = function() {
  103730. return e.EffectName
  103731. }
  103732. ,
  103733. e.prototype._numInternalDraws = function() {
  103734. return 2
  103735. }
  103736. ,
  103737. e.prototype._createMergeEffect = function() {
  103738. return this._engine.createEffect("glowMapMerge", [VertexBuffer.PositionKind], ["offset"], ["textureSampler"], this._options.isStroke ? `#define STROKE
  103739. ` : void 0)
  103740. }
  103741. ,
  103742. e.prototype._createTextureAndPostProcesses = function() {
  103743. var i = this
  103744. , o = this._mainTextureDesiredSize.width * this._options.blurTextureSizeRatio
  103745. , s = this._mainTextureDesiredSize.height * this._options.blurTextureSizeRatio;
  103746. o = this._engine.needPOTTextures ? Engine.GetExponentOfTwo(o, this._maxSize) : o,
  103747. s = this._engine.needPOTTextures ? Engine.GetExponentOfTwo(s, this._maxSize) : s;
  103748. var c = 0;
  103749. this._engine.getCaps().textureHalfFloatRender ? c = 2 : c = 0,
  103750. this._blurTexture = new RenderTargetTexture("HighlightLayerBlurRTT",{
  103751. width: o,
  103752. height: s
  103753. },this._scene,!1,!0,c),
  103754. this._blurTexture.wrapU = Texture.CLAMP_ADDRESSMODE,
  103755. this._blurTexture.wrapV = Texture.CLAMP_ADDRESSMODE,
  103756. this._blurTexture.anisotropicFilteringLevel = 16,
  103757. this._blurTexture.updateSamplingMode(Texture.TRILINEAR_SAMPLINGMODE),
  103758. this._blurTexture.renderParticles = !1,
  103759. this._blurTexture.ignoreCameraViewport = !0,
  103760. this._textures = [this._blurTexture],
  103761. this._options.alphaBlendingMode === 2 ? (this._downSamplePostprocess = new PassPostProcess("HighlightLayerPPP",this._options.blurTextureSizeRatio,null,Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine()),
  103762. this._downSamplePostprocess.externalTextureSamplerBinding = !0,
  103763. this._downSamplePostprocess.onApplyObservable.add(function(d) {
  103764. d.setTexture("textureSampler", i._mainTexture)
  103765. }),
  103766. this._horizontalBlurPostprocess = new GlowBlurPostProcess("HighlightLayerHBP",new Vector2(1,0),this._options.blurHorizontalSize,1,null,Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine()),
  103767. this._horizontalBlurPostprocess.onApplyObservable.add(function(d) {
  103768. d.setFloat2("screenSize", o, s)
  103769. }),
  103770. this._verticalBlurPostprocess = new GlowBlurPostProcess("HighlightLayerVBP",new Vector2(0,1),this._options.blurVerticalSize,1,null,Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine()),
  103771. this._verticalBlurPostprocess.onApplyObservable.add(function(d) {
  103772. d.setFloat2("screenSize", o, s)
  103773. }),
  103774. this._postProcesses = [this._downSamplePostprocess, this._horizontalBlurPostprocess, this._verticalBlurPostprocess]) : (this._horizontalBlurPostprocess = new BlurPostProcess("HighlightLayerHBP",new Vector2(1,0),this._options.blurHorizontalSize / 2,{
  103775. width: o,
  103776. height: s
  103777. },null,Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,c),
  103778. this._horizontalBlurPostprocess.width = o,
  103779. this._horizontalBlurPostprocess.height = s,
  103780. this._horizontalBlurPostprocess.externalTextureSamplerBinding = !0,
  103781. this._horizontalBlurPostprocess.onApplyObservable.add(function(d) {
  103782. d.setTexture("textureSampler", i._mainTexture)
  103783. }),
  103784. this._verticalBlurPostprocess = new BlurPostProcess("HighlightLayerVBP",new Vector2(0,1),this._options.blurVerticalSize / 2,{
  103785. width: o,
  103786. height: s
  103787. },null,Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,c),
  103788. this._postProcesses = [this._horizontalBlurPostprocess, this._verticalBlurPostprocess]),
  103789. this._mainTexture.onAfterUnbindObservable.add(function() {
  103790. i.onBeforeBlurObservable.notifyObservers(i);
  103791. var d = i._blurTexture.renderTarget;
  103792. d && (i._scene.postProcessManager.directRender(i._postProcesses, d, !0),
  103793. i._engine.unBindFramebuffer(d, !0)),
  103794. i.onAfterBlurObservable.notifyObservers(i)
  103795. }),
  103796. this._postProcesses.map(function(d) {
  103797. d.autoClear = !1
  103798. })
  103799. }
  103800. ,
  103801. e.prototype.needStencil = function() {
  103802. return !0
  103803. }
  103804. ,
  103805. e.prototype.isReady = function(i, o) {
  103806. var s = i.getMaterial()
  103807. , c = i.getRenderingMesh();
  103808. if (!s || !c || !this._meshes)
  103809. return !1;
  103810. var d = null
  103811. , _ = this._meshes[c.uniqueId];
  103812. return _ && _.glowEmissiveOnly && s && (d = s.emissiveTexture),
  103813. a.prototype._isReady.call(this, i, o, d)
  103814. }
  103815. ,
  103816. e.prototype._internalRender = function(i, o) {
  103817. i.setTexture("textureSampler", this._blurTexture);
  103818. var s = this._engine;
  103819. s.cacheStencilState(),
  103820. s.setStencilOperationPass(7681),
  103821. s.setStencilOperationFail(7680),
  103822. s.setStencilOperationDepthFail(7680),
  103823. s.setStencilMask(0),
  103824. s.setStencilBuffer(!0),
  103825. s.setStencilFunctionReference(this._instanceGlowingMeshStencilReference),
  103826. this.outerGlow && o === 0 && (i.setFloat("offset", 0),
  103827. s.setStencilFunction(517),
  103828. s.drawElementsType(Material.TriangleFillMode, 0, 6)),
  103829. this.innerGlow && o === 1 && (i.setFloat("offset", 1),
  103830. s.setStencilFunction(514),
  103831. s.drawElementsType(Material.TriangleFillMode, 0, 6)),
  103832. s.restoreStencilState()
  103833. }
  103834. ,
  103835. e.prototype.shouldRender = function() {
  103836. return a.prototype.shouldRender.call(this) ? !!this._meshes : !1
  103837. }
  103838. ,
  103839. e.prototype._shouldRenderMesh = function(i) {
  103840. return !(this._excludedMeshes && this._excludedMeshes[i.uniqueId] || !a.prototype.hasMesh.call(this, i))
  103841. }
  103842. ,
  103843. e.prototype._canRenderMesh = function(i, o) {
  103844. return !0
  103845. }
  103846. ,
  103847. e.prototype._addCustomEffectDefines = function(i) {
  103848. i.push("#define HIGHLIGHT")
  103849. }
  103850. ,
  103851. e.prototype._setEmissiveTextureAndColor = function(i, o, s) {
  103852. var c = this._meshes[i.uniqueId];
  103853. c ? this._emissiveTextureAndColor.color.set(c.color.r, c.color.g, c.color.b, 1) : this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a),
  103854. c && c.glowEmissiveOnly && s ? (this._emissiveTextureAndColor.texture = s.emissiveTexture,
  103855. this._emissiveTextureAndColor.color.set(1, 1, 1, 1)) : this._emissiveTextureAndColor.texture = null
  103856. }
  103857. ,
  103858. e.prototype.addExcludedMesh = function(i) {
  103859. if (!!this._excludedMeshes) {
  103860. var o = this._excludedMeshes[i.uniqueId];
  103861. o || (this._excludedMeshes[i.uniqueId] = {
  103862. mesh: i,
  103863. beforeBind: i.onBeforeBindObservable.add(function(s) {
  103864. s.getEngine().setStencilBuffer(!1)
  103865. }),
  103866. afterRender: i.onAfterRenderObservable.add(function(s) {
  103867. s.getEngine().setStencilBuffer(!0)
  103868. })
  103869. })
  103870. }
  103871. }
  103872. ,
  103873. e.prototype.removeExcludedMesh = function(i) {
  103874. if (!!this._excludedMeshes) {
  103875. var o = this._excludedMeshes[i.uniqueId];
  103876. o && (o.beforeBind && i.onBeforeBindObservable.remove(o.beforeBind),
  103877. o.afterRender && i.onAfterRenderObservable.remove(o.afterRender)),
  103878. this._excludedMeshes[i.uniqueId] = null
  103879. }
  103880. }
  103881. ,
  103882. e.prototype.hasMesh = function(i) {
  103883. return !this._meshes || !a.prototype.hasMesh.call(this, i) ? !1 : this._meshes[i.uniqueId] !== void 0 && this._meshes[i.uniqueId] !== null
  103884. }
  103885. ,
  103886. e.prototype.addMesh = function(i, o, s) {
  103887. var c = this;
  103888. if (s === void 0 && (s = !1),
  103889. !!this._meshes) {
  103890. var d = this._meshes[i.uniqueId];
  103891. d ? d.color = o : (this._meshes[i.uniqueId] = {
  103892. mesh: i,
  103893. color: o,
  103894. observerHighlight: i.onBeforeBindObservable.add(function(_) {
  103895. c.isEnabled && (c._excludedMeshes && c._excludedMeshes[_.uniqueId] ? c._defaultStencilReference(_) : _.getScene().getEngine().setStencilFunctionReference(c._instanceGlowingMeshStencilReference))
  103896. }),
  103897. observerDefault: i.onAfterRenderObservable.add(function(_) {
  103898. c.isEnabled && c._defaultStencilReference(_)
  103899. }),
  103900. glowEmissiveOnly: s
  103901. },
  103902. i.onDisposeObservable.add(function() {
  103903. c._disposeMesh(i)
  103904. })),
  103905. this._shouldRender = !0
  103906. }
  103907. }
  103908. ,
  103909. e.prototype.removeMesh = function(i) {
  103910. if (!!this._meshes) {
  103911. var o = this._meshes[i.uniqueId];
  103912. o && (o.observerHighlight && i.onBeforeBindObservable.remove(o.observerHighlight),
  103913. o.observerDefault && i.onAfterRenderObservable.remove(o.observerDefault),
  103914. delete this._meshes[i.uniqueId]),
  103915. this._shouldRender = !1;
  103916. for (var s in this._meshes)
  103917. if (this._meshes[s]) {
  103918. this._shouldRender = !0;
  103919. break
  103920. }
  103921. }
  103922. }
  103923. ,
  103924. e.prototype.removeAllMeshes = function() {
  103925. if (!!this._meshes) {
  103926. for (var i in this._meshes)
  103927. if (this._meshes.hasOwnProperty(i)) {
  103928. var o = this._meshes[i];
  103929. o && this.removeMesh(o.mesh)
  103930. }
  103931. }
  103932. }
  103933. ,
  103934. e.prototype._defaultStencilReference = function(i) {
  103935. i.getScene().getEngine().setStencilFunctionReference(e.NormalMeshStencilReference)
  103936. }
  103937. ,
  103938. e.prototype._disposeMesh = function(i) {
  103939. this.removeMesh(i),
  103940. this.removeExcludedMesh(i)
  103941. }
  103942. ,
  103943. e.prototype.dispose = function() {
  103944. if (this._meshes) {
  103945. for (var i in this._meshes) {
  103946. var o = this._meshes[i];
  103947. o && o.mesh && (o.observerHighlight && o.mesh.onBeforeBindObservable.remove(o.observerHighlight),
  103948. o.observerDefault && o.mesh.onAfterRenderObservable.remove(o.observerDefault))
  103949. }
  103950. this._meshes = null
  103951. }
  103952. if (this._excludedMeshes) {
  103953. for (var i in this._excludedMeshes) {
  103954. var o = this._excludedMeshes[i];
  103955. o && (o.beforeBind && o.mesh.onBeforeBindObservable.remove(o.beforeBind),
  103956. o.afterRender && o.mesh.onAfterRenderObservable.remove(o.afterRender))
  103957. }
  103958. this._excludedMeshes = null
  103959. }
  103960. a.prototype.dispose.call(this)
  103961. }
  103962. ,
  103963. e.prototype.getClassName = function() {
  103964. return "HighlightLayer"
  103965. }
  103966. ,
  103967. e.prototype.serialize = function() {
  103968. var i = SerializationHelper.Serialize(this);
  103969. if (i.customType = "BABYLON.HighlightLayer",
  103970. i.meshes = [],
  103971. this._meshes)
  103972. for (var o in this._meshes) {
  103973. var s = this._meshes[o];
  103974. s && i.meshes.push({
  103975. glowEmissiveOnly: s.glowEmissiveOnly,
  103976. color: s.color.asArray(),
  103977. meshId: s.mesh.id
  103978. })
  103979. }
  103980. if (i.excludedMeshes = [],
  103981. this._excludedMeshes)
  103982. for (var c in this._excludedMeshes) {
  103983. var d = this._excludedMeshes[c];
  103984. d && i.excludedMeshes.push(d.mesh.id)
  103985. }
  103986. return i
  103987. }
  103988. ,
  103989. e.Parse = function(i, o, s) {
  103990. var c = SerializationHelper.Parse(function() {
  103991. return new e(i.name,o,i.options)
  103992. }, i, o, s), d;
  103993. for (d = 0; d < i.excludedMeshes.length; d++) {
  103994. var _ = o.getMeshById(i.excludedMeshes[d]);
  103995. _ && c.addExcludedMesh(_)
  103996. }
  103997. for (d = 0; d < i.meshes.length; d++) {
  103998. var b = i.meshes[d]
  103999. , _ = o.getMeshById(b.meshId);
  104000. _ && c.addMesh(_, Color3.FromArray(b.color), b.glowEmissiveOnly)
  104001. }
  104002. return c
  104003. }
  104004. ,
  104005. e.EffectName = "HighlightLayer",
  104006. e.NeutralColor = new Color4(0,0,0,0),
  104007. e.GlowingMeshStencilReference = 2,
  104008. e.NormalMeshStencilReference = 1,
  104009. __decorate([serialize()], e.prototype, "innerGlow", void 0),
  104010. __decorate([serialize()], e.prototype, "outerGlow", void 0),
  104011. __decorate([serialize()], e.prototype, "blurHorizontalSize", null),
  104012. __decorate([serialize()], e.prototype, "blurVerticalSize", null),
  104013. __decorate([serialize("options")], e.prototype, "_options", void 0),
  104014. e
  104015. }(EffectLayer);
  104016. RegisterClass("BABYLON.HighlightLayer", HighlightLayer);
  104017. var name$y = "sharpenPixelShader"
  104018. , shader$y = `
  104019. varying vec2 vUV;
  104020. uniform sampler2D textureSampler;
  104021. uniform vec2 screenSize;
  104022. uniform vec2 sharpnessAmounts;
  104023. void main(void)
  104024. {
  104025. vec2 onePixel=vec2(1.0,1.0)/screenSize;
  104026. vec4 color=texture2D(textureSampler,vUV);
  104027. vec4 edgeDetection=texture2D(textureSampler,vUV+onePixel*vec2(0,-1)) +
  104028. texture2D(textureSampler,vUV+onePixel*vec2(-1,0)) +
  104029. texture2D(textureSampler,vUV+onePixel*vec2(1,0)) +
  104030. texture2D(textureSampler,vUV+onePixel*vec2(0,1)) -
  104031. color*4.0;
  104032. gl_FragColor=max(vec4(color.rgb*sharpnessAmounts.y,color.a)-(sharpnessAmounts.x*vec4(edgeDetection.rgb,0)),0.);
  104033. }`;
  104034. ShaderStore.ShadersStore[name$y] = shader$y;
  104035. var SharpenPostProcess = function(a) {
  104036. __extends(e, a);
  104037. function e(i, o, s, c, d, _, b, k) {
  104038. b === void 0 && (b = 0),
  104039. k === void 0 && (k = !1);
  104040. var j = a.call(this, i, "sharpen", ["sharpnessAmounts", "screenSize"], null, o, s, c, d, _, null, b, void 0, null, k) || this;
  104041. return j.colorAmount = 1,
  104042. j.edgeAmount = .3,
  104043. j.onApply = function($) {
  104044. $.setFloat2("screenSize", j.width, j.height),
  104045. $.setFloat2("sharpnessAmounts", j.edgeAmount, j.colorAmount)
  104046. }
  104047. ,
  104048. j
  104049. }
  104050. return e.prototype.getClassName = function() {
  104051. return "SharpenPostProcess"
  104052. }
  104053. ,
  104054. e._Parse = function(i, o, s, c) {
  104055. return SerializationHelper.Parse(function() {
  104056. return new e(i.name,i.options,o,i.renderTargetSamplingMode,s.getEngine(),i.textureType,i.reusable)
  104057. }, i, s, c)
  104058. }
  104059. ,
  104060. __decorate([serialize()], e.prototype, "colorAmount", void 0),
  104061. __decorate([serialize()], e.prototype, "edgeAmount", void 0),
  104062. e
  104063. }(PostProcess);
  104064. RegisterClass("BABYLON.SharpenPostProcess", SharpenPostProcess);
  104065. var name$x = "imageProcessingPixelShader"
  104066. , shader$x = `
  104067. varying vec2 vUV;
  104068. uniform sampler2D textureSampler;
  104069. #include<imageProcessingDeclaration>
  104070. #include<helperFunctions>
  104071. #include<imageProcessingFunctions>
  104072. void main(void)
  104073. {
  104074. vec4 result=texture2D(textureSampler,vUV);
  104075. #ifdef IMAGEPROCESSING
  104076. #ifndef FROMLINEARSPACE
  104077. result.rgb=toLinearSpace(result.rgb);
  104078. #endif
  104079. result=applyImageProcessing(result);
  104080. #else
  104081. #ifdef FROMLINEARSPACE
  104082. result=applyImageProcessing(result);
  104083. #endif
  104084. #endif
  104085. gl_FragColor=result;
  104086. }`;
  104087. ShaderStore.ShadersStore[name$x] = shader$x;
  104088. var ImageProcessingPostProcess = function(a) {
  104089. __extends(e, a);
  104090. function e(i, o, s, c, d, _, b, k) {
  104091. s === void 0 && (s = null),
  104092. b === void 0 && (b = 0);
  104093. var j = a.call(this, i, "imageProcessing", [], [], o, s, c, d, _, null, b, "postprocess", null, !0) || this;
  104094. return j._fromLinearSpace = !0,
  104095. j._defines = {
  104096. IMAGEPROCESSING: !1,
  104097. VIGNETTE: !1,
  104098. VIGNETTEBLENDMODEMULTIPLY: !1,
  104099. VIGNETTEBLENDMODEOPAQUE: !1,
  104100. TONEMAPPING: !1,
  104101. TONEMAPPING_ACES: !1,
  104102. CONTRAST: !1,
  104103. COLORCURVES: !1,
  104104. COLORGRADING: !1,
  104105. COLORGRADING3D: !1,
  104106. FROMLINEARSPACE: !1,
  104107. SAMPLER3DGREENDEPTH: !1,
  104108. SAMPLER3DBGRMAP: !1,
  104109. IMAGEPROCESSINGPOSTPROCESS: !1,
  104110. EXPOSURE: !1,
  104111. SKIPFINALCOLORCLAMP: !1
  104112. },
  104113. k ? (k.applyByPostProcess = !0,
  104114. j._attachImageProcessingConfiguration(k, !0),
  104115. j.fromLinearSpace = !1) : (j._attachImageProcessingConfiguration(null, !0),
  104116. j.imageProcessingConfiguration.applyByPostProcess = !0),
  104117. j.onApply = function($) {
  104118. j.imageProcessingConfiguration.bind($, j.aspectRatio)
  104119. }
  104120. ,
  104121. j
  104122. }
  104123. return Object.defineProperty(e.prototype, "imageProcessingConfiguration", {
  104124. get: function() {
  104125. return this._imageProcessingConfiguration
  104126. },
  104127. set: function(i) {
  104128. i.applyByPostProcess = !0,
  104129. this._attachImageProcessingConfiguration(i)
  104130. },
  104131. enumerable: !1,
  104132. configurable: !0
  104133. }),
  104134. e.prototype._attachImageProcessingConfiguration = function(i, o) {
  104135. var s = this;
  104136. if (o === void 0 && (o = !1),
  104137. i !== this._imageProcessingConfiguration) {
  104138. if (this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),
  104139. i)
  104140. this._imageProcessingConfiguration = i;
  104141. else {
  104142. var c = null
  104143. , d = this.getEngine()
  104144. , _ = this.getCamera();
  104145. if (_)
  104146. c = _.getScene();
  104147. else if (d && d.scenes) {
  104148. var b = d.scenes;
  104149. c = b[b.length - 1]
  104150. } else
  104151. c = EngineStore.LastCreatedScene;
  104152. c ? this._imageProcessingConfiguration = c.imageProcessingConfiguration : this._imageProcessingConfiguration = new ImageProcessingConfiguration
  104153. }
  104154. this._imageProcessingConfiguration && (this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function() {
  104155. s._updateParameters()
  104156. })),
  104157. o || this._updateParameters()
  104158. }
  104159. }
  104160. ,
  104161. Object.defineProperty(e.prototype, "isSupported", {
  104162. get: function() {
  104163. var i = this.getEffect();
  104164. return !i || i.isSupported
  104165. },
  104166. enumerable: !1,
  104167. configurable: !0
  104168. }),
  104169. Object.defineProperty(e.prototype, "colorCurves", {
  104170. get: function() {
  104171. return this.imageProcessingConfiguration.colorCurves
  104172. },
  104173. set: function(i) {
  104174. this.imageProcessingConfiguration.colorCurves = i
  104175. },
  104176. enumerable: !1,
  104177. configurable: !0
  104178. }),
  104179. Object.defineProperty(e.prototype, "colorCurvesEnabled", {
  104180. get: function() {
  104181. return this.imageProcessingConfiguration.colorCurvesEnabled
  104182. },
  104183. set: function(i) {
  104184. this.imageProcessingConfiguration.colorCurvesEnabled = i
  104185. },
  104186. enumerable: !1,
  104187. configurable: !0
  104188. }),
  104189. Object.defineProperty(e.prototype, "colorGradingTexture", {
  104190. get: function() {
  104191. return this.imageProcessingConfiguration.colorGradingTexture
  104192. },
  104193. set: function(i) {
  104194. this.imageProcessingConfiguration.colorGradingTexture = i
  104195. },
  104196. enumerable: !1,
  104197. configurable: !0
  104198. }),
  104199. Object.defineProperty(e.prototype, "colorGradingEnabled", {
  104200. get: function() {
  104201. return this.imageProcessingConfiguration.colorGradingEnabled
  104202. },
  104203. set: function(i) {
  104204. this.imageProcessingConfiguration.colorGradingEnabled = i
  104205. },
  104206. enumerable: !1,
  104207. configurable: !0
  104208. }),
  104209. Object.defineProperty(e.prototype, "exposure", {
  104210. get: function() {
  104211. return this.imageProcessingConfiguration.exposure
  104212. },
  104213. set: function(i) {
  104214. this.imageProcessingConfiguration.exposure = i
  104215. },
  104216. enumerable: !1,
  104217. configurable: !0
  104218. }),
  104219. Object.defineProperty(e.prototype, "toneMappingEnabled", {
  104220. get: function() {
  104221. return this._imageProcessingConfiguration.toneMappingEnabled
  104222. },
  104223. set: function(i) {
  104224. this._imageProcessingConfiguration.toneMappingEnabled = i
  104225. },
  104226. enumerable: !1,
  104227. configurable: !0
  104228. }),
  104229. Object.defineProperty(e.prototype, "toneMappingType", {
  104230. get: function() {
  104231. return this._imageProcessingConfiguration.toneMappingType
  104232. },
  104233. set: function(i) {
  104234. this._imageProcessingConfiguration.toneMappingType = i
  104235. },
  104236. enumerable: !1,
  104237. configurable: !0
  104238. }),
  104239. Object.defineProperty(e.prototype, "contrast", {
  104240. get: function() {
  104241. return this.imageProcessingConfiguration.contrast
  104242. },
  104243. set: function(i) {
  104244. this.imageProcessingConfiguration.contrast = i
  104245. },
  104246. enumerable: !1,
  104247. configurable: !0
  104248. }),
  104249. Object.defineProperty(e.prototype, "vignetteStretch", {
  104250. get: function() {
  104251. return this.imageProcessingConfiguration.vignetteStretch
  104252. },
  104253. set: function(i) {
  104254. this.imageProcessingConfiguration.vignetteStretch = i
  104255. },
  104256. enumerable: !1,
  104257. configurable: !0
  104258. }),
  104259. Object.defineProperty(e.prototype, "vignetteCentreX", {
  104260. get: function() {
  104261. return this.imageProcessingConfiguration.vignetteCentreX
  104262. },
  104263. set: function(i) {
  104264. this.imageProcessingConfiguration.vignetteCentreX = i
  104265. },
  104266. enumerable: !1,
  104267. configurable: !0
  104268. }),
  104269. Object.defineProperty(e.prototype, "vignetteCentreY", {
  104270. get: function() {
  104271. return this.imageProcessingConfiguration.vignetteCentreY
  104272. },
  104273. set: function(i) {
  104274. this.imageProcessingConfiguration.vignetteCentreY = i
  104275. },
  104276. enumerable: !1,
  104277. configurable: !0
  104278. }),
  104279. Object.defineProperty(e.prototype, "vignetteWeight", {
  104280. get: function() {
  104281. return this.imageProcessingConfiguration.vignetteWeight
  104282. },
  104283. set: function(i) {
  104284. this.imageProcessingConfiguration.vignetteWeight = i
  104285. },
  104286. enumerable: !1,
  104287. configurable: !0
  104288. }),
  104289. Object.defineProperty(e.prototype, "vignetteColor", {
  104290. get: function() {
  104291. return this.imageProcessingConfiguration.vignetteColor
  104292. },
  104293. set: function(i) {
  104294. this.imageProcessingConfiguration.vignetteColor = i
  104295. },
  104296. enumerable: !1,
  104297. configurable: !0
  104298. }),
  104299. Object.defineProperty(e.prototype, "vignetteCameraFov", {
  104300. get: function() {
  104301. return this.imageProcessingConfiguration.vignetteCameraFov
  104302. },
  104303. set: function(i) {
  104304. this.imageProcessingConfiguration.vignetteCameraFov = i
  104305. },
  104306. enumerable: !1,
  104307. configurable: !0
  104308. }),
  104309. Object.defineProperty(e.prototype, "vignetteBlendMode", {
  104310. get: function() {
  104311. return this.imageProcessingConfiguration.vignetteBlendMode
  104312. },
  104313. set: function(i) {
  104314. this.imageProcessingConfiguration.vignetteBlendMode = i
  104315. },
  104316. enumerable: !1,
  104317. configurable: !0
  104318. }),
  104319. Object.defineProperty(e.prototype, "vignetteEnabled", {
  104320. get: function() {
  104321. return this.imageProcessingConfiguration.vignetteEnabled
  104322. },
  104323. set: function(i) {
  104324. this.imageProcessingConfiguration.vignetteEnabled = i
  104325. },
  104326. enumerable: !1,
  104327. configurable: !0
  104328. }),
  104329. Object.defineProperty(e.prototype, "fromLinearSpace", {
  104330. get: function() {
  104331. return this._fromLinearSpace
  104332. },
  104333. set: function(i) {
  104334. this._fromLinearSpace !== i && (this._fromLinearSpace = i,
  104335. this._updateParameters())
  104336. },
  104337. enumerable: !1,
  104338. configurable: !0
  104339. }),
  104340. e.prototype.getClassName = function() {
  104341. return "ImageProcessingPostProcess"
  104342. }
  104343. ,
  104344. e.prototype._updateParameters = function() {
  104345. this._defines.FROMLINEARSPACE = this._fromLinearSpace,
  104346. this.imageProcessingConfiguration.prepareDefines(this._defines, !0);
  104347. var i = "";
  104348. for (var o in this._defines)
  104349. this._defines[o] && (i += "#define " + o + `;\r
  104350. `);
  104351. var s = ["textureSampler"]
  104352. , c = ["scale"];
  104353. ImageProcessingConfiguration && (ImageProcessingConfiguration.PrepareSamplers(s, this._defines),
  104354. ImageProcessingConfiguration.PrepareUniforms(c, this._defines)),
  104355. this.updateEffect(i, c, s)
  104356. }
  104357. ,
  104358. e.prototype.dispose = function(i) {
  104359. a.prototype.dispose.call(this, i),
  104360. this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),
  104361. this._imageProcessingConfiguration && (this.imageProcessingConfiguration.applyByPostProcess = !1)
  104362. }
  104363. ,
  104364. __decorate([serialize()], e.prototype, "_fromLinearSpace", void 0),
  104365. e
  104366. }(PostProcess)
  104367. , name$w = "chromaticAberrationPixelShader"
  104368. , shader$w = `
  104369. uniform sampler2D textureSampler;
  104370. uniform float chromatic_aberration;
  104371. uniform float radialIntensity;
  104372. uniform vec2 direction;
  104373. uniform vec2 centerPosition;
  104374. uniform float screen_width;
  104375. uniform float screen_height;
  104376. varying vec2 vUV;
  104377. void main(void)
  104378. {
  104379. vec2 centered_screen_pos=vec2(vUV.x-centerPosition.x,vUV.y-centerPosition.y);
  104380. vec2 directionOfEffect=direction;
  104381. if(directionOfEffect.x == 0. && directionOfEffect.y == 0.){
  104382. directionOfEffect=normalize(centered_screen_pos);
  104383. }
  104384. float radius2=centered_screen_pos.x*centered_screen_pos.x
  104385. +centered_screen_pos.y*centered_screen_pos.y;
  104386. float radius=sqrt(radius2);
  104387. vec4 original=texture2D(textureSampler,vUV);
  104388. vec3 ref_indices=vec3(-0.3,0.0,0.3);
  104389. float ref_shiftX=chromatic_aberration*pow(radius,radialIntensity)*directionOfEffect.x/screen_width;
  104390. float ref_shiftY=chromatic_aberration*pow(radius,radialIntensity)*directionOfEffect.y/screen_height;
  104391. vec2 ref_coords_r=vec2(vUV.x+ref_indices.r*ref_shiftX,vUV.y+ref_indices.r*ref_shiftY*0.5);
  104392. vec2 ref_coords_g=vec2(vUV.x+ref_indices.g*ref_shiftX,vUV.y+ref_indices.g*ref_shiftY*0.5);
  104393. vec2 ref_coords_b=vec2(vUV.x+ref_indices.b*ref_shiftX,vUV.y+ref_indices.b*ref_shiftY*0.5);
  104394. original.r=texture2D(textureSampler,ref_coords_r).r;
  104395. original.g=texture2D(textureSampler,ref_coords_g).g;
  104396. original.b=texture2D(textureSampler,ref_coords_b).b;
  104397. original.a=clamp(texture2D(textureSampler,ref_coords_r).a+texture2D(textureSampler,ref_coords_g).a+texture2D(textureSampler,ref_coords_b).a,0.,1.);
  104398. gl_FragColor=original;
  104399. }`;
  104400. ShaderStore.ShadersStore[name$w] = shader$w;
  104401. var ChromaticAberrationPostProcess = function(a) {
  104402. __extends(e, a);
  104403. function e(i, o, s, c, d, _, b, k, j, $) {
  104404. j === void 0 && (j = 0),
  104405. $ === void 0 && ($ = !1);
  104406. var _e = a.call(this, i, "chromaticAberration", ["chromatic_aberration", "screen_width", "screen_height", "direction", "radialIntensity", "centerPosition"], [], c, d, _, b, k, null, j, void 0, null, $) || this;
  104407. return _e.aberrationAmount = 30,
  104408. _e.radialIntensity = 0,
  104409. _e.direction = new Vector2(.707,.707),
  104410. _e.centerPosition = new Vector2(.5,.5),
  104411. _e.screenWidth = o,
  104412. _e.screenHeight = s,
  104413. _e.onApplyObservable.add(function(et) {
  104414. et.setFloat("chromatic_aberration", _e.aberrationAmount),
  104415. et.setFloat("screen_width", o),
  104416. et.setFloat("screen_height", s),
  104417. et.setFloat("radialIntensity", _e.radialIntensity),
  104418. et.setFloat2("direction", _e.direction.x, _e.direction.y),
  104419. et.setFloat2("centerPosition", _e.centerPosition.x, _e.centerPosition.y)
  104420. }),
  104421. _e
  104422. }
  104423. return e.prototype.getClassName = function() {
  104424. return "ChromaticAberrationPostProcess"
  104425. }
  104426. ,
  104427. e._Parse = function(i, o, s, c) {
  104428. return SerializationHelper.Parse(function() {
  104429. return new e(i.name,i.screenWidth,i.screenHeight,i.options,o,i.renderTargetSamplingMode,s.getEngine(),i.reusable,i.textureType,!1)
  104430. }, i, s, c)
  104431. }
  104432. ,
  104433. __decorate([serialize()], e.prototype, "aberrationAmount", void 0),
  104434. __decorate([serialize()], e.prototype, "radialIntensity", void 0),
  104435. __decorate([serialize()], e.prototype, "direction", void 0),
  104436. __decorate([serialize()], e.prototype, "centerPosition", void 0),
  104437. __decorate([serialize()], e.prototype, "screenWidth", void 0),
  104438. __decorate([serialize()], e.prototype, "screenHeight", void 0),
  104439. e
  104440. }(PostProcess);
  104441. RegisterClass("BABYLON.ChromaticAberrationPostProcess", ChromaticAberrationPostProcess);
  104442. var name$v = "grainPixelShader"
  104443. , shader$v = `#include<helperFunctions>
  104444. uniform sampler2D textureSampler;
  104445. uniform float intensity;
  104446. uniform float animatedSeed;
  104447. varying vec2 vUV;
  104448. void main(void)
  104449. {
  104450. gl_FragColor=texture2D(textureSampler,vUV);
  104451. vec2 seed=vUV*(animatedSeed);
  104452. float grain=dither(seed,intensity);
  104453. float lum=getLuminance(gl_FragColor.rgb);
  104454. float grainAmount=(cos(-PI+(lum*PI*2.))+1.)/2.;
  104455. gl_FragColor.rgb+=grain*grainAmount;
  104456. gl_FragColor.rgb=max(gl_FragColor.rgb,0.0);
  104457. }`;
  104458. ShaderStore.ShadersStore[name$v] = shader$v;
  104459. var GrainPostProcess = function(a) {
  104460. __extends(e, a);
  104461. function e(i, o, s, c, d, _, b, k) {
  104462. b === void 0 && (b = 0),
  104463. k === void 0 && (k = !1);
  104464. var j = a.call(this, i, "grain", ["intensity", "animatedSeed"], [], o, s, c, d, _, null, b, void 0, null, k) || this;
  104465. return j.intensity = 30,
  104466. j.animated = !1,
  104467. j.onApplyObservable.add(function($) {
  104468. $.setFloat("intensity", j.intensity),
  104469. $.setFloat("animatedSeed", j.animated ? Math.random() + 1 : 1)
  104470. }),
  104471. j
  104472. }
  104473. return e.prototype.getClassName = function() {
  104474. return "GrainPostProcess"
  104475. }
  104476. ,
  104477. e._Parse = function(i, o, s, c) {
  104478. return SerializationHelper.Parse(function() {
  104479. return new e(i.name,i.options,o,i.renderTargetSamplingMode,s.getEngine(),i.reusable)
  104480. }, i, s, c)
  104481. }
  104482. ,
  104483. __decorate([serialize()], e.prototype, "intensity", void 0),
  104484. __decorate([serialize()], e.prototype, "animated", void 0),
  104485. e
  104486. }(PostProcess);
  104487. RegisterClass("BABYLON.GrainPostProcess", GrainPostProcess);
  104488. var name$u = "fxaaPixelShader"
  104489. , shader$u = `uniform sampler2D textureSampler;
  104490. uniform vec2 texelSize;
  104491. varying vec2 vUV;
  104492. varying vec2 sampleCoordS;
  104493. varying vec2 sampleCoordE;
  104494. varying vec2 sampleCoordN;
  104495. varying vec2 sampleCoordW;
  104496. varying vec2 sampleCoordNW;
  104497. varying vec2 sampleCoordSE;
  104498. varying vec2 sampleCoordNE;
  104499. varying vec2 sampleCoordSW;
  104500. const float fxaaQualitySubpix=1.0;
  104501. const float fxaaQualityEdgeThreshold=0.166;
  104502. const float fxaaQualityEdgeThresholdMin=0.0833;
  104503. const vec3 kLumaCoefficients=vec3(0.2126,0.7152,0.0722);
  104504. #define FxaaLuma(rgba) dot(rgba.rgb,kLumaCoefficients)
  104505. void main(){
  104506. vec2 posM;
  104507. posM.x=vUV.x;
  104508. posM.y=vUV.y;
  104509. vec4 rgbyM=texture2D(textureSampler,vUV,0.0);
  104510. float lumaM=FxaaLuma(rgbyM);
  104511. float lumaS=FxaaLuma(texture2D(textureSampler,sampleCoordS,0.0));
  104512. float lumaE=FxaaLuma(texture2D(textureSampler,sampleCoordE,0.0));
  104513. float lumaN=FxaaLuma(texture2D(textureSampler,sampleCoordN,0.0));
  104514. float lumaW=FxaaLuma(texture2D(textureSampler,sampleCoordW,0.0));
  104515. float maxSM=max(lumaS,lumaM);
  104516. float minSM=min(lumaS,lumaM);
  104517. float maxESM=max(lumaE,maxSM);
  104518. float minESM=min(lumaE,minSM);
  104519. float maxWN=max(lumaN,lumaW);
  104520. float minWN=min(lumaN,lumaW);
  104521. float rangeMax=max(maxWN,maxESM);
  104522. float rangeMin=min(minWN,minESM);
  104523. float rangeMaxScaled=rangeMax*fxaaQualityEdgeThreshold;
  104524. float range=rangeMax-rangeMin;
  104525. float rangeMaxClamped=max(fxaaQualityEdgeThresholdMin,rangeMaxScaled);
  104526. #ifndef MALI
  104527. if(range<rangeMaxClamped)
  104528. {
  104529. gl_FragColor=rgbyM;
  104530. return;
  104531. }
  104532. #endif
  104533. float lumaNW=FxaaLuma(texture2D(textureSampler,sampleCoordNW,0.0));
  104534. float lumaSE=FxaaLuma(texture2D(textureSampler,sampleCoordSE,0.0));
  104535. float lumaNE=FxaaLuma(texture2D(textureSampler,sampleCoordNE,0.0));
  104536. float lumaSW=FxaaLuma(texture2D(textureSampler,sampleCoordSW,0.0));
  104537. float lumaNS=lumaN+lumaS;
  104538. float lumaWE=lumaW+lumaE;
  104539. float subpixRcpRange=1.0/range;
  104540. float subpixNSWE=lumaNS+lumaWE;
  104541. float edgeHorz1=(-2.0*lumaM)+lumaNS;
  104542. float edgeVert1=(-2.0*lumaM)+lumaWE;
  104543. float lumaNESE=lumaNE+lumaSE;
  104544. float lumaNWNE=lumaNW+lumaNE;
  104545. float edgeHorz2=(-2.0*lumaE)+lumaNESE;
  104546. float edgeVert2=(-2.0*lumaN)+lumaNWNE;
  104547. float lumaNWSW=lumaNW+lumaSW;
  104548. float lumaSWSE=lumaSW+lumaSE;
  104549. float edgeHorz4=(abs(edgeHorz1)*2.0)+abs(edgeHorz2);
  104550. float edgeVert4=(abs(edgeVert1)*2.0)+abs(edgeVert2);
  104551. float edgeHorz3=(-2.0*lumaW)+lumaNWSW;
  104552. float edgeVert3=(-2.0*lumaS)+lumaSWSE;
  104553. float edgeHorz=abs(edgeHorz3)+edgeHorz4;
  104554. float edgeVert=abs(edgeVert3)+edgeVert4;
  104555. float subpixNWSWNESE=lumaNWSW+lumaNESE;
  104556. float lengthSign=texelSize.x;
  104557. bool horzSpan=edgeHorz>=edgeVert;
  104558. float subpixA=subpixNSWE*2.0+subpixNWSWNESE;
  104559. if (!horzSpan)
  104560. {
  104561. lumaN=lumaW;
  104562. }
  104563. if (!horzSpan)
  104564. {
  104565. lumaS=lumaE;
  104566. }
  104567. if (horzSpan)
  104568. {
  104569. lengthSign=texelSize.y;
  104570. }
  104571. float subpixB=(subpixA*(1.0/12.0))-lumaM;
  104572. float gradientN=lumaN-lumaM;
  104573. float gradientS=lumaS-lumaM;
  104574. float lumaNN=lumaN+lumaM;
  104575. float lumaSS=lumaS+lumaM;
  104576. bool pairN=abs(gradientN)>=abs(gradientS);
  104577. float gradient=max(abs(gradientN),abs(gradientS));
  104578. if (pairN)
  104579. {
  104580. lengthSign=-lengthSign;
  104581. }
  104582. float subpixC=clamp(abs(subpixB)*subpixRcpRange,0.0,1.0);
  104583. vec2 posB;
  104584. posB.x=posM.x;
  104585. posB.y=posM.y;
  104586. vec2 offNP;
  104587. offNP.x=(!horzSpan) ? 0.0 : texelSize.x;
  104588. offNP.y=(horzSpan) ? 0.0 : texelSize.y;
  104589. if (!horzSpan)
  104590. {
  104591. posB.x+=lengthSign*0.5;
  104592. }
  104593. if (horzSpan)
  104594. {
  104595. posB.y+=lengthSign*0.5;
  104596. }
  104597. vec2 posN;
  104598. posN.x=posB.x-offNP.x*1.5;
  104599. posN.y=posB.y-offNP.y*1.5;
  104600. vec2 posP;
  104601. posP.x=posB.x+offNP.x*1.5;
  104602. posP.y=posB.y+offNP.y*1.5;
  104603. float subpixD=((-2.0)*subpixC)+3.0;
  104604. float lumaEndN=FxaaLuma(texture2D(textureSampler,posN,0.0));
  104605. float subpixE=subpixC*subpixC;
  104606. float lumaEndP=FxaaLuma(texture2D(textureSampler,posP,0.0));
  104607. if (!pairN)
  104608. {
  104609. lumaNN=lumaSS;
  104610. }
  104611. float gradientScaled=gradient*1.0/4.0;
  104612. float lumaMM=lumaM-lumaNN*0.5;
  104613. float subpixF=subpixD*subpixE;
  104614. bool lumaMLTZero=lumaMM<0.0;
  104615. lumaEndN-=lumaNN*0.5;
  104616. lumaEndP-=lumaNN*0.5;
  104617. bool doneN=abs(lumaEndN)>=gradientScaled;
  104618. bool doneP=abs(lumaEndP)>=gradientScaled;
  104619. if (!doneN)
  104620. {
  104621. posN.x-=offNP.x*3.0;
  104622. }
  104623. if (!doneN)
  104624. {
  104625. posN.y-=offNP.y*3.0;
  104626. }
  104627. bool doneNP=(!doneN) || (!doneP);
  104628. if (!doneP)
  104629. {
  104630. posP.x+=offNP.x*3.0;
  104631. }
  104632. if (!doneP)
  104633. {
  104634. posP.y+=offNP.y*3.0;
  104635. }
  104636. if (doneNP)
  104637. {
  104638. if (!doneN) lumaEndN=FxaaLuma(texture2D(textureSampler,posN.xy,0.0));
  104639. if (!doneP) lumaEndP=FxaaLuma(texture2D(textureSampler,posP.xy,0.0));
  104640. if (!doneN) lumaEndN=lumaEndN-lumaNN*0.5;
  104641. if (!doneP) lumaEndP=lumaEndP-lumaNN*0.5;
  104642. doneN=abs(lumaEndN)>=gradientScaled;
  104643. doneP=abs(lumaEndP)>=gradientScaled;
  104644. if (!doneN) posN.x-=offNP.x*12.0;
  104645. if (!doneN) posN.y-=offNP.y*12.0;
  104646. doneNP=(!doneN) || (!doneP);
  104647. if (!doneP) posP.x+=offNP.x*12.0;
  104648. if (!doneP) posP.y+=offNP.y*12.0;
  104649. }
  104650. float dstN=posM.x-posN.x;
  104651. float dstP=posP.x-posM.x;
  104652. if (!horzSpan)
  104653. {
  104654. dstN=posM.y-posN.y;
  104655. }
  104656. if (!horzSpan)
  104657. {
  104658. dstP=posP.y-posM.y;
  104659. }
  104660. bool goodSpanN=(lumaEndN<0.0) != lumaMLTZero;
  104661. float spanLength=(dstP+dstN);
  104662. bool goodSpanP=(lumaEndP<0.0) != lumaMLTZero;
  104663. float spanLengthRcp=1.0/spanLength;
  104664. bool directionN=dstN<dstP;
  104665. float dst=min(dstN,dstP);
  104666. bool goodSpan=directionN ? goodSpanN : goodSpanP;
  104667. float subpixG=subpixF*subpixF;
  104668. float pixelOffset=(dst*(-spanLengthRcp))+0.5;
  104669. float subpixH=subpixG*fxaaQualitySubpix;
  104670. float pixelOffsetGood=goodSpan ? pixelOffset : 0.0;
  104671. float pixelOffsetSubpix=max(pixelOffsetGood,subpixH);
  104672. if (!horzSpan)
  104673. {
  104674. posM.x+=pixelOffsetSubpix*lengthSign;
  104675. }
  104676. if (horzSpan)
  104677. {
  104678. posM.y+=pixelOffsetSubpix*lengthSign;
  104679. }
  104680. #ifdef MALI
  104681. if(range<rangeMaxClamped)
  104682. {
  104683. gl_FragColor=rgbyM;
  104684. }
  104685. else
  104686. {
  104687. gl_FragColor=texture2D(textureSampler,posM,0.0);
  104688. }
  104689. #else
  104690. gl_FragColor=texture2D(textureSampler,posM,0.0);
  104691. #endif
  104692. }`;
  104693. ShaderStore.ShadersStore[name$u] = shader$u;
  104694. var name$t = "fxaaVertexShader"
  104695. , shader$t = `
  104696. attribute vec2 position;
  104697. uniform vec2 texelSize;
  104698. varying vec2 vUV;
  104699. varying vec2 sampleCoordS;
  104700. varying vec2 sampleCoordE;
  104701. varying vec2 sampleCoordN;
  104702. varying vec2 sampleCoordW;
  104703. varying vec2 sampleCoordNW;
  104704. varying vec2 sampleCoordSE;
  104705. varying vec2 sampleCoordNE;
  104706. varying vec2 sampleCoordSW;
  104707. const vec2 madd=vec2(0.5,0.5);
  104708. void main(void) {
  104709. vUV=(position*madd+madd);
  104710. sampleCoordS=vUV+vec2( 0.0,1.0)*texelSize;
  104711. sampleCoordE=vUV+vec2( 1.0,0.0)*texelSize;
  104712. sampleCoordN=vUV+vec2( 0.0,-1.0)*texelSize;
  104713. sampleCoordW=vUV+vec2(-1.0,0.0)*texelSize;
  104714. sampleCoordNW=vUV+vec2(-1.0,-1.0)*texelSize;
  104715. sampleCoordSE=vUV+vec2( 1.0,1.0)*texelSize;
  104716. sampleCoordNE=vUV+vec2( 1.0,-1.0)*texelSize;
  104717. sampleCoordSW=vUV+vec2(-1.0,1.0)*texelSize;
  104718. gl_Position=vec4(position,0.0,1.0);
  104719. }`;
  104720. ShaderStore.ShadersStore[name$t] = shader$t;
  104721. var FxaaPostProcess = function(a) {
  104722. __extends(e, a);
  104723. function e(i, o, s, c, d, _, b) {
  104724. s === void 0 && (s = null),
  104725. b === void 0 && (b = 0);
  104726. var k = a.call(this, i, "fxaa", ["texelSize"], null, o, s, c || Texture.BILINEAR_SAMPLINGMODE, d, _, null, b, "fxaa", void 0, !0) || this
  104727. , j = k._getDefines();
  104728. return k.updateEffect(j),
  104729. k.onApplyObservable.add(function($) {
  104730. var _e = k.texelSize;
  104731. $.setFloat2("texelSize", _e.x, _e.y)
  104732. }),
  104733. k
  104734. }
  104735. return e.prototype.getClassName = function() {
  104736. return "FxaaPostProcess"
  104737. }
  104738. ,
  104739. e.prototype._getDefines = function() {
  104740. var i = this.getEngine();
  104741. if (!i)
  104742. return null;
  104743. var o = i.getGlInfo();
  104744. return o && o.renderer && o.renderer.toLowerCase().indexOf("mali") > -1 ? `#define MALI 1
  104745. ` : null
  104746. }
  104747. ,
  104748. e._Parse = function(i, o, s, c) {
  104749. return SerializationHelper.Parse(function() {
  104750. return new e(i.name,i.options,o,i.renderTargetSamplingMode,s.getEngine(),i.reusable)
  104751. }, i, s, c)
  104752. }
  104753. ,
  104754. e
  104755. }(PostProcess);
  104756. RegisterClass("BABYLON.FxaaPostProcess", FxaaPostProcess);
  104757. var PostProcessRenderPipeline = function() {
  104758. function a(e, i) {
  104759. this.engine = e,
  104760. this._name = i,
  104761. this._renderEffects = {},
  104762. this._renderEffectsForIsolatedPass = new Array,
  104763. this._cameras = []
  104764. }
  104765. return Object.defineProperty(a.prototype, "name", {
  104766. get: function() {
  104767. return this._name
  104768. },
  104769. enumerable: !1,
  104770. configurable: !0
  104771. }),
  104772. Object.defineProperty(a.prototype, "cameras", {
  104773. get: function() {
  104774. return this._cameras
  104775. },
  104776. enumerable: !1,
  104777. configurable: !0
  104778. }),
  104779. a.prototype.getClassName = function() {
  104780. return "PostProcessRenderPipeline"
  104781. }
  104782. ,
  104783. Object.defineProperty(a.prototype, "isSupported", {
  104784. get: function() {
  104785. for (var e in this._renderEffects)
  104786. if (this._renderEffects.hasOwnProperty(e) && !this._renderEffects[e].isSupported)
  104787. return !1;
  104788. return !0
  104789. },
  104790. enumerable: !1,
  104791. configurable: !0
  104792. }),
  104793. a.prototype.addEffect = function(e) {
  104794. this._renderEffects[e._name] = e
  104795. }
  104796. ,
  104797. a.prototype._rebuild = function() {}
  104798. ,
  104799. a.prototype._enableEffect = function(e, i) {
  104800. var o = this._renderEffects[e];
  104801. !o || o._enable(Tools.MakeArray(i || this._cameras))
  104802. }
  104803. ,
  104804. a.prototype._disableEffect = function(e, i) {
  104805. var o = this._renderEffects[e];
  104806. !o || o._disable(Tools.MakeArray(i || this._cameras))
  104807. }
  104808. ,
  104809. a.prototype._attachCameras = function(e, i) {
  104810. var o = Tools.MakeArray(e || this._cameras);
  104811. if (!!o) {
  104812. var s = [], c;
  104813. for (c = 0; c < o.length; c++) {
  104814. var d = o[c];
  104815. if (!!d) {
  104816. var _ = d.name;
  104817. this._cameras.indexOf(d) === -1 ? this._cameras[_] = d : i && s.push(c)
  104818. }
  104819. }
  104820. for (c = 0; c < s.length; c++)
  104821. o.splice(s[c], 1);
  104822. for (var b in this._renderEffects)
  104823. this._renderEffects.hasOwnProperty(b) && this._renderEffects[b]._attachCameras(o)
  104824. }
  104825. }
  104826. ,
  104827. a.prototype._detachCameras = function(e) {
  104828. var i = Tools.MakeArray(e || this._cameras);
  104829. if (!!i) {
  104830. for (var o in this._renderEffects)
  104831. this._renderEffects.hasOwnProperty(o) && this._renderEffects[o]._detachCameras(i);
  104832. for (var s = 0; s < i.length; s++)
  104833. this._cameras.splice(this._cameras.indexOf(i[s]), 1)
  104834. }
  104835. }
  104836. ,
  104837. a.prototype._update = function() {
  104838. for (var e in this._renderEffects)
  104839. this._renderEffects.hasOwnProperty(e) && this._renderEffects[e]._update();
  104840. for (var i = 0; i < this._cameras.length; i++)
  104841. if (!!this._cameras[i]) {
  104842. var o = this._cameras[i].name;
  104843. this._renderEffectsForIsolatedPass[o] && this._renderEffectsForIsolatedPass[o]._update()
  104844. }
  104845. }
  104846. ,
  104847. a.prototype._reset = function() {
  104848. this._renderEffects = {},
  104849. this._renderEffectsForIsolatedPass = new Array
  104850. }
  104851. ,
  104852. a.prototype._enableMSAAOnFirstPostProcess = function(e) {
  104853. if (!this.engine._features.supportMSAA)
  104854. return !1;
  104855. var i = Object.keys(this._renderEffects);
  104856. if (i.length > 0) {
  104857. var o = this._renderEffects[i[0]].getPostProcesses();
  104858. o && (o[0].samples = e)
  104859. }
  104860. return !0
  104861. }
  104862. ,
  104863. a.prototype.setPrePassRenderer = function(e) {
  104864. return !1
  104865. }
  104866. ,
  104867. a.prototype.dispose = function() {}
  104868. ,
  104869. __decorate([serialize()], a.prototype, "_name", void 0),
  104870. a
  104871. }()
  104872. , PostProcessRenderEffect = function() {
  104873. function a(e, i, o, s) {
  104874. this._name = i,
  104875. this._singleInstance = s || !0,
  104876. this._getPostProcesses = o,
  104877. this._cameras = {},
  104878. this._indicesForCamera = {},
  104879. this._postProcesses = {}
  104880. }
  104881. return Object.defineProperty(a.prototype, "isSupported", {
  104882. get: function() {
  104883. for (var e in this._postProcesses)
  104884. if (this._postProcesses.hasOwnProperty(e)) {
  104885. for (var i = this._postProcesses[e], o = 0; o < i.length; o++)
  104886. if (!i[o].isSupported)
  104887. return !1
  104888. }
  104889. return !0
  104890. },
  104891. enumerable: !1,
  104892. configurable: !0
  104893. }),
  104894. a.prototype._update = function() {}
  104895. ,
  104896. a.prototype._attachCameras = function(e) {
  104897. var i = this, o, s = Tools.MakeArray(e || this._cameras);
  104898. if (!!s)
  104899. for (var c = 0; c < s.length; c++) {
  104900. var d = s[c];
  104901. if (!!d) {
  104902. var _ = d.name;
  104903. if (this._singleInstance ? o = 0 : o = _,
  104904. !this._postProcesses[o]) {
  104905. var b = this._getPostProcesses();
  104906. b && (this._postProcesses[o] = Array.isArray(b) ? b : [b])
  104907. }
  104908. this._indicesForCamera[_] || (this._indicesForCamera[_] = []),
  104909. this._postProcesses[o].forEach(function(k) {
  104910. var j = d.attachPostProcess(k);
  104911. i._indicesForCamera[_].push(j)
  104912. }),
  104913. this._cameras[_] || (this._cameras[_] = d)
  104914. }
  104915. }
  104916. }
  104917. ,
  104918. a.prototype._detachCameras = function(e) {
  104919. var i = Tools.MakeArray(e || this._cameras);
  104920. if (!!i)
  104921. for (var o = 0; o < i.length; o++) {
  104922. var s = i[o]
  104923. , c = s.name
  104924. , d = this._postProcesses[this._singleInstance ? 0 : c];
  104925. d && d.forEach(function(_) {
  104926. s.detachPostProcess(_)
  104927. }),
  104928. this._cameras[c] && (this._cameras[c] = null)
  104929. }
  104930. }
  104931. ,
  104932. a.prototype._enable = function(e) {
  104933. var i = this
  104934. , o = Tools.MakeArray(e || this._cameras);
  104935. if (!!o)
  104936. for (var s = 0; s < o.length; s++)
  104937. for (var c = o[s], d = c.name, _ = 0; _ < this._indicesForCamera[d].length; _++)
  104938. (c._postProcesses[this._indicesForCamera[d][_]] === void 0 || c._postProcesses[this._indicesForCamera[d][_]] === null) && this._postProcesses[this._singleInstance ? 0 : d].forEach(function(b) {
  104939. o[s].attachPostProcess(b, i._indicesForCamera[d][_])
  104940. })
  104941. }
  104942. ,
  104943. a.prototype._disable = function(e) {
  104944. var i = Tools.MakeArray(e || this._cameras);
  104945. if (!!i)
  104946. for (var o = 0; o < i.length; o++) {
  104947. var s = i[o]
  104948. , c = s.name;
  104949. this._postProcesses[this._singleInstance ? 0 : c].forEach(function(d) {
  104950. s.detachPostProcess(d)
  104951. })
  104952. }
  104953. }
  104954. ,
  104955. a.prototype.getPostProcesses = function(e) {
  104956. return this._singleInstance ? this._postProcesses[0] : e ? this._postProcesses[e.name] : null
  104957. }
  104958. ,
  104959. a
  104960. }()
  104961. , name$s = "circleOfConfusionPixelShader"
  104962. , shader$s = `
  104963. uniform sampler2D depthSampler;
  104964. varying vec2 vUV;
  104965. uniform vec2 cameraMinMaxZ;
  104966. uniform float focusDistance;
  104967. uniform float cocPrecalculation;
  104968. void main(void)
  104969. {
  104970. float depth=texture2D(depthSampler,vUV).r;
  104971. float pixelDistance=(cameraMinMaxZ.x+(cameraMinMaxZ.y-cameraMinMaxZ.x)*depth)*1000.0;
  104972. float coc=abs(cocPrecalculation* ((focusDistance-pixelDistance)/pixelDistance));
  104973. coc=clamp(coc,0.0,1.0);
  104974. gl_FragColor=vec4(coc,depth,coc,1.0);
  104975. }
  104976. `;
  104977. ShaderStore.ShadersStore[name$s] = shader$s;
  104978. var CircleOfConfusionPostProcess = function(a) {
  104979. __extends(e, a);
  104980. function e(i, o, s, c, d, _, b, k, j) {
  104981. k === void 0 && (k = 0),
  104982. j === void 0 && (j = !1);
  104983. var $ = a.call(this, i, "circleOfConfusion", ["cameraMinMaxZ", "focusDistance", "cocPrecalculation"], ["depthSampler"], s, c, d, _, b, null, k, void 0, null, j) || this;
  104984. return $.lensSize = 50,
  104985. $.fStop = 1.4,
  104986. $.focusDistance = 2e3,
  104987. $.focalLength = 50,
  104988. $._depthTexture = null,
  104989. $._depthTexture = o,
  104990. $.onApplyObservable.add(function(_e) {
  104991. if (!$._depthTexture) {
  104992. Logger$2.Warn("No depth texture set on CircleOfConfusionPostProcess");
  104993. return
  104994. }
  104995. _e.setTexture("depthSampler", $._depthTexture);
  104996. var et = $.lensSize / $.fStop
  104997. , tt = et * $.focalLength / ($.focusDistance - $.focalLength);
  104998. _e.setFloat("focusDistance", $.focusDistance),
  104999. _e.setFloat("cocPrecalculation", tt),
  105000. _e.setFloat2("cameraMinMaxZ", $._depthTexture.activeCamera.minZ, $._depthTexture.activeCamera.maxZ)
  105001. }),
  105002. $
  105003. }
  105004. return e.prototype.getClassName = function() {
  105005. return "CircleOfConfusionPostProcess"
  105006. }
  105007. ,
  105008. Object.defineProperty(e.prototype, "depthTexture", {
  105009. set: function(i) {
  105010. this._depthTexture = i
  105011. },
  105012. enumerable: !1,
  105013. configurable: !0
  105014. }),
  105015. __decorate([serialize()], e.prototype, "lensSize", void 0),
  105016. __decorate([serialize()], e.prototype, "fStop", void 0),
  105017. __decorate([serialize()], e.prototype, "focusDistance", void 0),
  105018. __decorate([serialize()], e.prototype, "focalLength", void 0),
  105019. e
  105020. }(PostProcess);
  105021. RegisterClass("BABYLON.CircleOfConfusionPostProcess", CircleOfConfusionPostProcess);
  105022. var DepthOfFieldBlurPostProcess = function(a) {
  105023. __extends(e, a);
  105024. function e(i, o, s, c, d, _, b, k, j, $, _e, et, tt) {
  105025. k === void 0 && (k = null),
  105026. tt === void 0 && (tt = !1);
  105027. var rt = a.call(this, i, s, c, d, _, 2, $, _e, 0, `#define DOF 1\r
  105028. `, tt) || this;
  105029. return rt.direction = s,
  105030. rt.externalTextureSamplerBinding = !!k,
  105031. rt.onApplyObservable.add(function(it) {
  105032. k != null && it.setTextureFromPostProcess("textureSampler", k),
  105033. it.setTextureFromPostProcessOutput("circleOfConfusionSampler", b),
  105034. o.activeCamera && it.setFloat2("cameraMinMaxZ", o.activeCamera.minZ, o.activeCamera.maxZ)
  105035. }),
  105036. rt
  105037. }
  105038. return e.prototype.getClassName = function() {
  105039. return "DepthOfFieldBlurPostProcess"
  105040. }
  105041. ,
  105042. __decorate([serialize()], e.prototype, "direction", void 0),
  105043. e
  105044. }(BlurPostProcess);
  105045. RegisterClass("BABYLON.DepthOfFieldBlurPostProcess", DepthOfFieldBlurPostProcess);
  105046. var name$r = "depthOfFieldMergePixelShader"
  105047. , shader$r = `uniform sampler2D textureSampler;
  105048. varying vec2 vUV;
  105049. uniform sampler2D circleOfConfusionSampler;
  105050. uniform sampler2D blurStep0;
  105051. #if BLUR_LEVEL>0
  105052. uniform sampler2D blurStep1;
  105053. #endif
  105054. #if BLUR_LEVEL>1
  105055. uniform sampler2D blurStep2;
  105056. #endif
  105057. void main(void)
  105058. {
  105059. float coc=texture2D(circleOfConfusionSampler,vUV).r;
  105060. #if BLUR_LEVEL == 0
  105061. vec4 original=texture2D(textureSampler,vUV);
  105062. vec4 blurred0=texture2D(blurStep0,vUV);
  105063. gl_FragColor=mix(original,blurred0,coc);
  105064. #endif
  105065. #if BLUR_LEVEL == 1
  105066. if(coc<0.5){
  105067. vec4 original=texture2D(textureSampler,vUV);
  105068. vec4 blurred1=texture2D(blurStep1,vUV);
  105069. gl_FragColor=mix(original,blurred1,coc/0.5);
  105070. }else{
  105071. vec4 blurred0=texture2D(blurStep0,vUV);
  105072. vec4 blurred1=texture2D(blurStep1,vUV);
  105073. gl_FragColor=mix(blurred1,blurred0,(coc-0.5)/0.5);
  105074. }
  105075. #endif
  105076. #if BLUR_LEVEL == 2
  105077. if(coc<0.33){
  105078. vec4 original=texture2D(textureSampler,vUV);
  105079. vec4 blurred2=texture2D(blurStep2,vUV);
  105080. gl_FragColor=mix(original,blurred2,coc/0.33);
  105081. }else if(coc<0.66){
  105082. vec4 blurred1=texture2D(blurStep1,vUV);
  105083. vec4 blurred2=texture2D(blurStep2,vUV);
  105084. gl_FragColor=mix(blurred2,blurred1,(coc-0.33)/0.33);
  105085. }else{
  105086. vec4 blurred0=texture2D(blurStep0,vUV);
  105087. vec4 blurred1=texture2D(blurStep1,vUV);
  105088. gl_FragColor=mix(blurred1,blurred0,(coc-0.66)/0.34);
  105089. }
  105090. #endif
  105091. }
  105092. `;
  105093. ShaderStore.ShadersStore[name$r] = shader$r;
  105094. var DepthOfFieldMergePostProcess = function(a) {
  105095. __extends(e, a);
  105096. function e(i, o, s, c, d, _, b, k, j, $, _e) {
  105097. $ === void 0 && ($ = 0),
  105098. _e === void 0 && (_e = !1);
  105099. var et = a.call(this, i, "depthOfFieldMerge", [], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2"], d, _, b, k, j, null, $, void 0, null, !0) || this;
  105100. return et.blurSteps = c,
  105101. et.externalTextureSamplerBinding = !0,
  105102. et.onApplyObservable.add(function(tt) {
  105103. tt.setTextureFromPostProcess("textureSampler", o),
  105104. tt.setTextureFromPostProcessOutput("circleOfConfusionSampler", s),
  105105. c.forEach(function(rt, it) {
  105106. tt.setTextureFromPostProcessOutput("blurStep" + (c.length - it - 1), rt)
  105107. })
  105108. }),
  105109. _e || et.updateEffect(),
  105110. et
  105111. }
  105112. return e.prototype.getClassName = function() {
  105113. return "DepthOfFieldMergePostProcess"
  105114. }
  105115. ,
  105116. e.prototype.updateEffect = function(i, o, s, c, d, _) {
  105117. i === void 0 && (i = null),
  105118. o === void 0 && (o = null),
  105119. s === void 0 && (s = null),
  105120. i || (i = "",
  105121. i += "#define BLUR_LEVEL " + (this.blurSteps.length - 1) + `
  105122. `),
  105123. a.prototype.updateEffect.call(this, i, o, s, c, d, _)
  105124. }
  105125. ,
  105126. e
  105127. }(PostProcess), DepthOfFieldEffectBlurLevel;
  105128. (function(a) {
  105129. a[a.Low = 0] = "Low",
  105130. a[a.Medium = 1] = "Medium",
  105131. a[a.High = 2] = "High"
  105132. }
  105133. )(DepthOfFieldEffectBlurLevel || (DepthOfFieldEffectBlurLevel = {}));
  105134. var DepthOfFieldEffect = function(a) {
  105135. __extends(e, a);
  105136. function e(i, o, s, c, d) {
  105137. s === void 0 && (s = DepthOfFieldEffectBlurLevel.Low),
  105138. c === void 0 && (c = 0),
  105139. d === void 0 && (d = !1);
  105140. var _ = a.call(this, i.getEngine(), "depth of field", function() {
  105141. return _._effects
  105142. }, !0) || this;
  105143. _._effects = [],
  105144. _._circleOfConfusion = new CircleOfConfusionPostProcess("circleOfConfusion",o,1,null,Texture.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,c,d),
  105145. _._depthOfFieldBlurY = [],
  105146. _._depthOfFieldBlurX = [];
  105147. var b = 1
  105148. , k = 15;
  105149. switch (s) {
  105150. case DepthOfFieldEffectBlurLevel.High:
  105151. {
  105152. b = 3,
  105153. k = 51;
  105154. break
  105155. }
  105156. case DepthOfFieldEffectBlurLevel.Medium:
  105157. {
  105158. b = 2,
  105159. k = 31;
  105160. break
  105161. }
  105162. default:
  105163. {
  105164. k = 15,
  105165. b = 1;
  105166. break
  105167. }
  105168. }
  105169. for (var j = k / Math.pow(2, b - 1), $ = 1, _e = 0; _e < b; _e++) {
  105170. var et = new DepthOfFieldBlurPostProcess("vertical blur",i,new Vector2(0,1),j,$,null,_._circleOfConfusion,_e == 0 ? _._circleOfConfusion : null,Texture.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,c,d);
  105171. et.autoClear = !1,
  105172. $ = .75 / Math.pow(2, _e);
  105173. var tt = new DepthOfFieldBlurPostProcess("horizontal blur",i,new Vector2(1,0),j,$,null,_._circleOfConfusion,null,Texture.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,c,d);
  105174. tt.autoClear = !1,
  105175. _._depthOfFieldBlurY.push(et),
  105176. _._depthOfFieldBlurX.push(tt)
  105177. }
  105178. _._effects = [_._circleOfConfusion];
  105179. for (var _e = 0; _e < _._depthOfFieldBlurX.length; _e++)
  105180. _._effects.push(_._depthOfFieldBlurY[_e]),
  105181. _._effects.push(_._depthOfFieldBlurX[_e]);
  105182. return _._dofMerge = new DepthOfFieldMergePostProcess("dofMerge",_._circleOfConfusion,_._circleOfConfusion,_._depthOfFieldBlurX,$,null,Texture.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,c,d),
  105183. _._dofMerge.autoClear = !1,
  105184. _._effects.push(_._dofMerge),
  105185. _
  105186. }
  105187. return Object.defineProperty(e.prototype, "focalLength", {
  105188. get: function() {
  105189. return this._circleOfConfusion.focalLength
  105190. },
  105191. set: function(i) {
  105192. this._circleOfConfusion.focalLength = i
  105193. },
  105194. enumerable: !1,
  105195. configurable: !0
  105196. }),
  105197. Object.defineProperty(e.prototype, "fStop", {
  105198. get: function() {
  105199. return this._circleOfConfusion.fStop
  105200. },
  105201. set: function(i) {
  105202. this._circleOfConfusion.fStop = i
  105203. },
  105204. enumerable: !1,
  105205. configurable: !0
  105206. }),
  105207. Object.defineProperty(e.prototype, "focusDistance", {
  105208. get: function() {
  105209. return this._circleOfConfusion.focusDistance
  105210. },
  105211. set: function(i) {
  105212. this._circleOfConfusion.focusDistance = i
  105213. },
  105214. enumerable: !1,
  105215. configurable: !0
  105216. }),
  105217. Object.defineProperty(e.prototype, "lensSize", {
  105218. get: function() {
  105219. return this._circleOfConfusion.lensSize
  105220. },
  105221. set: function(i) {
  105222. this._circleOfConfusion.lensSize = i
  105223. },
  105224. enumerable: !1,
  105225. configurable: !0
  105226. }),
  105227. e.prototype.getClassName = function() {
  105228. return "DepthOfFieldEffect"
  105229. }
  105230. ,
  105231. Object.defineProperty(e.prototype, "depthTexture", {
  105232. set: function(i) {
  105233. this._circleOfConfusion.depthTexture = i
  105234. },
  105235. enumerable: !1,
  105236. configurable: !0
  105237. }),
  105238. e.prototype.disposeEffects = function(i) {
  105239. for (var o = 0; o < this._effects.length; o++)
  105240. this._effects[o].dispose(i)
  105241. }
  105242. ,
  105243. e.prototype._updateEffects = function() {
  105244. for (var i = 0; i < this._effects.length; i++)
  105245. this._effects[i].updateEffect()
  105246. }
  105247. ,
  105248. e.prototype._isReady = function() {
  105249. for (var i = 0; i < this._effects.length; i++)
  105250. if (!this._effects[i].isReady())
  105251. return !1;
  105252. return !0
  105253. }
  105254. ,
  105255. e
  105256. }(PostProcessRenderEffect)
  105257. , name$q = "extractHighlightsPixelShader"
  105258. , shader$q = `#include<helperFunctions>
  105259. varying vec2 vUV;
  105260. uniform sampler2D textureSampler;
  105261. uniform float threshold;
  105262. uniform float exposure;
  105263. void main(void)
  105264. {
  105265. gl_FragColor=texture2D(textureSampler,vUV);
  105266. float luma=getLuminance(gl_FragColor.rgb*exposure);
  105267. gl_FragColor.rgb=step(threshold,luma)*gl_FragColor.rgb;
  105268. }`;
  105269. ShaderStore.ShadersStore[name$q] = shader$q;
  105270. var ExtractHighlightsPostProcess = function(a) {
  105271. __extends(e, a);
  105272. function e(i, o, s, c, d, _, b, k) {
  105273. b === void 0 && (b = 0),
  105274. k === void 0 && (k = !1);
  105275. var j = a.call(this, i, "extractHighlights", ["threshold", "exposure"], null, o, s, c, d, _, null, b, void 0, null, k) || this;
  105276. return j.threshold = .9,
  105277. j._exposure = 1,
  105278. j._inputPostProcess = null,
  105279. j.onApplyObservable.add(function($) {
  105280. j.externalTextureSamplerBinding = !!j._inputPostProcess,
  105281. j._inputPostProcess && $.setTextureFromPostProcess("textureSampler", j._inputPostProcess),
  105282. $.setFloat("threshold", Math.pow(j.threshold, ToGammaSpace)),
  105283. $.setFloat("exposure", j._exposure)
  105284. }),
  105285. j
  105286. }
  105287. return e.prototype.getClassName = function() {
  105288. return "ExtractHighlightsPostProcess"
  105289. }
  105290. ,
  105291. __decorate([serialize()], e.prototype, "threshold", void 0),
  105292. e
  105293. }(PostProcess);
  105294. RegisterClass("BABYLON.ExtractHighlightsPostProcess", ExtractHighlightsPostProcess);
  105295. var name$p = "bloomMergePixelShader"
  105296. , shader$p = `uniform sampler2D textureSampler;
  105297. uniform sampler2D bloomBlur;
  105298. varying vec2 vUV;
  105299. uniform float bloomWeight;
  105300. void main(void)
  105301. {
  105302. gl_FragColor=texture2D(textureSampler,vUV);
  105303. vec3 blurred=texture2D(bloomBlur,vUV).rgb;
  105304. gl_FragColor.rgb=gl_FragColor.rgb+(blurred.rgb*bloomWeight);
  105305. }
  105306. `;
  105307. ShaderStore.ShadersStore[name$p] = shader$p;
  105308. var BloomMergePostProcess = function(a) {
  105309. __extends(e, a);
  105310. function e(i, o, s, c, d, _, b, k, j, $, _e) {
  105311. $ === void 0 && ($ = 0),
  105312. _e === void 0 && (_e = !1);
  105313. var et = a.call(this, i, "bloomMerge", ["bloomWeight"], ["bloomBlur"], d, _, b, k, j, null, $, void 0, null, !0) || this;
  105314. return et.weight = 1,
  105315. et.weight = c,
  105316. et.externalTextureSamplerBinding = !0,
  105317. et.onApplyObservable.add(function(tt) {
  105318. tt.setTextureFromPostProcess("textureSampler", o),
  105319. tt.setTextureFromPostProcessOutput("bloomBlur", s),
  105320. tt.setFloat("bloomWeight", et.weight)
  105321. }),
  105322. _e || et.updateEffect(),
  105323. et
  105324. }
  105325. return e.prototype.getClassName = function() {
  105326. return "BloomMergePostProcess"
  105327. }
  105328. ,
  105329. __decorate([serialize()], e.prototype, "weight", void 0),
  105330. e
  105331. }(PostProcess);
  105332. RegisterClass("BABYLON.BloomMergePostProcess", BloomMergePostProcess);
  105333. var BloomEffect = function(a) {
  105334. __extends(e, a);
  105335. function e(i, o, s, c, d, _) {
  105336. d === void 0 && (d = 0),
  105337. _ === void 0 && (_ = !1);
  105338. var b = a.call(this, i.getEngine(), "bloom", function() {
  105339. return b._effects
  105340. }, !0) || this;
  105341. return b.bloomScale = o,
  105342. b._effects = [],
  105343. b._downscale = new ExtractHighlightsPostProcess("highlights",1,null,Texture.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,d,_),
  105344. b._blurX = new BlurPostProcess("horizontal blur",new Vector2(1,0),10,o,null,Texture.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,d,void 0,_),
  105345. b._blurX.alwaysForcePOT = !0,
  105346. b._blurX.autoClear = !1,
  105347. b._blurY = new BlurPostProcess("vertical blur",new Vector2(0,1),10,o,null,Texture.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,d,void 0,_),
  105348. b._blurY.alwaysForcePOT = !0,
  105349. b._blurY.autoClear = !1,
  105350. b.kernel = c,
  105351. b._effects = [b._downscale, b._blurX, b._blurY],
  105352. b._merge = new BloomMergePostProcess("bloomMerge",b._downscale,b._blurY,s,o,null,Texture.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,d,_),
  105353. b._merge.autoClear = !1,
  105354. b._effects.push(b._merge),
  105355. b
  105356. }
  105357. return Object.defineProperty(e.prototype, "threshold", {
  105358. get: function() {
  105359. return this._downscale.threshold
  105360. },
  105361. set: function(i) {
  105362. this._downscale.threshold = i
  105363. },
  105364. enumerable: !1,
  105365. configurable: !0
  105366. }),
  105367. Object.defineProperty(e.prototype, "weight", {
  105368. get: function() {
  105369. return this._merge.weight
  105370. },
  105371. set: function(i) {
  105372. this._merge.weight = i
  105373. },
  105374. enumerable: !1,
  105375. configurable: !0
  105376. }),
  105377. Object.defineProperty(e.prototype, "kernel", {
  105378. get: function() {
  105379. return this._blurX.kernel / this.bloomScale
  105380. },
  105381. set: function(i) {
  105382. this._blurX.kernel = i * this.bloomScale,
  105383. this._blurY.kernel = i * this.bloomScale
  105384. },
  105385. enumerable: !1,
  105386. configurable: !0
  105387. }),
  105388. e.prototype.disposeEffects = function(i) {
  105389. for (var o = 0; o < this._effects.length; o++)
  105390. this._effects[o].dispose(i)
  105391. }
  105392. ,
  105393. e.prototype._updateEffects = function() {
  105394. for (var i = 0; i < this._effects.length; i++)
  105395. this._effects[i].updateEffect()
  105396. }
  105397. ,
  105398. e.prototype._isReady = function() {
  105399. for (var i = 0; i < this._effects.length; i++)
  105400. if (!this._effects[i].isReady())
  105401. return !1;
  105402. return !0
  105403. }
  105404. ,
  105405. e
  105406. }(PostProcessRenderEffect)
  105407. , PostProcessRenderPipelineManager = function() {
  105408. function a() {
  105409. this._renderPipelines = {}
  105410. }
  105411. return Object.defineProperty(a.prototype, "supportedPipelines", {
  105412. get: function() {
  105413. var e = [];
  105414. for (var i in this._renderPipelines)
  105415. if (this._renderPipelines.hasOwnProperty(i)) {
  105416. var o = this._renderPipelines[i];
  105417. o.isSupported && e.push(o)
  105418. }
  105419. return e
  105420. },
  105421. enumerable: !1,
  105422. configurable: !0
  105423. }),
  105424. a.prototype.addPipeline = function(e) {
  105425. this._renderPipelines[e._name] = e
  105426. }
  105427. ,
  105428. a.prototype.attachCamerasToRenderPipeline = function(e, i, o) {
  105429. o === void 0 && (o = !1);
  105430. var s = this._renderPipelines[e];
  105431. !s || s._attachCameras(i, o)
  105432. }
  105433. ,
  105434. a.prototype.detachCamerasFromRenderPipeline = function(e, i) {
  105435. var o = this._renderPipelines[e];
  105436. !o || o._detachCameras(i)
  105437. }
  105438. ,
  105439. a.prototype.enableEffectInPipeline = function(e, i, o) {
  105440. var s = this._renderPipelines[e];
  105441. !s || s._enableEffect(i, o)
  105442. }
  105443. ,
  105444. a.prototype.disableEffectInPipeline = function(e, i, o) {
  105445. var s = this._renderPipelines[e];
  105446. !s || s._disableEffect(i, o)
  105447. }
  105448. ,
  105449. a.prototype.update = function() {
  105450. for (var e in this._renderPipelines)
  105451. if (this._renderPipelines.hasOwnProperty(e)) {
  105452. var i = this._renderPipelines[e];
  105453. i.isSupported ? i._update() : (i.dispose(),
  105454. delete this._renderPipelines[e])
  105455. }
  105456. }
  105457. ,
  105458. a.prototype._rebuild = function() {
  105459. for (var e in this._renderPipelines)
  105460. if (this._renderPipelines.hasOwnProperty(e)) {
  105461. var i = this._renderPipelines[e];
  105462. i._rebuild()
  105463. }
  105464. }
  105465. ,
  105466. a.prototype.dispose = function() {
  105467. for (var e in this._renderPipelines)
  105468. if (this._renderPipelines.hasOwnProperty(e)) {
  105469. var i = this._renderPipelines[e];
  105470. i.dispose()
  105471. }
  105472. }
  105473. ,
  105474. a
  105475. }();
  105476. Object.defineProperty(Scene.prototype, "postProcessRenderPipelineManager", {
  105477. get: function() {
  105478. if (!this._postProcessRenderPipelineManager) {
  105479. var a = this._getComponent(SceneComponentConstants.NAME_POSTPROCESSRENDERPIPELINEMANAGER);
  105480. a || (a = new PostProcessRenderPipelineManagerSceneComponent(this),
  105481. this._addComponent(a)),
  105482. this._postProcessRenderPipelineManager = new PostProcessRenderPipelineManager
  105483. }
  105484. return this._postProcessRenderPipelineManager
  105485. },
  105486. enumerable: !0,
  105487. configurable: !0
  105488. });
  105489. var PostProcessRenderPipelineManagerSceneComponent = function() {
  105490. function a(e) {
  105491. this.name = SceneComponentConstants.NAME_POSTPROCESSRENDERPIPELINEMANAGER,
  105492. this.scene = e
  105493. }
  105494. return a.prototype.register = function() {
  105495. this.scene._gatherRenderTargetsStage.registerStep(SceneComponentConstants.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER, this, this._gatherRenderTargets)
  105496. }
  105497. ,
  105498. a.prototype.rebuild = function() {
  105499. this.scene._postProcessRenderPipelineManager && this.scene._postProcessRenderPipelineManager._rebuild()
  105500. }
  105501. ,
  105502. a.prototype.dispose = function() {
  105503. this.scene._postProcessRenderPipelineManager && this.scene._postProcessRenderPipelineManager.dispose()
  105504. }
  105505. ,
  105506. a.prototype._gatherRenderTargets = function() {
  105507. this.scene._postProcessRenderPipelineManager && this.scene._postProcessRenderPipelineManager.update()
  105508. }
  105509. ,
  105510. a
  105511. }()
  105512. , DefaultRenderingPipeline = function(a) {
  105513. __extends(e, a);
  105514. function e(i, o, s, c, d) {
  105515. i === void 0 && (i = ""),
  105516. o === void 0 && (o = !0),
  105517. s === void 0 && (s = EngineStore.LastCreatedScene),
  105518. d === void 0 && (d = !0);
  105519. var _ = a.call(this, s.getEngine(), i) || this;
  105520. _._camerasToBeAttached = [],
  105521. _.SharpenPostProcessId = "SharpenPostProcessEffect",
  105522. _.ImageProcessingPostProcessId = "ImageProcessingPostProcessEffect",
  105523. _.FxaaPostProcessId = "FxaaPostProcessEffect",
  105524. _.ChromaticAberrationPostProcessId = "ChromaticAberrationPostProcessEffect",
  105525. _.GrainPostProcessId = "GrainPostProcessEffect",
  105526. _._glowLayer = null,
  105527. _.animations = [],
  105528. _._imageProcessingConfigurationObserver = null,
  105529. _._sharpenEnabled = !1,
  105530. _._bloomEnabled = !1,
  105531. _._depthOfFieldEnabled = !1,
  105532. _._depthOfFieldBlurLevel = DepthOfFieldEffectBlurLevel.Low,
  105533. _._fxaaEnabled = !1,
  105534. _._imageProcessingEnabled = !0,
  105535. _._bloomScale = .5,
  105536. _._chromaticAberrationEnabled = !1,
  105537. _._grainEnabled = !1,
  105538. _._buildAllowed = !0,
  105539. _.onBuildObservable = new Observable,
  105540. _._resizeObserver = null,
  105541. _._hardwareScaleLevel = 1,
  105542. _._bloomKernel = 64,
  105543. _._bloomWeight = .15,
  105544. _._bloomThreshold = .9,
  105545. _._samples = 1,
  105546. _._hasCleared = !1,
  105547. _._prevPostProcess = null,
  105548. _._prevPrevPostProcess = null,
  105549. _._depthOfFieldSceneObserver = null,
  105550. _._cameras = c || s.cameras,
  105551. _._cameras = _._cameras.slice(),
  105552. _._camerasToBeAttached = _._cameras.slice(),
  105553. _._buildAllowed = d,
  105554. _._scene = s;
  105555. var b = _._scene.getEngine().getCaps();
  105556. _._hdr = o && (b.textureHalfFloatRender || b.textureFloatRender),
  105557. _._hdr ? b.textureHalfFloatRender ? _._defaultPipelineTextureType = 2 : b.textureFloatRender && (_._defaultPipelineTextureType = 1) : _._defaultPipelineTextureType = 0,
  105558. s.postProcessRenderPipelineManager.addPipeline(_);
  105559. var k = _._scene.getEngine();
  105560. return _.sharpen = new SharpenPostProcess("sharpen",1,null,Texture.BILINEAR_SAMPLINGMODE,k,!1,_._defaultPipelineTextureType,!0),
  105561. _._sharpenEffect = new PostProcessRenderEffect(k,_.SharpenPostProcessId,function() {
  105562. return _.sharpen
  105563. }
  105564. ,!0),
  105565. _.depthOfField = new DepthOfFieldEffect(_._scene,null,_._depthOfFieldBlurLevel,_._defaultPipelineTextureType,!0),
  105566. _.bloom = new BloomEffect(_._scene,_._bloomScale,_._bloomWeight,_.bloomKernel,_._defaultPipelineTextureType,!0),
  105567. _.chromaticAberration = new ChromaticAberrationPostProcess("ChromaticAberration",k.getRenderWidth(),k.getRenderHeight(),1,null,Texture.BILINEAR_SAMPLINGMODE,k,!1,_._defaultPipelineTextureType,!0),
  105568. _._chromaticAberrationEffect = new PostProcessRenderEffect(k,_.ChromaticAberrationPostProcessId,function() {
  105569. return _.chromaticAberration
  105570. }
  105571. ,!0),
  105572. _.grain = new GrainPostProcess("Grain",1,null,Texture.BILINEAR_SAMPLINGMODE,k,!1,_._defaultPipelineTextureType,!0),
  105573. _._grainEffect = new PostProcessRenderEffect(k,_.GrainPostProcessId,function() {
  105574. return _.grain
  105575. }
  105576. ,!0),
  105577. _._resizeObserver = k.onResizeObservable.add(function() {
  105578. _._hardwareScaleLevel = k.getHardwareScalingLevel(),
  105579. _.bloomKernel = _.bloomKernel
  105580. }),
  105581. _._imageProcessingConfigurationObserver = _._scene.imageProcessingConfiguration.onUpdateParameters.add(function() {
  105582. _.bloom._downscale._exposure = _._scene.imageProcessingConfiguration.exposure,
  105583. _.imageProcessingEnabled !== _._scene.imageProcessingConfiguration.isEnabled && (_._imageProcessingEnabled = _._scene.imageProcessingConfiguration.isEnabled,
  105584. _._buildPipeline())
  105585. }),
  105586. _._buildPipeline(),
  105587. _
  105588. }
  105589. return Object.defineProperty(e.prototype, "scene", {
  105590. get: function() {
  105591. return this._scene
  105592. },
  105593. enumerable: !1,
  105594. configurable: !0
  105595. }),
  105596. Object.defineProperty(e.prototype, "sharpenEnabled", {
  105597. get: function() {
  105598. return this._sharpenEnabled
  105599. },
  105600. set: function(i) {
  105601. this._sharpenEnabled !== i && (this._sharpenEnabled = i,
  105602. this._buildPipeline())
  105603. },
  105604. enumerable: !1,
  105605. configurable: !0
  105606. }),
  105607. Object.defineProperty(e.prototype, "bloomKernel", {
  105608. get: function() {
  105609. return this._bloomKernel
  105610. },
  105611. set: function(i) {
  105612. this._bloomKernel = i,
  105613. this.bloom.kernel = i / this._hardwareScaleLevel
  105614. },
  105615. enumerable: !1,
  105616. configurable: !0
  105617. }),
  105618. Object.defineProperty(e.prototype, "bloomWeight", {
  105619. get: function() {
  105620. return this._bloomWeight
  105621. },
  105622. set: function(i) {
  105623. this._bloomWeight !== i && (this.bloom.weight = i,
  105624. this._bloomWeight = i)
  105625. },
  105626. enumerable: !1,
  105627. configurable: !0
  105628. }),
  105629. Object.defineProperty(e.prototype, "bloomThreshold", {
  105630. get: function() {
  105631. return this._bloomThreshold
  105632. },
  105633. set: function(i) {
  105634. this._bloomThreshold !== i && (this.bloom.threshold = i,
  105635. this._bloomThreshold = i)
  105636. },
  105637. enumerable: !1,
  105638. configurable: !0
  105639. }),
  105640. Object.defineProperty(e.prototype, "bloomScale", {
  105641. get: function() {
  105642. return this._bloomScale
  105643. },
  105644. set: function(i) {
  105645. this._bloomScale !== i && (this._bloomScale = i,
  105646. this._rebuildBloom(),
  105647. this._buildPipeline())
  105648. },
  105649. enumerable: !1,
  105650. configurable: !0
  105651. }),
  105652. Object.defineProperty(e.prototype, "bloomEnabled", {
  105653. get: function() {
  105654. return this._bloomEnabled
  105655. },
  105656. set: function(i) {
  105657. this._bloomEnabled !== i && (this._bloomEnabled = i,
  105658. this._buildPipeline())
  105659. },
  105660. enumerable: !1,
  105661. configurable: !0
  105662. }),
  105663. e.prototype._rebuildBloom = function() {
  105664. var i = this.bloom;
  105665. this.bloom = new BloomEffect(this._scene,this.bloomScale,this._bloomWeight,this.bloomKernel,this._defaultPipelineTextureType,!1),
  105666. this.bloom.threshold = i.threshold;
  105667. for (var o = 0; o < this._cameras.length; o++)
  105668. i.disposeEffects(this._cameras[o])
  105669. }
  105670. ,
  105671. Object.defineProperty(e.prototype, "depthOfFieldEnabled", {
  105672. get: function() {
  105673. return this._depthOfFieldEnabled
  105674. },
  105675. set: function(i) {
  105676. this._depthOfFieldEnabled !== i && (this._depthOfFieldEnabled = i,
  105677. this._buildPipeline())
  105678. },
  105679. enumerable: !1,
  105680. configurable: !0
  105681. }),
  105682. Object.defineProperty(e.prototype, "depthOfFieldBlurLevel", {
  105683. get: function() {
  105684. return this._depthOfFieldBlurLevel
  105685. },
  105686. set: function(i) {
  105687. if (this._depthOfFieldBlurLevel !== i) {
  105688. this._depthOfFieldBlurLevel = i;
  105689. var o = this.depthOfField;
  105690. this.depthOfField = new DepthOfFieldEffect(this._scene,null,this._depthOfFieldBlurLevel,this._defaultPipelineTextureType,!1),
  105691. this.depthOfField.focalLength = o.focalLength,
  105692. this.depthOfField.focusDistance = o.focusDistance,
  105693. this.depthOfField.fStop = o.fStop,
  105694. this.depthOfField.lensSize = o.lensSize;
  105695. for (var s = 0; s < this._cameras.length; s++)
  105696. o.disposeEffects(this._cameras[s]);
  105697. this._buildPipeline()
  105698. }
  105699. },
  105700. enumerable: !1,
  105701. configurable: !0
  105702. }),
  105703. Object.defineProperty(e.prototype, "fxaaEnabled", {
  105704. get: function() {
  105705. return this._fxaaEnabled
  105706. },
  105707. set: function(i) {
  105708. this._fxaaEnabled !== i && (this._fxaaEnabled = i,
  105709. this._buildPipeline())
  105710. },
  105711. enumerable: !1,
  105712. configurable: !0
  105713. }),
  105714. Object.defineProperty(e.prototype, "samples", {
  105715. get: function() {
  105716. return this._samples
  105717. },
  105718. set: function(i) {
  105719. this._samples !== i && (this._samples = i,
  105720. this._buildPipeline())
  105721. },
  105722. enumerable: !1,
  105723. configurable: !0
  105724. }),
  105725. Object.defineProperty(e.prototype, "imageProcessingEnabled", {
  105726. get: function() {
  105727. return this._imageProcessingEnabled
  105728. },
  105729. set: function(i) {
  105730. this._imageProcessingEnabled !== i && (this._scene.imageProcessingConfiguration.isEnabled = i)
  105731. },
  105732. enumerable: !1,
  105733. configurable: !0
  105734. }),
  105735. Object.defineProperty(e.prototype, "glowLayerEnabled", {
  105736. get: function() {
  105737. return this._glowLayer != null
  105738. },
  105739. set: function(i) {
  105740. i && !this._glowLayer ? this._glowLayer = new GlowLayer("",this._scene) : !i && this._glowLayer && (this._glowLayer.dispose(),
  105741. this._glowLayer = null)
  105742. },
  105743. enumerable: !1,
  105744. configurable: !0
  105745. }),
  105746. Object.defineProperty(e.prototype, "glowLayer", {
  105747. get: function() {
  105748. return this._glowLayer
  105749. },
  105750. enumerable: !1,
  105751. configurable: !0
  105752. }),
  105753. Object.defineProperty(e.prototype, "chromaticAberrationEnabled", {
  105754. get: function() {
  105755. return this._chromaticAberrationEnabled
  105756. },
  105757. set: function(i) {
  105758. this._chromaticAberrationEnabled !== i && (this._chromaticAberrationEnabled = i,
  105759. this._buildPipeline())
  105760. },
  105761. enumerable: !1,
  105762. configurable: !0
  105763. }),
  105764. Object.defineProperty(e.prototype, "grainEnabled", {
  105765. get: function() {
  105766. return this._grainEnabled
  105767. },
  105768. set: function(i) {
  105769. this._grainEnabled !== i && (this._grainEnabled = i,
  105770. this._buildPipeline())
  105771. },
  105772. enumerable: !1,
  105773. configurable: !0
  105774. }),
  105775. e.prototype.getClassName = function() {
  105776. return "DefaultRenderingPipeline"
  105777. }
  105778. ,
  105779. e.prototype.prepare = function() {
  105780. var i = this._buildAllowed;
  105781. this._buildAllowed = !0,
  105782. this._buildPipeline(),
  105783. this._buildAllowed = i
  105784. }
  105785. ,
  105786. e.prototype._setAutoClearAndTextureSharing = function(i, o) {
  105787. o === void 0 && (o = !1),
  105788. this._hasCleared ? i.autoClear = !1 : (i.autoClear = !0,
  105789. this._scene.autoClear = !1,
  105790. this._hasCleared = !0),
  105791. o || (this._prevPrevPostProcess ? i.shareOutputWith(this._prevPrevPostProcess) : i.useOwnOutput(),
  105792. this._prevPostProcess && (this._prevPrevPostProcess = this._prevPostProcess),
  105793. this._prevPostProcess = i)
  105794. }
  105795. ,
  105796. e.prototype._buildPipeline = function() {
  105797. var i = this;
  105798. if (!!this._buildAllowed) {
  105799. this._scene.autoClear = !0;
  105800. var o = this._scene.getEngine();
  105801. if (this._disposePostProcesses(),
  105802. this._cameras !== null && (this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras),
  105803. this._cameras = this._camerasToBeAttached.slice()),
  105804. this._reset(),
  105805. this._prevPostProcess = null,
  105806. this._prevPrevPostProcess = null,
  105807. this._hasCleared = !1,
  105808. this.depthOfFieldEnabled) {
  105809. if (this._cameras.length > 1) {
  105810. for (var s = 0, c = this._cameras; s < c.length; s++) {
  105811. var d = c[s]
  105812. , _ = this._scene.enableDepthRenderer(d);
  105813. _.useOnlyInActiveCamera = !0
  105814. }
  105815. this._depthOfFieldSceneObserver = this._scene.onAfterRenderTargetsRenderObservable.add(function(b) {
  105816. i._cameras.indexOf(b.activeCamera) > -1 && (i.depthOfField.depthTexture = b.enableDepthRenderer(b.activeCamera).getDepthMap())
  105817. })
  105818. } else {
  105819. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  105820. var _ = this._scene.enableDepthRenderer(this._cameras[0]);
  105821. this.depthOfField.depthTexture = _.getDepthMap()
  105822. }
  105823. this.depthOfField._isReady() || this.depthOfField._updateEffects(),
  105824. this.addEffect(this.depthOfField),
  105825. this._setAutoClearAndTextureSharing(this.depthOfField._effects[0], !0)
  105826. } else
  105827. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  105828. this.bloomEnabled && (this.bloom._isReady() || this.bloom._updateEffects(),
  105829. this.addEffect(this.bloom),
  105830. this._setAutoClearAndTextureSharing(this.bloom._effects[0], !0)),
  105831. this._imageProcessingEnabled && (this.imageProcessing = new ImageProcessingPostProcess("imageProcessing",1,null,Texture.BILINEAR_SAMPLINGMODE,o,!1,this._defaultPipelineTextureType),
  105832. this._hdr ? (this.addEffect(new PostProcessRenderEffect(o,this.ImageProcessingPostProcessId,function() {
  105833. return i.imageProcessing
  105834. }
  105835. ,!0)),
  105836. this._setAutoClearAndTextureSharing(this.imageProcessing)) : this._scene.imageProcessingConfiguration.applyByPostProcess = !1,
  105837. (!this.cameras || this.cameras.length === 0) && (this._scene.imageProcessingConfiguration.applyByPostProcess = !1),
  105838. this.imageProcessing.getEffect() || this.imageProcessing._updateParameters()),
  105839. this.sharpenEnabled && (this.sharpen.isReady() || this.sharpen.updateEffect(),
  105840. this.addEffect(this._sharpenEffect),
  105841. this._setAutoClearAndTextureSharing(this.sharpen)),
  105842. this.grainEnabled && (this.grain.isReady() || this.grain.updateEffect(),
  105843. this.addEffect(this._grainEffect),
  105844. this._setAutoClearAndTextureSharing(this.grain)),
  105845. this.chromaticAberrationEnabled && (this.chromaticAberration.isReady() || this.chromaticAberration.updateEffect(),
  105846. this.addEffect(this._chromaticAberrationEffect),
  105847. this._setAutoClearAndTextureSharing(this.chromaticAberration)),
  105848. this.fxaaEnabled && (this.fxaa = new FxaaPostProcess("fxaa",1,null,Texture.BILINEAR_SAMPLINGMODE,o,!1,this._defaultPipelineTextureType),
  105849. this.addEffect(new PostProcessRenderEffect(o,this.FxaaPostProcessId,function() {
  105850. return i.fxaa
  105851. }
  105852. ,!0)),
  105853. this._setAutoClearAndTextureSharing(this.fxaa, !0)),
  105854. this._cameras !== null && this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras),
  105855. this._scene.activeCameras && this._scene.activeCameras.length > 1 && (this._scene.autoClear = !0),
  105856. !this._enableMSAAOnFirstPostProcess(this.samples) && this.samples > 1 && Logger$2.Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0"),
  105857. this.onBuildObservable.notifyObservers(this)
  105858. }
  105859. }
  105860. ,
  105861. e.prototype._disposePostProcesses = function(i) {
  105862. i === void 0 && (i = !1);
  105863. for (var o = 0; o < this._cameras.length; o++) {
  105864. var s = this._cameras[o];
  105865. this.imageProcessing && this.imageProcessing.dispose(s),
  105866. this.fxaa && this.fxaa.dispose(s),
  105867. i && (this.sharpen && this.sharpen.dispose(s),
  105868. this.depthOfField && (this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver),
  105869. this.depthOfField.disposeEffects(s)),
  105870. this.bloom && this.bloom.disposeEffects(s),
  105871. this.chromaticAberration && this.chromaticAberration.dispose(s),
  105872. this.grain && this.grain.dispose(s),
  105873. this._glowLayer && this._glowLayer.dispose())
  105874. }
  105875. this.imageProcessing = null,
  105876. this.fxaa = null,
  105877. i && (this.sharpen = null,
  105878. this._sharpenEffect = null,
  105879. this.depthOfField = null,
  105880. this.bloom = null,
  105881. this.chromaticAberration = null,
  105882. this._chromaticAberrationEffect = null,
  105883. this.grain = null,
  105884. this._grainEffect = null,
  105885. this._glowLayer = null)
  105886. }
  105887. ,
  105888. e.prototype.addCamera = function(i) {
  105889. this._camerasToBeAttached.push(i),
  105890. this._buildPipeline()
  105891. }
  105892. ,
  105893. e.prototype.removeCamera = function(i) {
  105894. var o = this._camerasToBeAttached.indexOf(i);
  105895. this._camerasToBeAttached.splice(o, 1),
  105896. this._buildPipeline()
  105897. }
  105898. ,
  105899. e.prototype.dispose = function() {
  105900. this.onBuildObservable.clear(),
  105901. this._disposePostProcesses(!0),
  105902. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras),
  105903. this._scene.autoClear = !0,
  105904. this._resizeObserver && (this._scene.getEngine().onResizeObservable.remove(this._resizeObserver),
  105905. this._resizeObserver = null),
  105906. this._scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigurationObserver),
  105907. a.prototype.dispose.call(this)
  105908. }
  105909. ,
  105910. e.prototype.serialize = function() {
  105911. var i = SerializationHelper.Serialize(this);
  105912. return i.customType = "DefaultRenderingPipeline",
  105913. i
  105914. }
  105915. ,
  105916. e.Parse = function(i, o, s) {
  105917. return SerializationHelper.Parse(function() {
  105918. return new e(i._name,i._name._hdr,o)
  105919. }, i, o, s)
  105920. }
  105921. ,
  105922. __decorate([serialize()], e.prototype, "sharpenEnabled", null),
  105923. __decorate([serialize()], e.prototype, "bloomKernel", null),
  105924. __decorate([serialize()], e.prototype, "_bloomWeight", void 0),
  105925. __decorate([serialize()], e.prototype, "_bloomThreshold", void 0),
  105926. __decorate([serialize()], e.prototype, "_hdr", void 0),
  105927. __decorate([serialize()], e.prototype, "bloomWeight", null),
  105928. __decorate([serialize()], e.prototype, "bloomThreshold", null),
  105929. __decorate([serialize()], e.prototype, "bloomScale", null),
  105930. __decorate([serialize()], e.prototype, "bloomEnabled", null),
  105931. __decorate([serialize()], e.prototype, "depthOfFieldEnabled", null),
  105932. __decorate([serialize()], e.prototype, "depthOfFieldBlurLevel", null),
  105933. __decorate([serialize()], e.prototype, "fxaaEnabled", null),
  105934. __decorate([serialize()], e.prototype, "samples", null),
  105935. __decorate([serialize()], e.prototype, "imageProcessingEnabled", null),
  105936. __decorate([serialize()], e.prototype, "glowLayerEnabled", null),
  105937. __decorate([serialize()], e.prototype, "chromaticAberrationEnabled", null),
  105938. __decorate([serialize()], e.prototype, "grainEnabled", null),
  105939. e
  105940. }(PostProcessRenderPipeline);
  105941. RegisterClass("BABYLON.DefaultRenderingPipeline", DefaultRenderingPipeline);
  105942. var name$o = "imageProcessingCompatibility"
  105943. , shader$o = `#ifdef IMAGEPROCESSINGPOSTPROCESS
  105944. gl_FragColor.rgb=pow(gl_FragColor.rgb,vec3(2.2));
  105945. #endif`;
  105946. ShaderStore.IncludesShadersStore[name$o] = shader$o;
  105947. var name$n = "gridPixelShader"
  105948. , shader$n = `#extension GL_OES_standard_derivatives : enable
  105949. #define SQRT2 1.41421356
  105950. #define PI 3.14159
  105951. precision highp float;
  105952. uniform float visibility;
  105953. uniform vec3 mainColor;
  105954. uniform vec3 lineColor;
  105955. uniform vec4 gridControl;
  105956. uniform vec3 gridOffset;
  105957. varying vec3 vPosition;
  105958. varying vec3 vNormal;
  105959. #include<fogFragmentDeclaration>
  105960. #ifdef OPACITY
  105961. varying vec2 vOpacityUV;
  105962. uniform sampler2D opacitySampler;
  105963. uniform vec2 vOpacityInfos;
  105964. #endif
  105965. float getDynamicVisibility(float position) {
  105966. float majorGridFrequency=gridControl.y;
  105967. if (floor(position+0.5) == floor(position/majorGridFrequency+0.5)*majorGridFrequency)
  105968. {
  105969. return 1.0;
  105970. }
  105971. return gridControl.z;
  105972. }
  105973. float getAnisotropicAttenuation(float differentialLength) {
  105974. const float maxNumberOfLines=10.0;
  105975. return clamp(1.0/(differentialLength+1.0)-1.0/maxNumberOfLines,0.0,1.0);
  105976. }
  105977. float isPointOnLine(float position,float differentialLength) {
  105978. float fractionPartOfPosition=position-floor(position+0.5);
  105979. fractionPartOfPosition/=differentialLength;
  105980. fractionPartOfPosition=clamp(fractionPartOfPosition,-1.,1.);
  105981. float result=0.5+0.5*cos(fractionPartOfPosition*PI);
  105982. return result;
  105983. }
  105984. float contributionOnAxis(float position) {
  105985. float differentialLength=length(vec2(dFdx(position),dFdy(position)));
  105986. differentialLength*=SQRT2;
  105987. float result=isPointOnLine(position,differentialLength);
  105988. float dynamicVisibility=getDynamicVisibility(position);
  105989. result*=dynamicVisibility;
  105990. float anisotropicAttenuation=getAnisotropicAttenuation(differentialLength);
  105991. result*=anisotropicAttenuation;
  105992. return result;
  105993. }
  105994. float normalImpactOnAxis(float x) {
  105995. float normalImpact=clamp(1.0-3.0*abs(x*x*x),0.0,1.0);
  105996. return normalImpact;
  105997. }
  105998. void main(void) {
  105999. float gridRatio=gridControl.x;
  106000. vec3 gridPos=(vPosition+gridOffset.xyz)/gridRatio;
  106001. float x=contributionOnAxis(gridPos.x);
  106002. float y=contributionOnAxis(gridPos.y);
  106003. float z=contributionOnAxis(gridPos.z);
  106004. vec3 normal=normalize(vNormal);
  106005. x*=normalImpactOnAxis(normal.x);
  106006. y*=normalImpactOnAxis(normal.y);
  106007. z*=normalImpactOnAxis(normal.z);
  106008. #ifdef MAX_LINE
  106009. float grid=clamp(max(max(x,y),z),0.,1.);
  106010. #else
  106011. float grid=clamp(x+y+z,0.,1.);
  106012. #endif
  106013. vec3 color=mix(mainColor,lineColor,grid);
  106014. #ifdef FOG
  106015. #include<fogFragment>
  106016. #endif
  106017. float opacity=1.0;
  106018. #ifdef TRANSPARENT
  106019. opacity=clamp(grid,0.08,gridControl.w*grid);
  106020. #endif
  106021. #ifdef OPACITY
  106022. opacity*=texture2D(opacitySampler,vOpacityUV).a;
  106023. #endif
  106024. gl_FragColor=vec4(color.rgb,opacity*visibility);
  106025. #ifdef TRANSPARENT
  106026. #ifdef PREMULTIPLYALPHA
  106027. gl_FragColor.rgb*=opacity;
  106028. #endif
  106029. #else
  106030. #endif
  106031. #include<imageProcessingCompatibility>
  106032. }
  106033. `;
  106034. ShaderStore.ShadersStore[name$n] = shader$n;
  106035. var name$m = "gridVertexShader"
  106036. , shader$m = `precision highp float;
  106037. attribute vec3 position;
  106038. attribute vec3 normal;
  106039. #ifdef UV1
  106040. attribute vec2 uv;
  106041. #endif
  106042. #ifdef UV2
  106043. attribute vec2 uv2;
  106044. #endif
  106045. #include<instancesDeclaration>
  106046. uniform mat4 projection;
  106047. uniform mat4 view;
  106048. varying vec3 vPosition;
  106049. varying vec3 vNormal;
  106050. #include<fogVertexDeclaration>
  106051. #ifdef OPACITY
  106052. varying vec2 vOpacityUV;
  106053. uniform mat4 opacityMatrix;
  106054. uniform vec2 vOpacityInfos;
  106055. #endif
  106056. void main(void) {
  106057. #include<instancesVertex>
  106058. vec4 worldPos=finalWorld*vec4(position,1.0);
  106059. #include<fogVertex>
  106060. vec4 cameraSpacePosition=view*worldPos;
  106061. gl_Position=projection*cameraSpacePosition;
  106062. #ifdef OPACITY
  106063. #ifndef UV1
  106064. vec2 uv=vec2(0.,0.);
  106065. #endif
  106066. #ifndef UV2
  106067. vec2 uv2=vec2(0.,0.);
  106068. #endif
  106069. if (vOpacityInfos.x == 0.)
  106070. {
  106071. vOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));
  106072. }
  106073. else
  106074. {
  106075. vOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));
  106076. }
  106077. #endif
  106078. vPosition=position;
  106079. vNormal=normal;
  106080. }`;
  106081. ShaderStore.ShadersStore[name$m] = shader$m;
  106082. var GridMaterialDefines = function(a) {
  106083. __extends(e, a);
  106084. function e() {
  106085. var i = a.call(this) || this;
  106086. return i.OPACITY = !1,
  106087. i.TRANSPARENT = !1,
  106088. i.FOG = !1,
  106089. i.PREMULTIPLYALPHA = !1,
  106090. i.MAX_LINE = !1,
  106091. i.UV1 = !1,
  106092. i.UV2 = !1,
  106093. i.INSTANCES = !1,
  106094. i.THIN_INSTANCES = !1,
  106095. i.IMAGEPROCESSINGPOSTPROCESS = !1,
  106096. i.SKIPFINALCOLORCLAMP = !1,
  106097. i.rebuild(),
  106098. i
  106099. }
  106100. return e
  106101. }(MaterialDefines)
  106102. , GridMaterial = function(a) {
  106103. __extends(e, a);
  106104. function e(i, o) {
  106105. var s = a.call(this, i, o) || this;
  106106. return s.mainColor = Color3.Black(),
  106107. s.lineColor = Color3.Teal(),
  106108. s.gridRatio = 1,
  106109. s.gridOffset = Vector3.Zero(),
  106110. s.majorUnitFrequency = 10,
  106111. s.minorUnitVisibility = .33,
  106112. s.opacity = 1,
  106113. s.preMultiplyAlpha = !1,
  106114. s.useMaxLine = !1,
  106115. s._gridControl = new Vector4(s.gridRatio,s.majorUnitFrequency,s.minorUnitVisibility,s.opacity),
  106116. s
  106117. }
  106118. return e.prototype.needAlphaBlending = function() {
  106119. return this.opacity < 1 || this._opacityTexture && this._opacityTexture.isReady()
  106120. }
  106121. ,
  106122. e.prototype.needAlphaBlendingForMesh = function(i) {
  106123. return i.visibility < 1 || this.needAlphaBlending()
  106124. }
  106125. ,
  106126. e.prototype.isReadyForSubMesh = function(i, o, s) {
  106127. if (this.isFrozen && o.effect && o.effect._wasPreviouslyReady)
  106128. return !0;
  106129. o.materialDefines || (o.materialDefines = new GridMaterialDefines);
  106130. var c = o.materialDefines
  106131. , d = this.getScene();
  106132. if (this._isReadyForSubMesh(o))
  106133. return !0;
  106134. if (c.TRANSPARENT !== this.opacity < 1 && (c.TRANSPARENT = !c.TRANSPARENT,
  106135. c.markAsUnprocessed()),
  106136. c.PREMULTIPLYALPHA != this.preMultiplyAlpha && (c.PREMULTIPLYALPHA = !c.PREMULTIPLYALPHA,
  106137. c.markAsUnprocessed()),
  106138. c.MAX_LINE !== this.useMaxLine && (c.MAX_LINE = !c.MAX_LINE,
  106139. c.markAsUnprocessed()),
  106140. c._areTexturesDirty && (c._needUVs = !1,
  106141. d.texturesEnabled && this._opacityTexture && MaterialFlags.OpacityTextureEnabled))
  106142. if (this._opacityTexture.isReady())
  106143. c._needUVs = !0,
  106144. c.OPACITY = !0;
  106145. else
  106146. return !1;
  106147. if (MaterialHelper.PrepareDefinesForMisc(i, d, !1, !1, this.fogEnabled, !1, c),
  106148. MaterialHelper.PrepareDefinesForFrameBoundValues(d, d.getEngine(), c, !!s),
  106149. c.isDirty) {
  106150. c.markAsProcessed(),
  106151. d.resetCachedMaterial(),
  106152. MaterialHelper.PrepareDefinesForAttributes(i, c, !1, !1);
  106153. var _ = [VertexBuffer.PositionKind, VertexBuffer.NormalKind];
  106154. c.UV1 && _.push(VertexBuffer.UVKind),
  106155. c.UV2 && _.push(VertexBuffer.UV2Kind),
  106156. c.IMAGEPROCESSINGPOSTPROCESS = d.imageProcessingConfiguration.applyByPostProcess,
  106157. MaterialHelper.PrepareAttributesForInstances(_, c);
  106158. var b = c.toString();
  106159. o.setEffect(d.getEngine().createEffect("grid", _, ["projection", "mainColor", "lineColor", "gridControl", "gridOffset", "vFogInfos", "vFogColor", "world", "view", "opacityMatrix", "vOpacityInfos", "visibility"], ["opacitySampler"], b, void 0, this.onCompiled, this.onError), c, this._materialContext)
  106160. }
  106161. return !o.effect || !o.effect.isReady() ? !1 : (c._renderId = d.getRenderId(),
  106162. o.effect._wasPreviouslyReady = !0,
  106163. !0)
  106164. }
  106165. ,
  106166. e.prototype.bindForSubMesh = function(i, o, s) {
  106167. var c = this.getScene()
  106168. , d = s.materialDefines;
  106169. if (!!d) {
  106170. var _ = s.effect;
  106171. !_ || (this._activeEffect = _,
  106172. this._activeEffect.setFloat("visibility", o.visibility),
  106173. (!d.INSTANCES || d.THIN_INSTANCE) && this.bindOnlyWorldMatrix(i),
  106174. this._activeEffect.setMatrix("view", c.getViewMatrix()),
  106175. this._activeEffect.setMatrix("projection", c.getProjectionMatrix()),
  106176. this._mustRebind(c, _) && (this._activeEffect.setColor3("mainColor", this.mainColor),
  106177. this._activeEffect.setColor3("lineColor", this.lineColor),
  106178. this._activeEffect.setVector3("gridOffset", this.gridOffset),
  106179. this._gridControl.x = this.gridRatio,
  106180. this._gridControl.y = Math.round(this.majorUnitFrequency),
  106181. this._gridControl.z = this.minorUnitVisibility,
  106182. this._gridControl.w = this.opacity,
  106183. this._activeEffect.setVector4("gridControl", this._gridControl),
  106184. this._opacityTexture && MaterialFlags.OpacityTextureEnabled && (this._activeEffect.setTexture("opacitySampler", this._opacityTexture),
  106185. this._activeEffect.setFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level),
  106186. this._activeEffect.setMatrix("opacityMatrix", this._opacityTexture.getTextureMatrix()))),
  106187. MaterialHelper.BindFogParameters(c, o, this._activeEffect),
  106188. this._afterBind(o, this._activeEffect))
  106189. }
  106190. }
  106191. ,
  106192. e.prototype.dispose = function(i) {
  106193. a.prototype.dispose.call(this, i)
  106194. }
  106195. ,
  106196. e.prototype.clone = function(i) {
  106197. var o = this;
  106198. return SerializationHelper.Clone(function() {
  106199. return new e(i,o.getScene())
  106200. }, this)
  106201. }
  106202. ,
  106203. e.prototype.serialize = function() {
  106204. var i = SerializationHelper.Serialize(this);
  106205. return i.customType = "BABYLON.GridMaterial",
  106206. i
  106207. }
  106208. ,
  106209. e.prototype.getClassName = function() {
  106210. return "GridMaterial"
  106211. }
  106212. ,
  106213. e.Parse = function(i, o, s) {
  106214. return SerializationHelper.Parse(function() {
  106215. return new e(i.name,o)
  106216. }, i, o, s)
  106217. }
  106218. ,
  106219. __decorate([serializeAsColor3()], e.prototype, "mainColor", void 0),
  106220. __decorate([serializeAsColor3()], e.prototype, "lineColor", void 0),
  106221. __decorate([serialize()], e.prototype, "gridRatio", void 0),
  106222. __decorate([serializeAsVector3()], e.prototype, "gridOffset", void 0),
  106223. __decorate([serialize()], e.prototype, "majorUnitFrequency", void 0),
  106224. __decorate([serialize()], e.prototype, "minorUnitVisibility", void 0),
  106225. __decorate([serialize()], e.prototype, "opacity", void 0),
  106226. __decorate([serialize()], e.prototype, "preMultiplyAlpha", void 0),
  106227. __decorate([serialize()], e.prototype, "useMaxLine", void 0),
  106228. __decorate([serializeAsTexture("opacityTexture")], e.prototype, "_opacityTexture", void 0),
  106229. __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "opacityTexture", void 0),
  106230. e
  106231. }(PushMaterial);
  106232. RegisterClass("BABYLON.GridMaterial", GridMaterial);
  106233. var SceneInstrumentation = function() {
  106234. function a(e) {
  106235. var i = this;
  106236. this.scene = e,
  106237. this._captureActiveMeshesEvaluationTime = !1,
  106238. this._activeMeshesEvaluationTime = new PerfCounter,
  106239. this._captureRenderTargetsRenderTime = !1,
  106240. this._renderTargetsRenderTime = new PerfCounter,
  106241. this._registerBeforeRenderTime = new PerfCounter,
  106242. this._onBeforeRegisterBeforeRenderObserver = null,
  106243. this._onAfterRegisterBeforeRenderObserver = null,
  106244. this._RTT1Time = new PerfCounter,
  106245. this._onBeforeRTT1Observer = null,
  106246. this._onAfterRTT1Observer = null,
  106247. this._registerAfterRenderTime = new PerfCounter,
  106248. this._onBeforeRegisterAfterRenderObserver = null,
  106249. this._onAfterRegisterAfterRenderObserver = null,
  106250. this._captureFrameTime = !1,
  106251. this._frameTime = new PerfCounter,
  106252. this._captureRenderTime = !1,
  106253. this._renderTime = new PerfCounter,
  106254. this._captureInterFrameTime = !1,
  106255. this._interFrameTime = new PerfCounter,
  106256. this._captureParticlesRenderTime = !1,
  106257. this._particlesRenderTime = new PerfCounter,
  106258. this._captureSpritesRenderTime = !1,
  106259. this._spritesRenderTime = new PerfCounter,
  106260. this._capturePhysicsTime = !1,
  106261. this._physicsTime = new PerfCounter,
  106262. this._captureAnimationsTime = !1,
  106263. this._animationsTime = new PerfCounter,
  106264. this._captureCameraRenderTime = !1,
  106265. this._cameraRenderTime = new PerfCounter,
  106266. this._onBeforeActiveMeshesEvaluationObserver = null,
  106267. this._onAfterActiveMeshesEvaluationObserver = null,
  106268. this._onBeforeRenderTargetsRenderObserver = null,
  106269. this._onAfterRenderTargetsRenderObserver = null,
  106270. this._onAfterRenderObserver = null,
  106271. this._onBeforeDrawPhaseObserver = null,
  106272. this._onAfterDrawPhaseObserver = null,
  106273. this._onBeforeAnimationsObserver = null,
  106274. this._onBeforeParticlesRenderingObserver = null,
  106275. this._onAfterParticlesRenderingObserver = null,
  106276. this._onBeforeSpritesRenderingObserver = null,
  106277. this._onAfterSpritesRenderingObserver = null,
  106278. this._onBeforePhysicsObserver = null,
  106279. this._onAfterPhysicsObserver = null,
  106280. this._onAfterAnimationsObserver = null,
  106281. this._onBeforeCameraRenderObserver = null,
  106282. this._onAfterCameraRenderObserver = null,
  106283. this._onBeforeAnimationsObserver = e.onBeforeAnimationsObservable.add(function() {
  106284. i._captureActiveMeshesEvaluationTime && i._activeMeshesEvaluationTime.fetchNewFrame(),
  106285. i._captureRenderTargetsRenderTime && i._renderTargetsRenderTime.fetchNewFrame(),
  106286. i._captureFrameTime && (Tools.StartPerformanceCounter("Scene rendering"),
  106287. i._frameTime.beginMonitoring()),
  106288. i._captureInterFrameTime && i._interFrameTime.endMonitoring(),
  106289. i._captureParticlesRenderTime && i._particlesRenderTime.fetchNewFrame(),
  106290. i._captureSpritesRenderTime && i._spritesRenderTime.fetchNewFrame(),
  106291. i._captureAnimationsTime && i._animationsTime.beginMonitoring(),
  106292. i.scene.getEngine()._drawCalls.fetchNewFrame()
  106293. }),
  106294. this._onAfterRenderObserver = e.onAfterRenderObservable.add(function() {
  106295. i._captureFrameTime && (Tools.EndPerformanceCounter("Scene rendering"),
  106296. i._frameTime.endMonitoring()),
  106297. i._captureRenderTime && i._renderTime.endMonitoring(!1),
  106298. i._captureInterFrameTime && i._interFrameTime.beginMonitoring()
  106299. }),
  106300. this._onBeforeRegisterBeforeRenderObserver = e.onBeforeRunRegisterBeforeRenderObservable.add(function() {
  106301. i._registerBeforeRenderTime.beginMonitoring()
  106302. }),
  106303. this._onAfterRegisterBeforeRenderObserver = e.onAfterRunRegisterBeforeRenderObservable.add(function() {
  106304. i._registerBeforeRenderTime.endMonitoring()
  106305. }),
  106306. this._onBeforeRegisterAfterRenderObserver = e.onBeforeRunRegisterAfterRenderObservable.add(function() {
  106307. i._registerAfterRenderTime.beginMonitoring()
  106308. }),
  106309. this._onAfterRegisterAfterRenderObserver = e.onAfterRunRegisterAfterRenderObservable.add(function() {
  106310. i._registerAfterRenderTime.endMonitoring()
  106311. }),
  106312. this._onBeforeRTT1Observer = e.onBeforeRTT1Observable.add(function() {
  106313. i._RTT1Time.beginMonitoring()
  106314. }),
  106315. this._onAfterRTT1Observer = e.onAfterRTT1Observable.add(function() {
  106316. i._RTT1Time.endMonitoring()
  106317. })
  106318. }
  106319. return Object.defineProperty(a.prototype, "activeMeshesEvaluationTimeCounter", {
  106320. get: function() {
  106321. return this._activeMeshesEvaluationTime
  106322. },
  106323. enumerable: !1,
  106324. configurable: !0
  106325. }),
  106326. Object.defineProperty(a.prototype, "captureActiveMeshesEvaluationTime", {
  106327. get: function() {
  106328. return this._captureActiveMeshesEvaluationTime
  106329. },
  106330. set: function(e) {
  106331. var i = this;
  106332. e !== this._captureActiveMeshesEvaluationTime && (this._captureActiveMeshesEvaluationTime = e,
  106333. e ? (this._onBeforeActiveMeshesEvaluationObserver = this.scene.onBeforeActiveMeshesEvaluationObservable.add(function() {
  106334. Tools.StartPerformanceCounter("Active meshes evaluation"),
  106335. i._activeMeshesEvaluationTime.beginMonitoring()
  106336. }),
  106337. this._onAfterActiveMeshesEvaluationObserver = this.scene.onAfterActiveMeshesEvaluationObservable.add(function() {
  106338. Tools.EndPerformanceCounter("Active meshes evaluation"),
  106339. i._activeMeshesEvaluationTime.endMonitoring()
  106340. })) : (this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver),
  106341. this._onBeforeActiveMeshesEvaluationObserver = null,
  106342. this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver),
  106343. this._onAfterActiveMeshesEvaluationObserver = null))
  106344. },
  106345. enumerable: !1,
  106346. configurable: !0
  106347. }),
  106348. Object.defineProperty(a.prototype, "renderTargetsRenderTimeCounter", {
  106349. get: function() {
  106350. return this._renderTargetsRenderTime
  106351. },
  106352. enumerable: !1,
  106353. configurable: !0
  106354. }),
  106355. Object.defineProperty(a.prototype, "registerBeforeTimeCounter", {
  106356. get: function() {
  106357. return this._registerBeforeRenderTime
  106358. },
  106359. enumerable: !1,
  106360. configurable: !0
  106361. }),
  106362. Object.defineProperty(a.prototype, "getRTT1TimeCounter", {
  106363. get: function() {
  106364. return this._RTT1Time
  106365. },
  106366. enumerable: !1,
  106367. configurable: !0
  106368. }),
  106369. Object.defineProperty(a.prototype, "registerAfterTimeCounter", {
  106370. get: function() {
  106371. return this._registerAfterRenderTime
  106372. },
  106373. enumerable: !1,
  106374. configurable: !0
  106375. }),
  106376. Object.defineProperty(a.prototype, "captureRenderTargetsRenderTime", {
  106377. get: function() {
  106378. return this._captureRenderTargetsRenderTime
  106379. },
  106380. set: function(e) {
  106381. var i = this;
  106382. e !== this._captureRenderTargetsRenderTime && (this._captureRenderTargetsRenderTime = e,
  106383. e ? (this._onBeforeRenderTargetsRenderObserver = this.scene.onBeforeRenderTargetsRenderObservable.add(function() {
  106384. Tools.StartPerformanceCounter("Render targets rendering"),
  106385. i._renderTargetsRenderTime.beginMonitoring()
  106386. }),
  106387. this._onAfterRenderTargetsRenderObserver = this.scene.onAfterRenderTargetsRenderObservable.add(function() {
  106388. Tools.EndPerformanceCounter("Render targets rendering"),
  106389. i._renderTargetsRenderTime.endMonitoring(!1)
  106390. })) : (this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver),
  106391. this._onBeforeRenderTargetsRenderObserver = null,
  106392. this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver),
  106393. this._onAfterRenderTargetsRenderObserver = null))
  106394. },
  106395. enumerable: !1,
  106396. configurable: !0
  106397. }),
  106398. Object.defineProperty(a.prototype, "particlesRenderTimeCounter", {
  106399. get: function() {
  106400. return this._particlesRenderTime
  106401. },
  106402. enumerable: !1,
  106403. configurable: !0
  106404. }),
  106405. Object.defineProperty(a.prototype, "captureParticlesRenderTime", {
  106406. get: function() {
  106407. return this._captureParticlesRenderTime
  106408. },
  106409. set: function(e) {
  106410. var i = this;
  106411. e !== this._captureParticlesRenderTime && (this._captureParticlesRenderTime = e,
  106412. e ? (this._onBeforeParticlesRenderingObserver = this.scene.onBeforeParticlesRenderingObservable.add(function() {
  106413. Tools.StartPerformanceCounter("Particles"),
  106414. i._particlesRenderTime.beginMonitoring()
  106415. }),
  106416. this._onAfterParticlesRenderingObserver = this.scene.onAfterParticlesRenderingObservable.add(function() {
  106417. Tools.EndPerformanceCounter("Particles"),
  106418. i._particlesRenderTime.endMonitoring(!1)
  106419. })) : (this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver),
  106420. this._onBeforeParticlesRenderingObserver = null,
  106421. this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver),
  106422. this._onAfterParticlesRenderingObserver = null))
  106423. },
  106424. enumerable: !1,
  106425. configurable: !0
  106426. }),
  106427. Object.defineProperty(a.prototype, "spritesRenderTimeCounter", {
  106428. get: function() {
  106429. return this._spritesRenderTime
  106430. },
  106431. enumerable: !1,
  106432. configurable: !0
  106433. }),
  106434. Object.defineProperty(a.prototype, "captureSpritesRenderTime", {
  106435. get: function() {
  106436. return this._captureSpritesRenderTime
  106437. },
  106438. set: function(e) {
  106439. var i = this;
  106440. e !== this._captureSpritesRenderTime && (this._captureSpritesRenderTime = e,
  106441. this.scene.spriteManagers && (e ? (this._onBeforeSpritesRenderingObserver = this.scene.onBeforeSpritesRenderingObservable.add(function() {
  106442. Tools.StartPerformanceCounter("Sprites"),
  106443. i._spritesRenderTime.beginMonitoring()
  106444. }),
  106445. this._onAfterSpritesRenderingObserver = this.scene.onAfterSpritesRenderingObservable.add(function() {
  106446. Tools.EndPerformanceCounter("Sprites"),
  106447. i._spritesRenderTime.endMonitoring(!1)
  106448. })) : (this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver),
  106449. this._onBeforeSpritesRenderingObserver = null,
  106450. this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver),
  106451. this._onAfterSpritesRenderingObserver = null)))
  106452. },
  106453. enumerable: !1,
  106454. configurable: !0
  106455. }),
  106456. Object.defineProperty(a.prototype, "physicsTimeCounter", {
  106457. get: function() {
  106458. return this._physicsTime
  106459. },
  106460. enumerable: !1,
  106461. configurable: !0
  106462. }),
  106463. Object.defineProperty(a.prototype, "capturePhysicsTime", {
  106464. get: function() {
  106465. return this._capturePhysicsTime
  106466. },
  106467. set: function(e) {
  106468. var i = this;
  106469. e !== this._capturePhysicsTime && (!this.scene.onBeforePhysicsObservable || (this._capturePhysicsTime = e,
  106470. e ? (this._onBeforePhysicsObserver = this.scene.onBeforePhysicsObservable.add(function() {
  106471. Tools.StartPerformanceCounter("Physics"),
  106472. i._physicsTime.beginMonitoring()
  106473. }),
  106474. this._onAfterPhysicsObserver = this.scene.onAfterPhysicsObservable.add(function() {
  106475. Tools.EndPerformanceCounter("Physics"),
  106476. i._physicsTime.endMonitoring()
  106477. })) : (this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver),
  106478. this._onBeforePhysicsObserver = null,
  106479. this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver),
  106480. this._onAfterPhysicsObserver = null)))
  106481. },
  106482. enumerable: !1,
  106483. configurable: !0
  106484. }),
  106485. Object.defineProperty(a.prototype, "animationsTimeCounter", {
  106486. get: function() {
  106487. return this._animationsTime
  106488. },
  106489. enumerable: !1,
  106490. configurable: !0
  106491. }),
  106492. Object.defineProperty(a.prototype, "captureAnimationsTime", {
  106493. get: function() {
  106494. return this._captureAnimationsTime
  106495. },
  106496. set: function(e) {
  106497. var i = this;
  106498. e !== this._captureAnimationsTime && (this._captureAnimationsTime = e,
  106499. e ? this._onAfterAnimationsObserver = this.scene.onAfterAnimationsObservable.add(function() {
  106500. i._animationsTime.endMonitoring()
  106501. }) : (this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver),
  106502. this._onAfterAnimationsObserver = null))
  106503. },
  106504. enumerable: !1,
  106505. configurable: !0
  106506. }),
  106507. Object.defineProperty(a.prototype, "frameTimeCounter", {
  106508. get: function() {
  106509. return this._frameTime
  106510. },
  106511. enumerable: !1,
  106512. configurable: !0
  106513. }),
  106514. Object.defineProperty(a.prototype, "captureFrameTime", {
  106515. get: function() {
  106516. return this._captureFrameTime
  106517. },
  106518. set: function(e) {
  106519. this._captureFrameTime = e
  106520. },
  106521. enumerable: !1,
  106522. configurable: !0
  106523. }),
  106524. Object.defineProperty(a.prototype, "interFrameTimeCounter", {
  106525. get: function() {
  106526. return this._interFrameTime
  106527. },
  106528. enumerable: !1,
  106529. configurable: !0
  106530. }),
  106531. Object.defineProperty(a.prototype, "captureInterFrameTime", {
  106532. get: function() {
  106533. return this._captureInterFrameTime
  106534. },
  106535. set: function(e) {
  106536. this._captureInterFrameTime = e
  106537. },
  106538. enumerable: !1,
  106539. configurable: !0
  106540. }),
  106541. Object.defineProperty(a.prototype, "renderTimeCounter", {
  106542. get: function() {
  106543. return this._renderTime
  106544. },
  106545. enumerable: !1,
  106546. configurable: !0
  106547. }),
  106548. Object.defineProperty(a.prototype, "captureRenderTime", {
  106549. get: function() {
  106550. return this._captureRenderTime
  106551. },
  106552. set: function(e) {
  106553. var i = this;
  106554. e !== this._captureRenderTime && (this._captureRenderTime = e,
  106555. e ? (this._onBeforeDrawPhaseObserver = this.scene.onBeforeDrawPhaseObservable.add(function() {
  106556. i._renderTime.beginMonitoring(),
  106557. Tools.StartPerformanceCounter("Main render")
  106558. }),
  106559. this._onAfterDrawPhaseObserver = this.scene.onAfterDrawPhaseObservable.add(function() {
  106560. i._renderTime.endMonitoring(!1),
  106561. Tools.EndPerformanceCounter("Main render")
  106562. })) : (this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver),
  106563. this._onBeforeDrawPhaseObserver = null,
  106564. this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver),
  106565. this._onAfterDrawPhaseObserver = null))
  106566. },
  106567. enumerable: !1,
  106568. configurable: !0
  106569. }),
  106570. Object.defineProperty(a.prototype, "cameraRenderTimeCounter", {
  106571. get: function() {
  106572. return this._cameraRenderTime
  106573. },
  106574. enumerable: !1,
  106575. configurable: !0
  106576. }),
  106577. Object.defineProperty(a.prototype, "captureCameraRenderTime", {
  106578. get: function() {
  106579. return this._captureCameraRenderTime
  106580. },
  106581. set: function(e) {
  106582. var i = this;
  106583. e !== this._captureCameraRenderTime && (this._captureCameraRenderTime = e,
  106584. e ? (this._onBeforeCameraRenderObserver = this.scene.onBeforeCameraRenderObservable.add(function(o) {
  106585. i._cameraRenderTime.beginMonitoring(),
  106586. Tools.StartPerformanceCounter("Rendering camera " + o.name)
  106587. }),
  106588. this._onAfterCameraRenderObserver = this.scene.onAfterCameraRenderObservable.add(function(o) {
  106589. i._cameraRenderTime.endMonitoring(!1),
  106590. Tools.EndPerformanceCounter("Rendering camera " + o.name)
  106591. })) : (this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),
  106592. this._onBeforeCameraRenderObserver = null,
  106593. this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver),
  106594. this._onAfterCameraRenderObserver = null))
  106595. },
  106596. enumerable: !1,
  106597. configurable: !0
  106598. }),
  106599. Object.defineProperty(a.prototype, "drawCallsCounter", {
  106600. get: function() {
  106601. return this.scene.getEngine()._drawCalls
  106602. },
  106603. enumerable: !1,
  106604. configurable: !0
  106605. }),
  106606. a.prototype.dispose = function() {
  106607. this.scene.onBeforeRunRegisterBeforeRenderObservable.remove(this._onBeforeRegisterBeforeRenderObserver),
  106608. this._onBeforeRegisterBeforeRenderObserver = null,
  106609. this.scene.onAfterRunRegisterBeforeRenderObservable.remove(this._onAfterRegisterBeforeRenderObserver),
  106610. this._onAfterRegisterBeforeRenderObserver = null,
  106611. this.scene.onBeforeRunRegisterAfterRenderObservable.remove(this._onBeforeRegisterAfterRenderObserver),
  106612. this._onBeforeRegisterAfterRenderObserver = null,
  106613. this.scene.onAfterRunRegisterAfterRenderObservable.remove(this._onAfterRegisterAfterRenderObserver),
  106614. this._onAfterRegisterAfterRenderObserver = null,
  106615. this.scene.onBeforeRTT1Observable.remove(this._onBeforeRTT1Observer),
  106616. this._onBeforeRTT1Observer = null,
  106617. this.scene.onAfterRTT1Observable.remove(this._onAfterRTT1Observer),
  106618. this._onAfterRTT1Observer = null,
  106619. this.scene.onAfterRenderObservable.remove(this._onAfterRenderObserver),
  106620. this._onAfterRenderObserver = null,
  106621. this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver),
  106622. this._onBeforeActiveMeshesEvaluationObserver = null,
  106623. this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver),
  106624. this._onAfterActiveMeshesEvaluationObserver = null,
  106625. this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver),
  106626. this._onBeforeRenderTargetsRenderObserver = null,
  106627. this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver),
  106628. this._onAfterRenderTargetsRenderObserver = null,
  106629. this.scene.onBeforeAnimationsObservable.remove(this._onBeforeAnimationsObserver),
  106630. this._onBeforeAnimationsObserver = null,
  106631. this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver),
  106632. this._onBeforeParticlesRenderingObserver = null,
  106633. this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver),
  106634. this._onAfterParticlesRenderingObserver = null,
  106635. this._onBeforeSpritesRenderingObserver && (this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver),
  106636. this._onBeforeSpritesRenderingObserver = null),
  106637. this._onAfterSpritesRenderingObserver && (this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver),
  106638. this._onAfterSpritesRenderingObserver = null),
  106639. this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver),
  106640. this._onBeforeDrawPhaseObserver = null,
  106641. this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver),
  106642. this._onAfterDrawPhaseObserver = null,
  106643. this._onBeforePhysicsObserver && (this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver),
  106644. this._onBeforePhysicsObserver = null),
  106645. this._onAfterPhysicsObserver && (this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver),
  106646. this._onAfterPhysicsObserver = null),
  106647. this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver),
  106648. this._onAfterAnimationsObserver = null,
  106649. this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),
  106650. this._onBeforeCameraRenderObserver = null,
  106651. this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver),
  106652. this._onAfterCameraRenderObserver = null,
  106653. this.scene = null
  106654. }
  106655. ,
  106656. a
  106657. }()
  106658. , EngineInstrumentation = function() {
  106659. function a(e) {
  106660. this.engine = e,
  106661. this._captureGPUFrameTime = !1,
  106662. this._captureShaderCompilationTime = !1,
  106663. this._shaderCompilationTime = new PerfCounter,
  106664. this._onBeginFrameObserver = null,
  106665. this._onEndFrameObserver = null,
  106666. this._onBeforeShaderCompilationObserver = null,
  106667. this._onAfterShaderCompilationObserver = null
  106668. }
  106669. return Object.defineProperty(a.prototype, "gpuFrameTimeCounter", {
  106670. get: function() {
  106671. return this.engine.getGPUFrameTimeCounter()
  106672. },
  106673. enumerable: !1,
  106674. configurable: !0
  106675. }),
  106676. Object.defineProperty(a.prototype, "captureGPUFrameTime", {
  106677. get: function() {
  106678. return this._captureGPUFrameTime
  106679. },
  106680. set: function(e) {
  106681. e !== this._captureGPUFrameTime && (this._captureGPUFrameTime = e,
  106682. this.engine.captureGPUFrameTime(e))
  106683. },
  106684. enumerable: !1,
  106685. configurable: !0
  106686. }),
  106687. Object.defineProperty(a.prototype, "shaderCompilationTimeCounter", {
  106688. get: function() {
  106689. return this._shaderCompilationTime
  106690. },
  106691. enumerable: !1,
  106692. configurable: !0
  106693. }),
  106694. Object.defineProperty(a.prototype, "captureShaderCompilationTime", {
  106695. get: function() {
  106696. return this._captureShaderCompilationTime
  106697. },
  106698. set: function(e) {
  106699. var i = this;
  106700. e !== this._captureShaderCompilationTime && (this._captureShaderCompilationTime = e,
  106701. e ? (this._onBeforeShaderCompilationObserver = this.engine.onBeforeShaderCompilationObservable.add(function() {
  106702. i._shaderCompilationTime.fetchNewFrame(),
  106703. i._shaderCompilationTime.beginMonitoring()
  106704. }),
  106705. this._onAfterShaderCompilationObserver = this.engine.onAfterShaderCompilationObservable.add(function() {
  106706. i._shaderCompilationTime.endMonitoring()
  106707. })) : (this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver),
  106708. this._onBeforeShaderCompilationObserver = null,
  106709. this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver),
  106710. this._onAfterShaderCompilationObserver = null))
  106711. },
  106712. enumerable: !1,
  106713. configurable: !0
  106714. }),
  106715. a.prototype.dispose = function() {
  106716. this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver),
  106717. this._onBeginFrameObserver = null,
  106718. this.engine.onEndFrameObservable.remove(this._onEndFrameObserver),
  106719. this._onEndFrameObserver = null,
  106720. this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver),
  106721. this._onBeforeShaderCompilationObserver = null,
  106722. this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver),
  106723. this._onAfterShaderCompilationObserver = null,
  106724. this.engine = null
  106725. }
  106726. ,
  106727. a
  106728. }()
  106729. , KeepAssets = function(a) {
  106730. __extends(e, a);
  106731. function e() {
  106732. return a !== null && a.apply(this, arguments) || this
  106733. }
  106734. return e
  106735. }(AbstractScene)
  106736. , InstantiatedEntries = function() {
  106737. function a() {
  106738. this.rootNodes = [],
  106739. this.skeletons = [],
  106740. this.animationGroups = []
  106741. }
  106742. return a
  106743. }()
  106744. , AssetContainer = function(a) {
  106745. __extends(e, a);
  106746. function e(i) {
  106747. var o = a.call(this) || this;
  106748. return o._wasAddedToScene = !1,
  106749. o.scene = i,
  106750. o.sounds = [],
  106751. o.effectLayers = [],
  106752. o.layers = [],
  106753. o.lensFlareSystems = [],
  106754. o.proceduralTextures = [],
  106755. o.reflectionProbes = [],
  106756. i.onDisposeObservable.add(function() {
  106757. o._wasAddedToScene || o.dispose()
  106758. }),
  106759. o._onContextRestoredObserver = i.getEngine().onContextRestoredObservable.add(function() {
  106760. for (var s = 0, c = o.geometries; s < c.length; s++) {
  106761. var d = c[s];
  106762. d._rebuild()
  106763. }
  106764. for (var _ = 0, b = o.meshes; _ < b.length; _++) {
  106765. var k = b[_];
  106766. k._rebuild()
  106767. }
  106768. for (var j = 0, $ = o.particleSystems; j < $.length; j++) {
  106769. var _e = $[j];
  106770. _e.rebuild()
  106771. }
  106772. for (var et = 0, tt = o.textures; et < tt.length; et++) {
  106773. var rt = tt[et];
  106774. rt._rebuild()
  106775. }
  106776. }),
  106777. o
  106778. }
  106779. return e.prototype.instantiateModelsToScene = function(i, o, s) {
  106780. var c = this;
  106781. o === void 0 && (o = !1);
  106782. var d = {}
  106783. , _ = {}
  106784. , b = new InstantiatedEntries
  106785. , k = []
  106786. , j = [];
  106787. s || (s = {
  106788. doNotInstantiate: !0
  106789. });
  106790. var $ = function(_e, et) {
  106791. if (d[_e.uniqueId] = et.uniqueId,
  106792. _[et.uniqueId] = et,
  106793. i && (et.name = i(_e.name)),
  106794. et instanceof Mesh) {
  106795. var tt = et;
  106796. if (tt.morphTargetManager) {
  106797. var rt = _e.morphTargetManager;
  106798. tt.morphTargetManager = rt.clone();
  106799. for (var it = 0; it < rt.numTargets; it++) {
  106800. var nt = rt.getTarget(it)
  106801. , ot = tt.morphTargetManager.getTarget(it);
  106802. d[nt.uniqueId] = ot.uniqueId,
  106803. _[ot.uniqueId] = ot
  106804. }
  106805. }
  106806. }
  106807. };
  106808. return this.transformNodes.forEach(function(_e) {
  106809. if (!_e.parent) {
  106810. var et = _e.instantiateHierarchy(null, s, function(tt, rt) {
  106811. $(tt, rt)
  106812. });
  106813. et && b.rootNodes.push(et)
  106814. }
  106815. }),
  106816. this.meshes.forEach(function(_e) {
  106817. if (!_e.parent) {
  106818. var et = _e.instantiateHierarchy(null, s, function(tt, rt) {
  106819. if ($(tt, rt),
  106820. rt.material) {
  106821. var it = rt;
  106822. if (it.material)
  106823. if (o) {
  106824. var nt = tt.material;
  106825. if (j.indexOf(nt) === -1) {
  106826. var ot = nt.clone(i ? i(nt.name) : "Clone of " + nt.name);
  106827. if (j.push(nt),
  106828. d[nt.uniqueId] = ot.uniqueId,
  106829. _[ot.uniqueId] = ot,
  106830. nt.getClassName() === "MultiMaterial") {
  106831. for (var at = nt, st = 0, ut = at.subMaterials; st < ut.length; st++) {
  106832. var ct = ut[st];
  106833. !ct || (ot = ct.clone(i ? i(ct.name) : "Clone of " + ct.name),
  106834. j.push(ct),
  106835. d[ct.uniqueId] = ot.uniqueId,
  106836. _[ot.uniqueId] = ot)
  106837. }
  106838. at.subMaterials = at.subMaterials.map(function(lt) {
  106839. return lt && _[d[lt.uniqueId]]
  106840. })
  106841. }
  106842. }
  106843. it.getClassName() !== "InstancedMesh" && (it.material = _[d[nt.uniqueId]])
  106844. } else
  106845. it.material.getClassName() === "MultiMaterial" ? c.scene.multiMaterials.indexOf(it.material) === -1 && c.scene.addMultiMaterial(it.material) : c.scene.materials.indexOf(it.material) === -1 && c.scene.addMaterial(it.material)
  106846. }
  106847. });
  106848. et && b.rootNodes.push(et)
  106849. }
  106850. }),
  106851. this.skeletons.forEach(function(_e) {
  106852. var et = _e.clone(i ? i(_e.name) : "Clone of " + _e.name);
  106853. _e.overrideMesh && (et.overrideMesh = _[d[_e.overrideMesh.uniqueId]]);
  106854. for (var tt = 0, rt = c.meshes; tt < rt.length; tt++) {
  106855. var it = rt[tt];
  106856. if (it.skeleton === _e && !it.isAnInstance) {
  106857. var nt = _[d[it.uniqueId]];
  106858. if (nt.isAnInstance || (nt.skeleton = et,
  106859. k.indexOf(et) !== -1))
  106860. continue;
  106861. k.push(et);
  106862. for (var ot = 0, at = et.bones; ot < at.length; ot++) {
  106863. var st = at[ot];
  106864. st._linkedTransformNode && (st._linkedTransformNode = _[d[st._linkedTransformNode.uniqueId]])
  106865. }
  106866. }
  106867. }
  106868. b.skeletons.push(et)
  106869. }),
  106870. this.animationGroups.forEach(function(_e) {
  106871. var et = _e.clone(_e.name, function(tt) {
  106872. var rt = _[d[tt.uniqueId]];
  106873. return rt || tt
  106874. });
  106875. b.animationGroups.push(et)
  106876. }),
  106877. b
  106878. }
  106879. ,
  106880. e.prototype.addAllToScene = function() {
  106881. var i = this;
  106882. this._wasAddedToScene = !0,
  106883. this.cameras.forEach(function(d) {
  106884. i.scene.addCamera(d)
  106885. }),
  106886. this.lights.forEach(function(d) {
  106887. i.scene.addLight(d)
  106888. }),
  106889. this.meshes.forEach(function(d) {
  106890. i.scene.addMesh(d)
  106891. }),
  106892. this.skeletons.forEach(function(d) {
  106893. i.scene.addSkeleton(d)
  106894. }),
  106895. this.animations.forEach(function(d) {
  106896. i.scene.addAnimation(d)
  106897. }),
  106898. this.animationGroups.forEach(function(d) {
  106899. i.scene.addAnimationGroup(d)
  106900. }),
  106901. this.multiMaterials.forEach(function(d) {
  106902. i.scene.addMultiMaterial(d)
  106903. }),
  106904. this.materials.forEach(function(d) {
  106905. i.scene.addMaterial(d)
  106906. }),
  106907. this.morphTargetManagers.forEach(function(d) {
  106908. i.scene.addMorphTargetManager(d)
  106909. }),
  106910. this.geometries.forEach(function(d) {
  106911. i.scene.addGeometry(d)
  106912. }),
  106913. this.transformNodes.forEach(function(d) {
  106914. i.scene.addTransformNode(d)
  106915. }),
  106916. this.actionManagers.forEach(function(d) {
  106917. i.scene.addActionManager(d)
  106918. }),
  106919. this.textures.forEach(function(d) {
  106920. i.scene.addTexture(d)
  106921. }),
  106922. this.reflectionProbes.forEach(function(d) {
  106923. i.scene.addReflectionProbe(d)
  106924. }),
  106925. this.environmentTexture && (this.scene.environmentTexture = this.environmentTexture);
  106926. for (var o = 0, s = this.scene._serializableComponents; o < s.length; o++) {
  106927. var c = s[o];
  106928. c.addFromContainer(this)
  106929. }
  106930. this.scene.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver),
  106931. this._onContextRestoredObserver = null
  106932. }
  106933. ,
  106934. e.prototype.removeAllFromScene = function() {
  106935. var i = this;
  106936. this._wasAddedToScene = !1,
  106937. this.cameras.forEach(function(d) {
  106938. i.scene.removeCamera(d)
  106939. }),
  106940. this.lights.forEach(function(d) {
  106941. i.scene.removeLight(d)
  106942. }),
  106943. this.meshes.forEach(function(d) {
  106944. i.scene.removeMesh(d)
  106945. }),
  106946. this.skeletons.forEach(function(d) {
  106947. i.scene.removeSkeleton(d)
  106948. }),
  106949. this.animations.forEach(function(d) {
  106950. i.scene.removeAnimation(d)
  106951. }),
  106952. this.animationGroups.forEach(function(d) {
  106953. i.scene.removeAnimationGroup(d)
  106954. }),
  106955. this.multiMaterials.forEach(function(d) {
  106956. i.scene.removeMultiMaterial(d)
  106957. }),
  106958. this.materials.forEach(function(d) {
  106959. i.scene.removeMaterial(d)
  106960. }),
  106961. this.morphTargetManagers.forEach(function(d) {
  106962. i.scene.removeMorphTargetManager(d)
  106963. }),
  106964. this.geometries.forEach(function(d) {
  106965. i.scene.removeGeometry(d)
  106966. }),
  106967. this.transformNodes.forEach(function(d) {
  106968. i.scene.removeTransformNode(d)
  106969. }),
  106970. this.actionManagers.forEach(function(d) {
  106971. i.scene.removeActionManager(d)
  106972. }),
  106973. this.textures.forEach(function(d) {
  106974. i.scene.removeTexture(d)
  106975. }),
  106976. this.reflectionProbes.forEach(function(d) {
  106977. i.scene.removeReflectionProbe(d)
  106978. }),
  106979. this.environmentTexture === this.scene.environmentTexture && (this.scene.environmentTexture = null);
  106980. for (var o = 0, s = this.scene._serializableComponents; o < s.length; o++) {
  106981. var c = s[o];
  106982. c.removeFromContainer(this)
  106983. }
  106984. }
  106985. ,
  106986. e.prototype.dispose = function() {
  106987. this.cameras.slice(0).forEach(function(c) {
  106988. c.dispose()
  106989. }),
  106990. this.cameras = [],
  106991. this.lights.slice(0).forEach(function(c) {
  106992. c.dispose()
  106993. }),
  106994. this.lights = [],
  106995. this.meshes.slice(0).forEach(function(c) {
  106996. c.dispose()
  106997. }),
  106998. this.meshes = [],
  106999. this.skeletons.slice(0).forEach(function(c) {
  107000. c.dispose()
  107001. }),
  107002. this.skeletons = [],
  107003. this.animationGroups.slice(0).forEach(function(c) {
  107004. c.dispose()
  107005. }),
  107006. this.animationGroups = [],
  107007. this.multiMaterials.slice(0).forEach(function(c) {
  107008. c.dispose()
  107009. }),
  107010. this.multiMaterials = [],
  107011. this.materials.slice(0).forEach(function(c) {
  107012. c.dispose()
  107013. }),
  107014. this.materials = [],
  107015. this.geometries.slice(0).forEach(function(c) {
  107016. c.dispose()
  107017. }),
  107018. this.geometries = [],
  107019. this.transformNodes.slice(0).forEach(function(c) {
  107020. c.dispose()
  107021. }),
  107022. this.transformNodes = [],
  107023. this.actionManagers.slice(0).forEach(function(c) {
  107024. c.dispose()
  107025. }),
  107026. this.actionManagers = [],
  107027. this.textures.slice(0).forEach(function(c) {
  107028. c.dispose()
  107029. }),
  107030. this.textures = [],
  107031. this.reflectionProbes.slice(0).forEach(function(c) {
  107032. c.dispose()
  107033. }),
  107034. this.reflectionProbes = [],
  107035. this.environmentTexture && (this.environmentTexture.dispose(),
  107036. this.environmentTexture = null);
  107037. for (var i = 0, o = this.scene._serializableComponents; i < o.length; i++) {
  107038. var s = o[i];
  107039. s.removeFromContainer(this, !0)
  107040. }
  107041. this._onContextRestoredObserver && (this.scene.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver),
  107042. this._onContextRestoredObserver = null)
  107043. }
  107044. ,
  107045. e.prototype._moveAssets = function(i, o, s) {
  107046. if (!!i)
  107047. for (var c = 0, d = i; c < d.length; c++) {
  107048. var _ = d[c]
  107049. , b = !0;
  107050. if (s)
  107051. for (var k = 0, j = s; k < j.length; k++) {
  107052. var $ = j[k];
  107053. if (_ === $) {
  107054. b = !1;
  107055. break
  107056. }
  107057. }
  107058. b && (o.push(_),
  107059. _._parentContainer = this)
  107060. }
  107061. }
  107062. ,
  107063. e.prototype.moveAllFromScene = function(i) {
  107064. this._wasAddedToScene = !1,
  107065. i === void 0 && (i = new KeepAssets);
  107066. for (var o in this)
  107067. this.hasOwnProperty(o) && (this[o] = this[o] || (o === "environmentTexture" ? null : []),
  107068. this._moveAssets(this.scene[o], this[o], i[o]));
  107069. this.environmentTexture = this.scene.environmentTexture,
  107070. this.removeAllFromScene()
  107071. }
  107072. ,
  107073. e.prototype.createRootMesh = function() {
  107074. var i = new Mesh("assetContainerRootMesh",this.scene);
  107075. return this.meshes.forEach(function(o) {
  107076. o.parent || i.addChild(o)
  107077. }),
  107078. this.meshes.unshift(i),
  107079. i
  107080. }
  107081. ,
  107082. e.prototype.mergeAnimationsTo = function(i, o, s) {
  107083. if (i === void 0 && (i = EngineStore.LastCreatedScene),
  107084. s === void 0 && (s = null),
  107085. !i)
  107086. return Logger$2.Error("No scene available to merge animations to"),
  107087. [];
  107088. var c = s || function(b) {
  107089. var k = null
  107090. , j = b.animations.length ? b.animations[0].targetProperty : ""
  107091. , $ = b.name.split(".").join("").split("_primitive")[0];
  107092. switch (j) {
  107093. case "position":
  107094. case "rotationQuaternion":
  107095. k = i.getTransformNodeByName(b.name) || i.getTransformNodeByName($);
  107096. break;
  107097. case "influence":
  107098. k = i.getMorphTargetByName(b.name) || i.getMorphTargetByName($);
  107099. break;
  107100. default:
  107101. k = i.getNodeByName(b.name) || i.getNodeByName($)
  107102. }
  107103. return k
  107104. }
  107105. , d = this.getNodes();
  107106. d.forEach(function(b) {
  107107. var k = c(b);
  107108. if (k !== null) {
  107109. for (var j = function(tt) {
  107110. for (var rt = k.animations.filter(function(st) {
  107111. return st.targetProperty === tt.targetProperty
  107112. }), it = 0, nt = rt; it < nt.length; it++) {
  107113. var ot = nt[it]
  107114. , at = k.animations.indexOf(ot, 0);
  107115. at > -1 && k.animations.splice(at, 1)
  107116. }
  107117. }, $ = 0, _e = b.animations; $ < _e.length; $++) {
  107118. var et = _e[$];
  107119. j(et)
  107120. }
  107121. k.animations = k.animations.concat(b.animations)
  107122. }
  107123. });
  107124. var _ = new Array;
  107125. return this.animationGroups.slice().forEach(function(b) {
  107126. _.push(b.clone(b.name, c)),
  107127. b.animatables.forEach(function(k) {
  107128. k.stop()
  107129. })
  107130. }),
  107131. o.forEach(function(b) {
  107132. var k = c(b.target);
  107133. k && (i.beginAnimation(k, b.fromFrame, b.toFrame, b.loopAnimation, b.speedRatio, b.onAnimationEnd ? b.onAnimationEnd : void 0, void 0, !0, void 0, b.onAnimationLoop ? b.onAnimationLoop : void 0),
  107134. i.stopAnimation(b.target))
  107135. }),
  107136. _
  107137. }
  107138. ,
  107139. e
  107140. }(AbstractScene)
  107141. , Sound = function() {
  107142. function a(e, i, o, s, c) {
  107143. var d = this;
  107144. s === void 0 && (s = null);
  107145. var _, b, k, j, $;
  107146. if (this.autoplay = !1,
  107147. this._loop = !1,
  107148. this.useCustomAttenuation = !1,
  107149. this.isPlaying = !1,
  107150. this.isPaused = !1,
  107151. this.spatialSound = !1,
  107152. this.refDistance = 1,
  107153. this.rolloffFactor = 1,
  107154. this.maxDistance = 100,
  107155. this.distanceModel = "linear",
  107156. this.metadata = null,
  107157. this.onEndedObservable = new Observable,
  107158. this._panningModel = "equalpower",
  107159. this._playbackRate = 1,
  107160. this._streaming = !1,
  107161. this._startTime = 0,
  107162. this._startOffset = 0,
  107163. this._position = Vector3.Zero(),
  107164. this._localDirection = new Vector3(1,0,0),
  107165. this._volume = 1,
  107166. this._isReadyToPlay = !1,
  107167. this._isDirectional = !1,
  107168. this._coneInnerAngle = 360,
  107169. this._coneOuterAngle = 360,
  107170. this._coneOuterGain = 0,
  107171. this._isOutputConnected = !1,
  107172. this._urlType = "Unknown",
  107173. this.name = e,
  107174. this._scene = o,
  107175. a._SceneComponentInitialization(o),
  107176. this._readyToPlayCallback = s,
  107177. this._customAttenuationFunction = function(nt, ot, at, st, ut) {
  107178. return ot < at ? nt * (1 - ot / at) : 0
  107179. }
  107180. ,
  107181. c && (this.autoplay = c.autoplay || !1,
  107182. this._loop = c.loop || !1,
  107183. c.volume !== void 0 && (this._volume = c.volume),
  107184. this.spatialSound = (_ = c.spatialSound) !== null && _ !== void 0 ? _ : !1,
  107185. this.maxDistance = (b = c.maxDistance) !== null && b !== void 0 ? b : 100,
  107186. this.useCustomAttenuation = (k = c.useCustomAttenuation) !== null && k !== void 0 ? k : !1,
  107187. this.rolloffFactor = c.rolloffFactor || 1,
  107188. this.refDistance = c.refDistance || 1,
  107189. this.distanceModel = c.distanceModel || "linear",
  107190. this._playbackRate = c.playbackRate || 1,
  107191. this._streaming = (j = c.streaming) !== null && j !== void 0 ? j : !1,
  107192. this._length = c.length,
  107193. this._offset = c.offset),
  107194. (($ = Engine.audioEngine) === null || $ === void 0 ? void 0 : $.canUseWebAudio) && Engine.audioEngine.audioContext) {
  107195. this._soundGain = Engine.audioEngine.audioContext.createGain(),
  107196. this._soundGain.gain.value = this._volume,
  107197. this._inputAudioNode = this._soundGain,
  107198. this._outputAudioNode = this._soundGain,
  107199. this.spatialSound && this._createSpatialParameters(),
  107200. this._scene.mainSoundTrack.addSound(this);
  107201. var _e = !0;
  107202. if (i)
  107203. try {
  107204. typeof i == "string" ? this._urlType = "String" : i instanceof ArrayBuffer ? this._urlType = "ArrayBuffer" : i instanceof HTMLMediaElement ? this._urlType = "MediaElement" : i instanceof MediaStream ? this._urlType = "MediaStream" : Array.isArray(i) && (this._urlType = "Array");
  107205. var et = []
  107206. , tt = !1;
  107207. switch (this._urlType) {
  107208. case "MediaElement":
  107209. this._streaming = !0,
  107210. this._isReadyToPlay = !0,
  107211. this._streamingSource = Engine.audioEngine.audioContext.createMediaElementSource(i),
  107212. this.autoplay && this.play(0, this._offset, this._length),
  107213. this._readyToPlayCallback && this._readyToPlayCallback();
  107214. break;
  107215. case "MediaStream":
  107216. this._streaming = !0,
  107217. this._isReadyToPlay = !0,
  107218. this._streamingSource = Engine.audioEngine.audioContext.createMediaStreamSource(i),
  107219. this.autoplay && this.play(0, this._offset, this._length),
  107220. this._readyToPlayCallback && this._readyToPlayCallback();
  107221. break;
  107222. case "ArrayBuffer":
  107223. i.byteLength > 0 && (tt = !0,
  107224. this._soundLoaded(i));
  107225. break;
  107226. case "String":
  107227. et.push(i);
  107228. case "Array":
  107229. et.length === 0 && (et = i);
  107230. for (var rt = 0; rt < et.length; rt++) {
  107231. var it = et[rt];
  107232. if (tt = c && c.skipCodecCheck || it.indexOf(".mp3", it.length - 4) !== -1 && Engine.audioEngine.isMP3supported || it.indexOf(".ogg", it.length - 4) !== -1 && Engine.audioEngine.isOGGsupported || it.indexOf(".wav", it.length - 4) !== -1 || it.indexOf(".m4a", it.length - 4) !== -1 || it.indexOf("blob:") !== -1,
  107233. tt) {
  107234. this._streaming ? (this._htmlAudioElement = new Audio(it),
  107235. this._htmlAudioElement.controls = !1,
  107236. this._htmlAudioElement.loop = this.loop,
  107237. Tools.SetCorsBehavior(it, this._htmlAudioElement),
  107238. this._htmlAudioElement.preload = "auto",
  107239. this._htmlAudioElement.addEventListener("canplaythrough", function() {
  107240. d._isReadyToPlay = !0,
  107241. d.autoplay && d.play(0, d._offset, d._length),
  107242. d._readyToPlayCallback && d._readyToPlayCallback()
  107243. }),
  107244. document.body.appendChild(this._htmlAudioElement),
  107245. this._htmlAudioElement.load()) : this._scene._loadFile(it, function(nt) {
  107246. d._soundLoaded(nt)
  107247. }, void 0, !0, !0, function(nt) {
  107248. nt && Logger$2.Error("XHR " + nt.status + " error on: " + it + "."),
  107249. Logger$2.Error("Sound creation aborted."),
  107250. d._scene.mainSoundTrack.removeSound(d)
  107251. });
  107252. break
  107253. }
  107254. }
  107255. break;
  107256. default:
  107257. _e = !1;
  107258. break
  107259. }
  107260. _e ? tt || (this._isReadyToPlay = !0,
  107261. this._readyToPlayCallback && window.setTimeout(function() {
  107262. d._readyToPlayCallback && d._readyToPlayCallback()
  107263. }, 1e3)) : Logger$2.Error("Parameter must be a URL to the sound, an Array of URLs (.mp3 & .ogg) or an ArrayBuffer of the sound.")
  107264. } catch {
  107265. Logger$2.Error("Unexpected error. Sound creation aborted."),
  107266. this._scene.mainSoundTrack.removeSound(this)
  107267. }
  107268. } else
  107269. this._scene.mainSoundTrack.addSound(this),
  107270. Engine.audioEngine && !Engine.audioEngine.WarnedWebAudioUnsupported && (Logger$2.Error("Web Audio is not supported by your browser."),
  107271. Engine.audioEngine.WarnedWebAudioUnsupported = !0),
  107272. this._readyToPlayCallback && window.setTimeout(function() {
  107273. d._readyToPlayCallback && d._readyToPlayCallback()
  107274. }, 1e3)
  107275. }
  107276. return Object.defineProperty(a.prototype, "loop", {
  107277. get: function() {
  107278. return this._loop
  107279. },
  107280. set: function(e) {
  107281. e !== this._loop && (this._loop = e,
  107282. this.updateOptions({
  107283. loop: e
  107284. }))
  107285. },
  107286. enumerable: !1,
  107287. configurable: !0
  107288. }),
  107289. Object.defineProperty(a.prototype, "currentTime", {
  107290. get: function() {
  107291. var e;
  107292. if (this._htmlAudioElement)
  107293. return this._htmlAudioElement.currentTime;
  107294. var i = this._startOffset;
  107295. return this.isPlaying && ((e = Engine.audioEngine) === null || e === void 0 ? void 0 : e.audioContext) && (i += Engine.audioEngine.audioContext.currentTime - this._startTime),
  107296. i
  107297. },
  107298. enumerable: !1,
  107299. configurable: !0
  107300. }),
  107301. a.prototype.dispose = function() {
  107302. var e;
  107303. !((e = Engine.audioEngine) === null || e === void 0) && e.canUseWebAudio && (this.isPlaying && this.stop(),
  107304. this._isReadyToPlay = !1,
  107305. this.soundTrackId === -1 ? this._scene.mainSoundTrack.removeSound(this) : this._scene.soundTracks && this._scene.soundTracks[this.soundTrackId].removeSound(this),
  107306. this._soundGain && (this._soundGain.disconnect(),
  107307. this._soundGain = null),
  107308. this._soundPanner && (this._soundPanner.disconnect(),
  107309. this._soundPanner = null),
  107310. this._soundSource && (this._soundSource.disconnect(),
  107311. this._soundSource = null),
  107312. this._audioBuffer = null,
  107313. this._htmlAudioElement && (this._htmlAudioElement.pause(),
  107314. this._htmlAudioElement.src = "",
  107315. document.body.removeChild(this._htmlAudioElement)),
  107316. this._streamingSource && this._streamingSource.disconnect(),
  107317. this._connectedTransformNode && this._registerFunc && (this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc),
  107318. this._connectedTransformNode = null))
  107319. }
  107320. ,
  107321. a.prototype.isReady = function() {
  107322. return this._isReadyToPlay
  107323. }
  107324. ,
  107325. a.prototype.getClassName = function() {
  107326. return "Sound"
  107327. }
  107328. ,
  107329. a.prototype._soundLoaded = function(e) {
  107330. var i = this, o;
  107331. !(!((o = Engine.audioEngine) === null || o === void 0) && o.audioContext) || Engine.audioEngine.audioContext.decodeAudioData(e, function(s) {
  107332. i._audioBuffer = s,
  107333. i._isReadyToPlay = !0,
  107334. i.autoplay && i.play(0, i._offset, i._length),
  107335. i._readyToPlayCallback && i._readyToPlayCallback()
  107336. }, function(s) {
  107337. Logger$2.Error("Error while decoding audio data for: " + i.name + " / Error: " + s)
  107338. })
  107339. }
  107340. ,
  107341. a.prototype.setAudioBuffer = function(e) {
  107342. var i;
  107343. !((i = Engine.audioEngine) === null || i === void 0) && i.canUseWebAudio && (this._audioBuffer = e,
  107344. this._isReadyToPlay = !0)
  107345. }
  107346. ,
  107347. a.prototype.updateOptions = function(e) {
  107348. var i, o, s, c, d, _, b, k, j;
  107349. e && (this.loop = (i = e.loop) !== null && i !== void 0 ? i : this.loop,
  107350. this.maxDistance = (o = e.maxDistance) !== null && o !== void 0 ? o : this.maxDistance,
  107351. this.useCustomAttenuation = (s = e.useCustomAttenuation) !== null && s !== void 0 ? s : this.useCustomAttenuation,
  107352. this.rolloffFactor = (c = e.rolloffFactor) !== null && c !== void 0 ? c : this.rolloffFactor,
  107353. this.refDistance = (d = e.refDistance) !== null && d !== void 0 ? d : this.refDistance,
  107354. this.distanceModel = (_ = e.distanceModel) !== null && _ !== void 0 ? _ : this.distanceModel,
  107355. this._playbackRate = (b = e.playbackRate) !== null && b !== void 0 ? b : this._playbackRate,
  107356. this._length = (k = e.length) !== null && k !== void 0 ? k : void 0,
  107357. this._offset = (j = e.offset) !== null && j !== void 0 ? j : void 0,
  107358. this._updateSpatialParameters(),
  107359. this.isPlaying && (this._streaming && this._htmlAudioElement ? (this._htmlAudioElement.playbackRate = this._playbackRate,
  107360. this._htmlAudioElement.loop !== this.loop && (this._htmlAudioElement.loop = this.loop)) : this._soundSource && (this._soundSource.playbackRate.value = this._playbackRate,
  107361. this._soundSource.loop !== this.loop && (this._soundSource.loop = this.loop),
  107362. this._offset !== void 0 && this._soundSource.loopStart !== this._offset && (this._soundSource.loopStart = this._offset),
  107363. this._length !== void 0 && this._length !== this._soundSource.loopEnd && (this._soundSource.loopEnd = (this._offset | 0) + this._length))))
  107364. }
  107365. ,
  107366. a.prototype._createSpatialParameters = function() {
  107367. var e;
  107368. ((e = Engine.audioEngine) === null || e === void 0 ? void 0 : e.canUseWebAudio) && Engine.audioEngine.audioContext && (this._scene.headphone && (this._panningModel = "HRTF"),
  107369. this._soundPanner = Engine.audioEngine.audioContext.createPanner(),
  107370. this._soundPanner && this._outputAudioNode && (this._updateSpatialParameters(),
  107371. this._soundPanner.connect(this._outputAudioNode),
  107372. this._inputAudioNode = this._soundPanner))
  107373. }
  107374. ,
  107375. a.prototype._updateSpatialParameters = function() {
  107376. this.spatialSound && this._soundPanner && (this.useCustomAttenuation ? (this._soundPanner.distanceModel = "linear",
  107377. this._soundPanner.maxDistance = Number.MAX_VALUE,
  107378. this._soundPanner.refDistance = 1,
  107379. this._soundPanner.rolloffFactor = 1,
  107380. this._soundPanner.panningModel = this._panningModel) : (this._soundPanner.distanceModel = this.distanceModel,
  107381. this._soundPanner.maxDistance = this.maxDistance,
  107382. this._soundPanner.refDistance = this.refDistance,
  107383. this._soundPanner.rolloffFactor = this.rolloffFactor,
  107384. this._soundPanner.panningModel = this._panningModel))
  107385. }
  107386. ,
  107387. a.prototype.switchPanningModelToHRTF = function() {
  107388. this._panningModel = "HRTF",
  107389. this._switchPanningModel()
  107390. }
  107391. ,
  107392. a.prototype.switchPanningModelToEqualPower = function() {
  107393. this._panningModel = "equalpower",
  107394. this._switchPanningModel()
  107395. }
  107396. ,
  107397. a.prototype._switchPanningModel = function() {
  107398. var e;
  107399. ((e = Engine.audioEngine) === null || e === void 0 ? void 0 : e.canUseWebAudio) && this.spatialSound && this._soundPanner && (this._soundPanner.panningModel = this._panningModel)
  107400. }
  107401. ,
  107402. a.prototype.connectToSoundTrackAudioNode = function(e) {
  107403. var i;
  107404. ((i = Engine.audioEngine) === null || i === void 0 ? void 0 : i.canUseWebAudio) && this._outputAudioNode && (this._isOutputConnected && this._outputAudioNode.disconnect(),
  107405. this._outputAudioNode.connect(e),
  107406. this._isOutputConnected = !0)
  107407. }
  107408. ,
  107409. a.prototype.setDirectionalCone = function(e, i, o) {
  107410. if (i < e) {
  107411. Logger$2.Error("setDirectionalCone(): outer angle of the cone must be superior or equal to the inner angle.");
  107412. return
  107413. }
  107414. this._coneInnerAngle = e,
  107415. this._coneOuterAngle = i,
  107416. this._coneOuterGain = o,
  107417. this._isDirectional = !0,
  107418. this.isPlaying && this.loop && (this.stop(),
  107419. this.play(0, this._offset, this._length))
  107420. }
  107421. ,
  107422. Object.defineProperty(a.prototype, "directionalConeInnerAngle", {
  107423. get: function() {
  107424. return this._coneInnerAngle
  107425. },
  107426. set: function(e) {
  107427. var i;
  107428. if (e != this._coneInnerAngle) {
  107429. if (this._coneOuterAngle < e) {
  107430. Logger$2.Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
  107431. return
  107432. }
  107433. this._coneInnerAngle = e,
  107434. ((i = Engine.audioEngine) === null || i === void 0 ? void 0 : i.canUseWebAudio) && this.spatialSound && this._soundPanner && (this._soundPanner.coneInnerAngle = this._coneInnerAngle)
  107435. }
  107436. },
  107437. enumerable: !1,
  107438. configurable: !0
  107439. }),
  107440. Object.defineProperty(a.prototype, "directionalConeOuterAngle", {
  107441. get: function() {
  107442. return this._coneOuterAngle
  107443. },
  107444. set: function(e) {
  107445. var i;
  107446. if (e != this._coneOuterAngle) {
  107447. if (e < this._coneInnerAngle) {
  107448. Logger$2.Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
  107449. return
  107450. }
  107451. this._coneOuterAngle = e,
  107452. ((i = Engine.audioEngine) === null || i === void 0 ? void 0 : i.canUseWebAudio) && this.spatialSound && this._soundPanner && (this._soundPanner.coneOuterAngle = this._coneOuterAngle)
  107453. }
  107454. },
  107455. enumerable: !1,
  107456. configurable: !0
  107457. }),
  107458. a.prototype.setPosition = function(e) {
  107459. var i;
  107460. e.equals(this._position) || (this._position.copyFrom(e),
  107461. ((i = Engine.audioEngine) === null || i === void 0 ? void 0 : i.canUseWebAudio) && this.spatialSound && this._soundPanner && !isNaN(this._position.x) && !isNaN(this._position.y) && !isNaN(this._position.z) && this._soundPanner.setPosition(this._position.x, this._position.y, this._position.z))
  107462. }
  107463. ,
  107464. a.prototype.setLocalDirectionToMesh = function(e) {
  107465. var i;
  107466. this._localDirection = e,
  107467. ((i = Engine.audioEngine) === null || i === void 0 ? void 0 : i.canUseWebAudio) && this._connectedTransformNode && this.isPlaying && this._updateDirection()
  107468. }
  107469. ,
  107470. a.prototype._updateDirection = function() {
  107471. if (!(!this._connectedTransformNode || !this._soundPanner)) {
  107472. var e = this._connectedTransformNode.getWorldMatrix()
  107473. , i = Vector3.TransformNormal(this._localDirection, e);
  107474. i.normalize(),
  107475. this._soundPanner.setOrientation(i.x, i.y, i.z)
  107476. }
  107477. }
  107478. ,
  107479. a.prototype.updateDistanceFromListener = function() {
  107480. var e;
  107481. if (((e = Engine.audioEngine) === null || e === void 0 ? void 0 : e.canUseWebAudio) && this._connectedTransformNode && this.useCustomAttenuation && this._soundGain && this._scene.activeCamera) {
  107482. var i = this._connectedTransformNode.getDistanceToCamera(this._scene.activeCamera);
  107483. this._soundGain.gain.value = this._customAttenuationFunction(this._volume, i, this.maxDistance, this.refDistance, this.rolloffFactor)
  107484. }
  107485. }
  107486. ,
  107487. a.prototype.setAttenuationFunction = function(e) {
  107488. this._customAttenuationFunction = e
  107489. }
  107490. ,
  107491. a.prototype.play = function(e, i, o) {
  107492. var s = this, c, d, _, b;
  107493. if (this._isReadyToPlay && this._scene.audioEnabled && ((c = Engine.audioEngine) === null || c === void 0 ? void 0 : c.audioContext))
  107494. try {
  107495. this._startOffset < 0 && (e = -this._startOffset,
  107496. this._startOffset = 0);
  107497. var k = e ? ((d = Engine.audioEngine) === null || d === void 0 ? void 0 : d.audioContext.currentTime) + e : (_ = Engine.audioEngine) === null || _ === void 0 ? void 0 : _.audioContext.currentTime;
  107498. if ((!this._soundSource || !this._streamingSource) && this.spatialSound && this._soundPanner && (!isNaN(this._position.x) && !isNaN(this._position.y) && !isNaN(this._position.z) && this._soundPanner.setPosition(this._position.x, this._position.y, this._position.z),
  107499. this._isDirectional && (this._soundPanner.coneInnerAngle = this._coneInnerAngle,
  107500. this._soundPanner.coneOuterAngle = this._coneOuterAngle,
  107501. this._soundPanner.coneOuterGain = this._coneOuterGain,
  107502. this._connectedTransformNode ? this._updateDirection() : this._soundPanner.setOrientation(this._localDirection.x, this._localDirection.y, this._localDirection.z))),
  107503. this._streaming) {
  107504. if (this._streamingSource || (this._streamingSource = Engine.audioEngine.audioContext.createMediaElementSource(this._htmlAudioElement),
  107505. this._htmlAudioElement.onended = function() {
  107506. s._onended()
  107507. }
  107508. ,
  107509. this._htmlAudioElement.playbackRate = this._playbackRate),
  107510. this._streamingSource.disconnect(),
  107511. this._inputAudioNode && this._streamingSource.connect(this._inputAudioNode),
  107512. this._htmlAudioElement) {
  107513. var j = function() {
  107514. var $, _e;
  107515. if (!(($ = Engine.audioEngine) === null || $ === void 0) && $.unlocked) {
  107516. var et = s._htmlAudioElement.play();
  107517. et !== void 0 && et.catch(function(tt) {
  107518. var rt, it;
  107519. (rt = Engine.audioEngine) === null || rt === void 0 || rt.lock(),
  107520. (s.loop || s.autoplay) && ((it = Engine.audioEngine) === null || it === void 0 || it.onAudioUnlockedObservable.addOnce(function() {
  107521. j()
  107522. }))
  107523. })
  107524. } else
  107525. (s.loop || s.autoplay) && ((_e = Engine.audioEngine) === null || _e === void 0 || _e.onAudioUnlockedObservable.addOnce(function() {
  107526. j()
  107527. }))
  107528. };
  107529. j()
  107530. }
  107531. } else {
  107532. var j = function() {
  107533. var _e, et, tt;
  107534. if (!((_e = Engine.audioEngine) === null || _e === void 0) && _e.audioContext) {
  107535. if (o = o || s._length,
  107536. i = i || s._offset,
  107537. s._soundSource) {
  107538. var rt = s._soundSource;
  107539. rt.onended = function() {
  107540. rt.disconnect()
  107541. }
  107542. }
  107543. if (s._soundSource = (et = Engine.audioEngine) === null || et === void 0 ? void 0 : et.audioContext.createBufferSource(),
  107544. s._soundSource && s._inputAudioNode) {
  107545. s._soundSource.buffer = s._audioBuffer,
  107546. s._soundSource.connect(s._inputAudioNode),
  107547. s._soundSource.loop = s.loop,
  107548. i !== void 0 && (s._soundSource.loopStart = i),
  107549. o !== void 0 && (s._soundSource.loopEnd = (i | 0) + o),
  107550. s._soundSource.playbackRate.value = s._playbackRate,
  107551. s._soundSource.onended = function() {
  107552. s._onended()
  107553. }
  107554. ,
  107555. k = e ? ((tt = Engine.audioEngine) === null || tt === void 0 ? void 0 : tt.audioContext.currentTime) + e : Engine.audioEngine.audioContext.currentTime;
  107556. var it = s.isPaused ? s._startOffset % s._soundSource.buffer.duration : i || 0;
  107557. s._soundSource.start(k, it, s.loop ? void 0 : o)
  107558. }
  107559. }
  107560. };
  107561. ((b = Engine.audioEngine) === null || b === void 0 ? void 0 : b.audioContext.state) === "suspended" ? setTimeout(function() {
  107562. var _e;
  107563. ((_e = Engine.audioEngine) === null || _e === void 0 ? void 0 : _e.audioContext.state) === "suspended" ? (Engine.audioEngine.lock(),
  107564. (s.loop || s.autoplay) && Engine.audioEngine.onAudioUnlockedObservable.addOnce(function() {
  107565. j()
  107566. })) : j()
  107567. }, 500) : j()
  107568. }
  107569. this._startTime = k,
  107570. this.isPlaying = !0,
  107571. this.isPaused = !1
  107572. } catch ($) {
  107573. Logger$2.Error("Error while trying to play audio: " + this.name + ", " + $.message)
  107574. }
  107575. }
  107576. ,
  107577. a.prototype._onended = function() {
  107578. this.isPlaying = !1,
  107579. this._startOffset = 0,
  107580. this.onended && this.onended(),
  107581. this.onEndedObservable.notifyObservers(this)
  107582. }
  107583. ,
  107584. a.prototype.stop = function(e) {
  107585. var i = this, o;
  107586. if (this.isPlaying) {
  107587. if (this._streaming)
  107588. this._htmlAudioElement ? (this._htmlAudioElement.pause(),
  107589. this._htmlAudioElement.currentTime > 0 && (this._htmlAudioElement.currentTime = 0)) : this._streamingSource.disconnect(),
  107590. this.isPlaying = !1;
  107591. else if (((o = Engine.audioEngine) === null || o === void 0 ? void 0 : o.audioContext) && this._soundSource) {
  107592. var s = e ? Engine.audioEngine.audioContext.currentTime + e : void 0;
  107593. this._soundSource.stop(s),
  107594. s === void 0 ? (this.isPlaying = !1,
  107595. this._soundSource.onended = function() {}
  107596. ) : this._soundSource.onended = function() {
  107597. i.isPlaying = !1
  107598. }
  107599. ,
  107600. this.isPaused || (this._startOffset = 0)
  107601. }
  107602. }
  107603. }
  107604. ,
  107605. a.prototype.pause = function() {
  107606. var e;
  107607. this.isPlaying && (this.isPaused = !0,
  107608. this._streaming ? (this._htmlAudioElement ? this._htmlAudioElement.pause() : this._streamingSource.disconnect(),
  107609. this.isPlaying = !1) : !((e = Engine.audioEngine) === null || e === void 0) && e.audioContext && (this.stop(0),
  107610. this._startOffset += Engine.audioEngine.audioContext.currentTime - this._startTime))
  107611. }
  107612. ,
  107613. a.prototype.setVolume = function(e, i) {
  107614. var o;
  107615. ((o = Engine.audioEngine) === null || o === void 0 ? void 0 : o.canUseWebAudio) && this._soundGain && (i && Engine.audioEngine.audioContext ? (this._soundGain.gain.cancelScheduledValues(Engine.audioEngine.audioContext.currentTime),
  107616. this._soundGain.gain.setValueAtTime(this._soundGain.gain.value, Engine.audioEngine.audioContext.currentTime),
  107617. this._soundGain.gain.linearRampToValueAtTime(e, Engine.audioEngine.audioContext.currentTime + i)) : this._soundGain.gain.value = e),
  107618. this._volume = e
  107619. }
  107620. ,
  107621. a.prototype.setPlaybackRate = function(e) {
  107622. this._playbackRate = e,
  107623. this.isPlaying && (this._streaming && this._htmlAudioElement ? this._htmlAudioElement.playbackRate = this._playbackRate : this._soundSource && (this._soundSource.playbackRate.value = this._playbackRate))
  107624. }
  107625. ,
  107626. a.prototype.getVolume = function() {
  107627. return this._volume
  107628. }
  107629. ,
  107630. a.prototype.attachToMesh = function(e) {
  107631. var i = this;
  107632. this._connectedTransformNode && this._registerFunc && (this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc),
  107633. this._registerFunc = null),
  107634. this._connectedTransformNode = e,
  107635. this.spatialSound || (this.spatialSound = !0,
  107636. this._createSpatialParameters(),
  107637. this.isPlaying && this.loop && (this.stop(),
  107638. this.play(0, this._offset, this._length))),
  107639. this._onRegisterAfterWorldMatrixUpdate(this._connectedTransformNode),
  107640. this._registerFunc = function(o) {
  107641. return i._onRegisterAfterWorldMatrixUpdate(o)
  107642. }
  107643. ,
  107644. this._connectedTransformNode.registerAfterWorldMatrixUpdate(this._registerFunc)
  107645. }
  107646. ,
  107647. a.prototype.detachFromMesh = function() {
  107648. this._connectedTransformNode && this._registerFunc && (this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc),
  107649. this._registerFunc = null,
  107650. this._connectedTransformNode = null)
  107651. }
  107652. ,
  107653. a.prototype._onRegisterAfterWorldMatrixUpdate = function(e) {
  107654. var i;
  107655. if (!e.getBoundingInfo)
  107656. this.setPosition(e.absolutePosition);
  107657. else {
  107658. var o = e
  107659. , s = o.getBoundingInfo();
  107660. this.setPosition(s.boundingSphere.centerWorld)
  107661. }
  107662. ((i = Engine.audioEngine) === null || i === void 0 ? void 0 : i.canUseWebAudio) && this._isDirectional && this.isPlaying && this._updateDirection()
  107663. }
  107664. ,
  107665. a.prototype.clone = function() {
  107666. var e = this;
  107667. if (this._streaming)
  107668. return null;
  107669. var i = function() {
  107670. e._isReadyToPlay ? (s._audioBuffer = e.getAudioBuffer(),
  107671. s._isReadyToPlay = !0,
  107672. s.autoplay && s.play(0, e._offset, e._length)) : window.setTimeout(i, 300)
  107673. }
  107674. , o = {
  107675. autoplay: this.autoplay,
  107676. loop: this.loop,
  107677. volume: this._volume,
  107678. spatialSound: this.spatialSound,
  107679. maxDistance: this.maxDistance,
  107680. useCustomAttenuation: this.useCustomAttenuation,
  107681. rolloffFactor: this.rolloffFactor,
  107682. refDistance: this.refDistance,
  107683. distanceModel: this.distanceModel
  107684. }
  107685. , s = new a(this.name + "_cloned",new ArrayBuffer(0),this._scene,null,o);
  107686. return this.useCustomAttenuation && s.setAttenuationFunction(this._customAttenuationFunction),
  107687. s.setPosition(this._position),
  107688. s.setPlaybackRate(this._playbackRate),
  107689. i(),
  107690. s
  107691. }
  107692. ,
  107693. a.prototype.getAudioBuffer = function() {
  107694. return this._audioBuffer
  107695. }
  107696. ,
  107697. a.prototype.getSoundSource = function() {
  107698. return this._soundSource
  107699. }
  107700. ,
  107701. a.prototype.getSoundGain = function() {
  107702. return this._soundGain
  107703. }
  107704. ,
  107705. a.prototype.serialize = function() {
  107706. var e = {
  107707. name: this.name,
  107708. url: this.name,
  107709. autoplay: this.autoplay,
  107710. loop: this.loop,
  107711. volume: this._volume,
  107712. spatialSound: this.spatialSound,
  107713. maxDistance: this.maxDistance,
  107714. rolloffFactor: this.rolloffFactor,
  107715. refDistance: this.refDistance,
  107716. distanceModel: this.distanceModel,
  107717. playbackRate: this._playbackRate,
  107718. panningModel: this._panningModel,
  107719. soundTrackId: this.soundTrackId,
  107720. metadata: this.metadata
  107721. };
  107722. return this.spatialSound && (this._connectedTransformNode && (e.connectedMeshId = this._connectedTransformNode.id),
  107723. e.position = this._position.asArray(),
  107724. e.refDistance = this.refDistance,
  107725. e.distanceModel = this.distanceModel,
  107726. e.isDirectional = this._isDirectional,
  107727. e.localDirectionToMesh = this._localDirection.asArray(),
  107728. e.coneInnerAngle = this._coneInnerAngle,
  107729. e.coneOuterAngle = this._coneOuterAngle,
  107730. e.coneOuterGain = this._coneOuterGain),
  107731. e
  107732. }
  107733. ,
  107734. a.Parse = function(e, i, o, s) {
  107735. var c = e.name, d;
  107736. e.url ? d = o + e.url : d = o + c;
  107737. var _ = {
  107738. autoplay: e.autoplay,
  107739. loop: e.loop,
  107740. volume: e.volume,
  107741. spatialSound: e.spatialSound,
  107742. maxDistance: e.maxDistance,
  107743. rolloffFactor: e.rolloffFactor,
  107744. refDistance: e.refDistance,
  107745. distanceModel: e.distanceModel,
  107746. playbackRate: e.playbackRate
  107747. }, b;
  107748. if (!s)
  107749. b = new a(c,d,i,function() {
  107750. i._removePendingData(b)
  107751. }
  107752. ,_),
  107753. i._addPendingData(b);
  107754. else {
  107755. var k = function() {
  107756. s._isReadyToPlay ? (b._audioBuffer = s.getAudioBuffer(),
  107757. b._isReadyToPlay = !0,
  107758. b.autoplay && b.play(0, b._offset, b._length)) : window.setTimeout(k, 300)
  107759. };
  107760. b = new a(c,new ArrayBuffer(0),i,null,_),
  107761. k()
  107762. }
  107763. if (e.position) {
  107764. var j = Vector3.FromArray(e.position);
  107765. b.setPosition(j)
  107766. }
  107767. if (e.isDirectional && (b.setDirectionalCone(e.coneInnerAngle || 360, e.coneOuterAngle || 360, e.coneOuterGain || 0),
  107768. e.localDirectionToMesh)) {
  107769. var $ = Vector3.FromArray(e.localDirectionToMesh);
  107770. b.setLocalDirectionToMesh($)
  107771. }
  107772. if (e.connectedMeshId) {
  107773. var _e = i.getMeshById(e.connectedMeshId);
  107774. _e && b.attachToMesh(_e)
  107775. }
  107776. return e.metadata && (b.metadata = e.metadata),
  107777. b
  107778. }
  107779. ,
  107780. a._SceneComponentInitialization = function(e) {
  107781. throw _WarnImport("AudioSceneComponent")
  107782. }
  107783. ,
  107784. a
  107785. }()
  107786. , ThinSprite = function() {
  107787. function a() {
  107788. this.width = 1,
  107789. this.height = 1,
  107790. this.angle = 0,
  107791. this.invertU = !1,
  107792. this.invertV = !1,
  107793. this.isVisible = !0,
  107794. this._animationStarted = !1,
  107795. this._loopAnimation = !1,
  107796. this._fromIndex = 0,
  107797. this._toIndex = 0,
  107798. this._delay = 0,
  107799. this._direction = 1,
  107800. this._time = 0,
  107801. this._onBaseAnimationEnd = null,
  107802. this.position = {
  107803. x: 1,
  107804. y: 1,
  107805. z: 1
  107806. },
  107807. this.color = {
  107808. r: 1,
  107809. g: 1,
  107810. b: 1,
  107811. a: 1
  107812. }
  107813. }
  107814. return Object.defineProperty(a.prototype, "animationStarted", {
  107815. get: function() {
  107816. return this._animationStarted
  107817. },
  107818. enumerable: !1,
  107819. configurable: !0
  107820. }),
  107821. Object.defineProperty(a.prototype, "fromIndex", {
  107822. get: function() {
  107823. return this._fromIndex
  107824. },
  107825. enumerable: !1,
  107826. configurable: !0
  107827. }),
  107828. Object.defineProperty(a.prototype, "toIndex", {
  107829. get: function() {
  107830. return this._toIndex
  107831. },
  107832. enumerable: !1,
  107833. configurable: !0
  107834. }),
  107835. Object.defineProperty(a.prototype, "loopAnimation", {
  107836. get: function() {
  107837. return this._loopAnimation
  107838. },
  107839. enumerable: !1,
  107840. configurable: !0
  107841. }),
  107842. Object.defineProperty(a.prototype, "delay", {
  107843. get: function() {
  107844. return Math.max(this._delay, 1)
  107845. },
  107846. enumerable: !1,
  107847. configurable: !0
  107848. }),
  107849. a.prototype.playAnimation = function(e, i, o, s, c) {
  107850. this._fromIndex = e,
  107851. this._toIndex = i,
  107852. this._loopAnimation = o,
  107853. this._delay = s || 1,
  107854. this._animationStarted = !0,
  107855. this._onBaseAnimationEnd = c,
  107856. e < i ? this._direction = 1 : (this._direction = -1,
  107857. this._toIndex = e,
  107858. this._fromIndex = i),
  107859. this.cellIndex = e,
  107860. this._time = 0
  107861. }
  107862. ,
  107863. a.prototype.stopAnimation = function() {
  107864. this._animationStarted = !1
  107865. }
  107866. ,
  107867. a.prototype._animate = function(e) {
  107868. !this._animationStarted || (this._time += e,
  107869. this._time > this._delay && (this._time = this._time % this._delay,
  107870. this.cellIndex += this._direction,
  107871. (this._direction > 0 && this.cellIndex > this._toIndex || this._direction < 0 && this.cellIndex < this._fromIndex) && (this._loopAnimation ? this.cellIndex = this._direction > 0 ? this._fromIndex : this._toIndex : (this.cellIndex = this._toIndex,
  107872. this._animationStarted = !1,
  107873. this._onBaseAnimationEnd && this._onBaseAnimationEnd()))))
  107874. }
  107875. ,
  107876. a
  107877. }()
  107878. , Sprite = function(a) {
  107879. __extends(e, a);
  107880. function e(i, o) {
  107881. var s = a.call(this) || this;
  107882. return s.name = i,
  107883. s.animations = new Array,
  107884. s.isPickable = !1,
  107885. s.useAlphaForPicking = !1,
  107886. s.onDisposeObservable = new Observable,
  107887. s._onAnimationEnd = null,
  107888. s._endAnimation = function() {
  107889. s._onAnimationEnd && s._onAnimationEnd(),
  107890. s.disposeWhenFinishedAnimating && s.dispose()
  107891. }
  107892. ,
  107893. s.color = new Color4(1,1,1,1),
  107894. s.position = Vector3.Zero(),
  107895. s._manager = o,
  107896. s._manager.sprites.push(s),
  107897. s.uniqueId = s._manager.scene.getUniqueId(),
  107898. s
  107899. }
  107900. return Object.defineProperty(e.prototype, "size", {
  107901. get: function() {
  107902. return this.width
  107903. },
  107904. set: function(i) {
  107905. this.width = i,
  107906. this.height = i
  107907. },
  107908. enumerable: !1,
  107909. configurable: !0
  107910. }),
  107911. Object.defineProperty(e.prototype, "manager", {
  107912. get: function() {
  107913. return this._manager
  107914. },
  107915. enumerable: !1,
  107916. configurable: !0
  107917. }),
  107918. e.prototype.getClassName = function() {
  107919. return "Sprite"
  107920. }
  107921. ,
  107922. Object.defineProperty(e.prototype, "fromIndex", {
  107923. get: function() {
  107924. return this._fromIndex
  107925. },
  107926. set: function(i) {
  107927. this.playAnimation(i, this._toIndex, this._loopAnimation, this._delay, this._onAnimationEnd)
  107928. },
  107929. enumerable: !1,
  107930. configurable: !0
  107931. }),
  107932. Object.defineProperty(e.prototype, "toIndex", {
  107933. get: function() {
  107934. return this._toIndex
  107935. },
  107936. set: function(i) {
  107937. this.playAnimation(this._fromIndex, i, this._loopAnimation, this._delay, this._onAnimationEnd)
  107938. },
  107939. enumerable: !1,
  107940. configurable: !0
  107941. }),
  107942. Object.defineProperty(e.prototype, "loopAnimation", {
  107943. get: function() {
  107944. return this._loopAnimation
  107945. },
  107946. set: function(i) {
  107947. this.playAnimation(this._fromIndex, this._toIndex, i, this._delay, this._onAnimationEnd)
  107948. },
  107949. enumerable: !1,
  107950. configurable: !0
  107951. }),
  107952. Object.defineProperty(e.prototype, "delay", {
  107953. get: function() {
  107954. return Math.max(this._delay, 1)
  107955. },
  107956. set: function(i) {
  107957. this.playAnimation(this._fromIndex, this._toIndex, this._loopAnimation, i, this._onAnimationEnd)
  107958. },
  107959. enumerable: !1,
  107960. configurable: !0
  107961. }),
  107962. e.prototype.playAnimation = function(i, o, s, c, d) {
  107963. d === void 0 && (d = null),
  107964. this._onAnimationEnd = d,
  107965. a.prototype.playAnimation.call(this, i, o, s, c, this._endAnimation)
  107966. }
  107967. ,
  107968. e.prototype.dispose = function() {
  107969. for (var i = 0; i < this._manager.sprites.length; i++)
  107970. this._manager.sprites[i] == this && this._manager.sprites.splice(i, 1);
  107971. this.onDisposeObservable.notifyObservers(this),
  107972. this.onDisposeObservable.clear()
  107973. }
  107974. ,
  107975. e.prototype.serialize = function() {
  107976. var i = {};
  107977. return i.name = this.name,
  107978. i.position = this.position.asArray(),
  107979. i.color = this.color.asArray(),
  107980. i.width = this.width,
  107981. i.height = this.height,
  107982. i.angle = this.angle,
  107983. i.cellIndex = this.cellIndex,
  107984. i.cellRef = this.cellRef,
  107985. i.invertU = this.invertU,
  107986. i.invertV = this.invertV,
  107987. i.disposeWhenFinishedAnimating = this.disposeWhenFinishedAnimating,
  107988. i.isPickable = this.isPickable,
  107989. i.isVisible = this.isVisible,
  107990. i.useAlphaForPicking = this.useAlphaForPicking,
  107991. i.animationStarted = this.animationStarted,
  107992. i.fromIndex = this.fromIndex,
  107993. i.toIndex = this.toIndex,
  107994. i.loopAnimation = this.loopAnimation,
  107995. i.delay = this.delay,
  107996. i
  107997. }
  107998. ,
  107999. e.Parse = function(i, o) {
  108000. var s = new e(i.name,o);
  108001. return s.position = Vector3.FromArray(i.position),
  108002. s.color = Color4.FromArray(i.color),
  108003. s.width = i.width,
  108004. s.height = i.height,
  108005. s.angle = i.angle,
  108006. s.cellIndex = i.cellIndex,
  108007. s.cellRef = i.cellRef,
  108008. s.invertU = i.invertU,
  108009. s.invertV = i.invertV,
  108010. s.disposeWhenFinishedAnimating = i.disposeWhenFinishedAnimating,
  108011. s.isPickable = i.isPickable,
  108012. s.isVisible = i.isVisible,
  108013. s.useAlphaForPicking = i.useAlphaForPicking,
  108014. s.fromIndex = i.fromIndex,
  108015. s.toIndex = i.toIndex,
  108016. s.loopAnimation = i.loopAnimation,
  108017. s.delay = i.delay,
  108018. i.animationStarted && s.playAnimation(s.fromIndex, s.toIndex, s.loopAnimation, s.delay),
  108019. s
  108020. }
  108021. ,
  108022. e
  108023. }(ThinSprite);
  108024. Scene.prototype._internalPickSprites = function(a, e, i, o) {
  108025. if (!PickingInfo)
  108026. return null;
  108027. var s = null;
  108028. if (!o) {
  108029. if (!this.activeCamera)
  108030. return null;
  108031. o = this.activeCamera
  108032. }
  108033. if (this.spriteManagers.length > 0)
  108034. for (var c = 0; c < this.spriteManagers.length; c++) {
  108035. var d = this.spriteManagers[c];
  108036. if (!!d.isPickable) {
  108037. var _ = d.intersects(a, o, e, i);
  108038. if (!(!_ || !_.hit) && !(!i && s != null && _.distance >= s.distance) && (s = _,
  108039. i))
  108040. break
  108041. }
  108042. }
  108043. return s || new PickingInfo
  108044. }
  108045. ;
  108046. Scene.prototype._internalMultiPickSprites = function(a, e, i) {
  108047. if (!PickingInfo)
  108048. return null;
  108049. var o = new Array;
  108050. if (!i) {
  108051. if (!this.activeCamera)
  108052. return null;
  108053. i = this.activeCamera
  108054. }
  108055. if (this.spriteManagers.length > 0)
  108056. for (var s = 0; s < this.spriteManagers.length; s++) {
  108057. var c = this.spriteManagers[s];
  108058. if (!!c.isPickable) {
  108059. var d = c.multiIntersects(a, i, e);
  108060. d !== null && (o = o.concat(d))
  108061. }
  108062. }
  108063. return o
  108064. }
  108065. ;
  108066. Scene.prototype.pickSprite = function(a, e, i, o, s) {
  108067. if (!this._tempSpritePickingRay)
  108068. return null;
  108069. this.createPickingRayInCameraSpaceToRef(a, e, this._tempSpritePickingRay, s);
  108070. var c = this._internalPickSprites(this._tempSpritePickingRay, i, o, s);
  108071. return c && (c.ray = this.createPickingRayInCameraSpace(a, e, s)),
  108072. c
  108073. }
  108074. ;
  108075. Scene.prototype.pickSpriteWithRay = function(a, e, i, o) {
  108076. if (!this._tempSpritePickingRay)
  108077. return null;
  108078. if (!o) {
  108079. if (!this.activeCamera)
  108080. return null;
  108081. o = this.activeCamera
  108082. }
  108083. Ray.TransformToRef(a, o.getViewMatrix(), this._tempSpritePickingRay);
  108084. var s = this._internalPickSprites(this._tempSpritePickingRay, e, i, o);
  108085. return s && (s.ray = a),
  108086. s
  108087. }
  108088. ;
  108089. Scene.prototype.multiPickSprite = function(a, e, i, o) {
  108090. return this.createPickingRayInCameraSpaceToRef(a, e, this._tempSpritePickingRay, o),
  108091. this._internalMultiPickSprites(this._tempSpritePickingRay, i, o)
  108092. }
  108093. ;
  108094. Scene.prototype.multiPickSpriteWithRay = function(a, e, i) {
  108095. if (!this._tempSpritePickingRay)
  108096. return null;
  108097. if (!i) {
  108098. if (!this.activeCamera)
  108099. return null;
  108100. i = this.activeCamera
  108101. }
  108102. return Ray.TransformToRef(a, i.getViewMatrix(), this._tempSpritePickingRay),
  108103. this._internalMultiPickSprites(this._tempSpritePickingRay, e, i)
  108104. }
  108105. ;
  108106. Scene.prototype.setPointerOverSprite = function(a) {
  108107. this._pointerOverSprite !== a && (this._pointerOverSprite && this._pointerOverSprite.actionManager && this._pointerOverSprite.actionManager.processTrigger(10, ActionEvent.CreateNewFromSprite(this._pointerOverSprite, this)),
  108108. this._pointerOverSprite = a,
  108109. this._pointerOverSprite && this._pointerOverSprite.actionManager && this._pointerOverSprite.actionManager.processTrigger(9, ActionEvent.CreateNewFromSprite(this._pointerOverSprite, this)))
  108110. }
  108111. ;
  108112. Scene.prototype.getPointerOverSprite = function() {
  108113. return this._pointerOverSprite
  108114. }
  108115. ;
  108116. var SpriteSceneComponent = function() {
  108117. function a(e) {
  108118. this.name = SceneComponentConstants.NAME_SPRITE,
  108119. this.scene = e,
  108120. this.scene.spriteManagers = new Array,
  108121. this.scene._tempSpritePickingRay = Ray ? Ray.Zero() : null,
  108122. this.scene.onBeforeSpritesRenderingObservable = new Observable,
  108123. this.scene.onAfterSpritesRenderingObservable = new Observable,
  108124. this._spritePredicate = function(i) {
  108125. return i.actionManager ? i.isPickable && i.actionManager.hasPointerTriggers : !1
  108126. }
  108127. }
  108128. return a.prototype.register = function() {
  108129. this.scene._pointerMoveStage.registerStep(SceneComponentConstants.STEP_POINTERMOVE_SPRITE, this, this._pointerMove),
  108130. this.scene._pointerDownStage.registerStep(SceneComponentConstants.STEP_POINTERDOWN_SPRITE, this, this._pointerDown),
  108131. this.scene._pointerUpStage.registerStep(SceneComponentConstants.STEP_POINTERUP_SPRITE, this, this._pointerUp)
  108132. }
  108133. ,
  108134. a.prototype.rebuild = function() {}
  108135. ,
  108136. a.prototype.dispose = function() {
  108137. this.scene.onBeforeSpritesRenderingObservable.clear(),
  108138. this.scene.onAfterSpritesRenderingObservable.clear();
  108139. for (var e = this.scene.spriteManagers; e.length; )
  108140. e[0].dispose()
  108141. }
  108142. ,
  108143. a.prototype._pickSpriteButKeepRay = function(e, i, o, s, c) {
  108144. var d = this.scene.pickSprite(i, o, this._spritePredicate, s, c);
  108145. return d && (d.ray = e ? e.ray : null),
  108146. d
  108147. }
  108148. ,
  108149. a.prototype._pointerMove = function(e, i, o, s, c) {
  108150. var d = this.scene;
  108151. return s ? d.setPointerOverSprite(null) : (o = this._pickSpriteButKeepRay(o, e, i, !1, d.cameraToUseForPointers || void 0),
  108152. o && o.hit && o.pickedSprite ? (d.setPointerOverSprite(o.pickedSprite),
  108153. !d.doNotHandleCursors && c && (d._pointerOverSprite && d._pointerOverSprite.actionManager && d._pointerOverSprite.actionManager.hoverCursor ? c.style.cursor = d._pointerOverSprite.actionManager.hoverCursor : c.style.cursor = d.hoverCursor)) : d.setPointerOverSprite(null)),
  108154. o
  108155. }
  108156. ,
  108157. a.prototype._pointerDown = function(e, i, o, s) {
  108158. var c = this.scene;
  108159. if (c._pickedDownSprite = null,
  108160. c.spriteManagers.length > 0 && (o = c.pickSprite(e, i, this._spritePredicate, !1, c.cameraToUseForPointers || void 0),
  108161. o && o.hit && o.pickedSprite && o.pickedSprite.actionManager)) {
  108162. switch (c._pickedDownSprite = o.pickedSprite,
  108163. s.button) {
  108164. case 0:
  108165. o.pickedSprite.actionManager.processTrigger(2, ActionEvent.CreateNewFromSprite(o.pickedSprite, c, s));
  108166. break;
  108167. case 1:
  108168. o.pickedSprite.actionManager.processTrigger(4, ActionEvent.CreateNewFromSprite(o.pickedSprite, c, s));
  108169. break;
  108170. case 2:
  108171. o.pickedSprite.actionManager.processTrigger(3, ActionEvent.CreateNewFromSprite(o.pickedSprite, c, s));
  108172. break
  108173. }
  108174. o.pickedSprite.actionManager && o.pickedSprite.actionManager.processTrigger(5, ActionEvent.CreateNewFromSprite(o.pickedSprite, c, s))
  108175. }
  108176. return o
  108177. }
  108178. ,
  108179. a.prototype._pointerUp = function(e, i, o, s) {
  108180. var c = this.scene;
  108181. if (c.spriteManagers.length > 0) {
  108182. var d = c.pickSprite(e, i, this._spritePredicate, !1, c.cameraToUseForPointers || void 0);
  108183. d && (d.hit && d.pickedSprite && d.pickedSprite.actionManager && (d.pickedSprite.actionManager.processTrigger(7, ActionEvent.CreateNewFromSprite(d.pickedSprite, c, s)),
  108184. d.pickedSprite.actionManager && (this.scene._inputManager._isPointerSwiping() || d.pickedSprite.actionManager.processTrigger(1, ActionEvent.CreateNewFromSprite(d.pickedSprite, c, s)))),
  108185. c._pickedDownSprite && c._pickedDownSprite.actionManager && c._pickedDownSprite !== d.pickedSprite && c._pickedDownSprite.actionManager.processTrigger(16, ActionEvent.CreateNewFromSprite(c._pickedDownSprite, c, s)))
  108186. }
  108187. return o
  108188. }
  108189. ,
  108190. a
  108191. }()
  108192. , name$l = "spritesPixelShader"
  108193. , shader$l = `uniform bool alphaTest;
  108194. varying vec4 vColor;
  108195. varying vec2 vUV;
  108196. uniform sampler2D diffuseSampler;
  108197. #include<fogFragmentDeclaration>
  108198. void main(void) {
  108199. vec4 color=texture2D(diffuseSampler,vUV);
  108200. if (alphaTest)
  108201. {
  108202. if (color.a<0.95)
  108203. discard;
  108204. }
  108205. color*=vColor;
  108206. #include<fogFragment>
  108207. gl_FragColor=color;
  108208. #include<imageProcessingCompatibility>
  108209. }`;
  108210. ShaderStore.ShadersStore[name$l] = shader$l;
  108211. var name$k = "spritesVertexShader"
  108212. , shader$k = `
  108213. attribute vec4 position;
  108214. attribute vec2 options;
  108215. attribute vec2 offsets;
  108216. attribute vec2 inverts;
  108217. attribute vec4 cellInfo;
  108218. attribute vec4 color;
  108219. uniform mat4 view;
  108220. uniform mat4 projection;
  108221. varying vec2 vUV;
  108222. varying vec4 vColor;
  108223. #include<fogVertexDeclaration>
  108224. void main(void) {
  108225. vec3 viewPos=(view*vec4(position.xyz,1.0)).xyz;
  108226. vec2 cornerPos;
  108227. float angle=position.w;
  108228. vec2 size=vec2(options.x,options.y);
  108229. vec2 offset=offsets.xy;
  108230. cornerPos=vec2(offset.x-0.5,offset.y-0.5)*size;
  108231. vec3 rotatedCorner;
  108232. rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);
  108233. rotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);
  108234. rotatedCorner.z=0.;
  108235. viewPos+=rotatedCorner;
  108236. gl_Position=projection*vec4(viewPos,1.0);
  108237. vColor=color;
  108238. vec2 uvOffset=vec2(abs(offset.x-inverts.x),abs(1.0-offset.y-inverts.y));
  108239. vec2 uvPlace=cellInfo.xy;
  108240. vec2 uvSize=cellInfo.zw;
  108241. vUV.x=uvPlace.x+uvSize.x*uvOffset.x;
  108242. vUV.y=uvPlace.y+uvSize.y*uvOffset.y;
  108243. #ifdef FOG
  108244. vFogDistance=viewPos;
  108245. #endif
  108246. }`;
  108247. ShaderStore.ShadersStore[name$k] = shader$k;
  108248. var SpriteRenderer = function() {
  108249. function a(e, i, o, s) {
  108250. o === void 0 && (o = .01),
  108251. s === void 0 && (s = null),
  108252. this.blendMode = 2,
  108253. this.autoResetAlpha = !0,
  108254. this.disableDepthWrite = !1,
  108255. this.fogEnabled = !0,
  108256. this._useVAO = !1,
  108257. this._useInstancing = !1,
  108258. this._vertexBuffers = {},
  108259. this._capacity = i,
  108260. this._epsilon = o,
  108261. this._engine = e,
  108262. this._useInstancing = e.getCaps().instancedArrays,
  108263. this._useVAO = e.getCaps().vertexArrayObject && !e.disableVertexArrayObjects,
  108264. this._scene = s,
  108265. this._drawWrapperBase = new DrawWrapper(e),
  108266. this._drawWrapperFog = new DrawWrapper(e),
  108267. this._drawWrapperDepth = new DrawWrapper(e,!1),
  108268. this._drawWrapperFogDepth = new DrawWrapper(e,!1),
  108269. this._useInstancing || this._buildIndexBuffer(),
  108270. this._drawWrapperBase.drawContext && (this._drawWrapperBase.drawContext.useInstancing = this._useInstancing),
  108271. this._drawWrapperFog.drawContext && (this._drawWrapperFog.drawContext.useInstancing = this._useInstancing),
  108272. this._drawWrapperDepth.drawContext && (this._drawWrapperDepth.drawContext.useInstancing = this._useInstancing),
  108273. this._drawWrapperFogDepth.drawContext && (this._drawWrapperFogDepth.drawContext.useInstancing = this._useInstancing),
  108274. this._vertexBufferSize = this._useInstancing ? 16 : 18,
  108275. this._vertexData = new Float32Array(i * this._vertexBufferSize * (this._useInstancing ? 1 : 4)),
  108276. this._buffer = new Buffer(e,this._vertexData,!0,this._vertexBufferSize);
  108277. var c = this._buffer.createVertexBuffer(VertexBuffer.PositionKind, 0, 4, this._vertexBufferSize, this._useInstancing), d = this._buffer.createVertexBuffer("options", 4, 2, this._vertexBufferSize, this._useInstancing), _ = 6, b;
  108278. if (this._useInstancing) {
  108279. var k = new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]);
  108280. this._spriteBuffer = new Buffer(e,k,!1,2),
  108281. b = this._spriteBuffer.createVertexBuffer("offsets", 0, 2)
  108282. } else
  108283. b = this._buffer.createVertexBuffer("offsets", _, 2, this._vertexBufferSize, this._useInstancing),
  108284. _ += 2;
  108285. var j = this._buffer.createVertexBuffer("inverts", _, 2, this._vertexBufferSize, this._useInstancing)
  108286. , $ = this._buffer.createVertexBuffer("cellInfo", _ + 2, 4, this._vertexBufferSize, this._useInstancing)
  108287. , _e = this._buffer.createVertexBuffer(VertexBuffer.ColorKind, _ + 6, 4, this._vertexBufferSize, this._useInstancing);
  108288. this._vertexBuffers[VertexBuffer.PositionKind] = c,
  108289. this._vertexBuffers.options = d,
  108290. this._vertexBuffers.offsets = b,
  108291. this._vertexBuffers.inverts = j,
  108292. this._vertexBuffers.cellInfo = $,
  108293. this._vertexBuffers[VertexBuffer.ColorKind] = _e,
  108294. this._drawWrapperBase.effect = this._engine.createEffect("sprites", [VertexBuffer.PositionKind, "options", "offsets", "inverts", "cellInfo", VertexBuffer.ColorKind], ["view", "projection", "textureInfos", "alphaTest"], ["diffuseSampler"], ""),
  108295. this._drawWrapperDepth.effect = this._drawWrapperBase.effect,
  108296. this._drawWrapperDepth.materialContext = this._drawWrapperBase.materialContext,
  108297. this._scene && (this._drawWrapperFog.effect = this._scene.getEngine().createEffect("sprites", [VertexBuffer.PositionKind, "options", "offsets", "inverts", "cellInfo", VertexBuffer.ColorKind], ["view", "projection", "textureInfos", "alphaTest", "vFogInfos", "vFogColor"], ["diffuseSampler"], "#define FOG"),
  108298. this._drawWrapperFogDepth.effect = this._drawWrapperFog.effect,
  108299. this._drawWrapperFogDepth.materialContext = this._drawWrapperFog.materialContext)
  108300. }
  108301. return Object.defineProperty(a.prototype, "capacity", {
  108302. get: function() {
  108303. return this._capacity
  108304. },
  108305. enumerable: !1,
  108306. configurable: !0
  108307. }),
  108308. a.prototype.render = function(e, i, o, s, c) {
  108309. if (c === void 0 && (c = null),
  108310. !(!this.texture || !this.texture.isReady() || !e.length)) {
  108311. var d = this._drawWrapperBase
  108312. , _ = this._drawWrapperDepth
  108313. , b = !1;
  108314. this.fogEnabled && this._scene && this._scene.fogEnabled && this._scene.fogMode !== 0 && (d = this._drawWrapperFog,
  108315. _ = this._drawWrapperFogDepth,
  108316. b = !0);
  108317. var k = d.effect;
  108318. if (!!k.isReady()) {
  108319. for (var j = this._engine, $ = !!(this._scene && this._scene.useRightHandedSystem), _e = this.texture.getBaseSize(), et = Math.min(this._capacity, e.length), tt = 0, rt = !0, it = 0; it < et; it++) {
  108320. var nt = e[it];
  108321. !nt || !nt.isVisible || (rt = !1,
  108322. nt._animate(i),
  108323. this._appendSpriteVertex(tt++, nt, 0, 0, _e, $, c),
  108324. this._useInstancing || (this._appendSpriteVertex(tt++, nt, 1, 0, _e, $, c),
  108325. this._appendSpriteVertex(tt++, nt, 1, 1, _e, $, c),
  108326. this._appendSpriteVertex(tt++, nt, 0, 1, _e, $, c)))
  108327. }
  108328. if (!rt) {
  108329. this._buffer.update(this._vertexData);
  108330. var ot = j.depthCullingState.cull || !0
  108331. , at = j.depthCullingState.zOffset
  108332. , st = j.depthCullingState.zOffsetUnits;
  108333. if (j.setState(ot, at, !1, !1, void 0, void 0, st),
  108334. j.enableEffect(d),
  108335. k.setTexture("diffuseSampler", this.texture),
  108336. k.setMatrix("view", o),
  108337. k.setMatrix("projection", s),
  108338. b) {
  108339. var ut = this._scene;
  108340. k.setFloat4("vFogInfos", ut.fogMode, ut.fogStart, ut.fogEnd, ut.fogDensity),
  108341. k.setColor3("vFogColor", ut.fogColor)
  108342. }
  108343. this._useVAO ? (this._vertexArrayObject || (this._vertexArrayObject = j.recordVertexArrayObject(this._vertexBuffers, this._indexBuffer, k)),
  108344. j.bindVertexArrayObject(this._vertexArrayObject, this._indexBuffer)) : j.bindBuffers(this._vertexBuffers, this._indexBuffer, k),
  108345. j.depthCullingState.depthFunc = j.useReverseDepthBuffer ? 518 : 515,
  108346. this.disableDepthWrite || (k.setBool("alphaTest", !0),
  108347. j.setColorWrite(!1),
  108348. j.enableEffect(_),
  108349. this._useInstancing ? j.drawArraysType(7, 0, 4, tt) : j.drawElementsType(0, 0, tt / 4 * 6),
  108350. j.enableEffect(d),
  108351. j.setColorWrite(!0),
  108352. k.setBool("alphaTest", !1)),
  108353. j.setAlphaMode(this.blendMode),
  108354. this._useInstancing ? j.drawArraysType(7, 0, 4, tt) : j.drawElementsType(0, 0, tt / 4 * 6),
  108355. this.autoResetAlpha && j.setAlphaMode(0),
  108356. $ && this._scene.getEngine().setState(ot, at, !1, !0, void 0, void 0, st),
  108357. j.unbindInstanceAttributes()
  108358. }
  108359. }
  108360. }
  108361. }
  108362. ,
  108363. a.prototype._appendSpriteVertex = function(e, i, o, s, c, d, _) {
  108364. var b = e * this._vertexBufferSize;
  108365. if (o === 0 ? o = this._epsilon : o === 1 && (o = 1 - this._epsilon),
  108366. s === 0 ? s = this._epsilon : s === 1 && (s = 1 - this._epsilon),
  108367. _)
  108368. _(i, c);
  108369. else {
  108370. i.cellIndex || (i.cellIndex = 0);
  108371. var k = c.width / this.cellWidth
  108372. , j = i.cellIndex / k >> 0;
  108373. i._xOffset = (i.cellIndex - j * k) * this.cellWidth / c.width,
  108374. i._yOffset = j * this.cellHeight / c.height,
  108375. i._xSize = this.cellWidth,
  108376. i._ySize = this.cellHeight
  108377. }
  108378. this._vertexData[b] = i.position.x,
  108379. this._vertexData[b + 1] = i.position.y,
  108380. this._vertexData[b + 2] = i.position.z,
  108381. this._vertexData[b + 3] = i.angle,
  108382. this._vertexData[b + 4] = i.width,
  108383. this._vertexData[b + 5] = i.height,
  108384. this._useInstancing ? b -= 2 : (this._vertexData[b + 6] = o,
  108385. this._vertexData[b + 7] = s),
  108386. d ? this._vertexData[b + 8] = i.invertU ? 0 : 1 : this._vertexData[b + 8] = i.invertU ? 1 : 0,
  108387. this._vertexData[b + 9] = i.invertV ? 1 : 0,
  108388. this._vertexData[b + 10] = i._xOffset,
  108389. this._vertexData[b + 11] = i._yOffset,
  108390. this._vertexData[b + 12] = i._xSize / c.width,
  108391. this._vertexData[b + 13] = i._ySize / c.height,
  108392. this._vertexData[b + 14] = i.color.r,
  108393. this._vertexData[b + 15] = i.color.g,
  108394. this._vertexData[b + 16] = i.color.b,
  108395. this._vertexData[b + 17] = i.color.a
  108396. }
  108397. ,
  108398. a.prototype._buildIndexBuffer = function() {
  108399. for (var e = [], i = 0, o = 0; o < this._capacity; o++)
  108400. e.push(i),
  108401. e.push(i + 1),
  108402. e.push(i + 2),
  108403. e.push(i),
  108404. e.push(i + 2),
  108405. e.push(i + 3),
  108406. i += 4;
  108407. this._indexBuffer = this._engine.createIndexBuffer(e)
  108408. }
  108409. ,
  108410. a.prototype.rebuild = function() {
  108411. var e;
  108412. this._indexBuffer && this._buildIndexBuffer(),
  108413. this._useVAO && (this._vertexArrayObject = void 0),
  108414. this._buffer._rebuild();
  108415. for (var i in this._vertexBuffers) {
  108416. var o = this._vertexBuffers[i];
  108417. o._rebuild()
  108418. }
  108419. (e = this._spriteBuffer) === null || e === void 0 || e._rebuild()
  108420. }
  108421. ,
  108422. a.prototype.dispose = function() {
  108423. this._buffer && (this._buffer.dispose(),
  108424. this._buffer = null),
  108425. this._spriteBuffer && (this._spriteBuffer.dispose(),
  108426. this._spriteBuffer = null),
  108427. this._indexBuffer && (this._engine._releaseBuffer(this._indexBuffer),
  108428. this._indexBuffer = null),
  108429. this._vertexArrayObject && (this._engine.releaseVertexArrayObject(this._vertexArrayObject),
  108430. this._vertexArrayObject = null),
  108431. this.texture && (this.texture.dispose(),
  108432. this.texture = null),
  108433. this._drawWrapperBase.dispose(),
  108434. this._drawWrapperFog.dispose(),
  108435. this._drawWrapperDepth.dispose(),
  108436. this._drawWrapperFogDepth.dispose()
  108437. }
  108438. ,
  108439. a
  108440. }()
  108441. , SpriteManager = function() {
  108442. function a(e, i, o, s, c, d, _, b, k) {
  108443. var j = this;
  108444. d === void 0 && (d = .01),
  108445. _ === void 0 && (_ = Texture.TRILINEAR_SAMPLINGMODE),
  108446. b === void 0 && (b = !1),
  108447. k === void 0 && (k = null),
  108448. this.name = e,
  108449. this.sprites = new Array,
  108450. this.renderingGroupId = 0,
  108451. this.layerMask = 268435455,
  108452. this.isPickable = !1,
  108453. this.onDisposeObservable = new Observable,
  108454. this._disableDepthWrite = !1,
  108455. this._packedAndReady = !1,
  108456. this._customUpdate = function(_e, et) {
  108457. _e.cellRef || (_e.cellIndex = 0);
  108458. var tt = _e.cellIndex;
  108459. typeof tt == "number" && isFinite(tt) && Math.floor(tt) === tt && (_e.cellRef = j._spriteMap[_e.cellIndex]),
  108460. _e._xOffset = j._cellData[_e.cellRef].frame.x / et.width,
  108461. _e._yOffset = j._cellData[_e.cellRef].frame.y / et.height,
  108462. _e._xSize = j._cellData[_e.cellRef].frame.w,
  108463. _e._ySize = j._cellData[_e.cellRef].frame.h
  108464. }
  108465. ,
  108466. c || (c = Engine.LastCreatedScene),
  108467. c._getComponent(SceneComponentConstants.NAME_SPRITE) || c._addComponent(new SpriteSceneComponent(c)),
  108468. this._fromPacked = b,
  108469. this._scene = c;
  108470. var $ = this._scene.getEngine();
  108471. if (this._spriteRenderer = new SpriteRenderer($,o,d,c),
  108472. s.width && s.height)
  108473. this.cellWidth = s.width,
  108474. this.cellHeight = s.height;
  108475. else if (s !== void 0)
  108476. this.cellWidth = s,
  108477. this.cellHeight = s;
  108478. else {
  108479. this._spriteRenderer = null;
  108480. return
  108481. }
  108482. this._scene.spriteManagers.push(this),
  108483. this.uniqueId = this.scene.getUniqueId(),
  108484. i && (this.texture = new Texture(i,c,!0,!1,_)),
  108485. this._fromPacked && this._makePacked(i, k)
  108486. }
  108487. return Object.defineProperty(a.prototype, "onDispose", {
  108488. set: function(e) {
  108489. this._onDisposeObserver && this.onDisposeObservable.remove(this._onDisposeObserver),
  108490. this._onDisposeObserver = this.onDisposeObservable.add(e)
  108491. },
  108492. enumerable: !1,
  108493. configurable: !0
  108494. }),
  108495. Object.defineProperty(a.prototype, "children", {
  108496. get: function() {
  108497. return this.sprites
  108498. },
  108499. enumerable: !1,
  108500. configurable: !0
  108501. }),
  108502. Object.defineProperty(a.prototype, "scene", {
  108503. get: function() {
  108504. return this._scene
  108505. },
  108506. enumerable: !1,
  108507. configurable: !0
  108508. }),
  108509. Object.defineProperty(a.prototype, "capacity", {
  108510. get: function() {
  108511. return this._spriteRenderer.capacity
  108512. },
  108513. enumerable: !1,
  108514. configurable: !0
  108515. }),
  108516. Object.defineProperty(a.prototype, "texture", {
  108517. get: function() {
  108518. return this._spriteRenderer.texture
  108519. },
  108520. set: function(e) {
  108521. e.wrapU = Texture.CLAMP_ADDRESSMODE,
  108522. e.wrapV = Texture.CLAMP_ADDRESSMODE,
  108523. this._spriteRenderer.texture = e,
  108524. this._textureContent = null
  108525. },
  108526. enumerable: !1,
  108527. configurable: !0
  108528. }),
  108529. Object.defineProperty(a.prototype, "cellWidth", {
  108530. get: function() {
  108531. return this._spriteRenderer.cellWidth
  108532. },
  108533. set: function(e) {
  108534. this._spriteRenderer.cellWidth = e
  108535. },
  108536. enumerable: !1,
  108537. configurable: !0
  108538. }),
  108539. Object.defineProperty(a.prototype, "cellHeight", {
  108540. get: function() {
  108541. return this._spriteRenderer.cellHeight
  108542. },
  108543. set: function(e) {
  108544. this._spriteRenderer.cellHeight = e
  108545. },
  108546. enumerable: !1,
  108547. configurable: !0
  108548. }),
  108549. Object.defineProperty(a.prototype, "fogEnabled", {
  108550. get: function() {
  108551. return this._spriteRenderer.fogEnabled
  108552. },
  108553. set: function(e) {
  108554. this._spriteRenderer.fogEnabled = e
  108555. },
  108556. enumerable: !1,
  108557. configurable: !0
  108558. }),
  108559. Object.defineProperty(a.prototype, "blendMode", {
  108560. get: function() {
  108561. return this._spriteRenderer.blendMode
  108562. },
  108563. set: function(e) {
  108564. this._spriteRenderer.blendMode = e
  108565. },
  108566. enumerable: !1,
  108567. configurable: !0
  108568. }),
  108569. Object.defineProperty(a.prototype, "disableDepthWrite", {
  108570. get: function() {
  108571. return this._disableDepthWrite
  108572. },
  108573. set: function(e) {
  108574. this._disableDepthWrite = e,
  108575. this._spriteRenderer.disableDepthWrite = e
  108576. },
  108577. enumerable: !1,
  108578. configurable: !0
  108579. }),
  108580. a.prototype.getClassName = function() {
  108581. return "SpriteManager"
  108582. }
  108583. ,
  108584. a.prototype._makePacked = function(e, i) {
  108585. var o = this;
  108586. if (i !== null)
  108587. try {
  108588. var s = void 0;
  108589. if (typeof i == "string" ? s = JSON.parse(i) : s = i,
  108590. s.frames.length) {
  108591. for (var c = {}, d = 0; d < s.frames.length; d++) {
  108592. var _ = s.frames[d];
  108593. if (typeof Object.keys(_)[0] != "string")
  108594. throw new Error("Invalid JSON Format. Check the frame values and make sure the name is the first parameter.");
  108595. var b = _[Object.keys(_)[0]];
  108596. c[b] = _
  108597. }
  108598. s.frames = c
  108599. }
  108600. var k = Reflect.ownKeys(s.frames);
  108601. this._spriteMap = k,
  108602. this._packedAndReady = !0,
  108603. this._cellData = s.frames
  108604. } catch {
  108605. throw this._fromPacked = !1,
  108606. this._packedAndReady = !1,
  108607. new Error("Invalid JSON from string. Spritesheet managed with constant cell size.")
  108608. }
  108609. else {
  108610. var j = /\./g
  108611. , $ = void 0;
  108612. do
  108613. $ = j.lastIndex,
  108614. j.test(e);
  108615. while (j.lastIndex > 0);
  108616. var _e = e.substring(0, $ - 1) + ".json"
  108617. , et = new XMLHttpRequest;
  108618. et.open("GET", _e, !0),
  108619. et.onerror = function() {
  108620. Logger$2.Error("JSON ERROR: Unable to load JSON file."),
  108621. o._fromPacked = !1,
  108622. o._packedAndReady = !1
  108623. }
  108624. ,
  108625. et.onload = function() {
  108626. try {
  108627. var tt = JSON.parse(et.response)
  108628. , rt = Reflect.ownKeys(tt.frames);
  108629. o._spriteMap = rt,
  108630. o._packedAndReady = !0,
  108631. o._cellData = tt.frames
  108632. } catch {
  108633. throw o._fromPacked = !1,
  108634. o._packedAndReady = !1,
  108635. new Error("Invalid JSON format. Please check documentation for format specifications.")
  108636. }
  108637. }
  108638. ,
  108639. et.send()
  108640. }
  108641. }
  108642. ,
  108643. a.prototype._checkTextureAlpha = function(e, i, o, s, c) {
  108644. if (!e.useAlphaForPicking || !this.texture)
  108645. return !0;
  108646. var d = this.texture.getSize();
  108647. this._textureContent || (this._textureContent = new Uint8Array(d.width * d.height * 4),
  108648. this.texture.readPixels(0, 0, this._textureContent));
  108649. var _ = TmpVectors.Vector3[0];
  108650. _.copyFrom(i.direction),
  108651. _.normalize(),
  108652. _.scaleInPlace(o),
  108653. _.addInPlace(i.origin);
  108654. var b = (_.x - s.x) / (c.x - s.x) - .5
  108655. , k = 1 - (_.y - s.y) / (c.y - s.y) - .5
  108656. , j = e.angle
  108657. , $ = .5 + (b * Math.cos(j) - k * Math.sin(j))
  108658. , _e = .5 + (b * Math.sin(j) + k * Math.cos(j))
  108659. , et = e._xOffset * d.width + $ * e._xSize | 0
  108660. , tt = e._yOffset * d.height + _e * e._ySize | 0
  108661. , rt = this._textureContent[(et + tt * d.width) * 4 + 3];
  108662. return rt > .5
  108663. }
  108664. ,
  108665. a.prototype.intersects = function(e, i, o, s) {
  108666. for (var c = Math.min(this.capacity, this.sprites.length), d = Vector3.Zero(), _ = Vector3.Zero(), b = Number.MAX_VALUE, k = null, j = TmpVectors.Vector3[0], $ = TmpVectors.Vector3[1], _e = i.getViewMatrix(), et = e, tt = e, rt = 0; rt < c; rt++) {
  108667. var it = this.sprites[rt];
  108668. if (!!it) {
  108669. if (o) {
  108670. if (!o(it))
  108671. continue
  108672. } else if (!it.isPickable)
  108673. continue;
  108674. if (Vector3.TransformCoordinatesToRef(it.position, _e, $),
  108675. it.angle ? (Matrix.TranslationToRef(-$.x, -$.y, 0, TmpVectors.Matrix[1]),
  108676. Matrix.TranslationToRef($.x, $.y, 0, TmpVectors.Matrix[2]),
  108677. Matrix.RotationZToRef(it.angle, TmpVectors.Matrix[3]),
  108678. TmpVectors.Matrix[1].multiplyToRef(TmpVectors.Matrix[3], TmpVectors.Matrix[4]),
  108679. TmpVectors.Matrix[4].multiplyToRef(TmpVectors.Matrix[2], TmpVectors.Matrix[0]),
  108680. et = e.clone(),
  108681. Vector3.TransformCoordinatesToRef(e.origin, TmpVectors.Matrix[0], et.origin),
  108682. Vector3.TransformNormalToRef(e.direction, TmpVectors.Matrix[0], et.direction)) : et = e,
  108683. d.copyFromFloats($.x - it.width / 2, $.y - it.height / 2, $.z),
  108684. _.copyFromFloats($.x + it.width / 2, $.y + it.height / 2, $.z),
  108685. et.intersectsBoxMinMax(d, _)) {
  108686. var nt = Vector3.Distance($, et.origin);
  108687. if (b > nt) {
  108688. if (!this._checkTextureAlpha(it, et, nt, d, _))
  108689. continue;
  108690. if (tt = et,
  108691. b = nt,
  108692. k = it,
  108693. s)
  108694. break
  108695. }
  108696. }
  108697. }
  108698. }
  108699. if (k) {
  108700. var ot = new PickingInfo;
  108701. _e.invertToRef(TmpVectors.Matrix[0]),
  108702. ot.hit = !0,
  108703. ot.pickedSprite = k,
  108704. ot.distance = b;
  108705. var at = TmpVectors.Vector3[2];
  108706. return at.copyFrom(tt.direction),
  108707. at.normalize(),
  108708. at.scaleInPlace(b),
  108709. tt.origin.addToRef(at, j),
  108710. ot.pickedPoint = Vector3.TransformCoordinates(j, TmpVectors.Matrix[0]),
  108711. ot
  108712. }
  108713. return null
  108714. }
  108715. ,
  108716. a.prototype.multiIntersects = function(e, i, o) {
  108717. for (var s = Math.min(this.capacity, this.sprites.length), c = Vector3.Zero(), d = Vector3.Zero(), _, b = [], k = TmpVectors.Vector3[0].copyFromFloats(0, 0, 0), j = TmpVectors.Vector3[1].copyFromFloats(0, 0, 0), $ = i.getViewMatrix(), _e = 0; _e < s; _e++) {
  108718. var et = this.sprites[_e];
  108719. if (!!et) {
  108720. if (o) {
  108721. if (!o(et))
  108722. continue
  108723. } else if (!et.isPickable)
  108724. continue;
  108725. if (Vector3.TransformCoordinatesToRef(et.position, $, j),
  108726. c.copyFromFloats(j.x - et.width / 2, j.y - et.height / 2, j.z),
  108727. d.copyFromFloats(j.x + et.width / 2, j.y + et.height / 2, j.z),
  108728. e.intersectsBoxMinMax(c, d)) {
  108729. if (_ = Vector3.Distance(j, e.origin),
  108730. !this._checkTextureAlpha(et, e, _, c, d))
  108731. continue;
  108732. var tt = new PickingInfo;
  108733. b.push(tt),
  108734. $.invertToRef(TmpVectors.Matrix[0]),
  108735. tt.hit = !0,
  108736. tt.pickedSprite = et,
  108737. tt.distance = _;
  108738. var rt = TmpVectors.Vector3[2];
  108739. rt.copyFrom(e.direction),
  108740. rt.normalize(),
  108741. rt.scaleInPlace(_),
  108742. e.origin.addToRef(rt, k),
  108743. tt.pickedPoint = Vector3.TransformCoordinates(k, TmpVectors.Matrix[0])
  108744. }
  108745. }
  108746. }
  108747. return b
  108748. }
  108749. ,
  108750. a.prototype.render = function() {
  108751. if (!(this._fromPacked && (!this._packedAndReady || !this._spriteMap || !this._cellData))) {
  108752. var e = 16.6;
  108753. this._packedAndReady ? this._spriteRenderer.render(this.sprites, e, this._scene.getViewMatrix(), this._scene.getProjectionMatrix(), this._customUpdate) : this._spriteRenderer.render(this.sprites, e, this._scene.getViewMatrix(), this._scene.getProjectionMatrix())
  108754. }
  108755. }
  108756. ,
  108757. a.prototype.rebuild = function() {
  108758. var e;
  108759. (e = this._spriteRenderer) === null || e === void 0 || e.rebuild()
  108760. }
  108761. ,
  108762. a.prototype.dispose = function() {
  108763. this._spriteRenderer && (this._spriteRenderer.dispose(),
  108764. this._spriteRenderer = null),
  108765. this._textureContent = null;
  108766. var e = this._scene.spriteManagers.indexOf(this);
  108767. this._scene.spriteManagers.splice(e, 1),
  108768. this.onDisposeObservable.notifyObservers(this),
  108769. this.onDisposeObservable.clear()
  108770. }
  108771. ,
  108772. a.prototype.serialize = function(e) {
  108773. e === void 0 && (e = !1);
  108774. var i = {};
  108775. i.name = this.name,
  108776. i.capacity = this.capacity,
  108777. i.cellWidth = this.cellWidth,
  108778. i.cellHeight = this.cellHeight,
  108779. this.texture && (e ? i.texture = this.texture.serialize() : (i.textureUrl = this.texture.name,
  108780. i.invertY = this.texture._invertY)),
  108781. i.sprites = [];
  108782. for (var o = 0, s = this.sprites; o < s.length; o++) {
  108783. var c = s[o];
  108784. i.sprites.push(c.serialize())
  108785. }
  108786. return i
  108787. }
  108788. ,
  108789. a.Parse = function(e, i, o) {
  108790. var s = new a(e.name,"",e.capacity,{
  108791. width: e.cellWidth,
  108792. height: e.cellHeight
  108793. },i);
  108794. e.texture ? s.texture = Texture.Parse(e.texture, i, o) : e.textureName && (s.texture = new Texture(o + e.textureUrl,i,!1,e.invertY !== void 0 ? e.invertY : !0));
  108795. for (var c = 0, d = e.sprites; c < d.length; c++) {
  108796. var _ = d[c];
  108797. Sprite.Parse(_, s)
  108798. }
  108799. return s
  108800. }
  108801. ,
  108802. a.ParseFromFileAsync = function(e, i, o, s) {
  108803. return s === void 0 && (s = ""),
  108804. new Promise(function(c, d) {
  108805. var _ = new WebRequest;
  108806. _.addEventListener("readystatechange", function() {
  108807. if (_.readyState == 4)
  108808. if (_.status == 200) {
  108809. var b = JSON.parse(_.responseText)
  108810. , k = a.Parse(b, o || Engine.LastCreatedScene, s);
  108811. e && (k.name = e),
  108812. c(k)
  108813. } else
  108814. d("Unable to load the sprite manager")
  108815. }),
  108816. _.open("GET", i),
  108817. _.send()
  108818. }
  108819. )
  108820. }
  108821. ,
  108822. a.CreateFromSnippetAsync = function(e, i, o) {
  108823. var s = this;
  108824. return o === void 0 && (o = ""),
  108825. e === "_BLANK" ? Promise.resolve(new a("Default sprite manager","//playground.babylonjs.com/textures/player.png",500,64,i)) : new Promise(function(c, d) {
  108826. var _ = new WebRequest;
  108827. _.addEventListener("readystatechange", function() {
  108828. if (_.readyState == 4)
  108829. if (_.status == 200) {
  108830. var b = JSON.parse(JSON.parse(_.responseText).jsonPayload)
  108831. , k = JSON.parse(b.spriteManager)
  108832. , j = a.Parse(k, i || Engine.LastCreatedScene, o);
  108833. j.snippetId = e,
  108834. c(j)
  108835. } else
  108836. d("Unable to load the snippet " + e)
  108837. }),
  108838. _.open("GET", s.SnippetUrl + "/" + e.replace(/#/g, "/")),
  108839. _.send()
  108840. }
  108841. )
  108842. }
  108843. ,
  108844. a.SnippetUrl = "https://snippet.babylonjs.com",
  108845. a
  108846. }()
  108847. , UtilityLayerRenderer = function() {
  108848. function a(e, i) {
  108849. var o = this;
  108850. i === void 0 && (i = !0),
  108851. this.originalScene = e,
  108852. this._pointerCaptures = {},
  108853. this._lastPointerEvents = {},
  108854. this._sharedGizmoLight = null,
  108855. this._renderCamera = null,
  108856. this.pickUtilitySceneFirst = !0,
  108857. this.shouldRender = !0,
  108858. this.onlyCheckPointerDownEvents = !0,
  108859. this.processAllEvents = !1,
  108860. this.pickingEnabled = !0,
  108861. this.onPointerOutObservable = new Observable,
  108862. this.utilityLayerScene = new Scene(e.getEngine(),{
  108863. virtual: !0
  108864. }),
  108865. this.utilityLayerScene.useRightHandedSystem = e.useRightHandedSystem,
  108866. this.utilityLayerScene._allowPostProcessClearColor = !1,
  108867. this.utilityLayerScene.detachControl(),
  108868. i && (this._originalPointerObserver = e.onPrePointerObservable.add(function(s, c) {
  108869. if (!!o.utilityLayerScene.activeCamera && !!o.pickingEnabled && !(!o.processAllEvents && s.type !== PointerEventTypes.POINTERMOVE && s.type !== PointerEventTypes.POINTERUP && s.type !== PointerEventTypes.POINTERDOWN && s.type !== PointerEventTypes.POINTERDOUBLETAP)) {
  108870. o.utilityLayerScene.pointerX = e.pointerX,
  108871. o.utilityLayerScene.pointerY = e.pointerY;
  108872. var d = s.event;
  108873. if (e.isPointerCaptured(d.pointerId)) {
  108874. o._pointerCaptures[d.pointerId] = !1;
  108875. return
  108876. }
  108877. var _ = function($) {
  108878. var _e = null;
  108879. if (s.nearInteractionPickingInfo)
  108880. s.nearInteractionPickingInfo.pickedMesh.getScene() == $ ? _e = s.nearInteractionPickingInfo : _e = new PickingInfo;
  108881. else {
  108882. var et = null;
  108883. o._renderCamera && (et = $._activeCamera,
  108884. $._activeCamera = o._renderCamera,
  108885. s.ray = null),
  108886. _e = s.ray ? $.pickWithRay(s.ray) : $.pick(e.pointerX, e.pointerY),
  108887. et && ($._activeCamera = et)
  108888. }
  108889. return _e
  108890. }
  108891. , b = _(o.utilityLayerScene);
  108892. if (!s.ray && b && (s.ray = b.ray),
  108893. o.utilityLayerScene.onPrePointerObservable.notifyObservers(s),
  108894. o.onlyCheckPointerDownEvents && s.type != PointerEventTypes.POINTERDOWN) {
  108895. s.skipOnPointerObservable || o.utilityLayerScene.onPointerObservable.notifyObservers(new PointerInfo(s.type,s.event,b), s.type),
  108896. s.type === PointerEventTypes.POINTERUP && o._pointerCaptures[d.pointerId] && (o._pointerCaptures[d.pointerId] = !1);
  108897. return
  108898. }
  108899. if (o.utilityLayerScene.autoClearDepthAndStencil || o.pickUtilitySceneFirst)
  108900. b && b.hit && (s.skipOnPointerObservable || o.utilityLayerScene.onPointerObservable.notifyObservers(new PointerInfo(s.type,s.event,b), s.type),
  108901. s.skipOnPointerObservable = !0);
  108902. else {
  108903. var k = _(e)
  108904. , j = s.event;
  108905. k && b && (b.distance === 0 && k.pickedMesh ? o.mainSceneTrackerPredicate && o.mainSceneTrackerPredicate(k.pickedMesh) ? (o._notifyObservers(s, k, j),
  108906. s.skipOnPointerObservable = !0) : s.type === PointerEventTypes.POINTERDOWN ? o._pointerCaptures[j.pointerId] = !0 : (s.type === PointerEventTypes.POINTERMOVE || s.type === PointerEventTypes.POINTERUP) && (o._lastPointerEvents[j.pointerId] && (o.onPointerOutObservable.notifyObservers(j.pointerId),
  108907. delete o._lastPointerEvents[j.pointerId]),
  108908. o._notifyObservers(s, k, j)) : !o._pointerCaptures[j.pointerId] && (b.distance < k.distance || k.distance === 0) ? (o._notifyObservers(s, b, j),
  108909. s.skipOnPointerObservable || (s.skipOnPointerObservable = b.distance > 0)) : !o._pointerCaptures[j.pointerId] && b.distance > k.distance && (o.mainSceneTrackerPredicate && o.mainSceneTrackerPredicate(k.pickedMesh) ? (o._notifyObservers(s, k, j),
  108910. s.skipOnPointerObservable = !0) : (s.type === PointerEventTypes.POINTERMOVE || s.type === PointerEventTypes.POINTERUP) && (o._lastPointerEvents[j.pointerId] && (o.onPointerOutObservable.notifyObservers(j.pointerId),
  108911. delete o._lastPointerEvents[j.pointerId]),
  108912. o._notifyObservers(s, b, j))),
  108913. s.type === PointerEventTypes.POINTERUP && o._pointerCaptures[j.pointerId] && (o._pointerCaptures[j.pointerId] = !1))
  108914. }
  108915. }
  108916. }),
  108917. this._originalPointerObserver && e.onPrePointerObservable.makeObserverTopPriority(this._originalPointerObserver)),
  108918. this.utilityLayerScene.autoClear = !1,
  108919. this._afterRenderObserver = this.originalScene.onAfterCameraRenderObservable.add(function(s) {
  108920. o.shouldRender && s == o.getRenderCamera() && o.render()
  108921. }),
  108922. this._sceneDisposeObserver = this.originalScene.onDisposeObservable.add(function() {
  108923. o.dispose()
  108924. }),
  108925. this._updateCamera()
  108926. }
  108927. return a.prototype.getRenderCamera = function(e) {
  108928. if (this._renderCamera)
  108929. return this._renderCamera;
  108930. var i = void 0;
  108931. return this.originalScene.activeCameras && this.originalScene.activeCameras.length > 1 ? i = this.originalScene.activeCameras[this.originalScene.activeCameras.length - 1] : i = this.originalScene.activeCamera,
  108932. e && i && i.isRigCamera ? i.rigParent : i
  108933. }
  108934. ,
  108935. a.prototype.setRenderCamera = function(e) {
  108936. this._renderCamera = e
  108937. }
  108938. ,
  108939. a.prototype._getSharedGizmoLight = function() {
  108940. return this._sharedGizmoLight || (this._sharedGizmoLight = new HemisphericLight("shared gizmo light",new Vector3(0,1,0),this.utilityLayerScene),
  108941. this._sharedGizmoLight.intensity = 2,
  108942. this._sharedGizmoLight.groundColor = Color3.Gray()),
  108943. this._sharedGizmoLight
  108944. }
  108945. ,
  108946. Object.defineProperty(a, "DefaultUtilityLayer", {
  108947. get: function() {
  108948. return a._DefaultUtilityLayer == null ? a._CreateDefaultUtilityLayerFromScene(EngineStore.LastCreatedScene) : a._DefaultUtilityLayer
  108949. },
  108950. enumerable: !1,
  108951. configurable: !0
  108952. }),
  108953. a._CreateDefaultUtilityLayerFromScene = function(e) {
  108954. return a._DefaultUtilityLayer = new a(e),
  108955. a._DefaultUtilityLayer.originalScene.onDisposeObservable.addOnce(function() {
  108956. a._DefaultUtilityLayer = null
  108957. }),
  108958. a._DefaultUtilityLayer
  108959. }
  108960. ,
  108961. Object.defineProperty(a, "DefaultKeepDepthUtilityLayer", {
  108962. get: function() {
  108963. return a._DefaultKeepDepthUtilityLayer == null && (a._DefaultKeepDepthUtilityLayer = new a(EngineStore.LastCreatedScene),
  108964. a._DefaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = !1,
  108965. a._DefaultKeepDepthUtilityLayer.originalScene.onDisposeObservable.addOnce(function() {
  108966. a._DefaultKeepDepthUtilityLayer = null
  108967. })),
  108968. a._DefaultKeepDepthUtilityLayer
  108969. },
  108970. enumerable: !1,
  108971. configurable: !0
  108972. }),
  108973. a.prototype._notifyObservers = function(e, i, o) {
  108974. e.skipOnPointerObservable || (this.utilityLayerScene.onPointerObservable.notifyObservers(new PointerInfo(e.type,e.event,i), e.type),
  108975. this._lastPointerEvents[o.pointerId] = !0)
  108976. }
  108977. ,
  108978. a.prototype.render = function() {
  108979. if (this._updateCamera(),
  108980. this.utilityLayerScene.activeCamera) {
  108981. var e = this.utilityLayerScene.activeCamera.getScene()
  108982. , i = this.utilityLayerScene.activeCamera;
  108983. i._scene = this.utilityLayerScene,
  108984. i.leftCamera && (i.leftCamera._scene = this.utilityLayerScene),
  108985. i.rightCamera && (i.rightCamera._scene = this.utilityLayerScene),
  108986. this.utilityLayerScene.render(!1),
  108987. i._scene = e,
  108988. i.leftCamera && (i.leftCamera._scene = e),
  108989. i.rightCamera && (i.rightCamera._scene = e)
  108990. }
  108991. }
  108992. ,
  108993. a.prototype.dispose = function() {
  108994. this.onPointerOutObservable.clear(),
  108995. this._afterRenderObserver && this.originalScene.onAfterCameraRenderObservable.remove(this._afterRenderObserver),
  108996. this._sceneDisposeObserver && this.originalScene.onDisposeObservable.remove(this._sceneDisposeObserver),
  108997. this._originalPointerObserver && this.originalScene.onPrePointerObservable.remove(this._originalPointerObserver),
  108998. this.utilityLayerScene.dispose()
  108999. }
  109000. ,
  109001. a.prototype._updateCamera = function() {
  109002. this.utilityLayerScene.cameraToUseForPointers = this.getRenderCamera(),
  109003. this.utilityLayerScene.activeCamera = this.getRenderCamera()
  109004. }
  109005. ,
  109006. a._DefaultUtilityLayer = null,
  109007. a._DefaultKeepDepthUtilityLayer = null,
  109008. a
  109009. }()
  109010. , BaseSixDofDragBehavior = function() {
  109011. function a() {
  109012. this._attachedToElement = !1,
  109013. this._virtualMeshesInfo = {},
  109014. this._tmpVector = new Vector3,
  109015. this._tmpQuaternion = new Quaternion,
  109016. this._dragType = {
  109017. NONE: 0,
  109018. DRAG: 1,
  109019. DRAG_WITH_CONTROLLER: 2,
  109020. NEAR_DRAG: 3
  109021. },
  109022. this._moving = !1,
  109023. this._dragging = this._dragType.NONE,
  109024. this.draggableMeshes = null,
  109025. this.zDragFactor = 3,
  109026. this.currentDraggingPointerIds = [],
  109027. this.detachCameraControls = !0,
  109028. this.onDragStartObservable = new Observable,
  109029. this.onDragObservable = new Observable,
  109030. this.onDragEndObservable = new Observable,
  109031. this.allowMultiPointer = !0
  109032. }
  109033. return Object.defineProperty(a.prototype, "currentDraggingPointerId", {
  109034. get: function() {
  109035. return this.currentDraggingPointerIds[0] !== void 0 ? this.currentDraggingPointerIds[0] : -1
  109036. },
  109037. set: function(e) {
  109038. this.currentDraggingPointerIds[0] = e
  109039. },
  109040. enumerable: !1,
  109041. configurable: !0
  109042. }),
  109043. Object.defineProperty(a.prototype, "currentDraggingPointerID", {
  109044. get: function() {
  109045. return this.currentDraggingPointerId
  109046. },
  109047. set: function(e) {
  109048. this.currentDraggingPointerId = e
  109049. },
  109050. enumerable: !1,
  109051. configurable: !0
  109052. }),
  109053. Object.defineProperty(a.prototype, "name", {
  109054. get: function() {
  109055. return "BaseSixDofDrag"
  109056. },
  109057. enumerable: !1,
  109058. configurable: !0
  109059. }),
  109060. Object.defineProperty(a.prototype, "isMoving", {
  109061. get: function() {
  109062. return this._moving
  109063. },
  109064. enumerable: !1,
  109065. configurable: !0
  109066. }),
  109067. a.prototype.init = function() {}
  109068. ,
  109069. Object.defineProperty(a.prototype, "_pointerCamera", {
  109070. get: function() {
  109071. return this._scene.cameraToUseForPointers ? this._scene.cameraToUseForPointers : this._scene.activeCamera
  109072. },
  109073. enumerable: !1,
  109074. configurable: !0
  109075. }),
  109076. a.prototype._createVirtualMeshInfo = function() {
  109077. var e = new AbstractMesh("",a._virtualScene);
  109078. e.rotationQuaternion = new Quaternion;
  109079. var i = new AbstractMesh("",a._virtualScene);
  109080. i.rotationQuaternion = new Quaternion;
  109081. var o = new AbstractMesh("",a._virtualScene);
  109082. return o.rotationQuaternion = new Quaternion,
  109083. {
  109084. dragging: !1,
  109085. moving: !1,
  109086. dragMesh: e,
  109087. originMesh: i,
  109088. pivotMesh: o,
  109089. startingPivotPosition: new Vector3,
  109090. startingPivotOrientation: new Quaternion,
  109091. startingPosition: new Vector3,
  109092. startingOrientation: new Quaternion,
  109093. lastOriginPosition: new Vector3,
  109094. lastDragPosition: new Vector3
  109095. }
  109096. }
  109097. ,
  109098. a.prototype._resetVirtualMeshesPosition = function() {
  109099. for (var e = 0; e < this.currentDraggingPointerIds.length; e++)
  109100. this._virtualMeshesInfo[this.currentDraggingPointerIds[e]].pivotMesh.position.copyFrom(this._ownerNode.getAbsolutePivotPoint()),
  109101. this._virtualMeshesInfo[this.currentDraggingPointerIds[e]].pivotMesh.rotationQuaternion.copyFrom(this._ownerNode.rotationQuaternion),
  109102. this._virtualMeshesInfo[this.currentDraggingPointerIds[e]].startingPivotPosition.copyFrom(this._virtualMeshesInfo[this.currentDraggingPointerIds[e]].pivotMesh.position),
  109103. this._virtualMeshesInfo[this.currentDraggingPointerIds[e]].startingPivotOrientation.copyFrom(this._virtualMeshesInfo[this.currentDraggingPointerIds[e]].pivotMesh.rotationQuaternion),
  109104. this._virtualMeshesInfo[this.currentDraggingPointerIds[e]].startingPosition.copyFrom(this._virtualMeshesInfo[this.currentDraggingPointerIds[e]].dragMesh.position),
  109105. this._virtualMeshesInfo[this.currentDraggingPointerIds[e]].startingOrientation.copyFrom(this._virtualMeshesInfo[this.currentDraggingPointerIds[e]].dragMesh.rotationQuaternion)
  109106. }
  109107. ,
  109108. a.prototype._pointerUpdate2D = function(e, i, o) {
  109109. this._pointerCamera && this._pointerCamera.cameraRigMode == Camera$1.RIG_MODE_NONE && !this._pointerCamera._isLeftCamera && !this._pointerCamera._isRightCamera && (e.origin.copyFrom(this._pointerCamera.globalPosition),
  109110. o = 0);
  109111. var s = this._virtualMeshesInfo[i]
  109112. , c = TmpVectors.Vector3[0];
  109113. e.origin.subtractToRef(s.lastOriginPosition, c),
  109114. s.lastOriginPosition.copyFrom(e.origin);
  109115. var d = -Vector3.Dot(c, e.direction);
  109116. s.originMesh.addChild(s.dragMesh),
  109117. s.originMesh.addChild(s.pivotMesh),
  109118. this._applyZOffset(s.dragMesh, d, o),
  109119. this._applyZOffset(s.pivotMesh, d, o),
  109120. s.originMesh.position.copyFrom(e.origin);
  109121. var _ = TmpVectors.Vector3[0];
  109122. e.origin.addToRef(e.direction, _),
  109123. s.originMesh.lookAt(_),
  109124. s.originMesh.removeChild(s.dragMesh),
  109125. s.originMesh.removeChild(s.pivotMesh)
  109126. }
  109127. ,
  109128. a.prototype._pointerUpdateXR = function(e, i, o, s) {
  109129. var c = this._virtualMeshesInfo[o];
  109130. c.originMesh.position.copyFrom(e.position),
  109131. this._dragging === this._dragType.NEAR_DRAG && i ? c.originMesh.rotationQuaternion.copyFrom(i.rotationQuaternion) : c.originMesh.rotationQuaternion.copyFrom(e.rotationQuaternion);
  109132. var d = TmpVectors.Vector3[0]
  109133. , _ = TmpVectors.Vector3[1];
  109134. d.copyFrom(this._pointerCamera.getForwardRay().direction),
  109135. c.originMesh.position.subtractToRef(c.lastOriginPosition, _),
  109136. c.lastOriginPosition.copyFrom(c.originMesh.position);
  109137. var b = _.length();
  109138. _.normalize(),
  109139. c.pivotMesh.computeWorldMatrix(!0),
  109140. c.dragMesh.computeWorldMatrix(!0);
  109141. var k = TmpVectors.Vector3[2]
  109142. , j = TmpVectors.Vector3[3];
  109143. c.dragMesh.absolutePosition.subtractToRef(this._pointerCamera.globalPosition, k),
  109144. c.dragMesh.absolutePosition.subtractToRef(c.originMesh.position, j);
  109145. var $ = j.length();
  109146. k.normalize(),
  109147. j.normalize();
  109148. var _e = Math.abs(Vector3.Dot(_, j)) * Vector3.Dot(_, d)
  109149. , et = _e * s * b * $;
  109150. et + $ < .1 && (et = Math.min($, .1)),
  109151. j.scaleInPlace(et),
  109152. j.addToRef(c.pivotMesh.absolutePosition, this._tmpVector),
  109153. c.pivotMesh.setAbsolutePosition(this._tmpVector),
  109154. j.addToRef(c.dragMesh.absolutePosition, this._tmpVector),
  109155. c.dragMesh.setAbsolutePosition(this._tmpVector)
  109156. }
  109157. ,
  109158. a.prototype.attach = function(e) {
  109159. var i = this;
  109160. this._ownerNode = e,
  109161. this._scene = this._ownerNode.getScene(),
  109162. a._virtualScene || (a._virtualScene = new Scene(this._scene.getEngine(),{
  109163. virtual: !0
  109164. }),
  109165. a._virtualScene.detachControl());
  109166. var o = function(s) {
  109167. return i._ownerNode === s || s.isDescendantOf(i._ownerNode) && (!i.draggableMeshes || i.draggableMeshes.indexOf(s) !== -1)
  109168. };
  109169. this._pointerObserver = this._scene.onPointerObservable.add(function(s, c) {
  109170. var d = s.event.pointerId;
  109171. i._virtualMeshesInfo[d] || (i._virtualMeshesInfo[d] = i._createVirtualMeshInfo());
  109172. var _ = i._virtualMeshesInfo[d]
  109173. , b = s.event.pointerType === "xr";
  109174. if (s.type == PointerEventTypes.POINTERDOWN) {
  109175. if (!_.dragging && s.pickInfo && s.pickInfo.hit && s.pickInfo.pickedMesh && s.pickInfo.pickedPoint && s.pickInfo.ray && (!b || s.pickInfo.aimTransform) && o(s.pickInfo.pickedMesh)) {
  109176. if (!i.allowMultiPointer && i.currentDraggingPointerIds.length > 0)
  109177. return;
  109178. i._pointerCamera && i._pointerCamera.cameraRigMode === Camera$1.RIG_MODE_NONE && !i._pointerCamera._isLeftCamera && !i._pointerCamera._isRightCamera && s.pickInfo.ray.origin.copyFrom(i._pointerCamera.globalPosition),
  109179. i._ownerNode.computeWorldMatrix(!0);
  109180. var k = i._virtualMeshesInfo[d];
  109181. b ? (i._dragging = s.pickInfo.originMesh ? i._dragType.NEAR_DRAG : i._dragType.DRAG_WITH_CONTROLLER,
  109182. k.originMesh.position.copyFrom(s.pickInfo.aimTransform.position),
  109183. i._dragging === i._dragType.NEAR_DRAG && s.pickInfo.gripTransform ? k.originMesh.rotationQuaternion.copyFrom(s.pickInfo.gripTransform.rotationQuaternion) : k.originMesh.rotationQuaternion.copyFrom(s.pickInfo.aimTransform.rotationQuaternion)) : (i._dragging = i._dragType.DRAG,
  109184. k.originMesh.position.copyFrom(s.pickInfo.ray.origin)),
  109185. k.lastOriginPosition.copyFrom(k.originMesh.position),
  109186. k.dragMesh.position.copyFrom(s.pickInfo.pickedPoint),
  109187. k.lastDragPosition.copyFrom(s.pickInfo.pickedPoint),
  109188. k.pivotMesh.position.copyFrom(i._ownerNode.getAbsolutePivotPoint()),
  109189. k.pivotMesh.rotationQuaternion.copyFrom(i._ownerNode.absoluteRotationQuaternion),
  109190. k.startingPosition.copyFrom(k.dragMesh.position),
  109191. k.startingPivotPosition.copyFrom(k.pivotMesh.position),
  109192. k.startingOrientation.copyFrom(k.dragMesh.rotationQuaternion),
  109193. k.startingPivotOrientation.copyFrom(k.pivotMesh.rotationQuaternion),
  109194. b ? (k.originMesh.addChild(k.dragMesh),
  109195. k.originMesh.addChild(k.pivotMesh)) : k.originMesh.lookAt(k.dragMesh.position),
  109196. k.dragging = !0,
  109197. i.currentDraggingPointerIds.indexOf(d) === -1 && i.currentDraggingPointerIds.push(d),
  109198. i.detachCameraControls && i._pointerCamera && !i._pointerCamera.leftCamera && (i._pointerCamera.inputs && i._pointerCamera.inputs.attachedToElement ? (i._pointerCamera.detachControl(),
  109199. i._attachedToElement = !0) : i._attachedToElement = !1),
  109200. i._targetDragStart(k.pivotMesh.position, k.pivotMesh.rotationQuaternion, d),
  109201. i.onDragStartObservable.notifyObservers({
  109202. position: k.pivotMesh.position
  109203. })
  109204. }
  109205. } else if (s.type == PointerEventTypes.POINTERUP || s.type == PointerEventTypes.POINTERDOUBLETAP) {
  109206. var j = i.currentDraggingPointerIds.indexOf(d);
  109207. _.dragging = !1,
  109208. j !== -1 && (i.currentDraggingPointerIds.splice(j, 1),
  109209. i.currentDraggingPointerIds.length === 0 && (i._moving = !1,
  109210. i._dragging = i._dragType.NONE,
  109211. i.detachCameraControls && i._attachedToElement && i._pointerCamera && !i._pointerCamera.leftCamera && (i._pointerCamera.attachControl(!0),
  109212. i._attachedToElement = !1)),
  109213. _.originMesh.removeChild(_.dragMesh),
  109214. _.originMesh.removeChild(_.pivotMesh),
  109215. i._targetDragEnd(d),
  109216. i.onDragEndObservable.notifyObservers({}))
  109217. } else if (s.type == PointerEventTypes.POINTERMOVE) {
  109218. var j = i.currentDraggingPointerIds.indexOf(d);
  109219. if (j !== -1 && _.dragging && s.pickInfo && (s.pickInfo.ray || s.pickInfo.aimTransform)) {
  109220. var $ = i.zDragFactor;
  109221. (i.currentDraggingPointerIds.length > 1 || s.pickInfo.originMesh) && ($ = 0),
  109222. i._ownerNode.computeWorldMatrix(!0),
  109223. b ? i._pointerUpdateXR(s.pickInfo.aimTransform, s.pickInfo.gripTransform, d, $) : i._pointerUpdate2D(s.pickInfo.ray, d, $),
  109224. i._tmpQuaternion.copyFrom(_.startingPivotOrientation),
  109225. i._tmpQuaternion.x = -i._tmpQuaternion.x,
  109226. i._tmpQuaternion.y = -i._tmpQuaternion.y,
  109227. i._tmpQuaternion.z = -i._tmpQuaternion.z,
  109228. _.pivotMesh.absoluteRotationQuaternion.multiplyToRef(i._tmpQuaternion, i._tmpQuaternion),
  109229. _.pivotMesh.absolutePosition.subtractToRef(_.startingPivotPosition, i._tmpVector),
  109230. i.onDragObservable.notifyObservers({
  109231. delta: i._tmpVector,
  109232. position: _.pivotMesh.position,
  109233. pickInfo: s.pickInfo
  109234. }),
  109235. i._targetDrag(i._tmpVector, i._tmpQuaternion, d),
  109236. _.lastDragPosition.copyFrom(_.dragMesh.absolutePosition),
  109237. i._moving = !0
  109238. }
  109239. }
  109240. })
  109241. }
  109242. ,
  109243. a.prototype._applyZOffset = function(e, i, o) {
  109244. e.position.z -= e.position.z < 1 ? i * o : i * o * e.position.z,
  109245. e.position.z < 0 && (e.position.z = 0)
  109246. }
  109247. ,
  109248. a.prototype._targetDragStart = function(e, i, o) {}
  109249. ,
  109250. a.prototype._targetDrag = function(e, i, o) {}
  109251. ,
  109252. a.prototype._targetDragEnd = function(e) {}
  109253. ,
  109254. a.prototype.detach = function() {
  109255. this._scene && (this.detachCameraControls && this._attachedToElement && this._pointerCamera && !this._pointerCamera.leftCamera && (this._pointerCamera.attachControl(!0),
  109256. this._attachedToElement = !1),
  109257. this._scene.onPointerObservable.remove(this._pointerObserver));
  109258. for (var e in this._virtualMeshesInfo)
  109259. this._virtualMeshesInfo[e].originMesh.dispose(),
  109260. this._virtualMeshesInfo[e].dragMesh.dispose();
  109261. this.onDragEndObservable.clear(),
  109262. this.onDragObservable.clear(),
  109263. this.onDragStartObservable.clear()
  109264. }
  109265. ,
  109266. a
  109267. }()
  109268. , SixDofDragBehavior = function(a) {
  109269. __extends(e, a);
  109270. function e() {
  109271. var i = a !== null && a.apply(this, arguments) || this;
  109272. return i._sceneRenderObserver = null,
  109273. i._targetPosition = new Vector3(0,0,0),
  109274. i._targetOrientation = new Quaternion,
  109275. i._targetScaling = new Vector3(1,1,1),
  109276. i._startingPosition = new Vector3(0,0,0),
  109277. i._startingOrientation = new Quaternion,
  109278. i._startingScaling = new Vector3(1,1,1),
  109279. i.onPositionChangedObservable = new Observable,
  109280. i.dragDeltaRatio = .2,
  109281. i.rotateDraggedObject = !0,
  109282. i.rotateAroundYOnly = !1,
  109283. i.rotateWithMotionController = !0,
  109284. i.disableMovement = !1,
  109285. i.faceCameraOnDragStart = !1,
  109286. i
  109287. }
  109288. return Object.defineProperty(e.prototype, "name", {
  109289. get: function() {
  109290. return "SixDofDrag"
  109291. },
  109292. enumerable: !1,
  109293. configurable: !0
  109294. }),
  109295. e.prototype.attach = function(i) {
  109296. var o = this;
  109297. a.prototype.attach.call(this, i),
  109298. i.isNearGrabbable = !0,
  109299. this._virtualTransformNode = new TransformNode("virtual_sixDof",BaseSixDofDragBehavior._virtualScene),
  109300. this._virtualTransformNode.rotationQuaternion = Quaternion.Identity(),
  109301. this._sceneRenderObserver = i.getScene().onBeforeRenderObservable.add(function() {
  109302. if (o.currentDraggingPointerIds.length === 1 && o._moving && !o.disableMovement) {
  109303. var s = i.parent;
  109304. i.setParent(null),
  109305. i.position.addInPlace(o._targetPosition.subtract(i.position).scale(o.dragDeltaRatio)),
  109306. o.onPositionChangedObservable.notifyObservers({
  109307. position: i.absolutePosition
  109308. }),
  109309. (!s || s.scaling && !s.scaling.isNonUniformWithinEpsilon(.001)) && Quaternion.SlerpToRef(i.rotationQuaternion, o._targetOrientation, o.dragDeltaRatio, i.rotationQuaternion),
  109310. i.setParent(s)
  109311. }
  109312. })
  109313. }
  109314. ,
  109315. e.prototype._getPositionOffsetAround = function(i, o, s) {
  109316. var c = TmpVectors.Matrix[0]
  109317. , d = TmpVectors.Matrix[1]
  109318. , _ = TmpVectors.Matrix[2]
  109319. , b = TmpVectors.Matrix[3]
  109320. , k = TmpVectors.Matrix[4];
  109321. return Matrix.TranslationToRef(i.x, i.y, i.z, c),
  109322. Matrix.TranslationToRef(-i.x, -i.y, -i.z, d),
  109323. Matrix.FromQuaternionToRef(s, _),
  109324. Matrix.ScalingToRef(o, o, o, b),
  109325. d.multiplyToRef(_, k),
  109326. k.multiplyToRef(b, k),
  109327. k.multiplyToRef(c, k),
  109328. k.getTranslation()
  109329. }
  109330. ,
  109331. e.prototype._onePointerPositionUpdated = function(i, o) {
  109332. var s = TmpVectors.Vector3[0];
  109333. s.setAll(0),
  109334. this._dragging === this._dragType.DRAG ? this.rotateDraggedObject && (this.rotateAroundYOnly ? Quaternion.RotationYawPitchRollToRef(o.toEulerAngles().y, 0, 0, TmpVectors.Quaternion[0]) : TmpVectors.Quaternion[0].copyFrom(o),
  109335. TmpVectors.Quaternion[0].multiplyToRef(this._startingOrientation, this._targetOrientation)) : (this._dragging === this._dragType.NEAR_DRAG || this._dragging === this._dragType.DRAG_WITH_CONTROLLER && this.rotateWithMotionController) && o.multiplyToRef(this._startingOrientation, this._targetOrientation),
  109336. this._targetPosition.copyFrom(this._startingPosition).addInPlace(i)
  109337. }
  109338. ,
  109339. e.prototype._twoPointersPositionUpdated = function() {
  109340. var i = this._virtualMeshesInfo[this.currentDraggingPointerIds[0]].startingPosition
  109341. , o = this._virtualMeshesInfo[this.currentDraggingPointerIds[1]].startingPosition
  109342. , s = TmpVectors.Vector3[0];
  109343. i.addToRef(o, s),
  109344. s.scaleInPlace(.5);
  109345. var c = TmpVectors.Vector3[1];
  109346. o.subtractToRef(i, c);
  109347. var d = this._virtualMeshesInfo[this.currentDraggingPointerIds[0]].dragMesh.absolutePosition
  109348. , _ = this._virtualMeshesInfo[this.currentDraggingPointerIds[1]].dragMesh.absolutePosition
  109349. , b = TmpVectors.Vector3[2];
  109350. d.addToRef(_, b),
  109351. b.scaleInPlace(.5);
  109352. var k = TmpVectors.Vector3[3];
  109353. _.subtractToRef(d, k);
  109354. var j = k.length() / c.length()
  109355. , $ = b.subtract(s)
  109356. , _e = Quaternion.FromEulerAngles(0, Vector3.GetAngleBetweenVectorsOnPlane(c.normalize(), k.normalize(), Vector3.UpReadOnly), 0)
  109357. , et = this._ownerNode.parent;
  109358. this._ownerNode.setParent(null);
  109359. var tt = this._getPositionOffsetAround(s.subtract(this._virtualTransformNode.getAbsolutePivotPoint()), j, _e);
  109360. this._virtualTransformNode.rotationQuaternion.multiplyToRef(_e, this._ownerNode.rotationQuaternion),
  109361. this._virtualTransformNode.scaling.scaleToRef(j, this._ownerNode.scaling),
  109362. this._virtualTransformNode.position.addToRef($.addInPlace(tt), this._ownerNode.position),
  109363. this.onPositionChangedObservable.notifyObservers({
  109364. position: this._ownerNode.position
  109365. }),
  109366. this._ownerNode.setParent(et)
  109367. }
  109368. ,
  109369. e.prototype._targetDragStart = function() {
  109370. var i = this.currentDraggingPointerIds.length
  109371. , o = this._ownerNode.parent;
  109372. this._ownerNode.rotationQuaternion || (this._ownerNode.rotationQuaternion = Quaternion.RotationYawPitchRoll(this._ownerNode.rotation.y, this._ownerNode.rotation.x, this._ownerNode.rotation.z));
  109373. var s = this._ownerNode.getAbsolutePivotPoint();
  109374. if (this._ownerNode.setParent(null),
  109375. i === 1) {
  109376. if (this._targetPosition.copyFrom(this._ownerNode.position),
  109377. this._targetOrientation.copyFrom(this._ownerNode.rotationQuaternion),
  109378. this._targetScaling.copyFrom(this._ownerNode.scaling),
  109379. this.faceCameraOnDragStart && this._scene.activeCamera) {
  109380. var c = TmpVectors.Vector3[0];
  109381. this._scene.activeCamera.position.subtractToRef(s, c),
  109382. c.normalize();
  109383. var d = TmpVectors.Quaternion[0];
  109384. this._scene.useRightHandedSystem ? Quaternion.FromLookDirectionRHToRef(c, new Vector3(0,1,0), d) : Quaternion.FromLookDirectionLHToRef(c, new Vector3(0,1,0), d),
  109385. d.normalize(),
  109386. Quaternion.RotationYawPitchRollToRef(d.toEulerAngles().y, 0, 0, TmpVectors.Quaternion[0]),
  109387. this._targetOrientation.copyFrom(TmpVectors.Quaternion[0])
  109388. }
  109389. this._startingPosition.copyFrom(this._targetPosition),
  109390. this._startingOrientation.copyFrom(this._targetOrientation),
  109391. this._startingScaling.copyFrom(this._targetScaling)
  109392. } else
  109393. i === 2 && (this._virtualTransformNode.setPivotPoint(new Vector3(0,0,0), Space.LOCAL),
  109394. this._virtualTransformNode.position.copyFrom(this._ownerNode.position),
  109395. this._virtualTransformNode.scaling.copyFrom(this._ownerNode.scaling),
  109396. this._virtualTransformNode.rotationQuaternion.copyFrom(this._ownerNode.rotationQuaternion),
  109397. this._virtualTransformNode.setPivotPoint(s, Space.WORLD),
  109398. this._resetVirtualMeshesPosition());
  109399. this._ownerNode.setParent(o)
  109400. }
  109401. ,
  109402. e.prototype._targetDrag = function(i, o, s) {
  109403. this.currentDraggingPointerIds.length === 1 ? this._onePointerPositionUpdated(i, o) : this.currentDraggingPointerIds.length === 2 && this._twoPointersPositionUpdated()
  109404. }
  109405. ,
  109406. e.prototype._targetDragEnd = function() {
  109407. if (this.currentDraggingPointerIds.length === 1) {
  109408. this._resetVirtualMeshesPosition();
  109409. var i = this.faceCameraOnDragStart;
  109410. this.faceCameraOnDragStart = !1,
  109411. this._targetDragStart(),
  109412. this.faceCameraOnDragStart = i
  109413. }
  109414. }
  109415. ,
  109416. e.prototype.detach = function() {
  109417. a.prototype.detach.call(this),
  109418. this._ownerNode && (this._ownerNode.isNearGrabbable = !1,
  109419. this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver)),
  109420. this._virtualTransformNode && this._virtualTransformNode.dispose()
  109421. }
  109422. ,
  109423. e
  109424. }(BaseSixDofDragBehavior)
  109425. , Gizmo = function() {
  109426. function a(e) {
  109427. var i = this;
  109428. e === void 0 && (e = UtilityLayerRenderer.DefaultUtilityLayer),
  109429. this.gizmoLayer = e,
  109430. this._attachedMesh = null,
  109431. this._attachedNode = null,
  109432. this._customRotationQuaternion = null,
  109433. this._scaleRatio = 1,
  109434. this._isHovered = !1,
  109435. this._customMeshSet = !1,
  109436. this._updateGizmoRotationToMatchAttachedMesh = !0,
  109437. this.updateGizmoPositionToMatchAttachedMesh = !0,
  109438. this.updateScale = !0,
  109439. this._interactionsEnabled = !0,
  109440. this._tempQuaternion = new Quaternion(0,0,0,1),
  109441. this._tempVector = new Vector3,
  109442. this._tempVector2 = new Vector3,
  109443. this._tempMatrix1 = new Matrix,
  109444. this._tempMatrix2 = new Matrix,
  109445. this._rightHandtoLeftHandMatrix = Matrix.RotationY(Math.PI),
  109446. this._rootMesh = new Mesh("gizmoRootNode",e.utilityLayerScene),
  109447. this._rootMesh.rotationQuaternion = Quaternion.Identity(),
  109448. this._beforeRenderObserver = this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.add(function() {
  109449. i._update()
  109450. })
  109451. }
  109452. return Object.defineProperty(a.prototype, "scaleRatio", {
  109453. get: function() {
  109454. return this._scaleRatio
  109455. },
  109456. set: function(e) {
  109457. this._scaleRatio = e
  109458. },
  109459. enumerable: !1,
  109460. configurable: !0
  109461. }),
  109462. Object.defineProperty(a.prototype, "isHovered", {
  109463. get: function() {
  109464. return this._isHovered
  109465. },
  109466. enumerable: !1,
  109467. configurable: !0
  109468. }),
  109469. Object.defineProperty(a.prototype, "attachedMesh", {
  109470. get: function() {
  109471. return this._attachedMesh
  109472. },
  109473. set: function(e) {
  109474. this._attachedMesh = e,
  109475. e && (this._attachedNode = e),
  109476. this._rootMesh.setEnabled(!!e),
  109477. this._attachedNodeChanged(e)
  109478. },
  109479. enumerable: !1,
  109480. configurable: !0
  109481. }),
  109482. Object.defineProperty(a.prototype, "attachedNode", {
  109483. get: function() {
  109484. return this._attachedNode
  109485. },
  109486. set: function(e) {
  109487. this._attachedNode = e,
  109488. this._attachedMesh = null,
  109489. this._rootMesh.setEnabled(!!e),
  109490. this._attachedNodeChanged(e)
  109491. },
  109492. enumerable: !1,
  109493. configurable: !0
  109494. }),
  109495. a.prototype.setCustomMesh = function(e) {
  109496. if (e.getScene() != this.gizmoLayer.utilityLayerScene)
  109497. throw "When setting a custom mesh on a gizmo, the custom meshes scene must be the same as the gizmos (eg. gizmo.gizmoLayer.utilityLayerScene)";
  109498. this._rootMesh.getChildMeshes().forEach(function(i) {
  109499. i.dispose()
  109500. }),
  109501. e.parent = this._rootMesh,
  109502. this._customMeshSet = !0
  109503. }
  109504. ,
  109505. Object.defineProperty(a.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  109506. get: function() {
  109507. return this._updateGizmoRotationToMatchAttachedMesh
  109508. },
  109509. set: function(e) {
  109510. this._updateGizmoRotationToMatchAttachedMesh = e
  109511. },
  109512. enumerable: !1,
  109513. configurable: !0
  109514. }),
  109515. a.prototype._attachedNodeChanged = function(e) {}
  109516. ,
  109517. Object.defineProperty(a.prototype, "customRotationQuaternion", {
  109518. get: function() {
  109519. return this._customRotationQuaternion
  109520. },
  109521. set: function(e) {
  109522. this._customRotationQuaternion = e
  109523. },
  109524. enumerable: !1,
  109525. configurable: !0
  109526. }),
  109527. a.prototype._update = function() {
  109528. if (this.attachedNode) {
  109529. var e = this.attachedNode;
  109530. if (this.attachedMesh && (e = this.attachedMesh._effectiveMesh || this.attachedNode),
  109531. this.updateGizmoPositionToMatchAttachedMesh) {
  109532. var i = e.getWorldMatrix().getRow(3)
  109533. , o = i ? i.toVector3() : new Vector3(0,0,0);
  109534. this._rootMesh.position.copyFrom(o)
  109535. }
  109536. if (this.updateGizmoRotationToMatchAttachedMesh ? e.getWorldMatrix().decompose(void 0, this._rootMesh.rotationQuaternion) : this._customRotationQuaternion ? this._rootMesh.rotationQuaternion.copyFrom(this._customRotationQuaternion) : this._rootMesh.rotationQuaternion.set(0, 0, 0, 1),
  109537. this.updateScale) {
  109538. var s = this.gizmoLayer.utilityLayerScene.activeCamera
  109539. , c = s.globalPosition;
  109540. s.devicePosition && (c = s.devicePosition),
  109541. this._rootMesh.position.subtractToRef(c, this._tempVector);
  109542. var d = this._tempVector.length() * this.scaleRatio;
  109543. this._rootMesh.scaling.set(d, d, d),
  109544. e._getWorldMatrixDeterminant() < 0 && (this._rootMesh.scaling.y *= -1)
  109545. } else
  109546. this._rootMesh.scaling.setAll(this.scaleRatio)
  109547. }
  109548. }
  109549. ,
  109550. a.prototype._handlePivot = function() {
  109551. var e = this._attachedNode;
  109552. e.isUsingPivotMatrix && e.isUsingPivotMatrix() && e.position && e.getWorldMatrix().setTranslation(e.position)
  109553. }
  109554. ,
  109555. a.prototype._matrixChanged = function() {
  109556. if (!!this._attachedNode)
  109557. if (this._attachedNode._isCamera) {
  109558. var e = this._attachedNode, i, o;
  109559. if (e.parent) {
  109560. var s = this._tempMatrix2;
  109561. e.parent._worldMatrix.invertToRef(s),
  109562. this._attachedNode._worldMatrix.multiplyToRef(s, this._tempMatrix1),
  109563. i = this._tempMatrix1
  109564. } else
  109565. i = this._attachedNode._worldMatrix;
  109566. e.getScene().useRightHandedSystem ? (this._rightHandtoLeftHandMatrix.multiplyToRef(i, this._tempMatrix2),
  109567. o = this._tempMatrix2) : o = i,
  109568. o.decompose(this._tempVector2, this._tempQuaternion, this._tempVector);
  109569. var c = this._attachedNode.getClassName() === "FreeCamera" || this._attachedNode.getClassName() === "FlyCamera" || this._attachedNode.getClassName() === "ArcFollowCamera" || this._attachedNode.getClassName() === "TargetCamera" || this._attachedNode.getClassName() === "TouchCamera" || this._attachedNode.getClassName() === "UniversalCamera";
  109570. if (c) {
  109571. var d = this._attachedNode;
  109572. d.rotation = this._tempQuaternion.toEulerAngles(),
  109573. d.rotationQuaternion && (d.rotationQuaternion.copyFrom(this._tempQuaternion),
  109574. d.rotationQuaternion.normalize())
  109575. }
  109576. e.position.copyFrom(this._tempVector)
  109577. } else if (this._attachedNode._isMesh || this._attachedNode.getClassName() === "AbstractMesh" || this._attachedNode.getClassName() === "TransformNode" || this._attachedNode.getClassName() === "InstancedMesh") {
  109578. var _ = this._attachedNode;
  109579. if (_.parent) {
  109580. var s = this._tempMatrix1
  109581. , b = this._tempMatrix2;
  109582. _.parent.getWorldMatrix().invertToRef(s),
  109583. this._attachedNode.getWorldMatrix().multiplyToRef(s, b),
  109584. b.decompose(_.scaling, this._tempQuaternion, _.position)
  109585. } else
  109586. this._attachedNode._worldMatrix.decompose(_.scaling, this._tempQuaternion, _.position);
  109587. _.billboardMode || (_.rotationQuaternion ? (_.rotationQuaternion.copyFrom(this._tempQuaternion),
  109588. _.rotationQuaternion.normalize()) : _.rotation = this._tempQuaternion.toEulerAngles())
  109589. } else if (this._attachedNode.getClassName() === "Bone") {
  109590. var k = this._attachedNode
  109591. , j = k.getParent();
  109592. if (j) {
  109593. var $ = this._tempMatrix1
  109594. , _e = this._tempMatrix2;
  109595. j.getWorldMatrix().invertToRef($),
  109596. k.getWorldMatrix().multiplyToRef($, _e);
  109597. var et = k.getLocalMatrix();
  109598. et.copyFrom(_e)
  109599. } else {
  109600. var et = k.getLocalMatrix();
  109601. et.copyFrom(k.getWorldMatrix())
  109602. }
  109603. k.markAsDirty()
  109604. } else {
  109605. var tt = this._attachedNode;
  109606. if (tt.getTypeID) {
  109607. var rt = tt.getTypeID();
  109608. if (rt === Light.LIGHTTYPEID_DIRECTIONALLIGHT || rt === Light.LIGHTTYPEID_SPOTLIGHT || rt === Light.LIGHTTYPEID_POINTLIGHT) {
  109609. var it = tt.parent;
  109610. if (it) {
  109611. var $ = this._tempMatrix1
  109612. , nt = this._tempMatrix2;
  109613. it.getWorldMatrix().invertToRef($),
  109614. tt.getWorldMatrix().multiplyToRef($, nt),
  109615. nt.decompose(void 0, this._tempQuaternion, this._tempVector)
  109616. } else
  109617. this._attachedNode._worldMatrix.decompose(void 0, this._tempQuaternion, this._tempVector);
  109618. tt.position = new Vector3(this._tempVector.x,this._tempVector.y,this._tempVector.z),
  109619. Vector3.Backward(!1).rotateByQuaternionToRef(this._tempQuaternion, this._tempVector),
  109620. tt.direction = new Vector3(this._tempVector.x,this._tempVector.y,this._tempVector.z)
  109621. }
  109622. }
  109623. }
  109624. }
  109625. ,
  109626. a.prototype._setGizmoMeshMaterial = function(e, i) {
  109627. e && e.forEach(function(o) {
  109628. o.material = i,
  109629. o.color && (o.color = i.diffuseColor)
  109630. })
  109631. }
  109632. ,
  109633. a.GizmoAxisPointerObserver = function(e, i) {
  109634. var o = !1
  109635. , s = e.utilityLayerScene.onPointerObservable.add(function(c) {
  109636. var d, _;
  109637. if (c.pickInfo) {
  109638. if (c.type === PointerEventTypes.POINTERMOVE) {
  109639. if (o)
  109640. return;
  109641. i.forEach(function(k) {
  109642. var j, $;
  109643. if (k.colliderMeshes && k.gizmoMeshes) {
  109644. var _e = ((j = k.colliderMeshes) === null || j === void 0 ? void 0 : j.indexOf(($ = c == null ? void 0 : c.pickInfo) === null || $ === void 0 ? void 0 : $.pickedMesh)) != -1
  109645. , et = k.dragBehavior.enabled ? _e || k.active ? k.hoverMaterial : k.material : k.disableMaterial;
  109646. k.gizmoMeshes.forEach(function(tt) {
  109647. tt.material = et,
  109648. tt.color && (tt.color = et.diffuseColor)
  109649. })
  109650. }
  109651. })
  109652. }
  109653. if (c.type === PointerEventTypes.POINTERDOWN && i.has((d = c.pickInfo.pickedMesh) === null || d === void 0 ? void 0 : d.parent)) {
  109654. o = !0;
  109655. var b = i.get((_ = c.pickInfo.pickedMesh) === null || _ === void 0 ? void 0 : _.parent);
  109656. b.active = !0,
  109657. i.forEach(function(k) {
  109658. var j, $, _e = ((j = k.colliderMeshes) === null || j === void 0 ? void 0 : j.indexOf(($ = c == null ? void 0 : c.pickInfo) === null || $ === void 0 ? void 0 : $.pickedMesh)) != -1, et = (_e || k.active) && k.dragBehavior.enabled ? k.hoverMaterial : k.disableMaterial;
  109659. k.gizmoMeshes.forEach(function(tt) {
  109660. tt.material = et,
  109661. tt.color && (tt.color = et.diffuseColor)
  109662. })
  109663. })
  109664. }
  109665. c.type === PointerEventTypes.POINTERUP && i.forEach(function(k) {
  109666. k.active = !1,
  109667. o = !1,
  109668. k.gizmoMeshes.forEach(function(j) {
  109669. j.material = k.dragBehavior.enabled ? k.material : k.disableMaterial,
  109670. j.color && (j.color = k.material.diffuseColor)
  109671. })
  109672. })
  109673. }
  109674. });
  109675. return s
  109676. }
  109677. ,
  109678. a.prototype.dispose = function() {
  109679. this._rootMesh.dispose(),
  109680. this._beforeRenderObserver && this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.remove(this._beforeRenderObserver)
  109681. }
  109682. ,
  109683. a
  109684. }()
  109685. , PivotTools = function() {
  109686. function a() {}
  109687. return a._RemoveAndStorePivotPoint = function(e) {
  109688. e && a._PivotCached === 0 && (e.getPivotPointToRef(a._OldPivotPoint),
  109689. a._PivotPostMultiplyPivotMatrix = e._postMultiplyPivotMatrix,
  109690. a._OldPivotPoint.equalsToFloats(0, 0, 0) || (e.setPivotMatrix(Matrix.IdentityReadOnly),
  109691. a._OldPivotPoint.subtractToRef(e.getPivotPoint(), a._PivotTranslation),
  109692. a._PivotTmpVector.copyFromFloats(1, 1, 1),
  109693. a._PivotTmpVector.subtractInPlace(e.scaling),
  109694. a._PivotTmpVector.multiplyInPlace(a._PivotTranslation),
  109695. e.position.addInPlace(a._PivotTmpVector))),
  109696. a._PivotCached++
  109697. }
  109698. ,
  109699. a._RestorePivotPoint = function(e) {
  109700. e && !a._OldPivotPoint.equalsToFloats(0, 0, 0) && a._PivotCached === 1 && (e.setPivotPoint(a._OldPivotPoint),
  109701. e._postMultiplyPivotMatrix = a._PivotPostMultiplyPivotMatrix,
  109702. a._PivotTmpVector.copyFromFloats(1, 1, 1),
  109703. a._PivotTmpVector.subtractInPlace(e.scaling),
  109704. a._PivotTmpVector.multiplyInPlace(a._PivotTranslation),
  109705. e.position.subtractInPlace(a._PivotTmpVector)),
  109706. this._PivotCached--
  109707. }
  109708. ,
  109709. a._PivotCached = 0,
  109710. a._OldPivotPoint = new Vector3,
  109711. a._PivotTranslation = new Vector3,
  109712. a._PivotTmpVector = new Vector3,
  109713. a._PivotPostMultiplyPivotMatrix = !1,
  109714. a
  109715. }()
  109716. , PointerDragBehavior = function() {
  109717. function a(e) {
  109718. this._useAlternatePickedPointAboveMaxDragAngleDragSpeed = -1.1,
  109719. this.maxDragAngle = 0,
  109720. this._useAlternatePickedPointAboveMaxDragAngle = !1,
  109721. this.currentDraggingPointerId = -1,
  109722. this.dragging = !1,
  109723. this.dragDeltaRatio = .2,
  109724. this.updateDragPlane = !0,
  109725. this._debugMode = !1,
  109726. this._moving = !1,
  109727. this.onDragObservable = new Observable,
  109728. this.onDragStartObservable = new Observable,
  109729. this.onDragEndObservable = new Observable,
  109730. this.onEnabledObservable = new Observable,
  109731. this.moveAttached = !0,
  109732. this._enabled = !0,
  109733. this.startAndReleaseDragOnPointerEvents = !0,
  109734. this.detachCameraControls = !0,
  109735. this.useObjectOrientationForDragging = !0,
  109736. this.validateDrag = function(o) {
  109737. return !0
  109738. }
  109739. ,
  109740. this._tmpVector = new Vector3(0,0,0),
  109741. this._alternatePickedPoint = new Vector3(0,0,0),
  109742. this._worldDragAxis = new Vector3(0,0,0),
  109743. this._targetPosition = new Vector3(0,0,0),
  109744. this._attachedToElement = !1,
  109745. this._startDragRay = new Ray(new Vector3,new Vector3),
  109746. this._lastPointerRay = {},
  109747. this._dragDelta = new Vector3,
  109748. this._pointA = new Vector3(0,0,0),
  109749. this._pointC = new Vector3(0,0,0),
  109750. this._localAxis = new Vector3(0,0,0),
  109751. this._lookAt = new Vector3(0,0,0),
  109752. this._options = e || {};
  109753. var i = 0;
  109754. if (this._options.dragAxis && i++,
  109755. this._options.dragPlaneNormal && i++,
  109756. i > 1)
  109757. throw "Multiple drag modes specified in dragBehavior options. Only one expected"
  109758. }
  109759. return Object.defineProperty(a.prototype, "currentDraggingPointerID", {
  109760. get: function() {
  109761. return this.currentDraggingPointerId
  109762. },
  109763. set: function(e) {
  109764. this.currentDraggingPointerId = e
  109765. },
  109766. enumerable: !1,
  109767. configurable: !0
  109768. }),
  109769. Object.defineProperty(a.prototype, "enabled", {
  109770. get: function() {
  109771. return this._enabled
  109772. },
  109773. set: function(e) {
  109774. e != this._enabled && this.onEnabledObservable.notifyObservers(e),
  109775. this._enabled = e
  109776. },
  109777. enumerable: !1,
  109778. configurable: !0
  109779. }),
  109780. Object.defineProperty(a.prototype, "options", {
  109781. get: function() {
  109782. return this._options
  109783. },
  109784. set: function(e) {
  109785. this._options = e
  109786. },
  109787. enumerable: !1,
  109788. configurable: !0
  109789. }),
  109790. Object.defineProperty(a.prototype, "name", {
  109791. get: function() {
  109792. return "PointerDrag"
  109793. },
  109794. enumerable: !1,
  109795. configurable: !0
  109796. }),
  109797. a.prototype.init = function() {}
  109798. ,
  109799. a.prototype.attach = function(e, i) {
  109800. var o = this;
  109801. this._scene = e.getScene(),
  109802. e.isNearGrabbable = !0,
  109803. this.attachedNode = e,
  109804. a._planeScene || (this._debugMode ? a._planeScene = this._scene : (a._planeScene = new Scene(this._scene.getEngine(),{
  109805. virtual: !0
  109806. }),
  109807. a._planeScene.detachControl(),
  109808. this._scene.onDisposeObservable.addOnce(function() {
  109809. a._planeScene.dispose(),
  109810. a._planeScene = null
  109811. }))),
  109812. this._dragPlane = CreatePlane("pointerDragPlane", {
  109813. size: this._debugMode ? 1 : 1e4,
  109814. updatable: !1,
  109815. sideOrientation: Mesh.DOUBLESIDE
  109816. }, a._planeScene),
  109817. this.lastDragPosition = new Vector3(0,0,0);
  109818. var s = i || function(c) {
  109819. return o.attachedNode == c || c.isDescendantOf(o.attachedNode)
  109820. }
  109821. ;
  109822. this._pointerObserver = this._scene.onPointerObservable.add(function(c, d) {
  109823. if (!o.enabled) {
  109824. o._attachedToElement && o.releaseDrag();
  109825. return
  109826. }
  109827. if (c.type == PointerEventTypes.POINTERDOWN)
  109828. o.startAndReleaseDragOnPointerEvents && !o.dragging && c.pickInfo && c.pickInfo.hit && c.pickInfo.pickedMesh && c.pickInfo.pickedPoint && c.pickInfo.ray && s(c.pickInfo.pickedMesh) && o._startDrag(c.event.pointerId, c.pickInfo.ray, c.pickInfo.pickedPoint);
  109829. else if (c.type == PointerEventTypes.POINTERUP)
  109830. o.startAndReleaseDragOnPointerEvents && o.currentDraggingPointerId == c.event.pointerId && o.releaseDrag();
  109831. else if (c.type == PointerEventTypes.POINTERMOVE) {
  109832. var _ = c.event.pointerId;
  109833. if (o.currentDraggingPointerId === a._AnyMouseId && _ !== a._AnyMouseId) {
  109834. var b = c.event
  109835. , k = b.pointerType === "mouse" || !o._scene.getEngine().hostInformation.isMobile && b instanceof MouseEvent;
  109836. k && (o._lastPointerRay[o.currentDraggingPointerId] && (o._lastPointerRay[_] = o._lastPointerRay[o.currentDraggingPointerId],
  109837. delete o._lastPointerRay[o.currentDraggingPointerId]),
  109838. o.currentDraggingPointerId = _)
  109839. }
  109840. o._lastPointerRay[_] || (o._lastPointerRay[_] = new Ray(new Vector3,new Vector3)),
  109841. c.pickInfo && c.pickInfo.ray && (o._lastPointerRay[_].origin.copyFrom(c.pickInfo.ray.origin),
  109842. o._lastPointerRay[_].direction.copyFrom(c.pickInfo.ray.direction),
  109843. o.currentDraggingPointerId == _ && o.dragging && o._moveDrag(c.pickInfo.ray))
  109844. }
  109845. }),
  109846. this._beforeRenderObserver = this._scene.onBeforeRenderObservable.add(function() {
  109847. o._moving && o.moveAttached && (PivotTools._RemoveAndStorePivotPoint(o.attachedNode),
  109848. o._targetPosition.subtractToRef(o.attachedNode.absolutePosition, o._tmpVector),
  109849. o._tmpVector.scaleInPlace(o.dragDeltaRatio),
  109850. o.attachedNode.getAbsolutePosition().addToRef(o._tmpVector, o._tmpVector),
  109851. o.validateDrag(o._tmpVector) && o.attachedNode.setAbsolutePosition(o._tmpVector),
  109852. PivotTools._RestorePivotPoint(o.attachedNode))
  109853. })
  109854. }
  109855. ,
  109856. a.prototype.releaseDrag = function() {
  109857. if (this.dragging && (this.dragging = !1,
  109858. this.onDragEndObservable.notifyObservers({
  109859. dragPlanePoint: this.lastDragPosition,
  109860. pointerId: this.currentDraggingPointerId
  109861. })),
  109862. this.currentDraggingPointerId = -1,
  109863. this._moving = !1,
  109864. this.detachCameraControls && this._attachedToElement && this._scene.activeCamera && !this._scene.activeCamera.leftCamera) {
  109865. if (this._scene.activeCamera.getClassName() === "ArcRotateCamera") {
  109866. var e = this._scene.activeCamera;
  109867. e.attachControl(e.inputs ? e.inputs.noPreventDefault : !0, e._useCtrlForPanning, e._panningMouseButton)
  109868. } else
  109869. this._scene.activeCamera.attachControl(this._scene.activeCamera.inputs ? this._scene.activeCamera.inputs.noPreventDefault : !0);
  109870. this._attachedToElement = !1
  109871. }
  109872. }
  109873. ,
  109874. a.prototype.startDrag = function(e, i, o) {
  109875. e === void 0 && (e = a._AnyMouseId),
  109876. this._startDrag(e, i, o);
  109877. var s = this._lastPointerRay[e];
  109878. e === a._AnyMouseId && (s = this._lastPointerRay[Object.keys(this._lastPointerRay)[0]]),
  109879. s && this._moveDrag(s)
  109880. }
  109881. ,
  109882. a.prototype._startDrag = function(e, i, o) {
  109883. if (!(!this._scene.activeCamera || this.dragging || !this.attachedNode)) {
  109884. PivotTools._RemoveAndStorePivotPoint(this.attachedNode),
  109885. i ? (this._startDragRay.direction.copyFrom(i.direction),
  109886. this._startDragRay.origin.copyFrom(i.origin)) : (this._startDragRay.origin.copyFrom(this._scene.activeCamera.position),
  109887. this.attachedNode.getWorldMatrix().getTranslationToRef(this._tmpVector),
  109888. this._tmpVector.subtractToRef(this._scene.activeCamera.position, this._startDragRay.direction)),
  109889. this._updateDragPlanePosition(this._startDragRay, o || this._tmpVector);
  109890. var s = this._pickWithRayOnDragPlane(this._startDragRay);
  109891. s && (this.dragging = !0,
  109892. this.currentDraggingPointerId = e,
  109893. this.lastDragPosition.copyFrom(s),
  109894. this.onDragStartObservable.notifyObservers({
  109895. dragPlanePoint: s,
  109896. pointerId: this.currentDraggingPointerId
  109897. }),
  109898. this._targetPosition.copyFrom(this.attachedNode.getAbsolutePosition()),
  109899. this.detachCameraControls && this._scene.activeCamera && this._scene.activeCamera.inputs && !this._scene.activeCamera.leftCamera && (this._scene.activeCamera.inputs.attachedToElement ? (this._scene.activeCamera.detachControl(),
  109900. this._attachedToElement = !0) : this._attachedToElement = !1)),
  109901. PivotTools._RestorePivotPoint(this.attachedNode)
  109902. }
  109903. }
  109904. ,
  109905. a.prototype._moveDrag = function(e) {
  109906. this._moving = !0;
  109907. var i = this._pickWithRayOnDragPlane(e);
  109908. if (i) {
  109909. this.updateDragPlane && this._updateDragPlanePosition(e, i);
  109910. var o = 0;
  109911. this._options.dragAxis ? (this.useObjectOrientationForDragging ? Vector3.TransformCoordinatesToRef(this._options.dragAxis, this.attachedNode.getWorldMatrix().getRotationMatrix(), this._worldDragAxis) : this._worldDragAxis.copyFrom(this._options.dragAxis),
  109912. i.subtractToRef(this.lastDragPosition, this._tmpVector),
  109913. o = Vector3.Dot(this._tmpVector, this._worldDragAxis),
  109914. this._worldDragAxis.scaleToRef(o, this._dragDelta)) : (o = this._dragDelta.length(),
  109915. i.subtractToRef(this.lastDragPosition, this._dragDelta)),
  109916. this._targetPosition.addInPlace(this._dragDelta),
  109917. this.onDragObservable.notifyObservers({
  109918. dragDistance: o,
  109919. delta: this._dragDelta,
  109920. dragPlanePoint: i,
  109921. dragPlaneNormal: this._dragPlane.forward,
  109922. pointerId: this.currentDraggingPointerId
  109923. }),
  109924. this.lastDragPosition.copyFrom(i)
  109925. }
  109926. }
  109927. ,
  109928. a.prototype._pickWithRayOnDragPlane = function(e) {
  109929. var i = this;
  109930. if (!e)
  109931. return null;
  109932. var o = Math.acos(Vector3.Dot(this._dragPlane.forward, e.direction));
  109933. if (o > Math.PI / 2 && (o = Math.PI - o),
  109934. this.maxDragAngle > 0 && o > this.maxDragAngle)
  109935. if (this._useAlternatePickedPointAboveMaxDragAngle) {
  109936. this._tmpVector.copyFrom(e.direction),
  109937. this.attachedNode.absolutePosition.subtractToRef(e.origin, this._alternatePickedPoint),
  109938. this._alternatePickedPoint.normalize(),
  109939. this._alternatePickedPoint.scaleInPlace(this._useAlternatePickedPointAboveMaxDragAngleDragSpeed * Vector3.Dot(this._alternatePickedPoint, this._tmpVector)),
  109940. this._tmpVector.addInPlace(this._alternatePickedPoint);
  109941. var s = Vector3.Dot(this._dragPlane.forward, this._tmpVector);
  109942. return this._dragPlane.forward.scaleToRef(-s, this._alternatePickedPoint),
  109943. this._alternatePickedPoint.addInPlace(this._tmpVector),
  109944. this._alternatePickedPoint.addInPlace(this.attachedNode.absolutePosition),
  109945. this._alternatePickedPoint
  109946. } else
  109947. return null;
  109948. var c = a._planeScene.pickWithRay(e, function(d) {
  109949. return d == i._dragPlane
  109950. });
  109951. return c && c.hit && c.pickedMesh && c.pickedPoint ? c.pickedPoint : null
  109952. }
  109953. ,
  109954. a.prototype._updateDragPlanePosition = function(e, i) {
  109955. this._pointA.copyFrom(i),
  109956. this._options.dragAxis ? (this.useObjectOrientationForDragging ? Vector3.TransformCoordinatesToRef(this._options.dragAxis, this.attachedNode.getWorldMatrix().getRotationMatrix(), this._localAxis) : this._localAxis.copyFrom(this._options.dragAxis),
  109957. e.origin.subtractToRef(this._pointA, this._pointC),
  109958. this._pointC.normalize(),
  109959. Math.abs(Vector3.Dot(this._localAxis, this._pointC)) > .999 ? Math.abs(Vector3.Dot(Vector3.UpReadOnly, this._pointC)) > .999 ? this._lookAt.copyFrom(Vector3.Right()) : this._lookAt.copyFrom(Vector3.UpReadOnly) : (Vector3.CrossToRef(this._localAxis, this._pointC, this._lookAt),
  109960. Vector3.CrossToRef(this._localAxis, this._lookAt, this._lookAt),
  109961. this._lookAt.normalize()),
  109962. this._dragPlane.position.copyFrom(this._pointA),
  109963. this._pointA.addToRef(this._lookAt, this._lookAt),
  109964. this._dragPlane.lookAt(this._lookAt)) : this._options.dragPlaneNormal ? (this.useObjectOrientationForDragging ? Vector3.TransformCoordinatesToRef(this._options.dragPlaneNormal, this.attachedNode.getWorldMatrix().getRotationMatrix(), this._localAxis) : this._localAxis.copyFrom(this._options.dragPlaneNormal),
  109965. this._dragPlane.position.copyFrom(this._pointA),
  109966. this._pointA.addToRef(this._localAxis, this._lookAt),
  109967. this._dragPlane.lookAt(this._lookAt)) : (this._dragPlane.position.copyFrom(this._pointA),
  109968. this._dragPlane.lookAt(e.origin)),
  109969. this._dragPlane.position.copyFrom(this.attachedNode.getAbsolutePosition()),
  109970. this._dragPlane.computeWorldMatrix(!0)
  109971. }
  109972. ,
  109973. a.prototype.detach = function() {
  109974. this.attachedNode.isNearGrabbable = !1,
  109975. this._pointerObserver && this._scene.onPointerObservable.remove(this._pointerObserver),
  109976. this._beforeRenderObserver && this._scene.onBeforeRenderObservable.remove(this._beforeRenderObserver),
  109977. this._dragPlane.dispose(),
  109978. this.releaseDrag()
  109979. }
  109980. ,
  109981. a._AnyMouseId = -2,
  109982. a
  109983. }()
  109984. , PlaneRotationGizmo = function(a) {
  109985. __extends(e, a);
  109986. function e(i, o, s, c, d, _, b) {
  109987. o === void 0 && (o = Color3.Gray()),
  109988. s === void 0 && (s = UtilityLayerRenderer.DefaultUtilityLayer),
  109989. c === void 0 && (c = 32),
  109990. d === void 0 && (d = null),
  109991. b === void 0 && (b = 1);
  109992. var k, j = a.call(this, s) || this;
  109993. j._pointerObserver = null,
  109994. j.snapDistance = 0,
  109995. j.onSnapObservable = new Observable,
  109996. j.angle = 0,
  109997. j._isEnabled = !0,
  109998. j._parent = null,
  109999. j._dragging = !1,
  110000. j._angles = new Vector3,
  110001. j._parent = d,
  110002. j._coloredMaterial = new StandardMaterial("",s.utilityLayerScene),
  110003. j._coloredMaterial.diffuseColor = o,
  110004. j._coloredMaterial.specularColor = o.subtract(new Color3(.1,.1,.1)),
  110005. j._hoverMaterial = new StandardMaterial("",s.utilityLayerScene),
  110006. j._hoverMaterial.diffuseColor = Color3.Yellow(),
  110007. j._disableMaterial = new StandardMaterial("",s.utilityLayerScene),
  110008. j._disableMaterial.diffuseColor = Color3.Gray(),
  110009. j._disableMaterial.alpha = .4,
  110010. j._gizmoMesh = new Mesh("",s.utilityLayerScene);
  110011. var $ = j._createGizmoMesh(j._gizmoMesh, b, c)
  110012. , _e = $.rotationMesh
  110013. , et = $.collider;
  110014. j._rotationDisplayPlane = CreatePlane("rotationDisplay", {
  110015. size: .6,
  110016. updatable: !1
  110017. }, j.gizmoLayer.utilityLayerScene),
  110018. j._rotationDisplayPlane.rotation.z = Math.PI * .5,
  110019. j._rotationDisplayPlane.parent = j._gizmoMesh,
  110020. j._rotationDisplayPlane.setEnabled(!1),
  110021. Effect.ShadersStore.rotationGizmoVertexShader = e._rotationGizmoVertexShader,
  110022. Effect.ShadersStore.rotationGizmoFragmentShader = e._rotationGizmoFragmentShader,
  110023. j._rotationShaderMaterial = new ShaderMaterial("shader",j.gizmoLayer.utilityLayerScene,{
  110024. vertex: "rotationGizmo",
  110025. fragment: "rotationGizmo"
  110026. },{
  110027. attributes: ["position", "uv"],
  110028. uniforms: ["worldViewProjection", "angles"]
  110029. }),
  110030. j._rotationShaderMaterial.backFaceCulling = !1,
  110031. j._rotationDisplayPlane.material = j._rotationShaderMaterial,
  110032. j._rotationDisplayPlane.visibility = .999,
  110033. j._gizmoMesh.lookAt(j._rootMesh.position.add(i)),
  110034. j._rootMesh.addChild(j._gizmoMesh),
  110035. j._gizmoMesh.scaling.scaleInPlace(1 / 3),
  110036. j.dragBehavior = new PointerDragBehavior({
  110037. dragPlaneNormal: i
  110038. }),
  110039. j.dragBehavior.moveAttached = !1,
  110040. j.dragBehavior.maxDragAngle = e.MaxDragAngle,
  110041. j.dragBehavior._useAlternatePickedPointAboveMaxDragAngle = !0,
  110042. j._rootMesh.addBehavior(j.dragBehavior);
  110043. var tt = new Vector3
  110044. , rt = new Matrix
  110045. , it = new Vector3
  110046. , nt = new Vector3;
  110047. j.dragBehavior.onDragStartObservable.add(function(ft) {
  110048. j.attachedNode && (tt.copyFrom(ft.dragPlanePoint),
  110049. j._rotationDisplayPlane.setEnabled(!0),
  110050. j._rotationDisplayPlane.getWorldMatrix().invertToRef(rt),
  110051. Vector3.TransformCoordinatesToRef(ft.dragPlanePoint, rt, tt),
  110052. j._angles.x = Math.atan2(tt.y, tt.x) + Math.PI,
  110053. j._angles.y = 0,
  110054. j._angles.z = j.updateGizmoRotationToMatchAttachedMesh ? 1 : 0,
  110055. j._dragging = !0,
  110056. tt.copyFrom(ft.dragPlanePoint),
  110057. j._rotationShaderMaterial.setVector3("angles", j._angles),
  110058. j.angle = 0)
  110059. }),
  110060. j.dragBehavior.onDragEndObservable.add(function() {
  110061. j._dragging = !1,
  110062. j._rotationDisplayPlane.setEnabled(!1)
  110063. });
  110064. var ot = {
  110065. snapDistance: 0
  110066. }
  110067. , at = 0
  110068. , st = new Matrix
  110069. , ut = new Quaternion;
  110070. j.dragBehavior.onDragObservable.add(function(ft) {
  110071. if (j.attachedNode) {
  110072. var ht = new Vector3(1,1,1)
  110073. , pt = new Quaternion(0,0,0,1)
  110074. , dt = new Vector3(0,0,0);
  110075. j._handlePivot(),
  110076. j.attachedNode.getWorldMatrix().decompose(ht, pt, dt);
  110077. var _t = ft.dragPlanePoint.subtract(dt).normalize()
  110078. , mt = tt.subtract(dt).normalize()
  110079. , vt = Vector3.Cross(_t, mt)
  110080. , yt = Vector3.Dot(_t, mt)
  110081. , Et = Math.atan2(vt.length(), yt);
  110082. it.copyFrom(i),
  110083. nt.copyFrom(i),
  110084. j.updateGizmoRotationToMatchAttachedMesh && (pt.toRotationMatrix(rt),
  110085. nt = Vector3.TransformCoordinates(it, rt));
  110086. var At = !1;
  110087. if (s.utilityLayerScene.activeCamera) {
  110088. var gt = s.utilityLayerScene.activeCamera.position.subtract(dt).normalize();
  110089. Vector3.Dot(gt, nt) > 0 && (it.scaleInPlace(-1),
  110090. nt.scaleInPlace(-1),
  110091. At = !0)
  110092. }
  110093. var St = Vector3.Dot(nt, vt) > 0;
  110094. St && (Et = -Et);
  110095. var xt = !1;
  110096. if (j.snapDistance != 0)
  110097. if (at += Et,
  110098. Math.abs(at) > j.snapDistance) {
  110099. var bt = Math.floor(Math.abs(at) / j.snapDistance);
  110100. at < 0 && (bt *= -1),
  110101. at = at % j.snapDistance,
  110102. Et = j.snapDistance * bt,
  110103. xt = !0
  110104. } else
  110105. Et = 0;
  110106. var Rt = Math.sin(Et / 2);
  110107. if (ut.set(it.x * Rt, it.y * Rt, it.z * Rt, Math.cos(Et / 2)),
  110108. st.determinant() > 0) {
  110109. var Mt = new Vector3;
  110110. ut.toEulerAnglesToRef(Mt),
  110111. Quaternion.RotationYawPitchRollToRef(Mt.y, -Mt.x, -Mt.z, ut)
  110112. }
  110113. j.updateGizmoRotationToMatchAttachedMesh ? pt.multiplyToRef(ut, pt) : ut.multiplyToRef(pt, pt),
  110114. j.attachedNode.getWorldMatrix().copyFrom(Matrix.Compose(ht, pt, dt)),
  110115. tt.copyFrom(ft.dragPlanePoint),
  110116. xt && (ot.snapDistance = Et,
  110117. j.onSnapObservable.notifyObservers(ot)),
  110118. j._angles.y += Et,
  110119. j.angle += At ? -Et : Et,
  110120. j._rotationShaderMaterial.setVector3("angles", j._angles),
  110121. j._matrixChanged()
  110122. }
  110123. });
  110124. var ct = s._getSharedGizmoLight();
  110125. ct.includedOnlyMeshes = ct.includedOnlyMeshes.concat(j._rootMesh.getChildMeshes(!1));
  110126. var lt = {
  110127. colliderMeshes: [et],
  110128. gizmoMeshes: [_e],
  110129. material: j._coloredMaterial,
  110130. hoverMaterial: j._hoverMaterial,
  110131. disableMaterial: j._disableMaterial,
  110132. active: !1,
  110133. dragBehavior: j.dragBehavior
  110134. };
  110135. return (k = j._parent) === null || k === void 0 || k.addToAxisCache(j._gizmoMesh, lt),
  110136. j._pointerObserver = s.utilityLayerScene.onPointerObservable.add(function(ft) {
  110137. var ht;
  110138. if (!j._customMeshSet && (j.dragBehavior.maxDragAngle = e.MaxDragAngle,
  110139. j._isHovered = lt.colliderMeshes.indexOf((ht = ft == null ? void 0 : ft.pickInfo) === null || ht === void 0 ? void 0 : ht.pickedMesh) != -1,
  110140. !j._parent)) {
  110141. var pt = lt.dragBehavior.enabled ? j._isHovered || j._dragging ? j._hoverMaterial : j._coloredMaterial : j._disableMaterial;
  110142. j._setGizmoMeshMaterial(lt.gizmoMeshes, pt)
  110143. }
  110144. }),
  110145. j.dragBehavior.onEnabledObservable.add(function(ft) {
  110146. j._setGizmoMeshMaterial(lt.gizmoMeshes, ft ? j._coloredMaterial : j._disableMaterial)
  110147. }),
  110148. j
  110149. }
  110150. return e.prototype._createGizmoMesh = function(i, o, s) {
  110151. var c = CreateTorus("ignore", {
  110152. diameter: .6,
  110153. thickness: .03 * o,
  110154. tessellation: s
  110155. }, this.gizmoLayer.utilityLayerScene);
  110156. c.visibility = 0;
  110157. var d = CreateTorus("", {
  110158. diameter: .6,
  110159. thickness: .005 * o,
  110160. tessellation: s
  110161. }, this.gizmoLayer.utilityLayerScene);
  110162. return d.material = this._coloredMaterial,
  110163. d.rotation.x = Math.PI / 2,
  110164. c.rotation.x = Math.PI / 2,
  110165. i.addChild(d),
  110166. i.addChild(c),
  110167. {
  110168. rotationMesh: d,
  110169. collider: c
  110170. }
  110171. }
  110172. ,
  110173. e.prototype._attachedNodeChanged = function(i) {
  110174. this.dragBehavior && (this.dragBehavior.enabled = !!i)
  110175. }
  110176. ,
  110177. Object.defineProperty(e.prototype, "isEnabled", {
  110178. get: function() {
  110179. return this._isEnabled
  110180. },
  110181. set: function(i) {
  110182. this._isEnabled = i,
  110183. i ? this._parent && (this.attachedMesh = this._parent.attachedMesh) : this.attachedMesh = null
  110184. },
  110185. enumerable: !1,
  110186. configurable: !0
  110187. }),
  110188. e.prototype.dispose = function() {
  110189. this.onSnapObservable.clear(),
  110190. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),
  110191. this.dragBehavior.detach(),
  110192. this._gizmoMesh && this._gizmoMesh.dispose(),
  110193. this._rotationDisplayPlane && this._rotationDisplayPlane.dispose(),
  110194. this._rotationShaderMaterial && this._rotationShaderMaterial.dispose(),
  110195. [this._coloredMaterial, this._hoverMaterial, this._disableMaterial].forEach(function(i) {
  110196. i && i.dispose()
  110197. }),
  110198. a.prototype.dispose.call(this)
  110199. }
  110200. ,
  110201. e.MaxDragAngle = Math.PI * 9 / 20,
  110202. e._rotationGizmoVertexShader = `
  110203. precision highp float;
  110204. attribute vec3 position;
  110205. attribute vec2 uv;
  110206. uniform mat4 worldViewProjection;
  110207. varying vec3 vPosition;
  110208. varying vec2 vUV;
  110209. void main(void) {
  110210. gl_Position = worldViewProjection * vec4(position, 1.0);
  110211. vUV = uv;
  110212. }`,
  110213. e._rotationGizmoFragmentShader = `
  110214. precision highp float;
  110215. varying vec2 vUV;
  110216. varying vec3 vPosition;
  110217. uniform vec3 angles;
  110218. #define twopi 6.283185307
  110219. void main(void) {
  110220. vec2 uv = vUV - vec2(0.5);
  110221. float angle = atan(uv.y, uv.x) + 3.141592;
  110222. float delta = gl_FrontFacing ? angles.y : -angles.y;
  110223. float begin = angles.x - delta * angles.z;
  110224. float start = (begin < (begin + delta)) ? begin : (begin + delta);
  110225. float end = (begin > (begin + delta)) ? begin : (begin + delta);
  110226. float len = sqrt(dot(uv,uv));
  110227. float opacity = 1. - step(0.5, len);
  110228. float base = abs(floor(start / twopi)) * twopi;
  110229. start += base;
  110230. end += base;
  110231. float intensity = 0.;
  110232. for (int i = 0; i < 5; i++)
  110233. {
  110234. intensity += max(step(start, angle) - step(end, angle), 0.);
  110235. angle += twopi;
  110236. }
  110237. gl_FragColor = vec4(1.,1.,0., min(intensity * 0.25, 0.8)) * opacity;
  110238. }`,
  110239. e
  110240. }(Gizmo)
  110241. , RotationGizmo = function(a) {
  110242. __extends(e, a);
  110243. function e(i, o, s, c, d, _) {
  110244. i === void 0 && (i = UtilityLayerRenderer.DefaultUtilityLayer),
  110245. o === void 0 && (o = 32),
  110246. s === void 0 && (s = !1),
  110247. c === void 0 && (c = 1);
  110248. var b = a.call(this, i) || this;
  110249. b.onDragStartObservable = new Observable,
  110250. b.onDragEndObservable = new Observable,
  110251. b._observables = [],
  110252. b._gizmoAxisCache = new Map;
  110253. var k = _ && _.xOptions && _.xOptions.color ? _.xOptions.color : Color3.Red().scale(.5)
  110254. , j = _ && _.yOptions && _.yOptions.color ? _.yOptions.color : Color3.Green().scale(.5)
  110255. , $ = _ && _.zOptions && _.zOptions.color ? _.zOptions.color : Color3.Blue().scale(.5);
  110256. return b.xGizmo = new PlaneRotationGizmo(new Vector3(1,0,0),k,i,o,b,s,c),
  110257. b.yGizmo = new PlaneRotationGizmo(new Vector3(0,1,0),j,i,o,b,s,c),
  110258. b.zGizmo = new PlaneRotationGizmo(new Vector3(0,0,1),$,i,o,b,s,c),
  110259. [b.xGizmo, b.yGizmo, b.zGizmo].forEach(function(_e) {
  110260. _ && _.updateScale != null && (_e.updateScale = _.updateScale),
  110261. _e.dragBehavior.onDragStartObservable.add(function() {
  110262. b.onDragStartObservable.notifyObservers({})
  110263. }),
  110264. _e.dragBehavior.onDragEndObservable.add(function() {
  110265. b.onDragEndObservable.notifyObservers({})
  110266. })
  110267. }),
  110268. b.attachedMesh = null,
  110269. b.attachedNode = null,
  110270. d ? d.addToAxisCache(b._gizmoAxisCache) : Gizmo.GizmoAxisPointerObserver(i, b._gizmoAxisCache),
  110271. b
  110272. }
  110273. return Object.defineProperty(e.prototype, "attachedMesh", {
  110274. get: function() {
  110275. return this._meshAttached
  110276. },
  110277. set: function(i) {
  110278. this._meshAttached = i,
  110279. this._nodeAttached = i,
  110280. this._checkBillboardTransform(),
  110281. [this.xGizmo, this.yGizmo, this.zGizmo].forEach(function(o) {
  110282. o.isEnabled ? o.attachedMesh = i : o.attachedMesh = null
  110283. })
  110284. },
  110285. enumerable: !1,
  110286. configurable: !0
  110287. }),
  110288. Object.defineProperty(e.prototype, "attachedNode", {
  110289. get: function() {
  110290. return this._nodeAttached
  110291. },
  110292. set: function(i) {
  110293. this._meshAttached = null,
  110294. this._nodeAttached = i,
  110295. this._checkBillboardTransform(),
  110296. [this.xGizmo, this.yGizmo, this.zGizmo].forEach(function(o) {
  110297. o.isEnabled ? o.attachedNode = i : o.attachedNode = null
  110298. })
  110299. },
  110300. enumerable: !1,
  110301. configurable: !0
  110302. }),
  110303. e.prototype._checkBillboardTransform = function() {
  110304. this._nodeAttached && this._nodeAttached.billboardMode && console.log("Rotation Gizmo will not work with transforms in billboard mode.")
  110305. }
  110306. ,
  110307. Object.defineProperty(e.prototype, "isHovered", {
  110308. get: function() {
  110309. var i = !1;
  110310. return [this.xGizmo, this.yGizmo, this.zGizmo].forEach(function(o) {
  110311. i = i || o.isHovered
  110312. }),
  110313. i
  110314. },
  110315. enumerable: !1,
  110316. configurable: !0
  110317. }),
  110318. Object.defineProperty(e.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  110319. get: function() {
  110320. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh
  110321. },
  110322. set: function(i) {
  110323. this.xGizmo && (this.xGizmo.updateGizmoRotationToMatchAttachedMesh = i,
  110324. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = i,
  110325. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = i)
  110326. },
  110327. enumerable: !1,
  110328. configurable: !0
  110329. }),
  110330. Object.defineProperty(e.prototype, "snapDistance", {
  110331. get: function() {
  110332. return this.xGizmo.snapDistance
  110333. },
  110334. set: function(i) {
  110335. this.xGizmo && (this.xGizmo.snapDistance = i,
  110336. this.yGizmo.snapDistance = i,
  110337. this.zGizmo.snapDistance = i)
  110338. },
  110339. enumerable: !1,
  110340. configurable: !0
  110341. }),
  110342. Object.defineProperty(e.prototype, "scaleRatio", {
  110343. get: function() {
  110344. return this.xGizmo.scaleRatio
  110345. },
  110346. set: function(i) {
  110347. this.xGizmo && (this.xGizmo.scaleRatio = i,
  110348. this.yGizmo.scaleRatio = i,
  110349. this.zGizmo.scaleRatio = i)
  110350. },
  110351. enumerable: !1,
  110352. configurable: !0
  110353. }),
  110354. e.prototype.addToAxisCache = function(i, o) {
  110355. this._gizmoAxisCache.set(i, o)
  110356. }
  110357. ,
  110358. e.prototype.dispose = function() {
  110359. var i = this;
  110360. this.xGizmo.dispose(),
  110361. this.yGizmo.dispose(),
  110362. this.zGizmo.dispose(),
  110363. this.onDragStartObservable.clear(),
  110364. this.onDragEndObservable.clear(),
  110365. this._observables.forEach(function(o) {
  110366. i.gizmoLayer.utilityLayerScene.onPointerObservable.remove(o)
  110367. })
  110368. }
  110369. ,
  110370. e.prototype.setCustomMesh = function(i) {
  110371. Logger$2.Error("Custom meshes are not supported on this gizmo, please set the custom meshes on the gizmos contained within this one (gizmo.xGizmo, gizmo.yGizmo, gizmo.zGizmo)")
  110372. }
  110373. ,
  110374. e
  110375. }(Gizmo)
  110376. , AxisDragGizmo = function(a) {
  110377. __extends(e, a);
  110378. function e(i, o, s, c, d) {
  110379. o === void 0 && (o = Color3.Gray()),
  110380. s === void 0 && (s = UtilityLayerRenderer.DefaultUtilityLayer),
  110381. c === void 0 && (c = null),
  110382. d === void 0 && (d = 1);
  110383. var _, b = a.call(this, s) || this;
  110384. b._pointerObserver = null,
  110385. b.snapDistance = 0,
  110386. b.onSnapObservable = new Observable,
  110387. b._isEnabled = !0,
  110388. b._parent = null,
  110389. b._dragging = !1,
  110390. b._parent = c,
  110391. b._coloredMaterial = new StandardMaterial("",s.utilityLayerScene),
  110392. b._coloredMaterial.diffuseColor = o,
  110393. b._coloredMaterial.specularColor = o.subtract(new Color3(.1,.1,.1)),
  110394. b._hoverMaterial = new StandardMaterial("",s.utilityLayerScene),
  110395. b._hoverMaterial.diffuseColor = Color3.Yellow(),
  110396. b._disableMaterial = new StandardMaterial("",s.utilityLayerScene),
  110397. b._disableMaterial.diffuseColor = Color3.Gray(),
  110398. b._disableMaterial.alpha = .4;
  110399. var k = e._CreateArrow(s.utilityLayerScene, b._coloredMaterial, d)
  110400. , j = e._CreateArrow(s.utilityLayerScene, b._coloredMaterial, d + 4, !0);
  110401. b._gizmoMesh = new Mesh("",s.utilityLayerScene),
  110402. b._gizmoMesh.addChild(k),
  110403. b._gizmoMesh.addChild(j),
  110404. b._gizmoMesh.lookAt(b._rootMesh.position.add(i)),
  110405. b._gizmoMesh.scaling.scaleInPlace(1 / 3),
  110406. b._gizmoMesh.parent = b._rootMesh;
  110407. var $ = 0
  110408. , _e = new Vector3
  110409. , et = new Vector3
  110410. , tt = {
  110411. snapDistance: 0
  110412. };
  110413. b.dragBehavior = new PointerDragBehavior({
  110414. dragAxis: i
  110415. }),
  110416. b.dragBehavior.moveAttached = !1,
  110417. b._rootMesh.addBehavior(b.dragBehavior),
  110418. b.dragBehavior.onDragObservable.add(function(nt) {
  110419. if (b.attachedNode) {
  110420. b._handlePivot();
  110421. var ot = !1;
  110422. if (b.snapDistance == 0)
  110423. b.attachedNode.getWorldMatrix().getTranslationToRef(et),
  110424. et.addInPlace(nt.delta),
  110425. b.dragBehavior.validateDrag(et) && (b.attachedNode.position && b.attachedNode.position.addInPlaceFromFloats(nt.delta.x, nt.delta.y, nt.delta.z),
  110426. b.attachedNode.getWorldMatrix().addTranslationFromFloats(nt.delta.x, nt.delta.y, nt.delta.z),
  110427. b.attachedNode.updateCache(),
  110428. ot = !0);
  110429. else if ($ += nt.dragDistance,
  110430. Math.abs($) > b.snapDistance) {
  110431. var at = Math.floor(Math.abs($) / b.snapDistance);
  110432. $ = $ % b.snapDistance,
  110433. nt.delta.normalizeToRef(_e),
  110434. _e.scaleInPlace(b.snapDistance * at),
  110435. b.attachedNode.getWorldMatrix().getTranslationToRef(et),
  110436. et.addInPlace(_e),
  110437. b.dragBehavior.validateDrag(et) && (b.attachedNode.getWorldMatrix().addTranslationFromFloats(_e.x, _e.y, _e.z),
  110438. b.attachedNode.updateCache(),
  110439. tt.snapDistance = b.snapDistance * at,
  110440. b.onSnapObservable.notifyObservers(tt),
  110441. ot = !0)
  110442. }
  110443. ot && b._matrixChanged()
  110444. }
  110445. }),
  110446. b.dragBehavior.onDragStartObservable.add(function() {
  110447. b._dragging = !0
  110448. }),
  110449. b.dragBehavior.onDragEndObservable.add(function() {
  110450. b._dragging = !1
  110451. });
  110452. var rt = s._getSharedGizmoLight();
  110453. rt.includedOnlyMeshes = rt.includedOnlyMeshes.concat(b._rootMesh.getChildMeshes(!1));
  110454. var it = {
  110455. gizmoMeshes: k.getChildMeshes(),
  110456. colliderMeshes: j.getChildMeshes(),
  110457. material: b._coloredMaterial,
  110458. hoverMaterial: b._hoverMaterial,
  110459. disableMaterial: b._disableMaterial,
  110460. active: !1,
  110461. dragBehavior: b.dragBehavior
  110462. };
  110463. return (_ = b._parent) === null || _ === void 0 || _.addToAxisCache(j, it),
  110464. b._pointerObserver = s.utilityLayerScene.onPointerObservable.add(function(nt) {
  110465. var ot;
  110466. if (!b._customMeshSet && (b._isHovered = it.colliderMeshes.indexOf((ot = nt == null ? void 0 : nt.pickInfo) === null || ot === void 0 ? void 0 : ot.pickedMesh) != -1,
  110467. !b._parent)) {
  110468. var at = b.dragBehavior.enabled ? b._isHovered || b._dragging ? b._hoverMaterial : b._coloredMaterial : b._disableMaterial;
  110469. b._setGizmoMeshMaterial(it.gizmoMeshes, at)
  110470. }
  110471. }),
  110472. b.dragBehavior.onEnabledObservable.add(function(nt) {
  110473. b._setGizmoMeshMaterial(it.gizmoMeshes, nt ? it.material : it.disableMaterial)
  110474. }),
  110475. b
  110476. }
  110477. return e._CreateArrow = function(i, o, s, c) {
  110478. s === void 0 && (s = 1),
  110479. c === void 0 && (c = !1);
  110480. var d = new TransformNode("arrow",i)
  110481. , _ = CreateCylinder("cylinder", {
  110482. diameterTop: 0,
  110483. height: .075,
  110484. diameterBottom: .0375 * (1 + (s - 1) / 4),
  110485. tessellation: 96
  110486. }, i)
  110487. , b = CreateCylinder("cylinder", {
  110488. diameterTop: .005 * s,
  110489. height: .275,
  110490. diameterBottom: .005 * s,
  110491. tessellation: 96
  110492. }, i);
  110493. return _.parent = d,
  110494. _.material = o,
  110495. _.rotation.x = Math.PI / 2,
  110496. _.position.z += .3,
  110497. b.parent = d,
  110498. b.material = o,
  110499. b.position.z += .275 / 2,
  110500. b.rotation.x = Math.PI / 2,
  110501. c && (b.visibility = 0,
  110502. _.visibility = 0),
  110503. d
  110504. }
  110505. ,
  110506. e._CreateArrowInstance = function(i, o) {
  110507. for (var s = new TransformNode("arrow",i), c = 0, d = o.getChildMeshes(); c < d.length; c++) {
  110508. var _ = d[c]
  110509. , b = _.createInstance(_.name);
  110510. b.parent = s
  110511. }
  110512. return s
  110513. }
  110514. ,
  110515. e.prototype._attachedNodeChanged = function(i) {
  110516. this.dragBehavior && (this.dragBehavior.enabled = !!i)
  110517. }
  110518. ,
  110519. Object.defineProperty(e.prototype, "isEnabled", {
  110520. get: function() {
  110521. return this._isEnabled
  110522. },
  110523. set: function(i) {
  110524. this._isEnabled = i,
  110525. i ? this._parent && (this.attachedMesh = this._parent.attachedMesh,
  110526. this.attachedNode = this._parent.attachedNode) : (this.attachedMesh = null,
  110527. this.attachedNode = null)
  110528. },
  110529. enumerable: !1,
  110530. configurable: !0
  110531. }),
  110532. e.prototype.dispose = function() {
  110533. this.onSnapObservable.clear(),
  110534. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),
  110535. this.dragBehavior.detach(),
  110536. this._gizmoMesh && this._gizmoMesh.dispose(),
  110537. [this._coloredMaterial, this._hoverMaterial, this._disableMaterial].forEach(function(i) {
  110538. i && i.dispose()
  110539. }),
  110540. a.prototype.dispose.call(this)
  110541. }
  110542. ,
  110543. e
  110544. }(Gizmo)
  110545. , PlaneDragGizmo = function(a) {
  110546. __extends(e, a);
  110547. function e(i, o, s, c) {
  110548. o === void 0 && (o = Color3.Gray()),
  110549. s === void 0 && (s = UtilityLayerRenderer.DefaultUtilityLayer),
  110550. c === void 0 && (c = null);
  110551. var d, _ = a.call(this, s) || this;
  110552. _._pointerObserver = null,
  110553. _.snapDistance = 0,
  110554. _.onSnapObservable = new Observable,
  110555. _._isEnabled = !1,
  110556. _._parent = null,
  110557. _._dragging = !1,
  110558. _._parent = c,
  110559. _._coloredMaterial = new StandardMaterial("",s.utilityLayerScene),
  110560. _._coloredMaterial.diffuseColor = o,
  110561. _._coloredMaterial.specularColor = o.subtract(new Color3(.1,.1,.1)),
  110562. _._hoverMaterial = new StandardMaterial("",s.utilityLayerScene),
  110563. _._hoverMaterial.diffuseColor = Color3.Yellow(),
  110564. _._disableMaterial = new StandardMaterial("",s.utilityLayerScene),
  110565. _._disableMaterial.diffuseColor = Color3.Gray(),
  110566. _._disableMaterial.alpha = .4,
  110567. _._gizmoMesh = e._CreatePlane(s.utilityLayerScene, _._coloredMaterial),
  110568. _._gizmoMesh.lookAt(_._rootMesh.position.add(i)),
  110569. _._gizmoMesh.scaling.scaleInPlace(1 / 3),
  110570. _._gizmoMesh.parent = _._rootMesh;
  110571. var b = 0
  110572. , k = new Vector3
  110573. , j = {
  110574. snapDistance: 0
  110575. };
  110576. _.dragBehavior = new PointerDragBehavior({
  110577. dragPlaneNormal: i
  110578. }),
  110579. _.dragBehavior.moveAttached = !1,
  110580. _._rootMesh.addBehavior(_.dragBehavior),
  110581. _.dragBehavior.onDragObservable.add(function(et) {
  110582. if (_.attachedNode) {
  110583. if (_._handlePivot(),
  110584. _.snapDistance == 0)
  110585. _.attachedNode.getWorldMatrix().addTranslationFromFloats(et.delta.x, et.delta.y, et.delta.z);
  110586. else if (b += et.dragDistance,
  110587. Math.abs(b) > _.snapDistance) {
  110588. var tt = Math.floor(Math.abs(b) / _.snapDistance);
  110589. b = b % _.snapDistance,
  110590. et.delta.normalizeToRef(k),
  110591. k.scaleInPlace(_.snapDistance * tt),
  110592. _.attachedNode.getWorldMatrix().addTranslationFromFloats(k.x, k.y, k.z),
  110593. j.snapDistance = _.snapDistance * tt,
  110594. _.onSnapObservable.notifyObservers(j)
  110595. }
  110596. _._matrixChanged()
  110597. }
  110598. }),
  110599. _.dragBehavior.onDragStartObservable.add(function() {
  110600. _._dragging = !0
  110601. }),
  110602. _.dragBehavior.onDragEndObservable.add(function() {
  110603. _._dragging = !1
  110604. });
  110605. var $ = s._getSharedGizmoLight();
  110606. $.includedOnlyMeshes = $.includedOnlyMeshes.concat(_._rootMesh.getChildMeshes(!1));
  110607. var _e = {
  110608. gizmoMeshes: _._gizmoMesh.getChildMeshes(),
  110609. colliderMeshes: _._gizmoMesh.getChildMeshes(),
  110610. material: _._coloredMaterial,
  110611. hoverMaterial: _._hoverMaterial,
  110612. disableMaterial: _._disableMaterial,
  110613. active: !1,
  110614. dragBehavior: _.dragBehavior
  110615. };
  110616. return (d = _._parent) === null || d === void 0 || d.addToAxisCache(_._gizmoMesh, _e),
  110617. _._pointerObserver = s.utilityLayerScene.onPointerObservable.add(function(et) {
  110618. var tt;
  110619. if (!_._customMeshSet && (_._isHovered = _e.colliderMeshes.indexOf((tt = et == null ? void 0 : et.pickInfo) === null || tt === void 0 ? void 0 : tt.pickedMesh) != -1,
  110620. !_._parent)) {
  110621. var rt = _e.dragBehavior.enabled ? _._isHovered || _._dragging ? _._hoverMaterial : _._coloredMaterial : _._disableMaterial;
  110622. _._setGizmoMeshMaterial(_e.gizmoMeshes, rt)
  110623. }
  110624. }),
  110625. _.dragBehavior.onEnabledObservable.add(function(et) {
  110626. _._setGizmoMeshMaterial(_e.gizmoMeshes, et ? _._coloredMaterial : _._disableMaterial)
  110627. }),
  110628. _
  110629. }
  110630. return e._CreatePlane = function(i, o) {
  110631. var s = new TransformNode("plane",i)
  110632. , c = CreatePlane("dragPlane", {
  110633. width: .1375,
  110634. height: .1375,
  110635. sideOrientation: 2
  110636. }, i);
  110637. return c.material = o,
  110638. c.parent = s,
  110639. s
  110640. }
  110641. ,
  110642. e.prototype._attachedNodeChanged = function(i) {
  110643. this.dragBehavior && (this.dragBehavior.enabled = !!i)
  110644. }
  110645. ,
  110646. Object.defineProperty(e.prototype, "isEnabled", {
  110647. get: function() {
  110648. return this._isEnabled
  110649. },
  110650. set: function(i) {
  110651. this._isEnabled = i,
  110652. i ? this._parent && (this.attachedNode = this._parent.attachedNode) : this.attachedNode = null
  110653. },
  110654. enumerable: !1,
  110655. configurable: !0
  110656. }),
  110657. e.prototype.dispose = function() {
  110658. this.onSnapObservable.clear(),
  110659. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),
  110660. this.dragBehavior.detach(),
  110661. a.prototype.dispose.call(this),
  110662. this._gizmoMesh && this._gizmoMesh.dispose(),
  110663. [this._coloredMaterial, this._hoverMaterial, this._disableMaterial].forEach(function(i) {
  110664. i && i.dispose()
  110665. })
  110666. }
  110667. ,
  110668. e
  110669. }(Gizmo)
  110670. , PositionGizmo = function(a) {
  110671. __extends(e, a);
  110672. function e(i, o, s) {
  110673. i === void 0 && (i = UtilityLayerRenderer.DefaultUtilityLayer),
  110674. o === void 0 && (o = 1);
  110675. var c = a.call(this, i) || this;
  110676. return c._meshAttached = null,
  110677. c._nodeAttached = null,
  110678. c._observables = [],
  110679. c._gizmoAxisCache = new Map,
  110680. c.onDragStartObservable = new Observable,
  110681. c.onDragEndObservable = new Observable,
  110682. c._planarGizmoEnabled = !1,
  110683. c.xGizmo = new AxisDragGizmo(new Vector3(1,0,0),Color3.Red().scale(.5),i,c,o),
  110684. c.yGizmo = new AxisDragGizmo(new Vector3(0,1,0),Color3.Green().scale(.5),i,c,o),
  110685. c.zGizmo = new AxisDragGizmo(new Vector3(0,0,1),Color3.Blue().scale(.5),i,c,o),
  110686. c.xPlaneGizmo = new PlaneDragGizmo(new Vector3(1,0,0),Color3.Red().scale(.5),c.gizmoLayer,c),
  110687. c.yPlaneGizmo = new PlaneDragGizmo(new Vector3(0,1,0),Color3.Green().scale(.5),c.gizmoLayer,c),
  110688. c.zPlaneGizmo = new PlaneDragGizmo(new Vector3(0,0,1),Color3.Blue().scale(.5),c.gizmoLayer,c),
  110689. [c.xGizmo, c.yGizmo, c.zGizmo, c.xPlaneGizmo, c.yPlaneGizmo, c.zPlaneGizmo].forEach(function(d) {
  110690. d.dragBehavior.onDragStartObservable.add(function() {
  110691. c.onDragStartObservable.notifyObservers({})
  110692. }),
  110693. d.dragBehavior.onDragEndObservable.add(function() {
  110694. c.onDragEndObservable.notifyObservers({})
  110695. })
  110696. }),
  110697. c.attachedMesh = null,
  110698. s ? s.addToAxisCache(c._gizmoAxisCache) : Gizmo.GizmoAxisPointerObserver(i, c._gizmoAxisCache),
  110699. c
  110700. }
  110701. return Object.defineProperty(e.prototype, "attachedMesh", {
  110702. get: function() {
  110703. return this._meshAttached
  110704. },
  110705. set: function(i) {
  110706. this._meshAttached = i,
  110707. this._nodeAttached = i,
  110708. [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach(function(o) {
  110709. o.isEnabled ? o.attachedMesh = i : o.attachedMesh = null
  110710. })
  110711. },
  110712. enumerable: !1,
  110713. configurable: !0
  110714. }),
  110715. Object.defineProperty(e.prototype, "attachedNode", {
  110716. get: function() {
  110717. return this._nodeAttached
  110718. },
  110719. set: function(i) {
  110720. this._meshAttached = null,
  110721. this._nodeAttached = i,
  110722. [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach(function(o) {
  110723. o.isEnabled ? o.attachedNode = i : o.attachedNode = null
  110724. })
  110725. },
  110726. enumerable: !1,
  110727. configurable: !0
  110728. }),
  110729. Object.defineProperty(e.prototype, "isHovered", {
  110730. get: function() {
  110731. var i = !1;
  110732. return [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach(function(o) {
  110733. i = i || o.isHovered
  110734. }),
  110735. i
  110736. },
  110737. enumerable: !1,
  110738. configurable: !0
  110739. }),
  110740. Object.defineProperty(e.prototype, "planarGizmoEnabled", {
  110741. get: function() {
  110742. return this._planarGizmoEnabled
  110743. },
  110744. set: function(i) {
  110745. var o = this;
  110746. this._planarGizmoEnabled = i,
  110747. [this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach(function(s) {
  110748. s && (s.isEnabled = i,
  110749. i && (s.attachedMesh ? s.attachedMesh = o.attachedMesh : s.attachedNode = o.attachedNode))
  110750. }, this)
  110751. },
  110752. enumerable: !1,
  110753. configurable: !0
  110754. }),
  110755. Object.defineProperty(e.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  110756. get: function() {
  110757. return this._updateGizmoRotationToMatchAttachedMesh
  110758. },
  110759. set: function(i) {
  110760. this._updateGizmoRotationToMatchAttachedMesh = i,
  110761. [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach(function(o) {
  110762. o && (o.updateGizmoRotationToMatchAttachedMesh = i)
  110763. })
  110764. },
  110765. enumerable: !1,
  110766. configurable: !0
  110767. }),
  110768. Object.defineProperty(e.prototype, "snapDistance", {
  110769. get: function() {
  110770. return this._snapDistance
  110771. },
  110772. set: function(i) {
  110773. this._snapDistance = i,
  110774. [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach(function(o) {
  110775. o && (o.snapDistance = i)
  110776. })
  110777. },
  110778. enumerable: !1,
  110779. configurable: !0
  110780. }),
  110781. Object.defineProperty(e.prototype, "scaleRatio", {
  110782. get: function() {
  110783. return this._scaleRatio
  110784. },
  110785. set: function(i) {
  110786. this._scaleRatio = i,
  110787. [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach(function(o) {
  110788. o && (o.scaleRatio = i)
  110789. })
  110790. },
  110791. enumerable: !1,
  110792. configurable: !0
  110793. }),
  110794. e.prototype.addToAxisCache = function(i, o) {
  110795. this._gizmoAxisCache.set(i, o)
  110796. }
  110797. ,
  110798. e.prototype.dispose = function() {
  110799. var i = this;
  110800. [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach(function(o) {
  110801. o && o.dispose()
  110802. }),
  110803. this._observables.forEach(function(o) {
  110804. i.gizmoLayer.utilityLayerScene.onPointerObservable.remove(o)
  110805. }),
  110806. this.onDragStartObservable.clear(),
  110807. this.onDragEndObservable.clear()
  110808. }
  110809. ,
  110810. e.prototype.setCustomMesh = function(i) {
  110811. Logger$2.Error("Custom meshes are not supported on this gizmo, please set the custom meshes on the gizmos contained within this one (gizmo.xGizmo, gizmo.yGizmo, gizmo.zGizmo,gizmo.xPlaneGizmo, gizmo.yPlaneGizmo, gizmo.zPlaneGizmo)")
  110812. }
  110813. ,
  110814. e
  110815. }(Gizmo)
  110816. , AxisScaleGizmo = function(a) {
  110817. __extends(e, a);
  110818. function e(i, o, s, c, d) {
  110819. o === void 0 && (o = Color3.Gray()),
  110820. s === void 0 && (s = UtilityLayerRenderer.DefaultUtilityLayer),
  110821. c === void 0 && (c = null),
  110822. d === void 0 && (d = 1);
  110823. var _, b, k, j, $, _e, et, tt = a.call(this, s) || this;
  110824. tt._pointerObserver = null,
  110825. tt.snapDistance = 0,
  110826. tt.onSnapObservable = new Observable,
  110827. tt.uniformScaling = !1,
  110828. tt.sensitivity = 1,
  110829. tt.dragScale = 1,
  110830. tt._isEnabled = !0,
  110831. tt._parent = null,
  110832. tt._dragging = !1,
  110833. tt._tmpVector = new Vector3,
  110834. tt._tmpMatrix = new Matrix,
  110835. tt._tmpMatrix2 = new Matrix,
  110836. tt._parent = c,
  110837. tt._coloredMaterial = new StandardMaterial("",s.utilityLayerScene),
  110838. tt._coloredMaterial.diffuseColor = o,
  110839. tt._coloredMaterial.specularColor = o.subtract(new Color3(.1,.1,.1)),
  110840. tt._hoverMaterial = new StandardMaterial("",s.utilityLayerScene),
  110841. tt._hoverMaterial.diffuseColor = Color3.Yellow(),
  110842. tt._disableMaterial = new StandardMaterial("",s.utilityLayerScene),
  110843. tt._disableMaterial.diffuseColor = Color3.Gray(),
  110844. tt._disableMaterial.alpha = .4,
  110845. tt._gizmoMesh = new Mesh("axis",s.utilityLayerScene);
  110846. var rt = tt._createGizmoMesh(tt._gizmoMesh, d)
  110847. , it = rt.arrowMesh
  110848. , nt = rt.arrowTail
  110849. , ot = tt._createGizmoMesh(tt._gizmoMesh, d + 4, !0);
  110850. tt._gizmoMesh.lookAt(tt._rootMesh.position.add(i)),
  110851. tt._rootMesh.addChild(tt._gizmoMesh),
  110852. tt._gizmoMesh.scaling.scaleInPlace(1 / 3);
  110853. var at = it.position.clone()
  110854. , st = nt.position.clone()
  110855. , ut = nt.scaling.clone()
  110856. , ct = function(mt) {
  110857. var vt = mt * (3 / tt._rootMesh.scaling.length()) * 6;
  110858. it.position.z += vt / 3.5,
  110859. nt.scaling.y += vt,
  110860. tt.dragScale = nt.scaling.y,
  110861. nt.position.z = it.position.z / 2
  110862. }
  110863. , lt = function() {
  110864. it.position.set(at.x, at.y, at.z),
  110865. nt.position.set(st.x, st.y, st.z),
  110866. nt.scaling.set(ut.x, ut.y, ut.z),
  110867. tt.dragScale = nt.scaling.y,
  110868. tt._dragging = !1
  110869. };
  110870. tt.dragBehavior = new PointerDragBehavior({
  110871. dragAxis: i
  110872. }),
  110873. tt.dragBehavior.moveAttached = !1,
  110874. tt._rootMesh.addBehavior(tt.dragBehavior);
  110875. var ft = 0
  110876. , ht = new Vector3
  110877. , pt = {
  110878. snapDistance: 0
  110879. };
  110880. tt.dragBehavior.onDragObservable.add(function(mt) {
  110881. if (tt.attachedNode) {
  110882. tt._handlePivot();
  110883. var vt = tt.sensitivity * mt.dragDistance * (tt.scaleRatio * 3 / tt._rootMesh.scaling.length())
  110884. , yt = !1
  110885. , Et = 0;
  110886. tt.uniformScaling ? ht.setAll(.57735) : ht.copyFrom(i),
  110887. tt.snapDistance == 0 ? ht.scaleToRef(vt, ht) : (ft += vt,
  110888. Math.abs(ft) > tt.snapDistance ? (Et = Math.floor(Math.abs(ft) / tt.snapDistance),
  110889. ft < 0 && (Et *= -1),
  110890. ft = ft % tt.snapDistance,
  110891. ht.scaleToRef(tt.snapDistance * Et, ht),
  110892. yt = !0) : ht.scaleInPlace(0)),
  110893. Matrix.ScalingToRef(1 + ht.x, 1 + ht.y, 1 + ht.z, tt._tmpMatrix2),
  110894. tt._tmpMatrix2.multiplyToRef(tt.attachedNode.getWorldMatrix(), tt._tmpMatrix),
  110895. tt._tmpMatrix.decompose(tt._tmpVector);
  110896. var At = 1e5;
  110897. Math.abs(tt._tmpVector.x) < At && Math.abs(tt._tmpVector.y) < At && Math.abs(tt._tmpVector.z) < At && tt.attachedNode.getWorldMatrix().copyFrom(tt._tmpMatrix),
  110898. yt && (pt.snapDistance = tt.snapDistance * Et,
  110899. tt.onSnapObservable.notifyObservers(pt)),
  110900. tt._matrixChanged()
  110901. }
  110902. }),
  110903. tt.dragBehavior.onDragStartObservable.add(function() {
  110904. tt._dragging = !0
  110905. }),
  110906. tt.dragBehavior.onDragObservable.add(function(mt) {
  110907. return ct(mt.dragDistance)
  110908. }),
  110909. tt.dragBehavior.onDragEndObservable.add(lt),
  110910. (k = (b = (_ = c == null ? void 0 : c.uniformScaleGizmo) === null || _ === void 0 ? void 0 : _.dragBehavior) === null || b === void 0 ? void 0 : b.onDragObservable) === null || k === void 0 || k.add(function(mt) {
  110911. return ct(mt.delta.y)
  110912. }),
  110913. (_e = ($ = (j = c == null ? void 0 : c.uniformScaleGizmo) === null || j === void 0 ? void 0 : j.dragBehavior) === null || $ === void 0 ? void 0 : $.onDragEndObservable) === null || _e === void 0 || _e.add(lt);
  110914. var dt = {
  110915. gizmoMeshes: [it, nt],
  110916. colliderMeshes: [ot.arrowMesh, ot.arrowTail],
  110917. material: tt._coloredMaterial,
  110918. hoverMaterial: tt._hoverMaterial,
  110919. disableMaterial: tt._disableMaterial,
  110920. active: !1,
  110921. dragBehavior: tt.dragBehavior
  110922. };
  110923. (et = tt._parent) === null || et === void 0 || et.addToAxisCache(tt._gizmoMesh, dt),
  110924. tt._pointerObserver = s.utilityLayerScene.onPointerObservable.add(function(mt) {
  110925. var vt;
  110926. if (!tt._customMeshSet && (tt._isHovered = dt.colliderMeshes.indexOf((vt = mt == null ? void 0 : mt.pickInfo) === null || vt === void 0 ? void 0 : vt.pickedMesh) != -1,
  110927. !tt._parent)) {
  110928. var yt = tt.dragBehavior.enabled ? tt._isHovered || tt._dragging ? tt._hoverMaterial : tt._coloredMaterial : tt._disableMaterial;
  110929. tt._setGizmoMeshMaterial(dt.gizmoMeshes, yt)
  110930. }
  110931. }),
  110932. tt.dragBehavior.onEnabledObservable.add(function(mt) {
  110933. tt._setGizmoMeshMaterial(dt.gizmoMeshes, mt ? tt._coloredMaterial : tt._disableMaterial)
  110934. });
  110935. var _t = s._getSharedGizmoLight();
  110936. return _t.includedOnlyMeshes = _t.includedOnlyMeshes.concat(tt._rootMesh.getChildMeshes()),
  110937. tt
  110938. }
  110939. return e.prototype._createGizmoMesh = function(i, o, s) {
  110940. s === void 0 && (s = !1);
  110941. var c = CreateBox("yPosMesh", {
  110942. size: .4 * (1 + (o - 1) / 4)
  110943. }, this.gizmoLayer.utilityLayerScene)
  110944. , d = CreateCylinder("cylinder", {
  110945. diameterTop: .005 * o,
  110946. height: .275,
  110947. diameterBottom: .005 * o,
  110948. tessellation: 96
  110949. }, this.gizmoLayer.utilityLayerScene);
  110950. return c.scaling.scaleInPlace(.1),
  110951. c.material = this._coloredMaterial,
  110952. c.rotation.x = Math.PI / 2,
  110953. c.position.z += .3,
  110954. d.material = this._coloredMaterial,
  110955. d.position.z += .275 / 2,
  110956. d.rotation.x = Math.PI / 2,
  110957. s && (c.visibility = 0,
  110958. d.visibility = 0),
  110959. i.addChild(c),
  110960. i.addChild(d),
  110961. {
  110962. arrowMesh: c,
  110963. arrowTail: d
  110964. }
  110965. }
  110966. ,
  110967. e.prototype._attachedNodeChanged = function(i) {
  110968. this.dragBehavior && (this.dragBehavior.enabled = !!i)
  110969. }
  110970. ,
  110971. Object.defineProperty(e.prototype, "isEnabled", {
  110972. get: function() {
  110973. return this._isEnabled
  110974. },
  110975. set: function(i) {
  110976. this._isEnabled = i,
  110977. i ? this._parent && (this.attachedMesh = this._parent.attachedMesh,
  110978. this.attachedNode = this._parent.attachedNode) : (this.attachedMesh = null,
  110979. this.attachedNode = null)
  110980. },
  110981. enumerable: !1,
  110982. configurable: !0
  110983. }),
  110984. e.prototype.dispose = function() {
  110985. this.onSnapObservable.clear(),
  110986. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),
  110987. this.dragBehavior.detach(),
  110988. this._gizmoMesh && this._gizmoMesh.dispose(),
  110989. [this._coloredMaterial, this._hoverMaterial, this._disableMaterial].forEach(function(i) {
  110990. i && i.dispose()
  110991. }),
  110992. a.prototype.dispose.call(this)
  110993. }
  110994. ,
  110995. e.prototype.setCustomMesh = function(i, o) {
  110996. var s = this;
  110997. o === void 0 && (o = !1),
  110998. a.prototype.setCustomMesh.call(this, i),
  110999. o && (this._rootMesh.getChildMeshes().forEach(function(c) {
  111000. c.material = s._coloredMaterial,
  111001. c.color && (c.color = s._coloredMaterial.diffuseColor)
  111002. }),
  111003. this._customMeshSet = !1)
  111004. }
  111005. ,
  111006. e
  111007. }(Gizmo)
  111008. , ScaleGizmo = function(a) {
  111009. __extends(e, a);
  111010. function e(i, o, s) {
  111011. i === void 0 && (i = UtilityLayerRenderer.DefaultUtilityLayer),
  111012. o === void 0 && (o = 1);
  111013. var c = a.call(this, i) || this;
  111014. return c._meshAttached = null,
  111015. c._nodeAttached = null,
  111016. c._sensitivity = 1,
  111017. c._observables = [],
  111018. c._gizmoAxisCache = new Map,
  111019. c.onDragStartObservable = new Observable,
  111020. c.onDragEndObservable = new Observable,
  111021. c.uniformScaleGizmo = c._createUniformScaleMesh(),
  111022. c.xGizmo = new AxisScaleGizmo(new Vector3(1,0,0),Color3.Red().scale(.5),i,c,o),
  111023. c.yGizmo = new AxisScaleGizmo(new Vector3(0,1,0),Color3.Green().scale(.5),i,c,o),
  111024. c.zGizmo = new AxisScaleGizmo(new Vector3(0,0,1),Color3.Blue().scale(.5),i,c,o),
  111025. [c.xGizmo, c.yGizmo, c.zGizmo, c.uniformScaleGizmo].forEach(function(d) {
  111026. d.dragBehavior.onDragStartObservable.add(function() {
  111027. c.onDragStartObservable.notifyObservers({})
  111028. }),
  111029. d.dragBehavior.onDragEndObservable.add(function() {
  111030. c.onDragEndObservable.notifyObservers({})
  111031. })
  111032. }),
  111033. c.attachedMesh = null,
  111034. c.attachedNode = null,
  111035. s ? s.addToAxisCache(c._gizmoAxisCache) : Gizmo.GizmoAxisPointerObserver(i, c._gizmoAxisCache),
  111036. c
  111037. }
  111038. return Object.defineProperty(e.prototype, "attachedMesh", {
  111039. get: function() {
  111040. return this._meshAttached
  111041. },
  111042. set: function(i) {
  111043. this._meshAttached = i,
  111044. this._nodeAttached = i,
  111045. [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach(function(o) {
  111046. o.isEnabled ? o.attachedMesh = i : o.attachedMesh = null
  111047. })
  111048. },
  111049. enumerable: !1,
  111050. configurable: !0
  111051. }),
  111052. Object.defineProperty(e.prototype, "attachedNode", {
  111053. get: function() {
  111054. return this._nodeAttached
  111055. },
  111056. set: function(i) {
  111057. this._meshAttached = null,
  111058. this._nodeAttached = i,
  111059. [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach(function(o) {
  111060. o.isEnabled ? o.attachedNode = i : o.attachedNode = null
  111061. })
  111062. },
  111063. enumerable: !1,
  111064. configurable: !0
  111065. }),
  111066. Object.defineProperty(e.prototype, "isHovered", {
  111067. get: function() {
  111068. var i = !1;
  111069. return [this.xGizmo, this.yGizmo, this.zGizmo].forEach(function(o) {
  111070. i = i || o.isHovered
  111071. }),
  111072. i
  111073. },
  111074. enumerable: !1,
  111075. configurable: !0
  111076. }),
  111077. e.prototype._createUniformScaleMesh = function() {
  111078. this._coloredMaterial = new StandardMaterial("",this.gizmoLayer.utilityLayerScene),
  111079. this._coloredMaterial.diffuseColor = Color3.Gray(),
  111080. this._hoverMaterial = new StandardMaterial("",this.gizmoLayer.utilityLayerScene),
  111081. this._hoverMaterial.diffuseColor = Color3.Yellow(),
  111082. this._disableMaterial = new StandardMaterial("",this.gizmoLayer.utilityLayerScene),
  111083. this._disableMaterial.diffuseColor = Color3.Gray(),
  111084. this._disableMaterial.alpha = .4;
  111085. var i = new AxisScaleGizmo(new Vector3(0,1,0),Color3.Gray().scale(.5),this.gizmoLayer,this);
  111086. i.updateGizmoRotationToMatchAttachedMesh = !1,
  111087. i.uniformScaling = !0,
  111088. this._uniformScalingMesh = CreatePolyhedron("uniform", {
  111089. type: 1
  111090. }, i.gizmoLayer.utilityLayerScene),
  111091. this._uniformScalingMesh.scaling.scaleInPlace(.01),
  111092. this._uniformScalingMesh.visibility = 0,
  111093. this._octahedron = CreatePolyhedron("", {
  111094. type: 1
  111095. }, i.gizmoLayer.utilityLayerScene),
  111096. this._octahedron.scaling.scaleInPlace(.007),
  111097. this._uniformScalingMesh.addChild(this._octahedron),
  111098. i.setCustomMesh(this._uniformScalingMesh, !0);
  111099. var o = this.gizmoLayer._getSharedGizmoLight();
  111100. o.includedOnlyMeshes = o.includedOnlyMeshes.concat(this._octahedron);
  111101. var s = {
  111102. gizmoMeshes: [this._octahedron, this._uniformScalingMesh],
  111103. colliderMeshes: [this._uniformScalingMesh],
  111104. material: this._coloredMaterial,
  111105. hoverMaterial: this._hoverMaterial,
  111106. disableMaterial: this._disableMaterial,
  111107. active: !1,
  111108. dragBehavior: i.dragBehavior
  111109. };
  111110. return this.addToAxisCache(i._rootMesh, s),
  111111. i
  111112. }
  111113. ,
  111114. Object.defineProperty(e.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  111115. get: function() {
  111116. return this._updateGizmoRotationToMatchAttachedMesh
  111117. },
  111118. set: function(i) {
  111119. i ? (this._updateGizmoRotationToMatchAttachedMesh = i,
  111120. [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach(function(o) {
  111121. o && (o.updateGizmoRotationToMatchAttachedMesh = i)
  111122. })) : Logger$2.Warn("Setting updateGizmoRotationToMatchAttachedMesh = false on scaling gizmo is not supported.")
  111123. },
  111124. enumerable: !1,
  111125. configurable: !0
  111126. }),
  111127. Object.defineProperty(e.prototype, "snapDistance", {
  111128. get: function() {
  111129. return this._snapDistance
  111130. },
  111131. set: function(i) {
  111132. this._snapDistance = i,
  111133. [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach(function(o) {
  111134. o && (o.snapDistance = i)
  111135. })
  111136. },
  111137. enumerable: !1,
  111138. configurable: !0
  111139. }),
  111140. Object.defineProperty(e.prototype, "scaleRatio", {
  111141. get: function() {
  111142. return this._scaleRatio
  111143. },
  111144. set: function(i) {
  111145. this._scaleRatio = i,
  111146. [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach(function(o) {
  111147. o && (o.scaleRatio = i)
  111148. })
  111149. },
  111150. enumerable: !1,
  111151. configurable: !0
  111152. }),
  111153. Object.defineProperty(e.prototype, "sensitivity", {
  111154. get: function() {
  111155. return this._sensitivity
  111156. },
  111157. set: function(i) {
  111158. this._sensitivity = i,
  111159. [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach(function(o) {
  111160. o && (o.sensitivity = i)
  111161. })
  111162. },
  111163. enumerable: !1,
  111164. configurable: !0
  111165. }),
  111166. e.prototype.addToAxisCache = function(i, o) {
  111167. this._gizmoAxisCache.set(i, o)
  111168. }
  111169. ,
  111170. e.prototype.dispose = function() {
  111171. var i = this;
  111172. [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach(function(o) {
  111173. o && o.dispose()
  111174. }),
  111175. this._observables.forEach(function(o) {
  111176. i.gizmoLayer.utilityLayerScene.onPointerObservable.remove(o)
  111177. }),
  111178. this.onDragStartObservable.clear(),
  111179. this.onDragEndObservable.clear(),
  111180. [this._uniformScalingMesh, this._octahedron].forEach(function(o) {
  111181. o && o.dispose()
  111182. }),
  111183. [this._coloredMaterial, this._hoverMaterial, this._disableMaterial].forEach(function(o) {
  111184. o && o.dispose()
  111185. })
  111186. }
  111187. ,
  111188. e
  111189. }(Gizmo)
  111190. , BoundingBoxGizmo = function(a) {
  111191. __extends(e, a);
  111192. function e(i, o) {
  111193. i === void 0 && (i = Color3.Gray()),
  111194. o === void 0 && (o = UtilityLayerRenderer.DefaultKeepDepthUtilityLayer);
  111195. var s = a.call(this, o) || this;
  111196. s._boundingDimensions = new Vector3(1,1,1),
  111197. s._renderObserver = null,
  111198. s._pointerObserver = null,
  111199. s._scaleDragSpeed = .2,
  111200. s._tmpQuaternion = new Quaternion,
  111201. s._tmpVector = new Vector3(0,0,0),
  111202. s._tmpRotationMatrix = new Matrix,
  111203. s.ignoreChildren = !1,
  111204. s.includeChildPredicate = null,
  111205. s.rotationSphereSize = .1,
  111206. s.scaleBoxSize = .1,
  111207. s.fixedDragMeshScreenSize = !1,
  111208. s.fixedDragMeshBoundsSize = !1,
  111209. s.fixedDragMeshScreenSizeDistanceFactor = 10,
  111210. s.onDragStartObservable = new Observable,
  111211. s.onScaleBoxDragObservable = new Observable,
  111212. s.onScaleBoxDragEndObservable = new Observable,
  111213. s.onRotationSphereDragObservable = new Observable,
  111214. s.onRotationSphereDragEndObservable = new Observable,
  111215. s.scalePivot = null,
  111216. s._axisFactor = new Vector3(1,1,1),
  111217. s._existingMeshScale = new Vector3,
  111218. s._dragMesh = null,
  111219. s.pointerDragBehavior = new PointerDragBehavior,
  111220. s.updateScale = !1,
  111221. s._anchorMesh = new AbstractMesh("anchor",o.utilityLayerScene),
  111222. s.coloredMaterial = new StandardMaterial("",o.utilityLayerScene),
  111223. s.coloredMaterial.disableLighting = !0,
  111224. s.hoverColoredMaterial = new StandardMaterial("",o.utilityLayerScene),
  111225. s.hoverColoredMaterial.disableLighting = !0,
  111226. s._lineBoundingBox = new AbstractMesh("",o.utilityLayerScene),
  111227. s._lineBoundingBox.rotationQuaternion = new Quaternion;
  111228. var c = [];
  111229. c.push(CreateLines("lines", {
  111230. points: [new Vector3(0,0,0), new Vector3(s._boundingDimensions.x,0,0)]
  111231. }, o.utilityLayerScene)),
  111232. c.push(CreateLines("lines", {
  111233. points: [new Vector3(0,0,0), new Vector3(0,s._boundingDimensions.y,0)]
  111234. }, o.utilityLayerScene)),
  111235. c.push(CreateLines("lines", {
  111236. points: [new Vector3(0,0,0), new Vector3(0,0,s._boundingDimensions.z)]
  111237. }, o.utilityLayerScene)),
  111238. c.push(CreateLines("lines", {
  111239. points: [new Vector3(s._boundingDimensions.x,0,0), new Vector3(s._boundingDimensions.x,s._boundingDimensions.y,0)]
  111240. }, o.utilityLayerScene)),
  111241. c.push(CreateLines("lines", {
  111242. points: [new Vector3(s._boundingDimensions.x,0,0), new Vector3(s._boundingDimensions.x,0,s._boundingDimensions.z)]
  111243. }, o.utilityLayerScene)),
  111244. c.push(CreateLines("lines", {
  111245. points: [new Vector3(0,s._boundingDimensions.y,0), new Vector3(s._boundingDimensions.x,s._boundingDimensions.y,0)]
  111246. }, o.utilityLayerScene)),
  111247. c.push(CreateLines("lines", {
  111248. points: [new Vector3(0,s._boundingDimensions.y,0), new Vector3(0,s._boundingDimensions.y,s._boundingDimensions.z)]
  111249. }, o.utilityLayerScene)),
  111250. c.push(CreateLines("lines", {
  111251. points: [new Vector3(0,0,s._boundingDimensions.z), new Vector3(s._boundingDimensions.x,0,s._boundingDimensions.z)]
  111252. }, o.utilityLayerScene)),
  111253. c.push(CreateLines("lines", {
  111254. points: [new Vector3(0,0,s._boundingDimensions.z), new Vector3(0,s._boundingDimensions.y,s._boundingDimensions.z)]
  111255. }, o.utilityLayerScene)),
  111256. c.push(CreateLines("lines", {
  111257. points: [new Vector3(s._boundingDimensions.x,s._boundingDimensions.y,s._boundingDimensions.z), new Vector3(0,s._boundingDimensions.y,s._boundingDimensions.z)]
  111258. }, o.utilityLayerScene)),
  111259. c.push(CreateLines("lines", {
  111260. points: [new Vector3(s._boundingDimensions.x,s._boundingDimensions.y,s._boundingDimensions.z), new Vector3(s._boundingDimensions.x,0,s._boundingDimensions.z)]
  111261. }, o.utilityLayerScene)),
  111262. c.push(CreateLines("lines", {
  111263. points: [new Vector3(s._boundingDimensions.x,s._boundingDimensions.y,s._boundingDimensions.z), new Vector3(s._boundingDimensions.x,s._boundingDimensions.y,0)]
  111264. }, o.utilityLayerScene)),
  111265. c.forEach(function(it) {
  111266. it.color = i,
  111267. it.position.addInPlace(new Vector3(-s._boundingDimensions.x / 2,-s._boundingDimensions.y / 2,-s._boundingDimensions.z / 2)),
  111268. it.isPickable = !1,
  111269. s._lineBoundingBox.addChild(it)
  111270. }),
  111271. s._rootMesh.addChild(s._lineBoundingBox),
  111272. s.setColor(i),
  111273. s._rotateSpheresParent = new AbstractMesh("",o.utilityLayerScene),
  111274. s._rotateSpheresParent.rotationQuaternion = new Quaternion;
  111275. for (var d = function(it) {
  111276. var nt = CreateSphere("", {
  111277. diameter: 1
  111278. }, o.utilityLayerScene);
  111279. nt.rotationQuaternion = new Quaternion,
  111280. nt.material = _.coloredMaterial,
  111281. nt.isNearGrabbable = !0,
  111282. b = new PointerDragBehavior({}),
  111283. b.moveAttached = !1,
  111284. b.updateDragPlane = !1,
  111285. nt.addBehavior(b);
  111286. var ot = new Vector3(1,0,0)
  111287. , at = 0;
  111288. b.onDragStartObservable.add(function() {
  111289. ot.copyFrom(nt.forward),
  111290. at = 0
  111291. }),
  111292. b.onDragObservable.add(function(st) {
  111293. if (s.onRotationSphereDragObservable.notifyObservers({}),
  111294. s.attachedMesh) {
  111295. var ut = s.attachedMesh.parent;
  111296. if (ut && ut.scaling && ut.scaling.isNonUniformWithinEpsilon(.001)) {
  111297. Logger$2.Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
  111298. return
  111299. }
  111300. PivotTools._RemoveAndStorePivotPoint(s.attachedMesh);
  111301. var ct = ot
  111302. , lt = st.dragPlaneNormal.scale(Vector3.Dot(st.dragPlaneNormal, ct))
  111303. , ft = ct.subtract(lt).normalizeToNew()
  111304. , ht = Vector3.Dot(ft, st.delta) < 0 ? Math.abs(st.delta.length()) : -Math.abs(st.delta.length());
  111305. ht = ht / s._boundingDimensions.length() * s._anchorMesh.scaling.length(),
  111306. s.attachedMesh.rotationQuaternion || (s.attachedMesh.rotationQuaternion = Quaternion.RotationYawPitchRoll(s.attachedMesh.rotation.y, s.attachedMesh.rotation.x, s.attachedMesh.rotation.z)),
  111307. s._anchorMesh.rotationQuaternion || (s._anchorMesh.rotationQuaternion = Quaternion.RotationYawPitchRoll(s._anchorMesh.rotation.y, s._anchorMesh.rotation.x, s._anchorMesh.rotation.z)),
  111308. at += ht,
  111309. Math.abs(at) <= 2 * Math.PI && (it >= 8 ? Quaternion.RotationYawPitchRollToRef(0, 0, ht, s._tmpQuaternion) : it >= 4 ? Quaternion.RotationYawPitchRollToRef(ht, 0, 0, s._tmpQuaternion) : Quaternion.RotationYawPitchRollToRef(0, ht, 0, s._tmpQuaternion),
  111310. s._anchorMesh.addChild(s.attachedMesh),
  111311. s._anchorMesh.rotationQuaternion.multiplyToRef(s._tmpQuaternion, s._anchorMesh.rotationQuaternion),
  111312. s._anchorMesh.removeChild(s.attachedMesh),
  111313. s.attachedMesh.setParent(ut)),
  111314. s.updateBoundingBox(),
  111315. PivotTools._RestorePivotPoint(s.attachedMesh)
  111316. }
  111317. s._updateDummy()
  111318. }),
  111319. b.onDragStartObservable.add(function() {
  111320. s.onDragStartObservable.notifyObservers({}),
  111321. s._selectNode(nt)
  111322. }),
  111323. b.onDragEndObservable.add(function() {
  111324. s.onRotationSphereDragEndObservable.notifyObservers({}),
  111325. s._selectNode(null),
  111326. s._updateDummy()
  111327. }),
  111328. _._rotateSpheresParent.addChild(nt)
  111329. }, _ = this, b, k = 0; k < 12; k++)
  111330. d(k);
  111331. s._rootMesh.addChild(s._rotateSpheresParent),
  111332. s._scaleBoxesParent = new AbstractMesh("",o.utilityLayerScene),
  111333. s._scaleBoxesParent.rotationQuaternion = new Quaternion;
  111334. for (var j = 0; j < 3; j++)
  111335. for (var $ = 0; $ < 3; $++)
  111336. for (var _e = function() {
  111337. var nt = (j === 1 ? 1 : 0) + ($ === 1 ? 1 : 0) + (tt === 1 ? 1 : 0);
  111338. if (nt === 1 || nt === 3)
  111339. return "continue";
  111340. var ot = CreateBox("", {
  111341. size: 1
  111342. }, o.utilityLayerScene);
  111343. ot.material = et.coloredMaterial,
  111344. ot.metadata = nt === 2,
  111345. ot.isNearGrabbable = !0;
  111346. var at = new Vector3(j - 1,$ - 1,tt - 1).normalize();
  111347. b = new PointerDragBehavior({
  111348. dragAxis: at
  111349. }),
  111350. b.updateDragPlane = !1,
  111351. b.moveAttached = !1,
  111352. ot.addBehavior(b),
  111353. b.onDragObservable.add(function(st) {
  111354. if (s.onScaleBoxDragObservable.notifyObservers({}),
  111355. s.attachedMesh) {
  111356. var ut = s.attachedMesh.parent;
  111357. if (ut && ut.scaling && ut.scaling.isNonUniformWithinEpsilon(.001)) {
  111358. Logger$2.Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
  111359. return
  111360. }
  111361. PivotTools._RemoveAndStorePivotPoint(s.attachedMesh);
  111362. var ct = st.dragDistance / s._boundingDimensions.length() * s._anchorMesh.scaling.length()
  111363. , lt = new Vector3(ct,ct,ct);
  111364. nt === 2 && (lt.x *= Math.abs(at.x),
  111365. lt.y *= Math.abs(at.y),
  111366. lt.z *= Math.abs(at.z)),
  111367. lt.scaleInPlace(s._scaleDragSpeed),
  111368. lt.multiplyInPlace(s._axisFactor),
  111369. s.updateBoundingBox(),
  111370. s.scalePivot ? (s.attachedMesh.getWorldMatrix().getRotationMatrixToRef(s._tmpRotationMatrix),
  111371. s._boundingDimensions.scaleToRef(.5, s._tmpVector),
  111372. Vector3.TransformCoordinatesToRef(s._tmpVector, s._tmpRotationMatrix, s._tmpVector),
  111373. s._anchorMesh.position.subtractInPlace(s._tmpVector),
  111374. s._boundingDimensions.multiplyToRef(s.scalePivot, s._tmpVector),
  111375. Vector3.TransformCoordinatesToRef(s._tmpVector, s._tmpRotationMatrix, s._tmpVector),
  111376. s._anchorMesh.position.addInPlace(s._tmpVector)) : (ot.absolutePosition.subtractToRef(s._anchorMesh.position, s._tmpVector),
  111377. s._anchorMesh.position.subtractInPlace(s._tmpVector)),
  111378. s._anchorMesh.addChild(s.attachedMesh),
  111379. s._anchorMesh.scaling.addInPlace(lt),
  111380. (s._anchorMesh.scaling.x < 0 || s._anchorMesh.scaling.y < 0 || s._anchorMesh.scaling.z < 0) && s._anchorMesh.scaling.subtractInPlace(lt),
  111381. s._anchorMesh.removeChild(s.attachedMesh),
  111382. s.attachedMesh.setParent(ut),
  111383. PivotTools._RestorePivotPoint(s.attachedMesh)
  111384. }
  111385. s._updateDummy()
  111386. }),
  111387. b.onDragStartObservable.add(function() {
  111388. s.onDragStartObservable.notifyObservers({}),
  111389. s._selectNode(ot)
  111390. }),
  111391. b.onDragEndObservable.add(function() {
  111392. s.onScaleBoxDragEndObservable.notifyObservers({}),
  111393. s._selectNode(null),
  111394. s._updateDummy()
  111395. }),
  111396. et._scaleBoxesParent.addChild(ot)
  111397. }, et = this, b, tt = 0; tt < 3; tt++)
  111398. _e();
  111399. s._rootMesh.addChild(s._scaleBoxesParent);
  111400. var rt = new Array;
  111401. return s._pointerObserver = o.utilityLayerScene.onPointerObservable.add(function(it) {
  111402. rt[it.event.pointerId] ? it.pickInfo && it.pickInfo.pickedMesh != rt[it.event.pointerId] && (rt[it.event.pointerId].material = s.coloredMaterial,
  111403. delete rt[it.event.pointerId]) : s._rotateSpheresParent.getChildMeshes().concat(s._scaleBoxesParent.getChildMeshes()).forEach(function(nt) {
  111404. it.pickInfo && it.pickInfo.pickedMesh == nt && (rt[it.event.pointerId] = nt,
  111405. nt.material = s.hoverColoredMaterial)
  111406. })
  111407. }),
  111408. s._renderObserver = s.gizmoLayer.originalScene.onBeforeRenderObservable.add(function() {
  111409. s.attachedMesh && !s._existingMeshScale.equals(s.attachedMesh.scaling) ? s.updateBoundingBox() : (s.fixedDragMeshScreenSize || s.fixedDragMeshBoundsSize) && (s._updateRotationSpheres(),
  111410. s._updateScaleBoxes()),
  111411. s._dragMesh && s.attachedMesh && s.pointerDragBehavior.dragging && (s._lineBoundingBox.position.rotateByQuaternionToRef(s._rootMesh.rotationQuaternion, s._tmpVector),
  111412. s.attachedMesh.setAbsolutePosition(s._dragMesh.position.add(s._tmpVector.scale(-1))))
  111413. }),
  111414. s.updateBoundingBox(),
  111415. s
  111416. }
  111417. return Object.defineProperty(e.prototype, "axisFactor", {
  111418. get: function() {
  111419. return this._axisFactor
  111420. },
  111421. set: function(i) {
  111422. this._axisFactor = i;
  111423. for (var o = this._scaleBoxesParent.getChildMeshes(), s = 0, c = 0; c < 3; c++)
  111424. for (var d = 0; d < 3; d++)
  111425. for (var _ = 0; _ < 3; _++) {
  111426. var b = (c === 1 ? 1 : 0) + (d === 1 ? 1 : 0) + (_ === 1 ? 1 : 0);
  111427. if (!(b === 1 || b === 3)) {
  111428. if (o[s]) {
  111429. var k = new Vector3(c - 1,d - 1,_ - 1);
  111430. k.multiplyInPlace(this._axisFactor),
  111431. o[s].setEnabled(k.lengthSquared() > Epsilon)
  111432. }
  111433. s++
  111434. }
  111435. }
  111436. },
  111437. enumerable: !1,
  111438. configurable: !0
  111439. }),
  111440. Object.defineProperty(e.prototype, "scaleDragSpeed", {
  111441. get: function() {
  111442. return this._scaleDragSpeed
  111443. },
  111444. set: function(i) {
  111445. this._scaleDragSpeed = i
  111446. },
  111447. enumerable: !1,
  111448. configurable: !0
  111449. }),
  111450. e.prototype.setColor = function(i) {
  111451. this.coloredMaterial.emissiveColor = i,
  111452. this.hoverColoredMaterial.emissiveColor = i.clone().add(new Color3(.3,.3,.3)),
  111453. this._lineBoundingBox.getChildren().forEach(function(o) {
  111454. o.color && (o.color = i)
  111455. })
  111456. }
  111457. ,
  111458. e.prototype._attachedNodeChanged = function(i) {
  111459. var o = this;
  111460. if (i) {
  111461. this._anchorMesh.scaling.setAll(1),
  111462. PivotTools._RemoveAndStorePivotPoint(i);
  111463. var s = i.parent;
  111464. this._anchorMesh.addChild(i),
  111465. this._anchorMesh.removeChild(i),
  111466. i.setParent(s),
  111467. PivotTools._RestorePivotPoint(i),
  111468. this.updateBoundingBox(),
  111469. i.getChildMeshes(!1).forEach(function(c) {
  111470. c.markAsDirty("scaling")
  111471. }),
  111472. this.gizmoLayer.utilityLayerScene.onAfterRenderObservable.addOnce(function() {
  111473. o._updateDummy()
  111474. })
  111475. }
  111476. }
  111477. ,
  111478. e.prototype._selectNode = function(i) {
  111479. this._rotateSpheresParent.getChildMeshes().concat(this._scaleBoxesParent.getChildMeshes()).forEach(function(o) {
  111480. o.isVisible = !i || o == i
  111481. })
  111482. }
  111483. ,
  111484. e.prototype.updateBoundingBox = function() {
  111485. if (this.attachedMesh) {
  111486. PivotTools._RemoveAndStorePivotPoint(this.attachedMesh);
  111487. var i = this.attachedMesh.parent;
  111488. this.attachedMesh.setParent(null);
  111489. var o = null;
  111490. this.attachedMesh.skeleton && (o = this.attachedMesh.skeleton.overrideMesh,
  111491. this.attachedMesh.skeleton.overrideMesh = null),
  111492. this._update(),
  111493. this.attachedMesh.rotationQuaternion || (this.attachedMesh.rotationQuaternion = Quaternion.RotationYawPitchRoll(this.attachedMesh.rotation.y, this.attachedMesh.rotation.x, this.attachedMesh.rotation.z)),
  111494. this._anchorMesh.rotationQuaternion || (this._anchorMesh.rotationQuaternion = Quaternion.RotationYawPitchRoll(this._anchorMesh.rotation.y, this._anchorMesh.rotation.x, this._anchorMesh.rotation.z)),
  111495. this._anchorMesh.rotationQuaternion.copyFrom(this.attachedMesh.rotationQuaternion),
  111496. this._tmpQuaternion.copyFrom(this.attachedMesh.rotationQuaternion),
  111497. this._tmpVector.copyFrom(this.attachedMesh.position),
  111498. this.attachedMesh.rotationQuaternion.set(0, 0, 0, 1),
  111499. this.attachedMesh.position.set(0, 0, 0);
  111500. var s = this.attachedMesh.getHierarchyBoundingVectors(!this.ignoreChildren, this.includeChildPredicate);
  111501. s.max.subtractToRef(s.min, this._boundingDimensions),
  111502. this._lineBoundingBox.scaling.copyFrom(this._boundingDimensions),
  111503. this._lineBoundingBox.position.set((s.max.x + s.min.x) / 2, (s.max.y + s.min.y) / 2, (s.max.z + s.min.z) / 2),
  111504. this._rotateSpheresParent.position.copyFrom(this._lineBoundingBox.position),
  111505. this._scaleBoxesParent.position.copyFrom(this._lineBoundingBox.position),
  111506. this._lineBoundingBox.computeWorldMatrix(),
  111507. this._anchorMesh.position.copyFrom(this._lineBoundingBox.absolutePosition),
  111508. this.attachedMesh.rotationQuaternion.copyFrom(this._tmpQuaternion),
  111509. this.attachedMesh.position.copyFrom(this._tmpVector),
  111510. this.attachedMesh.setParent(i),
  111511. this.attachedMesh.skeleton && (this.attachedMesh.skeleton.overrideMesh = o)
  111512. }
  111513. this._updateRotationSpheres(),
  111514. this._updateScaleBoxes(),
  111515. this.attachedMesh && (this._existingMeshScale.copyFrom(this.attachedMesh.scaling),
  111516. PivotTools._RestorePivotPoint(this.attachedMesh))
  111517. }
  111518. ,
  111519. e.prototype._updateRotationSpheres = function() {
  111520. for (var i = this._rotateSpheresParent.getChildMeshes(), o = 0; o < 3; o++)
  111521. for (var s = 0; s < 2; s++)
  111522. for (var c = 0; c < 2; c++) {
  111523. var d = o * 4 + s * 2 + c;
  111524. if (o == 0 && (i[d].position.set(this._boundingDimensions.x / 2, this._boundingDimensions.y * s, this._boundingDimensions.z * c),
  111525. i[d].position.addInPlace(new Vector3(-this._boundingDimensions.x / 2,-this._boundingDimensions.y / 2,-this._boundingDimensions.z / 2)),
  111526. i[d].lookAt(Vector3.Cross(i[d].position.normalizeToNew(), Vector3.Right()).normalizeToNew().add(i[d].position))),
  111527. o == 1 && (i[d].position.set(this._boundingDimensions.x * s, this._boundingDimensions.y / 2, this._boundingDimensions.z * c),
  111528. i[d].position.addInPlace(new Vector3(-this._boundingDimensions.x / 2,-this._boundingDimensions.y / 2,-this._boundingDimensions.z / 2)),
  111529. i[d].lookAt(Vector3.Cross(i[d].position.normalizeToNew(), Vector3.Up()).normalizeToNew().add(i[d].position))),
  111530. o == 2 && (i[d].position.set(this._boundingDimensions.x * s, this._boundingDimensions.y * c, this._boundingDimensions.z / 2),
  111531. i[d].position.addInPlace(new Vector3(-this._boundingDimensions.x / 2,-this._boundingDimensions.y / 2,-this._boundingDimensions.z / 2)),
  111532. i[d].lookAt(Vector3.Cross(i[d].position.normalizeToNew(), Vector3.Forward()).normalizeToNew().add(i[d].position))),
  111533. this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
  111534. i[d].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
  111535. var _ = this.rotationSphereSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
  111536. i[d].scaling.set(_, _, _)
  111537. } else
  111538. this.fixedDragMeshBoundsSize ? i[d].scaling.set(this.rotationSphereSize * this._boundingDimensions.x, this.rotationSphereSize * this._boundingDimensions.y, this.rotationSphereSize * this._boundingDimensions.z) : i[d].scaling.set(this.rotationSphereSize, this.rotationSphereSize, this.rotationSphereSize)
  111539. }
  111540. }
  111541. ,
  111542. e.prototype._updateScaleBoxes = function() {
  111543. for (var i = this._scaleBoxesParent.getChildMeshes(), o = 0, s = 0; s < 3; s++)
  111544. for (var c = 0; c < 3; c++)
  111545. for (var d = 0; d < 3; d++) {
  111546. var _ = (s === 1 ? 1 : 0) + (c === 1 ? 1 : 0) + (d === 1 ? 1 : 0);
  111547. if (!(_ === 1 || _ === 3)) {
  111548. if (i[o])
  111549. if (i[o].position.set(this._boundingDimensions.x * (s / 2), this._boundingDimensions.y * (c / 2), this._boundingDimensions.z * (d / 2)),
  111550. i[o].position.addInPlace(new Vector3(-this._boundingDimensions.x / 2,-this._boundingDimensions.y / 2,-this._boundingDimensions.z / 2)),
  111551. this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
  111552. i[o].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
  111553. var b = this.scaleBoxSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
  111554. i[o].scaling.set(b, b, b)
  111555. } else
  111556. this.fixedDragMeshBoundsSize ? i[o].scaling.set(this.scaleBoxSize * this._boundingDimensions.x, this.scaleBoxSize * this._boundingDimensions.y, this.scaleBoxSize * this._boundingDimensions.z) : i[o].scaling.set(this.scaleBoxSize, this.scaleBoxSize, this.scaleBoxSize);
  111557. o++
  111558. }
  111559. }
  111560. }
  111561. ,
  111562. e.prototype.setEnabledRotationAxis = function(i) {
  111563. this._rotateSpheresParent.getChildMeshes().forEach(function(o, s) {
  111564. s < 4 ? o.setEnabled(i.indexOf("x") != -1) : s < 8 ? o.setEnabled(i.indexOf("y") != -1) : o.setEnabled(i.indexOf("z") != -1)
  111565. })
  111566. }
  111567. ,
  111568. e.prototype.setEnabledScaling = function(i, o) {
  111569. o === void 0 && (o = !1),
  111570. this._scaleBoxesParent.getChildMeshes().forEach(function(s, c) {
  111571. var d = i;
  111572. o && s.metadata === !0 && (d = !1),
  111573. s.setEnabled(d)
  111574. })
  111575. }
  111576. ,
  111577. e.prototype._updateDummy = function() {
  111578. this._dragMesh && (this._dragMesh.position.copyFrom(this._lineBoundingBox.getAbsolutePosition()),
  111579. this._dragMesh.scaling.copyFrom(this._lineBoundingBox.scaling),
  111580. this._dragMesh.rotationQuaternion.copyFrom(this._rootMesh.rotationQuaternion))
  111581. }
  111582. ,
  111583. e.prototype.enableDragBehavior = function() {
  111584. this._dragMesh = CreateBox("dummy", {
  111585. size: 1
  111586. }, this.gizmoLayer.utilityLayerScene),
  111587. this._dragMesh.visibility = 0,
  111588. this._dragMesh.rotationQuaternion = new Quaternion,
  111589. this.pointerDragBehavior.useObjectOrientationForDragging = !1,
  111590. this._dragMesh.addBehavior(this.pointerDragBehavior)
  111591. }
  111592. ,
  111593. e.prototype.dispose = function() {
  111594. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),
  111595. this.gizmoLayer.originalScene.onBeforeRenderObservable.remove(this._renderObserver),
  111596. this._lineBoundingBox.dispose(),
  111597. this._rotateSpheresParent.dispose(),
  111598. this._scaleBoxesParent.dispose(),
  111599. this._dragMesh && this._dragMesh.dispose(),
  111600. a.prototype.dispose.call(this)
  111601. }
  111602. ,
  111603. e.MakeNotPickableAndWrapInBoundingBox = function(i) {
  111604. var o = function(b) {
  111605. b.isPickable = !1,
  111606. b.getChildMeshes().forEach(function(k) {
  111607. o(k)
  111608. })
  111609. };
  111610. o(i),
  111611. i.rotationQuaternion || (i.rotationQuaternion = Quaternion.RotationYawPitchRoll(i.rotation.y, i.rotation.x, i.rotation.z));
  111612. var s = i.position.clone()
  111613. , c = i.rotationQuaternion.clone();
  111614. i.rotationQuaternion.set(0, 0, 0, 1),
  111615. i.position.set(0, 0, 0);
  111616. var d = CreateBox("box", {
  111617. size: 1
  111618. }, i.getScene())
  111619. , _ = i.getHierarchyBoundingVectors();
  111620. return _.max.subtractToRef(_.min, d.scaling),
  111621. d.scaling.y === 0 && (d.scaling.y = Epsilon),
  111622. d.scaling.x === 0 && (d.scaling.x = Epsilon),
  111623. d.scaling.z === 0 && (d.scaling.z = Epsilon),
  111624. d.position.set((_.max.x + _.min.x) / 2, (_.max.y + _.min.y) / 2, (_.max.z + _.min.z) / 2),
  111625. i.addChild(d),
  111626. i.rotationQuaternion.copyFrom(c),
  111627. i.position.copyFrom(s),
  111628. i.removeChild(d),
  111629. d.addChild(i),
  111630. d.visibility = 0,
  111631. d
  111632. }
  111633. ,
  111634. e.prototype.setCustomMesh = function(i) {
  111635. Logger$2.Error("Custom meshes are not supported on this gizmo")
  111636. }
  111637. ,
  111638. e
  111639. }(Gizmo);
  111640. (function() {
  111641. function a(e, i, o, s) {
  111642. i === void 0 && (i = 1),
  111643. o === void 0 && (o = UtilityLayerRenderer.DefaultUtilityLayer),
  111644. s === void 0 && (s = UtilityLayerRenderer.DefaultKeepDepthUtilityLayer),
  111645. this.scene = e,
  111646. this.clearGizmoOnEmptyPointerEvent = !1,
  111647. this.onAttachedToMeshObservable = new Observable,
  111648. this.onAttachedToNodeObservable = new Observable,
  111649. this._gizmosEnabled = {
  111650. positionGizmo: !1,
  111651. rotationGizmo: !1,
  111652. scaleGizmo: !1,
  111653. boundingBoxGizmo: !1
  111654. },
  111655. this._pointerObservers = [],
  111656. this._attachedMesh = null,
  111657. this._attachedNode = null,
  111658. this._boundingBoxColor = Color3.FromHexString("#0984e3"),
  111659. this._thickness = 1,
  111660. this._scaleRatio = 1,
  111661. this._gizmoAxisCache = new Map,
  111662. this.boundingBoxDragBehavior = new SixDofDragBehavior,
  111663. this.attachableMeshes = null,
  111664. this.attachableNodes = null,
  111665. this.usePointerToAttachGizmos = !0,
  111666. this._defaultUtilityLayer = o,
  111667. this._defaultKeepDepthUtilityLayer = s,
  111668. this._defaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = !1,
  111669. this._thickness = i,
  111670. this.gizmos = {
  111671. positionGizmo: null,
  111672. rotationGizmo: null,
  111673. scaleGizmo: null,
  111674. boundingBoxGizmo: null
  111675. };
  111676. var c = this._attachToMeshPointerObserver(e)
  111677. , d = Gizmo.GizmoAxisPointerObserver(this._defaultUtilityLayer, this._gizmoAxisCache);
  111678. this._pointerObservers = [c, d]
  111679. }
  111680. return Object.defineProperty(a.prototype, "keepDepthUtilityLayer", {
  111681. get: function() {
  111682. return this._defaultKeepDepthUtilityLayer
  111683. },
  111684. enumerable: !1,
  111685. configurable: !0
  111686. }),
  111687. Object.defineProperty(a.prototype, "utilityLayer", {
  111688. get: function() {
  111689. return this._defaultUtilityLayer
  111690. },
  111691. enumerable: !1,
  111692. configurable: !0
  111693. }),
  111694. Object.defineProperty(a.prototype, "isHovered", {
  111695. get: function() {
  111696. var e = !1;
  111697. for (var i in this.gizmos) {
  111698. var o = this.gizmos[i];
  111699. if (o && o.isHovered) {
  111700. e = !0;
  111701. break
  111702. }
  111703. }
  111704. return e
  111705. },
  111706. enumerable: !1,
  111707. configurable: !0
  111708. }),
  111709. Object.defineProperty(a.prototype, "scaleRatio", {
  111710. get: function() {
  111711. return this._scaleRatio
  111712. },
  111713. set: function(e) {
  111714. this._scaleRatio = e,
  111715. [this.gizmos.positionGizmo, this.gizmos.rotationGizmo, this.gizmos.scaleGizmo].forEach(function(i) {
  111716. i && (i.scaleRatio = e)
  111717. })
  111718. },
  111719. enumerable: !1,
  111720. configurable: !0
  111721. }),
  111722. a.prototype._attachToMeshPointerObserver = function(e) {
  111723. var i = this
  111724. , o = e.onPointerObservable.add(function(s) {
  111725. if (!!i.usePointerToAttachGizmos && s.type == PointerEventTypes.POINTERDOWN)
  111726. if (s.pickInfo && s.pickInfo.pickedMesh) {
  111727. var c = s.pickInfo.pickedMesh;
  111728. if (i.attachableMeshes == null)
  111729. for (; c && c.parent != null; )
  111730. c = c.parent;
  111731. else {
  111732. var d = !1;
  111733. i.attachableMeshes.forEach(function(_) {
  111734. c && (c == _ || c.isDescendantOf(_)) && (c = _,
  111735. d = !0)
  111736. }),
  111737. d || (c = null)
  111738. }
  111739. c instanceof AbstractMesh ? i._attachedMesh != c && i.attachToMesh(c) : i.clearGizmoOnEmptyPointerEvent && i.attachToMesh(null)
  111740. } else
  111741. i.clearGizmoOnEmptyPointerEvent && i.attachToMesh(null)
  111742. });
  111743. return o
  111744. }
  111745. ,
  111746. a.prototype.attachToMesh = function(e) {
  111747. this._attachedMesh && this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior),
  111748. this._attachedNode && this._attachedNode.removeBehavior(this.boundingBoxDragBehavior),
  111749. this._attachedMesh = e,
  111750. this._attachedNode = null;
  111751. for (var i in this.gizmos) {
  111752. var o = this.gizmos[i];
  111753. o && this._gizmosEnabled[i] && (o.attachedMesh = e)
  111754. }
  111755. this.boundingBoxGizmoEnabled && this._attachedMesh && this._attachedMesh.addBehavior(this.boundingBoxDragBehavior),
  111756. this.onAttachedToMeshObservable.notifyObservers(e)
  111757. }
  111758. ,
  111759. a.prototype.attachToNode = function(e) {
  111760. this._attachedMesh && this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior),
  111761. this._attachedNode && this._attachedNode.removeBehavior(this.boundingBoxDragBehavior),
  111762. this._attachedMesh = null,
  111763. this._attachedNode = e;
  111764. for (var i in this.gizmos) {
  111765. var o = this.gizmos[i];
  111766. o && this._gizmosEnabled[i] && (o.attachedNode = e)
  111767. }
  111768. this.boundingBoxGizmoEnabled && this._attachedNode && this._attachedNode.addBehavior(this.boundingBoxDragBehavior),
  111769. this.onAttachedToNodeObservable.notifyObservers(e)
  111770. }
  111771. ,
  111772. Object.defineProperty(a.prototype, "positionGizmoEnabled", {
  111773. get: function() {
  111774. return this._gizmosEnabled.positionGizmo
  111775. },
  111776. set: function(e) {
  111777. e ? (this.gizmos.positionGizmo || (this.gizmos.positionGizmo = new PositionGizmo(this._defaultUtilityLayer,this._thickness,this)),
  111778. this._attachedNode ? this.gizmos.positionGizmo.attachedNode = this._attachedNode : this.gizmos.positionGizmo.attachedMesh = this._attachedMesh) : this.gizmos.positionGizmo && (this.gizmos.positionGizmo.attachedNode = null),
  111779. this._gizmosEnabled.positionGizmo = e
  111780. },
  111781. enumerable: !1,
  111782. configurable: !0
  111783. }),
  111784. Object.defineProperty(a.prototype, "rotationGizmoEnabled", {
  111785. get: function() {
  111786. return this._gizmosEnabled.rotationGizmo
  111787. },
  111788. set: function(e) {
  111789. e ? (this.gizmos.rotationGizmo || (this.gizmos.rotationGizmo = new RotationGizmo(this._defaultUtilityLayer,32,!1,this._thickness,this)),
  111790. this._attachedNode ? this.gizmos.rotationGizmo.attachedNode = this._attachedNode : this.gizmos.rotationGizmo.attachedMesh = this._attachedMesh) : this.gizmos.rotationGizmo && (this.gizmos.rotationGizmo.attachedNode = null),
  111791. this._gizmosEnabled.rotationGizmo = e
  111792. },
  111793. enumerable: !1,
  111794. configurable: !0
  111795. }),
  111796. Object.defineProperty(a.prototype, "scaleGizmoEnabled", {
  111797. get: function() {
  111798. return this._gizmosEnabled.scaleGizmo
  111799. },
  111800. set: function(e) {
  111801. e ? (this.gizmos.scaleGizmo = this.gizmos.scaleGizmo || new ScaleGizmo(this._defaultUtilityLayer,this._thickness,this),
  111802. this._attachedNode ? this.gizmos.scaleGizmo.attachedNode = this._attachedNode : this.gizmos.scaleGizmo.attachedMesh = this._attachedMesh) : this.gizmos.scaleGizmo && (this.gizmos.scaleGizmo.attachedNode = null),
  111803. this._gizmosEnabled.scaleGizmo = e
  111804. },
  111805. enumerable: !1,
  111806. configurable: !0
  111807. }),
  111808. Object.defineProperty(a.prototype, "boundingBoxGizmoEnabled", {
  111809. get: function() {
  111810. return this._gizmosEnabled.boundingBoxGizmo
  111811. },
  111812. set: function(e) {
  111813. e ? (this.gizmos.boundingBoxGizmo = this.gizmos.boundingBoxGizmo || new BoundingBoxGizmo(this._boundingBoxColor,this._defaultKeepDepthUtilityLayer),
  111814. this._attachedMesh ? this.gizmos.boundingBoxGizmo.attachedMesh = this._attachedMesh : this.gizmos.boundingBoxGizmo.attachedNode = this._attachedNode,
  111815. this._attachedMesh ? (this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior),
  111816. this._attachedMesh.addBehavior(this.boundingBoxDragBehavior)) : this._attachedNode && (this._attachedNode.removeBehavior(this.boundingBoxDragBehavior),
  111817. this._attachedNode.addBehavior(this.boundingBoxDragBehavior))) : this.gizmos.boundingBoxGizmo && (this._attachedMesh ? this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior) : this._attachedNode && this._attachedNode.removeBehavior(this.boundingBoxDragBehavior),
  111818. this.gizmos.boundingBoxGizmo.attachedNode = null),
  111819. this._gizmosEnabled.boundingBoxGizmo = e
  111820. },
  111821. enumerable: !1,
  111822. configurable: !0
  111823. }),
  111824. a.prototype.addToAxisCache = function(e) {
  111825. var i = this;
  111826. e.size > 0 && e.forEach(function(o, s) {
  111827. i._gizmoAxisCache.set(s, o)
  111828. })
  111829. }
  111830. ,
  111831. a.prototype.dispose = function() {
  111832. var e = this, i, o;
  111833. this._pointerObservers.forEach(function(d) {
  111834. e.scene.onPointerObservable.remove(d)
  111835. });
  111836. for (var s in this.gizmos) {
  111837. var c = this.gizmos[s];
  111838. c && c.dispose()
  111839. }
  111840. this._defaultKeepDepthUtilityLayer !== UtilityLayerRenderer._DefaultKeepDepthUtilityLayer && ((i = this._defaultKeepDepthUtilityLayer) === null || i === void 0 || i.dispose()),
  111841. this._defaultUtilityLayer !== UtilityLayerRenderer._DefaultUtilityLayer && ((o = this._defaultUtilityLayer) === null || o === void 0 || o.dispose()),
  111842. this.boundingBoxDragBehavior.detach(),
  111843. this.onAttachedToMeshObservable.clear()
  111844. }
  111845. ,
  111846. a
  111847. }
  111848. )();
  111849. var LayerSceneComponent = function() {
  111850. function a(e) {
  111851. this.name = SceneComponentConstants.NAME_LAYER,
  111852. this.scene = e,
  111853. this._engine = e.getEngine(),
  111854. e.layers = new Array
  111855. }
  111856. return a.prototype.register = function() {
  111857. this.scene._beforeCameraDrawStage.registerStep(SceneComponentConstants.STEP_BEFORECAMERADRAW_LAYER, this, this._drawCameraBackground),
  111858. this.scene._afterCameraDrawStage.registerStep(SceneComponentConstants.STEP_AFTERCAMERADRAW_LAYER, this, this._drawCameraForeground),
  111859. this.scene._beforeRenderTargetDrawStage.registerStep(SceneComponentConstants.STEP_BEFORERENDERTARGETDRAW_LAYER, this, this._drawRenderTargetBackground),
  111860. this.scene._afterRenderTargetDrawStage.registerStep(SceneComponentConstants.STEP_AFTERRENDERTARGETDRAW_LAYER, this, this._drawRenderTargetForeground)
  111861. }
  111862. ,
  111863. a.prototype.rebuild = function() {
  111864. for (var e = this.scene.layers, i = 0, o = e; i < o.length; i++) {
  111865. var s = o[i];
  111866. s._rebuild()
  111867. }
  111868. }
  111869. ,
  111870. a.prototype.dispose = function() {
  111871. for (var e = this.scene.layers; e.length; )
  111872. e[0].dispose()
  111873. }
  111874. ,
  111875. a.prototype._draw = function(e) {
  111876. var i = this.scene.layers;
  111877. if (i.length) {
  111878. this._engine.setDepthBuffer(!1);
  111879. for (var o = 0, s = i; o < s.length; o++) {
  111880. var c = s[o];
  111881. e(c) && c.render()
  111882. }
  111883. this._engine.setDepthBuffer(!0)
  111884. }
  111885. }
  111886. ,
  111887. a.prototype._drawCameraPredicate = function(e, i, o) {
  111888. return !e.renderOnlyInRenderTargetTextures && e.isBackground === i && (e.layerMask & o) !== 0
  111889. }
  111890. ,
  111891. a.prototype._drawCameraBackground = function(e) {
  111892. var i = this;
  111893. this._draw(function(o) {
  111894. return i._drawCameraPredicate(o, !0, e.layerMask)
  111895. })
  111896. }
  111897. ,
  111898. a.prototype._drawCameraForeground = function(e) {
  111899. var i = this;
  111900. this._draw(function(o) {
  111901. return i._drawCameraPredicate(o, !1, e.layerMask)
  111902. })
  111903. }
  111904. ,
  111905. a.prototype._drawRenderTargetPredicate = function(e, i, o, s) {
  111906. return e.renderTargetTextures.length > 0 && e.isBackground === i && e.renderTargetTextures.indexOf(s) > -1 && (e.layerMask & o) !== 0
  111907. }
  111908. ,
  111909. a.prototype._drawRenderTargetBackground = function(e) {
  111910. var i = this;
  111911. this._draw(function(o) {
  111912. return i._drawRenderTargetPredicate(o, !0, i.scene.activeCamera.layerMask, e)
  111913. })
  111914. }
  111915. ,
  111916. a.prototype._drawRenderTargetForeground = function(e) {
  111917. var i = this;
  111918. this._draw(function(o) {
  111919. return i._drawRenderTargetPredicate(o, !1, i.scene.activeCamera.layerMask, e)
  111920. })
  111921. }
  111922. ,
  111923. a.prototype.addFromContainer = function(e) {
  111924. var i = this;
  111925. !e.layers || e.layers.forEach(function(o) {
  111926. i.scene.layers.push(o)
  111927. })
  111928. }
  111929. ,
  111930. a.prototype.removeFromContainer = function(e, i) {
  111931. var o = this;
  111932. i === void 0 && (i = !1),
  111933. e.layers && e.layers.forEach(function(s) {
  111934. var c = o.scene.layers.indexOf(s);
  111935. c !== -1 && o.scene.layers.splice(c, 1),
  111936. i && s.dispose()
  111937. })
  111938. }
  111939. ,
  111940. a
  111941. }()
  111942. , name$j = "layerPixelShader"
  111943. , shader$j = `
  111944. varying vec2 vUV;
  111945. uniform sampler2D textureSampler;
  111946. uniform vec4 color;
  111947. #include<helperFunctions>
  111948. void main(void) {
  111949. vec4 baseColor=texture2D(textureSampler,vUV);
  111950. #ifdef LINEAR
  111951. baseColor.rgb=toGammaSpace(baseColor.rgb);
  111952. #endif
  111953. #ifdef ALPHATEST
  111954. if (baseColor.a<0.4)
  111955. discard;
  111956. #endif
  111957. gl_FragColor=baseColor*color;
  111958. }`;
  111959. ShaderStore.ShadersStore[name$j] = shader$j;
  111960. var name$i = "layerVertexShader"
  111961. , shader$i = `
  111962. attribute vec2 position;
  111963. uniform vec2 scale;
  111964. uniform vec2 offset;
  111965. uniform mat4 textureMatrix;
  111966. varying vec2 vUV;
  111967. const vec2 madd=vec2(0.5,0.5);
  111968. void main(void) {
  111969. vec2 shiftedPosition=position*scale+offset;
  111970. vUV=vec2(textureMatrix*vec4(shiftedPosition*madd+madd,1.0,0.0));
  111971. gl_Position=vec4(shiftedPosition,0.0,1.0);
  111972. }`;
  111973. ShaderStore.ShadersStore[name$i] = shader$i;
  111974. var Layer = function() {
  111975. function a(e, i, o, s, c) {
  111976. this.name = e,
  111977. this.scale = new Vector2(1,1),
  111978. this.offset = new Vector2(0,0),
  111979. this.alphaBlendingMode = 2,
  111980. this.layerMask = 268435455,
  111981. this.renderTargetTextures = [],
  111982. this.renderOnlyInRenderTargetTextures = !1,
  111983. this.isEnabled = !0,
  111984. this._vertexBuffers = {},
  111985. this.onDisposeObservable = new Observable,
  111986. this.onBeforeRenderObservable = new Observable,
  111987. this.onAfterRenderObservable = new Observable,
  111988. this.texture = i ? new Texture(i,o,!0) : null,
  111989. this.isBackground = s === void 0 ? !0 : s,
  111990. this.color = c === void 0 ? new Color4(1,1,1,1) : c,
  111991. this._scene = o || EngineStore.LastCreatedScene;
  111992. var d = this._scene._getComponent(SceneComponentConstants.NAME_LAYER);
  111993. d || (d = new LayerSceneComponent(this._scene),
  111994. this._scene._addComponent(d)),
  111995. this._scene.layers.push(this);
  111996. var _ = this._scene.getEngine();
  111997. this._drawWrapper = new DrawWrapper(_);
  111998. var b = [];
  111999. b.push(1, 1),
  112000. b.push(-1, 1),
  112001. b.push(-1, -1),
  112002. b.push(1, -1);
  112003. var k = new VertexBuffer(_,b,VertexBuffer.PositionKind,!1,!1,2);
  112004. this._vertexBuffers[VertexBuffer.PositionKind] = k,
  112005. this._createIndexBuffer()
  112006. }
  112007. return Object.defineProperty(a.prototype, "onDispose", {
  112008. set: function(e) {
  112009. this._onDisposeObserver && this.onDisposeObservable.remove(this._onDisposeObserver),
  112010. this._onDisposeObserver = this.onDisposeObservable.add(e)
  112011. },
  112012. enumerable: !1,
  112013. configurable: !0
  112014. }),
  112015. Object.defineProperty(a.prototype, "onBeforeRender", {
  112016. set: function(e) {
  112017. this._onBeforeRenderObserver && this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),
  112018. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(e)
  112019. },
  112020. enumerable: !1,
  112021. configurable: !0
  112022. }),
  112023. Object.defineProperty(a.prototype, "onAfterRender", {
  112024. set: function(e) {
  112025. this._onAfterRenderObserver && this.onAfterRenderObservable.remove(this._onAfterRenderObserver),
  112026. this._onAfterRenderObserver = this.onAfterRenderObservable.add(e)
  112027. },
  112028. enumerable: !1,
  112029. configurable: !0
  112030. }),
  112031. a.prototype._createIndexBuffer = function() {
  112032. var e = this._scene.getEngine()
  112033. , i = [];
  112034. i.push(0),
  112035. i.push(1),
  112036. i.push(2),
  112037. i.push(0),
  112038. i.push(2),
  112039. i.push(3),
  112040. this._indexBuffer = e.createIndexBuffer(i)
  112041. }
  112042. ,
  112043. a.prototype._rebuild = function() {
  112044. var e = this._vertexBuffers[VertexBuffer.PositionKind];
  112045. e && e._rebuild(),
  112046. this._createIndexBuffer()
  112047. }
  112048. ,
  112049. a.prototype.render = function() {
  112050. if (!!this.isEnabled) {
  112051. var o = this._scene.getEngine()
  112052. , e = "";
  112053. this.alphaTest && (e = "#define ALPHATEST"),
  112054. this.texture && !this.texture.gammaSpace && (e += `\r
  112055. #define LINEAR`),
  112056. this._previousDefines !== e && (this._previousDefines = e,
  112057. this._drawWrapper.effect = o.createEffect("layer", [VertexBuffer.PositionKind], ["textureMatrix", "color", "scale", "offset"], ["textureSampler"], e));
  112058. var i = this._drawWrapper.effect;
  112059. if (!(!i || !i.isReady() || !this.texture || !this.texture.isReady())) {
  112060. var o = this._scene.getEngine();
  112061. this.onBeforeRenderObservable.notifyObservers(this),
  112062. o.enableEffect(this._drawWrapper),
  112063. o.setState(!1),
  112064. i.setTexture("textureSampler", this.texture),
  112065. i.setMatrix("textureMatrix", this.texture.getTextureMatrix()),
  112066. i.setFloat4("color", this.color.r, this.color.g, this.color.b, this.color.a),
  112067. i.setVector2("offset", this.offset),
  112068. i.setVector2("scale", this.scale),
  112069. o.bindBuffers(this._vertexBuffers, this._indexBuffer, i),
  112070. this.alphaTest ? o.drawElementsType(Material.TriangleFillMode, 0, 6) : (o.setAlphaMode(this.alphaBlendingMode),
  112071. o.drawElementsType(Material.TriangleFillMode, 0, 6),
  112072. o.setAlphaMode(0)),
  112073. this.onAfterRenderObservable.notifyObservers(this)
  112074. }
  112075. }
  112076. }
  112077. ,
  112078. a.prototype.dispose = function() {
  112079. var e = this._vertexBuffers[VertexBuffer.PositionKind];
  112080. e && (e.dispose(),
  112081. this._vertexBuffers[VertexBuffer.PositionKind] = null),
  112082. this._indexBuffer && (this._scene.getEngine()._releaseBuffer(this._indexBuffer),
  112083. this._indexBuffer = null),
  112084. this.texture && (this.texture.dispose(),
  112085. this.texture = null),
  112086. this.renderTargetTextures = [];
  112087. var i = this._scene.layers.indexOf(this);
  112088. this._scene.layers.splice(i, 1),
  112089. this.onDisposeObservable.notifyObservers(this),
  112090. this.onDisposeObservable.clear(),
  112091. this.onAfterRenderObservable.clear(),
  112092. this.onBeforeRenderObservable.clear()
  112093. }
  112094. ,
  112095. a
  112096. }()
  112097. , name$h = "boundingBoxRendererFragmentDeclaration"
  112098. , shader$h = `uniform vec4 color;
  112099. `;
  112100. ShaderStore.IncludesShadersStore[name$h] = shader$h;
  112101. var name$g = "boundingBoxRendererUboDeclaration"
  112102. , shader$g = `layout(std140,column_major) uniform;
  112103. uniform BoundingBoxRenderer {
  112104. vec4 color;
  112105. mat4 world;
  112106. mat4 viewProjection;
  112107. mat4 viewProjectionR;
  112108. };
  112109. `;
  112110. ShaderStore.IncludesShadersStore[name$g] = shader$g;
  112111. var name$f = "boundingBoxRendererPixelShader"
  112112. , shader$f = `#include<__decl__boundingBoxRendererFragment>
  112113. void main(void) {
  112114. gl_FragColor=color;
  112115. }`;
  112116. ShaderStore.ShadersStore[name$f] = shader$f;
  112117. var name$e = "boundingBoxRendererVertexDeclaration"
  112118. , shader$e = `uniform mat4 world;
  112119. uniform mat4 viewProjection;
  112120. #ifdef MULTIVIEW
  112121. uniform mat4 viewProjectionR;
  112122. #endif
  112123. `;
  112124. ShaderStore.IncludesShadersStore[name$e] = shader$e;
  112125. var name$d = "boundingBoxRendererVertexShader"
  112126. , shader$d = `
  112127. attribute vec3 position;
  112128. #include<__decl__boundingBoxRendererVertex>
  112129. void main(void) {
  112130. vec4 worldPos=world*vec4(position,1.0);
  112131. #ifdef MULTIVIEW
  112132. if (gl_ViewID_OVR == 0u) {
  112133. gl_Position=viewProjection*worldPos;
  112134. } else {
  112135. gl_Position=viewProjectionR*worldPos;
  112136. }
  112137. #else
  112138. gl_Position=viewProjection*worldPos;
  112139. #endif
  112140. }
  112141. `;
  112142. ShaderStore.ShadersStore[name$d] = shader$d;
  112143. Object.defineProperty(Scene.prototype, "forceShowBoundingBoxes", {
  112144. get: function() {
  112145. return this._forceShowBoundingBoxes || !1
  112146. },
  112147. set: function(a) {
  112148. this._forceShowBoundingBoxes = a,
  112149. a && this.getBoundingBoxRenderer()
  112150. },
  112151. enumerable: !0,
  112152. configurable: !0
  112153. });
  112154. Scene.prototype.getBoundingBoxRenderer = function() {
  112155. return this._boundingBoxRenderer || (this._boundingBoxRenderer = new BoundingBoxRenderer(this)),
  112156. this._boundingBoxRenderer
  112157. }
  112158. ;
  112159. Object.defineProperty(AbstractMesh.prototype, "showBoundingBox", {
  112160. get: function() {
  112161. return this._showBoundingBox || !1
  112162. },
  112163. set: function(a) {
  112164. this._showBoundingBox = a,
  112165. a && this.getScene().getBoundingBoxRenderer()
  112166. },
  112167. enumerable: !0,
  112168. configurable: !0
  112169. });
  112170. var BoundingBoxRenderer = function() {
  112171. function a(e) {
  112172. this.name = SceneComponentConstants.NAME_BOUNDINGBOXRENDERER,
  112173. this.frontColor = new Color3(1,1,1),
  112174. this.backColor = new Color3(.1,.1,.1),
  112175. this.showBackLines = !0,
  112176. this.onBeforeBoxRenderingObservable = new Observable,
  112177. this.onAfterBoxRenderingObservable = new Observable,
  112178. this.onResourcesReadyObservable = new Observable,
  112179. this.enabled = !0,
  112180. this.renderList = new SmartArray(32),
  112181. this._vertexBuffers = {},
  112182. this._fillIndexBuffer = null,
  112183. this._fillIndexData = null,
  112184. this.scene = e,
  112185. e._addComponent(this),
  112186. this._uniformBufferFront = new UniformBuffer(this.scene.getEngine(),void 0,void 0,"BoundingBoxRendererFront"),
  112187. this._buildUniformLayout(this._uniformBufferFront),
  112188. this._uniformBufferBack = new UniformBuffer(this.scene.getEngine(),void 0,void 0,"BoundingBoxRendererBack"),
  112189. this._buildUniformLayout(this._uniformBufferBack)
  112190. }
  112191. return a.prototype._buildUniformLayout = function(e) {
  112192. e.addUniform("color", 4),
  112193. e.addUniform("world", 16),
  112194. e.addUniform("viewProjection", 16),
  112195. e.addUniform("viewProjectionR", 16),
  112196. e.create()
  112197. }
  112198. ,
  112199. a.prototype.register = function() {
  112200. this.scene._beforeEvaluateActiveMeshStage.registerStep(SceneComponentConstants.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER, this, this.reset),
  112201. this.scene._preActiveMeshStage.registerStep(SceneComponentConstants.STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER, this, this._preActiveMesh),
  112202. this.scene._evaluateSubMeshStage.registerStep(SceneComponentConstants.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER, this, this._evaluateSubMesh),
  112203. this.scene._afterRenderingGroupDrawStage.registerStep(SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER, this, this.render)
  112204. }
  112205. ,
  112206. a.prototype._evaluateSubMesh = function(e, i) {
  112207. if (e.showSubMeshesBoundingBox) {
  112208. var o = i.getBoundingInfo();
  112209. o != null && (o.boundingBox._tag = e.renderingGroupId,
  112210. this.renderList.push(o.boundingBox))
  112211. }
  112212. }
  112213. ,
  112214. a.prototype._preActiveMesh = function(e) {
  112215. if (e.showBoundingBox || this.scene.forceShowBoundingBoxes) {
  112216. var i = e.getBoundingInfo();
  112217. i.boundingBox._tag = e.renderingGroupId,
  112218. this.renderList.push(i.boundingBox)
  112219. }
  112220. }
  112221. ,
  112222. a.prototype._prepareResources = function() {
  112223. if (!this._colorShader) {
  112224. this._colorShader = new ShaderMaterial("colorShader",this.scene,"boundingBoxRenderer",{
  112225. attributes: [VertexBuffer.PositionKind],
  112226. uniforms: ["world", "viewProjection", "color"],
  112227. uniformBuffers: ["BoundingBoxRenderer"]
  112228. },!1),
  112229. this._colorShader.reservedDataStore = {
  112230. hidden: !0
  112231. },
  112232. this._colorShaderForOcclusionQuery = new ShaderMaterial("colorShaderOccQuery",this.scene,"boundingBoxRenderer",{
  112233. attributes: [VertexBuffer.PositionKind],
  112234. uniforms: ["world", "viewProjection", "color"],
  112235. uniformBuffers: ["BoundingBoxRenderer"]
  112236. },!0),
  112237. this._colorShaderForOcclusionQuery.reservedDataStore = {
  112238. hidden: !0
  112239. };
  112240. var e = this.scene.getEngine()
  112241. , i = CreateBoxVertexData({
  112242. size: 1
  112243. });
  112244. this._vertexBuffers[VertexBuffer.PositionKind] = new VertexBuffer(e,i.positions,VertexBuffer.PositionKind,!1),
  112245. this._createIndexBuffer(),
  112246. this._fillIndexData = i.indices,
  112247. this.onResourcesReadyObservable.notifyObservers(this)
  112248. }
  112249. }
  112250. ,
  112251. a.prototype._createIndexBuffer = function() {
  112252. var e = this.scene.getEngine();
  112253. this._indexBuffer = e.createIndexBuffer([0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 7, 1, 6, 2, 5, 3, 4])
  112254. }
  112255. ,
  112256. a.prototype.rebuild = function() {
  112257. var e = this._vertexBuffers[VertexBuffer.PositionKind];
  112258. e && e._rebuild(),
  112259. this._createIndexBuffer()
  112260. }
  112261. ,
  112262. a.prototype.reset = function() {
  112263. this.renderList.reset()
  112264. }
  112265. ,
  112266. a.prototype.render = function(e) {
  112267. var i, o;
  112268. if (!(this.renderList.length === 0 || !this.enabled) && (this._prepareResources(),
  112269. !!this._colorShader.isReady())) {
  112270. var s = this.scene.getEngine();
  112271. s.setDepthWrite(!1);
  112272. for (var c = this.frontColor.toColor4(), d = this.backColor.toColor4(), _ = this.scene.getTransformMatrix(), b = 0; b < this.renderList.length; b++) {
  112273. var k = this.renderList.data[b];
  112274. if (k._tag === e) {
  112275. this._createWrappersForBoundingBox(k),
  112276. this.onBeforeBoxRenderingObservable.notifyObservers(k);
  112277. var j = k.minimum
  112278. , $ = k.maximum
  112279. , _e = $.subtract(j)
  112280. , et = j.add(_e.scale(.5))
  112281. , tt = Matrix.Scaling(_e.x, _e.y, _e.z).multiply(Matrix.Translation(et.x, et.y, et.z)).multiply(k.getWorldMatrix())
  112282. , rt = s.useReverseDepthBuffer;
  112283. if (this.showBackLines) {
  112284. var it = (i = k._drawWrapperBack) !== null && i !== void 0 ? i : this._colorShader._getDrawWrapper();
  112285. this._colorShader._preBind(it),
  112286. s.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect()),
  112287. rt ? s.setDepthFunctionToLessOrEqual() : s.setDepthFunctionToGreaterOrEqual(),
  112288. this._uniformBufferBack.bindToEffect(it.effect, "BoundingBoxRenderer"),
  112289. this._uniformBufferBack.updateDirectColor4("color", d),
  112290. this._uniformBufferBack.updateMatrix("world", tt),
  112291. this._uniformBufferBack.updateMatrix("viewProjection", _),
  112292. this._uniformBufferBack.update(),
  112293. s.drawElementsType(Material.LineListDrawMode, 0, 24)
  112294. }
  112295. var nt = (o = k._drawWrapperFront) !== null && o !== void 0 ? o : this._colorShader._getDrawWrapper();
  112296. this._colorShader._preBind(nt),
  112297. s.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect()),
  112298. rt ? s.setDepthFunctionToGreater() : s.setDepthFunctionToLess(),
  112299. this._uniformBufferFront.bindToEffect(nt.effect, "BoundingBoxRenderer"),
  112300. this._uniformBufferFront.updateDirectColor4("color", c),
  112301. this._uniformBufferFront.updateMatrix("world", tt),
  112302. this._uniformBufferFront.updateMatrix("viewProjection", _),
  112303. this._uniformBufferFront.update(),
  112304. s.drawElementsType(Material.LineListDrawMode, 0, 24),
  112305. this.onAfterBoxRenderingObservable.notifyObservers(k)
  112306. }
  112307. }
  112308. this._colorShader.unbind(),
  112309. s.setDepthFunctionToLessOrEqual(),
  112310. s.setDepthWrite(!0)
  112311. }
  112312. }
  112313. ,
  112314. a.prototype._createWrappersForBoundingBox = function(e) {
  112315. if (!e._drawWrapperFront) {
  112316. var i = this.scene.getEngine();
  112317. e._drawWrapperFront = new DrawWrapper(i),
  112318. e._drawWrapperBack = new DrawWrapper(i),
  112319. e._drawWrapperFront.setEffect(this._colorShader.getEffect()),
  112320. e._drawWrapperBack.setEffect(this._colorShader.getEffect())
  112321. }
  112322. }
  112323. ,
  112324. a.prototype.renderOcclusionBoundingBox = function(e) {
  112325. var i = this.scene.getEngine();
  112326. this._renderPassIdForOcclusionQuery === void 0 && (this._renderPassIdForOcclusionQuery = i.createRenderPassId("Render pass for occlusion query"));
  112327. var o = i.currentRenderPassId;
  112328. i.currentRenderPassId = this._renderPassIdForOcclusionQuery,
  112329. this._prepareResources();
  112330. var s = e.subMeshes[0];
  112331. if (!this._colorShaderForOcclusionQuery.isReady(e, void 0, s) || !e.hasBoundingInfo) {
  112332. i.currentRenderPassId = o;
  112333. return
  112334. }
  112335. this._fillIndexBuffer || (this._fillIndexBuffer = i.createIndexBuffer(this._fillIndexData));
  112336. var c = i.useReverseDepthBuffer;
  112337. i.setDepthWrite(!1),
  112338. i.setColorWrite(!1);
  112339. var d = e.getBoundingInfo().boundingBox
  112340. , _ = d.minimum
  112341. , b = d.maximum
  112342. , k = b.subtract(_)
  112343. , j = _.add(k.scale(.5))
  112344. , $ = Matrix.Scaling(k.x, k.y, k.z).multiply(Matrix.Translation(j.x, j.y, j.z)).multiply(d.getWorldMatrix())
  112345. , _e = s._drawWrapper;
  112346. this._colorShaderForOcclusionQuery._preBind(_e),
  112347. i.bindBuffers(this._vertexBuffers, this._fillIndexBuffer, _e.effect),
  112348. c ? i.setDepthFunctionToGreater() : i.setDepthFunctionToLess(),
  112349. this.scene.resetCachedMaterial(),
  112350. this._uniformBufferFront.bindToEffect(_e.effect, "BoundingBoxRenderer"),
  112351. this._uniformBufferFront.updateMatrix("world", $),
  112352. this._uniformBufferFront.updateMatrix("viewProjection", this.scene.getTransformMatrix()),
  112353. this._uniformBufferFront.update(),
  112354. i.drawElementsType(Material.TriangleFillMode, 0, 36),
  112355. this._colorShaderForOcclusionQuery.unbind(),
  112356. i.setDepthFunctionToLessOrEqual(),
  112357. i.setDepthWrite(!0),
  112358. i.setColorWrite(!0),
  112359. i.currentRenderPassId = o
  112360. }
  112361. ,
  112362. a.prototype.dispose = function() {
  112363. if (this._renderPassIdForOcclusionQuery !== void 0 && (this.scene.getEngine().releaseRenderPassId(this._renderPassIdForOcclusionQuery),
  112364. this._renderPassIdForOcclusionQuery = void 0),
  112365. !!this._colorShader) {
  112366. this.onBeforeBoxRenderingObservable.clear(),
  112367. this.onAfterBoxRenderingObservable.clear(),
  112368. this.onResourcesReadyObservable.clear(),
  112369. this.renderList.dispose(),
  112370. this._colorShader.dispose(),
  112371. this._colorShaderForOcclusionQuery.dispose(),
  112372. this._uniformBufferFront.dispose(),
  112373. this._uniformBufferBack.dispose();
  112374. var e = this._vertexBuffers[VertexBuffer.PositionKind];
  112375. e && (e.dispose(),
  112376. this._vertexBuffers[VertexBuffer.PositionKind] = null),
  112377. this.scene.getEngine()._releaseBuffer(this._indexBuffer),
  112378. this._fillIndexBuffer && (this.scene.getEngine()._releaseBuffer(this._fillIndexBuffer),
  112379. this._fillIndexBuffer = null)
  112380. }
  112381. }
  112382. ,
  112383. a
  112384. }()
  112385. , DataReader = function() {
  112386. function a(e) {
  112387. this.byteOffset = 0,
  112388. this.buffer = e
  112389. }
  112390. return a.prototype.loadAsync = function(e) {
  112391. var i = this;
  112392. return this.buffer.readAsync(this.byteOffset, e).then(function(o) {
  112393. i._dataView = new DataView(o.buffer,o.byteOffset,o.byteLength),
  112394. i._dataByteOffset = 0
  112395. })
  112396. }
  112397. ,
  112398. a.prototype.readUint32 = function() {
  112399. var e = this._dataView.getUint32(this._dataByteOffset, !0);
  112400. return this._dataByteOffset += 4,
  112401. this.byteOffset += 4,
  112402. e
  112403. }
  112404. ,
  112405. a.prototype.readUint8Array = function(e) {
  112406. var i = new Uint8Array(this._dataView.buffer,this._dataView.byteOffset + this._dataByteOffset,e);
  112407. return this._dataByteOffset += e,
  112408. this.byteOffset += e,
  112409. i
  112410. }
  112411. ,
  112412. a.prototype.readString = function(e) {
  112413. return Decode(this.readUint8Array(e))
  112414. }
  112415. ,
  112416. a.prototype.skipBytes = function(e) {
  112417. this._dataByteOffset += e,
  112418. this.byteOffset += e
  112419. }
  112420. ,
  112421. a
  112422. }();
  112423. function validateAsync(a, e, i, o) {
  112424. var s = {
  112425. externalResourceFunction: function(c) {
  112426. return o(c).then(function(d) {
  112427. return new Uint8Array(d)
  112428. })
  112429. }
  112430. };
  112431. return i && (s.uri = e === "file:" ? i : e + i),
  112432. a instanceof ArrayBuffer ? GLTFValidator.validateBytes(new Uint8Array(a), s) : GLTFValidator.validateString(a, s)
  112433. }
  112434. function workerFunc$1() {
  112435. var a = [];
  112436. onmessage = function(e) {
  112437. var i = e.data;
  112438. switch (i.id) {
  112439. case "init":
  112440. {
  112441. importScripts(i.url);
  112442. break
  112443. }
  112444. case "validate":
  112445. {
  112446. validateAsync(i.data, i.rootUrl, i.fileName, function(o) {
  112447. return new Promise(function(s, c) {
  112448. var d = a.length;
  112449. a.push({
  112450. resolve: s,
  112451. reject: c
  112452. }),
  112453. postMessage({
  112454. id: "getExternalResource",
  112455. index: d,
  112456. uri: o
  112457. })
  112458. }
  112459. )
  112460. }).then(function(o) {
  112461. postMessage({
  112462. id: "validate.resolve",
  112463. value: o
  112464. })
  112465. }, function(o) {
  112466. postMessage({
  112467. id: "validate.reject",
  112468. reason: o
  112469. })
  112470. });
  112471. break
  112472. }
  112473. case "getExternalResource.resolve":
  112474. {
  112475. a[i.index].resolve(i.value);
  112476. break
  112477. }
  112478. case "getExternalResource.reject":
  112479. {
  112480. a[i.index].reject(i.reason);
  112481. break
  112482. }
  112483. }
  112484. }
  112485. }
  112486. var GLTFValidation = function() {
  112487. function a() {}
  112488. return a.ValidateAsync = function(e, i, o, s) {
  112489. var c = this;
  112490. return typeof Worker == "function" ? new Promise(function(d, _) {
  112491. var b = validateAsync + "(" + workerFunc$1 + ")()"
  112492. , k = URL.createObjectURL(new Blob([b],{
  112493. type: "application/javascript"
  112494. }))
  112495. , j = new Worker(k)
  112496. , $ = function(et) {
  112497. j.removeEventListener("error", $),
  112498. j.removeEventListener("message", _e),
  112499. _(et)
  112500. }
  112501. , _e = function(et) {
  112502. var tt = et.data;
  112503. switch (tt.id) {
  112504. case "getExternalResource":
  112505. {
  112506. s(tt.uri).then(function(rt) {
  112507. j.postMessage({
  112508. id: "getExternalResource.resolve",
  112509. index: tt.index,
  112510. value: rt
  112511. }, [rt])
  112512. }, function(rt) {
  112513. j.postMessage({
  112514. id: "getExternalResource.reject",
  112515. index: tt.index,
  112516. reason: rt
  112517. })
  112518. });
  112519. break
  112520. }
  112521. case "validate.resolve":
  112522. {
  112523. j.removeEventListener("error", $),
  112524. j.removeEventListener("message", _e),
  112525. d(tt.value);
  112526. break
  112527. }
  112528. case "validate.reject":
  112529. j.removeEventListener("error", $),
  112530. j.removeEventListener("message", _e),
  112531. _(tt.reason)
  112532. }
  112533. };
  112534. j.addEventListener("error", $),
  112535. j.addEventListener("message", _e),
  112536. j.postMessage({
  112537. id: "init",
  112538. url: c.Configuration.url
  112539. }),
  112540. j.postMessage({
  112541. id: "validate",
  112542. data: e,
  112543. rootUrl: i,
  112544. fileName: o
  112545. })
  112546. }
  112547. ) : (this._LoadScriptPromise || (this._LoadScriptPromise = Tools.LoadScriptAsync(this.Configuration.url)),
  112548. this._LoadScriptPromise.then(function() {
  112549. return validateAsync(e, i, o, s)
  112550. }))
  112551. }
  112552. ,
  112553. a.Configuration = {
  112554. url: "https://preview.babylonjs.com/gltf_validator.js"
  112555. },
  112556. a
  112557. }();
  112558. function readAsync(a, e, i) {
  112559. try {
  112560. return Promise.resolve(new Uint8Array(a,e,i))
  112561. } catch (o) {
  112562. return Promise.reject(o)
  112563. }
  112564. }
  112565. var GLTFLoaderCoordinateSystemMode;
  112566. (function(a) {
  112567. a[a.AUTO = 0] = "AUTO",
  112568. a[a.FORCE_RIGHT_HANDED = 1] = "FORCE_RIGHT_HANDED"
  112569. }
  112570. )(GLTFLoaderCoordinateSystemMode || (GLTFLoaderCoordinateSystemMode = {}));
  112571. var GLTFLoaderAnimationStartMode;
  112572. (function(a) {
  112573. a[a.NONE = 0] = "NONE",
  112574. a[a.FIRST = 1] = "FIRST",
  112575. a[a.ALL = 2] = "ALL"
  112576. }
  112577. )(GLTFLoaderAnimationStartMode || (GLTFLoaderAnimationStartMode = {}));
  112578. var GLTFLoaderState;
  112579. (function(a) {
  112580. a[a.LOADING = 0] = "LOADING",
  112581. a[a.READY = 1] = "READY",
  112582. a[a.COMPLETE = 2] = "COMPLETE"
  112583. }
  112584. )(GLTFLoaderState || (GLTFLoaderState = {}));
  112585. var GLTFFileLoader = function() {
  112586. function a() {
  112587. this.onParsedObservable = new Observable,
  112588. this.coordinateSystemMode = GLTFLoaderCoordinateSystemMode.AUTO,
  112589. this.animationStartMode = GLTFLoaderAnimationStartMode.FIRST,
  112590. this.compileMaterials = !1,
  112591. this.useClipPlane = !1,
  112592. this.compileShadowGenerators = !1,
  112593. this.transparencyAsCoverage = !1,
  112594. this.useRangeRequests = !1,
  112595. this.createInstances = !0,
  112596. this.alwaysComputeBoundingBox = !1,
  112597. this.loadAllMaterials = !1,
  112598. this.useSRGBBuffers = !0,
  112599. this.preprocessUrlAsync = function(e) {
  112600. return Promise.resolve(e)
  112601. }
  112602. ,
  112603. this.onMeshLoadedObservable = new Observable,
  112604. this.onTextureLoadedObservable = new Observable,
  112605. this.onMaterialLoadedObservable = new Observable,
  112606. this.onCameraLoadedObservable = new Observable,
  112607. this.onCompleteObservable = new Observable,
  112608. this.onErrorObservable = new Observable,
  112609. this.onDisposeObservable = new Observable,
  112610. this.onExtensionLoadedObservable = new Observable,
  112611. this.validate = !1,
  112612. this.onValidatedObservable = new Observable,
  112613. this._loader = null,
  112614. this._state = null,
  112615. this._requests = new Array,
  112616. this.name = "gltf",
  112617. this.extensions = {
  112618. ".gltf": {
  112619. isBinary: !1
  112620. },
  112621. ".glb": {
  112622. isBinary: !0
  112623. }
  112624. },
  112625. this.onLoaderStateChangedObservable = new Observable,
  112626. this._logIndentLevel = 0,
  112627. this._loggingEnabled = !1,
  112628. this._log = this._logDisabled,
  112629. this._capturePerformanceCounters = !1,
  112630. this._startPerformanceCounter = this._startPerformanceCounterDisabled,
  112631. this._endPerformanceCounter = this._endPerformanceCounterDisabled
  112632. }
  112633. return Object.defineProperty(a.prototype, "onParsed", {
  112634. set: function(e) {
  112635. this._onParsedObserver && this.onParsedObservable.remove(this._onParsedObserver),
  112636. this._onParsedObserver = this.onParsedObservable.add(e)
  112637. },
  112638. enumerable: !1,
  112639. configurable: !0
  112640. }),
  112641. Object.defineProperty(a.prototype, "onMeshLoaded", {
  112642. set: function(e) {
  112643. this._onMeshLoadedObserver && this.onMeshLoadedObservable.remove(this._onMeshLoadedObserver),
  112644. this._onMeshLoadedObserver = this.onMeshLoadedObservable.add(e)
  112645. },
  112646. enumerable: !1,
  112647. configurable: !0
  112648. }),
  112649. Object.defineProperty(a.prototype, "onTextureLoaded", {
  112650. set: function(e) {
  112651. this._onTextureLoadedObserver && this.onTextureLoadedObservable.remove(this._onTextureLoadedObserver),
  112652. this._onTextureLoadedObserver = this.onTextureLoadedObservable.add(e)
  112653. },
  112654. enumerable: !1,
  112655. configurable: !0
  112656. }),
  112657. Object.defineProperty(a.prototype, "onMaterialLoaded", {
  112658. set: function(e) {
  112659. this._onMaterialLoadedObserver && this.onMaterialLoadedObservable.remove(this._onMaterialLoadedObserver),
  112660. this._onMaterialLoadedObserver = this.onMaterialLoadedObservable.add(e)
  112661. },
  112662. enumerable: !1,
  112663. configurable: !0
  112664. }),
  112665. Object.defineProperty(a.prototype, "onCameraLoaded", {
  112666. set: function(e) {
  112667. this._onCameraLoadedObserver && this.onCameraLoadedObservable.remove(this._onCameraLoadedObserver),
  112668. this._onCameraLoadedObserver = this.onCameraLoadedObservable.add(e)
  112669. },
  112670. enumerable: !1,
  112671. configurable: !0
  112672. }),
  112673. Object.defineProperty(a.prototype, "onComplete", {
  112674. set: function(e) {
  112675. this._onCompleteObserver && this.onCompleteObservable.remove(this._onCompleteObserver),
  112676. this._onCompleteObserver = this.onCompleteObservable.add(e)
  112677. },
  112678. enumerable: !1,
  112679. configurable: !0
  112680. }),
  112681. Object.defineProperty(a.prototype, "onError", {
  112682. set: function(e) {
  112683. this._onErrorObserver && this.onErrorObservable.remove(this._onErrorObserver),
  112684. this._onErrorObserver = this.onErrorObservable.add(e)
  112685. },
  112686. enumerable: !1,
  112687. configurable: !0
  112688. }),
  112689. Object.defineProperty(a.prototype, "onDispose", {
  112690. set: function(e) {
  112691. this._onDisposeObserver && this.onDisposeObservable.remove(this._onDisposeObserver),
  112692. this._onDisposeObserver = this.onDisposeObservable.add(e)
  112693. },
  112694. enumerable: !1,
  112695. configurable: !0
  112696. }),
  112697. Object.defineProperty(a.prototype, "onExtensionLoaded", {
  112698. set: function(e) {
  112699. this._onExtensionLoadedObserver && this.onExtensionLoadedObservable.remove(this._onExtensionLoadedObserver),
  112700. this._onExtensionLoadedObserver = this.onExtensionLoadedObservable.add(e)
  112701. },
  112702. enumerable: !1,
  112703. configurable: !0
  112704. }),
  112705. Object.defineProperty(a.prototype, "loggingEnabled", {
  112706. get: function() {
  112707. return this._loggingEnabled
  112708. },
  112709. set: function(e) {
  112710. this._loggingEnabled !== e && (this._loggingEnabled = e,
  112711. this._loggingEnabled ? this._log = this._logEnabled : this._log = this._logDisabled)
  112712. },
  112713. enumerable: !1,
  112714. configurable: !0
  112715. }),
  112716. Object.defineProperty(a.prototype, "capturePerformanceCounters", {
  112717. get: function() {
  112718. return this._capturePerformanceCounters
  112719. },
  112720. set: function(e) {
  112721. this._capturePerformanceCounters !== e && (this._capturePerformanceCounters = e,
  112722. this._capturePerformanceCounters ? (this._startPerformanceCounter = this._startPerformanceCounterEnabled,
  112723. this._endPerformanceCounter = this._endPerformanceCounterEnabled) : (this._startPerformanceCounter = this._startPerformanceCounterDisabled,
  112724. this._endPerformanceCounter = this._endPerformanceCounterDisabled))
  112725. },
  112726. enumerable: !1,
  112727. configurable: !0
  112728. }),
  112729. Object.defineProperty(a.prototype, "onValidated", {
  112730. set: function(e) {
  112731. this._onValidatedObserver && this.onValidatedObservable.remove(this._onValidatedObserver),
  112732. this._onValidatedObserver = this.onValidatedObservable.add(e)
  112733. },
  112734. enumerable: !1,
  112735. configurable: !0
  112736. }),
  112737. a.prototype.dispose = function() {
  112738. this._loader && (this._loader.dispose(),
  112739. this._loader = null);
  112740. for (var e = 0, i = this._requests; e < i.length; e++) {
  112741. var o = i[e];
  112742. o.abort()
  112743. }
  112744. this._requests.length = 0,
  112745. delete this._progressCallback,
  112746. this.preprocessUrlAsync = function(s) {
  112747. return Promise.resolve(s)
  112748. }
  112749. ,
  112750. this.onMeshLoadedObservable.clear(),
  112751. this.onTextureLoadedObservable.clear(),
  112752. this.onMaterialLoadedObservable.clear(),
  112753. this.onCameraLoadedObservable.clear(),
  112754. this.onCompleteObservable.clear(),
  112755. this.onExtensionLoadedObservable.clear(),
  112756. this.onDisposeObservable.notifyObservers(void 0),
  112757. this.onDisposeObservable.clear()
  112758. }
  112759. ,
  112760. a.prototype.loadFile = function(e, i, o, s, c, d) {
  112761. var _ = this;
  112762. if (this._progressCallback = s,
  112763. c) {
  112764. if (this.useRangeRequests) {
  112765. this.validate && Logger$2.Warn("glTF validation is not supported when range requests are enabled");
  112766. var b = {
  112767. abort: function() {},
  112768. onCompleteObservable: new Observable
  112769. }
  112770. , k = {
  112771. readAsync: function(j, $) {
  112772. return new Promise(function(_e, et) {
  112773. _._loadFile(e, i, function(tt) {
  112774. _e(new Uint8Array(tt))
  112775. }, !0, function(tt) {
  112776. et(tt)
  112777. }, function(tt) {
  112778. tt.setRequestHeader("Range", "bytes=" + j + "-" + (j + $ - 1))
  112779. })
  112780. }
  112781. )
  112782. },
  112783. byteLength: 0
  112784. };
  112785. return this._unpackBinaryAsync(new DataReader(k)).then(function(j) {
  112786. b.onCompleteObservable.notifyObservers(b),
  112787. o(j)
  112788. }, d ? function(j) {
  112789. return d(void 0, j)
  112790. }
  112791. : void 0),
  112792. b
  112793. }
  112794. return this._loadFile(e, i, function(j) {
  112795. var $ = j;
  112796. _._unpackBinaryAsync(new DataReader({
  112797. readAsync: function(_e, et) {
  112798. return readAsync($, _e, et)
  112799. },
  112800. byteLength: $.byteLength
  112801. })).then(function(_e) {
  112802. o(_e)
  112803. }, d ? function(_e) {
  112804. return d(void 0, _e)
  112805. }
  112806. : void 0)
  112807. }, !0, d)
  112808. }
  112809. return this._loadFile(e, i, function(j) {
  112810. if (i.name)
  112811. _._validate(e, j, "file:", i.name);
  112812. else {
  112813. var $ = i;
  112814. _._validate(e, j, Tools.GetFolderPath($), Tools.GetFilename($))
  112815. }
  112816. o({
  112817. json: _._parseJson(j)
  112818. })
  112819. }, c, d)
  112820. }
  112821. ,
  112822. a.prototype.importMeshAsync = function(e, i, o, s, c, d) {
  112823. var _ = this;
  112824. return Promise.resolve().then(function() {
  112825. return _.onParsedObservable.notifyObservers(o),
  112826. _.onParsedObservable.clear(),
  112827. _._log("Loading " + (d || "")),
  112828. _._loader = _._getLoader(o),
  112829. _._loader.importMeshAsync(e, i, null, o, s, c, d)
  112830. })
  112831. }
  112832. ,
  112833. a.prototype.loadAsync = function(e, i, o, s, c) {
  112834. var d = this;
  112835. return Promise.resolve().then(function() {
  112836. return d.onParsedObservable.notifyObservers(i),
  112837. d.onParsedObservable.clear(),
  112838. d._log("Loading " + (c || "")),
  112839. d._loader = d._getLoader(i),
  112840. d._loader.loadAsync(e, i, o, s, c)
  112841. })
  112842. }
  112843. ,
  112844. a.prototype.loadAssetContainerAsync = function(e, i, o, s, c) {
  112845. var d = this;
  112846. return Promise.resolve().then(function() {
  112847. d.onParsedObservable.notifyObservers(i),
  112848. d.onParsedObservable.clear(),
  112849. d._log("Loading " + (c || "")),
  112850. d._loader = d._getLoader(i);
  112851. var _ = new AssetContainer(e)
  112852. , b = [];
  112853. d.onMaterialLoadedObservable.add(function($) {
  112854. b.push($)
  112855. });
  112856. var k = [];
  112857. d.onTextureLoadedObservable.add(function($) {
  112858. k.push($)
  112859. });
  112860. var j = [];
  112861. return d.onCameraLoadedObservable.add(function($) {
  112862. j.push($)
  112863. }),
  112864. d._loader.importMeshAsync(null, e, _, i, o, s, c).then(function($) {
  112865. return Array.prototype.push.apply(_.geometries, $.geometries),
  112866. Array.prototype.push.apply(_.meshes, $.meshes),
  112867. Array.prototype.push.apply(_.particleSystems, $.particleSystems),
  112868. Array.prototype.push.apply(_.skeletons, $.skeletons),
  112869. Array.prototype.push.apply(_.animationGroups, $.animationGroups),
  112870. Array.prototype.push.apply(_.materials, b),
  112871. Array.prototype.push.apply(_.textures, k),
  112872. Array.prototype.push.apply(_.lights, $.lights),
  112873. Array.prototype.push.apply(_.transformNodes, $.transformNodes),
  112874. Array.prototype.push.apply(_.cameras, j),
  112875. _
  112876. })
  112877. })
  112878. }
  112879. ,
  112880. a.prototype.canDirectLoad = function(e) {
  112881. return e.indexOf("asset") !== -1 && e.indexOf("version") !== -1 || StringTools.StartsWith(e, "data:base64," + a.magicBase64Encoded) || StringTools.StartsWith(e, "data:;base64," + a.magicBase64Encoded) || StringTools.StartsWith(e, "data:application/octet-stream;base64," + a.magicBase64Encoded) || StringTools.StartsWith(e, "data:model/gltf-binary;base64," + a.magicBase64Encoded)
  112882. }
  112883. ,
  112884. a.prototype.directLoad = function(e, i) {
  112885. if (StringTools.StartsWith(i, "base64," + a.magicBase64Encoded) || StringTools.StartsWith(i, ";base64," + a.magicBase64Encoded) || StringTools.StartsWith(i, "application/octet-stream;base64," + a.magicBase64Encoded) || StringTools.StartsWith(i, "model/gltf-binary;base64," + a.magicBase64Encoded)) {
  112886. var o = DecodeBase64UrlToBinary(i);
  112887. return this._validate(e, o),
  112888. this._unpackBinaryAsync(new DataReader({
  112889. readAsync: function(s, c) {
  112890. return readAsync(o, s, c)
  112891. },
  112892. byteLength: o.byteLength
  112893. }))
  112894. }
  112895. return this._validate(e, i),
  112896. Promise.resolve({
  112897. json: this._parseJson(i)
  112898. })
  112899. }
  112900. ,
  112901. a.prototype.createPlugin = function() {
  112902. return new a
  112903. }
  112904. ,
  112905. Object.defineProperty(a.prototype, "loaderState", {
  112906. get: function() {
  112907. return this._state
  112908. },
  112909. enumerable: !1,
  112910. configurable: !0
  112911. }),
  112912. a.prototype.whenCompleteAsync = function() {
  112913. var e = this;
  112914. return new Promise(function(i, o) {
  112915. e.onCompleteObservable.addOnce(function() {
  112916. i()
  112917. }),
  112918. e.onErrorObservable.addOnce(function(s) {
  112919. o(s)
  112920. })
  112921. }
  112922. )
  112923. }
  112924. ,
  112925. a.prototype._setState = function(e) {
  112926. this._state !== e && (this._state = e,
  112927. this.onLoaderStateChangedObservable.notifyObservers(this._state),
  112928. this._log(GLTFLoaderState[this._state]))
  112929. }
  112930. ,
  112931. a.prototype._loadFile = function(e, i, o, s, c, d) {
  112932. var _ = this
  112933. , b = e._loadFile(i, o, function(k) {
  112934. _._onProgress(k, b)
  112935. }, !0, s, c, d);
  112936. return b.onCompleteObservable.add(function(k) {
  112937. _._requests.splice(_._requests.indexOf(k), 1)
  112938. }),
  112939. this._requests.push(b),
  112940. b
  112941. }
  112942. ,
  112943. a.prototype._onProgress = function(e, i) {
  112944. if (!!this._progressCallback) {
  112945. i._lengthComputable = e.lengthComputable,
  112946. i._loaded = e.loaded,
  112947. i._total = e.total;
  112948. for (var o = !0, s = 0, c = 0, d = 0, _ = this._requests; d < _.length; d++) {
  112949. var b = _[d];
  112950. if (b._lengthComputable === void 0 || b._loaded === void 0 || b._total === void 0)
  112951. return;
  112952. o = o && b._lengthComputable,
  112953. s += b._loaded,
  112954. c += b._total
  112955. }
  112956. this._progressCallback({
  112957. lengthComputable: o,
  112958. loaded: s,
  112959. total: o ? c : 0
  112960. })
  112961. }
  112962. }
  112963. ,
  112964. a.prototype._validate = function(e, i, o, s) {
  112965. var c = this;
  112966. o === void 0 && (o = ""),
  112967. s === void 0 && (s = ""),
  112968. this.validate && (this._startPerformanceCounter("Validate JSON"),
  112969. GLTFValidation.ValidateAsync(i, o, s, function(d) {
  112970. return c.preprocessUrlAsync(o + d).then(function(_) {
  112971. return e._loadFileAsync(_, void 0, !0, !0)
  112972. })
  112973. }).then(function(d) {
  112974. c._endPerformanceCounter("Validate JSON"),
  112975. c.onValidatedObservable.notifyObservers(d),
  112976. c.onValidatedObservable.clear()
  112977. }, function(d) {
  112978. c._endPerformanceCounter("Validate JSON"),
  112979. Tools.Warn("Failed to validate: " + d.message),
  112980. c.onValidatedObservable.clear()
  112981. }))
  112982. }
  112983. ,
  112984. a.prototype._getLoader = function(e) {
  112985. var i = e.json.asset || {};
  112986. this._log("Asset version: " + i.version),
  112987. i.minVersion && this._log("Asset minimum version: " + i.minVersion),
  112988. i.generator && this._log("Asset generator: " + i.generator);
  112989. var o = a._parseVersion(i.version);
  112990. if (!o)
  112991. throw new Error("Invalid version: " + i.version);
  112992. if (i.minVersion !== void 0) {
  112993. var s = a._parseVersion(i.minVersion);
  112994. if (!s)
  112995. throw new Error("Invalid minimum version: " + i.minVersion);
  112996. if (a._compareVersion(s, {
  112997. major: 2,
  112998. minor: 0
  112999. }) > 0)
  113000. throw new Error("Incompatible minimum version: " + i.minVersion)
  113001. }
  113002. var c = {
  113003. 1: a._CreateGLTF1Loader,
  113004. 2: a._CreateGLTF2Loader
  113005. }
  113006. , d = c[o.major];
  113007. if (!d)
  113008. throw new Error("Unsupported version: " + i.version);
  113009. return d(this)
  113010. }
  113011. ,
  113012. a.prototype._parseJson = function(e) {
  113013. this._startPerformanceCounter("Parse JSON"),
  113014. this._log("JSON length: " + e.length);
  113015. var i = JSON.parse(e);
  113016. return this._endPerformanceCounter("Parse JSON"),
  113017. i
  113018. }
  113019. ,
  113020. a.prototype._unpackBinaryAsync = function(e) {
  113021. var i = this;
  113022. return this._startPerformanceCounter("Unpack Binary"),
  113023. e.loadAsync(20).then(function() {
  113024. var o = {
  113025. Magic: 1179937895
  113026. }
  113027. , s = e.readUint32();
  113028. if (s !== o.Magic)
  113029. throw new Error("Unexpected magic: " + s);
  113030. var c = e.readUint32();
  113031. i.loggingEnabled && i._log("Binary version: " + c);
  113032. var d = e.readUint32();
  113033. if (e.buffer.byteLength !== 0 && d !== e.buffer.byteLength)
  113034. throw new Error("Length in header does not match actual data length: " + d + " != " + e.buffer.byteLength);
  113035. var _;
  113036. switch (c) {
  113037. case 1:
  113038. {
  113039. _ = i._unpackBinaryV1Async(e, d);
  113040. break
  113041. }
  113042. case 2:
  113043. {
  113044. _ = i._unpackBinaryV2Async(e, d);
  113045. break
  113046. }
  113047. default:
  113048. throw new Error("Unsupported version: " + c)
  113049. }
  113050. return i._endPerformanceCounter("Unpack Binary"),
  113051. _
  113052. })
  113053. }
  113054. ,
  113055. a.prototype._unpackBinaryV1Async = function(e, i) {
  113056. var o = {
  113057. JSON: 0
  113058. }
  113059. , s = e.readUint32()
  113060. , c = e.readUint32();
  113061. if (c !== o.JSON)
  113062. throw new Error("Unexpected content format: " + c);
  113063. var d = i - e.byteOffset
  113064. , _ = {
  113065. json: this._parseJson(e.readString(s)),
  113066. bin: null
  113067. };
  113068. if (d !== 0) {
  113069. var b = e.byteOffset;
  113070. _.bin = {
  113071. readAsync: function(k, j) {
  113072. return e.buffer.readAsync(b + k, j)
  113073. },
  113074. byteLength: d
  113075. }
  113076. }
  113077. return Promise.resolve(_)
  113078. }
  113079. ,
  113080. a.prototype._unpackBinaryV2Async = function(e, i) {
  113081. var o = this
  113082. , s = {
  113083. JSON: 1313821514,
  113084. BIN: 5130562
  113085. }
  113086. , c = e.readUint32()
  113087. , d = e.readUint32();
  113088. if (d !== s.JSON)
  113089. throw new Error("First chunk format is not JSON");
  113090. return e.byteOffset + c === i ? e.loadAsync(c).then(function() {
  113091. return {
  113092. json: o._parseJson(e.readString(c)),
  113093. bin: null
  113094. }
  113095. }) : e.loadAsync(c + 8).then(function() {
  113096. var _ = {
  113097. json: o._parseJson(e.readString(c)),
  113098. bin: null
  113099. }
  113100. , b = function() {
  113101. var k = e.readUint32()
  113102. , j = e.readUint32();
  113103. switch (j) {
  113104. case s.JSON:
  113105. throw new Error("Unexpected JSON chunk");
  113106. case s.BIN:
  113107. {
  113108. var $ = e.byteOffset;
  113109. _.bin = {
  113110. readAsync: function(_e, et) {
  113111. return e.buffer.readAsync($ + _e, et)
  113112. },
  113113. byteLength: k
  113114. },
  113115. e.skipBytes(k);
  113116. break
  113117. }
  113118. default:
  113119. {
  113120. e.skipBytes(k);
  113121. break
  113122. }
  113123. }
  113124. return e.byteOffset !== i ? e.loadAsync(8).then(b) : Promise.resolve(_)
  113125. };
  113126. return b()
  113127. })
  113128. }
  113129. ,
  113130. a._parseVersion = function(e) {
  113131. if (e === "1.0" || e === "1.0.1")
  113132. return {
  113133. major: 1,
  113134. minor: 0
  113135. };
  113136. var i = (e + "").match(/^(\d+)\.(\d+)/);
  113137. return i ? {
  113138. major: parseInt(i[1]),
  113139. minor: parseInt(i[2])
  113140. } : null
  113141. }
  113142. ,
  113143. a._compareVersion = function(e, i) {
  113144. return e.major > i.major ? 1 : e.major < i.major ? -1 : e.minor > i.minor ? 1 : e.minor < i.minor ? -1 : 0
  113145. }
  113146. ,
  113147. a.prototype._logOpen = function(e) {
  113148. this._log(e),
  113149. this._logIndentLevel++
  113150. }
  113151. ,
  113152. a.prototype._logClose = function() {
  113153. --this._logIndentLevel
  113154. }
  113155. ,
  113156. a.prototype._logEnabled = function(e) {
  113157. var i = a._logSpaces.substr(0, this._logIndentLevel * 2);
  113158. Logger$2.Log("" + i + e)
  113159. }
  113160. ,
  113161. a.prototype._logDisabled = function(e) {}
  113162. ,
  113163. a.prototype._startPerformanceCounterEnabled = function(e) {
  113164. Tools.StartPerformanceCounter(e)
  113165. }
  113166. ,
  113167. a.prototype._startPerformanceCounterDisabled = function(e) {}
  113168. ,
  113169. a.prototype._endPerformanceCounterEnabled = function(e) {
  113170. Tools.EndPerformanceCounter(e)
  113171. }
  113172. ,
  113173. a.prototype._endPerformanceCounterDisabled = function(e) {}
  113174. ,
  113175. a.IncrementalLoading = !0,
  113176. a.HomogeneousCoordinates = !1,
  113177. a.magicBase64Encoded = "Z2xURg",
  113178. a._logSpaces = " ",
  113179. a
  113180. }();
  113181. SceneLoader && SceneLoader.RegisterPlugin(new GLTFFileLoader);
  113182. var EComponentType;
  113183. (function(a) {
  113184. a[a.BYTE = 5120] = "BYTE",
  113185. a[a.UNSIGNED_BYTE = 5121] = "UNSIGNED_BYTE",
  113186. a[a.SHORT = 5122] = "SHORT",
  113187. a[a.UNSIGNED_SHORT = 5123] = "UNSIGNED_SHORT",
  113188. a[a.FLOAT = 5126] = "FLOAT"
  113189. }
  113190. )(EComponentType || (EComponentType = {}));
  113191. var EShaderType;
  113192. (function(a) {
  113193. a[a.FRAGMENT = 35632] = "FRAGMENT",
  113194. a[a.VERTEX = 35633] = "VERTEX"
  113195. }
  113196. )(EShaderType || (EShaderType = {}));
  113197. var EParameterType;
  113198. (function(a) {
  113199. a[a.BYTE = 5120] = "BYTE",
  113200. a[a.UNSIGNED_BYTE = 5121] = "UNSIGNED_BYTE",
  113201. a[a.SHORT = 5122] = "SHORT",
  113202. a[a.UNSIGNED_SHORT = 5123] = "UNSIGNED_SHORT",
  113203. a[a.INT = 5124] = "INT",
  113204. a[a.UNSIGNED_INT = 5125] = "UNSIGNED_INT",
  113205. a[a.FLOAT = 5126] = "FLOAT",
  113206. a[a.FLOAT_VEC2 = 35664] = "FLOAT_VEC2",
  113207. a[a.FLOAT_VEC3 = 35665] = "FLOAT_VEC3",
  113208. a[a.FLOAT_VEC4 = 35666] = "FLOAT_VEC4",
  113209. a[a.INT_VEC2 = 35667] = "INT_VEC2",
  113210. a[a.INT_VEC3 = 35668] = "INT_VEC3",
  113211. a[a.INT_VEC4 = 35669] = "INT_VEC4",
  113212. a[a.BOOL = 35670] = "BOOL",
  113213. a[a.BOOL_VEC2 = 35671] = "BOOL_VEC2",
  113214. a[a.BOOL_VEC3 = 35672] = "BOOL_VEC3",
  113215. a[a.BOOL_VEC4 = 35673] = "BOOL_VEC4",
  113216. a[a.FLOAT_MAT2 = 35674] = "FLOAT_MAT2",
  113217. a[a.FLOAT_MAT3 = 35675] = "FLOAT_MAT3",
  113218. a[a.FLOAT_MAT4 = 35676] = "FLOAT_MAT4",
  113219. a[a.SAMPLER_2D = 35678] = "SAMPLER_2D"
  113220. }
  113221. )(EParameterType || (EParameterType = {}));
  113222. var ETextureWrapMode;
  113223. (function(a) {
  113224. a[a.CLAMP_TO_EDGE = 33071] = "CLAMP_TO_EDGE",
  113225. a[a.MIRRORED_REPEAT = 33648] = "MIRRORED_REPEAT",
  113226. a[a.REPEAT = 10497] = "REPEAT"
  113227. }
  113228. )(ETextureWrapMode || (ETextureWrapMode = {}));
  113229. var ETextureFilterType;
  113230. (function(a) {
  113231. a[a.NEAREST = 9728] = "NEAREST",
  113232. a[a.LINEAR = 9728] = "LINEAR",
  113233. a[a.NEAREST_MIPMAP_NEAREST = 9984] = "NEAREST_MIPMAP_NEAREST",
  113234. a[a.LINEAR_MIPMAP_NEAREST = 9985] = "LINEAR_MIPMAP_NEAREST",
  113235. a[a.NEAREST_MIPMAP_LINEAR = 9986] = "NEAREST_MIPMAP_LINEAR",
  113236. a[a.LINEAR_MIPMAP_LINEAR = 9987] = "LINEAR_MIPMAP_LINEAR"
  113237. }
  113238. )(ETextureFilterType || (ETextureFilterType = {}));
  113239. var ETextureFormat;
  113240. (function(a) {
  113241. a[a.ALPHA = 6406] = "ALPHA",
  113242. a[a.RGB = 6407] = "RGB",
  113243. a[a.RGBA = 6408] = "RGBA",
  113244. a[a.LUMINANCE = 6409] = "LUMINANCE",
  113245. a[a.LUMINANCE_ALPHA = 6410] = "LUMINANCE_ALPHA"
  113246. }
  113247. )(ETextureFormat || (ETextureFormat = {}));
  113248. var ECullingType;
  113249. (function(a) {
  113250. a[a.FRONT = 1028] = "FRONT",
  113251. a[a.BACK = 1029] = "BACK",
  113252. a[a.FRONT_AND_BACK = 1032] = "FRONT_AND_BACK"
  113253. }
  113254. )(ECullingType || (ECullingType = {}));
  113255. var EBlendingFunction;
  113256. (function(a) {
  113257. a[a.ZERO = 0] = "ZERO",
  113258. a[a.ONE = 1] = "ONE",
  113259. a[a.SRC_COLOR = 768] = "SRC_COLOR",
  113260. a[a.ONE_MINUS_SRC_COLOR = 769] = "ONE_MINUS_SRC_COLOR",
  113261. a[a.DST_COLOR = 774] = "DST_COLOR",
  113262. a[a.ONE_MINUS_DST_COLOR = 775] = "ONE_MINUS_DST_COLOR",
  113263. a[a.SRC_ALPHA = 770] = "SRC_ALPHA",
  113264. a[a.ONE_MINUS_SRC_ALPHA = 771] = "ONE_MINUS_SRC_ALPHA",
  113265. a[a.DST_ALPHA = 772] = "DST_ALPHA",
  113266. a[a.ONE_MINUS_DST_ALPHA = 773] = "ONE_MINUS_DST_ALPHA",
  113267. a[a.CONSTANT_COLOR = 32769] = "CONSTANT_COLOR",
  113268. a[a.ONE_MINUS_CONSTANT_COLOR = 32770] = "ONE_MINUS_CONSTANT_COLOR",
  113269. a[a.CONSTANT_ALPHA = 32771] = "CONSTANT_ALPHA",
  113270. a[a.ONE_MINUS_CONSTANT_ALPHA = 32772] = "ONE_MINUS_CONSTANT_ALPHA",
  113271. a[a.SRC_ALPHA_SATURATE = 776] = "SRC_ALPHA_SATURATE"
  113272. }
  113273. )(EBlendingFunction || (EBlendingFunction = {}));
  113274. var GLTFUtils = function() {
  113275. function a() {}
  113276. return a.SetMatrix = function(e, i, o, s, c) {
  113277. var d = null;
  113278. if (o.semantic === "MODEL")
  113279. d = i.getWorldMatrix();
  113280. else if (o.semantic === "PROJECTION")
  113281. d = e.getProjectionMatrix();
  113282. else if (o.semantic === "VIEW")
  113283. d = e.getViewMatrix();
  113284. else if (o.semantic === "MODELVIEWINVERSETRANSPOSE")
  113285. d = Matrix.Transpose(i.getWorldMatrix().multiply(e.getViewMatrix()).invert());
  113286. else if (o.semantic === "MODELVIEW")
  113287. d = i.getWorldMatrix().multiply(e.getViewMatrix());
  113288. else if (o.semantic === "MODELVIEWPROJECTION")
  113289. d = i.getWorldMatrix().multiply(e.getTransformMatrix());
  113290. else if (o.semantic === "MODELINVERSE")
  113291. d = i.getWorldMatrix().invert();
  113292. else if (o.semantic === "VIEWINVERSE")
  113293. d = e.getViewMatrix().invert();
  113294. else if (o.semantic === "PROJECTIONINVERSE")
  113295. d = e.getProjectionMatrix().invert();
  113296. else if (o.semantic === "MODELVIEWINVERSE")
  113297. d = i.getWorldMatrix().multiply(e.getViewMatrix()).invert();
  113298. else if (o.semantic === "MODELVIEWPROJECTIONINVERSE")
  113299. d = i.getWorldMatrix().multiply(e.getTransformMatrix()).invert();
  113300. else if (o.semantic === "MODELINVERSETRANSPOSE")
  113301. d = Matrix.Transpose(i.getWorldMatrix().invert());
  113302. else
  113303. debugger ;if (d)
  113304. switch (o.type) {
  113305. case EParameterType.FLOAT_MAT2:
  113306. c.setMatrix2x2(s, Matrix.GetAsMatrix2x2(d));
  113307. break;
  113308. case EParameterType.FLOAT_MAT3:
  113309. c.setMatrix3x3(s, Matrix.GetAsMatrix3x3(d));
  113310. break;
  113311. case EParameterType.FLOAT_MAT4:
  113312. c.setMatrix(s, d);
  113313. break
  113314. }
  113315. }
  113316. ,
  113317. a.SetUniform = function(e, i, o, s) {
  113318. switch (s) {
  113319. case EParameterType.FLOAT:
  113320. return e.setFloat(i, o),
  113321. !0;
  113322. case EParameterType.FLOAT_VEC2:
  113323. return e.setVector2(i, Vector2.FromArray(o)),
  113324. !0;
  113325. case EParameterType.FLOAT_VEC3:
  113326. return e.setVector3(i, Vector3.FromArray(o)),
  113327. !0;
  113328. case EParameterType.FLOAT_VEC4:
  113329. return e.setVector4(i, Vector4.FromArray(o)),
  113330. !0;
  113331. default:
  113332. return !1
  113333. }
  113334. }
  113335. ,
  113336. a.GetWrapMode = function(e) {
  113337. switch (e) {
  113338. case ETextureWrapMode.CLAMP_TO_EDGE:
  113339. return Texture.CLAMP_ADDRESSMODE;
  113340. case ETextureWrapMode.MIRRORED_REPEAT:
  113341. return Texture.MIRROR_ADDRESSMODE;
  113342. case ETextureWrapMode.REPEAT:
  113343. return Texture.WRAP_ADDRESSMODE;
  113344. default:
  113345. return Texture.WRAP_ADDRESSMODE
  113346. }
  113347. }
  113348. ,
  113349. a.GetByteStrideFromType = function(e) {
  113350. var i = e.type;
  113351. switch (i) {
  113352. case "VEC2":
  113353. return 2;
  113354. case "VEC3":
  113355. return 3;
  113356. case "VEC4":
  113357. return 4;
  113358. case "MAT2":
  113359. return 4;
  113360. case "MAT3":
  113361. return 9;
  113362. case "MAT4":
  113363. return 16;
  113364. default:
  113365. return 1
  113366. }
  113367. }
  113368. ,
  113369. a.GetTextureFilterMode = function(e) {
  113370. switch (e) {
  113371. case ETextureFilterType.LINEAR:
  113372. case ETextureFilterType.LINEAR_MIPMAP_NEAREST:
  113373. case ETextureFilterType.LINEAR_MIPMAP_LINEAR:
  113374. return Texture.TRILINEAR_SAMPLINGMODE;
  113375. case ETextureFilterType.NEAREST:
  113376. case ETextureFilterType.NEAREST_MIPMAP_NEAREST:
  113377. return Texture.NEAREST_SAMPLINGMODE;
  113378. default:
  113379. return Texture.BILINEAR_SAMPLINGMODE
  113380. }
  113381. }
  113382. ,
  113383. a.GetBufferFromBufferView = function(e, i, d, s, c) {
  113384. var d = i.byteOffset + d
  113385. , _ = e.loadedBufferViews[i.buffer];
  113386. if (d + s > _.byteLength)
  113387. throw new Error("Buffer access is out of range");
  113388. var b = _.buffer;
  113389. switch (d += _.byteOffset,
  113390. c) {
  113391. case EComponentType.BYTE:
  113392. return new Int8Array(b,d,s);
  113393. case EComponentType.UNSIGNED_BYTE:
  113394. return new Uint8Array(b,d,s);
  113395. case EComponentType.SHORT:
  113396. return new Int16Array(b,d,s);
  113397. case EComponentType.UNSIGNED_SHORT:
  113398. return new Uint16Array(b,d,s);
  113399. default:
  113400. return new Float32Array(b,d,s)
  113401. }
  113402. }
  113403. ,
  113404. a.GetBufferFromAccessor = function(e, i) {
  113405. var o = e.bufferViews[i.bufferView]
  113406. , s = i.count * a.GetByteStrideFromType(i);
  113407. return a.GetBufferFromBufferView(e, o, i.byteOffset, s, i.componentType)
  113408. }
  113409. ,
  113410. a.DecodeBufferToText = function(e) {
  113411. for (var i = "", o = e.byteLength, s = 0; s < o; ++s)
  113412. i += String.fromCharCode(e[s]);
  113413. return i
  113414. }
  113415. ,
  113416. a.GetDefaultMaterial = function(e) {
  113417. if (!a._DefaultMaterial) {
  113418. Effect.ShadersStore.GLTFDefaultMaterialVertexShader = ["precision highp float;", "", "uniform mat4 worldView;", "uniform mat4 projection;", "", "attribute vec3 position;", "", "void main(void)", "{", " gl_Position = projection * worldView * vec4(position, 1.0);", "}"].join(`
  113419. `),
  113420. Effect.ShadersStore.GLTFDefaultMaterialPixelShader = ["precision highp float;", "", "uniform vec4 u_emission;", "", "void main(void)", "{", " gl_FragColor = u_emission;", "}"].join(`
  113421. `);
  113422. var i = {
  113423. vertex: "GLTFDefaultMaterial",
  113424. fragment: "GLTFDefaultMaterial"
  113425. }
  113426. , o = {
  113427. attributes: ["position"],
  113428. uniforms: ["worldView", "projection", "u_emission"],
  113429. samplers: new Array,
  113430. needAlphaBlending: !1
  113431. };
  113432. a._DefaultMaterial = new ShaderMaterial("GLTFDefaultMaterial",e,i,o),
  113433. a._DefaultMaterial.setColor4("u_emission", new Color4(.5,.5,.5,1))
  113434. }
  113435. return a._DefaultMaterial
  113436. }
  113437. ,
  113438. a._DefaultMaterial = null,
  113439. a
  113440. }(), ETokenType;
  113441. (function(a) {
  113442. a[a.IDENTIFIER = 1] = "IDENTIFIER",
  113443. a[a.UNKNOWN = 2] = "UNKNOWN",
  113444. a[a.END_OF_INPUT = 3] = "END_OF_INPUT"
  113445. }
  113446. )(ETokenType || (ETokenType = {}));
  113447. var Tokenizer = function() {
  113448. function a(e) {
  113449. this._pos = 0,
  113450. this.currentToken = ETokenType.UNKNOWN,
  113451. this.currentIdentifier = "",
  113452. this.currentString = "",
  113453. this.isLetterOrDigitPattern = /^[a-zA-Z0-9]+$/,
  113454. this._toParse = e,
  113455. this._maxPos = e.length
  113456. }
  113457. return a.prototype.getNextToken = function() {
  113458. if (this.isEnd())
  113459. return ETokenType.END_OF_INPUT;
  113460. if (this.currentString = this.read(),
  113461. this.currentToken = ETokenType.UNKNOWN,
  113462. this.currentString === "_" || this.isLetterOrDigitPattern.test(this.currentString))
  113463. for (this.currentToken = ETokenType.IDENTIFIER,
  113464. this.currentIdentifier = this.currentString; !this.isEnd() && (this.isLetterOrDigitPattern.test(this.currentString = this.peek()) || this.currentString === "_"); )
  113465. this.currentIdentifier += this.currentString,
  113466. this.forward();
  113467. return this.currentToken
  113468. }
  113469. ,
  113470. a.prototype.peek = function() {
  113471. return this._toParse[this._pos]
  113472. }
  113473. ,
  113474. a.prototype.read = function() {
  113475. return this._toParse[this._pos++]
  113476. }
  113477. ,
  113478. a.prototype.forward = function() {
  113479. this._pos++
  113480. }
  113481. ,
  113482. a.prototype.isEnd = function() {
  113483. return this._pos >= this._maxPos
  113484. }
  113485. ,
  113486. a
  113487. }()
  113488. , glTFTransforms = ["MODEL", "VIEW", "PROJECTION", "MODELVIEW", "MODELVIEWPROJECTION", "JOINTMATRIX"]
  113489. , babylonTransforms = ["world", "view", "projection", "worldView", "worldViewProjection", "mBones"]
  113490. , glTFAnimationPaths = ["translation", "rotation", "scale"]
  113491. , babylonAnimationPaths = ["position", "rotationQuaternion", "scaling"]
  113492. , parseBuffers = function(a, e) {
  113493. for (var i in a) {
  113494. var o = a[i];
  113495. e.buffers[i] = o,
  113496. e.buffersCount++
  113497. }
  113498. }
  113499. , parseShaders = function(a, e) {
  113500. for (var i in a) {
  113501. var o = a[i];
  113502. e.shaders[i] = o,
  113503. e.shaderscount++
  113504. }
  113505. }
  113506. , parseObject = function(a, e, i) {
  113507. for (var o in a) {
  113508. var s = a[o];
  113509. i[e][o] = s
  113510. }
  113511. }
  113512. , normalizeUVs = function(a) {
  113513. if (!!a)
  113514. for (var e = 0; e < a.length / 2; e++)
  113515. a[e * 2 + 1] = 1 - a[e * 2 + 1]
  113516. }
  113517. , getAttribute = function(a) {
  113518. if (a.semantic === "NORMAL")
  113519. return "normal";
  113520. if (a.semantic === "POSITION")
  113521. return "position";
  113522. if (a.semantic === "JOINT")
  113523. return "matricesIndices";
  113524. if (a.semantic === "WEIGHT")
  113525. return "matricesWeights";
  113526. if (a.semantic === "COLOR")
  113527. return "color";
  113528. if (a.semantic && a.semantic.indexOf("TEXCOORD_") !== -1) {
  113529. var e = Number(a.semantic.split("_")[1]);
  113530. return "uv" + (e === 0 ? "" : e + 1)
  113531. }
  113532. return null
  113533. }
  113534. , loadAnimations = function(a) {
  113535. for (var e in a.animations) {
  113536. var i = a.animations[e];
  113537. if (!(!i.channels || !i.samplers))
  113538. for (var o = null, s = 0; s < i.channels.length; s++) {
  113539. var c = i.channels[s]
  113540. , d = i.samplers[c.sampler];
  113541. if (!!d) {
  113542. var _ = null
  113543. , b = null;
  113544. i.parameters ? (_ = i.parameters[d.input],
  113545. b = i.parameters[d.output]) : (_ = d.input,
  113546. b = d.output);
  113547. var k = GLTFUtils.GetBufferFromAccessor(a, a.accessors[_])
  113548. , j = GLTFUtils.GetBufferFromAccessor(a, a.accessors[b])
  113549. , $ = c.target.id
  113550. , _e = a.scene.getNodeById($);
  113551. if (_e === null && (_e = a.scene.getNodeByName($)),
  113552. _e === null) {
  113553. Tools.Warn("Creating animation named " + e + ". But cannot find node named " + $ + " to attach to");
  113554. continue
  113555. }
  113556. var et = _e instanceof Bone
  113557. , tt = c.target.path
  113558. , rt = glTFAnimationPaths.indexOf(tt);
  113559. rt !== -1 && (tt = babylonAnimationPaths[rt]);
  113560. var it = Animation.ANIMATIONTYPE_MATRIX;
  113561. et || (tt === "rotationQuaternion" ? (it = Animation.ANIMATIONTYPE_QUATERNION,
  113562. _e.rotationQuaternion = new Quaternion) : it = Animation.ANIMATIONTYPE_VECTOR3);
  113563. var nt = null
  113564. , ot = []
  113565. , at = 0
  113566. , st = !1;
  113567. et && o && o.getKeys().length === k.length && (nt = o,
  113568. st = !0),
  113569. st || (a.scene._blockEntityCollection = !!a.assetContainer,
  113570. nt = new Animation(e,et ? "_matrix" : tt,1,it,Animation.ANIMATIONLOOPMODE_CYCLE),
  113571. a.scene._blockEntityCollection = !1);
  113572. for (var ut = 0; ut < k.length; ut++) {
  113573. var ct = null;
  113574. if (tt === "rotationQuaternion" ? (ct = Quaternion.FromArray([j[at], j[at + 1], j[at + 2], j[at + 3]]),
  113575. at += 4) : (ct = Vector3.FromArray([j[at], j[at + 1], j[at + 2]]),
  113576. at += 3),
  113577. et) {
  113578. var lt = _e
  113579. , ft = Vector3.Zero()
  113580. , ht = new Quaternion
  113581. , pt = Vector3.Zero()
  113582. , dt = lt.getBaseMatrix();
  113583. st && o && (dt = o.getKeys()[ut].value),
  113584. dt.decompose(pt, ht, ft),
  113585. tt === "position" ? ft = ct : tt === "rotationQuaternion" ? ht = ct : pt = ct,
  113586. ct = Matrix.Compose(pt, ht, ft)
  113587. }
  113588. st ? o && (o.getKeys()[ut].value = ct) : ot.push({
  113589. frame: k[ut],
  113590. value: ct
  113591. })
  113592. }
  113593. !st && nt && (nt.setKeys(ot),
  113594. _e.animations.push(nt)),
  113595. o = nt,
  113596. a.scene.stopAnimation(_e),
  113597. a.scene.beginAnimation(_e, 0, k[k.length - 1], !0, 1)
  113598. }
  113599. }
  113600. }
  113601. }
  113602. , configureBoneTransformation = function(a) {
  113603. var e = null;
  113604. if (a.translation || a.rotation || a.scale) {
  113605. var i = Vector3.FromArray(a.scale || [1, 1, 1])
  113606. , o = Quaternion.FromArray(a.rotation || [0, 0, 0, 1])
  113607. , s = Vector3.FromArray(a.translation || [0, 0, 0]);
  113608. e = Matrix.Compose(i, o, s)
  113609. } else
  113610. e = Matrix.FromArray(a.matrix);
  113611. return e
  113612. }
  113613. , getParentBone = function(a, e, i, o) {
  113614. for (var s = 0; s < o.bones.length; s++)
  113615. if (o.bones[s].name === i)
  113616. return o.bones[s];
  113617. var c = a.nodes;
  113618. for (var d in c) {
  113619. var _ = c[d];
  113620. if (!!_.jointName)
  113621. for (var b = _.children, s = 0; s < b.length; s++) {
  113622. var k = a.nodes[b[s]];
  113623. if (!!k.jointName && k.jointName === i) {
  113624. var j = configureBoneTransformation(_)
  113625. , $ = new Bone(_.name || "",o,getParentBone(a, e, _.jointName, o),j);
  113626. return $.id = d,
  113627. $
  113628. }
  113629. }
  113630. }
  113631. return null
  113632. }
  113633. , getNodeToRoot = function(a, e) {
  113634. for (var i = 0; i < a.length; i++)
  113635. for (var o = a[i], s = 0; s < o.node.children.length; s++) {
  113636. var c = o.node.children[s];
  113637. if (c === e)
  113638. return o.bone
  113639. }
  113640. return null
  113641. }
  113642. , getJointNode = function(a, e) {
  113643. var i = a.nodes
  113644. , o = i[e];
  113645. if (o)
  113646. return {
  113647. node: o,
  113648. id: e
  113649. };
  113650. for (var s in i)
  113651. if (o = i[s],
  113652. o.jointName === e)
  113653. return {
  113654. node: o,
  113655. id: s
  113656. };
  113657. return null
  113658. }
  113659. , nodeIsInJoints = function(a, e) {
  113660. for (var i = 0; i < a.jointNames.length; i++)
  113661. if (a.jointNames[i] === e)
  113662. return !0;
  113663. return !1
  113664. }
  113665. , getNodesToRoot = function(a, e, i, o) {
  113666. for (var s in a.nodes) {
  113667. var c = a.nodes[s]
  113668. , d = s;
  113669. if (!(!c.jointName || nodeIsInJoints(i, c.jointName))) {
  113670. var _ = configureBoneTransformation(c)
  113671. , b = new Bone(c.name || "",e,null,_);
  113672. b.id = d,
  113673. o.push({
  113674. bone: b,
  113675. node: c,
  113676. id: d
  113677. })
  113678. }
  113679. }
  113680. for (var k = 0; k < o.length; k++)
  113681. for (var j = o[k], $ = j.node.children, _e = 0; _e < $.length; _e++) {
  113682. for (var et = null, tt = 0; tt < o.length; tt++)
  113683. if (o[tt].id === $[_e]) {
  113684. et = o[tt];
  113685. break
  113686. }
  113687. et && (et.bone._parent = j.bone,
  113688. j.bone.children.push(et.bone))
  113689. }
  113690. }
  113691. , importSkeleton = function(a, e, i, o, s) {
  113692. if (o || (o = new Skeleton(e.name || "","",a.scene)),
  113693. !e.babylonSkeleton)
  113694. return o;
  113695. var c = []
  113696. , d = [];
  113697. getNodesToRoot(a, o, e, c),
  113698. o.bones = [];
  113699. for (var _ = 0; _ < e.jointNames.length; _++) {
  113700. var b = getJointNode(a, e.jointNames[_]);
  113701. if (!!b) {
  113702. var k = b.node;
  113703. if (!k) {
  113704. Tools.Warn("Joint named " + e.jointNames[_] + " does not exist");
  113705. continue
  113706. }
  113707. var s = b.id
  113708. , j = a.scene.getBoneById(s);
  113709. if (j) {
  113710. o.bones.push(j);
  113711. continue
  113712. }
  113713. for (var $ = !1, _e = null, et = 0; et < _; et++) {
  113714. var tt = getJointNode(a, e.jointNames[et]);
  113715. if (!!tt) {
  113716. var rt = tt.node;
  113717. if (!rt) {
  113718. Tools.Warn("Joint named " + e.jointNames[et] + " does not exist when looking for parent");
  113719. continue
  113720. }
  113721. var it = rt.children;
  113722. if (!!it) {
  113723. $ = !1;
  113724. for (var nt = 0; nt < it.length; nt++)
  113725. if (it[nt] === s) {
  113726. _e = getParentBone(a, e, e.jointNames[et], o),
  113727. $ = !0;
  113728. break
  113729. }
  113730. if ($)
  113731. break
  113732. }
  113733. }
  113734. }
  113735. var ot = configureBoneTransformation(k);
  113736. !_e && c.length > 0 && (_e = getNodeToRoot(c, s),
  113737. _e && d.indexOf(_e) === -1 && d.push(_e));
  113738. var at = new Bone(k.jointName || "",o,_e,ot);
  113739. at.id = s
  113740. }
  113741. }
  113742. var st = o.bones;
  113743. o.bones = [];
  113744. for (var _ = 0; _ < e.jointNames.length; _++) {
  113745. var b = getJointNode(a, e.jointNames[_]);
  113746. if (!!b) {
  113747. for (var et = 0; et < st.length; et++)
  113748. if (st[et].id === b.id) {
  113749. o.bones.push(st[et]);
  113750. break
  113751. }
  113752. }
  113753. }
  113754. o.prepare();
  113755. for (var _ = 0; _ < d.length; _++)
  113756. o.bones.push(d[_]);
  113757. return o
  113758. }
  113759. , importMesh = function(a, e, i, o, s) {
  113760. if (s || (a.scene._blockEntityCollection = !!a.assetContainer,
  113761. s = new Mesh(e.name || "",a.scene),
  113762. s._parentContainer = a.assetContainer,
  113763. a.scene._blockEntityCollection = !1,
  113764. s.id = o),
  113765. !e.babylonNode)
  113766. return s;
  113767. for (var c = [], d = null, _ = new Array, b = new Array, k = new Array, j = new Array, $ = 0; $ < i.length; $++) {
  113768. var _e = i[$]
  113769. , et = a.meshes[_e];
  113770. if (!!et)
  113771. for (var tt = 0; tt < et.primitives.length; tt++) {
  113772. var rt = new VertexData
  113773. , it = et.primitives[tt];
  113774. it.mode;
  113775. var nt = it.attributes
  113776. , ot = null
  113777. , at = null;
  113778. for (var st in nt)
  113779. if (ot = a.accessors[nt[st]],
  113780. at = GLTFUtils.GetBufferFromAccessor(a, ot),
  113781. st === "NORMAL")
  113782. rt.normals = new Float32Array(at.length),
  113783. rt.normals.set(at);
  113784. else if (st === "POSITION") {
  113785. if (GLTFFileLoader.HomogeneousCoordinates) {
  113786. rt.positions = new Float32Array(at.length - at.length / 4);
  113787. for (var ut = 0; ut < at.length; ut += 4)
  113788. rt.positions[ut] = at[ut],
  113789. rt.positions[ut + 1] = at[ut + 1],
  113790. rt.positions[ut + 2] = at[ut + 2]
  113791. } else
  113792. rt.positions = new Float32Array(at.length),
  113793. rt.positions.set(at);
  113794. b.push(rt.positions.length)
  113795. } else if (st.indexOf("TEXCOORD_") !== -1) {
  113796. var ct = Number(st.split("_")[1])
  113797. , lt = VertexBuffer.UVKind + (ct === 0 ? "" : ct + 1)
  113798. , ft = new Float32Array(at.length);
  113799. ft.set(at),
  113800. normalizeUVs(ft),
  113801. rt.set(ft, lt)
  113802. } else
  113803. st === "JOINT" ? (rt.matricesIndices = new Float32Array(at.length),
  113804. rt.matricesIndices.set(at)) : st === "WEIGHT" ? (rt.matricesWeights = new Float32Array(at.length),
  113805. rt.matricesWeights.set(at)) : st === "COLOR" && (rt.colors = new Float32Array(at.length),
  113806. rt.colors.set(at));
  113807. if (ot = a.accessors[it.indices],
  113808. ot)
  113809. at = GLTFUtils.GetBufferFromAccessor(a, ot),
  113810. rt.indices = new Int32Array(at.length),
  113811. rt.indices.set(at),
  113812. j.push(rt.indices.length);
  113813. else {
  113814. for (var ht = [], ut = 0; ut < rt.positions.length / 3; ut++)
  113815. ht.push(ut);
  113816. rt.indices = new Int32Array(ht),
  113817. j.push(rt.indices.length)
  113818. }
  113819. d ? d.merge(rt) : d = rt;
  113820. var pt = a.scene.getMaterialById(it.material);
  113821. c.push(pt === null ? GLTFUtils.GetDefaultMaterial(a.scene) : pt),
  113822. _.push(_.length === 0 ? 0 : _[_.length - 1] + b[b.length - 2]),
  113823. k.push(k.length === 0 ? 0 : k[k.length - 1] + j[j.length - 2])
  113824. }
  113825. }
  113826. var dt;
  113827. a.scene._blockEntityCollection = !!a.assetContainer,
  113828. c.length > 1 ? (dt = new MultiMaterial("multimat" + o,a.scene),
  113829. dt.subMaterials = c) : dt = new StandardMaterial("multimat" + o,a.scene),
  113830. c.length === 1 && (dt = c[0]),
  113831. dt._parentContainer = a.assetContainer,
  113832. s.material || (s.material = dt),
  113833. new Geometry(o,a.scene,d,!1,s),
  113834. s.computeWorldMatrix(!0),
  113835. a.scene._blockEntityCollection = !1,
  113836. s.subMeshes = [];
  113837. for (var _t = 0, $ = 0; $ < i.length; $++) {
  113838. var _e = i[$]
  113839. , et = a.meshes[_e];
  113840. if (!!et)
  113841. for (var tt = 0; tt < et.primitives.length; tt++)
  113842. et.primitives[tt].mode,
  113843. SubMesh.AddToMesh(_t, _[_t], b[_t], k[_t], j[_t], s, s, !0),
  113844. _t++
  113845. }
  113846. return s
  113847. }
  113848. , configureNode = function(a, e, i, o) {
  113849. a.position && (a.position = e),
  113850. (a.rotationQuaternion || a.rotation) && (a.rotationQuaternion = i),
  113851. a.scaling && (a.scaling = o)
  113852. }
  113853. , configureNodeFromMatrix = function(a, e, i) {
  113854. if (e.matrix) {
  113855. var o = new Vector3(0,0,0)
  113856. , s = new Quaternion
  113857. , c = new Vector3(0,0,0)
  113858. , d = Matrix.FromArray(e.matrix);
  113859. d.decompose(c, s, o),
  113860. configureNode(a, o, s, c)
  113861. } else
  113862. e.translation && e.rotation && e.scale && configureNode(a, Vector3.FromArray(e.translation), Quaternion.FromArray(e.rotation), Vector3.FromArray(e.scale));
  113863. a.computeWorldMatrix(!0)
  113864. }
  113865. , importNode$1 = function(a, e, i, o) {
  113866. var s = null;
  113867. if (a.importOnlyMeshes && (e.skin || e.meshes) && a.importMeshesNames && a.importMeshesNames.length > 0 && a.importMeshesNames.indexOf(e.name || "") === -1)
  113868. return null;
  113869. if (e.skin) {
  113870. if (e.meshes) {
  113871. var c = a.skins[e.skin]
  113872. , d = importMesh(a, e, e.meshes, i, e.babylonNode);
  113873. d.skeleton = a.scene.getLastSkeletonById(e.skin),
  113874. d.skeleton === null && (d.skeleton = importSkeleton(a, c, d, c.babylonSkeleton, e.skin),
  113875. c.babylonSkeleton || (c.babylonSkeleton = d.skeleton)),
  113876. s = d
  113877. }
  113878. } else if (e.meshes) {
  113879. var d = importMesh(a, e, e.mesh ? [e.mesh] : e.meshes, i, e.babylonNode);
  113880. s = d
  113881. } else if (e.light && !e.babylonNode && !a.importOnlyMeshes) {
  113882. var _ = a.lights[e.light];
  113883. if (_) {
  113884. if (_.type === "ambient") {
  113885. var b = _[_.type]
  113886. , k = new HemisphericLight(e.light,Vector3.Zero(),a.scene);
  113887. k.name = e.name || "",
  113888. b.color && (k.diffuse = Color3.FromArray(b.color)),
  113889. s = k
  113890. } else if (_.type === "directional") {
  113891. var j = _[_.type]
  113892. , $ = new DirectionalLight(e.light,Vector3.Zero(),a.scene);
  113893. $.name = e.name || "",
  113894. j.color && ($.diffuse = Color3.FromArray(j.color)),
  113895. s = $
  113896. } else if (_.type === "point") {
  113897. var _e = _[_.type]
  113898. , et = new PointLight(e.light,Vector3.Zero(),a.scene);
  113899. et.name = e.name || "",
  113900. _e.color && (et.diffuse = Color3.FromArray(_e.color)),
  113901. s = et
  113902. } else if (_.type === "spot") {
  113903. var tt = _[_.type]
  113904. , rt = new SpotLight(e.light,Vector3.Zero(),Vector3.Zero(),0,0,a.scene);
  113905. rt.name = e.name || "",
  113906. tt.color && (rt.diffuse = Color3.FromArray(tt.color)),
  113907. tt.fallOfAngle && (rt.angle = tt.fallOfAngle),
  113908. tt.fallOffExponent && (rt.exponent = tt.fallOffExponent),
  113909. s = rt
  113910. }
  113911. }
  113912. } else if (e.camera && !e.babylonNode && !a.importOnlyMeshes) {
  113913. var it = a.cameras[e.camera];
  113914. if (it) {
  113915. if (a.scene._blockEntityCollection = !!a.assetContainer,
  113916. it.type === "orthographic") {
  113917. var nt = new FreeCamera(e.camera,Vector3.Zero(),a.scene,!1);
  113918. nt.name = e.name || "",
  113919. nt.mode = Camera$1.ORTHOGRAPHIC_CAMERA,
  113920. nt.attachControl(),
  113921. s = nt,
  113922. nt._parentContainer = a.assetContainer
  113923. } else if (it.type === "perspective") {
  113924. var ot = it[it.type]
  113925. , at = new FreeCamera(e.camera,Vector3.Zero(),a.scene,!1);
  113926. at.name = e.name || "",
  113927. at.attachControl(),
  113928. ot.aspectRatio || (ot.aspectRatio = a.scene.getEngine().getRenderWidth() / a.scene.getEngine().getRenderHeight()),
  113929. ot.znear && ot.zfar && (at.maxZ = ot.zfar,
  113930. at.minZ = ot.znear),
  113931. s = at,
  113932. at._parentContainer = a.assetContainer
  113933. }
  113934. a.scene._blockEntityCollection = !1
  113935. }
  113936. }
  113937. if (!e.jointName) {
  113938. if (e.babylonNode)
  113939. return e.babylonNode;
  113940. if (s === null) {
  113941. a.scene._blockEntityCollection = !!a.assetContainer;
  113942. var st = new Mesh(e.name || "",a.scene);
  113943. st._parentContainer = a.assetContainer,
  113944. a.scene._blockEntityCollection = !1,
  113945. e.babylonNode = st,
  113946. s = st
  113947. }
  113948. }
  113949. if (s !== null) {
  113950. if (e.matrix && s instanceof Mesh)
  113951. configureNodeFromMatrix(s, e);
  113952. else {
  113953. var ut = e.translation || [0, 0, 0]
  113954. , ct = e.rotation || [0, 0, 0, 1]
  113955. , lt = e.scale || [1, 1, 1];
  113956. configureNode(s, Vector3.FromArray(ut), Quaternion.FromArray(ct), Vector3.FromArray(lt))
  113957. }
  113958. s.updateCache(!0),
  113959. e.babylonNode = s
  113960. }
  113961. return s
  113962. }
  113963. , traverseNodes = function(a, e, i, o) {
  113964. o === void 0 && (o = !1);
  113965. var s = a.nodes[e]
  113966. , c = null;
  113967. if (a.importOnlyMeshes && !o && a.importMeshesNames ? a.importMeshesNames.indexOf(s.name || "") !== -1 || a.importMeshesNames.length === 0 ? o = !0 : o = !1 : o = !0,
  113968. !s.jointName && o && (c = importNode$1(a, s, e),
  113969. c !== null && (c.id = e,
  113970. c.parent = i)),
  113971. s.children)
  113972. for (var d = 0; d < s.children.length; d++)
  113973. traverseNodes(a, s.children[d], c, o)
  113974. }
  113975. , postLoad = function(a) {
  113976. var e = a.currentScene;
  113977. if (e)
  113978. for (var i = 0; i < e.nodes.length; i++)
  113979. traverseNodes(a, e.nodes[i], null);
  113980. else
  113981. for (var o in a.scenes) {
  113982. e = a.scenes[o];
  113983. for (var i = 0; i < e.nodes.length; i++)
  113984. traverseNodes(a, e.nodes[i], null)
  113985. }
  113986. loadAnimations(a);
  113987. for (var i = 0; i < a.scene.skeletons.length; i++) {
  113988. var s = a.scene.skeletons[i];
  113989. a.scene.beginAnimation(s, 0, Number.MAX_VALUE, !0, 1)
  113990. }
  113991. }
  113992. , onBindShaderMaterial = function(a, e, i, o, s, c, d) {
  113993. var _ = c.values || s.parameters;
  113994. for (var b in i) {
  113995. var k = i[b]
  113996. , j = k.type;
  113997. if (j === EParameterType.FLOAT_MAT2 || j === EParameterType.FLOAT_MAT3 || j === EParameterType.FLOAT_MAT4) {
  113998. if (k.semantic && !k.source && !k.node)
  113999. GLTFUtils.SetMatrix(e.scene, a, k, b, o.getEffect());
  114000. else if (k.semantic && (k.source || k.node)) {
  114001. var $ = e.scene.getNodeByName(k.source || k.node || "");
  114002. if ($ === null && ($ = e.scene.getNodeById(k.source || k.node || "")),
  114003. $ === null)
  114004. continue;
  114005. GLTFUtils.SetMatrix(e.scene, $, k, b, o.getEffect())
  114006. }
  114007. } else {
  114008. var _e = _[s.uniforms[b]];
  114009. if (!_e)
  114010. continue;
  114011. if (j === EParameterType.SAMPLER_2D) {
  114012. var et = e.textures[c.values ? _e : k.value].babylonTexture;
  114013. if (et == null)
  114014. continue;
  114015. o.getEffect().setTexture(b, et)
  114016. } else
  114017. GLTFUtils.SetUniform(o.getEffect(), b, _e, j)
  114018. }
  114019. }
  114020. d(o)
  114021. }
  114022. , prepareShaderMaterialUniforms = function(a, e, i, o, s) {
  114023. var c = o.values || i.parameters
  114024. , d = i.uniforms;
  114025. for (var _ in s) {
  114026. var b = s[_]
  114027. , k = b.type
  114028. , j = c[d[_]];
  114029. if (j === void 0 && (j = b.value),
  114030. !!j) {
  114031. var $ = function(_e) {
  114032. return function(et) {
  114033. b.value && _e && (e.setTexture(_e, et),
  114034. delete s[_e])
  114035. }
  114036. };
  114037. k === EParameterType.SAMPLER_2D ? GLTFLoaderExtension.LoadTextureAsync(a, o.values ? j : b.value, $(_), function() {
  114038. return $(null)
  114039. }) : b.value && GLTFUtils.SetUniform(e, _, o.values ? j : b.value, k) && delete s[_]
  114040. }
  114041. }
  114042. }
  114043. , onShaderCompileError = function(a, e, i) {
  114044. return function(o, s) {
  114045. e.dispose(!0),
  114046. i("Cannot compile program named " + a.name + ". Error: " + s + ". Default material will be applied")
  114047. }
  114048. }
  114049. , onShaderCompileSuccess = function(a, e, i, o, s, c) {
  114050. return function(d) {
  114051. prepareShaderMaterialUniforms(a, e, i, o, s),
  114052. e.onBind = function(_) {
  114053. onBindShaderMaterial(_, a, s, e, i, o, c)
  114054. }
  114055. }
  114056. }
  114057. , parseShaderUniforms = function(a, e, i) {
  114058. for (var o in e.uniforms) {
  114059. var s = e.uniforms[o]
  114060. , c = e.parameters[s];
  114061. if (a.currentIdentifier === o && c.semantic && !c.source && !c.node) {
  114062. var d = glTFTransforms.indexOf(c.semantic);
  114063. if (d !== -1)
  114064. return delete i[o],
  114065. babylonTransforms[d]
  114066. }
  114067. }
  114068. return a.currentIdentifier
  114069. }
  114070. , importMaterials = function(a) {
  114071. for (var e in a.materials)
  114072. GLTFLoaderExtension.LoadMaterialAsync(a, e, function(i) {}, function() {})
  114073. }
  114074. , GLTFLoaderBase = function() {
  114075. function a() {}
  114076. return a.CreateRuntime = function(e, i, o) {
  114077. var s = {
  114078. extensions: {},
  114079. accessors: {},
  114080. buffers: {},
  114081. bufferViews: {},
  114082. meshes: {},
  114083. lights: {},
  114084. cameras: {},
  114085. nodes: {},
  114086. images: {},
  114087. textures: {},
  114088. shaders: {},
  114089. programs: {},
  114090. samplers: {},
  114091. techniques: {},
  114092. materials: {},
  114093. animations: {},
  114094. skins: {},
  114095. extensionsUsed: [],
  114096. scenes: {},
  114097. buffersCount: 0,
  114098. shaderscount: 0,
  114099. scene: i,
  114100. rootUrl: o,
  114101. loadedBufferCount: 0,
  114102. loadedBufferViews: {},
  114103. loadedShaderCount: 0,
  114104. importOnlyMeshes: !1,
  114105. dummyNodes: [],
  114106. assetContainer: null
  114107. };
  114108. return e.extensions && parseObject(e.extensions, "extensions", s),
  114109. e.extensionsUsed && parseObject(e.extensionsUsed, "extensionsUsed", s),
  114110. e.buffers && parseBuffers(e.buffers, s),
  114111. e.bufferViews && parseObject(e.bufferViews, "bufferViews", s),
  114112. e.accessors && parseObject(e.accessors, "accessors", s),
  114113. e.meshes && parseObject(e.meshes, "meshes", s),
  114114. e.lights && parseObject(e.lights, "lights", s),
  114115. e.cameras && parseObject(e.cameras, "cameras", s),
  114116. e.nodes && parseObject(e.nodes, "nodes", s),
  114117. e.images && parseObject(e.images, "images", s),
  114118. e.textures && parseObject(e.textures, "textures", s),
  114119. e.shaders && parseShaders(e.shaders, s),
  114120. e.programs && parseObject(e.programs, "programs", s),
  114121. e.samplers && parseObject(e.samplers, "samplers", s),
  114122. e.techniques && parseObject(e.techniques, "techniques", s),
  114123. e.materials && parseObject(e.materials, "materials", s),
  114124. e.animations && parseObject(e.animations, "animations", s),
  114125. e.skins && parseObject(e.skins, "skins", s),
  114126. e.scenes && (s.scenes = e.scenes),
  114127. e.scene && e.scenes && (s.currentScene = e.scenes[e.scene]),
  114128. s
  114129. }
  114130. ,
  114131. a.LoadBufferAsync = function(e, i, o, s, c) {
  114132. var d = e.buffers[i];
  114133. Tools.IsBase64(d.uri) ? setTimeout(function() {
  114134. return o(new Uint8Array(Tools.DecodeBase64(d.uri)))
  114135. }) : Tools.LoadFile(e.rootUrl + d.uri, function(_) {
  114136. return o(new Uint8Array(_))
  114137. }, c, void 0, !0, function(_) {
  114138. _ && s(_.status + " " + _.statusText)
  114139. })
  114140. }
  114141. ,
  114142. a.LoadTextureBufferAsync = function(e, i, o, s) {
  114143. var c = e.textures[i];
  114144. if (!c || !c.source) {
  114145. s("");
  114146. return
  114147. }
  114148. if (c.babylonTexture) {
  114149. o(null);
  114150. return
  114151. }
  114152. var d = e.images[c.source];
  114153. Tools.IsBase64(d.uri) ? setTimeout(function() {
  114154. return o(new Uint8Array(Tools.DecodeBase64(d.uri)))
  114155. }) : Tools.LoadFile(e.rootUrl + d.uri, function(_) {
  114156. return o(new Uint8Array(_))
  114157. }, void 0, void 0, !0, function(_) {
  114158. _ && s(_.status + " " + _.statusText)
  114159. })
  114160. }
  114161. ,
  114162. a.CreateTextureAsync = function(e, i, o, s, c) {
  114163. var d = e.textures[i];
  114164. if (d.babylonTexture) {
  114165. s(d.babylonTexture);
  114166. return
  114167. }
  114168. var _ = e.samplers[d.sampler]
  114169. , b = _.minFilter === ETextureFilterType.NEAREST_MIPMAP_NEAREST || _.minFilter === ETextureFilterType.NEAREST_MIPMAP_LINEAR || _.minFilter === ETextureFilterType.LINEAR_MIPMAP_NEAREST || _.minFilter === ETextureFilterType.LINEAR_MIPMAP_LINEAR
  114170. , k = Texture.BILINEAR_SAMPLINGMODE
  114171. , j = o == null ? new Blob : new Blob([o])
  114172. , $ = URL.createObjectURL(j)
  114173. , _e = function() {
  114174. return URL.revokeObjectURL($)
  114175. }
  114176. , et = new Texture($,e.scene,!b,!0,k,_e,_e);
  114177. _.wrapS !== void 0 && (et.wrapU = GLTFUtils.GetWrapMode(_.wrapS)),
  114178. _.wrapT !== void 0 && (et.wrapV = GLTFUtils.GetWrapMode(_.wrapT)),
  114179. et.name = i,
  114180. d.babylonTexture = et,
  114181. s(et)
  114182. }
  114183. ,
  114184. a.LoadShaderStringAsync = function(e, i, o, s) {
  114185. var c = e.shaders[i];
  114186. if (Tools.IsBase64(c.uri)) {
  114187. var d = atob(c.uri.split(",")[1]);
  114188. o && o(d)
  114189. } else
  114190. Tools.LoadFile(e.rootUrl + c.uri, o, void 0, void 0, !1, function(_) {
  114191. _ && s && s(_.status + " " + _.statusText)
  114192. })
  114193. }
  114194. ,
  114195. a.LoadMaterialAsync = function(e, i, o, s) {
  114196. var c = e.materials[i];
  114197. if (!c.technique) {
  114198. s && s("No technique found.");
  114199. return
  114200. }
  114201. var d = e.techniques[c.technique];
  114202. if (!d) {
  114203. e.scene._blockEntityCollection = !!e.assetContainer;
  114204. var _ = new StandardMaterial(i,e.scene);
  114205. _._parentContainer = e.assetContainer,
  114206. e.scene._blockEntityCollection = !1,
  114207. _.diffuseColor = new Color3(.5,.5,.5),
  114208. _.sideOrientation = Material.CounterClockWiseSideOrientation,
  114209. o(_);
  114210. return
  114211. }
  114212. var b = e.programs[d.program]
  114213. , k = d.states
  114214. , j = Effect.ShadersStore[b.vertexShader + "VertexShader"]
  114215. , $ = Effect.ShadersStore[b.fragmentShader + "PixelShader"]
  114216. , _e = ""
  114217. , et = ""
  114218. , tt = new Tokenizer(j)
  114219. , rt = new Tokenizer($)
  114220. , it = {}
  114221. , nt = []
  114222. , ot = []
  114223. , at = [];
  114224. for (var st in d.uniforms) {
  114225. var ut = d.uniforms[st]
  114226. , ct = d.parameters[ut];
  114227. if (it[st] = ct,
  114228. ct.semantic && !ct.node && !ct.source) {
  114229. var lt = glTFTransforms.indexOf(ct.semantic);
  114230. lt !== -1 ? (nt.push(babylonTransforms[lt]),
  114231. delete it[st]) : nt.push(st)
  114232. } else
  114233. ct.type === EParameterType.SAMPLER_2D ? at.push(st) : nt.push(st)
  114234. }
  114235. for (var ft in d.attributes) {
  114236. var ht = d.attributes[ft]
  114237. , pt = d.parameters[ht];
  114238. if (pt.semantic) {
  114239. var dt = getAttribute(pt);
  114240. dt && ot.push(dt)
  114241. }
  114242. }
  114243. for (; !tt.isEnd() && tt.getNextToken(); ) {
  114244. var _t = tt.currentToken;
  114245. if (_t !== ETokenType.IDENTIFIER) {
  114246. _e += tt.currentString;
  114247. continue
  114248. }
  114249. var mt = !1;
  114250. for (var ft in d.attributes) {
  114251. var ht = d.attributes[ft]
  114252. , pt = d.parameters[ht];
  114253. if (tt.currentIdentifier === ft && pt.semantic) {
  114254. _e += getAttribute(pt),
  114255. mt = !0;
  114256. break
  114257. }
  114258. }
  114259. mt || (_e += parseShaderUniforms(tt, d, it))
  114260. }
  114261. for (; !rt.isEnd() && rt.getNextToken(); ) {
  114262. var _t = rt.currentToken;
  114263. if (_t !== ETokenType.IDENTIFIER) {
  114264. et += rt.currentString;
  114265. continue
  114266. }
  114267. et += parseShaderUniforms(rt, d, it)
  114268. }
  114269. var vt = {
  114270. vertex: b.vertexShader + i,
  114271. fragment: b.fragmentShader + i
  114272. }
  114273. , yt = {
  114274. attributes: ot,
  114275. uniforms: nt,
  114276. samplers: at,
  114277. needAlphaBlending: k && k.enable && k.enable.indexOf(3042) !== -1
  114278. };
  114279. Effect.ShadersStore[b.vertexShader + i + "VertexShader"] = _e,
  114280. Effect.ShadersStore[b.fragmentShader + i + "PixelShader"] = et;
  114281. var Et = new ShaderMaterial(i,e.scene,vt,yt);
  114282. if (Et.onError = onShaderCompileError(b, Et, s),
  114283. Et.onCompiled = onShaderCompileSuccess(e, Et, d, c, it, o),
  114284. Et.sideOrientation = Material.CounterClockWiseSideOrientation,
  114285. k && k.functions) {
  114286. var At = k.functions;
  114287. At.cullFace && At.cullFace[0] !== ECullingType.BACK && (Et.backFaceCulling = !1);
  114288. var gt = At.blendFuncSeparate;
  114289. gt && (gt[0] === EBlendingFunction.SRC_ALPHA && gt[1] === EBlendingFunction.ONE_MINUS_SRC_ALPHA && gt[2] === EBlendingFunction.ONE && gt[3] === EBlendingFunction.ONE ? Et.alphaMode = Constants.ALPHA_COMBINE : gt[0] === EBlendingFunction.ONE && gt[1] === EBlendingFunction.ONE && gt[2] === EBlendingFunction.ZERO && gt[3] === EBlendingFunction.ONE ? Et.alphaMode = Constants.ALPHA_ONEONE : gt[0] === EBlendingFunction.SRC_ALPHA && gt[1] === EBlendingFunction.ONE && gt[2] === EBlendingFunction.ZERO && gt[3] === EBlendingFunction.ONE ? Et.alphaMode = Constants.ALPHA_ADD : gt[0] === EBlendingFunction.ZERO && gt[1] === EBlendingFunction.ONE_MINUS_SRC_COLOR && gt[2] === EBlendingFunction.ONE && gt[3] === EBlendingFunction.ONE ? Et.alphaMode = Constants.ALPHA_SUBTRACT : gt[0] === EBlendingFunction.DST_COLOR && gt[1] === EBlendingFunction.ZERO && gt[2] === EBlendingFunction.ONE && gt[3] === EBlendingFunction.ONE ? Et.alphaMode = Constants.ALPHA_MULTIPLY : gt[0] === EBlendingFunction.SRC_ALPHA && gt[1] === EBlendingFunction.ONE_MINUS_SRC_COLOR && gt[2] === EBlendingFunction.ONE && gt[3] === EBlendingFunction.ONE && (Et.alphaMode = Constants.ALPHA_MAXIMIZED))
  114290. }
  114291. }
  114292. ,
  114293. a
  114294. }()
  114295. , GLTFLoader$1 = function() {
  114296. function a() {}
  114297. return a.RegisterExtension = function(e) {
  114298. if (a.Extensions[e.name]) {
  114299. Tools.Error('Tool with the same name "' + e.name + '" already exists');
  114300. return
  114301. }
  114302. a.Extensions[e.name] = e
  114303. }
  114304. ,
  114305. a.prototype.dispose = function() {}
  114306. ,
  114307. a.prototype._importMeshAsync = function(e, i, o, s, c, d, _, b) {
  114308. var k = this;
  114309. return i.useRightHandedSystem = !0,
  114310. GLTFLoaderExtension.LoadRuntimeAsync(i, o, s, function(j) {
  114311. j.assetContainer = c,
  114312. j.importOnlyMeshes = !0,
  114313. e === "" ? j.importMeshesNames = [] : typeof e == "string" ? j.importMeshesNames = [e] : e && !(e instanceof Array) ? j.importMeshesNames = [e] : (j.importMeshesNames = [],
  114314. Tools.Warn("Argument meshesNames must be of type string or string[]")),
  114315. k._createNodes(j);
  114316. var $ = new Array
  114317. , _e = new Array;
  114318. for (var et in j.nodes) {
  114319. var tt = j.nodes[et];
  114320. tt.babylonNode instanceof AbstractMesh && $.push(tt.babylonNode)
  114321. }
  114322. for (var rt in j.skins) {
  114323. var it = j.skins[rt];
  114324. it.babylonSkeleton instanceof Skeleton && _e.push(it.babylonSkeleton)
  114325. }
  114326. k._loadBuffersAsync(j, function() {
  114327. k._loadShadersAsync(j, function() {
  114328. importMaterials(j),
  114329. postLoad(j),
  114330. !GLTFFileLoader.IncrementalLoading && d && d($, _e)
  114331. })
  114332. }, _),
  114333. GLTFFileLoader.IncrementalLoading && d && d($, _e)
  114334. }, b),
  114335. !0
  114336. }
  114337. ,
  114338. a.prototype.importMeshAsync = function(e, i, o, s, c, d) {
  114339. var _ = this;
  114340. return new Promise(function(b, k) {
  114341. _._importMeshAsync(e, i, s, c, o, function(j, $) {
  114342. b({
  114343. meshes: j,
  114344. particleSystems: [],
  114345. skeletons: $,
  114346. animationGroups: [],
  114347. lights: [],
  114348. transformNodes: [],
  114349. geometries: []
  114350. })
  114351. }, d, function(j) {
  114352. k(new Error(j))
  114353. })
  114354. }
  114355. )
  114356. }
  114357. ,
  114358. a.prototype._loadAsync = function(e, i, o, s, c, d) {
  114359. var _ = this;
  114360. e.useRightHandedSystem = !0,
  114361. GLTFLoaderExtension.LoadRuntimeAsync(e, i, o, function(b) {
  114362. GLTFLoaderExtension.LoadRuntimeExtensionsAsync(b, function() {
  114363. _._createNodes(b),
  114364. _._loadBuffersAsync(b, function() {
  114365. _._loadShadersAsync(b, function() {
  114366. importMaterials(b),
  114367. postLoad(b),
  114368. GLTFFileLoader.IncrementalLoading || s()
  114369. })
  114370. }),
  114371. GLTFFileLoader.IncrementalLoading && s()
  114372. }, d)
  114373. }, d)
  114374. }
  114375. ,
  114376. a.prototype.loadAsync = function(e, i, o, s) {
  114377. var c = this;
  114378. return new Promise(function(d, _) {
  114379. c._loadAsync(e, i, o, function() {
  114380. d()
  114381. }, s, function(b) {
  114382. _(new Error(b))
  114383. })
  114384. }
  114385. )
  114386. }
  114387. ,
  114388. a.prototype._loadShadersAsync = function(e, i) {
  114389. var o = !1
  114390. , s = function(_, b) {
  114391. GLTFLoaderExtension.LoadShaderStringAsync(e, _, function(k) {
  114392. k instanceof ArrayBuffer || (e.loadedShaderCount++,
  114393. k && (Effect.ShadersStore[_ + (b.type === EShaderType.VERTEX ? "VertexShader" : "PixelShader")] = k),
  114394. e.loadedShaderCount === e.shaderscount && i())
  114395. }, function() {
  114396. Tools.Error("Error when loading shader program named " + _ + " located at " + b.uri)
  114397. })
  114398. };
  114399. for (var c in e.shaders) {
  114400. o = !0;
  114401. var d = e.shaders[c];
  114402. d ? s.bind(this, c, d)() : Tools.Error("No shader named: " + c)
  114403. }
  114404. o || i()
  114405. }
  114406. ,
  114407. a.prototype._loadBuffersAsync = function(e, i, o) {
  114408. var s = !1
  114409. , c = function(b, k) {
  114410. GLTFLoaderExtension.LoadBufferAsync(e, b, function(j) {
  114411. e.loadedBufferCount++,
  114412. j && (j.byteLength != e.buffers[b].byteLength && Tools.Error("Buffer named " + b + " is length " + j.byteLength + ". Expected: " + k.byteLength),
  114413. e.loadedBufferViews[b] = j),
  114414. e.loadedBufferCount === e.buffersCount && i()
  114415. }, function() {
  114416. Tools.Error("Error when loading buffer named " + b + " located at " + k.uri)
  114417. })
  114418. };
  114419. for (var d in e.buffers) {
  114420. s = !0;
  114421. var _ = e.buffers[d];
  114422. _ ? c.bind(this, d, _)() : Tools.Error("No buffer named: " + d)
  114423. }
  114424. s || i()
  114425. }
  114426. ,
  114427. a.prototype._createNodes = function(e) {
  114428. var i = e.currentScene;
  114429. if (i)
  114430. for (var o = 0; o < i.nodes.length; o++)
  114431. traverseNodes(e, i.nodes[o], null);
  114432. else
  114433. for (var s in e.scenes) {
  114434. i = e.scenes[s];
  114435. for (var o = 0; o < i.nodes.length; o++)
  114436. traverseNodes(e, i.nodes[o], null)
  114437. }
  114438. }
  114439. ,
  114440. a.Extensions = {},
  114441. a
  114442. }()
  114443. , GLTFLoaderExtension = function() {
  114444. function a(e) {
  114445. this._name = e
  114446. }
  114447. return Object.defineProperty(a.prototype, "name", {
  114448. get: function() {
  114449. return this._name
  114450. },
  114451. enumerable: !1,
  114452. configurable: !0
  114453. }),
  114454. a.prototype.loadRuntimeAsync = function(e, i, o, s, c) {
  114455. return !1
  114456. }
  114457. ,
  114458. a.prototype.loadRuntimeExtensionsAsync = function(e, i, o) {
  114459. return !1
  114460. }
  114461. ,
  114462. a.prototype.loadBufferAsync = function(e, i, o, s, c) {
  114463. return !1
  114464. }
  114465. ,
  114466. a.prototype.loadTextureBufferAsync = function(e, i, o, s) {
  114467. return !1
  114468. }
  114469. ,
  114470. a.prototype.createTextureAsync = function(e, i, o, s, c) {
  114471. return !1
  114472. }
  114473. ,
  114474. a.prototype.loadShaderStringAsync = function(e, i, o, s) {
  114475. return !1
  114476. }
  114477. ,
  114478. a.prototype.loadMaterialAsync = function(e, i, o, s) {
  114479. return !1
  114480. }
  114481. ,
  114482. a.LoadRuntimeAsync = function(e, i, o, s, c) {
  114483. a.ApplyExtensions(function(d) {
  114484. return d.loadRuntimeAsync(e, i, o, s, c)
  114485. }, function() {
  114486. setTimeout(function() {
  114487. !s || s(GLTFLoaderBase.CreateRuntime(i.json, e, o))
  114488. })
  114489. })
  114490. }
  114491. ,
  114492. a.LoadRuntimeExtensionsAsync = function(e, i, o) {
  114493. a.ApplyExtensions(function(s) {
  114494. return s.loadRuntimeExtensionsAsync(e, i, o)
  114495. }, function() {
  114496. setTimeout(function() {
  114497. i()
  114498. })
  114499. })
  114500. }
  114501. ,
  114502. a.LoadBufferAsync = function(e, i, o, s, c) {
  114503. a.ApplyExtensions(function(d) {
  114504. return d.loadBufferAsync(e, i, o, s, c)
  114505. }, function() {
  114506. GLTFLoaderBase.LoadBufferAsync(e, i, o, s, c)
  114507. })
  114508. }
  114509. ,
  114510. a.LoadTextureAsync = function(e, i, o, s) {
  114511. a.LoadTextureBufferAsync(e, i, function(c) {
  114512. c && a.CreateTextureAsync(e, i, c, o, s)
  114513. }, s)
  114514. }
  114515. ,
  114516. a.LoadShaderStringAsync = function(e, i, o, s) {
  114517. a.ApplyExtensions(function(c) {
  114518. return c.loadShaderStringAsync(e, i, o, s)
  114519. }, function() {
  114520. GLTFLoaderBase.LoadShaderStringAsync(e, i, o, s)
  114521. })
  114522. }
  114523. ,
  114524. a.LoadMaterialAsync = function(e, i, o, s) {
  114525. a.ApplyExtensions(function(c) {
  114526. return c.loadMaterialAsync(e, i, o, s)
  114527. }, function() {
  114528. GLTFLoaderBase.LoadMaterialAsync(e, i, o, s)
  114529. })
  114530. }
  114531. ,
  114532. a.LoadTextureBufferAsync = function(e, i, o, s) {
  114533. a.ApplyExtensions(function(c) {
  114534. return c.loadTextureBufferAsync(e, i, o, s)
  114535. }, function() {
  114536. GLTFLoaderBase.LoadTextureBufferAsync(e, i, o, s)
  114537. })
  114538. }
  114539. ,
  114540. a.CreateTextureAsync = function(e, i, o, s, c) {
  114541. a.ApplyExtensions(function(d) {
  114542. return d.createTextureAsync(e, i, o, s, c)
  114543. }, function() {
  114544. GLTFLoaderBase.CreateTextureAsync(e, i, o, s, c)
  114545. })
  114546. }
  114547. ,
  114548. a.ApplyExtensions = function(e, i) {
  114549. for (var o in GLTFLoader$1.Extensions) {
  114550. var s = GLTFLoader$1.Extensions[o];
  114551. if (e(s))
  114552. return
  114553. }
  114554. i()
  114555. }
  114556. ,
  114557. a
  114558. }();
  114559. GLTFFileLoader._CreateGLTF1Loader = function() {
  114560. return new GLTFLoader$1
  114561. }
  114562. ;
  114563. var BinaryExtensionBufferName = "binary_glTF"
  114564. , GLTFBinaryExtension = function(a) {
  114565. __extends(e, a);
  114566. function e() {
  114567. return a.call(this, "KHR_binary_glTF") || this
  114568. }
  114569. return e.prototype.loadRuntimeAsync = function(i, o, s, c, d) {
  114570. var _ = o.json.extensionsUsed;
  114571. return !_ || _.indexOf(this.name) === -1 || !o.bin ? !1 : (this._bin = o.bin,
  114572. c(GLTFLoaderBase.CreateRuntime(o.json, i, s)),
  114573. !0)
  114574. }
  114575. ,
  114576. e.prototype.loadBufferAsync = function(i, o, s, c) {
  114577. return i.extensionsUsed.indexOf(this.name) === -1 || o !== BinaryExtensionBufferName ? !1 : (this._bin.readAsync(0, this._bin.byteLength).then(s, function(d) {
  114578. return c(d.message)
  114579. }),
  114580. !0)
  114581. }
  114582. ,
  114583. e.prototype.loadTextureBufferAsync = function(i, o, s, c) {
  114584. var d = i.textures[o]
  114585. , _ = i.images[d.source];
  114586. if (!_.extensions || !(this.name in _.extensions))
  114587. return !1;
  114588. var b = _.extensions[this.name]
  114589. , k = i.bufferViews[b.bufferView]
  114590. , j = GLTFUtils.GetBufferFromBufferView(i, k, 0, k.byteLength, EComponentType.UNSIGNED_BYTE);
  114591. return s(j),
  114592. !0
  114593. }
  114594. ,
  114595. e.prototype.loadShaderStringAsync = function(i, o, s, c) {
  114596. var d = i.shaders[o];
  114597. if (!d.extensions || !(this.name in d.extensions))
  114598. return !1;
  114599. var _ = d.extensions[this.name]
  114600. , b = i.bufferViews[_.bufferView]
  114601. , k = GLTFUtils.GetBufferFromBufferView(i, b, 0, b.byteLength, EComponentType.UNSIGNED_BYTE);
  114602. return setTimeout(function() {
  114603. var j = GLTFUtils.DecodeBufferToText(k);
  114604. s(j)
  114605. }),
  114606. !0
  114607. }
  114608. ,
  114609. e
  114610. }(GLTFLoaderExtension);
  114611. GLTFLoader$1.RegisterExtension(new GLTFBinaryExtension);
  114612. var GLTFMaterialsCommonExtension = function(a) {
  114613. __extends(e, a);
  114614. function e() {
  114615. return a.call(this, "KHR_materials_common") || this
  114616. }
  114617. return e.prototype.loadRuntimeExtensionsAsync = function(i, o, s) {
  114618. if (!i.extensions)
  114619. return !1;
  114620. var c = i.extensions[this.name];
  114621. if (!c)
  114622. return !1;
  114623. var d = c.lights;
  114624. if (d)
  114625. for (var _ in d) {
  114626. var b = d[_];
  114627. switch (b.type) {
  114628. case "ambient":
  114629. var k = new HemisphericLight(b.name,new Vector3(0,1,0),i.scene)
  114630. , j = b.ambient;
  114631. j && (k.diffuse = Color3.FromArray(j.color || [1, 1, 1]));
  114632. break;
  114633. case "point":
  114634. var $ = new PointLight(b.name,new Vector3(10,10,10),i.scene)
  114635. , _e = b.point;
  114636. _e && ($.diffuse = Color3.FromArray(_e.color || [1, 1, 1]));
  114637. break;
  114638. case "directional":
  114639. var et = new DirectionalLight(b.name,new Vector3(0,-1,0),i.scene)
  114640. , tt = b.directional;
  114641. tt && (et.diffuse = Color3.FromArray(tt.color || [1, 1, 1]));
  114642. break;
  114643. case "spot":
  114644. var rt = b.spot;
  114645. if (rt) {
  114646. var it = new SpotLight(b.name,new Vector3(0,10,0),new Vector3(0,-1,0),rt.fallOffAngle || Math.PI,rt.fallOffExponent || 0,i.scene);
  114647. it.diffuse = Color3.FromArray(rt.color || [1, 1, 1])
  114648. }
  114649. break;
  114650. default:
  114651. Tools.Warn('GLTF Material Common extension: light type "' + b.type + "\u201D not supported");
  114652. break
  114653. }
  114654. }
  114655. return !1
  114656. }
  114657. ,
  114658. e.prototype.loadMaterialAsync = function(i, o, s, c) {
  114659. var d = i.materials[o];
  114660. if (!d || !d.extensions)
  114661. return !1;
  114662. var _ = d.extensions[this.name];
  114663. if (!_)
  114664. return !1;
  114665. var b = new StandardMaterial(o,i.scene);
  114666. return b.sideOrientation = Material.CounterClockWiseSideOrientation,
  114667. _.technique === "CONSTANT" && (b.disableLighting = !0),
  114668. b.backFaceCulling = _.doubleSided === void 0 ? !1 : !_.doubleSided,
  114669. b.alpha = _.values.transparency === void 0 ? 1 : _.values.transparency,
  114670. b.specularPower = _.values.shininess === void 0 ? 0 : _.values.shininess,
  114671. typeof _.values.ambient == "string" ? this._loadTexture(i, _.values.ambient, b, "ambientTexture", c) : b.ambientColor = Color3.FromArray(_.values.ambient || [0, 0, 0]),
  114672. typeof _.values.diffuse == "string" ? this._loadTexture(i, _.values.diffuse, b, "diffuseTexture", c) : b.diffuseColor = Color3.FromArray(_.values.diffuse || [0, 0, 0]),
  114673. typeof _.values.emission == "string" ? this._loadTexture(i, _.values.emission, b, "emissiveTexture", c) : b.emissiveColor = Color3.FromArray(_.values.emission || [0, 0, 0]),
  114674. typeof _.values.specular == "string" ? this._loadTexture(i, _.values.specular, b, "specularTexture", c) : b.specularColor = Color3.FromArray(_.values.specular || [0, 0, 0]),
  114675. !0
  114676. }
  114677. ,
  114678. e.prototype._loadTexture = function(i, o, s, c, d) {
  114679. GLTFLoaderBase.LoadTextureBufferAsync(i, o, function(_) {
  114680. GLTFLoaderBase.CreateTextureAsync(i, o, _, function(b) {
  114681. return s[c] = b
  114682. }, d)
  114683. }, d)
  114684. }
  114685. ,
  114686. e
  114687. }(GLTFLoaderExtension);
  114688. GLTFLoader$1.RegisterExtension(new GLTFMaterialsCommonExtension);
  114689. var Deferred = function() {
  114690. function a() {
  114691. var e = this;
  114692. this.promise = new Promise(function(i, o) {
  114693. e._resolve = i,
  114694. e._reject = o
  114695. }
  114696. )
  114697. }
  114698. return Object.defineProperty(a.prototype, "resolve", {
  114699. get: function() {
  114700. return this._resolve
  114701. },
  114702. enumerable: !1,
  114703. configurable: !0
  114704. }),
  114705. Object.defineProperty(a.prototype, "reject", {
  114706. get: function() {
  114707. return this._reject
  114708. },
  114709. enumerable: !1,
  114710. configurable: !0
  114711. }),
  114712. a
  114713. }()
  114714. , PBRMaterial = function(a) {
  114715. __extends(e, a);
  114716. function e(i, o) {
  114717. var s = a.call(this, i, o) || this;
  114718. return s.directIntensity = 1,
  114719. s.emissiveIntensity = 1,
  114720. s.environmentIntensity = 1,
  114721. s.specularIntensity = 1,
  114722. s.disableBumpMap = !1,
  114723. s.ambientTextureStrength = 1,
  114724. s.ambientTextureImpactOnAnalyticalLights = e.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,
  114725. s.metallicF0Factor = 1,
  114726. s.metallicReflectanceColor = Color3.White(),
  114727. s.useOnlyMetallicFromMetallicReflectanceTexture = !1,
  114728. s.ambientColor = new Color3(0,0,0),
  114729. s.albedoColor = new Color3(1,1,1),
  114730. s.reflectivityColor = new Color3(1,1,1),
  114731. s.reflectionColor = new Color3(1,1,1),
  114732. s.emissiveColor = new Color3(0,0,0),
  114733. s.microSurface = 1,
  114734. s.useLightmapAsShadowmap = !1,
  114735. s.useAlphaFromAlbedoTexture = !1,
  114736. s.forceAlphaTest = !1,
  114737. s.alphaCutOff = .4,
  114738. s.useSpecularOverAlpha = !0,
  114739. s.useMicroSurfaceFromReflectivityMapAlpha = !1,
  114740. s.useRoughnessFromMetallicTextureAlpha = !0,
  114741. s.useRoughnessFromMetallicTextureGreen = !1,
  114742. s.useMetallnessFromMetallicTextureBlue = !1,
  114743. s.useAmbientOcclusionFromMetallicTextureRed = !1,
  114744. s.useAmbientInGrayScale = !1,
  114745. s.useAutoMicroSurfaceFromReflectivityMap = !1,
  114746. s.useRadianceOverAlpha = !0,
  114747. s.useObjectSpaceNormalMap = !1,
  114748. s.useParallax = !1,
  114749. s.useParallaxOcclusion = !1,
  114750. s.parallaxScaleBias = .05,
  114751. s.disableLighting = !1,
  114752. s.forceIrradianceInFragment = !1,
  114753. s.maxSimultaneousLights = 4,
  114754. s.invertNormalMapX = !1,
  114755. s.invertNormalMapY = !1,
  114756. s.twoSidedLighting = !1,
  114757. s.useAlphaFresnel = !1,
  114758. s.useLinearAlphaFresnel = !1,
  114759. s.environmentBRDFTexture = null,
  114760. s.forceNormalForward = !1,
  114761. s.enableSpecularAntiAliasing = !1,
  114762. s.useHorizonOcclusion = !0,
  114763. s.useRadianceOcclusion = !0,
  114764. s.unlit = !1,
  114765. s._environmentBRDFTexture = GetEnvironmentBRDFTexture(o),
  114766. s
  114767. }
  114768. return Object.defineProperty(e.prototype, "refractionTexture", {
  114769. get: function() {
  114770. return this.subSurface.refractionTexture
  114771. },
  114772. set: function(i) {
  114773. this.subSurface.refractionTexture = i,
  114774. i ? this.subSurface.isRefractionEnabled = !0 : this.subSurface.linkRefractionWithTransparency || (this.subSurface.isRefractionEnabled = !1)
  114775. },
  114776. enumerable: !1,
  114777. configurable: !0
  114778. }),
  114779. Object.defineProperty(e.prototype, "indexOfRefraction", {
  114780. get: function() {
  114781. return this.subSurface.indexOfRefraction
  114782. },
  114783. set: function(i) {
  114784. this.subSurface.indexOfRefraction = i
  114785. },
  114786. enumerable: !1,
  114787. configurable: !0
  114788. }),
  114789. Object.defineProperty(e.prototype, "invertRefractionY", {
  114790. get: function() {
  114791. return this.subSurface.invertRefractionY
  114792. },
  114793. set: function(i) {
  114794. this.subSurface.invertRefractionY = i
  114795. },
  114796. enumerable: !1,
  114797. configurable: !0
  114798. }),
  114799. Object.defineProperty(e.prototype, "linkRefractionWithTransparency", {
  114800. get: function() {
  114801. return this.subSurface.linkRefractionWithTransparency
  114802. },
  114803. set: function(i) {
  114804. this.subSurface.linkRefractionWithTransparency = i,
  114805. i && (this.subSurface.isRefractionEnabled = !0)
  114806. },
  114807. enumerable: !1,
  114808. configurable: !0
  114809. }),
  114810. Object.defineProperty(e.prototype, "usePhysicalLightFalloff", {
  114811. get: function() {
  114812. return this._lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL
  114813. },
  114814. set: function(i) {
  114815. i !== this.usePhysicalLightFalloff && (this._markAllSubMeshesAsTexturesDirty(),
  114816. i ? this._lightFalloff = PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL : this._lightFalloff = PBRBaseMaterial.LIGHTFALLOFF_STANDARD)
  114817. },
  114818. enumerable: !1,
  114819. configurable: !0
  114820. }),
  114821. Object.defineProperty(e.prototype, "useGLTFLightFalloff", {
  114822. get: function() {
  114823. return this._lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_GLTF
  114824. },
  114825. set: function(i) {
  114826. i !== this.useGLTFLightFalloff && (this._markAllSubMeshesAsTexturesDirty(),
  114827. i ? this._lightFalloff = PBRBaseMaterial.LIGHTFALLOFF_GLTF : this._lightFalloff = PBRBaseMaterial.LIGHTFALLOFF_STANDARD)
  114828. },
  114829. enumerable: !1,
  114830. configurable: !0
  114831. }),
  114832. Object.defineProperty(e.prototype, "imageProcessingConfiguration", {
  114833. get: function() {
  114834. return this._imageProcessingConfiguration
  114835. },
  114836. set: function(i) {
  114837. this._attachImageProcessingConfiguration(i),
  114838. this._markAllSubMeshesAsTexturesDirty()
  114839. },
  114840. enumerable: !1,
  114841. configurable: !0
  114842. }),
  114843. Object.defineProperty(e.prototype, "cameraColorCurvesEnabled", {
  114844. get: function() {
  114845. return this.imageProcessingConfiguration.colorCurvesEnabled
  114846. },
  114847. set: function(i) {
  114848. this.imageProcessingConfiguration.colorCurvesEnabled = i
  114849. },
  114850. enumerable: !1,
  114851. configurable: !0
  114852. }),
  114853. Object.defineProperty(e.prototype, "cameraColorGradingEnabled", {
  114854. get: function() {
  114855. return this.imageProcessingConfiguration.colorGradingEnabled
  114856. },
  114857. set: function(i) {
  114858. this.imageProcessingConfiguration.colorGradingEnabled = i
  114859. },
  114860. enumerable: !1,
  114861. configurable: !0
  114862. }),
  114863. Object.defineProperty(e.prototype, "cameraToneMappingEnabled", {
  114864. get: function() {
  114865. return this._imageProcessingConfiguration.toneMappingEnabled
  114866. },
  114867. set: function(i) {
  114868. this._imageProcessingConfiguration.toneMappingEnabled = i
  114869. },
  114870. enumerable: !1,
  114871. configurable: !0
  114872. }),
  114873. Object.defineProperty(e.prototype, "cameraExposure", {
  114874. get: function() {
  114875. return this._imageProcessingConfiguration.exposure
  114876. },
  114877. set: function(i) {
  114878. this._imageProcessingConfiguration.exposure = i
  114879. },
  114880. enumerable: !1,
  114881. configurable: !0
  114882. }),
  114883. Object.defineProperty(e.prototype, "cameraContrast", {
  114884. get: function() {
  114885. return this._imageProcessingConfiguration.contrast
  114886. },
  114887. set: function(i) {
  114888. this._imageProcessingConfiguration.contrast = i
  114889. },
  114890. enumerable: !1,
  114891. configurable: !0
  114892. }),
  114893. Object.defineProperty(e.prototype, "cameraColorGradingTexture", {
  114894. get: function() {
  114895. return this._imageProcessingConfiguration.colorGradingTexture
  114896. },
  114897. set: function(i) {
  114898. this._imageProcessingConfiguration.colorGradingTexture = i
  114899. },
  114900. enumerable: !1,
  114901. configurable: !0
  114902. }),
  114903. Object.defineProperty(e.prototype, "cameraColorCurves", {
  114904. get: function() {
  114905. return this._imageProcessingConfiguration.colorCurves
  114906. },
  114907. set: function(i) {
  114908. this._imageProcessingConfiguration.colorCurves = i
  114909. },
  114910. enumerable: !1,
  114911. configurable: !0
  114912. }),
  114913. e.prototype.getClassName = function() {
  114914. return "PBRMaterial"
  114915. }
  114916. ,
  114917. e.prototype.clone = function(i) {
  114918. var o = this
  114919. , s = SerializationHelper.Clone(function() {
  114920. return new e(i,o.getScene())
  114921. }, this);
  114922. return s.id = i,
  114923. s.name = i,
  114924. this.stencil.copyTo(s.stencil),
  114925. this.clearCoat.copyTo(s.clearCoat),
  114926. this.anisotropy.copyTo(s.anisotropy),
  114927. this.brdf.copyTo(s.brdf),
  114928. this.sheen.copyTo(s.sheen),
  114929. this.subSurface.copyTo(s.subSurface),
  114930. s
  114931. }
  114932. ,
  114933. e.prototype.serialize = function() {
  114934. var i = SerializationHelper.Serialize(this);
  114935. return i.customType = "BABYLON.PBRMaterial",
  114936. i.stencil = this.stencil.serialize(),
  114937. i.clearCoat = this.clearCoat.serialize(),
  114938. i.anisotropy = this.anisotropy.serialize(),
  114939. i.brdf = this.brdf.serialize(),
  114940. i.sheen = this.sheen.serialize(),
  114941. i.subSurface = this.subSurface.serialize(),
  114942. i
  114943. }
  114944. ,
  114945. e.Parse = function(i, o, s) {
  114946. var c = SerializationHelper.Parse(function() {
  114947. return new e(i.name,o)
  114948. }, i, o, s);
  114949. return i.stencil && c.stencil.parse(i.stencil, o, s),
  114950. i.clearCoat && c.clearCoat.parse(i.clearCoat, o, s),
  114951. i.anisotropy && c.anisotropy.parse(i.anisotropy, o, s),
  114952. i.brdf && c.brdf.parse(i.brdf, o, s),
  114953. i.sheen && c.sheen.parse(i.sheen, o, s),
  114954. i.subSurface && c.subSurface.parse(i.subSurface, o, s),
  114955. c
  114956. }
  114957. ,
  114958. e.PBRMATERIAL_OPAQUE = PBRBaseMaterial.PBRMATERIAL_OPAQUE,
  114959. e.PBRMATERIAL_ALPHATEST = PBRBaseMaterial.PBRMATERIAL_ALPHATEST,
  114960. e.PBRMATERIAL_ALPHABLEND = PBRBaseMaterial.PBRMATERIAL_ALPHABLEND,
  114961. e.PBRMATERIAL_ALPHATESTANDBLEND = PBRBaseMaterial.PBRMATERIAL_ALPHATESTANDBLEND,
  114962. e.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = PBRBaseMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,
  114963. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "directIntensity", void 0),
  114964. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "emissiveIntensity", void 0),
  114965. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "environmentIntensity", void 0),
  114966. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "specularIntensity", void 0),
  114967. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "disableBumpMap", void 0),
  114968. __decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "albedoTexture", void 0),
  114969. __decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "ambientTexture", void 0),
  114970. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "ambientTextureStrength", void 0),
  114971. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "ambientTextureImpactOnAnalyticalLights", void 0),
  114972. __decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")], e.prototype, "opacityTexture", void 0),
  114973. __decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "reflectionTexture", void 0),
  114974. __decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "emissiveTexture", void 0),
  114975. __decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "reflectivityTexture", void 0),
  114976. __decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "metallicTexture", void 0),
  114977. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "metallic", void 0),
  114978. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "roughness", void 0),
  114979. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "metallicF0Factor", void 0),
  114980. __decorate([serializeAsColor3(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "metallicReflectanceColor", void 0),
  114981. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useOnlyMetallicFromMetallicReflectanceTexture", void 0),
  114982. __decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "metallicReflectanceTexture", void 0),
  114983. __decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "reflectanceTexture", void 0),
  114984. __decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "microSurfaceTexture", void 0),
  114985. __decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "bumpTexture", void 0),
  114986. __decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty", null)], e.prototype, "lightmapTexture", void 0),
  114987. __decorate([serializeAsColor3("ambient"), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "ambientColor", void 0),
  114988. __decorate([serializeAsColor3("albedo"), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "albedoColor", void 0),
  114989. __decorate([serializeAsColor3("reflectivity"), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "reflectivityColor", void 0),
  114990. __decorate([serializeAsColor3("reflection"), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "reflectionColor", void 0),
  114991. __decorate([serializeAsColor3("emissive"), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "emissiveColor", void 0),
  114992. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "microSurface", void 0),
  114993. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useLightmapAsShadowmap", void 0),
  114994. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")], e.prototype, "useAlphaFromAlbedoTexture", void 0),
  114995. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")], e.prototype, "forceAlphaTest", void 0),
  114996. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")], e.prototype, "alphaCutOff", void 0),
  114997. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useSpecularOverAlpha", void 0),
  114998. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useMicroSurfaceFromReflectivityMapAlpha", void 0),
  114999. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useRoughnessFromMetallicTextureAlpha", void 0),
  115000. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useRoughnessFromMetallicTextureGreen", void 0),
  115001. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useMetallnessFromMetallicTextureBlue", void 0),
  115002. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useAmbientOcclusionFromMetallicTextureRed", void 0),
  115003. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useAmbientInGrayScale", void 0),
  115004. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useAutoMicroSurfaceFromReflectivityMap", void 0),
  115005. __decorate([serialize()], e.prototype, "usePhysicalLightFalloff", null),
  115006. __decorate([serialize()], e.prototype, "useGLTFLightFalloff", null),
  115007. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useRadianceOverAlpha", void 0),
  115008. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useObjectSpaceNormalMap", void 0),
  115009. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useParallax", void 0),
  115010. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useParallaxOcclusion", void 0),
  115011. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "parallaxScaleBias", void 0),
  115012. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsLightsDirty")], e.prototype, "disableLighting", void 0),
  115013. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "forceIrradianceInFragment", void 0),
  115014. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsLightsDirty")], e.prototype, "maxSimultaneousLights", void 0),
  115015. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "invertNormalMapX", void 0),
  115016. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "invertNormalMapY", void 0),
  115017. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "twoSidedLighting", void 0),
  115018. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useAlphaFresnel", void 0),
  115019. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useLinearAlphaFresnel", void 0),
  115020. __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "environmentBRDFTexture", void 0),
  115021. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "forceNormalForward", void 0),
  115022. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "enableSpecularAntiAliasing", void 0),
  115023. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useHorizonOcclusion", void 0),
  115024. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useRadianceOcclusion", void 0),
  115025. __decorate([serialize(), expandToProperty("_markAllSubMeshesAsMiscDirty")], e.prototype, "unlit", void 0),
  115026. e
  115027. }(PBRBaseMaterial);
  115028. RegisterClass("BABYLON.PBRMaterial", PBRMaterial);
  115029. var MorphTarget = function() {
  115030. function a(e, i, o) {
  115031. i === void 0 && (i = 0),
  115032. o === void 0 && (o = null),
  115033. this.name = e,
  115034. this.animations = new Array,
  115035. this._positions = null,
  115036. this._normals = null,
  115037. this._tangents = null,
  115038. this._uvs = null,
  115039. this._uniqueId = 0,
  115040. this.onInfluenceChanged = new Observable,
  115041. this._onDataLayoutChanged = new Observable,
  115042. this._animationPropertiesOverride = null,
  115043. this._scene = o || EngineStore.LastCreatedScene,
  115044. this.influence = i,
  115045. this._scene && (this._uniqueId = this._scene.getUniqueId())
  115046. }
  115047. return Object.defineProperty(a.prototype, "influence", {
  115048. get: function() {
  115049. return this._influence
  115050. },
  115051. set: function(e) {
  115052. if (this._influence !== e) {
  115053. var i = this._influence;
  115054. this._influence = e,
  115055. this.onInfluenceChanged.hasObservers() && this.onInfluenceChanged.notifyObservers(i === 0 || e === 0)
  115056. }
  115057. },
  115058. enumerable: !1,
  115059. configurable: !0
  115060. }),
  115061. Object.defineProperty(a.prototype, "animationPropertiesOverride", {
  115062. get: function() {
  115063. return !this._animationPropertiesOverride && this._scene ? this._scene.animationPropertiesOverride : this._animationPropertiesOverride
  115064. },
  115065. set: function(e) {
  115066. this._animationPropertiesOverride = e
  115067. },
  115068. enumerable: !1,
  115069. configurable: !0
  115070. }),
  115071. Object.defineProperty(a.prototype, "uniqueId", {
  115072. get: function() {
  115073. return this._uniqueId
  115074. },
  115075. enumerable: !1,
  115076. configurable: !0
  115077. }),
  115078. Object.defineProperty(a.prototype, "hasPositions", {
  115079. get: function() {
  115080. return !!this._positions
  115081. },
  115082. enumerable: !1,
  115083. configurable: !0
  115084. }),
  115085. Object.defineProperty(a.prototype, "hasNormals", {
  115086. get: function() {
  115087. return !!this._normals
  115088. },
  115089. enumerable: !1,
  115090. configurable: !0
  115091. }),
  115092. Object.defineProperty(a.prototype, "hasTangents", {
  115093. get: function() {
  115094. return !!this._tangents
  115095. },
  115096. enumerable: !1,
  115097. configurable: !0
  115098. }),
  115099. Object.defineProperty(a.prototype, "hasUVs", {
  115100. get: function() {
  115101. return !!this._uvs
  115102. },
  115103. enumerable: !1,
  115104. configurable: !0
  115105. }),
  115106. a.prototype.setPositions = function(e) {
  115107. var i = this.hasPositions;
  115108. this._positions = e,
  115109. i !== this.hasPositions && this._onDataLayoutChanged.notifyObservers(void 0)
  115110. }
  115111. ,
  115112. a.prototype.getPositions = function() {
  115113. return this._positions
  115114. }
  115115. ,
  115116. a.prototype.setNormals = function(e) {
  115117. var i = this.hasNormals;
  115118. this._normals = e,
  115119. i !== this.hasNormals && this._onDataLayoutChanged.notifyObservers(void 0)
  115120. }
  115121. ,
  115122. a.prototype.getNormals = function() {
  115123. return this._normals
  115124. }
  115125. ,
  115126. a.prototype.setTangents = function(e) {
  115127. var i = this.hasTangents;
  115128. this._tangents = e,
  115129. i !== this.hasTangents && this._onDataLayoutChanged.notifyObservers(void 0)
  115130. }
  115131. ,
  115132. a.prototype.getTangents = function() {
  115133. return this._tangents
  115134. }
  115135. ,
  115136. a.prototype.setUVs = function(e) {
  115137. var i = this.hasUVs;
  115138. this._uvs = e,
  115139. i !== this.hasUVs && this._onDataLayoutChanged.notifyObservers(void 0)
  115140. }
  115141. ,
  115142. a.prototype.getUVs = function() {
  115143. return this._uvs
  115144. }
  115145. ,
  115146. a.prototype.clone = function() {
  115147. var e = this
  115148. , i = SerializationHelper.Clone(function() {
  115149. return new a(e.name,e.influence,e._scene)
  115150. }, this);
  115151. return i._positions = this._positions,
  115152. i._normals = this._normals,
  115153. i._tangents = this._tangents,
  115154. i._uvs = this._uvs,
  115155. i
  115156. }
  115157. ,
  115158. a.prototype.serialize = function() {
  115159. var e = {};
  115160. return e.name = this.name,
  115161. e.influence = this.influence,
  115162. e.positions = Array.prototype.slice.call(this.getPositions()),
  115163. this.id != null && (e.id = this.id),
  115164. this.hasNormals && (e.normals = Array.prototype.slice.call(this.getNormals())),
  115165. this.hasTangents && (e.tangents = Array.prototype.slice.call(this.getTangents())),
  115166. this.hasUVs && (e.uvs = Array.prototype.slice.call(this.getUVs())),
  115167. SerializationHelper.AppendSerializedAnimations(this, e),
  115168. e
  115169. }
  115170. ,
  115171. a.prototype.getClassName = function() {
  115172. return "MorphTarget"
  115173. }
  115174. ,
  115175. a.Parse = function(e) {
  115176. var i = new a(e.name,e.influence);
  115177. if (i.setPositions(e.positions),
  115178. e.id != null && (i.id = e.id),
  115179. e.normals && i.setNormals(e.normals),
  115180. e.tangents && i.setTangents(e.tangents),
  115181. e.uvs && i.setUVs(e.uvs),
  115182. e.animations)
  115183. for (var o = 0; o < e.animations.length; o++) {
  115184. var s = e.animations[o]
  115185. , c = GetClass("BABYLON.Animation");
  115186. c && i.animations.push(c.Parse(s))
  115187. }
  115188. return i
  115189. }
  115190. ,
  115191. a.FromMesh = function(e, i, o) {
  115192. i || (i = e.name);
  115193. var s = new a(i,o,e.getScene());
  115194. return s.setPositions(e.getVerticesData(VertexBuffer.PositionKind)),
  115195. e.isVerticesDataPresent(VertexBuffer.NormalKind) && s.setNormals(e.getVerticesData(VertexBuffer.NormalKind)),
  115196. e.isVerticesDataPresent(VertexBuffer.TangentKind) && s.setTangents(e.getVerticesData(VertexBuffer.TangentKind)),
  115197. e.isVerticesDataPresent(VertexBuffer.UVKind) && s.setUVs(e.getVerticesData(VertexBuffer.UVKind)),
  115198. s
  115199. }
  115200. ,
  115201. __decorate([serialize()], a.prototype, "id", void 0),
  115202. a
  115203. }()
  115204. , RawTexture2DArray = function(a) {
  115205. __extends(e, a);
  115206. function e(i, o, s, c, d, _, b, k, j, $) {
  115207. b === void 0 && (b = !0),
  115208. k === void 0 && (k = !1),
  115209. j === void 0 && (j = Texture.TRILINEAR_SAMPLINGMODE),
  115210. $ === void 0 && ($ = 0);
  115211. var _e = a.call(this, null, _, !b, k) || this;
  115212. return _e.format = d,
  115213. _e._texture = _.getEngine().createRawTexture2DArray(i, o, s, c, d, b, k, j, null, $),
  115214. _e._depth = c,
  115215. _e.is2DArray = !0,
  115216. _e
  115217. }
  115218. return Object.defineProperty(e.prototype, "depth", {
  115219. get: function() {
  115220. return this._depth
  115221. },
  115222. enumerable: !1,
  115223. configurable: !0
  115224. }),
  115225. e.prototype.update = function(i) {
  115226. !this._texture || this._getEngine().updateRawTexture2DArray(this._texture, i, this._texture.format, this._texture.invertY, null, this._texture.type)
  115227. }
  115228. ,
  115229. e.CreateRGBATexture = function(i, o, s, c, d, _, b, k, j) {
  115230. return _ === void 0 && (_ = !0),
  115231. b === void 0 && (b = !1),
  115232. k === void 0 && (k = 3),
  115233. j === void 0 && (j = 0),
  115234. new e(i,o,s,c,5,d,_,b,k,j)
  115235. }
  115236. ,
  115237. e
  115238. }(Texture)
  115239. , MorphTargetManager = function() {
  115240. function a(e) {
  115241. if (e === void 0 && (e = null),
  115242. this._targets = new Array,
  115243. this._targetInfluenceChangedObservers = new Array,
  115244. this._targetDataLayoutChangedObservers = new Array,
  115245. this._activeTargets = new SmartArray(16),
  115246. this._supportsNormals = !1,
  115247. this._supportsTangents = !1,
  115248. this._supportsUVs = !1,
  115249. this._vertexCount = 0,
  115250. this._textureVertexStride = 0,
  115251. this._textureWidth = 0,
  115252. this._textureHeight = 1,
  115253. this._uniqueId = 0,
  115254. this._tempInfluences = new Array,
  115255. this._canUseTextureForTargets = !1,
  115256. this._blockCounter = 0,
  115257. this._parentContainer = null,
  115258. this.optimizeInfluencers = !0,
  115259. this.enableNormalMorphing = !0,
  115260. this.enableTangentMorphing = !0,
  115261. this.enableUVMorphing = !0,
  115262. this._useTextureToStoreTargets = !0,
  115263. e || (e = EngineStore.LastCreatedScene),
  115264. this._scene = e,
  115265. this._scene) {
  115266. this._scene.morphTargetManagers.push(this),
  115267. this._uniqueId = this._scene.getUniqueId();
  115268. var i = this._scene.getEngine().getCaps();
  115269. this._canUseTextureForTargets = i.canUseGLVertexID && i.textureFloat && i.maxVertexTextureImageUnits > 0
  115270. }
  115271. }
  115272. return Object.defineProperty(a.prototype, "areUpdatesFrozen", {
  115273. get: function() {
  115274. return this._blockCounter > 0
  115275. },
  115276. set: function(e) {
  115277. e ? this._blockCounter++ : (this._blockCounter--,
  115278. this._blockCounter <= 0 && (this._blockCounter = 0,
  115279. this._syncActiveTargets(!0)))
  115280. },
  115281. enumerable: !1,
  115282. configurable: !0
  115283. }),
  115284. Object.defineProperty(a.prototype, "uniqueId", {
  115285. get: function() {
  115286. return this._uniqueId
  115287. },
  115288. enumerable: !1,
  115289. configurable: !0
  115290. }),
  115291. Object.defineProperty(a.prototype, "vertexCount", {
  115292. get: function() {
  115293. return this._vertexCount
  115294. },
  115295. enumerable: !1,
  115296. configurable: !0
  115297. }),
  115298. Object.defineProperty(a.prototype, "supportsNormals", {
  115299. get: function() {
  115300. return this._supportsNormals && this.enableNormalMorphing
  115301. },
  115302. enumerable: !1,
  115303. configurable: !0
  115304. }),
  115305. Object.defineProperty(a.prototype, "supportsTangents", {
  115306. get: function() {
  115307. return this._supportsTangents && this.enableTangentMorphing
  115308. },
  115309. enumerable: !1,
  115310. configurable: !0
  115311. }),
  115312. Object.defineProperty(a.prototype, "supportsUVs", {
  115313. get: function() {
  115314. return this._supportsUVs && this.enableUVMorphing
  115315. },
  115316. enumerable: !1,
  115317. configurable: !0
  115318. }),
  115319. Object.defineProperty(a.prototype, "numTargets", {
  115320. get: function() {
  115321. return this._targets.length
  115322. },
  115323. enumerable: !1,
  115324. configurable: !0
  115325. }),
  115326. Object.defineProperty(a.prototype, "numInfluencers", {
  115327. get: function() {
  115328. return this._activeTargets.length
  115329. },
  115330. enumerable: !1,
  115331. configurable: !0
  115332. }),
  115333. Object.defineProperty(a.prototype, "influences", {
  115334. get: function() {
  115335. return this._influences
  115336. },
  115337. enumerable: !1,
  115338. configurable: !0
  115339. }),
  115340. Object.defineProperty(a.prototype, "useTextureToStoreTargets", {
  115341. get: function() {
  115342. return this._useTextureToStoreTargets
  115343. },
  115344. set: function(e) {
  115345. this._useTextureToStoreTargets = e
  115346. },
  115347. enumerable: !1,
  115348. configurable: !0
  115349. }),
  115350. Object.defineProperty(a.prototype, "isUsingTextureForTargets", {
  115351. get: function() {
  115352. return a.EnableTextureStorage && this.useTextureToStoreTargets && this._canUseTextureForTargets
  115353. },
  115354. enumerable: !1,
  115355. configurable: !0
  115356. }),
  115357. a.prototype.getActiveTarget = function(e) {
  115358. return this._activeTargets.data[e]
  115359. }
  115360. ,
  115361. a.prototype.getTarget = function(e) {
  115362. return this._targets[e]
  115363. }
  115364. ,
  115365. a.prototype.addTarget = function(e) {
  115366. var i = this;
  115367. this._targets.push(e),
  115368. this._targetInfluenceChangedObservers.push(e.onInfluenceChanged.add(function(o) {
  115369. i._syncActiveTargets(o)
  115370. })),
  115371. this._targetDataLayoutChangedObservers.push(e._onDataLayoutChanged.add(function() {
  115372. i._syncActiveTargets(!0)
  115373. })),
  115374. this._syncActiveTargets(!0)
  115375. }
  115376. ,
  115377. a.prototype.removeTarget = function(e) {
  115378. var i = this._targets.indexOf(e);
  115379. i >= 0 && (this._targets.splice(i, 1),
  115380. e.onInfluenceChanged.remove(this._targetInfluenceChangedObservers.splice(i, 1)[0]),
  115381. e._onDataLayoutChanged.remove(this._targetDataLayoutChangedObservers.splice(i, 1)[0]),
  115382. this._syncActiveTargets(!0))
  115383. }
  115384. ,
  115385. a.prototype._bind = function(e) {
  115386. e.setFloat3("morphTargetTextureInfo", this._textureVertexStride, this._textureWidth, this._textureHeight),
  115387. e.setFloatArray("morphTargetTextureIndices", this._morphTargetTextureIndices),
  115388. e.setTexture("morphTargets", this._targetStoreTexture)
  115389. }
  115390. ,
  115391. a.prototype.clone = function() {
  115392. for (var e = new a(this._scene), i = 0, o = this._targets; i < o.length; i++) {
  115393. var s = o[i];
  115394. e.addTarget(s.clone())
  115395. }
  115396. return e.enableNormalMorphing = this.enableNormalMorphing,
  115397. e.enableTangentMorphing = this.enableTangentMorphing,
  115398. e.enableUVMorphing = this.enableUVMorphing,
  115399. e
  115400. }
  115401. ,
  115402. a.prototype.serialize = function() {
  115403. var e = {};
  115404. e.id = this.uniqueId,
  115405. e.targets = [];
  115406. for (var i = 0, o = this._targets; i < o.length; i++) {
  115407. var s = o[i];
  115408. e.targets.push(s.serialize())
  115409. }
  115410. return e
  115411. }
  115412. ,
  115413. a.prototype._syncActiveTargets = function(e) {
  115414. if (!this.areUpdatesFrozen) {
  115415. var i = 0;
  115416. this._activeTargets.reset(),
  115417. this._supportsNormals = !0,
  115418. this._supportsTangents = !0,
  115419. this._supportsUVs = !0,
  115420. this._vertexCount = 0,
  115421. (!this._morphTargetTextureIndices || this._morphTargetTextureIndices.length !== this._targets.length) && (this._morphTargetTextureIndices = new Float32Array(this._targets.length));
  115422. for (var o = -1, s = 0, c = this._targets; s < c.length; s++) {
  115423. var d = c[s];
  115424. if (o++,
  115425. !(d.influence === 0 && this.optimizeInfluencers)) {
  115426. this._activeTargets.push(d),
  115427. this._morphTargetTextureIndices[i] = o,
  115428. this._tempInfluences[i++] = d.influence,
  115429. this._supportsNormals = this._supportsNormals && d.hasNormals,
  115430. this._supportsTangents = this._supportsTangents && d.hasTangents,
  115431. this._supportsUVs = this._supportsUVs && d.hasUVs;
  115432. var _ = d.getPositions();
  115433. if (_) {
  115434. var b = _.length / 3;
  115435. if (this._vertexCount === 0)
  115436. this._vertexCount = b;
  115437. else if (this._vertexCount !== b) {
  115438. Logger$2.Error("Incompatible target. Targets must all have the same vertices count.");
  115439. return
  115440. }
  115441. }
  115442. }
  115443. }
  115444. (!this._influences || this._influences.length !== i) && (this._influences = new Float32Array(i));
  115445. for (var k = 0; k < i; k++)
  115446. this._influences[k] = this._tempInfluences[k];
  115447. e && this.synchronize()
  115448. }
  115449. }
  115450. ,
  115451. a.prototype.synchronize = function() {
  115452. if (!(!this._scene || this.areUpdatesFrozen)) {
  115453. if (this.isUsingTextureForTargets && this._vertexCount) {
  115454. this._textureVertexStride = 1,
  115455. this._supportsNormals && this._textureVertexStride++,
  115456. this._supportsTangents && this._textureVertexStride++,
  115457. this._supportsUVs && this._textureVertexStride++,
  115458. this._textureWidth = this._vertexCount * this._textureVertexStride,
  115459. this._textureHeight = 1;
  115460. var e = this._scene.getEngine().getCaps().maxTextureSize;
  115461. this._textureWidth > e && (this._textureHeight = Math.ceil(this._textureWidth / e),
  115462. this._textureWidth = e);
  115463. var i = !0;
  115464. if (this._targetStoreTexture) {
  115465. var o = this._targetStoreTexture.getSize();
  115466. o.width === this._textureWidth && o.height === this._textureHeight && this._targetStoreTexture.depth === this._targets.length && (i = !1)
  115467. }
  115468. if (i) {
  115469. this._targetStoreTexture && this._targetStoreTexture.dispose();
  115470. for (var s = this._targets.length, c = new Float32Array(s * this._textureWidth * this._textureHeight * 4), d = 0, _ = 0; _ < s; _++) {
  115471. var b = this._targets[_]
  115472. , k = b.getPositions()
  115473. , j = b.getNormals()
  115474. , $ = b.getUVs()
  115475. , _e = b.getTangents();
  115476. if (!k) {
  115477. _ === 0 && Logger$2.Error("Invalid morph target. Target must have positions.");
  115478. return
  115479. }
  115480. d = _ * this._textureWidth * this._textureHeight * 4;
  115481. for (var et = 0; et < this._vertexCount; et++)
  115482. c[d] = k[et * 3],
  115483. c[d + 1] = k[et * 3 + 1],
  115484. c[d + 2] = k[et * 3 + 2],
  115485. d += 4,
  115486. j && (c[d] = j[et * 3],
  115487. c[d + 1] = j[et * 3 + 1],
  115488. c[d + 2] = j[et * 3 + 2],
  115489. d += 4),
  115490. $ && (c[d] = $[et * 2],
  115491. c[d + 1] = $[et * 2 + 1],
  115492. d += 4),
  115493. _e && (c[d] = _e[et * 3],
  115494. c[d + 1] = _e[et * 3 + 1],
  115495. c[d + 2] = _e[et * 3 + 2],
  115496. d += 4)
  115497. }
  115498. this._targetStoreTexture = RawTexture2DArray.CreateRGBATexture(c, this._textureWidth, this._textureHeight, s, this._scene, !1, !1, 1, 1)
  115499. }
  115500. }
  115501. for (var tt = 0, rt = this._scene.meshes; tt < rt.length; tt++) {
  115502. var it = rt[tt];
  115503. it.morphTargetManager === this && it._syncGeometryWithMorphTargetManager()
  115504. }
  115505. }
  115506. }
  115507. ,
  115508. a.prototype.dispose = function() {
  115509. if (this._targetStoreTexture && this._targetStoreTexture.dispose(),
  115510. this._targetStoreTexture = null,
  115511. this._scene && (this._scene.removeMorphTargetManager(this),
  115512. this._parentContainer)) {
  115513. var e = this._parentContainer.morphTargetManagers.indexOf(this);
  115514. e > -1 && this._parentContainer.morphTargetManagers.splice(e, 1),
  115515. this._parentContainer = null
  115516. }
  115517. }
  115518. ,
  115519. a.Parse = function(e, i) {
  115520. var o = new a(i);
  115521. o._uniqueId = e.id;
  115522. for (var s = 0, c = e.targets; s < c.length; s++) {
  115523. var d = c[s];
  115524. o.addTarget(MorphTarget.Parse(d))
  115525. }
  115526. return o
  115527. }
  115528. ,
  115529. a.EnableTextureStorage = !0,
  115530. a
  115531. }()
  115532. , ArrayItem = function() {
  115533. function a() {}
  115534. return a.Get = function(e, i, o) {
  115535. if (!i || o == null || !i[o])
  115536. throw new Error(e + ": Failed to find index (" + o + ")");
  115537. return i[o]
  115538. }
  115539. ,
  115540. a.Assign = function(e) {
  115541. if (e)
  115542. for (var i = 0; i < e.length; i++)
  115543. e[i].index = i
  115544. }
  115545. ,
  115546. a
  115547. }()
  115548. , GLTFLoader = function() {
  115549. function a(e) {
  115550. this._completePromises = new Array,
  115551. this._assetContainer = null,
  115552. this._babylonLights = [],
  115553. this._disableInstancedMesh = 0,
  115554. this._disposed = !1,
  115555. this._extensions = new Array,
  115556. this._rootBabylonMesh = null,
  115557. this._defaultBabylonMaterialData = {},
  115558. this._parent = e
  115559. }
  115560. return a.RegisterExtension = function(e, i) {
  115561. a.UnregisterExtension(e) && Logger$2.Warn("Extension with the name '" + e + "' already exists"),
  115562. a._RegisteredExtensions[e] = {
  115563. factory: i
  115564. }
  115565. }
  115566. ,
  115567. a.UnregisterExtension = function(e) {
  115568. return a._RegisteredExtensions[e] ? (delete a._RegisteredExtensions[e],
  115569. !0) : !1
  115570. }
  115571. ,
  115572. Object.defineProperty(a.prototype, "gltf", {
  115573. get: function() {
  115574. return this._gltf
  115575. },
  115576. enumerable: !1,
  115577. configurable: !0
  115578. }),
  115579. Object.defineProperty(a.prototype, "bin", {
  115580. get: function() {
  115581. return this._bin
  115582. },
  115583. enumerable: !1,
  115584. configurable: !0
  115585. }),
  115586. Object.defineProperty(a.prototype, "parent", {
  115587. get: function() {
  115588. return this._parent
  115589. },
  115590. enumerable: !1,
  115591. configurable: !0
  115592. }),
  115593. Object.defineProperty(a.prototype, "babylonScene", {
  115594. get: function() {
  115595. return this._babylonScene
  115596. },
  115597. enumerable: !1,
  115598. configurable: !0
  115599. }),
  115600. Object.defineProperty(a.prototype, "rootBabylonMesh", {
  115601. get: function() {
  115602. return this._rootBabylonMesh
  115603. },
  115604. enumerable: !1,
  115605. configurable: !0
  115606. }),
  115607. a.prototype.dispose = function() {
  115608. if (!this._disposed) {
  115609. this._disposed = !0,
  115610. this._completePromises.length = 0;
  115611. for (var e in this._extensions) {
  115612. var i = this._extensions[e];
  115613. i.dispose && i.dispose(),
  115614. delete this._extensions[e]
  115615. }
  115616. this._gltf = null,
  115617. this._babylonScene = null,
  115618. this._rootBabylonMesh = null,
  115619. this._parent.dispose()
  115620. }
  115621. }
  115622. ,
  115623. a.prototype.importMeshAsync = function(e, i, o, s, c, d, _) {
  115624. var b = this;
  115625. return _ === void 0 && (_ = ""),
  115626. Promise.resolve().then(function() {
  115627. b._babylonScene = i,
  115628. b._assetContainer = o,
  115629. b._loadData(s);
  115630. var k = null;
  115631. if (e) {
  115632. var j = {};
  115633. if (b._gltf.nodes)
  115634. for (var $ = 0, _e = b._gltf.nodes; $ < _e.length; $++) {
  115635. var et = _e[$];
  115636. et.name && (j[et.name] = et.index)
  115637. }
  115638. var tt = e instanceof Array ? e : [e];
  115639. k = tt.map(function(rt) {
  115640. var it = j[rt];
  115641. if (it === void 0)
  115642. throw new Error("Failed to find node '" + rt + "'");
  115643. return it
  115644. })
  115645. }
  115646. return b._loadAsync(c, _, k, function() {
  115647. return {
  115648. meshes: b._getMeshes(),
  115649. particleSystems: [],
  115650. skeletons: b._getSkeletons(),
  115651. animationGroups: b._getAnimationGroups(),
  115652. lights: b._babylonLights,
  115653. transformNodes: b._getTransformNodes(),
  115654. geometries: b._getGeometries()
  115655. }
  115656. })
  115657. })
  115658. }
  115659. ,
  115660. a.prototype.loadAsync = function(e, i, o, s, c) {
  115661. var d = this;
  115662. return c === void 0 && (c = ""),
  115663. Promise.resolve().then(function() {
  115664. return d._babylonScene = e,
  115665. d._loadData(i),
  115666. d._loadAsync(o, c, null, function() {})
  115667. })
  115668. }
  115669. ,
  115670. a.prototype._loadAsync = function(e, i, o, s) {
  115671. var c = this;
  115672. return Promise.resolve().then(function() {
  115673. c._rootUrl = e,
  115674. c._uniqueRootUrl = !StringTools.StartsWith(e, "file:") && i ? e : "" + e + Date.now() + "/",
  115675. c._fileName = i,
  115676. c._loadExtensions(),
  115677. c._checkExtensions();
  115678. var d = GLTFLoaderState[GLTFLoaderState.LOADING] + " => " + GLTFLoaderState[GLTFLoaderState.READY]
  115679. , _ = GLTFLoaderState[GLTFLoaderState.LOADING] + " => " + GLTFLoaderState[GLTFLoaderState.COMPLETE];
  115680. c._parent._startPerformanceCounter(d),
  115681. c._parent._startPerformanceCounter(_),
  115682. c._parent._setState(GLTFLoaderState.LOADING),
  115683. c._extensionsOnLoading();
  115684. var b = new Array
  115685. , k = c._babylonScene.blockMaterialDirtyMechanism;
  115686. if (c._babylonScene.blockMaterialDirtyMechanism = !0,
  115687. o)
  115688. b.push(c.loadSceneAsync("/nodes", {
  115689. nodes: o,
  115690. index: -1
  115691. }));
  115692. else if (c._gltf.scene != null || c._gltf.scenes && c._gltf.scenes[0]) {
  115693. var j = ArrayItem.Get("/scene", c._gltf.scenes, c._gltf.scene || 0);
  115694. b.push(c.loadSceneAsync("/scenes/" + j.index, j))
  115695. }
  115696. if (c.parent.loadAllMaterials && c._gltf.materials)
  115697. for (var $ = 0; $ < c._gltf.materials.length; ++$) {
  115698. var _e = c._gltf.materials[$]
  115699. , et = "/materials/" + $
  115700. , tt = Material.TriangleFillMode;
  115701. b.push(c._loadMaterialAsync(et, _e, null, tt, function(it) {}))
  115702. }
  115703. c._babylonScene.blockMaterialDirtyMechanism = k,
  115704. c._parent.compileMaterials && b.push(c._compileMaterialsAsync()),
  115705. c._parent.compileShadowGenerators && b.push(c._compileShadowGeneratorsAsync());
  115706. var rt = Promise.all(b).then(function() {
  115707. return c._rootBabylonMesh && c._rootBabylonMesh.setEnabled(!0),
  115708. c._extensionsOnReady(),
  115709. c._parent._setState(GLTFLoaderState.READY),
  115710. c._startAnimations(),
  115711. s()
  115712. });
  115713. return rt.then(function(it) {
  115714. return c._parent._endPerformanceCounter(d),
  115715. Tools.SetImmediate(function() {
  115716. c._disposed || Promise.all(c._completePromises).then(function() {
  115717. c._parent._endPerformanceCounter(_),
  115718. c._parent._setState(GLTFLoaderState.COMPLETE),
  115719. c._parent.onCompleteObservable.notifyObservers(void 0),
  115720. c._parent.onCompleteObservable.clear(),
  115721. c.dispose()
  115722. }, function(nt) {
  115723. c._parent.onErrorObservable.notifyObservers(nt),
  115724. c._parent.onErrorObservable.clear(),
  115725. c.dispose()
  115726. })
  115727. }),
  115728. it
  115729. })
  115730. }).catch(function(d) {
  115731. throw c._disposed || (c._parent.onErrorObservable.notifyObservers(d),
  115732. c._parent.onErrorObservable.clear(),
  115733. c.dispose()),
  115734. d
  115735. })
  115736. }
  115737. ,
  115738. a.prototype._loadData = function(e) {
  115739. if (this._gltf = e.json,
  115740. this._setupData(),
  115741. e.bin) {
  115742. var i = this._gltf.buffers;
  115743. if (i && i[0] && !i[0].uri) {
  115744. var o = i[0];
  115745. (o.byteLength < e.bin.byteLength - 3 || o.byteLength > e.bin.byteLength) && Logger$2.Warn("Binary buffer length (" + o.byteLength + ") from JSON does not match chunk length (" + e.bin.byteLength + ")"),
  115746. this._bin = e.bin
  115747. } else
  115748. Logger$2.Warn("Unexpected BIN chunk")
  115749. }
  115750. }
  115751. ,
  115752. a.prototype._setupData = function() {
  115753. if (ArrayItem.Assign(this._gltf.accessors),
  115754. ArrayItem.Assign(this._gltf.animations),
  115755. ArrayItem.Assign(this._gltf.buffers),
  115756. ArrayItem.Assign(this._gltf.bufferViews),
  115757. ArrayItem.Assign(this._gltf.cameras),
  115758. ArrayItem.Assign(this._gltf.images),
  115759. ArrayItem.Assign(this._gltf.materials),
  115760. ArrayItem.Assign(this._gltf.meshes),
  115761. ArrayItem.Assign(this._gltf.nodes),
  115762. ArrayItem.Assign(this._gltf.samplers),
  115763. ArrayItem.Assign(this._gltf.scenes),
  115764. ArrayItem.Assign(this._gltf.skins),
  115765. ArrayItem.Assign(this._gltf.textures),
  115766. this._gltf.nodes) {
  115767. for (var e = {}, i = 0, o = this._gltf.nodes; i < o.length; i++) {
  115768. var s = o[i];
  115769. if (s.children)
  115770. for (var c = 0, d = s.children; c < d.length; c++) {
  115771. var _ = d[c];
  115772. e[_] = s.index
  115773. }
  115774. }
  115775. for (var b = this._createRootNode(), k = 0, j = this._gltf.nodes; k < j.length; k++) {
  115776. var s = j[k]
  115777. , $ = e[s.index];
  115778. s.parent = $ === void 0 ? b : this._gltf.nodes[$]
  115779. }
  115780. }
  115781. }
  115782. ,
  115783. a.prototype._loadExtensions = function() {
  115784. for (var e in a._RegisteredExtensions) {
  115785. var i = a._RegisteredExtensions[e].factory(this);
  115786. i.name !== e && Logger$2.Warn("The name of the glTF loader extension instance does not match the registered name: " + i.name + " !== " + e),
  115787. this._extensions.push(i),
  115788. this._parent.onExtensionLoadedObservable.notifyObservers(i)
  115789. }
  115790. this._extensions.sort(function(o, s) {
  115791. return (o.order || Number.MAX_VALUE) - (s.order || Number.MAX_VALUE)
  115792. }),
  115793. this._parent.onExtensionLoadedObservable.clear()
  115794. }
  115795. ,
  115796. a.prototype._checkExtensions = function() {
  115797. if (this._gltf.extensionsRequired)
  115798. for (var e = function(d) {
  115799. var _ = i._extensions.some(function(b) {
  115800. return b.name === d && b.enabled
  115801. });
  115802. if (!_)
  115803. throw new Error("Require extension " + d + " is not available")
  115804. }, i = this, o = 0, s = this._gltf.extensionsRequired; o < s.length; o++) {
  115805. var c = s[o];
  115806. e(c)
  115807. }
  115808. }
  115809. ,
  115810. a.prototype._createRootNode = function() {
  115811. this._babylonScene._blockEntityCollection = !!this._assetContainer,
  115812. this._rootBabylonMesh = new Mesh("__root__",this._babylonScene),
  115813. this._rootBabylonMesh._parentContainer = this._assetContainer,
  115814. this._babylonScene._blockEntityCollection = !1,
  115815. this._rootBabylonMesh.setEnabled(!1);
  115816. var e = {
  115817. _babylonTransformNode: this._rootBabylonMesh,
  115818. index: -1
  115819. };
  115820. switch (this._parent.coordinateSystemMode) {
  115821. case GLTFLoaderCoordinateSystemMode.AUTO:
  115822. {
  115823. this._babylonScene.useRightHandedSystem || (e.rotation = [0, 1, 0, 0],
  115824. e.scale = [1, 1, -1],
  115825. a._LoadTransform(e, this._rootBabylonMesh));
  115826. break
  115827. }
  115828. case GLTFLoaderCoordinateSystemMode.FORCE_RIGHT_HANDED:
  115829. {
  115830. this._babylonScene.useRightHandedSystem = !0;
  115831. break
  115832. }
  115833. default:
  115834. throw new Error("Invalid coordinate system mode (" + this._parent.coordinateSystemMode + ")")
  115835. }
  115836. return this._parent.onMeshLoadedObservable.notifyObservers(this._rootBabylonMesh),
  115837. e
  115838. }
  115839. ,
  115840. a.prototype.loadSceneAsync = function(e, i) {
  115841. var o = this
  115842. , s = this._extensionsLoadSceneAsync(e, i);
  115843. if (s)
  115844. return s;
  115845. var c = new Array;
  115846. if (this.logOpen(e + " " + (i.name || "")),
  115847. i.nodes)
  115848. for (var d = 0, _ = i.nodes; d < _.length; d++) {
  115849. var b = _[d]
  115850. , k = ArrayItem.Get(e + "/nodes/" + b, this._gltf.nodes, b);
  115851. c.push(this.loadNodeAsync("/nodes/" + k.index, k, function(rt) {
  115852. rt.parent = o._rootBabylonMesh
  115853. }))
  115854. }
  115855. if (this._gltf.nodes)
  115856. for (var j = 0, $ = this._gltf.nodes; j < $.length; j++) {
  115857. var k = $[j];
  115858. if (k._babylonTransformNode && k._babylonBones)
  115859. for (var _e = 0, et = k._babylonBones; _e < et.length; _e++) {
  115860. var tt = et[_e];
  115861. tt.linkTransformNode(k._babylonTransformNode)
  115862. }
  115863. }
  115864. return c.push(this._loadAnimationsAsync()),
  115865. this.logClose(),
  115866. Promise.all(c).then(function() {})
  115867. }
  115868. ,
  115869. a.prototype._forEachPrimitive = function(e, i) {
  115870. if (e._primitiveBabylonMeshes)
  115871. for (var o = 0, s = e._primitiveBabylonMeshes; o < s.length; o++) {
  115872. var c = s[o];
  115873. i(c)
  115874. }
  115875. }
  115876. ,
  115877. a.prototype._getGeometries = function() {
  115878. var e = new Array
  115879. , i = this._gltf.nodes;
  115880. if (i)
  115881. for (var o = 0, s = i; o < s.length; o++) {
  115882. var c = s[o];
  115883. this._forEachPrimitive(c, function(d) {
  115884. var _ = d.geometry;
  115885. _ && e.indexOf(_) === -1 && e.push(_)
  115886. })
  115887. }
  115888. return e
  115889. }
  115890. ,
  115891. a.prototype._getMeshes = function() {
  115892. var e = new Array;
  115893. this._rootBabylonMesh && e.push(this._rootBabylonMesh);
  115894. var i = this._gltf.nodes;
  115895. if (i)
  115896. for (var o = 0, s = i; o < s.length; o++) {
  115897. var c = s[o];
  115898. this._forEachPrimitive(c, function(d) {
  115899. e.push(d)
  115900. })
  115901. }
  115902. return e
  115903. }
  115904. ,
  115905. a.prototype._getTransformNodes = function() {
  115906. var e = new Array
  115907. , i = this._gltf.nodes;
  115908. if (i)
  115909. for (var o = 0, s = i; o < s.length; o++) {
  115910. var c = s[o];
  115911. c._babylonTransformNode && c._babylonTransformNode.getClassName() === "TransformNode" && e.push(c._babylonTransformNode)
  115912. }
  115913. return e
  115914. }
  115915. ,
  115916. a.prototype._getSkeletons = function() {
  115917. var e = new Array
  115918. , i = this._gltf.skins;
  115919. if (i)
  115920. for (var o = 0, s = i; o < s.length; o++) {
  115921. var c = s[o];
  115922. c._data && e.push(c._data.babylonSkeleton)
  115923. }
  115924. return e
  115925. }
  115926. ,
  115927. a.prototype._getAnimationGroups = function() {
  115928. var e = new Array
  115929. , i = this._gltf.animations;
  115930. if (i)
  115931. for (var o = 0, s = i; o < s.length; o++) {
  115932. var c = s[o];
  115933. c._babylonAnimationGroup && e.push(c._babylonAnimationGroup)
  115934. }
  115935. return e
  115936. }
  115937. ,
  115938. a.prototype._startAnimations = function() {
  115939. switch (this._parent.animationStartMode) {
  115940. case GLTFLoaderAnimationStartMode.NONE:
  115941. break;
  115942. case GLTFLoaderAnimationStartMode.FIRST:
  115943. {
  115944. var e = this._getAnimationGroups();
  115945. e.length !== 0 && e[0].start(!0);
  115946. break
  115947. }
  115948. case GLTFLoaderAnimationStartMode.ALL:
  115949. {
  115950. for (var e = this._getAnimationGroups(), i = 0, o = e; i < o.length; i++) {
  115951. var s = o[i];
  115952. s.start(!0)
  115953. }
  115954. break
  115955. }
  115956. default:
  115957. {
  115958. Logger$2.Error("Invalid animation start mode (" + this._parent.animationStartMode + ")");
  115959. return
  115960. }
  115961. }
  115962. }
  115963. ,
  115964. a.prototype.loadNodeAsync = function(e, i, o) {
  115965. var s = this;
  115966. o === void 0 && (o = function() {}
  115967. );
  115968. var c = this._extensionsLoadNodeAsync(e, i, o);
  115969. if (c)
  115970. return c;
  115971. if (i._babylonTransformNode)
  115972. throw new Error(e + ": Invalid recursive node hierarchy");
  115973. var d = new Array;
  115974. this.logOpen(e + " " + (i.name || ""));
  115975. var _ = function(j) {
  115976. if (a.AddPointerMetadata(j, e),
  115977. a._LoadTransform(i, j),
  115978. i.camera != null) {
  115979. var $ = ArrayItem.Get(e + "/camera", s._gltf.cameras, i.camera);
  115980. d.push(s.loadCameraAsync("/cameras/" + $.index, $, function(it) {
  115981. it.parent = j
  115982. }))
  115983. }
  115984. if (i.children)
  115985. for (var _e = 0, et = i.children; _e < et.length; _e++) {
  115986. var tt = et[_e]
  115987. , rt = ArrayItem.Get(e + "/children/" + tt, s._gltf.nodes, tt);
  115988. d.push(s.loadNodeAsync("/nodes/" + rt.index, rt, function(it) {
  115989. it.parent = j
  115990. }))
  115991. }
  115992. o(j)
  115993. };
  115994. if (i.mesh == null) {
  115995. var b = i.name || "node" + i.index;
  115996. this._babylonScene._blockEntityCollection = !!this._assetContainer,
  115997. i._babylonTransformNode = new TransformNode(b,this._babylonScene),
  115998. i._babylonTransformNode._parentContainer = this._assetContainer,
  115999. this._babylonScene._blockEntityCollection = !1,
  116000. _(i._babylonTransformNode)
  116001. } else {
  116002. var k = ArrayItem.Get(e + "/mesh", this._gltf.meshes, i.mesh);
  116003. d.push(this._loadMeshAsync("/meshes/" + k.index, i, k, _))
  116004. }
  116005. return this.logClose(),
  116006. Promise.all(d).then(function() {
  116007. return s._forEachPrimitive(i, function(j) {
  116008. j.geometry && j.geometry.useBoundingInfoFromGeometry ? j._updateBoundingInfo() : j.refreshBoundingInfo(!0)
  116009. }),
  116010. i._babylonTransformNode
  116011. })
  116012. }
  116013. ,
  116014. a.prototype._loadMeshAsync = function(e, i, o, s) {
  116015. var c = o.primitives;
  116016. if (!c || !c.length)
  116017. throw new Error(e + ": Primitives are missing");
  116018. c[0].index == null && ArrayItem.Assign(c);
  116019. var d = new Array;
  116020. this.logOpen(e + " " + (o.name || ""));
  116021. var _ = i.name || "node" + i.index;
  116022. if (c.length === 1) {
  116023. var b = o.primitives[0];
  116024. d.push(this._loadMeshPrimitiveAsync(e + "/primitives/" + b.index, _, i, o, b, function(_e) {
  116025. i._babylonTransformNode = _e,
  116026. i._primitiveBabylonMeshes = [_e]
  116027. }))
  116028. } else {
  116029. this._babylonScene._blockEntityCollection = !!this._assetContainer,
  116030. i._babylonTransformNode = new TransformNode(_,this._babylonScene),
  116031. i._babylonTransformNode._parentContainer = this._assetContainer,
  116032. this._babylonScene._blockEntityCollection = !1,
  116033. i._primitiveBabylonMeshes = [];
  116034. for (var k = 0, j = c; k < j.length; k++) {
  116035. var b = j[k];
  116036. d.push(this._loadMeshPrimitiveAsync(e + "/primitives/" + b.index, _ + "_primitive" + b.index, i, o, b, function(et) {
  116037. et.parent = i._babylonTransformNode,
  116038. i._primitiveBabylonMeshes.push(et)
  116039. }))
  116040. }
  116041. }
  116042. if (i.skin != null) {
  116043. var $ = ArrayItem.Get(e + "/skin", this._gltf.skins, i.skin);
  116044. d.push(this._loadSkinAsync("/skins/" + $.index, i, $))
  116045. }
  116046. return s(i._babylonTransformNode),
  116047. this.logClose(),
  116048. Promise.all(d).then(function() {
  116049. return i._babylonTransformNode
  116050. })
  116051. }
  116052. ,
  116053. a.prototype._loadMeshPrimitiveAsync = function(e, i, o, s, c, d) {
  116054. var _ = this
  116055. , b = this._extensionsLoadMeshPrimitiveAsync(e, i, o, s, c, d);
  116056. if (b)
  116057. return b;
  116058. this.logOpen("" + e);
  116059. var k = this._disableInstancedMesh === 0 && this._parent.createInstances && o.skin == null && !s.primitives[0].targets, j, $;
  116060. if (k && c._instanceData)
  116061. this._babylonScene._blockEntityCollection = !!this._assetContainer,
  116062. j = c._instanceData.babylonSourceMesh.createInstance(i),
  116063. j._parentContainer = this._assetContainer,
  116064. this._babylonScene._blockEntityCollection = !1,
  116065. $ = c._instanceData.promise;
  116066. else {
  116067. var _e = new Array;
  116068. this._babylonScene._blockEntityCollection = !!this._assetContainer;
  116069. var et = new Mesh(i,this._babylonScene);
  116070. et._parentContainer = this._assetContainer,
  116071. this._babylonScene._blockEntityCollection = !1,
  116072. et.overrideMaterialSideOrientation = this._babylonScene.useRightHandedSystem ? Material.CounterClockWiseSideOrientation : Material.ClockWiseSideOrientation,
  116073. this._createMorphTargets(e, o, s, c, et),
  116074. _e.push(this._loadVertexDataAsync(e, c, et).then(function(nt) {
  116075. return _._loadMorphTargetsAsync(e, c, et, nt).then(function() {
  116076. _._babylonScene._blockEntityCollection = !!_._assetContainer,
  116077. nt.applyToMesh(et),
  116078. nt._parentContainer = _._assetContainer,
  116079. _._babylonScene._blockEntityCollection = !1
  116080. })
  116081. }));
  116082. var tt = a._GetDrawMode(e, c.mode);
  116083. if (c.material == null) {
  116084. var rt = this._defaultBabylonMaterialData[tt];
  116085. rt || (rt = this._createDefaultMaterial("__GLTFLoader._default", tt),
  116086. this._parent.onMaterialLoadedObservable.notifyObservers(rt),
  116087. this._defaultBabylonMaterialData[tt] = rt),
  116088. et.material = rt
  116089. } else {
  116090. var it = ArrayItem.Get(e + "/material", this._gltf.materials, c.material);
  116091. _e.push(this._loadMaterialAsync("/materials/" + it.index, it, et, tt, function(nt) {
  116092. et.material = nt
  116093. }))
  116094. }
  116095. $ = Promise.all(_e),
  116096. k && (c._instanceData = {
  116097. babylonSourceMesh: et,
  116098. promise: $
  116099. }),
  116100. j = et
  116101. }
  116102. return a.AddPointerMetadata(j, e),
  116103. this._parent.onMeshLoadedObservable.notifyObservers(j),
  116104. d(j),
  116105. this.logClose(),
  116106. $.then(function() {
  116107. return j
  116108. })
  116109. }
  116110. ,
  116111. a.prototype._loadVertexDataAsync = function(e, i, o) {
  116112. var s = this
  116113. , c = this._extensionsLoadVertexDataAsync(e, i, o);
  116114. if (c)
  116115. return c;
  116116. var d = i.attributes;
  116117. if (!d)
  116118. throw new Error(e + ": Attributes are missing");
  116119. var _ = new Array
  116120. , b = new Geometry(o.name,this._babylonScene);
  116121. if (i.indices == null)
  116122. o.isUnIndexed = !0;
  116123. else {
  116124. var k = ArrayItem.Get(e + "/indices", this._gltf.accessors, i.indices);
  116125. _.push(this._loadIndicesAccessorAsync("/accessors/" + k.index, k).then(function($) {
  116126. b.setIndices($)
  116127. }))
  116128. }
  116129. var j = function($, _e, et) {
  116130. if (d[$] != null) {
  116131. o._delayInfo = o._delayInfo || [],
  116132. o._delayInfo.indexOf(_e) === -1 && o._delayInfo.push(_e);
  116133. var tt = ArrayItem.Get(e + "/attributes/" + $, s._gltf.accessors, d[$]);
  116134. _.push(s._loadVertexAccessorAsync("/accessors/" + tt.index, tt, _e).then(function(rt) {
  116135. if (rt.getKind() === VertexBuffer.PositionKind && !s.parent.alwaysComputeBoundingBox && !o.skeleton) {
  116136. var it = tt.min
  116137. , nt = tt.max;
  116138. if (it !== void 0 && nt !== void 0) {
  116139. if (tt.normalized && tt.componentType !== 5126) {
  116140. var ot = 1;
  116141. switch (tt.componentType) {
  116142. case 5120:
  116143. ot = 127;
  116144. break;
  116145. case 5121:
  116146. ot = 255;
  116147. break;
  116148. case 5122:
  116149. ot = 32767;
  116150. break;
  116151. case 5123:
  116152. ot = 65535;
  116153. break
  116154. }
  116155. for (var at = 0; at < 3; ++at)
  116156. it[at] = Math.max(it[at] / ot, -1),
  116157. nt[at] = Math.max(nt[at] / ot, -1)
  116158. }
  116159. var st = TmpVectors.Vector3[0]
  116160. , ut = TmpVectors.Vector3[1];
  116161. st.copyFromFloats.apply(st, it),
  116162. ut.copyFromFloats.apply(ut, nt),
  116163. b._boundingInfo = new BoundingInfo(st,ut),
  116164. b.useBoundingInfoFromGeometry = !0
  116165. }
  116166. }
  116167. b.setVerticesBuffer(rt, tt.count)
  116168. })),
  116169. _e == VertexBuffer.MatricesIndicesExtraKind && (o.numBoneInfluencers = 8),
  116170. et && et(tt)
  116171. }
  116172. };
  116173. return j("POSITION", VertexBuffer.PositionKind),
  116174. j("NORMAL", VertexBuffer.NormalKind),
  116175. j("TANGENT", VertexBuffer.TangentKind),
  116176. j("TEXCOORD_0", VertexBuffer.UVKind),
  116177. j("TEXCOORD_1", VertexBuffer.UV2Kind),
  116178. j("TEXCOORD_2", VertexBuffer.UV3Kind),
  116179. j("TEXCOORD_3", VertexBuffer.UV4Kind),
  116180. j("TEXCOORD_4", VertexBuffer.UV5Kind),
  116181. j("TEXCOORD_5", VertexBuffer.UV6Kind),
  116182. j("JOINTS_0", VertexBuffer.MatricesIndicesKind),
  116183. j("WEIGHTS_0", VertexBuffer.MatricesWeightsKind),
  116184. j("JOINTS_1", VertexBuffer.MatricesIndicesExtraKind),
  116185. j("WEIGHTS_1", VertexBuffer.MatricesWeightsExtraKind),
  116186. j("COLOR_0", VertexBuffer.ColorKind, function($) {
  116187. $.type === "VEC4" && (o.hasVertexAlpha = !0)
  116188. }),
  116189. Promise.all(_).then(function() {
  116190. return b
  116191. })
  116192. }
  116193. ,
  116194. a.prototype._createMorphTargets = function(e, i, o, s, c) {
  116195. if (!!s.targets) {
  116196. if (i._numMorphTargets == null)
  116197. i._numMorphTargets = s.targets.length;
  116198. else if (s.targets.length !== i._numMorphTargets)
  116199. throw new Error(e + ": Primitives do not have the same number of targets");
  116200. var d = o.extras ? o.extras.targetNames : null;
  116201. c.morphTargetManager = new MorphTargetManager(c.getScene()),
  116202. c.morphTargetManager.areUpdatesFrozen = !0;
  116203. for (var _ = 0; _ < s.targets.length; _++) {
  116204. var b = i.weights ? i.weights[_] : o.weights ? o.weights[_] : 0
  116205. , k = d ? d[_] : "morphTarget" + _;
  116206. c.morphTargetManager.addTarget(new MorphTarget(k,b,c.getScene()))
  116207. }
  116208. }
  116209. }
  116210. ,
  116211. a.prototype._loadMorphTargetsAsync = function(e, i, o, s) {
  116212. if (!i.targets)
  116213. return Promise.resolve();
  116214. for (var c = new Array, d = o.morphTargetManager, _ = 0; _ < d.numTargets; _++) {
  116215. var b = d.getTarget(_);
  116216. c.push(this._loadMorphTargetVertexDataAsync(e + "/targets/" + _, s, i.targets[_], b))
  116217. }
  116218. return Promise.all(c).then(function() {
  116219. d.areUpdatesFrozen = !1
  116220. })
  116221. }
  116222. ,
  116223. a.prototype._loadMorphTargetVertexDataAsync = function(e, i, o, s) {
  116224. var c = this
  116225. , d = new Array
  116226. , _ = function(b, k, j) {
  116227. if (o[b] != null) {
  116228. var $ = i.getVertexBuffer(k);
  116229. if (!!$) {
  116230. var _e = ArrayItem.Get(e + "/" + b, c._gltf.accessors, o[b]);
  116231. d.push(c._loadFloatAccessorAsync("/accessors/" + _e.index, _e).then(function(et) {
  116232. j($, et)
  116233. }))
  116234. }
  116235. }
  116236. };
  116237. return _("POSITION", VertexBuffer.PositionKind, function(b, k) {
  116238. var j = new Float32Array(k.length);
  116239. b.forEach(k.length, function($, _e) {
  116240. j[_e] = k[_e] + $
  116241. }),
  116242. s.setPositions(j)
  116243. }),
  116244. _("NORMAL", VertexBuffer.NormalKind, function(b, k) {
  116245. var j = new Float32Array(k.length);
  116246. b.forEach(j.length, function($, _e) {
  116247. j[_e] = k[_e] + $
  116248. }),
  116249. s.setNormals(j)
  116250. }),
  116251. _("TANGENT", VertexBuffer.TangentKind, function(b, k) {
  116252. var j = new Float32Array(k.length / 3 * 4)
  116253. , $ = 0;
  116254. b.forEach(k.length / 3 * 4, function(_e, et) {
  116255. (et + 1) % 4 !== 0 && (j[$] = k[$] + _e,
  116256. $++)
  116257. }),
  116258. s.setTangents(j)
  116259. }),
  116260. Promise.all(d).then(function() {})
  116261. }
  116262. ,
  116263. a._LoadTransform = function(e, i) {
  116264. if (e.skin == null) {
  116265. var o = Vector3.Zero()
  116266. , s = Quaternion.Identity()
  116267. , c = Vector3.One();
  116268. if (e.matrix) {
  116269. var d = Matrix.FromArray(e.matrix);
  116270. d.decompose(c, s, o)
  116271. } else
  116272. e.translation && (o = Vector3.FromArray(e.translation)),
  116273. e.rotation && (s = Quaternion.FromArray(e.rotation)),
  116274. e.scale && (c = Vector3.FromArray(e.scale));
  116275. i.position = o,
  116276. i.rotationQuaternion = s,
  116277. i.scaling = c
  116278. }
  116279. }
  116280. ,
  116281. a.prototype._loadSkinAsync = function(e, i, o) {
  116282. var s = this
  116283. , c = this._extensionsLoadSkinAsync(e, i, o);
  116284. if (c)
  116285. return c;
  116286. var d = function(j) {
  116287. s._forEachPrimitive(i, function($) {
  116288. $.skeleton = j
  116289. })
  116290. };
  116291. if (o._data)
  116292. return d(o._data.babylonSkeleton),
  116293. o._data.promise;
  116294. var _ = "skeleton" + o.index;
  116295. this._babylonScene._blockEntityCollection = !!this._assetContainer;
  116296. var b = new Skeleton(o.name || _,_,this._babylonScene);
  116297. b._parentContainer = this._assetContainer,
  116298. this._babylonScene._blockEntityCollection = !1,
  116299. b.overrideMesh = this._rootBabylonMesh,
  116300. this._loadBones(e, o, b),
  116301. d(b);
  116302. var k = this._loadSkinInverseBindMatricesDataAsync(e, o).then(function(j) {
  116303. s._updateBoneMatrices(b, j)
  116304. });
  116305. return o._data = {
  116306. babylonSkeleton: b,
  116307. promise: k
  116308. },
  116309. k
  116310. }
  116311. ,
  116312. a.prototype._loadBones = function(e, i, o) {
  116313. for (var s = {}, c = 0, d = i.joints; c < d.length; c++) {
  116314. var _ = d[c]
  116315. , b = ArrayItem.Get(e + "/joints/" + _, this._gltf.nodes, _);
  116316. this._loadBone(b, i, o, s)
  116317. }
  116318. }
  116319. ,
  116320. a.prototype._loadBone = function(e, i, o, s) {
  116321. var c = s[e.index];
  116322. if (c)
  116323. return c;
  116324. var d = null;
  116325. e.parent && e.parent._babylonTransformNode !== this._rootBabylonMesh && (d = this._loadBone(e.parent, i, o, s));
  116326. var _ = i.joints.indexOf(e.index);
  116327. return c = new Bone(e.name || "joint" + e.index,o,d,this._getNodeMatrix(e),null,null,_),
  116328. s[e.index] = c,
  116329. e._babylonBones = e._babylonBones || [],
  116330. e._babylonBones.push(c),
  116331. c
  116332. }
  116333. ,
  116334. a.prototype._loadSkinInverseBindMatricesDataAsync = function(e, i) {
  116335. if (i.inverseBindMatrices == null)
  116336. return Promise.resolve(null);
  116337. var o = ArrayItem.Get(e + "/inverseBindMatrices", this._gltf.accessors, i.inverseBindMatrices);
  116338. return this._loadFloatAccessorAsync("/accessors/" + o.index, o)
  116339. }
  116340. ,
  116341. a.prototype._updateBoneMatrices = function(e, i) {
  116342. for (var o = 0, s = e.bones; o < s.length; o++) {
  116343. var c = s[o]
  116344. , d = Matrix.Identity()
  116345. , _ = c._index;
  116346. i && _ !== -1 && (Matrix.FromArrayToRef(i, _ * 16, d),
  116347. d.invertToRef(d));
  116348. var b = c.getParent();
  116349. b && d.multiplyToRef(b.getInvertedAbsoluteTransform(), d),
  116350. c.updateMatrix(d, !1, !1),
  116351. c._updateDifferenceMatrix(void 0, !1)
  116352. }
  116353. }
  116354. ,
  116355. a.prototype._getNodeMatrix = function(e) {
  116356. return e.matrix ? Matrix.FromArray(e.matrix) : Matrix.Compose(e.scale ? Vector3.FromArray(e.scale) : Vector3.One(), e.rotation ? Quaternion.FromArray(e.rotation) : Quaternion.Identity(), e.translation ? Vector3.FromArray(e.translation) : Vector3.Zero())
  116357. }
  116358. ,
  116359. a.prototype.loadCameraAsync = function(e, i, o) {
  116360. o === void 0 && (o = function() {}
  116361. );
  116362. var s = this._extensionsLoadCameraAsync(e, i, o);
  116363. if (s)
  116364. return s;
  116365. var c = new Array;
  116366. this.logOpen(e + " " + (i.name || "")),
  116367. this._babylonScene._blockEntityCollection = !!this._assetContainer;
  116368. var d = new FreeCamera(i.name || "camera" + i.index,Vector3.Zero(),this._babylonScene,!1);
  116369. switch (d._parentContainer = this._assetContainer,
  116370. this._babylonScene._blockEntityCollection = !1,
  116371. d.ignoreParentScaling = !0,
  116372. d.rotation = new Vector3(0,Math.PI,0),
  116373. i.type) {
  116374. case "perspective":
  116375. {
  116376. var _ = i.perspective;
  116377. if (!_)
  116378. throw new Error(e + ": Camera perspective properties are missing");
  116379. d.fov = _.yfov,
  116380. d.minZ = _.znear,
  116381. d.maxZ = _.zfar || 0;
  116382. break
  116383. }
  116384. case "orthographic":
  116385. {
  116386. if (!i.orthographic)
  116387. throw new Error(e + ": Camera orthographic properties are missing");
  116388. d.mode = Camera$1.ORTHOGRAPHIC_CAMERA,
  116389. d.orthoLeft = -i.orthographic.xmag,
  116390. d.orthoRight = i.orthographic.xmag,
  116391. d.orthoBottom = -i.orthographic.ymag,
  116392. d.orthoTop = i.orthographic.ymag,
  116393. d.minZ = i.orthographic.znear,
  116394. d.maxZ = i.orthographic.zfar;
  116395. break
  116396. }
  116397. default:
  116398. throw new Error(e + ": Invalid camera type (" + i.type + ")")
  116399. }
  116400. return a.AddPointerMetadata(d, e),
  116401. this._parent.onCameraLoadedObservable.notifyObservers(d),
  116402. o(d),
  116403. this.logClose(),
  116404. Promise.all(c).then(function() {
  116405. return d
  116406. })
  116407. }
  116408. ,
  116409. a.prototype._loadAnimationsAsync = function() {
  116410. var e = this._gltf.animations;
  116411. if (!e)
  116412. return Promise.resolve();
  116413. for (var i = new Array, o = 0; o < e.length; o++) {
  116414. var s = e[o];
  116415. i.push(this.loadAnimationAsync("/animations/" + s.index, s).then(function(c) {
  116416. c.targetedAnimations.length === 0 && c.dispose()
  116417. }))
  116418. }
  116419. return Promise.all(i).then(function() {})
  116420. }
  116421. ,
  116422. a.prototype.loadAnimationAsync = function(e, i) {
  116423. var o = this._extensionsLoadAnimationAsync(e, i);
  116424. if (o)
  116425. return o;
  116426. this._babylonScene._blockEntityCollection = !!this._assetContainer;
  116427. var s = new AnimationGroup(i.name || "animation" + i.index,this._babylonScene);
  116428. s._parentContainer = this._assetContainer,
  116429. this._babylonScene._blockEntityCollection = !1,
  116430. i._babylonAnimationGroup = s;
  116431. var c = new Array;
  116432. ArrayItem.Assign(i.channels),
  116433. ArrayItem.Assign(i.samplers);
  116434. for (var d = 0, _ = i.channels; d < _.length; d++) {
  116435. var b = _[d];
  116436. c.push(this._loadAnimationChannelAsync(e + "/channels/" + b.index, e, i, b, s))
  116437. }
  116438. return Promise.all(c).then(function() {
  116439. return s.normalize(0),
  116440. s
  116441. })
  116442. }
  116443. ,
  116444. a.prototype._loadAnimationChannelAsync = function(e, i, o, s, c, d) {
  116445. var _ = this;
  116446. if (d === void 0 && (d = null),
  116447. s.target.node == null)
  116448. return Promise.resolve();
  116449. var b = ArrayItem.Get(e + "/target/node", this._gltf.nodes, s.target.node);
  116450. if (s.target.path === "weights" && !b._numMorphTargets || s.target.path !== "weights" && !b._babylonTransformNode)
  116451. return Promise.resolve();
  116452. var k = ArrayItem.Get(e + "/sampler", o.samplers, s.sampler);
  116453. return this._loadAnimationSamplerAsync(i + "/samplers/" + s.sampler, k).then(function(j) {
  116454. var $, _e;
  116455. switch (s.target.path) {
  116456. case "translation":
  116457. {
  116458. $ = "position",
  116459. _e = Animation.ANIMATIONTYPE_VECTOR3;
  116460. break
  116461. }
  116462. case "rotation":
  116463. {
  116464. $ = "rotationQuaternion",
  116465. _e = Animation.ANIMATIONTYPE_QUATERNION;
  116466. break
  116467. }
  116468. case "scale":
  116469. {
  116470. $ = "scaling",
  116471. _e = Animation.ANIMATIONTYPE_VECTOR3;
  116472. break
  116473. }
  116474. case "weights":
  116475. {
  116476. $ = "influence",
  116477. _e = Animation.ANIMATIONTYPE_FLOAT;
  116478. break
  116479. }
  116480. default:
  116481. throw new Error(e + "/target/path: Invalid value (" + s.target.path + ")")
  116482. }
  116483. var et = 0, tt;
  116484. switch ($) {
  116485. case "position":
  116486. {
  116487. tt = function() {
  116488. var ct = Vector3.FromArray(j.output, et);
  116489. return et += 3,
  116490. ct
  116491. }
  116492. ;
  116493. break
  116494. }
  116495. case "rotationQuaternion":
  116496. {
  116497. tt = function() {
  116498. var ct = Quaternion.FromArray(j.output, et);
  116499. return et += 4,
  116500. ct
  116501. }
  116502. ;
  116503. break
  116504. }
  116505. case "scaling":
  116506. {
  116507. tt = function() {
  116508. var ct = Vector3.FromArray(j.output, et);
  116509. return et += 3,
  116510. ct
  116511. }
  116512. ;
  116513. break
  116514. }
  116515. case "influence":
  116516. {
  116517. tt = function() {
  116518. for (var ct = new Array(b._numMorphTargets), lt = 0; lt < b._numMorphTargets; lt++)
  116519. ct[lt] = j.output[et++];
  116520. return ct
  116521. }
  116522. ;
  116523. break
  116524. }
  116525. }
  116526. var rt;
  116527. switch (j.interpolation) {
  116528. case "STEP":
  116529. {
  116530. rt = function(ct) {
  116531. return {
  116532. frame: j.input[ct],
  116533. value: tt(),
  116534. interpolation: AnimationKeyInterpolation.STEP
  116535. }
  116536. }
  116537. ;
  116538. break
  116539. }
  116540. case "LINEAR":
  116541. {
  116542. rt = function(ct) {
  116543. return {
  116544. frame: j.input[ct],
  116545. value: tt()
  116546. }
  116547. }
  116548. ;
  116549. break
  116550. }
  116551. case "CUBICSPLINE":
  116552. {
  116553. rt = function(ct) {
  116554. return {
  116555. frame: j.input[ct],
  116556. inTangent: tt(),
  116557. value: tt(),
  116558. outTangent: tt()
  116559. }
  116560. }
  116561. ;
  116562. break
  116563. }
  116564. }
  116565. for (var it = new Array(j.input.length), nt = 0; nt < j.input.length; nt++)
  116566. it[nt] = rt(nt);
  116567. if ($ === "influence")
  116568. for (var ot = function(ct) {
  116569. var lt = c.name + "_channel" + c.targetedAnimations.length
  116570. , ft = new Animation(lt,$,1,_e);
  116571. ft.setKeys(it.map(function(ht) {
  116572. return {
  116573. frame: ht.frame,
  116574. inTangent: ht.inTangent ? ht.inTangent[ct] : void 0,
  116575. value: ht.value[ct],
  116576. outTangent: ht.outTangent ? ht.outTangent[ct] : void 0
  116577. }
  116578. })),
  116579. _._forEachPrimitive(b, function(ht) {
  116580. var pt = ht
  116581. , dt = pt.morphTargetManager.getTarget(ct)
  116582. , _t = ft.clone();
  116583. dt.animations.push(_t),
  116584. c.addTargetedAnimation(_t, dt)
  116585. })
  116586. }, at = 0; at < b._numMorphTargets; at++)
  116587. ot(at);
  116588. else {
  116589. var st = c.name + "_channel" + c.targetedAnimations.length
  116590. , ut = new Animation(st,$,1,_e);
  116591. ut.setKeys(it),
  116592. d != null && d.animations != null ? (d.animations.push(ut),
  116593. c.addTargetedAnimation(ut, d)) : (b._babylonTransformNode.animations.push(ut),
  116594. c.addTargetedAnimation(ut, b._babylonTransformNode))
  116595. }
  116596. })
  116597. }
  116598. ,
  116599. a.prototype._loadAnimationSamplerAsync = function(e, i) {
  116600. if (i._data)
  116601. return i._data;
  116602. var o = i.interpolation || "LINEAR";
  116603. switch (o) {
  116604. case "STEP":
  116605. case "LINEAR":
  116606. case "CUBICSPLINE":
  116607. break;
  116608. default:
  116609. throw new Error(e + "/interpolation: Invalid value (" + i.interpolation + ")")
  116610. }
  116611. var s = ArrayItem.Get(e + "/input", this._gltf.accessors, i.input)
  116612. , c = ArrayItem.Get(e + "/output", this._gltf.accessors, i.output);
  116613. return i._data = Promise.all([this._loadFloatAccessorAsync("/accessors/" + s.index, s), this._loadFloatAccessorAsync("/accessors/" + c.index, c)]).then(function(d) {
  116614. var _ = d[0]
  116615. , b = d[1];
  116616. return {
  116617. input: _,
  116618. interpolation: o,
  116619. output: b
  116620. }
  116621. }),
  116622. i._data
  116623. }
  116624. ,
  116625. a.prototype.loadBufferAsync = function(e, i, o, s) {
  116626. var c = this._extensionsLoadBufferAsync(e, i, o, s);
  116627. if (c)
  116628. return c;
  116629. if (!i._data)
  116630. if (i.uri)
  116631. i._data = this.loadUriAsync(e + "/uri", i, i.uri);
  116632. else {
  116633. if (!this._bin)
  116634. throw new Error(e + ": Uri is missing or the binary glTF is missing its binary chunk");
  116635. i._data = this._bin.readAsync(0, i.byteLength)
  116636. }
  116637. return i._data.then(function(d) {
  116638. try {
  116639. return new Uint8Array(d.buffer,d.byteOffset + o,s)
  116640. } catch (_) {
  116641. throw new Error(e + ": " + _.message)
  116642. }
  116643. })
  116644. }
  116645. ,
  116646. a.prototype.loadBufferViewAsync = function(e, i) {
  116647. var o = this._extensionsLoadBufferViewAsync(e, i);
  116648. if (o)
  116649. return o;
  116650. if (i._data)
  116651. return i._data;
  116652. var s = ArrayItem.Get(e + "/buffer", this._gltf.buffers, i.buffer);
  116653. return i._data = this.loadBufferAsync("/buffers/" + s.index, s, i.byteOffset || 0, i.byteLength),
  116654. i._data
  116655. }
  116656. ,
  116657. a.prototype._loadAccessorAsync = function(e, i, o) {
  116658. var s = this;
  116659. if (i._data)
  116660. return i._data;
  116661. var c = a._GetNumComponents(e, i.type)
  116662. , d = c * VertexBuffer.GetTypeByteLength(i.componentType)
  116663. , _ = c * i.count;
  116664. if (i.bufferView == null)
  116665. i._data = Promise.resolve(new o(_));
  116666. else {
  116667. var b = ArrayItem.Get(e + "/bufferView", this._gltf.bufferViews, i.bufferView);
  116668. i._data = this.loadBufferViewAsync("/bufferViews/" + b.index, b).then(function(j) {
  116669. if (i.componentType === 5126 && !i.normalized && (!b.byteStride || b.byteStride === d))
  116670. return a._GetTypedArray(e, i.componentType, j, i.byteOffset, _);
  116671. var $ = new o(_);
  116672. return VertexBuffer.ForEach(j, i.byteOffset || 0, b.byteStride || d, c, i.componentType, $.length, i.normalized || !1, function(_e, et) {
  116673. $[et] = _e
  116674. }),
  116675. $
  116676. })
  116677. }
  116678. if (i.sparse) {
  116679. var k = i.sparse;
  116680. i._data = i._data.then(function(j) {
  116681. var $ = j
  116682. , _e = ArrayItem.Get(e + "/sparse/indices/bufferView", s._gltf.bufferViews, k.indices.bufferView)
  116683. , et = ArrayItem.Get(e + "/sparse/values/bufferView", s._gltf.bufferViews, k.values.bufferView);
  116684. return Promise.all([s.loadBufferViewAsync("/bufferViews/" + _e.index, _e), s.loadBufferViewAsync("/bufferViews/" + et.index, et)]).then(function(tt) {
  116685. var rt = tt[0], it = tt[1], nt = a._GetTypedArray(e + "/sparse/indices", k.indices.componentType, rt, k.indices.byteOffset, k.count), ot = c * k.count, at;
  116686. if (i.componentType === 5126 && !i.normalized)
  116687. at = a._GetTypedArray(e + "/sparse/values", i.componentType, it, k.values.byteOffset, ot);
  116688. else {
  116689. var st = a._GetTypedArray(e + "/sparse/values", i.componentType, it, k.values.byteOffset, ot);
  116690. at = new o(ot),
  116691. VertexBuffer.ForEach(st, 0, d, c, i.componentType, at.length, i.normalized || !1, function(ht, pt) {
  116692. at[pt] = ht
  116693. })
  116694. }
  116695. for (var ut = 0, ct = 0; ct < nt.length; ct++)
  116696. for (var lt = nt[ct] * c, ft = 0; ft < c; ft++)
  116697. $[lt++] = at[ut++];
  116698. return $
  116699. })
  116700. })
  116701. }
  116702. return i._data
  116703. }
  116704. ,
  116705. a.prototype._loadFloatAccessorAsync = function(e, i) {
  116706. return this._loadAccessorAsync(e, i, Float32Array)
  116707. }
  116708. ,
  116709. a.prototype._loadIndicesAccessorAsync = function(e, i) {
  116710. if (i.type !== "SCALAR")
  116711. throw new Error(e + "/type: Invalid value " + i.type);
  116712. if (i.componentType !== 5121 && i.componentType !== 5123 && i.componentType !== 5125)
  116713. throw new Error(e + "/componentType: Invalid value " + i.componentType);
  116714. if (i._data)
  116715. return i._data;
  116716. if (i.sparse) {
  116717. var o = a._GetTypedArrayConstructor(e + "/componentType", i.componentType);
  116718. i._data = this._loadAccessorAsync(e, i, o)
  116719. } else {
  116720. var s = ArrayItem.Get(e + "/bufferView", this._gltf.bufferViews, i.bufferView);
  116721. i._data = this.loadBufferViewAsync("/bufferViews/" + s.index, s).then(function(c) {
  116722. return a._GetTypedArray(e, i.componentType, c, i.byteOffset, i.count)
  116723. })
  116724. }
  116725. return i._data
  116726. }
  116727. ,
  116728. a.prototype._loadVertexBufferViewAsync = function(e, i) {
  116729. var o = this;
  116730. return e._babylonBuffer || (e._babylonBuffer = this.loadBufferViewAsync("/bufferViews/" + e.index, e).then(function(s) {
  116731. return new Buffer(o._babylonScene.getEngine(),s,!1)
  116732. })),
  116733. e._babylonBuffer
  116734. }
  116735. ,
  116736. a.prototype._loadVertexAccessorAsync = function(e, i, o) {
  116737. var s = this, c;
  116738. if (!((c = i._babylonVertexBuffer) === null || c === void 0) && c[o])
  116739. return i._babylonVertexBuffer[o];
  116740. if (i._babylonVertexBuffer || (i._babylonVertexBuffer = {}),
  116741. i.sparse)
  116742. i._babylonVertexBuffer[o] = this._loadFloatAccessorAsync(e, i).then(function(_) {
  116743. return new VertexBuffer(s._babylonScene.getEngine(),_,o,!1)
  116744. });
  116745. else if (o === VertexBuffer.MatricesIndicesKind || o === VertexBuffer.MatricesIndicesExtraKind)
  116746. i._babylonVertexBuffer[o] = this._loadFloatAccessorAsync(e, i).then(function(_) {
  116747. return new VertexBuffer(s._babylonScene.getEngine(),_,o,!1)
  116748. });
  116749. else {
  116750. var d = ArrayItem.Get(e + "/bufferView", this._gltf.bufferViews, i.bufferView);
  116751. i._babylonVertexBuffer[o] = this._loadVertexBufferViewAsync(d, o).then(function(_) {
  116752. var b = a._GetNumComponents(e, i.type);
  116753. return new VertexBuffer(s._babylonScene.getEngine(),_,o,!1,!1,d.byteStride,!1,i.byteOffset,b,i.componentType,i.normalized,!0,1,!0)
  116754. })
  116755. }
  116756. return i._babylonVertexBuffer[o]
  116757. }
  116758. ,
  116759. a.prototype._loadMaterialMetallicRoughnessPropertiesAsync = function(e, i, o) {
  116760. if (!(o instanceof PBRMaterial))
  116761. throw new Error(e + ": Material type not supported");
  116762. var s = new Array;
  116763. return i && (i.baseColorFactor ? (o.albedoColor = Color3.FromArray(i.baseColorFactor),
  116764. o.alpha = i.baseColorFactor[3]) : o.albedoColor = Color3.White(),
  116765. o.metallic = i.metallicFactor == null ? 1 : i.metallicFactor,
  116766. o.roughness = i.roughnessFactor == null ? 1 : i.roughnessFactor,
  116767. i.baseColorTexture && s.push(this.loadTextureInfoAsync(e + "/baseColorTexture", i.baseColorTexture, function(c) {
  116768. c.name = o.name + " (Base Color)",
  116769. o.albedoTexture = c
  116770. })),
  116771. i.metallicRoughnessTexture && (i.metallicRoughnessTexture.nonColorData = !0,
  116772. s.push(this.loadTextureInfoAsync(e + "/metallicRoughnessTexture", i.metallicRoughnessTexture, function(c) {
  116773. c.name = o.name + " (Metallic Roughness)",
  116774. o.metallicTexture = c
  116775. })),
  116776. o.useMetallnessFromMetallicTextureBlue = !0,
  116777. o.useRoughnessFromMetallicTextureGreen = !0,
  116778. o.useRoughnessFromMetallicTextureAlpha = !1)),
  116779. Promise.all(s).then(function() {})
  116780. }
  116781. ,
  116782. a.prototype._loadMaterialAsync = function(e, i, o, s, c) {
  116783. c === void 0 && (c = function() {}
  116784. );
  116785. var d = this._extensionsLoadMaterialAsync(e, i, o, s, c);
  116786. if (d)
  116787. return d;
  116788. i._data = i._data || {};
  116789. var _ = i._data[s];
  116790. if (!_) {
  116791. this.logOpen(e + " " + (i.name || ""));
  116792. var b = this.createMaterial(e, i, s);
  116793. _ = {
  116794. babylonMaterial: b,
  116795. babylonMeshes: [],
  116796. promise: this.loadMaterialPropertiesAsync(e, i, b)
  116797. },
  116798. i._data[s] = _,
  116799. a.AddPointerMetadata(b, e),
  116800. this._parent.onMaterialLoadedObservable.notifyObservers(b),
  116801. this.logClose()
  116802. }
  116803. return o && (_.babylonMeshes.push(o),
  116804. o.onDisposeObservable.addOnce(function() {
  116805. var k = _.babylonMeshes.indexOf(o);
  116806. k !== -1 && _.babylonMeshes.splice(k, 1)
  116807. })),
  116808. c(_.babylonMaterial),
  116809. _.promise.then(function() {
  116810. return _.babylonMaterial
  116811. })
  116812. }
  116813. ,
  116814. a.prototype._createDefaultMaterial = function(e, i) {
  116815. this._babylonScene._blockEntityCollection = !!this._assetContainer;
  116816. var o = new PBRMaterial(e,this._babylonScene);
  116817. return o._parentContainer = this._assetContainer,
  116818. this._babylonScene._blockEntityCollection = !1,
  116819. o.fillMode = i,
  116820. o.enableSpecularAntiAliasing = !0,
  116821. o.useRadianceOverAlpha = !this._parent.transparencyAsCoverage,
  116822. o.useSpecularOverAlpha = !this._parent.transparencyAsCoverage,
  116823. o.transparencyMode = PBRMaterial.PBRMATERIAL_OPAQUE,
  116824. o.metallic = 1,
  116825. o.roughness = 1,
  116826. o
  116827. }
  116828. ,
  116829. a.prototype.createMaterial = function(e, i, o) {
  116830. var s = this._extensionsCreateMaterial(e, i, o);
  116831. if (s)
  116832. return s;
  116833. var c = i.name || "material" + i.index
  116834. , d = this._createDefaultMaterial(c, o);
  116835. return d
  116836. }
  116837. ,
  116838. a.prototype.loadMaterialPropertiesAsync = function(e, i, o) {
  116839. var s = this._extensionsLoadMaterialPropertiesAsync(e, i, o);
  116840. if (s)
  116841. return s;
  116842. var c = new Array;
  116843. return c.push(this.loadMaterialBasePropertiesAsync(e, i, o)),
  116844. i.pbrMetallicRoughness && c.push(this._loadMaterialMetallicRoughnessPropertiesAsync(e + "/pbrMetallicRoughness", i.pbrMetallicRoughness, o)),
  116845. this.loadMaterialAlphaProperties(e, i, o),
  116846. Promise.all(c).then(function() {})
  116847. }
  116848. ,
  116849. a.prototype.loadMaterialBasePropertiesAsync = function(e, i, o) {
  116850. if (!(o instanceof PBRMaterial))
  116851. throw new Error(e + ": Material type not supported");
  116852. var s = new Array;
  116853. return o.emissiveColor = i.emissiveFactor ? Color3.FromArray(i.emissiveFactor) : new Color3(0,0,0),
  116854. i.doubleSided && (o.backFaceCulling = !1,
  116855. o.twoSidedLighting = !0),
  116856. i.normalTexture && (i.normalTexture.nonColorData = !0,
  116857. s.push(this.loadTextureInfoAsync(e + "/normalTexture", i.normalTexture, function(c) {
  116858. c.name = o.name + " (Normal)",
  116859. o.bumpTexture = c
  116860. })),
  116861. o.invertNormalMapX = !this._babylonScene.useRightHandedSystem,
  116862. o.invertNormalMapY = this._babylonScene.useRightHandedSystem,
  116863. i.normalTexture.scale != null && (o.bumpTexture.level = i.normalTexture.scale),
  116864. o.forceIrradianceInFragment = !0),
  116865. i.occlusionTexture && (i.occlusionTexture.nonColorData = !0,
  116866. s.push(this.loadTextureInfoAsync(e + "/occlusionTexture", i.occlusionTexture, function(c) {
  116867. c.name = o.name + " (Occlusion)",
  116868. o.ambientTexture = c
  116869. })),
  116870. o.useAmbientInGrayScale = !0,
  116871. i.occlusionTexture.strength != null && (o.ambientTextureStrength = i.occlusionTexture.strength)),
  116872. i.emissiveTexture && s.push(this.loadTextureInfoAsync(e + "/emissiveTexture", i.emissiveTexture, function(c) {
  116873. c.name = o.name + " (Emissive)",
  116874. o.emissiveTexture = c
  116875. })),
  116876. Promise.all(s).then(function() {})
  116877. }
  116878. ,
  116879. a.prototype.loadMaterialAlphaProperties = function(e, i, o) {
  116880. if (!(o instanceof PBRMaterial))
  116881. throw new Error(e + ": Material type not supported");
  116882. var s = i.alphaMode || "OPAQUE";
  116883. switch (s) {
  116884. case "OPAQUE":
  116885. {
  116886. o.transparencyMode = PBRMaterial.PBRMATERIAL_OPAQUE;
  116887. break
  116888. }
  116889. case "MASK":
  116890. {
  116891. o.transparencyMode = PBRMaterial.PBRMATERIAL_ALPHATEST,
  116892. o.alphaCutOff = i.alphaCutoff == null ? .5 : i.alphaCutoff,
  116893. o.albedoTexture && (o.albedoTexture.hasAlpha = !0);
  116894. break
  116895. }
  116896. case "BLEND":
  116897. {
  116898. o.transparencyMode = PBRMaterial.PBRMATERIAL_ALPHABLEND,
  116899. o.albedoTexture && (o.albedoTexture.hasAlpha = !0,
  116900. o.useAlphaFromAlbedoTexture = !0);
  116901. break
  116902. }
  116903. default:
  116904. throw new Error(e + "/alphaMode: Invalid value (" + i.alphaMode + ")")
  116905. }
  116906. }
  116907. ,
  116908. a.prototype.loadTextureInfoAsync = function(e, i, o) {
  116909. var s = this;
  116910. o === void 0 && (o = function() {}
  116911. );
  116912. var c = this._extensionsLoadTextureInfoAsync(e, i, o);
  116913. if (c)
  116914. return c;
  116915. if (this.logOpen("" + e),
  116916. i.texCoord >= 6)
  116917. throw new Error(e + "/texCoord: Invalid value (" + i.texCoord + ")");
  116918. var d = ArrayItem.Get(e + "/index", this._gltf.textures, i.index);
  116919. d._textureInfo = i;
  116920. var _ = this._loadTextureAsync("/textures/" + i.index, d, function(b) {
  116921. b.coordinatesIndex = i.texCoord || 0,
  116922. a.AddPointerMetadata(b, e),
  116923. s._parent.onTextureLoadedObservable.notifyObservers(b),
  116924. o(b)
  116925. });
  116926. return this.logClose(),
  116927. _
  116928. }
  116929. ,
  116930. a.prototype._loadTextureAsync = function(e, i, o) {
  116931. o === void 0 && (o = function() {}
  116932. );
  116933. var s = this._extensionsLoadTextureAsync(e, i, o);
  116934. if (s)
  116935. return s;
  116936. this.logOpen(e + " " + (i.name || ""));
  116937. var c = i.sampler == null ? a.DefaultSampler : ArrayItem.Get(e + "/sampler", this._gltf.samplers, i.sampler)
  116938. , d = ArrayItem.Get(e + "/source", this._gltf.images, i.source)
  116939. , _ = this._createTextureAsync(e, c, d, o, void 0, !i._textureInfo.nonColorData);
  116940. return this.logClose(),
  116941. _
  116942. }
  116943. ,
  116944. a.prototype._createTextureAsync = function(e, i, o, s, c, d) {
  116945. var _ = this;
  116946. s === void 0 && (s = function() {}
  116947. );
  116948. var b = this._loadSampler("/samplers/" + i.index, i)
  116949. , k = new Array
  116950. , j = new Deferred;
  116951. this._babylonScene._blockEntityCollection = !!this._assetContainer;
  116952. var $ = {
  116953. noMipmap: b.noMipMaps,
  116954. invertY: !1,
  116955. samplingMode: b.samplingMode,
  116956. onLoad: function() {
  116957. _._disposed || j.resolve()
  116958. },
  116959. onError: function(et, tt) {
  116960. _._disposed || j.reject(new Error(e + ": " + (tt && tt.message ? tt.message : et || "Failed to load texture")))
  116961. },
  116962. mimeType: o.mimeType,
  116963. loaderOptions: c,
  116964. useSRGBBuffer: !!d && this._parent.useSRGBBuffers
  116965. }
  116966. , _e = new Texture(null,this._babylonScene,$);
  116967. return _e._parentContainer = this._assetContainer,
  116968. this._babylonScene._blockEntityCollection = !1,
  116969. k.push(j.promise),
  116970. k.push(this.loadImageAsync("/images/" + o.index, o).then(function(et) {
  116971. var tt = o.uri || _._fileName + "#image" + o.index
  116972. , rt = "data:" + _._uniqueRootUrl + tt;
  116973. _e.updateURL(rt, et)
  116974. })),
  116975. _e.wrapU = b.wrapU,
  116976. _e.wrapV = b.wrapV,
  116977. s(_e),
  116978. Promise.all(k).then(function() {
  116979. return _e
  116980. })
  116981. }
  116982. ,
  116983. a.prototype._loadSampler = function(e, i) {
  116984. return i._data || (i._data = {
  116985. noMipMaps: i.minFilter === 9728 || i.minFilter === 9729,
  116986. samplingMode: a._GetTextureSamplingMode(e, i),
  116987. wrapU: a._GetTextureWrapMode(e + "/wrapS", i.wrapS),
  116988. wrapV: a._GetTextureWrapMode(e + "/wrapT", i.wrapT)
  116989. }),
  116990. i._data
  116991. }
  116992. ,
  116993. a.prototype.loadImageAsync = function(e, i) {
  116994. if (!i._data) {
  116995. if (this.logOpen(e + " " + (i.name || "")),
  116996. i.uri)
  116997. i._data = this.loadUriAsync(e + "/uri", i, i.uri);
  116998. else {
  116999. var o = ArrayItem.Get(e + "/bufferView", this._gltf.bufferViews, i.bufferView);
  117000. i._data = this.loadBufferViewAsync("/bufferViews/" + o.index, o)
  117001. }
  117002. this.logClose()
  117003. }
  117004. return i._data
  117005. }
  117006. ,
  117007. a.prototype.loadUriAsync = function(e, i, o) {
  117008. var s = this
  117009. , c = this._extensionsLoadUriAsync(e, i, o);
  117010. if (c)
  117011. return c;
  117012. if (!a._ValidateUri(o))
  117013. throw new Error(e + ": '" + o + "' is invalid");
  117014. if (IsBase64DataUrl(o)) {
  117015. var d = new Uint8Array(DecodeBase64UrlToBinary(o));
  117016. return this.log(e + ": Decoded " + o.substr(0, 64) + "... (" + d.length + " bytes)"),
  117017. Promise.resolve(d)
  117018. }
  117019. return this.log(e + ": Loading " + o),
  117020. this._parent.preprocessUrlAsync(this._rootUrl + o).then(function(_) {
  117021. return new Promise(function(b, k) {
  117022. s._parent._loadFile(s._babylonScene, _, function(j) {
  117023. s._disposed || (s.log(e + ": Loaded " + o + " (" + j.byteLength + " bytes)"),
  117024. b(new Uint8Array(j)))
  117025. }, !0, function(j) {
  117026. k(new LoadFileError(e + ": Failed to load '" + o + "'" + (j ? ": " + j.status + " " + j.statusText : ""),j))
  117027. })
  117028. }
  117029. )
  117030. })
  117031. }
  117032. ,
  117033. a.AddPointerMetadata = function(e, i) {
  117034. var o = e.metadata = e.metadata || {}
  117035. , s = o.gltf = o.gltf || {}
  117036. , c = s.pointers = s.pointers || [];
  117037. c.push(i)
  117038. }
  117039. ,
  117040. a._GetTextureWrapMode = function(e, i) {
  117041. switch (i = i == null ? 10497 : i,
  117042. i) {
  117043. case 33071:
  117044. return Texture.CLAMP_ADDRESSMODE;
  117045. case 33648:
  117046. return Texture.MIRROR_ADDRESSMODE;
  117047. case 10497:
  117048. return Texture.WRAP_ADDRESSMODE;
  117049. default:
  117050. return Logger$2.Warn(e + ": Invalid value (" + i + ")"),
  117051. Texture.WRAP_ADDRESSMODE
  117052. }
  117053. }
  117054. ,
  117055. a._GetTextureSamplingMode = function(e, i) {
  117056. var o = i.magFilter == null ? 9729 : i.magFilter
  117057. , s = i.minFilter == null ? 9987 : i.minFilter;
  117058. if (o === 9729)
  117059. switch (s) {
  117060. case 9728:
  117061. return Texture.LINEAR_NEAREST;
  117062. case 9729:
  117063. return Texture.LINEAR_LINEAR;
  117064. case 9984:
  117065. return Texture.LINEAR_NEAREST_MIPNEAREST;
  117066. case 9985:
  117067. return Texture.LINEAR_LINEAR_MIPNEAREST;
  117068. case 9986:
  117069. return Texture.LINEAR_NEAREST_MIPLINEAR;
  117070. case 9987:
  117071. return Texture.LINEAR_LINEAR_MIPLINEAR;
  117072. default:
  117073. return Logger$2.Warn(e + "/minFilter: Invalid value (" + s + ")"),
  117074. Texture.LINEAR_LINEAR_MIPLINEAR
  117075. }
  117076. else
  117077. switch (o !== 9728 && Logger$2.Warn(e + "/magFilter: Invalid value (" + o + ")"),
  117078. s) {
  117079. case 9728:
  117080. return Texture.NEAREST_NEAREST;
  117081. case 9729:
  117082. return Texture.NEAREST_LINEAR;
  117083. case 9984:
  117084. return Texture.NEAREST_NEAREST_MIPNEAREST;
  117085. case 9985:
  117086. return Texture.NEAREST_LINEAR_MIPNEAREST;
  117087. case 9986:
  117088. return Texture.NEAREST_NEAREST_MIPLINEAR;
  117089. case 9987:
  117090. return Texture.NEAREST_LINEAR_MIPLINEAR;
  117091. default:
  117092. return Logger$2.Warn(e + "/minFilter: Invalid value (" + s + ")"),
  117093. Texture.NEAREST_NEAREST_MIPNEAREST
  117094. }
  117095. }
  117096. ,
  117097. a._GetTypedArrayConstructor = function(e, i) {
  117098. switch (i) {
  117099. case 5120:
  117100. return Int8Array;
  117101. case 5121:
  117102. return Uint8Array;
  117103. case 5122:
  117104. return Int16Array;
  117105. case 5123:
  117106. return Uint16Array;
  117107. case 5125:
  117108. return Uint32Array;
  117109. case 5126:
  117110. return Float32Array;
  117111. default:
  117112. throw new Error(e + ": Invalid component type " + i)
  117113. }
  117114. }
  117115. ,
  117116. a._GetTypedArray = function(e, i, o, s, c) {
  117117. var d = o.buffer;
  117118. s = o.byteOffset + (s || 0);
  117119. var _ = a._GetTypedArrayConstructor(e + "/componentType", i)
  117120. , b = VertexBuffer.GetTypeByteLength(i);
  117121. return s % b !== 0 ? (Logger$2.Warn(e + ": Copying buffer as byte offset (" + s + ") is not a multiple of component type byte length (" + b + ")"),
  117122. new _(d.slice(s, s + c * b),0)) : new _(d,s,c)
  117123. }
  117124. ,
  117125. a._GetNumComponents = function(e, i) {
  117126. switch (i) {
  117127. case "SCALAR":
  117128. return 1;
  117129. case "VEC2":
  117130. return 2;
  117131. case "VEC3":
  117132. return 3;
  117133. case "VEC4":
  117134. return 4;
  117135. case "MAT2":
  117136. return 4;
  117137. case "MAT3":
  117138. return 9;
  117139. case "MAT4":
  117140. return 16
  117141. }
  117142. throw new Error(e + ": Invalid type (" + i + ")")
  117143. }
  117144. ,
  117145. a._ValidateUri = function(e) {
  117146. return Tools.IsBase64(e) || e.indexOf("..") === -1
  117147. }
  117148. ,
  117149. a._GetDrawMode = function(e, i) {
  117150. switch (i == null && (i = 4),
  117151. i) {
  117152. case 0:
  117153. return Material.PointListDrawMode;
  117154. case 1:
  117155. return Material.LineListDrawMode;
  117156. case 2:
  117157. return Material.LineLoopDrawMode;
  117158. case 3:
  117159. return Material.LineStripDrawMode;
  117160. case 4:
  117161. return Material.TriangleFillMode;
  117162. case 5:
  117163. return Material.TriangleStripDrawMode;
  117164. case 6:
  117165. return Material.TriangleFanDrawMode
  117166. }
  117167. throw new Error(e + ": Invalid mesh primitive mode (" + i + ")")
  117168. }
  117169. ,
  117170. a.prototype._compileMaterialsAsync = function() {
  117171. var e = this;
  117172. this._parent._startPerformanceCounter("Compile materials");
  117173. var i = new Array;
  117174. if (this._gltf.materials)
  117175. for (var o = 0, s = this._gltf.materials; o < s.length; o++) {
  117176. var c = s[o];
  117177. if (c._data)
  117178. for (var d in c._data)
  117179. for (var _ = c._data[d], b = 0, k = _.babylonMeshes; b < k.length; b++) {
  117180. var j = k[b];
  117181. j.computeWorldMatrix(!0);
  117182. var $ = _.babylonMaterial;
  117183. i.push($.forceCompilationAsync(j)),
  117184. i.push($.forceCompilationAsync(j, {
  117185. useInstances: !0
  117186. })),
  117187. this._parent.useClipPlane && (i.push($.forceCompilationAsync(j, {
  117188. clipPlane: !0
  117189. })),
  117190. i.push($.forceCompilationAsync(j, {
  117191. clipPlane: !0,
  117192. useInstances: !0
  117193. })))
  117194. }
  117195. }
  117196. return Promise.all(i).then(function() {
  117197. e._parent._endPerformanceCounter("Compile materials")
  117198. })
  117199. }
  117200. ,
  117201. a.prototype._compileShadowGeneratorsAsync = function() {
  117202. var e = this;
  117203. this._parent._startPerformanceCounter("Compile shadow generators");
  117204. for (var i = new Array, o = this._babylonScene.lights, s = 0, c = o; s < c.length; s++) {
  117205. var d = c[s]
  117206. , _ = d.getShadowGenerator();
  117207. _ && i.push(_.forceCompilationAsync())
  117208. }
  117209. return Promise.all(i).then(function() {
  117210. e._parent._endPerformanceCounter("Compile shadow generators")
  117211. })
  117212. }
  117213. ,
  117214. a.prototype._forEachExtensions = function(e) {
  117215. for (var i = 0, o = this._extensions; i < o.length; i++) {
  117216. var s = o[i];
  117217. s.enabled && e(s)
  117218. }
  117219. }
  117220. ,
  117221. a.prototype._applyExtensions = function(e, i, o) {
  117222. for (var s = 0, c = this._extensions; s < c.length; s++) {
  117223. var d = c[s];
  117224. if (d.enabled) {
  117225. var _ = d.name + "." + i
  117226. , b = e;
  117227. b._activeLoaderExtensionFunctions = b._activeLoaderExtensionFunctions || {};
  117228. var k = b._activeLoaderExtensionFunctions;
  117229. if (!k[_]) {
  117230. k[_] = !0;
  117231. try {
  117232. var j = o(d);
  117233. if (j)
  117234. return j
  117235. } finally {
  117236. delete k[_]
  117237. }
  117238. }
  117239. }
  117240. }
  117241. return null
  117242. }
  117243. ,
  117244. a.prototype._extensionsOnLoading = function() {
  117245. this._forEachExtensions(function(e) {
  117246. return e.onLoading && e.onLoading()
  117247. })
  117248. }
  117249. ,
  117250. a.prototype._extensionsOnReady = function() {
  117251. this._forEachExtensions(function(e) {
  117252. return e.onReady && e.onReady()
  117253. })
  117254. }
  117255. ,
  117256. a.prototype._extensionsLoadSceneAsync = function(e, i) {
  117257. return this._applyExtensions(i, "loadScene", function(o) {
  117258. return o.loadSceneAsync && o.loadSceneAsync(e, i)
  117259. })
  117260. }
  117261. ,
  117262. a.prototype._extensionsLoadNodeAsync = function(e, i, o) {
  117263. return this._applyExtensions(i, "loadNode", function(s) {
  117264. return s.loadNodeAsync && s.loadNodeAsync(e, i, o)
  117265. })
  117266. }
  117267. ,
  117268. a.prototype._extensionsLoadCameraAsync = function(e, i, o) {
  117269. return this._applyExtensions(i, "loadCamera", function(s) {
  117270. return s.loadCameraAsync && s.loadCameraAsync(e, i, o)
  117271. })
  117272. }
  117273. ,
  117274. a.prototype._extensionsLoadVertexDataAsync = function(e, i, o) {
  117275. return this._applyExtensions(i, "loadVertexData", function(s) {
  117276. return s._loadVertexDataAsync && s._loadVertexDataAsync(e, i, o)
  117277. })
  117278. }
  117279. ,
  117280. a.prototype._extensionsLoadMeshPrimitiveAsync = function(e, i, o, s, c, d) {
  117281. return this._applyExtensions(c, "loadMeshPrimitive", function(_) {
  117282. return _._loadMeshPrimitiveAsync && _._loadMeshPrimitiveAsync(e, i, o, s, c, d)
  117283. })
  117284. }
  117285. ,
  117286. a.prototype._extensionsLoadMaterialAsync = function(e, i, o, s, c) {
  117287. return this._applyExtensions(i, "loadMaterial", function(d) {
  117288. return d._loadMaterialAsync && d._loadMaterialAsync(e, i, o, s, c)
  117289. })
  117290. }
  117291. ,
  117292. a.prototype._extensionsCreateMaterial = function(e, i, o) {
  117293. return this._applyExtensions(i, "createMaterial", function(s) {
  117294. return s.createMaterial && s.createMaterial(e, i, o)
  117295. })
  117296. }
  117297. ,
  117298. a.prototype._extensionsLoadMaterialPropertiesAsync = function(e, i, o) {
  117299. return this._applyExtensions(i, "loadMaterialProperties", function(s) {
  117300. return s.loadMaterialPropertiesAsync && s.loadMaterialPropertiesAsync(e, i, o)
  117301. })
  117302. }
  117303. ,
  117304. a.prototype._extensionsLoadTextureInfoAsync = function(e, i, o) {
  117305. return this._applyExtensions(i, "loadTextureInfo", function(s) {
  117306. return s.loadTextureInfoAsync && s.loadTextureInfoAsync(e, i, o)
  117307. })
  117308. }
  117309. ,
  117310. a.prototype._extensionsLoadTextureAsync = function(e, i, o) {
  117311. return this._applyExtensions(i, "loadTexture", function(s) {
  117312. return s._loadTextureAsync && s._loadTextureAsync(e, i, o)
  117313. })
  117314. }
  117315. ,
  117316. a.prototype._extensionsLoadAnimationAsync = function(e, i) {
  117317. return this._applyExtensions(i, "loadAnimation", function(o) {
  117318. return o.loadAnimationAsync && o.loadAnimationAsync(e, i)
  117319. })
  117320. }
  117321. ,
  117322. a.prototype._extensionsLoadSkinAsync = function(e, i, o) {
  117323. return this._applyExtensions(o, "loadSkin", function(s) {
  117324. return s._loadSkinAsync && s._loadSkinAsync(e, i, o)
  117325. })
  117326. }
  117327. ,
  117328. a.prototype._extensionsLoadUriAsync = function(e, i, o) {
  117329. return this._applyExtensions(i, "loadUri", function(s) {
  117330. return s._loadUriAsync && s._loadUriAsync(e, i, o)
  117331. })
  117332. }
  117333. ,
  117334. a.prototype._extensionsLoadBufferViewAsync = function(e, i) {
  117335. return this._applyExtensions(i, "loadBufferView", function(o) {
  117336. return o.loadBufferViewAsync && o.loadBufferViewAsync(e, i)
  117337. })
  117338. }
  117339. ,
  117340. a.prototype._extensionsLoadBufferAsync = function(e, i, o, s) {
  117341. return this._applyExtensions(i, "loadBuffer", function(c) {
  117342. return c.loadBufferAsync && c.loadBufferAsync(e, i, o, s)
  117343. })
  117344. }
  117345. ,
  117346. a.LoadExtensionAsync = function(e, i, o, s) {
  117347. if (!i.extensions)
  117348. return null;
  117349. var c = i.extensions
  117350. , d = c[o];
  117351. return d ? s(e + "/extensions/" + o, d) : null
  117352. }
  117353. ,
  117354. a.LoadExtraAsync = function(e, i, o, s) {
  117355. if (!i.extras)
  117356. return null;
  117357. var c = i.extras
  117358. , d = c[o];
  117359. return d ? s(e + "/extras/" + o, d) : null
  117360. }
  117361. ,
  117362. a.prototype.isExtensionUsed = function(e) {
  117363. return !!this._gltf.extensionsUsed && this._gltf.extensionsUsed.indexOf(e) !== -1
  117364. }
  117365. ,
  117366. a.prototype.logOpen = function(e) {
  117367. this._parent._logOpen(e)
  117368. }
  117369. ,
  117370. a.prototype.logClose = function() {
  117371. this._parent._logClose()
  117372. }
  117373. ,
  117374. a.prototype.log = function(e) {
  117375. this._parent._log(e)
  117376. }
  117377. ,
  117378. a.prototype.startPerformanceCounter = function(e) {
  117379. this._parent._startPerformanceCounter(e)
  117380. }
  117381. ,
  117382. a.prototype.endPerformanceCounter = function(e) {
  117383. this._parent._endPerformanceCounter(e)
  117384. }
  117385. ,
  117386. a._RegisteredExtensions = {},
  117387. a.DefaultSampler = {
  117388. index: -1
  117389. },
  117390. a
  117391. }();
  117392. GLTFFileLoader._CreateGLTF2Loader = function(a) {
  117393. return new GLTFLoader(a)
  117394. }
  117395. ;
  117396. var RawCubeTexture = function(a) {
  117397. __extends(e, a);
  117398. function e(i, o, s, c, d, _, b, k, j) {
  117399. c === void 0 && (c = 5),
  117400. d === void 0 && (d = 0),
  117401. _ === void 0 && (_ = !1),
  117402. b === void 0 && (b = !1),
  117403. k === void 0 && (k = 3),
  117404. j === void 0 && (j = null);
  117405. var $ = a.call(this, "", i) || this;
  117406. return $._texture = i.getEngine().createRawCubeTexture(o, s, c, d, _, b, k, j),
  117407. $
  117408. }
  117409. return e.prototype.update = function(i, o, s, c, d) {
  117410. d === void 0 && (d = null),
  117411. this._texture.getEngine().updateRawCubeTexture(this._texture, i, o, s, c, d)
  117412. }
  117413. ,
  117414. e.prototype.updateRGBDAsync = function(i, o, s, c) {
  117415. return o === void 0 && (o = null),
  117416. s === void 0 && (s = .8),
  117417. c === void 0 && (c = 0),
  117418. _UpdateRGBDAsync(this._texture, i, o, s, c).then(function() {})
  117419. }
  117420. ,
  117421. e.prototype.clone = function() {
  117422. var i = this;
  117423. return SerializationHelper.Clone(function() {
  117424. var o = i.getScene()
  117425. , s = i._texture
  117426. , c = new e(o,s._bufferViewArray,s.width,s.format,s.type,s.generateMipMaps,s.invertY,s.samplingMode,s._compression);
  117427. return s.source === InternalTextureSource.CubeRawRGBD && c.updateRGBDAsync(s._bufferViewArrayArray, s._sphericalPolynomial, s._lodGenerationScale, s._lodGenerationOffset),
  117428. c
  117429. }, this)
  117430. }
  117431. ,
  117432. e
  117433. }(CubeTexture)
  117434. , NAME$u = "EXT_lights_image_based"
  117435. , EXT_lights_image_based = function() {
  117436. function a(e) {
  117437. this.name = NAME$u,
  117438. this._loader = e,
  117439. this.enabled = this._loader.isExtensionUsed(NAME$u)
  117440. }
  117441. return a.prototype.dispose = function() {
  117442. this._loader = null,
  117443. delete this._lights
  117444. }
  117445. ,
  117446. a.prototype.onLoading = function() {
  117447. var e = this._loader.gltf.extensions;
  117448. if (e && e[this.name]) {
  117449. var i = e[this.name];
  117450. this._lights = i.lights
  117451. }
  117452. }
  117453. ,
  117454. a.prototype.loadSceneAsync = function(e, i) {
  117455. var o = this;
  117456. return GLTFLoader.LoadExtensionAsync(e, i, this.name, function(s, c) {
  117457. var d = new Array;
  117458. d.push(o._loader.loadSceneAsync(e, i)),
  117459. o._loader.logOpen("" + s);
  117460. var _ = ArrayItem.Get(s + "/light", o._lights, c.light);
  117461. return d.push(o._loadLightAsync("/extensions/" + o.name + "/lights/" + c.light, _).then(function(b) {
  117462. o._loader.babylonScene.environmentTexture = b
  117463. })),
  117464. o._loader.logClose(),
  117465. Promise.all(d).then(function() {})
  117466. })
  117467. }
  117468. ,
  117469. a.prototype._loadLightAsync = function(e, i) {
  117470. var o = this;
  117471. if (!i._loaded) {
  117472. var s = new Array;
  117473. this._loader.logOpen("" + e);
  117474. for (var c = new Array(i.specularImages.length), d = function(k) {
  117475. var j = i.specularImages[k];
  117476. c[k] = new Array(j.length);
  117477. for (var $ = function(et) {
  117478. var tt = e + "/specularImages/" + k + "/" + et;
  117479. _._loader.logOpen("" + tt);
  117480. var rt = j[et]
  117481. , it = ArrayItem.Get(tt, _._loader.gltf.images, rt);
  117482. s.push(_._loader.loadImageAsync("/images/" + rt, it).then(function(nt) {
  117483. c[k][et] = nt
  117484. })),
  117485. _._loader.logClose()
  117486. }, _e = 0; _e < j.length; _e++)
  117487. $(_e)
  117488. }, _ = this, b = 0; b < i.specularImages.length; b++)
  117489. d(b);
  117490. this._loader.logClose(),
  117491. i._loaded = Promise.all(s).then(function() {
  117492. var k = new RawCubeTexture(o._loader.babylonScene,null,i.specularImageSize);
  117493. if (k.name = i.name || "environment",
  117494. i._babylonTexture = k,
  117495. i.intensity != null && (k.level = i.intensity),
  117496. i.rotation) {
  117497. var j = Quaternion.FromArray(i.rotation);
  117498. o._loader.babylonScene.useRightHandedSystem || (j = Quaternion.Inverse(j)),
  117499. Matrix.FromQuaternionToRef(j, k.getReflectionTextureMatrix())
  117500. }
  117501. if (!i.irradianceCoefficients)
  117502. throw new Error(e + ": Irradiance coefficients are missing");
  117503. var $ = SphericalHarmonics.FromArray(i.irradianceCoefficients);
  117504. $.scaleInPlace(i.intensity),
  117505. $.convertIrradianceToLambertianRadiance();
  117506. var _e = SphericalPolynomial.FromHarmonics($)
  117507. , et = (c.length - 1) / Scalar.Log2(i.specularImageSize);
  117508. return k.updateRGBDAsync(c, _e, et)
  117509. })
  117510. }
  117511. return i._loaded.then(function() {
  117512. return i._babylonTexture
  117513. })
  117514. }
  117515. ,
  117516. a
  117517. }();
  117518. GLTFLoader.RegisterExtension(NAME$u, function(a) {
  117519. return new EXT_lights_image_based(a)
  117520. });
  117521. var NAME$t = "EXT_mesh_gpu_instancing"
  117522. , EXT_mesh_gpu_instancing = function() {
  117523. function a(e) {
  117524. this.name = NAME$t,
  117525. this._loader = e,
  117526. this.enabled = this._loader.isExtensionUsed(NAME$t)
  117527. }
  117528. return a.prototype.dispose = function() {
  117529. this._loader = null
  117530. }
  117531. ,
  117532. a.prototype.loadNodeAsync = function(e, i, o) {
  117533. var s = this;
  117534. return GLTFLoader.LoadExtensionAsync(e, i, this.name, function(c, d) {
  117535. s._loader._disableInstancedMesh++;
  117536. var _ = s._loader.loadNodeAsync("/nodes/" + i.index, i, o);
  117537. if (s._loader._disableInstancedMesh--,
  117538. !i._primitiveBabylonMeshes)
  117539. return _;
  117540. var b = new Array
  117541. , k = 0
  117542. , j = function($) {
  117543. if (d.attributes[$] == null) {
  117544. b.push(Promise.resolve(null));
  117545. return
  117546. }
  117547. var _e = ArrayItem.Get(c + "/attributes/" + $, s._loader.gltf.accessors, d.attributes[$]);
  117548. if (b.push(s._loader._loadFloatAccessorAsync("/accessors/" + _e.bufferView, _e)),
  117549. k === 0)
  117550. k = _e.count;
  117551. else if (k !== _e.count)
  117552. throw new Error(c + "/attributes: Instance buffer accessors do not have the same count.")
  117553. };
  117554. return j("TRANSLATION"),
  117555. j("ROTATION"),
  117556. j("SCALE"),
  117557. _.then(function($) {
  117558. return Promise.all(b).then(function(_e) {
  117559. var et = _e[0]
  117560. , tt = _e[1]
  117561. , rt = _e[2]
  117562. , it = new Float32Array(k * 16);
  117563. TmpVectors.Vector3[0].copyFromFloats(0, 0, 0),
  117564. TmpVectors.Quaternion[0].copyFromFloats(0, 0, 0, 1),
  117565. TmpVectors.Vector3[1].copyFromFloats(1, 1, 1);
  117566. for (var nt = 0; nt < k; ++nt)
  117567. et && Vector3.FromArrayToRef(et, nt * 3, TmpVectors.Vector3[0]),
  117568. tt && Quaternion.FromArrayToRef(tt, nt * 4, TmpVectors.Quaternion[0]),
  117569. rt && Vector3.FromArrayToRef(rt, nt * 3, TmpVectors.Vector3[1]),
  117570. Matrix.ComposeToRef(TmpVectors.Vector3[1], TmpVectors.Quaternion[0], TmpVectors.Vector3[0], TmpVectors.Matrix[0]),
  117571. TmpVectors.Matrix[0].copyToArray(it, nt * 16);
  117572. for (var ot = 0, at = i._primitiveBabylonMeshes; ot < at.length; ot++) {
  117573. var st = at[ot];
  117574. st.thinInstanceSetBuffer("matrix", it, 16, !0)
  117575. }
  117576. return $
  117577. })
  117578. })
  117579. })
  117580. }
  117581. ,
  117582. a
  117583. }();
  117584. GLTFLoader.RegisterExtension(NAME$t, function(a) {
  117585. return new EXT_mesh_gpu_instancing(a)
  117586. });
  117587. var MeshoptCompression = function() {
  117588. function a() {
  117589. var e = a.Configuration.decoder;
  117590. this._decoderModulePromise = Tools.LoadScriptAsync(Tools.GetAbsoluteUrl(e.url)).then(function() {
  117591. return MeshoptDecoder.ready
  117592. })
  117593. }
  117594. return Object.defineProperty(a, "Default", {
  117595. get: function() {
  117596. return a._Default || (a._Default = new a),
  117597. a._Default
  117598. },
  117599. enumerable: !1,
  117600. configurable: !0
  117601. }),
  117602. a.prototype.dispose = function() {
  117603. delete this._decoderModulePromise
  117604. }
  117605. ,
  117606. a.prototype.decodeGltfBufferAsync = function(e, i, o, s, c) {
  117607. return this._decoderModulePromise.then(function() {
  117608. var d = new Uint8Array(i * o);
  117609. return MeshoptDecoder.decodeGltfBuffer(d, i, o, e, s, c),
  117610. d
  117611. })
  117612. }
  117613. ,
  117614. a.Configuration = {
  117615. decoder: {
  117616. url: "https://preview.babylonjs.com/meshopt_decoder.js"
  117617. }
  117618. },
  117619. a._Default = null,
  117620. a
  117621. }()
  117622. , NAME$s = "EXT_meshopt_compression"
  117623. , EXT_meshopt_compression = function() {
  117624. function a(e) {
  117625. this.name = NAME$s,
  117626. this.enabled = e.isExtensionUsed(NAME$s),
  117627. this._loader = e
  117628. }
  117629. return a.prototype.dispose = function() {
  117630. this._loader = null
  117631. }
  117632. ,
  117633. a.prototype.loadBufferViewAsync = function(e, i) {
  117634. var o = this;
  117635. return GLTFLoader.LoadExtensionAsync(e, i, this.name, function(s, c) {
  117636. var d = i;
  117637. if (d._meshOptData)
  117638. return d._meshOptData;
  117639. var _ = ArrayItem.Get(e + "/buffer", o._loader.gltf.buffers, c.buffer);
  117640. return d._meshOptData = o._loader.loadBufferAsync("/buffers/" + _.index, _, c.byteOffset || 0, c.byteLength).then(function(b) {
  117641. return MeshoptCompression.Default.decodeGltfBufferAsync(b, c.count, c.byteStride, c.mode, c.filter)
  117642. }),
  117643. d._meshOptData
  117644. })
  117645. }
  117646. ,
  117647. a
  117648. }();
  117649. GLTFLoader.RegisterExtension(NAME$s, function(a) {
  117650. return new EXT_meshopt_compression(a)
  117651. });
  117652. var NAME$r = "EXT_texture_webp"
  117653. , EXT_texture_webp = function() {
  117654. function a(e) {
  117655. this.name = NAME$r,
  117656. this._loader = e,
  117657. this.enabled = e.isExtensionUsed(NAME$r)
  117658. }
  117659. return a.prototype.dispose = function() {
  117660. this._loader = null
  117661. }
  117662. ,
  117663. a.prototype._loadTextureAsync = function(e, i, o) {
  117664. var s = this;
  117665. return GLTFLoader.LoadExtensionAsync(e, i, this.name, function(c, d) {
  117666. var _ = i.sampler == null ? GLTFLoader.DefaultSampler : ArrayItem.Get(e + "/sampler", s._loader.gltf.samplers, i.sampler)
  117667. , b = ArrayItem.Get(c + "/source", s._loader.gltf.images, d.source);
  117668. return s._loader._createTextureAsync(e, _, b, function(k) {
  117669. o(k)
  117670. }, void 0, !i._textureInfo.nonColorData)
  117671. })
  117672. }
  117673. ,
  117674. a
  117675. }();
  117676. GLTFLoader.RegisterExtension(NAME$r, function(a) {
  117677. return new EXT_texture_webp(a)
  117678. });
  117679. var WorkerPool = function() {
  117680. function a(e) {
  117681. this._pendingActions = new Array,
  117682. this._workerInfos = e.map(function(i) {
  117683. return {
  117684. worker: i,
  117685. active: !1
  117686. }
  117687. })
  117688. }
  117689. return a.prototype.dispose = function() {
  117690. for (var e = 0, i = this._workerInfos; e < i.length; e++) {
  117691. var o = i[e];
  117692. o.worker.terminate()
  117693. }
  117694. this._workerInfos = [],
  117695. this._pendingActions = []
  117696. }
  117697. ,
  117698. a.prototype.push = function(e) {
  117699. for (var i = 0, o = this._workerInfos; i < o.length; i++) {
  117700. var s = o[i];
  117701. if (!s.active) {
  117702. this._execute(s, e);
  117703. return
  117704. }
  117705. }
  117706. this._pendingActions.push(e)
  117707. }
  117708. ,
  117709. a.prototype._execute = function(e, i) {
  117710. var o = this;
  117711. e.active = !0,
  117712. i(e.worker, function() {
  117713. e.active = !1;
  117714. var s = o._pendingActions.shift();
  117715. s && o._execute(e, s)
  117716. })
  117717. }
  117718. ,
  117719. a
  117720. }();
  117721. function createDecoderAsync(a) {
  117722. return new Promise(function(e) {
  117723. DracoDecoderModule({
  117724. wasmBinary: a
  117725. }).then(function(i) {
  117726. e({
  117727. module: i
  117728. })
  117729. })
  117730. }
  117731. )
  117732. }
  117733. function decodeMesh(a, e, i, o, s) {
  117734. var c = new a.DecoderBuffer;
  117735. c.Init(e, e.byteLength);
  117736. var d = new a.Decoder, _, b;
  117737. try {
  117738. var k = d.GetEncodedGeometryType(c);
  117739. switch (k) {
  117740. case a.TRIANGULAR_MESH:
  117741. _ = new a.Mesh,
  117742. b = d.DecodeBufferToMesh(c, _);
  117743. break;
  117744. case a.POINT_CLOUD:
  117745. _ = new a.PointCloud,
  117746. b = d.DecodeBufferToPointCloud(c, _);
  117747. break;
  117748. default:
  117749. throw new Error("Invalid geometry type " + k)
  117750. }
  117751. if (!b.ok() || !_.ptr)
  117752. throw new Error(b.error_msg());
  117753. if (k === a.TRIANGULAR_MESH) {
  117754. var j = _.num_faces()
  117755. , $ = j * 3
  117756. , _e = $ * 4
  117757. , et = a._malloc(_e);
  117758. try {
  117759. d.GetTrianglesUInt32Array(_, _e, et);
  117760. var tt = new Uint32Array($);
  117761. tt.set(new Uint32Array(a.HEAPF32.buffer,et,$)),
  117762. o(tt)
  117763. } finally {
  117764. a._free(et)
  117765. }
  117766. }
  117767. var rt = function(st, ut) {
  117768. var ct = ut.num_components()
  117769. , lt = _.num_points()
  117770. , ft = lt * ct
  117771. , ht = ft * Float32Array.BYTES_PER_ELEMENT
  117772. , pt = a._malloc(ht);
  117773. try {
  117774. d.GetAttributeDataArrayForAllPoints(_, ut, a.DT_FLOAT32, ht, pt);
  117775. var dt = new Float32Array(a.HEAPF32.buffer,pt,ft);
  117776. if (st === "color" && ct === 3) {
  117777. for (var _t = new Float32Array(lt * 4), mt = 0, vt = 0; mt < _t.length; mt += 4,
  117778. vt += ct)
  117779. _t[mt + 0] = dt[vt + 0],
  117780. _t[mt + 1] = dt[vt + 1],
  117781. _t[mt + 2] = dt[vt + 2],
  117782. _t[mt + 3] = 1;
  117783. s(st, _t)
  117784. } else {
  117785. var _t = new Float32Array(ft);
  117786. _t.set(new Float32Array(a.HEAPF32.buffer,pt,ft)),
  117787. s(st, _t)
  117788. }
  117789. } finally {
  117790. a._free(pt)
  117791. }
  117792. };
  117793. if (i)
  117794. for (var it in i) {
  117795. var nt = i[it]
  117796. , ot = d.GetAttributeByUniqueId(_, nt);
  117797. rt(it, ot)
  117798. }
  117799. else {
  117800. var at = {
  117801. position: "POSITION",
  117802. normal: "NORMAL",
  117803. color: "COLOR",
  117804. uv: "TEX_COORD"
  117805. };
  117806. for (var it in at) {
  117807. var nt = d.GetAttributeId(_, a[at[it]]);
  117808. if (nt !== -1) {
  117809. var ot = d.GetAttribute(_, nt);
  117810. rt(it, ot)
  117811. }
  117812. }
  117813. }
  117814. } finally {
  117815. _ && a.destroy(_),
  117816. a.destroy(d),
  117817. a.destroy(c)
  117818. }
  117819. }
  117820. function worker$1() {
  117821. var a;
  117822. onmessage = function(e) {
  117823. var i = e.data;
  117824. switch (i.id) {
  117825. case "init":
  117826. {
  117827. var o = i.decoder;
  117828. o.url && (importScripts(o.url),
  117829. a = DracoDecoderModule({
  117830. wasmBinary: o.wasmBinary
  117831. })),
  117832. postMessage("done");
  117833. break
  117834. }
  117835. case "decodeMesh":
  117836. {
  117837. if (!a)
  117838. throw new Error("Draco decoder module is not available");
  117839. a.then(function(s) {
  117840. decodeMesh(s, i.dataView, i.attributes, function(c) {
  117841. postMessage({
  117842. id: "indices",
  117843. value: c
  117844. }, [c.buffer])
  117845. }, function(c, d) {
  117846. postMessage({
  117847. id: c,
  117848. value: d
  117849. }, [d.buffer])
  117850. }),
  117851. postMessage("done")
  117852. });
  117853. break
  117854. }
  117855. }
  117856. }
  117857. }
  117858. var DracoCompression = function() {
  117859. function a(e) {
  117860. e === void 0 && (e = a.DefaultNumWorkers);
  117861. var i = a.Configuration.decoder
  117862. , o = i.wasmUrl && i.wasmBinaryUrl && typeof WebAssembly == "object" ? {
  117863. url: Tools.GetAbsoluteUrl(i.wasmUrl),
  117864. wasmBinaryPromise: Tools.LoadFileAsync(Tools.GetAbsoluteUrl(i.wasmBinaryUrl))
  117865. } : {
  117866. url: Tools.GetAbsoluteUrl(i.fallbackUrl),
  117867. wasmBinaryPromise: Promise.resolve(void 0)
  117868. };
  117869. e && typeof Worker == "function" ? this._workerPoolPromise = o.wasmBinaryPromise.then(function(s) {
  117870. for (var c = decodeMesh + "(" + worker$1 + ")()", d = URL.createObjectURL(new Blob([c],{
  117871. type: "application/javascript"
  117872. })), _ = new Array(e), b = 0; b < _.length; b++)
  117873. _[b] = new Promise(function(k, j) {
  117874. var $ = new Worker(d)
  117875. , _e = function(tt) {
  117876. $.removeEventListener("error", _e),
  117877. $.removeEventListener("message", et),
  117878. j(tt)
  117879. }
  117880. , et = function(tt) {
  117881. tt.data === "done" && ($.removeEventListener("error", _e),
  117882. $.removeEventListener("message", et),
  117883. k($))
  117884. };
  117885. $.addEventListener("error", _e),
  117886. $.addEventListener("message", et),
  117887. $.postMessage({
  117888. id: "init",
  117889. decoder: {
  117890. url: o.url,
  117891. wasmBinary: s
  117892. }
  117893. })
  117894. }
  117895. );
  117896. return Promise.all(_).then(function(k) {
  117897. return new WorkerPool(k)
  117898. })
  117899. }) : this._decoderModulePromise = o.wasmBinaryPromise.then(function(s) {
  117900. if (!o.url)
  117901. throw new Error("Draco decoder module is not available");
  117902. return Tools.LoadScriptAsync(o.url).then(function() {
  117903. return createDecoderAsync(s)
  117904. })
  117905. })
  117906. }
  117907. return Object.defineProperty(a, "DecoderAvailable", {
  117908. get: function() {
  117909. var e = a.Configuration.decoder;
  117910. return !!(e.wasmUrl && e.wasmBinaryUrl && typeof WebAssembly == "object" || e.fallbackUrl)
  117911. },
  117912. enumerable: !1,
  117913. configurable: !0
  117914. }),
  117915. a.GetDefaultNumWorkers = function() {
  117916. return typeof navigator != "object" || !navigator.hardwareConcurrency ? 1 : Math.min(Math.floor(navigator.hardwareConcurrency * .5), 4)
  117917. }
  117918. ,
  117919. Object.defineProperty(a, "Default", {
  117920. get: function() {
  117921. return a._Default || (a._Default = new a),
  117922. a._Default
  117923. },
  117924. enumerable: !1,
  117925. configurable: !0
  117926. }),
  117927. a.prototype.dispose = function() {
  117928. this._workerPoolPromise && this._workerPoolPromise.then(function(e) {
  117929. e.dispose()
  117930. }),
  117931. delete this._workerPoolPromise,
  117932. delete this._decoderModulePromise
  117933. }
  117934. ,
  117935. a.prototype.whenReadyAsync = function() {
  117936. return this._workerPoolPromise ? this._workerPoolPromise.then(function() {}) : this._decoderModulePromise ? this._decoderModulePromise.then(function() {}) : Promise.resolve()
  117937. }
  117938. ,
  117939. a.prototype.decodeMeshAsync = function(e, i) {
  117940. var o = e instanceof ArrayBuffer ? new Uint8Array(e) : e;
  117941. if (this._workerPoolPromise)
  117942. return this._workerPoolPromise.then(function(s) {
  117943. return new Promise(function(c, d) {
  117944. s.push(function(_, b) {
  117945. var k = new VertexData
  117946. , j = function(et) {
  117947. _.removeEventListener("error", j),
  117948. _.removeEventListener("message", $),
  117949. d(et),
  117950. b()
  117951. }
  117952. , $ = function(et) {
  117953. et.data === "done" ? (_.removeEventListener("error", j),
  117954. _.removeEventListener("message", $),
  117955. c(k),
  117956. b()) : et.data.id === "indices" ? k.indices = et.data.value : k.set(et.data.value, et.data.id)
  117957. };
  117958. _.addEventListener("error", j),
  117959. _.addEventListener("message", $);
  117960. var _e = new Uint8Array(o.byteLength);
  117961. _e.set(new Uint8Array(o.buffer,o.byteOffset,o.byteLength)),
  117962. _.postMessage({
  117963. id: "decodeMesh",
  117964. dataView: _e,
  117965. attributes: i
  117966. }, [_e.buffer])
  117967. })
  117968. }
  117969. )
  117970. });
  117971. if (this._decoderModulePromise)
  117972. return this._decoderModulePromise.then(function(s) {
  117973. var c = new VertexData;
  117974. return decodeMesh(s.module, o, i, function(d) {
  117975. c.indices = d
  117976. }, function(d, _) {
  117977. c.set(_, d)
  117978. }),
  117979. c
  117980. });
  117981. throw new Error("Draco decoder module is not available")
  117982. }
  117983. ,
  117984. a.Configuration = {
  117985. decoder: {
  117986. wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js",
  117987. wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm",
  117988. fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  117989. }
  117990. },
  117991. a.DefaultNumWorkers = a.GetDefaultNumWorkers(),
  117992. a._Default = null,
  117993. a
  117994. }()
  117995. , NAME$q = "KHR_draco_mesh_compression"
  117996. , KHR_draco_mesh_compression = function() {
  117997. function a(e) {
  117998. this.name = NAME$q,
  117999. this._loader = e,
  118000. this.enabled = DracoCompression.DecoderAvailable && this._loader.isExtensionUsed(NAME$q)
  118001. }
  118002. return a.prototype.dispose = function() {
  118003. delete this.dracoCompression,
  118004. this._loader = null
  118005. }
  118006. ,
  118007. a.prototype._loadVertexDataAsync = function(e, i, o) {
  118008. var s = this;
  118009. return GLTFLoader.LoadExtensionAsync(e, i, this.name, function(c, d) {
  118010. if (i.mode != null) {
  118011. if (i.mode !== 5 && i.mode !== 4)
  118012. throw new Error(e + ": Unsupported mode " + i.mode);
  118013. if (i.mode === 5)
  118014. throw new Error(e + ": Mode " + i.mode + " is not currently supported")
  118015. }
  118016. var _ = {}
  118017. , b = function(j, $) {
  118018. var _e = d.attributes[j];
  118019. _e != null && (o._delayInfo = o._delayInfo || [],
  118020. o._delayInfo.indexOf($) === -1 && o._delayInfo.push($),
  118021. _[$] = _e)
  118022. };
  118023. b("POSITION", VertexBuffer.PositionKind),
  118024. b("NORMAL", VertexBuffer.NormalKind),
  118025. b("TANGENT", VertexBuffer.TangentKind),
  118026. b("TEXCOORD_0", VertexBuffer.UVKind),
  118027. b("TEXCOORD_1", VertexBuffer.UV2Kind),
  118028. b("TEXCOORD_2", VertexBuffer.UV3Kind),
  118029. b("TEXCOORD_3", VertexBuffer.UV4Kind),
  118030. b("TEXCOORD_4", VertexBuffer.UV5Kind),
  118031. b("TEXCOORD_5", VertexBuffer.UV6Kind),
  118032. b("JOINTS_0", VertexBuffer.MatricesIndicesKind),
  118033. b("WEIGHTS_0", VertexBuffer.MatricesWeightsKind),
  118034. b("COLOR_0", VertexBuffer.ColorKind);
  118035. var k = ArrayItem.Get(c, s._loader.gltf.bufferViews, d.bufferView);
  118036. return k._dracoBabylonGeometry || (k._dracoBabylonGeometry = s._loader.loadBufferViewAsync("/bufferViews/" + k.index, k).then(function(j) {
  118037. var $ = s.dracoCompression || DracoCompression.Default;
  118038. return $.decodeMeshAsync(j, _).then(function(_e) {
  118039. var et = new Geometry(o.name,s._loader.babylonScene);
  118040. return _e.applyToGeometry(et),
  118041. et
  118042. }).catch(function(_e) {
  118043. throw new Error(e + ": " + _e.message)
  118044. })
  118045. })),
  118046. k._dracoBabylonGeometry
  118047. })
  118048. }
  118049. ,
  118050. a
  118051. }();
  118052. GLTFLoader.RegisterExtension(NAME$q, function(a) {
  118053. return new KHR_draco_mesh_compression(a)
  118054. });
  118055. var NAME$p = "KHR_lights_punctual"
  118056. , KHR_lights = function() {
  118057. function a(e) {
  118058. this.name = NAME$p,
  118059. this._loader = e,
  118060. this.enabled = this._loader.isExtensionUsed(NAME$p)
  118061. }
  118062. return a.prototype.dispose = function() {
  118063. this._loader = null,
  118064. delete this._lights
  118065. }
  118066. ,
  118067. a.prototype.onLoading = function() {
  118068. var e = this._loader.gltf.extensions;
  118069. if (e && e[this.name]) {
  118070. var i = e[this.name];
  118071. this._lights = i.lights
  118072. }
  118073. }
  118074. ,
  118075. a.prototype.loadNodeAsync = function(e, i, o) {
  118076. var s = this;
  118077. return GLTFLoader.LoadExtensionAsync(e, i, this.name, function(c, d) {
  118078. return s._loader.loadNodeAsync(e, i, function(_) {
  118079. var b, k = ArrayItem.Get(c, s._lights, d.light), j = k.name || _.name;
  118080. switch (s._loader.babylonScene._blockEntityCollection = !!s._loader._assetContainer,
  118081. k.type) {
  118082. case "directional":
  118083. {
  118084. b = new DirectionalLight(j,Vector3.Backward(),s._loader.babylonScene);
  118085. break
  118086. }
  118087. case "point":
  118088. {
  118089. b = new PointLight(j,Vector3.Zero(),s._loader.babylonScene);
  118090. break
  118091. }
  118092. case "spot":
  118093. {
  118094. var $ = new SpotLight(j,Vector3.Zero(),Vector3.Backward(),0,1,s._loader.babylonScene);
  118095. $.angle = (k.spot && k.spot.outerConeAngle || Math.PI / 4) * 2,
  118096. $.innerAngle = (k.spot && k.spot.innerConeAngle || 0) * 2,
  118097. b = $;
  118098. break
  118099. }
  118100. default:
  118101. throw s._loader.babylonScene._blockEntityCollection = !1,
  118102. new Error(c + ": Invalid light type (" + k.type + ")")
  118103. }
  118104. b._parentContainer = s._loader._assetContainer,
  118105. s._loader.babylonScene._blockEntityCollection = !1,
  118106. b.falloffType = Light.FALLOFF_GLTF,
  118107. b.diffuse = k.color ? Color3.FromArray(k.color) : Color3.White(),
  118108. b.intensity = k.intensity == null ? 1 : k.intensity,
  118109. b.range = k.range == null ? Number.MAX_VALUE : k.range,
  118110. b.parent = _,
  118111. s._loader._babylonLights.push(b),
  118112. GLTFLoader.AddPointerMetadata(b, c),
  118113. o(_)
  118114. })
  118115. })
  118116. }
  118117. ,
  118118. a
  118119. }();
  118120. GLTFLoader.RegisterExtension(NAME$p, function(a) {
  118121. return new KHR_lights(a)
  118122. });
  118123. var NAME$o = "KHR_materials_pbrSpecularGlossiness"
  118124. , KHR_materials_pbrSpecularGlossiness = function() {
  118125. function a(e) {
  118126. this.name = NAME$o,
  118127. this.order = 200,
  118128. this._loader = e,
  118129. this.enabled = this._loader.isExtensionUsed(NAME$o)
  118130. }
  118131. return a.prototype.dispose = function() {
  118132. this._loader = null
  118133. }
  118134. ,
  118135. a.prototype.loadMaterialPropertiesAsync = function(e, i, o) {
  118136. var s = this;
  118137. return GLTFLoader.LoadExtensionAsync(e, i, this.name, function(c, d) {
  118138. var _ = new Array;
  118139. return _.push(s._loader.loadMaterialBasePropertiesAsync(e, i, o)),
  118140. _.push(s._loadSpecularGlossinessPropertiesAsync(c, i, d, o)),
  118141. s._loader.loadMaterialAlphaProperties(e, i, o),
  118142. Promise.all(_).then(function() {})
  118143. })
  118144. }
  118145. ,
  118146. a.prototype._loadSpecularGlossinessPropertiesAsync = function(e, i, o, s) {
  118147. if (!(s instanceof PBRMaterial))
  118148. throw new Error(e + ": Material type not supported");
  118149. var c = new Array;
  118150. return s.metallic = null,
  118151. s.roughness = null,
  118152. o.diffuseFactor ? (s.albedoColor = Color3.FromArray(o.diffuseFactor),
  118153. s.alpha = o.diffuseFactor[3]) : s.albedoColor = Color3.White(),
  118154. s.reflectivityColor = o.specularFactor ? Color3.FromArray(o.specularFactor) : Color3.White(),
  118155. s.microSurface = o.glossinessFactor == null ? 1 : o.glossinessFactor,
  118156. o.diffuseTexture && c.push(this._loader.loadTextureInfoAsync(e + "/diffuseTexture", o.diffuseTexture, function(d) {
  118157. d.name = s.name + " (Diffuse)",
  118158. s.albedoTexture = d
  118159. })),
  118160. o.specularGlossinessTexture && (c.push(this._loader.loadTextureInfoAsync(e + "/specularGlossinessTexture", o.specularGlossinessTexture, function(d) {
  118161. d.name = s.name + " (Specular Glossiness)",
  118162. s.reflectivityTexture = d
  118163. })),
  118164. s.reflectivityTexture.hasAlpha = !0,
  118165. s.useMicroSurfaceFromReflectivityMapAlpha = !0),
  118166. Promise.all(c).then(function() {})
  118167. }
  118168. ,
  118169. a
  118170. }();
  118171. GLTFLoader.RegisterExtension(NAME$o, function(a) {
  118172. return new KHR_materials_pbrSpecularGlossiness(a)
  118173. });
  118174. var NAME$n = "KHR_materials_unlit"
  118175. , KHR_materials_unlit$1 = function() {
  118176. function a(e) {
  118177. this.name = NAME$n,
  118178. this.order = 210,
  118179. this._loader = e,
  118180. this.enabled = this._loader.isExtensionUsed(NAME$n)
  118181. }
  118182. return a.prototype.dispose = function() {
  118183. this._loader = null
  118184. }
  118185. ,
  118186. a.prototype.loadMaterialPropertiesAsync = function(e, i, o) {
  118187. var s = this;
  118188. return GLTFLoader.LoadExtensionAsync(e, i, this.name, function() {
  118189. return s._loadUnlitPropertiesAsync(e, i, o)
  118190. })
  118191. }
  118192. ,
  118193. a.prototype._loadUnlitPropertiesAsync = function(e, i, o) {
  118194. if (!(o instanceof PBRMaterial))
  118195. throw new Error(e + ": Material type not supported");
  118196. var s = new Array;
  118197. o.unlit = !0;
  118198. var c = i.pbrMetallicRoughness;
  118199. return c && (c.baseColorFactor ? (o.albedoColor = Color3.FromArray(c.baseColorFactor),
  118200. o.alpha = c.baseColorFactor[3]) : o.albedoColor = Color3.White(),
  118201. c.baseColorTexture && s.push(this._loader.loadTextureInfoAsync(e + "/baseColorTexture", c.baseColorTexture, function(d) {
  118202. d.name = o.name + " (Base Color)",
  118203. o.albedoTexture = d
  118204. }))),
  118205. i.doubleSided && (o.backFaceCulling = !1,
  118206. o.twoSidedLighting = !0),
  118207. this._loader.loadMaterialAlphaProperties(e, i, o),
  118208. Promise.all(s).then(function() {})
  118209. }
  118210. ,
  118211. a
  118212. }();
  118213. GLTFLoader.RegisterExtension(NAME$n, function(a) {
  118214. return new KHR_materials_unlit$1(a)
  118215. });
  118216. var NAME$m = "KHR_materials_clearcoat"
  118217. , KHR_materials_clearcoat$1 = function() {
  118218. function a(e) {
  118219. this.name = NAME$m,
  118220. this.order = 190,
  118221. this._loader = e,
  118222. this.enabled = this._loader.isExtensionUsed(NAME$m)
  118223. }
  118224. return a.prototype.dispose = function() {
  118225. this._loader = null
  118226. }
  118227. ,
  118228. a.prototype.loadMaterialPropertiesAsync = function(e, i, o) {
  118229. var s = this;
  118230. return GLTFLoader.LoadExtensionAsync(e, i, this.name, function(c, d) {
  118231. var _ = new Array;
  118232. return _.push(s._loader.loadMaterialPropertiesAsync(e, i, o)),
  118233. _.push(s._loadClearCoatPropertiesAsync(c, d, o)),
  118234. Promise.all(_).then(function() {})
  118235. })
  118236. }
  118237. ,
  118238. a.prototype._loadClearCoatPropertiesAsync = function(e, i, o) {
  118239. if (!(o instanceof PBRMaterial))
  118240. throw new Error(e + ": Material type not supported");
  118241. var s = new Array;
  118242. return o.clearCoat.isEnabled = !0,
  118243. o.clearCoat.useRoughnessFromMainTexture = !1,
  118244. o.clearCoat.remapF0OnInterfaceChange = !1,
  118245. i.clearcoatFactor != null ? o.clearCoat.intensity = i.clearcoatFactor : o.clearCoat.intensity = 0,
  118246. i.clearcoatTexture && s.push(this._loader.loadTextureInfoAsync(e + "/clearcoatTexture", i.clearcoatTexture, function(c) {
  118247. c.name = o.name + " (ClearCoat Intensity)",
  118248. o.clearCoat.texture = c
  118249. })),
  118250. i.clearcoatRoughnessFactor != null ? o.clearCoat.roughness = i.clearcoatRoughnessFactor : o.clearCoat.roughness = 0,
  118251. i.clearcoatRoughnessTexture && (i.clearcoatRoughnessTexture.nonColorData = !0,
  118252. s.push(this._loader.loadTextureInfoAsync(e + "/clearcoatRoughnessTexture", i.clearcoatRoughnessTexture, function(c) {
  118253. c.name = o.name + " (ClearCoat Roughness)",
  118254. o.clearCoat.textureRoughness = c
  118255. }))),
  118256. i.clearcoatNormalTexture && (i.clearcoatNormalTexture.nonColorData = !0,
  118257. s.push(this._loader.loadTextureInfoAsync(e + "/clearcoatNormalTexture", i.clearcoatNormalTexture, function(c) {
  118258. c.name = o.name + " (ClearCoat Normal)",
  118259. o.clearCoat.bumpTexture = c
  118260. })),
  118261. o.invertNormalMapX = !o.getScene().useRightHandedSystem,
  118262. o.invertNormalMapY = o.getScene().useRightHandedSystem,
  118263. i.clearcoatNormalTexture.scale != null && (o.clearCoat.bumpTexture.level = i.clearcoatNormalTexture.scale)),
  118264. Promise.all(s).then(function() {})
  118265. }
  118266. ,
  118267. a
  118268. }();
  118269. GLTFLoader.RegisterExtension(NAME$m, function(a) {
  118270. return new KHR_materials_clearcoat$1(a)
  118271. });
  118272. var NAME$l = "KHR_materials_emissive_strength"
  118273. , KHR_materials_emissive_strength = function() {
  118274. function a(e) {
  118275. this.name = NAME$l,
  118276. this.order = 170,
  118277. this._loader = e,
  118278. this.enabled = this._loader.isExtensionUsed(NAME$l)
  118279. }
  118280. return a.prototype.dispose = function() {
  118281. this._loader = null
  118282. }
  118283. ,
  118284. a.prototype.loadMaterialPropertiesAsync = function(e, i, o) {
  118285. var s = this;
  118286. return GLTFLoader.LoadExtensionAsync(e, i, this.name, function(c, d) {
  118287. return s._loader.loadMaterialPropertiesAsync(e, i, o).then(function() {
  118288. s._loadEmissiveProperties(c, d, o)
  118289. })
  118290. })
  118291. }
  118292. ,
  118293. a.prototype._loadEmissiveProperties = function(e, i, o) {
  118294. if (!(o instanceof PBRMaterial))
  118295. throw new Error(e + ": Material type not supported");
  118296. i.emissiveStrength !== void 0 && o.emissiveColor.scaleToRef(i.emissiveStrength, o.emissiveColor)
  118297. }
  118298. ,
  118299. a
  118300. }();
  118301. GLTFLoader.RegisterExtension(NAME$l, function(a) {
  118302. return new KHR_materials_emissive_strength(a)
  118303. });
  118304. var NAME$k = "KHR_materials_sheen"
  118305. , KHR_materials_sheen$1 = function() {
  118306. function a(e) {
  118307. this.name = NAME$k,
  118308. this.order = 190,
  118309. this._loader = e,
  118310. this.enabled = this._loader.isExtensionUsed(NAME$k)
  118311. }
  118312. return a.prototype.dispose = function() {
  118313. this._loader = null
  118314. }
  118315. ,
  118316. a.prototype.loadMaterialPropertiesAsync = function(e, i, o) {
  118317. var s = this;
  118318. return GLTFLoader.LoadExtensionAsync(e, i, this.name, function(c, d) {
  118319. var _ = new Array;
  118320. return _.push(s._loader.loadMaterialPropertiesAsync(e, i, o)),
  118321. _.push(s._loadSheenPropertiesAsync(c, d, o)),
  118322. Promise.all(_).then(function() {})
  118323. })
  118324. }
  118325. ,
  118326. a.prototype._loadSheenPropertiesAsync = function(e, i, o) {
  118327. if (!(o instanceof PBRMaterial))
  118328. throw new Error(e + ": Material type not supported");
  118329. var s = new Array;
  118330. return o.sheen.isEnabled = !0,
  118331. o.sheen.intensity = 1,
  118332. i.sheenColorFactor != null ? o.sheen.color = Color3.FromArray(i.sheenColorFactor) : o.sheen.color = Color3.Black(),
  118333. i.sheenColorTexture && s.push(this._loader.loadTextureInfoAsync(e + "/sheenColorTexture", i.sheenColorTexture, function(c) {
  118334. c.name = o.name + " (Sheen Color)",
  118335. o.sheen.texture = c
  118336. })),
  118337. i.sheenRoughnessFactor !== void 0 ? o.sheen.roughness = i.sheenRoughnessFactor : o.sheen.roughness = 0,
  118338. i.sheenRoughnessTexture && (i.sheenRoughnessTexture.nonColorData = !0,
  118339. s.push(this._loader.loadTextureInfoAsync(e + "/sheenRoughnessTexture", i.sheenRoughnessTexture, function(c) {
  118340. c.name = o.name + " (Sheen Roughness)",
  118341. o.sheen.textureRoughness = c
  118342. }))),
  118343. o.sheen.albedoScaling = !0,
  118344. o.sheen.useRoughnessFromMainTexture = !1,
  118345. Promise.all(s).then(function() {})
  118346. }
  118347. ,
  118348. a
  118349. }();
  118350. GLTFLoader.RegisterExtension(NAME$k, function(a) {
  118351. return new KHR_materials_sheen$1(a)
  118352. });
  118353. var NAME$j = "KHR_materials_specular"
  118354. , KHR_materials_specular = function() {
  118355. function a(e) {
  118356. this.name = NAME$j,
  118357. this.order = 190,
  118358. this._loader = e,
  118359. this.enabled = this._loader.isExtensionUsed(NAME$j)
  118360. }
  118361. return a.prototype.dispose = function() {
  118362. this._loader = null
  118363. }
  118364. ,
  118365. a.prototype.loadMaterialPropertiesAsync = function(e, i, o) {
  118366. var s = this;
  118367. return GLTFLoader.LoadExtensionAsync(e, i, this.name, function(c, d) {
  118368. var _ = new Array;
  118369. return _.push(s._loader.loadMaterialPropertiesAsync(e, i, o)),
  118370. _.push(s._loadSpecularPropertiesAsync(c, d, o)),
  118371. Promise.all(_).then(function() {})
  118372. })
  118373. }
  118374. ,
  118375. a.prototype._loadSpecularPropertiesAsync = function(e, i, o) {
  118376. if (!(o instanceof PBRMaterial))
  118377. throw new Error(e + ": Material type not supported");
  118378. var s = new Array;
  118379. return i.specularFactor !== void 0 && (o.metallicF0Factor = i.specularFactor),
  118380. i.specularColorFactor !== void 0 && (o.metallicReflectanceColor = Color3.FromArray(i.specularColorFactor)),
  118381. i.specularTexture && (i.specularTexture.nonColorData = !0,
  118382. s.push(this._loader.loadTextureInfoAsync(e + "/specularTexture", i.specularTexture, function(c) {
  118383. c.name = o.name + " (Specular F0 Strength)",
  118384. o.metallicReflectanceTexture = c,
  118385. o.useOnlyMetallicFromMetallicReflectanceTexture = !0
  118386. }))),
  118387. i.specularColorTexture && s.push(this._loader.loadTextureInfoAsync(e + "/specularColorTexture", i.specularColorTexture, function(c) {
  118388. c.name = o.name + " (Specular F0 Color)",
  118389. o.reflectanceTexture = c
  118390. })),
  118391. Promise.all(s).then(function() {})
  118392. }
  118393. ,
  118394. a
  118395. }();
  118396. GLTFLoader.RegisterExtension(NAME$j, function(a) {
  118397. return new KHR_materials_specular(a)
  118398. });
  118399. var NAME$i = "KHR_materials_ior"
  118400. , KHR_materials_ior = function() {
  118401. function a(e) {
  118402. this.name = NAME$i,
  118403. this.order = 180,
  118404. this._loader = e,
  118405. this.enabled = this._loader.isExtensionUsed(NAME$i)
  118406. }
  118407. return a.prototype.dispose = function() {
  118408. this._loader = null
  118409. }
  118410. ,
  118411. a.prototype.loadMaterialPropertiesAsync = function(e, i, o) {
  118412. var s = this;
  118413. return GLTFLoader.LoadExtensionAsync(e, i, this.name, function(c, d) {
  118414. var _ = new Array;
  118415. return _.push(s._loader.loadMaterialPropertiesAsync(e, i, o)),
  118416. _.push(s._loadIorPropertiesAsync(c, d, o)),
  118417. Promise.all(_).then(function() {})
  118418. })
  118419. }
  118420. ,
  118421. a.prototype._loadIorPropertiesAsync = function(e, i, o) {
  118422. if (!(o instanceof PBRMaterial))
  118423. throw new Error(e + ": Material type not supported");
  118424. return i.ior !== void 0 ? o.indexOfRefraction = i.ior : o.indexOfRefraction = a._DEFAULT_IOR,
  118425. Promise.resolve()
  118426. }
  118427. ,
  118428. a._DEFAULT_IOR = 1.5,
  118429. a
  118430. }();
  118431. GLTFLoader.RegisterExtension(NAME$i, function(a) {
  118432. return new KHR_materials_ior(a)
  118433. });
  118434. var NAME$h = "KHR_materials_variants"
  118435. , KHR_materials_variants = function() {
  118436. function a(e) {
  118437. this.name = NAME$h,
  118438. this._loader = e,
  118439. this.enabled = this._loader.isExtensionUsed(NAME$h)
  118440. }
  118441. return a.prototype.dispose = function() {
  118442. this._loader = null
  118443. }
  118444. ,
  118445. a.GetAvailableVariants = function(e) {
  118446. var i = this._GetExtensionMetadata(e);
  118447. return i ? Object.keys(i.variants) : []
  118448. }
  118449. ,
  118450. a.prototype.getAvailableVariants = function(e) {
  118451. return a.GetAvailableVariants(e)
  118452. }
  118453. ,
  118454. a.SelectVariant = function(e, i) {
  118455. var o = this._GetExtensionMetadata(e);
  118456. if (!o)
  118457. throw new Error("Cannot select variant on a glTF mesh that does not have the " + NAME$h + " extension");
  118458. var s = function(b) {
  118459. var k = o.variants[b];
  118460. if (k)
  118461. for (var j = 0, $ = k; j < $.length; j++) {
  118462. var _e = $[j];
  118463. _e.mesh.material = _e.material
  118464. }
  118465. };
  118466. if (i instanceof Array)
  118467. for (var c = 0, d = i; c < d.length; c++) {
  118468. var _ = d[c];
  118469. s(_)
  118470. }
  118471. else
  118472. s(i);
  118473. o.lastSelected = i
  118474. }
  118475. ,
  118476. a.prototype.selectVariant = function(e, i) {
  118477. return a.SelectVariant(e, i)
  118478. }
  118479. ,
  118480. a.Reset = function(e) {
  118481. var i = this._GetExtensionMetadata(e);
  118482. if (!i)
  118483. throw new Error("Cannot reset on a glTF mesh that does not have the " + NAME$h + " extension");
  118484. for (var o = 0, s = i.original; o < s.length; o++) {
  118485. var c = s[o];
  118486. c.mesh.material = c.material
  118487. }
  118488. i.lastSelected = null
  118489. }
  118490. ,
  118491. a.prototype.reset = function(e) {
  118492. return a.Reset(e)
  118493. }
  118494. ,
  118495. a.GetLastSelectedVariant = function(e) {
  118496. var i = this._GetExtensionMetadata(e);
  118497. if (!i)
  118498. throw new Error("Cannot get the last selected variant on a glTF mesh that does not have the " + NAME$h + " extension");
  118499. return i.lastSelected
  118500. }
  118501. ,
  118502. a.prototype.getLastSelectedVariant = function(e) {
  118503. return a.GetLastSelectedVariant(e)
  118504. }
  118505. ,
  118506. a._GetExtensionMetadata = function(e) {
  118507. var i, o;
  118508. return ((o = (i = e == null ? void 0 : e.metadata) === null || i === void 0 ? void 0 : i.gltf) === null || o === void 0 ? void 0 : o[NAME$h]) || null
  118509. }
  118510. ,
  118511. a.prototype.onLoading = function() {
  118512. var e = this._loader.gltf.extensions;
  118513. if (e && e[this.name]) {
  118514. var i = e[this.name];
  118515. this._variants = i.variants
  118516. }
  118517. }
  118518. ,
  118519. a.prototype._loadMeshPrimitiveAsync = function(e, i, o, s, c, d) {
  118520. var _ = this;
  118521. return GLTFLoader.LoadExtensionAsync(e, c, this.name, function(b, k) {
  118522. var j = new Array;
  118523. return j.push(_._loader._loadMeshPrimitiveAsync(e, i, o, s, c, function($) {
  118524. if (d($),
  118525. $instanceof Mesh) {
  118526. var _e = GLTFLoader._GetDrawMode(e, c.mode)
  118527. , et = _._loader.rootBabylonMesh
  118528. , tt = et ? et.metadata = et.metadata || {} : {}
  118529. , rt = tt.gltf = tt.gltf || {}
  118530. , it = rt[NAME$h] = rt[NAME$h] || {
  118531. lastSelected: null,
  118532. original: [],
  118533. variants: {}
  118534. };
  118535. it.original.push({
  118536. mesh: $,
  118537. material: $.material
  118538. });
  118539. for (var nt = function(at) {
  118540. var st = k.mappings[at]
  118541. , ut = ArrayItem.Get(b + "/mappings/" + at + "/material", _._loader.gltf.materials, st.material);
  118542. j.push(_._loader._loadMaterialAsync("#/materials/" + st.material, ut, $, _e, function(ct) {
  118543. for (var lt = function(ht) {
  118544. var pt = st.variants[ht]
  118545. , dt = ArrayItem.Get("/extensions/" + NAME$h + "/variants/" + pt, _._variants, pt);
  118546. it.variants[dt.name] = it.variants[dt.name] || [],
  118547. it.variants[dt.name].push({
  118548. mesh: $,
  118549. material: ct
  118550. }),
  118551. $.onClonedObservable.add(function(_t) {
  118552. var mt = _t
  118553. , vt = null
  118554. , yt = mt;
  118555. do {
  118556. if (yt = yt.parent,
  118557. !yt)
  118558. return;
  118559. vt = a._GetExtensionMetadata(yt)
  118560. } while (vt === null);
  118561. if (et && vt === a._GetExtensionMetadata(et)) {
  118562. yt.metadata = {};
  118563. for (var Et in et.metadata)
  118564. yt.metadata[Et] = et.metadata[Et];
  118565. yt.metadata.gltf = [];
  118566. for (var Et in et.metadata.gltf)
  118567. yt.metadata.gltf[Et] = et.metadata.gltf[Et];
  118568. yt.metadata.gltf[NAME$h] = {
  118569. lastSelected: null,
  118570. original: [],
  118571. variants: {}
  118572. };
  118573. for (var At = 0, gt = vt.original; At < gt.length; At++) {
  118574. var St = gt[At];
  118575. yt.metadata.gltf[NAME$h].original.push({
  118576. mesh: St.mesh,
  118577. material: St.material
  118578. })
  118579. }
  118580. for (var Et in vt.variants)
  118581. if (vt.variants.hasOwnProperty(Et)) {
  118582. yt.metadata.gltf[NAME$h].variants[Et] = [];
  118583. for (var xt = 0, bt = vt.variants[Et]; xt < bt.length; xt++) {
  118584. var Rt = bt[xt];
  118585. yt.metadata.gltf[NAME$h].variants[Et].push({
  118586. mesh: Rt.mesh,
  118587. material: Rt.material
  118588. })
  118589. }
  118590. }
  118591. vt = yt.metadata.gltf[NAME$h]
  118592. }
  118593. for (var Mt = 0, Pt = vt.original; Mt < Pt.length; Mt++) {
  118594. var It = Pt[Mt];
  118595. It.mesh === $ && (It.mesh = mt)
  118596. }
  118597. for (var Dt = 0, Ct = vt.variants[dt.name]; Dt < Ct.length; Dt++) {
  118598. var It = Ct[Dt];
  118599. It.mesh === $ && (It.mesh = mt)
  118600. }
  118601. })
  118602. }, ft = 0; ft < st.variants.length; ++ft)
  118603. lt(ft)
  118604. }))
  118605. }, ot = 0; ot < k.mappings.length; ++ot)
  118606. nt(ot)
  118607. }
  118608. })),
  118609. Promise.all(j).then(function($) {
  118610. var _e = $[0];
  118611. return _e
  118612. })
  118613. })
  118614. }
  118615. ,
  118616. a
  118617. }();
  118618. GLTFLoader.RegisterExtension(NAME$h, function(a) {
  118619. return new KHR_materials_variants(a)
  118620. });
  118621. var TransmissionHelper = function() {
  118622. function a(e, i) {
  118623. var o = this;
  118624. this._opaqueRenderTarget = null,
  118625. this._opaqueMeshesCache = [],
  118626. this._transparentMeshesCache = [],
  118627. this._materialObservers = {},
  118628. this._options = __assign(__assign({}, a._getDefaultOptions()), e),
  118629. this._scene = i,
  118630. this._scene._transmissionHelper = this,
  118631. this.onErrorObservable = new Observable,
  118632. this._scene.onDisposeObservable.addOnce(function(s) {
  118633. o.dispose()
  118634. }),
  118635. this._parseScene(),
  118636. this._setupRenderTargets()
  118637. }
  118638. return a._getDefaultOptions = function() {
  118639. return {
  118640. renderSize: 1024,
  118641. samples: 4,
  118642. lodGenerationScale: 1,
  118643. lodGenerationOffset: -4,
  118644. renderTargetTextureType: Constants.TEXTURETYPE_HALF_FLOAT,
  118645. generateMipmaps: !0
  118646. }
  118647. }
  118648. ,
  118649. a.prototype.updateOptions = function(e) {
  118650. var i = this
  118651. , o = Object.keys(e).filter(function(d) {
  118652. return i._options[d] !== e[d]
  118653. });
  118654. if (!!o.length) {
  118655. var s = __assign(__assign({}, this._options), e)
  118656. , c = this._options;
  118657. this._options = s,
  118658. s.renderSize !== c.renderSize || s.renderTargetTextureType !== c.renderTargetTextureType || s.generateMipmaps !== c.generateMipmaps || !this._opaqueRenderTarget ? this._setupRenderTargets() : (this._opaqueRenderTarget.samples = s.samples,
  118659. this._opaqueRenderTarget.lodGenerationScale = s.lodGenerationScale,
  118660. this._opaqueRenderTarget.lodGenerationOffset = s.lodGenerationOffset)
  118661. }
  118662. }
  118663. ,
  118664. a.prototype.getOpaqueTarget = function() {
  118665. return this._opaqueRenderTarget
  118666. }
  118667. ,
  118668. a.prototype.shouldRenderAsTransmission = function(e) {
  118669. return e ? !!(e instanceof PBRMaterial && e.subSurface.isRefractionEnabled) : !1
  118670. }
  118671. ,
  118672. a.prototype._addMesh = function(e) {
  118673. var i = this;
  118674. this._materialObservers[e.uniqueId] = e.onMaterialChangedObservable.add(this._onMeshMaterialChanged.bind(this)),
  118675. Tools.SetImmediate(function() {
  118676. i.shouldRenderAsTransmission(e.material) ? (e.material.refractionTexture = i._opaqueRenderTarget,
  118677. i._transparentMeshesCache.push(e)) : i._opaqueMeshesCache.push(e)
  118678. })
  118679. }
  118680. ,
  118681. a.prototype._removeMesh = function(e) {
  118682. e.onMaterialChangedObservable.remove(this._materialObservers[e.uniqueId]),
  118683. delete this._materialObservers[e.uniqueId];
  118684. var i = this._transparentMeshesCache.indexOf(e);
  118685. i !== -1 && this._transparentMeshesCache.splice(i, 1),
  118686. i = this._opaqueMeshesCache.indexOf(e),
  118687. i !== -1 && this._opaqueMeshesCache.splice(i, 1)
  118688. }
  118689. ,
  118690. a.prototype._parseScene = function() {
  118691. this._scene.meshes.forEach(this._addMesh.bind(this)),
  118692. this._scene.onNewMeshAddedObservable.add(this._addMesh.bind(this)),
  118693. this._scene.onMeshRemovedObservable.add(this._removeMesh.bind(this))
  118694. }
  118695. ,
  118696. a.prototype._onMeshMaterialChanged = function(e) {
  118697. var i = this._transparentMeshesCache.indexOf(e)
  118698. , o = this._opaqueMeshesCache.indexOf(e)
  118699. , s = this.shouldRenderAsTransmission(e.material);
  118700. s ? (e.material instanceof PBRMaterial && (e.material.subSurface.refractionTexture = this._opaqueRenderTarget),
  118701. o !== -1 ? (this._opaqueMeshesCache.splice(o, 1),
  118702. this._transparentMeshesCache.push(e)) : i === -1 && this._transparentMeshesCache.push(e)) : i !== -1 ? (this._transparentMeshesCache.splice(i, 1),
  118703. this._opaqueMeshesCache.push(e)) : o === -1 && this._opaqueMeshesCache.push(e)
  118704. }
  118705. ,
  118706. a.prototype._setupRenderTargets = function() {
  118707. var e = this, i, o;
  118708. this._opaqueRenderTarget && this._opaqueRenderTarget.dispose(),
  118709. this._opaqueRenderTarget = new RenderTargetTexture("opaqueSceneTexture",this._options.renderSize,this._scene,this._options.generateMipmaps,void 0,this._options.renderTargetTextureType),
  118710. this._opaqueRenderTarget.ignoreCameraViewport = !0,
  118711. this._opaqueRenderTarget.renderList = this._opaqueMeshesCache,
  118712. this._opaqueRenderTarget.clearColor = (o = (i = this._options.clearColor) === null || i === void 0 ? void 0 : i.clone()) !== null && o !== void 0 ? o : this._scene.clearColor.clone(),
  118713. this._opaqueRenderTarget.gammaSpace = !1,
  118714. this._opaqueRenderTarget.lodGenerationScale = this._options.lodGenerationScale,
  118715. this._opaqueRenderTarget.lodGenerationOffset = this._options.lodGenerationOffset,
  118716. this._opaqueRenderTarget.samples = this._options.samples;
  118717. var s, c;
  118718. this._opaqueRenderTarget.onBeforeBindObservable.add(function(d) {
  118719. c = e._scene.environmentIntensity,
  118720. e._scene.environmentIntensity = 1,
  118721. s = e._scene.imageProcessingConfiguration.applyByPostProcess,
  118722. e._options.clearColor ? d.clearColor.copyFrom(e._options.clearColor) : e._scene.clearColor.toLinearSpaceToRef(d.clearColor),
  118723. e._scene.imageProcessingConfiguration._applyByPostProcess = !0
  118724. }),
  118725. this._opaqueRenderTarget.onAfterUnbindObservable.add(function() {
  118726. e._scene.environmentIntensity = c,
  118727. e._scene.imageProcessingConfiguration._applyByPostProcess = s
  118728. }),
  118729. this._transparentMeshesCache.forEach(function(d) {
  118730. e.shouldRenderAsTransmission(d.material) && (d.material.refractionTexture = e._opaqueRenderTarget)
  118731. })
  118732. }
  118733. ,
  118734. a.prototype.dispose = function() {
  118735. this._scene._transmissionHelper = void 0,
  118736. this._opaqueRenderTarget && (this._opaqueRenderTarget.dispose(),
  118737. this._opaqueRenderTarget = null),
  118738. this._transparentMeshesCache = [],
  118739. this._opaqueMeshesCache = []
  118740. }
  118741. ,
  118742. a
  118743. }()
  118744. , NAME$g = "KHR_materials_transmission"
  118745. , KHR_materials_transmission = function() {
  118746. function a(e) {
  118747. this.name = NAME$g,
  118748. this.order = 175,
  118749. this._loader = e,
  118750. this.enabled = this._loader.isExtensionUsed(NAME$g),
  118751. this.enabled && (e.parent.transparencyAsCoverage = !0)
  118752. }
  118753. return a.prototype.dispose = function() {
  118754. this._loader = null
  118755. }
  118756. ,
  118757. a.prototype.loadMaterialPropertiesAsync = function(e, i, o) {
  118758. var s = this;
  118759. return GLTFLoader.LoadExtensionAsync(e, i, this.name, function(c, d) {
  118760. var _ = new Array;
  118761. return _.push(s._loader.loadMaterialBasePropertiesAsync(e, i, o)),
  118762. _.push(s._loader.loadMaterialPropertiesAsync(e, i, o)),
  118763. _.push(s._loadTransparentPropertiesAsync(c, i, o, d)),
  118764. Promise.all(_).then(function() {})
  118765. })
  118766. }
  118767. ,
  118768. a.prototype._loadTransparentPropertiesAsync = function(e, i, o, s) {
  118769. if (!(o instanceof PBRMaterial))
  118770. throw new Error(e + ": Material type not supported");
  118771. var c = o;
  118772. if (c.subSurface.isRefractionEnabled = !0,
  118773. c.subSurface.volumeIndexOfRefraction = 1,
  118774. c.subSurface.useAlbedoToTintRefraction = !0,
  118775. s.transmissionFactor !== void 0) {
  118776. c.subSurface.refractionIntensity = s.transmissionFactor;
  118777. var d = c.getScene();
  118778. c.subSurface.refractionIntensity && !d._transmissionHelper && new TransmissionHelper({},c.getScene())
  118779. } else
  118780. return c.subSurface.refractionIntensity = 0,
  118781. c.subSurface.isRefractionEnabled = !1,
  118782. Promise.resolve();
  118783. return c.subSurface.minimumThickness = 0,
  118784. c.subSurface.maximumThickness = 0,
  118785. s.transmissionTexture ? (s.transmissionTexture.nonColorData = !0,
  118786. this._loader.loadTextureInfoAsync(e + "/transmissionTexture", s.transmissionTexture, void 0).then(function(_) {
  118787. c.subSurface.refractionIntensityTexture = _,
  118788. c.subSurface.useGltfStyleTextures = !0
  118789. })) : Promise.resolve()
  118790. }
  118791. ,
  118792. a
  118793. }();
  118794. GLTFLoader.RegisterExtension(NAME$g, function(a) {
  118795. return new KHR_materials_transmission(a)
  118796. });
  118797. var NAME$f = "KHR_materials_translucency"
  118798. , KHR_materials_translucency = function() {
  118799. function a(e) {
  118800. this.name = NAME$f,
  118801. this.order = 174,
  118802. this._loader = e,
  118803. this.enabled = this._loader.isExtensionUsed(NAME$f),
  118804. this.enabled && (e.parent.transparencyAsCoverage = !0)
  118805. }
  118806. return a.prototype.dispose = function() {
  118807. this._loader = null
  118808. }
  118809. ,
  118810. a.prototype.loadMaterialPropertiesAsync = function(e, i, o) {
  118811. var s = this;
  118812. return GLTFLoader.LoadExtensionAsync(e, i, this.name, function(c, d) {
  118813. var _ = new Array;
  118814. return _.push(s._loader.loadMaterialBasePropertiesAsync(e, i, o)),
  118815. _.push(s._loader.loadMaterialPropertiesAsync(e, i, o)),
  118816. _.push(s._loadTranslucentPropertiesAsync(c, i, o, d)),
  118817. Promise.all(_).then(function() {})
  118818. })
  118819. }
  118820. ,
  118821. a.prototype._loadTranslucentPropertiesAsync = function(e, i, o, s) {
  118822. if (!(o instanceof PBRMaterial))
  118823. throw new Error(e + ": Material type not supported");
  118824. var c = o;
  118825. if (c.subSurface.isTranslucencyEnabled = !0,
  118826. c.subSurface.volumeIndexOfRefraction = 1,
  118827. c.subSurface.minimumThickness = 0,
  118828. c.subSurface.maximumThickness = 0,
  118829. c.subSurface.useAlbedoToTintTranslucency = !0,
  118830. s.translucencyFactor !== void 0)
  118831. c.subSurface.translucencyIntensity = s.translucencyFactor;
  118832. else
  118833. return c.subSurface.translucencyIntensity = 0,
  118834. c.subSurface.isTranslucencyEnabled = !1,
  118835. Promise.resolve();
  118836. return s.translucencyTexture ? (s.translucencyTexture.nonColorData = !0,
  118837. this._loader.loadTextureInfoAsync(e + "/translucencyTexture", s.translucencyTexture).then(function(d) {
  118838. c.subSurface.translucencyIntensityTexture = d
  118839. })) : Promise.resolve()
  118840. }
  118841. ,
  118842. a
  118843. }();
  118844. GLTFLoader.RegisterExtension(NAME$f, function(a) {
  118845. return new KHR_materials_translucency(a)
  118846. });
  118847. var NAME$e = "KHR_materials_volume"
  118848. , KHR_materials_volume = function() {
  118849. function a(e) {
  118850. this.name = NAME$e,
  118851. this.order = 173,
  118852. this._loader = e,
  118853. this.enabled = this._loader.isExtensionUsed(NAME$e),
  118854. this.enabled && this._loader._disableInstancedMesh++
  118855. }
  118856. return a.prototype.dispose = function() {
  118857. this.enabled && this._loader._disableInstancedMesh--,
  118858. this._loader = null
  118859. }
  118860. ,
  118861. a.prototype.loadMaterialPropertiesAsync = function(e, i, o) {
  118862. var s = this;
  118863. return GLTFLoader.LoadExtensionAsync(e, i, this.name, function(c, d) {
  118864. var _ = new Array;
  118865. return _.push(s._loader.loadMaterialBasePropertiesAsync(e, i, o)),
  118866. _.push(s._loader.loadMaterialPropertiesAsync(e, i, o)),
  118867. _.push(s._loadVolumePropertiesAsync(c, i, o, d)),
  118868. Promise.all(_).then(function() {})
  118869. })
  118870. }
  118871. ,
  118872. a.prototype._loadVolumePropertiesAsync = function(e, i, o, s) {
  118873. if (!(o instanceof PBRMaterial))
  118874. throw new Error(e + ": Material type not supported");
  118875. if (!o.subSurface.isRefractionEnabled && !o.subSurface.isTranslucencyEnabled || !s.thicknessFactor)
  118876. return Promise.resolve();
  118877. o.subSurface.volumeIndexOfRefraction = o.indexOfRefraction;
  118878. var c = s.attenuationDistance !== void 0 ? s.attenuationDistance : Number.MAX_VALUE;
  118879. return o.subSurface.tintColorAtDistance = c,
  118880. s.attenuationColor !== void 0 && s.attenuationColor.length == 3 && o.subSurface.tintColor.copyFromFloats(s.attenuationColor[0], s.attenuationColor[1], s.attenuationColor[2]),
  118881. o.subSurface.minimumThickness = 0,
  118882. o.subSurface.maximumThickness = s.thicknessFactor,
  118883. o.subSurface.useThicknessAsDepth = !0,
  118884. s.thicknessTexture ? (s.thicknessTexture.nonColorData = !0,
  118885. this._loader.loadTextureInfoAsync(e + "/thicknessTexture", s.thicknessTexture).then(function(d) {
  118886. o.subSurface.thicknessTexture = d,
  118887. o.subSurface.useGltfStyleTextures = !0
  118888. })) : Promise.resolve()
  118889. }
  118890. ,
  118891. a
  118892. }();
  118893. GLTFLoader.RegisterExtension(NAME$e, function(a) {
  118894. return new KHR_materials_volume(a)
  118895. });
  118896. var NAME$d = "KHR_mesh_quantization"
  118897. , KHR_mesh_quantization = function() {
  118898. function a(e) {
  118899. this.name = NAME$d,
  118900. this.enabled = e.isExtensionUsed(NAME$d)
  118901. }
  118902. return a.prototype.dispose = function() {}
  118903. ,
  118904. a
  118905. }();
  118906. GLTFLoader.RegisterExtension(NAME$d, function(a) {
  118907. return new KHR_mesh_quantization(a)
  118908. });
  118909. var NAME$c = "KHR_texture_basisu"
  118910. , KHR_texture_basisu = function() {
  118911. function a(e) {
  118912. this.name = NAME$c,
  118913. this._loader = e,
  118914. this.enabled = e.isExtensionUsed(NAME$c)
  118915. }
  118916. return a.prototype.dispose = function() {
  118917. this._loader = null
  118918. }
  118919. ,
  118920. a.prototype._loadTextureAsync = function(e, i, o) {
  118921. var s = this;
  118922. return GLTFLoader.LoadExtensionAsync(e, i, this.name, function(c, d) {
  118923. var _ = i.sampler == null ? GLTFLoader.DefaultSampler : ArrayItem.Get(e + "/sampler", s._loader.gltf.samplers, i.sampler)
  118924. , b = ArrayItem.Get(c + "/source", s._loader.gltf.images, d.source);
  118925. return s._loader._createTextureAsync(e, _, b, function(k) {
  118926. o(k)
  118927. }, i._textureInfo.nonColorData ? {
  118928. useRGBAIfASTCBC7NotAvailableWhenUASTC: !0
  118929. } : void 0, !i._textureInfo.nonColorData)
  118930. })
  118931. }
  118932. ,
  118933. a
  118934. }();
  118935. GLTFLoader.RegisterExtension(NAME$c, function(a) {
  118936. return new KHR_texture_basisu(a)
  118937. });
  118938. var NAME$b = "KHR_texture_transform"
  118939. , KHR_texture_transform$1 = function() {
  118940. function a(e) {
  118941. this.name = NAME$b,
  118942. this._loader = e,
  118943. this.enabled = this._loader.isExtensionUsed(NAME$b)
  118944. }
  118945. return a.prototype.dispose = function() {
  118946. this._loader = null
  118947. }
  118948. ,
  118949. a.prototype.loadTextureInfoAsync = function(e, i, o) {
  118950. var s = this;
  118951. return GLTFLoader.LoadExtensionAsync(e, i, this.name, function(c, d) {
  118952. return s._loader.loadTextureInfoAsync(e, i, function(_) {
  118953. if (!(_ instanceof Texture))
  118954. throw new Error(c + ": Texture type not supported");
  118955. d.offset && (_.uOffset = d.offset[0],
  118956. _.vOffset = d.offset[1]),
  118957. _.uRotationCenter = 0,
  118958. _.vRotationCenter = 0,
  118959. d.rotation && (_.wAng = -d.rotation),
  118960. d.scale && (_.uScale = d.scale[0],
  118961. _.vScale = d.scale[1]),
  118962. d.texCoord != null && (_.coordinatesIndex = d.texCoord),
  118963. o(_)
  118964. })
  118965. })
  118966. }
  118967. ,
  118968. a
  118969. }();
  118970. GLTFLoader.RegisterExtension(NAME$b, function(a) {
  118971. return new KHR_texture_transform$1(a)
  118972. });
  118973. var NAME$a = "KHR_xmp_json_ld"
  118974. , KHR_xmp_json_ld = function() {
  118975. function a(e) {
  118976. this.name = NAME$a,
  118977. this.order = 100,
  118978. this._loader = e,
  118979. this.enabled = this._loader.isExtensionUsed(NAME$a)
  118980. }
  118981. return a.prototype.dispose = function() {
  118982. this._loader = null
  118983. }
  118984. ,
  118985. a.prototype.onLoading = function() {
  118986. var e, i, o;
  118987. if (this._loader.rootBabylonMesh !== null) {
  118988. var s = (e = this._loader.gltf.extensions) === null || e === void 0 ? void 0 : e.KHR_xmp_json_ld
  118989. , c = (o = (i = this._loader.gltf.asset) === null || i === void 0 ? void 0 : i.extensions) === null || o === void 0 ? void 0 : o.KHR_xmp_json_ld;
  118990. if (s && c) {
  118991. var d = +c.packet;
  118992. s.packets && d < s.packets.length && (this._loader.rootBabylonMesh.metadata = this._loader.rootBabylonMesh.metadata || {},
  118993. this._loader.rootBabylonMesh.metadata.xmp = s.packets[d])
  118994. }
  118995. }
  118996. }
  118997. ,
  118998. a
  118999. }();
  119000. GLTFLoader.RegisterExtension(NAME$a, function(a) {
  119001. return new KHR_xmp_json_ld(a)
  119002. });
  119003. var AnimationEvent = function() {
  119004. function a(e, i, o) {
  119005. this.frame = e,
  119006. this.action = i,
  119007. this.onlyOnce = o,
  119008. this.isDone = !1
  119009. }
  119010. return a.prototype._clone = function() {
  119011. return new a(this.frame,this.action,this.onlyOnce)
  119012. }
  119013. ,
  119014. a
  119015. }()
  119016. , WeightedSound = function() {
  119017. function a(e, i, o) {
  119018. var s = this;
  119019. if (this.loop = !1,
  119020. this._coneInnerAngle = 360,
  119021. this._coneOuterAngle = 360,
  119022. this._volume = 1,
  119023. this.isPlaying = !1,
  119024. this.isPaused = !1,
  119025. this._sounds = [],
  119026. this._weights = [],
  119027. i.length !== o.length)
  119028. throw new Error("Sounds length does not equal weights length");
  119029. this.loop = e,
  119030. this._weights = o;
  119031. for (var c = 0, d = 0, _ = o; d < _.length; d++) {
  119032. var b = _[d];
  119033. c += b
  119034. }
  119035. for (var k = c > 0 ? 1 / c : 0, j = 0; j < this._weights.length; j++)
  119036. this._weights[j] *= k;
  119037. this._sounds = i;
  119038. for (var $ = 0, _e = this._sounds; $ < _e.length; $++) {
  119039. var et = _e[$];
  119040. et.onEndedObservable.add(function() {
  119041. s._onended()
  119042. })
  119043. }
  119044. }
  119045. return Object.defineProperty(a.prototype, "directionalConeInnerAngle", {
  119046. get: function() {
  119047. return this._coneInnerAngle
  119048. },
  119049. set: function(e) {
  119050. if (e !== this._coneInnerAngle) {
  119051. if (this._coneOuterAngle < e) {
  119052. Logger$2.Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
  119053. return
  119054. }
  119055. this._coneInnerAngle = e;
  119056. for (var i = 0, o = this._sounds; i < o.length; i++) {
  119057. var s = o[i];
  119058. s.directionalConeInnerAngle = e
  119059. }
  119060. }
  119061. },
  119062. enumerable: !1,
  119063. configurable: !0
  119064. }),
  119065. Object.defineProperty(a.prototype, "directionalConeOuterAngle", {
  119066. get: function() {
  119067. return this._coneOuterAngle
  119068. },
  119069. set: function(e) {
  119070. if (e !== this._coneOuterAngle) {
  119071. if (e < this._coneInnerAngle) {
  119072. Logger$2.Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
  119073. return
  119074. }
  119075. this._coneOuterAngle = e;
  119076. for (var i = 0, o = this._sounds; i < o.length; i++) {
  119077. var s = o[i];
  119078. s.directionalConeOuterAngle = e
  119079. }
  119080. }
  119081. },
  119082. enumerable: !1,
  119083. configurable: !0
  119084. }),
  119085. Object.defineProperty(a.prototype, "volume", {
  119086. get: function() {
  119087. return this._volume
  119088. },
  119089. set: function(e) {
  119090. if (e !== this._volume)
  119091. for (var i = 0, o = this._sounds; i < o.length; i++) {
  119092. var s = o[i];
  119093. s.setVolume(e)
  119094. }
  119095. },
  119096. enumerable: !1,
  119097. configurable: !0
  119098. }),
  119099. a.prototype._onended = function() {
  119100. this._currentIndex !== void 0 && (this._sounds[this._currentIndex].autoplay = !1),
  119101. this.loop && this.isPlaying ? this.play() : this.isPlaying = !1
  119102. }
  119103. ,
  119104. a.prototype.pause = function() {
  119105. this.isPaused = !0,
  119106. this._currentIndex !== void 0 && this._sounds[this._currentIndex].pause()
  119107. }
  119108. ,
  119109. a.prototype.stop = function() {
  119110. this.isPlaying = !1,
  119111. this._currentIndex !== void 0 && this._sounds[this._currentIndex].stop()
  119112. }
  119113. ,
  119114. a.prototype.play = function(e) {
  119115. if (!this.isPaused) {
  119116. this.stop();
  119117. for (var i = Math.random(), o = 0, s = 0; s < this._weights.length; s++)
  119118. if (o += this._weights[s],
  119119. i <= o) {
  119120. this._currentIndex = s;
  119121. break
  119122. }
  119123. }
  119124. var c = this._sounds[this._currentIndex];
  119125. c.isReady() ? c.play(0, this.isPaused ? void 0 : e) : c.autoplay = !0,
  119126. this.isPlaying = !0,
  119127. this.isPaused = !1
  119128. }
  119129. ,
  119130. a
  119131. }()
  119132. , NAME$9 = "MSFT_audio_emitter"
  119133. , MSFT_audio_emitter = function() {
  119134. function a(e) {
  119135. this.name = NAME$9,
  119136. this._loader = e,
  119137. this.enabled = this._loader.isExtensionUsed(NAME$9)
  119138. }
  119139. return a.prototype.dispose = function() {
  119140. this._loader = null,
  119141. this._clips = null,
  119142. this._emitters = null
  119143. }
  119144. ,
  119145. a.prototype.onLoading = function() {
  119146. var e = this._loader.gltf.extensions;
  119147. if (e && e[this.name]) {
  119148. var i = e[this.name];
  119149. this._clips = i.clips,
  119150. this._emitters = i.emitters,
  119151. ArrayItem.Assign(this._clips),
  119152. ArrayItem.Assign(this._emitters)
  119153. }
  119154. }
  119155. ,
  119156. a.prototype.loadSceneAsync = function(e, i) {
  119157. var o = this;
  119158. return GLTFLoader.LoadExtensionAsync(e, i, this.name, function(s, c) {
  119159. var d = new Array;
  119160. d.push(o._loader.loadSceneAsync(e, i));
  119161. for (var _ = 0, b = c.emitters; _ < b.length; _++) {
  119162. var k = b[_]
  119163. , j = ArrayItem.Get(s + "/emitters", o._emitters, k);
  119164. if (j.refDistance != null || j.maxDistance != null || j.rolloffFactor != null || j.distanceModel != null || j.innerAngle != null || j.outerAngle != null)
  119165. throw new Error(s + ": Direction or Distance properties are not allowed on emitters attached to a scene");
  119166. d.push(o._loadEmitterAsync(s + "/emitters/" + j.index, j))
  119167. }
  119168. return Promise.all(d).then(function() {})
  119169. })
  119170. }
  119171. ,
  119172. a.prototype.loadNodeAsync = function(e, i, o) {
  119173. var s = this;
  119174. return GLTFLoader.LoadExtensionAsync(e, i, this.name, function(c, d) {
  119175. var _ = new Array;
  119176. return s._loader.loadNodeAsync(c, i, function(b) {
  119177. for (var k = function(et) {
  119178. var tt = ArrayItem.Get(c + "/emitters", s._emitters, et);
  119179. _.push(s._loadEmitterAsync(c + "/emitters/" + tt.index, tt).then(function() {
  119180. for (var rt = 0, it = tt._babylonSounds; rt < it.length; rt++) {
  119181. var nt = it[rt];
  119182. nt.attachToMesh(b),
  119183. (tt.innerAngle != null || tt.outerAngle != null) && (nt.setLocalDirectionToMesh(Vector3.Forward()),
  119184. nt.setDirectionalCone(2 * Tools.ToDegrees(tt.innerAngle == null ? Math.PI : tt.innerAngle), 2 * Tools.ToDegrees(tt.outerAngle == null ? Math.PI : tt.outerAngle), 0))
  119185. }
  119186. }))
  119187. }, j = 0, $ = d.emitters; j < $.length; j++) {
  119188. var _e = $[j];
  119189. k(_e)
  119190. }
  119191. o(b)
  119192. }).then(function(b) {
  119193. return Promise.all(_).then(function() {
  119194. return b
  119195. })
  119196. })
  119197. })
  119198. }
  119199. ,
  119200. a.prototype.loadAnimationAsync = function(e, i) {
  119201. var o = this;
  119202. return GLTFLoader.LoadExtensionAsync(e, i, this.name, function(s, c) {
  119203. return o._loader.loadAnimationAsync(e, i).then(function(d) {
  119204. var _ = new Array;
  119205. ArrayItem.Assign(c.events);
  119206. for (var b = 0, k = c.events; b < k.length; b++) {
  119207. var j = k[b];
  119208. _.push(o._loadAnimationEventAsync(s + "/events/" + j.index, e, i, j, d))
  119209. }
  119210. return Promise.all(_).then(function() {
  119211. return d
  119212. })
  119213. })
  119214. })
  119215. }
  119216. ,
  119217. a.prototype._loadClipAsync = function(e, i) {
  119218. if (i._objectURL)
  119219. return i._objectURL;
  119220. var o;
  119221. if (i.uri)
  119222. o = this._loader.loadUriAsync(e, i, i.uri);
  119223. else {
  119224. var s = ArrayItem.Get(e + "/bufferView", this._loader.gltf.bufferViews, i.bufferView);
  119225. o = this._loader.loadBufferViewAsync("/bufferViews/" + s.index, s)
  119226. }
  119227. return i._objectURL = o.then(function(c) {
  119228. return URL.createObjectURL(new Blob([c],{
  119229. type: i.mimeType
  119230. }))
  119231. }),
  119232. i._objectURL
  119233. }
  119234. ,
  119235. a.prototype._loadEmitterAsync = function(e, i) {
  119236. var o = this;
  119237. if (i._babylonSounds = i._babylonSounds || [],
  119238. !i._babylonData) {
  119239. for (var s = new Array, c = i.name || "emitter" + i.index, d = {
  119240. loop: !1,
  119241. autoplay: !1,
  119242. volume: i.volume == null ? 1 : i.volume
  119243. }, _ = function($) {
  119244. var _e = "/extensions/" + b.name + "/clips"
  119245. , et = ArrayItem.Get(_e, b._clips, i.clips[$].clip);
  119246. s.push(b._loadClipAsync(_e + "/" + i.clips[$].clip, et).then(function(tt) {
  119247. var rt = i._babylonSounds[$] = new Sound(c,tt,o._loader.babylonScene,null,d);
  119248. rt.refDistance = i.refDistance || 1,
  119249. rt.maxDistance = i.maxDistance || 256,
  119250. rt.rolloffFactor = i.rolloffFactor || 1,
  119251. rt.distanceModel = i.distanceModel || "exponential"
  119252. }))
  119253. }, b = this, k = 0; k < i.clips.length; k++)
  119254. _(k);
  119255. var j = Promise.all(s).then(function() {
  119256. var $ = i.clips.map(function(et) {
  119257. return et.weight || 1
  119258. })
  119259. , _e = new WeightedSound(i.loop || !1,i._babylonSounds,$);
  119260. i.innerAngle && (_e.directionalConeInnerAngle = 2 * Tools.ToDegrees(i.innerAngle)),
  119261. i.outerAngle && (_e.directionalConeOuterAngle = 2 * Tools.ToDegrees(i.outerAngle)),
  119262. i.volume && (_e.volume = i.volume),
  119263. i._babylonData.sound = _e
  119264. });
  119265. i._babylonData = {
  119266. loaded: j
  119267. }
  119268. }
  119269. return i._babylonData.loaded
  119270. }
  119271. ,
  119272. a.prototype._getEventAction = function(e, i, o, s, c) {
  119273. switch (o) {
  119274. case "play":
  119275. return function(d) {
  119276. var _ = (c || 0) + (d - s);
  119277. i.play(_)
  119278. }
  119279. ;
  119280. case "stop":
  119281. return function(d) {
  119282. i.stop()
  119283. }
  119284. ;
  119285. case "pause":
  119286. return function(d) {
  119287. i.pause()
  119288. }
  119289. ;
  119290. default:
  119291. throw new Error(e + ": Unsupported action " + o)
  119292. }
  119293. }
  119294. ,
  119295. a.prototype._loadAnimationEventAsync = function(e, i, o, s, c) {
  119296. var d = this;
  119297. if (c.targetedAnimations.length == 0)
  119298. return Promise.resolve();
  119299. var _ = c.targetedAnimations[0]
  119300. , b = s.emitter
  119301. , k = ArrayItem.Get("/extensions/" + this.name + "/emitters", this._emitters, b);
  119302. return this._loadEmitterAsync(e, k).then(function() {
  119303. var j = k._babylonData.sound;
  119304. if (j) {
  119305. var $ = new AnimationEvent(s.time,d._getEventAction(e, j, s.action, s.time, s.startOffset));
  119306. _.animation.addEvent($),
  119307. c.onAnimationGroupEndObservable.add(function() {
  119308. j.stop()
  119309. }),
  119310. c.onAnimationGroupPauseObservable.add(function() {
  119311. j.pause()
  119312. })
  119313. }
  119314. })
  119315. }
  119316. ,
  119317. a
  119318. }();
  119319. GLTFLoader.RegisterExtension(NAME$9, function(a) {
  119320. return new MSFT_audio_emitter(a)
  119321. });
  119322. var NAME$8 = "MSFT_lod"
  119323. , MSFT_lod = function() {
  119324. function a(e) {
  119325. this.name = NAME$8,
  119326. this.order = 100,
  119327. this.maxLODsToLoad = 10,
  119328. this.onNodeLODsLoadedObservable = new Observable,
  119329. this.onMaterialLODsLoadedObservable = new Observable,
  119330. this._bufferLODs = new Array,
  119331. this._nodeIndexLOD = null,
  119332. this._nodeSignalLODs = new Array,
  119333. this._nodePromiseLODs = new Array,
  119334. this._nodeBufferLODs = new Array,
  119335. this._materialIndexLOD = null,
  119336. this._materialSignalLODs = new Array,
  119337. this._materialPromiseLODs = new Array,
  119338. this._materialBufferLODs = new Array,
  119339. this._loader = e,
  119340. this.enabled = this._loader.isExtensionUsed(NAME$8)
  119341. }
  119342. return a.prototype.dispose = function() {
  119343. this._loader = null,
  119344. this._nodeIndexLOD = null,
  119345. this._nodeSignalLODs.length = 0,
  119346. this._nodePromiseLODs.length = 0,
  119347. this._nodeBufferLODs.length = 0,
  119348. this._materialIndexLOD = null,
  119349. this._materialSignalLODs.length = 0,
  119350. this._materialPromiseLODs.length = 0,
  119351. this._materialBufferLODs.length = 0,
  119352. this.onMaterialLODsLoadedObservable.clear(),
  119353. this.onNodeLODsLoadedObservable.clear()
  119354. }
  119355. ,
  119356. a.prototype.onReady = function() {
  119357. for (var e = this, i = function(_) {
  119358. var b = Promise.all(o._nodePromiseLODs[_]).then(function() {
  119359. _ !== 0 && (e._loader.endPerformanceCounter("Node LOD " + _),
  119360. e._loader.log("Loaded node LOD " + _)),
  119361. e.onNodeLODsLoadedObservable.notifyObservers(_),
  119362. _ !== e._nodePromiseLODs.length - 1 && (e._loader.startPerformanceCounter("Node LOD " + (_ + 1)),
  119363. e._loadBufferLOD(e._nodeBufferLODs, _ + 1),
  119364. e._nodeSignalLODs[_] && e._nodeSignalLODs[_].resolve())
  119365. });
  119366. o._loader._completePromises.push(b)
  119367. }, o = this, s = 0; s < this._nodePromiseLODs.length; s++)
  119368. i(s);
  119369. for (var c = function(_) {
  119370. var b = Promise.all(d._materialPromiseLODs[_]).then(function() {
  119371. _ !== 0 && (e._loader.endPerformanceCounter("Material LOD " + _),
  119372. e._loader.log("Loaded material LOD " + _)),
  119373. e.onMaterialLODsLoadedObservable.notifyObservers(_),
  119374. _ !== e._materialPromiseLODs.length - 1 && (e._loader.startPerformanceCounter("Material LOD " + (_ + 1)),
  119375. e._loadBufferLOD(e._materialBufferLODs, _ + 1),
  119376. e._materialSignalLODs[_] && e._materialSignalLODs[_].resolve())
  119377. });
  119378. d._loader._completePromises.push(b)
  119379. }, d = this, s = 0; s < this._materialPromiseLODs.length; s++)
  119380. c(s)
  119381. }
  119382. ,
  119383. a.prototype.loadSceneAsync = function(e, i) {
  119384. var o = this._loader.loadSceneAsync(e, i);
  119385. return this._loadBufferLOD(this._bufferLODs, 0),
  119386. o
  119387. }
  119388. ,
  119389. a.prototype.loadNodeAsync = function(e, i, o) {
  119390. var s = this;
  119391. return GLTFLoader.LoadExtensionAsync(e, i, this.name, function(c, d) {
  119392. var _, b = s._getLODs(c, i, s._loader.gltf.nodes, d.ids);
  119393. s._loader.logOpen("" + c);
  119394. for (var k = [], j = 0; j < b.length; j++)
  119395. k.push(null);
  119396. for (var $ = function(_e) {
  119397. var et = b[_e];
  119398. _e !== 0 && (s._nodeIndexLOD = _e,
  119399. s._nodeSignalLODs[_e] = s._nodeSignalLODs[_e] || new Deferred);
  119400. var tt = function(it, nt) {
  119401. var ot, at, st;
  119402. it.setEnabled(!1),
  119403. k[nt] = it;
  119404. for (var ut = !0, ct = 0; ct < k.length; ct++)
  119405. k[ct] || (ut = !1);
  119406. var lt = k[k.length - 1];
  119407. if (ut && lt && s._isMesh(lt)) {
  119408. var ft = (st = (at = (ot = lt.metadata) === null || ot === void 0 ? void 0 : ot.gltf) === null || at === void 0 ? void 0 : at.extras) === null || st === void 0 ? void 0 : st.MSFT_screencoverage;
  119409. if (ft && ft.length) {
  119410. ft.reverse(),
  119411. lt.useLODScreenCoverage = !0;
  119412. for (var ct = 0; ct < k.length - 1; ct++) {
  119413. var ht = k[ct];
  119414. ht && s._isMesh(ht) && lt.addLODLevel(ft[ct + 1], ht)
  119415. }
  119416. ft[0] > 0 && lt.addLODLevel(ft[0], null)
  119417. }
  119418. }
  119419. }
  119420. , rt = s._loader.loadNodeAsync("/nodes/" + et.index, et, function(it) {
  119421. return tt(it, _e)
  119422. }).then(function(it) {
  119423. var nt, ot, at, st = (at = (ot = (nt = b[b.length - 1]._babylonTransformNode.metadata) === null || nt === void 0 ? void 0 : nt.gltf) === null || ot === void 0 ? void 0 : ot.extras) === null || at === void 0 ? void 0 : at.MSFT_screencoverage;
  119424. if (_e !== 0 && !st) {
  119425. var ut = b[_e - 1];
  119426. ut._babylonTransformNode && (s._disposeTransformNode(ut._babylonTransformNode),
  119427. delete ut._babylonTransformNode)
  119428. }
  119429. return o(it),
  119430. it.setEnabled(!0),
  119431. it
  119432. });
  119433. s._nodePromiseLODs[_e] = s._nodePromiseLODs[_e] || [],
  119434. _e === 0 ? _ = rt : (s._nodeIndexLOD = null,
  119435. s._nodePromiseLODs[_e].push(rt))
  119436. }, j = 0; j < b.length; j++)
  119437. $(j);
  119438. return s._loader.logClose(),
  119439. _
  119440. })
  119441. }
  119442. ,
  119443. a.prototype._loadMaterialAsync = function(e, i, o, s, c) {
  119444. var d = this;
  119445. return this._nodeIndexLOD ? null : GLTFLoader.LoadExtensionAsync(e, i, this.name, function(_, b) {
  119446. var k, j = d._getLODs(_, i, d._loader.gltf.materials, b.ids);
  119447. d._loader.logOpen("" + _);
  119448. for (var $ = function(et) {
  119449. var tt = j[et];
  119450. et !== 0 && (d._materialIndexLOD = et);
  119451. var rt = d._loader._loadMaterialAsync("/materials/" + tt.index, tt, o, s, function(it) {
  119452. et === 0 && c(it)
  119453. }).then(function(it) {
  119454. if (et !== 0) {
  119455. c(it);
  119456. var nt = j[et - 1]._data;
  119457. nt[s] && (d._disposeMaterials([nt[s].babylonMaterial]),
  119458. delete nt[s])
  119459. }
  119460. return it
  119461. });
  119462. d._materialPromiseLODs[et] = d._materialPromiseLODs[et] || [],
  119463. et === 0 ? k = rt : (d._materialIndexLOD = null,
  119464. d._materialPromiseLODs[et].push(rt))
  119465. }, _e = 0; _e < j.length; _e++)
  119466. $(_e);
  119467. return d._loader.logClose(),
  119468. k
  119469. })
  119470. }
  119471. ,
  119472. a.prototype._loadUriAsync = function(e, i, o) {
  119473. var s = this;
  119474. if (this._nodeIndexLOD !== null) {
  119475. this._loader.log("deferred");
  119476. var c = this._nodeIndexLOD - 1;
  119477. return this._nodeSignalLODs[c] = this._nodeSignalLODs[c] || new Deferred,
  119478. this._nodeSignalLODs[this._nodeIndexLOD - 1].promise.then(function() {
  119479. return s._loader.loadUriAsync(e, i, o)
  119480. })
  119481. } else if (this._materialIndexLOD !== null) {
  119482. this._loader.log("deferred");
  119483. var c = this._materialIndexLOD - 1;
  119484. return this._materialSignalLODs[c] = this._materialSignalLODs[c] || new Deferred,
  119485. this._materialSignalLODs[c].promise.then(function() {
  119486. return s._loader.loadUriAsync(e, i, o)
  119487. })
  119488. }
  119489. return null
  119490. }
  119491. ,
  119492. a.prototype.loadBufferAsync = function(e, i, o, s) {
  119493. if (this._loader.parent.useRangeRequests && !i.uri) {
  119494. if (!this._loader.bin)
  119495. throw new Error(e + ": Uri is missing or the binary glTF is missing its binary chunk");
  119496. var c = function(d, _) {
  119497. var b = o
  119498. , k = b + s - 1
  119499. , j = d[_];
  119500. return j ? (j.start = Math.min(j.start, b),
  119501. j.end = Math.max(j.end, k)) : (j = {
  119502. start: b,
  119503. end: k,
  119504. loaded: new Deferred
  119505. },
  119506. d[_] = j),
  119507. j.loaded.promise.then(function($) {
  119508. return new Uint8Array($.buffer,$.byteOffset + o - j.start,s)
  119509. })
  119510. };
  119511. return this._loader.log("deferred"),
  119512. this._nodeIndexLOD !== null ? c(this._nodeBufferLODs, this._nodeIndexLOD) : this._materialIndexLOD !== null ? c(this._materialBufferLODs, this._materialIndexLOD) : c(this._bufferLODs, 0)
  119513. }
  119514. return null
  119515. }
  119516. ,
  119517. a.prototype._isMesh = function(e) {
  119518. return !!e.addLODLevel
  119519. }
  119520. ,
  119521. a.prototype._loadBufferLOD = function(e, i) {
  119522. var o = e[i];
  119523. o && (this._loader.log("Loading buffer range [" + o.start + "-" + o.end + "]"),
  119524. this._loader.bin.readAsync(o.start, o.end - o.start + 1).then(function(s) {
  119525. o.loaded.resolve(s)
  119526. }, function(s) {
  119527. o.loaded.reject(s)
  119528. }))
  119529. }
  119530. ,
  119531. a.prototype._getLODs = function(e, i, o, s) {
  119532. if (this.maxLODsToLoad <= 0)
  119533. throw new Error("maxLODsToLoad must be greater than zero");
  119534. for (var c = new Array, d = s.length - 1; d >= 0; d--)
  119535. if (c.push(ArrayItem.Get(e + "/ids/" + s[d], o, s[d])),
  119536. c.length === this.maxLODsToLoad)
  119537. return c;
  119538. return c.push(i),
  119539. c
  119540. }
  119541. ,
  119542. a.prototype._disposeTransformNode = function(e) {
  119543. var i = this
  119544. , o = new Array
  119545. , s = e.material;
  119546. s && o.push(s);
  119547. for (var c = 0, d = e.getChildMeshes(); c < d.length; c++) {
  119548. var _ = d[c];
  119549. _.material && o.push(_.material)
  119550. }
  119551. e.dispose();
  119552. var b = o.filter(function(k) {
  119553. return i._loader.babylonScene.meshes.every(function(j) {
  119554. return j.material != k
  119555. })
  119556. });
  119557. this._disposeMaterials(b)
  119558. }
  119559. ,
  119560. a.prototype._disposeMaterials = function(e) {
  119561. for (var i = {}, o = 0, s = e; o < s.length; o++) {
  119562. for (var c = s[o], d = 0, _ = c.getActiveTextures(); d < _.length; d++) {
  119563. var b = _[d];
  119564. i[b.uniqueId] = b
  119565. }
  119566. c.dispose()
  119567. }
  119568. for (var k in i)
  119569. for (var j = 0, $ = this._loader.babylonScene.materials; j < $.length; j++) {
  119570. var c = $[j];
  119571. c.hasTexture(i[k]) && delete i[k]
  119572. }
  119573. for (var k in i)
  119574. i[k].dispose()
  119575. }
  119576. ,
  119577. a
  119578. }();
  119579. GLTFLoader.RegisterExtension(NAME$8, function(a) {
  119580. return new MSFT_lod(a)
  119581. });
  119582. var NAME$7 = "MSFT_minecraftMesh"
  119583. , MSFT_minecraftMesh = function() {
  119584. function a(e) {
  119585. this.name = NAME$7,
  119586. this._loader = e,
  119587. this.enabled = this._loader.isExtensionUsed(NAME$7)
  119588. }
  119589. return a.prototype.dispose = function() {
  119590. this._loader = null
  119591. }
  119592. ,
  119593. a.prototype.loadMaterialPropertiesAsync = function(e, i, o) {
  119594. var s = this;
  119595. return GLTFLoader.LoadExtraAsync(e, i, this.name, function(c, d) {
  119596. if (d) {
  119597. if (!(o instanceof PBRMaterial))
  119598. throw new Error(c + ": Material type not supported");
  119599. var _ = s._loader.loadMaterialPropertiesAsync(e, i, o);
  119600. return o.needAlphaBlending() && (o.forceDepthWrite = !0,
  119601. o.separateCullingPass = !0),
  119602. o.backFaceCulling = o.forceDepthWrite,
  119603. o.twoSidedLighting = !0,
  119604. _
  119605. }
  119606. return null
  119607. })
  119608. }
  119609. ,
  119610. a
  119611. }();
  119612. GLTFLoader.RegisterExtension(NAME$7, function(a) {
  119613. return new MSFT_minecraftMesh(a)
  119614. });
  119615. var NAME$6 = "MSFT_sRGBFactors"
  119616. , MSFT_sRGBFactors = function() {
  119617. function a(e) {
  119618. this.name = NAME$6,
  119619. this._loader = e,
  119620. this.enabled = this._loader.isExtensionUsed(NAME$6)
  119621. }
  119622. return a.prototype.dispose = function() {
  119623. this._loader = null
  119624. }
  119625. ,
  119626. a.prototype.loadMaterialPropertiesAsync = function(e, i, o) {
  119627. var s = this;
  119628. return GLTFLoader.LoadExtraAsync(e, i, this.name, function(c, d) {
  119629. if (d) {
  119630. if (!(o instanceof PBRMaterial))
  119631. throw new Error(c + ": Material type not supported");
  119632. var _ = s._loader.loadMaterialPropertiesAsync(e, i, o);
  119633. return o.albedoTexture || o.albedoColor.toLinearSpaceToRef(o.albedoColor),
  119634. o.reflectivityTexture || o.reflectivityColor.toLinearSpaceToRef(o.reflectivityColor),
  119635. _
  119636. }
  119637. return null
  119638. })
  119639. }
  119640. ,
  119641. a
  119642. }();
  119643. GLTFLoader.RegisterExtension(NAME$6, function(a) {
  119644. return new MSFT_sRGBFactors(a)
  119645. });
  119646. var NAME$5 = "ExtrasAsMetadata"
  119647. , ExtrasAsMetadata = function() {
  119648. function a(e) {
  119649. this.name = NAME$5,
  119650. this.enabled = !0,
  119651. this._loader = e
  119652. }
  119653. return a.prototype._assignExtras = function(e, i) {
  119654. if (i.extras && Object.keys(i.extras).length > 0) {
  119655. var o = e.metadata = e.metadata || {}
  119656. , s = o.gltf = o.gltf || {};
  119657. s.extras = i.extras
  119658. }
  119659. }
  119660. ,
  119661. a.prototype.dispose = function() {
  119662. this._loader = null
  119663. }
  119664. ,
  119665. a.prototype.loadNodeAsync = function(e, i, o) {
  119666. var s = this;
  119667. return this._loader.loadNodeAsync(e, i, function(c) {
  119668. s._assignExtras(c, i),
  119669. o(c)
  119670. })
  119671. }
  119672. ,
  119673. a.prototype.loadCameraAsync = function(e, i, o) {
  119674. var s = this;
  119675. return this._loader.loadCameraAsync(e, i, function(c) {
  119676. s._assignExtras(c, i),
  119677. o(c)
  119678. })
  119679. }
  119680. ,
  119681. a.prototype.createMaterial = function(e, i, o) {
  119682. var s = this._loader.createMaterial(e, i, o);
  119683. return this._assignExtras(s, i),
  119684. s
  119685. }
  119686. ,
  119687. a
  119688. }();
  119689. GLTFLoader.RegisterExtension(NAME$5, function(a) {
  119690. return new ExtrasAsMetadata(a)
  119691. });
  119692. var MTLFileLoader = function() {
  119693. function a() {
  119694. this.materials = []
  119695. }
  119696. return a.prototype.parseMTL = function(e, i, o, s) {
  119697. if (!(i instanceof ArrayBuffer)) {
  119698. for (var c = i.split(`
  119699. `), d = /\s+/, _, b = null, k = 0; k < c.length; k++) {
  119700. var j = c[k].trim();
  119701. if (!(j.length === 0 || j.charAt(0) === "#")) {
  119702. var $ = j.indexOf(" ")
  119703. , _e = $ >= 0 ? j.substring(0, $) : j;
  119704. _e = _e.toLowerCase();
  119705. var et = $ >= 0 ? j.substring($ + 1).trim() : "";
  119706. _e === "newmtl" ? (b && this.materials.push(b),
  119707. e._blockEntityCollection = !!s,
  119708. b = new StandardMaterial(et,e),
  119709. b._parentContainer = s,
  119710. e._blockEntityCollection = !1) : _e === "kd" && b ? (_ = et.split(d, 3).map(parseFloat),
  119711. b.diffuseColor = Color3.FromArray(_)) : _e === "ka" && b ? (_ = et.split(d, 3).map(parseFloat),
  119712. b.ambientColor = Color3.FromArray(_)) : _e === "ks" && b ? (_ = et.split(d, 3).map(parseFloat),
  119713. b.specularColor = Color3.FromArray(_)) : _e === "ke" && b ? (_ = et.split(d, 3).map(parseFloat),
  119714. b.emissiveColor = Color3.FromArray(_)) : _e === "ns" && b ? b.specularPower = parseFloat(et) : _e === "d" && b ? b.alpha = parseFloat(et) : _e === "map_ka" && b ? b.ambientTexture = a._getTexture(o, et, e) : _e === "map_kd" && b ? b.diffuseTexture = a._getTexture(o, et, e) : _e === "map_ks" && b ? b.specularTexture = a._getTexture(o, et, e) : _e === "map_ns" || (_e === "map_bump" && b ? b.bumpTexture = a._getTexture(o, et, e) : _e === "map_d" && b && (b.opacityTexture = a._getTexture(o, et, e)))
  119715. }
  119716. }
  119717. b && this.materials.push(b)
  119718. }
  119719. }
  119720. ,
  119721. a._getTexture = function(e, i, o) {
  119722. if (!i)
  119723. return null;
  119724. var s = e;
  119725. if (e === "file:") {
  119726. var c = i.lastIndexOf("\\");
  119727. c === -1 && (c = i.lastIndexOf("/")),
  119728. c > -1 ? s += i.substr(c + 1) : s += i
  119729. } else
  119730. s += i;
  119731. return new Texture(s,o,!1,a.INVERT_TEXTURE_Y)
  119732. }
  119733. ,
  119734. a.INVERT_TEXTURE_Y = !0,
  119735. a
  119736. }()
  119737. , SolidParser = function() {
  119738. function a(e, i, o) {
  119739. this._positions = [],
  119740. this._normals = [],
  119741. this._uvs = [],
  119742. this._colors = [],
  119743. this._meshesFromObj = [],
  119744. this._indicesForBabylon = [],
  119745. this._wrappedPositionForBabylon = [],
  119746. this._wrappedUvsForBabylon = [],
  119747. this._wrappedColorsForBabylon = [],
  119748. this._wrappedNormalsForBabylon = [],
  119749. this._tuplePosNorm = [],
  119750. this._curPositionInIndices = 0,
  119751. this._hasMeshes = !1,
  119752. this._unwrappedPositionsForBabylon = [],
  119753. this._unwrappedColorsForBabylon = [],
  119754. this._unwrappedNormalsForBabylon = [],
  119755. this._unwrappedUVForBabylon = [],
  119756. this._triangles = [],
  119757. this._materialNameFromObj = "",
  119758. this._objMeshName = "",
  119759. this._increment = 1,
  119760. this._isFirstMaterial = !0,
  119761. this._grayColor = new Color4(.5,.5,.5,1),
  119762. this._materialToUse = e,
  119763. this._babylonMeshesArray = i,
  119764. this._loadingOptions = o
  119765. }
  119766. return a.prototype._isInArray = function(e, i) {
  119767. e[i[0]] || (e[i[0]] = {
  119768. normals: [],
  119769. idx: []
  119770. });
  119771. var o = e[i[0]].normals.indexOf(i[1]);
  119772. return o === -1 ? -1 : e[i[0]].idx[o]
  119773. }
  119774. ,
  119775. a.prototype._isInArrayUV = function(e, i) {
  119776. e[i[0]] || (e[i[0]] = {
  119777. normals: [],
  119778. idx: [],
  119779. uv: []
  119780. });
  119781. var o = e[i[0]].normals.indexOf(i[1]);
  119782. return o != 1 && i[2] === e[i[0]].uv[o] ? e[i[0]].idx[o] : -1
  119783. }
  119784. ,
  119785. a.prototype._setData = function(e, i, o, s, c, d, _) {
  119786. var b;
  119787. this._loadingOptions.optimizeWithUV ? b = this._isInArrayUV(this._tuplePosNorm, [e, o, i]) : b = this._isInArray(this._tuplePosNorm, [e, o]),
  119788. b === -1 ? (this._indicesForBabylon.push(this._wrappedPositionForBabylon.length),
  119789. this._wrappedPositionForBabylon.push(s),
  119790. this._wrappedUvsForBabylon.push(c),
  119791. this._wrappedNormalsForBabylon.push(d),
  119792. _ !== void 0 && this._wrappedColorsForBabylon.push(_),
  119793. this._tuplePosNorm[e].normals.push(o),
  119794. this._tuplePosNorm[e].idx.push(this._curPositionInIndices++),
  119795. this._loadingOptions.optimizeWithUV && this._tuplePosNorm[e].uv.push(i)) : this._indicesForBabylon.push(b)
  119796. }
  119797. ,
  119798. a.prototype._unwrapData = function() {
  119799. for (var e = 0; e < this._wrappedPositionForBabylon.length; e++)
  119800. this._unwrappedPositionsForBabylon.push(this._wrappedPositionForBabylon[e].x, this._wrappedPositionForBabylon[e].y, this._wrappedPositionForBabylon[e].z),
  119801. this._unwrappedNormalsForBabylon.push(this._wrappedNormalsForBabylon[e].x, this._wrappedNormalsForBabylon[e].y, this._wrappedNormalsForBabylon[e].z),
  119802. this._unwrappedUVForBabylon.push(this._wrappedUvsForBabylon[e].x, this._wrappedUvsForBabylon[e].y),
  119803. this._loadingOptions.importVertexColors && this._unwrappedColorsForBabylon.push(this._wrappedColorsForBabylon[e].r, this._wrappedColorsForBabylon[e].g, this._wrappedColorsForBabylon[e].b, this._wrappedColorsForBabylon[e].a);
  119804. this._wrappedPositionForBabylon = [],
  119805. this._wrappedNormalsForBabylon = [],
  119806. this._wrappedUvsForBabylon = [],
  119807. this._wrappedColorsForBabylon = [],
  119808. this._tuplePosNorm = [],
  119809. this._curPositionInIndices = 0
  119810. }
  119811. ,
  119812. a.prototype._getTriangles = function(e, i) {
  119813. for (var o = i; o < e.length - 1; o++)
  119814. this._triangles.push(e[0], e[o], e[o + 1])
  119815. }
  119816. ,
  119817. a.prototype._setDataForCurrentFaceWithPattern1 = function(e, i) {
  119818. this._getTriangles(e, i);
  119819. for (var o = 0; o < this._triangles.length; o++) {
  119820. var s = parseInt(this._triangles[o]) - 1;
  119821. this._setData(s, 0, 0, this._positions[s], Vector2.Zero(), Vector3.Up(), this._loadingOptions.importVertexColors ? this._colors[s] : void 0)
  119822. }
  119823. this._triangles = []
  119824. }
  119825. ,
  119826. a.prototype._setDataForCurrentFaceWithPattern2 = function(e, i) {
  119827. this._getTriangles(e, i);
  119828. for (var o = 0; o < this._triangles.length; o++) {
  119829. var s = this._triangles[o].split("/")
  119830. , c = parseInt(s[0]) - 1
  119831. , d = parseInt(s[1]) - 1;
  119832. this._setData(c, d, 0, this._positions[c], this._uvs[d], Vector3.Up(), this._loadingOptions.importVertexColors ? this._colors[c] : void 0)
  119833. }
  119834. this._triangles = []
  119835. }
  119836. ,
  119837. a.prototype._setDataForCurrentFaceWithPattern3 = function(e, i) {
  119838. this._getTriangles(e, i);
  119839. for (var o = 0; o < this._triangles.length; o++) {
  119840. var s = this._triangles[o].split("/")
  119841. , c = parseInt(s[0]) - 1
  119842. , d = parseInt(s[1]) - 1
  119843. , _ = parseInt(s[2]) - 1;
  119844. this._setData(c, d, _, this._positions[c], this._uvs[d], this._normals[_])
  119845. }
  119846. this._triangles = []
  119847. }
  119848. ,
  119849. a.prototype._setDataForCurrentFaceWithPattern4 = function(e, i) {
  119850. this._getTriangles(e, i);
  119851. for (var o = 0; o < this._triangles.length; o++) {
  119852. var s = this._triangles[o].split("//")
  119853. , c = parseInt(s[0]) - 1
  119854. , d = parseInt(s[1]) - 1;
  119855. this._setData(c, 1, d, this._positions[c], Vector2.Zero(), this._normals[d], this._loadingOptions.importVertexColors ? this._colors[c] : void 0)
  119856. }
  119857. this._triangles = []
  119858. }
  119859. ,
  119860. a.prototype._setDataForCurrentFaceWithPattern5 = function(e, i) {
  119861. this._getTriangles(e, i);
  119862. for (var o = 0; o < this._triangles.length; o++) {
  119863. var s = this._triangles[o].split("/")
  119864. , c = this._positions.length + parseInt(s[0])
  119865. , d = this._uvs.length + parseInt(s[1])
  119866. , _ = this._normals.length + parseInt(s[2]);
  119867. this._setData(c, d, _, this._positions[c], this._uvs[d], this._normals[_], this._loadingOptions.importVertexColors ? this._colors[c] : void 0)
  119868. }
  119869. this._triangles = []
  119870. }
  119871. ,
  119872. a.prototype._addPreviousObjMesh = function() {
  119873. this._meshesFromObj.length > 0 && (this._handledMesh = this._meshesFromObj[this._meshesFromObj.length - 1],
  119874. this._unwrapData(),
  119875. this._indicesForBabylon.reverse(),
  119876. this._handledMesh.indices = this._indicesForBabylon.slice(),
  119877. this._handledMesh.positions = this._unwrappedPositionsForBabylon.slice(),
  119878. this._handledMesh.normals = this._unwrappedNormalsForBabylon.slice(),
  119879. this._handledMesh.uvs = this._unwrappedUVForBabylon.slice(),
  119880. this._loadingOptions.importVertexColors && (this._handledMesh.colors = this._unwrappedColorsForBabylon.slice()),
  119881. this._indicesForBabylon = [],
  119882. this._unwrappedPositionsForBabylon = [],
  119883. this._unwrappedColorsForBabylon = [],
  119884. this._unwrappedNormalsForBabylon = [],
  119885. this._unwrappedUVForBabylon = [])
  119886. }
  119887. ,
  119888. a.prototype._optimizeNormals = function(e) {
  119889. var i = e.getVerticesData(VertexBuffer.PositionKind)
  119890. , o = e.getVerticesData(VertexBuffer.NormalKind)
  119891. , s = {};
  119892. if (!(!i || !o)) {
  119893. for (var c = 0; c < i.length / 3; c++) {
  119894. var d = i[c * 3 + 0]
  119895. , _ = i[c * 3 + 1]
  119896. , b = i[c * 3 + 2]
  119897. , k = d + "_" + _ + "_" + b
  119898. , j = s[k];
  119899. j || (j = [],
  119900. s[k] = j),
  119901. j.push(c)
  119902. }
  119903. var $ = new Vector3;
  119904. for (var k in s) {
  119905. var j = s[k];
  119906. if (!(j.length < 2)) {
  119907. for (var _e = j[0], c = 1; c < j.length; ++c) {
  119908. var et = j[c];
  119909. o[_e * 3 + 0] += o[et * 3 + 0],
  119910. o[_e * 3 + 1] += o[et * 3 + 1],
  119911. o[_e * 3 + 2] += o[et * 3 + 2]
  119912. }
  119913. $.copyFromFloats(o[_e * 3 + 0], o[_e * 3 + 1], o[_e * 3 + 2]),
  119914. $.normalize();
  119915. for (var c = 0; c < j.length; ++c) {
  119916. var et = j[c];
  119917. o[et * 3 + 0] = $.x,
  119918. o[et * 3 + 1] = $.y,
  119919. o[et * 3 + 2] = $.z
  119920. }
  119921. }
  119922. }
  119923. e.setVerticesData(VertexBuffer.NormalKind, o)
  119924. }
  119925. }
  119926. ,
  119927. a.prototype.parse = function(e, i, o, s, c) {
  119928. for (var d, _ = i.split(`
  119929. `), b = 0; b < _.length; b++) {
  119930. var k = _[b].trim().replace(/\s\s/g, " "), j;
  119931. if (!(k.length === 0 || k.charAt(0) === "#"))
  119932. if (a.VertexPattern.test(k)) {
  119933. if (j = k.match(/[^ ]+/g),
  119934. this._positions.push(new Vector3(parseFloat(j[1]),parseFloat(j[2]),parseFloat(j[3]))),
  119935. this._loadingOptions.importVertexColors)
  119936. if (j.length >= 7) {
  119937. var $ = parseFloat(j[4])
  119938. , _e = parseFloat(j[5])
  119939. , et = parseFloat(j[6]);
  119940. this._colors.push(new Color4($ > 1 ? $ / 255 : $,_e > 1 ? _e / 255 : _e,et > 1 ? et / 255 : et,j.length === 7 || j[7] === void 0 ? 1 : parseFloat(j[7])))
  119941. } else
  119942. this._colors.push(this._grayColor)
  119943. } else if ((j = a.NormalPattern.exec(k)) !== null)
  119944. this._normals.push(new Vector3(parseFloat(j[1]),parseFloat(j[2]),parseFloat(j[3])));
  119945. else if ((j = a.UVPattern.exec(k)) !== null)
  119946. this._uvs.push(new Vector2(parseFloat(j[1]) * this._loadingOptions.UVScaling.x,parseFloat(j[2]) * this._loadingOptions.UVScaling.y));
  119947. else if ((j = a.FacePattern3.exec(k)) !== null)
  119948. this._setDataForCurrentFaceWithPattern3(j[1].trim().split(" "), 1);
  119949. else if ((j = a.FacePattern4.exec(k)) !== null)
  119950. this._setDataForCurrentFaceWithPattern4(j[1].trim().split(" "), 1);
  119951. else if ((j = a.FacePattern5.exec(k)) !== null)
  119952. this._setDataForCurrentFaceWithPattern5(j[1].trim().split(" "), 1);
  119953. else if ((j = a.FacePattern2.exec(k)) !== null)
  119954. this._setDataForCurrentFaceWithPattern2(j[1].trim().split(" "), 1);
  119955. else if ((j = a.FacePattern1.exec(k)) !== null)
  119956. this._setDataForCurrentFaceWithPattern1(j[1].trim().split(" "), 1);
  119957. else if (a.GroupDescriptor.test(k) || a.ObjectDescriptor.test(k)) {
  119958. var tt = {
  119959. name: k.substring(2).trim(),
  119960. indices: void 0,
  119961. positions: void 0,
  119962. normals: void 0,
  119963. uvs: void 0,
  119964. colors: void 0,
  119965. materialName: ""
  119966. };
  119967. this._addPreviousObjMesh(),
  119968. this._meshesFromObj.push(tt),
  119969. this._hasMeshes = !0,
  119970. this._isFirstMaterial = !0,
  119971. this._increment = 1
  119972. } else if (a.UseMtlDescriptor.test(k)) {
  119973. if (this._materialNameFromObj = k.substring(7).trim(),
  119974. !this._isFirstMaterial || !this._hasMeshes) {
  119975. this._addPreviousObjMesh();
  119976. var tt = {
  119977. name: (this._objMeshName || "mesh") + "_mm" + this._increment.toString(),
  119978. indices: void 0,
  119979. positions: void 0,
  119980. normals: void 0,
  119981. uvs: void 0,
  119982. colors: void 0,
  119983. materialName: this._materialNameFromObj
  119984. };
  119985. this._increment++,
  119986. this._meshesFromObj.push(tt),
  119987. this._hasMeshes = !0
  119988. }
  119989. this._hasMeshes && this._isFirstMaterial && (this._meshesFromObj[this._meshesFromObj.length - 1].materialName = this._materialNameFromObj,
  119990. this._isFirstMaterial = !1)
  119991. } else
  119992. a.MtlLibGroupDescriptor.test(k) ? c(k.substring(7).trim()) : a.SmoothDescriptor.test(k) || console.log("Unhandled expression at line : " + k)
  119993. }
  119994. if (this._hasMeshes && (this._handledMesh = this._meshesFromObj[this._meshesFromObj.length - 1],
  119995. this._indicesForBabylon.reverse(),
  119996. this._unwrapData(),
  119997. this._handledMesh.indices = this._indicesForBabylon,
  119998. this._handledMesh.positions = this._unwrappedPositionsForBabylon,
  119999. this._handledMesh.normals = this._unwrappedNormalsForBabylon,
  120000. this._handledMesh.uvs = this._unwrappedUVForBabylon,
  120001. this._loadingOptions.importVertexColors && (this._handledMesh.colors = this._unwrappedColorsForBabylon)),
  120002. !this._hasMeshes) {
  120003. var rt = null;
  120004. if (this._indicesForBabylon.length)
  120005. this._indicesForBabylon.reverse(),
  120006. this._unwrapData();
  120007. else {
  120008. for (var it = 0, nt = this._positions; it < nt.length; it++) {
  120009. var ot = nt[it];
  120010. this._unwrappedPositionsForBabylon.push(ot.x, ot.y, ot.z)
  120011. }
  120012. if (this._normals.length)
  120013. for (var at = 0, st = this._normals; at < st.length; at++) {
  120014. var ut = st[at];
  120015. this._unwrappedNormalsForBabylon.push(ut.x, ut.y, ut.z)
  120016. }
  120017. if (this._uvs.length)
  120018. for (var ct = 0, lt = this._uvs; ct < lt.length; ct++) {
  120019. var ft = lt[ct];
  120020. this._unwrappedUVForBabylon.push(ft.x, ft.y)
  120021. }
  120022. if (this._colors.length)
  120023. for (var ht = 0, pt = this._colors; ht < pt.length; ht++) {
  120024. var dt = pt[ht];
  120025. this._unwrappedColorsForBabylon.push(dt.r, dt.g, dt.b, dt.a)
  120026. }
  120027. this._materialNameFromObj || (rt = new StandardMaterial(Geometry.RandomId(),o),
  120028. rt.pointsCloud = !0,
  120029. this._materialNameFromObj = rt.name,
  120030. this._normals.length || (rt.disableLighting = !0,
  120031. rt.emissiveColor = Color3.White()))
  120032. }
  120033. this._meshesFromObj.push({
  120034. name: Geometry.RandomId(),
  120035. indices: this._indicesForBabylon,
  120036. positions: this._unwrappedPositionsForBabylon,
  120037. colors: this._unwrappedColorsForBabylon,
  120038. normals: this._unwrappedNormalsForBabylon,
  120039. uvs: this._unwrappedUVForBabylon,
  120040. materialName: this._materialNameFromObj,
  120041. directMaterial: rt
  120042. })
  120043. }
  120044. for (var _t = 0; _t < this._meshesFromObj.length; _t++) {
  120045. if (e && this._meshesFromObj[_t].name) {
  120046. if (e instanceof Array) {
  120047. if (e.indexOf(this._meshesFromObj[_t].name) === -1)
  120048. continue
  120049. } else if (this._meshesFromObj[_t].name !== e)
  120050. continue
  120051. }
  120052. this._handledMesh = this._meshesFromObj[_t],
  120053. o._blockEntityCollection = !!s;
  120054. var mt = new Mesh(this._meshesFromObj[_t].name,o);
  120055. if (mt._parentContainer = s,
  120056. o._blockEntityCollection = !1,
  120057. this._materialToUse.push(this._meshesFromObj[_t].materialName),
  120058. ((d = this._handledMesh.positions) === null || d === void 0 ? void 0 : d.length) === 0) {
  120059. this._babylonMeshesArray.push(mt);
  120060. continue
  120061. }
  120062. var vt = new VertexData;
  120063. if (vt.uvs = this._handledMesh.uvs,
  120064. vt.indices = this._handledMesh.indices,
  120065. vt.positions = this._handledMesh.positions,
  120066. this._loadingOptions.computeNormals) {
  120067. var yt = new Array;
  120068. VertexData.ComputeNormals(this._handledMesh.positions, this._handledMesh.indices, yt),
  120069. vt.normals = yt
  120070. } else
  120071. vt.normals = this._handledMesh.normals;
  120072. this._loadingOptions.importVertexColors && (vt.colors = this._handledMesh.colors),
  120073. vt.applyToMesh(mt),
  120074. this._loadingOptions.invertY && (mt.scaling.y *= -1),
  120075. this._loadingOptions.optimizeNormals && this._optimizeNormals(mt),
  120076. this._babylonMeshesArray.push(mt),
  120077. this._handledMesh.directMaterial && (mt.material = this._handledMesh.directMaterial)
  120078. }
  120079. }
  120080. ,
  120081. a.ObjectDescriptor = /^o/,
  120082. a.GroupDescriptor = /^g/,
  120083. a.MtlLibGroupDescriptor = /^mtllib /,
  120084. a.UseMtlDescriptor = /^usemtl /,
  120085. a.SmoothDescriptor = /^s /,
  120086. a.VertexPattern = /v(\s+[\d|\.|\+|\-|e|E]+){3,7}/,
  120087. a.NormalPattern = /vn(\s+[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)/,
  120088. a.UVPattern = /vt(\s+[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)/,
  120089. a.FacePattern1 = /f\s+(([\d]{1,}[\s]?){3,})+/,
  120090. a.FacePattern2 = /f\s+((([\d]{1,}\/[\d]{1,}[\s]?){3,})+)/,
  120091. a.FacePattern3 = /f\s+((([\d]{1,}\/[\d]{1,}\/[\d]{1,}[\s]?){3,})+)/,
  120092. a.FacePattern4 = /f\s+((([\d]{1,}\/\/[\d]{1,}[\s]?){3,})+)/,
  120093. a.FacePattern5 = /f\s+(((-[\d]{1,}\/-[\d]{1,}\/-[\d]{1,}[\s]?){3,})+)/,
  120094. a
  120095. }()
  120096. , OBJFileLoader = function() {
  120097. function a(e) {
  120098. this.name = "obj",
  120099. this.extensions = ".obj",
  120100. this._assetContainer = null,
  120101. this._loadingOptions = e || a.DefaultLoadingOptions
  120102. }
  120103. return Object.defineProperty(a, "INVERT_TEXTURE_Y", {
  120104. get: function() {
  120105. return MTLFileLoader.INVERT_TEXTURE_Y
  120106. },
  120107. set: function(e) {
  120108. MTLFileLoader.INVERT_TEXTURE_Y = e
  120109. },
  120110. enumerable: !1,
  120111. configurable: !0
  120112. }),
  120113. Object.defineProperty(a, "DefaultLoadingOptions", {
  120114. get: function() {
  120115. return {
  120116. computeNormals: a.COMPUTE_NORMALS,
  120117. optimizeNormals: a.OPTIMIZE_NORMALS,
  120118. importVertexColors: a.IMPORT_VERTEX_COLORS,
  120119. invertY: a.INVERT_Y,
  120120. invertTextureY: a.INVERT_TEXTURE_Y,
  120121. UVScaling: a.UV_SCALING,
  120122. materialLoadingFailsSilently: a.MATERIAL_LOADING_FAILS_SILENTLY,
  120123. optimizeWithUV: a.OPTIMIZE_WITH_UV,
  120124. skipMaterials: a.SKIP_MATERIALS
  120125. }
  120126. },
  120127. enumerable: !1,
  120128. configurable: !0
  120129. }),
  120130. a.prototype._loadMTL = function(e, i, o, s) {
  120131. var c = i + e;
  120132. Tools.LoadFile(c, o, void 0, void 0, !1, function(d, _) {
  120133. s(c, _)
  120134. })
  120135. }
  120136. ,
  120137. a.prototype.createPlugin = function() {
  120138. return new a(a.DefaultLoadingOptions)
  120139. }
  120140. ,
  120141. a.prototype.canDirectLoad = function(e) {
  120142. return !1
  120143. }
  120144. ,
  120145. a.prototype.importMeshAsync = function(e, i, o, s, c, d) {
  120146. return this._parseSolid(e, i, o, s).then(function(_) {
  120147. return {
  120148. meshes: _,
  120149. particleSystems: [],
  120150. skeletons: [],
  120151. animationGroups: [],
  120152. transformNodes: [],
  120153. geometries: [],
  120154. lights: []
  120155. }
  120156. })
  120157. }
  120158. ,
  120159. a.prototype.loadAsync = function(e, i, o, s, c) {
  120160. return this.importMeshAsync(null, e, i, o, s).then(function() {})
  120161. }
  120162. ,
  120163. a.prototype.loadAssetContainerAsync = function(e, i, o, s, c) {
  120164. var d = this
  120165. , _ = new AssetContainer(e);
  120166. return this._assetContainer = _,
  120167. this.importMeshAsync(null, e, i, o).then(function(b) {
  120168. return b.meshes.forEach(function(k) {
  120169. return _.meshes.push(k)
  120170. }),
  120171. b.meshes.forEach(function(k) {
  120172. var j = k.material;
  120173. if (j && _.materials.indexOf(j) == -1) {
  120174. _.materials.push(j);
  120175. var $ = j.getActiveTextures();
  120176. $.forEach(function(_e) {
  120177. _.textures.indexOf(_e) == -1 && _.textures.push(_e)
  120178. })
  120179. }
  120180. }),
  120181. d._assetContainer = null,
  120182. _
  120183. }).catch(function(b) {
  120184. throw d._assetContainer = null,
  120185. b
  120186. })
  120187. }
  120188. ,
  120189. a.prototype._parseSolid = function(e, i, o, s) {
  120190. var c = this
  120191. , d = ""
  120192. , _ = new MTLFileLoader
  120193. , b = new Array
  120194. , k = []
  120195. , j = new SolidParser(b,k,this._loadingOptions);
  120196. j.parse(e, o, i, this._assetContainer, function(_e) {
  120197. d = _e
  120198. });
  120199. var $ = [];
  120200. return d !== "" && !this._loadingOptions.skipMaterials && $.push(new Promise(function(_e, et) {
  120201. c._loadMTL(d, s, function(tt) {
  120202. try {
  120203. _.parseMTL(i, tt, s, c._assetContainer);
  120204. for (var rt = 0; rt < _.materials.length; rt++) {
  120205. for (var it = 0, nt = [], ot; (ot = b.indexOf(_.materials[rt].name, it)) > -1; )
  120206. nt.push(ot),
  120207. it = ot + 1;
  120208. if (ot === -1 && nt.length === 0)
  120209. _.materials[rt].dispose();
  120210. else
  120211. for (var at = 0; at < nt.length; at++) {
  120212. var st = k[nt[at]]
  120213. , ut = _.materials[rt];
  120214. st.material = ut,
  120215. st.getTotalIndices() || (ut.pointsCloud = !0)
  120216. }
  120217. }
  120218. _e()
  120219. } catch (ct) {
  120220. Tools.Warn("Error processing MTL file: '" + d + "'"),
  120221. c._loadingOptions.materialLoadingFailsSilently ? _e() : et(ct)
  120222. }
  120223. }, function(tt, rt) {
  120224. Tools.Warn("Error downloading MTL file: '" + d + "'"),
  120225. c._loadingOptions.materialLoadingFailsSilently ? _e() : et(rt)
  120226. })
  120227. }
  120228. )),
  120229. Promise.all($).then(function() {
  120230. return k
  120231. })
  120232. }
  120233. ,
  120234. a.OPTIMIZE_WITH_UV = !0,
  120235. a.INVERT_Y = !1,
  120236. a.IMPORT_VERTEX_COLORS = !1,
  120237. a.COMPUTE_NORMALS = !1,
  120238. a.OPTIMIZE_NORMALS = !1,
  120239. a.UV_SCALING = new Vector2(1,1),
  120240. a.SKIP_MATERIALS = !1,
  120241. a.MATERIAL_LOADING_FAILS_SILENTLY = !0,
  120242. a
  120243. }();
  120244. SceneLoader && SceneLoader.RegisterPlugin(new OBJFileLoader);
  120245. var STLFileLoader = function() {
  120246. function a() {
  120247. this.solidPattern = /solid (\S*)([\S\s]*?)endsolid[ ]*(\S*)/g,
  120248. this.facetsPattern = /facet([\s\S]*?)endfacet/g,
  120249. this.normalPattern = /normal[\s]+([\-+]?[0-9]+\.?[0-9]*([eE][\-+]?[0-9]+)?)+[\s]+([\-+]?[0-9]*\.?[0-9]+([eE][\-+]?[0-9]+)?)+[\s]+([\-+]?[0-9]*\.?[0-9]+([eE][\-+]?[0-9]+)?)+/g,
  120250. this.vertexPattern = /vertex[\s]+([\-+]?[0-9]+\.?[0-9]*([eE][\-+]?[0-9]+)?)+[\s]+([\-+]?[0-9]*\.?[0-9]+([eE][\-+]?[0-9]+)?)+[\s]+([\-+]?[0-9]*\.?[0-9]+([eE][\-+]?[0-9]+)?)+/g,
  120251. this.name = "stl",
  120252. this.extensions = {
  120253. ".stl": {
  120254. isBinary: !0
  120255. }
  120256. }
  120257. }
  120258. return a.prototype.importMesh = function(e, i, o, s, c, d, _) {
  120259. var b;
  120260. if (typeof o != "string") {
  120261. if (this._isBinary(o)) {
  120262. var k = new Mesh("stlmesh",i);
  120263. return this._parseBinary(k, o),
  120264. c && c.push(k),
  120265. !0
  120266. }
  120267. for (var j = new Uint8Array(o), $ = "", _e = 0; _e < o.byteLength; _e++)
  120268. $ += String.fromCharCode(j[_e]);
  120269. o = $
  120270. }
  120271. for (; b = this.solidPattern.exec(o); ) {
  120272. var et = b[1]
  120273. , tt = b[3];
  120274. if (et != tt)
  120275. return Tools.Error("Error in STL, solid name != endsolid name"),
  120276. !1;
  120277. if (e && et) {
  120278. if (e instanceof Array) {
  120279. if (!e.indexOf(et))
  120280. continue
  120281. } else if (et !== e)
  120282. continue
  120283. }
  120284. et = et || "stlmesh";
  120285. var k = new Mesh(et,i);
  120286. this._parseASCII(k, b[2]),
  120287. c && c.push(k)
  120288. }
  120289. return !0
  120290. }
  120291. ,
  120292. a.prototype.load = function(e, i, o) {
  120293. var s = this.importMesh(null, e, i, o, null, null, null);
  120294. return s
  120295. }
  120296. ,
  120297. a.prototype.loadAssetContainer = function(e, i, o, s) {
  120298. var c = new AssetContainer(e);
  120299. return e._blockEntityCollection = !0,
  120300. this.importMesh(null, e, i, o, c.meshes, null, null),
  120301. e._blockEntityCollection = !1,
  120302. c
  120303. }
  120304. ,
  120305. a.prototype._isBinary = function(e) {
  120306. var i, o, s;
  120307. if (s = new DataView(e),
  120308. s.byteLength <= 80)
  120309. return !1;
  120310. if (i = 32 / 8 * 3 + 32 / 8 * 3 * 3 + 16 / 8,
  120311. o = s.getUint32(80, !0),
  120312. 80 + 32 / 8 + o * i === s.byteLength)
  120313. return !0;
  120314. for (var c = s.byteLength, d = 0; d < c; d++)
  120315. if (s.getUint8(d) > 127)
  120316. return !0;
  120317. return !1
  120318. }
  120319. ,
  120320. a.prototype._parseBinary = function(e, i) {
  120321. for (var o = new DataView(i), s = o.getUint32(80, !0), c = 84, d = 12 * 4 + 2, _ = 0, b = new Float32Array(s * 3 * 3), k = new Float32Array(s * 3 * 3), j = new Uint32Array(s * 3), $ = 0, _e = 0; _e < s; _e++) {
  120322. for (var et = c + _e * d, tt = o.getFloat32(et, !0), rt = o.getFloat32(et + 4, !0), it = o.getFloat32(et + 8, !0), nt = 1; nt <= 3; nt++) {
  120323. var ot = et + nt * 12;
  120324. b[_] = o.getFloat32(ot, !0),
  120325. k[_] = tt,
  120326. a.DO_NOT_ALTER_FILE_COORDINATES ? (b[_ + 1] = o.getFloat32(ot + 4, !0),
  120327. b[_ + 2] = o.getFloat32(ot + 8, !0),
  120328. k[_ + 1] = rt,
  120329. k[_ + 2] = it) : (b[_ + 2] = o.getFloat32(ot + 4, !0),
  120330. b[_ + 1] = o.getFloat32(ot + 8, !0),
  120331. k[_ + 2] = rt,
  120332. k[_ + 1] = it),
  120333. _ += 3
  120334. }
  120335. j[$] = $++,
  120336. j[$] = $++,
  120337. j[$] = $++
  120338. }
  120339. e.setVerticesData(VertexBuffer.PositionKind, b),
  120340. e.setVerticesData(VertexBuffer.NormalKind, k),
  120341. e.setIndices(j),
  120342. e.computeWorldMatrix(!0)
  120343. }
  120344. ,
  120345. a.prototype._parseASCII = function(e, i) {
  120346. for (var o = [], s = [], c = [], d = 0, _; _ = this.facetsPattern.exec(i); ) {
  120347. var b = _[1]
  120348. , k = this.normalPattern.exec(b);
  120349. if (this.normalPattern.lastIndex = 0,
  120350. !!k) {
  120351. for (var j = [Number(k[1]), Number(k[5]), Number(k[3])], $; $ = this.vertexPattern.exec(b); )
  120352. a.DO_NOT_ALTER_FILE_COORDINATES ? (o.push(Number($[1]), Number($[3]), Number($[5])),
  120353. s.push(j[0], j[2], j[1])) : (o.push(Number($[1]), Number($[5]), Number($[3])),
  120354. s.push(j[0], j[1], j[2]));
  120355. c.push(d++, d++, d++),
  120356. this.vertexPattern.lastIndex = 0
  120357. }
  120358. }
  120359. this.facetsPattern.lastIndex = 0,
  120360. e.setVerticesData(VertexBuffer.PositionKind, o),
  120361. e.setVerticesData(VertexBuffer.NormalKind, s),
  120362. e.setIndices(c),
  120363. e.computeWorldMatrix(!0)
  120364. }
  120365. ,
  120366. a.DO_NOT_ALTER_FILE_COORDINATES = !1,
  120367. a
  120368. }();
  120369. SceneLoader && SceneLoader.RegisterPlugin(new STLFileLoader);
  120370. var SoundTrack = function() {
  120371. function a(e, i) {
  120372. i === void 0 && (i = {}),
  120373. this.id = -1,
  120374. this._isInitialized = !1,
  120375. this._scene = e,
  120376. this.soundCollection = new Array,
  120377. this._options = i,
  120378. !this._options.mainTrack && this._scene.soundTracks && (this._scene.soundTracks.push(this),
  120379. this.id = this._scene.soundTracks.length - 1)
  120380. }
  120381. return a.prototype._initializeSoundTrackAudioGraph = function() {
  120382. var e;
  120383. ((e = Engine.audioEngine) === null || e === void 0 ? void 0 : e.canUseWebAudio) && Engine.audioEngine.audioContext && (this._outputAudioNode = Engine.audioEngine.audioContext.createGain(),
  120384. this._outputAudioNode.connect(Engine.audioEngine.masterGain),
  120385. this._options && this._options.volume && (this._outputAudioNode.gain.value = this._options.volume),
  120386. this._isInitialized = !0)
  120387. }
  120388. ,
  120389. a.prototype.dispose = function() {
  120390. if (Engine.audioEngine && Engine.audioEngine.canUseWebAudio) {
  120391. for (this._connectedAnalyser && this._connectedAnalyser.stopDebugCanvas(); this.soundCollection.length; )
  120392. this.soundCollection[0].dispose();
  120393. this._outputAudioNode && this._outputAudioNode.disconnect(),
  120394. this._outputAudioNode = null
  120395. }
  120396. }
  120397. ,
  120398. a.prototype.addSound = function(e) {
  120399. var i;
  120400. this._isInitialized || this._initializeSoundTrackAudioGraph(),
  120401. ((i = Engine.audioEngine) === null || i === void 0 ? void 0 : i.canUseWebAudio) && this._outputAudioNode && e.connectToSoundTrackAudioNode(this._outputAudioNode),
  120402. e.soundTrackId && (e.soundTrackId === -1 ? this._scene.mainSoundTrack.removeSound(e) : this._scene.soundTracks && this._scene.soundTracks[e.soundTrackId].removeSound(e)),
  120403. this.soundCollection.push(e),
  120404. e.soundTrackId = this.id
  120405. }
  120406. ,
  120407. a.prototype.removeSound = function(e) {
  120408. var i = this.soundCollection.indexOf(e);
  120409. i !== -1 && this.soundCollection.splice(i, 1)
  120410. }
  120411. ,
  120412. a.prototype.setVolume = function(e) {
  120413. var i;
  120414. ((i = Engine.audioEngine) === null || i === void 0 ? void 0 : i.canUseWebAudio) && this._outputAudioNode && (this._outputAudioNode.gain.value = e)
  120415. }
  120416. ,
  120417. a.prototype.switchPanningModelToHRTF = function() {
  120418. var e;
  120419. if (!((e = Engine.audioEngine) === null || e === void 0) && e.canUseWebAudio)
  120420. for (var i = 0; i < this.soundCollection.length; i++)
  120421. this.soundCollection[i].switchPanningModelToHRTF()
  120422. }
  120423. ,
  120424. a.prototype.switchPanningModelToEqualPower = function() {
  120425. var e;
  120426. if (!((e = Engine.audioEngine) === null || e === void 0) && e.canUseWebAudio)
  120427. for (var i = 0; i < this.soundCollection.length; i++)
  120428. this.soundCollection[i].switchPanningModelToEqualPower()
  120429. }
  120430. ,
  120431. a.prototype.connectToAnalyser = function(e) {
  120432. var i;
  120433. this._connectedAnalyser && this._connectedAnalyser.stopDebugCanvas(),
  120434. this._connectedAnalyser = e,
  120435. ((i = Engine.audioEngine) === null || i === void 0 ? void 0 : i.canUseWebAudio) && this._outputAudioNode && (this._outputAudioNode.disconnect(),
  120436. this._connectedAnalyser.connectAudioNodes(this._outputAudioNode, Engine.audioEngine.masterGain))
  120437. }
  120438. ,
  120439. a
  120440. }();
  120441. Engine.AudioEngineFactory = function(a, e, i) {
  120442. return new AudioEngine(a,e,i)
  120443. }
  120444. ;
  120445. var AudioEngine = function() {
  120446. function a(e, i, o) {
  120447. var s = this;
  120448. if (e === void 0 && (e = null),
  120449. i === void 0 && (i = null),
  120450. o === void 0 && (o = null),
  120451. this._audioContext = null,
  120452. this._audioContextInitialized = !1,
  120453. this._muteButton = null,
  120454. this._audioDestination = null,
  120455. this.canUseWebAudio = !1,
  120456. this.WarnedWebAudioUnsupported = !1,
  120457. this.isMP3supported = !1,
  120458. this.isOGGsupported = !1,
  120459. this.unlocked = !0,
  120460. this.useCustomUnlockedButton = !1,
  120461. this.onAudioUnlockedObservable = new Observable,
  120462. this.onAudioLockedObservable = new Observable,
  120463. this._tryToRun = !1,
  120464. this._onResize = function() {
  120465. s._moveButtonToTopLeft()
  120466. }
  120467. ,
  120468. !!IsWindowObjectExist()) {
  120469. (typeof window.AudioContext != "undefined" || typeof window.webkitAudioContext != "undefined") && (window.AudioContext = window.AudioContext || window.webkitAudioContext,
  120470. this.canUseWebAudio = !0);
  120471. var c = document.createElement("audio");
  120472. this._hostElement = e,
  120473. this._audioContext = i,
  120474. this._audioDestination = o;
  120475. try {
  120476. c && !!c.canPlayType && (c.canPlayType('audio/mpeg; codecs="mp3"').replace(/^no$/, "") || c.canPlayType("audio/mp3").replace(/^no$/, "")) && (this.isMP3supported = !0)
  120477. } catch {}
  120478. try {
  120479. c && !!c.canPlayType && c.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, "") && (this.isOGGsupported = !0)
  120480. } catch {}
  120481. }
  120482. }
  120483. return Object.defineProperty(a.prototype, "audioContext", {
  120484. get: function() {
  120485. return this._audioContextInitialized ? !this.unlocked && !this._muteButton && this._displayMuteButton() : this._initializeAudioContext(),
  120486. this._audioContext
  120487. },
  120488. enumerable: !1,
  120489. configurable: !0
  120490. }),
  120491. a.prototype.lock = function() {
  120492. this._triggerSuspendedState()
  120493. }
  120494. ,
  120495. a.prototype.unlock = function() {
  120496. this._triggerRunningState()
  120497. }
  120498. ,
  120499. a.prototype._resumeAudioContext = function() {
  120500. var e;
  120501. return this._audioContext.resume !== void 0 && (e = this._audioContext.resume()),
  120502. e || Promise.resolve()
  120503. }
  120504. ,
  120505. a.prototype._initializeAudioContext = function() {
  120506. try {
  120507. this.canUseWebAudio && (this._audioContext || (this._audioContext = new AudioContext),
  120508. this.masterGain = this._audioContext.createGain(),
  120509. this.masterGain.gain.value = 1,
  120510. this._audioDestination || (this._audioDestination = this._audioContext.destination),
  120511. this.masterGain.connect(this._audioDestination),
  120512. this._audioContextInitialized = !0,
  120513. this._audioContext.state === "running" && this._triggerRunningState())
  120514. } catch (e) {
  120515. this.canUseWebAudio = !1,
  120516. Logger$2.Error("Web Audio: " + e.message)
  120517. }
  120518. }
  120519. ,
  120520. a.prototype._triggerRunningState = function() {
  120521. var e = this;
  120522. this._tryToRun || (this._tryToRun = !0,
  120523. this._resumeAudioContext().then(function() {
  120524. e._tryToRun = !1,
  120525. e._muteButton && e._hideMuteButton(),
  120526. e.unlocked = !0,
  120527. e.onAudioUnlockedObservable.notifyObservers(e)
  120528. }).catch(function() {
  120529. e._tryToRun = !1,
  120530. e.unlocked = !1
  120531. }))
  120532. }
  120533. ,
  120534. a.prototype._triggerSuspendedState = function() {
  120535. this.unlocked = !1,
  120536. this.onAudioLockedObservable.notifyObservers(this),
  120537. this._displayMuteButton()
  120538. }
  120539. ,
  120540. a.prototype._displayMuteButton = function() {
  120541. var e = this;
  120542. if (!(this.useCustomUnlockedButton || this._muteButton)) {
  120543. this._muteButton = document.createElement("BUTTON"),
  120544. this._muteButton.className = "babylonUnmuteIcon",
  120545. this._muteButton.id = "babylonUnmuteIconBtn",
  120546. this._muteButton.title = "Unmute";
  120547. var i = window.SVGSVGElement ? "data:image/svg+xml;charset=UTF-8,%3Csvg%20version%3D%221.1%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2239%22%20height%3D%2232%22%20viewBox%3D%220%200%2039%2032%22%3E%3Cpath%20fill%3D%22white%22%20d%3D%22M9.625%2018.938l-0.031%200.016h-4.953q-0.016%200-0.031-0.016v-12.453q0-0.016%200.031-0.016h4.953q0.031%200%200.031%200.016v12.453zM12.125%207.688l8.719-8.703v27.453l-8.719-8.719-0.016-0.047v-9.938zM23.359%207.875l1.406-1.406%204.219%204.203%204.203-4.203%201.422%201.406-4.219%204.219%204.219%204.203-1.484%201.359-4.141-4.156-4.219%204.219-1.406-1.422%204.219-4.203z%22%3E%3C%2Fpath%3E%3C%2Fsvg%3E" : "https://cdn.babylonjs.com/Assets/audio.png"
  120548. , o = ".babylonUnmuteIcon { position: absolute; left: 20px; top: 20px; height: 40px; width: 60px; background-color: rgba(51,51,51,0.7); background-image: url(" + i + "); background-size: 80%; background-repeat:no-repeat; background-position: center; background-position-y: 4px; border: none; outline: none; transition: transform 0.125s ease-out; cursor: pointer; z-index: 9999; } .babylonUnmuteIcon:hover { transform: scale(1.05) } .babylonUnmuteIcon:active { background-color: rgba(51,51,51,1) }"
  120549. , s = document.createElement("style");
  120550. s.appendChild(document.createTextNode(o)),
  120551. document.getElementsByTagName("head")[0].appendChild(s),
  120552. document.body.appendChild(this._muteButton),
  120553. this._moveButtonToTopLeft(),
  120554. this._muteButton.addEventListener("touchend", function() {
  120555. e._triggerRunningState()
  120556. }, !0),
  120557. this._muteButton.addEventListener("click", function() {
  120558. e._triggerRunningState()
  120559. }, !0),
  120560. window.addEventListener("resize", this._onResize)
  120561. }
  120562. }
  120563. ,
  120564. a.prototype._moveButtonToTopLeft = function() {
  120565. this._hostElement && this._muteButton && (this._muteButton.style.top = this._hostElement.offsetTop + 20 + "px",
  120566. this._muteButton.style.left = this._hostElement.offsetLeft + 20 + "px")
  120567. }
  120568. ,
  120569. a.prototype._hideMuteButton = function() {
  120570. this._muteButton && (document.body.removeChild(this._muteButton),
  120571. this._muteButton = null)
  120572. }
  120573. ,
  120574. a.prototype.dispose = function() {
  120575. this.canUseWebAudio && this._audioContextInitialized && (this._connectedAnalyser && this._audioContext && (this._connectedAnalyser.stopDebugCanvas(),
  120576. this._connectedAnalyser.dispose(),
  120577. this.masterGain.disconnect(),
  120578. this.masterGain.connect(this._audioContext.destination),
  120579. this._connectedAnalyser = null),
  120580. this.masterGain.gain.value = 1),
  120581. this.WarnedWebAudioUnsupported = !1,
  120582. this._hideMuteButton(),
  120583. window.removeEventListener("resize", this._onResize),
  120584. this.onAudioUnlockedObservable.clear(),
  120585. this.onAudioLockedObservable.clear()
  120586. }
  120587. ,
  120588. a.prototype.getGlobalVolume = function() {
  120589. return this.canUseWebAudio && this._audioContextInitialized ? this.masterGain.gain.value : -1
  120590. }
  120591. ,
  120592. a.prototype.setGlobalVolume = function(e) {
  120593. this.canUseWebAudio && this._audioContextInitialized && (this.masterGain.gain.value = e)
  120594. }
  120595. ,
  120596. a.prototype.connectToAnalyser = function(e) {
  120597. this._connectedAnalyser && this._connectedAnalyser.stopDebugCanvas(),
  120598. this.canUseWebAudio && this._audioContextInitialized && this._audioContext && (this._connectedAnalyser = e,
  120599. this.masterGain.disconnect(),
  120600. this._connectedAnalyser.connectAudioNodes(this.masterGain, this._audioContext.destination))
  120601. }
  120602. ,
  120603. a
  120604. }();
  120605. AbstractScene.AddParser(SceneComponentConstants.NAME_AUDIO, function(a, e, i, o) {
  120606. var s, c = [], d;
  120607. if (i.sounds = i.sounds || [],
  120608. a.sounds !== void 0 && a.sounds !== null)
  120609. for (var _ = 0, b = a.sounds.length; _ < b; _++) {
  120610. var k = a.sounds[_];
  120611. !((s = Engine.audioEngine) === null || s === void 0) && s.canUseWebAudio ? (k.url || (k.url = k.name),
  120612. c[k.url] ? i.sounds.push(Sound.Parse(k, e, o, c[k.url])) : (d = Sound.Parse(k, e, o),
  120613. c[k.url] = d,
  120614. i.sounds.push(d))) : i.sounds.push(new Sound(k.name,null,e))
  120615. }
  120616. c = []
  120617. });
  120618. Object.defineProperty(Scene.prototype, "mainSoundTrack", {
  120619. get: function() {
  120620. var a = this._getComponent(SceneComponentConstants.NAME_AUDIO);
  120621. return a || (a = new AudioSceneComponent(this),
  120622. this._addComponent(a)),
  120623. this._mainSoundTrack || (this._mainSoundTrack = new SoundTrack(this,{
  120624. mainTrack: !0
  120625. })),
  120626. this._mainSoundTrack
  120627. },
  120628. enumerable: !0,
  120629. configurable: !0
  120630. });
  120631. Scene.prototype.getSoundByName = function(a) {
  120632. var e;
  120633. for (e = 0; e < this.mainSoundTrack.soundCollection.length; e++)
  120634. if (this.mainSoundTrack.soundCollection[e].name === a)
  120635. return this.mainSoundTrack.soundCollection[e];
  120636. if (this.soundTracks) {
  120637. for (var i = 0; i < this.soundTracks.length; i++)
  120638. for (e = 0; e < this.soundTracks[i].soundCollection.length; e++)
  120639. if (this.soundTracks[i].soundCollection[e].name === a)
  120640. return this.soundTracks[i].soundCollection[e]
  120641. }
  120642. return null
  120643. }
  120644. ;
  120645. Object.defineProperty(Scene.prototype, "audioEnabled", {
  120646. get: function() {
  120647. var a = this._getComponent(SceneComponentConstants.NAME_AUDIO);
  120648. return a || (a = new AudioSceneComponent(this),
  120649. this._addComponent(a)),
  120650. a.audioEnabled
  120651. },
  120652. set: function(a) {
  120653. var e = this._getComponent(SceneComponentConstants.NAME_AUDIO);
  120654. e || (e = new AudioSceneComponent(this),
  120655. this._addComponent(e)),
  120656. a ? e.enableAudio() : e.disableAudio()
  120657. },
  120658. enumerable: !0,
  120659. configurable: !0
  120660. });
  120661. Object.defineProperty(Scene.prototype, "headphone", {
  120662. get: function() {
  120663. var a = this._getComponent(SceneComponentConstants.NAME_AUDIO);
  120664. return a || (a = new AudioSceneComponent(this),
  120665. this._addComponent(a)),
  120666. a.headphone
  120667. },
  120668. set: function(a) {
  120669. var e = this._getComponent(SceneComponentConstants.NAME_AUDIO);
  120670. e || (e = new AudioSceneComponent(this),
  120671. this._addComponent(e)),
  120672. a ? e.switchAudioModeForHeadphones() : e.switchAudioModeForNormalSpeakers()
  120673. },
  120674. enumerable: !0,
  120675. configurable: !0
  120676. });
  120677. Object.defineProperty(Scene.prototype, "audioListenerPositionProvider", {
  120678. get: function() {
  120679. var a = this._getComponent(SceneComponentConstants.NAME_AUDIO);
  120680. return a || (a = new AudioSceneComponent(this),
  120681. this._addComponent(a)),
  120682. a.audioListenerPositionProvider
  120683. },
  120684. set: function(a) {
  120685. var e = this._getComponent(SceneComponentConstants.NAME_AUDIO);
  120686. if (e || (e = new AudioSceneComponent(this),
  120687. this._addComponent(e)),
  120688. typeof a != "function")
  120689. throw new Error("The value passed to [Scene.audioListenerPositionProvider] must be a function that returns a Vector3");
  120690. e.audioListenerPositionProvider = a
  120691. },
  120692. enumerable: !0,
  120693. configurable: !0
  120694. });
  120695. Object.defineProperty(Scene.prototype, "audioPositioningRefreshRate", {
  120696. get: function() {
  120697. var a = this._getComponent(SceneComponentConstants.NAME_AUDIO);
  120698. return a || (a = new AudioSceneComponent(this),
  120699. this._addComponent(a)),
  120700. a.audioPositioningRefreshRate
  120701. },
  120702. set: function(a) {
  120703. var e = this._getComponent(SceneComponentConstants.NAME_AUDIO);
  120704. e || (e = new AudioSceneComponent(this),
  120705. this._addComponent(e)),
  120706. e.audioPositioningRefreshRate = a
  120707. },
  120708. enumerable: !0,
  120709. configurable: !0
  120710. });
  120711. var AudioSceneComponent = function() {
  120712. function a(e) {
  120713. this.name = SceneComponentConstants.NAME_AUDIO,
  120714. this._audioEnabled = !0,
  120715. this._headphone = !1,
  120716. this.audioPositioningRefreshRate = 500,
  120717. this._audioListenerPositionProvider = null,
  120718. this._cachedCameraDirection = new Vector3,
  120719. this._cachedCameraPosition = new Vector3,
  120720. this._lastCheck = 0,
  120721. this.scene = e,
  120722. e.soundTracks = new Array,
  120723. e.sounds = new Array
  120724. }
  120725. return Object.defineProperty(a.prototype, "audioEnabled", {
  120726. get: function() {
  120727. return this._audioEnabled
  120728. },
  120729. enumerable: !1,
  120730. configurable: !0
  120731. }),
  120732. Object.defineProperty(a.prototype, "headphone", {
  120733. get: function() {
  120734. return this._headphone
  120735. },
  120736. enumerable: !1,
  120737. configurable: !0
  120738. }),
  120739. Object.defineProperty(a.prototype, "audioListenerPositionProvider", {
  120740. get: function() {
  120741. return this._audioListenerPositionProvider
  120742. },
  120743. set: function(e) {
  120744. this._audioListenerPositionProvider = e
  120745. },
  120746. enumerable: !1,
  120747. configurable: !0
  120748. }),
  120749. a.prototype.register = function() {
  120750. this.scene._afterRenderStage.registerStep(SceneComponentConstants.STEP_AFTERRENDER_AUDIO, this, this._afterRender)
  120751. }
  120752. ,
  120753. a.prototype.rebuild = function() {}
  120754. ,
  120755. a.prototype.serialize = function(e) {
  120756. if (e.sounds = [],
  120757. this.scene.soundTracks)
  120758. for (var i = 0; i < this.scene.soundTracks.length; i++)
  120759. for (var o = this.scene.soundTracks[i], s = 0; s < o.soundCollection.length; s++)
  120760. e.sounds.push(o.soundCollection[s].serialize())
  120761. }
  120762. ,
  120763. a.prototype.addFromContainer = function(e) {
  120764. var i = this;
  120765. !e.sounds || e.sounds.forEach(function(o) {
  120766. o.play(),
  120767. o.autoplay = !0,
  120768. i.scene.mainSoundTrack.addSound(o)
  120769. })
  120770. }
  120771. ,
  120772. a.prototype.removeFromContainer = function(e, i) {
  120773. var o = this;
  120774. i === void 0 && (i = !1),
  120775. e.sounds && e.sounds.forEach(function(s) {
  120776. s.stop(),
  120777. s.autoplay = !1,
  120778. o.scene.mainSoundTrack.removeSound(s),
  120779. i && s.dispose()
  120780. })
  120781. }
  120782. ,
  120783. a.prototype.dispose = function() {
  120784. var e = this.scene;
  120785. if (e._mainSoundTrack && e.mainSoundTrack.dispose(),
  120786. e.soundTracks)
  120787. for (var i = 0; i < e.soundTracks.length; i++)
  120788. e.soundTracks[i].dispose()
  120789. }
  120790. ,
  120791. a.prototype.disableAudio = function() {
  120792. var e = this.scene;
  120793. this._audioEnabled = !1,
  120794. Engine.audioEngine && Engine.audioEngine.audioContext && Engine.audioEngine.audioContext.suspend();
  120795. var i;
  120796. for (i = 0; i < e.mainSoundTrack.soundCollection.length; i++)
  120797. e.mainSoundTrack.soundCollection[i].pause();
  120798. if (e.soundTracks)
  120799. for (i = 0; i < e.soundTracks.length; i++)
  120800. for (var o = 0; o < e.soundTracks[i].soundCollection.length; o++)
  120801. e.soundTracks[i].soundCollection[o].pause()
  120802. }
  120803. ,
  120804. a.prototype.enableAudio = function() {
  120805. var e = this.scene;
  120806. this._audioEnabled = !0,
  120807. Engine.audioEngine && Engine.audioEngine.audioContext && Engine.audioEngine.audioContext.resume();
  120808. var i;
  120809. for (i = 0; i < e.mainSoundTrack.soundCollection.length; i++)
  120810. e.mainSoundTrack.soundCollection[i].isPaused && e.mainSoundTrack.soundCollection[i].play();
  120811. if (e.soundTracks)
  120812. for (i = 0; i < e.soundTracks.length; i++)
  120813. for (var o = 0; o < e.soundTracks[i].soundCollection.length; o++)
  120814. e.soundTracks[i].soundCollection[o].isPaused && e.soundTracks[i].soundCollection[o].play()
  120815. }
  120816. ,
  120817. a.prototype.switchAudioModeForHeadphones = function() {
  120818. var e = this.scene;
  120819. if (this._headphone = !0,
  120820. e.mainSoundTrack.switchPanningModelToHRTF(),
  120821. e.soundTracks)
  120822. for (var i = 0; i < e.soundTracks.length; i++)
  120823. e.soundTracks[i].switchPanningModelToHRTF()
  120824. }
  120825. ,
  120826. a.prototype.switchAudioModeForNormalSpeakers = function() {
  120827. var e = this.scene;
  120828. if (this._headphone = !1,
  120829. e.mainSoundTrack.switchPanningModelToEqualPower(),
  120830. e.soundTracks)
  120831. for (var i = 0; i < e.soundTracks.length; i++)
  120832. e.soundTracks[i].switchPanningModelToEqualPower()
  120833. }
  120834. ,
  120835. a.prototype._afterRender = function() {
  120836. var e = PrecisionDate.Now;
  120837. if (!(this._lastCheck && e - this._lastCheck < this.audioPositioningRefreshRate)) {
  120838. this._lastCheck = e;
  120839. var i = this.scene;
  120840. if (!(!this._audioEnabled || !i._mainSoundTrack || !i.soundTracks || i._mainSoundTrack.soundCollection.length === 0 && i.soundTracks.length === 1)) {
  120841. var o = Engine.audioEngine;
  120842. if (!!o && o.audioContext) {
  120843. if (this._audioListenerPositionProvider) {
  120844. var s = this._audioListenerPositionProvider();
  120845. s.x = s.x || 0,
  120846. s.y = s.y || 0,
  120847. s.z = s.z || 0,
  120848. o.audioContext.listener.setPosition(s.x, s.y, s.z)
  120849. } else {
  120850. var c;
  120851. if (i.activeCameras && i.activeCameras.length > 0 ? c = i.activeCameras[0] : c = i.activeCamera,
  120852. c) {
  120853. this._cachedCameraPosition.equals(c.globalPosition) || (this._cachedCameraPosition.copyFrom(c.globalPosition),
  120854. o.audioContext.listener.setPosition(c.globalPosition.x, c.globalPosition.y, c.globalPosition.z)),
  120855. c.rigCameras && c.rigCameras.length > 0 && (c = c.rigCameras[0]);
  120856. var d = Matrix.Invert(c.getViewMatrix())
  120857. , _ = Vector3.TransformNormal(a._CameraDirection, d);
  120858. _.normalize(),
  120859. !isNaN(_.x) && !isNaN(_.y) && !isNaN(_.z) && (this._cachedCameraDirection.equals(_) || (this._cachedCameraDirection.copyFrom(_),
  120860. o.audioContext.listener.setOrientation(_.x, _.y, _.z, 0, 1, 0)))
  120861. } else
  120862. o.audioContext.listener.setPosition(0, 0, 0)
  120863. }
  120864. var b;
  120865. for (b = 0; b < i.mainSoundTrack.soundCollection.length; b++) {
  120866. var k = i.mainSoundTrack.soundCollection[b];
  120867. k.useCustomAttenuation && k.updateDistanceFromListener()
  120868. }
  120869. if (i.soundTracks)
  120870. for (b = 0; b < i.soundTracks.length; b++)
  120871. for (var j = 0; j < i.soundTracks[b].soundCollection.length; j++)
  120872. k = i.soundTracks[b].soundCollection[j],
  120873. k.useCustomAttenuation && k.updateDistanceFromListener()
  120874. }
  120875. }
  120876. }
  120877. }
  120878. ,
  120879. a._CameraDirection = new Vector3(0,0,-1),
  120880. a
  120881. }();
  120882. Sound._SceneComponentInitialization = function(a) {
  120883. var e = a._getComponent(SceneComponentConstants.NAME_AUDIO);
  120884. e || (e = new AudioSceneComponent(a),
  120885. a._addComponent(e))
  120886. }
  120887. ;
  120888. var DefaultLoadingScreen = function() {
  120889. function a(e, i, o) {
  120890. var s = this;
  120891. i === void 0 && (i = ""),
  120892. o === void 0 && (o = "black"),
  120893. this._renderingCanvas = e,
  120894. this._loadingText = i,
  120895. this._loadingDivBackgroundColor = o,
  120896. this._resizeLoadingUI = function() {
  120897. var c = s._renderingCanvas.getBoundingClientRect()
  120898. , d = window.getComputedStyle(s._renderingCanvas).position;
  120899. !s._loadingDiv || (s._loadingDiv.style.position = d === "fixed" ? "fixed" : "absolute",
  120900. s._loadingDiv.style.left = c.left + "px",
  120901. s._loadingDiv.style.top = c.top + "px",
  120902. s._loadingDiv.style.width = c.width + "px",
  120903. s._loadingDiv.style.height = c.height + "px")
  120904. }
  120905. }
  120906. return a.prototype.displayLoadingUI = function() {
  120907. if (!this._loadingDiv) {
  120908. this._loadingDiv = document.createElement("div"),
  120909. this._loadingDiv.id = "babylonjsLoadingDiv",
  120910. this._loadingDiv.style.opacity = "0",
  120911. this._loadingDiv.style.transition = "opacity 1.5s ease",
  120912. this._loadingDiv.style.pointerEvents = "none",
  120913. this._loadingDiv.style.display = "grid",
  120914. this._loadingDiv.style.gridTemplateRows = "100%",
  120915. this._loadingDiv.style.gridTemplateColumns = "100%",
  120916. this._loadingDiv.style.justifyItems = "center",
  120917. this._loadingDiv.style.alignItems = "center",
  120918. this._loadingTextDiv = document.createElement("div"),
  120919. this._loadingTextDiv.style.position = "absolute",
  120920. this._loadingTextDiv.style.left = "0",
  120921. this._loadingTextDiv.style.top = "50%",
  120922. this._loadingTextDiv.style.marginTop = "80px",
  120923. this._loadingTextDiv.style.width = "100%",
  120924. this._loadingTextDiv.style.height = "20px",
  120925. this._loadingTextDiv.style.fontFamily = "Arial",
  120926. this._loadingTextDiv.style.fontSize = "14px",
  120927. this._loadingTextDiv.style.color = "white",
  120928. this._loadingTextDiv.style.textAlign = "center",
  120929. this._loadingTextDiv.style.zIndex = "1",
  120930. this._loadingTextDiv.innerHTML = "Loading",
  120931. this._loadingDiv.appendChild(this._loadingTextDiv),
  120932. this._loadingTextDiv.innerHTML = this._loadingText,
  120933. this._style = document.createElement("style"),
  120934. this._style.type = "text/css";
  120935. var e = `@-webkit-keyframes spin1 { 0% { -webkit-transform: rotate(0deg);}
  120936. 100% { -webkit-transform: rotate(360deg);}
  120937. } @keyframes spin1 { 0% { transform: rotate(0deg);}
  120938. 100% { transform: rotate(360deg);}
  120939. }`;
  120940. this._style.innerHTML = e,
  120941. document.getElementsByTagName("head")[0].appendChild(this._style);
  120942. var i = !!window.SVGSVGElement
  120943. , o = new Image;
  120944. a.DefaultLogoUrl ? o.src = a.DefaultLogoUrl : o.src = i ? "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxODAuMTcgMjA4LjA0Ij48ZGVmcz48c3R5bGU+LmNscy0xe2ZpbGw6I2ZmZjt9LmNscy0ye2ZpbGw6I2UwNjg0Yjt9LmNscy0ze2ZpbGw6I2JiNDY0Yjt9LmNscy00e2ZpbGw6I2UwZGVkODt9LmNscy01e2ZpbGw6I2Q1ZDJjYTt9PC9zdHlsZT48L2RlZnM+PHRpdGxlPkJhYnlsb25Mb2dvPC90aXRsZT48ZyBpZD0iTGF5ZXJfMiIgZGF0YS1uYW1lPSJMYXllciAyIj48ZyBpZD0iUGFnZV9FbGVtZW50cyIgZGF0YS1uYW1lPSJQYWdlIEVsZW1lbnRzIj48cGF0aCBjbGFzcz0iY2xzLTEiIGQ9Ik05MC4wOSwwLDAsNTJWMTU2bDkwLjA5LDUyLDkwLjA4LTUyVjUyWiIvPjxwb2x5Z29uIGNsYXNzPSJjbHMtMiIgcG9pbnRzPSIxODAuMTcgNTIuMDEgMTUxLjk3IDM1LjczIDEyNC44NSA1MS4zOSAxNTMuMDUgNjcuNjcgMTgwLjE3IDUyLjAxIi8+PHBvbHlnb24gY2xhc3M9ImNscy0yIiBwb2ludHM9IjI3LjEyIDY3LjY3IDExNy4yMSAxNS42NiA5MC4wOCAwIDAgNTIuMDEgMjcuMTIgNjcuNjciLz48cG9seWdvbiBjbGFzcz0iY2xzLTIiIHBvaW50cz0iNjEuODkgMTIwLjMgOTAuMDggMTM2LjU4IDExOC4yOCAxMjAuMyA5MC4wOCAxMDQuMDIgNjEuODkgMTIwLjMiLz48cG9seWdvbiBjbGFzcz0iY2xzLTMiIHBvaW50cz0iMTUzLjA1IDY3LjY3IDE1My4wNSAxNDAuMzcgOTAuMDggMTc2LjcyIDI3LjEyIDE0MC4zNyAyNy4xMiA2Ny42NyAwIDUyLjAxIDAgMTU2LjAzIDkwLjA4IDIwOC4wNCAxODAuMTcgMTU2LjAzIDE4MC4xNyA1Mi4wMSAxNTMuMDUgNjcuNjciLz48cG9seWdvbiBjbGFzcz0iY2xzLTMiIHBvaW50cz0iOTAuMDggNzEuNDYgNjEuODkgODcuNzQgNjEuODkgMTIwLjMgOTAuMDggMTA0LjAyIDExOC4yOCAxMjAuMyAxMTguMjggODcuNzQgOTAuMDggNzEuNDYiLz48cG9seWdvbiBjbGFzcz0iY2xzLTQiIHBvaW50cz0iMTUzLjA1IDY3LjY3IDExOC4yOCA4Ny43NCAxMTguMjggMTIwLjMgOTAuMDggMTM2LjU4IDkwLjA4IDE3Ni43MiAxNTMuMDUgMTQwLjM3IDE1My4wNSA2Ny42NyIvPjxwb2x5Z29uIGNsYXNzPSJjbHMtNSIgcG9pbnRzPSIyNy4xMiA2Ny42NyA2MS44OSA4Ny43NCA2MS44OSAxMjAuMyA5MC4wOCAxMzYuNTggOTAuMDggMTc2LjcyIDI3LjEyIDE0MC4zNyAyNy4xMiA2Ny42NyIvPjwvZz48L2c+PC9zdmc+" : "https://cdn.babylonjs.com/Assets/babylonLogo.png",
  120945. o.style.width = "150px",
  120946. o.style.gridColumn = "1",
  120947. o.style.gridRow = "1",
  120948. o.style.top = "50%",
  120949. o.style.left = "50%",
  120950. o.style.transform = "translate(-50%, -50%)",
  120951. o.style.position = "absolute";
  120952. var s = document.createElement("div");
  120953. s.style.width = "300px",
  120954. s.style.gridColumn = "1",
  120955. s.style.gridRow = "1",
  120956. s.style.top = "50%",
  120957. s.style.left = "50%",
  120958. s.style.transform = "translate(-50%, -50%)",
  120959. s.style.position = "absolute";
  120960. var c = new Image;
  120961. if (a.DefaultSpinnerUrl ? c.src = a.DefaultSpinnerUrl : c.src = i ? "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzOTIgMzkyIj48ZGVmcz48c3R5bGU+LmNscy0xe2ZpbGw6I2UwNjg0Yjt9LmNscy0ye2ZpbGw6bm9uZTt9PC9zdHlsZT48L2RlZnM+PHRpdGxlPlNwaW5uZXJJY29uPC90aXRsZT48ZyBpZD0iTGF5ZXJfMiIgZGF0YS1uYW1lPSJMYXllciAyIj48ZyBpZD0iU3Bpbm5lciI+PHBhdGggY2xhc3M9ImNscy0xIiBkPSJNNDAuMjEsMTI2LjQzYzMuNy03LjMxLDcuNjctMTQuNDQsMTItMjEuMzJsMy4zNi01LjEsMy41Mi01YzEuMjMtMS42MywyLjQxLTMuMjksMy42NS00LjkxczIuNTMtMy4yMSwzLjgyLTQuNzlBMTg1LjIsMTg1LjIsMCwwLDEsODMuNCw2Ny40M2EyMDgsMjA4LDAsMCwxLDE5LTE1LjY2YzMuMzUtMi40MSw2Ljc0LTQuNzgsMTAuMjUtN3M3LjExLTQuMjgsMTAuNzUtNi4zMmM3LjI5LTQsMTQuNzMtOCwyMi41My0xMS40OSwzLjktMS43Miw3Ljg4LTMuMywxMi00LjY0YTEwNC4yMiwxMDQuMjIsMCwwLDEsMTIuNDQtMy4yMyw2Mi40NCw2Mi40NCwwLDAsMSwxMi43OC0xLjM5QTI1LjkyLDI1LjkyLDAsMCwxLDE5NiwyMS40NGE2LjU1LDYuNTUsMCwwLDEsMi4wNSw5LDYuNjYsNi42NiwwLDAsMS0xLjY0LDEuNzhsLS40MS4yOWEyMi4wNywyMi4wNywwLDAsMS01Ljc4LDMsMzAuNDIsMzAuNDIsMCwwLDEtNS42NywxLjYyLDM3LjgyLDM3LjgyLDAsMCwxLTUuNjkuNzFjLTEsMC0xLjkuMTgtMi44NS4yNmwtMi44NS4yNHEtNS43Mi41MS0xMS40OCwxLjFjLTMuODQuNC03LjcxLjgyLTExLjU4LDEuNGExMTIuMzQsMTEyLjM0LDAsMCwwLTIyLjk0LDUuNjFjLTMuNzIsMS4zNS03LjM0LDMtMTAuOTQsNC42NHMtNy4xNCwzLjUxLTEwLjYsNS41MUExNTEuNiwxNTEuNiwwLDAsMCw2OC41Niw4N0M2Ny4yMyw4OC40OCw2Niw5MCw2NC42NCw5MS41NnMtMi41MSwzLjE1LTMuNzUsNC43M2wtMy41NCw0LjljLTEuMTMsMS42Ni0yLjIzLDMuMzUtMy4zMyw1YTEyNywxMjcsMCwwLDAtMTAuOTMsMjEuNDksMS41OCwxLjU4LDAsMSwxLTMtMS4xNVM0MC4xOSwxMjYuNDcsNDAuMjEsMTI2LjQzWiIvPjxyZWN0IGNsYXNzPSJjbHMtMiIgd2lkdGg9IjM5MiIgaGVpZ2h0PSIzOTIiLz48L2c+PC9nPjwvc3ZnPg==" : "https://cdn.babylonjs.com/Assets/loadingIcon.png",
  120962. c.style.animation = "spin1 0.75s infinite linear",
  120963. c.style.webkitAnimation = "spin1 0.75s infinite linear",
  120964. c.style.transformOrigin = "50% 50%",
  120965. c.style.webkitTransformOrigin = "50% 50%",
  120966. !i) {
  120967. var d = {
  120968. w: 16,
  120969. h: 18.5
  120970. }
  120971. , _ = {
  120972. w: 30,
  120973. h: 30
  120974. };
  120975. o.style.width = d.w + "vh",
  120976. o.style.height = d.h + "vh",
  120977. o.style.left = "calc(50% - " + d.w / 2 + "vh)",
  120978. o.style.top = "calc(50% - " + d.h / 2 + "vh)",
  120979. c.style.width = _.w + "vh",
  120980. c.style.height = _.h + "vh",
  120981. c.style.left = "calc(50% - " + _.w / 2 + "vh)",
  120982. c.style.top = "calc(50% - " + _.h / 2 + "vh)"
  120983. }
  120984. s.appendChild(c),
  120985. this._loadingDiv.appendChild(o),
  120986. this._loadingDiv.appendChild(s),
  120987. this._resizeLoadingUI(),
  120988. window.addEventListener("resize", this._resizeLoadingUI),
  120989. this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor,
  120990. document.body.appendChild(this._loadingDiv),
  120991. this._loadingDiv.style.opacity = "1"
  120992. }
  120993. }
  120994. ,
  120995. a.prototype.hideLoadingUI = function() {
  120996. var e = this;
  120997. if (!!this._loadingDiv) {
  120998. var i = function() {
  120999. e._loadingDiv && (e._loadingDiv.parentElement && e._loadingDiv.parentElement.removeChild(e._loadingDiv),
  121000. e._loadingDiv = null),
  121001. e._style && (e._style.parentElement && e._style.parentElement.removeChild(e._style),
  121002. e._style = null),
  121003. window.removeEventListener("resize", e._resizeLoadingUI)
  121004. };
  121005. this._loadingDiv.style.opacity = "0",
  121006. this._loadingDiv.addEventListener("transitionend", i)
  121007. }
  121008. }
  121009. ,
  121010. Object.defineProperty(a.prototype, "loadingUIText", {
  121011. get: function() {
  121012. return this._loadingText
  121013. },
  121014. set: function(e) {
  121015. this._loadingText = e,
  121016. this._loadingTextDiv && (this._loadingTextDiv.innerHTML = this._loadingText)
  121017. },
  121018. enumerable: !1,
  121019. configurable: !0
  121020. }),
  121021. Object.defineProperty(a.prototype, "loadingUIBackgroundColor", {
  121022. get: function() {
  121023. return this._loadingDivBackgroundColor
  121024. },
  121025. set: function(e) {
  121026. this._loadingDivBackgroundColor = e,
  121027. this._loadingDiv && (this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor)
  121028. },
  121029. enumerable: !1,
  121030. configurable: !0
  121031. }),
  121032. a.DefaultLogoUrl = "",
  121033. a.DefaultSpinnerUrl = "",
  121034. a
  121035. }();
  121036. Engine.DefaultLoadingScreenFactory = function(a) {
  121037. return new DefaultLoadingScreen(a)
  121038. }
  121039. ;
  121040. var PanoramaToCubeMapTools = function() {
  121041. function a() {}
  121042. return a.ConvertPanoramaToCubemap = function(e, i, o, s) {
  121043. if (!e)
  121044. throw "ConvertPanoramaToCubemap: input cannot be null";
  121045. if (e.length != i * o * 3)
  121046. throw "ConvertPanoramaToCubemap: input size is wrong";
  121047. var c = this.CreateCubemapTexture(s, this.FACE_FRONT, e, i, o)
  121048. , d = this.CreateCubemapTexture(s, this.FACE_BACK, e, i, o)
  121049. , _ = this.CreateCubemapTexture(s, this.FACE_LEFT, e, i, o)
  121050. , b = this.CreateCubemapTexture(s, this.FACE_RIGHT, e, i, o)
  121051. , k = this.CreateCubemapTexture(s, this.FACE_UP, e, i, o)
  121052. , j = this.CreateCubemapTexture(s, this.FACE_DOWN, e, i, o);
  121053. return {
  121054. front: c,
  121055. back: d,
  121056. left: _,
  121057. right: b,
  121058. up: k,
  121059. down: j,
  121060. size: s,
  121061. type: 1,
  121062. format: 4,
  121063. gammaSpace: !1
  121064. }
  121065. }
  121066. ,
  121067. a.CreateCubemapTexture = function(e, i, o, s, c) {
  121068. for (var d = new ArrayBuffer(e * e * 4 * 3), _ = new Float32Array(d), b = i[1].subtract(i[0]).scale(1 / e), k = i[3].subtract(i[2]).scale(1 / e), j = 1 / e, $ = 0, _e = 0; _e < e; _e++) {
  121069. for (var et = i[0], tt = i[2], rt = 0; rt < e; rt++) {
  121070. var it = tt.subtract(et).scale($).add(et);
  121071. it.normalize();
  121072. var nt = this.CalcProjectionSpherical(it, o, s, c);
  121073. _[_e * e * 3 + rt * 3 + 0] = nt.r,
  121074. _[_e * e * 3 + rt * 3 + 1] = nt.g,
  121075. _[_e * e * 3 + rt * 3 + 2] = nt.b,
  121076. et = et.add(b),
  121077. tt = tt.add(k)
  121078. }
  121079. $ += j
  121080. }
  121081. return _
  121082. }
  121083. ,
  121084. a.CalcProjectionSpherical = function(e, i, o, s) {
  121085. for (var c = Math.atan2(e.z, e.x), d = Math.acos(e.y); c < -Math.PI; )
  121086. c += 2 * Math.PI;
  121087. for (; c > Math.PI; )
  121088. c -= 2 * Math.PI;
  121089. var _ = c / Math.PI
  121090. , b = d / Math.PI;
  121091. _ = _ * .5 + .5;
  121092. var k = Math.round(_ * o);
  121093. k < 0 ? k = 0 : k >= o && (k = o - 1);
  121094. var j = Math.round(b * s);
  121095. j < 0 ? j = 0 : j >= s && (j = s - 1);
  121096. var $ = s - j - 1
  121097. , _e = i[$ * o * 3 + k * 3 + 0]
  121098. , et = i[$ * o * 3 + k * 3 + 1]
  121099. , tt = i[$ * o * 3 + k * 3 + 2];
  121100. return {
  121101. r: _e,
  121102. g: et,
  121103. b: tt
  121104. }
  121105. }
  121106. ,
  121107. a.FACE_LEFT = [new Vector3(-1,-1,-1), new Vector3(1,-1,-1), new Vector3(-1,1,-1), new Vector3(1,1,-1)],
  121108. a.FACE_RIGHT = [new Vector3(1,-1,1), new Vector3(-1,-1,1), new Vector3(1,1,1), new Vector3(-1,1,1)],
  121109. a.FACE_FRONT = [new Vector3(1,-1,-1), new Vector3(1,-1,1), new Vector3(1,1,-1), new Vector3(1,1,1)],
  121110. a.FACE_BACK = [new Vector3(-1,-1,1), new Vector3(-1,-1,-1), new Vector3(-1,1,1), new Vector3(-1,1,-1)],
  121111. a.FACE_DOWN = [new Vector3(1,1,-1), new Vector3(1,1,1), new Vector3(-1,1,-1), new Vector3(-1,1,1)],
  121112. a.FACE_UP = [new Vector3(-1,-1,-1), new Vector3(-1,-1,1), new Vector3(1,-1,-1), new Vector3(1,-1,1)],
  121113. a
  121114. }()
  121115. , HDRTools = function() {
  121116. function a() {}
  121117. return a.Ldexp = function(e, i) {
  121118. return i > 1023 ? e * Math.pow(2, 1023) * Math.pow(2, i - 1023) : i < -1074 ? e * Math.pow(2, -1074) * Math.pow(2, i + 1074) : e * Math.pow(2, i)
  121119. }
  121120. ,
  121121. a.Rgbe2float = function(e, i, o, s, c, d) {
  121122. c > 0 ? (c = this.Ldexp(1, c - (128 + 8)),
  121123. e[d + 0] = i * c,
  121124. e[d + 1] = o * c,
  121125. e[d + 2] = s * c) : (e[d + 0] = 0,
  121126. e[d + 1] = 0,
  121127. e[d + 2] = 0)
  121128. }
  121129. ,
  121130. a.readStringLine = function(e, i) {
  121131. for (var o = "", s = "", c = i; c < e.length - i && (s = String.fromCharCode(e[c]),
  121132. s != `
  121133. `); c++)
  121134. o += s;
  121135. return o
  121136. }
  121137. ,
  121138. a.RGBE_ReadHeader = function(e) {
  121139. var i = 0
  121140. , o = 0
  121141. , s = this.readStringLine(e, 0);
  121142. if (s[0] != "#" || s[1] != "?")
  121143. throw "Bad HDR Format.";
  121144. var c = !1
  121145. , d = !1
  121146. , _ = 0;
  121147. do
  121148. _ += s.length + 1,
  121149. s = this.readStringLine(e, _),
  121150. s == "FORMAT=32-bit_rle_rgbe" ? d = !0 : s.length == 0 && (c = !0);
  121151. while (!c);
  121152. if (!d)
  121153. throw "HDR Bad header format, unsupported FORMAT";
  121154. _ += s.length + 1,
  121155. s = this.readStringLine(e, _);
  121156. var b = /^\-Y (.*) \+X (.*)$/g
  121157. , k = b.exec(s);
  121158. if (!k || k.length < 3)
  121159. throw "HDR Bad header format, no size";
  121160. if (o = parseInt(k[2]),
  121161. i = parseInt(k[1]),
  121162. o < 8 || o > 32767)
  121163. throw "HDR Bad header format, unsupported size";
  121164. return _ += s.length + 1,
  121165. {
  121166. height: i,
  121167. width: o,
  121168. dataPosition: _
  121169. }
  121170. }
  121171. ,
  121172. a.GetCubeMapTextureData = function(e, i) {
  121173. var o = new Uint8Array(e)
  121174. , s = this.RGBE_ReadHeader(o)
  121175. , c = this.RGBE_ReadPixels(o, s)
  121176. , d = PanoramaToCubeMapTools.ConvertPanoramaToCubemap(c, s.width, s.height, i);
  121177. return d
  121178. }
  121179. ,
  121180. a.RGBE_ReadPixels = function(e, i) {
  121181. return this.RGBE_ReadPixels_RLE(e, i)
  121182. }
  121183. ,
  121184. a.RGBE_ReadPixels_RLE = function(e, i) {
  121185. for (var o = i.height, s = i.width, c, d, _, b, k, j = i.dataPosition, $ = 0, _e = 0, et = 0, tt = new ArrayBuffer(s * 4), rt = new Uint8Array(tt), it = new ArrayBuffer(i.width * i.height * 4 * 3), nt = new Float32Array(it); o > 0; ) {
  121186. if (c = e[j++],
  121187. d = e[j++],
  121188. _ = e[j++],
  121189. b = e[j++],
  121190. c != 2 || d != 2 || _ & 128 || i.width < 8 || i.width > 32767)
  121191. return this.RGBE_ReadPixels_NOT_RLE(e, i);
  121192. if ((_ << 8 | b) != s)
  121193. throw "HDR Bad header format, wrong scan line width";
  121194. for ($ = 0,
  121195. et = 0; et < 4; et++)
  121196. for (_e = (et + 1) * s; $ < _e; )
  121197. if (c = e[j++],
  121198. d = e[j++],
  121199. c > 128) {
  121200. if (k = c - 128,
  121201. k == 0 || k > _e - $)
  121202. throw "HDR Bad Format, bad scanline data (run)";
  121203. for (; k-- > 0; )
  121204. rt[$++] = d
  121205. } else {
  121206. if (k = c,
  121207. k == 0 || k > _e - $)
  121208. throw "HDR Bad Format, bad scanline data (non-run)";
  121209. if (rt[$++] = d,
  121210. --k > 0)
  121211. for (var ot = 0; ot < k; ot++)
  121212. rt[$++] = e[j++]
  121213. }
  121214. for (et = 0; et < s; et++)
  121215. c = rt[et],
  121216. d = rt[et + s],
  121217. _ = rt[et + 2 * s],
  121218. b = rt[et + 3 * s],
  121219. this.Rgbe2float(nt, c, d, _, b, (i.height - o) * s * 3 + et * 3);
  121220. o--
  121221. }
  121222. return nt
  121223. }
  121224. ,
  121225. a.RGBE_ReadPixels_NOT_RLE = function(e, i) {
  121226. for (var o = i.height, s = i.width, c, d, _, b, k, j = i.dataPosition, $ = new ArrayBuffer(i.width * i.height * 4 * 3), _e = new Float32Array($); o > 0; ) {
  121227. for (k = 0; k < i.width; k++)
  121228. c = e[j++],
  121229. d = e[j++],
  121230. _ = e[j++],
  121231. b = e[j++],
  121232. this.Rgbe2float(_e, c, d, _, b, (i.height - o) * s * 3 + k * 3);
  121233. o--
  121234. }
  121235. return _e
  121236. }
  121237. ,
  121238. a
  121239. }()
  121240. , EffectRenderer = function() {
  121241. function a(e, i) {
  121242. var o, s = this;
  121243. i === void 0 && (i = a._DefaultOptions),
  121244. this.engine = e,
  121245. this._fullscreenViewport = new Viewport(0,0,1,1),
  121246. i = __assign(__assign({}, a._DefaultOptions), i),
  121247. this._vertexBuffers = (o = {},
  121248. o[VertexBuffer.PositionKind] = new VertexBuffer(e,i.positions,VertexBuffer.PositionKind,!1,!1,2),
  121249. o),
  121250. this._indexBuffer = e.createIndexBuffer(i.indices),
  121251. this._onContextRestoredObserver = e.onContextRestoredObservable.add(function() {
  121252. s._indexBuffer = e.createIndexBuffer(i.indices);
  121253. for (var c in s._vertexBuffers) {
  121254. var d = s._vertexBuffers[c];
  121255. d._rebuild()
  121256. }
  121257. })
  121258. }
  121259. return a.prototype.setViewport = function(e) {
  121260. e === void 0 && (e = this._fullscreenViewport),
  121261. this.engine.setViewport(e)
  121262. }
  121263. ,
  121264. a.prototype.bindBuffers = function(e) {
  121265. this.engine.bindBuffers(this._vertexBuffers, this._indexBuffer, e)
  121266. }
  121267. ,
  121268. a.prototype.applyEffectWrapper = function(e) {
  121269. this.engine.depthCullingState.depthTest = !1,
  121270. this.engine.stencilState.stencilTest = !1,
  121271. this.engine.enableEffect(e._drawWrapper),
  121272. this.bindBuffers(e.effect),
  121273. e.onApplyObservable.notifyObservers({})
  121274. }
  121275. ,
  121276. a.prototype.restoreStates = function() {
  121277. this.engine.depthCullingState.depthTest = !0,
  121278. this.engine.stencilState.stencilTest = !0
  121279. }
  121280. ,
  121281. a.prototype.draw = function() {
  121282. this.engine.drawElementsType(0, 0, 6)
  121283. }
  121284. ,
  121285. a.prototype.isRenderTargetTexture = function(e) {
  121286. return e.renderTarget !== void 0
  121287. }
  121288. ,
  121289. a.prototype.render = function(e, i) {
  121290. if (i === void 0 && (i = null),
  121291. !!e.effect.isReady()) {
  121292. this.setViewport();
  121293. var o = i === null ? null : this.isRenderTargetTexture(i) ? i.renderTarget : i;
  121294. o && this.engine.bindFramebuffer(o),
  121295. this.applyEffectWrapper(e),
  121296. this.draw(),
  121297. o && this.engine.unBindFramebuffer(o),
  121298. this.restoreStates()
  121299. }
  121300. }
  121301. ,
  121302. a.prototype.dispose = function() {
  121303. var e = this._vertexBuffers[VertexBuffer.PositionKind];
  121304. e && (e.dispose(),
  121305. delete this._vertexBuffers[VertexBuffer.PositionKind]),
  121306. this._indexBuffer && this.engine._releaseBuffer(this._indexBuffer),
  121307. this._onContextRestoredObserver && (this.engine.onContextRestoredObservable.remove(this._onContextRestoredObserver),
  121308. this._onContextRestoredObserver = null)
  121309. }
  121310. ,
  121311. a._DefaultOptions = {
  121312. positions: [1, 1, -1, 1, -1, -1, 1, -1],
  121313. indices: [0, 1, 2, 0, 2, 3]
  121314. },
  121315. a
  121316. }()
  121317. , EffectWrapper = function() {
  121318. function a(e) {
  121319. var i = this;
  121320. this.onApplyObservable = new Observable;
  121321. var o, s = e.uniformNames || [];
  121322. e.vertexShader ? o = {
  121323. fragmentSource: e.fragmentShader,
  121324. vertexSource: e.vertexShader,
  121325. spectorName: e.name || "effectWrapper"
  121326. } : (s.push("scale"),
  121327. o = {
  121328. fragmentSource: e.fragmentShader,
  121329. vertex: "postprocess",
  121330. spectorName: e.name || "effectWrapper"
  121331. },
  121332. this.onApplyObservable.add(function() {
  121333. i.effect.setFloat2("scale", 1, 1)
  121334. }));
  121335. var c = e.defines ? e.defines.join(`
  121336. `) : "";
  121337. this._drawWrapper = new DrawWrapper(e.engine),
  121338. e.useShaderStore ? (o.fragment = o.fragmentSource,
  121339. o.vertex || (o.vertex = o.vertexSource),
  121340. delete o.fragmentSource,
  121341. delete o.vertexSource,
  121342. this.effect = e.engine.createEffect(o, e.attributeNames || ["position"], s, e.samplerNames, c, void 0, e.onCompiled, void 0, void 0, e.shaderLanguage)) : (this.effect = new Effect(o,e.attributeNames || ["position"],s,e.samplerNames,e.engine,c,void 0,e.onCompiled,void 0,void 0,void 0,e.shaderLanguage),
  121343. this._onContextRestoredObserver = e.engine.onContextRestoredObservable.add(function() {
  121344. i.effect._pipelineContext = null,
  121345. i.effect._wasPreviouslyReady = !1,
  121346. i.effect._prepareEffect()
  121347. }))
  121348. }
  121349. return Object.defineProperty(a.prototype, "effect", {
  121350. get: function() {
  121351. return this._drawWrapper.effect
  121352. },
  121353. set: function(e) {
  121354. this._drawWrapper.effect = e
  121355. },
  121356. enumerable: !1,
  121357. configurable: !0
  121358. }),
  121359. a.prototype.dispose = function() {
  121360. this._onContextRestoredObserver && (this.effect.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver),
  121361. this._onContextRestoredObserver = null),
  121362. this.effect.dispose()
  121363. }
  121364. ,
  121365. a
  121366. }()
  121367. , name$c = "hdrFilteringVertexShader"
  121368. , shader$c = `
  121369. attribute vec2 position;
  121370. varying vec3 direction;
  121371. uniform vec3 up;
  121372. uniform vec3 right;
  121373. uniform vec3 front;
  121374. void main(void) {
  121375. mat3 view=mat3(up,right,front);
  121376. direction=view*vec3(position,1.0);
  121377. gl_Position=vec4(position,0.0,1.0);
  121378. }`;
  121379. ShaderStore.ShadersStore[name$c] = shader$c;
  121380. var name$b = "hdrFilteringPixelShader"
  121381. , shader$b = `#include<helperFunctions>
  121382. #include<importanceSampling>
  121383. #include<pbrBRDFFunctions>
  121384. #include<hdrFilteringFunctions>
  121385. uniform float alphaG;
  121386. uniform samplerCube inputTexture;
  121387. uniform vec2 vFilteringInfo;
  121388. uniform float hdrScale;
  121389. varying vec3 direction;
  121390. void main() {
  121391. vec3 color=radiance(alphaG,inputTexture,direction,vFilteringInfo);
  121392. gl_FragColor=vec4(color*hdrScale,1.0);
  121393. }`;
  121394. ShaderStore.ShadersStore[name$b] = shader$b;
  121395. var HDRFiltering = function() {
  121396. function a(e, i) {
  121397. i === void 0 && (i = {}),
  121398. this._lodGenerationOffset = 0,
  121399. this._lodGenerationScale = .8,
  121400. this.quality = 4096,
  121401. this.hdrScale = 1,
  121402. this._engine = e,
  121403. this.hdrScale = i.hdrScale || this.hdrScale,
  121404. this.quality = i.hdrScale || this.quality
  121405. }
  121406. return a.prototype._createRenderTarget = function(e) {
  121407. var i = 0;
  121408. this._engine.getCaps().textureHalfFloatRender ? i = 2 : this._engine.getCaps().textureFloatRender && (i = 1);
  121409. var o = this._engine.createRenderTargetCubeTexture(e, {
  121410. format: 5,
  121411. type: i,
  121412. createMipMaps: !0,
  121413. generateMipMaps: !1,
  121414. generateDepthBuffer: !1,
  121415. generateStencilBuffer: !1,
  121416. samplingMode: 1
  121417. });
  121418. return this._engine.updateTextureWrappingMode(o.texture, 0, 0, 0),
  121419. this._engine.updateTextureSamplingMode(3, o.texture, !0),
  121420. o
  121421. }
  121422. ,
  121423. a.prototype._prefilterInternal = function(e) {
  121424. var i = e.getSize().width
  121425. , o = Scalar.ILog2(i) + 1
  121426. , s = this._effectWrapper.effect
  121427. , c = this._createRenderTarget(i);
  121428. this._effectRenderer.setViewport();
  121429. var d = e.getInternalTexture();
  121430. d && this._engine.updateTextureSamplingMode(3, d, !0),
  121431. this._effectRenderer.applyEffectWrapper(this._effectWrapper);
  121432. var _ = [[new Vector3(0,0,-1), new Vector3(0,-1,0), new Vector3(1,0,0)], [new Vector3(0,0,1), new Vector3(0,-1,0), new Vector3(-1,0,0)], [new Vector3(1,0,0), new Vector3(0,0,1), new Vector3(0,1,0)], [new Vector3(1,0,0), new Vector3(0,0,-1), new Vector3(0,-1,0)], [new Vector3(1,0,0), new Vector3(0,-1,0), new Vector3(0,0,1)], [new Vector3(-1,0,0), new Vector3(0,-1,0), new Vector3(0,0,-1)]];
  121433. s.setFloat("hdrScale", this.hdrScale),
  121434. s.setFloat2("vFilteringInfo", e.getSize().width, o),
  121435. s.setTexture("inputTexture", e);
  121436. for (var b = 0; b < 6; b++) {
  121437. s.setVector3("up", _[b][0]),
  121438. s.setVector3("right", _[b][1]),
  121439. s.setVector3("front", _[b][2]);
  121440. for (var k = 0; k < o; k++) {
  121441. this._engine.bindFramebuffer(c, b, void 0, void 0, !0, k),
  121442. this._effectRenderer.applyEffectWrapper(this._effectWrapper);
  121443. var j = Math.pow(2, (k - this._lodGenerationOffset) / this._lodGenerationScale) / i;
  121444. k === 0 && (j = 0),
  121445. s.setFloat("alphaG", j),
  121446. this._effectRenderer.draw()
  121447. }
  121448. }
  121449. return this._effectRenderer.restoreStates(),
  121450. this._engine.restoreDefaultFramebuffer(),
  121451. this._engine._releaseTexture(e._texture),
  121452. c._swapAndDie(e._texture),
  121453. e._prefiltered = !0,
  121454. e
  121455. }
  121456. ,
  121457. a.prototype._createEffect = function(e, i) {
  121458. var o = [];
  121459. e.gammaSpace && o.push("#define GAMMA_INPUT"),
  121460. o.push("#define NUM_SAMPLES " + this.quality + "u");
  121461. var s = new EffectWrapper({
  121462. engine: this._engine,
  121463. name: "hdrFiltering",
  121464. vertexShader: "hdrFiltering",
  121465. fragmentShader: "hdrFiltering",
  121466. samplerNames: ["inputTexture"],
  121467. uniformNames: ["vSampleDirections", "vWeights", "up", "right", "front", "vFilteringInfo", "hdrScale", "alphaG"],
  121468. useShaderStore: !0,
  121469. defines: o,
  121470. onCompiled: i
  121471. });
  121472. return s
  121473. }
  121474. ,
  121475. a.prototype.isReady = function(e) {
  121476. return e.isReady() && this._effectWrapper.effect.isReady()
  121477. }
  121478. ,
  121479. a.prototype.prefilter = function(e, i) {
  121480. var o = this;
  121481. return i === void 0 && (i = null),
  121482. this._engine._features.allowTexturePrefiltering ? new Promise(function(s) {
  121483. o._effectRenderer = new EffectRenderer(o._engine),
  121484. o._effectWrapper = o._createEffect(e),
  121485. o._effectWrapper.effect.executeWhenCompiled(function() {
  121486. o._prefilterInternal(e),
  121487. o._effectRenderer.dispose(),
  121488. o._effectWrapper.dispose(),
  121489. s(),
  121490. i && i()
  121491. })
  121492. }
  121493. ) : (Logger$2.Warn("HDR prefiltering is not available in WebGL 1., you can use real time filtering instead."),
  121494. Promise.reject("HDR prefiltering is not available in WebGL 1., you can use real time filtering instead."))
  121495. }
  121496. ,
  121497. a
  121498. }()
  121499. , HDRCubeTexture = function(a) {
  121500. __extends(e, a);
  121501. function e(i, o, s, c, d, _, b, k, j) {
  121502. c === void 0 && (c = !1),
  121503. d === void 0 && (d = !0),
  121504. _ === void 0 && (_ = !1),
  121505. b === void 0 && (b = !1),
  121506. k === void 0 && (k = null),
  121507. j === void 0 && (j = null);
  121508. var $, _e = a.call(this, o) || this;
  121509. return _e._generateHarmonics = !0,
  121510. _e._onError = null,
  121511. _e._isBlocking = !0,
  121512. _e._rotationY = 0,
  121513. _e.boundingBoxPosition = Vector3.Zero(),
  121514. _e.onLoadObservable = new Observable,
  121515. i && (_e._coordinatesMode = Texture.CUBIC_MODE,
  121516. _e.name = i,
  121517. _e.url = i,
  121518. _e.hasAlpha = !1,
  121519. _e.isCube = !0,
  121520. _e._textureMatrix = Matrix.Identity(),
  121521. _e._prefilterOnLoad = b,
  121522. _e._onLoad = function() {
  121523. _e.onLoadObservable.notifyObservers(_e),
  121524. k && k()
  121525. }
  121526. ,
  121527. _e._onError = j,
  121528. _e.gammaSpace = _,
  121529. _e._noMipmap = c,
  121530. _e._size = s,
  121531. _e._generateHarmonics = d,
  121532. _e._texture = _e._getFromCache(i, _e._noMipmap),
  121533. _e._texture ? _e._texture.isReady ? Tools.SetImmediate(function() {
  121534. return _e._onLoad()
  121535. }) : _e._texture.onLoadedObservable.add(_e._onLoad) : !(($ = _e.getScene()) === null || $ === void 0) && $.useDelayedTextureLoading ? _e.delayLoadState = 4 : _e.loadTexture()),
  121536. _e
  121537. }
  121538. return Object.defineProperty(e.prototype, "isBlocking", {
  121539. get: function() {
  121540. return this._isBlocking
  121541. },
  121542. set: function(i) {
  121543. this._isBlocking = i
  121544. },
  121545. enumerable: !1,
  121546. configurable: !0
  121547. }),
  121548. Object.defineProperty(e.prototype, "rotationY", {
  121549. get: function() {
  121550. return this._rotationY
  121551. },
  121552. set: function(i) {
  121553. this._rotationY = i,
  121554. this.setReflectionTextureMatrix(Matrix.RotationY(this._rotationY))
  121555. },
  121556. enumerable: !1,
  121557. configurable: !0
  121558. }),
  121559. Object.defineProperty(e.prototype, "boundingBoxSize", {
  121560. get: function() {
  121561. return this._boundingBoxSize
  121562. },
  121563. set: function(i) {
  121564. if (!(this._boundingBoxSize && this._boundingBoxSize.equals(i))) {
  121565. this._boundingBoxSize = i;
  121566. var o = this.getScene();
  121567. o && o.markAllMaterialsAsDirty(1)
  121568. }
  121569. },
  121570. enumerable: !1,
  121571. configurable: !0
  121572. }),
  121573. e.prototype.getClassName = function() {
  121574. return "HDRCubeTexture"
  121575. }
  121576. ,
  121577. e.prototype.loadTexture = function() {
  121578. var i = this
  121579. , o = this._getEngine()
  121580. , s = o.getCaps()
  121581. , c = 0;
  121582. s.textureFloat && s.textureFloatLinearFiltering ? c = 1 : s.textureHalfFloat && s.textureHalfFloatLinearFiltering && (c = 2);
  121583. var d = function(k) {
  121584. i.lodGenerationOffset = 0,
  121585. i.lodGenerationScale = .8;
  121586. var j = HDRTools.GetCubeMapTextureData(k, i._size);
  121587. if (i._generateHarmonics) {
  121588. var $ = CubeMapToSphericalPolynomialTools.ConvertCubeMapToSphericalPolynomial(j);
  121589. i.sphericalPolynomial = $
  121590. }
  121591. for (var _e = [], et = null, tt = null, rt = 0; rt < 6; rt++) {
  121592. c === 2 ? tt = new Uint16Array(i._size * i._size * 3) : c === 0 && (et = new Uint8Array(i._size * i._size * 3));
  121593. var it = j[e._facesMapping[rt]];
  121594. if (i.gammaSpace || tt || et) {
  121595. for (var nt = 0; nt < i._size * i._size; nt++)
  121596. if (i.gammaSpace && (it[nt * 3 + 0] = Math.pow(it[nt * 3 + 0], ToGammaSpace),
  121597. it[nt * 3 + 1] = Math.pow(it[nt * 3 + 1], ToGammaSpace),
  121598. it[nt * 3 + 2] = Math.pow(it[nt * 3 + 2], ToGammaSpace)),
  121599. tt && (tt[nt * 3 + 0] = ToHalfFloat(it[nt * 3 + 0]),
  121600. tt[nt * 3 + 1] = ToHalfFloat(it[nt * 3 + 1]),
  121601. tt[nt * 3 + 2] = ToHalfFloat(it[nt * 3 + 2])),
  121602. et) {
  121603. var ot = Math.max(it[nt * 3 + 0] * 255, 0)
  121604. , at = Math.max(it[nt * 3 + 1] * 255, 0)
  121605. , st = Math.max(it[nt * 3 + 2] * 255, 0)
  121606. , ut = Math.max(Math.max(ot, at), st);
  121607. if (ut > 255) {
  121608. var ct = 255 / ut;
  121609. ot *= ct,
  121610. at *= ct,
  121611. st *= ct
  121612. }
  121613. et[nt * 3 + 0] = ot,
  121614. et[nt * 3 + 1] = at,
  121615. et[nt * 3 + 2] = st
  121616. }
  121617. }
  121618. tt ? _e.push(tt) : et ? _e.push(et) : _e.push(it)
  121619. }
  121620. return _e
  121621. };
  121622. if (o._features.allowTexturePrefiltering && this._prefilterOnLoad) {
  121623. var _ = this._onLoad
  121624. , b = new HDRFiltering(o);
  121625. this._onLoad = function() {
  121626. b.prefilter(i, _)
  121627. }
  121628. }
  121629. this._texture = o.createRawCubeTextureFromUrl(this.url, this.getScene(), this._size, 4, c, this._noMipmap, d, null, this._onLoad, this._onError)
  121630. }
  121631. ,
  121632. e.prototype.clone = function() {
  121633. var i = new e(this.url,this.getScene() || this._getEngine(),this._size,this._noMipmap,this._generateHarmonics,this.gammaSpace);
  121634. return i.level = this.level,
  121635. i.wrapU = this.wrapU,
  121636. i.wrapV = this.wrapV,
  121637. i.coordinatesIndex = this.coordinatesIndex,
  121638. i.coordinatesMode = this.coordinatesMode,
  121639. i
  121640. }
  121641. ,
  121642. e.prototype.delayLoad = function() {
  121643. this.delayLoadState === 4 && (this.delayLoadState = 1,
  121644. this._texture = this._getFromCache(this.url, this._noMipmap),
  121645. this._texture || this.loadTexture())
  121646. }
  121647. ,
  121648. e.prototype.getReflectionTextureMatrix = function() {
  121649. return this._textureMatrix
  121650. }
  121651. ,
  121652. e.prototype.setReflectionTextureMatrix = function(i) {
  121653. var o = this, s;
  121654. this._textureMatrix = i,
  121655. i.updateFlag !== this._textureMatrix.updateFlag && i.isIdentity() !== this._textureMatrix.isIdentity() && ((s = this.getScene()) === null || s === void 0 || s.markAllMaterialsAsDirty(1, function(c) {
  121656. return c.getActiveTextures().indexOf(o) !== -1
  121657. }))
  121658. }
  121659. ,
  121660. e.prototype.dispose = function() {
  121661. this.onLoadObservable.clear(),
  121662. a.prototype.dispose.call(this)
  121663. }
  121664. ,
  121665. e.Parse = function(i, o, s) {
  121666. var c = null;
  121667. return i.name && !i.isRenderTarget && (c = new e(s + i.name,o,i.size,i.noMipmap,i.generateHarmonics,i.useInGammaSpace),
  121668. c.name = i.name,
  121669. c.hasAlpha = i.hasAlpha,
  121670. c.level = i.level,
  121671. c.coordinatesMode = i.coordinatesMode,
  121672. c.isBlocking = i.isBlocking),
  121673. c && (i.boundingBoxPosition && (c.boundingBoxPosition = Vector3.FromArray(i.boundingBoxPosition)),
  121674. i.boundingBoxSize && (c.boundingBoxSize = Vector3.FromArray(i.boundingBoxSize)),
  121675. i.rotationY && (c.rotationY = i.rotationY)),
  121676. c
  121677. }
  121678. ,
  121679. e.prototype.serialize = function() {
  121680. if (!this.name)
  121681. return null;
  121682. var i = {};
  121683. return i.name = this.name,
  121684. i.hasAlpha = this.hasAlpha,
  121685. i.isCube = !0,
  121686. i.level = this.level,
  121687. i.size = this._size,
  121688. i.coordinatesMode = this.coordinatesMode,
  121689. i.useInGammaSpace = this.gammaSpace,
  121690. i.generateHarmonics = this._generateHarmonics,
  121691. i.customType = "BABYLON.HDRCubeTexture",
  121692. i.noMipmap = this._noMipmap,
  121693. i.isBlocking = this._isBlocking,
  121694. i.rotationY = this._rotationY,
  121695. i
  121696. }
  121697. ,
  121698. e._facesMapping = ["right", "left", "up", "down", "front", "back"],
  121699. e
  121700. }(BaseTexture);
  121701. RegisterClass("BABYLON.HDRCubeTexture", HDRCubeTexture);
  121702. var PhysicsJoint = function() {
  121703. function a(e, i) {
  121704. this.type = e,
  121705. this.jointData = i,
  121706. i.nativeParams = i.nativeParams || {}
  121707. }
  121708. return Object.defineProperty(a.prototype, "physicsJoint", {
  121709. get: function() {
  121710. return this._physicsJoint
  121711. },
  121712. set: function(e) {
  121713. this._physicsJoint,
  121714. this._physicsJoint = e
  121715. },
  121716. enumerable: !1,
  121717. configurable: !0
  121718. }),
  121719. Object.defineProperty(a.prototype, "physicsPlugin", {
  121720. set: function(e) {
  121721. this._physicsPlugin = e
  121722. },
  121723. enumerable: !1,
  121724. configurable: !0
  121725. }),
  121726. a.prototype.executeNativeFunction = function(e) {
  121727. e(this._physicsPlugin.world, this._physicsJoint)
  121728. }
  121729. ,
  121730. a.DistanceJoint = 0,
  121731. a.HingeJoint = 1,
  121732. a.BallAndSocketJoint = 2,
  121733. a.WheelJoint = 3,
  121734. a.SliderJoint = 4,
  121735. a.PrismaticJoint = 5,
  121736. a.UniversalJoint = 6,
  121737. a.Hinge2Joint = a.WheelJoint,
  121738. a.PointToPointJoint = 8,
  121739. a.SpringJoint = 9,
  121740. a.LockJoint = 10,
  121741. a
  121742. }();
  121743. (function(a) {
  121744. __extends(e, a);
  121745. function e(i) {
  121746. return a.call(this, PhysicsJoint.DistanceJoint, i) || this
  121747. }
  121748. return e.prototype.updateDistance = function(i, o) {
  121749. this._physicsPlugin.updateDistanceJoint(this, i, o)
  121750. }
  121751. ,
  121752. e
  121753. }
  121754. )(PhysicsJoint);
  121755. var MotorEnabledJoint = function(a) {
  121756. __extends(e, a);
  121757. function e(i, o) {
  121758. return a.call(this, i, o) || this
  121759. }
  121760. return e.prototype.setMotor = function(i, o) {
  121761. this._physicsPlugin.setMotor(this, i || 0, o)
  121762. }
  121763. ,
  121764. e.prototype.setLimit = function(i, o) {
  121765. this._physicsPlugin.setLimit(this, i, o)
  121766. }
  121767. ,
  121768. e
  121769. }(PhysicsJoint);
  121770. (function(a) {
  121771. __extends(e, a);
  121772. function e(i) {
  121773. return a.call(this, PhysicsJoint.HingeJoint, i) || this
  121774. }
  121775. return e.prototype.setMotor = function(i, o) {
  121776. this._physicsPlugin.setMotor(this, i || 0, o)
  121777. }
  121778. ,
  121779. e.prototype.setLimit = function(i, o) {
  121780. this._physicsPlugin.setLimit(this, i, o)
  121781. }
  121782. ,
  121783. e
  121784. }
  121785. )(MotorEnabledJoint);
  121786. (function(a) {
  121787. __extends(e, a);
  121788. function e(i) {
  121789. return a.call(this, PhysicsJoint.Hinge2Joint, i) || this
  121790. }
  121791. return e.prototype.setMotor = function(i, o, s) {
  121792. s === void 0 && (s = 0),
  121793. this._physicsPlugin.setMotor(this, i || 0, o, s)
  121794. }
  121795. ,
  121796. e.prototype.setLimit = function(i, o, s) {
  121797. s === void 0 && (s = 0),
  121798. this._physicsPlugin.setLimit(this, i, o, s)
  121799. }
  121800. ,
  121801. e
  121802. }
  121803. )(MotorEnabledJoint);
  121804. Mesh._PhysicsImpostorParser = function(a, e, i) {
  121805. return new PhysicsImpostor(e,i.physicsImpostor,{
  121806. mass: i.physicsMass,
  121807. friction: i.physicsFriction,
  121808. restitution: i.physicsRestitution
  121809. },a)
  121810. }
  121811. ;
  121812. var PhysicsImpostor = function() {
  121813. function a(e, i, o, s) {
  121814. var c = this;
  121815. if (o === void 0 && (o = {
  121816. mass: 0
  121817. }),
  121818. this.object = e,
  121819. this.type = i,
  121820. this._options = o,
  121821. this._scene = s,
  121822. this._pluginData = {},
  121823. this._bodyUpdateRequired = !1,
  121824. this._onBeforePhysicsStepCallbacks = new Array,
  121825. this._onAfterPhysicsStepCallbacks = new Array,
  121826. this._onPhysicsCollideCallbacks = [],
  121827. this._deltaPosition = Vector3.Zero(),
  121828. this._isDisposed = !1,
  121829. this.soft = !1,
  121830. this.segments = 0,
  121831. this._tmpQuat = new Quaternion,
  121832. this._tmpQuat2 = new Quaternion,
  121833. this.beforeStep = function() {
  121834. !c._physicsEngine || (c.object.translate(c._deltaPosition, -1),
  121835. c._deltaRotationConjugated && c.object.rotationQuaternion && c.object.rotationQuaternion.multiplyToRef(c._deltaRotationConjugated, c.object.rotationQuaternion),
  121836. c.object.computeWorldMatrix(!1),
  121837. c.object.parent && c.object.rotationQuaternion ? (c.getParentsRotation(),
  121838. c._tmpQuat.multiplyToRef(c.object.rotationQuaternion, c._tmpQuat)) : c._tmpQuat.copyFrom(c.object.rotationQuaternion || new Quaternion),
  121839. c._options.disableBidirectionalTransformation || c.object.rotationQuaternion && c._physicsEngine.getPhysicsPlugin().setPhysicsBodyTransformation(c, c.object.getAbsolutePosition(), c._tmpQuat),
  121840. c._onBeforePhysicsStepCallbacks.forEach(function(d) {
  121841. d(c)
  121842. }))
  121843. }
  121844. ,
  121845. this.afterStep = function() {
  121846. !c._physicsEngine || (c._onAfterPhysicsStepCallbacks.forEach(function(d) {
  121847. d(c)
  121848. }),
  121849. c._physicsEngine.getPhysicsPlugin().setTransformationFromPhysicsBody(c),
  121850. c.object.parent && c.object.rotationQuaternion && (c.getParentsRotation(),
  121851. c._tmpQuat.conjugateInPlace(),
  121852. c._tmpQuat.multiplyToRef(c.object.rotationQuaternion, c.object.rotationQuaternion)),
  121853. c.object.setAbsolutePosition(c.object.position),
  121854. c._deltaRotation && c.object.rotationQuaternion && c.object.rotationQuaternion.multiplyToRef(c._deltaRotation, c.object.rotationQuaternion),
  121855. c.object.translate(c._deltaPosition, 1))
  121856. }
  121857. ,
  121858. this.onCollideEvent = null,
  121859. this.onCollide = function(d) {
  121860. if (!(!c._onPhysicsCollideCallbacks.length && !c.onCollideEvent) && !!c._physicsEngine) {
  121861. var _ = c._physicsEngine.getImpostorWithPhysicsBody(d.body);
  121862. _ && (c.onCollideEvent && c.onCollideEvent(c, _),
  121863. c._onPhysicsCollideCallbacks.filter(function(b) {
  121864. return b.otherImpostors.indexOf(_) !== -1
  121865. }).forEach(function(b) {
  121866. b.callback(c, _, d.point)
  121867. }))
  121868. }
  121869. }
  121870. ,
  121871. !this.object) {
  121872. Logger$2.Error("No object was provided. A physics object is obligatory");
  121873. return
  121874. }
  121875. this.object.parent && o.mass !== 0 && Logger$2.Warn("A physics impostor has been created for an object which has a parent. Babylon physics currently works in local space so unexpected issues may occur."),
  121876. !this._scene && e.getScene && (this._scene = e.getScene()),
  121877. this._scene && (this.type > 100 && (this.soft = !0),
  121878. this._physicsEngine = this._scene.getPhysicsEngine(),
  121879. this._physicsEngine ? (this.object.rotationQuaternion || (this.object.rotation ? this.object.rotationQuaternion = Quaternion.RotationYawPitchRoll(this.object.rotation.y, this.object.rotation.x, this.object.rotation.z) : this.object.rotationQuaternion = new Quaternion),
  121880. this._options.mass = o.mass === void 0 ? 0 : o.mass,
  121881. this._options.friction = o.friction === void 0 ? .2 : o.friction,
  121882. this._options.restitution = o.restitution === void 0 ? .2 : o.restitution,
  121883. this.soft && (this._options.mass = this._options.mass > 0 ? this._options.mass : 1,
  121884. this._options.pressure = o.pressure === void 0 ? 200 : o.pressure,
  121885. this._options.stiffness = o.stiffness === void 0 ? 1 : o.stiffness,
  121886. this._options.velocityIterations = o.velocityIterations === void 0 ? 20 : o.velocityIterations,
  121887. this._options.positionIterations = o.positionIterations === void 0 ? 20 : o.positionIterations,
  121888. this._options.fixedPoints = o.fixedPoints === void 0 ? 0 : o.fixedPoints,
  121889. this._options.margin = o.margin === void 0 ? 0 : o.margin,
  121890. this._options.damping = o.damping === void 0 ? 0 : o.damping,
  121891. this._options.path = o.path === void 0 ? null : o.path,
  121892. this._options.shape = o.shape === void 0 ? null : o.shape),
  121893. this._joints = [],
  121894. !this.object.parent || this._options.ignoreParent ? this._init() : this.object.parent.physicsImpostor && Logger$2.Warn("You must affect impostors to children before affecting impostor to parent.")) : Logger$2.Error("Physics not enabled. Please use scene.enablePhysics(...) before creating impostors."))
  121895. }
  121896. return Object.defineProperty(a.prototype, "isDisposed", {
  121897. get: function() {
  121898. return this._isDisposed
  121899. },
  121900. enumerable: !1,
  121901. configurable: !0
  121902. }),
  121903. Object.defineProperty(a.prototype, "mass", {
  121904. get: function() {
  121905. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyMass(this) : 0
  121906. },
  121907. set: function(e) {
  121908. this.setMass(e)
  121909. },
  121910. enumerable: !1,
  121911. configurable: !0
  121912. }),
  121913. Object.defineProperty(a.prototype, "friction", {
  121914. get: function() {
  121915. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyFriction(this) : 0
  121916. },
  121917. set: function(e) {
  121918. !this._physicsEngine || this._physicsEngine.getPhysicsPlugin().setBodyFriction(this, e)
  121919. },
  121920. enumerable: !1,
  121921. configurable: !0
  121922. }),
  121923. Object.defineProperty(a.prototype, "restitution", {
  121924. get: function() {
  121925. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyRestitution(this) : 0
  121926. },
  121927. set: function(e) {
  121928. !this._physicsEngine || this._physicsEngine.getPhysicsPlugin().setBodyRestitution(this, e)
  121929. },
  121930. enumerable: !1,
  121931. configurable: !0
  121932. }),
  121933. Object.defineProperty(a.prototype, "pressure", {
  121934. get: function() {
  121935. if (!this._physicsEngine)
  121936. return 0;
  121937. var e = this._physicsEngine.getPhysicsPlugin();
  121938. return e.setBodyPressure ? e.getBodyPressure(this) : 0
  121939. },
  121940. set: function(e) {
  121941. if (!!this._physicsEngine) {
  121942. var i = this._physicsEngine.getPhysicsPlugin();
  121943. !i.setBodyPressure || i.setBodyPressure(this, e)
  121944. }
  121945. },
  121946. enumerable: !1,
  121947. configurable: !0
  121948. }),
  121949. Object.defineProperty(a.prototype, "stiffness", {
  121950. get: function() {
  121951. if (!this._physicsEngine)
  121952. return 0;
  121953. var e = this._physicsEngine.getPhysicsPlugin();
  121954. return e.getBodyStiffness ? e.getBodyStiffness(this) : 0
  121955. },
  121956. set: function(e) {
  121957. if (!!this._physicsEngine) {
  121958. var i = this._physicsEngine.getPhysicsPlugin();
  121959. !i.setBodyStiffness || i.setBodyStiffness(this, e)
  121960. }
  121961. },
  121962. enumerable: !1,
  121963. configurable: !0
  121964. }),
  121965. Object.defineProperty(a.prototype, "velocityIterations", {
  121966. get: function() {
  121967. if (!this._physicsEngine)
  121968. return 0;
  121969. var e = this._physicsEngine.getPhysicsPlugin();
  121970. return e.getBodyVelocityIterations ? e.getBodyVelocityIterations(this) : 0
  121971. },
  121972. set: function(e) {
  121973. if (!!this._physicsEngine) {
  121974. var i = this._physicsEngine.getPhysicsPlugin();
  121975. !i.setBodyVelocityIterations || i.setBodyVelocityIterations(this, e)
  121976. }
  121977. },
  121978. enumerable: !1,
  121979. configurable: !0
  121980. }),
  121981. Object.defineProperty(a.prototype, "positionIterations", {
  121982. get: function() {
  121983. if (!this._physicsEngine)
  121984. return 0;
  121985. var e = this._physicsEngine.getPhysicsPlugin();
  121986. return e.getBodyPositionIterations ? e.getBodyPositionIterations(this) : 0
  121987. },
  121988. set: function(e) {
  121989. if (!!this._physicsEngine) {
  121990. var i = this._physicsEngine.getPhysicsPlugin();
  121991. !i.setBodyPositionIterations || i.setBodyPositionIterations(this, e)
  121992. }
  121993. },
  121994. enumerable: !1,
  121995. configurable: !0
  121996. }),
  121997. a.prototype._init = function() {
  121998. !this._physicsEngine || (this._physicsEngine.removeImpostor(this),
  121999. this.physicsBody = null,
  122000. this._parent = this._parent || this._getPhysicsParent(),
  122001. !this._isDisposed && (!this.parent || this._options.ignoreParent) && this._physicsEngine.addImpostor(this))
  122002. }
  122003. ,
  122004. a.prototype._getPhysicsParent = function() {
  122005. if (this.object.parent instanceof AbstractMesh) {
  122006. var e = this.object.parent;
  122007. return e.physicsImpostor
  122008. }
  122009. return null
  122010. }
  122011. ,
  122012. a.prototype.isBodyInitRequired = function() {
  122013. return this._bodyUpdateRequired || !this._physicsBody && !this._parent
  122014. }
  122015. ,
  122016. a.prototype.setScalingUpdated = function() {
  122017. this.forceUpdate()
  122018. }
  122019. ,
  122020. a.prototype.forceUpdate = function() {
  122021. this._init(),
  122022. this.parent && !this._options.ignoreParent && this.parent.forceUpdate()
  122023. }
  122024. ,
  122025. Object.defineProperty(a.prototype, "physicsBody", {
  122026. get: function() {
  122027. return this._parent && !this._options.ignoreParent ? this._parent.physicsBody : this._physicsBody
  122028. },
  122029. set: function(e) {
  122030. this._physicsBody && this._physicsEngine && this._physicsEngine.getPhysicsPlugin().removePhysicsBody(this),
  122031. this._physicsBody = e,
  122032. this.resetUpdateFlags()
  122033. },
  122034. enumerable: !1,
  122035. configurable: !0
  122036. }),
  122037. Object.defineProperty(a.prototype, "parent", {
  122038. get: function() {
  122039. return !this._options.ignoreParent && this._parent ? this._parent : null
  122040. },
  122041. set: function(e) {
  122042. this._parent = e
  122043. },
  122044. enumerable: !1,
  122045. configurable: !0
  122046. }),
  122047. a.prototype.resetUpdateFlags = function() {
  122048. this._bodyUpdateRequired = !1
  122049. }
  122050. ,
  122051. a.prototype.getObjectExtendSize = function() {
  122052. if (this.object.getBoundingInfo) {
  122053. var e = this.object.rotationQuaternion
  122054. , i = this.object.scaling.clone();
  122055. this.object.rotationQuaternion = a.IDENTITY_QUATERNION;
  122056. var o = this.object.computeWorldMatrix && this.object.computeWorldMatrix(!0);
  122057. o && o.decompose(i, void 0, void 0);
  122058. var s = this.object.getBoundingInfo()
  122059. , c = s.boundingBox.extendSize.scale(2).multiplyInPlace(i);
  122060. return c.x = Math.abs(c.x),
  122061. c.y = Math.abs(c.y),
  122062. c.z = Math.abs(c.z),
  122063. this.object.rotationQuaternion = e,
  122064. this.object.computeWorldMatrix && this.object.computeWorldMatrix(!0),
  122065. c
  122066. } else
  122067. return a.DEFAULT_OBJECT_SIZE
  122068. }
  122069. ,
  122070. a.prototype.getObjectCenter = function() {
  122071. if (this.object.getBoundingInfo) {
  122072. var e = this.object.getBoundingInfo();
  122073. return e.boundingBox.centerWorld
  122074. } else
  122075. return this.object.position
  122076. }
  122077. ,
  122078. a.prototype.getParam = function(e) {
  122079. return this._options[e]
  122080. }
  122081. ,
  122082. a.prototype.setParam = function(e, i) {
  122083. this._options[e] = i,
  122084. this._bodyUpdateRequired = !0
  122085. }
  122086. ,
  122087. a.prototype.setMass = function(e) {
  122088. this.getParam("mass") !== e && this.setParam("mass", e),
  122089. this._physicsEngine && this._physicsEngine.getPhysicsPlugin().setBodyMass(this, e)
  122090. }
  122091. ,
  122092. a.prototype.getLinearVelocity = function() {
  122093. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getLinearVelocity(this) : Vector3.Zero()
  122094. }
  122095. ,
  122096. a.prototype.setLinearVelocity = function(e) {
  122097. this._physicsEngine && this._physicsEngine.getPhysicsPlugin().setLinearVelocity(this, e)
  122098. }
  122099. ,
  122100. a.prototype.getAngularVelocity = function() {
  122101. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getAngularVelocity(this) : Vector3.Zero()
  122102. }
  122103. ,
  122104. a.prototype.setAngularVelocity = function(e) {
  122105. this._physicsEngine && this._physicsEngine.getPhysicsPlugin().setAngularVelocity(this, e)
  122106. }
  122107. ,
  122108. a.prototype.executeNativeFunction = function(e) {
  122109. this._physicsEngine && e(this._physicsEngine.getPhysicsPlugin().world, this.physicsBody)
  122110. }
  122111. ,
  122112. a.prototype.registerBeforePhysicsStep = function(e) {
  122113. this._onBeforePhysicsStepCallbacks.push(e)
  122114. }
  122115. ,
  122116. a.prototype.unregisterBeforePhysicsStep = function(e) {
  122117. var i = this._onBeforePhysicsStepCallbacks.indexOf(e);
  122118. i > -1 ? this._onBeforePhysicsStepCallbacks.splice(i, 1) : Logger$2.Warn("Function to remove was not found")
  122119. }
  122120. ,
  122121. a.prototype.registerAfterPhysicsStep = function(e) {
  122122. this._onAfterPhysicsStepCallbacks.push(e)
  122123. }
  122124. ,
  122125. a.prototype.unregisterAfterPhysicsStep = function(e) {
  122126. var i = this._onAfterPhysicsStepCallbacks.indexOf(e);
  122127. i > -1 ? this._onAfterPhysicsStepCallbacks.splice(i, 1) : Logger$2.Warn("Function to remove was not found")
  122128. }
  122129. ,
  122130. a.prototype.registerOnPhysicsCollide = function(e, i) {
  122131. var o = e instanceof Array ? e : [e];
  122132. this._onPhysicsCollideCallbacks.push({
  122133. callback: i,
  122134. otherImpostors: o
  122135. })
  122136. }
  122137. ,
  122138. a.prototype.unregisterOnPhysicsCollide = function(e, i) {
  122139. var o = e instanceof Array ? e : [e]
  122140. , s = -1
  122141. , c = this._onPhysicsCollideCallbacks.some(function(d, _) {
  122142. if (d.callback === i && d.otherImpostors.length === o.length) {
  122143. var b = d.otherImpostors.every(function(k) {
  122144. return o.indexOf(k) > -1
  122145. });
  122146. return b && (s = _),
  122147. b
  122148. }
  122149. return !1
  122150. });
  122151. c ? this._onPhysicsCollideCallbacks.splice(s, 1) : Logger$2.Warn("Function to remove was not found")
  122152. }
  122153. ,
  122154. a.prototype.getParentsRotation = function() {
  122155. var e = this.object.parent;
  122156. for (this._tmpQuat.copyFromFloats(0, 0, 0, 1); e; )
  122157. e.rotationQuaternion ? this._tmpQuat2.copyFrom(e.rotationQuaternion) : Quaternion.RotationYawPitchRollToRef(e.rotation.y, e.rotation.x, e.rotation.z, this._tmpQuat2),
  122158. this._tmpQuat.multiplyToRef(this._tmpQuat2, this._tmpQuat),
  122159. e = e.parent;
  122160. return this._tmpQuat
  122161. }
  122162. ,
  122163. a.prototype.applyForce = function(e, i) {
  122164. return this._physicsEngine && this._physicsEngine.getPhysicsPlugin().applyForce(this, e, i),
  122165. this
  122166. }
  122167. ,
  122168. a.prototype.applyImpulse = function(e, i) {
  122169. return this._physicsEngine && this._physicsEngine.getPhysicsPlugin().applyImpulse(this, e, i),
  122170. this
  122171. }
  122172. ,
  122173. a.prototype.createJoint = function(e, i, o) {
  122174. var s = new PhysicsJoint(i,o);
  122175. return this.addJoint(e, s),
  122176. this
  122177. }
  122178. ,
  122179. a.prototype.addJoint = function(e, i) {
  122180. return this._joints.push({
  122181. otherImpostor: e,
  122182. joint: i
  122183. }),
  122184. this._physicsEngine && this._physicsEngine.addJoint(this, e, i),
  122185. this
  122186. }
  122187. ,
  122188. a.prototype.addAnchor = function(e, i, o, s, c) {
  122189. if (!this._physicsEngine)
  122190. return this;
  122191. var d = this._physicsEngine.getPhysicsPlugin();
  122192. return d.appendAnchor ? (this._physicsEngine && d.appendAnchor(this, e, i, o, s, c),
  122193. this) : this
  122194. }
  122195. ,
  122196. a.prototype.addHook = function(e, i, o, s) {
  122197. if (!this._physicsEngine)
  122198. return this;
  122199. var c = this._physicsEngine.getPhysicsPlugin();
  122200. return c.appendAnchor ? (this._physicsEngine && c.appendHook(this, e, i, o, s),
  122201. this) : this
  122202. }
  122203. ,
  122204. a.prototype.sleep = function() {
  122205. return this._physicsEngine && this._physicsEngine.getPhysicsPlugin().sleepBody(this),
  122206. this
  122207. }
  122208. ,
  122209. a.prototype.wakeUp = function() {
  122210. return this._physicsEngine && this._physicsEngine.getPhysicsPlugin().wakeUpBody(this),
  122211. this
  122212. }
  122213. ,
  122214. a.prototype.clone = function(e) {
  122215. return e ? new a(e,this.type,this._options,this._scene) : null
  122216. }
  122217. ,
  122218. a.prototype.dispose = function() {
  122219. var e = this;
  122220. !this._physicsEngine || (this._joints.forEach(function(i) {
  122221. e._physicsEngine && e._physicsEngine.removeJoint(e, i.otherImpostor, i.joint)
  122222. }),
  122223. this._physicsEngine.removeImpostor(this),
  122224. this.parent && this.parent.forceUpdate(),
  122225. this._isDisposed = !0)
  122226. }
  122227. ,
  122228. a.prototype.setDeltaPosition = function(e) {
  122229. this._deltaPosition.copyFrom(e)
  122230. }
  122231. ,
  122232. a.prototype.setDeltaRotation = function(e) {
  122233. this._deltaRotation || (this._deltaRotation = new Quaternion),
  122234. this._deltaRotation.copyFrom(e),
  122235. this._deltaRotationConjugated = this._deltaRotation.conjugate()
  122236. }
  122237. ,
  122238. a.prototype.getBoxSizeToRef = function(e) {
  122239. return this._physicsEngine && this._physicsEngine.getPhysicsPlugin().getBoxSizeToRef(this, e),
  122240. this
  122241. }
  122242. ,
  122243. a.prototype.getRadius = function() {
  122244. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getRadius(this) : 0
  122245. }
  122246. ,
  122247. a.prototype.syncBoneWithImpostor = function(e, i, o, s, c) {
  122248. var d = a._tmpVecs[0]
  122249. , _ = this.object;
  122250. if (_.rotationQuaternion)
  122251. if (c) {
  122252. var b = a._tmpQuat;
  122253. _.rotationQuaternion.multiplyToRef(c, b),
  122254. e.setRotationQuaternion(b, Space.WORLD, i)
  122255. } else
  122256. e.setRotationQuaternion(_.rotationQuaternion, Space.WORLD, i);
  122257. d.x = 0,
  122258. d.y = 0,
  122259. d.z = 0,
  122260. o && (d.x = o.x,
  122261. d.y = o.y,
  122262. d.z = o.z,
  122263. e.getDirectionToRef(d, i, d),
  122264. s == null && (s = o.length()),
  122265. d.x *= s,
  122266. d.y *= s,
  122267. d.z *= s),
  122268. e.getParent() ? (d.addInPlace(_.getAbsolutePosition()),
  122269. e.setAbsolutePosition(d, i)) : (i.setAbsolutePosition(_.getAbsolutePosition()),
  122270. i.position.x -= d.x,
  122271. i.position.y -= d.y,
  122272. i.position.z -= d.z)
  122273. }
  122274. ,
  122275. a.prototype.syncImpostorWithBone = function(e, i, o, s, c, d) {
  122276. var _ = this.object;
  122277. if (_.rotationQuaternion)
  122278. if (c) {
  122279. var b = a._tmpQuat;
  122280. e.getRotationQuaternionToRef(Space.WORLD, i, b),
  122281. b.multiplyToRef(c, _.rotationQuaternion)
  122282. } else
  122283. e.getRotationQuaternionToRef(Space.WORLD, i, _.rotationQuaternion);
  122284. var k = a._tmpVecs[0]
  122285. , j = a._tmpVecs[1];
  122286. d || (d = a._tmpVecs[2],
  122287. d.x = 0,
  122288. d.y = 1,
  122289. d.z = 0),
  122290. e.getDirectionToRef(d, i, j),
  122291. e.getAbsolutePositionToRef(i, k),
  122292. s == null && o && (s = o.length()),
  122293. s != null && (k.x += j.x * s,
  122294. k.y += j.y * s,
  122295. k.z += j.z * s),
  122296. _.setAbsolutePosition(k)
  122297. }
  122298. ,
  122299. a.DEFAULT_OBJECT_SIZE = new Vector3(1,1,1),
  122300. a.IDENTITY_QUATERNION = Quaternion.Identity(),
  122301. a._tmpVecs = ArrayTools.BuildArray(3, Vector3.Zero),
  122302. a._tmpQuat = Quaternion.Identity(),
  122303. a.NoImpostor = 0,
  122304. a.SphereImpostor = 1,
  122305. a.BoxImpostor = 2,
  122306. a.PlaneImpostor = 3,
  122307. a.MeshImpostor = 4,
  122308. a.CapsuleImpostor = 6,
  122309. a.CylinderImpostor = 7,
  122310. a.ParticleImpostor = 8,
  122311. a.HeightmapImpostor = 9,
  122312. a.ConvexHullImpostor = 10,
  122313. a.CustomImpostor = 100,
  122314. a.RopeImpostor = 101,
  122315. a.ClothImpostor = 102,
  122316. a.SoftbodyImpostor = 103,
  122317. a
  122318. }()
  122319. , PhysicsEngine = function() {
  122320. function a(e, i) {
  122321. if (i === void 0 && (i = a.DefaultPluginFactory()),
  122322. this._physicsPlugin = i,
  122323. this._impostors = [],
  122324. this._joints = [],
  122325. this._subTimeStep = 0,
  122326. !this._physicsPlugin.isSupported())
  122327. throw new Error("Physics Engine " + this._physicsPlugin.name + " cannot be found. Please make sure it is included.");
  122328. e = e || new Vector3(0,-9.807,0),
  122329. this.setGravity(e),
  122330. this.setTimeStep()
  122331. }
  122332. return a.DefaultPluginFactory = function() {
  122333. throw _WarnImport("CannonJSPlugin")
  122334. }
  122335. ,
  122336. a.prototype.setGravity = function(e) {
  122337. this.gravity = e,
  122338. this._physicsPlugin.setGravity(this.gravity)
  122339. }
  122340. ,
  122341. a.prototype.setTimeStep = function(e) {
  122342. e === void 0 && (e = 1 / 60),
  122343. this._physicsPlugin.setTimeStep(e)
  122344. }
  122345. ,
  122346. a.prototype.getTimeStep = function() {
  122347. return this._physicsPlugin.getTimeStep()
  122348. }
  122349. ,
  122350. a.prototype.setSubTimeStep = function(e) {
  122351. e === void 0 && (e = 0),
  122352. this._subTimeStep = e
  122353. }
  122354. ,
  122355. a.prototype.getSubTimeStep = function() {
  122356. return this._subTimeStep
  122357. }
  122358. ,
  122359. a.prototype.dispose = function() {
  122360. this._impostors.forEach(function(e) {
  122361. e.dispose()
  122362. }),
  122363. this._physicsPlugin.dispose()
  122364. }
  122365. ,
  122366. a.prototype.getPhysicsPluginName = function() {
  122367. return this._physicsPlugin.name
  122368. }
  122369. ,
  122370. a.prototype.addImpostor = function(e) {
  122371. e.uniqueId = this._impostors.push(e),
  122372. e.parent || this._physicsPlugin.generatePhysicsBody(e)
  122373. }
  122374. ,
  122375. a.prototype.removeImpostor = function(e) {
  122376. var i = this._impostors.indexOf(e);
  122377. if (i > -1) {
  122378. var o = this._impostors.splice(i, 1);
  122379. o.length && this.getPhysicsPlugin().removePhysicsBody(e)
  122380. }
  122381. }
  122382. ,
  122383. a.prototype.addJoint = function(e, i, o) {
  122384. var s = {
  122385. mainImpostor: e,
  122386. connectedImpostor: i,
  122387. joint: o
  122388. };
  122389. o.physicsPlugin = this._physicsPlugin,
  122390. this._joints.push(s),
  122391. this._physicsPlugin.generateJoint(s)
  122392. }
  122393. ,
  122394. a.prototype.removeJoint = function(e, i, o) {
  122395. var s = this._joints.filter(function(c) {
  122396. return c.connectedImpostor === i && c.joint === o && c.mainImpostor === e
  122397. });
  122398. s.length && this._physicsPlugin.removeJoint(s[0])
  122399. }
  122400. ,
  122401. a.prototype._step = function(e) {
  122402. var i = this;
  122403. this._impostors.forEach(function(o) {
  122404. o.isBodyInitRequired() && i._physicsPlugin.generatePhysicsBody(o)
  122405. }),
  122406. e > .1 ? e = .1 : e <= 0 && (e = 1 / 60),
  122407. this._physicsPlugin.executeStep(e, this._impostors)
  122408. }
  122409. ,
  122410. a.prototype.getPhysicsPlugin = function() {
  122411. return this._physicsPlugin
  122412. }
  122413. ,
  122414. a.prototype.getImpostors = function() {
  122415. return this._impostors
  122416. }
  122417. ,
  122418. a.prototype.getImpostorForPhysicsObject = function(e) {
  122419. for (var i = 0; i < this._impostors.length; ++i)
  122420. if (this._impostors[i].object === e)
  122421. return this._impostors[i];
  122422. return null
  122423. }
  122424. ,
  122425. a.prototype.getImpostorWithPhysicsBody = function(e) {
  122426. for (var i = 0; i < this._impostors.length; ++i)
  122427. if (this._impostors[i].physicsBody === e)
  122428. return this._impostors[i];
  122429. return null
  122430. }
  122431. ,
  122432. a.prototype.raycast = function(e, i) {
  122433. return this._physicsPlugin.raycast(e, i)
  122434. }
  122435. ,
  122436. a.Epsilon = .001,
  122437. a
  122438. }()
  122439. , PhysicsRaycastResult = function() {
  122440. function a() {
  122441. this._hasHit = !1,
  122442. this._hitDistance = 0,
  122443. this._hitNormalWorld = Vector3.Zero(),
  122444. this._hitPointWorld = Vector3.Zero(),
  122445. this._rayFromWorld = Vector3.Zero(),
  122446. this._rayToWorld = Vector3.Zero()
  122447. }
  122448. return Object.defineProperty(a.prototype, "hasHit", {
  122449. get: function() {
  122450. return this._hasHit
  122451. },
  122452. enumerable: !1,
  122453. configurable: !0
  122454. }),
  122455. Object.defineProperty(a.prototype, "hitDistance", {
  122456. get: function() {
  122457. return this._hitDistance
  122458. },
  122459. enumerable: !1,
  122460. configurable: !0
  122461. }),
  122462. Object.defineProperty(a.prototype, "hitNormalWorld", {
  122463. get: function() {
  122464. return this._hitNormalWorld
  122465. },
  122466. enumerable: !1,
  122467. configurable: !0
  122468. }),
  122469. Object.defineProperty(a.prototype, "hitPointWorld", {
  122470. get: function() {
  122471. return this._hitPointWorld
  122472. },
  122473. enumerable: !1,
  122474. configurable: !0
  122475. }),
  122476. Object.defineProperty(a.prototype, "rayFromWorld", {
  122477. get: function() {
  122478. return this._rayFromWorld
  122479. },
  122480. enumerable: !1,
  122481. configurable: !0
  122482. }),
  122483. Object.defineProperty(a.prototype, "rayToWorld", {
  122484. get: function() {
  122485. return this._rayToWorld
  122486. },
  122487. enumerable: !1,
  122488. configurable: !0
  122489. }),
  122490. a.prototype.setHitData = function(e, i) {
  122491. this._hasHit = !0,
  122492. this._hitNormalWorld = new Vector3(e.x,e.y,e.z),
  122493. this._hitPointWorld = new Vector3(i.x,i.y,i.z)
  122494. }
  122495. ,
  122496. a.prototype.setHitDistance = function(e) {
  122497. this._hitDistance = e
  122498. }
  122499. ,
  122500. a.prototype.calculateHitDistance = function() {
  122501. this._hitDistance = Vector3.Distance(this._rayFromWorld, this._hitPointWorld)
  122502. }
  122503. ,
  122504. a.prototype.reset = function(e, i) {
  122505. e === void 0 && (e = Vector3.Zero()),
  122506. i === void 0 && (i = Vector3.Zero()),
  122507. this._rayFromWorld = e,
  122508. this._rayToWorld = i,
  122509. this._hasHit = !1,
  122510. this._hitDistance = 0,
  122511. this._hitNormalWorld = Vector3.Zero(),
  122512. this._hitPointWorld = Vector3.Zero()
  122513. }
  122514. ,
  122515. a
  122516. }()
  122517. , CannonJSPlugin = function() {
  122518. function a(e, i, o) {
  122519. if (e === void 0 && (e = !0),
  122520. i === void 0 && (i = 10),
  122521. o === void 0 && (o = CANNON),
  122522. this._useDeltaForWorldStep = e,
  122523. this.name = "CannonJSPlugin",
  122524. this._physicsMaterials = new Array,
  122525. this._fixedTimeStep = 1 / 60,
  122526. this._physicsBodysToRemoveAfterStep = new Array,
  122527. this._firstFrame = !0,
  122528. this._tmpQuaternion = new Quaternion,
  122529. this._minus90X = new Quaternion(-.7071067811865475,0,0,.7071067811865475),
  122530. this._plus90X = new Quaternion(.7071067811865475,0,0,.7071067811865475),
  122531. this._tmpPosition = Vector3.Zero(),
  122532. this._tmpDeltaPosition = Vector3.Zero(),
  122533. this._tmpUnityRotation = new Quaternion,
  122534. this.BJSCANNON = o,
  122535. !this.isSupported()) {
  122536. Logger$2.Error("CannonJS is not available. Please make sure you included the js file.");
  122537. return
  122538. }
  122539. this._extendNamespace(),
  122540. this.world = new this.BJSCANNON.World,
  122541. this.world.broadphase = new this.BJSCANNON.NaiveBroadphase,
  122542. this.world.solver.iterations = i,
  122543. this._cannonRaycastResult = new this.BJSCANNON.RaycastResult,
  122544. this._raycastResult = new PhysicsRaycastResult
  122545. }
  122546. return a.prototype.setGravity = function(e) {
  122547. var i = e;
  122548. this.world.gravity.set(i.x, i.y, i.z)
  122549. }
  122550. ,
  122551. a.prototype.setTimeStep = function(e) {
  122552. this._fixedTimeStep = e
  122553. }
  122554. ,
  122555. a.prototype.getTimeStep = function() {
  122556. return this._fixedTimeStep
  122557. }
  122558. ,
  122559. a.prototype.executeStep = function(e, i) {
  122560. if (this._firstFrame) {
  122561. this._firstFrame = !1;
  122562. for (var o = 0, s = i; o < s.length; o++) {
  122563. var c = s[o];
  122564. c.type == PhysicsImpostor.HeightmapImpostor || c.type === PhysicsImpostor.PlaneImpostor || c.beforeStep()
  122565. }
  122566. }
  122567. this.world.step(this._useDeltaForWorldStep ? e : this._fixedTimeStep),
  122568. this._removeMarkedPhysicsBodiesFromWorld()
  122569. }
  122570. ,
  122571. a.prototype._removeMarkedPhysicsBodiesFromWorld = function() {
  122572. var e = this;
  122573. this._physicsBodysToRemoveAfterStep.length > 0 && (this._physicsBodysToRemoveAfterStep.forEach(function(i) {
  122574. typeof e.world.removeBody == "function" ? e.world.removeBody(i) : e.world.remove(i)
  122575. }),
  122576. this._physicsBodysToRemoveAfterStep = [])
  122577. }
  122578. ,
  122579. a.prototype.applyImpulse = function(e, i, o) {
  122580. var s = new this.BJSCANNON.Vec3(o.x,o.y,o.z)
  122581. , c = new this.BJSCANNON.Vec3(i.x,i.y,i.z);
  122582. e.physicsBody.applyImpulse(c, s)
  122583. }
  122584. ,
  122585. a.prototype.applyForce = function(e, i, o) {
  122586. var s = new this.BJSCANNON.Vec3(o.x,o.y,o.z)
  122587. , c = new this.BJSCANNON.Vec3(i.x,i.y,i.z);
  122588. e.physicsBody.applyForce(c, s)
  122589. }
  122590. ,
  122591. a.prototype.generatePhysicsBody = function(e) {
  122592. if (this._removeMarkedPhysicsBodiesFromWorld(),
  122593. e.parent) {
  122594. e.physicsBody && (this.removePhysicsBody(e),
  122595. e.forceUpdate());
  122596. return
  122597. }
  122598. if (e.isBodyInitRequired()) {
  122599. var i = this._createShape(e)
  122600. , o = e.physicsBody;
  122601. o && this.removePhysicsBody(e);
  122602. var s = this._addMaterial("mat-" + e.uniqueId, e.getParam("friction"), e.getParam("restitution"))
  122603. , c = {
  122604. mass: e.getParam("mass"),
  122605. material: s
  122606. }
  122607. , d = e.getParam("nativeOptions");
  122608. for (var _ in d)
  122609. d.hasOwnProperty(_) && (c[_] = d[_]);
  122610. e.physicsBody = new this.BJSCANNON.Body(c),
  122611. e.physicsBody.addEventListener("collide", e.onCollide),
  122612. this.world.addEventListener("preStep", e.beforeStep),
  122613. this.world.addEventListener("postStep", e.afterStep),
  122614. e.physicsBody.addShape(i),
  122615. typeof this.world.addBody == "function" ? this.world.addBody(e.physicsBody) : this.world.add(e.physicsBody),
  122616. o && ["force", "torque", "velocity", "angularVelocity"].forEach(function(b) {
  122617. var k = o[b];
  122618. e.physicsBody[b].set(k.x, k.y, k.z)
  122619. }),
  122620. this._processChildMeshes(e)
  122621. }
  122622. this._updatePhysicsBodyTransformation(e)
  122623. }
  122624. ,
  122625. a.prototype._processChildMeshes = function(e) {
  122626. var i = this
  122627. , o = e.object.getChildMeshes ? e.object.getChildMeshes(!0) : []
  122628. , s = e.object.rotationQuaternion;
  122629. if (s ? s.conjugateToRef(this._tmpQuaternion) : this._tmpQuaternion.set(0, 0, 0, 1),
  122630. o.length) {
  122631. var c = function(d) {
  122632. if (!!d.rotationQuaternion) {
  122633. var _ = d.getPhysicsImpostor();
  122634. if (_) {
  122635. var b = _.parent;
  122636. if (b !== e && d.parent) {
  122637. var k = d.getAbsolutePosition().subtract(d.parent.getAbsolutePosition())
  122638. , j = d.rotationQuaternion.multiply(i._tmpQuaternion);
  122639. _.physicsBody && (i.removePhysicsBody(_),
  122640. _.physicsBody = null),
  122641. _.parent = e,
  122642. _.resetUpdateFlags(),
  122643. e.physicsBody.addShape(i._createShape(_), new i.BJSCANNON.Vec3(k.x,k.y,k.z), new i.BJSCANNON.Quaternion(j.x,j.y,j.z,j.w)),
  122644. e.physicsBody.mass += _.getParam("mass")
  122645. }
  122646. }
  122647. d.getChildMeshes(!0).filter(function($) {
  122648. return !!$.physicsImpostor
  122649. }).forEach(c)
  122650. }
  122651. };
  122652. o.filter(function(d) {
  122653. return !!d.physicsImpostor
  122654. }).forEach(c)
  122655. }
  122656. }
  122657. ,
  122658. a.prototype.removePhysicsBody = function(e) {
  122659. e.physicsBody.removeEventListener("collide", e.onCollide),
  122660. this.world.removeEventListener("preStep", e.beforeStep),
  122661. this.world.removeEventListener("postStep", e.afterStep),
  122662. this._physicsBodysToRemoveAfterStep.indexOf(e.physicsBody) === -1 && this._physicsBodysToRemoveAfterStep.push(e.physicsBody)
  122663. }
  122664. ,
  122665. a.prototype.generateJoint = function(e) {
  122666. var i = e.mainImpostor.physicsBody
  122667. , o = e.connectedImpostor.physicsBody;
  122668. if (!(!i || !o)) {
  122669. var s, c = e.joint.jointData, d = {
  122670. pivotA: c.mainPivot ? new this.BJSCANNON.Vec3().set(c.mainPivot.x, c.mainPivot.y, c.mainPivot.z) : null,
  122671. pivotB: c.connectedPivot ? new this.BJSCANNON.Vec3().set(c.connectedPivot.x, c.connectedPivot.y, c.connectedPivot.z) : null,
  122672. axisA: c.mainAxis ? new this.BJSCANNON.Vec3().set(c.mainAxis.x, c.mainAxis.y, c.mainAxis.z) : null,
  122673. axisB: c.connectedAxis ? new this.BJSCANNON.Vec3().set(c.connectedAxis.x, c.connectedAxis.y, c.connectedAxis.z) : null,
  122674. maxForce: c.nativeParams.maxForce,
  122675. collideConnected: !!c.collision
  122676. };
  122677. switch (e.joint.type) {
  122678. case PhysicsJoint.HingeJoint:
  122679. case PhysicsJoint.Hinge2Joint:
  122680. s = new this.BJSCANNON.HingeConstraint(i,o,d);
  122681. break;
  122682. case PhysicsJoint.DistanceJoint:
  122683. s = new this.BJSCANNON.DistanceConstraint(i,o,c.maxDistance || 2);
  122684. break;
  122685. case PhysicsJoint.SpringJoint:
  122686. var _ = c;
  122687. s = new this.BJSCANNON.Spring(i,o,{
  122688. restLength: _.length,
  122689. stiffness: _.stiffness,
  122690. damping: _.damping,
  122691. localAnchorA: d.pivotA,
  122692. localAnchorB: d.pivotB
  122693. });
  122694. break;
  122695. case PhysicsJoint.LockJoint:
  122696. s = new this.BJSCANNON.LockConstraint(i,o,d);
  122697. break;
  122698. case PhysicsJoint.PointToPointJoint:
  122699. case PhysicsJoint.BallAndSocketJoint:
  122700. default:
  122701. s = new this.BJSCANNON.PointToPointConstraint(i,d.pivotA,o,d.pivotB,d.maxForce);
  122702. break
  122703. }
  122704. s.collideConnected = !!c.collision,
  122705. e.joint.physicsJoint = s,
  122706. e.joint.type !== PhysicsJoint.SpringJoint ? this.world.addConstraint(s) : (e.joint.jointData.forceApplicationCallback = e.joint.jointData.forceApplicationCallback || function() {
  122707. s.applyForce()
  122708. }
  122709. ,
  122710. e.mainImpostor.registerAfterPhysicsStep(e.joint.jointData.forceApplicationCallback))
  122711. }
  122712. }
  122713. ,
  122714. a.prototype.removeJoint = function(e) {
  122715. e.joint.type !== PhysicsJoint.SpringJoint ? this.world.removeConstraint(e.joint.physicsJoint) : e.mainImpostor.unregisterAfterPhysicsStep(e.joint.jointData.forceApplicationCallback)
  122716. }
  122717. ,
  122718. a.prototype._addMaterial = function(e, i, o) {
  122719. var s, c;
  122720. for (s = 0; s < this._physicsMaterials.length; s++)
  122721. if (c = this._physicsMaterials[s],
  122722. c.friction === i && c.restitution === o)
  122723. return c;
  122724. var d = new this.BJSCANNON.Material(e);
  122725. return d.friction = i,
  122726. d.restitution = o,
  122727. this._physicsMaterials.push(d),
  122728. d
  122729. }
  122730. ,
  122731. a.prototype._checkWithEpsilon = function(e) {
  122732. return e < PhysicsEngine.Epsilon ? PhysicsEngine.Epsilon : e
  122733. }
  122734. ,
  122735. a.prototype._createShape = function(e) {
  122736. var i = e.object, o, s = e.getObjectExtendSize();
  122737. switch (e.type) {
  122738. case PhysicsImpostor.SphereImpostor:
  122739. var c = s.x
  122740. , d = s.y
  122741. , _ = s.z;
  122742. o = new this.BJSCANNON.Sphere(Math.max(this._checkWithEpsilon(c), this._checkWithEpsilon(d), this._checkWithEpsilon(_)) / 2);
  122743. break;
  122744. case PhysicsImpostor.CylinderImpostor:
  122745. var b = e.getParam("nativeOptions");
  122746. b || (b = {});
  122747. var k = b.radiusTop !== void 0 ? b.radiusTop : this._checkWithEpsilon(s.x) / 2
  122748. , j = b.radiusBottom !== void 0 ? b.radiusBottom : this._checkWithEpsilon(s.x) / 2
  122749. , $ = b.height !== void 0 ? b.height : this._checkWithEpsilon(s.y)
  122750. , _e = b.numSegments !== void 0 ? b.numSegments : 16;
  122751. o = new this.BJSCANNON.Cylinder(k,j,$,_e);
  122752. var et = new this.BJSCANNON.Quaternion;
  122753. et.setFromAxisAngle(new this.BJSCANNON.Vec3(1,0,0), -Math.PI / 2);
  122754. var tt = new this.BJSCANNON.Vec3(0,0,0);
  122755. o.transformAllPoints(tt, et);
  122756. break;
  122757. case PhysicsImpostor.BoxImpostor:
  122758. var rt = s.scale(.5);
  122759. o = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(this._checkWithEpsilon(rt.x),this._checkWithEpsilon(rt.y),this._checkWithEpsilon(rt.z)));
  122760. break;
  122761. case PhysicsImpostor.PlaneImpostor:
  122762. Logger$2.Warn("Attention, PlaneImposter might not behave as you expect. Consider using BoxImposter instead"),
  122763. o = new this.BJSCANNON.Plane;
  122764. break;
  122765. case PhysicsImpostor.MeshImpostor:
  122766. var it = i.getVerticesData ? i.getVerticesData(VertexBuffer.PositionKind) : []
  122767. , nt = i.getIndices ? i.getIndices() : [];
  122768. if (!it)
  122769. return;
  122770. var ot = i.position.clone()
  122771. , at = i.rotation && i.rotation.clone()
  122772. , st = i.rotationQuaternion && i.rotationQuaternion.clone();
  122773. i.position.copyFromFloats(0, 0, 0),
  122774. i.rotation && i.rotation.copyFromFloats(0, 0, 0),
  122775. i.rotationQuaternion && i.rotationQuaternion.copyFrom(e.getParentsRotation()),
  122776. i.rotationQuaternion && i.parent && i.rotationQuaternion.conjugateInPlace();
  122777. var ut = i.computeWorldMatrix(!0), ct = new Array, lt;
  122778. for (lt = 0; lt < it.length; lt += 3)
  122779. Vector3.TransformCoordinates(Vector3.FromArray(it, lt), ut).toArray(ct, lt);
  122780. Logger$2.Warn("MeshImpostor only collides against spheres."),
  122781. o = new this.BJSCANNON.Trimesh(ct,nt),
  122782. i.position.copyFrom(ot),
  122783. at && i.rotation && i.rotation.copyFrom(at),
  122784. st && i.rotationQuaternion && i.rotationQuaternion.copyFrom(st);
  122785. break;
  122786. case PhysicsImpostor.HeightmapImpostor:
  122787. var ft = i.position.clone()
  122788. , ht = i.rotation && i.rotation.clone()
  122789. , pt = i.rotationQuaternion && i.rotationQuaternion.clone();
  122790. i.position.copyFromFloats(0, 0, 0),
  122791. i.rotation && i.rotation.copyFromFloats(0, 0, 0),
  122792. i.rotationQuaternion && i.rotationQuaternion.copyFrom(e.getParentsRotation()),
  122793. i.rotationQuaternion && i.parent && i.rotationQuaternion.conjugateInPlace(),
  122794. i.rotationQuaternion && i.rotationQuaternion.multiplyInPlace(this._minus90X),
  122795. o = this._createHeightmap(i),
  122796. i.position.copyFrom(ft),
  122797. ht && i.rotation && i.rotation.copyFrom(ht),
  122798. pt && i.rotationQuaternion && i.rotationQuaternion.copyFrom(pt),
  122799. i.computeWorldMatrix(!0);
  122800. break;
  122801. case PhysicsImpostor.ParticleImpostor:
  122802. o = new this.BJSCANNON.Particle;
  122803. break;
  122804. case PhysicsImpostor.NoImpostor:
  122805. o = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(0,0,0));
  122806. break
  122807. }
  122808. return o
  122809. }
  122810. ,
  122811. a.prototype._createHeightmap = function(e, i) {
  122812. var o = e.getVerticesData(VertexBuffer.PositionKind), s = e.computeWorldMatrix(!0), c = new Array, d;
  122813. for (d = 0; d < o.length; d += 3)
  122814. Vector3.TransformCoordinates(Vector3.FromArray(o, d), s).toArray(c, d);
  122815. o = c;
  122816. for (var _ = new Array, b = i || ~~(Math.sqrt(o.length / 3) - 1), k = e.getBoundingInfo(), j = Math.min(k.boundingBox.extendSizeWorld.x, k.boundingBox.extendSizeWorld.y), $ = k.boundingBox.extendSizeWorld.z, _e = j * 2 / b, et = 0; et < o.length; et = et + 3) {
  122817. var tt = Math.round(o[et + 0] / _e + b / 2)
  122818. , rt = Math.round((o[et + 1] / _e - b / 2) * -1)
  122819. , it = -o[et + 2] + $;
  122820. _[tt] || (_[tt] = []),
  122821. _[tt][rt] || (_[tt][rt] = it),
  122822. _[tt][rt] = Math.max(it, _[tt][rt])
  122823. }
  122824. for (var tt = 0; tt <= b; ++tt) {
  122825. if (!_[tt]) {
  122826. for (var nt = 1; !_[(tt + nt) % b]; )
  122827. nt++;
  122828. _[tt] = _[(tt + nt) % b].slice()
  122829. }
  122830. for (var rt = 0; rt <= b; ++rt)
  122831. if (!_[tt][rt]) {
  122832. for (var nt = 1, ot; ot === void 0; )
  122833. ot = _[tt][(rt + nt++) % b];
  122834. _[tt][rt] = ot
  122835. }
  122836. }
  122837. var at = new this.BJSCANNON.Heightfield(_,{
  122838. elementSize: _e
  122839. });
  122840. return at.minY = $,
  122841. at
  122842. }
  122843. ,
  122844. a.prototype._updatePhysicsBodyTransformation = function(e) {
  122845. var i = e.object;
  122846. if (i.computeWorldMatrix && i.computeWorldMatrix(!0),
  122847. !!i.getBoundingInfo()) {
  122848. var o = e.getObjectCenter();
  122849. this._tmpDeltaPosition.copyFrom(i.getAbsolutePivotPoint().subtract(o)),
  122850. this._tmpDeltaPosition.divideInPlace(e.object.scaling),
  122851. this._tmpPosition.copyFrom(o);
  122852. var s = i.rotationQuaternion;
  122853. if (!!s) {
  122854. if ((e.type === PhysicsImpostor.PlaneImpostor || e.type === PhysicsImpostor.HeightmapImpostor) && (s = s.multiply(this._minus90X),
  122855. e.setDeltaRotation(this._plus90X)),
  122856. e.type === PhysicsImpostor.HeightmapImpostor) {
  122857. var c = i
  122858. , d = c.getBoundingInfo()
  122859. , _ = c.rotationQuaternion;
  122860. c.rotationQuaternion = this._tmpUnityRotation,
  122861. c.computeWorldMatrix(!0);
  122862. var b = o.clone()
  122863. , k = c.getPivotMatrix();
  122864. k ? k = k.clone() : k = Matrix.Identity();
  122865. var j = Matrix.Translation(d.boundingBox.extendSizeWorld.x, 0, -d.boundingBox.extendSizeWorld.z);
  122866. c.setPreTransformMatrix(j),
  122867. c.computeWorldMatrix(!0),
  122868. d = c.getBoundingInfo();
  122869. var $ = d.boundingBox.centerWorld.subtract(o).subtract(c.position).negate();
  122870. this._tmpPosition.copyFromFloats($.x, $.y - d.boundingBox.extendSizeWorld.y, $.z),
  122871. this._tmpDeltaPosition.copyFrom(d.boundingBox.centerWorld.subtract(b)),
  122872. this._tmpDeltaPosition.y += d.boundingBox.extendSizeWorld.y,
  122873. c.rotationQuaternion = _,
  122874. c.setPreTransformMatrix(k),
  122875. c.computeWorldMatrix(!0)
  122876. } else
  122877. e.type === PhysicsImpostor.MeshImpostor && this._tmpDeltaPosition.copyFromFloats(0, 0, 0);
  122878. e.setDeltaPosition(this._tmpDeltaPosition),
  122879. e.physicsBody.position.set(this._tmpPosition.x, this._tmpPosition.y, this._tmpPosition.z),
  122880. e.physicsBody.quaternion.set(s.x, s.y, s.z, s.w)
  122881. }
  122882. }
  122883. }
  122884. ,
  122885. a.prototype.setTransformationFromPhysicsBody = function(e) {
  122886. if (e.object.position.set(e.physicsBody.position.x, e.physicsBody.position.y, e.physicsBody.position.z),
  122887. e.object.rotationQuaternion) {
  122888. var i = e.physicsBody.quaternion;
  122889. e.object.rotationQuaternion.set(i.x, i.y, i.z, i.w)
  122890. }
  122891. }
  122892. ,
  122893. a.prototype.setPhysicsBodyTransformation = function(e, i, o) {
  122894. e.physicsBody.position.set(i.x, i.y, i.z),
  122895. e.physicsBody.quaternion.set(o.x, o.y, o.z, o.w)
  122896. }
  122897. ,
  122898. a.prototype.isSupported = function() {
  122899. return this.BJSCANNON !== void 0
  122900. }
  122901. ,
  122902. a.prototype.setLinearVelocity = function(e, i) {
  122903. e.physicsBody.velocity.set(i.x, i.y, i.z)
  122904. }
  122905. ,
  122906. a.prototype.setAngularVelocity = function(e, i) {
  122907. e.physicsBody.angularVelocity.set(i.x, i.y, i.z)
  122908. }
  122909. ,
  122910. a.prototype.getLinearVelocity = function(e) {
  122911. var i = e.physicsBody.velocity;
  122912. return i ? new Vector3(i.x,i.y,i.z) : null
  122913. }
  122914. ,
  122915. a.prototype.getAngularVelocity = function(e) {
  122916. var i = e.physicsBody.angularVelocity;
  122917. return i ? new Vector3(i.x,i.y,i.z) : null
  122918. }
  122919. ,
  122920. a.prototype.setBodyMass = function(e, i) {
  122921. e.physicsBody.mass = i,
  122922. e.physicsBody.updateMassProperties()
  122923. }
  122924. ,
  122925. a.prototype.getBodyMass = function(e) {
  122926. return e.physicsBody.mass
  122927. }
  122928. ,
  122929. a.prototype.getBodyFriction = function(e) {
  122930. return e.physicsBody.material.friction
  122931. }
  122932. ,
  122933. a.prototype.setBodyFriction = function(e, i) {
  122934. e.physicsBody.material.friction = i
  122935. }
  122936. ,
  122937. a.prototype.getBodyRestitution = function(e) {
  122938. return e.physicsBody.material.restitution
  122939. }
  122940. ,
  122941. a.prototype.setBodyRestitution = function(e, i) {
  122942. e.physicsBody.material.restitution = i
  122943. }
  122944. ,
  122945. a.prototype.sleepBody = function(e) {
  122946. e.physicsBody.sleep()
  122947. }
  122948. ,
  122949. a.prototype.wakeUpBody = function(e) {
  122950. e.physicsBody.wakeUp()
  122951. }
  122952. ,
  122953. a.prototype.updateDistanceJoint = function(e, i) {
  122954. e.physicsJoint.distance = i
  122955. }
  122956. ,
  122957. a.prototype.setMotor = function(e, i, o, s) {
  122958. s || (e.physicsJoint.enableMotor(),
  122959. e.physicsJoint.setMotorSpeed(i),
  122960. o && this.setLimit(e, o))
  122961. }
  122962. ,
  122963. a.prototype.setLimit = function(e, i, o) {
  122964. e.physicsJoint.motorEquation.maxForce = i,
  122965. e.physicsJoint.motorEquation.minForce = o === void 0 ? -i : o
  122966. }
  122967. ,
  122968. a.prototype.syncMeshWithImpostor = function(e, i) {
  122969. var o = i.physicsBody;
  122970. e.position.x = o.position.x,
  122971. e.position.y = o.position.y,
  122972. e.position.z = o.position.z,
  122973. e.rotationQuaternion && (e.rotationQuaternion.x = o.quaternion.x,
  122974. e.rotationQuaternion.y = o.quaternion.y,
  122975. e.rotationQuaternion.z = o.quaternion.z,
  122976. e.rotationQuaternion.w = o.quaternion.w)
  122977. }
  122978. ,
  122979. a.prototype.getRadius = function(e) {
  122980. var i = e.physicsBody.shapes[0];
  122981. return i.boundingSphereRadius
  122982. }
  122983. ,
  122984. a.prototype.getBoxSizeToRef = function(e, i) {
  122985. var o = e.physicsBody.shapes[0];
  122986. i.x = o.halfExtents.x * 2,
  122987. i.y = o.halfExtents.y * 2,
  122988. i.z = o.halfExtents.z * 2
  122989. }
  122990. ,
  122991. a.prototype.dispose = function() {}
  122992. ,
  122993. a.prototype._extendNamespace = function() {
  122994. var e = new this.BJSCANNON.Vec3
  122995. , i = this.BJSCANNON;
  122996. this.BJSCANNON.World.prototype.step = function(o, s, c) {
  122997. if (c = c || 10,
  122998. s = s || 0,
  122999. s === 0)
  123000. this.internalStep(o),
  123001. this.time += o;
  123002. else {
  123003. var d = Math.floor((this.time + s) / o) - Math.floor(this.time / o);
  123004. d = Math.min(d, c) || 1;
  123005. for (var _ = performance.now(), b = 0; b !== d && (this.internalStep(o),
  123006. !(performance.now() - _ > o * 1e3)); b++)
  123007. ;
  123008. this.time += s;
  123009. for (var k = this.time % o, j = k / o, $ = e, _e = this.bodies, et = 0; et !== _e.length; et++) {
  123010. var tt = _e[et];
  123011. tt.type !== i.Body.STATIC && tt.sleepState !== i.Body.SLEEPING ? (tt.position.vsub(tt.previousPosition, $),
  123012. $.scale(j, $),
  123013. tt.position.vadd($, tt.interpolatedPosition)) : (tt.interpolatedPosition.set(tt.position.x, tt.position.y, tt.position.z),
  123014. tt.interpolatedQuaternion.set(tt.quaternion.x, tt.quaternion.y, tt.quaternion.z, tt.quaternion.w))
  123015. }
  123016. }
  123017. }
  123018. }
  123019. ,
  123020. a.prototype.raycast = function(e, i) {
  123021. return this._cannonRaycastResult.reset(),
  123022. this.world.raycastClosest(e, i, {}, this._cannonRaycastResult),
  123023. this._raycastResult.reset(e, i),
  123024. this._cannonRaycastResult.hasHit && (this._raycastResult.setHitData({
  123025. x: this._cannonRaycastResult.hitNormalWorld.x,
  123026. y: this._cannonRaycastResult.hitNormalWorld.y,
  123027. z: this._cannonRaycastResult.hitNormalWorld.z
  123028. }, {
  123029. x: this._cannonRaycastResult.hitPointWorld.x,
  123030. y: this._cannonRaycastResult.hitPointWorld.y,
  123031. z: this._cannonRaycastResult.hitPointWorld.z
  123032. }),
  123033. this._raycastResult.setHitDistance(this._cannonRaycastResult.distance)),
  123034. this._raycastResult
  123035. }
  123036. ,
  123037. a
  123038. }();
  123039. PhysicsEngine.DefaultPluginFactory = function() {
  123040. return new CannonJSPlugin
  123041. }
  123042. ;
  123043. var OimoJSPlugin = function() {
  123044. function a(e, i, o) {
  123045. e === void 0 && (e = !0),
  123046. o === void 0 && (o = OIMO),
  123047. this._useDeltaForWorldStep = e,
  123048. this.name = "OimoJSPlugin",
  123049. this._fixedTimeStep = 1 / 60,
  123050. this._tmpImpostorsArray = [],
  123051. this._tmpPositionVector = Vector3.Zero(),
  123052. this.BJSOIMO = o,
  123053. this.world = new this.BJSOIMO.World({
  123054. iterations: i
  123055. }),
  123056. this.world.clear(),
  123057. this._raycastResult = new PhysicsRaycastResult
  123058. }
  123059. return a.prototype.setGravity = function(e) {
  123060. this.world.gravity.set(e.x, e.y, e.z)
  123061. }
  123062. ,
  123063. a.prototype.setTimeStep = function(e) {
  123064. this.world.timeStep = e
  123065. }
  123066. ,
  123067. a.prototype.getTimeStep = function() {
  123068. return this.world.timeStep
  123069. }
  123070. ,
  123071. a.prototype.executeStep = function(e, i) {
  123072. var o = this;
  123073. i.forEach(function(_) {
  123074. _.beforeStep()
  123075. }),
  123076. this.world.timeStep = this._useDeltaForWorldStep ? e : this._fixedTimeStep,
  123077. this.world.step(),
  123078. i.forEach(function(_) {
  123079. _.afterStep(),
  123080. o._tmpImpostorsArray[_.uniqueId] = _
  123081. });
  123082. for (var s = this.world.contacts; s !== null; ) {
  123083. if (s.touching && !s.body1.sleeping && !s.body2.sleeping) {
  123084. s = s.next;
  123085. continue
  123086. }
  123087. var c = this._tmpImpostorsArray[+s.body1.name]
  123088. , d = this._tmpImpostorsArray[+s.body2.name];
  123089. if (!c || !d) {
  123090. s = s.next;
  123091. continue
  123092. }
  123093. c.onCollide({
  123094. body: d.physicsBody,
  123095. point: null
  123096. }),
  123097. d.onCollide({
  123098. body: c.physicsBody,
  123099. point: null
  123100. }),
  123101. s = s.next
  123102. }
  123103. }
  123104. ,
  123105. a.prototype.applyImpulse = function(e, i, o) {
  123106. var s = e.physicsBody.mass;
  123107. e.physicsBody.applyImpulse(o.scale(this.world.invScale), i.scale(this.world.invScale * s))
  123108. }
  123109. ,
  123110. a.prototype.applyForce = function(e, i, o) {
  123111. Logger$2.Warn("Oimo doesn't support applying force. Using impule instead."),
  123112. this.applyImpulse(e, i, o)
  123113. }
  123114. ,
  123115. a.prototype.generatePhysicsBody = function(e) {
  123116. var i = this;
  123117. if (e.parent) {
  123118. e.physicsBody && (this.removePhysicsBody(e),
  123119. e.forceUpdate());
  123120. return
  123121. }
  123122. if (e.isBodyInitRequired()) {
  123123. var o = {
  123124. name: e.uniqueId,
  123125. config: [e.getParam("mass") || .001, e.getParam("friction"), e.getParam("restitution")],
  123126. size: [],
  123127. type: [],
  123128. pos: [],
  123129. posShape: [],
  123130. rot: [],
  123131. rotShape: [],
  123132. move: e.getParam("mass") !== 0,
  123133. density: e.getParam("mass"),
  123134. friction: e.getParam("friction"),
  123135. restitution: e.getParam("restitution"),
  123136. world: this.world
  123137. }
  123138. , s = [e]
  123139. , c = function(b) {
  123140. !b.getChildMeshes || b.getChildMeshes().forEach(function(k) {
  123141. k.physicsImpostor && s.push(k.physicsImpostor)
  123142. })
  123143. };
  123144. c(e.object);
  123145. var d = function(b) {
  123146. return Math.max(b, PhysicsEngine.Epsilon)
  123147. }
  123148. , _ = new Quaternion;
  123149. s.forEach(function(b) {
  123150. if (!!b.object.rotationQuaternion) {
  123151. var k = b.object.rotationQuaternion;
  123152. _.copyFrom(k),
  123153. b.object.rotationQuaternion.set(0, 0, 0, 1),
  123154. b.object.computeWorldMatrix(!0);
  123155. var j = _.toEulerAngles()
  123156. , $ = b.getObjectExtendSize()
  123157. , _e = 57.29577951308232;
  123158. if (b === e) {
  123159. var et = e.getObjectCenter();
  123160. e.object.getAbsolutePivotPoint().subtractToRef(et, i._tmpPositionVector),
  123161. i._tmpPositionVector.divideInPlace(e.object.scaling),
  123162. o.pos.push(et.x),
  123163. o.pos.push(et.y),
  123164. o.pos.push(et.z),
  123165. o.posShape.push(0, 0, 0),
  123166. o.rotShape.push(0, 0, 0)
  123167. } else {
  123168. var tt = b.object.position.clone();
  123169. o.posShape.push(tt.x),
  123170. o.posShape.push(tt.y),
  123171. o.posShape.push(tt.z),
  123172. o.rotShape.push(j.x * _e, j.y * _e, j.z * _e)
  123173. }
  123174. switch (b.object.rotationQuaternion.copyFrom(_),
  123175. b.type) {
  123176. case PhysicsImpostor.ParticleImpostor:
  123177. Logger$2.Warn("No Particle support in OIMO.js. using SphereImpostor instead");
  123178. case PhysicsImpostor.SphereImpostor:
  123179. var rt = $.x
  123180. , it = $.y
  123181. , nt = $.z
  123182. , ot = Math.max(d(rt), d(it), d(nt)) / 2;
  123183. o.type.push("sphere"),
  123184. o.size.push(ot),
  123185. o.size.push(ot),
  123186. o.size.push(ot);
  123187. break;
  123188. case PhysicsImpostor.CylinderImpostor:
  123189. var at = d($.x) / 2
  123190. , st = d($.y);
  123191. o.type.push("cylinder"),
  123192. o.size.push(at),
  123193. o.size.push(st),
  123194. o.size.push(st);
  123195. break;
  123196. case PhysicsImpostor.PlaneImpostor:
  123197. case PhysicsImpostor.BoxImpostor:
  123198. default:
  123199. var at = d($.x)
  123200. , st = d($.y)
  123201. , ut = d($.z);
  123202. o.type.push("box"),
  123203. o.size.push(at),
  123204. o.size.push(st),
  123205. o.size.push(ut);
  123206. break
  123207. }
  123208. b.object.rotationQuaternion = k
  123209. }
  123210. }),
  123211. e.physicsBody = this.world.add(o),
  123212. e.physicsBody.resetQuaternion(_),
  123213. e.physicsBody.updatePosition(0)
  123214. } else
  123215. this._tmpPositionVector.copyFromFloats(0, 0, 0);
  123216. e.setDeltaPosition(this._tmpPositionVector)
  123217. }
  123218. ,
  123219. a.prototype.removePhysicsBody = function(e) {
  123220. this.world.removeRigidBody(e.physicsBody)
  123221. }
  123222. ,
  123223. a.prototype.generateJoint = function(e) {
  123224. var i = e.mainImpostor.physicsBody
  123225. , o = e.connectedImpostor.physicsBody;
  123226. if (!(!i || !o)) {
  123227. var s = e.joint.jointData, c = s.nativeParams || {}, d, _ = {
  123228. body1: i,
  123229. body2: o,
  123230. axe1: c.axe1 || (s.mainAxis ? s.mainAxis.asArray() : null),
  123231. axe2: c.axe2 || (s.connectedAxis ? s.connectedAxis.asArray() : null),
  123232. pos1: c.pos1 || (s.mainPivot ? s.mainPivot.asArray() : null),
  123233. pos2: c.pos2 || (s.connectedPivot ? s.connectedPivot.asArray() : null),
  123234. min: c.min,
  123235. max: c.max,
  123236. collision: c.collision || s.collision,
  123237. spring: c.spring,
  123238. world: this.world
  123239. };
  123240. switch (e.joint.type) {
  123241. case PhysicsJoint.BallAndSocketJoint:
  123242. d = "jointBall";
  123243. break;
  123244. case PhysicsJoint.SpringJoint:
  123245. Logger$2.Warn("OIMO.js doesn't support Spring Constraint. Simulating using DistanceJoint instead");
  123246. var b = s;
  123247. _.min = b.length || _.min,
  123248. _.max = Math.max(_.min, _.max);
  123249. case PhysicsJoint.DistanceJoint:
  123250. d = "jointDistance",
  123251. _.max = s.maxDistance;
  123252. break;
  123253. case PhysicsJoint.PrismaticJoint:
  123254. d = "jointPrisme";
  123255. break;
  123256. case PhysicsJoint.SliderJoint:
  123257. d = "jointSlide";
  123258. break;
  123259. case PhysicsJoint.WheelJoint:
  123260. d = "jointWheel";
  123261. break;
  123262. case PhysicsJoint.HingeJoint:
  123263. default:
  123264. d = "jointHinge";
  123265. break
  123266. }
  123267. _.type = d,
  123268. e.joint.physicsJoint = this.world.add(_)
  123269. }
  123270. }
  123271. ,
  123272. a.prototype.removeJoint = function(e) {
  123273. try {
  123274. this.world.removeJoint(e.joint.physicsJoint)
  123275. } catch (i) {
  123276. Logger$2.Warn(i)
  123277. }
  123278. }
  123279. ,
  123280. a.prototype.isSupported = function() {
  123281. return this.BJSOIMO !== void 0
  123282. }
  123283. ,
  123284. a.prototype.setTransformationFromPhysicsBody = function(e) {
  123285. if (!e.physicsBody.sleeping) {
  123286. if (e.physicsBody.shapes.next) {
  123287. for (var i = e.physicsBody.shapes; i.next; )
  123288. i = i.next;
  123289. e.object.position.set(i.position.x, i.position.y, i.position.z)
  123290. } else {
  123291. var o = e.physicsBody.getPosition();
  123292. e.object.position.set(o.x, o.y, o.z)
  123293. }
  123294. if (e.object.rotationQuaternion) {
  123295. var s = e.physicsBody.getQuaternion();
  123296. e.object.rotationQuaternion.set(s.x, s.y, s.z, s.w)
  123297. }
  123298. }
  123299. }
  123300. ,
  123301. a.prototype.setPhysicsBodyTransformation = function(e, i, o) {
  123302. var s = e.physicsBody;
  123303. e.physicsBody.shapes.next || (s.position.set(i.x, i.y, i.z),
  123304. s.orientation.set(o.x, o.y, o.z, o.w),
  123305. s.syncShapes(),
  123306. s.awake())
  123307. }
  123308. ,
  123309. a.prototype.setLinearVelocity = function(e, i) {
  123310. e.physicsBody.linearVelocity.set(i.x, i.y, i.z)
  123311. }
  123312. ,
  123313. a.prototype.setAngularVelocity = function(e, i) {
  123314. e.physicsBody.angularVelocity.set(i.x, i.y, i.z)
  123315. }
  123316. ,
  123317. a.prototype.getLinearVelocity = function(e) {
  123318. var i = e.physicsBody.linearVelocity;
  123319. return i ? new Vector3(i.x,i.y,i.z) : null
  123320. }
  123321. ,
  123322. a.prototype.getAngularVelocity = function(e) {
  123323. var i = e.physicsBody.angularVelocity;
  123324. return i ? new Vector3(i.x,i.y,i.z) : null
  123325. }
  123326. ,
  123327. a.prototype.setBodyMass = function(e, i) {
  123328. var o = i === 0;
  123329. e.physicsBody.shapes.density = o ? 1 : i,
  123330. e.physicsBody.setupMass(o ? 2 : 1)
  123331. }
  123332. ,
  123333. a.prototype.getBodyMass = function(e) {
  123334. return e.physicsBody.shapes.density
  123335. }
  123336. ,
  123337. a.prototype.getBodyFriction = function(e) {
  123338. return e.physicsBody.shapes.friction
  123339. }
  123340. ,
  123341. a.prototype.setBodyFriction = function(e, i) {
  123342. e.physicsBody.shapes.friction = i
  123343. }
  123344. ,
  123345. a.prototype.getBodyRestitution = function(e) {
  123346. return e.physicsBody.shapes.restitution
  123347. }
  123348. ,
  123349. a.prototype.setBodyRestitution = function(e, i) {
  123350. e.physicsBody.shapes.restitution = i
  123351. }
  123352. ,
  123353. a.prototype.sleepBody = function(e) {
  123354. e.physicsBody.sleep()
  123355. }
  123356. ,
  123357. a.prototype.wakeUpBody = function(e) {
  123358. e.physicsBody.awake()
  123359. }
  123360. ,
  123361. a.prototype.updateDistanceJoint = function(e, i, o) {
  123362. e.physicsJoint.limitMotor.upperLimit = i,
  123363. o !== void 0 && (e.physicsJoint.limitMotor.lowerLimit = o)
  123364. }
  123365. ,
  123366. a.prototype.setMotor = function(e, i, o, s) {
  123367. o !== void 0 ? Logger$2.Warn("OimoJS plugin currently has unexpected behavior when using setMotor with force parameter") : o = 1e6,
  123368. i *= -1;
  123369. var c = s ? e.physicsJoint.rotationalLimitMotor2 : e.physicsJoint.rotationalLimitMotor1 || e.physicsJoint.rotationalLimitMotor || e.physicsJoint.limitMotor;
  123370. c && c.setMotor(i, o)
  123371. }
  123372. ,
  123373. a.prototype.setLimit = function(e, i, o, s) {
  123374. var c = s ? e.physicsJoint.rotationalLimitMotor2 : e.physicsJoint.rotationalLimitMotor1 || e.physicsJoint.rotationalLimitMotor || e.physicsJoint.limitMotor;
  123375. c && c.setLimit(i, o === void 0 ? -i : o)
  123376. }
  123377. ,
  123378. a.prototype.syncMeshWithImpostor = function(e, i) {
  123379. var o = i.physicsBody;
  123380. e.position.x = o.position.x,
  123381. e.position.y = o.position.y,
  123382. e.position.z = o.position.z,
  123383. e.rotationQuaternion && (e.rotationQuaternion.x = o.orientation.x,
  123384. e.rotationQuaternion.y = o.orientation.y,
  123385. e.rotationQuaternion.z = o.orientation.z,
  123386. e.rotationQuaternion.w = o.orientation.s)
  123387. }
  123388. ,
  123389. a.prototype.getRadius = function(e) {
  123390. return e.physicsBody.shapes.radius
  123391. }
  123392. ,
  123393. a.prototype.getBoxSizeToRef = function(e, i) {
  123394. var o = e.physicsBody.shapes;
  123395. i.x = o.halfWidth * 2,
  123396. i.y = o.halfHeight * 2,
  123397. i.z = o.halfDepth * 2
  123398. }
  123399. ,
  123400. a.prototype.dispose = function() {
  123401. this.world.clear()
  123402. }
  123403. ,
  123404. a.prototype.raycast = function(e, i) {
  123405. return Logger$2.Warn("raycast is not currently supported by the Oimo physics plugin"),
  123406. this._raycastResult.reset(e, i),
  123407. this._raycastResult
  123408. }
  123409. ,
  123410. a
  123411. }()
  123412. , AmmoJSPlugin = function() {
  123413. function a(e, i, o) {
  123414. var s = this;
  123415. if (e === void 0 && (e = !0),
  123416. i === void 0 && (i = Ammo),
  123417. o === void 0 && (o = null),
  123418. this._useDeltaForWorldStep = e,
  123419. this.bjsAMMO = {},
  123420. this.name = "AmmoJSPlugin",
  123421. this._timeStep = 1 / 60,
  123422. this._fixedTimeStep = 1 / 60,
  123423. this._maxSteps = 5,
  123424. this._tmpQuaternion = new Quaternion,
  123425. this._tmpContactCallbackResult = !1,
  123426. this._tmpContactPoint = new Vector3,
  123427. this._tmpVec3 = new Vector3,
  123428. this._tmpMatrix = new Matrix,
  123429. typeof i == "function") {
  123430. Logger$2.Error("AmmoJS is not ready. Please make sure you await Ammo() before using the plugin.");
  123431. return
  123432. } else
  123433. this.bjsAMMO = i;
  123434. if (!this.isSupported()) {
  123435. Logger$2.Error("AmmoJS is not available. Please make sure you included the js file.");
  123436. return
  123437. }
  123438. this._collisionConfiguration = new this.bjsAMMO.btSoftBodyRigidBodyCollisionConfiguration,
  123439. this._dispatcher = new this.bjsAMMO.btCollisionDispatcher(this._collisionConfiguration),
  123440. this._overlappingPairCache = o || new this.bjsAMMO.btDbvtBroadphase,
  123441. this._solver = new this.bjsAMMO.btSequentialImpulseConstraintSolver,
  123442. this._softBodySolver = new this.bjsAMMO.btDefaultSoftBodySolver,
  123443. this.world = new this.bjsAMMO.btSoftRigidDynamicsWorld(this._dispatcher,this._overlappingPairCache,this._solver,this._collisionConfiguration,this._softBodySolver),
  123444. this._tmpAmmoConcreteContactResultCallback = new this.bjsAMMO.ConcreteContactResultCallback,
  123445. this._tmpAmmoConcreteContactResultCallback.addSingleResult = function(c, d, _, b) {
  123446. c = s.bjsAMMO.wrapPointer(c, s.bjsAMMO.btManifoldPoint);
  123447. var k = c.getPositionWorldOnA();
  123448. s._tmpContactPoint.x = k.x(),
  123449. s._tmpContactPoint.y = k.y(),
  123450. s._tmpContactPoint.z = k.z(),
  123451. s._tmpContactCallbackResult = !0
  123452. }
  123453. ,
  123454. this._raycastResult = new PhysicsRaycastResult,
  123455. this._tmpAmmoTransform = new this.bjsAMMO.btTransform,
  123456. this._tmpAmmoTransform.setIdentity(),
  123457. this._tmpAmmoQuaternion = new this.bjsAMMO.btQuaternion(0,0,0,1),
  123458. this._tmpAmmoVectorA = new this.bjsAMMO.btVector3(0,0,0),
  123459. this._tmpAmmoVectorB = new this.bjsAMMO.btVector3(0,0,0),
  123460. this._tmpAmmoVectorC = new this.bjsAMMO.btVector3(0,0,0),
  123461. this._tmpAmmoVectorD = new this.bjsAMMO.btVector3(0,0,0)
  123462. }
  123463. return a.prototype.setGravity = function(e) {
  123464. this._tmpAmmoVectorA.setValue(e.x, e.y, e.z),
  123465. this.world.setGravity(this._tmpAmmoVectorA),
  123466. this.world.getWorldInfo().set_m_gravity(this._tmpAmmoVectorA)
  123467. }
  123468. ,
  123469. a.prototype.setTimeStep = function(e) {
  123470. this._timeStep = e
  123471. }
  123472. ,
  123473. a.prototype.setFixedTimeStep = function(e) {
  123474. this._fixedTimeStep = e
  123475. }
  123476. ,
  123477. a.prototype.setMaxSteps = function(e) {
  123478. this._maxSteps = e
  123479. }
  123480. ,
  123481. a.prototype.getTimeStep = function() {
  123482. return this._timeStep
  123483. }
  123484. ,
  123485. a.prototype._isImpostorInContact = function(e) {
  123486. return this._tmpContactCallbackResult = !1,
  123487. this.world.contactTest(e.physicsBody, this._tmpAmmoConcreteContactResultCallback),
  123488. this._tmpContactCallbackResult
  123489. }
  123490. ,
  123491. a.prototype._isImpostorPairInContact = function(e, i) {
  123492. return this._tmpContactCallbackResult = !1,
  123493. this.world.contactPairTest(e.physicsBody, i.physicsBody, this._tmpAmmoConcreteContactResultCallback),
  123494. this._tmpContactCallbackResult
  123495. }
  123496. ,
  123497. a.prototype._stepSimulation = function(e, i, o) {
  123498. if (e === void 0 && (e = 1 / 60),
  123499. i === void 0 && (i = 10),
  123500. o === void 0 && (o = 1 / 60),
  123501. i == 0)
  123502. this.world.stepSimulation(e, 0);
  123503. else
  123504. for (; i > 0 && e > 0; )
  123505. e - o < o ? (this.world.stepSimulation(e, 0),
  123506. e = 0) : (e -= o,
  123507. this.world.stepSimulation(o, 0)),
  123508. i--
  123509. }
  123510. ,
  123511. a.prototype.executeStep = function(e, i) {
  123512. for (var o = 0, s = i; o < s.length; o++) {
  123513. var c = s[o];
  123514. c.soft || c.beforeStep()
  123515. }
  123516. this._stepSimulation(this._useDeltaForWorldStep ? e : this._timeStep, this._maxSteps, this._fixedTimeStep);
  123517. for (var d = 0, _ = i; d < _.length; d++) {
  123518. var b = _[d];
  123519. if (b.soft ? this._afterSoftStep(b) : b.afterStep(),
  123520. b._onPhysicsCollideCallbacks.length > 0 && this._isImpostorInContact(b))
  123521. for (var k = 0, j = b._onPhysicsCollideCallbacks; k < j.length; k++)
  123522. for (var $ = j[k], _e = 0, et = $.otherImpostors; _e < et.length; _e++) {
  123523. var tt = et[_e];
  123524. (b.physicsBody.isActive() || tt.physicsBody.isActive()) && this._isImpostorPairInContact(b, tt) && (b.onCollide({
  123525. body: tt.physicsBody,
  123526. point: this._tmpContactPoint
  123527. }),
  123528. tt.onCollide({
  123529. body: b.physicsBody,
  123530. point: this._tmpContactPoint
  123531. }))
  123532. }
  123533. }
  123534. }
  123535. ,
  123536. a.prototype._afterSoftStep = function(e) {
  123537. e.type === PhysicsImpostor.RopeImpostor ? this._ropeStep(e) : this._softbodyOrClothStep(e)
  123538. }
  123539. ,
  123540. a.prototype._ropeStep = function(e) {
  123541. for (var i = e.physicsBody.get_m_nodes(), o = i.size(), s, c, d, _, b, k = new Array, j = 0; j < o; j++)
  123542. s = i.at(j),
  123543. c = s.get_m_x(),
  123544. d = c.x(),
  123545. _ = c.y(),
  123546. b = c.z(),
  123547. k.push(new Vector3(d,_,b));
  123548. var $ = e.object
  123549. , _e = e.getParam("shape");
  123550. e._isFromLine ? e.object = CreateLines("lines", {
  123551. points: k,
  123552. instance: $
  123553. }) : e.object = ExtrudeShape("ext", {
  123554. shape: _e,
  123555. path: k,
  123556. instance: $
  123557. })
  123558. }
  123559. ,
  123560. a.prototype._softbodyOrClothStep = function(e) {
  123561. var i = e.type === PhysicsImpostor.ClothImpostor ? 1 : -1
  123562. , o = e.object
  123563. , s = o.getVerticesData(VertexBuffer.PositionKind);
  123564. s || (s = []);
  123565. var c = o.getVerticesData(VertexBuffer.NormalKind);
  123566. c || (c = []);
  123567. for (var d = s.length / 3, _ = e.physicsBody.get_m_nodes(), b, k, j, $, _e, et, tt, rt, it, nt = 0; nt < d; nt++) {
  123568. b = _.at(nt),
  123569. k = b.get_m_x(),
  123570. $ = k.x(),
  123571. _e = k.y(),
  123572. et = k.z() * i;
  123573. var j = b.get_m_n();
  123574. tt = j.x(),
  123575. rt = j.y(),
  123576. it = j.z() * i,
  123577. s[3 * nt] = $,
  123578. s[3 * nt + 1] = _e,
  123579. s[3 * nt + 2] = et,
  123580. c[3 * nt] = tt,
  123581. c[3 * nt + 1] = rt,
  123582. c[3 * nt + 2] = it
  123583. }
  123584. var ot = new VertexData;
  123585. ot.positions = s,
  123586. ot.normals = c,
  123587. ot.uvs = o.getVerticesData(VertexBuffer.UVKind),
  123588. ot.colors = o.getVerticesData(VertexBuffer.ColorKind),
  123589. o && o.getIndices && (ot.indices = o.getIndices()),
  123590. ot.applyToMesh(o)
  123591. }
  123592. ,
  123593. a.prototype.applyImpulse = function(e, i, o) {
  123594. if (e.soft)
  123595. Logger$2.Warn("Cannot be applied to a soft body");
  123596. else {
  123597. e.physicsBody.activate();
  123598. var s = this._tmpAmmoVectorA
  123599. , c = this._tmpAmmoVectorB;
  123600. e.object && e.object.getWorldMatrix && o.subtractInPlace(e.object.getWorldMatrix().getTranslation()),
  123601. s.setValue(o.x, o.y, o.z),
  123602. c.setValue(i.x, i.y, i.z),
  123603. e.physicsBody.applyImpulse(c, s)
  123604. }
  123605. }
  123606. ,
  123607. a.prototype.applyForce = function(e, i, o) {
  123608. if (e.soft)
  123609. Logger$2.Warn("Cannot be applied to a soft body");
  123610. else {
  123611. e.physicsBody.activate();
  123612. var s = this._tmpAmmoVectorA
  123613. , c = this._tmpAmmoVectorB;
  123614. if (s.setValue(o.x, o.y, o.z),
  123615. e.object && e.object.getWorldMatrix) {
  123616. var d = e.object.getWorldMatrix().getTranslation();
  123617. s.x -= d.x,
  123618. s.y -= d.y,
  123619. s.z -= d.z
  123620. }
  123621. c.setValue(i.x, i.y, i.z),
  123622. e.physicsBody.applyForce(c, s)
  123623. }
  123624. }
  123625. ,
  123626. a.prototype.generatePhysicsBody = function(e) {
  123627. if (e._pluginData.toDispose = [],
  123628. e.parent) {
  123629. e.physicsBody && (this.removePhysicsBody(e),
  123630. e.forceUpdate());
  123631. return
  123632. }
  123633. if (e.isBodyInitRequired()) {
  123634. var i = this._createShape(e)
  123635. , o = e.getParam("mass");
  123636. if (e._pluginData.mass = o,
  123637. e.soft)
  123638. i.get_m_cfg().set_collisions(17),
  123639. i.get_m_cfg().set_kDP(e.getParam("damping")),
  123640. this.bjsAMMO.castObject(i, this.bjsAMMO.btCollisionObject).getCollisionShape().setMargin(e.getParam("margin")),
  123641. i.setActivationState(a.DISABLE_DEACTIVATION_FLAG),
  123642. this.world.addSoftBody(i, 1, -1),
  123643. e.physicsBody = i,
  123644. e._pluginData.toDispose.push(i),
  123645. this.setBodyPressure(e, 0),
  123646. e.type === PhysicsImpostor.SoftbodyImpostor && this.setBodyPressure(e, e.getParam("pressure")),
  123647. this.setBodyStiffness(e, e.getParam("stiffness")),
  123648. this.setBodyVelocityIterations(e, e.getParam("velocityIterations")),
  123649. this.setBodyPositionIterations(e, e.getParam("positionIterations"));
  123650. else {
  123651. var s = new this.bjsAMMO.btVector3(0,0,0)
  123652. , c = new this.bjsAMMO.btTransform;
  123653. e.object.computeWorldMatrix(!0),
  123654. c.setIdentity(),
  123655. o !== 0 && i.calculateLocalInertia(o, s),
  123656. this._tmpAmmoVectorA.setValue(e.object.position.x, e.object.position.y, e.object.position.z),
  123657. this._tmpAmmoQuaternion.setValue(e.object.rotationQuaternion.x, e.object.rotationQuaternion.y, e.object.rotationQuaternion.z, e.object.rotationQuaternion.w),
  123658. c.setOrigin(this._tmpAmmoVectorA),
  123659. c.setRotation(this._tmpAmmoQuaternion);
  123660. var d = new this.bjsAMMO.btDefaultMotionState(c)
  123661. , _ = new this.bjsAMMO.btRigidBodyConstructionInfo(o,d,i,s)
  123662. , b = new this.bjsAMMO.btRigidBody(_);
  123663. if (o === 0 && (b.setCollisionFlags(b.getCollisionFlags() | a.KINEMATIC_FLAG),
  123664. b.setActivationState(a.DISABLE_DEACTIVATION_FLAG)),
  123665. e.type == PhysicsImpostor.NoImpostor && !i.getChildShape && b.setCollisionFlags(b.getCollisionFlags() | a.DISABLE_COLLISION_FLAG),
  123666. e.type !== PhysicsImpostor.MeshImpostor && e.type !== PhysicsImpostor.NoImpostor) {
  123667. var k = e.object.getBoundingInfo();
  123668. this._tmpVec3.copyFrom(e.object.getAbsolutePosition()),
  123669. this._tmpVec3.subtractInPlace(k.boundingBox.centerWorld),
  123670. this._tmpVec3.x /= e.object.scaling.x,
  123671. this._tmpVec3.y /= e.object.scaling.y,
  123672. this._tmpVec3.z /= e.object.scaling.z,
  123673. e.setDeltaPosition(this._tmpVec3)
  123674. }
  123675. var j = e.getParam("group")
  123676. , $ = e.getParam("mask");
  123677. j && $ ? this.world.addRigidBody(b, j, $) : this.world.addRigidBody(b),
  123678. e.physicsBody = b,
  123679. e._pluginData.toDispose = e._pluginData.toDispose.concat([b, _, d, c, s, i])
  123680. }
  123681. this.setBodyRestitution(e, e.getParam("restitution")),
  123682. this.setBodyFriction(e, e.getParam("friction"))
  123683. }
  123684. }
  123685. ,
  123686. a.prototype.removePhysicsBody = function(e) {
  123687. var i = this;
  123688. this.world && (e.soft ? this.world.removeSoftBody(e.physicsBody) : this.world.removeRigidBody(e.physicsBody),
  123689. e._pluginData && (e._pluginData.toDispose.forEach(function(o) {
  123690. i.bjsAMMO.destroy(o)
  123691. }),
  123692. e._pluginData.toDispose = []))
  123693. }
  123694. ,
  123695. a.prototype.generateJoint = function(e) {
  123696. var i = e.mainImpostor.physicsBody
  123697. , o = e.connectedImpostor.physicsBody;
  123698. if (!(!i || !o)) {
  123699. var s = e.joint.jointData;
  123700. s.mainPivot || (s.mainPivot = new Vector3(0,0,0)),
  123701. s.connectedPivot || (s.connectedPivot = new Vector3(0,0,0));
  123702. var c;
  123703. switch (e.joint.type) {
  123704. case PhysicsJoint.DistanceJoint:
  123705. var d = s.maxDistance;
  123706. d && (s.mainPivot = new Vector3(0,-d / 2,0),
  123707. s.connectedPivot = new Vector3(0,d / 2,0)),
  123708. c = new this.bjsAMMO.btPoint2PointConstraint(i,o,new this.bjsAMMO.btVector3(s.mainPivot.x,s.mainPivot.y,s.mainPivot.z),new this.bjsAMMO.btVector3(s.connectedPivot.x,s.connectedPivot.y,s.connectedPivot.z));
  123709. break;
  123710. case PhysicsJoint.HingeJoint:
  123711. s.mainAxis || (s.mainAxis = new Vector3(0,0,0)),
  123712. s.connectedAxis || (s.connectedAxis = new Vector3(0,0,0));
  123713. var _ = new this.bjsAMMO.btVector3(s.mainAxis.x,s.mainAxis.y,s.mainAxis.z)
  123714. , b = new this.bjsAMMO.btVector3(s.connectedAxis.x,s.connectedAxis.y,s.connectedAxis.z);
  123715. c = new this.bjsAMMO.btHingeConstraint(i,o,new this.bjsAMMO.btVector3(s.mainPivot.x,s.mainPivot.y,s.mainPivot.z),new this.bjsAMMO.btVector3(s.connectedPivot.x,s.connectedPivot.y,s.connectedPivot.z),_,b);
  123716. break;
  123717. case PhysicsJoint.BallAndSocketJoint:
  123718. c = new this.bjsAMMO.btPoint2PointConstraint(i,o,new this.bjsAMMO.btVector3(s.mainPivot.x,s.mainPivot.y,s.mainPivot.z),new this.bjsAMMO.btVector3(s.connectedPivot.x,s.connectedPivot.y,s.connectedPivot.z));
  123719. break;
  123720. default:
  123721. Logger$2.Warn("JointType not currently supported by the Ammo plugin, falling back to PhysicsJoint.BallAndSocketJoint"),
  123722. c = new this.bjsAMMO.btPoint2PointConstraint(i,o,new this.bjsAMMO.btVector3(s.mainPivot.x,s.mainPivot.y,s.mainPivot.z),new this.bjsAMMO.btVector3(s.connectedPivot.x,s.connectedPivot.y,s.connectedPivot.z));
  123723. break
  123724. }
  123725. this.world.addConstraint(c, !e.joint.jointData.collision),
  123726. e.joint.physicsJoint = c
  123727. }
  123728. }
  123729. ,
  123730. a.prototype.removeJoint = function(e) {
  123731. this.world && this.world.removeConstraint(e.joint.physicsJoint)
  123732. }
  123733. ,
  123734. a.prototype._addMeshVerts = function(e, i, o) {
  123735. var s = this
  123736. , c = 0;
  123737. if (o && o.getIndices && o.getWorldMatrix && o.getChildMeshes) {
  123738. var d = o.getIndices();
  123739. d || (d = []);
  123740. var _ = o.getVerticesData(VertexBuffer.PositionKind);
  123741. _ || (_ = []);
  123742. var b = void 0;
  123743. if (i && i !== o) {
  123744. var k = void 0;
  123745. i.rotationQuaternion ? k = i.rotationQuaternion : i.rotation ? k = Quaternion.FromEulerAngles(i.rotation.x, i.rotation.y, i.rotation.z) : k = Quaternion.Identity();
  123746. var j = Matrix.Compose(Vector3.One(), k, i.position);
  123747. j.invertToRef(this._tmpMatrix);
  123748. var $ = o.computeWorldMatrix(!1);
  123749. b = $.multiply(this._tmpMatrix)
  123750. } else
  123751. Matrix.ScalingToRef(o.scaling.x, o.scaling.y, o.scaling.z, this._tmpMatrix),
  123752. b = this._tmpMatrix;
  123753. for (var _e = d.length / 3, et = 0; et < _e; et++) {
  123754. for (var tt = [], rt = 0; rt < 3; rt++) {
  123755. var it = new Vector3(_[d[et * 3 + rt] * 3 + 0],_[d[et * 3 + rt] * 3 + 1],_[d[et * 3 + rt] * 3 + 2]);
  123756. it = Vector3.TransformCoordinates(it, b);
  123757. var nt;
  123758. rt == 0 ? nt = this._tmpAmmoVectorA : rt == 1 ? nt = this._tmpAmmoVectorB : nt = this._tmpAmmoVectorC,
  123759. nt.setValue(it.x, it.y, it.z),
  123760. tt.push(nt)
  123761. }
  123762. e.addTriangle(tt[0], tt[1], tt[2]),
  123763. c++
  123764. }
  123765. o.getChildMeshes().forEach(function(ot) {
  123766. c += s._addMeshVerts(e, i, ot)
  123767. })
  123768. }
  123769. return c
  123770. }
  123771. ,
  123772. a.prototype._softVertexData = function(e) {
  123773. var i = e.object;
  123774. if (i && i.getIndices && i.getWorldMatrix && i.getChildMeshes) {
  123775. i.getIndices();
  123776. var o = i.getVerticesData(VertexBuffer.PositionKind);
  123777. o || (o = []);
  123778. var s = i.getVerticesData(VertexBuffer.NormalKind);
  123779. s || (s = []),
  123780. i.computeWorldMatrix(!1);
  123781. for (var c = [], d = [], _ = 0; _ < o.length; _ += 3) {
  123782. var b = new Vector3(o[_],o[_ + 1],o[_ + 2])
  123783. , k = new Vector3(s[_],s[_ + 1],s[_ + 2]);
  123784. b = Vector3.TransformCoordinates(b, i.getWorldMatrix()),
  123785. k = Vector3.TransformNormal(k, i.getWorldMatrix()),
  123786. c.push(b.x, b.y, b.z),
  123787. d.push(k.x, k.y, k.z)
  123788. }
  123789. var j = new VertexData;
  123790. return j.positions = c,
  123791. j.normals = d,
  123792. j.uvs = i.getVerticesData(VertexBuffer.UVKind),
  123793. j.colors = i.getVerticesData(VertexBuffer.ColorKind),
  123794. i && i.getIndices && (j.indices = i.getIndices()),
  123795. j.applyToMesh(i),
  123796. i.position = Vector3.Zero(),
  123797. i.rotationQuaternion = null,
  123798. i.rotation = Vector3.Zero(),
  123799. i.computeWorldMatrix(!0),
  123800. j
  123801. }
  123802. return VertexData.ExtractFromMesh(i)
  123803. }
  123804. ,
  123805. a.prototype._createSoftbody = function(e) {
  123806. var i = e.object;
  123807. if (i && i.getIndices) {
  123808. var o = i.getIndices();
  123809. o || (o = []);
  123810. var s = this._softVertexData(e)
  123811. , c = s.positions
  123812. , d = s.normals;
  123813. if (c === null || d === null)
  123814. return new this.bjsAMMO.btCompoundShape;
  123815. for (var _ = [], b = [], k = 0; k < c.length; k += 3) {
  123816. var j = new Vector3(c[k],c[k + 1],c[k + 2])
  123817. , $ = new Vector3(d[k],d[k + 1],d[k + 2]);
  123818. _.push(j.x, j.y, -j.z),
  123819. b.push($.x, $.y, -$.z)
  123820. }
  123821. for (var _e = new this.bjsAMMO.btSoftBodyHelpers().CreateFromTriMesh(this.world.getWorldInfo(), _, i.getIndices(), o.length / 3, !0), et = c.length / 3, tt = _e.get_m_nodes(), rt, it, k = 0; k < et; k++) {
  123822. rt = tt.at(k);
  123823. var it = rt.get_m_n();
  123824. it.setX(b[3 * k]),
  123825. it.setY(b[3 * k + 1]),
  123826. it.setZ(b[3 * k + 2])
  123827. }
  123828. return _e
  123829. }
  123830. }
  123831. ,
  123832. a.prototype._createCloth = function(e) {
  123833. var i = e.object;
  123834. if (i && i.getIndices) {
  123835. i.getIndices();
  123836. var o = this._softVertexData(e)
  123837. , s = o.positions
  123838. , c = o.normals;
  123839. if (s === null || c === null)
  123840. return new this.bjsAMMO.btCompoundShape;
  123841. var d = s.length
  123842. , _ = Math.sqrt(d / 3);
  123843. e.segments = _;
  123844. var b = _ - 1;
  123845. this._tmpAmmoVectorA.setValue(s[0], s[1], s[2]),
  123846. this._tmpAmmoVectorB.setValue(s[3 * b], s[3 * b + 1], s[3 * b + 2]),
  123847. this._tmpAmmoVectorD.setValue(s[d - 3], s[d - 2], s[d - 1]),
  123848. this._tmpAmmoVectorC.setValue(s[d - 3 - 3 * b], s[d - 2 - 3 * b], s[d - 1 - 3 * b]);
  123849. var k = new this.bjsAMMO.btSoftBodyHelpers().CreatePatch(this.world.getWorldInfo(), this._tmpAmmoVectorA, this._tmpAmmoVectorB, this._tmpAmmoVectorC, this._tmpAmmoVectorD, _, _, e.getParam("fixedPoints"), !0);
  123850. return k
  123851. }
  123852. }
  123853. ,
  123854. a.prototype._createRope = function(e) {
  123855. var i, o, s = this._softVertexData(e), c = s.positions, d = s.normals;
  123856. if (c === null || d === null)
  123857. return new this.bjsAMMO.btCompoundShape;
  123858. s.applyToMesh(e.object, !0),
  123859. e._isFromLine = !0;
  123860. var _ = d.map(function(tt) {
  123861. return tt * tt
  123862. })
  123863. , b = function(tt, rt) {
  123864. return tt + rt
  123865. }
  123866. , k = _.reduce(b);
  123867. if (k === 0)
  123868. i = c.length,
  123869. o = i / 3 - 1,
  123870. this._tmpAmmoVectorA.setValue(c[0], c[1], c[2]),
  123871. this._tmpAmmoVectorB.setValue(c[i - 3], c[i - 2], c[i - 1]);
  123872. else {
  123873. e._isFromLine = !1;
  123874. var j = e.getParam("path")
  123875. , $ = e.getParam("shape");
  123876. if ($ === null)
  123877. return Logger$2.Warn("No shape available for extruded mesh"),
  123878. new this.bjsAMMO.btCompoundShape;
  123879. i = j.length,
  123880. o = i - 1,
  123881. this._tmpAmmoVectorA.setValue(j[0].x, j[0].y, j[0].z),
  123882. this._tmpAmmoVectorB.setValue(j[i - 1].x, j[i - 1].y, j[i - 1].z)
  123883. }
  123884. e.segments = o;
  123885. var _e = e.getParam("fixedPoints");
  123886. _e = _e > 3 ? 3 : _e;
  123887. var et = new this.bjsAMMO.btSoftBodyHelpers().CreateRope(this.world.getWorldInfo(), this._tmpAmmoVectorA, this._tmpAmmoVectorB, o - 1, _e);
  123888. return et.get_m_cfg().set_collisions(17),
  123889. et
  123890. }
  123891. ,
  123892. a.prototype._createCustom = function(e) {
  123893. var i = null;
  123894. return this.onCreateCustomShape && (i = this.onCreateCustomShape(e)),
  123895. i == null && (i = new this.bjsAMMO.btCompoundShape),
  123896. i
  123897. }
  123898. ,
  123899. a.prototype._addHullVerts = function(e, i, o) {
  123900. var s = this
  123901. , c = 0;
  123902. if (o && o.getIndices && o.getWorldMatrix && o.getChildMeshes) {
  123903. var d = o.getIndices();
  123904. d || (d = []);
  123905. var _ = o.getVerticesData(VertexBuffer.PositionKind);
  123906. _ || (_ = []),
  123907. o.computeWorldMatrix(!1);
  123908. for (var b = d.length / 3, k = 0; k < b; k++) {
  123909. for (var j = [], $ = 0; $ < 3; $++) {
  123910. var _e = new Vector3(_[d[k * 3 + $] * 3 + 0],_[d[k * 3 + $] * 3 + 1],_[d[k * 3 + $] * 3 + 2]);
  123911. Matrix.ScalingToRef(o.scaling.x, o.scaling.y, o.scaling.z, this._tmpMatrix),
  123912. _e = Vector3.TransformCoordinates(_e, this._tmpMatrix);
  123913. var et;
  123914. $ == 0 ? et = this._tmpAmmoVectorA : $ == 1 ? et = this._tmpAmmoVectorB : et = this._tmpAmmoVectorC,
  123915. et.setValue(_e.x, _e.y, _e.z),
  123916. j.push(et)
  123917. }
  123918. e.addPoint(j[0], !0),
  123919. e.addPoint(j[1], !0),
  123920. e.addPoint(j[2], !0),
  123921. c++
  123922. }
  123923. o.getChildMeshes().forEach(function(tt) {
  123924. c += s._addHullVerts(e, i, tt)
  123925. })
  123926. }
  123927. return c
  123928. }
  123929. ,
  123930. a.prototype._createShape = function(e, i) {
  123931. var o = this;
  123932. i === void 0 && (i = !1);
  123933. var s = e.object, c, d = e.getObjectExtendSize();
  123934. if (!i) {
  123935. var _ = e.object.getChildMeshes ? e.object.getChildMeshes(!0) : [];
  123936. c = new this.bjsAMMO.btCompoundShape;
  123937. var b = 0;
  123938. if (_.forEach(function(it) {
  123939. var nt = it.getPhysicsImpostor();
  123940. if (nt) {
  123941. if (nt.type == PhysicsImpostor.MeshImpostor)
  123942. throw "A child MeshImpostor is not supported. Only primitive impostors are supported as children (eg. box or sphere)";
  123943. var ot = o._createShape(nt)
  123944. , at = it.parent.getWorldMatrix().clone()
  123945. , st = new Vector3;
  123946. at.decompose(st),
  123947. o._tmpAmmoTransform.getOrigin().setValue(it.position.x * st.x, it.position.y * st.y, it.position.z * st.z),
  123948. o._tmpAmmoQuaternion.setValue(it.rotationQuaternion.x, it.rotationQuaternion.y, it.rotationQuaternion.z, it.rotationQuaternion.w),
  123949. o._tmpAmmoTransform.setRotation(o._tmpAmmoQuaternion),
  123950. c.addChildShape(o._tmpAmmoTransform, ot),
  123951. nt.dispose(),
  123952. b++
  123953. }
  123954. }),
  123955. b > 0) {
  123956. if (e.type != PhysicsImpostor.NoImpostor) {
  123957. var k = this._createShape(e, !0);
  123958. k && (this._tmpAmmoTransform.getOrigin().setValue(0, 0, 0),
  123959. this._tmpAmmoQuaternion.setValue(0, 0, 0, 1),
  123960. this._tmpAmmoTransform.setRotation(this._tmpAmmoQuaternion),
  123961. c.addChildShape(this._tmpAmmoTransform, k))
  123962. }
  123963. return c
  123964. } else
  123965. this.bjsAMMO.destroy(c),
  123966. c = null
  123967. }
  123968. switch (e.type) {
  123969. case PhysicsImpostor.SphereImpostor:
  123970. if (Scalar.WithinEpsilon(d.x, d.y, 1e-4) && Scalar.WithinEpsilon(d.x, d.z, 1e-4))
  123971. c = new this.bjsAMMO.btSphereShape(d.x / 2);
  123972. else {
  123973. var j = [new this.bjsAMMO.btVector3(0,0,0)]
  123974. , $ = [1];
  123975. c = new this.bjsAMMO.btMultiSphereShape(j,$,1),
  123976. c.setLocalScaling(new this.bjsAMMO.btVector3(d.x / 2,d.y / 2,d.z / 2))
  123977. }
  123978. break;
  123979. case PhysicsImpostor.CapsuleImpostor:
  123980. var _e = d.x / 2;
  123981. c = new this.bjsAMMO.btCapsuleShape(_e,d.y - _e * 2);
  123982. break;
  123983. case PhysicsImpostor.CylinderImpostor:
  123984. this._tmpAmmoVectorA.setValue(d.x / 2, d.y / 2, d.z / 2),
  123985. c = new this.bjsAMMO.btCylinderShape(this._tmpAmmoVectorA);
  123986. break;
  123987. case PhysicsImpostor.PlaneImpostor:
  123988. case PhysicsImpostor.BoxImpostor:
  123989. this._tmpAmmoVectorA.setValue(d.x / 2, d.y / 2, d.z / 2),
  123990. c = new this.bjsAMMO.btBoxShape(this._tmpAmmoVectorA);
  123991. break;
  123992. case PhysicsImpostor.MeshImpostor:
  123993. if (e.getParam("mass") == 0) {
  123994. var et = new this.bjsAMMO.btTriangleMesh;
  123995. e._pluginData.toDispose.push(et);
  123996. var rt = this._addMeshVerts(et, s, s);
  123997. rt == 0 ? c = new this.bjsAMMO.btCompoundShape : c = new this.bjsAMMO.btBvhTriangleMeshShape(et);
  123998. break
  123999. }
  124000. case PhysicsImpostor.ConvexHullImpostor:
  124001. var tt = new this.bjsAMMO.btConvexHullShape
  124002. , rt = this._addHullVerts(tt, s, s);
  124003. rt == 0 ? (e._pluginData.toDispose.push(tt),
  124004. c = new this.bjsAMMO.btCompoundShape) : c = tt;
  124005. break;
  124006. case PhysicsImpostor.NoImpostor:
  124007. c = new this.bjsAMMO.btSphereShape(d.x / 2);
  124008. break;
  124009. case PhysicsImpostor.CustomImpostor:
  124010. c = this._createCustom(e);
  124011. break;
  124012. case PhysicsImpostor.SoftbodyImpostor:
  124013. c = this._createSoftbody(e);
  124014. break;
  124015. case PhysicsImpostor.ClothImpostor:
  124016. c = this._createCloth(e);
  124017. break;
  124018. case PhysicsImpostor.RopeImpostor:
  124019. c = this._createRope(e);
  124020. break;
  124021. default:
  124022. Logger$2.Warn("The impostor type is not currently supported by the ammo plugin.");
  124023. break
  124024. }
  124025. return c
  124026. }
  124027. ,
  124028. a.prototype.setTransformationFromPhysicsBody = function(e) {
  124029. e.physicsBody.getMotionState().getWorldTransform(this._tmpAmmoTransform),
  124030. e.object.position.set(this._tmpAmmoTransform.getOrigin().x(), this._tmpAmmoTransform.getOrigin().y(), this._tmpAmmoTransform.getOrigin().z()),
  124031. e.object.rotationQuaternion ? e.object.rotationQuaternion.set(this._tmpAmmoTransform.getRotation().x(), this._tmpAmmoTransform.getRotation().y(), this._tmpAmmoTransform.getRotation().z(), this._tmpAmmoTransform.getRotation().w()) : e.object.rotation && (this._tmpQuaternion.set(this._tmpAmmoTransform.getRotation().x(), this._tmpAmmoTransform.getRotation().y(), this._tmpAmmoTransform.getRotation().z(), this._tmpAmmoTransform.getRotation().w()),
  124032. this._tmpQuaternion.toEulerAnglesToRef(e.object.rotation))
  124033. }
  124034. ,
  124035. a.prototype.setPhysicsBodyTransformation = function(e, i, o) {
  124036. var s = e.physicsBody.getWorldTransform();
  124037. if (Math.abs(s.getOrigin().x() - i.x) > Epsilon || Math.abs(s.getOrigin().y() - i.y) > Epsilon || Math.abs(s.getOrigin().z() - i.z) > Epsilon || Math.abs(s.getRotation().x() - o.x) > Epsilon || Math.abs(s.getRotation().y() - o.y) > Epsilon || Math.abs(s.getRotation().z() - o.z) > Epsilon || Math.abs(s.getRotation().w() - o.w) > Epsilon)
  124038. if (this._tmpAmmoVectorA.setValue(i.x, i.y, i.z),
  124039. s.setOrigin(this._tmpAmmoVectorA),
  124040. this._tmpAmmoQuaternion.setValue(o.x, o.y, o.z, o.w),
  124041. s.setRotation(this._tmpAmmoQuaternion),
  124042. e.physicsBody.setWorldTransform(s),
  124043. e.mass == 0) {
  124044. var c = e.physicsBody.getMotionState();
  124045. c && c.setWorldTransform(s)
  124046. } else
  124047. e.physicsBody.activate()
  124048. }
  124049. ,
  124050. a.prototype.isSupported = function() {
  124051. return this.bjsAMMO !== void 0
  124052. }
  124053. ,
  124054. a.prototype.setLinearVelocity = function(e, i) {
  124055. this._tmpAmmoVectorA.setValue(i.x, i.y, i.z),
  124056. e.soft ? e.physicsBody.linearVelocity(this._tmpAmmoVectorA) : e.physicsBody.setLinearVelocity(this._tmpAmmoVectorA)
  124057. }
  124058. ,
  124059. a.prototype.setAngularVelocity = function(e, i) {
  124060. this._tmpAmmoVectorA.setValue(i.x, i.y, i.z),
  124061. e.soft ? e.physicsBody.angularVelocity(this._tmpAmmoVectorA) : e.physicsBody.setAngularVelocity(this._tmpAmmoVectorA)
  124062. }
  124063. ,
  124064. a.prototype.getLinearVelocity = function(e) {
  124065. if (e.soft)
  124066. var i = e.physicsBody.linearVelocity();
  124067. else
  124068. var i = e.physicsBody.getLinearVelocity();
  124069. if (!i)
  124070. return null;
  124071. var o = new Vector3(i.x(),i.y(),i.z());
  124072. return this.bjsAMMO.destroy(i),
  124073. o
  124074. }
  124075. ,
  124076. a.prototype.getAngularVelocity = function(e) {
  124077. if (e.soft)
  124078. var i = e.physicsBody.angularVelocity();
  124079. else
  124080. var i = e.physicsBody.getAngularVelocity();
  124081. if (!i)
  124082. return null;
  124083. var o = new Vector3(i.x(),i.y(),i.z());
  124084. return this.bjsAMMO.destroy(i),
  124085. o
  124086. }
  124087. ,
  124088. a.prototype.setBodyMass = function(e, i) {
  124089. e.soft ? e.physicsBody.setTotalMass(i, !1) : e.physicsBody.setMassProps(i),
  124090. e._pluginData.mass = i
  124091. }
  124092. ,
  124093. a.prototype.getBodyMass = function(e) {
  124094. return e._pluginData.mass || 0
  124095. }
  124096. ,
  124097. a.prototype.getBodyFriction = function(e) {
  124098. return e._pluginData.friction || 0
  124099. }
  124100. ,
  124101. a.prototype.setBodyFriction = function(e, i) {
  124102. e.soft ? e.physicsBody.get_m_cfg().set_kDF(i) : e.physicsBody.setFriction(i),
  124103. e._pluginData.friction = i
  124104. }
  124105. ,
  124106. a.prototype.getBodyRestitution = function(e) {
  124107. return e._pluginData.restitution || 0
  124108. }
  124109. ,
  124110. a.prototype.setBodyRestitution = function(e, i) {
  124111. e.physicsBody.setRestitution(i),
  124112. e._pluginData.restitution = i
  124113. }
  124114. ,
  124115. a.prototype.getBodyPressure = function(e) {
  124116. return e.soft ? e._pluginData.pressure || 0 : (Logger$2.Warn("Pressure is not a property of a rigid body"),
  124117. 0)
  124118. }
  124119. ,
  124120. a.prototype.setBodyPressure = function(e, i) {
  124121. e.soft ? e.type === PhysicsImpostor.SoftbodyImpostor ? (e.physicsBody.get_m_cfg().set_kPR(i),
  124122. e._pluginData.pressure = i) : (e.physicsBody.get_m_cfg().set_kPR(0),
  124123. e._pluginData.pressure = 0) : Logger$2.Warn("Pressure can only be applied to a softbody")
  124124. }
  124125. ,
  124126. a.prototype.getBodyStiffness = function(e) {
  124127. return e.soft ? e._pluginData.stiffness || 0 : (Logger$2.Warn("Stiffness is not a property of a rigid body"),
  124128. 0)
  124129. }
  124130. ,
  124131. a.prototype.setBodyStiffness = function(e, i) {
  124132. e.soft ? (i = i < 0 ? 0 : i,
  124133. i = i > 1 ? 1 : i,
  124134. e.physicsBody.get_m_materials().at(0).set_m_kLST(i),
  124135. e._pluginData.stiffness = i) : Logger$2.Warn("Stiffness cannot be applied to a rigid body")
  124136. }
  124137. ,
  124138. a.prototype.getBodyVelocityIterations = function(e) {
  124139. return e.soft ? e._pluginData.velocityIterations || 0 : (Logger$2.Warn("Velocity iterations is not a property of a rigid body"),
  124140. 0)
  124141. }
  124142. ,
  124143. a.prototype.setBodyVelocityIterations = function(e, i) {
  124144. e.soft ? (i = i < 0 ? 0 : i,
  124145. e.physicsBody.get_m_cfg().set_viterations(i),
  124146. e._pluginData.velocityIterations = i) : Logger$2.Warn("Velocity iterations cannot be applied to a rigid body")
  124147. }
  124148. ,
  124149. a.prototype.getBodyPositionIterations = function(e) {
  124150. return e.soft ? e._pluginData.positionIterations || 0 : (Logger$2.Warn("Position iterations is not a property of a rigid body"),
  124151. 0)
  124152. }
  124153. ,
  124154. a.prototype.setBodyPositionIterations = function(e, i) {
  124155. e.soft ? (i = i < 0 ? 0 : i,
  124156. e.physicsBody.get_m_cfg().set_piterations(i),
  124157. e._pluginData.positionIterations = i) : Logger$2.Warn("Position iterations cannot be applied to a rigid body")
  124158. }
  124159. ,
  124160. a.prototype.appendAnchor = function(e, i, o, s, c, d) {
  124161. c === void 0 && (c = 1),
  124162. d === void 0 && (d = !1);
  124163. var _ = e.segments
  124164. , b = Math.round((_ - 1) * o)
  124165. , k = Math.round((_ - 1) * s)
  124166. , j = _ - 1 - k
  124167. , $ = b + _ * j;
  124168. e.physicsBody.appendAnchor($, i.physicsBody, d, c)
  124169. }
  124170. ,
  124171. a.prototype.appendHook = function(e, i, o, s, c) {
  124172. s === void 0 && (s = 1),
  124173. c === void 0 && (c = !1);
  124174. var d = Math.round(e.segments * o);
  124175. e.physicsBody.appendAnchor(d, i.physicsBody, c, s)
  124176. }
  124177. ,
  124178. a.prototype.sleepBody = function(e) {
  124179. e.physicsBody.forceActivationState(0)
  124180. }
  124181. ,
  124182. a.prototype.wakeUpBody = function(e) {
  124183. e.physicsBody.activate()
  124184. }
  124185. ,
  124186. a.prototype.updateDistanceJoint = function(e, i, o) {
  124187. Logger$2.Warn("updateDistanceJoint is not currently supported by the Ammo physics plugin")
  124188. }
  124189. ,
  124190. a.prototype.setMotor = function(e, i, o, s) {
  124191. e.physicsJoint.enableAngularMotor(!0, i, o)
  124192. }
  124193. ,
  124194. a.prototype.setLimit = function(e, i, o) {
  124195. Logger$2.Warn("setLimit is not currently supported by the Ammo physics plugin")
  124196. }
  124197. ,
  124198. a.prototype.syncMeshWithImpostor = function(e, i) {
  124199. var o = i.physicsBody;
  124200. o.getMotionState().getWorldTransform(this._tmpAmmoTransform),
  124201. e.position.x = this._tmpAmmoTransform.getOrigin().x(),
  124202. e.position.y = this._tmpAmmoTransform.getOrigin().y(),
  124203. e.position.z = this._tmpAmmoTransform.getOrigin().z(),
  124204. e.rotationQuaternion && (e.rotationQuaternion.x = this._tmpAmmoTransform.getRotation().x(),
  124205. e.rotationQuaternion.y = this._tmpAmmoTransform.getRotation().y(),
  124206. e.rotationQuaternion.z = this._tmpAmmoTransform.getRotation().z(),
  124207. e.rotationQuaternion.w = this._tmpAmmoTransform.getRotation().w())
  124208. }
  124209. ,
  124210. a.prototype.getRadius = function(e) {
  124211. var i = e.getObjectExtendSize();
  124212. return i.x / 2
  124213. }
  124214. ,
  124215. a.prototype.getBoxSizeToRef = function(e, i) {
  124216. var o = e.getObjectExtendSize();
  124217. i.x = o.x,
  124218. i.y = o.y,
  124219. i.z = o.z
  124220. }
  124221. ,
  124222. a.prototype.dispose = function() {
  124223. this.bjsAMMO.destroy(this.world),
  124224. this.bjsAMMO.destroy(this._solver),
  124225. this.bjsAMMO.destroy(this._overlappingPairCache),
  124226. this.bjsAMMO.destroy(this._dispatcher),
  124227. this.bjsAMMO.destroy(this._collisionConfiguration),
  124228. this.bjsAMMO.destroy(this._tmpAmmoVectorA),
  124229. this.bjsAMMO.destroy(this._tmpAmmoVectorB),
  124230. this.bjsAMMO.destroy(this._tmpAmmoVectorC),
  124231. this.bjsAMMO.destroy(this._tmpAmmoTransform),
  124232. this.bjsAMMO.destroy(this._tmpAmmoQuaternion),
  124233. this.bjsAMMO.destroy(this._tmpAmmoConcreteContactResultCallback),
  124234. this.world = null
  124235. }
  124236. ,
  124237. a.prototype.raycast = function(e, i) {
  124238. this._tmpAmmoVectorRCA = new this.bjsAMMO.btVector3(e.x,e.y,e.z),
  124239. this._tmpAmmoVectorRCB = new this.bjsAMMO.btVector3(i.x,i.y,i.z);
  124240. var o = new this.bjsAMMO.ClosestRayResultCallback(this._tmpAmmoVectorRCA,this._tmpAmmoVectorRCB);
  124241. return this.world.rayTest(this._tmpAmmoVectorRCA, this._tmpAmmoVectorRCB, o),
  124242. this._raycastResult.reset(e, i),
  124243. o.hasHit() && (this._raycastResult.setHitData({
  124244. x: o.get_m_hitNormalWorld().x(),
  124245. y: o.get_m_hitNormalWorld().y(),
  124246. z: o.get_m_hitNormalWorld().z()
  124247. }, {
  124248. x: o.get_m_hitPointWorld().x(),
  124249. y: o.get_m_hitPointWorld().y(),
  124250. z: o.get_m_hitPointWorld().z()
  124251. }),
  124252. this._raycastResult.calculateHitDistance()),
  124253. this.bjsAMMO.destroy(o),
  124254. this.bjsAMMO.destroy(this._tmpAmmoVectorRCA),
  124255. this.bjsAMMO.destroy(this._tmpAmmoVectorRCB),
  124256. this._raycastResult
  124257. }
  124258. ,
  124259. a.DISABLE_COLLISION_FLAG = 4,
  124260. a.KINEMATIC_FLAG = 2,
  124261. a.DISABLE_DEACTIVATION_FLAG = 4,
  124262. a
  124263. }();
  124264. AbstractScene.prototype.removeReflectionProbe = function(a) {
  124265. if (!this.reflectionProbes)
  124266. return -1;
  124267. var e = this.reflectionProbes.indexOf(a);
  124268. return e !== -1 && this.reflectionProbes.splice(e, 1),
  124269. e
  124270. }
  124271. ;
  124272. AbstractScene.prototype.addReflectionProbe = function(a) {
  124273. this.reflectionProbes || (this.reflectionProbes = []),
  124274. this.reflectionProbes.push(a)
  124275. }
  124276. ;
  124277. var ReflectionProbe = function() {
  124278. function a(e, i, o, s, c, d) {
  124279. var _ = this;
  124280. if (s === void 0 && (s = !0),
  124281. c === void 0 && (c = !1),
  124282. d === void 0 && (d = !1),
  124283. this.name = e,
  124284. this._viewMatrix = Matrix.Identity(),
  124285. this._target = Vector3.Zero(),
  124286. this._add = Vector3.Zero(),
  124287. this._invertYAxis = !1,
  124288. this.position = Vector3.Zero(),
  124289. this._parentContainer = null,
  124290. this._scene = o,
  124291. o.getEngine().supportsUniformBuffers) {
  124292. this._sceneUBOs = [];
  124293. for (var b = 0; b < 6; ++b)
  124294. this._sceneUBOs.push(o.createSceneUniformBuffer('Scene for Reflection Probe (name "' + e + '") face #' + b))
  124295. }
  124296. this._scene.reflectionProbes || (this._scene.reflectionProbes = new Array),
  124297. this._scene.reflectionProbes.push(this);
  124298. var k = 0;
  124299. if (c) {
  124300. var j = this._scene.getEngine().getCaps();
  124301. j.textureHalfFloatRender ? k = 2 : j.textureFloatRender && (k = 1)
  124302. }
  124303. this._renderTargetTexture = new RenderTargetTexture(e,i,o,s,!0,k,!0),
  124304. this._renderTargetTexture.gammaSpace = !d;
  124305. var $ = o.getEngine().useReverseDepthBuffer;
  124306. this._renderTargetTexture.onBeforeRenderObservable.add(function(et) {
  124307. switch (_._sceneUBOs && (o.setSceneUniformBuffer(_._sceneUBOs[et]),
  124308. o.getSceneUniformBuffer().unbindEffect()),
  124309. et) {
  124310. case 0:
  124311. _._add.copyFromFloats(1, 0, 0);
  124312. break;
  124313. case 1:
  124314. _._add.copyFromFloats(-1, 0, 0);
  124315. break;
  124316. case 2:
  124317. _._add.copyFromFloats(0, _._invertYAxis ? 1 : -1, 0);
  124318. break;
  124319. case 3:
  124320. _._add.copyFromFloats(0, _._invertYAxis ? -1 : 1, 0);
  124321. break;
  124322. case 4:
  124323. _._add.copyFromFloats(0, 0, o.useRightHandedSystem ? -1 : 1);
  124324. break;
  124325. case 5:
  124326. _._add.copyFromFloats(0, 0, o.useRightHandedSystem ? 1 : -1);
  124327. break
  124328. }
  124329. _._attachedMesh && _.position.copyFrom(_._attachedMesh.getAbsolutePosition()),
  124330. _.position.addToRef(_._add, _._target);
  124331. var tt = o.useRightHandedSystem ? Matrix.LookAtRHToRef : Matrix.LookAtLHToRef
  124332. , rt = o.useRightHandedSystem ? Matrix.PerspectiveFovRH : Matrix.PerspectiveFovLH;
  124333. tt(_.position, _._target, Vector3.Up(), _._viewMatrix),
  124334. o.activeCamera && (_._projectionMatrix = rt(Math.PI / 2, 1, $ ? o.activeCamera.maxZ : o.activeCamera.minZ, $ ? o.activeCamera.minZ : o.activeCamera.maxZ, _._scene.getEngine().isNDCHalfZRange),
  124335. o.setTransformMatrix(_._viewMatrix, _._projectionMatrix),
  124336. o.activeCamera.isRigCamera && !_._renderTargetTexture.activeCamera && (_._renderTargetTexture.activeCamera = o.activeCamera.rigParent || null)),
  124337. o._forcedViewPosition = _.position
  124338. });
  124339. var _e;
  124340. this._renderTargetTexture.onBeforeBindObservable.add(function() {
  124341. var et, tt;
  124342. _._currentSceneUBO = o.getSceneUniformBuffer(),
  124343. (tt = (et = o.getEngine())._debugPushGroup) === null || tt === void 0 || tt.call(et, "reflection probe generation for " + e, 1),
  124344. _e = _._scene.imageProcessingConfiguration.applyByPostProcess,
  124345. d && (o.imageProcessingConfiguration.applyByPostProcess = !0)
  124346. }),
  124347. this._renderTargetTexture.onAfterUnbindObservable.add(function() {
  124348. var et, tt;
  124349. o.imageProcessingConfiguration.applyByPostProcess = _e,
  124350. o._forcedViewPosition = null,
  124351. _._sceneUBOs && o.setSceneUniformBuffer(_._currentSceneUBO),
  124352. o.updateTransformMatrix(!0),
  124353. (tt = (et = o.getEngine())._debugPopGroup) === null || tt === void 0 || tt.call(et, 1)
  124354. })
  124355. }
  124356. return Object.defineProperty(a.prototype, "samples", {
  124357. get: function() {
  124358. return this._renderTargetTexture.samples
  124359. },
  124360. set: function(e) {
  124361. this._renderTargetTexture.samples = e
  124362. },
  124363. enumerable: !1,
  124364. configurable: !0
  124365. }),
  124366. Object.defineProperty(a.prototype, "refreshRate", {
  124367. get: function() {
  124368. return this._renderTargetTexture.refreshRate
  124369. },
  124370. set: function(e) {
  124371. this._renderTargetTexture.refreshRate = e
  124372. },
  124373. enumerable: !1,
  124374. configurable: !0
  124375. }),
  124376. a.prototype.getScene = function() {
  124377. return this._scene
  124378. }
  124379. ,
  124380. Object.defineProperty(a.prototype, "cubeTexture", {
  124381. get: function() {
  124382. return this._renderTargetTexture
  124383. },
  124384. enumerable: !1,
  124385. configurable: !0
  124386. }),
  124387. Object.defineProperty(a.prototype, "renderList", {
  124388. get: function() {
  124389. return this._renderTargetTexture.renderList
  124390. },
  124391. enumerable: !1,
  124392. configurable: !0
  124393. }),
  124394. a.prototype.attachToMesh = function(e) {
  124395. this._attachedMesh = e
  124396. }
  124397. ,
  124398. a.prototype.setRenderingAutoClearDepthStencil = function(e, i) {
  124399. this._renderTargetTexture.setRenderingAutoClearDepthStencil(e, i)
  124400. }
  124401. ,
  124402. a.prototype.dispose = function() {
  124403. var e = this._scene.reflectionProbes.indexOf(this);
  124404. if (e !== -1 && this._scene.reflectionProbes.splice(e, 1),
  124405. this._parentContainer) {
  124406. var i = this._parentContainer.reflectionProbes.indexOf(this);
  124407. i > -1 && this._parentContainer.reflectionProbes.splice(i, 1),
  124408. this._parentContainer = null
  124409. }
  124410. if (this._renderTargetTexture && (this._renderTargetTexture.dispose(),
  124411. this._renderTargetTexture = null),
  124412. this._sceneUBOs) {
  124413. for (var o = 0, s = this._sceneUBOs; o < s.length; o++) {
  124414. var c = s[o];
  124415. c.dispose()
  124416. }
  124417. this._sceneUBOs = []
  124418. }
  124419. }
  124420. ,
  124421. a.prototype.toString = function(e) {
  124422. var i = "Name: " + this.name;
  124423. return e && (i += ", position: " + this.position.toString(),
  124424. this._attachedMesh && (i += ", attached mesh: " + this._attachedMesh.name)),
  124425. i
  124426. }
  124427. ,
  124428. a.prototype.getClassName = function() {
  124429. return "ReflectionProbe"
  124430. }
  124431. ,
  124432. a.prototype.serialize = function() {
  124433. var e = SerializationHelper.Serialize(this, this._renderTargetTexture.serialize());
  124434. return e.isReflectionProbe = !0,
  124435. e
  124436. }
  124437. ,
  124438. a.Parse = function(e, i, o) {
  124439. var s = null;
  124440. if (i.reflectionProbes)
  124441. for (var c = 0; c < i.reflectionProbes.length; c++) {
  124442. var d = i.reflectionProbes[c];
  124443. if (d.name === e.name) {
  124444. s = d;
  124445. break
  124446. }
  124447. }
  124448. return s = SerializationHelper.Parse(function() {
  124449. return s || new a(e.name,e.renderTargetSize,i,e._generateMipMaps)
  124450. }, e, i, o),
  124451. s.cubeTexture._waitingRenderList = e.renderList,
  124452. e._attachedMesh && s.attachToMesh(i.getMeshById(e._attachedMesh)),
  124453. s
  124454. }
  124455. ,
  124456. __decorate([serializeAsMeshReference()], a.prototype, "_attachedMesh", void 0),
  124457. __decorate([serializeAsVector3()], a.prototype, "position", void 0),
  124458. a
  124459. }()
  124460. , BabylonFileLoaderConfiguration = function() {
  124461. function a() {}
  124462. return a.LoaderInjectedPhysicsEngine = void 0,
  124463. a
  124464. }()
  124465. , tempIndexContainer = {}
  124466. , parseMaterialById = function(a, e, i, o) {
  124467. if (!e.materials)
  124468. return null;
  124469. for (var s = 0, c = e.materials.length; s < c; s++) {
  124470. var d = e.materials[s];
  124471. if (d.id === a)
  124472. return Material.Parse(d, i, o)
  124473. }
  124474. return null
  124475. }
  124476. , isDescendantOf = function(a, e, i) {
  124477. for (var o in e)
  124478. if (a.name === e[o])
  124479. return i.push(a.id),
  124480. !0;
  124481. return a.parentId && i.indexOf(a.parentId) !== -1 ? (i.push(a.id),
  124482. !0) : !1
  124483. }
  124484. , logOperation = function(a, e) {
  124485. return a + " of " + (e ? e.file + " from " + e.name + " version: " + e.version + ", exporter version: " + e.exporter_version : "unknown")
  124486. }
  124487. , loadDetailLevels = function(a, e) {
  124488. var i = e;
  124489. if (e._waitingData.lods) {
  124490. if (e._waitingData.lods.ids && e._waitingData.lods.ids.length > 0) {
  124491. var o = e._waitingData.lods.ids
  124492. , s = i.isEnabled(!1);
  124493. if (e._waitingData.lods.distances) {
  124494. var c = e._waitingData.lods.distances;
  124495. if (c.length >= o.length) {
  124496. var d = c.length > o.length ? c[c.length - 1] : 0;
  124497. i.setEnabled(!1);
  124498. for (var _ = 0; _ < o.length; _++) {
  124499. var b = o[_]
  124500. , k = a.getMeshById(b);
  124501. k != null && i.addLODLevel(c[_], k)
  124502. }
  124503. d > 0 && i.addLODLevel(d, null),
  124504. s === !0 && i.setEnabled(!0)
  124505. } else
  124506. Tools.Warn("Invalid level of detail distances for " + e.name)
  124507. }
  124508. }
  124509. e._waitingData.lods = null
  124510. }
  124511. }
  124512. , findParent = function(a, e) {
  124513. if (typeof a != "number")
  124514. return e.getLastEntryById(a);
  124515. var i = tempIndexContainer[a];
  124516. return i
  124517. }
  124518. , loadAssetContainer = function(a, e, i, o, s) {
  124519. s === void 0 && (s = !1);
  124520. var c = new AssetContainer(a)
  124521. , d = "importScene has failed JSON parse";
  124522. try {
  124523. var _ = JSON.parse(e);
  124524. d = "";
  124525. var b = SceneLoader.loggingLevel === SceneLoader.DETAILED_LOGGING, k, j;
  124526. if (_.environmentTexture !== void 0 && _.environmentTexture !== null) {
  124527. var $ = _.isPBR !== void 0 ? _.isPBR : !0;
  124528. if (_.environmentTextureType && _.environmentTextureType === "BABYLON.HDRCubeTexture") {
  124529. var _e = _.environmentTextureSize ? _.environmentTextureSize : 128
  124530. , et = new HDRCubeTexture((_.environmentTexture.match(/https?:\/\//g) ? "" : i) + _.environmentTexture,a,_e,!0,!$);
  124531. _.environmentTextureRotationY && (et.rotationY = _.environmentTextureRotationY),
  124532. a.environmentTexture = et
  124533. } else if (EndsWith(_.environmentTexture, ".env")) {
  124534. var tt = new CubeTexture((_.environmentTexture.match(/https?:\/\//g) ? "" : i) + _.environmentTexture,a);
  124535. _.environmentTextureRotationY && (tt.rotationY = _.environmentTextureRotationY),
  124536. a.environmentTexture = tt
  124537. } else {
  124538. var rt = CubeTexture.CreateFromPrefilteredData((_.environmentTexture.match(/https?:\/\//g) ? "" : i) + _.environmentTexture, a);
  124539. _.environmentTextureRotationY && (rt.rotationY = _.environmentTextureRotationY),
  124540. a.environmentTexture = rt
  124541. }
  124542. if (_.createDefaultSkybox === !0) {
  124543. var it = a.activeCamera !== void 0 && a.activeCamera !== null ? (a.activeCamera.maxZ - a.activeCamera.minZ) / 2 : 1e3
  124544. , nt = _.skyboxBlurLevel || 0;
  124545. a.createDefaultSkybox(a.environmentTexture, $, it, nt)
  124546. }
  124547. c.environmentTexture = a.environmentTexture
  124548. }
  124549. if (_.environmentIntensity !== void 0 && _.environmentIntensity !== null && (a.environmentIntensity = _.environmentIntensity),
  124550. _.lights !== void 0 && _.lights !== null)
  124551. for (k = 0,
  124552. j = _.lights.length; k < j; k++) {
  124553. var ot = _.lights[k]
  124554. , at = Light.Parse(ot, a);
  124555. at && (tempIndexContainer[ot.uniqueId] = at,
  124556. c.lights.push(at),
  124557. at._parentContainer = c,
  124558. d += k === 0 ? `
  124559. Lights:` : "",
  124560. d += `
  124561. ` + at.toString(b))
  124562. }
  124563. if (_.reflectionProbes !== void 0 && _.reflectionProbes !== null)
  124564. for (k = 0,
  124565. j = _.reflectionProbes.length; k < j; k++) {
  124566. var st = _.reflectionProbes[k]
  124567. , ut = ReflectionProbe.Parse(st, a, i);
  124568. ut && (c.reflectionProbes.push(ut),
  124569. ut._parentContainer = c,
  124570. d += k === 0 ? `
  124571. Reflection Probes:` : "",
  124572. d += `
  124573. ` + ut.toString(b))
  124574. }
  124575. if (_.animations !== void 0 && _.animations !== null)
  124576. for (k = 0,
  124577. j = _.animations.length; k < j; k++) {
  124578. var ct = _.animations[k]
  124579. , lt = GetClass("BABYLON.Animation");
  124580. if (lt) {
  124581. var ft = lt.Parse(ct);
  124582. a.animations.push(ft),
  124583. c.animations.push(ft),
  124584. d += k === 0 ? `
  124585. Animations:` : "",
  124586. d += `
  124587. ` + ft.toString(b)
  124588. }
  124589. }
  124590. if (_.materials !== void 0 && _.materials !== null)
  124591. for (k = 0,
  124592. j = _.materials.length; k < j; k++) {
  124593. var ht = _.materials[k]
  124594. , pt = Material.Parse(ht, a, i);
  124595. if (pt) {
  124596. c.materials.push(pt),
  124597. pt._parentContainer = c,
  124598. d += k === 0 ? `
  124599. Materials:` : "",
  124600. d += `
  124601. ` + pt.toString(b);
  124602. var dt = pt.getActiveTextures();
  124603. dt.forEach(function(jt) {
  124604. c.textures.indexOf(jt) == -1 && (c.textures.push(jt),
  124605. jt._parentContainer = c)
  124606. })
  124607. }
  124608. }
  124609. if (_.multiMaterials !== void 0 && _.multiMaterials !== null)
  124610. for (k = 0,
  124611. j = _.multiMaterials.length; k < j; k++) {
  124612. var _t = _.multiMaterials[k]
  124613. , mt = MultiMaterial.ParseMultiMaterial(_t, a);
  124614. c.multiMaterials.push(mt),
  124615. mt._parentContainer = c,
  124616. d += k === 0 ? `
  124617. MultiMaterials:` : "",
  124618. d += `
  124619. ` + mt.toString(b);
  124620. var dt = mt.getActiveTextures();
  124621. dt.forEach(function(Xt) {
  124622. c.textures.indexOf(Xt) == -1 && (c.textures.push(Xt),
  124623. Xt._parentContainer = c)
  124624. })
  124625. }
  124626. if (_.morphTargetManagers !== void 0 && _.morphTargetManagers !== null)
  124627. for (var vt = 0, yt = _.morphTargetManagers; vt < yt.length; vt++) {
  124628. var Et = yt[vt]
  124629. , At = MorphTargetManager.Parse(Et, a);
  124630. c.morphTargetManagers.push(At),
  124631. At._parentContainer = c
  124632. }
  124633. if (_.skeletons !== void 0 && _.skeletons !== null)
  124634. for (k = 0,
  124635. j = _.skeletons.length; k < j; k++) {
  124636. var gt = _.skeletons[k]
  124637. , St = Skeleton.Parse(gt, a);
  124638. c.skeletons.push(St),
  124639. St._parentContainer = c,
  124640. d += k === 0 ? `
  124641. Skeletons:` : "",
  124642. d += `
  124643. ` + St.toString(b)
  124644. }
  124645. var xt = _.geometries;
  124646. if (xt != null) {
  124647. var bt = new Array
  124648. , Rt = xt.vertexData;
  124649. if (Rt != null)
  124650. for (k = 0,
  124651. j = Rt.length; k < j; k++) {
  124652. var Mt = Rt[k];
  124653. bt.push(Geometry.Parse(Mt, a, i))
  124654. }
  124655. bt.forEach(function(jt) {
  124656. jt && (c.geometries.push(jt),
  124657. jt._parentContainer = c)
  124658. })
  124659. }
  124660. if (_.transformNodes !== void 0 && _.transformNodes !== null)
  124661. for (k = 0,
  124662. j = _.transformNodes.length; k < j; k++) {
  124663. var Pt = _.transformNodes[k]
  124664. , It = TransformNode.Parse(Pt, a, i);
  124665. tempIndexContainer[Pt.uniqueId] = It,
  124666. c.transformNodes.push(It),
  124667. It._parentContainer = c
  124668. }
  124669. if (_.meshes !== void 0 && _.meshes !== null)
  124670. for (k = 0,
  124671. j = _.meshes.length; k < j; k++) {
  124672. var Dt = _.meshes[k]
  124673. , Ct = Mesh.Parse(Dt, a, i);
  124674. if (tempIndexContainer[Dt.uniqueId] = Ct,
  124675. c.meshes.push(Ct),
  124676. Ct._parentContainer = c,
  124677. Ct.hasInstances)
  124678. for (var Ot = 0, wt = Ct.instances; Ot < wt.length; Ot++) {
  124679. var Nt = wt[Ot];
  124680. c.meshes.push(Nt),
  124681. Nt._parentContainer = c
  124682. }
  124683. d += k === 0 ? `
  124684. Meshes:` : "",
  124685. d += `
  124686. ` + Ct.toString(b)
  124687. }
  124688. if (_.cameras !== void 0 && _.cameras !== null)
  124689. for (k = 0,
  124690. j = _.cameras.length; k < j; k++) {
  124691. var Ft = _.cameras[k]
  124692. , Vt = Camera$1.Parse(Ft, a);
  124693. tempIndexContainer[Ft.uniqueId] = Vt,
  124694. c.cameras.push(Vt),
  124695. Vt._parentContainer = c,
  124696. d += k === 0 ? `
  124697. Cameras:` : "",
  124698. d += `
  124699. ` + Vt.toString(b)
  124700. }
  124701. if (_.postProcesses !== void 0 && _.postProcesses !== null)
  124702. for (k = 0,
  124703. j = _.postProcesses.length; k < j; k++) {
  124704. var Lt = _.postProcesses[k]
  124705. , kt = PostProcess.Parse(Lt, a, i);
  124706. kt && (c.postProcesses.push(kt),
  124707. kt._parentContainer = c,
  124708. d += k === 0 ? `
  124709. Postprocesses:` : "",
  124710. d += `
  124711. ` + kt.toString())
  124712. }
  124713. if (_.animationGroups !== void 0 && _.animationGroups !== null)
  124714. for (k = 0,
  124715. j = _.animationGroups.length; k < j; k++) {
  124716. var Bt = _.animationGroups[k]
  124717. , Ut = AnimationGroup.Parse(Bt, a);
  124718. c.animationGroups.push(Ut),
  124719. Ut._parentContainer = c,
  124720. d += k === 0 ? `
  124721. AnimationGroups:` : "",
  124722. d += `
  124723. ` + Ut.toString(b)
  124724. }
  124725. for (k = 0,
  124726. j = a.cameras.length; k < j; k++) {
  124727. var Vt = a.cameras[k];
  124728. Vt._waitingParentId && (Vt.parent = findParent(Vt._waitingParentId, a),
  124729. Vt._waitingParentId = null)
  124730. }
  124731. for (k = 0,
  124732. j = a.lights.length; k < j; k++) {
  124733. var Gt = a.lights[k];
  124734. Gt && Gt._waitingParentId && (Gt.parent = findParent(Gt._waitingParentId, a),
  124735. Gt._waitingParentId = null)
  124736. }
  124737. for (k = 0,
  124738. j = a.transformNodes.length; k < j; k++) {
  124739. var Ht = a.transformNodes[k];
  124740. Ht._waitingParentId && (Ht.parent = findParent(Ht._waitingParentId, a),
  124741. Ht._waitingParentId = null)
  124742. }
  124743. for (k = 0,
  124744. j = a.meshes.length; k < j; k++) {
  124745. var Ct = a.meshes[k];
  124746. Ct._waitingParentId && (Ct.parent = findParent(Ct._waitingParentId, a),
  124747. Ct._waitingParentId = null),
  124748. Ct._waitingData.lods && loadDetailLevels(a, Ct)
  124749. }
  124750. for (k = 0,
  124751. j = a.skeletons.length; k < j; k++) {
  124752. var St = a.skeletons[k];
  124753. St._hasWaitingData && (St.bones != null && St.bones.forEach(function(Xt) {
  124754. if (Xt._waitingTransformNodeId) {
  124755. var nr = a.getLastEntryById(Xt._waitingTransformNodeId);
  124756. nr && Xt.linkTransformNode(nr),
  124757. Xt._waitingTransformNodeId = null
  124758. }
  124759. }),
  124760. St._waitingOverrideMeshId && (St.overrideMesh = a.getMeshById(St._waitingOverrideMeshId),
  124761. St._waitingOverrideMeshId = null),
  124762. St._hasWaitingData = null)
  124763. }
  124764. for (k = 0,
  124765. j = a.meshes.length; k < j; k++) {
  124766. var zt = a.meshes[k];
  124767. zt._waitingData.freezeWorldMatrix ? (zt.freezeWorldMatrix(),
  124768. zt._waitingData.freezeWorldMatrix = null) : zt.computeWorldMatrix(!0)
  124769. }
  124770. for (k = 0,
  124771. j = a.lights.length; k < j; k++) {
  124772. var Wt = a.lights[k];
  124773. if (Wt._excludedMeshesIds.length > 0) {
  124774. for (var Kt = 0; Kt < Wt._excludedMeshesIds.length; Kt++) {
  124775. var Qt = a.getMeshById(Wt._excludedMeshesIds[Kt]);
  124776. Qt && Wt.excludedMeshes.push(Qt)
  124777. }
  124778. Wt._excludedMeshesIds = []
  124779. }
  124780. if (Wt._includedOnlyMeshesIds.length > 0) {
  124781. for (var qt = 0; qt < Wt._includedOnlyMeshesIds.length; qt++) {
  124782. var Yt = a.getMeshById(Wt._includedOnlyMeshesIds[qt]);
  124783. Yt && Wt.includedOnlyMeshes.push(Yt)
  124784. }
  124785. Wt._includedOnlyMeshesIds = []
  124786. }
  124787. }
  124788. for (AbstractScene.Parse(_, a, c, i),
  124789. k = 0,
  124790. j = a.meshes.length; k < j; k++) {
  124791. var Ct = a.meshes[k];
  124792. Ct._waitingData.actions && (ActionManager.Parse(Ct._waitingData.actions, Ct, a),
  124793. Ct._waitingData.actions = null)
  124794. }
  124795. _.actions !== void 0 && _.actions !== null && ActionManager.Parse(_.actions, null, a)
  124796. } catch (jt) {
  124797. var Jt = logOperation("loadAssets", _ ? _.producer : "Unknown") + d;
  124798. if (o)
  124799. o(Jt, jt);
  124800. else
  124801. throw Logger$2.Log(Jt),
  124802. jt
  124803. } finally {
  124804. tempIndexContainer = {},
  124805. s || c.removeAllFromScene(),
  124806. d !== null && SceneLoader.loggingLevel !== SceneLoader.NO_LOGGING && Logger$2.Log(logOperation("loadAssets", _ ? _.producer : "Unknown") + (SceneLoader.loggingLevel !== SceneLoader.MINIMAL_LOGGING ? d : ""))
  124807. }
  124808. return c
  124809. };
  124810. SceneLoader.RegisterPlugin({
  124811. name: "babylon.js",
  124812. extensions: ".babylon",
  124813. canDirectLoad: function(a) {
  124814. return a.indexOf("babylon") !== -1
  124815. },
  124816. importMesh: function(a, e, i, o, s, c, d, _) {
  124817. var b = "importMesh has failed JSON parse";
  124818. try {
  124819. var k = JSON.parse(i);
  124820. b = "";
  124821. var j = SceneLoader.loggingLevel === SceneLoader.DETAILED_LOGGING;
  124822. a ? Array.isArray(a) || (a = [a]) : a = null;
  124823. var $ = new Array;
  124824. if (k.meshes !== void 0 && k.meshes !== null) {
  124825. var _e = [], et = [], tt, rt;
  124826. for (tt = 0,
  124827. rt = k.meshes.length; tt < rt; tt++) {
  124828. var it = k.meshes[tt];
  124829. if (a === null || isDescendantOf(it, a, $)) {
  124830. if (a !== null && delete a[a.indexOf(it.name)],
  124831. it.geometryId !== void 0 && it.geometryId !== null && k.geometries !== void 0 && k.geometries !== null) {
  124832. var nt = !1;
  124833. ["boxes", "spheres", "cylinders", "toruses", "grounds", "planes", "torusKnots", "vertexData"].forEach(function(Pt) {
  124834. nt === !0 || !k.geometries[Pt] || !Array.isArray(k.geometries[Pt]) || k.geometries[Pt].forEach(function(It) {
  124835. if (It.id === it.geometryId) {
  124836. switch (Pt) {
  124837. case "vertexData":
  124838. Geometry.Parse(It, e, o);
  124839. break
  124840. }
  124841. nt = !0
  124842. }
  124843. })
  124844. }),
  124845. nt === !1 && Logger$2.Warn("Geometry not found for mesh " + it.id)
  124846. }
  124847. if (it.materialId) {
  124848. var ot = et.indexOf(it.materialId) !== -1;
  124849. if (ot === !1 && k.multiMaterials !== void 0 && k.multiMaterials !== null)
  124850. for (var at = 0, st = k.multiMaterials.length; at < st; at++) {
  124851. var ut = k.multiMaterials[at];
  124852. if (ut.id === it.materialId) {
  124853. for (var ct = 0, lt = ut.materials.length; ct < lt; ct++) {
  124854. var ft = ut.materials[ct];
  124855. et.push(ft);
  124856. var ht = parseMaterialById(ft, k, e, o);
  124857. ht && (b += `
  124858. Material ` + ht.toString(j))
  124859. }
  124860. et.push(ut.id);
  124861. var pt = MultiMaterial.ParseMultiMaterial(ut, e);
  124862. pt && (ot = !0,
  124863. b += `
  124864. Multi-Material ` + pt.toString(j));
  124865. break
  124866. }
  124867. }
  124868. if (ot === !1) {
  124869. et.push(it.materialId);
  124870. var ht = parseMaterialById(it.materialId, k, e, o);
  124871. ht ? b += `
  124872. Material ` + ht.toString(j) : Logger$2.Warn("Material not found for mesh " + it.id)
  124873. }
  124874. }
  124875. if (it.skeletonId > -1 && k.skeletons !== void 0 && k.skeletons !== null) {
  124876. var dt = _e.indexOf(it.skeletonId) > -1;
  124877. if (dt === !1)
  124878. for (var _t = 0, mt = k.skeletons.length; _t < mt; _t++) {
  124879. var vt = k.skeletons[_t];
  124880. if (vt.id === it.skeletonId) {
  124881. var yt = Skeleton.Parse(vt, e);
  124882. d.push(yt),
  124883. _e.push(vt.id),
  124884. b += `
  124885. Skeleton ` + yt.toString(j)
  124886. }
  124887. }
  124888. }
  124889. if (k.morphTargetManagers !== void 0 && k.morphTargetManagers !== null)
  124890. for (var Et = 0, At = k.morphTargetManagers; Et < At.length; Et++) {
  124891. var gt = At[Et];
  124892. MorphTargetManager.Parse(gt, e)
  124893. }
  124894. var St = Mesh.Parse(it, e, o);
  124895. s.push(St),
  124896. b += `
  124897. Mesh ` + St.toString(j)
  124898. }
  124899. }
  124900. var xt;
  124901. for (tt = 0,
  124902. rt = e.meshes.length; tt < rt; tt++)
  124903. xt = e.meshes[tt],
  124904. xt._waitingParentId && (xt.parent = e.getLastEntryById(xt._waitingParentId),
  124905. xt._waitingParentId = null),
  124906. xt._waitingData.lods && loadDetailLevels(e, xt);
  124907. for (tt = 0,
  124908. rt = e.skeletons.length; tt < rt; tt++) {
  124909. var yt = e.skeletons[tt];
  124910. yt._hasWaitingData && (yt.bones != null && yt.bones.forEach(function(It) {
  124911. if (It._waitingTransformNodeId) {
  124912. var Dt = e.getLastEntryById(It._waitingTransformNodeId);
  124913. Dt && It.linkTransformNode(Dt),
  124914. It._waitingTransformNodeId = null
  124915. }
  124916. }),
  124917. yt._waitingOverrideMeshId && (yt.overrideMesh = e.getMeshById(yt._waitingOverrideMeshId),
  124918. yt._waitingOverrideMeshId = null),
  124919. yt._hasWaitingData = null)
  124920. }
  124921. for (tt = 0,
  124922. rt = e.meshes.length; tt < rt; tt++)
  124923. xt = e.meshes[tt],
  124924. xt._waitingData.freezeWorldMatrix ? (xt.freezeWorldMatrix(),
  124925. xt._waitingData.freezeWorldMatrix = null) : xt.computeWorldMatrix(!0)
  124926. }
  124927. if (k.particleSystems !== void 0 && k.particleSystems !== null) {
  124928. var bt = AbstractScene.GetIndividualParser(SceneComponentConstants.NAME_PARTICLESYSTEM);
  124929. if (bt)
  124930. for (tt = 0,
  124931. rt = k.particleSystems.length; tt < rt; tt++) {
  124932. var Rt = k.particleSystems[tt];
  124933. $.indexOf(Rt.emitterId) !== -1 && c.push(bt(Rt, e, o))
  124934. }
  124935. }
  124936. return !0
  124937. } catch (Pt) {
  124938. var Mt = logOperation("importMesh", k ? k.producer : "Unknown") + b;
  124939. if (_)
  124940. _(Mt, Pt);
  124941. else
  124942. throw Logger$2.Log(Mt),
  124943. Pt
  124944. } finally {
  124945. b !== null && SceneLoader.loggingLevel !== SceneLoader.NO_LOGGING && Logger$2.Log(logOperation("importMesh", k ? k.producer : "Unknown") + (SceneLoader.loggingLevel !== SceneLoader.MINIMAL_LOGGING ? b : ""))
  124946. }
  124947. return !1
  124948. },
  124949. load: function(a, e, i, o) {
  124950. var s = "importScene has failed JSON parse";
  124951. try {
  124952. var c = JSON.parse(e);
  124953. if (s = "",
  124954. c.useDelayedTextureLoading !== void 0 && c.useDelayedTextureLoading !== null && (a.useDelayedTextureLoading = c.useDelayedTextureLoading && !SceneLoader.ForceFullSceneLoadingForIncremental),
  124955. c.autoClear !== void 0 && c.autoClear !== null && (a.autoClear = c.autoClear),
  124956. c.clearColor !== void 0 && c.clearColor !== null && (a.clearColor = Color4.FromArray(c.clearColor)),
  124957. c.ambientColor !== void 0 && c.ambientColor !== null && (a.ambientColor = Color3.FromArray(c.ambientColor)),
  124958. c.gravity !== void 0 && c.gravity !== null && (a.gravity = Vector3.FromArray(c.gravity)),
  124959. c.fogMode && c.fogMode !== 0)
  124960. switch (a.fogMode = c.fogMode,
  124961. a.fogColor = Color3.FromArray(c.fogColor),
  124962. a.fogStart = c.fogStart,
  124963. a.fogEnd = c.fogEnd,
  124964. a.fogDensity = c.fogDensity,
  124965. s += " Fog mode for scene: ",
  124966. a.fogMode) {
  124967. case 1:
  124968. s += `exp
  124969. `;
  124970. break;
  124971. case 2:
  124972. s += `exp2
  124973. `;
  124974. break;
  124975. case 3:
  124976. s += `linear
  124977. `;
  124978. break
  124979. }
  124980. if (c.physicsEnabled) {
  124981. var d;
  124982. c.physicsEngine === "cannon" ? d = new CannonJSPlugin(void 0,void 0,BabylonFileLoaderConfiguration.LoaderInjectedPhysicsEngine) : c.physicsEngine === "oimo" ? d = new OimoJSPlugin(void 0,BabylonFileLoaderConfiguration.LoaderInjectedPhysicsEngine) : c.physicsEngine === "ammo" && (d = new AmmoJSPlugin(void 0,BabylonFileLoaderConfiguration.LoaderInjectedPhysicsEngine,void 0)),
  124983. s = " Physics engine " + (c.physicsEngine ? c.physicsEngine : "oimo") + ` enabled
  124984. `;
  124985. var _ = c.physicsGravity ? Vector3.FromArray(c.physicsGravity) : null;
  124986. a.enablePhysics(_, d)
  124987. }
  124988. c.metadata !== void 0 && c.metadata !== null && (a.metadata = c.metadata),
  124989. c.collisionsEnabled !== void 0 && c.collisionsEnabled !== null && (a.collisionsEnabled = c.collisionsEnabled);
  124990. var b = loadAssetContainer(a, e, i, o, !0);
  124991. return b ? (c.autoAnimate && a.beginAnimation(a, c.autoAnimateFrom, c.autoAnimateTo, c.autoAnimateLoop, c.autoAnimateSpeed || 1),
  124992. c.activeCameraID !== void 0 && c.activeCameraID !== null && a.setActiveCameraById(c.activeCameraID),
  124993. !0) : !1
  124994. } catch (j) {
  124995. var k = logOperation("importScene", c ? c.producer : "Unknown") + s;
  124996. if (o)
  124997. o(k, j);
  124998. else
  124999. throw Logger$2.Log(k),
  125000. j
  125001. } finally {
  125002. s !== null && SceneLoader.loggingLevel !== SceneLoader.NO_LOGGING && Logger$2.Log(logOperation("importScene", c ? c.producer : "Unknown") + (SceneLoader.loggingLevel !== SceneLoader.MINIMAL_LOGGING ? s : ""))
  125003. }
  125004. return !1
  125005. },
  125006. loadAssetContainer: function(a, e, i, o) {
  125007. var s = loadAssetContainer(a, e, i, o);
  125008. return s
  125009. }
  125010. });
  125011. var name$a = "depthPixelShader"
  125012. , shader$a = `#ifdef ALPHATEST
  125013. varying vec2 vUV;
  125014. uniform sampler2D diffuseSampler;
  125015. #endif
  125016. varying float vDepthMetric;
  125017. #ifdef PACKED
  125018. #include<packingFunctions>
  125019. #endif
  125020. void main(void)
  125021. {
  125022. #ifdef ALPHATEST
  125023. if (texture2D(diffuseSampler,vUV).a<0.4)
  125024. discard;
  125025. #endif
  125026. #ifdef NONLINEARDEPTH
  125027. #ifdef PACKED
  125028. gl_FragColor=pack(gl_FragCoord.z);
  125029. #else
  125030. gl_FragColor=vec4(gl_FragCoord.z,0.0,0.0,0.0);
  125031. #endif
  125032. #else
  125033. #ifdef PACKED
  125034. gl_FragColor=pack(vDepthMetric);
  125035. #else
  125036. gl_FragColor=vec4(vDepthMetric,0.0,0.0,1.0);
  125037. #endif
  125038. #endif
  125039. }`;
  125040. ShaderStore.ShadersStore[name$a] = shader$a;
  125041. var name$9 = "depthVertexShader"
  125042. , shader$9 = `
  125043. attribute vec3 position;
  125044. #include<bonesDeclaration>
  125045. #include<bakedVertexAnimationDeclaration>
  125046. #include<morphTargetsVertexGlobalDeclaration>
  125047. #include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
  125048. #include<instancesDeclaration>
  125049. uniform mat4 viewProjection;
  125050. uniform vec2 depthValues;
  125051. #if defined(ALPHATEST) || defined(NEED_UV)
  125052. varying vec2 vUV;
  125053. uniform mat4 diffuseMatrix;
  125054. #ifdef UV1
  125055. attribute vec2 uv;
  125056. #endif
  125057. #ifdef UV2
  125058. attribute vec2 uv2;
  125059. #endif
  125060. #endif
  125061. varying float vDepthMetric;
  125062. void main(void)
  125063. {
  125064. vec3 positionUpdated=position;
  125065. #ifdef UV1
  125066. vec2 uvUpdated=uv;
  125067. #endif
  125068. #include<morphTargetsVertexGlobal>
  125069. #include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
  125070. #include<instancesVertex>
  125071. #include<bonesVertex>
  125072. #include<bakedVertexAnimation>
  125073. gl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);
  125074. #ifdef USE_REVERSE_DEPTHBUFFER
  125075. vDepthMetric=((-gl_Position.z+depthValues.x)/(depthValues.y));
  125076. #else
  125077. vDepthMetric=((gl_Position.z+depthValues.x)/(depthValues.y));
  125078. #endif
  125079. #if defined(ALPHATEST) || defined(BASIC_RENDER)
  125080. #ifdef UV1
  125081. vUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));
  125082. #endif
  125083. #ifdef UV2
  125084. vUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));
  125085. #endif
  125086. #endif
  125087. }
  125088. `;
  125089. ShaderStore.ShadersStore[name$9] = shader$9;
  125090. var DepthRenderer = function() {
  125091. function a(e, i, o, s, c) {
  125092. var d = this;
  125093. i === void 0 && (i = 1),
  125094. o === void 0 && (o = null),
  125095. s === void 0 && (s = !1),
  125096. c === void 0 && (c = Texture.TRILINEAR_SAMPLINGMODE),
  125097. this.enabled = !0,
  125098. this.forceDepthWriteTransparentMeshes = !1,
  125099. this.useOnlyInActiveCamera = !1,
  125100. this._scene = e,
  125101. this._storeNonLinearDepth = s,
  125102. this.isPacked = i === 0,
  125103. this.isPacked ? this._clearColor = new Color4(1,1,1,1) : this._clearColor = new Color4(1,0,0,1),
  125104. a._SceneComponentInitialization(this._scene);
  125105. var _ = e.getEngine();
  125106. this._camera = o,
  125107. c !== Texture.NEAREST_SAMPLINGMODE && (i === 1 && !_._caps.textureFloatLinearFiltering && (c = Texture.NEAREST_SAMPLINGMODE),
  125108. i === 2 && !_._caps.textureHalfFloatLinearFiltering && (c = Texture.NEAREST_SAMPLINGMODE));
  125109. var b = this.isPacked || !_._features.supportExtendedTextureFormats ? 5 : 6;
  125110. this._depthMap = new RenderTargetTexture("DepthRenderer",{
  125111. width: _.getRenderWidth(),
  125112. height: _.getRenderHeight()
  125113. },this._scene,!1,!0,i,!1,c,void 0,void 0,void 0,b),
  125114. this._depthMap.wrapU = Texture.CLAMP_ADDRESSMODE,
  125115. this._depthMap.wrapV = Texture.CLAMP_ADDRESSMODE,
  125116. this._depthMap.refreshRate = 1,
  125117. this._depthMap.renderParticles = !1,
  125118. this._depthMap.renderList = null,
  125119. this._depthMap.activeCamera = this._camera,
  125120. this._depthMap.ignoreCameraViewport = !0,
  125121. this._depthMap.useCameraPostProcesses = !1,
  125122. this._depthMap.onClearObservable.add(function(j) {
  125123. j.clear(d._clearColor, !0, !0, !0)
  125124. }),
  125125. this._depthMap.onBeforeBindObservable.add(function() {
  125126. var j;
  125127. (j = _._debugPushGroup) === null || j === void 0 || j.call(_, "depth renderer", 1)
  125128. }),
  125129. this._depthMap.onAfterUnbindObservable.add(function() {
  125130. var j;
  125131. (j = _._debugPopGroup) === null || j === void 0 || j.call(_, 1)
  125132. });
  125133. var k = function(j) {
  125134. var $, _e, et = j.getRenderingMesh(), tt = j.getEffectiveMesh(), rt = d._scene, it = rt.getEngine(), nt = j.getMaterial();
  125135. if (tt._internalAbstractMeshDataInfo._isActiveIntermediate = !1,
  125136. !(!nt || tt.infiniteDistance || nt.disableDepthWrite || j.verticesCount === 0 || j._renderId === rt.getRenderId())) {
  125137. var ot = tt._getWorldMatrixDeterminant() < 0
  125138. , at = ($ = et.overrideMaterialSideOrientation) !== null && $ !== void 0 ? $ : nt.sideOrientation;
  125139. (rt.useRightHandedSystem && !ot || !rt.useRightHandedSystem && ot) && (at = at === 0 ? 1 : 0);
  125140. var st = at === 0;
  125141. it.setState(nt.backFaceCulling, 0, !1, st, nt.cullBackFaces);
  125142. var ut = et._getInstancesRenderList(j._id, !!j.getReplacementMesh());
  125143. if (!ut.mustReturn) {
  125144. var ct = it.getCaps().instancedArrays && (ut.visibleInstances[j._id] !== null && ut.visibleInstances[j._id] !== void 0 || et.hasThinInstances)
  125145. , lt = d._camera || rt.activeCamera;
  125146. if (d.isReady(j, ct) && lt) {
  125147. j._renderId = rt.getRenderId();
  125148. var ft = (_e = tt._internalAbstractMeshDataInfo._materialForRenderPass) === null || _e === void 0 ? void 0 : _e[it.currentRenderPassId]
  125149. , ht = j._getDrawWrapper();
  125150. !ht && ft && (ht = ft._getDrawWrapper());
  125151. var pt = lt.mode === Camera$1.ORTHOGRAPHIC_CAMERA;
  125152. if (!ht)
  125153. return;
  125154. var dt = ht.effect;
  125155. it.enableEffect(ht),
  125156. ct || et._bind(j, dt, nt.fillMode),
  125157. ft ? ft.bindForSubMesh(tt.getWorldMatrix(), tt, j) : (dt.setMatrix("viewProjection", rt.getTransformMatrix()),
  125158. dt.setMatrix("world", tt.getWorldMatrix()));
  125159. var _t = void 0
  125160. , mt = void 0;
  125161. if (pt ? (_t = !it.useReverseDepthBuffer && it.isNDCHalfZRange ? 0 : 1,
  125162. mt = it.useReverseDepthBuffer && it.isNDCHalfZRange ? 0 : 1) : (_t = it.useReverseDepthBuffer && it.isNDCHalfZRange ? lt.minZ : it.isNDCHalfZRange ? 0 : lt.minZ,
  125163. mt = it.useReverseDepthBuffer && it.isNDCHalfZRange ? 0 : lt.maxZ),
  125164. dt.setFloat2("depthValues", _t, _t + mt),
  125165. !ft) {
  125166. if (nt && nt.needAlphaTesting()) {
  125167. var vt = nt.getAlphaTestTexture();
  125168. vt && (dt.setTexture("diffuseSampler", vt),
  125169. dt.setMatrix("diffuseMatrix", vt.getTextureMatrix()))
  125170. }
  125171. if (et.useBones && et.computeBonesUsingShaders && et.skeleton) {
  125172. var yt = et.skeleton;
  125173. if (yt.isUsingTextureForMatrices) {
  125174. var Et = yt.getTransformMatrixTexture(et);
  125175. if (!Et)
  125176. return;
  125177. dt.setTexture("boneSampler", Et),
  125178. dt.setFloat("boneTextureWidth", 4 * (yt.bones.length + 1))
  125179. } else
  125180. dt.setMatrices("mBones", yt.getTransformMatrices(et))
  125181. }
  125182. MaterialHelper.BindMorphTargetParameters(et, dt),
  125183. et.morphTargetManager && et.morphTargetManager.isUsingTextureForTargets && et.morphTargetManager._bind(dt)
  125184. }
  125185. et._processRendering(tt, j, dt, nt.fillMode, ut, ct, function(At, gt) {
  125186. return dt.setMatrix("world", gt)
  125187. })
  125188. }
  125189. }
  125190. }
  125191. };
  125192. this._depthMap.customRenderFunction = function(j, $, _e, et) {
  125193. var tt;
  125194. if (et.length)
  125195. for (tt = 0; tt < et.length; tt++)
  125196. k(et.data[tt]);
  125197. for (tt = 0; tt < j.length; tt++)
  125198. k(j.data[tt]);
  125199. for (tt = 0; tt < $.length; tt++)
  125200. k($.data[tt]);
  125201. if (d.forceDepthWriteTransparentMeshes)
  125202. for (tt = 0; tt < _e.length; tt++)
  125203. k(_e.data[tt]);
  125204. else
  125205. for (tt = 0; tt < _e.length; tt++)
  125206. _e.data[tt].getEffectiveMesh()._internalAbstractMeshDataInfo._isActiveIntermediate = !1
  125207. }
  125208. }
  125209. return a.prototype.setMaterialForRendering = function(e, i) {
  125210. this._depthMap.setMaterialForRendering(e, i)
  125211. }
  125212. ,
  125213. a.prototype.isReady = function(e, i) {
  125214. var o, s = this._scene.getEngine(), c = e.getMesh(), d = (o = c._internalAbstractMeshDataInfo._materialForRenderPass) === null || o === void 0 ? void 0 : o[s.currentRenderPassId];
  125215. if (d)
  125216. return d.isReadyForSubMesh(c, e, i);
  125217. var _ = e.getMaterial();
  125218. if (!_ || _.disableDepthWrite)
  125219. return !1;
  125220. var b = []
  125221. , k = [VertexBuffer.PositionKind];
  125222. if (_ && _.needAlphaTesting() && _.getAlphaTestTexture() && (b.push("#define ALPHATEST"),
  125223. c.isVerticesDataPresent(VertexBuffer.UVKind) && (k.push(VertexBuffer.UVKind),
  125224. b.push("#define UV1")),
  125225. c.isVerticesDataPresent(VertexBuffer.UV2Kind) && (k.push(VertexBuffer.UV2Kind),
  125226. b.push("#define UV2"))),
  125227. c.useBones && c.computeBonesUsingShaders) {
  125228. k.push(VertexBuffer.MatricesIndicesKind),
  125229. k.push(VertexBuffer.MatricesWeightsKind),
  125230. c.numBoneInfluencers > 4 && (k.push(VertexBuffer.MatricesIndicesExtraKind),
  125231. k.push(VertexBuffer.MatricesWeightsExtraKind)),
  125232. b.push("#define NUM_BONE_INFLUENCERS " + c.numBoneInfluencers),
  125233. b.push("#define BonesPerMesh " + (c.skeleton ? c.skeleton.bones.length + 1 : 0));
  125234. var j = e.getRenderingMesh().skeleton;
  125235. j != null && j.isUsingTextureForMatrices && b.push("#define BONETEXTURE")
  125236. } else
  125237. b.push("#define NUM_BONE_INFLUENCERS 0");
  125238. var $ = c.morphTargetManager
  125239. , _e = 0;
  125240. $ && $.numInfluencers > 0 && (_e = $.numInfluencers,
  125241. b.push("#define MORPHTARGETS"),
  125242. b.push("#define NUM_MORPH_INFLUENCERS " + _e),
  125243. $.isUsingTextureForTargets && b.push("#define MORPHTARGETS_TEXTURE"),
  125244. MaterialHelper.PrepareAttributesForMorphTargetsInfluencers(k, c, _e)),
  125245. i && (b.push("#define INSTANCES"),
  125246. MaterialHelper.PushAttributesForInstances(k),
  125247. e.getRenderingMesh().hasThinInstances && b.push("#define THIN_INSTANCES")),
  125248. this._storeNonLinearDepth && b.push("#define NONLINEARDEPTH"),
  125249. this.isPacked && b.push("#define PACKED");
  125250. var et = e._getDrawWrapper(void 0, !0)
  125251. , tt = et.defines
  125252. , rt = b.join(`
  125253. `);
  125254. return tt !== rt && et.setEffect(s.createEffect("depth", k, ["world", "mBones", "boneTextureWidth", "viewProjection", "diffuseMatrix", "depthValues", "morphTargetInfluences", "morphTargetTextureInfo", "morphTargetTextureIndices"], ["diffuseSampler", "morphTargets", "boneSampler"], rt, void 0, void 0, void 0, {
  125255. maxSimultaneousMorphTargets: _e
  125256. }), rt),
  125257. et.effect.isReady()
  125258. }
  125259. ,
  125260. a.prototype.getDepthMap = function() {
  125261. return this._depthMap
  125262. }
  125263. ,
  125264. a.prototype.dispose = function() {
  125265. var e = [];
  125266. for (var i in this._scene._depthRenderer) {
  125267. var o = this._scene._depthRenderer[i];
  125268. o === this && e.push(i)
  125269. }
  125270. if (e.length > 0) {
  125271. this._depthMap.dispose();
  125272. for (var s = 0, c = e; s < c.length; s++) {
  125273. var d = c[s];
  125274. delete this._scene._depthRenderer[d]
  125275. }
  125276. }
  125277. }
  125278. ,
  125279. a._SceneComponentInitialization = function(e) {
  125280. throw _WarnImport("DepthRendererSceneComponent")
  125281. }
  125282. ,
  125283. a
  125284. }()
  125285. , name$8 = "minmaxReduxPixelShader"
  125286. , shader$8 = `varying vec2 vUV;
  125287. uniform sampler2D textureSampler;
  125288. #if defined(INITIAL)
  125289. uniform sampler2D sourceTexture;
  125290. uniform vec2 texSize;
  125291. void main(void)
  125292. {
  125293. ivec2 coord=ivec2(vUV*(texSize-1.0));
  125294. float f1=texelFetch(sourceTexture,coord,0).r;
  125295. float f2=texelFetch(sourceTexture,coord+ivec2(1,0),0).r;
  125296. float f3=texelFetch(sourceTexture,coord+ivec2(1,1),0).r;
  125297. float f4=texelFetch(sourceTexture,coord+ivec2(0,1),0).r;
  125298. float minz=min(min(min(f1,f2),f3),f4);
  125299. #ifdef DEPTH_REDUX
  125300. float maxz=max(max(max(sign(1.0-f1)*f1,sign(1.0-f2)*f2),sign(1.0-f3)*f3),sign(1.0-f4)*f4);
  125301. #else
  125302. float maxz=max(max(max(f1,f2),f3),f4);
  125303. #endif
  125304. glFragColor=vec4(minz,maxz,0.,0.);
  125305. }
  125306. #elif defined(MAIN)
  125307. uniform vec2 texSize;
  125308. void main(void)
  125309. {
  125310. ivec2 coord=ivec2(vUV*(texSize-1.0));
  125311. vec2 f1=texelFetch(textureSampler,coord,0).rg;
  125312. vec2 f2=texelFetch(textureSampler,coord+ivec2(1,0),0).rg;
  125313. vec2 f3=texelFetch(textureSampler,coord+ivec2(1,1),0).rg;
  125314. vec2 f4=texelFetch(textureSampler,coord+ivec2(0,1),0).rg;
  125315. float minz=min(min(min(f1.x,f2.x),f3.x),f4.x);
  125316. float maxz=max(max(max(f1.y,f2.y),f3.y),f4.y);
  125317. glFragColor=vec4(minz,maxz,0.,0.);
  125318. }
  125319. #elif defined(ONEBEFORELAST)
  125320. uniform ivec2 texSize;
  125321. void main(void)
  125322. {
  125323. ivec2 coord=ivec2(vUV*vec2(texSize-1));
  125324. vec2 f1=texelFetch(textureSampler,coord % texSize,0).rg;
  125325. vec2 f2=texelFetch(textureSampler,(coord+ivec2(1,0)) % texSize,0).rg;
  125326. vec2 f3=texelFetch(textureSampler,(coord+ivec2(1,1)) % texSize,0).rg;
  125327. vec2 f4=texelFetch(textureSampler,(coord+ivec2(0,1)) % texSize,0).rg;
  125328. float minz=min(f1.x,f2.x);
  125329. float maxz=max(f1.y,f2.y);
  125330. glFragColor=vec4(minz,maxz,0.,0.);
  125331. }
  125332. #elif defined(LAST)
  125333. void main(void)
  125334. {
  125335. glFragColor=vec4(0.);
  125336. discard;
  125337. }
  125338. #endif
  125339. `;
  125340. ShaderStore.ShadersStore[name$8] = shader$8;
  125341. var MinMaxReducer = function() {
  125342. function a(e) {
  125343. var i = this;
  125344. this.onAfterReductionPerformed = new Observable,
  125345. this._forceFullscreenViewport = !0,
  125346. this._activated = !1,
  125347. this._camera = e,
  125348. this._postProcessManager = new PostProcessManager(e.getScene()),
  125349. this._onContextRestoredObserver = e.getEngine().onContextRestoredObservable.add(function() {
  125350. i._postProcessManager._rebuild()
  125351. })
  125352. }
  125353. return Object.defineProperty(a.prototype, "sourceTexture", {
  125354. get: function() {
  125355. return this._sourceTexture
  125356. },
  125357. enumerable: !1,
  125358. configurable: !0
  125359. }),
  125360. a.prototype.setSourceTexture = function(e, i, o, s) {
  125361. var c = this;
  125362. if (o === void 0 && (o = 2),
  125363. s === void 0 && (s = !0),
  125364. e !== this._sourceTexture) {
  125365. this.dispose(!1),
  125366. this._sourceTexture = e,
  125367. this._reductionSteps = [],
  125368. this._forceFullscreenViewport = s;
  125369. var d = this._camera.getScene()
  125370. , _ = new PostProcess("Initial reduction phase","minmaxRedux",["texSize"],["sourceTexture"],1,null,1,d.getEngine(),!1,"#define INITIAL" + (i ? `
  125371. #define DEPTH_REDUX` : ""),o,void 0,void 0,void 0,7);
  125372. _.autoClear = !1,
  125373. _.forceFullscreenViewport = s;
  125374. var b = this._sourceTexture.getRenderWidth()
  125375. , k = this._sourceTexture.getRenderHeight();
  125376. _.onApply = function(et, tt) {
  125377. return function(rt) {
  125378. rt.setTexture("sourceTexture", c._sourceTexture),
  125379. rt.setFloat2("texSize", et, tt)
  125380. }
  125381. }(b, k),
  125382. this._reductionSteps.push(_);
  125383. for (var j = 1; b > 1 || k > 1; ) {
  125384. b = Math.max(Math.round(b / 2), 1),
  125385. k = Math.max(Math.round(k / 2), 1);
  125386. var $ = new PostProcess("Reduction phase " + j,"minmaxRedux",["texSize"],null,{
  125387. width: b,
  125388. height: k
  125389. },null,1,d.getEngine(),!1,"#define " + (b == 1 && k == 1 ? "LAST" : b == 1 || k == 1 ? "ONEBEFORELAST" : "MAIN"),o,void 0,void 0,void 0,7);
  125390. if ($.autoClear = !1,
  125391. $.forceFullscreenViewport = s,
  125392. $.onApply = function(et, tt) {
  125393. return function(rt) {
  125394. et == 1 || tt == 1 ? rt.setInt2("texSize", et, tt) : rt.setFloat2("texSize", et, tt)
  125395. }
  125396. }(b, k),
  125397. this._reductionSteps.push($),
  125398. j++,
  125399. b == 1 && k == 1) {
  125400. var _e = function(et, tt, rt) {
  125401. var it = new Float32Array(4 * et * tt)
  125402. , nt = {
  125403. min: 0,
  125404. max: 0
  125405. };
  125406. return function() {
  125407. d.getEngine()._readTexturePixels(rt.inputTexture.texture, et, tt, -1, 0, it, !1),
  125408. nt.min = it[0],
  125409. nt.max = it[1],
  125410. c.onAfterReductionPerformed.notifyObservers(nt)
  125411. }
  125412. };
  125413. $.onAfterRenderObservable.add(_e(b, k, $))
  125414. }
  125415. }
  125416. }
  125417. }
  125418. ,
  125419. Object.defineProperty(a.prototype, "refreshRate", {
  125420. get: function() {
  125421. return this._sourceTexture ? this._sourceTexture.refreshRate : -1
  125422. },
  125423. set: function(e) {
  125424. this._sourceTexture && (this._sourceTexture.refreshRate = e)
  125425. },
  125426. enumerable: !1,
  125427. configurable: !0
  125428. }),
  125429. Object.defineProperty(a.prototype, "activated", {
  125430. get: function() {
  125431. return this._activated
  125432. },
  125433. enumerable: !1,
  125434. configurable: !0
  125435. }),
  125436. a.prototype.activate = function() {
  125437. var e = this;
  125438. this._onAfterUnbindObserver || !this._sourceTexture || (this._onAfterUnbindObserver = this._sourceTexture.onAfterUnbindObservable.add(function() {
  125439. var i, o, s = e._camera.getScene().getEngine();
  125440. (i = s._debugPushGroup) === null || i === void 0 || i.call(s, "min max reduction", 1),
  125441. e._reductionSteps[0].activate(e._camera),
  125442. e._postProcessManager.directRender(e._reductionSteps, e._reductionSteps[0].inputTexture, e._forceFullscreenViewport),
  125443. s.unBindFramebuffer(e._reductionSteps[0].inputTexture, !1),
  125444. (o = s._debugPopGroup) === null || o === void 0 || o.call(s, 1)
  125445. }),
  125446. this._activated = !0)
  125447. }
  125448. ,
  125449. a.prototype.deactivate = function() {
  125450. !this._onAfterUnbindObserver || !this._sourceTexture || (this._sourceTexture.onAfterUnbindObservable.remove(this._onAfterUnbindObserver),
  125451. this._onAfterUnbindObserver = null,
  125452. this._activated = !1)
  125453. }
  125454. ,
  125455. a.prototype.dispose = function(e) {
  125456. if (e === void 0 && (e = !0),
  125457. e && (this.onAfterReductionPerformed.clear(),
  125458. this._onContextRestoredObserver && (this._camera.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver),
  125459. this._onContextRestoredObserver = null)),
  125460. this.deactivate(),
  125461. this._reductionSteps) {
  125462. for (var i = 0; i < this._reductionSteps.length; ++i)
  125463. this._reductionSteps[i].dispose();
  125464. this._reductionSteps = null
  125465. }
  125466. this._postProcessManager && e && this._postProcessManager.dispose(),
  125467. this._sourceTexture = null
  125468. }
  125469. ,
  125470. a
  125471. }()
  125472. , DepthReducer = function(a) {
  125473. __extends(e, a);
  125474. function e(i) {
  125475. return a.call(this, i) || this
  125476. }
  125477. return Object.defineProperty(e.prototype, "depthRenderer", {
  125478. get: function() {
  125479. return this._depthRenderer
  125480. },
  125481. enumerable: !1,
  125482. configurable: !0
  125483. }),
  125484. e.prototype.setDepthRenderer = function(i, o, s) {
  125485. i === void 0 && (i = null),
  125486. o === void 0 && (o = 2),
  125487. s === void 0 && (s = !0);
  125488. var c = this._camera.getScene();
  125489. this._depthRenderer && (delete c._depthRenderer[this._depthRendererId],
  125490. this._depthRenderer.dispose(),
  125491. this._depthRenderer = null),
  125492. i === null && (c._depthRenderer || (c._depthRenderer = {}),
  125493. i = this._depthRenderer = new DepthRenderer(c,o,this._camera,!1,1),
  125494. i.enabled = !1,
  125495. this._depthRendererId = "minmax" + this._camera.id,
  125496. c._depthRenderer[this._depthRendererId] = i),
  125497. a.prototype.setSourceTexture.call(this, i.getDepthMap(), !0, o, s)
  125498. }
  125499. ,
  125500. e.prototype.setSourceTexture = function(i, o, s, c) {
  125501. s === void 0 && (s = 2),
  125502. c === void 0 && (c = !0),
  125503. a.prototype.setSourceTexture.call(this, i, o, s, c)
  125504. }
  125505. ,
  125506. e.prototype.activate = function() {
  125507. this._depthRenderer && (this._depthRenderer.enabled = !0),
  125508. a.prototype.activate.call(this)
  125509. }
  125510. ,
  125511. e.prototype.deactivate = function() {
  125512. a.prototype.deactivate.call(this),
  125513. this._depthRenderer && (this._depthRenderer.enabled = !1)
  125514. }
  125515. ,
  125516. e.prototype.dispose = function(i) {
  125517. if (i === void 0 && (i = !0),
  125518. a.prototype.dispose.call(this, i),
  125519. this._depthRenderer && i) {
  125520. var o = this._depthRenderer.getDepthMap().getScene();
  125521. o && delete o._depthRenderer[this._depthRendererId],
  125522. this._depthRenderer.dispose(),
  125523. this._depthRenderer = null
  125524. }
  125525. }
  125526. ,
  125527. e
  125528. }(MinMaxReducer)
  125529. , UpDir = Vector3.Up()
  125530. , ZeroVec = Vector3.Zero()
  125531. , tmpv1 = new Vector3
  125532. , tmpv2 = new Vector3
  125533. , tmpMatrix = new Matrix
  125534. , CascadedShadowGenerator = function(a) {
  125535. __extends(e, a);
  125536. function e(i, o, s) {
  125537. var c = this;
  125538. if (!e.IsSupported) {
  125539. Logger$2.Error("CascadedShadowMap is not supported by the current engine.");
  125540. return
  125541. }
  125542. return c = a.call(this, i, o, s) || this,
  125543. c.usePercentageCloserFiltering = !0,
  125544. c
  125545. }
  125546. return e.prototype._validateFilter = function(i) {
  125547. return i === ShadowGenerator.FILTER_NONE || i === ShadowGenerator.FILTER_PCF || i === ShadowGenerator.FILTER_PCSS ? i : (console.error('Unsupported filter "' + i + '"!'),
  125548. ShadowGenerator.FILTER_NONE)
  125549. }
  125550. ,
  125551. Object.defineProperty(e.prototype, "numCascades", {
  125552. get: function() {
  125553. return this._numCascades
  125554. },
  125555. set: function(i) {
  125556. i = Math.min(Math.max(i, e.MIN_CASCADES_COUNT), e.MAX_CASCADES_COUNT),
  125557. i !== this._numCascades && (this._numCascades = i,
  125558. this.recreateShadowMap(),
  125559. this._recreateSceneUBOs())
  125560. },
  125561. enumerable: !1,
  125562. configurable: !0
  125563. }),
  125564. Object.defineProperty(e.prototype, "freezeShadowCastersBoundingInfo", {
  125565. get: function() {
  125566. return this._freezeShadowCastersBoundingInfo
  125567. },
  125568. set: function(i) {
  125569. this._freezeShadowCastersBoundingInfoObservable && i && (this._scene.onBeforeRenderObservable.remove(this._freezeShadowCastersBoundingInfoObservable),
  125570. this._freezeShadowCastersBoundingInfoObservable = null),
  125571. !this._freezeShadowCastersBoundingInfoObservable && !i && (this._freezeShadowCastersBoundingInfoObservable = this._scene.onBeforeRenderObservable.add(this._computeShadowCastersBoundingInfo.bind(this))),
  125572. this._freezeShadowCastersBoundingInfo = i,
  125573. i && this._computeShadowCastersBoundingInfo()
  125574. },
  125575. enumerable: !1,
  125576. configurable: !0
  125577. }),
  125578. e.prototype._computeShadowCastersBoundingInfo = function() {
  125579. if (this._scbiMin.copyFromFloats(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE),
  125580. this._scbiMax.copyFromFloats(Number.MIN_VALUE, Number.MIN_VALUE, Number.MIN_VALUE),
  125581. this._shadowMap && this._shadowMap.renderList) {
  125582. for (var i = this._shadowMap.renderList, o = 0; o < i.length; o++) {
  125583. var s = i[o];
  125584. if (!!s) {
  125585. var c = s.getBoundingInfo()
  125586. , d = c.boundingBox;
  125587. this._scbiMin.minimizeInPlace(d.minimumWorld),
  125588. this._scbiMax.maximizeInPlace(d.maximumWorld)
  125589. }
  125590. }
  125591. for (var _ = this._scene.meshes, o = 0; o < _.length; o++) {
  125592. var s = _[o];
  125593. if (!(!s || !s.isVisible || !s.isEnabled || !s.receiveShadows)) {
  125594. var c = s.getBoundingInfo()
  125595. , d = c.boundingBox;
  125596. this._scbiMin.minimizeInPlace(d.minimumWorld),
  125597. this._scbiMax.maximizeInPlace(d.maximumWorld)
  125598. }
  125599. }
  125600. }
  125601. this._shadowCastersBoundingInfo.reConstruct(this._scbiMin, this._scbiMax)
  125602. }
  125603. ,
  125604. Object.defineProperty(e.prototype, "shadowCastersBoundingInfo", {
  125605. get: function() {
  125606. return this._shadowCastersBoundingInfo
  125607. },
  125608. set: function(i) {
  125609. this._shadowCastersBoundingInfo = i
  125610. },
  125611. enumerable: !1,
  125612. configurable: !0
  125613. }),
  125614. e.prototype.setMinMaxDistance = function(i, o) {
  125615. this._minDistance === i && this._maxDistance === o || (i > o && (i = 0,
  125616. o = 1),
  125617. i < 0 && (i = 0),
  125618. o > 1 && (o = 1),
  125619. this._minDistance = i,
  125620. this._maxDistance = o,
  125621. this._breaksAreDirty = !0)
  125622. }
  125623. ,
  125624. Object.defineProperty(e.prototype, "minDistance", {
  125625. get: function() {
  125626. return this._minDistance
  125627. },
  125628. enumerable: !1,
  125629. configurable: !0
  125630. }),
  125631. Object.defineProperty(e.prototype, "maxDistance", {
  125632. get: function() {
  125633. return this._maxDistance
  125634. },
  125635. enumerable: !1,
  125636. configurable: !0
  125637. }),
  125638. e.prototype.getClassName = function() {
  125639. return e.CLASSNAME
  125640. }
  125641. ,
  125642. e.prototype.getCascadeMinExtents = function(i) {
  125643. return i >= 0 && i < this._numCascades ? this._cascadeMinExtents[i] : null
  125644. }
  125645. ,
  125646. e.prototype.getCascadeMaxExtents = function(i) {
  125647. return i >= 0 && i < this._numCascades ? this._cascadeMaxExtents[i] : null
  125648. }
  125649. ,
  125650. Object.defineProperty(e.prototype, "shadowMaxZ", {
  125651. get: function() {
  125652. return !this._scene || !this._scene.activeCamera ? 0 : this._shadowMaxZ
  125653. },
  125654. set: function(i) {
  125655. if (!this._scene || !this._scene.activeCamera) {
  125656. this._shadowMaxZ = i;
  125657. return
  125658. }
  125659. this._shadowMaxZ === i || i < this._scene.activeCamera.minZ || i > this._scene.activeCamera.maxZ || (this._shadowMaxZ = i,
  125660. this._light._markMeshesAsLightDirty(),
  125661. this._breaksAreDirty = !0)
  125662. },
  125663. enumerable: !1,
  125664. configurable: !0
  125665. }),
  125666. Object.defineProperty(e.prototype, "debug", {
  125667. get: function() {
  125668. return this._debug
  125669. },
  125670. set: function(i) {
  125671. this._debug = i,
  125672. this._light._markMeshesAsLightDirty()
  125673. },
  125674. enumerable: !1,
  125675. configurable: !0
  125676. }),
  125677. Object.defineProperty(e.prototype, "depthClamp", {
  125678. get: function() {
  125679. return this._depthClamp
  125680. },
  125681. set: function(i) {
  125682. this._depthClamp = i
  125683. },
  125684. enumerable: !1,
  125685. configurable: !0
  125686. }),
  125687. Object.defineProperty(e.prototype, "cascadeBlendPercentage", {
  125688. get: function() {
  125689. return this._cascadeBlendPercentage
  125690. },
  125691. set: function(i) {
  125692. this._cascadeBlendPercentage = i,
  125693. this._light._markMeshesAsLightDirty()
  125694. },
  125695. enumerable: !1,
  125696. configurable: !0
  125697. }),
  125698. Object.defineProperty(e.prototype, "lambda", {
  125699. get: function() {
  125700. return this._lambda
  125701. },
  125702. set: function(i) {
  125703. var o = Math.min(Math.max(i, 0), 1);
  125704. this._lambda != o && (this._lambda = o,
  125705. this._breaksAreDirty = !0)
  125706. },
  125707. enumerable: !1,
  125708. configurable: !0
  125709. }),
  125710. e.prototype.getCascadeViewMatrix = function(i) {
  125711. return i >= 0 && i < this._numCascades ? this._viewMatrices[i] : null
  125712. }
  125713. ,
  125714. e.prototype.getCascadeProjectionMatrix = function(i) {
  125715. return i >= 0 && i < this._numCascades ? this._projectionMatrices[i] : null
  125716. }
  125717. ,
  125718. e.prototype.getCascadeTransformMatrix = function(i) {
  125719. return i >= 0 && i < this._numCascades ? this._transformMatrices[i] : null
  125720. }
  125721. ,
  125722. e.prototype.setDepthRenderer = function(i) {
  125723. this._depthRenderer = i,
  125724. this._depthReducer && this._depthReducer.setDepthRenderer(this._depthRenderer)
  125725. }
  125726. ,
  125727. Object.defineProperty(e.prototype, "autoCalcDepthBounds", {
  125728. get: function() {
  125729. return this._autoCalcDepthBounds
  125730. },
  125731. set: function(i) {
  125732. var o = this
  125733. , s = this._scene.activeCamera;
  125734. if (!!s) {
  125735. if (this._autoCalcDepthBounds = i,
  125736. !i) {
  125737. this._depthReducer && this._depthReducer.deactivate(),
  125738. this.setMinMaxDistance(0, 1);
  125739. return
  125740. }
  125741. this._depthReducer || (this._depthReducer = new DepthReducer(s),
  125742. this._depthReducer.onAfterReductionPerformed.add(function(c) {
  125743. var d = c.min
  125744. , _ = c.max;
  125745. d >= _ && (d = 0,
  125746. _ = 1),
  125747. (d != o._minDistance || _ != o._maxDistance) && o.setMinMaxDistance(d, _)
  125748. }),
  125749. this._depthReducer.setDepthRenderer(this._depthRenderer)),
  125750. this._depthReducer.activate()
  125751. }
  125752. },
  125753. enumerable: !1,
  125754. configurable: !0
  125755. }),
  125756. Object.defineProperty(e.prototype, "autoCalcDepthBoundsRefreshRate", {
  125757. get: function() {
  125758. var i, o, s;
  125759. return (s = (o = (i = this._depthReducer) === null || i === void 0 ? void 0 : i.depthRenderer) === null || o === void 0 ? void 0 : o.getDepthMap().refreshRate) !== null && s !== void 0 ? s : -1
  125760. },
  125761. set: function(i) {
  125762. var o;
  125763. !((o = this._depthReducer) === null || o === void 0) && o.depthRenderer && (this._depthReducer.depthRenderer.getDepthMap().refreshRate = i)
  125764. },
  125765. enumerable: !1,
  125766. configurable: !0
  125767. }),
  125768. e.prototype.splitFrustum = function() {
  125769. this._breaksAreDirty = !0
  125770. }
  125771. ,
  125772. e.prototype._splitFrustum = function() {
  125773. var i = this._scene.activeCamera;
  125774. if (!!i) {
  125775. for (var o = i.minZ, s = i.maxZ, c = s - o, d = this._minDistance, _ = this._shadowMaxZ < s && this._shadowMaxZ >= o ? Math.min((this._shadowMaxZ - o) / (s - o), this._maxDistance) : this._maxDistance, b = o + d * c, k = o + _ * c, j = k - b, $ = k / b, _e = 0; _e < this._cascades.length; ++_e) {
  125776. var et = (_e + 1) / this._numCascades
  125777. , tt = b * Math.pow($, et)
  125778. , rt = b + j * et
  125779. , it = this._lambda * (tt - rt) + rt;
  125780. this._cascades[_e].prevBreakDistance = _e === 0 ? d : this._cascades[_e - 1].breakDistance,
  125781. this._cascades[_e].breakDistance = (it - o) / c,
  125782. this._viewSpaceFrustumsZ[_e] = it,
  125783. this._frustumLengths[_e] = (this._cascades[_e].breakDistance - this._cascades[_e].prevBreakDistance) * c
  125784. }
  125785. this._breaksAreDirty = !1
  125786. }
  125787. }
  125788. ,
  125789. e.prototype._computeMatrices = function() {
  125790. var i = this._scene
  125791. , o = i.activeCamera;
  125792. if (!!o) {
  125793. Vector3.NormalizeToRef(this._light.getShadowDirection(0), this._lightDirection),
  125794. Math.abs(Vector3.Dot(this._lightDirection, Vector3.Up())) === 1 && (this._lightDirection.z = 1e-13),
  125795. this._cachedDirection.copyFrom(this._lightDirection);
  125796. for (var s = i.getEngine().useReverseDepthBuffer, c = 0; c < this._numCascades; ++c) {
  125797. this._computeFrustumInWorldSpace(c),
  125798. this._computeCascadeFrustum(c),
  125799. this._cascadeMaxExtents[c].subtractToRef(this._cascadeMinExtents[c], tmpv1),
  125800. this._frustumCenter[c].addToRef(this._lightDirection.scale(this._cascadeMinExtents[c].z), this._shadowCameraPos[c]),
  125801. Matrix.LookAtLHToRef(this._shadowCameraPos[c], this._frustumCenter[c], UpDir, this._viewMatrices[c]);
  125802. var d = 0
  125803. , _ = tmpv1.z
  125804. , b = this._shadowCastersBoundingInfo;
  125805. b.update(this._viewMatrices[c]),
  125806. _ = Math.min(_, b.boundingBox.maximumWorld.z),
  125807. !this._depthClamp || this.filter === ShadowGenerator.FILTER_PCSS ? d = Math.min(d, b.boundingBox.minimumWorld.z) : d = Math.max(d, b.boundingBox.minimumWorld.z),
  125808. Matrix.OrthoOffCenterLHToRef(this._cascadeMinExtents[c].x, this._cascadeMaxExtents[c].x, this._cascadeMinExtents[c].y, this._cascadeMaxExtents[c].y, s ? _ : d, s ? d : _, this._projectionMatrices[c], i.getEngine().isNDCHalfZRange),
  125809. this._cascadeMinExtents[c].z = d,
  125810. this._cascadeMaxExtents[c].z = _,
  125811. this._viewMatrices[c].multiplyToRef(this._projectionMatrices[c], this._transformMatrices[c]),
  125812. Vector3.TransformCoordinatesToRef(ZeroVec, this._transformMatrices[c], tmpv1),
  125813. tmpv1.scaleInPlace(this._mapSize / 2),
  125814. tmpv2.copyFromFloats(Math.round(tmpv1.x), Math.round(tmpv1.y), Math.round(tmpv1.z)),
  125815. tmpv2.subtractInPlace(tmpv1).scaleInPlace(2 / this._mapSize),
  125816. Matrix.TranslationToRef(tmpv2.x, tmpv2.y, 0, tmpMatrix),
  125817. this._projectionMatrices[c].multiplyToRef(tmpMatrix, this._projectionMatrices[c]),
  125818. this._viewMatrices[c].multiplyToRef(this._projectionMatrices[c], this._transformMatrices[c]),
  125819. this._transformMatrices[c].copyToArray(this._transformMatricesAsArray, c * 16)
  125820. }
  125821. }
  125822. }
  125823. ,
  125824. e.prototype._computeFrustumInWorldSpace = function(i) {
  125825. if (!!this._scene.activeCamera) {
  125826. var o = this._cascades[i].prevBreakDistance
  125827. , s = this._cascades[i].breakDistance
  125828. , c = this._scene.getEngine().isNDCHalfZRange;
  125829. this._scene.activeCamera.getViewMatrix();
  125830. for (var d = Matrix.Invert(this._scene.activeCamera.getTransformationMatrix()), _ = this._scene.getEngine().useReverseDepthBuffer ? 4 : 0, b = 0; b < e.frustumCornersNDCSpace.length; ++b)
  125831. tmpv1.copyFrom(e.frustumCornersNDCSpace[(b + _) % e.frustumCornersNDCSpace.length]),
  125832. c && tmpv1.z === -1 && (tmpv1.z = 0),
  125833. Vector3.TransformCoordinatesToRef(tmpv1, d, this._frustumCornersWorldSpace[i][b]);
  125834. for (var b = 0; b < e.frustumCornersNDCSpace.length / 2; ++b)
  125835. tmpv1.copyFrom(this._frustumCornersWorldSpace[i][b + 4]).subtractInPlace(this._frustumCornersWorldSpace[i][b]),
  125836. tmpv2.copyFrom(tmpv1).scaleInPlace(o),
  125837. tmpv1.scaleInPlace(s),
  125838. tmpv1.addInPlace(this._frustumCornersWorldSpace[i][b]),
  125839. this._frustumCornersWorldSpace[i][b + 4].copyFrom(tmpv1),
  125840. this._frustumCornersWorldSpace[i][b].addInPlace(tmpv2)
  125841. }
  125842. }
  125843. ,
  125844. e.prototype._computeCascadeFrustum = function(i) {
  125845. this._cascadeMinExtents[i].copyFromFloats(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE),
  125846. this._cascadeMaxExtents[i].copyFromFloats(Number.MIN_VALUE, Number.MIN_VALUE, Number.MIN_VALUE),
  125847. this._frustumCenter[i].copyFromFloats(0, 0, 0);
  125848. var o = this._scene.activeCamera;
  125849. if (!!o) {
  125850. for (var s = 0; s < this._frustumCornersWorldSpace[i].length; ++s)
  125851. this._frustumCenter[i].addInPlace(this._frustumCornersWorldSpace[i][s]);
  125852. if (this._frustumCenter[i].scaleInPlace(1 / this._frustumCornersWorldSpace[i].length),
  125853. this.stabilizeCascades) {
  125854. for (var c = 0, s = 0; s < this._frustumCornersWorldSpace[i].length; ++s) {
  125855. var d = this._frustumCornersWorldSpace[i][s].subtractToRef(this._frustumCenter[i], tmpv1).length();
  125856. c = Math.max(c, d)
  125857. }
  125858. c = Math.ceil(c * 16) / 16,
  125859. this._cascadeMaxExtents[i].copyFromFloats(c, c, c),
  125860. this._cascadeMinExtents[i].copyFromFloats(-c, -c, -c)
  125861. } else {
  125862. var _ = this._frustumCenter[i];
  125863. this._frustumCenter[i].addToRef(this._lightDirection, tmpv1),
  125864. Matrix.LookAtLHToRef(_, tmpv1, UpDir, tmpMatrix);
  125865. for (var s = 0; s < this._frustumCornersWorldSpace[i].length; ++s)
  125866. Vector3.TransformCoordinatesToRef(this._frustumCornersWorldSpace[i][s], tmpMatrix, tmpv1),
  125867. this._cascadeMinExtents[i].minimizeInPlace(tmpv1),
  125868. this._cascadeMaxExtents[i].maximizeInPlace(tmpv1)
  125869. }
  125870. }
  125871. }
  125872. ,
  125873. e.prototype._recreateSceneUBOs = function() {
  125874. if (this._disposeSceneUBOs(),
  125875. this._sceneUBOs)
  125876. for (var i = 0; i < this._numCascades; ++i)
  125877. this._sceneUBOs.push(this._scene.createSceneUniformBuffer('Scene for CSM Shadow Generator (light "' + this._light.name + '" cascade #' + i + ")"))
  125878. }
  125879. ,
  125880. Object.defineProperty(e, "IsSupported", {
  125881. get: function() {
  125882. var i = EngineStore.LastCreatedEngine;
  125883. return i ? i._features.supportCSM : !1
  125884. },
  125885. enumerable: !1,
  125886. configurable: !0
  125887. }),
  125888. e.prototype._initializeGenerator = function() {
  125889. var i, o, s, c, d, _, b, k, j, $, _e, et, tt, rt, it, nt, ot, at, st, ut;
  125890. this.penumbraDarkness = (i = this.penumbraDarkness) !== null && i !== void 0 ? i : 1,
  125891. this._numCascades = (o = this._numCascades) !== null && o !== void 0 ? o : e.DEFAULT_CASCADES_COUNT,
  125892. this.stabilizeCascades = (s = this.stabilizeCascades) !== null && s !== void 0 ? s : !1,
  125893. this._freezeShadowCastersBoundingInfoObservable = (c = this._freezeShadowCastersBoundingInfoObservable) !== null && c !== void 0 ? c : null,
  125894. this.freezeShadowCastersBoundingInfo = (d = this.freezeShadowCastersBoundingInfo) !== null && d !== void 0 ? d : !1,
  125895. this._scbiMin = (_ = this._scbiMin) !== null && _ !== void 0 ? _ : new Vector3(0,0,0),
  125896. this._scbiMax = (b = this._scbiMax) !== null && b !== void 0 ? b : new Vector3(0,0,0),
  125897. this._shadowCastersBoundingInfo = (k = this._shadowCastersBoundingInfo) !== null && k !== void 0 ? k : new BoundingInfo(new Vector3(0,0,0),new Vector3(0,0,0)),
  125898. this._breaksAreDirty = (j = this._breaksAreDirty) !== null && j !== void 0 ? j : !0,
  125899. this._minDistance = ($ = this._minDistance) !== null && $ !== void 0 ? $ : 0,
  125900. this._maxDistance = (_e = this._maxDistance) !== null && _e !== void 0 ? _e : 1,
  125901. this._currentLayer = (et = this._currentLayer) !== null && et !== void 0 ? et : 0,
  125902. this._shadowMaxZ = (it = (tt = this._shadowMaxZ) !== null && tt !== void 0 ? tt : (rt = this._scene.activeCamera) === null || rt === void 0 ? void 0 : rt.maxZ) !== null && it !== void 0 ? it : 1e4,
  125903. this._debug = (nt = this._debug) !== null && nt !== void 0 ? nt : !1,
  125904. this._depthClamp = (ot = this._depthClamp) !== null && ot !== void 0 ? ot : !0,
  125905. this._cascadeBlendPercentage = (at = this._cascadeBlendPercentage) !== null && at !== void 0 ? at : .1,
  125906. this._lambda = (st = this._lambda) !== null && st !== void 0 ? st : .5,
  125907. this._autoCalcDepthBounds = (ut = this._autoCalcDepthBounds) !== null && ut !== void 0 ? ut : !1,
  125908. this._recreateSceneUBOs(),
  125909. a.prototype._initializeGenerator.call(this)
  125910. }
  125911. ,
  125912. e.prototype._createTargetRenderTexture = function() {
  125913. var i = this._scene.getEngine()
  125914. , o = {
  125915. width: this._mapSize,
  125916. height: this._mapSize,
  125917. layers: this.numCascades
  125918. };
  125919. this._shadowMap = new RenderTargetTexture(this._light.name + "_CSMShadowMap",o,this._scene,!1,!0,this._textureType,!1,void 0,!1,!1,void 0),
  125920. this._shadowMap.createDepthStencilTexture(i.useReverseDepthBuffer ? 516 : 513, !0)
  125921. }
  125922. ,
  125923. e.prototype._initializeShadowMap = function() {
  125924. var i = this;
  125925. if (a.prototype._initializeShadowMap.call(this),
  125926. this._shadowMap !== null) {
  125927. this._transformMatricesAsArray = new Float32Array(this._numCascades * 16),
  125928. this._viewSpaceFrustumsZ = new Array(this._numCascades),
  125929. this._frustumLengths = new Array(this._numCascades),
  125930. this._lightSizeUVCorrection = new Array(this._numCascades * 2),
  125931. this._depthCorrection = new Array(this._numCascades),
  125932. this._cascades = [],
  125933. this._viewMatrices = [],
  125934. this._projectionMatrices = [],
  125935. this._transformMatrices = [],
  125936. this._cascadeMinExtents = [],
  125937. this._cascadeMaxExtents = [],
  125938. this._frustumCenter = [],
  125939. this._shadowCameraPos = [],
  125940. this._frustumCornersWorldSpace = [];
  125941. for (var o = 0; o < this._numCascades; ++o) {
  125942. this._cascades[o] = {
  125943. prevBreakDistance: 0,
  125944. breakDistance: 0
  125945. },
  125946. this._viewMatrices[o] = Matrix.Zero(),
  125947. this._projectionMatrices[o] = Matrix.Zero(),
  125948. this._transformMatrices[o] = Matrix.Zero(),
  125949. this._cascadeMinExtents[o] = new Vector3,
  125950. this._cascadeMaxExtents[o] = new Vector3,
  125951. this._frustumCenter[o] = new Vector3,
  125952. this._shadowCameraPos[o] = new Vector3,
  125953. this._frustumCornersWorldSpace[o] = new Array(e.frustumCornersNDCSpace.length);
  125954. for (var s = 0; s < e.frustumCornersNDCSpace.length; ++s)
  125955. this._frustumCornersWorldSpace[o][s] = new Vector3
  125956. }
  125957. var c = this._scene.getEngine();
  125958. this._shadowMap.onBeforeBindObservable.clear(),
  125959. this._shadowMap.onBeforeRenderObservable.clear(),
  125960. this._shadowMap.onBeforeRenderObservable.add(function(d) {
  125961. i._sceneUBOs && i._scene.setSceneUniformBuffer(i._sceneUBOs[d]),
  125962. i._currentLayer = d,
  125963. i._filter === ShadowGenerator.FILTER_PCF && c.setColorWrite(!1),
  125964. i._scene.setTransformMatrix(i.getCascadeViewMatrix(d), i.getCascadeProjectionMatrix(d)),
  125965. i._useUBO && (i._scene.getSceneUniformBuffer().unbindEffect(),
  125966. i._scene.finalizeSceneUbo())
  125967. }),
  125968. this._shadowMap.onBeforeBindObservable.add(function() {
  125969. var d;
  125970. i._currentSceneUBO = i._scene.getSceneUniformBuffer(),
  125971. (d = c._debugPushGroup) === null || d === void 0 || d.call(c, "cascaded shadow map generation for pass id " + c.currentRenderPassId, 1),
  125972. i._breaksAreDirty && i._splitFrustum(),
  125973. i._computeMatrices()
  125974. }),
  125975. this._splitFrustum()
  125976. }
  125977. }
  125978. ,
  125979. e.prototype._bindCustomEffectForRenderSubMeshForShadowMap = function(i, o, s) {
  125980. o.setMatrix("viewProjection", this.getCascadeTransformMatrix(this._currentLayer))
  125981. }
  125982. ,
  125983. e.prototype._isReadyCustomDefines = function(i, o, s) {
  125984. i.push("#define SM_DEPTHCLAMP " + (this._depthClamp && this._filter !== ShadowGenerator.FILTER_PCSS ? "1" : "0"))
  125985. }
  125986. ,
  125987. e.prototype.prepareDefines = function(i, o) {
  125988. a.prototype.prepareDefines.call(this, i, o);
  125989. var s = this._scene
  125990. , c = this._light;
  125991. if (!(!s.shadowsEnabled || !c.shadowEnabled)) {
  125992. i["SHADOWCSM" + o] = !0,
  125993. i["SHADOWCSMDEBUG" + o] = this.debug,
  125994. i["SHADOWCSMNUM_CASCADES" + o] = this.numCascades,
  125995. i["SHADOWCSM_RIGHTHANDED" + o] = s.useRightHandedSystem;
  125996. var d = s.activeCamera;
  125997. d && this._shadowMaxZ < d.maxZ && (i["SHADOWCSMUSESHADOWMAXZ" + o] = !0),
  125998. this.cascadeBlendPercentage === 0 && (i["SHADOWCSMNOBLEND" + o] = !0)
  125999. }
  126000. }
  126001. ,
  126002. e.prototype.bindShadowLight = function(i, o) {
  126003. var s = this._light
  126004. , c = this._scene;
  126005. if (!(!c.shadowsEnabled || !s.shadowEnabled)) {
  126006. var d = c.activeCamera;
  126007. if (!!d) {
  126008. var _ = this.getShadowMap();
  126009. if (!!_) {
  126010. var b = _.getSize().width;
  126011. if (o.setMatrices("lightMatrix" + i, this._transformMatricesAsArray),
  126012. o.setArray("viewFrustumZ" + i, this._viewSpaceFrustumsZ),
  126013. o.setFloat("cascadeBlendFactor" + i, this.cascadeBlendPercentage === 0 ? 1e4 : 1 / this.cascadeBlendPercentage),
  126014. o.setArray("frustumLengths" + i, this._frustumLengths),
  126015. this._filter === ShadowGenerator.FILTER_PCF)
  126016. o.setDepthStencilTexture("shadowSampler" + i, _),
  126017. s._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), b, 1 / b, this.frustumEdgeFalloff, i);
  126018. else if (this._filter === ShadowGenerator.FILTER_PCSS) {
  126019. for (var k = 0; k < this._numCascades; ++k)
  126020. this._lightSizeUVCorrection[k * 2 + 0] = k === 0 ? 1 : (this._cascadeMaxExtents[0].x - this._cascadeMinExtents[0].x) / (this._cascadeMaxExtents[k].x - this._cascadeMinExtents[k].x),
  126021. this._lightSizeUVCorrection[k * 2 + 1] = k === 0 ? 1 : (this._cascadeMaxExtents[0].y - this._cascadeMinExtents[0].y) / (this._cascadeMaxExtents[k].y - this._cascadeMinExtents[k].y),
  126022. this._depthCorrection[k] = k === 0 ? 1 : (this._cascadeMaxExtents[k].z - this._cascadeMinExtents[k].z) / (this._cascadeMaxExtents[0].z - this._cascadeMinExtents[0].z);
  126023. o.setDepthStencilTexture("shadowSampler" + i, _),
  126024. o.setTexture("depthSampler" + i, _),
  126025. o.setArray2("lightSizeUVCorrection" + i, this._lightSizeUVCorrection),
  126026. o.setArray("depthCorrection" + i, this._depthCorrection),
  126027. o.setFloat("penumbraDarkness" + i, this.penumbraDarkness),
  126028. s._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), 1 / b, this._contactHardeningLightSizeUVRatio * b, this.frustumEdgeFalloff, i)
  126029. } else
  126030. o.setTexture("shadowSampler" + i, _),
  126031. s._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), b, 1 / b, this.frustumEdgeFalloff, i);
  126032. s._uniformBuffer.updateFloat2("depthValues", this.getLight().getDepthMinZ(d), this.getLight().getDepthMinZ(d) + this.getLight().getDepthMaxZ(d), i)
  126033. }
  126034. }
  126035. }
  126036. }
  126037. ,
  126038. e.prototype.getTransformMatrix = function() {
  126039. return this.getCascadeTransformMatrix(0)
  126040. }
  126041. ,
  126042. e.prototype.dispose = function() {
  126043. a.prototype.dispose.call(this),
  126044. this._freezeShadowCastersBoundingInfoObservable && (this._scene.onBeforeRenderObservable.remove(this._freezeShadowCastersBoundingInfoObservable),
  126045. this._freezeShadowCastersBoundingInfoObservable = null),
  126046. this._depthReducer && (this._depthReducer.dispose(),
  126047. this._depthReducer = null)
  126048. }
  126049. ,
  126050. e.prototype.serialize = function() {
  126051. var i = a.prototype.serialize.call(this)
  126052. , o = this.getShadowMap();
  126053. if (!o)
  126054. return i;
  126055. if (i.numCascades = this._numCascades,
  126056. i.debug = this._debug,
  126057. i.stabilizeCascades = this.stabilizeCascades,
  126058. i.lambda = this._lambda,
  126059. i.cascadeBlendPercentage = this.cascadeBlendPercentage,
  126060. i.depthClamp = this._depthClamp,
  126061. i.autoCalcDepthBounds = this.autoCalcDepthBounds,
  126062. i.shadowMaxZ = this._shadowMaxZ,
  126063. i.penumbraDarkness = this.penumbraDarkness,
  126064. i.freezeShadowCastersBoundingInfo = this._freezeShadowCastersBoundingInfo,
  126065. i.minDistance = this.minDistance,
  126066. i.maxDistance = this.maxDistance,
  126067. i.renderList = [],
  126068. o.renderList)
  126069. for (var s = 0; s < o.renderList.length; s++) {
  126070. var c = o.renderList[s];
  126071. i.renderList.push(c.id)
  126072. }
  126073. return i
  126074. }
  126075. ,
  126076. e.Parse = function(i, o) {
  126077. var s = ShadowGenerator.Parse(i, o, function(c, d) {
  126078. return new e(c,d)
  126079. });
  126080. return i.numCascades !== void 0 && (s.numCascades = i.numCascades),
  126081. i.debug !== void 0 && (s.debug = i.debug),
  126082. i.stabilizeCascades !== void 0 && (s.stabilizeCascades = i.stabilizeCascades),
  126083. i.lambda !== void 0 && (s.lambda = i.lambda),
  126084. i.cascadeBlendPercentage !== void 0 && (s.cascadeBlendPercentage = i.cascadeBlendPercentage),
  126085. i.depthClamp !== void 0 && (s.depthClamp = i.depthClamp),
  126086. i.autoCalcDepthBounds !== void 0 && (s.autoCalcDepthBounds = i.autoCalcDepthBounds),
  126087. i.shadowMaxZ !== void 0 && (s.shadowMaxZ = i.shadowMaxZ),
  126088. i.penumbraDarkness !== void 0 && (s.penumbraDarkness = i.penumbraDarkness),
  126089. i.freezeShadowCastersBoundingInfo !== void 0 && (s.freezeShadowCastersBoundingInfo = i.freezeShadowCastersBoundingInfo),
  126090. i.minDistance !== void 0 && i.maxDistance !== void 0 && s.setMinMaxDistance(i.minDistance, i.maxDistance),
  126091. s
  126092. }
  126093. ,
  126094. e.frustumCornersNDCSpace = [new Vector3(-1,1,-1), new Vector3(1,1,-1), new Vector3(1,-1,-1), new Vector3(-1,-1,-1), new Vector3(-1,1,1), new Vector3(1,1,1), new Vector3(1,-1,1), new Vector3(-1,-1,1)],
  126095. e.CLASSNAME = "CascadedShadowGenerator",
  126096. e.DEFAULT_CASCADES_COUNT = 4,
  126097. e.MIN_CASCADES_COUNT = 2,
  126098. e.MAX_CASCADES_COUNT = 4,
  126099. e._SceneComponentInitialization = function(i) {
  126100. throw _WarnImport("ShadowGeneratorSceneComponent")
  126101. }
  126102. ,
  126103. e
  126104. }(ShadowGenerator);
  126105. AbstractScene.AddParser(SceneComponentConstants.NAME_SHADOWGENERATOR, function(a, e) {
  126106. if (a.shadowGenerators !== void 0 && a.shadowGenerators !== null)
  126107. for (var i = 0, o = a.shadowGenerators.length; i < o; i++) {
  126108. var s = a.shadowGenerators[i];
  126109. s.className === CascadedShadowGenerator.CLASSNAME ? CascadedShadowGenerator.Parse(s, e) : ShadowGenerator.Parse(s, e)
  126110. }
  126111. });
  126112. var ShadowGeneratorSceneComponent = function() {
  126113. function a(e) {
  126114. this.name = SceneComponentConstants.NAME_SHADOWGENERATOR,
  126115. this.scene = e
  126116. }
  126117. return a.prototype.register = function() {
  126118. this.scene._gatherRenderTargetsStage.registerStep(SceneComponentConstants.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR, this, this._gatherRenderTargets)
  126119. }
  126120. ,
  126121. a.prototype.rebuild = function() {}
  126122. ,
  126123. a.prototype.serialize = function(e) {
  126124. e.shadowGenerators = [];
  126125. for (var i = this.scene.lights, o = 0, s = i; o < s.length; o++) {
  126126. var c = s[o]
  126127. , d = c.getShadowGenerator();
  126128. d && e.shadowGenerators.push(d.serialize())
  126129. }
  126130. }
  126131. ,
  126132. a.prototype.addFromContainer = function(e) {}
  126133. ,
  126134. a.prototype.removeFromContainer = function(e, i) {}
  126135. ,
  126136. a.prototype.dispose = function() {}
  126137. ,
  126138. a.prototype._gatherRenderTargets = function(e) {
  126139. var i = this.scene;
  126140. if (this.scene.shadowsEnabled)
  126141. for (var o = 0; o < i.lights.length; o++) {
  126142. var s = i.lights[o]
  126143. , c = s.getShadowGenerator();
  126144. if (s.isEnabled() && s.shadowEnabled && c) {
  126145. var d = c.getShadowMap();
  126146. i.textures.indexOf(d) !== -1 && e.push(d)
  126147. }
  126148. }
  126149. }
  126150. ,
  126151. a
  126152. }();
  126153. ShadowGenerator._SceneComponentInitialization = function(a) {
  126154. var e = a._getComponent(SceneComponentConstants.NAME_SHADOWGENERATOR);
  126155. e || (e = new ShadowGeneratorSceneComponent(a),
  126156. a._addComponent(e))
  126157. }
  126158. ;
  126159. var DDS_MAGIC = 542327876
  126160. , DDSD_MIPMAPCOUNT = 131072
  126161. , DDSCAPS2_CUBEMAP = 512
  126162. , DDPF_FOURCC = 4
  126163. , DDPF_RGB = 64
  126164. , DDPF_LUMINANCE = 131072;
  126165. function FourCCToInt32(a) {
  126166. return a.charCodeAt(0) + (a.charCodeAt(1) << 8) + (a.charCodeAt(2) << 16) + (a.charCodeAt(3) << 24)
  126167. }
  126168. function Int32ToFourCC(a) {
  126169. return String.fromCharCode(a & 255, a >> 8 & 255, a >> 16 & 255, a >> 24 & 255)
  126170. }
  126171. var FOURCC_DXT1 = FourCCToInt32("DXT1")
  126172. , FOURCC_DXT3 = FourCCToInt32("DXT3")
  126173. , FOURCC_DXT5 = FourCCToInt32("DXT5")
  126174. , FOURCC_DX10 = FourCCToInt32("DX10")
  126175. , FOURCC_D3DFMT_R16G16B16A16F = 113
  126176. , FOURCC_D3DFMT_R32G32B32A32F = 116
  126177. , DXGI_FORMAT_R32G32B32A32_FLOAT = 2
  126178. , DXGI_FORMAT_R16G16B16A16_FLOAT = 10
  126179. , DXGI_FORMAT_B8G8R8X8_UNORM = 88
  126180. , headerLengthInt = 31
  126181. , off_magic = 0
  126182. , off_size = 1
  126183. , off_flags = 2
  126184. , off_height = 3
  126185. , off_width = 4
  126186. , off_mipmapCount = 7
  126187. , off_pfFlags = 20
  126188. , off_pfFourCC = 21
  126189. , off_RGBbpp = 22
  126190. , off_RMask = 23
  126191. , off_GMask = 24
  126192. , off_BMask = 25
  126193. , off_AMask = 26
  126194. , off_caps2 = 28
  126195. , off_dxgiFormat = 32
  126196. , DDSTools = function() {
  126197. function a() {}
  126198. return a.GetDDSInfo = function(e) {
  126199. var i = new Int32Array(e.buffer,e.byteOffset,headerLengthInt)
  126200. , o = new Int32Array(e.buffer,e.byteOffset,headerLengthInt + 4)
  126201. , s = 1;
  126202. i[off_flags] & DDSD_MIPMAPCOUNT && (s = Math.max(1, i[off_mipmapCount]));
  126203. var c = i[off_pfFourCC]
  126204. , d = c === FOURCC_DX10 ? o[off_dxgiFormat] : 0
  126205. , _ = 0;
  126206. switch (c) {
  126207. case FOURCC_D3DFMT_R16G16B16A16F:
  126208. _ = 2;
  126209. break;
  126210. case FOURCC_D3DFMT_R32G32B32A32F:
  126211. _ = 1;
  126212. break;
  126213. case FOURCC_DX10:
  126214. if (d === DXGI_FORMAT_R16G16B16A16_FLOAT) {
  126215. _ = 2;
  126216. break
  126217. }
  126218. if (d === DXGI_FORMAT_R32G32B32A32_FLOAT) {
  126219. _ = 1;
  126220. break
  126221. }
  126222. }
  126223. return {
  126224. width: i[off_width],
  126225. height: i[off_height],
  126226. mipmapCount: s,
  126227. isFourCC: (i[off_pfFlags] & DDPF_FOURCC) === DDPF_FOURCC,
  126228. isRGB: (i[off_pfFlags] & DDPF_RGB) === DDPF_RGB,
  126229. isLuminance: (i[off_pfFlags] & DDPF_LUMINANCE) === DDPF_LUMINANCE,
  126230. isCube: (i[off_caps2] & DDSCAPS2_CUBEMAP) === DDSCAPS2_CUBEMAP,
  126231. isCompressed: c === FOURCC_DXT1 || c === FOURCC_DXT3 || c === FOURCC_DXT5,
  126232. dxgiFormat: d,
  126233. textureType: _
  126234. }
  126235. }
  126236. ,
  126237. a._GetHalfFloatAsFloatRGBAArrayBuffer = function(e, i, o, s, c, d) {
  126238. for (var _ = new Float32Array(s), b = new Uint16Array(c,o), k = 0, j = 0; j < i; j++)
  126239. for (var $ = 0; $ < e; $++) {
  126240. var _e = ($ + j * e) * 4;
  126241. _[k] = FromHalfFloat(b[_e]),
  126242. _[k + 1] = FromHalfFloat(b[_e + 1]),
  126243. _[k + 2] = FromHalfFloat(b[_e + 2]),
  126244. a.StoreLODInAlphaChannel ? _[k + 3] = d : _[k + 3] = FromHalfFloat(b[_e + 3]),
  126245. k += 4
  126246. }
  126247. return _
  126248. }
  126249. ,
  126250. a._GetHalfFloatRGBAArrayBuffer = function(e, i, o, s, c, d) {
  126251. if (a.StoreLODInAlphaChannel) {
  126252. for (var _ = new Uint16Array(s), b = new Uint16Array(c,o), k = 0, j = 0; j < i; j++)
  126253. for (var $ = 0; $ < e; $++) {
  126254. var _e = ($ + j * e) * 4;
  126255. _[k] = b[_e],
  126256. _[k + 1] = b[_e + 1],
  126257. _[k + 2] = b[_e + 2],
  126258. _[k + 3] = ToHalfFloat(d),
  126259. k += 4
  126260. }
  126261. return _
  126262. }
  126263. return new Uint16Array(c,o,s)
  126264. }
  126265. ,
  126266. a._GetFloatRGBAArrayBuffer = function(e, i, o, s, c, d) {
  126267. if (a.StoreLODInAlphaChannel) {
  126268. for (var _ = new Float32Array(s), b = new Float32Array(c,o), k = 0, j = 0; j < i; j++)
  126269. for (var $ = 0; $ < e; $++) {
  126270. var _e = ($ + j * e) * 4;
  126271. _[k] = b[_e],
  126272. _[k + 1] = b[_e + 1],
  126273. _[k + 2] = b[_e + 2],
  126274. _[k + 3] = d,
  126275. k += 4
  126276. }
  126277. return _
  126278. }
  126279. return new Float32Array(c,o,s)
  126280. }
  126281. ,
  126282. a._GetFloatAsHalfFloatRGBAArrayBuffer = function(e, i, o, s, c, d) {
  126283. for (var _ = new Uint16Array(s), b = new Float32Array(c,o), k = 0, j = 0; j < i; j++)
  126284. for (var $ = 0; $ < e; $++)
  126285. _[k] = ToHalfFloat(b[k]),
  126286. _[k + 1] = ToHalfFloat(b[k + 1]),
  126287. _[k + 2] = ToHalfFloat(b[k + 2]),
  126288. a.StoreLODInAlphaChannel ? _[k + 3] = ToHalfFloat(d) : _[k + 3] = ToHalfFloat(b[k + 3]),
  126289. k += 4;
  126290. return _
  126291. }
  126292. ,
  126293. a._GetFloatAsUIntRGBAArrayBuffer = function(e, i, o, s, c, d) {
  126294. for (var _ = new Uint8Array(s), b = new Float32Array(c,o), k = 0, j = 0; j < i; j++)
  126295. for (var $ = 0; $ < e; $++) {
  126296. var _e = ($ + j * e) * 4;
  126297. _[k] = Scalar.Clamp(b[_e]) * 255,
  126298. _[k + 1] = Scalar.Clamp(b[_e + 1]) * 255,
  126299. _[k + 2] = Scalar.Clamp(b[_e + 2]) * 255,
  126300. a.StoreLODInAlphaChannel ? _[k + 3] = d : _[k + 3] = Scalar.Clamp(b[_e + 3]) * 255,
  126301. k += 4
  126302. }
  126303. return _
  126304. }
  126305. ,
  126306. a._GetHalfFloatAsUIntRGBAArrayBuffer = function(e, i, o, s, c, d) {
  126307. for (var _ = new Uint8Array(s), b = new Uint16Array(c,o), k = 0, j = 0; j < i; j++)
  126308. for (var $ = 0; $ < e; $++) {
  126309. var _e = ($ + j * e) * 4;
  126310. _[k] = Scalar.Clamp(FromHalfFloat(b[_e])) * 255,
  126311. _[k + 1] = Scalar.Clamp(FromHalfFloat(b[_e + 1])) * 255,
  126312. _[k + 2] = Scalar.Clamp(FromHalfFloat(b[_e + 2])) * 255,
  126313. a.StoreLODInAlphaChannel ? _[k + 3] = d : _[k + 3] = Scalar.Clamp(FromHalfFloat(b[_e + 3])) * 255,
  126314. k += 4
  126315. }
  126316. return _
  126317. }
  126318. ,
  126319. a._GetRGBAArrayBuffer = function(e, i, o, s, c, d, _, b, k) {
  126320. for (var j = new Uint8Array(s), $ = new Uint8Array(c,o), _e = 0, et = 0; et < i; et++)
  126321. for (var tt = 0; tt < e; tt++) {
  126322. var rt = (tt + et * e) * 4;
  126323. j[_e] = $[rt + d],
  126324. j[_e + 1] = $[rt + _],
  126325. j[_e + 2] = $[rt + b],
  126326. j[_e + 3] = $[rt + k],
  126327. _e += 4
  126328. }
  126329. return j
  126330. }
  126331. ,
  126332. a._ExtractLongWordOrder = function(e) {
  126333. return e === 0 || e === 255 || e === -16777216 ? 0 : 1 + a._ExtractLongWordOrder(e >> 8)
  126334. }
  126335. ,
  126336. a._GetRGBArrayBuffer = function(e, i, o, s, c, d, _, b) {
  126337. for (var k = new Uint8Array(s), j = new Uint8Array(c,o), $ = 0, _e = 0; _e < i; _e++)
  126338. for (var et = 0; et < e; et++) {
  126339. var tt = (et + _e * e) * 3;
  126340. k[$] = j[tt + d],
  126341. k[$ + 1] = j[tt + _],
  126342. k[$ + 2] = j[tt + b],
  126343. $ += 3
  126344. }
  126345. return k
  126346. }
  126347. ,
  126348. a._GetLuminanceArrayBuffer = function(e, i, o, s, c) {
  126349. for (var d = new Uint8Array(s), _ = new Uint8Array(c,o), b = 0, k = 0; k < i; k++)
  126350. for (var j = 0; j < e; j++) {
  126351. var $ = j + k * e;
  126352. d[b] = _[$],
  126353. b++
  126354. }
  126355. return d
  126356. }
  126357. ,
  126358. a.UploadDDSLevels = function(e, i, o, s, c, d, _, b, k) {
  126359. _ === void 0 && (_ = -1),
  126360. k === void 0 && (k = !0);
  126361. var j = null;
  126362. s.sphericalPolynomial && (j = new Array);
  126363. var $ = !!e.getCaps().s3tc;
  126364. i.generateMipMaps = c;
  126365. var _e = new Int32Array(o.buffer,o.byteOffset,headerLengthInt), et, tt, rt, it = 0, nt, ot, at, st, ut = 0, ct = 1;
  126366. if (_e[off_magic] !== DDS_MAGIC) {
  126367. Logger$2.Error("Invalid magic number in DDS header");
  126368. return
  126369. }
  126370. if (!s.isFourCC && !s.isRGB && !s.isLuminance) {
  126371. Logger$2.Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");
  126372. return
  126373. }
  126374. if (s.isCompressed && !$) {
  126375. Logger$2.Error("Compressed textures are not supported on this platform.");
  126376. return
  126377. }
  126378. var lt = _e[off_RGBbpp];
  126379. nt = _e[off_size] + 4;
  126380. var ft = !1;
  126381. if (s.isFourCC)
  126382. switch (et = _e[off_pfFourCC],
  126383. et) {
  126384. case FOURCC_DXT1:
  126385. ct = 8,
  126386. ut = 33777;
  126387. break;
  126388. case FOURCC_DXT3:
  126389. ct = 16,
  126390. ut = 33778;
  126391. break;
  126392. case FOURCC_DXT5:
  126393. ct = 16,
  126394. ut = 33779;
  126395. break;
  126396. case FOURCC_D3DFMT_R16G16B16A16F:
  126397. ft = !0;
  126398. break;
  126399. case FOURCC_D3DFMT_R32G32B32A32F:
  126400. ft = !0;
  126401. break;
  126402. case FOURCC_DX10:
  126403. nt += 5 * 4;
  126404. var ht = !1;
  126405. switch (s.dxgiFormat) {
  126406. case DXGI_FORMAT_R16G16B16A16_FLOAT:
  126407. case DXGI_FORMAT_R32G32B32A32_FLOAT:
  126408. ft = !0,
  126409. ht = !0;
  126410. break;
  126411. case DXGI_FORMAT_B8G8R8X8_UNORM:
  126412. s.isRGB = !0,
  126413. s.isFourCC = !1,
  126414. lt = 32,
  126415. ht = !0;
  126416. break
  126417. }
  126418. if (ht)
  126419. break;
  126420. default:
  126421. console.error("Unsupported FourCC code:", Int32ToFourCC(et));
  126422. return
  126423. }
  126424. var pt = a._ExtractLongWordOrder(_e[off_RMask])
  126425. , dt = a._ExtractLongWordOrder(_e[off_GMask])
  126426. , _t = a._ExtractLongWordOrder(_e[off_BMask])
  126427. , mt = a._ExtractLongWordOrder(_e[off_AMask]);
  126428. ft && (ut = e._getRGBABufferInternalSizedFormat(s.textureType)),
  126429. at = 1,
  126430. _e[off_flags] & DDSD_MIPMAPCOUNT && c !== !1 && (at = Math.max(1, _e[off_mipmapCount]));
  126431. for (var vt = b || 0, yt = e.getCaps(), Et = vt; Et < d; Et++) {
  126432. for (tt = _e[off_width],
  126433. rt = _e[off_height],
  126434. st = 0; st < at; ++st) {
  126435. if (_ === -1 || _ === st) {
  126436. var At = _ === -1 ? st : 0;
  126437. if (!s.isCompressed && s.isFourCC) {
  126438. i.format = 5,
  126439. it = tt * rt * 4;
  126440. var gt = null;
  126441. if (e._badOS || e._badDesktopOS || !yt.textureHalfFloat && !yt.textureFloat)
  126442. lt === 128 ? (gt = a._GetFloatAsUIntRGBAArrayBuffer(tt, rt, o.byteOffset + nt, it, o.buffer, At),
  126443. j && At == 0 && j.push(a._GetFloatRGBAArrayBuffer(tt, rt, o.byteOffset + nt, it, o.buffer, At))) : lt === 64 && (gt = a._GetHalfFloatAsUIntRGBAArrayBuffer(tt, rt, o.byteOffset + nt, it, o.buffer, At),
  126444. j && At == 0 && j.push(a._GetHalfFloatAsFloatRGBAArrayBuffer(tt, rt, o.byteOffset + nt, it, o.buffer, At))),
  126445. i.type = 0;
  126446. else {
  126447. var St = yt.textureFloat && (k && yt.textureFloatLinearFiltering || !k)
  126448. , xt = yt.textureHalfFloat && (k && yt.textureHalfFloatLinearFiltering || !k)
  126449. , bt = (lt === 128 || lt === 64 && !xt) && St ? 1 : (lt === 64 || lt === 128 && !St) && xt ? 2 : 0
  126450. , Rt = void 0
  126451. , Mt = null;
  126452. switch (lt) {
  126453. case 128:
  126454. {
  126455. switch (bt) {
  126456. case 1:
  126457. Rt = a._GetFloatRGBAArrayBuffer,
  126458. Mt = null;
  126459. break;
  126460. case 2:
  126461. Rt = a._GetFloatAsHalfFloatRGBAArrayBuffer,
  126462. Mt = a._GetFloatRGBAArrayBuffer;
  126463. break;
  126464. case 0:
  126465. Rt = a._GetFloatAsUIntRGBAArrayBuffer,
  126466. Mt = a._GetFloatRGBAArrayBuffer;
  126467. break
  126468. }
  126469. break
  126470. }
  126471. default:
  126472. {
  126473. switch (bt) {
  126474. case 1:
  126475. Rt = a._GetHalfFloatAsFloatRGBAArrayBuffer,
  126476. Mt = null;
  126477. break;
  126478. case 2:
  126479. Rt = a._GetHalfFloatRGBAArrayBuffer,
  126480. Mt = a._GetHalfFloatAsFloatRGBAArrayBuffer;
  126481. break;
  126482. case 0:
  126483. Rt = a._GetHalfFloatAsUIntRGBAArrayBuffer,
  126484. Mt = a._GetHalfFloatAsFloatRGBAArrayBuffer;
  126485. break
  126486. }
  126487. break
  126488. }
  126489. }
  126490. i.type = bt,
  126491. gt = Rt(tt, rt, o.byteOffset + nt, it, o.buffer, At),
  126492. j && At == 0 && j.push(Mt ? Mt(tt, rt, o.byteOffset + nt, it, o.buffer, At) : gt)
  126493. }
  126494. gt && e._uploadDataToTextureDirectly(i, gt, Et, At)
  126495. } else if (s.isRGB)
  126496. i.type = 0,
  126497. lt === 24 ? (i.format = 4,
  126498. it = tt * rt * 3,
  126499. ot = a._GetRGBArrayBuffer(tt, rt, o.byteOffset + nt, it, o.buffer, pt, dt, _t),
  126500. e._uploadDataToTextureDirectly(i, ot, Et, At)) : (i.format = 5,
  126501. it = tt * rt * 4,
  126502. ot = a._GetRGBAArrayBuffer(tt, rt, o.byteOffset + nt, it, o.buffer, pt, dt, _t, mt),
  126503. e._uploadDataToTextureDirectly(i, ot, Et, At));
  126504. else if (s.isLuminance) {
  126505. var Pt = e._getUnpackAlignement()
  126506. , It = tt
  126507. , Dt = Math.floor((tt + Pt - 1) / Pt) * Pt;
  126508. it = Dt * (rt - 1) + It,
  126509. ot = a._GetLuminanceArrayBuffer(tt, rt, o.byteOffset + nt, it, o.buffer),
  126510. i.format = 1,
  126511. i.type = 0,
  126512. e._uploadDataToTextureDirectly(i, ot, Et, At)
  126513. } else
  126514. it = Math.max(4, tt) / 4 * Math.max(4, rt) / 4 * ct,
  126515. ot = new Uint8Array(o.buffer,o.byteOffset + nt,it),
  126516. i.type = 0,
  126517. e._uploadCompressedDataToTextureDirectly(i, ut, tt, rt, ot, Et, At)
  126518. }
  126519. nt += lt ? tt * rt * (lt / 8) : it,
  126520. tt *= .5,
  126521. rt *= .5,
  126522. tt = Math.max(1, tt),
  126523. rt = Math.max(1, rt)
  126524. }
  126525. if (b !== void 0)
  126526. break
  126527. }
  126528. j && j.length > 0 ? s.sphericalPolynomial = CubeMapToSphericalPolynomialTools.ConvertCubeMapToSphericalPolynomial({
  126529. size: _e[off_width],
  126530. right: j[0],
  126531. left: j[1],
  126532. up: j[2],
  126533. down: j[3],
  126534. front: j[4],
  126535. back: j[5],
  126536. format: 5,
  126537. type: 1,
  126538. gammaSpace: !1
  126539. }) : s.sphericalPolynomial = void 0
  126540. }
  126541. ,
  126542. a.StoreLODInAlphaChannel = !1,
  126543. a
  126544. }();
  126545. ThinEngine.prototype.createPrefilteredCubeTexture = function(a, e, i, o, s, c, d, _, b) {
  126546. var k = this;
  126547. s === void 0 && (s = null),
  126548. c === void 0 && (c = null),
  126549. _ === void 0 && (_ = null),
  126550. b === void 0 && (b = !0);
  126551. var j = function($) {
  126552. if (!$) {
  126553. s && s(null);
  126554. return
  126555. }
  126556. var _e = $.texture;
  126557. if (b ? $.info.sphericalPolynomial && (_e._sphericalPolynomial = $.info.sphericalPolynomial) : _e._sphericalPolynomial = new SphericalPolynomial,
  126558. _e._source = InternalTextureSource.CubePrefiltered,
  126559. k.getCaps().textureLOD) {
  126560. s && s(_e);
  126561. return
  126562. }
  126563. var et = 3
  126564. , tt = k._gl
  126565. , rt = $.width;
  126566. if (!!rt) {
  126567. for (var it = [], nt = 0; nt < et; nt++) {
  126568. var ot = nt / (et - 1)
  126569. , at = 1 - ot
  126570. , st = o
  126571. , ut = Scalar.Log2(rt) * i + o
  126572. , ct = st + (ut - st) * at
  126573. , lt = Math.round(Math.min(Math.max(ct, 0), ut))
  126574. , ft = new InternalTexture(k,InternalTextureSource.Temp);
  126575. if (ft.type = _e.type,
  126576. ft.format = _e.format,
  126577. ft.width = Math.pow(2, Math.max(Scalar.Log2(rt) - lt, 0)),
  126578. ft.height = ft.width,
  126579. ft.isCube = !0,
  126580. ft._cachedWrapU = 0,
  126581. ft._cachedWrapV = 0,
  126582. k._bindTextureDirectly(tt.TEXTURE_CUBE_MAP, ft, !0),
  126583. ft.samplingMode = 2,
  126584. tt.texParameteri(tt.TEXTURE_CUBE_MAP, tt.TEXTURE_MAG_FILTER, tt.LINEAR),
  126585. tt.texParameteri(tt.TEXTURE_CUBE_MAP, tt.TEXTURE_MIN_FILTER, tt.LINEAR),
  126586. tt.texParameteri(tt.TEXTURE_CUBE_MAP, tt.TEXTURE_WRAP_S, tt.CLAMP_TO_EDGE),
  126587. tt.texParameteri(tt.TEXTURE_CUBE_MAP, tt.TEXTURE_WRAP_T, tt.CLAMP_TO_EDGE),
  126588. $.isDDS) {
  126589. var ht = $.info
  126590. , pt = $.data;
  126591. k._unpackFlipY(ht.isCompressed),
  126592. DDSTools.UploadDDSLevels(k, ft, pt, ht, !0, 6, lt)
  126593. } else
  126594. Logger$2.Warn("DDS is the only prefiltered cube map supported so far.");
  126595. k._bindTextureDirectly(tt.TEXTURE_CUBE_MAP, null);
  126596. var dt = new BaseTexture(e);
  126597. dt.isCube = !0,
  126598. dt._texture = ft,
  126599. ft.isReady = !0,
  126600. it.push(dt)
  126601. }
  126602. _e._lodTextureHigh = it[2],
  126603. _e._lodTextureMid = it[1],
  126604. _e._lodTextureLow = it[0],
  126605. s && s(_e)
  126606. }
  126607. };
  126608. return this.createCubeTexture(a, e, null, !1, j, c, d, _, b, i, o)
  126609. }
  126610. ;
  126611. var _DDSTextureLoader = function() {
  126612. function a() {
  126613. this.supportCascades = !0
  126614. }
  126615. return a.prototype.canLoad = function(e) {
  126616. return EndsWith(e, ".dds")
  126617. }
  126618. ,
  126619. a.prototype.loadCubeData = function(e, i, o, s, c) {
  126620. var d = i.getEngine(), _, b = !1;
  126621. if (Array.isArray(e))
  126622. for (var k = 0; k < e.length; k++) {
  126623. var j = e[k];
  126624. _ = DDSTools.GetDDSInfo(j),
  126625. i.width = _.width,
  126626. i.height = _.height,
  126627. b = (_.isRGB || _.isLuminance || _.mipmapCount > 1) && i.generateMipMaps,
  126628. d._unpackFlipY(_.isCompressed),
  126629. DDSTools.UploadDDSLevels(d, i, j, _, b, 6, -1, k),
  126630. !_.isFourCC && _.mipmapCount === 1 && d.generateMipMapsForCubemap(i)
  126631. }
  126632. else {
  126633. var $ = e;
  126634. _ = DDSTools.GetDDSInfo($),
  126635. i.width = _.width,
  126636. i.height = _.height,
  126637. o && (_.sphericalPolynomial = new SphericalPolynomial),
  126638. b = (_.isRGB || _.isLuminance || _.mipmapCount > 1) && i.generateMipMaps,
  126639. d._unpackFlipY(_.isCompressed),
  126640. DDSTools.UploadDDSLevels(d, i, $, _, b, 6),
  126641. !_.isFourCC && _.mipmapCount === 1 && d.generateMipMapsForCubemap(i, !1)
  126642. }
  126643. d._setCubeMapTextureParams(i, b),
  126644. i.isReady = !0,
  126645. i.onLoadedObservable.notifyObservers(i),
  126646. i.onLoadedObservable.clear(),
  126647. s && s({
  126648. isDDS: !0,
  126649. width: i.width,
  126650. info: _,
  126651. data: e,
  126652. texture: i
  126653. })
  126654. }
  126655. ,
  126656. a.prototype.loadData = function(e, i, o) {
  126657. var s = DDSTools.GetDDSInfo(e)
  126658. , c = (s.isRGB || s.isLuminance || s.mipmapCount > 1) && i.generateMipMaps && s.width >> s.mipmapCount - 1 === 1;
  126659. o(s.width, s.height, c, s.isFourCC, function() {
  126660. DDSTools.UploadDDSLevels(i.getEngine(), i, e, s, c, 1)
  126661. })
  126662. }
  126663. ,
  126664. a
  126665. }();
  126666. Engine._TextureLoaders.push(new _DDSTextureLoader);
  126667. var MirrorTexture = function(a) {
  126668. __extends(e, a);
  126669. function e(i, o, s, c, d, _, b) {
  126670. d === void 0 && (d = 0),
  126671. _ === void 0 && (_ = Texture.BILINEAR_SAMPLINGMODE),
  126672. b === void 0 && (b = !0);
  126673. var k = a.call(this, i, o, s, c, !0, d, !1, _, b) || this;
  126674. k.scene = s,
  126675. k.mirrorPlane = new Plane(0,1,0,1),
  126676. k._transformMatrix = Matrix.Zero(),
  126677. k._mirrorMatrix = Matrix.Zero(),
  126678. k._adaptiveBlurKernel = 0,
  126679. k._blurKernelX = 0,
  126680. k._blurKernelY = 0,
  126681. k._blurRatio = 1,
  126682. k.ignoreCameraViewport = !0,
  126683. k._updateGammaSpace(),
  126684. k._imageProcessingConfigChangeObserver = s.imageProcessingConfiguration.onUpdateParameters.add(function() {
  126685. k._updateGammaSpace()
  126686. });
  126687. var j = k.getScene().getEngine();
  126688. j.supportsUniformBuffers && (k._sceneUBO = s.createSceneUniformBuffer('Scene for Mirror Texture (name "' + i + '")')),
  126689. k.onBeforeBindObservable.add(function() {
  126690. var _e;
  126691. (_e = j._debugPushGroup) === null || _e === void 0 || _e.call(j, "mirror generation for " + i, 1)
  126692. }),
  126693. k.onAfterUnbindObservable.add(function() {
  126694. var _e;
  126695. (_e = j._debugPopGroup) === null || _e === void 0 || _e.call(j, 1)
  126696. });
  126697. var $;
  126698. return k.onBeforeRenderObservable.add(function() {
  126699. k._sceneUBO && (k._currentSceneUBO = s.getSceneUniformBuffer(),
  126700. s.setSceneUniformBuffer(k._sceneUBO),
  126701. s.getSceneUniformBuffer().unbindEffect()),
  126702. Matrix.ReflectionToRef(k.mirrorPlane, k._mirrorMatrix),
  126703. k._mirrorMatrix.multiplyToRef(s.getViewMatrix(), k._transformMatrix),
  126704. s.setTransformMatrix(k._transformMatrix, s.getProjectionMatrix()),
  126705. $ = s.clipPlane,
  126706. s.clipPlane = k.mirrorPlane,
  126707. s.getEngine().cullBackFaces = !1,
  126708. s._mirroredCameraPosition = Vector3.TransformCoordinates(s.activeCamera.globalPosition, k._mirrorMatrix)
  126709. }),
  126710. k.onAfterRenderObservable.add(function() {
  126711. k._sceneUBO && s.setSceneUniformBuffer(k._currentSceneUBO),
  126712. s.updateTransformMatrix(),
  126713. s.getEngine().cullBackFaces = null,
  126714. s._mirroredCameraPosition = null,
  126715. s.clipPlane = $
  126716. }),
  126717. k
  126718. }
  126719. return Object.defineProperty(e.prototype, "blurRatio", {
  126720. get: function() {
  126721. return this._blurRatio
  126722. },
  126723. set: function(i) {
  126724. this._blurRatio !== i && (this._blurRatio = i,
  126725. this._preparePostProcesses())
  126726. },
  126727. enumerable: !1,
  126728. configurable: !0
  126729. }),
  126730. Object.defineProperty(e.prototype, "adaptiveBlurKernel", {
  126731. set: function(i) {
  126732. this._adaptiveBlurKernel = i,
  126733. this._autoComputeBlurKernel()
  126734. },
  126735. enumerable: !1,
  126736. configurable: !0
  126737. }),
  126738. Object.defineProperty(e.prototype, "blurKernel", {
  126739. set: function(i) {
  126740. this.blurKernelX = i,
  126741. this.blurKernelY = i
  126742. },
  126743. enumerable: !1,
  126744. configurable: !0
  126745. }),
  126746. Object.defineProperty(e.prototype, "blurKernelX", {
  126747. get: function() {
  126748. return this._blurKernelX
  126749. },
  126750. set: function(i) {
  126751. this._blurKernelX !== i && (this._blurKernelX = i,
  126752. this._preparePostProcesses())
  126753. },
  126754. enumerable: !1,
  126755. configurable: !0
  126756. }),
  126757. Object.defineProperty(e.prototype, "blurKernelY", {
  126758. get: function() {
  126759. return this._blurKernelY
  126760. },
  126761. set: function(i) {
  126762. this._blurKernelY !== i && (this._blurKernelY = i,
  126763. this._preparePostProcesses())
  126764. },
  126765. enumerable: !1,
  126766. configurable: !0
  126767. }),
  126768. e.prototype._autoComputeBlurKernel = function() {
  126769. var i = this.getScene().getEngine()
  126770. , o = this.getRenderWidth() / i.getRenderWidth()
  126771. , s = this.getRenderHeight() / i.getRenderHeight();
  126772. this.blurKernelX = this._adaptiveBlurKernel * o,
  126773. this.blurKernelY = this._adaptiveBlurKernel * s
  126774. }
  126775. ,
  126776. e.prototype._onRatioRescale = function() {
  126777. this._sizeRatio && (this.resize(this._initialSizeParameter),
  126778. this._adaptiveBlurKernel || this._preparePostProcesses()),
  126779. this._adaptiveBlurKernel && this._autoComputeBlurKernel()
  126780. }
  126781. ,
  126782. e.prototype._updateGammaSpace = function() {
  126783. this.gammaSpace = !this.scene.imageProcessingConfiguration.isEnabled || !this.scene.imageProcessingConfiguration.applyByPostProcess
  126784. }
  126785. ,
  126786. e.prototype._preparePostProcesses = function() {
  126787. if (this.clearPostProcesses(!0),
  126788. this._blurKernelX && this._blurKernelY) {
  126789. var i = this.getScene().getEngine()
  126790. , o = i.getCaps().textureFloatRender && i.getCaps().textureFloatLinearFiltering ? 1 : 2;
  126791. this._blurX = new BlurPostProcess("horizontal blur",new Vector2(1,0),this._blurKernelX,this._blurRatio,null,Texture.BILINEAR_SAMPLINGMODE,i,!1,o),
  126792. this._blurX.autoClear = !1,
  126793. this._blurRatio === 1 && this.samples < 2 && this._texture ? this._blurX.inputTexture = this._renderTarget : this._blurX.alwaysForcePOT = !0,
  126794. this._blurY = new BlurPostProcess("vertical blur",new Vector2(0,1),this._blurKernelY,this._blurRatio,null,Texture.BILINEAR_SAMPLINGMODE,i,!1,o),
  126795. this._blurY.autoClear = !1,
  126796. this._blurY.alwaysForcePOT = this._blurRatio !== 1,
  126797. this.addPostProcess(this._blurX),
  126798. this.addPostProcess(this._blurY)
  126799. } else
  126800. this._blurY && (this.removePostProcess(this._blurY),
  126801. this._blurY.dispose(),
  126802. this._blurY = null),
  126803. this._blurX && (this.removePostProcess(this._blurX),
  126804. this._blurX.dispose(),
  126805. this._blurX = null)
  126806. }
  126807. ,
  126808. e.prototype.clone = function() {
  126809. var i = this.getScene();
  126810. if (!i)
  126811. return this;
  126812. var o = this.getSize()
  126813. , s = new e(this.name,o.width,i,this._renderTargetOptions.generateMipMaps,this._renderTargetOptions.type,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer);
  126814. return s.hasAlpha = this.hasAlpha,
  126815. s.level = this.level,
  126816. s.mirrorPlane = this.mirrorPlane.clone(),
  126817. this.renderList && (s.renderList = this.renderList.slice(0)),
  126818. s
  126819. }
  126820. ,
  126821. e.prototype.serialize = function() {
  126822. if (!this.name)
  126823. return null;
  126824. var i = a.prototype.serialize.call(this);
  126825. return i.mirrorPlane = this.mirrorPlane.asArray(),
  126826. i
  126827. }
  126828. ,
  126829. e.prototype.dispose = function() {
  126830. var i;
  126831. a.prototype.dispose.call(this),
  126832. this.scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigChangeObserver),
  126833. (i = this._sceneUBO) === null || i === void 0 || i.dispose()
  126834. }
  126835. ,
  126836. e
  126837. }(RenderTargetTexture);
  126838. Texture._CreateMirror = function(a, e, i, o) {
  126839. return new MirrorTexture(a,e,i,o)
  126840. }
  126841. ;
  126842. var name$7 = "backgroundFragmentDeclaration"
  126843. , shader$7 = ` uniform vec4 vEyePosition;
  126844. uniform vec4 vPrimaryColor;
  126845. #ifdef USEHIGHLIGHTANDSHADOWCOLORS
  126846. uniform vec4 vPrimaryColorShadow;
  126847. #endif
  126848. uniform float shadowLevel;
  126849. uniform float alpha;
  126850. #ifdef DIFFUSE
  126851. uniform vec2 vDiffuseInfos;
  126852. #endif
  126853. #ifdef REFLECTION
  126854. uniform vec2 vReflectionInfos;
  126855. uniform mat4 reflectionMatrix;
  126856. uniform vec3 vReflectionMicrosurfaceInfos;
  126857. #endif
  126858. #if defined(REFLECTIONFRESNEL) || defined(OPACITYFRESNEL)
  126859. uniform vec3 vBackgroundCenter;
  126860. #endif
  126861. #ifdef REFLECTIONFRESNEL
  126862. uniform vec4 vReflectionControl;
  126863. #endif
  126864. #if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)
  126865. uniform mat4 view;
  126866. #endif`;
  126867. ShaderStore.IncludesShadersStore[name$7] = shader$7;
  126868. var name$6 = "backgroundUboDeclaration"
  126869. , shader$6 = `layout(std140,column_major) uniform;
  126870. uniform Material
  126871. {
  126872. uniform vec4 vPrimaryColor;
  126873. uniform vec4 vPrimaryColorShadow;
  126874. uniform vec2 vDiffuseInfos;
  126875. uniform vec2 vReflectionInfos;
  126876. uniform mat4 diffuseMatrix;
  126877. uniform mat4 reflectionMatrix;
  126878. uniform vec3 vReflectionMicrosurfaceInfos;
  126879. uniform float fFovMultiplier;
  126880. uniform float pointSize;
  126881. uniform float shadowLevel;
  126882. uniform float alpha;
  126883. #if defined(REFLECTIONFRESNEL) || defined(OPACITYFRESNEL)
  126884. uniform vec3 vBackgroundCenter;
  126885. #endif
  126886. #ifdef REFLECTIONFRESNEL
  126887. uniform vec4 vReflectionControl;
  126888. #endif
  126889. };
  126890. #include<sceneUboDeclaration>
  126891. `;
  126892. ShaderStore.IncludesShadersStore[name$6] = shader$6;
  126893. var name$5 = "backgroundPixelShader"
  126894. , shader$5 = `#ifdef TEXTURELODSUPPORT
  126895. #extension GL_EXT_shader_texture_lod : enable
  126896. #endif
  126897. precision highp float;
  126898. #include<__decl__backgroundFragment>
  126899. #include<helperFunctions>
  126900. #define RECIPROCAL_PI2 0.15915494
  126901. varying vec3 vPositionW;
  126902. #ifdef MAINUV1
  126903. varying vec2 vMainUV1;
  126904. #endif
  126905. #ifdef MAINUV2
  126906. varying vec2 vMainUV2;
  126907. #endif
  126908. #ifdef NORMAL
  126909. varying vec3 vNormalW;
  126910. #endif
  126911. #ifdef DIFFUSE
  126912. #if DIFFUSEDIRECTUV == 1
  126913. #define vDiffuseUV vMainUV1
  126914. #elif DIFFUSEDIRECTUV == 2
  126915. #define vDiffuseUV vMainUV2
  126916. #else
  126917. varying vec2 vDiffuseUV;
  126918. #endif
  126919. uniform sampler2D diffuseSampler;
  126920. #endif
  126921. #ifdef REFLECTION
  126922. #ifdef REFLECTIONMAP_3D
  126923. #define sampleReflection(s,c) textureCube(s,c)
  126924. uniform samplerCube reflectionSampler;
  126925. #ifdef TEXTURELODSUPPORT
  126926. #define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)
  126927. #else
  126928. uniform samplerCube reflectionSamplerLow;
  126929. uniform samplerCube reflectionSamplerHigh;
  126930. #endif
  126931. #else
  126932. #define sampleReflection(s,c) texture2D(s,c)
  126933. uniform sampler2D reflectionSampler;
  126934. #ifdef TEXTURELODSUPPORT
  126935. #define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)
  126936. #else
  126937. uniform samplerCube reflectionSamplerLow;
  126938. uniform samplerCube reflectionSamplerHigh;
  126939. #endif
  126940. #endif
  126941. #ifdef REFLECTIONMAP_SKYBOX
  126942. varying vec3 vPositionUVW;
  126943. #else
  126944. #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
  126945. varying vec3 vDirectionW;
  126946. #endif
  126947. #endif
  126948. #include<reflectionFunction>
  126949. #endif
  126950. #ifndef FROMLINEARSPACE
  126951. #define FROMLINEARSPACE;
  126952. #endif
  126953. #ifndef SHADOWONLY
  126954. #define SHADOWONLY;
  126955. #endif
  126956. #include<imageProcessingDeclaration>
  126957. #include<__decl__lightFragment>[0..maxSimultaneousLights]
  126958. #include<lightsFragmentFunctions>
  126959. #include<shadowsFragmentFunctions>
  126960. #include<imageProcessingFunctions>
  126961. #include<clipPlaneFragmentDeclaration>
  126962. #include<fogFragmentDeclaration>
  126963. #ifdef REFLECTIONFRESNEL
  126964. #define FRESNEL_MAXIMUM_ON_ROUGH 0.25
  126965. vec3 fresnelSchlickEnvironmentGGX(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)
  126966. {
  126967. float weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);
  126968. return reflectance0+weight*(reflectance90-reflectance0)*pow5(saturate(1.0-VdotN));
  126969. }
  126970. #endif
  126971. void main(void) {
  126972. #include<clipPlaneFragment>
  126973. vec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);
  126974. #ifdef NORMAL
  126975. vec3 normalW=normalize(vNormalW);
  126976. #else
  126977. vec3 normalW=vec3(0.0,1.0,0.0);
  126978. #endif
  126979. float shadow=1.;
  126980. float globalShadow=0.;
  126981. float shadowLightCount=0.;
  126982. #include<lightFragment>[0..maxSimultaneousLights]
  126983. #ifdef SHADOWINUSE
  126984. globalShadow/=shadowLightCount;
  126985. #else
  126986. globalShadow=1.0;
  126987. #endif
  126988. #ifndef BACKMAT_SHADOWONLY
  126989. vec4 reflectionColor=vec4(1.,1.,1.,1.);
  126990. #ifdef REFLECTION
  126991. vec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);
  126992. #ifdef REFLECTIONMAP_OPPOSITEZ
  126993. reflectionVector.z*=-1.0;
  126994. #endif
  126995. #ifdef REFLECTIONMAP_3D
  126996. vec3 reflectionCoords=reflectionVector;
  126997. #else
  126998. vec2 reflectionCoords=reflectionVector.xy;
  126999. #ifdef REFLECTIONMAP_PROJECTION
  127000. reflectionCoords/=reflectionVector.z;
  127001. #endif
  127002. reflectionCoords.y=1.0-reflectionCoords.y;
  127003. #endif
  127004. #ifdef REFLECTIONBLUR
  127005. float reflectionLOD=vReflectionInfos.y;
  127006. #ifdef TEXTURELODSUPPORT
  127007. reflectionLOD=reflectionLOD*log2(vReflectionMicrosurfaceInfos.x)*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;
  127008. reflectionColor=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD);
  127009. #else
  127010. float lodReflectionNormalized=saturate(reflectionLOD);
  127011. float lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;
  127012. vec4 reflectionSpecularMid=sampleReflection(reflectionSampler,reflectionCoords);
  127013. if(lodReflectionNormalizedDoubled<1.0){
  127014. reflectionColor=mix(
  127015. sampleReflection(reflectionSamplerHigh,reflectionCoords),
  127016. reflectionSpecularMid,
  127017. lodReflectionNormalizedDoubled
  127018. );
  127019. } else {
  127020. reflectionColor=mix(
  127021. reflectionSpecularMid,
  127022. sampleReflection(reflectionSamplerLow,reflectionCoords),
  127023. lodReflectionNormalizedDoubled-1.0
  127024. );
  127025. }
  127026. #endif
  127027. #else
  127028. vec4 reflectionSample=sampleReflection(reflectionSampler,reflectionCoords);
  127029. reflectionColor=reflectionSample;
  127030. #endif
  127031. #ifdef RGBDREFLECTION
  127032. reflectionColor.rgb=fromRGBD(reflectionColor);
  127033. #endif
  127034. #ifdef GAMMAREFLECTION
  127035. reflectionColor.rgb=toLinearSpace(reflectionColor.rgb);
  127036. #endif
  127037. #ifdef REFLECTIONBGR
  127038. reflectionColor.rgb=reflectionColor.bgr;
  127039. #endif
  127040. reflectionColor.rgb*=vReflectionInfos.x;
  127041. #endif
  127042. vec3 diffuseColor=vec3(1.,1.,1.);
  127043. float finalAlpha=alpha;
  127044. #ifdef DIFFUSE
  127045. vec4 diffuseMap=texture2D(diffuseSampler,vDiffuseUV);
  127046. #ifdef GAMMADIFFUSE
  127047. diffuseMap.rgb=toLinearSpace(diffuseMap.rgb);
  127048. #endif
  127049. diffuseMap.rgb*=vDiffuseInfos.y;
  127050. #ifdef DIFFUSEHASALPHA
  127051. finalAlpha*=diffuseMap.a;
  127052. #endif
  127053. diffuseColor=diffuseMap.rgb;
  127054. #endif
  127055. #ifdef REFLECTIONFRESNEL
  127056. vec3 colorBase=diffuseColor;
  127057. #else
  127058. vec3 colorBase=reflectionColor.rgb*diffuseColor;
  127059. #endif
  127060. colorBase=max(colorBase,0.0);
  127061. #ifdef USERGBCOLOR
  127062. vec3 finalColor=colorBase;
  127063. #else
  127064. #ifdef USEHIGHLIGHTANDSHADOWCOLORS
  127065. vec3 mainColor=mix(vPrimaryColorShadow.rgb,vPrimaryColor.rgb,colorBase);
  127066. #else
  127067. vec3 mainColor=vPrimaryColor.rgb;
  127068. #endif
  127069. vec3 finalColor=colorBase*mainColor;
  127070. #endif
  127071. #ifdef REFLECTIONFRESNEL
  127072. vec3 reflectionAmount=vReflectionControl.xxx;
  127073. vec3 reflectionReflectance0=vReflectionControl.yyy;
  127074. vec3 reflectionReflectance90=vReflectionControl.zzz;
  127075. float VdotN=dot(normalize(vEyePosition.xyz),normalW);
  127076. vec3 planarReflectionFresnel=fresnelSchlickEnvironmentGGX(saturate(VdotN),reflectionReflectance0,reflectionReflectance90,1.0);
  127077. reflectionAmount*=planarReflectionFresnel;
  127078. #ifdef REFLECTIONFALLOFF
  127079. float reflectionDistanceFalloff=1.0-saturate(length(vPositionW.xyz-vBackgroundCenter)*vReflectionControl.w);
  127080. reflectionDistanceFalloff*=reflectionDistanceFalloff;
  127081. reflectionAmount*=reflectionDistanceFalloff;
  127082. #endif
  127083. finalColor=mix(finalColor,reflectionColor.rgb,saturate(reflectionAmount));
  127084. #endif
  127085. #ifdef OPACITYFRESNEL
  127086. float viewAngleToFloor=dot(normalW,normalize(vEyePosition.xyz-vBackgroundCenter));
  127087. const float startAngle=0.1;
  127088. float fadeFactor=saturate(viewAngleToFloor/startAngle);
  127089. finalAlpha*=fadeFactor*fadeFactor;
  127090. #endif
  127091. #ifdef SHADOWINUSE
  127092. finalColor=mix(finalColor*shadowLevel,finalColor,globalShadow);
  127093. #endif
  127094. vec4 color=vec4(finalColor,finalAlpha);
  127095. #else
  127096. vec4 color=vec4(vPrimaryColor.rgb,(1.0-clamp(globalShadow,0.,1.))*alpha);
  127097. #endif
  127098. #include<fogFragment>
  127099. #ifdef IMAGEPROCESSINGPOSTPROCESS
  127100. #if !defined(SKIPFINALCOLORCLAMP)
  127101. color.rgb=clamp(color.rgb,0.,30.0);
  127102. #endif
  127103. #else
  127104. color=applyImageProcessing(color);
  127105. #endif
  127106. #ifdef PREMULTIPLYALPHA
  127107. color.rgb*=color.a;
  127108. #endif
  127109. #ifdef NOISE
  127110. color.rgb+=dither(vPositionW.xy,0.5);
  127111. color=max(color,0.0);
  127112. #endif
  127113. gl_FragColor=color;
  127114. }
  127115. `;
  127116. ShaderStore.ShadersStore[name$5] = shader$5;
  127117. var name$4 = "backgroundVertexDeclaration"
  127118. , shader$4 = `uniform mat4 view;
  127119. uniform mat4 viewProjection;
  127120. uniform float shadowLevel;
  127121. #ifdef DIFFUSE
  127122. uniform mat4 diffuseMatrix;
  127123. uniform vec2 vDiffuseInfos;
  127124. #endif
  127125. #ifdef REFLECTION
  127126. uniform vec2 vReflectionInfos;
  127127. uniform mat4 reflectionMatrix;
  127128. uniform vec3 vReflectionMicrosurfaceInfos;
  127129. uniform float fFovMultiplier;
  127130. #endif
  127131. #ifdef POINTSIZE
  127132. uniform float pointSize;
  127133. #endif`;
  127134. ShaderStore.IncludesShadersStore[name$4] = shader$4;
  127135. var name$3 = "backgroundVertexShader"
  127136. , shader$3 = `precision highp float;
  127137. #include<__decl__backgroundVertex>
  127138. #include<helperFunctions>
  127139. attribute vec3 position;
  127140. #ifdef NORMAL
  127141. attribute vec3 normal;
  127142. #endif
  127143. #include<bonesDeclaration>
  127144. #include<bakedVertexAnimationDeclaration>
  127145. #include<instancesDeclaration>
  127146. varying vec3 vPositionW;
  127147. #ifdef NORMAL
  127148. varying vec3 vNormalW;
  127149. #endif
  127150. #ifdef UV1
  127151. attribute vec2 uv;
  127152. #endif
  127153. #ifdef UV2
  127154. attribute vec2 uv2;
  127155. #endif
  127156. #ifdef MAINUV1
  127157. varying vec2 vMainUV1;
  127158. #endif
  127159. #ifdef MAINUV2
  127160. varying vec2 vMainUV2;
  127161. #endif
  127162. #if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0
  127163. varying vec2 vDiffuseUV;
  127164. #endif
  127165. #include<clipPlaneVertexDeclaration>
  127166. #include<fogVertexDeclaration>
  127167. #include<__decl__lightVxFragment>[0..maxSimultaneousLights]
  127168. #ifdef REFLECTIONMAP_SKYBOX
  127169. varying vec3 vPositionUVW;
  127170. #endif
  127171. #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
  127172. varying vec3 vDirectionW;
  127173. #endif
  127174. void main(void) {
  127175. #ifdef REFLECTIONMAP_SKYBOX
  127176. vPositionUVW=position;
  127177. #endif
  127178. #include<instancesVertex>
  127179. #include<bonesVertex>
  127180. #include<bakedVertexAnimation>
  127181. #ifdef MULTIVIEW
  127182. if (gl_ViewID_OVR == 0u) {
  127183. gl_Position=viewProjection*finalWorld*vec4(position,1.0);
  127184. } else {
  127185. gl_Position=viewProjectionR*finalWorld*vec4(position,1.0);
  127186. }
  127187. #else
  127188. gl_Position=viewProjection*finalWorld*vec4(position,1.0);
  127189. #endif
  127190. vec4 worldPos=finalWorld*vec4(position,1.0);
  127191. vPositionW=vec3(worldPos);
  127192. #ifdef NORMAL
  127193. mat3 normalWorld=mat3(finalWorld);
  127194. #ifdef NONUNIFORMSCALING
  127195. normalWorld=transposeMat3(inverseMat3(normalWorld));
  127196. #endif
  127197. vNormalW=normalize(normalWorld*normal);
  127198. #endif
  127199. #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
  127200. vDirectionW=normalize(vec3(finalWorld*vec4(position,0.0)));
  127201. #ifdef EQUIRECTANGULAR_RELFECTION_FOV
  127202. mat3 screenToWorld=inverseMat3(mat3(finalWorld*viewProjection));
  127203. vec3 segment=mix(vDirectionW,screenToWorld*vec3(0.0,0.0,1.0),abs(fFovMultiplier-1.0));
  127204. if (fFovMultiplier<=1.0) {
  127205. vDirectionW=normalize(segment);
  127206. } else {
  127207. vDirectionW=normalize(vDirectionW+(vDirectionW-segment));
  127208. }
  127209. #endif
  127210. #endif
  127211. #ifndef UV1
  127212. vec2 uv=vec2(0.,0.);
  127213. #endif
  127214. #ifndef UV2
  127215. vec2 uv2=vec2(0.,0.);
  127216. #endif
  127217. #ifdef MAINUV1
  127218. vMainUV1=uv;
  127219. #endif
  127220. #ifdef MAINUV2
  127221. vMainUV2=uv2;
  127222. #endif
  127223. #if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0
  127224. if (vDiffuseInfos.x == 0.)
  127225. {
  127226. vDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));
  127227. }
  127228. else
  127229. {
  127230. vDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));
  127231. }
  127232. #endif
  127233. #include<clipPlaneVertex>
  127234. #include<fogVertex>
  127235. #include<shadowsVertex>[0..maxSimultaneousLights]
  127236. #ifdef VERTEXCOLOR
  127237. vColor=color;
  127238. #endif
  127239. #ifdef POINTSIZE
  127240. gl_PointSize=pointSize;
  127241. #endif
  127242. }
  127243. `;
  127244. ShaderStore.ShadersStore[name$3] = shader$3;
  127245. var BackgroundMaterialDefines = function(a) {
  127246. __extends(e, a);
  127247. function e() {
  127248. var i = a.call(this) || this;
  127249. return i.DIFFUSE = !1,
  127250. i.DIFFUSEDIRECTUV = 0,
  127251. i.GAMMADIFFUSE = !1,
  127252. i.DIFFUSEHASALPHA = !1,
  127253. i.OPACITYFRESNEL = !1,
  127254. i.REFLECTIONBLUR = !1,
  127255. i.REFLECTIONFRESNEL = !1,
  127256. i.REFLECTIONFALLOFF = !1,
  127257. i.TEXTURELODSUPPORT = !1,
  127258. i.PREMULTIPLYALPHA = !1,
  127259. i.USERGBCOLOR = !1,
  127260. i.USEHIGHLIGHTANDSHADOWCOLORS = !1,
  127261. i.BACKMAT_SHADOWONLY = !1,
  127262. i.NOISE = !1,
  127263. i.REFLECTIONBGR = !1,
  127264. i.IMAGEPROCESSING = !1,
  127265. i.VIGNETTE = !1,
  127266. i.VIGNETTEBLENDMODEMULTIPLY = !1,
  127267. i.VIGNETTEBLENDMODEOPAQUE = !1,
  127268. i.TONEMAPPING = !1,
  127269. i.TONEMAPPING_ACES = !1,
  127270. i.CONTRAST = !1,
  127271. i.COLORCURVES = !1,
  127272. i.COLORGRADING = !1,
  127273. i.COLORGRADING3D = !1,
  127274. i.SAMPLER3DGREENDEPTH = !1,
  127275. i.SAMPLER3DBGRMAP = !1,
  127276. i.IMAGEPROCESSINGPOSTPROCESS = !1,
  127277. i.SKIPFINALCOLORCLAMP = !1,
  127278. i.EXPOSURE = !1,
  127279. i.MULTIVIEW = !1,
  127280. i.REFLECTION = !1,
  127281. i.REFLECTIONMAP_3D = !1,
  127282. i.REFLECTIONMAP_SPHERICAL = !1,
  127283. i.REFLECTIONMAP_PLANAR = !1,
  127284. i.REFLECTIONMAP_CUBIC = !1,
  127285. i.REFLECTIONMAP_PROJECTION = !1,
  127286. i.REFLECTIONMAP_SKYBOX = !1,
  127287. i.REFLECTIONMAP_EXPLICIT = !1,
  127288. i.REFLECTIONMAP_EQUIRECTANGULAR = !1,
  127289. i.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !1,
  127290. i.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !1,
  127291. i.INVERTCUBICMAP = !1,
  127292. i.REFLECTIONMAP_OPPOSITEZ = !1,
  127293. i.LODINREFLECTIONALPHA = !1,
  127294. i.GAMMAREFLECTION = !1,
  127295. i.RGBDREFLECTION = !1,
  127296. i.EQUIRECTANGULAR_RELFECTION_FOV = !1,
  127297. i.MAINUV1 = !1,
  127298. i.MAINUV2 = !1,
  127299. i.UV1 = !1,
  127300. i.UV2 = !1,
  127301. i.CLIPPLANE = !1,
  127302. i.CLIPPLANE2 = !1,
  127303. i.CLIPPLANE3 = !1,
  127304. i.CLIPPLANE4 = !1,
  127305. i.CLIPPLANE5 = !1,
  127306. i.CLIPPLANE6 = !1,
  127307. i.POINTSIZE = !1,
  127308. i.FOG = !1,
  127309. i.NORMAL = !1,
  127310. i.NUM_BONE_INFLUENCERS = 0,
  127311. i.BonesPerMesh = 0,
  127312. i.INSTANCES = !1,
  127313. i.SHADOWFLOAT = !1,
  127314. i.LOGARITHMICDEPTH = !1,
  127315. i.NONUNIFORMSCALING = !1,
  127316. i.ALPHATEST = !1,
  127317. i.rebuild(),
  127318. i
  127319. }
  127320. return e
  127321. }(MaterialDefines)
  127322. , BackgroundMaterial = function(a) {
  127323. __extends(e, a);
  127324. function e(i, o) {
  127325. var s = a.call(this, i, o) || this;
  127326. return s.primaryColor = Color3.White(),
  127327. s._primaryColorShadowLevel = 0,
  127328. s._primaryColorHighlightLevel = 0,
  127329. s.reflectionTexture = null,
  127330. s.reflectionBlur = 0,
  127331. s.diffuseTexture = null,
  127332. s._shadowLights = null,
  127333. s.shadowLights = null,
  127334. s.shadowLevel = 0,
  127335. s.sceneCenter = Vector3.Zero(),
  127336. s.opacityFresnel = !0,
  127337. s.reflectionFresnel = !1,
  127338. s.reflectionFalloffDistance = 0,
  127339. s.reflectionAmount = 1,
  127340. s.reflectionReflectance0 = .05,
  127341. s.reflectionReflectance90 = .5,
  127342. s.useRGBColor = !0,
  127343. s.enableNoise = !1,
  127344. s._fovMultiplier = 1,
  127345. s.useEquirectangularFOV = !1,
  127346. s._maxSimultaneousLights = 4,
  127347. s.maxSimultaneousLights = 4,
  127348. s._shadowOnly = !1,
  127349. s.shadowOnly = !1,
  127350. s._imageProcessingObserver = null,
  127351. s.switchToBGR = !1,
  127352. s._renderTargets = new SmartArray(16),
  127353. s._reflectionControls = Vector4.Zero(),
  127354. s._white = Color3.White(),
  127355. s._primaryShadowColor = Color3.Black(),
  127356. s._primaryHighlightColor = Color3.Black(),
  127357. s._attachImageProcessingConfiguration(null),
  127358. s.getRenderTargetTextures = function() {
  127359. return s._renderTargets.reset(),
  127360. s._diffuseTexture && s._diffuseTexture.isRenderTarget && s._renderTargets.push(s._diffuseTexture),
  127361. s._reflectionTexture && s._reflectionTexture.isRenderTarget && s._renderTargets.push(s._reflectionTexture),
  127362. s._renderTargets
  127363. }
  127364. ,
  127365. s
  127366. }
  127367. return Object.defineProperty(e.prototype, "_perceptualColor", {
  127368. get: function() {
  127369. return this.__perceptualColor
  127370. },
  127371. set: function(i) {
  127372. this.__perceptualColor = i,
  127373. this._computePrimaryColorFromPerceptualColor(),
  127374. this._markAllSubMeshesAsLightsDirty()
  127375. },
  127376. enumerable: !1,
  127377. configurable: !0
  127378. }),
  127379. Object.defineProperty(e.prototype, "primaryColorShadowLevel", {
  127380. get: function() {
  127381. return this._primaryColorShadowLevel
  127382. },
  127383. set: function(i) {
  127384. this._primaryColorShadowLevel = i,
  127385. this._computePrimaryColors(),
  127386. this._markAllSubMeshesAsLightsDirty()
  127387. },
  127388. enumerable: !1,
  127389. configurable: !0
  127390. }),
  127391. Object.defineProperty(e.prototype, "primaryColorHighlightLevel", {
  127392. get: function() {
  127393. return this._primaryColorHighlightLevel
  127394. },
  127395. set: function(i) {
  127396. this._primaryColorHighlightLevel = i,
  127397. this._computePrimaryColors(),
  127398. this._markAllSubMeshesAsLightsDirty()
  127399. },
  127400. enumerable: !1,
  127401. configurable: !0
  127402. }),
  127403. Object.defineProperty(e.prototype, "reflectionStandardFresnelWeight", {
  127404. set: function(i) {
  127405. var o = i;
  127406. o < .5 ? (o = o * 2,
  127407. this.reflectionReflectance0 = e.StandardReflectance0 * o,
  127408. this.reflectionReflectance90 = e.StandardReflectance90 * o) : (o = o * 2 - 1,
  127409. this.reflectionReflectance0 = e.StandardReflectance0 + (1 - e.StandardReflectance0) * o,
  127410. this.reflectionReflectance90 = e.StandardReflectance90 + (1 - e.StandardReflectance90) * o)
  127411. },
  127412. enumerable: !1,
  127413. configurable: !0
  127414. }),
  127415. Object.defineProperty(e.prototype, "fovMultiplier", {
  127416. get: function() {
  127417. return this._fovMultiplier
  127418. },
  127419. set: function(i) {
  127420. isNaN(i) && (i = 1),
  127421. this._fovMultiplier = Math.max(0, Math.min(2, i))
  127422. },
  127423. enumerable: !1,
  127424. configurable: !0
  127425. }),
  127426. e.prototype._attachImageProcessingConfiguration = function(i) {
  127427. var o = this;
  127428. i !== this._imageProcessingConfiguration && (this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),
  127429. i ? this._imageProcessingConfiguration = i : this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration,
  127430. this._imageProcessingConfiguration && (this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function() {
  127431. o._computePrimaryColorFromPerceptualColor(),
  127432. o._markAllSubMeshesAsImageProcessingDirty()
  127433. })))
  127434. }
  127435. ,
  127436. Object.defineProperty(e.prototype, "imageProcessingConfiguration", {
  127437. get: function() {
  127438. return this._imageProcessingConfiguration
  127439. },
  127440. set: function(i) {
  127441. this._attachImageProcessingConfiguration(i),
  127442. this._markAllSubMeshesAsTexturesDirty()
  127443. },
  127444. enumerable: !1,
  127445. configurable: !0
  127446. }),
  127447. Object.defineProperty(e.prototype, "cameraColorCurvesEnabled", {
  127448. get: function() {
  127449. return this.imageProcessingConfiguration.colorCurvesEnabled
  127450. },
  127451. set: function(i) {
  127452. this.imageProcessingConfiguration.colorCurvesEnabled = i
  127453. },
  127454. enumerable: !1,
  127455. configurable: !0
  127456. }),
  127457. Object.defineProperty(e.prototype, "cameraColorGradingEnabled", {
  127458. get: function() {
  127459. return this.imageProcessingConfiguration.colorGradingEnabled
  127460. },
  127461. set: function(i) {
  127462. this.imageProcessingConfiguration.colorGradingEnabled = i
  127463. },
  127464. enumerable: !1,
  127465. configurable: !0
  127466. }),
  127467. Object.defineProperty(e.prototype, "cameraToneMappingEnabled", {
  127468. get: function() {
  127469. return this._imageProcessingConfiguration.toneMappingEnabled
  127470. },
  127471. set: function(i) {
  127472. this._imageProcessingConfiguration.toneMappingEnabled = i
  127473. },
  127474. enumerable: !1,
  127475. configurable: !0
  127476. }),
  127477. Object.defineProperty(e.prototype, "cameraExposure", {
  127478. get: function() {
  127479. return this._imageProcessingConfiguration.exposure
  127480. },
  127481. set: function(i) {
  127482. this._imageProcessingConfiguration.exposure = i
  127483. },
  127484. enumerable: !1,
  127485. configurable: !0
  127486. }),
  127487. Object.defineProperty(e.prototype, "cameraContrast", {
  127488. get: function() {
  127489. return this._imageProcessingConfiguration.contrast
  127490. },
  127491. set: function(i) {
  127492. this._imageProcessingConfiguration.contrast = i
  127493. },
  127494. enumerable: !1,
  127495. configurable: !0
  127496. }),
  127497. Object.defineProperty(e.prototype, "cameraColorGradingTexture", {
  127498. get: function() {
  127499. return this._imageProcessingConfiguration.colorGradingTexture
  127500. },
  127501. set: function(i) {
  127502. this.imageProcessingConfiguration.colorGradingTexture = i
  127503. },
  127504. enumerable: !1,
  127505. configurable: !0
  127506. }),
  127507. Object.defineProperty(e.prototype, "cameraColorCurves", {
  127508. get: function() {
  127509. return this.imageProcessingConfiguration.colorCurves
  127510. },
  127511. set: function(i) {
  127512. this.imageProcessingConfiguration.colorCurves = i
  127513. },
  127514. enumerable: !1,
  127515. configurable: !0
  127516. }),
  127517. Object.defineProperty(e.prototype, "hasRenderTargetTextures", {
  127518. get: function() {
  127519. return !!(this._diffuseTexture && this._diffuseTexture.isRenderTarget || this._reflectionTexture && this._reflectionTexture.isRenderTarget)
  127520. },
  127521. enumerable: !1,
  127522. configurable: !0
  127523. }),
  127524. e.prototype.needAlphaTesting = function() {
  127525. return !0
  127526. }
  127527. ,
  127528. e.prototype.needAlphaBlending = function() {
  127529. return this.alpha < 1 || this._diffuseTexture != null && this._diffuseTexture.hasAlpha || this._shadowOnly
  127530. }
  127531. ,
  127532. e.prototype.isReadyForSubMesh = function(i, o, s) {
  127533. if (s === void 0 && (s = !1),
  127534. o.effect && this.isFrozen && o.effect._wasPreviouslyReady)
  127535. return !0;
  127536. o.materialDefines || (o.materialDefines = new BackgroundMaterialDefines);
  127537. var c = this.getScene()
  127538. , d = o.materialDefines;
  127539. if (this._isReadyForSubMesh(o))
  127540. return !0;
  127541. var _ = c.getEngine();
  127542. if (MaterialHelper.PrepareDefinesForLights(c, i, d, !1, this._maxSimultaneousLights),
  127543. d._needNormals = !0,
  127544. MaterialHelper.PrepareDefinesForMultiview(c, d),
  127545. d._areTexturesDirty) {
  127546. if (d._needUVs = !1,
  127547. c.texturesEnabled) {
  127548. if (c.getEngine().getCaps().textureLOD && (d.TEXTURELODSUPPORT = !0),
  127549. this._diffuseTexture && MaterialFlags.DiffuseTextureEnabled) {
  127550. if (!this._diffuseTexture.isReadyOrNotBlocking())
  127551. return !1;
  127552. MaterialHelper.PrepareDefinesForMergedUV(this._diffuseTexture, d, "DIFFUSE"),
  127553. d.DIFFUSEHASALPHA = this._diffuseTexture.hasAlpha,
  127554. d.GAMMADIFFUSE = this._diffuseTexture.gammaSpace,
  127555. d.OPACITYFRESNEL = this._opacityFresnel
  127556. } else
  127557. d.DIFFUSE = !1,
  127558. d.DIFFUSEHASALPHA = !1,
  127559. d.GAMMADIFFUSE = !1,
  127560. d.OPACITYFRESNEL = !1;
  127561. var b = this._reflectionTexture;
  127562. if (b && MaterialFlags.ReflectionTextureEnabled) {
  127563. if (!b.isReadyOrNotBlocking())
  127564. return !1;
  127565. switch (d.REFLECTION = !0,
  127566. d.GAMMAREFLECTION = b.gammaSpace,
  127567. d.RGBDREFLECTION = b.isRGBD,
  127568. d.REFLECTIONBLUR = this._reflectionBlur > 0,
  127569. d.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !b.invertZ : b.invertZ,
  127570. d.LODINREFLECTIONALPHA = b.lodLevelInAlpha,
  127571. d.EQUIRECTANGULAR_RELFECTION_FOV = this.useEquirectangularFOV,
  127572. d.REFLECTIONBGR = this.switchToBGR,
  127573. b.coordinatesMode === Texture.INVCUBIC_MODE && (d.INVERTCUBICMAP = !0),
  127574. d.REFLECTIONMAP_3D = b.isCube,
  127575. b.coordinatesMode) {
  127576. case Texture.EXPLICIT_MODE:
  127577. d.REFLECTIONMAP_EXPLICIT = !0;
  127578. break;
  127579. case Texture.PLANAR_MODE:
  127580. d.REFLECTIONMAP_PLANAR = !0;
  127581. break;
  127582. case Texture.PROJECTION_MODE:
  127583. d.REFLECTIONMAP_PROJECTION = !0;
  127584. break;
  127585. case Texture.SKYBOX_MODE:
  127586. d.REFLECTIONMAP_SKYBOX = !0;
  127587. break;
  127588. case Texture.SPHERICAL_MODE:
  127589. d.REFLECTIONMAP_SPHERICAL = !0;
  127590. break;
  127591. case Texture.EQUIRECTANGULAR_MODE:
  127592. d.REFLECTIONMAP_EQUIRECTANGULAR = !0;
  127593. break;
  127594. case Texture.FIXED_EQUIRECTANGULAR_MODE:
  127595. d.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !0;
  127596. break;
  127597. case Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  127598. d.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !0;
  127599. break;
  127600. case Texture.CUBIC_MODE:
  127601. case Texture.INVCUBIC_MODE:
  127602. default:
  127603. d.REFLECTIONMAP_CUBIC = !0;
  127604. break
  127605. }
  127606. this.reflectionFresnel ? (d.REFLECTIONFRESNEL = !0,
  127607. d.REFLECTIONFALLOFF = this.reflectionFalloffDistance > 0,
  127608. this._reflectionControls.x = this.reflectionAmount,
  127609. this._reflectionControls.y = this.reflectionReflectance0,
  127610. this._reflectionControls.z = this.reflectionReflectance90,
  127611. this._reflectionControls.w = 1 / this.reflectionFalloffDistance) : (d.REFLECTIONFRESNEL = !1,
  127612. d.REFLECTIONFALLOFF = !1)
  127613. } else
  127614. d.REFLECTION = !1,
  127615. d.REFLECTIONFRESNEL = !1,
  127616. d.REFLECTIONFALLOFF = !1,
  127617. d.REFLECTIONBLUR = !1,
  127618. d.REFLECTIONMAP_3D = !1,
  127619. d.REFLECTIONMAP_SPHERICAL = !1,
  127620. d.REFLECTIONMAP_PLANAR = !1,
  127621. d.REFLECTIONMAP_CUBIC = !1,
  127622. d.REFLECTIONMAP_PROJECTION = !1,
  127623. d.REFLECTIONMAP_SKYBOX = !1,
  127624. d.REFLECTIONMAP_EXPLICIT = !1,
  127625. d.REFLECTIONMAP_EQUIRECTANGULAR = !1,
  127626. d.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !1,
  127627. d.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !1,
  127628. d.INVERTCUBICMAP = !1,
  127629. d.REFLECTIONMAP_OPPOSITEZ = !1,
  127630. d.LODINREFLECTIONALPHA = !1,
  127631. d.GAMMAREFLECTION = !1,
  127632. d.RGBDREFLECTION = !1
  127633. }
  127634. d.PREMULTIPLYALPHA = this.alphaMode === 7 || this.alphaMode === 8,
  127635. d.USERGBCOLOR = this._useRGBColor,
  127636. d.NOISE = this._enableNoise
  127637. }
  127638. if (d._areLightsDirty && (d.USEHIGHLIGHTANDSHADOWCOLORS = !this._useRGBColor && (this._primaryColorShadowLevel !== 0 || this._primaryColorHighlightLevel !== 0),
  127639. d.BACKMAT_SHADOWONLY = this._shadowOnly),
  127640. d._areImageProcessingDirty && this._imageProcessingConfiguration) {
  127641. if (!this._imageProcessingConfiguration.isReady())
  127642. return !1;
  127643. this._imageProcessingConfiguration.prepareDefines(d)
  127644. }
  127645. if (MaterialHelper.PrepareDefinesForMisc(i, c, !1, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(i), d),
  127646. MaterialHelper.PrepareDefinesForFrameBoundValues(c, _, d, s, null, o.getRenderingMesh().hasThinInstances),
  127647. MaterialHelper.PrepareDefinesForAttributes(i, d, !1, !0, !1) && i && !c.getEngine().getCaps().standardDerivatives && !i.isVerticesDataPresent(VertexBuffer.NormalKind) && (i.createNormals(!0),
  127648. Logger$2.Warn("BackgroundMaterial: Normals have been created for the mesh: " + i.name)),
  127649. d.isDirty) {
  127650. d.markAsProcessed(),
  127651. c.resetCachedMaterial();
  127652. var k = new EffectFallbacks;
  127653. d.FOG && k.addFallback(0, "FOG"),
  127654. d.POINTSIZE && k.addFallback(1, "POINTSIZE"),
  127655. d.MULTIVIEW && k.addFallback(0, "MULTIVIEW"),
  127656. MaterialHelper.HandleFallbacksForShadows(d, k, this._maxSimultaneousLights);
  127657. var j = [VertexBuffer.PositionKind];
  127658. d.NORMAL && j.push(VertexBuffer.NormalKind),
  127659. d.UV1 && j.push(VertexBuffer.UVKind),
  127660. d.UV2 && j.push(VertexBuffer.UV2Kind),
  127661. MaterialHelper.PrepareAttributesForBones(j, i, d, k),
  127662. MaterialHelper.PrepareAttributesForInstances(j, d);
  127663. var $ = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vFogInfos", "vFogColor", "pointSize", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "mBones", "vPrimaryColor", "vPrimaryColorShadow", "vReflectionInfos", "reflectionMatrix", "vReflectionMicrosurfaceInfos", "fFovMultiplier", "shadowLevel", "alpha", "vBackgroundCenter", "vReflectionControl", "vDiffuseInfos", "diffuseMatrix"]
  127664. , _e = ["diffuseSampler", "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh"]
  127665. , et = ["Material", "Scene"];
  127666. ImageProcessingConfiguration && (ImageProcessingConfiguration.PrepareUniforms($, d),
  127667. ImageProcessingConfiguration.PrepareSamplers(_e, d)),
  127668. MaterialHelper.PrepareUniformsAndSamplersList({
  127669. uniformsNames: $,
  127670. uniformBuffersNames: et,
  127671. samplers: _e,
  127672. defines: d,
  127673. maxSimultaneousLights: this._maxSimultaneousLights
  127674. });
  127675. var tt = d.toString()
  127676. , rt = c.getEngine().createEffect("background", {
  127677. attributes: j,
  127678. uniformsNames: $,
  127679. uniformBuffersNames: et,
  127680. samplers: _e,
  127681. defines: tt,
  127682. fallbacks: k,
  127683. onCompiled: this.onCompiled,
  127684. onError: this.onError,
  127685. indexParameters: {
  127686. maxSimultaneousLights: this._maxSimultaneousLights
  127687. }
  127688. }, _);
  127689. o.setEffect(rt, d, this._materialContext),
  127690. this.buildUniformLayout()
  127691. }
  127692. return !o.effect || !o.effect.isReady() ? !1 : (d._renderId = c.getRenderId(),
  127693. o.effect._wasPreviouslyReady = !0,
  127694. !0)
  127695. }
  127696. ,
  127697. e.prototype._computePrimaryColorFromPerceptualColor = function() {
  127698. !this.__perceptualColor || (this._primaryColor.copyFrom(this.__perceptualColor),
  127699. this._primaryColor.toLinearSpaceToRef(this._primaryColor),
  127700. this._imageProcessingConfiguration && this._primaryColor.scaleToRef(1 / this._imageProcessingConfiguration.exposure, this._primaryColor),
  127701. this._computePrimaryColors())
  127702. }
  127703. ,
  127704. e.prototype._computePrimaryColors = function() {
  127705. this._primaryColorShadowLevel === 0 && this._primaryColorHighlightLevel === 0 || (this._primaryColor.scaleToRef(this._primaryColorShadowLevel, this._primaryShadowColor),
  127706. this._primaryColor.subtractToRef(this._primaryShadowColor, this._primaryShadowColor),
  127707. this._white.subtractToRef(this._primaryColor, this._primaryHighlightColor),
  127708. this._primaryHighlightColor.scaleToRef(this._primaryColorHighlightLevel, this._primaryHighlightColor),
  127709. this._primaryColor.addToRef(this._primaryHighlightColor, this._primaryHighlightColor))
  127710. }
  127711. ,
  127712. e.prototype.buildUniformLayout = function() {
  127713. this._uniformBuffer.addUniform("vPrimaryColor", 4),
  127714. this._uniformBuffer.addUniform("vPrimaryColorShadow", 4),
  127715. this._uniformBuffer.addUniform("vDiffuseInfos", 2),
  127716. this._uniformBuffer.addUniform("vReflectionInfos", 2),
  127717. this._uniformBuffer.addUniform("diffuseMatrix", 16),
  127718. this._uniformBuffer.addUniform("reflectionMatrix", 16),
  127719. this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos", 3),
  127720. this._uniformBuffer.addUniform("fFovMultiplier", 1),
  127721. this._uniformBuffer.addUniform("pointSize", 1),
  127722. this._uniformBuffer.addUniform("shadowLevel", 1),
  127723. this._uniformBuffer.addUniform("alpha", 1),
  127724. this._uniformBuffer.addUniform("vBackgroundCenter", 3),
  127725. this._uniformBuffer.addUniform("vReflectionControl", 4),
  127726. this._uniformBuffer.create()
  127727. }
  127728. ,
  127729. e.prototype.unbind = function() {
  127730. this._diffuseTexture && this._diffuseTexture.isRenderTarget && this._uniformBuffer.setTexture("diffuseSampler", null),
  127731. this._reflectionTexture && this._reflectionTexture.isRenderTarget && this._uniformBuffer.setTexture("reflectionSampler", null),
  127732. a.prototype.unbind.call(this)
  127733. }
  127734. ,
  127735. e.prototype.bindOnlyWorldMatrix = function(i) {
  127736. this._activeEffect.setMatrix("world", i)
  127737. }
  127738. ,
  127739. e.prototype.bindForSubMesh = function(i, o, s) {
  127740. var c = this.getScene()
  127741. , d = s.materialDefines;
  127742. if (!!d) {
  127743. var _ = s.effect;
  127744. if (!!_) {
  127745. this._activeEffect = _,
  127746. this.bindOnlyWorldMatrix(i),
  127747. MaterialHelper.BindBonesParameters(o, this._activeEffect);
  127748. var b = this._mustRebind(c, _, o.visibility);
  127749. if (b) {
  127750. this._uniformBuffer.bindToEffect(_, "Material"),
  127751. this.bindViewProjection(_);
  127752. var k = this._reflectionTexture;
  127753. (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) && (c.texturesEnabled && (this._diffuseTexture && MaterialFlags.DiffuseTextureEnabled && (this._uniformBuffer.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level),
  127754. MaterialHelper.BindTextureMatrix(this._diffuseTexture, this._uniformBuffer, "diffuse")),
  127755. k && MaterialFlags.ReflectionTextureEnabled && (this._uniformBuffer.updateMatrix("reflectionMatrix", k.getReflectionTextureMatrix()),
  127756. this._uniformBuffer.updateFloat2("vReflectionInfos", k.level, this._reflectionBlur),
  127757. this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos", k.getSize().width, k.lodGenerationScale, k.lodGenerationOffset))),
  127758. this.shadowLevel > 0 && this._uniformBuffer.updateFloat("shadowLevel", this.shadowLevel),
  127759. this._uniformBuffer.updateFloat("alpha", this.alpha),
  127760. this.pointsCloud && this._uniformBuffer.updateFloat("pointSize", this.pointSize),
  127761. d.USEHIGHLIGHTANDSHADOWCOLORS ? (this._uniformBuffer.updateColor4("vPrimaryColor", this._primaryHighlightColor, 1),
  127762. this._uniformBuffer.updateColor4("vPrimaryColorShadow", this._primaryShadowColor, 1)) : this._uniformBuffer.updateColor4("vPrimaryColor", this._primaryColor, 1)),
  127763. this._uniformBuffer.updateFloat("fFovMultiplier", this._fovMultiplier),
  127764. c.texturesEnabled && (this._diffuseTexture && MaterialFlags.DiffuseTextureEnabled && this._uniformBuffer.setTexture("diffuseSampler", this._diffuseTexture),
  127765. k && MaterialFlags.ReflectionTextureEnabled && (d.REFLECTIONBLUR && d.TEXTURELODSUPPORT ? this._uniformBuffer.setTexture("reflectionSampler", k) : d.REFLECTIONBLUR ? (this._uniformBuffer.setTexture("reflectionSampler", k._lodTextureMid || k),
  127766. this._uniformBuffer.setTexture("reflectionSamplerLow", k._lodTextureLow || k),
  127767. this._uniformBuffer.setTexture("reflectionSamplerHigh", k._lodTextureHigh || k)) : this._uniformBuffer.setTexture("reflectionSampler", k),
  127768. d.REFLECTIONFRESNEL && (this._uniformBuffer.updateFloat3("vBackgroundCenter", this.sceneCenter.x, this.sceneCenter.y, this.sceneCenter.z),
  127769. this._uniformBuffer.updateFloat4("vReflectionControl", this._reflectionControls.x, this._reflectionControls.y, this._reflectionControls.z, this._reflectionControls.w)))),
  127770. MaterialHelper.BindClipPlane(this._activeEffect, c),
  127771. c.bindEyePosition(_)
  127772. } else
  127773. c.getEngine()._features.needToAlwaysBindUniformBuffers && (this._uniformBuffer.bindToEffect(_, "Material"),
  127774. this._needToBindSceneUbo = !0);
  127775. (b || !this.isFrozen) && (c.lightsEnabled && MaterialHelper.BindLights(c, o, this._activeEffect, d, this._maxSimultaneousLights),
  127776. this.bindView(_),
  127777. MaterialHelper.BindFogParameters(c, o, this._activeEffect, !0),
  127778. this._imageProcessingConfiguration && this._imageProcessingConfiguration.bind(this._activeEffect)),
  127779. this._afterBind(o, this._activeEffect),
  127780. this._uniformBuffer.update()
  127781. }
  127782. }
  127783. }
  127784. ,
  127785. e.prototype.hasTexture = function(i) {
  127786. return !!(a.prototype.hasTexture.call(this, i) || this._reflectionTexture === i || this._diffuseTexture === i)
  127787. }
  127788. ,
  127789. e.prototype.dispose = function(i, o) {
  127790. i === void 0 && (i = !1),
  127791. o === void 0 && (o = !1),
  127792. o && (this.diffuseTexture && this.diffuseTexture.dispose(),
  127793. this.reflectionTexture && this.reflectionTexture.dispose()),
  127794. this._renderTargets.dispose(),
  127795. this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),
  127796. a.prototype.dispose.call(this, i)
  127797. }
  127798. ,
  127799. e.prototype.clone = function(i) {
  127800. var o = this;
  127801. return SerializationHelper.Clone(function() {
  127802. return new e(i,o.getScene())
  127803. }, this)
  127804. }
  127805. ,
  127806. e.prototype.serialize = function() {
  127807. var i = SerializationHelper.Serialize(this);
  127808. return i.customType = "BABYLON.BackgroundMaterial",
  127809. i
  127810. }
  127811. ,
  127812. e.prototype.getClassName = function() {
  127813. return "BackgroundMaterial"
  127814. }
  127815. ,
  127816. e.Parse = function(i, o, s) {
  127817. return SerializationHelper.Parse(function() {
  127818. return new e(i.name,o)
  127819. }, i, o, s)
  127820. }
  127821. ,
  127822. e.StandardReflectance0 = .05,
  127823. e.StandardReflectance90 = .5,
  127824. __decorate([serializeAsColor3()], e.prototype, "_primaryColor", void 0),
  127825. __decorate([expandToProperty("_markAllSubMeshesAsLightsDirty")], e.prototype, "primaryColor", void 0),
  127826. __decorate([serializeAsColor3()], e.prototype, "__perceptualColor", void 0),
  127827. __decorate([serialize()], e.prototype, "_primaryColorShadowLevel", void 0),
  127828. __decorate([serialize()], e.prototype, "_primaryColorHighlightLevel", void 0),
  127829. __decorate([expandToProperty("_markAllSubMeshesAsLightsDirty")], e.prototype, "primaryColorHighlightLevel", null),
  127830. __decorate([serializeAsTexture()], e.prototype, "_reflectionTexture", void 0),
  127831. __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "reflectionTexture", void 0),
  127832. __decorate([serialize()], e.prototype, "_reflectionBlur", void 0),
  127833. __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "reflectionBlur", void 0),
  127834. __decorate([serializeAsTexture()], e.prototype, "_diffuseTexture", void 0),
  127835. __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "diffuseTexture", void 0),
  127836. __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "shadowLights", void 0),
  127837. __decorate([serialize()], e.prototype, "_shadowLevel", void 0),
  127838. __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "shadowLevel", void 0),
  127839. __decorate([serializeAsVector3()], e.prototype, "_sceneCenter", void 0),
  127840. __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "sceneCenter", void 0),
  127841. __decorate([serialize()], e.prototype, "_opacityFresnel", void 0),
  127842. __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "opacityFresnel", void 0),
  127843. __decorate([serialize()], e.prototype, "_reflectionFresnel", void 0),
  127844. __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "reflectionFresnel", void 0),
  127845. __decorate([serialize()], e.prototype, "_reflectionFalloffDistance", void 0),
  127846. __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "reflectionFalloffDistance", void 0),
  127847. __decorate([serialize()], e.prototype, "_reflectionAmount", void 0),
  127848. __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "reflectionAmount", void 0),
  127849. __decorate([serialize()], e.prototype, "_reflectionReflectance0", void 0),
  127850. __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "reflectionReflectance0", void 0),
  127851. __decorate([serialize()], e.prototype, "_reflectionReflectance90", void 0),
  127852. __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "reflectionReflectance90", void 0),
  127853. __decorate([serialize()], e.prototype, "_useRGBColor", void 0),
  127854. __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useRGBColor", void 0),
  127855. __decorate([serialize()], e.prototype, "_enableNoise", void 0),
  127856. __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "enableNoise", void 0),
  127857. __decorate([serialize()], e.prototype, "_maxSimultaneousLights", void 0),
  127858. __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "maxSimultaneousLights", void 0),
  127859. __decorate([serialize()], e.prototype, "_shadowOnly", void 0),
  127860. __decorate([expandToProperty("_markAllSubMeshesAsLightsDirty")], e.prototype, "shadowOnly", void 0),
  127861. __decorate([serializeAsImageProcessingConfiguration()], e.prototype, "_imageProcessingConfiguration", void 0),
  127862. e
  127863. }(PushMaterial);
  127864. RegisterClass("BABYLON.BackgroundMaterial", BackgroundMaterial);
  127865. var EnvironmentHelper = function() {
  127866. function a(e, i) {
  127867. var o = this;
  127868. this._errorHandler = function(s, c) {
  127869. o.onErrorObservable.notifyObservers({
  127870. message: s,
  127871. exception: c
  127872. })
  127873. }
  127874. ,
  127875. this._options = __assign(__assign({}, a._getDefaultOptions()), e),
  127876. this._scene = i,
  127877. this.onErrorObservable = new Observable,
  127878. this._setupBackground(),
  127879. this._setupImageProcessing()
  127880. }
  127881. return a._getDefaultOptions = function() {
  127882. return {
  127883. createGround: !0,
  127884. groundSize: 15,
  127885. groundTexture: this._groundTextureCDNUrl,
  127886. groundColor: new Color3(.2,.2,.3).toLinearSpace().scale(3),
  127887. groundOpacity: .9,
  127888. enableGroundShadow: !0,
  127889. groundShadowLevel: .5,
  127890. enableGroundMirror: !1,
  127891. groundMirrorSizeRatio: .3,
  127892. groundMirrorBlurKernel: 64,
  127893. groundMirrorAmount: 1,
  127894. groundMirrorFresnelWeight: 1,
  127895. groundMirrorFallOffDistance: 0,
  127896. groundMirrorTextureType: 0,
  127897. groundYBias: 1e-5,
  127898. createSkybox: !0,
  127899. skyboxSize: 20,
  127900. skyboxTexture: this._skyboxTextureCDNUrl,
  127901. skyboxColor: new Color3(.2,.2,.3).toLinearSpace().scale(3),
  127902. backgroundYRotation: 0,
  127903. sizeAuto: !0,
  127904. rootPosition: Vector3.Zero(),
  127905. setupImageProcessing: !0,
  127906. environmentTexture: this._environmentTextureCDNUrl,
  127907. cameraExposure: .8,
  127908. cameraContrast: 1.2,
  127909. toneMappingEnabled: !0
  127910. }
  127911. }
  127912. ,
  127913. Object.defineProperty(a.prototype, "rootMesh", {
  127914. get: function() {
  127915. return this._rootMesh
  127916. },
  127917. enumerable: !1,
  127918. configurable: !0
  127919. }),
  127920. Object.defineProperty(a.prototype, "skybox", {
  127921. get: function() {
  127922. return this._skybox
  127923. },
  127924. enumerable: !1,
  127925. configurable: !0
  127926. }),
  127927. Object.defineProperty(a.prototype, "skyboxTexture", {
  127928. get: function() {
  127929. return this._skyboxTexture
  127930. },
  127931. enumerable: !1,
  127932. configurable: !0
  127933. }),
  127934. Object.defineProperty(a.prototype, "skyboxMaterial", {
  127935. get: function() {
  127936. return this._skyboxMaterial
  127937. },
  127938. enumerable: !1,
  127939. configurable: !0
  127940. }),
  127941. Object.defineProperty(a.prototype, "ground", {
  127942. get: function() {
  127943. return this._ground
  127944. },
  127945. enumerable: !1,
  127946. configurable: !0
  127947. }),
  127948. Object.defineProperty(a.prototype, "groundTexture", {
  127949. get: function() {
  127950. return this._groundTexture
  127951. },
  127952. enumerable: !1,
  127953. configurable: !0
  127954. }),
  127955. Object.defineProperty(a.prototype, "groundMirror", {
  127956. get: function() {
  127957. return this._groundMirror
  127958. },
  127959. enumerable: !1,
  127960. configurable: !0
  127961. }),
  127962. Object.defineProperty(a.prototype, "groundMirrorRenderList", {
  127963. get: function() {
  127964. return this._groundMirror ? this._groundMirror.renderList : null
  127965. },
  127966. enumerable: !1,
  127967. configurable: !0
  127968. }),
  127969. Object.defineProperty(a.prototype, "groundMaterial", {
  127970. get: function() {
  127971. return this._groundMaterial
  127972. },
  127973. enumerable: !1,
  127974. configurable: !0
  127975. }),
  127976. a.prototype.updateOptions = function(e) {
  127977. var i = __assign(__assign({}, this._options), e);
  127978. this._ground && !i.createGround && (this._ground.dispose(),
  127979. this._ground = null),
  127980. this._groundMaterial && !i.createGround && (this._groundMaterial.dispose(),
  127981. this._groundMaterial = null),
  127982. this._groundTexture && this._options.groundTexture != i.groundTexture && (this._groundTexture.dispose(),
  127983. this._groundTexture = null),
  127984. this._skybox && !i.createSkybox && (this._skybox.dispose(),
  127985. this._skybox = null),
  127986. this._skyboxMaterial && !i.createSkybox && (this._skyboxMaterial.dispose(),
  127987. this._skyboxMaterial = null),
  127988. this._skyboxTexture && this._options.skyboxTexture != i.skyboxTexture && (this._skyboxTexture.dispose(),
  127989. this._skyboxTexture = null),
  127990. this._groundMirror && !i.enableGroundMirror && (this._groundMirror.dispose(),
  127991. this._groundMirror = null),
  127992. this._scene.environmentTexture && this._options.environmentTexture != i.environmentTexture && this._scene.environmentTexture.dispose(),
  127993. this._options = i,
  127994. this._setupBackground(),
  127995. this._setupImageProcessing()
  127996. }
  127997. ,
  127998. a.prototype.setMainColor = function(e) {
  127999. this.groundMaterial && (this.groundMaterial.primaryColor = e),
  128000. this.skyboxMaterial && (this.skyboxMaterial.primaryColor = e),
  128001. this.groundMirror && (this.groundMirror.clearColor = new Color4(e.r,e.g,e.b,1))
  128002. }
  128003. ,
  128004. a.prototype._setupImageProcessing = function() {
  128005. this._options.setupImageProcessing && (this._scene.imageProcessingConfiguration.contrast = this._options.cameraContrast,
  128006. this._scene.imageProcessingConfiguration.exposure = this._options.cameraExposure,
  128007. this._scene.imageProcessingConfiguration.toneMappingEnabled = this._options.toneMappingEnabled,
  128008. this._setupEnvironmentTexture())
  128009. }
  128010. ,
  128011. a.prototype._setupEnvironmentTexture = function() {
  128012. if (!this._scene.environmentTexture) {
  128013. if (this._options.environmentTexture instanceof BaseTexture) {
  128014. this._scene.environmentTexture = this._options.environmentTexture;
  128015. return
  128016. }
  128017. var e = CubeTexture.CreateFromPrefilteredData(this._options.environmentTexture, this._scene);
  128018. this._scene.environmentTexture = e
  128019. }
  128020. }
  128021. ,
  128022. a.prototype._setupBackground = function() {
  128023. this._rootMesh || (this._rootMesh = new Mesh("BackgroundHelper",this._scene)),
  128024. this._rootMesh.rotation.y = this._options.backgroundYRotation;
  128025. var e = this._getSceneSize();
  128026. this._options.createGround && (this._setupGround(e),
  128027. this._setupGroundMaterial(),
  128028. this._setupGroundDiffuseTexture(),
  128029. this._options.enableGroundMirror && this._setupGroundMirrorTexture(e),
  128030. this._setupMirrorInGroundMaterial()),
  128031. this._options.createSkybox && (this._setupSkybox(e),
  128032. this._setupSkyboxMaterial(),
  128033. this._setupSkyboxReflectionTexture()),
  128034. this._rootMesh.position.x = e.rootPosition.x,
  128035. this._rootMesh.position.z = e.rootPosition.z,
  128036. this._rootMesh.position.y = e.rootPosition.y
  128037. }
  128038. ,
  128039. a.prototype._getSceneSize = function() {
  128040. var e = this
  128041. , i = this._options.groundSize
  128042. , o = this._options.skyboxSize
  128043. , s = this._options.rootPosition;
  128044. if (!this._scene.meshes || this._scene.meshes.length === 1)
  128045. return {
  128046. groundSize: i,
  128047. skyboxSize: o,
  128048. rootPosition: s
  128049. };
  128050. var c = this._scene.getWorldExtends(function(b) {
  128051. return b !== e._ground && b !== e._rootMesh && b !== e._skybox
  128052. })
  128053. , d = c.max.subtract(c.min);
  128054. if (this._options.sizeAuto) {
  128055. this._scene.activeCamera instanceof ArcRotateCamera && this._scene.activeCamera.upperRadiusLimit && (i = this._scene.activeCamera.upperRadiusLimit * 2,
  128056. o = i);
  128057. var _ = d.length();
  128058. _ > i && (i = _ * 2,
  128059. o = i),
  128060. i *= 1.1,
  128061. o *= 1.5,
  128062. s = c.min.add(d.scale(.5)),
  128063. s.y = c.min.y - this._options.groundYBias
  128064. }
  128065. return {
  128066. groundSize: i,
  128067. skyboxSize: o,
  128068. rootPosition: s
  128069. }
  128070. }
  128071. ,
  128072. a.prototype._setupGround = function(e) {
  128073. var i = this;
  128074. (!this._ground || this._ground.isDisposed()) && (this._ground = CreatePlane("BackgroundPlane", {
  128075. size: e.groundSize
  128076. }, this._scene),
  128077. this._ground.rotation.x = Math.PI / 2,
  128078. this._ground.parent = this._rootMesh,
  128079. this._ground.onDisposeObservable.add(function() {
  128080. i._ground = null
  128081. })),
  128082. this._ground.receiveShadows = this._options.enableGroundShadow
  128083. }
  128084. ,
  128085. a.prototype._setupGroundMaterial = function() {
  128086. this._groundMaterial || (this._groundMaterial = new BackgroundMaterial("BackgroundPlaneMaterial",this._scene)),
  128087. this._groundMaterial.alpha = this._options.groundOpacity,
  128088. this._groundMaterial.alphaMode = 8,
  128089. this._groundMaterial.shadowLevel = this._options.groundShadowLevel,
  128090. this._groundMaterial.primaryColor = this._options.groundColor,
  128091. this._groundMaterial.useRGBColor = !1,
  128092. this._groundMaterial.enableNoise = !0,
  128093. this._ground && (this._ground.material = this._groundMaterial)
  128094. }
  128095. ,
  128096. a.prototype._setupGroundDiffuseTexture = function() {
  128097. if (!!this._groundMaterial && !this._groundTexture) {
  128098. if (this._options.groundTexture instanceof BaseTexture) {
  128099. this._groundMaterial.diffuseTexture = this._options.groundTexture;
  128100. return
  128101. }
  128102. this._groundTexture = new Texture(this._options.groundTexture,this._scene,void 0,void 0,void 0,void 0,this._errorHandler),
  128103. this._groundTexture.gammaSpace = !1,
  128104. this._groundTexture.hasAlpha = !0,
  128105. this._groundMaterial.diffuseTexture = this._groundTexture
  128106. }
  128107. }
  128108. ,
  128109. a.prototype._setupGroundMirrorTexture = function(e) {
  128110. var i = Texture.CLAMP_ADDRESSMODE;
  128111. if (!this._groundMirror && (this._groundMirror = new MirrorTexture("BackgroundPlaneMirrorTexture",{
  128112. ratio: this._options.groundMirrorSizeRatio
  128113. },this._scene,!1,this._options.groundMirrorTextureType,Texture.BILINEAR_SAMPLINGMODE,!0),
  128114. this._groundMirror.mirrorPlane = new Plane(0,-1,0,e.rootPosition.y),
  128115. this._groundMirror.anisotropicFilteringLevel = 1,
  128116. this._groundMirror.wrapU = i,
  128117. this._groundMirror.wrapV = i,
  128118. this._groundMirror.gammaSpace = !1,
  128119. this._groundMirror.renderList))
  128120. for (var o = 0; o < this._scene.meshes.length; o++) {
  128121. var s = this._scene.meshes[o];
  128122. s !== this._ground && s !== this._skybox && s !== this._rootMesh && this._groundMirror.renderList.push(s)
  128123. }
  128124. this._groundMirror.clearColor = new Color4(this._options.groundColor.r,this._options.groundColor.g,this._options.groundColor.b,1),
  128125. this._groundMirror.adaptiveBlurKernel = this._options.groundMirrorBlurKernel
  128126. }
  128127. ,
  128128. a.prototype._setupMirrorInGroundMaterial = function() {
  128129. this._groundMaterial && (this._groundMaterial.reflectionTexture = this._groundMirror,
  128130. this._groundMaterial.reflectionFresnel = !0,
  128131. this._groundMaterial.reflectionAmount = this._options.groundMirrorAmount,
  128132. this._groundMaterial.reflectionStandardFresnelWeight = this._options.groundMirrorFresnelWeight,
  128133. this._groundMaterial.reflectionFalloffDistance = this._options.groundMirrorFallOffDistance)
  128134. }
  128135. ,
  128136. a.prototype._setupSkybox = function(e) {
  128137. var i = this;
  128138. (!this._skybox || this._skybox.isDisposed()) && (this._skybox = CreateBox("BackgroundSkybox", {
  128139. size: e.skyboxSize,
  128140. sideOrientation: Mesh.BACKSIDE
  128141. }, this._scene),
  128142. this._skybox.onDisposeObservable.add(function() {
  128143. i._skybox = null
  128144. })),
  128145. this._skybox.parent = this._rootMesh
  128146. }
  128147. ,
  128148. a.prototype._setupSkyboxMaterial = function() {
  128149. !this._skybox || (this._skyboxMaterial || (this._skyboxMaterial = new BackgroundMaterial("BackgroundSkyboxMaterial",this._scene)),
  128150. this._skyboxMaterial.useRGBColor = !1,
  128151. this._skyboxMaterial.primaryColor = this._options.skyboxColor,
  128152. this._skyboxMaterial.enableNoise = !0,
  128153. this._skybox.material = this._skyboxMaterial)
  128154. }
  128155. ,
  128156. a.prototype._setupSkyboxReflectionTexture = function() {
  128157. if (!!this._skyboxMaterial && !this._skyboxTexture) {
  128158. if (this._options.skyboxTexture instanceof BaseTexture) {
  128159. this._skyboxMaterial.reflectionTexture = this._options.skyboxTexture;
  128160. return
  128161. }
  128162. this._skyboxTexture = new CubeTexture(this._options.skyboxTexture,this._scene,void 0,void 0,void 0,void 0,this._errorHandler),
  128163. this._skyboxTexture.coordinatesMode = Texture.SKYBOX_MODE,
  128164. this._skyboxTexture.gammaSpace = !1,
  128165. this._skyboxMaterial.reflectionTexture = this._skyboxTexture
  128166. }
  128167. }
  128168. ,
  128169. a.prototype.dispose = function() {
  128170. this._groundMaterial && this._groundMaterial.dispose(!0, !0),
  128171. this._skyboxMaterial && this._skyboxMaterial.dispose(!0, !0),
  128172. this._rootMesh.dispose(!1)
  128173. }
  128174. ,
  128175. a._groundTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundGround.png",
  128176. a._skyboxTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundSkybox.dds",
  128177. a._environmentTextureCDNUrl = "https://assets.babylonjs.com/environments/environmentSpecular.env",
  128178. a
  128179. }();
  128180. FreeCameraInputsManager.prototype.addDeviceOrientation = function() {
  128181. return this._deviceOrientationInput || (this._deviceOrientationInput = new FreeCameraDeviceOrientationInput,
  128182. this.add(this._deviceOrientationInput)),
  128183. this
  128184. }
  128185. ;
  128186. var FreeCameraDeviceOrientationInput = function() {
  128187. function a() {
  128188. var e = this;
  128189. this._screenOrientationAngle = 0,
  128190. this._screenQuaternion = new Quaternion,
  128191. this._alpha = 0,
  128192. this._beta = 0,
  128193. this._gamma = 0,
  128194. this._onDeviceOrientationChangedObservable = new Observable,
  128195. this._orientationChanged = function() {
  128196. e._screenOrientationAngle = window.orientation !== void 0 ? +window.orientation : window.screen.orientation && window.screen.orientation.angle ? window.screen.orientation.angle : 0,
  128197. e._screenOrientationAngle = -Tools.ToRadians(e._screenOrientationAngle / 2),
  128198. e._screenQuaternion.copyFromFloats(0, Math.sin(e._screenOrientationAngle), 0, Math.cos(e._screenOrientationAngle))
  128199. }
  128200. ,
  128201. this._deviceOrientation = function(i) {
  128202. e._alpha = i.alpha !== null ? i.alpha : 0,
  128203. e._beta = i.beta !== null ? i.beta : 0,
  128204. e._gamma = i.gamma !== null ? i.gamma : 0,
  128205. i.alpha !== null && e._onDeviceOrientationChangedObservable.notifyObservers()
  128206. }
  128207. ,
  128208. this._constantTranform = new Quaternion(-Math.sqrt(.5),0,0,Math.sqrt(.5)),
  128209. this._orientationChanged()
  128210. }
  128211. return a.WaitForOrientationChangeAsync = function(e) {
  128212. return new Promise(function(i, o) {
  128213. var s = !1
  128214. , c = function() {
  128215. window.removeEventListener("deviceorientation", c),
  128216. s = !0,
  128217. i()
  128218. };
  128219. e && setTimeout(function() {
  128220. s || (window.removeEventListener("deviceorientation", c),
  128221. o("WaitForOrientationChangeAsync timed out"))
  128222. }, e),
  128223. typeof DeviceOrientationEvent != "undefined" && typeof DeviceOrientationEvent.requestPermission == "function" ? DeviceOrientationEvent.requestPermission().then(function(d) {
  128224. d == "granted" ? window.addEventListener("deviceorientation", c) : Tools.Warn("Permission not granted.")
  128225. }).catch(function(d) {
  128226. Tools.Error(d)
  128227. }) : window.addEventListener("deviceorientation", c)
  128228. }
  128229. )
  128230. }
  128231. ,
  128232. Object.defineProperty(a.prototype, "camera", {
  128233. get: function() {
  128234. return this._camera
  128235. },
  128236. set: function(e) {
  128237. var i = this;
  128238. this._camera = e,
  128239. this._camera != null && !this._camera.rotationQuaternion && (this._camera.rotationQuaternion = new Quaternion),
  128240. this._camera && this._camera.onDisposeObservable.add(function() {
  128241. i._onDeviceOrientationChangedObservable.clear()
  128242. })
  128243. },
  128244. enumerable: !1,
  128245. configurable: !0
  128246. }),
  128247. a.prototype.attachControl = function() {
  128248. var e = this
  128249. , i = this.camera.getScene().getEngine().getHostWindow();
  128250. if (i) {
  128251. var o = function() {
  128252. i.addEventListener("orientationchange", e._orientationChanged),
  128253. i.addEventListener("deviceorientation", e._deviceOrientation),
  128254. e._orientationChanged()
  128255. };
  128256. typeof DeviceOrientationEvent != "undefined" && typeof DeviceOrientationEvent.requestPermission == "function" ? DeviceOrientationEvent.requestPermission().then(function(s) {
  128257. s === "granted" ? o() : Tools.Warn("Permission not granted.")
  128258. }).catch(function(s) {
  128259. Tools.Error(s)
  128260. }) : o()
  128261. }
  128262. }
  128263. ,
  128264. a.prototype.detachControl = function(e) {
  128265. window.removeEventListener("orientationchange", this._orientationChanged),
  128266. window.removeEventListener("deviceorientation", this._deviceOrientation),
  128267. this._alpha = 0
  128268. }
  128269. ,
  128270. a.prototype.checkInputs = function() {
  128271. !this._alpha || (Quaternion.RotationYawPitchRollToRef(Tools.ToRadians(this._alpha), Tools.ToRadians(this._beta), -Tools.ToRadians(this._gamma), this.camera.rotationQuaternion),
  128272. this._camera.rotationQuaternion.multiplyInPlace(this._screenQuaternion),
  128273. this._camera.rotationQuaternion.multiplyInPlace(this._constantTranform),
  128274. this._camera.rotationQuaternion.z *= -1,
  128275. this._camera.rotationQuaternion.w *= -1)
  128276. }
  128277. ,
  128278. a.prototype.getClassName = function() {
  128279. return "FreeCameraDeviceOrientationInput"
  128280. }
  128281. ,
  128282. a.prototype.getSimpleName = function() {
  128283. return "deviceOrientation"
  128284. }
  128285. ,
  128286. a
  128287. }();
  128288. CameraInputTypes.FreeCameraDeviceOrientationInput = FreeCameraDeviceOrientationInput;
  128289. Node$2.AddNodeConstructor("DeviceOrientationCamera", function(a, e) {
  128290. return function() {
  128291. return new DeviceOrientationCamera(a,Vector3.Zero(),e)
  128292. }
  128293. });
  128294. var DeviceOrientationCamera = function(a) {
  128295. __extends(e, a);
  128296. function e(i, o, s) {
  128297. var c = a.call(this, i, o, s) || this;
  128298. return c._tmpDragQuaternion = new Quaternion,
  128299. c._disablePointerInputWhenUsingDeviceOrientation = !0,
  128300. c._dragFactor = 0,
  128301. c._quaternionCache = new Quaternion,
  128302. c.inputs.addDeviceOrientation(),
  128303. c.inputs._deviceOrientationInput && c.inputs._deviceOrientationInput._onDeviceOrientationChangedObservable.addOnce(function() {
  128304. c._disablePointerInputWhenUsingDeviceOrientation && c.inputs._mouseInput && (c.inputs._mouseInput._allowCameraRotation = !1,
  128305. c.inputs._mouseInput.onPointerMovedObservable.add(function(d) {
  128306. c._dragFactor != 0 && (c._initialQuaternion || (c._initialQuaternion = new Quaternion),
  128307. Quaternion.FromEulerAnglesToRef(0, d.offsetX * c._dragFactor, 0, c._tmpDragQuaternion),
  128308. c._initialQuaternion.multiplyToRef(c._tmpDragQuaternion, c._initialQuaternion))
  128309. }))
  128310. }),
  128311. c
  128312. }
  128313. return Object.defineProperty(e.prototype, "disablePointerInputWhenUsingDeviceOrientation", {
  128314. get: function() {
  128315. return this._disablePointerInputWhenUsingDeviceOrientation
  128316. },
  128317. set: function(i) {
  128318. this._disablePointerInputWhenUsingDeviceOrientation = i
  128319. },
  128320. enumerable: !1,
  128321. configurable: !0
  128322. }),
  128323. e.prototype.enableHorizontalDragging = function(i) {
  128324. i === void 0 && (i = 1 / 300),
  128325. this._dragFactor = i
  128326. }
  128327. ,
  128328. e.prototype.getClassName = function() {
  128329. return "DeviceOrientationCamera"
  128330. }
  128331. ,
  128332. e.prototype._checkInputs = function() {
  128333. a.prototype._checkInputs.call(this),
  128334. this._quaternionCache.copyFrom(this.rotationQuaternion),
  128335. this._initialQuaternion && this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion)
  128336. }
  128337. ,
  128338. e.prototype.resetToCurrentRotation = function(i) {
  128339. var o = this;
  128340. i === void 0 && (i = Axis.Y),
  128341. this.rotationQuaternion && (this._initialQuaternion || (this._initialQuaternion = new Quaternion),
  128342. this._initialQuaternion.copyFrom(this._quaternionCache || this.rotationQuaternion),
  128343. ["x", "y", "z"].forEach(function(s) {
  128344. i[s] ? o._initialQuaternion[s] *= -1 : o._initialQuaternion[s] = 0
  128345. }),
  128346. this._initialQuaternion.normalize(),
  128347. this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion))
  128348. }
  128349. ,
  128350. e
  128351. }(FreeCamera)
  128352. , VRCameraMetrics = function() {
  128353. function a() {
  128354. this.compensateDistortion = !0,
  128355. this.multiviewEnabled = !1
  128356. }
  128357. return Object.defineProperty(a.prototype, "aspectRatio", {
  128358. get: function() {
  128359. return this.hResolution / (2 * this.vResolution)
  128360. },
  128361. enumerable: !1,
  128362. configurable: !0
  128363. }),
  128364. Object.defineProperty(a.prototype, "aspectRatioFov", {
  128365. get: function() {
  128366. return 2 * Math.atan(this.postProcessScaleFactor * this.vScreenSize / (2 * this.eyeToScreenDistance))
  128367. },
  128368. enumerable: !1,
  128369. configurable: !0
  128370. }),
  128371. Object.defineProperty(a.prototype, "leftHMatrix", {
  128372. get: function() {
  128373. var e = this.hScreenSize / 4 - this.lensSeparationDistance / 2
  128374. , i = 4 * e / this.hScreenSize;
  128375. return Matrix.Translation(i, 0, 0)
  128376. },
  128377. enumerable: !1,
  128378. configurable: !0
  128379. }),
  128380. Object.defineProperty(a.prototype, "rightHMatrix", {
  128381. get: function() {
  128382. var e = this.hScreenSize / 4 - this.lensSeparationDistance / 2
  128383. , i = 4 * e / this.hScreenSize;
  128384. return Matrix.Translation(-i, 0, 0)
  128385. },
  128386. enumerable: !1,
  128387. configurable: !0
  128388. }),
  128389. Object.defineProperty(a.prototype, "leftPreViewMatrix", {
  128390. get: function() {
  128391. return Matrix.Translation(.5 * this.interpupillaryDistance, 0, 0)
  128392. },
  128393. enumerable: !1,
  128394. configurable: !0
  128395. }),
  128396. Object.defineProperty(a.prototype, "rightPreViewMatrix", {
  128397. get: function() {
  128398. return Matrix.Translation(-.5 * this.interpupillaryDistance, 0, 0)
  128399. },
  128400. enumerable: !1,
  128401. configurable: !0
  128402. }),
  128403. a.GetDefault = function() {
  128404. var e = new a;
  128405. return e.hResolution = 1280,
  128406. e.vResolution = 800,
  128407. e.hScreenSize = .149759993,
  128408. e.vScreenSize = .0935999975,
  128409. e.vScreenCenter = .0467999987,
  128410. e.eyeToScreenDistance = .0410000011,
  128411. e.lensSeparationDistance = .063500002,
  128412. e.interpupillaryDistance = .064000003,
  128413. e.distortionK = [1, .219999999, .239999995, 0],
  128414. e.chromaAbCorrection = [.995999992, -.00400000019, 1.01400006, 0],
  128415. e.postProcessScaleFactor = 1.714605507808412,
  128416. e.lensCenterOffset = .151976421,
  128417. e
  128418. }
  128419. ,
  128420. a
  128421. }()
  128422. , name$2 = "vrDistortionCorrectionPixelShader"
  128423. , shader$2 = `
  128424. varying vec2 vUV;
  128425. uniform sampler2D textureSampler;
  128426. uniform vec2 LensCenter;
  128427. uniform vec2 Scale;
  128428. uniform vec2 ScaleIn;
  128429. uniform vec4 HmdWarpParam;
  128430. vec2 HmdWarp(vec2 in01) {
  128431. vec2 theta=(in01-LensCenter)*ScaleIn;
  128432. float rSq=theta.x*theta.x+theta.y*theta.y;
  128433. vec2 rvector=theta*(HmdWarpParam.x+HmdWarpParam.y*rSq+HmdWarpParam.z*rSq*rSq+HmdWarpParam.w*rSq*rSq*rSq);
  128434. return LensCenter+Scale*rvector;
  128435. }
  128436. void main(void)
  128437. {
  128438. vec2 tc=HmdWarp(vUV);
  128439. if (tc.x <0.0 || tc.x>1.0 || tc.y<0.0 || tc.y>1.0)
  128440. gl_FragColor=vec4(0.0,0.0,0.0,0.0);
  128441. else{
  128442. gl_FragColor=texture2D(textureSampler,tc);
  128443. }
  128444. }`;
  128445. ShaderStore.ShadersStore[name$2] = shader$2;
  128446. var VRDistortionCorrectionPostProcess = function(a) {
  128447. __extends(e, a);
  128448. function e(i, o, s, c) {
  128449. var d = a.call(this, i, "vrDistortionCorrection", ["LensCenter", "Scale", "ScaleIn", "HmdWarpParam"], null, c.postProcessScaleFactor, o, Texture.BILINEAR_SAMPLINGMODE) || this;
  128450. return d._isRightEye = s,
  128451. d._distortionFactors = c.distortionK,
  128452. d._postProcessScaleFactor = c.postProcessScaleFactor,
  128453. d._lensCenterOffset = c.lensCenterOffset,
  128454. d.adaptScaleToCurrentViewport = !0,
  128455. d.onSizeChangedObservable.add(function() {
  128456. d._scaleIn = new Vector2(2,2 / d.aspectRatio),
  128457. d._scaleFactor = new Vector2(.5 * (1 / d._postProcessScaleFactor),.5 * (1 / d._postProcessScaleFactor) * d.aspectRatio),
  128458. d._lensCenter = new Vector2(d._isRightEye ? .5 - d._lensCenterOffset * .5 : .5 + d._lensCenterOffset * .5,.5)
  128459. }),
  128460. d.onApplyObservable.add(function(_) {
  128461. _.setFloat2("LensCenter", d._lensCenter.x, d._lensCenter.y),
  128462. _.setFloat2("Scale", d._scaleFactor.x, d._scaleFactor.y),
  128463. _.setFloat2("ScaleIn", d._scaleIn.x, d._scaleIn.y),
  128464. _.setFloat4("HmdWarpParam", d._distortionFactors[0], d._distortionFactors[1], d._distortionFactors[2], d._distortionFactors[3])
  128465. }),
  128466. d
  128467. }
  128468. return e.prototype.getClassName = function() {
  128469. return "VRDistortionCorrectionPostProcess"
  128470. }
  128471. ,
  128472. e
  128473. }(PostProcess)
  128474. , name$1 = "vrMultiviewToSingleviewPixelShader"
  128475. , shader$1 = `precision mediump sampler2DArray;
  128476. varying vec2 vUV;
  128477. uniform sampler2DArray multiviewSampler;
  128478. uniform int imageIndex;
  128479. void main(void)
  128480. {
  128481. gl_FragColor=texture2D(multiviewSampler,vec3(vUV,imageIndex));
  128482. }`;
  128483. ShaderStore.ShadersStore[name$1] = shader$1;
  128484. var VRMultiviewToSingleviewPostProcess = function(a) {
  128485. __extends(e, a);
  128486. function e(i, o, s) {
  128487. var c = a.call(this, i, "vrMultiviewToSingleview", ["imageIndex"], ["multiviewSampler"], s, o, Texture.BILINEAR_SAMPLINGMODE) || this;
  128488. return c.onSizeChangedObservable.add(function() {}),
  128489. c.onApplyObservable.add(function(d) {
  128490. o._scene.activeCamera && o._scene.activeCamera.isLeftCamera ? d.setInt("imageIndex", 0) : d.setInt("imageIndex", 1),
  128491. d.setTexture("multiviewSampler", o._multiviewTexture)
  128492. }),
  128493. c
  128494. }
  128495. return e.prototype.getClassName = function() {
  128496. return "VRMultiviewToSingleviewPostProcess"
  128497. }
  128498. ,
  128499. e
  128500. }(PostProcess);
  128501. function setVRRigMode(a, e) {
  128502. var i = e.vrCameraMetrics || VRCameraMetrics.GetDefault();
  128503. a._rigCameras[0]._cameraRigParams.vrMetrics = i,
  128504. a._rigCameras[0].viewport = new Viewport(0,0,.5,1),
  128505. a._rigCameras[0]._cameraRigParams.vrWorkMatrix = new Matrix,
  128506. a._rigCameras[0]._cameraRigParams.vrHMatrix = i.leftHMatrix,
  128507. a._rigCameras[0]._cameraRigParams.vrPreViewMatrix = i.leftPreViewMatrix,
  128508. a._rigCameras[0].getProjectionMatrix = a._rigCameras[0]._getVRProjectionMatrix,
  128509. a._rigCameras[1]._cameraRigParams.vrMetrics = i,
  128510. a._rigCameras[1].viewport = new Viewport(.5,0,.5,1),
  128511. a._rigCameras[1]._cameraRigParams.vrWorkMatrix = new Matrix,
  128512. a._rigCameras[1]._cameraRigParams.vrHMatrix = i.rightHMatrix,
  128513. a._rigCameras[1]._cameraRigParams.vrPreViewMatrix = i.rightPreViewMatrix,
  128514. a._rigCameras[1].getProjectionMatrix = a._rigCameras[1]._getVRProjectionMatrix,
  128515. i.multiviewEnabled && (a.getScene().getEngine().getCaps().multiview ? (a._useMultiviewToSingleView = !0,
  128516. a._rigPostProcess = new VRMultiviewToSingleviewPostProcess("VRMultiviewToSingleview",a,i.postProcessScaleFactor)) : (Logger$2.Warn("Multiview is not supported, falling back to standard rendering"),
  128517. i.multiviewEnabled = !1)),
  128518. i.compensateDistortion && (a._rigCameras[0]._rigPostProcess = new VRDistortionCorrectionPostProcess("VR_Distort_Compensation_Left",a._rigCameras[0],!1,i),
  128519. a._rigCameras[1]._rigPostProcess = new VRDistortionCorrectionPostProcess("VR_Distort_Compensation_Right",a._rigCameras[1],!0,i))
  128520. }
  128521. Node$2.AddNodeConstructor("VRDeviceOrientationFreeCamera", function(a, e) {
  128522. return function() {
  128523. return new VRDeviceOrientationFreeCamera(a,Vector3.Zero(),e)
  128524. }
  128525. });
  128526. var VRDeviceOrientationFreeCamera = function(a) {
  128527. __extends(e, a);
  128528. function e(i, o, s, c, d) {
  128529. c === void 0 && (c = !0),
  128530. d === void 0 && (d = VRCameraMetrics.GetDefault());
  128531. var _ = a.call(this, i, o, s) || this;
  128532. return _._setRigMode = setVRRigMode.bind(null, _),
  128533. d.compensateDistortion = c,
  128534. _.setCameraRigMode(Camera$1.RIG_MODE_VR, {
  128535. vrCameraMetrics: d
  128536. }),
  128537. _
  128538. }
  128539. return e.prototype.getClassName = function() {
  128540. return "VRDeviceOrientationFreeCamera"
  128541. }
  128542. ,
  128543. e
  128544. }(DeviceOrientationCamera), Gamepad = function() {
  128545. function a(e, i, o, s, c, d, _) {
  128546. s === void 0 && (s = 0),
  128547. c === void 0 && (c = 1),
  128548. d === void 0 && (d = 2),
  128549. _ === void 0 && (_ = 3),
  128550. this.id = e,
  128551. this.index = i,
  128552. this.browserGamepad = o,
  128553. this._leftStick = {
  128554. x: 0,
  128555. y: 0
  128556. },
  128557. this._rightStick = {
  128558. x: 0,
  128559. y: 0
  128560. },
  128561. this._isConnected = !0,
  128562. this._invertLeftStickY = !1,
  128563. this.type = a.GAMEPAD,
  128564. this._leftStickAxisX = s,
  128565. this._leftStickAxisY = c,
  128566. this._rightStickAxisX = d,
  128567. this._rightStickAxisY = _,
  128568. this.browserGamepad.axes.length >= 2 && (this._leftStick = {
  128569. x: this.browserGamepad.axes[this._leftStickAxisX],
  128570. y: this.browserGamepad.axes[this._leftStickAxisY]
  128571. }),
  128572. this.browserGamepad.axes.length >= 4 && (this._rightStick = {
  128573. x: this.browserGamepad.axes[this._rightStickAxisX],
  128574. y: this.browserGamepad.axes[this._rightStickAxisY]
  128575. })
  128576. }
  128577. return Object.defineProperty(a.prototype, "isConnected", {
  128578. get: function() {
  128579. return this._isConnected
  128580. },
  128581. enumerable: !1,
  128582. configurable: !0
  128583. }),
  128584. a.prototype.onleftstickchanged = function(e) {
  128585. this._onleftstickchanged = e
  128586. }
  128587. ,
  128588. a.prototype.onrightstickchanged = function(e) {
  128589. this._onrightstickchanged = e
  128590. }
  128591. ,
  128592. Object.defineProperty(a.prototype, "leftStick", {
  128593. get: function() {
  128594. return this._leftStick
  128595. },
  128596. set: function(e) {
  128597. this._onleftstickchanged && (this._leftStick.x !== e.x || this._leftStick.y !== e.y) && this._onleftstickchanged(e),
  128598. this._leftStick = e
  128599. },
  128600. enumerable: !1,
  128601. configurable: !0
  128602. }),
  128603. Object.defineProperty(a.prototype, "rightStick", {
  128604. get: function() {
  128605. return this._rightStick
  128606. },
  128607. set: function(e) {
  128608. this._onrightstickchanged && (this._rightStick.x !== e.x || this._rightStick.y !== e.y) && this._onrightstickchanged(e),
  128609. this._rightStick = e
  128610. },
  128611. enumerable: !1,
  128612. configurable: !0
  128613. }),
  128614. a.prototype.update = function() {
  128615. this._leftStick && (this.leftStick = {
  128616. x: this.browserGamepad.axes[this._leftStickAxisX],
  128617. y: this.browserGamepad.axes[this._leftStickAxisY]
  128618. },
  128619. this._invertLeftStickY && (this.leftStick.y *= -1)),
  128620. this._rightStick && (this.rightStick = {
  128621. x: this.browserGamepad.axes[this._rightStickAxisX],
  128622. y: this.browserGamepad.axes[this._rightStickAxisY]
  128623. })
  128624. }
  128625. ,
  128626. a.prototype.dispose = function() {}
  128627. ,
  128628. a.GAMEPAD = 0,
  128629. a.GENERIC = 1,
  128630. a.XBOX = 2,
  128631. a.POSE_ENABLED = 3,
  128632. a.DUALSHOCK = 4,
  128633. a
  128634. }(), GenericPad = function(a) {
  128635. __extends(e, a);
  128636. function e(i, o, s) {
  128637. var c = a.call(this, i, o, s) || this;
  128638. return c.onButtonDownObservable = new Observable,
  128639. c.onButtonUpObservable = new Observable,
  128640. c.type = Gamepad.GENERIC,
  128641. c._buttons = new Array(s.buttons.length),
  128642. c
  128643. }
  128644. return e.prototype.onbuttondown = function(i) {
  128645. this._onbuttondown = i
  128646. }
  128647. ,
  128648. e.prototype.onbuttonup = function(i) {
  128649. this._onbuttonup = i
  128650. }
  128651. ,
  128652. e.prototype._setButtonValue = function(i, o, s) {
  128653. return i !== o && (i === 1 && (this._onbuttondown && this._onbuttondown(s),
  128654. this.onButtonDownObservable.notifyObservers(s)),
  128655. i === 0 && (this._onbuttonup && this._onbuttonup(s),
  128656. this.onButtonUpObservable.notifyObservers(s))),
  128657. i
  128658. }
  128659. ,
  128660. e.prototype.update = function() {
  128661. a.prototype.update.call(this);
  128662. for (var i = 0; i < this._buttons.length; i++)
  128663. this._buttons[i] = this._setButtonValue(this.browserGamepad.buttons[i].value, this._buttons[i], i)
  128664. }
  128665. ,
  128666. e.prototype.dispose = function() {
  128667. a.prototype.dispose.call(this),
  128668. this.onButtonDownObservable.clear(),
  128669. this.onButtonUpObservable.clear()
  128670. }
  128671. ,
  128672. e
  128673. }(Gamepad), PoseEnabledControllerType;
  128674. (function(a) {
  128675. a[a.VIVE = 0] = "VIVE",
  128676. a[a.OCULUS = 1] = "OCULUS",
  128677. a[a.WINDOWS = 2] = "WINDOWS",
  128678. a[a.GEAR_VR = 3] = "GEAR_VR",
  128679. a[a.DAYDREAM = 4] = "DAYDREAM",
  128680. a[a.GENERIC = 5] = "GENERIC"
  128681. }
  128682. )(PoseEnabledControllerType || (PoseEnabledControllerType = {}));
  128683. var PoseEnabledControllerHelper = function() {
  128684. function a() {}
  128685. return a.InitiateController = function(e) {
  128686. for (var i = 0, o = this._ControllerFactories; i < o.length; i++) {
  128687. var s = o[i];
  128688. if (s.canCreate(e))
  128689. return s.create(e)
  128690. }
  128691. if (this._DefaultControllerFactory)
  128692. return this._DefaultControllerFactory(e);
  128693. throw "The type of gamepad you are trying to load needs to be imported first or is not supported."
  128694. }
  128695. ,
  128696. a._ControllerFactories = [],
  128697. a._DefaultControllerFactory = null,
  128698. a
  128699. }()
  128700. , PoseEnabledController = function(a) {
  128701. __extends(e, a);
  128702. function e(i) {
  128703. var o = a.call(this, i.id, i.index, i) || this;
  128704. return o.isXR = !1,
  128705. o._deviceRoomPosition = Vector3.Zero(),
  128706. o._deviceRoomRotationQuaternion = new Quaternion,
  128707. o.devicePosition = Vector3.Zero(),
  128708. o.deviceRotationQuaternion = new Quaternion,
  128709. o.deviceScaleFactor = 1,
  128710. o._trackPosition = !0,
  128711. o._maxRotationDistFromHeadset = Math.PI / 5,
  128712. o._draggedRoomRotation = 0,
  128713. o._leftHandSystemQuaternion = new Quaternion,
  128714. o._deviceToWorld = Matrix.Identity(),
  128715. o._pointingPoseNode = null,
  128716. o._workingMatrix = Matrix.Identity(),
  128717. o._meshAttachedObservable = new Observable,
  128718. o.type = Gamepad.POSE_ENABLED,
  128719. o.controllerType = PoseEnabledControllerType.GENERIC,
  128720. o.position = Vector3.Zero(),
  128721. o.rotationQuaternion = new Quaternion,
  128722. o._calculatedPosition = Vector3.Zero(),
  128723. o._calculatedRotation = new Quaternion,
  128724. Quaternion.RotationYawPitchRollToRef(Math.PI, 0, 0, o._leftHandSystemQuaternion),
  128725. o
  128726. }
  128727. return e.prototype._disableTrackPosition = function(i) {
  128728. this._trackPosition && (this._calculatedPosition.copyFrom(i),
  128729. this._trackPosition = !1)
  128730. }
  128731. ,
  128732. e.prototype.update = function() {
  128733. a.prototype.update.call(this),
  128734. this._updatePoseAndMesh()
  128735. }
  128736. ,
  128737. e.prototype._updatePoseAndMesh = function() {
  128738. if (!this.isXR) {
  128739. var i = this.browserGamepad.pose;
  128740. if (this.updateFromDevice(i),
  128741. !this._trackPosition && EngineStore.LastCreatedScene && EngineStore.LastCreatedScene.activeCamera && EngineStore.LastCreatedScene.activeCamera.devicePosition) {
  128742. var o = EngineStore.LastCreatedScene.activeCamera;
  128743. if (o._computeDevicePosition(),
  128744. this._deviceToWorld.setTranslation(o.devicePosition),
  128745. o.deviceRotationQuaternion) {
  128746. var o = o;
  128747. o._deviceRoomRotationQuaternion.toEulerAnglesToRef(TmpVectors.Vector3[0]);
  128748. var s = Math.atan2(Math.sin(TmpVectors.Vector3[0].y - this._draggedRoomRotation), Math.cos(TmpVectors.Vector3[0].y - this._draggedRoomRotation));
  128749. if (Math.abs(s) > this._maxRotationDistFromHeadset) {
  128750. var c = s - (s < 0 ? -this._maxRotationDistFromHeadset : this._maxRotationDistFromHeadset);
  128751. this._draggedRoomRotation += c;
  128752. var d = Math.sin(-c)
  128753. , _ = Math.cos(-c);
  128754. this._calculatedPosition.x = this._calculatedPosition.x * _ - this._calculatedPosition.z * d,
  128755. this._calculatedPosition.z = this._calculatedPosition.x * d + this._calculatedPosition.z * _
  128756. }
  128757. }
  128758. }
  128759. Vector3.TransformCoordinatesToRef(this._calculatedPosition, this._deviceToWorld, this.devicePosition),
  128760. this._deviceToWorld.getRotationMatrixToRef(this._workingMatrix),
  128761. Quaternion.FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion),
  128762. this.deviceRotationQuaternion.multiplyInPlace(this._calculatedRotation),
  128763. this._mesh && (this._mesh.position.copyFrom(this.devicePosition),
  128764. this._mesh.rotationQuaternion && this._mesh.rotationQuaternion.copyFrom(this.deviceRotationQuaternion))
  128765. }
  128766. }
  128767. ,
  128768. e.prototype.updateFromDevice = function(i) {
  128769. if (!this.isXR && i) {
  128770. this.rawPose = i,
  128771. i.position && (this._deviceRoomPosition.copyFromFloats(i.position[0], i.position[1], -i.position[2]),
  128772. this._mesh && this._mesh.getScene().useRightHandedSystem && (this._deviceRoomPosition.z *= -1),
  128773. this._trackPosition && this._deviceRoomPosition.scaleToRef(this.deviceScaleFactor, this._calculatedPosition),
  128774. this._calculatedPosition.addInPlace(this.position));
  128775. var o = this.rawPose;
  128776. i.orientation && o.orientation && o.orientation.length === 4 && (this._deviceRoomRotationQuaternion.copyFromFloats(o.orientation[0], o.orientation[1], -o.orientation[2], -o.orientation[3]),
  128777. this._mesh && (this._mesh.getScene().useRightHandedSystem ? (this._deviceRoomRotationQuaternion.z *= -1,
  128778. this._deviceRoomRotationQuaternion.w *= -1) : this._deviceRoomRotationQuaternion.multiplyToRef(this._leftHandSystemQuaternion, this._deviceRoomRotationQuaternion)),
  128779. this._deviceRoomRotationQuaternion.multiplyToRef(this.rotationQuaternion, this._calculatedRotation))
  128780. }
  128781. }
  128782. ,
  128783. e.prototype.attachToMesh = function(i) {
  128784. if (this._mesh && (this._mesh.parent = null),
  128785. this._mesh = i,
  128786. this._poseControlledCamera && (this._mesh.parent = this._poseControlledCamera),
  128787. this._mesh.rotationQuaternion || (this._mesh.rotationQuaternion = new Quaternion),
  128788. !this.isXR && (this._updatePoseAndMesh(),
  128789. this._pointingPoseNode)) {
  128790. for (var o = [], s = this._pointingPoseNode; s.parent; )
  128791. o.push(s.parent),
  128792. s = s.parent;
  128793. o.reverse().forEach(function(c) {
  128794. c.computeWorldMatrix(!0)
  128795. })
  128796. }
  128797. this._meshAttachedObservable.notifyObservers(i)
  128798. }
  128799. ,
  128800. e.prototype.attachToPoseControlledCamera = function(i) {
  128801. this._poseControlledCamera = i,
  128802. this._mesh && (this._mesh.parent = this._poseControlledCamera)
  128803. }
  128804. ,
  128805. e.prototype.dispose = function() {
  128806. this._mesh && this._mesh.dispose(),
  128807. this._mesh = null,
  128808. a.prototype.dispose.call(this)
  128809. }
  128810. ,
  128811. Object.defineProperty(e.prototype, "mesh", {
  128812. get: function() {
  128813. return this._mesh
  128814. },
  128815. enumerable: !1,
  128816. configurable: !0
  128817. }),
  128818. e.prototype.getForwardRay = function(i) {
  128819. if (i === void 0 && (i = 100),
  128820. !this.mesh)
  128821. return new Ray(Vector3.Zero(),new Vector3(0,0,1),i);
  128822. var o = this._pointingPoseNode ? this._pointingPoseNode.getWorldMatrix() : this.mesh.getWorldMatrix()
  128823. , s = o.getTranslation()
  128824. , c = new Vector3(0,0,-1)
  128825. , d = Vector3.TransformNormal(c, o)
  128826. , _ = Vector3.Normalize(d);
  128827. return new Ray(s,_,i)
  128828. }
  128829. ,
  128830. e.POINTING_POSE = "POINTING_POSE",
  128831. e
  128832. }(Gamepad);
  128833. function setWebVRRigMode(a, e) {
  128834. if (e.vrDisplay) {
  128835. var i = e.vrDisplay.getEyeParameters("left")
  128836. , o = e.vrDisplay.getEyeParameters("right");
  128837. a._rigCameras[0].viewport = new Viewport(0,0,.5,1),
  128838. a._rigCameras[0].setCameraRigParameter("left", !0),
  128839. a._rigCameras[0].setCameraRigParameter("specs", e.specs),
  128840. a._rigCameras[0].setCameraRigParameter("eyeParameters", i),
  128841. a._rigCameras[0].setCameraRigParameter("frameData", e.frameData),
  128842. a._rigCameras[0].setCameraRigParameter("parentCamera", e.parentCamera),
  128843. a._rigCameras[0]._cameraRigParams.vrWorkMatrix = new Matrix,
  128844. a._rigCameras[0].getProjectionMatrix = a._getWebVRProjectionMatrix,
  128845. a._rigCameras[0].parent = a,
  128846. a._rigCameras[0]._getViewMatrix = a._getWebVRViewMatrix,
  128847. a._rigCameras[1].viewport = new Viewport(.5,0,.5,1),
  128848. a._rigCameras[1].setCameraRigParameter("eyeParameters", o),
  128849. a._rigCameras[1].setCameraRigParameter("specs", e.specs),
  128850. a._rigCameras[1].setCameraRigParameter("frameData", e.frameData),
  128851. a._rigCameras[1].setCameraRigParameter("parentCamera", e.parentCamera),
  128852. a._rigCameras[1]._cameraRigParams.vrWorkMatrix = new Matrix,
  128853. a._rigCameras[1].getProjectionMatrix = a._getWebVRProjectionMatrix,
  128854. a._rigCameras[1].parent = a,
  128855. a._rigCameras[1]._getViewMatrix = a._getWebVRViewMatrix
  128856. }
  128857. }
  128858. Node$2.AddNodeConstructor("WebVRFreeCamera", function(a, e) {
  128859. return function() {
  128860. return new WebVRFreeCamera(a,Vector3.Zero(),e)
  128861. }
  128862. });
  128863. Node$2.AddNodeConstructor("WebVRGamepadCamera", function(a, e) {
  128864. return function() {
  128865. return new WebVRFreeCamera(a,Vector3.Zero(),e)
  128866. }
  128867. });
  128868. var WebVRFreeCamera = function(a) {
  128869. __extends(e, a);
  128870. function e(i, o, s, c) {
  128871. c === void 0 && (c = {});
  128872. var d = a.call(this, i, o, s) || this;
  128873. d.webVROptions = c,
  128874. d._vrDevice = null,
  128875. d.rawPose = null,
  128876. d._specsVersion = "1.1",
  128877. d._attached = !1,
  128878. d._descendants = [],
  128879. d._deviceRoomPosition = Vector3.Zero(),
  128880. d._deviceRoomRotationQuaternion = Quaternion.Identity(),
  128881. d._standingMatrix = null,
  128882. d.devicePosition = Vector3.Zero(),
  128883. d.deviceRotationQuaternion = Quaternion.Identity(),
  128884. d.deviceScaleFactor = 1,
  128885. d._deviceToWorld = Matrix.Identity(),
  128886. d._worldToDevice = Matrix.Identity(),
  128887. d.controllers = [],
  128888. d.onControllersAttachedObservable = new Observable,
  128889. d.onControllerMeshLoadedObservable = new Observable,
  128890. d.onPoseUpdatedFromDeviceObservable = new Observable,
  128891. d._poseSet = !1,
  128892. d.rigParenting = !0,
  128893. d._defaultHeight = void 0,
  128894. d._setRigMode = setWebVRRigMode.bind(null, d),
  128895. d._detachIfAttached = function() {
  128896. var b = d.getEngine().getVRDevice();
  128897. b && !b.isPresenting && d.detachControl()
  128898. }
  128899. ,
  128900. d._workingVector = Vector3.Zero(),
  128901. d._oneVector = Vector3.One(),
  128902. d._workingMatrix = Matrix.Identity(),
  128903. d._tmpMatrix = new Matrix,
  128904. d._cache.position = Vector3.Zero(),
  128905. c.defaultHeight && (d._defaultHeight = c.defaultHeight,
  128906. d.position.y = d._defaultHeight),
  128907. d.minZ = .1,
  128908. arguments.length === 5 && (d.webVROptions = arguments[4]),
  128909. d.webVROptions.trackPosition == null && (d.webVROptions.trackPosition = !0),
  128910. d.webVROptions.controllerMeshes == null && (d.webVROptions.controllerMeshes = !0),
  128911. d.webVROptions.defaultLightingOnControllers == null && (d.webVROptions.defaultLightingOnControllers = !0),
  128912. d.rotationQuaternion = new Quaternion,
  128913. d.webVROptions && d.webVROptions.positionScale && (d.deviceScaleFactor = d.webVROptions.positionScale);
  128914. var _ = d.getEngine();
  128915. return d._onVREnabled = function(b) {
  128916. b && d.initControllers()
  128917. }
  128918. ,
  128919. _.onVRRequestPresentComplete.add(d._onVREnabled),
  128920. _.initWebVR().add(function(b) {
  128921. !b.vrDisplay || d._vrDevice === b.vrDisplay || (d._vrDevice = b.vrDisplay,
  128922. d.setCameraRigMode(Camera$1.RIG_MODE_WEBVR, {
  128923. parentCamera: d,
  128924. vrDisplay: d._vrDevice,
  128925. frameData: d._frameData,
  128926. specs: d._specsVersion
  128927. }),
  128928. d._attached && d.getEngine().enableVR(d.webVROptions))
  128929. }),
  128930. typeof VRFrameData != "undefined" && (d._frameData = new VRFrameData),
  128931. c.useMultiview && (d.getScene().getEngine().getCaps().multiview ? (d._useMultiviewToSingleView = !0,
  128932. d._rigPostProcess = new VRMultiviewToSingleviewPostProcess("VRMultiviewToSingleview",d,1)) : (Logger$2.Warn("Multiview is not supported, falling back to standard rendering"),
  128933. d._useMultiviewToSingleView = !1)),
  128934. s.onBeforeCameraRenderObservable.add(function(b) {
  128935. b.parent === d && d.rigParenting && (d._descendants = d.getDescendants(!0, function(k) {
  128936. var j = d.controllers.some(function(_e) {
  128937. return _e._mesh === k
  128938. })
  128939. , $ = d._rigCameras.indexOf(k) !== -1;
  128940. return !j && !$
  128941. }),
  128942. d._descendants.forEach(function(k) {
  128943. k.parent = b
  128944. }))
  128945. }),
  128946. s.onAfterCameraRenderObservable.add(function(b) {
  128947. b.parent === d && d.rigParenting && d._descendants.forEach(function(k) {
  128948. k.parent = d
  128949. })
  128950. }),
  128951. d
  128952. }
  128953. return e.prototype.deviceDistanceToRoomGround = function() {
  128954. return this._standingMatrix ? (this._standingMatrix.getTranslationToRef(this._workingVector),
  128955. this._deviceRoomPosition.y + this._workingVector.y) : this._defaultHeight || 0
  128956. }
  128957. ,
  128958. e.prototype.useStandingMatrix = function(i) {
  128959. var o = this;
  128960. i === void 0 && (i = function(s) {}
  128961. ),
  128962. this.getEngine().initWebVRAsync().then(function(s) {
  128963. !s.vrDisplay || !s.vrDisplay.stageParameters || !s.vrDisplay.stageParameters.sittingToStandingTransform || !o.webVROptions.trackPosition ? i(!1) : (o._standingMatrix = new Matrix,
  128964. Matrix.FromFloat32ArrayToRefScaled(s.vrDisplay.stageParameters.sittingToStandingTransform, 0, 1, o._standingMatrix),
  128965. o.getScene().useRightHandedSystem || o._standingMatrix && o._standingMatrix.toggleModelMatrixHandInPlace(),
  128966. i(!0))
  128967. })
  128968. }
  128969. ,
  128970. e.prototype.useStandingMatrixAsync = function() {
  128971. var i = this;
  128972. return new Promise(function(o) {
  128973. i.useStandingMatrix(function(s) {
  128974. o(s)
  128975. })
  128976. }
  128977. )
  128978. }
  128979. ,
  128980. e.prototype.dispose = function() {
  128981. this._detachIfAttached(),
  128982. this.getEngine().onVRRequestPresentComplete.removeCallback(this._onVREnabled),
  128983. this._updateCacheWhenTrackingDisabledObserver && this._scene.onBeforeRenderObservable.remove(this._updateCacheWhenTrackingDisabledObserver),
  128984. a.prototype.dispose.call(this)
  128985. }
  128986. ,
  128987. e.prototype.getControllerByName = function(i) {
  128988. for (var o = 0, s = this.controllers; o < s.length; o++) {
  128989. var c = s[o];
  128990. if (c.hand === i)
  128991. return c
  128992. }
  128993. return null
  128994. }
  128995. ,
  128996. Object.defineProperty(e.prototype, "leftController", {
  128997. get: function() {
  128998. return this._leftController || (this._leftController = this.getControllerByName("left")),
  128999. this._leftController
  129000. },
  129001. enumerable: !1,
  129002. configurable: !0
  129003. }),
  129004. Object.defineProperty(e.prototype, "rightController", {
  129005. get: function() {
  129006. return this._rightController || (this._rightController = this.getControllerByName("right")),
  129007. this._rightController
  129008. },
  129009. enumerable: !1,
  129010. configurable: !0
  129011. }),
  129012. e.prototype.getForwardRay = function(i) {
  129013. return i === void 0 && (i = 100),
  129014. this.leftCamera ? a.prototype.getForwardRay.call(this, i, this.leftCamera.getWorldMatrix(), this.leftCamera.globalPosition) : a.prototype.getForwardRay.call(this, i)
  129015. }
  129016. ,
  129017. e.prototype._checkInputs = function() {
  129018. this._vrDevice && this._vrDevice.isPresenting && (this._vrDevice.getFrameData(this._frameData),
  129019. this.updateFromDevice(this._frameData.pose)),
  129020. a.prototype._checkInputs.call(this)
  129021. }
  129022. ,
  129023. e.prototype.updateFromDevice = function(i) {
  129024. i && i.orientation && i.orientation.length === 4 && (this.rawPose = i,
  129025. this._deviceRoomRotationQuaternion.copyFromFloats(i.orientation[0], i.orientation[1], -i.orientation[2], -i.orientation[3]),
  129026. this.getScene().useRightHandedSystem && (this._deviceRoomRotationQuaternion.z *= -1,
  129027. this._deviceRoomRotationQuaternion.w *= -1),
  129028. this.webVROptions.trackPosition && this.rawPose.position && (this._deviceRoomPosition.copyFromFloats(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2]),
  129029. this.getScene().useRightHandedSystem && (this._deviceRoomPosition.z *= -1)),
  129030. this._poseSet = !0)
  129031. }
  129032. ,
  129033. e.prototype.attachControl = function(i) {
  129034. i = Tools.BackCompatCameraNoPreventDefault(arguments),
  129035. a.prototype.attachControl.call(this, i),
  129036. this._attached = !0,
  129037. i = Camera$1.ForceAttachControlToAlwaysPreventDefault ? !1 : i,
  129038. this._vrDevice && this.getEngine().enableVR(this.webVROptions);
  129039. var o = this._scene.getEngine().getHostWindow();
  129040. o && o.addEventListener("vrdisplaypresentchange", this._detachIfAttached)
  129041. }
  129042. ,
  129043. e.prototype.detachControl = function(i) {
  129044. this.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver),
  129045. this.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver),
  129046. a.prototype.detachControl.call(this),
  129047. this._attached = !1,
  129048. this.getEngine().disableVR(),
  129049. window.removeEventListener("vrdisplaypresentchange", this._detachIfAttached)
  129050. }
  129051. ,
  129052. e.prototype.getClassName = function() {
  129053. return "WebVRFreeCamera"
  129054. }
  129055. ,
  129056. e.prototype.resetToCurrentRotation = function() {
  129057. this._vrDevice.resetPose()
  129058. }
  129059. ,
  129060. e.prototype._updateRigCameras = function() {
  129061. var i = this._rigCameras[0]
  129062. , o = this._rigCameras[1];
  129063. i.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion),
  129064. o.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion),
  129065. i.position.copyFrom(this._deviceRoomPosition),
  129066. o.position.copyFrom(this._deviceRoomPosition)
  129067. }
  129068. ,
  129069. e.prototype._correctPositionIfNotTrackPosition = function(i, o) {
  129070. o === void 0 && (o = !1),
  129071. this.rawPose && this.rawPose.position && !this.webVROptions.trackPosition && (Matrix.TranslationToRef(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2], this._tmpMatrix),
  129072. o || this._tmpMatrix.invert(),
  129073. this._tmpMatrix.multiplyToRef(i, i))
  129074. }
  129075. ,
  129076. e.prototype._updateCache = function(i) {
  129077. var o = this;
  129078. (!this.rotationQuaternion.equals(this._cache.rotationQuaternion) || !this.position.equals(this._cache.position)) && (this.updateCacheCalled || (this.updateCacheCalled = !0,
  129079. this.update()),
  129080. this.rotationQuaternion.toRotationMatrix(this._workingMatrix),
  129081. Vector3.TransformCoordinatesToRef(this._deviceRoomPosition, this._workingMatrix, this._workingVector),
  129082. this.devicePosition.subtractToRef(this._workingVector, this._workingVector),
  129083. Matrix.ComposeToRef(this._oneVector, this.rotationQuaternion, this._workingVector, this._deviceToWorld),
  129084. this._deviceToWorld.getTranslationToRef(this._workingVector),
  129085. this._workingVector.addInPlace(this.position),
  129086. this._workingVector.subtractInPlace(this._cache.position),
  129087. this._deviceToWorld.setTranslation(this._workingVector),
  129088. this._deviceToWorld.invertToRef(this._worldToDevice),
  129089. this.controllers.forEach(function(s) {
  129090. s._deviceToWorld.copyFrom(o._deviceToWorld),
  129091. o._correctPositionIfNotTrackPosition(s._deviceToWorld),
  129092. s.update()
  129093. })),
  129094. i || a.prototype._updateCache.call(this),
  129095. this.updateCacheCalled = !1
  129096. }
  129097. ,
  129098. e.prototype._computeDevicePosition = function() {
  129099. Vector3.TransformCoordinatesToRef(this._deviceRoomPosition, this._deviceToWorld, this.devicePosition)
  129100. }
  129101. ,
  129102. e.prototype.update = function() {
  129103. this._computeDevicePosition(),
  129104. Matrix.FromQuaternionToRef(this._deviceRoomRotationQuaternion, this._workingMatrix),
  129105. this._workingMatrix.multiplyToRef(this._deviceToWorld, this._workingMatrix),
  129106. Quaternion.FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion),
  129107. this._poseSet && this.onPoseUpdatedFromDeviceObservable.notifyObservers(null),
  129108. a.prototype.update.call(this)
  129109. }
  129110. ,
  129111. e.prototype._getViewMatrix = function() {
  129112. return Matrix.Identity()
  129113. }
  129114. ,
  129115. e.prototype._getWebVRViewMatrix = function() {
  129116. var i = this._cameraRigParams.parentCamera;
  129117. i._updateCache();
  129118. var o = this._cameraRigParams.left ? this._cameraRigParams.frameData.leftViewMatrix : this._cameraRigParams.frameData.rightViewMatrix;
  129119. return Matrix.FromArrayToRef(o, 0, this._webvrViewMatrix),
  129120. this.getScene().useRightHandedSystem || this._webvrViewMatrix.toggleModelMatrixHandInPlace(),
  129121. this._webvrViewMatrix.getRotationMatrixToRef(this._cameraRotationMatrix),
  129122. Vector3.TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint),
  129123. this.position.addToRef(this._transformedReferencePoint, this._currentTarget),
  129124. i.deviceScaleFactor !== 1 && (this._webvrViewMatrix.invert(),
  129125. i.deviceScaleFactor && (this._webvrViewMatrix.multiplyAtIndex(12, i.deviceScaleFactor),
  129126. this._webvrViewMatrix.multiplyAtIndex(13, i.deviceScaleFactor),
  129127. this._webvrViewMatrix.multiplyAtIndex(14, i.deviceScaleFactor)),
  129128. this._webvrViewMatrix.invert()),
  129129. i._correctPositionIfNotTrackPosition(this._webvrViewMatrix, !0),
  129130. i._worldToDevice.multiplyToRef(this._webvrViewMatrix, this._webvrViewMatrix),
  129131. this._workingMatrix = this._workingMatrix || Matrix.Identity(),
  129132. this._webvrViewMatrix.invertToRef(this._workingMatrix),
  129133. this._workingMatrix.multiplyToRef(i.getWorldMatrix(), this._workingMatrix),
  129134. this._workingMatrix.getTranslationToRef(this._globalPosition),
  129135. this._markSyncedWithParent(),
  129136. this._webvrViewMatrix
  129137. }
  129138. ,
  129139. e.prototype._getWebVRProjectionMatrix = function() {
  129140. var i = this.parent;
  129141. i._vrDevice.depthNear = i.minZ,
  129142. i._vrDevice.depthFar = i.maxZ;
  129143. var o = this._cameraRigParams.left ? this._cameraRigParams.frameData.leftProjectionMatrix : this._cameraRigParams.frameData.rightProjectionMatrix;
  129144. return Matrix.FromArrayToRef(o, 0, this._projectionMatrix),
  129145. this.getScene().useRightHandedSystem || this._projectionMatrix.toggleProjectionMatrixHandInPlace(),
  129146. this._projectionMatrix
  129147. }
  129148. ,
  129149. e.prototype.initControllers = function() {
  129150. var i = this;
  129151. this.controllers = [];
  129152. var o = this.getScene().gamepadManager;
  129153. this._onGamepadDisconnectedObserver = o.onGamepadDisconnectedObservable.add(function(s) {
  129154. if (s.type === Gamepad.POSE_ENABLED) {
  129155. var c = s;
  129156. c.defaultModel && c.defaultModel.setEnabled(!1),
  129157. c.hand === "right" && (i._rightController = null),
  129158. c.hand === "left" && (i._leftController = null);
  129159. var d = i.controllers.indexOf(c);
  129160. d !== -1 && i.controllers.splice(d, 1)
  129161. }
  129162. }),
  129163. this._onGamepadConnectedObserver = o.onGamepadConnectedObservable.add(function(s) {
  129164. if (s.type === Gamepad.POSE_ENABLED) {
  129165. var c = s;
  129166. if (i.webVROptions.trackPosition || (c._disableTrackPosition(new Vector3(c.hand == "left" ? -.15 : .15,-.5,.25)),
  129167. i._updateCacheWhenTrackingDisabledObserver || (i._updateCacheWhenTrackingDisabledObserver = i._scene.onBeforeRenderObservable.add(function() {
  129168. i._updateCache()
  129169. }))),
  129170. c.deviceScaleFactor = i.deviceScaleFactor,
  129171. c._deviceToWorld.copyFrom(i._deviceToWorld),
  129172. i._correctPositionIfNotTrackPosition(c._deviceToWorld),
  129173. i.webVROptions.controllerMeshes && (c.defaultModel ? c.defaultModel.setEnabled(!0) : c.initControllerMesh(i.getScene(), function(b) {
  129174. if (b.scaling.scaleInPlace(i.deviceScaleFactor),
  129175. i.onControllerMeshLoadedObservable.notifyObservers(c),
  129176. i.webVROptions.defaultLightingOnControllers) {
  129177. i._lightOnControllers || (i._lightOnControllers = new HemisphericLight("vrControllersLight",new Vector3(0,1,0),i.getScene()));
  129178. var k = function(j, $) {
  129179. var _e = j.getChildren();
  129180. _e && _e.length !== 0 && _e.forEach(function(et) {
  129181. $.includedOnlyMeshes.push(et),
  129182. k(et, $)
  129183. })
  129184. };
  129185. i._lightOnControllers.includedOnlyMeshes.push(b),
  129186. k(b, i._lightOnControllers)
  129187. }
  129188. })),
  129189. c.attachToPoseControlledCamera(i),
  129190. i.controllers.indexOf(c) === -1) {
  129191. i.controllers.push(c);
  129192. for (var d = !1, _ = 0; _ < i.controllers.length; _++)
  129193. i.controllers[_].controllerType === PoseEnabledControllerType.VIVE && (d ? i.controllers[_].hand = "right" : (d = !0,
  129194. i.controllers[_].hand = "left"));
  129195. i.controllers.length >= 2 && i.onControllersAttachedObservable.notifyObservers(i.controllers)
  129196. }
  129197. }
  129198. })
  129199. }
  129200. ,
  129201. e
  129202. }(FreeCamera), WebVRController = function(a) {
  129203. __extends(e, a);
  129204. function e(i) {
  129205. var o = a.call(this, i) || this;
  129206. return o.onTriggerStateChangedObservable = new Observable,
  129207. o.onMainButtonStateChangedObservable = new Observable,
  129208. o.onSecondaryButtonStateChangedObservable = new Observable,
  129209. o.onPadStateChangedObservable = new Observable,
  129210. o.onPadValuesChangedObservable = new Observable,
  129211. o.pad = {
  129212. x: 0,
  129213. y: 0
  129214. },
  129215. o._changes = {
  129216. pressChanged: !1,
  129217. touchChanged: !1,
  129218. valueChanged: !1,
  129219. changed: !1
  129220. },
  129221. o._buttons = new Array(i.buttons.length),
  129222. o.hand = i.hand,
  129223. o
  129224. }
  129225. return e.prototype.onButtonStateChange = function(i) {
  129226. this._onButtonStateChange = i
  129227. }
  129228. ,
  129229. Object.defineProperty(e.prototype, "defaultModel", {
  129230. get: function() {
  129231. return this._defaultModel
  129232. },
  129233. enumerable: !1,
  129234. configurable: !0
  129235. }),
  129236. e.prototype.update = function() {
  129237. a.prototype.update.call(this);
  129238. for (var i = 0; i < this._buttons.length; i++)
  129239. this._setButtonValue(this.browserGamepad.buttons[i], this._buttons[i], i);
  129240. (this.leftStick.x !== this.pad.x || this.leftStick.y !== this.pad.y) && (this.pad.x = this.leftStick.x,
  129241. this.pad.y = this.leftStick.y,
  129242. this.onPadValuesChangedObservable.notifyObservers(this.pad))
  129243. }
  129244. ,
  129245. e.prototype._setButtonValue = function(i, o, s) {
  129246. if (i || (i = {
  129247. pressed: !1,
  129248. touched: !1,
  129249. value: 0
  129250. }),
  129251. !o) {
  129252. this._buttons[s] = {
  129253. pressed: i.pressed,
  129254. touched: i.touched,
  129255. value: i.value
  129256. };
  129257. return
  129258. }
  129259. this._checkChanges(i, o),
  129260. this._changes.changed && (this._onButtonStateChange && this._onButtonStateChange(this.index, s, i),
  129261. this._handleButtonChange(s, i, this._changes)),
  129262. this._buttons[s].pressed = i.pressed,
  129263. this._buttons[s].touched = i.touched,
  129264. this._buttons[s].value = i.value < 1e-8 ? 0 : i.value
  129265. }
  129266. ,
  129267. e.prototype._checkChanges = function(i, o) {
  129268. return this._changes.pressChanged = i.pressed !== o.pressed,
  129269. this._changes.touchChanged = i.touched !== o.touched,
  129270. this._changes.valueChanged = i.value !== o.value,
  129271. this._changes.changed = this._changes.pressChanged || this._changes.touchChanged || this._changes.valueChanged,
  129272. this._changes
  129273. }
  129274. ,
  129275. e.prototype.dispose = function() {
  129276. a.prototype.dispose.call(this),
  129277. this._defaultModel = null,
  129278. this.onTriggerStateChangedObservable.clear(),
  129279. this.onMainButtonStateChangedObservable.clear(),
  129280. this.onSecondaryButtonStateChangedObservable.clear(),
  129281. this.onPadStateChangedObservable.clear(),
  129282. this.onPadValuesChangedObservable.clear()
  129283. }
  129284. ,
  129285. e
  129286. }(PoseEnabledController), Xbox360Button;
  129287. (function(a) {
  129288. a[a.A = 0] = "A",
  129289. a[a.B = 1] = "B",
  129290. a[a.X = 2] = "X",
  129291. a[a.Y = 3] = "Y",
  129292. a[a.LB = 4] = "LB",
  129293. a[a.RB = 5] = "RB",
  129294. a[a.Back = 8] = "Back",
  129295. a[a.Start = 9] = "Start",
  129296. a[a.LeftStick = 10] = "LeftStick",
  129297. a[a.RightStick = 11] = "RightStick"
  129298. }
  129299. )(Xbox360Button || (Xbox360Button = {}));
  129300. var Xbox360Dpad;
  129301. (function(a) {
  129302. a[a.Up = 12] = "Up",
  129303. a[a.Down = 13] = "Down",
  129304. a[a.Left = 14] = "Left",
  129305. a[a.Right = 15] = "Right"
  129306. }
  129307. )(Xbox360Dpad || (Xbox360Dpad = {}));
  129308. var Xbox360Pad = function(a) {
  129309. __extends(e, a);
  129310. function e(i, o, s, c) {
  129311. c === void 0 && (c = !1);
  129312. var d = a.call(this, i, o, s, 0, 1, 2, 3) || this;
  129313. return d._leftTrigger = 0,
  129314. d._rightTrigger = 0,
  129315. d.onButtonDownObservable = new Observable,
  129316. d.onButtonUpObservable = new Observable,
  129317. d.onPadDownObservable = new Observable,
  129318. d.onPadUpObservable = new Observable,
  129319. d._buttonA = 0,
  129320. d._buttonB = 0,
  129321. d._buttonX = 0,
  129322. d._buttonY = 0,
  129323. d._buttonBack = 0,
  129324. d._buttonStart = 0,
  129325. d._buttonLB = 0,
  129326. d._buttonRB = 0,
  129327. d._buttonLeftStick = 0,
  129328. d._buttonRightStick = 0,
  129329. d._dPadUp = 0,
  129330. d._dPadDown = 0,
  129331. d._dPadLeft = 0,
  129332. d._dPadRight = 0,
  129333. d._isXboxOnePad = !1,
  129334. d.type = Gamepad.XBOX,
  129335. d._isXboxOnePad = c,
  129336. d
  129337. }
  129338. return e.prototype.onlefttriggerchanged = function(i) {
  129339. this._onlefttriggerchanged = i
  129340. }
  129341. ,
  129342. e.prototype.onrighttriggerchanged = function(i) {
  129343. this._onrighttriggerchanged = i
  129344. }
  129345. ,
  129346. Object.defineProperty(e.prototype, "leftTrigger", {
  129347. get: function() {
  129348. return this._leftTrigger
  129349. },
  129350. set: function(i) {
  129351. this._onlefttriggerchanged && this._leftTrigger !== i && this._onlefttriggerchanged(i),
  129352. this._leftTrigger = i
  129353. },
  129354. enumerable: !1,
  129355. configurable: !0
  129356. }),
  129357. Object.defineProperty(e.prototype, "rightTrigger", {
  129358. get: function() {
  129359. return this._rightTrigger
  129360. },
  129361. set: function(i) {
  129362. this._onrighttriggerchanged && this._rightTrigger !== i && this._onrighttriggerchanged(i),
  129363. this._rightTrigger = i
  129364. },
  129365. enumerable: !1,
  129366. configurable: !0
  129367. }),
  129368. e.prototype.onbuttondown = function(i) {
  129369. this._onbuttondown = i
  129370. }
  129371. ,
  129372. e.prototype.onbuttonup = function(i) {
  129373. this._onbuttonup = i
  129374. }
  129375. ,
  129376. e.prototype.ondpaddown = function(i) {
  129377. this._ondpaddown = i
  129378. }
  129379. ,
  129380. e.prototype.ondpadup = function(i) {
  129381. this._ondpadup = i
  129382. }
  129383. ,
  129384. e.prototype._setButtonValue = function(i, o, s) {
  129385. return i !== o && (i === 1 && (this._onbuttondown && this._onbuttondown(s),
  129386. this.onButtonDownObservable.notifyObservers(s)),
  129387. i === 0 && (this._onbuttonup && this._onbuttonup(s),
  129388. this.onButtonUpObservable.notifyObservers(s))),
  129389. i
  129390. }
  129391. ,
  129392. e.prototype._setDPadValue = function(i, o, s) {
  129393. return i !== o && (i === 1 && (this._ondpaddown && this._ondpaddown(s),
  129394. this.onPadDownObservable.notifyObservers(s)),
  129395. i === 0 && (this._ondpadup && this._ondpadup(s),
  129396. this.onPadUpObservable.notifyObservers(s))),
  129397. i
  129398. }
  129399. ,
  129400. Object.defineProperty(e.prototype, "buttonA", {
  129401. get: function() {
  129402. return this._buttonA
  129403. },
  129404. set: function(i) {
  129405. this._buttonA = this._setButtonValue(i, this._buttonA, Xbox360Button.A)
  129406. },
  129407. enumerable: !1,
  129408. configurable: !0
  129409. }),
  129410. Object.defineProperty(e.prototype, "buttonB", {
  129411. get: function() {
  129412. return this._buttonB
  129413. },
  129414. set: function(i) {
  129415. this._buttonB = this._setButtonValue(i, this._buttonB, Xbox360Button.B)
  129416. },
  129417. enumerable: !1,
  129418. configurable: !0
  129419. }),
  129420. Object.defineProperty(e.prototype, "buttonX", {
  129421. get: function() {
  129422. return this._buttonX
  129423. },
  129424. set: function(i) {
  129425. this._buttonX = this._setButtonValue(i, this._buttonX, Xbox360Button.X)
  129426. },
  129427. enumerable: !1,
  129428. configurable: !0
  129429. }),
  129430. Object.defineProperty(e.prototype, "buttonY", {
  129431. get: function() {
  129432. return this._buttonY
  129433. },
  129434. set: function(i) {
  129435. this._buttonY = this._setButtonValue(i, this._buttonY, Xbox360Button.Y)
  129436. },
  129437. enumerable: !1,
  129438. configurable: !0
  129439. }),
  129440. Object.defineProperty(e.prototype, "buttonStart", {
  129441. get: function() {
  129442. return this._buttonStart
  129443. },
  129444. set: function(i) {
  129445. this._buttonStart = this._setButtonValue(i, this._buttonStart, Xbox360Button.Start)
  129446. },
  129447. enumerable: !1,
  129448. configurable: !0
  129449. }),
  129450. Object.defineProperty(e.prototype, "buttonBack", {
  129451. get: function() {
  129452. return this._buttonBack
  129453. },
  129454. set: function(i) {
  129455. this._buttonBack = this._setButtonValue(i, this._buttonBack, Xbox360Button.Back)
  129456. },
  129457. enumerable: !1,
  129458. configurable: !0
  129459. }),
  129460. Object.defineProperty(e.prototype, "buttonLB", {
  129461. get: function() {
  129462. return this._buttonLB
  129463. },
  129464. set: function(i) {
  129465. this._buttonLB = this._setButtonValue(i, this._buttonLB, Xbox360Button.LB)
  129466. },
  129467. enumerable: !1,
  129468. configurable: !0
  129469. }),
  129470. Object.defineProperty(e.prototype, "buttonRB", {
  129471. get: function() {
  129472. return this._buttonRB
  129473. },
  129474. set: function(i) {
  129475. this._buttonRB = this._setButtonValue(i, this._buttonRB, Xbox360Button.RB)
  129476. },
  129477. enumerable: !1,
  129478. configurable: !0
  129479. }),
  129480. Object.defineProperty(e.prototype, "buttonLeftStick", {
  129481. get: function() {
  129482. return this._buttonLeftStick
  129483. },
  129484. set: function(i) {
  129485. this._buttonLeftStick = this._setButtonValue(i, this._buttonLeftStick, Xbox360Button.LeftStick)
  129486. },
  129487. enumerable: !1,
  129488. configurable: !0
  129489. }),
  129490. Object.defineProperty(e.prototype, "buttonRightStick", {
  129491. get: function() {
  129492. return this._buttonRightStick
  129493. },
  129494. set: function(i) {
  129495. this._buttonRightStick = this._setButtonValue(i, this._buttonRightStick, Xbox360Button.RightStick)
  129496. },
  129497. enumerable: !1,
  129498. configurable: !0
  129499. }),
  129500. Object.defineProperty(e.prototype, "dPadUp", {
  129501. get: function() {
  129502. return this._dPadUp
  129503. },
  129504. set: function(i) {
  129505. this._dPadUp = this._setDPadValue(i, this._dPadUp, Xbox360Dpad.Up)
  129506. },
  129507. enumerable: !1,
  129508. configurable: !0
  129509. }),
  129510. Object.defineProperty(e.prototype, "dPadDown", {
  129511. get: function() {
  129512. return this._dPadDown
  129513. },
  129514. set: function(i) {
  129515. this._dPadDown = this._setDPadValue(i, this._dPadDown, Xbox360Dpad.Down)
  129516. },
  129517. enumerable: !1,
  129518. configurable: !0
  129519. }),
  129520. Object.defineProperty(e.prototype, "dPadLeft", {
  129521. get: function() {
  129522. return this._dPadLeft
  129523. },
  129524. set: function(i) {
  129525. this._dPadLeft = this._setDPadValue(i, this._dPadLeft, Xbox360Dpad.Left)
  129526. },
  129527. enumerable: !1,
  129528. configurable: !0
  129529. }),
  129530. Object.defineProperty(e.prototype, "dPadRight", {
  129531. get: function() {
  129532. return this._dPadRight
  129533. },
  129534. set: function(i) {
  129535. this._dPadRight = this._setDPadValue(i, this._dPadRight, Xbox360Dpad.Right)
  129536. },
  129537. enumerable: !1,
  129538. configurable: !0
  129539. }),
  129540. e.prototype.update = function() {
  129541. a.prototype.update.call(this),
  129542. this._isXboxOnePad ? (this.buttonA = this.browserGamepad.buttons[0].value,
  129543. this.buttonB = this.browserGamepad.buttons[1].value,
  129544. this.buttonX = this.browserGamepad.buttons[2].value,
  129545. this.buttonY = this.browserGamepad.buttons[3].value,
  129546. this.buttonLB = this.browserGamepad.buttons[4].value,
  129547. this.buttonRB = this.browserGamepad.buttons[5].value,
  129548. this.leftTrigger = this.browserGamepad.buttons[6].value,
  129549. this.rightTrigger = this.browserGamepad.buttons[7].value,
  129550. this.buttonBack = this.browserGamepad.buttons[8].value,
  129551. this.buttonStart = this.browserGamepad.buttons[9].value,
  129552. this.buttonLeftStick = this.browserGamepad.buttons[10].value,
  129553. this.buttonRightStick = this.browserGamepad.buttons[11].value,
  129554. this.dPadUp = this.browserGamepad.buttons[12].value,
  129555. this.dPadDown = this.browserGamepad.buttons[13].value,
  129556. this.dPadLeft = this.browserGamepad.buttons[14].value,
  129557. this.dPadRight = this.browserGamepad.buttons[15].value) : (this.buttonA = this.browserGamepad.buttons[0].value,
  129558. this.buttonB = this.browserGamepad.buttons[1].value,
  129559. this.buttonX = this.browserGamepad.buttons[2].value,
  129560. this.buttonY = this.browserGamepad.buttons[3].value,
  129561. this.buttonLB = this.browserGamepad.buttons[4].value,
  129562. this.buttonRB = this.browserGamepad.buttons[5].value,
  129563. this.leftTrigger = this.browserGamepad.buttons[6].value,
  129564. this.rightTrigger = this.browserGamepad.buttons[7].value,
  129565. this.buttonBack = this.browserGamepad.buttons[8].value,
  129566. this.buttonStart = this.browserGamepad.buttons[9].value,
  129567. this.buttonLeftStick = this.browserGamepad.buttons[10].value,
  129568. this.buttonRightStick = this.browserGamepad.buttons[11].value,
  129569. this.dPadUp = this.browserGamepad.buttons[12].value,
  129570. this.dPadDown = this.browserGamepad.buttons[13].value,
  129571. this.dPadLeft = this.browserGamepad.buttons[14].value,
  129572. this.dPadRight = this.browserGamepad.buttons[15].value)
  129573. }
  129574. ,
  129575. e.prototype.dispose = function() {
  129576. a.prototype.dispose.call(this),
  129577. this.onButtonDownObservable.clear(),
  129578. this.onButtonUpObservable.clear(),
  129579. this.onPadDownObservable.clear(),
  129580. this.onPadUpObservable.clear()
  129581. }
  129582. ,
  129583. e
  129584. }(Gamepad), DualShockButton;
  129585. (function(a) {
  129586. a[a.Cross = 0] = "Cross",
  129587. a[a.Circle = 1] = "Circle",
  129588. a[a.Square = 2] = "Square",
  129589. a[a.Triangle = 3] = "Triangle",
  129590. a[a.L1 = 4] = "L1",
  129591. a[a.R1 = 5] = "R1",
  129592. a[a.Share = 8] = "Share",
  129593. a[a.Options = 9] = "Options",
  129594. a[a.LeftStick = 10] = "LeftStick",
  129595. a[a.RightStick = 11] = "RightStick"
  129596. }
  129597. )(DualShockButton || (DualShockButton = {}));
  129598. var DualShockDpad;
  129599. (function(a) {
  129600. a[a.Up = 12] = "Up",
  129601. a[a.Down = 13] = "Down",
  129602. a[a.Left = 14] = "Left",
  129603. a[a.Right = 15] = "Right"
  129604. }
  129605. )(DualShockDpad || (DualShockDpad = {}));
  129606. var DualShockPad = function(a) {
  129607. __extends(e, a);
  129608. function e(i, o, s) {
  129609. var c = a.call(this, i.replace("STANDARD GAMEPAD", "SONY PLAYSTATION DUALSHOCK"), o, s, 0, 1, 2, 3) || this;
  129610. return c._leftTrigger = 0,
  129611. c._rightTrigger = 0,
  129612. c.onButtonDownObservable = new Observable,
  129613. c.onButtonUpObservable = new Observable,
  129614. c.onPadDownObservable = new Observable,
  129615. c.onPadUpObservable = new Observable,
  129616. c._buttonCross = 0,
  129617. c._buttonCircle = 0,
  129618. c._buttonSquare = 0,
  129619. c._buttonTriangle = 0,
  129620. c._buttonShare = 0,
  129621. c._buttonOptions = 0,
  129622. c._buttonL1 = 0,
  129623. c._buttonR1 = 0,
  129624. c._buttonLeftStick = 0,
  129625. c._buttonRightStick = 0,
  129626. c._dPadUp = 0,
  129627. c._dPadDown = 0,
  129628. c._dPadLeft = 0,
  129629. c._dPadRight = 0,
  129630. c.type = Gamepad.DUALSHOCK,
  129631. c
  129632. }
  129633. return e.prototype.onlefttriggerchanged = function(i) {
  129634. this._onlefttriggerchanged = i
  129635. }
  129636. ,
  129637. e.prototype.onrighttriggerchanged = function(i) {
  129638. this._onrighttriggerchanged = i
  129639. }
  129640. ,
  129641. Object.defineProperty(e.prototype, "leftTrigger", {
  129642. get: function() {
  129643. return this._leftTrigger
  129644. },
  129645. set: function(i) {
  129646. this._onlefttriggerchanged && this._leftTrigger !== i && this._onlefttriggerchanged(i),
  129647. this._leftTrigger = i
  129648. },
  129649. enumerable: !1,
  129650. configurable: !0
  129651. }),
  129652. Object.defineProperty(e.prototype, "rightTrigger", {
  129653. get: function() {
  129654. return this._rightTrigger
  129655. },
  129656. set: function(i) {
  129657. this._onrighttriggerchanged && this._rightTrigger !== i && this._onrighttriggerchanged(i),
  129658. this._rightTrigger = i
  129659. },
  129660. enumerable: !1,
  129661. configurable: !0
  129662. }),
  129663. e.prototype.onbuttondown = function(i) {
  129664. this._onbuttondown = i
  129665. }
  129666. ,
  129667. e.prototype.onbuttonup = function(i) {
  129668. this._onbuttonup = i
  129669. }
  129670. ,
  129671. e.prototype.ondpaddown = function(i) {
  129672. this._ondpaddown = i
  129673. }
  129674. ,
  129675. e.prototype.ondpadup = function(i) {
  129676. this._ondpadup = i
  129677. }
  129678. ,
  129679. e.prototype._setButtonValue = function(i, o, s) {
  129680. return i !== o && (i === 1 && (this._onbuttondown && this._onbuttondown(s),
  129681. this.onButtonDownObservable.notifyObservers(s)),
  129682. i === 0 && (this._onbuttonup && this._onbuttonup(s),
  129683. this.onButtonUpObservable.notifyObservers(s))),
  129684. i
  129685. }
  129686. ,
  129687. e.prototype._setDPadValue = function(i, o, s) {
  129688. return i !== o && (i === 1 && (this._ondpaddown && this._ondpaddown(s),
  129689. this.onPadDownObservable.notifyObservers(s)),
  129690. i === 0 && (this._ondpadup && this._ondpadup(s),
  129691. this.onPadUpObservable.notifyObservers(s))),
  129692. i
  129693. }
  129694. ,
  129695. Object.defineProperty(e.prototype, "buttonCross", {
  129696. get: function() {
  129697. return this._buttonCross
  129698. },
  129699. set: function(i) {
  129700. this._buttonCross = this._setButtonValue(i, this._buttonCross, DualShockButton.Cross)
  129701. },
  129702. enumerable: !1,
  129703. configurable: !0
  129704. }),
  129705. Object.defineProperty(e.prototype, "buttonCircle", {
  129706. get: function() {
  129707. return this._buttonCircle
  129708. },
  129709. set: function(i) {
  129710. this._buttonCircle = this._setButtonValue(i, this._buttonCircle, DualShockButton.Circle)
  129711. },
  129712. enumerable: !1,
  129713. configurable: !0
  129714. }),
  129715. Object.defineProperty(e.prototype, "buttonSquare", {
  129716. get: function() {
  129717. return this._buttonSquare
  129718. },
  129719. set: function(i) {
  129720. this._buttonSquare = this._setButtonValue(i, this._buttonSquare, DualShockButton.Square)
  129721. },
  129722. enumerable: !1,
  129723. configurable: !0
  129724. }),
  129725. Object.defineProperty(e.prototype, "buttonTriangle", {
  129726. get: function() {
  129727. return this._buttonTriangle
  129728. },
  129729. set: function(i) {
  129730. this._buttonTriangle = this._setButtonValue(i, this._buttonTriangle, DualShockButton.Triangle)
  129731. },
  129732. enumerable: !1,
  129733. configurable: !0
  129734. }),
  129735. Object.defineProperty(e.prototype, "buttonOptions", {
  129736. get: function() {
  129737. return this._buttonOptions
  129738. },
  129739. set: function(i) {
  129740. this._buttonOptions = this._setButtonValue(i, this._buttonOptions, DualShockButton.Options)
  129741. },
  129742. enumerable: !1,
  129743. configurable: !0
  129744. }),
  129745. Object.defineProperty(e.prototype, "buttonShare", {
  129746. get: function() {
  129747. return this._buttonShare
  129748. },
  129749. set: function(i) {
  129750. this._buttonShare = this._setButtonValue(i, this._buttonShare, DualShockButton.Share)
  129751. },
  129752. enumerable: !1,
  129753. configurable: !0
  129754. }),
  129755. Object.defineProperty(e.prototype, "buttonL1", {
  129756. get: function() {
  129757. return this._buttonL1
  129758. },
  129759. set: function(i) {
  129760. this._buttonL1 = this._setButtonValue(i, this._buttonL1, DualShockButton.L1)
  129761. },
  129762. enumerable: !1,
  129763. configurable: !0
  129764. }),
  129765. Object.defineProperty(e.prototype, "buttonR1", {
  129766. get: function() {
  129767. return this._buttonR1
  129768. },
  129769. set: function(i) {
  129770. this._buttonR1 = this._setButtonValue(i, this._buttonR1, DualShockButton.R1)
  129771. },
  129772. enumerable: !1,
  129773. configurable: !0
  129774. }),
  129775. Object.defineProperty(e.prototype, "buttonLeftStick", {
  129776. get: function() {
  129777. return this._buttonLeftStick
  129778. },
  129779. set: function(i) {
  129780. this._buttonLeftStick = this._setButtonValue(i, this._buttonLeftStick, DualShockButton.LeftStick)
  129781. },
  129782. enumerable: !1,
  129783. configurable: !0
  129784. }),
  129785. Object.defineProperty(e.prototype, "buttonRightStick", {
  129786. get: function() {
  129787. return this._buttonRightStick
  129788. },
  129789. set: function(i) {
  129790. this._buttonRightStick = this._setButtonValue(i, this._buttonRightStick, DualShockButton.RightStick)
  129791. },
  129792. enumerable: !1,
  129793. configurable: !0
  129794. }),
  129795. Object.defineProperty(e.prototype, "dPadUp", {
  129796. get: function() {
  129797. return this._dPadUp
  129798. },
  129799. set: function(i) {
  129800. this._dPadUp = this._setDPadValue(i, this._dPadUp, DualShockDpad.Up)
  129801. },
  129802. enumerable: !1,
  129803. configurable: !0
  129804. }),
  129805. Object.defineProperty(e.prototype, "dPadDown", {
  129806. get: function() {
  129807. return this._dPadDown
  129808. },
  129809. set: function(i) {
  129810. this._dPadDown = this._setDPadValue(i, this._dPadDown, DualShockDpad.Down)
  129811. },
  129812. enumerable: !1,
  129813. configurable: !0
  129814. }),
  129815. Object.defineProperty(e.prototype, "dPadLeft", {
  129816. get: function() {
  129817. return this._dPadLeft
  129818. },
  129819. set: function(i) {
  129820. this._dPadLeft = this._setDPadValue(i, this._dPadLeft, DualShockDpad.Left)
  129821. },
  129822. enumerable: !1,
  129823. configurable: !0
  129824. }),
  129825. Object.defineProperty(e.prototype, "dPadRight", {
  129826. get: function() {
  129827. return this._dPadRight
  129828. },
  129829. set: function(i) {
  129830. this._dPadRight = this._setDPadValue(i, this._dPadRight, DualShockDpad.Right)
  129831. },
  129832. enumerable: !1,
  129833. configurable: !0
  129834. }),
  129835. e.prototype.update = function() {
  129836. a.prototype.update.call(this),
  129837. this.buttonCross = this.browserGamepad.buttons[0].value,
  129838. this.buttonCircle = this.browserGamepad.buttons[1].value,
  129839. this.buttonSquare = this.browserGamepad.buttons[2].value,
  129840. this.buttonTriangle = this.browserGamepad.buttons[3].value,
  129841. this.buttonL1 = this.browserGamepad.buttons[4].value,
  129842. this.buttonR1 = this.browserGamepad.buttons[5].value,
  129843. this.leftTrigger = this.browserGamepad.buttons[6].value,
  129844. this.rightTrigger = this.browserGamepad.buttons[7].value,
  129845. this.buttonShare = this.browserGamepad.buttons[8].value,
  129846. this.buttonOptions = this.browserGamepad.buttons[9].value,
  129847. this.buttonLeftStick = this.browserGamepad.buttons[10].value,
  129848. this.buttonRightStick = this.browserGamepad.buttons[11].value,
  129849. this.dPadUp = this.browserGamepad.buttons[12].value,
  129850. this.dPadDown = this.browserGamepad.buttons[13].value,
  129851. this.dPadLeft = this.browserGamepad.buttons[14].value,
  129852. this.dPadRight = this.browserGamepad.buttons[15].value
  129853. }
  129854. ,
  129855. e.prototype.dispose = function() {
  129856. a.prototype.dispose.call(this),
  129857. this.onButtonDownObservable.clear(),
  129858. this.onButtonUpObservable.clear(),
  129859. this.onPadDownObservable.clear(),
  129860. this.onPadUpObservable.clear()
  129861. }
  129862. ,
  129863. e
  129864. }(Gamepad)
  129865. , GamepadManager = function() {
  129866. function a(e) {
  129867. var i = this;
  129868. if (this._scene = e,
  129869. this._babylonGamepads = [],
  129870. this._oneGamepadConnected = !1,
  129871. this._isMonitoring = !1,
  129872. this.onGamepadDisconnectedObservable = new Observable,
  129873. IsWindowObjectExist() ? (this._gamepadEventSupported = "GamepadEvent"in window,
  129874. this._gamepadSupport = navigator && (navigator.getGamepads || navigator.webkitGetGamepads || navigator.msGetGamepads || navigator.webkitGamepads)) : this._gamepadEventSupported = !1,
  129875. this.onGamepadConnectedObservable = new Observable(function(s) {
  129876. for (var c in i._babylonGamepads) {
  129877. var d = i._babylonGamepads[c];
  129878. d && d._isConnected && i.onGamepadConnectedObservable.notifyObserver(s, d)
  129879. }
  129880. }
  129881. ),
  129882. this._onGamepadConnectedEvent = function(s) {
  129883. var c = s.gamepad;
  129884. if (!(c.index in i._babylonGamepads && i._babylonGamepads[c.index].isConnected)) {
  129885. var d;
  129886. i._babylonGamepads[c.index] ? (d = i._babylonGamepads[c.index],
  129887. d.browserGamepad = c,
  129888. d._isConnected = !0) : d = i._addNewGamepad(c),
  129889. i.onGamepadConnectedObservable.notifyObservers(d),
  129890. i._startMonitoringGamepads()
  129891. }
  129892. }
  129893. ,
  129894. this._onGamepadDisconnectedEvent = function(s) {
  129895. var c = s.gamepad;
  129896. for (var d in i._babylonGamepads)
  129897. if (i._babylonGamepads[d].index === c.index) {
  129898. var _ = i._babylonGamepads[d];
  129899. _._isConnected = !1,
  129900. i.onGamepadDisconnectedObservable.notifyObservers(_),
  129901. _.dispose && _.dispose();
  129902. break
  129903. }
  129904. }
  129905. ,
  129906. this._gamepadSupport)
  129907. if (this._updateGamepadObjects(),
  129908. this._babylonGamepads.length && this._startMonitoringGamepads(),
  129909. this._gamepadEventSupported) {
  129910. var o = this._scene ? this._scene.getEngine().getHostWindow() : window;
  129911. o && (o.addEventListener("gamepadconnected", this._onGamepadConnectedEvent, !1),
  129912. o.addEventListener("gamepaddisconnected", this._onGamepadDisconnectedEvent, !1))
  129913. } else
  129914. this._startMonitoringGamepads()
  129915. }
  129916. return Object.defineProperty(a.prototype, "gamepads", {
  129917. get: function() {
  129918. return this._babylonGamepads
  129919. },
  129920. enumerable: !1,
  129921. configurable: !0
  129922. }),
  129923. a.prototype.getGamepadByType = function(e) {
  129924. e === void 0 && (e = Gamepad.XBOX);
  129925. for (var i = 0, o = this._babylonGamepads; i < o.length; i++) {
  129926. var s = o[i];
  129927. if (s && s.type === e)
  129928. return s
  129929. }
  129930. return null
  129931. }
  129932. ,
  129933. a.prototype.dispose = function() {
  129934. this._gamepadEventSupported && (this._onGamepadConnectedEvent && window.removeEventListener("gamepadconnected", this._onGamepadConnectedEvent),
  129935. this._onGamepadDisconnectedEvent && window.removeEventListener("gamepaddisconnected", this._onGamepadDisconnectedEvent),
  129936. this._onGamepadConnectedEvent = null,
  129937. this._onGamepadDisconnectedEvent = null),
  129938. this._babylonGamepads.forEach(function(e) {
  129939. e.dispose()
  129940. }),
  129941. this.onGamepadConnectedObservable.clear(),
  129942. this.onGamepadDisconnectedObservable.clear(),
  129943. this._oneGamepadConnected = !1,
  129944. this._stopMonitoringGamepads(),
  129945. this._babylonGamepads = []
  129946. }
  129947. ,
  129948. a.prototype._addNewGamepad = function(e) {
  129949. this._oneGamepadConnected || (this._oneGamepadConnected = !0);
  129950. var i, o = e.id.search("054c") !== -1 && e.id.search("0ce6") === -1, s = e.id.search("Xbox One") !== -1;
  129951. return s || e.id.search("Xbox 360") !== -1 || e.id.search("xinput") !== -1 || e.id.search("045e") !== -1 && e.id.search("Surface Dock") === -1 ? i = new Xbox360Pad(e.id,e.index,e,s) : o ? i = new DualShockPad(e.id,e.index,e) : e.pose ? i = PoseEnabledControllerHelper.InitiateController(e) : i = new GenericPad(e.id,e.index,e),
  129952. this._babylonGamepads[i.index] = i,
  129953. i
  129954. }
  129955. ,
  129956. a.prototype._startMonitoringGamepads = function() {
  129957. this._isMonitoring || (this._isMonitoring = !0,
  129958. this._scene || this._checkGamepadsStatus())
  129959. }
  129960. ,
  129961. a.prototype._stopMonitoringGamepads = function() {
  129962. this._isMonitoring = !1
  129963. }
  129964. ,
  129965. a.prototype._checkGamepadsStatus = function() {
  129966. var e = this;
  129967. this._updateGamepadObjects();
  129968. for (var i in this._babylonGamepads) {
  129969. var o = this._babylonGamepads[i];
  129970. if (!(!o || !o.isConnected))
  129971. try {
  129972. o.update()
  129973. } catch {
  129974. this._loggedErrors.indexOf(o.index) === -1 && (Tools.Warn("Error updating gamepad " + o.id),
  129975. this._loggedErrors.push(o.index))
  129976. }
  129977. }
  129978. this._isMonitoring && !this._scene && Engine.QueueNewFrame(function() {
  129979. e._checkGamepadsStatus()
  129980. })
  129981. }
  129982. ,
  129983. a.prototype._updateGamepadObjects = function() {
  129984. for (var e = navigator.getGamepads ? navigator.getGamepads() : navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : [], i = 0; i < e.length; i++) {
  129985. var o = e[i];
  129986. if (o)
  129987. if (this._babylonGamepads[o.index])
  129988. this._babylonGamepads[i].browserGamepad = o,
  129989. this._babylonGamepads[i].isConnected || (this._babylonGamepads[i]._isConnected = !0,
  129990. this.onGamepadConnectedObservable.notifyObservers(this._babylonGamepads[i]));
  129991. else {
  129992. var s = this._addNewGamepad(o);
  129993. this.onGamepadConnectedObservable.notifyObservers(s)
  129994. }
  129995. }
  129996. }
  129997. ,
  129998. a
  129999. }()
  130000. , FreeCameraGamepadInput = function() {
  130001. function a() {
  130002. this.gamepadAngularSensibility = 200,
  130003. this.gamepadMoveSensibility = 40,
  130004. this.deadzoneDelta = .1,
  130005. this._yAxisScale = 1,
  130006. this._cameraTransform = Matrix.Identity(),
  130007. this._deltaTransform = Vector3.Zero(),
  130008. this._vector3 = Vector3.Zero(),
  130009. this._vector2 = Vector2.Zero()
  130010. }
  130011. return Object.defineProperty(a.prototype, "invertYAxis", {
  130012. get: function() {
  130013. return this._yAxisScale !== 1
  130014. },
  130015. set: function(e) {
  130016. this._yAxisScale = e ? -1 : 1
  130017. },
  130018. enumerable: !1,
  130019. configurable: !0
  130020. }),
  130021. a.prototype.attachControl = function() {
  130022. var e = this
  130023. , i = this.camera.getScene().gamepadManager;
  130024. this._onGamepadConnectedObserver = i.onGamepadConnectedObservable.add(function(o) {
  130025. o.type !== Gamepad.POSE_ENABLED && (!e.gamepad || o.type === Gamepad.XBOX) && (e.gamepad = o)
  130026. }),
  130027. this._onGamepadDisconnectedObserver = i.onGamepadDisconnectedObservable.add(function(o) {
  130028. e.gamepad === o && (e.gamepad = null)
  130029. }),
  130030. this.gamepad = i.getGamepadByType(Gamepad.XBOX),
  130031. !this.gamepad && i.gamepads.length && (this.gamepad = i.gamepads[0])
  130032. }
  130033. ,
  130034. a.prototype.detachControl = function(e) {
  130035. this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver),
  130036. this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver),
  130037. this.gamepad = null
  130038. }
  130039. ,
  130040. a.prototype.checkInputs = function() {
  130041. if (this.gamepad && this.gamepad.leftStick) {
  130042. var e = this.camera
  130043. , i = this.gamepad.leftStick;
  130044. this.gamepadMoveSensibility !== 0 && (i.x = Math.abs(i.x) > this.deadzoneDelta ? i.x / this.gamepadMoveSensibility : 0,
  130045. i.y = Math.abs(i.y) > this.deadzoneDelta ? i.y / this.gamepadMoveSensibility : 0);
  130046. var o = this.gamepad.rightStick;
  130047. o && this.gamepadAngularSensibility !== 0 ? (o.x = Math.abs(o.x) > this.deadzoneDelta ? o.x / this.gamepadAngularSensibility : 0,
  130048. o.y = (Math.abs(o.y) > this.deadzoneDelta ? o.y / this.gamepadAngularSensibility : 0) * this._yAxisScale) : o = {
  130049. x: 0,
  130050. y: 0
  130051. },
  130052. e.rotationQuaternion ? e.rotationQuaternion.toRotationMatrix(this._cameraTransform) : Matrix.RotationYawPitchRollToRef(e.rotation.y, e.rotation.x, 0, this._cameraTransform);
  130053. var s = e._computeLocalCameraSpeed() * 50;
  130054. this._vector3.copyFromFloats(i.x * s, 0, -i.y * s),
  130055. Vector3.TransformCoordinatesToRef(this._vector3, this._cameraTransform, this._deltaTransform),
  130056. e.cameraDirection.addInPlace(this._deltaTransform),
  130057. this._vector2.copyFromFloats(o.y, o.x),
  130058. e.cameraRotation.addInPlace(this._vector2)
  130059. }
  130060. }
  130061. ,
  130062. a.prototype.getClassName = function() {
  130063. return "FreeCameraGamepadInput"
  130064. }
  130065. ,
  130066. a.prototype.getSimpleName = function() {
  130067. return "gamepad"
  130068. }
  130069. ,
  130070. __decorate([serialize()], a.prototype, "gamepadAngularSensibility", void 0),
  130071. __decorate([serialize()], a.prototype, "gamepadMoveSensibility", void 0),
  130072. a
  130073. }();
  130074. CameraInputTypes.FreeCameraGamepadInput = FreeCameraGamepadInput;
  130075. var ArcRotateCameraGamepadInput = function() {
  130076. function a() {
  130077. this.gamepadRotationSensibility = 80,
  130078. this.gamepadMoveSensibility = 40,
  130079. this._yAxisScale = 1
  130080. }
  130081. return Object.defineProperty(a.prototype, "invertYAxis", {
  130082. get: function() {
  130083. return this._yAxisScale !== 1
  130084. },
  130085. set: function(e) {
  130086. this._yAxisScale = e ? -1 : 1
  130087. },
  130088. enumerable: !1,
  130089. configurable: !0
  130090. }),
  130091. a.prototype.attachControl = function() {
  130092. var e = this
  130093. , i = this.camera.getScene().gamepadManager;
  130094. this._onGamepadConnectedObserver = i.onGamepadConnectedObservable.add(function(o) {
  130095. o.type !== Gamepad.POSE_ENABLED && (!e.gamepad || o.type === Gamepad.XBOX) && (e.gamepad = o)
  130096. }),
  130097. this._onGamepadDisconnectedObserver = i.onGamepadDisconnectedObservable.add(function(o) {
  130098. e.gamepad === o && (e.gamepad = null)
  130099. }),
  130100. this.gamepad = i.getGamepadByType(Gamepad.XBOX)
  130101. }
  130102. ,
  130103. a.prototype.detachControl = function(e) {
  130104. this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver),
  130105. this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver),
  130106. this.gamepad = null
  130107. }
  130108. ,
  130109. a.prototype.checkInputs = function() {
  130110. if (this.gamepad) {
  130111. var e = this.camera
  130112. , i = this.gamepad.rightStick;
  130113. if (i) {
  130114. if (i.x != 0) {
  130115. var o = i.x / this.gamepadRotationSensibility;
  130116. o != 0 && Math.abs(o) > .005 && (e.inertialAlphaOffset += o)
  130117. }
  130118. if (i.y != 0) {
  130119. var s = i.y / this.gamepadRotationSensibility * this._yAxisScale;
  130120. s != 0 && Math.abs(s) > .005 && (e.inertialBetaOffset += s)
  130121. }
  130122. }
  130123. var c = this.gamepad.leftStick;
  130124. if (c && c.y != 0) {
  130125. var d = c.y / this.gamepadMoveSensibility;
  130126. d != 0 && Math.abs(d) > .005 && (this.camera.inertialRadiusOffset -= d)
  130127. }
  130128. }
  130129. }
  130130. ,
  130131. a.prototype.getClassName = function() {
  130132. return "ArcRotateCameraGamepadInput"
  130133. }
  130134. ,
  130135. a.prototype.getSimpleName = function() {
  130136. return "gamepad"
  130137. }
  130138. ,
  130139. __decorate([serialize()], a.prototype, "gamepadRotationSensibility", void 0),
  130140. __decorate([serialize()], a.prototype, "gamepadMoveSensibility", void 0),
  130141. a
  130142. }();
  130143. CameraInputTypes.ArcRotateCameraGamepadInput = ArcRotateCameraGamepadInput;
  130144. Object.defineProperty(Scene.prototype, "gamepadManager", {
  130145. get: function() {
  130146. if (!this._gamepadManager) {
  130147. this._gamepadManager = new GamepadManager(this);
  130148. var a = this._getComponent(SceneComponentConstants.NAME_GAMEPAD);
  130149. a || (a = new GamepadSystemSceneComponent(this),
  130150. this._addComponent(a))
  130151. }
  130152. return this._gamepadManager
  130153. },
  130154. enumerable: !0,
  130155. configurable: !0
  130156. });
  130157. FreeCameraInputsManager.prototype.addGamepad = function() {
  130158. return this.add(new FreeCameraGamepadInput),
  130159. this
  130160. }
  130161. ;
  130162. ArcRotateCameraInputsManager.prototype.addGamepad = function() {
  130163. return this.add(new ArcRotateCameraGamepadInput),
  130164. this
  130165. }
  130166. ;
  130167. var GamepadSystemSceneComponent = function() {
  130168. function a(e) {
  130169. this.name = SceneComponentConstants.NAME_GAMEPAD,
  130170. this.scene = e
  130171. }
  130172. return a.prototype.register = function() {
  130173. this.scene._beforeCameraUpdateStage.registerStep(SceneComponentConstants.STEP_BEFORECAMERAUPDATE_GAMEPAD, this, this._beforeCameraUpdate)
  130174. }
  130175. ,
  130176. a.prototype.rebuild = function() {}
  130177. ,
  130178. a.prototype.dispose = function() {
  130179. var e = this.scene._gamepadManager;
  130180. e && (e.dispose(),
  130181. this.scene._gamepadManager = null)
  130182. }
  130183. ,
  130184. a.prototype._beforeCameraUpdate = function() {
  130185. var e = this.scene._gamepadManager;
  130186. e && e._isMonitoring && e._checkGamepadsStatus()
  130187. }
  130188. ,
  130189. a
  130190. }(), WebXRManagedOutputCanvasOptions = function() {
  130191. function a() {}
  130192. return a.GetDefaults = function(e) {
  130193. var i = new a;
  130194. return i.canvasOptions = {
  130195. antialias: !0,
  130196. depth: !0,
  130197. stencil: e ? e.isStencilEnable : !0,
  130198. alpha: !0,
  130199. multiview: !1,
  130200. framebufferScaleFactor: 1
  130201. },
  130202. i.newCanvasCssStyle = "position:absolute; bottom:0px;right:0px;z-index:10;width:90%;height:100%;background-color: #000000;",
  130203. i
  130204. }
  130205. ,
  130206. a
  130207. }(), WebXRManagedOutputCanvas = function() {
  130208. function a(e, i) {
  130209. var o = this;
  130210. if (i === void 0 && (i = WebXRManagedOutputCanvasOptions.GetDefaults()),
  130211. this._options = i,
  130212. this._canvas = null,
  130213. this._engine = null,
  130214. this.xrLayer = null,
  130215. this.onXRLayerInitObservable = new Observable,
  130216. this._engine = e.scene.getEngine(),
  130217. this._engine.onDisposeObservable.addOnce(function() {
  130218. o._engine = null
  130219. }),
  130220. i.canvasElement)
  130221. this._setManagedOutputCanvas(i.canvasElement);
  130222. else {
  130223. var s = document.createElement("canvas");
  130224. s.style.cssText = this._options.newCanvasCssStyle || "position:absolute; bottom:0px;right:0px;",
  130225. this._setManagedOutputCanvas(s)
  130226. }
  130227. e.onXRSessionInit.add(function() {
  130228. o._addCanvas()
  130229. }),
  130230. e.onXRSessionEnded.add(function() {
  130231. o._removeCanvas()
  130232. })
  130233. }
  130234. return a.prototype.dispose = function() {
  130235. this._removeCanvas(),
  130236. this._setManagedOutputCanvas(null)
  130237. }
  130238. ,
  130239. a.prototype.initializeXRLayerAsync = function(e) {
  130240. var i = this
  130241. , o = function() {
  130242. var s = new XRWebGLLayer(e,i.canvasContext,i._options.canvasOptions);
  130243. return i.onXRLayerInitObservable.notifyObservers(s),
  130244. s
  130245. };
  130246. return this.canvasContext.makeXRCompatible ? this.canvasContext.makeXRCompatible().then(function() {}, function() {
  130247. Tools.Warn("Error executing makeXRCompatible. This does not mean that the session will work incorrectly.")
  130248. }).then(function() {
  130249. return i.xrLayer = o(),
  130250. i.xrLayer
  130251. }) : (this.xrLayer = o(),
  130252. Promise.resolve(this.xrLayer))
  130253. }
  130254. ,
  130255. a.prototype._addCanvas = function() {
  130256. var e = this;
  130257. this._canvas && this._engine && this._canvas !== this._engine.getRenderingCanvas() && document.body.appendChild(this._canvas),
  130258. this.xrLayer ? this._setCanvasSize(!0) : this.onXRLayerInitObservable.addOnce(function(i) {
  130259. e._setCanvasSize(!0, i)
  130260. })
  130261. }
  130262. ,
  130263. a.prototype._removeCanvas = function() {
  130264. this._canvas && this._engine && document.body.contains(this._canvas) && this._canvas !== this._engine.getRenderingCanvas() && document.body.removeChild(this._canvas),
  130265. this._setCanvasSize(!1)
  130266. }
  130267. ,
  130268. a.prototype._setCanvasSize = function(e, i) {
  130269. e === void 0 && (e = !0),
  130270. i === void 0 && (i = this.xrLayer),
  130271. !(!this._canvas || !this._engine) && (e ? i && (this._canvas !== this._engine.getRenderingCanvas() ? (this._canvas.style.width = i.framebufferWidth + "px",
  130272. this._canvas.style.height = i.framebufferHeight + "px") : this._engine.setSize(i.framebufferWidth, i.framebufferHeight)) : this._originalCanvasSize && (this._canvas !== this._engine.getRenderingCanvas() ? (this._canvas.style.width = this._originalCanvasSize.width + "px",
  130273. this._canvas.style.height = this._originalCanvasSize.height + "px") : this._engine.setSize(this._originalCanvasSize.width, this._originalCanvasSize.height)))
  130274. }
  130275. ,
  130276. a.prototype._setManagedOutputCanvas = function(e) {
  130277. this._removeCanvas(),
  130278. e ? (this._originalCanvasSize = {
  130279. width: e.offsetWidth,
  130280. height: e.offsetHeight
  130281. },
  130282. this._canvas = e,
  130283. this.canvasContext = this._canvas.getContext("webgl2"),
  130284. this.canvasContext || (this.canvasContext = this._canvas.getContext("webgl"))) : (this._canvas = null,
  130285. this.canvasContext = null)
  130286. }
  130287. ,
  130288. a
  130289. }(), WebXRSessionManager = function() {
  130290. function a(e) {
  130291. var i = this;
  130292. this.scene = e,
  130293. this._sessionEnded = !1,
  130294. this._baseLayer = null,
  130295. this._renderTargetTextures = [],
  130296. this.currentTimestamp = -1,
  130297. this.defaultHeightCompensation = 1.7,
  130298. this.onXRFrameObservable = new Observable,
  130299. this.onXRReferenceSpaceChanged = new Observable,
  130300. this.onXRSessionEnded = new Observable,
  130301. this.onXRSessionInit = new Observable,
  130302. this._engine = e.getEngine(),
  130303. this._engine.onDisposeObservable.addOnce(function() {
  130304. i._engine = null
  130305. })
  130306. }
  130307. return Object.defineProperty(a.prototype, "referenceSpace", {
  130308. get: function() {
  130309. return this._referenceSpace
  130310. },
  130311. set: function(e) {
  130312. this._referenceSpace = e,
  130313. this.onXRReferenceSpaceChanged.notifyObservers(this._referenceSpace)
  130314. },
  130315. enumerable: !1,
  130316. configurable: !0
  130317. }),
  130318. Object.defineProperty(a.prototype, "sessionMode", {
  130319. get: function() {
  130320. return this._sessionMode
  130321. },
  130322. enumerable: !1,
  130323. configurable: !0
  130324. }),
  130325. a.prototype.dispose = function() {
  130326. this._sessionEnded || this.exitXRAsync(),
  130327. this.onXRFrameObservable.clear(),
  130328. this.onXRSessionEnded.clear(),
  130329. this.onXRReferenceSpaceChanged.clear(),
  130330. this.onXRSessionInit.clear()
  130331. }
  130332. ,
  130333. a.prototype.exitXRAsync = function() {
  130334. return this.session && !this._sessionEnded ? (this._sessionEnded = !0,
  130335. this.session.end().catch(function(e) {
  130336. Logger$2.Warn("Could not end XR session.")
  130337. })) : Promise.resolve()
  130338. }
  130339. ,
  130340. a.prototype.getRenderTargetTextureForEye = function(e) {
  130341. return this._rttProvider.getRenderTargetForEye(e)
  130342. }
  130343. ,
  130344. a.prototype.getWebXRRenderTarget = function(e) {
  130345. var i = this.scene.getEngine();
  130346. return this._xrNavigator.xr.native ? this._xrNavigator.xr.getWebXRRenderTarget(i) : (e = e || WebXRManagedOutputCanvasOptions.GetDefaults(i),
  130347. e.canvasElement = e.canvasElement || i.getRenderingCanvas() || void 0,
  130348. new WebXRManagedOutputCanvas(this,e))
  130349. }
  130350. ,
  130351. a.prototype.initializeAsync = function() {
  130352. return this._xrNavigator = navigator,
  130353. this._xrNavigator.xr ? Promise.resolve() : Promise.reject("WebXR not available")
  130354. }
  130355. ,
  130356. a.prototype.initializeSessionAsync = function(e, i) {
  130357. var o = this;
  130358. return e === void 0 && (e = "immersive-vr"),
  130359. i === void 0 && (i = {}),
  130360. this._xrNavigator.xr.requestSession(e, i).then(function(s) {
  130361. return o.session = s,
  130362. o._sessionMode = e,
  130363. o.onXRSessionInit.notifyObservers(s),
  130364. o._sessionEnded = !1,
  130365. o.session.addEventListener("end", function() {
  130366. o._sessionEnded = !0,
  130367. o.onXRSessionEnded.notifyObservers(null),
  130368. o._rttProvider = null,
  130369. o._engine && (o._engine.framebufferDimensionsObject = null,
  130370. o._engine.restoreDefaultFramebuffer(),
  130371. o._engine.customAnimationFrameRequester = null,
  130372. o._engine._renderLoop()),
  130373. o.isNative && (o._renderTargetTextures.forEach(function(c) {
  130374. return c.dispose()
  130375. }),
  130376. o._renderTargetTextures.length = 0)
  130377. }, {
  130378. once: !0
  130379. }),
  130380. o.session
  130381. })
  130382. }
  130383. ,
  130384. a.prototype.isSessionSupportedAsync = function(e) {
  130385. return a.IsSessionSupportedAsync(e)
  130386. }
  130387. ,
  130388. a.prototype.resetReferenceSpace = function() {
  130389. this.referenceSpace = this.baseReferenceSpace
  130390. }
  130391. ,
  130392. a.prototype.runXRRenderLoop = function() {
  130393. var e = this;
  130394. if (!(this._sessionEnded || !this._engine)) {
  130395. if (this._engine.customAnimationFrameRequester = {
  130396. requestAnimationFrame: this.session.requestAnimationFrame.bind(this.session),
  130397. renderFunction: function(d, _) {
  130398. e._sessionEnded || !e._engine || (e.currentFrame = _,
  130399. e.currentTimestamp = d,
  130400. _ && (e._engine.framebufferDimensionsObject = e._baseLayer,
  130401. e.onXRFrameObservable.notifyObservers(_),
  130402. e._engine._renderLoop(),
  130403. e._engine.framebufferDimensionsObject = null))
  130404. }
  130405. },
  130406. this._xrNavigator.xr.native)
  130407. this._rttProvider = this._xrNavigator.xr.getNativeRenderTargetProvider(this.session, this._createRenderTargetTexture.bind(this), this._destroyRenderTargetTexture.bind(this));
  130408. else {
  130409. var i, o, s, c;
  130410. this._rttProvider = {
  130411. getRenderTargetForEye: function() {
  130412. var d = e._baseLayer;
  130413. return (d.framebufferWidth !== o || d.framebufferHeight !== s || d.framebuffer !== c) && (i = e._createRenderTargetTexture(d.framebufferWidth, d.framebufferHeight, d.framebuffer),
  130414. o = d.framebufferWidth,
  130415. s = d.framebufferHeight,
  130416. c = d.framebuffer),
  130417. i
  130418. }
  130419. },
  130420. this._engine.framebufferDimensionsObject = this._baseLayer
  130421. }
  130422. typeof window != "undefined" && window.cancelAnimationFrame && window.cancelAnimationFrame(this._engine._frameHandler),
  130423. this._engine._renderLoop()
  130424. }
  130425. }
  130426. ,
  130427. a.prototype.setReferenceSpaceTypeAsync = function(e) {
  130428. var i = this;
  130429. return e === void 0 && (e = "local-floor"),
  130430. this.session.requestReferenceSpace(e).then(function(o) {
  130431. return o
  130432. }, function(o) {
  130433. return Logger$2.Error("XR.requestReferenceSpace failed for the following reason: "),
  130434. Logger$2.Error(o),
  130435. Logger$2.Log('Defaulting to universally-supported "viewer" reference space type.'),
  130436. i.session.requestReferenceSpace("viewer").then(function(s) {
  130437. var c = new XRRigidTransform({
  130438. x: 0,
  130439. y: -i.defaultHeightCompensation,
  130440. z: 0
  130441. });
  130442. return s.getOffsetReferenceSpace(c)
  130443. }, function(s) {
  130444. throw Logger$2.Error(s),
  130445. 'XR initialization failed: required "viewer" reference space type not supported.'
  130446. })
  130447. }).then(function(o) {
  130448. return i.session.requestReferenceSpace("viewer").then(function(s) {
  130449. return i.viewerReferenceSpace = s,
  130450. o
  130451. })
  130452. }).then(function(o) {
  130453. return i.referenceSpace = i.baseReferenceSpace = o,
  130454. i.referenceSpace
  130455. })
  130456. }
  130457. ,
  130458. a.prototype.updateRenderStateAsync = function(e) {
  130459. return e.baseLayer && (this._baseLayer = e.baseLayer),
  130460. this.session.updateRenderState(e)
  130461. }
  130462. ,
  130463. a.IsSessionSupportedAsync = function(e) {
  130464. if (!navigator.xr)
  130465. return Promise.resolve(!1);
  130466. var i = navigator.xr.isSessionSupported || navigator.xr.supportsSession;
  130467. return i ? i.call(navigator.xr, e).then(function(o) {
  130468. var s = typeof o == "undefined" ? !0 : o;
  130469. return Promise.resolve(s)
  130470. }).catch(function(o) {
  130471. return Logger$2.Warn(o),
  130472. Promise.resolve(!1)
  130473. }) : Promise.resolve(!1)
  130474. }
  130475. ,
  130476. Object.defineProperty(a.prototype, "isNative", {
  130477. get: function() {
  130478. var e;
  130479. return (e = this._xrNavigator.xr.native) !== null && e !== void 0 ? e : !1
  130480. },
  130481. enumerable: !1,
  130482. configurable: !0
  130483. }),
  130484. Object.defineProperty(a.prototype, "currentFrameRate", {
  130485. get: function() {
  130486. var e;
  130487. return (e = this.session) === null || e === void 0 ? void 0 : e.frameRate
  130488. },
  130489. enumerable: !1,
  130490. configurable: !0
  130491. }),
  130492. Object.defineProperty(a.prototype, "supportedFrameRates", {
  130493. get: function() {
  130494. var e;
  130495. return (e = this.session) === null || e === void 0 ? void 0 : e.supportedFrameRates
  130496. },
  130497. enumerable: !1,
  130498. configurable: !0
  130499. }),
  130500. a.prototype.updateTargetFrameRate = function(e) {
  130501. return this.session.updateTargetFrameRate(e)
  130502. }
  130503. ,
  130504. Object.defineProperty(a.prototype, "isFixedFoveationSupported", {
  130505. get: function() {
  130506. var e;
  130507. return !!(!((e = this._baseLayer) === null || e === void 0) && e.fixedFoveation) !== null
  130508. },
  130509. enumerable: !1,
  130510. configurable: !0
  130511. }),
  130512. Object.defineProperty(a.prototype, "fixedFoveation", {
  130513. get: function() {
  130514. var e;
  130515. return ((e = this._baseLayer) === null || e === void 0 ? void 0 : e.fixedFoveation) !== void 0 ? this._baseLayer.fixedFoveation : null
  130516. },
  130517. set: function(e) {
  130518. var i, o = Math.max(0, Math.min(1, e || 0));
  130519. ((i = this._baseLayer) === null || i === void 0 ? void 0 : i.fixedFoveation) !== void 0 && (this._baseLayer.fixedFoveation = o)
  130520. },
  130521. enumerable: !1,
  130522. configurable: !0
  130523. }),
  130524. a.prototype._createRenderTargetTexture = function(e, i, o) {
  130525. if (!this._engine)
  130526. throw new Error("Engine is disposed");
  130527. var s = new InternalTexture(this._engine,InternalTextureSource.Unknown,!0);
  130528. s.width = e,
  130529. s.height = i;
  130530. var c = new RenderTargetTexture("XR renderTargetTexture",{
  130531. width: e,
  130532. height: i
  130533. },this.scene)
  130534. , d = c.renderTarget;
  130535. return d.setTexture(s, 0),
  130536. d._framebuffer = o,
  130537. c._texture = s,
  130538. c.disableRescaling(),
  130539. c.skipInitialClear = !0,
  130540. this._renderTargetTextures.push(c),
  130541. c
  130542. }
  130543. ,
  130544. a.prototype._destroyRenderTargetTexture = function(e) {
  130545. this._renderTargetTextures.splice(this._renderTargetTextures.indexOf(e), 1),
  130546. e.dispose()
  130547. }
  130548. ,
  130549. a
  130550. }(), WebXRState;
  130551. (function(a) {
  130552. a[a.ENTERING_XR = 0] = "ENTERING_XR",
  130553. a[a.EXITING_XR = 1] = "EXITING_XR",
  130554. a[a.IN_XR = 2] = "IN_XR",
  130555. a[a.NOT_IN_XR = 3] = "NOT_IN_XR"
  130556. }
  130557. )(WebXRState || (WebXRState = {}));
  130558. var WebXRTrackingState;
  130559. (function(a) {
  130560. a[a.NOT_TRACKING = 0] = "NOT_TRACKING",
  130561. a[a.TRACKING_LOST = 1] = "TRACKING_LOST",
  130562. a[a.TRACKING = 2] = "TRACKING"
  130563. }
  130564. )(WebXRTrackingState || (WebXRTrackingState = {}));
  130565. var VRExperienceHelperGazer = function() {
  130566. function a(e, i) {
  130567. if (i === void 0 && (i = null),
  130568. this.scene = e,
  130569. this._pointerDownOnMeshAsked = !1,
  130570. this._isActionableMesh = !1,
  130571. this._teleportationRequestInitiated = !1,
  130572. this._teleportationBackRequestInitiated = !1,
  130573. this._rotationRightAsked = !1,
  130574. this._rotationLeftAsked = !1,
  130575. this._dpadPressed = !0,
  130576. this._activePointer = !1,
  130577. this._id = a._idCounter++,
  130578. i)
  130579. this._gazeTracker = i.clone("gazeTracker");
  130580. else {
  130581. this._gazeTracker = CreateTorus("gazeTracker", {
  130582. diameter: .0035,
  130583. thickness: .0025,
  130584. tessellation: 20,
  130585. updatable: !1
  130586. }, e),
  130587. this._gazeTracker.bakeCurrentTransformIntoVertices(),
  130588. this._gazeTracker.isPickable = !1,
  130589. this._gazeTracker.isVisible = !1;
  130590. var o = new StandardMaterial("targetMat",e);
  130591. o.specularColor = Color3.Black(),
  130592. o.emissiveColor = new Color3(.7,.7,.7),
  130593. o.backFaceCulling = !1,
  130594. this._gazeTracker.material = o
  130595. }
  130596. }
  130597. return a.prototype._getForwardRay = function(e) {
  130598. return new Ray(Vector3.Zero(),new Vector3(0,0,e))
  130599. }
  130600. ,
  130601. a.prototype._selectionPointerDown = function() {
  130602. this._pointerDownOnMeshAsked = !0,
  130603. this._currentHit && this.scene.simulatePointerDown(this._currentHit, {
  130604. pointerId: this._id
  130605. })
  130606. }
  130607. ,
  130608. a.prototype._selectionPointerUp = function() {
  130609. this._currentHit && this.scene.simulatePointerUp(this._currentHit, {
  130610. pointerId: this._id
  130611. }),
  130612. this._pointerDownOnMeshAsked = !1
  130613. }
  130614. ,
  130615. a.prototype._activatePointer = function() {
  130616. this._activePointer = !0
  130617. }
  130618. ,
  130619. a.prototype._deactivatePointer = function() {
  130620. this._activePointer = !1
  130621. }
  130622. ,
  130623. a.prototype._updatePointerDistance = function(e) {}
  130624. ,
  130625. a.prototype.dispose = function() {
  130626. this._interactionsEnabled = !1,
  130627. this._teleportationEnabled = !1,
  130628. this._gazeTracker && this._gazeTracker.dispose()
  130629. }
  130630. ,
  130631. a._idCounter = 0,
  130632. a
  130633. }()
  130634. , VRExperienceHelperControllerGazer = function(a) {
  130635. __extends(e, a);
  130636. function e(i, o, s) {
  130637. var c = a.call(this, o, s) || this;
  130638. c.webVRController = i,
  130639. c._laserPointer = CreateCylinder("laserPointer", {
  130640. updatable: !1,
  130641. height: 1,
  130642. diameterTop: .004,
  130643. diameterBottom: 2e-4,
  130644. tessellation: 20,
  130645. subdivisions: 1
  130646. }, o);
  130647. var d = new StandardMaterial("laserPointerMat",o);
  130648. if (d.emissiveColor = new Color3(.7,.7,.7),
  130649. d.alpha = .6,
  130650. c._laserPointer.material = d,
  130651. c._laserPointer.rotation.x = Math.PI / 2,
  130652. c._laserPointer.position.z = -.5,
  130653. c._laserPointer.isVisible = !1,
  130654. c._laserPointer.isPickable = !1,
  130655. !i.mesh) {
  130656. var _ = new Mesh("preloadControllerMesh",o)
  130657. , b = new Mesh(PoseEnabledController.POINTING_POSE,o);
  130658. b.rotation.x = -.7,
  130659. _.addChild(b),
  130660. i.attachToMesh(_)
  130661. }
  130662. return c._setLaserPointerParent(i.mesh),
  130663. c._meshAttachedObserver = i._meshAttachedObservable.add(function(k) {
  130664. c._setLaserPointerParent(k)
  130665. }),
  130666. c
  130667. }
  130668. return e.prototype._getForwardRay = function(i) {
  130669. return this.webVRController.getForwardRay(i)
  130670. }
  130671. ,
  130672. e.prototype._activatePointer = function() {
  130673. a.prototype._activatePointer.call(this),
  130674. this._laserPointer.isVisible = !0
  130675. }
  130676. ,
  130677. e.prototype._deactivatePointer = function() {
  130678. a.prototype._deactivatePointer.call(this),
  130679. this._laserPointer.isVisible = !1
  130680. }
  130681. ,
  130682. e.prototype._setLaserPointerColor = function(i) {
  130683. this._laserPointer.material.emissiveColor = i
  130684. }
  130685. ,
  130686. e.prototype._setLaserPointerLightingDisabled = function(i) {
  130687. this._laserPointer.material.disableLighting = i
  130688. }
  130689. ,
  130690. e.prototype._setLaserPointerParent = function(i) {
  130691. var o = function(_) {
  130692. _.isPickable = !1,
  130693. _.getChildMeshes().forEach(function(b) {
  130694. o(b)
  130695. })
  130696. };
  130697. o(i);
  130698. var s = i.getChildren(void 0, !1)
  130699. , c = i;
  130700. this.webVRController._pointingPoseNode = null;
  130701. for (var d = 0; d < s.length; d++)
  130702. if (s[d].name && s[d].name.indexOf(PoseEnabledController.POINTING_POSE) >= 0) {
  130703. c = s[d],
  130704. this.webVRController._pointingPoseNode = c;
  130705. break
  130706. }
  130707. this._laserPointer.parent = c
  130708. }
  130709. ,
  130710. e.prototype._updatePointerDistance = function(i) {
  130711. i === void 0 && (i = 100),
  130712. this._laserPointer.scaling.y = i,
  130713. this._laserPointer.position.z = -i / 2
  130714. }
  130715. ,
  130716. e.prototype.dispose = function() {
  130717. a.prototype.dispose.call(this),
  130718. this._laserPointer.dispose(),
  130719. this._meshAttachedObserver && this.webVRController._meshAttachedObservable.remove(this._meshAttachedObserver)
  130720. }
  130721. ,
  130722. e
  130723. }(VRExperienceHelperGazer)
  130724. , VRExperienceHelperCameraGazer = function(a) {
  130725. __extends(e, a);
  130726. function e(i, o) {
  130727. var s = a.call(this, o) || this;
  130728. return s.getCamera = i,
  130729. s
  130730. }
  130731. return e.prototype._getForwardRay = function(i) {
  130732. var o = this.getCamera();
  130733. return o ? o.getForwardRay(i) : new Ray(Vector3.Zero(),Vector3.Forward())
  130734. }
  130735. ,
  130736. e
  130737. }(VRExperienceHelperGazer)
  130738. , VRExperienceHelper = function() {
  130739. function a(e, i) {
  130740. var o = this;
  130741. i === void 0 && (i = {}),
  130742. this.webVROptions = i,
  130743. this._webVRsupported = !1,
  130744. this._webVRready = !1,
  130745. this._webVRrequesting = !1,
  130746. this._webVRpresenting = !1,
  130747. this._fullscreenVRpresenting = !1,
  130748. this.enableGazeEvenWhenNoPointerLock = !1,
  130749. this.exitVROnDoubleTap = !0,
  130750. this.onEnteringVRObservable = new Observable,
  130751. this.onAfterEnteringVRObservable = new Observable,
  130752. this.onExitingVRObservable = new Observable,
  130753. this.onControllerMeshLoadedObservable = new Observable,
  130754. this._useCustomVRButton = !1,
  130755. this._teleportationRequested = !1,
  130756. this._teleportActive = !1,
  130757. this._floorMeshesCollection = [],
  130758. this._teleportationMode = a.TELEPORTATIONMODE_CONSTANTTIME,
  130759. this._teleportationTime = 122,
  130760. this._teleportationSpeed = 20,
  130761. this._rotationAllowed = !0,
  130762. this._teleportBackwardsVector = new Vector3(0,-1,-1),
  130763. this._isDefaultTeleportationTarget = !0,
  130764. this._teleportationFillColor = "#444444",
  130765. this._teleportationBorderColor = "#FFFFFF",
  130766. this._rotationAngle = 0,
  130767. this._haloCenter = new Vector3(0,0,0),
  130768. this._padSensibilityUp = .65,
  130769. this._padSensibilityDown = .35,
  130770. this._leftController = null,
  130771. this._rightController = null,
  130772. this._gazeColor = new Color3(.7,.7,.7),
  130773. this._laserColor = new Color3(.7,.7,.7),
  130774. this._pickedLaserColor = new Color3(.2,.2,1),
  130775. this._pickedGazeColor = new Color3(0,0,1),
  130776. this.onNewMeshSelected = new Observable,
  130777. this.onMeshSelectedWithController = new Observable,
  130778. this.onNewMeshPicked = new Observable,
  130779. this.onBeforeCameraTeleport = new Observable,
  130780. this.onAfterCameraTeleport = new Observable,
  130781. this.onSelectedMeshUnselected = new Observable,
  130782. this.teleportationEnabled = !0,
  130783. this._teleportationInitialized = !1,
  130784. this._interactionsEnabled = !1,
  130785. this._interactionsRequested = !1,
  130786. this._displayGaze = !0,
  130787. this._displayLaserPointer = !0,
  130788. this.updateGazeTrackerScale = !0,
  130789. this.updateGazeTrackerColor = !0,
  130790. this.updateControllerLaserColor = !0,
  130791. this.requestPointerLockOnFullScreen = !0,
  130792. this.xrTestDone = !1,
  130793. this._onResize = function() {
  130794. o.moveButtonToBottomRight(),
  130795. o._fullscreenVRpresenting && o._webVRready && o.exitVR()
  130796. }
  130797. ,
  130798. this._onFullscreenChange = function() {
  130799. var d = document;
  130800. d.fullscreen !== void 0 ? o._fullscreenVRpresenting = document.fullscreen : d.mozFullScreen !== void 0 ? o._fullscreenVRpresenting = d.mozFullScreen : d.webkitIsFullScreen !== void 0 ? o._fullscreenVRpresenting = d.webkitIsFullScreen : d.msIsFullScreen !== void 0 ? o._fullscreenVRpresenting = d.msIsFullScreen : document.msFullscreenElement !== void 0 && (o._fullscreenVRpresenting = document.msFullscreenElement),
  130801. !o._fullscreenVRpresenting && o._inputElement && (o.exitVR(),
  130802. !o._useCustomVRButton && o._btnVR && (o._btnVR.style.top = o._inputElement.offsetTop + o._inputElement.offsetHeight - 70 + "px",
  130803. o._btnVR.style.left = o._inputElement.offsetLeft + o._inputElement.offsetWidth - 100 + "px",
  130804. o.updateButtonVisibility()))
  130805. }
  130806. ,
  130807. this._cachedAngularSensibility = {
  130808. angularSensibilityX: null,
  130809. angularSensibilityY: null,
  130810. angularSensibility: null
  130811. },
  130812. this.beforeRender = function() {
  130813. o._leftController && o._leftController._activePointer && o._castRayAndSelectObject(o._leftController),
  130814. o._rightController && o._rightController._activePointer && o._castRayAndSelectObject(o._rightController),
  130815. o._noControllerIsActive && (o._scene.getEngine().isPointerLock || o.enableGazeEvenWhenNoPointerLock) ? o._castRayAndSelectObject(o._cameraGazer) : o._cameraGazer._gazeTracker.isVisible = !1
  130816. }
  130817. ,
  130818. this._onNewGamepadConnected = function(d) {
  130819. if (d.type !== Gamepad.POSE_ENABLED)
  130820. d.leftStick && d.onleftstickchanged(function(k) {
  130821. o._teleportationInitialized && o.teleportationEnabled && (!o._leftController && !o._rightController || o._leftController && !o._leftController._activePointer && o._rightController && !o._rightController._activePointer) && (o._checkTeleportWithRay(k, o._cameraGazer),
  130822. o._checkTeleportBackwards(k, o._cameraGazer))
  130823. }),
  130824. d.rightStick && d.onrightstickchanged(function(k) {
  130825. o._teleportationInitialized && o._checkRotate(k, o._cameraGazer)
  130826. }),
  130827. d.type === Gamepad.XBOX && (d.onbuttondown(function(k) {
  130828. o._interactionsEnabled && k === Xbox360Button.A && o._cameraGazer._selectionPointerDown()
  130829. }),
  130830. d.onbuttonup(function(k) {
  130831. o._interactionsEnabled && k === Xbox360Button.A && o._cameraGazer._selectionPointerUp()
  130832. }));
  130833. else {
  130834. var _ = d
  130835. , b = new VRExperienceHelperControllerGazer(_,o._scene,o._cameraGazer._gazeTracker);
  130836. _.hand === "right" || o._leftController && o._leftController.webVRController != _ ? o._rightController = b : o._leftController = b,
  130837. o._tryEnableInteractionOnController(b)
  130838. }
  130839. }
  130840. ,
  130841. this._tryEnableInteractionOnController = function(d) {
  130842. o._interactionsRequested && !d._interactionsEnabled && o._enableInteractionOnController(d),
  130843. o._teleportationRequested && !d._teleportationEnabled && o._enableTeleportationOnController(d)
  130844. }
  130845. ,
  130846. this._onNewGamepadDisconnected = function(d) {
  130847. d instanceof WebVRController && (d.hand === "left" && o._leftController != null && (o._leftController.dispose(),
  130848. o._leftController = null),
  130849. d.hand === "right" && o._rightController != null && (o._rightController.dispose(),
  130850. o._rightController = null))
  130851. }
  130852. ,
  130853. this._workingVector = Vector3.Zero(),
  130854. this._workingQuaternion = Quaternion.Identity(),
  130855. this._workingMatrix = Matrix.Identity(),
  130856. Logger$2.Warn("WebVR is deprecated. Please avoid using this experience helper and use the WebXR experience helper instead"),
  130857. this._scene = e,
  130858. this._inputElement = e.getEngine().getInputElement();
  130859. var s = "getVRDisplays"in navigator;
  130860. if (!s && i.useXR === void 0 && (i.useXR = !0),
  130861. i.createFallbackVRDeviceOrientationFreeCamera === void 0 && (i.createFallbackVRDeviceOrientationFreeCamera = !0),
  130862. i.createDeviceOrientationCamera === void 0 && (i.createDeviceOrientationCamera = !0),
  130863. i.laserToggle === void 0 && (i.laserToggle = !0),
  130864. i.defaultHeight === void 0 && (i.defaultHeight = 1.7),
  130865. i.useCustomVRButton && (this._useCustomVRButton = !0,
  130866. i.customVRButton && (this._btnVR = i.customVRButton)),
  130867. i.rayLength && (this._rayLength = i.rayLength),
  130868. this._defaultHeight = i.defaultHeight,
  130869. i.positionScale && (this._rayLength *= i.positionScale,
  130870. this._defaultHeight *= i.positionScale),
  130871. this._hasEnteredVR = !1,
  130872. this._scene.activeCamera ? this._position = this._scene.activeCamera.position.clone() : this._position = new Vector3(0,this._defaultHeight,0),
  130873. i.createDeviceOrientationCamera || !this._scene.activeCamera) {
  130874. if (this._deviceOrientationCamera = new DeviceOrientationCamera("deviceOrientationVRHelper",this._position.clone(),e),
  130875. this._scene.activeCamera && (this._deviceOrientationCamera.minZ = this._scene.activeCamera.minZ,
  130876. this._deviceOrientationCamera.maxZ = this._scene.activeCamera.maxZ,
  130877. this._scene.activeCamera instanceof TargetCamera && this._scene.activeCamera.rotation)) {
  130878. var c = this._scene.activeCamera;
  130879. c.rotationQuaternion ? this._deviceOrientationCamera.rotationQuaternion.copyFrom(c.rotationQuaternion) : this._deviceOrientationCamera.rotationQuaternion.copyFrom(Quaternion.RotationYawPitchRoll(c.rotation.y, c.rotation.x, c.rotation.z)),
  130880. this._deviceOrientationCamera.rotation = c.rotation.clone()
  130881. }
  130882. this._scene.activeCamera = this._deviceOrientationCamera,
  130883. this._inputElement && this._scene.activeCamera.attachControl()
  130884. } else
  130885. this._existingCamera = this._scene.activeCamera;
  130886. this.webVROptions.useXR && navigator.xr ? WebXRSessionManager.IsSessionSupportedAsync("immersive-vr").then(function(d) {
  130887. d ? (Logger$2.Log("Using WebXR. It is recommended to use the WebXRDefaultExperience directly"),
  130888. e.createDefaultXRExperienceAsync({
  130889. floorMeshes: i.floorMeshes || []
  130890. }).then(function(_) {
  130891. o.xr = _,
  130892. o.xrTestDone = !0,
  130893. o._cameraGazer = new VRExperienceHelperCameraGazer(function() {
  130894. return o.xr.baseExperience.camera
  130895. }
  130896. ,e),
  130897. o.xr.baseExperience.onStateChangedObservable.add(function(b) {
  130898. switch (b) {
  130899. case WebXRState.ENTERING_XR:
  130900. o.onEnteringVRObservable.notifyObservers(o),
  130901. o._interactionsEnabled || o.xr.pointerSelection.detach(),
  130902. o.xr.pointerSelection.displayLaserPointer = o._displayLaserPointer;
  130903. break;
  130904. case WebXRState.EXITING_XR:
  130905. o.onExitingVRObservable.notifyObservers(o),
  130906. o._scene.getEngine().resize();
  130907. break;
  130908. case WebXRState.IN_XR:
  130909. o._hasEnteredVR = !0;
  130910. break;
  130911. case WebXRState.NOT_IN_XR:
  130912. o._hasEnteredVR = !1;
  130913. break
  130914. }
  130915. })
  130916. })) : o.completeVRInit(e, i)
  130917. }) : this.completeVRInit(e, i)
  130918. }
  130919. return Object.defineProperty(a.prototype, "onEnteringVR", {
  130920. get: function() {
  130921. return this.onEnteringVRObservable
  130922. },
  130923. enumerable: !1,
  130924. configurable: !0
  130925. }),
  130926. Object.defineProperty(a.prototype, "onExitingVR", {
  130927. get: function() {
  130928. return this.onExitingVRObservable
  130929. },
  130930. enumerable: !1,
  130931. configurable: !0
  130932. }),
  130933. Object.defineProperty(a.prototype, "onControllerMeshLoaded", {
  130934. get: function() {
  130935. return this.onControllerMeshLoadedObservable
  130936. },
  130937. enumerable: !1,
  130938. configurable: !0
  130939. }),
  130940. Object.defineProperty(a.prototype, "teleportationTarget", {
  130941. get: function() {
  130942. return this._teleportationTarget
  130943. },
  130944. set: function(e) {
  130945. e && (e.name = "teleportationTarget",
  130946. this._isDefaultTeleportationTarget = !1,
  130947. this._teleportationTarget = e)
  130948. },
  130949. enumerable: !1,
  130950. configurable: !0
  130951. }),
  130952. Object.defineProperty(a.prototype, "gazeTrackerMesh", {
  130953. get: function() {
  130954. return this._cameraGazer._gazeTracker
  130955. },
  130956. set: function(e) {
  130957. e && (this._cameraGazer._gazeTracker && this._cameraGazer._gazeTracker.dispose(),
  130958. this._leftController && this._leftController._gazeTracker && this._leftController._gazeTracker.dispose(),
  130959. this._rightController && this._rightController._gazeTracker && this._rightController._gazeTracker.dispose(),
  130960. this._cameraGazer._gazeTracker = e,
  130961. this._cameraGazer._gazeTracker.bakeCurrentTransformIntoVertices(),
  130962. this._cameraGazer._gazeTracker.isPickable = !1,
  130963. this._cameraGazer._gazeTracker.isVisible = !1,
  130964. this._cameraGazer._gazeTracker.name = "gazeTracker",
  130965. this._leftController && (this._leftController._gazeTracker = this._cameraGazer._gazeTracker.clone("gazeTracker")),
  130966. this._rightController && (this._rightController._gazeTracker = this._cameraGazer._gazeTracker.clone("gazeTracker")))
  130967. },
  130968. enumerable: !1,
  130969. configurable: !0
  130970. }),
  130971. Object.defineProperty(a.prototype, "leftControllerGazeTrackerMesh", {
  130972. get: function() {
  130973. return this._leftController ? this._leftController._gazeTracker : null
  130974. },
  130975. enumerable: !1,
  130976. configurable: !0
  130977. }),
  130978. Object.defineProperty(a.prototype, "rightControllerGazeTrackerMesh", {
  130979. get: function() {
  130980. return this._rightController ? this._rightController._gazeTracker : null
  130981. },
  130982. enumerable: !1,
  130983. configurable: !0
  130984. }),
  130985. Object.defineProperty(a.prototype, "displayGaze", {
  130986. get: function() {
  130987. return this._displayGaze
  130988. },
  130989. set: function(e) {
  130990. this._displayGaze = e,
  130991. e || (this._cameraGazer._gazeTracker.isVisible = !1,
  130992. this._leftController && (this._leftController._gazeTracker.isVisible = !1),
  130993. this._rightController && (this._rightController._gazeTracker.isVisible = !1))
  130994. },
  130995. enumerable: !1,
  130996. configurable: !0
  130997. }),
  130998. Object.defineProperty(a.prototype, "displayLaserPointer", {
  130999. get: function() {
  131000. return this._displayLaserPointer
  131001. },
  131002. set: function(e) {
  131003. this._displayLaserPointer = e,
  131004. e ? (this._rightController && this._rightController._activatePointer(),
  131005. this._leftController && this._leftController._activatePointer()) : (this._rightController && (this._rightController._deactivatePointer(),
  131006. this._rightController._gazeTracker.isVisible = !1),
  131007. this._leftController && (this._leftController._deactivatePointer(),
  131008. this._leftController._gazeTracker.isVisible = !1))
  131009. },
  131010. enumerable: !1,
  131011. configurable: !0
  131012. }),
  131013. Object.defineProperty(a.prototype, "deviceOrientationCamera", {
  131014. get: function() {
  131015. return this._deviceOrientationCamera
  131016. },
  131017. enumerable: !1,
  131018. configurable: !0
  131019. }),
  131020. Object.defineProperty(a.prototype, "currentVRCamera", {
  131021. get: function() {
  131022. return this._webVRready ? this._webVRCamera : this._scene.activeCamera
  131023. },
  131024. enumerable: !1,
  131025. configurable: !0
  131026. }),
  131027. Object.defineProperty(a.prototype, "webVRCamera", {
  131028. get: function() {
  131029. return this._webVRCamera
  131030. },
  131031. enumerable: !1,
  131032. configurable: !0
  131033. }),
  131034. Object.defineProperty(a.prototype, "vrDeviceOrientationCamera", {
  131035. get: function() {
  131036. return this._vrDeviceOrientationCamera
  131037. },
  131038. enumerable: !1,
  131039. configurable: !0
  131040. }),
  131041. Object.defineProperty(a.prototype, "vrButton", {
  131042. get: function() {
  131043. return this._btnVR
  131044. },
  131045. enumerable: !1,
  131046. configurable: !0
  131047. }),
  131048. Object.defineProperty(a.prototype, "_teleportationRequestInitiated", {
  131049. get: function() {
  131050. var e = this._cameraGazer._teleportationRequestInitiated || this._leftController !== null && this._leftController._teleportationRequestInitiated || this._rightController !== null && this._rightController._teleportationRequestInitiated;
  131051. return e
  131052. },
  131053. enumerable: !1,
  131054. configurable: !0
  131055. }),
  131056. a.prototype.completeVRInit = function(e, i) {
  131057. var o = this;
  131058. if (this.xrTestDone = !0,
  131059. i.createFallbackVRDeviceOrientationFreeCamera && (i.useMultiview && (i.vrDeviceOrientationCameraMetrics || (i.vrDeviceOrientationCameraMetrics = VRCameraMetrics.GetDefault()),
  131060. i.vrDeviceOrientationCameraMetrics.multiviewEnabled = !0),
  131061. this._vrDeviceOrientationCamera = new VRDeviceOrientationFreeCamera("VRDeviceOrientationVRHelper",this._position,this._scene,!0,i.vrDeviceOrientationCameraMetrics),
  131062. this._vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE),
  131063. this._webVRCamera = new WebVRFreeCamera("WebVRHelper",this._position,this._scene,i),
  131064. this._webVRCamera.useStandingMatrix(),
  131065. this._cameraGazer = new VRExperienceHelperCameraGazer(function() {
  131066. return o.currentVRCamera
  131067. }
  131068. ,e),
  131069. !this._useCustomVRButton) {
  131070. this._btnVR = document.createElement("BUTTON"),
  131071. this._btnVR.className = "babylonVRicon",
  131072. this._btnVR.id = "babylonVRiconbtn",
  131073. this._btnVR.title = "Click to switch to VR";
  131074. var s = window.SVGSVGElement ? "data:image/svg+xml;charset=UTF-8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%222048%22%20height%3D%221152%22%20viewBox%3D%220%200%202048%201152%22%20version%3D%221.1%22%3E%3Cpath%20transform%3D%22rotate%28180%201024%2C576.0000000000001%29%22%20d%3D%22m1109%2C896q17%2C0%2030%2C-12t13%2C-30t-12.5%2C-30.5t-30.5%2C-12.5l-170%2C0q-18%2C0%20-30.5%2C12.5t-12.5%2C30.5t13%2C30t30%2C12l170%2C0zm-85%2C256q59%2C0%20132.5%2C-1.5t154.5%2C-5.5t164.5%2C-11.5t163%2C-20t150%2C-30t124.5%2C-41.5q23%2C-11%2042%2C-24t38%2C-30q27%2C-25%2041%2C-61.5t14%2C-72.5l0%2C-257q0%2C-123%20-47%2C-232t-128%2C-190t-190%2C-128t-232%2C-47l-81%2C0q-37%2C0%20-68.5%2C14t-60.5%2C34.5t-55.5%2C45t-53%2C45t-53%2C34.5t-55.5%2C14t-55.5%2C-14t-53%2C-34.5t-53%2C-45t-55.5%2C-45t-60.5%2C-34.5t-68.5%2C-14l-81%2C0q-123%2C0%20-232%2C47t-190%2C128t-128%2C190t-47%2C232l0%2C257q0%2C68%2038%2C115t97%2C73q54%2C24%20124.5%2C41.5t150%2C30t163%2C20t164.5%2C11.5t154.5%2C5.5t132.5%2C1.5zm939%2C-298q0%2C39%20-24.5%2C67t-58.5%2C42q-54%2C23%20-122%2C39.5t-143.5%2C28t-155.5%2C19t-157%2C11t-148.5%2C5t-129.5%2C1.5q-59%2C0%20-130%2C-1.5t-148%2C-5t-157%2C-11t-155.5%2C-19t-143.5%2C-28t-122%2C-39.5q-34%2C-14%20-58.5%2C-42t-24.5%2C-67l0%2C-257q0%2C-106%2040.5%2C-199t110%2C-162.5t162.5%2C-109.5t199%2C-40l81%2C0q27%2C0%2052%2C14t50%2C34.5t51%2C44.5t55.5%2C44.5t63.5%2C34.5t74%2C14t74%2C-14t63.5%2C-34.5t55.5%2C-44.5t51%2C-44.5t50%2C-34.5t52%2C-14l14%2C0q37%2C0%2070%2C0.5t64.5%2C4.5t63.5%2C12t68%2C23q71%2C30%20128.5%2C78.5t98.5%2C110t63.5%2C133.5t22.5%2C149l0%2C257z%22%20fill%3D%22white%22%20/%3E%3C/svg%3E%0A" : "https://cdn.babylonjs.com/Assets/vrButton.png"
  131075. , c = ".babylonVRicon { position: absolute; right: 20px; height: 50px; width: 80px; background-color: rgba(51,51,51,0.7); background-image: url(" + s + "); background-size: 80%; background-repeat:no-repeat; background-position: center; border: none; outline: none; transition: transform 0.125s ease-out } .babylonVRicon:hover { transform: scale(1.05) } .babylonVRicon:active {background-color: rgba(51,51,51,1) } .babylonVRicon:focus {background-color: rgba(51,51,51,1) }";
  131076. c += ".babylonVRicon.vrdisplaypresenting { display: none; }";
  131077. var d = document.createElement("style");
  131078. d.appendChild(document.createTextNode(c)),
  131079. document.getElementsByTagName("head")[0].appendChild(d),
  131080. this.moveButtonToBottomRight()
  131081. }
  131082. this._btnVR && this._btnVR.addEventListener("click", function() {
  131083. o.isInVRMode ? o._scene.getEngine().disableVR() : o.enterVR()
  131084. });
  131085. var _ = this._scene.getEngine().getHostWindow();
  131086. !_ || (_.addEventListener("resize", this._onResize),
  131087. document.addEventListener("fullscreenchange", this._onFullscreenChange, !1),
  131088. document.addEventListener("mozfullscreenchange", this._onFullscreenChange, !1),
  131089. document.addEventListener("webkitfullscreenchange", this._onFullscreenChange, !1),
  131090. document.addEventListener("msfullscreenchange", this._onFullscreenChange, !1),
  131091. document.onmsfullscreenchange = this._onFullscreenChange,
  131092. i.createFallbackVRDeviceOrientationFreeCamera ? this.displayVRButton() : this._scene.getEngine().onVRDisplayChangedObservable.add(function(b) {
  131093. b.vrDisplay && o.displayVRButton()
  131094. }),
  131095. this._onKeyDown = function(b) {
  131096. b.keyCode === 27 && o.isInVRMode && o.exitVR()
  131097. }
  131098. ,
  131099. document.addEventListener("keydown", this._onKeyDown),
  131100. this._scene.onPrePointerObservable.add(function() {
  131101. o._hasEnteredVR && o.exitVROnDoubleTap && (o.exitVR(),
  131102. o._fullscreenVRpresenting && o._scene.getEngine().exitFullscreen())
  131103. }, PointerEventTypes.POINTERDOUBLETAP, !1),
  131104. this._onVRDisplayChanged = function(b) {
  131105. return o.onVRDisplayChanged(b)
  131106. }
  131107. ,
  131108. this._onVrDisplayPresentChange = function() {
  131109. return o.onVrDisplayPresentChange()
  131110. }
  131111. ,
  131112. this._onVRRequestPresentStart = function() {
  131113. o._webVRrequesting = !0,
  131114. o.updateButtonVisibility()
  131115. }
  131116. ,
  131117. this._onVRRequestPresentComplete = function() {
  131118. o._webVRrequesting = !1,
  131119. o.updateButtonVisibility()
  131120. }
  131121. ,
  131122. e.getEngine().onVRDisplayChangedObservable.add(this._onVRDisplayChanged),
  131123. e.getEngine().onVRRequestPresentStart.add(this._onVRRequestPresentStart),
  131124. e.getEngine().onVRRequestPresentComplete.add(this._onVRRequestPresentComplete),
  131125. _.addEventListener("vrdisplaypresentchange", this._onVrDisplayPresentChange),
  131126. e.onDisposeObservable.add(function() {
  131127. o.dispose()
  131128. }),
  131129. this._webVRCamera.onControllerMeshLoadedObservable.add(function(b) {
  131130. return o._onDefaultMeshLoaded(b)
  131131. }),
  131132. this._scene.gamepadManager.onGamepadConnectedObservable.add(this._onNewGamepadConnected),
  131133. this._scene.gamepadManager.onGamepadDisconnectedObservable.add(this._onNewGamepadDisconnected),
  131134. this.updateButtonVisibility(),
  131135. this._circleEase = new CircleEase,
  131136. this._circleEase.setEasingMode(EasingFunction.EASINGMODE_EASEINOUT),
  131137. this._teleportationEasing = this._circleEase,
  131138. e.onPointerObservable.add(function(b) {
  131139. o._interactionsEnabled && e.activeCamera === o.vrDeviceOrientationCamera && b.event.pointerType === "mouse" && (b.type === PointerEventTypes.POINTERDOWN ? o._cameraGazer._selectionPointerDown() : b.type === PointerEventTypes.POINTERUP && o._cameraGazer._selectionPointerUp())
  131140. }),
  131141. this.webVROptions.floorMeshes && this.enableTeleportation({
  131142. floorMeshes: this.webVROptions.floorMeshes
  131143. }))
  131144. }
  131145. ,
  131146. a.prototype._onDefaultMeshLoaded = function(e) {
  131147. this._leftController && this._leftController.webVRController == e && e.mesh && this._leftController._setLaserPointerParent(e.mesh),
  131148. this._rightController && this._rightController.webVRController == e && e.mesh && this._rightController._setLaserPointerParent(e.mesh);
  131149. try {
  131150. this.onControllerMeshLoadedObservable.notifyObservers(e)
  131151. } catch (i) {
  131152. Logger$2.Warn("Error in your custom logic onControllerMeshLoaded: " + i)
  131153. }
  131154. }
  131155. ,
  131156. Object.defineProperty(a.prototype, "isInVRMode", {
  131157. get: function() {
  131158. return this.xr && this.webVROptions.useXR && this.xr.baseExperience.state === WebXRState.IN_XR || this._webVRpresenting || this._fullscreenVRpresenting
  131159. },
  131160. enumerable: !1,
  131161. configurable: !0
  131162. }),
  131163. a.prototype.onVrDisplayPresentChange = function() {
  131164. var e = this._scene.getEngine().getVRDevice();
  131165. if (e) {
  131166. var i = this._webVRpresenting;
  131167. this._webVRpresenting = e.isPresenting,
  131168. i && !this._webVRpresenting && this.exitVR()
  131169. } else
  131170. Logger$2.Warn("Detected VRDisplayPresentChange on an unknown VRDisplay. Did you can enterVR on the vrExperienceHelper?");
  131171. this.updateButtonVisibility()
  131172. }
  131173. ,
  131174. a.prototype.onVRDisplayChanged = function(e) {
  131175. this._webVRsupported = e.vrSupported,
  131176. this._webVRready = !!e.vrDisplay,
  131177. this._webVRpresenting = e.vrDisplay && e.vrDisplay.isPresenting,
  131178. this.updateButtonVisibility()
  131179. }
  131180. ,
  131181. a.prototype.moveButtonToBottomRight = function() {
  131182. if (this._inputElement && !this._useCustomVRButton && this._btnVR) {
  131183. var e = this._inputElement.getBoundingClientRect();
  131184. this._btnVR.style.top = e.top + e.height - 70 + "px",
  131185. this._btnVR.style.left = e.left + e.width - 100 + "px"
  131186. }
  131187. }
  131188. ,
  131189. a.prototype.displayVRButton = function() {
  131190. !this._useCustomVRButton && !this._btnVRDisplayed && this._btnVR && (document.body.appendChild(this._btnVR),
  131191. this._btnVRDisplayed = !0)
  131192. }
  131193. ,
  131194. a.prototype.updateButtonVisibility = function() {
  131195. !this._btnVR || this._useCustomVRButton || (this._btnVR.className = "babylonVRicon",
  131196. this.isInVRMode ? this._btnVR.className += " vrdisplaypresenting" : (this._webVRready && (this._btnVR.className += " vrdisplayready"),
  131197. this._webVRsupported && (this._btnVR.className += " vrdisplaysupported"),
  131198. this._webVRrequesting && (this._btnVR.className += " vrdisplayrequesting")))
  131199. }
  131200. ,
  131201. a.prototype.enterVR = function() {
  131202. var e = this;
  131203. if (this.xr) {
  131204. this.xr.baseExperience.enterXRAsync("immersive-vr", "local-floor", this.xr.renderTarget);
  131205. return
  131206. }
  131207. if (this.onEnteringVRObservable)
  131208. try {
  131209. this.onEnteringVRObservable.notifyObservers(this)
  131210. } catch (d) {
  131211. Logger$2.Warn("Error in your custom logic onEnteringVR: " + d)
  131212. }
  131213. if (this._scene.activeCamera) {
  131214. if (this._position = this._scene.activeCamera.position.clone(),
  131215. this.vrDeviceOrientationCamera && (this.vrDeviceOrientationCamera.rotation = Quaternion.FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles(),
  131216. this.vrDeviceOrientationCamera.angularSensibility = 2e3),
  131217. this.webVRCamera) {
  131218. var i = this.webVRCamera.deviceRotationQuaternion.toEulerAngles().y
  131219. , o = Quaternion.FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles().y
  131220. , s = o - i
  131221. , c = this.webVRCamera.rotationQuaternion.toEulerAngles().y;
  131222. this.webVRCamera.rotationQuaternion = Quaternion.FromEulerAngles(0, c + s, 0)
  131223. }
  131224. this._existingCamera = this._scene.activeCamera,
  131225. this._existingCamera.angularSensibilityX && (this._cachedAngularSensibility.angularSensibilityX = this._existingCamera.angularSensibilityX,
  131226. this._existingCamera.angularSensibilityX = Number.MAX_VALUE),
  131227. this._existingCamera.angularSensibilityY && (this._cachedAngularSensibility.angularSensibilityY = this._existingCamera.angularSensibilityY,
  131228. this._existingCamera.angularSensibilityY = Number.MAX_VALUE),
  131229. this._existingCamera.angularSensibility && (this._cachedAngularSensibility.angularSensibility = this._existingCamera.angularSensibility,
  131230. this._existingCamera.angularSensibility = Number.MAX_VALUE)
  131231. }
  131232. this._webVRrequesting || (this._webVRready ? this._webVRpresenting || (this._scene.getEngine().onVRRequestPresentComplete.addOnce(function(d) {
  131233. e.onAfterEnteringVRObservable.notifyObservers({
  131234. success: d
  131235. })
  131236. }),
  131237. this._webVRCamera.position = this._position,
  131238. this._scene.activeCamera = this._webVRCamera) : this._vrDeviceOrientationCamera && (this._vrDeviceOrientationCamera.position = this._position,
  131239. this._scene.activeCamera && (this._vrDeviceOrientationCamera.minZ = this._scene.activeCamera.minZ),
  131240. this._scene.activeCamera = this._vrDeviceOrientationCamera,
  131241. this._scene.getEngine().enterFullscreen(this.requestPointerLockOnFullScreen),
  131242. this.updateButtonVisibility(),
  131243. this._vrDeviceOrientationCamera.onViewMatrixChangedObservable.addOnce(function() {
  131244. e.onAfterEnteringVRObservable.notifyObservers({
  131245. success: !0
  131246. })
  131247. })),
  131248. this._scene.activeCamera && this._inputElement && this._scene.activeCamera.attachControl(),
  131249. this._interactionsEnabled && this._scene.registerBeforeRender(this.beforeRender),
  131250. this._displayLaserPointer && [this._leftController, this._rightController].forEach(function(d) {
  131251. d && d._activatePointer()
  131252. }),
  131253. this._hasEnteredVR = !0)
  131254. }
  131255. ,
  131256. a.prototype.exitVR = function() {
  131257. if (this.xr) {
  131258. this.xr.baseExperience.exitXRAsync();
  131259. return
  131260. }
  131261. if (this._hasEnteredVR) {
  131262. if (this.onExitingVRObservable)
  131263. try {
  131264. this.onExitingVRObservable.notifyObservers(this)
  131265. } catch (i) {
  131266. Logger$2.Warn("Error in your custom logic onExitingVR: " + i)
  131267. }
  131268. this._webVRpresenting && this._scene.getEngine().disableVR(),
  131269. this._scene.activeCamera && (this._position = this._scene.activeCamera.position.clone()),
  131270. this.vrDeviceOrientationCamera && (this.vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE),
  131271. this._deviceOrientationCamera ? (this._deviceOrientationCamera.position = this._position,
  131272. this._scene.activeCamera = this._deviceOrientationCamera,
  131273. this._cachedAngularSensibility.angularSensibilityX && (this._deviceOrientationCamera.angularSensibilityX = this._cachedAngularSensibility.angularSensibilityX,
  131274. this._cachedAngularSensibility.angularSensibilityX = null),
  131275. this._cachedAngularSensibility.angularSensibilityY && (this._deviceOrientationCamera.angularSensibilityY = this._cachedAngularSensibility.angularSensibilityY,
  131276. this._cachedAngularSensibility.angularSensibilityY = null),
  131277. this._cachedAngularSensibility.angularSensibility && (this._deviceOrientationCamera.angularSensibility = this._cachedAngularSensibility.angularSensibility,
  131278. this._cachedAngularSensibility.angularSensibility = null)) : this._existingCamera && (this._existingCamera.position = this._position,
  131279. this._scene.activeCamera = this._existingCamera,
  131280. this._inputElement && this._scene.activeCamera.attachControl(),
  131281. this._cachedAngularSensibility.angularSensibilityX && (this._existingCamera.angularSensibilityX = this._cachedAngularSensibility.angularSensibilityX,
  131282. this._cachedAngularSensibility.angularSensibilityX = null),
  131283. this._cachedAngularSensibility.angularSensibilityY && (this._existingCamera.angularSensibilityY = this._cachedAngularSensibility.angularSensibilityY,
  131284. this._cachedAngularSensibility.angularSensibilityY = null),
  131285. this._cachedAngularSensibility.angularSensibility && (this._existingCamera.angularSensibility = this._cachedAngularSensibility.angularSensibility,
  131286. this._cachedAngularSensibility.angularSensibility = null)),
  131287. this.updateButtonVisibility(),
  131288. this._interactionsEnabled && (this._scene.unregisterBeforeRender(this.beforeRender),
  131289. this._cameraGazer._gazeTracker.isVisible = !1,
  131290. this._leftController && (this._leftController._gazeTracker.isVisible = !1),
  131291. this._rightController && (this._rightController._gazeTracker.isVisible = !1)),
  131292. this._scene.getEngine().resize(),
  131293. [this._leftController, this._rightController].forEach(function(i) {
  131294. i && i._deactivatePointer()
  131295. }),
  131296. this._hasEnteredVR = !1;
  131297. var e = this._scene.getEngine();
  131298. e._onVrDisplayPresentChange && e._onVrDisplayPresentChange()
  131299. }
  131300. }
  131301. ,
  131302. Object.defineProperty(a.prototype, "position", {
  131303. get: function() {
  131304. return this._position
  131305. },
  131306. set: function(e) {
  131307. this._position = e,
  131308. this._scene.activeCamera && (this._scene.activeCamera.position = e)
  131309. },
  131310. enumerable: !1,
  131311. configurable: !0
  131312. }),
  131313. a.prototype.enableInteractions = function() {
  131314. var e = this;
  131315. if (!this._interactionsEnabled) {
  131316. if (this._interactionsRequested = !0,
  131317. this.xr) {
  131318. this.xr.baseExperience.state === WebXRState.IN_XR && this.xr.pointerSelection.attach();
  131319. return
  131320. }
  131321. this._leftController && this._enableInteractionOnController(this._leftController),
  131322. this._rightController && this._enableInteractionOnController(this._rightController),
  131323. this.raySelectionPredicate = function(i) {
  131324. return i.isVisible && (i.isPickable || i.name === e._floorMeshName)
  131325. }
  131326. ,
  131327. this.meshSelectionPredicate = function() {
  131328. return !0
  131329. }
  131330. ,
  131331. this._raySelectionPredicate = function(i) {
  131332. return e._isTeleportationFloor(i) || i.name.indexOf("gazeTracker") === -1 && i.name.indexOf("teleportationTarget") === -1 && i.name.indexOf("torusTeleportation") === -1 ? e.raySelectionPredicate(i) : !1
  131333. }
  131334. ,
  131335. this._interactionsEnabled = !0
  131336. }
  131337. }
  131338. ,
  131339. Object.defineProperty(a.prototype, "_noControllerIsActive", {
  131340. get: function() {
  131341. return !(this._leftController && this._leftController._activePointer) && !(this._rightController && this._rightController._activePointer)
  131342. },
  131343. enumerable: !1,
  131344. configurable: !0
  131345. }),
  131346. a.prototype._isTeleportationFloor = function(e) {
  131347. for (var i = 0; i < this._floorMeshesCollection.length; i++)
  131348. if (this._floorMeshesCollection[i].id === e.id)
  131349. return !0;
  131350. return !!(this._floorMeshName && e.name === this._floorMeshName)
  131351. }
  131352. ,
  131353. a.prototype.addFloorMesh = function(e) {
  131354. !this._floorMeshesCollection || this._floorMeshesCollection.indexOf(e) > -1 || this._floorMeshesCollection.push(e)
  131355. }
  131356. ,
  131357. a.prototype.removeFloorMesh = function(e) {
  131358. if (!!this._floorMeshesCollection) {
  131359. var i = this._floorMeshesCollection.indexOf(e);
  131360. i !== -1 && this._floorMeshesCollection.splice(i, 1)
  131361. }
  131362. }
  131363. ,
  131364. a.prototype.enableTeleportation = function(e) {
  131365. var i = this;
  131366. if (e === void 0 && (e = {}),
  131367. !this._teleportationInitialized) {
  131368. if (this._teleportationRequested = !0,
  131369. this.enableInteractions(),
  131370. this.webVROptions.useXR && (e.floorMeshes || e.floorMeshName)) {
  131371. var o = e.floorMeshes || [];
  131372. if (!o.length) {
  131373. var s = this._scene.getMeshByName(e.floorMeshName);
  131374. s && o.push(s)
  131375. }
  131376. if (this.xr) {
  131377. o.forEach(function(_) {
  131378. i.xr.teleportation.addFloorMesh(_)
  131379. }),
  131380. this.xr.teleportation.attached || this.xr.teleportation.attach();
  131381. return
  131382. } else if (!this.xrTestDone) {
  131383. var c = function() {
  131384. i.xrTestDone && (i._scene.unregisterBeforeRender(c),
  131385. i.xr ? i.xr.teleportation.attached || i.xr.teleportation.attach() : i.enableTeleportation(e))
  131386. };
  131387. this._scene.registerBeforeRender(c);
  131388. return
  131389. }
  131390. }
  131391. e.floorMeshName && (this._floorMeshName = e.floorMeshName),
  131392. e.floorMeshes && (this._floorMeshesCollection = e.floorMeshes),
  131393. e.teleportationMode && (this._teleportationMode = e.teleportationMode),
  131394. e.teleportationTime && e.teleportationTime > 0 && (this._teleportationTime = e.teleportationTime),
  131395. e.teleportationSpeed && e.teleportationSpeed > 0 && (this._teleportationSpeed = e.teleportationSpeed),
  131396. e.easingFunction !== void 0 && (this._teleportationEasing = e.easingFunction),
  131397. this._leftController != null && this._enableTeleportationOnController(this._leftController),
  131398. this._rightController != null && this._enableTeleportationOnController(this._rightController);
  131399. var d = new ImageProcessingConfiguration;
  131400. d.vignetteColor = new Color4(0,0,0,0),
  131401. d.vignetteEnabled = !0,
  131402. this._postProcessMove = new ImageProcessingPostProcess("postProcessMove",1,this._webVRCamera,void 0,void 0,void 0,void 0,d),
  131403. this._webVRCamera.detachPostProcess(this._postProcessMove),
  131404. this._teleportationInitialized = !0,
  131405. this._isDefaultTeleportationTarget && (this._createTeleportationCircles(),
  131406. this._teleportationTarget.scaling.scaleInPlace(this._webVRCamera.deviceScaleFactor))
  131407. }
  131408. }
  131409. ,
  131410. a.prototype._enableInteractionOnController = function(e) {
  131411. var i = this
  131412. , o = e.webVRController.mesh;
  131413. o && (e._interactionsEnabled = !0,
  131414. this.isInVRMode && this._displayLaserPointer && e._activatePointer(),
  131415. this.webVROptions.laserToggle && e.webVRController.onMainButtonStateChangedObservable.add(function(s) {
  131416. i._displayLaserPointer && s.value === 1 && (e._activePointer ? e._deactivatePointer() : e._activatePointer(),
  131417. i.displayGaze && (e._gazeTracker.isVisible = e._activePointer))
  131418. }),
  131419. e.webVRController.onTriggerStateChangedObservable.add(function(s) {
  131420. var c = e;
  131421. i._noControllerIsActive && (c = i._cameraGazer),
  131422. c._pointerDownOnMeshAsked ? s.value < i._padSensibilityDown && c._selectionPointerUp() : s.value > i._padSensibilityUp && c._selectionPointerDown()
  131423. }))
  131424. }
  131425. ,
  131426. a.prototype._checkTeleportWithRay = function(e, i) {
  131427. this._teleportationRequestInitiated && !i._teleportationRequestInitiated || (i._teleportationRequestInitiated ? Math.sqrt(e.y * e.y + e.x * e.x) < this._padSensibilityDown && (this._teleportActive && this.teleportCamera(this._haloCenter),
  131428. i._teleportationRequestInitiated = !1) : e.y < -this._padSensibilityUp && i._dpadPressed && (i._activatePointer(),
  131429. i._teleportationRequestInitiated = !0))
  131430. }
  131431. ,
  131432. a.prototype._checkRotate = function(e, i) {
  131433. i._teleportationRequestInitiated || (i._rotationLeftAsked ? e.x > -this._padSensibilityDown && (i._rotationLeftAsked = !1) : e.x < -this._padSensibilityUp && i._dpadPressed && (i._rotationLeftAsked = !0,
  131434. this._rotationAllowed && this._rotateCamera(!1)),
  131435. i._rotationRightAsked ? e.x < this._padSensibilityDown && (i._rotationRightAsked = !1) : e.x > this._padSensibilityUp && i._dpadPressed && (i._rotationRightAsked = !0,
  131436. this._rotationAllowed && this._rotateCamera(!0)))
  131437. }
  131438. ,
  131439. a.prototype._checkTeleportBackwards = function(e, i) {
  131440. if (!i._teleportationRequestInitiated)
  131441. if (e.y > this._padSensibilityUp && i._dpadPressed) {
  131442. if (!i._teleportationBackRequestInitiated) {
  131443. if (!this.currentVRCamera)
  131444. return;
  131445. var o = Quaternion.FromRotationMatrix(this.currentVRCamera.getWorldMatrix().getRotationMatrix())
  131446. , s = this.currentVRCamera.position;
  131447. this.currentVRCamera.devicePosition && this.currentVRCamera.deviceRotationQuaternion && (o = this.currentVRCamera.deviceRotationQuaternion,
  131448. s = this.currentVRCamera.devicePosition),
  131449. o.toEulerAnglesToRef(this._workingVector),
  131450. this._workingVector.z = 0,
  131451. this._workingVector.x = 0,
  131452. Quaternion.RotationYawPitchRollToRef(this._workingVector.y, this._workingVector.x, this._workingVector.z, this._workingQuaternion),
  131453. this._workingQuaternion.toRotationMatrix(this._workingMatrix),
  131454. Vector3.TransformCoordinatesToRef(this._teleportBackwardsVector, this._workingMatrix, this._workingVector);
  131455. var c = new Ray(s,this._workingVector)
  131456. , d = this._scene.pickWithRay(c, this._raySelectionPredicate);
  131457. d && d.pickedPoint && d.pickedMesh && this._isTeleportationFloor(d.pickedMesh) && d.distance < 5 && this.teleportCamera(d.pickedPoint),
  131458. i._teleportationBackRequestInitiated = !0
  131459. }
  131460. } else
  131461. i._teleportationBackRequestInitiated = !1
  131462. }
  131463. ,
  131464. a.prototype._enableTeleportationOnController = function(e) {
  131465. var i = this
  131466. , o = e.webVRController.mesh;
  131467. o && (e._interactionsEnabled || this._enableInteractionOnController(e),
  131468. e._interactionsEnabled = !0,
  131469. e._teleportationEnabled = !0,
  131470. e.webVRController.controllerType === PoseEnabledControllerType.VIVE && (e._dpadPressed = !1,
  131471. e.webVRController.onPadStateChangedObservable.add(function(s) {
  131472. e._dpadPressed = s.pressed,
  131473. e._dpadPressed || (e._rotationLeftAsked = !1,
  131474. e._rotationRightAsked = !1,
  131475. e._teleportationBackRequestInitiated = !1)
  131476. })),
  131477. e.webVRController.onPadValuesChangedObservable.add(function(s) {
  131478. i.teleportationEnabled && (i._checkTeleportBackwards(s, e),
  131479. i._checkTeleportWithRay(s, e)),
  131480. i._checkRotate(s, e)
  131481. }))
  131482. }
  131483. ,
  131484. a.prototype._createTeleportationCircles = function() {
  131485. this._teleportationTarget = CreateGround("teleportationTarget", {
  131486. width: 2,
  131487. height: 2,
  131488. subdivisions: 2
  131489. }, this._scene),
  131490. this._teleportationTarget.isPickable = !1;
  131491. var e = 512
  131492. , i = new DynamicTexture("DynamicTexture",e,this._scene,!0);
  131493. i.hasAlpha = !0;
  131494. var o = i.getContext()
  131495. , s = e / 2
  131496. , c = e / 2
  131497. , d = 200;
  131498. o.beginPath(),
  131499. o.arc(s, c, d, 0, 2 * Math.PI, !1),
  131500. o.fillStyle = this._teleportationFillColor,
  131501. o.fill(),
  131502. o.lineWidth = 10,
  131503. o.strokeStyle = this._teleportationBorderColor,
  131504. o.stroke(),
  131505. o.closePath(),
  131506. i.update();
  131507. var _ = new StandardMaterial("TextPlaneMaterial",this._scene);
  131508. _.diffuseTexture = i,
  131509. this._teleportationTarget.material = _;
  131510. var b = CreateTorus("torusTeleportation", {
  131511. diameter: .75,
  131512. thickness: .1,
  131513. tessellation: 25,
  131514. updatable: !1
  131515. }, this._scene);
  131516. b.isPickable = !1,
  131517. b.parent = this._teleportationTarget;
  131518. var k = new Animation("animationInnerCircle","position.y",30,Animation.ANIMATIONTYPE_FLOAT,Animation.ANIMATIONLOOPMODE_CYCLE)
  131519. , j = [];
  131520. j.push({
  131521. frame: 0,
  131522. value: 0
  131523. }),
  131524. j.push({
  131525. frame: 30,
  131526. value: .4
  131527. }),
  131528. j.push({
  131529. frame: 60,
  131530. value: 0
  131531. }),
  131532. k.setKeys(j);
  131533. var $ = new SineEase;
  131534. $.setEasingMode(EasingFunction.EASINGMODE_EASEINOUT),
  131535. k.setEasingFunction($),
  131536. b.animations = [],
  131537. b.animations.push(k),
  131538. this._scene.beginAnimation(b, 0, 60, !0),
  131539. this._hideTeleportationTarget()
  131540. }
  131541. ,
  131542. a.prototype._displayTeleportationTarget = function() {
  131543. this._teleportActive = !0,
  131544. this._teleportationInitialized && (this._teleportationTarget.isVisible = !0,
  131545. this._isDefaultTeleportationTarget && (this._teleportationTarget.getChildren()[0].isVisible = !0))
  131546. }
  131547. ,
  131548. a.prototype._hideTeleportationTarget = function() {
  131549. this._teleportActive = !1,
  131550. this._teleportationInitialized && (this._teleportationTarget.isVisible = !1,
  131551. this._isDefaultTeleportationTarget && (this._teleportationTarget.getChildren()[0].isVisible = !1))
  131552. }
  131553. ,
  131554. a.prototype._rotateCamera = function(e) {
  131555. var i = this;
  131556. if (this.currentVRCamera instanceof FreeCamera) {
  131557. e ? this._rotationAngle++ : this._rotationAngle--,
  131558. this.currentVRCamera.animations = [];
  131559. var o = Quaternion.FromRotationMatrix(Matrix.RotationY(Math.PI / 4 * this._rotationAngle))
  131560. , s = new Animation("animationRotation","rotationQuaternion",90,Animation.ANIMATIONTYPE_QUATERNION,Animation.ANIMATIONLOOPMODE_CONSTANT)
  131561. , c = [];
  131562. c.push({
  131563. frame: 0,
  131564. value: this.currentVRCamera.rotationQuaternion
  131565. }),
  131566. c.push({
  131567. frame: 6,
  131568. value: o
  131569. }),
  131570. s.setKeys(c),
  131571. s.setEasingFunction(this._circleEase),
  131572. this.currentVRCamera.animations.push(s),
  131573. this._postProcessMove.animations = [];
  131574. var d = new Animation("animationPP","vignetteWeight",90,Animation.ANIMATIONTYPE_FLOAT,Animation.ANIMATIONLOOPMODE_CONSTANT)
  131575. , _ = [];
  131576. _.push({
  131577. frame: 0,
  131578. value: 0
  131579. }),
  131580. _.push({
  131581. frame: 3,
  131582. value: 4
  131583. }),
  131584. _.push({
  131585. frame: 6,
  131586. value: 0
  131587. }),
  131588. d.setKeys(_),
  131589. d.setEasingFunction(this._circleEase),
  131590. this._postProcessMove.animations.push(d);
  131591. var b = new Animation("animationPP2","vignetteStretch",90,Animation.ANIMATIONTYPE_FLOAT,Animation.ANIMATIONLOOPMODE_CONSTANT)
  131592. , k = [];
  131593. k.push({
  131594. frame: 0,
  131595. value: 0
  131596. }),
  131597. k.push({
  131598. frame: 3,
  131599. value: 10
  131600. }),
  131601. k.push({
  131602. frame: 6,
  131603. value: 0
  131604. }),
  131605. b.setKeys(k),
  131606. b.setEasingFunction(this._circleEase),
  131607. this._postProcessMove.animations.push(b),
  131608. this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0,
  131609. this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0,
  131610. this._postProcessMove.samples = 4,
  131611. this._webVRCamera.attachPostProcess(this._postProcessMove),
  131612. this._scene.beginAnimation(this._postProcessMove, 0, 6, !1, 1, function() {
  131613. i._webVRCamera.detachPostProcess(i._postProcessMove)
  131614. }),
  131615. this._scene.beginAnimation(this.currentVRCamera, 0, 6, !1, 1)
  131616. }
  131617. }
  131618. ,
  131619. a.prototype._moveTeleportationSelectorTo = function(e, i, o) {
  131620. if (e.pickedPoint) {
  131621. i._teleportationRequestInitiated && (this._displayTeleportationTarget(),
  131622. this._haloCenter.copyFrom(e.pickedPoint),
  131623. this._teleportationTarget.position.copyFrom(e.pickedPoint));
  131624. var s = this._convertNormalToDirectionOfRay(e.getNormal(!0, !1), o);
  131625. if (s) {
  131626. var c = Vector3.Cross(Axis.Y, s)
  131627. , d = Vector3.Cross(s, c);
  131628. Vector3.RotationFromAxisToRef(d, s, c, this._teleportationTarget.rotation)
  131629. }
  131630. this._teleportationTarget.position.y += .1
  131631. }
  131632. }
  131633. ,
  131634. a.prototype.teleportCamera = function(e) {
  131635. var i = this;
  131636. if (this.currentVRCamera instanceof FreeCamera) {
  131637. this.webVRCamera.leftCamera ? (this._workingVector.copyFrom(this.webVRCamera.leftCamera.globalPosition),
  131638. this._workingVector.subtractInPlace(this.webVRCamera.position),
  131639. e.subtractToRef(this._workingVector, this._workingVector)) : this._workingVector.copyFrom(e),
  131640. this.isInVRMode ? this._workingVector.y += this.webVRCamera.deviceDistanceToRoomGround() * this._webVRCamera.deviceScaleFactor : this._workingVector.y += this._defaultHeight,
  131641. this.onBeforeCameraTeleport.notifyObservers(this._workingVector);
  131642. var o = 90, s, c;
  131643. if (this._teleportationMode == a.TELEPORTATIONMODE_CONSTANTSPEED) {
  131644. c = o;
  131645. var d = Vector3.Distance(this.currentVRCamera.position, this._workingVector);
  131646. s = this._teleportationSpeed / d
  131647. } else
  131648. c = Math.round(this._teleportationTime * o / 1e3),
  131649. s = 1;
  131650. this.currentVRCamera.animations = [];
  131651. var _ = new Animation("animationCameraTeleportation","position",o,Animation.ANIMATIONTYPE_VECTOR3,Animation.ANIMATIONLOOPMODE_CONSTANT)
  131652. , b = [{
  131653. frame: 0,
  131654. value: this.currentVRCamera.position
  131655. }, {
  131656. frame: c,
  131657. value: this._workingVector
  131658. }];
  131659. _.setKeys(b),
  131660. _.setEasingFunction(this._teleportationEasing),
  131661. this.currentVRCamera.animations.push(_),
  131662. this._postProcessMove.animations = [];
  131663. var k = Math.round(c / 2)
  131664. , j = new Animation("animationPP","vignetteWeight",o,Animation.ANIMATIONTYPE_FLOAT,Animation.ANIMATIONLOOPMODE_CONSTANT)
  131665. , $ = [];
  131666. $.push({
  131667. frame: 0,
  131668. value: 0
  131669. }),
  131670. $.push({
  131671. frame: k,
  131672. value: 8
  131673. }),
  131674. $.push({
  131675. frame: c,
  131676. value: 0
  131677. }),
  131678. j.setKeys($),
  131679. this._postProcessMove.animations.push(j);
  131680. var _e = new Animation("animationPP2","vignetteStretch",o,Animation.ANIMATIONTYPE_FLOAT,Animation.ANIMATIONLOOPMODE_CONSTANT)
  131681. , et = [];
  131682. et.push({
  131683. frame: 0,
  131684. value: 0
  131685. }),
  131686. et.push({
  131687. frame: k,
  131688. value: 10
  131689. }),
  131690. et.push({
  131691. frame: c,
  131692. value: 0
  131693. }),
  131694. _e.setKeys(et),
  131695. this._postProcessMove.animations.push(_e),
  131696. this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0,
  131697. this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0,
  131698. this._webVRCamera.attachPostProcess(this._postProcessMove),
  131699. this._scene.beginAnimation(this._postProcessMove, 0, c, !1, s, function() {
  131700. i._webVRCamera.detachPostProcess(i._postProcessMove)
  131701. }),
  131702. this._scene.beginAnimation(this.currentVRCamera, 0, c, !1, s, function() {
  131703. i.onAfterCameraTeleport.notifyObservers(i._workingVector)
  131704. }),
  131705. this._hideTeleportationTarget()
  131706. }
  131707. }
  131708. ,
  131709. a.prototype._convertNormalToDirectionOfRay = function(e, i) {
  131710. if (e) {
  131711. var o = Math.acos(Vector3.Dot(e, i.direction));
  131712. o < Math.PI / 2 && e.scaleInPlace(-1)
  131713. }
  131714. return e
  131715. }
  131716. ,
  131717. a.prototype._castRayAndSelectObject = function(e) {
  131718. if (this.currentVRCamera instanceof FreeCamera) {
  131719. var i = e._getForwardRay(this._rayLength)
  131720. , o = this._scene.pickWithRay(i, this._raySelectionPredicate);
  131721. if (o && this._scene.simulatePointerMove(o, {
  131722. pointerId: e._id
  131723. }),
  131724. e._currentHit = o,
  131725. o && o.pickedPoint) {
  131726. if (this._displayGaze) {
  131727. var s = 1;
  131728. e._gazeTracker.isVisible = !0,
  131729. e._isActionableMesh && (s = 3),
  131730. this.updateGazeTrackerScale && (e._gazeTracker.scaling.x = o.distance * s,
  131731. e._gazeTracker.scaling.y = o.distance * s,
  131732. e._gazeTracker.scaling.z = o.distance * s);
  131733. var c = this._convertNormalToDirectionOfRay(o.getNormal(), i)
  131734. , d = .002;
  131735. if (c) {
  131736. var _ = Vector3.Cross(Axis.Y, c)
  131737. , b = Vector3.Cross(c, _);
  131738. Vector3.RotationFromAxisToRef(b, c, _, e._gazeTracker.rotation)
  131739. }
  131740. e._gazeTracker.position.copyFrom(o.pickedPoint),
  131741. e._gazeTracker.position.x < 0 ? e._gazeTracker.position.x += d : e._gazeTracker.position.x -= d,
  131742. e._gazeTracker.position.y < 0 ? e._gazeTracker.position.y += d : e._gazeTracker.position.y -= d,
  131743. e._gazeTracker.position.z < 0 ? e._gazeTracker.position.z += d : e._gazeTracker.position.z -= d
  131744. }
  131745. e._updatePointerDistance(o.distance)
  131746. } else
  131747. e._updatePointerDistance(),
  131748. e._gazeTracker.isVisible = !1;
  131749. if (o && o.pickedMesh) {
  131750. if (this._teleportationInitialized && this._isTeleportationFloor(o.pickedMesh) && o.pickedPoint) {
  131751. e._currentMeshSelected && !this._isTeleportationFloor(e._currentMeshSelected) && this._notifySelectedMeshUnselected(e._currentMeshSelected),
  131752. e._currentMeshSelected = null,
  131753. e._teleportationRequestInitiated && this._moveTeleportationSelectorTo(o, e, i);
  131754. return
  131755. }
  131756. if (o.pickedMesh !== e._currentMeshSelected)
  131757. if (this.meshSelectionPredicate(o.pickedMesh)) {
  131758. this.onNewMeshPicked.notifyObservers(o),
  131759. e._currentMeshSelected = o.pickedMesh,
  131760. o.pickedMesh.isPickable && o.pickedMesh.actionManager ? (this.changeGazeColor(this._pickedGazeColor),
  131761. this.changeLaserColor(this._pickedLaserColor),
  131762. e._isActionableMesh = !0) : (this.changeGazeColor(this._gazeColor),
  131763. this.changeLaserColor(this._laserColor),
  131764. e._isActionableMesh = !1);
  131765. try {
  131766. this.onNewMeshSelected.notifyObservers(o.pickedMesh);
  131767. var k = e;
  131768. k.webVRController && this.onMeshSelectedWithController.notifyObservers({
  131769. mesh: o.pickedMesh,
  131770. controller: k.webVRController
  131771. })
  131772. } catch (j) {
  131773. Logger$2.Warn("Error while raising onNewMeshSelected or onMeshSelectedWithController: " + j)
  131774. }
  131775. } else
  131776. this._notifySelectedMeshUnselected(e._currentMeshSelected),
  131777. e._currentMeshSelected = null,
  131778. this.changeGazeColor(this._gazeColor),
  131779. this.changeLaserColor(this._laserColor)
  131780. } else
  131781. this._notifySelectedMeshUnselected(e._currentMeshSelected),
  131782. e._currentMeshSelected = null,
  131783. this.changeGazeColor(this._gazeColor),
  131784. this.changeLaserColor(this._laserColor)
  131785. }
  131786. }
  131787. ,
  131788. a.prototype._notifySelectedMeshUnselected = function(e) {
  131789. e && this.onSelectedMeshUnselected.notifyObservers(e)
  131790. }
  131791. ,
  131792. a.prototype.setLaserColor = function(e, i) {
  131793. i === void 0 && (i = this._pickedLaserColor),
  131794. this._laserColor = e,
  131795. this._pickedLaserColor = i
  131796. }
  131797. ,
  131798. a.prototype.setLaserLightingState = function(e) {
  131799. e === void 0 && (e = !0),
  131800. this._leftController && this._leftController._setLaserPointerLightingDisabled(!e),
  131801. this._rightController && this._rightController._setLaserPointerLightingDisabled(!e)
  131802. }
  131803. ,
  131804. a.prototype.setGazeColor = function(e, i) {
  131805. i === void 0 && (i = this._pickedGazeColor),
  131806. this._gazeColor = e,
  131807. this._pickedGazeColor = i
  131808. }
  131809. ,
  131810. a.prototype.changeLaserColor = function(e) {
  131811. !this.updateControllerLaserColor || (this._leftController && this._leftController._setLaserPointerColor(e),
  131812. this._rightController && this._rightController._setLaserPointerColor(e))
  131813. }
  131814. ,
  131815. a.prototype.changeGazeColor = function(e) {
  131816. !this.updateGazeTrackerColor || !this._cameraGazer._gazeTracker.material || (this._cameraGazer._gazeTracker.material.emissiveColor = e,
  131817. this._leftController && (this._leftController._gazeTracker.material.emissiveColor = e),
  131818. this._rightController && (this._rightController._gazeTracker.material.emissiveColor = e))
  131819. }
  131820. ,
  131821. a.prototype.dispose = function() {
  131822. this.isInVRMode && this.exitVR(),
  131823. this._postProcessMove && this._postProcessMove.dispose(),
  131824. this._webVRCamera && this._webVRCamera.dispose(),
  131825. this._vrDeviceOrientationCamera && this._vrDeviceOrientationCamera.dispose(),
  131826. !this._useCustomVRButton && this._btnVR && this._btnVR.parentNode && document.body.removeChild(this._btnVR),
  131827. this._deviceOrientationCamera && this._scene.activeCamera != this._deviceOrientationCamera && this._deviceOrientationCamera.dispose(),
  131828. this._cameraGazer && this._cameraGazer.dispose(),
  131829. this._leftController && this._leftController.dispose(),
  131830. this._rightController && this._rightController.dispose(),
  131831. this._teleportationTarget && this._teleportationTarget.dispose(),
  131832. this.xr && this.xr.dispose(),
  131833. this._floorMeshesCollection = [],
  131834. document.removeEventListener("keydown", this._onKeyDown),
  131835. window.removeEventListener("vrdisplaypresentchange", this._onVrDisplayPresentChange),
  131836. window.removeEventListener("resize", this._onResize),
  131837. document.removeEventListener("fullscreenchange", this._onFullscreenChange),
  131838. document.removeEventListener("mozfullscreenchange", this._onFullscreenChange),
  131839. document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange),
  131840. document.removeEventListener("msfullscreenchange", this._onFullscreenChange),
  131841. document.onmsfullscreenchange = null,
  131842. this._scene.getEngine().onVRDisplayChangedObservable.removeCallback(this._onVRDisplayChanged),
  131843. this._scene.getEngine().onVRRequestPresentStart.removeCallback(this._onVRRequestPresentStart),
  131844. this._scene.getEngine().onVRRequestPresentComplete.removeCallback(this._onVRRequestPresentComplete),
  131845. window.removeEventListener("vrdisplaypresentchange", this._onVrDisplayPresentChange),
  131846. this._scene.gamepadManager.onGamepadConnectedObservable.removeCallback(this._onNewGamepadConnected),
  131847. this._scene.gamepadManager.onGamepadDisconnectedObservable.removeCallback(this._onNewGamepadDisconnected),
  131848. this._scene.unregisterBeforeRender(this.beforeRender)
  131849. }
  131850. ,
  131851. a.prototype.getClassName = function() {
  131852. return "VRExperienceHelper"
  131853. }
  131854. ,
  131855. a.TELEPORTATIONMODE_CONSTANTTIME = 0,
  131856. a.TELEPORTATIONMODE_CONSTANTSPEED = 1,
  131857. a
  131858. }()
  131859. , _ENVTextureLoader = function() {
  131860. function a() {
  131861. this.supportCascades = !1
  131862. }
  131863. return a.prototype.canLoad = function(e) {
  131864. return EndsWith(e, ".env")
  131865. }
  131866. ,
  131867. a.prototype.loadCubeData = function(e, i, o, s, c) {
  131868. if (!Array.isArray(e)) {
  131869. var d = GetEnvInfo(e);
  131870. if (d) {
  131871. i.width = d.width,
  131872. i.height = d.width;
  131873. try {
  131874. UploadEnvSpherical(i, d),
  131875. UploadEnvLevelsAsync(i, e, d).then(function() {
  131876. i.isReady = !0,
  131877. i.onLoadedObservable.notifyObservers(i),
  131878. i.onLoadedObservable.clear(),
  131879. s && s()
  131880. }, function(_) {
  131881. c == null || c("Can not upload environment levels", _)
  131882. })
  131883. } catch (_) {
  131884. c == null || c("Can not upload environment file", _)
  131885. }
  131886. } else
  131887. c && c("Can not parse the environment file", null)
  131888. }
  131889. }
  131890. ,
  131891. a.prototype.loadData = function(e, i, o) {
  131892. throw ".env not supported in 2d."
  131893. }
  131894. ,
  131895. a
  131896. }();
  131897. Engine._TextureLoaders.push(new _ENVTextureLoader);
  131898. var KhronosTextureContainer = function() {
  131899. function a(e, i, o, s) {
  131900. if (this.data = e,
  131901. this.isInvalid = !1,
  131902. !a.IsValid(e)) {
  131903. this.isInvalid = !0,
  131904. Logger$2.Error("texture missing KTX identifier");
  131905. return
  131906. }
  131907. var c = Uint32Array.BYTES_PER_ELEMENT
  131908. , d = new DataView(this.data.buffer,this.data.byteOffset + 12,13 * c)
  131909. , _ = d.getUint32(0, !0)
  131910. , b = _ === 67305985;
  131911. if (this.glType = d.getUint32(1 * c, b),
  131912. this.glTypeSize = d.getUint32(2 * c, b),
  131913. this.glFormat = d.getUint32(3 * c, b),
  131914. this.glInternalFormat = d.getUint32(4 * c, b),
  131915. this.glBaseInternalFormat = d.getUint32(5 * c, b),
  131916. this.pixelWidth = d.getUint32(6 * c, b),
  131917. this.pixelHeight = d.getUint32(7 * c, b),
  131918. this.pixelDepth = d.getUint32(8 * c, b),
  131919. this.numberOfArrayElements = d.getUint32(9 * c, b),
  131920. this.numberOfFaces = d.getUint32(10 * c, b),
  131921. this.numberOfMipmapLevels = d.getUint32(11 * c, b),
  131922. this.bytesOfKeyValueData = d.getUint32(12 * c, b),
  131923. this.glType !== 0) {
  131924. Logger$2.Error("only compressed formats currently supported");
  131925. return
  131926. } else
  131927. this.numberOfMipmapLevels = Math.max(1, this.numberOfMipmapLevels);
  131928. if (this.pixelHeight === 0 || this.pixelDepth !== 0) {
  131929. Logger$2.Error("only 2D textures currently supported");
  131930. return
  131931. }
  131932. if (this.numberOfArrayElements !== 0) {
  131933. Logger$2.Error("texture arrays not currently supported");
  131934. return
  131935. }
  131936. if (this.numberOfFaces !== i) {
  131937. Logger$2.Error("number of faces expected" + i + ", but found " + this.numberOfFaces);
  131938. return
  131939. }
  131940. this.loadType = a.COMPRESSED_2D
  131941. }
  131942. return a.prototype.uploadLevels = function(e, i) {
  131943. switch (this.loadType) {
  131944. case a.COMPRESSED_2D:
  131945. this._upload2DCompressedLevels(e, i);
  131946. break
  131947. }
  131948. }
  131949. ,
  131950. a.prototype._upload2DCompressedLevels = function(e, i) {
  131951. for (var o = a.HEADER_LEN + this.bytesOfKeyValueData, s = this.pixelWidth, c = this.pixelHeight, d = i ? this.numberOfMipmapLevels : 1, _ = 0; _ < d; _++) {
  131952. var b = new Int32Array(this.data.buffer,this.data.byteOffset + o,1)[0];
  131953. o += 4;
  131954. for (var k = 0; k < this.numberOfFaces; k++) {
  131955. var j = new Uint8Array(this.data.buffer,this.data.byteOffset + o,b)
  131956. , $ = e.getEngine();
  131957. $._uploadCompressedDataToTextureDirectly(e, this.glInternalFormat, s, c, j, k, _),
  131958. o += b,
  131959. o += 3 - (b + 3) % 4
  131960. }
  131961. s = Math.max(1, s * .5),
  131962. c = Math.max(1, c * .5)
  131963. }
  131964. }
  131965. ,
  131966. a.IsValid = function(e) {
  131967. if (e.byteLength >= 12) {
  131968. var i = new Uint8Array(e.buffer,e.byteOffset,12);
  131969. if (i[0] === 171 && i[1] === 75 && i[2] === 84 && i[3] === 88 && i[4] === 32 && i[5] === 49 && i[6] === 49 && i[7] === 187 && i[8] === 13 && i[9] === 10 && i[10] === 26 && i[11] === 10)
  131970. return !0
  131971. }
  131972. return !1
  131973. }
  131974. ,
  131975. a.HEADER_LEN = 12 + 13 * 4,
  131976. a.COMPRESSED_2D = 0,
  131977. a.COMPRESSED_3D = 1,
  131978. a.TEX_2D = 2,
  131979. a.TEX_3D = 3,
  131980. a
  131981. }()
  131982. , KhronosTextureContainer2 = function() {
  131983. function a(e, i) {
  131984. i === void 0 && (i = a.DefaultNumWorkers),
  131985. this._engine = e,
  131986. a._Initialized || a._CreateWorkerPool(i)
  131987. }
  131988. return a.GetDefaultNumWorkers = function() {
  131989. return typeof navigator != "object" || !navigator.hardwareConcurrency ? 1 : Math.min(Math.floor(navigator.hardwareConcurrency * .5), 4)
  131990. }
  131991. ,
  131992. a._CreateWorkerPool = function(e) {
  131993. this._Initialized = !0,
  131994. e && typeof Worker == "function" ? a._WorkerPoolPromise = new Promise(function(i) {
  131995. for (var o = "(" + workerFunc + ")()", s = URL.createObjectURL(new Blob([o],{
  131996. type: "application/javascript"
  131997. })), c = new Array(e), d = 0; d < c.length; d++)
  131998. c[d] = new Promise(function(_, b) {
  131999. var k = new Worker(s)
  132000. , j = function(_e) {
  132001. k.removeEventListener("error", j),
  132002. k.removeEventListener("message", $),
  132003. b(_e)
  132004. }
  132005. , $ = function(_e) {
  132006. _e.data.action === "init" && (k.removeEventListener("error", j),
  132007. k.removeEventListener("message", $),
  132008. _(k))
  132009. };
  132010. k.addEventListener("error", j),
  132011. k.addEventListener("message", $),
  132012. k.postMessage({
  132013. action: "init",
  132014. urls: a.URLConfig
  132015. })
  132016. }
  132017. );
  132018. Promise.all(c).then(function(_) {
  132019. i(new WorkerPool(_))
  132020. })
  132021. }
  132022. ) : typeof KTX2DECODER == "undefined" ? a._NoWorkerPromise = Tools.LoadScriptAsync(a.URLConfig.jsDecoderModule).then(function() {
  132023. KTX2DECODER.MSCTranscoder.UseFromWorkerThread = !1,
  132024. KTX2DECODER.WASMMemoryManager.LoadBinariesFromCurrentThread = !0;
  132025. var i = a.URLConfig;
  132026. i.wasmUASTCToASTC !== null && (KTX2DECODER.LiteTranscoder_UASTC_ASTC.WasmModuleURL = i.wasmUASTCToASTC),
  132027. i.wasmUASTCToBC7 !== null && (KTX2DECODER.LiteTranscoder_UASTC_BC7.WasmModuleURL = i.wasmUASTCToBC7),
  132028. i.wasmUASTCToRGBA_UNORM !== null && (KTX2DECODER.LiteTranscoder_UASTC_RGBA_UNORM.WasmModuleURL = i.wasmUASTCToRGBA_UNORM),
  132029. i.wasmUASTCToRGBA_SRGB !== null && (KTX2DECODER.LiteTranscoder_UASTC_RGBA_SRGB.WasmModuleURL = i.wasmUASTCToRGBA_SRGB),
  132030. i.jsMSCTranscoder !== null && (KTX2DECODER.MSCTranscoder.JSModuleURL = i.jsMSCTranscoder),
  132031. i.wasmMSCTranscoder !== null && (KTX2DECODER.MSCTranscoder.WasmModuleURL = i.wasmMSCTranscoder),
  132032. i.wasmZSTDDecoder !== null && (KTX2DECODER.ZSTDDecoder.WasmModuleURL = i.wasmZSTDDecoder)
  132033. }) : (KTX2DECODER.MSCTranscoder.UseFromWorkerThread = !1,
  132034. KTX2DECODER.WASMMemoryManager.LoadBinariesFromCurrentThread = !0)
  132035. }
  132036. ,
  132037. a.prototype.uploadAsync = function(e, i, o) {
  132038. var s = this
  132039. , c = this._engine.getCaps()
  132040. , d = {
  132041. astc: !!c.astc,
  132042. bptc: !!c.bptc,
  132043. s3tc: !!c.s3tc,
  132044. pvrtc: !!c.pvrtc,
  132045. etc2: !!c.etc2,
  132046. etc1: !!c.etc1
  132047. };
  132048. return a._WorkerPoolPromise ? a._WorkerPoolPromise.then(function(_) {
  132049. return new Promise(function(b, k) {
  132050. _.push(function(j, $) {
  132051. var _e = function(tt) {
  132052. j.removeEventListener("error", _e),
  132053. j.removeEventListener("message", et),
  132054. k(tt),
  132055. $()
  132056. }
  132057. , et = function(tt) {
  132058. if (tt.data.action === "decoded") {
  132059. if (j.removeEventListener("error", _e),
  132060. j.removeEventListener("message", et),
  132061. !tt.data.success)
  132062. k({
  132063. message: tt.data.msg
  132064. });
  132065. else
  132066. try {
  132067. s._createTexture(tt.data.decodedData, i, o),
  132068. b()
  132069. } catch (rt) {
  132070. k({
  132071. message: rt
  132072. })
  132073. }
  132074. $()
  132075. }
  132076. };
  132077. j.addEventListener("error", _e),
  132078. j.addEventListener("message", et),
  132079. j.postMessage({
  132080. action: "decode",
  132081. data: e,
  132082. caps: d,
  132083. options: o
  132084. })
  132085. })
  132086. }
  132087. )
  132088. }) : a._NoWorkerPromise ? a._NoWorkerPromise.then(function() {
  132089. return new Promise(function(_, b) {
  132090. a._Ktx2Decoder || (a._Ktx2Decoder = new KTX2DECODER.KTX2Decoder),
  132091. a._Ktx2Decoder.decode(e, c).then(function(k) {
  132092. s._createTexture(k, i),
  132093. _()
  132094. }).catch(function(k) {
  132095. b({
  132096. message: k
  132097. })
  132098. })
  132099. }
  132100. )
  132101. }) : new Promise(function(_, b) {
  132102. a._Ktx2Decoder || (a._Ktx2Decoder = new KTX2DECODER.KTX2Decoder),
  132103. a._Ktx2Decoder.decode(e, c).then(function(k) {
  132104. s._createTexture(k, i),
  132105. _()
  132106. }).catch(function(k) {
  132107. b({
  132108. message: k
  132109. })
  132110. })
  132111. }
  132112. )
  132113. }
  132114. ,
  132115. a.prototype.dispose = function() {
  132116. a._WorkerPoolPromise && a._WorkerPoolPromise.then(function(e) {
  132117. e.dispose()
  132118. }),
  132119. delete a._WorkerPoolPromise,
  132120. delete a._NoWorkerPromise
  132121. }
  132122. ,
  132123. a.prototype._createTexture = function(e, i, o) {
  132124. var s = 3553;
  132125. if (this._engine._bindTextureDirectly(s, i),
  132126. o && (o.transcodedFormat = e.transcodedFormat,
  132127. o.isInGammaSpace = e.isInGammaSpace,
  132128. o.hasAlpha = e.hasAlpha,
  132129. o.transcoderName = e.transcoderName),
  132130. e.transcodedFormat === 32856 ? (i.type = 0,
  132131. i.format = 5) : i.format = e.transcodedFormat,
  132132. i._gammaSpace = e.isInGammaSpace,
  132133. i.generateMipMaps = e.mipmaps.length > 1,
  132134. e.errors)
  132135. throw new Error("KTX2 container - could not transcode the data. " + e.errors);
  132136. for (var c = 0; c < e.mipmaps.length; ++c) {
  132137. var d = e.mipmaps[c];
  132138. if (!d || !d.data)
  132139. throw new Error("KTX2 container - could not transcode one of the image");
  132140. e.transcodedFormat === 32856 ? (i.width = d.width,
  132141. i.height = d.height,
  132142. this._engine._uploadDataToTextureDirectly(i, d.data, 0, c, void 0, !0)) : this._engine._uploadCompressedDataToTextureDirectly(i, e.transcodedFormat, d.width, d.height, d.data, 0, c)
  132143. }
  132144. i._extension = ".ktx2",
  132145. i.width = e.mipmaps[0].width,
  132146. i.height = e.mipmaps[0].height,
  132147. i.isReady = !0,
  132148. this._engine._bindTextureDirectly(s, null)
  132149. }
  132150. ,
  132151. a.IsValid = function(e) {
  132152. if (e.byteLength >= 12) {
  132153. var i = new Uint8Array(e.buffer,e.byteOffset,12);
  132154. if (i[0] === 171 && i[1] === 75 && i[2] === 84 && i[3] === 88 && i[4] === 32 && i[5] === 50 && i[6] === 48 && i[7] === 187 && i[8] === 13 && i[9] === 10 && i[10] === 26 && i[11] === 10)
  132155. return !0
  132156. }
  132157. return !1
  132158. }
  132159. ,
  132160. a.URLConfig = {
  132161. jsDecoderModule: "https://app-asset-1258211750.file.myqcloud.com/4/ktx2/ktx2decoder/babylon.ktx2Decoder.js",
  132162. wasmUASTCToASTC: "https://app-asset-1258211750.file.myqcloud.com/4/ktx2/ktx2decoder/ktx2Transcoders/uastc_astc.wasm",
  132163. wasmUASTCToBC7: "https://app-asset-1258211750.file.myqcloud.com/4/ktx2/ktx2decoder/ktx2Transcoders/uastc_bc7.wasm",
  132164. wasmUASTCToRGBA_UNORM: "https://app-asset-1258211750.file.myqcloud.com/4/ktx2/ktx2decoder/ktx2Transcoders/uastc_rgba32_unorm.wasm",
  132165. wasmUASTCToRGBA_SRGB: "https://app-asset-1258211750.file.myqcloud.com/4/ktx2/ktx2decoder/ktx2Transcoders/uastc_rgba32_srgb.wasm",
  132166. jsMSCTranscoder: "https://app-asset-1258211750.file.myqcloud.com/4/ktx2/ktx2decoder/ktx2Transcoders/msc_basis_transcoder.js",
  132167. wasmMSCTranscoder: "https://app-asset-1258211750.file.myqcloud.com/4/ktx2/ktx2decoder/ktx2Transcoders/msc_basis_transcoder.wasm",
  132168. wasmZSTDDecoder: null
  132169. },
  132170. a.DefaultNumWorkers = a.GetDefaultNumWorkers(),
  132171. a
  132172. }();
  132173. function workerFunc() {
  132174. var a;
  132175. onmessage = function(e) {
  132176. if (!!e.data)
  132177. switch (e.data.action) {
  132178. case "init":
  132179. var i = e.data.urls;
  132180. importScripts(i.jsDecoderModule),
  132181. i.wasmUASTCToASTC !== null && (KTX2DECODER.LiteTranscoder_UASTC_ASTC.WasmModuleURL = i.wasmUASTCToASTC),
  132182. i.wasmUASTCToBC7 !== null && (KTX2DECODER.LiteTranscoder_UASTC_BC7.WasmModuleURL = i.wasmUASTCToBC7),
  132183. i.wasmUASTCToRGBA_UNORM !== null && (KTX2DECODER.LiteTranscoder_UASTC_RGBA_UNORM.WasmModuleURL = i.wasmUASTCToRGBA_UNORM),
  132184. i.wasmUASTCToRGBA_SRGB !== null && (KTX2DECODER.LiteTranscoder_UASTC_RGBA_SRGB.WasmModuleURL = i.wasmUASTCToRGBA_SRGB),
  132185. i.jsMSCTranscoder !== null && (KTX2DECODER.MSCTranscoder.JSModuleURL = i.jsMSCTranscoder),
  132186. i.wasmMSCTranscoder !== null && (KTX2DECODER.MSCTranscoder.WasmModuleURL = i.wasmMSCTranscoder),
  132187. i.wasmZSTDDecoder !== null && (KTX2DECODER.ZSTDDecoder.WasmModuleURL = i.wasmZSTDDecoder),
  132188. a = new KTX2DECODER.KTX2Decoder,
  132189. postMessage({
  132190. action: "init"
  132191. });
  132192. break;
  132193. case "decode":
  132194. a.decode(e.data.data, e.data.caps, e.data.options).then(function(o) {
  132195. for (var s = [], c = 0; c < o.mipmaps.length; ++c) {
  132196. var d = o.mipmaps[c];
  132197. d && d.data && s.push(d.data.buffer)
  132198. }
  132199. postMessage({
  132200. action: "decoded",
  132201. success: !0,
  132202. decodedData: o
  132203. }, s)
  132204. }).catch(function(o) {
  132205. postMessage({
  132206. action: "decoded",
  132207. success: !1,
  132208. msg: o
  132209. })
  132210. });
  132211. break
  132212. }
  132213. }
  132214. }
  132215. var _KTXTextureLoader = function() {
  132216. function a() {
  132217. this.supportCascades = !1
  132218. }
  132219. return a.prototype.canLoad = function(e, i) {
  132220. return EndsWith(e, ".ktx") || EndsWith(e, ".ktx2") || i === "image/ktx" || i === "image/ktx2"
  132221. }
  132222. ,
  132223. a.prototype.loadCubeData = function(e, i, o, s, c) {
  132224. if (!Array.isArray(e)) {
  132225. i._invertVScale = !i.invertY;
  132226. var d = i.getEngine()
  132227. , _ = new KhronosTextureContainer(e,6)
  132228. , b = _.numberOfMipmapLevels > 1 && i.generateMipMaps;
  132229. d._unpackFlipY(!0),
  132230. _.uploadLevels(i, i.generateMipMaps),
  132231. i.width = _.pixelWidth,
  132232. i.height = _.pixelHeight,
  132233. d._setCubeMapTextureParams(i, b),
  132234. i.isReady = !0,
  132235. i.onLoadedObservable.notifyObservers(i),
  132236. i.onLoadedObservable.clear(),
  132237. s && s()
  132238. }
  132239. }
  132240. ,
  132241. a.prototype.loadData = function(e, i, o, s) {
  132242. if (KhronosTextureContainer.IsValid(e)) {
  132243. i._invertVScale = !i.invertY;
  132244. var c = new KhronosTextureContainer(e,1);
  132245. o(c.pixelWidth, c.pixelHeight, i.generateMipMaps, !0, function() {
  132246. c.uploadLevels(i, i.generateMipMaps)
  132247. }, c.isInvalid)
  132248. } else if (KhronosTextureContainer2.IsValid(e)) {
  132249. var d = new KhronosTextureContainer2(i.getEngine());
  132250. d.uploadAsync(e, i, s).then(function() {
  132251. o(i.width, i.height, i.generateMipMaps, !0, function() {}, !1)
  132252. }, function(_) {
  132253. Logger$2.Warn("Failed to load KTX2 texture data: " + _.message),
  132254. o(0, 0, !1, !1, function() {}, !0)
  132255. })
  132256. } else
  132257. Logger$2.Error("texture missing KTX identifier"),
  132258. o(0, 0, !1, !1, function() {}, !0)
  132259. }
  132260. ,
  132261. a
  132262. }();
  132263. Engine._TextureLoaders.unshift(new _KTXTextureLoader);
  132264. var WebXRCamera = function(a) {
  132265. __extends(e, a);
  132266. function e(i, o, s) {
  132267. var c = a.call(this, i, Vector3.Zero(), o) || this;
  132268. return c._xrSessionManager = s,
  132269. c._firstFrame = !1,
  132270. c._referenceQuaternion = Quaternion.Identity(),
  132271. c._referencedPosition = new Vector3,
  132272. c._trackingState = WebXRTrackingState.NOT_TRACKING,
  132273. c.onBeforeCameraTeleport = new Observable,
  132274. c.onAfterCameraTeleport = new Observable,
  132275. c.onTrackingStateChanged = new Observable,
  132276. c.compensateOnFirstFrame = !0,
  132277. c._rotate180 = new Quaternion(0,1,0,0),
  132278. c.minZ = .1,
  132279. c.rotationQuaternion = new Quaternion,
  132280. c.cameraRigMode = Camera$1.RIG_MODE_CUSTOM,
  132281. c.updateUpVectorFromRotation = !0,
  132282. c._updateNumberOfRigCameras(1),
  132283. c.freezeProjectionMatrix(),
  132284. c._xrSessionManager.onXRSessionInit.add(function() {
  132285. c._referencedPosition.copyFromFloats(0, 0, 0),
  132286. c._referenceQuaternion.copyFromFloats(0, 0, 0, 1),
  132287. c._firstFrame = c.compensateOnFirstFrame
  132288. }),
  132289. c._xrSessionManager.onXRFrameObservable.add(function(d) {
  132290. c._firstFrame && c._updateFromXRSession(),
  132291. c._updateReferenceSpace(),
  132292. c._updateFromXRSession()
  132293. }, void 0, !0),
  132294. c
  132295. }
  132296. return Object.defineProperty(e.prototype, "trackingState", {
  132297. get: function() {
  132298. return this._trackingState
  132299. },
  132300. enumerable: !1,
  132301. configurable: !0
  132302. }),
  132303. e.prototype._setTrackingState = function(i) {
  132304. this._trackingState !== i && (this._trackingState = i,
  132305. this.onTrackingStateChanged.notifyObservers(i))
  132306. }
  132307. ,
  132308. Object.defineProperty(e.prototype, "realWorldHeight", {
  132309. get: function() {
  132310. var i = this._xrSessionManager.currentFrame && this._xrSessionManager.currentFrame.getViewerPose(this._xrSessionManager.baseReferenceSpace);
  132311. return i && i.transform ? i.transform.position.y : 0
  132312. },
  132313. enumerable: !1,
  132314. configurable: !0
  132315. }),
  132316. e.prototype._updateForDualEyeDebugging = function() {
  132317. this._updateNumberOfRigCameras(2),
  132318. this.rigCameras[0].viewport = new Viewport(0,0,.5,1),
  132319. this.rigCameras[0].outputRenderTarget = null,
  132320. this.rigCameras[1].viewport = new Viewport(.5,0,.5,1),
  132321. this.rigCameras[1].outputRenderTarget = null
  132322. }
  132323. ,
  132324. e.prototype.setTransformationFromNonVRCamera = function(i, o) {
  132325. if (i === void 0 && (i = this.getScene().activeCamera),
  132326. o === void 0 && (o = !0),
  132327. !(!i || i === this)) {
  132328. var s = i.computeWorldMatrix();
  132329. s.decompose(void 0, this.rotationQuaternion, this.position),
  132330. this.position.y = 0,
  132331. Quaternion.FromEulerAnglesToRef(0, this.rotationQuaternion.toEulerAngles().y, 0, this.rotationQuaternion),
  132332. this._firstFrame = !0,
  132333. o && this._xrSessionManager.resetReferenceSpace()
  132334. }
  132335. }
  132336. ,
  132337. e.prototype.getClassName = function() {
  132338. return "WebXRCamera"
  132339. }
  132340. ,
  132341. e.prototype.dispose = function() {
  132342. a.prototype.dispose.call(this),
  132343. this._lastXRViewerPose = void 0
  132344. }
  132345. ,
  132346. e.prototype._updateFromXRSession = function() {
  132347. var i = this
  132348. , o = this._xrSessionManager.currentFrame && this._xrSessionManager.currentFrame.getViewerPose(this._xrSessionManager.referenceSpace);
  132349. if (this._lastXRViewerPose = o || void 0,
  132350. !o) {
  132351. this._setTrackingState(WebXRTrackingState.NOT_TRACKING);
  132352. return
  132353. }
  132354. var s = o.emulatedPosition ? WebXRTrackingState.TRACKING_LOST : WebXRTrackingState.TRACKING;
  132355. if (this._setTrackingState(s),
  132356. o.transform) {
  132357. var c = o.transform.orientation;
  132358. if (o.transform.orientation.x === void 0)
  132359. return;
  132360. var d = o.transform.position;
  132361. this._referencedPosition.set(d.x, d.y, d.z),
  132362. this._referenceQuaternion.set(c.x, c.y, c.z, c.w),
  132363. this._scene.useRightHandedSystem || (this._referencedPosition.z *= -1,
  132364. this._referenceQuaternion.z *= -1,
  132365. this._referenceQuaternion.w *= -1),
  132366. this._firstFrame ? (this._firstFrame = !1,
  132367. this.position.y += this._referencedPosition.y,
  132368. this._referenceQuaternion.copyFromFloats(0, 0, 0, 1)) : (this.rotationQuaternion.copyFrom(this._referenceQuaternion),
  132369. this.position.copyFrom(this._referencedPosition))
  132370. }
  132371. this.rigCameras.length !== o.views.length && this._updateNumberOfRigCameras(o.views.length),
  132372. o.views.forEach(function(_, b) {
  132373. var k = i.rigCameras[b];
  132374. !k.isLeftCamera && !k.isRightCamera && (_.eye === "right" ? k._isRightCamera = !0 : _.eye === "left" && (k._isLeftCamera = !0));
  132375. var j = _.transform.position
  132376. , $ = _.transform.orientation;
  132377. if (k.parent = i.parent,
  132378. k.position.set(j.x, j.y, j.z),
  132379. k.rotationQuaternion.set($.x, $.y, $.z, $.w),
  132380. i._scene.useRightHandedSystem ? k.rotationQuaternion.multiplyInPlace(i._rotate180) : (k.position.z *= -1,
  132381. k.rotationQuaternion.z *= -1,
  132382. k.rotationQuaternion.w *= -1),
  132383. Matrix.FromFloat32ArrayToRefScaled(_.projectionMatrix, 0, 1, k._projectionMatrix),
  132384. i._scene.useRightHandedSystem || k._projectionMatrix.toggleProjectionMatrixHandInPlace(),
  132385. b === 0 && i._projectionMatrix.copyFrom(k._projectionMatrix),
  132386. i._xrSessionManager.session.renderState.baseLayer) {
  132387. var _e = i._xrSessionManager.session.renderState.baseLayer.getViewport(_)
  132388. , et = i._xrSessionManager.session.renderState.baseLayer.framebufferWidth
  132389. , tt = i._xrSessionManager.session.renderState.baseLayer.framebufferHeight;
  132390. k.viewport.width = _e.width / et,
  132391. k.viewport.height = _e.height / tt,
  132392. k.viewport.x = _e.x / et,
  132393. k.viewport.y = _e.y / tt
  132394. }
  132395. k.outputRenderTarget = i._xrSessionManager.getRenderTargetTextureForEye(_.eye)
  132396. })
  132397. }
  132398. ,
  132399. e.prototype._updateNumberOfRigCameras = function(i) {
  132400. for (i === void 0 && (i = 1); this.rigCameras.length < i; ) {
  132401. var o = new TargetCamera("XR-RigCamera: " + this.rigCameras.length,Vector3.Zero(),this.getScene());
  132402. o.minZ = .1,
  132403. o.rotationQuaternion = new Quaternion,
  132404. o.updateUpVectorFromRotation = !0,
  132405. o.isRigCamera = !0,
  132406. o.rigParent = this,
  132407. o.freezeProjectionMatrix(),
  132408. this.rigCameras.push(o)
  132409. }
  132410. for (; this.rigCameras.length > i; ) {
  132411. var s = this.rigCameras.pop();
  132412. s && s.dispose()
  132413. }
  132414. }
  132415. ,
  132416. e.prototype._updateReferenceSpace = function() {
  132417. if (!this.position.equals(this._referencedPosition) || !this.rotationQuaternion.equals(this._referenceQuaternion)) {
  132418. var i = TmpVectors.Matrix[0]
  132419. , o = TmpVectors.Matrix[1]
  132420. , s = TmpVectors.Matrix[2];
  132421. Matrix.ComposeToRef(e._ScaleReadOnly, this._referenceQuaternion, this._referencedPosition, i),
  132422. Matrix.ComposeToRef(e._ScaleReadOnly, this.rotationQuaternion, this.position, o),
  132423. i.invert().multiplyToRef(o, s),
  132424. s.invert(),
  132425. this._scene.useRightHandedSystem || s.toggleModelMatrixHandInPlace(),
  132426. s.decompose(void 0, this._referenceQuaternion, this._referencedPosition);
  132427. var c = new XRRigidTransform({
  132428. x: this._referencedPosition.x,
  132429. y: this._referencedPosition.y,
  132430. z: this._referencedPosition.z
  132431. },{
  132432. x: this._referenceQuaternion.x,
  132433. y: this._referenceQuaternion.y,
  132434. z: this._referenceQuaternion.z,
  132435. w: this._referenceQuaternion.w
  132436. });
  132437. this._xrSessionManager.referenceSpace = this._xrSessionManager.referenceSpace.getOffsetReferenceSpace(c)
  132438. }
  132439. }
  132440. ,
  132441. e._ScaleReadOnly = Vector3.One(),
  132442. e
  132443. }(FreeCamera), _a, WebXRFeatureName = function() {
  132444. function a() {}
  132445. return a.ANCHOR_SYSTEM = "xr-anchor-system",
  132446. a.BACKGROUND_REMOVER = "xr-background-remover",
  132447. a.HIT_TEST = "xr-hit-test",
  132448. a.MESH_DETECTION = "xr-mesh-detection",
  132449. a.PHYSICS_CONTROLLERS = "xr-physics-controller",
  132450. a.PLANE_DETECTION = "xr-plane-detection",
  132451. a.POINTER_SELECTION = "xr-controller-pointer-selection",
  132452. a.TELEPORTATION = "xr-controller-teleportation",
  132453. a.FEATURE_POINTS = "xr-feature-points",
  132454. a.HAND_TRACKING = "xr-hand-tracking",
  132455. a.IMAGE_TRACKING = "xr-image-tracking",
  132456. a.NEAR_INTERACTION = "xr-near-interaction",
  132457. a.DOM_OVERLAY = "xr-dom-overlay",
  132458. a.MOVEMENT = "xr-controller-movement",
  132459. a.LIGHT_ESTIMATION = "xr-light-estimation",
  132460. a.EYE_TRACKING = "xr-eye-tracking",
  132461. a.WALKING_LOCOMOTION = "xr-walking-locomotion",
  132462. a
  132463. }(), WebXRFeaturesManager = function() {
  132464. function a(e) {
  132465. var i = this;
  132466. this._xrSessionManager = e,
  132467. this._features = {},
  132468. this._xrSessionManager.onXRSessionInit.add(function() {
  132469. i.getEnabledFeatures().forEach(function(o) {
  132470. var s = i._features[o];
  132471. s.enabled && !s.featureImplementation.attached && !s.featureImplementation.disableAutoAttach && i.attachFeature(o)
  132472. })
  132473. }),
  132474. this._xrSessionManager.onXRSessionEnded.add(function() {
  132475. i.getEnabledFeatures().forEach(function(o) {
  132476. var s = i._features[o];
  132477. s.enabled && s.featureImplementation.attached && i.detachFeature(o)
  132478. })
  132479. })
  132480. }
  132481. return a.AddWebXRFeature = function(e, i, o, s) {
  132482. o === void 0 && (o = 1),
  132483. s === void 0 && (s = !1),
  132484. this._AvailableFeatures[e] = this._AvailableFeatures[e] || {
  132485. latest: o
  132486. },
  132487. o > this._AvailableFeatures[e].latest && (this._AvailableFeatures[e].latest = o),
  132488. s && (this._AvailableFeatures[e].stable = o),
  132489. this._AvailableFeatures[e][o] = i
  132490. }
  132491. ,
  132492. a.ConstructFeature = function(e, i, o, s) {
  132493. i === void 0 && (i = 1);
  132494. var c = this._AvailableFeatures[e][i];
  132495. if (!c)
  132496. throw new Error("feature not found");
  132497. return c(o, s)
  132498. }
  132499. ,
  132500. a.GetAvailableFeatures = function() {
  132501. return Object.keys(this._AvailableFeatures)
  132502. }
  132503. ,
  132504. a.GetAvailableVersions = function(e) {
  132505. return Object.keys(this._AvailableFeatures[e])
  132506. }
  132507. ,
  132508. a.GetLatestVersionOfFeature = function(e) {
  132509. return this._AvailableFeatures[e] && this._AvailableFeatures[e].latest || -1
  132510. }
  132511. ,
  132512. a.GetStableVersionOfFeature = function(e) {
  132513. return this._AvailableFeatures[e] && this._AvailableFeatures[e].stable || -1
  132514. }
  132515. ,
  132516. a.prototype.attachFeature = function(e) {
  132517. var i = this._features[e];
  132518. i && i.enabled && !i.featureImplementation.attached && i.featureImplementation.attach()
  132519. }
  132520. ,
  132521. a.prototype.detachFeature = function(e) {
  132522. var i = this._features[e];
  132523. i && i.featureImplementation.attached && i.featureImplementation.detach()
  132524. }
  132525. ,
  132526. a.prototype.disableFeature = function(e) {
  132527. var i = typeof e == "string" ? e : e.Name
  132528. , o = this._features[i];
  132529. return o && o.enabled ? (o.enabled = !1,
  132530. this.detachFeature(i),
  132531. o.featureImplementation.dispose(),
  132532. delete this._features[i],
  132533. !0) : !1
  132534. }
  132535. ,
  132536. a.prototype.dispose = function() {
  132537. var e = this;
  132538. this.getEnabledFeatures().forEach(function(i) {
  132539. e.disableFeature(i)
  132540. })
  132541. }
  132542. ,
  132543. a.prototype.enableFeature = function(e, i, o, s, c) {
  132544. var d = this;
  132545. i === void 0 && (i = "latest"),
  132546. o === void 0 && (o = {}),
  132547. s === void 0 && (s = !0),
  132548. c === void 0 && (c = !0);
  132549. var _ = typeof e == "string" ? e : e.Name
  132550. , b = 0;
  132551. if (typeof i == "string") {
  132552. if (!i)
  132553. throw new Error("Error in provided version - " + _ + " (" + i + ")");
  132554. if (i === "stable" ? b = a.GetStableVersionOfFeature(_) : i === "latest" ? b = a.GetLatestVersionOfFeature(_) : b = +i,
  132555. b === -1 || isNaN(b))
  132556. throw new Error("feature not found - " + _ + " (" + i + ")")
  132557. } else
  132558. b = i;
  132559. var k = a._ConflictingFeatures[_];
  132560. if (k !== void 0 && this.getEnabledFeatures().indexOf(k) !== -1)
  132561. throw new Error("Feature " + _ + " cannot be enabled while " + k + " is enabled.");
  132562. var j = this._features[_]
  132563. , $ = a.ConstructFeature(_, b, this._xrSessionManager, o);
  132564. if (!$)
  132565. throw new Error("feature not found - " + _);
  132566. j && this.disableFeature(_);
  132567. var _e = $();
  132568. if (_e.dependsOn) {
  132569. var et = _e.dependsOn.every(function(tt) {
  132570. return !!d._features[tt]
  132571. });
  132572. if (!et)
  132573. throw new Error("Dependant features missing. Make sure the following features are enabled - " + _e.dependsOn.join(", "))
  132574. }
  132575. if (_e.isCompatible())
  132576. return this._features[_] = {
  132577. featureImplementation: _e,
  132578. enabled: !0,
  132579. version: b,
  132580. required: c
  132581. },
  132582. s ? this._xrSessionManager.session && !this._features[_].featureImplementation.attached && this.attachFeature(_) : this._features[_].featureImplementation.disableAutoAttach = !0,
  132583. this._features[_].featureImplementation;
  132584. if (c)
  132585. throw new Error("required feature not compatible");
  132586. return Tools.Warn("Feature " + _ + " not compatible with the current environment/browser and was not enabled."),
  132587. _e
  132588. }
  132589. ,
  132590. a.prototype.getEnabledFeature = function(e) {
  132591. return this._features[e] && this._features[e].featureImplementation
  132592. }
  132593. ,
  132594. a.prototype.getEnabledFeatures = function() {
  132595. return Object.keys(this._features)
  132596. }
  132597. ,
  132598. a.prototype._extendXRSessionInitObject = function(e) {
  132599. return __awaiter(this, void 0, void 0, function() {
  132600. var i, o, s, c, d, _, b;
  132601. return __generator(this, function(k) {
  132602. switch (k.label) {
  132603. case 0:
  132604. i = this.getEnabledFeatures(),
  132605. o = 0,
  132606. s = i,
  132607. k.label = 1;
  132608. case 1:
  132609. return o < s.length ? (c = s[o],
  132610. d = this._features[c],
  132611. _ = d.featureImplementation.xrNativeFeatureName,
  132612. _ && (d.required ? (e.requiredFeatures = e.requiredFeatures || [],
  132613. e.requiredFeatures.indexOf(_) === -1 && e.requiredFeatures.push(_)) : (e.optionalFeatures = e.optionalFeatures || [],
  132614. e.optionalFeatures.indexOf(_) === -1 && e.optionalFeatures.push(_))),
  132615. d.featureImplementation.getXRSessionInitExtension ? [4, d.featureImplementation.getXRSessionInitExtension()] : [3, 3]) : [3, 4];
  132616. case 2:
  132617. b = k.sent(),
  132618. e = __assign(__assign({}, e), b),
  132619. k.label = 3;
  132620. case 3:
  132621. return o++,
  132622. [3, 1];
  132623. case 4:
  132624. return [2, e]
  132625. }
  132626. })
  132627. })
  132628. }
  132629. ,
  132630. a._AvailableFeatures = {},
  132631. a._ConflictingFeatures = (_a = {},
  132632. _a[WebXRFeatureName.TELEPORTATION] = WebXRFeatureName.MOVEMENT,
  132633. _a[WebXRFeatureName.MOVEMENT] = WebXRFeatureName.TELEPORTATION,
  132634. _a),
  132635. a
  132636. }();
  132637. Node$2.AddNodeConstructor("TouchCamera", function(a, e) {
  132638. return function() {
  132639. return new TouchCamera(a,Vector3.Zero(),e)
  132640. }
  132641. });
  132642. var TouchCamera = function(a) {
  132643. __extends(e, a);
  132644. function e(i, o, s) {
  132645. var c = a.call(this, i, o, s) || this;
  132646. return c.inputs.addTouch(),
  132647. c._setupInputs(),
  132648. c
  132649. }
  132650. return Object.defineProperty(e.prototype, "touchAngularSensibility", {
  132651. get: function() {
  132652. var i = this.inputs.attached.touch;
  132653. return i ? i.touchAngularSensibility : 0
  132654. },
  132655. set: function(i) {
  132656. var o = this.inputs.attached.touch;
  132657. o && (o.touchAngularSensibility = i)
  132658. },
  132659. enumerable: !1,
  132660. configurable: !0
  132661. }),
  132662. Object.defineProperty(e.prototype, "touchMoveSensibility", {
  132663. get: function() {
  132664. var i = this.inputs.attached.touch;
  132665. return i ? i.touchMoveSensibility : 0
  132666. },
  132667. set: function(i) {
  132668. var o = this.inputs.attached.touch;
  132669. o && (o.touchMoveSensibility = i)
  132670. },
  132671. enumerable: !1,
  132672. configurable: !0
  132673. }),
  132674. e.prototype.getClassName = function() {
  132675. return "TouchCamera"
  132676. }
  132677. ,
  132678. e.prototype._setupInputs = function() {
  132679. var i = this.inputs.attached.touch
  132680. , o = this.inputs.attached.mouse;
  132681. o ? o.touchEnabled = !1 : i.allowMouse = !0
  132682. }
  132683. ,
  132684. e
  132685. }(FreeCamera);
  132686. Node$2.AddNodeConstructor("FreeCamera", function(a, e) {
  132687. return function() {
  132688. return new UniversalCamera(a,Vector3.Zero(),e)
  132689. }
  132690. });
  132691. var UniversalCamera = function(a) {
  132692. __extends(e, a);
  132693. function e(i, o, s) {
  132694. var c = a.call(this, i, o, s) || this;
  132695. return c.inputs.addGamepad(),
  132696. c
  132697. }
  132698. return Object.defineProperty(e.prototype, "gamepadAngularSensibility", {
  132699. get: function() {
  132700. var i = this.inputs.attached.gamepad;
  132701. return i ? i.gamepadAngularSensibility : 0
  132702. },
  132703. set: function(i) {
  132704. var o = this.inputs.attached.gamepad;
  132705. o && (o.gamepadAngularSensibility = i)
  132706. },
  132707. enumerable: !1,
  132708. configurable: !0
  132709. }),
  132710. Object.defineProperty(e.prototype, "gamepadMoveSensibility", {
  132711. get: function() {
  132712. var i = this.inputs.attached.gamepad;
  132713. return i ? i.gamepadMoveSensibility : 0
  132714. },
  132715. set: function(i) {
  132716. var o = this.inputs.attached.gamepad;
  132717. o && (o.gamepadMoveSensibility = i)
  132718. },
  132719. enumerable: !1,
  132720. configurable: !0
  132721. }),
  132722. e.prototype.getClassName = function() {
  132723. return "UniversalCamera"
  132724. }
  132725. ,
  132726. e
  132727. }(TouchCamera);
  132728. Camera$1._createDefaultParsedCamera = function(a, e) {
  132729. return new UniversalCamera(a,Vector3.Zero(),e)
  132730. }
  132731. ;
  132732. var WebXRExperienceHelper = function() {
  132733. function a(e) {
  132734. var i = this;
  132735. this.scene = e,
  132736. this._nonVRCamera = null,
  132737. this._attachedToElement = !1,
  132738. this._spectatorCamera = null,
  132739. this._originalSceneAutoClear = !0,
  132740. this._supported = !1,
  132741. this._spectatorMode = !1,
  132742. this.onInitialXRPoseSetObservable = new Observable,
  132743. this.onStateChangedObservable = new Observable,
  132744. this.state = WebXRState.NOT_IN_XR,
  132745. this.sessionManager = new WebXRSessionManager(e),
  132746. this.camera = new WebXRCamera("webxr",e,this.sessionManager),
  132747. this.featuresManager = new WebXRFeaturesManager(this.sessionManager),
  132748. e.onDisposeObservable.add(function() {
  132749. i.exitXRAsync()
  132750. })
  132751. }
  132752. return a.CreateAsync = function(e) {
  132753. var i = new a(e);
  132754. return i.sessionManager.initializeAsync().then(function() {
  132755. return i._supported = !0,
  132756. i
  132757. }).catch(function(o) {
  132758. throw i._setState(WebXRState.NOT_IN_XR),
  132759. i.dispose(),
  132760. o
  132761. })
  132762. }
  132763. ,
  132764. a.prototype.dispose = function() {
  132765. var e;
  132766. this.camera.dispose(),
  132767. this.onStateChangedObservable.clear(),
  132768. this.onInitialXRPoseSetObservable.clear(),
  132769. this.sessionManager.dispose(),
  132770. (e = this._spectatorCamera) === null || e === void 0 || e.dispose(),
  132771. this._nonVRCamera && (this.scene.activeCamera = this._nonVRCamera)
  132772. }
  132773. ,
  132774. a.prototype.enterXRAsync = function(e, i, o, s) {
  132775. var c, d;
  132776. return o === void 0 && (o = this.sessionManager.getWebXRRenderTarget()),
  132777. s === void 0 && (s = {}),
  132778. __awaiter(this, void 0, void 0, function() {
  132779. var _, b = this;
  132780. return __generator(this, function(k) {
  132781. switch (k.label) {
  132782. case 0:
  132783. if (!this._supported)
  132784. throw "WebXR not supported in this browser or environment";
  132785. return this._setState(WebXRState.ENTERING_XR),
  132786. i !== "viewer" && i !== "local" && (s.optionalFeatures = s.optionalFeatures || [],
  132787. s.optionalFeatures.push(i)),
  132788. [4, this.featuresManager._extendXRSessionInitObject(s)];
  132789. case 1:
  132790. s = k.sent(),
  132791. e === "immersive-ar" && i !== "unbounded" && Logger$2.Warn("We recommend using 'unbounded' reference space type when using 'immersive-ar' session mode"),
  132792. k.label = 2;
  132793. case 2:
  132794. return k.trys.push([2, 7, , 8]),
  132795. [4, this.sessionManager.initializeSessionAsync(e, s)];
  132796. case 3:
  132797. return k.sent(),
  132798. [4, this.sessionManager.setReferenceSpaceTypeAsync(i)];
  132799. case 4:
  132800. return k.sent(),
  132801. [4, o.initializeXRLayerAsync(this.sessionManager.session)];
  132802. case 5:
  132803. return k.sent(),
  132804. [4, this.sessionManager.updateRenderStateAsync({
  132805. depthFar: this.camera.maxZ,
  132806. depthNear: this.camera.minZ,
  132807. baseLayer: o.xrLayer
  132808. })];
  132809. case 6:
  132810. return k.sent(),
  132811. this.sessionManager.runXRRenderLoop(),
  132812. this._originalSceneAutoClear = this.scene.autoClear,
  132813. this._nonVRCamera = this.scene.activeCamera,
  132814. this._attachedToElement = !!(!((c = this._nonVRCamera) === null || c === void 0) && c.inputs.attachedToElement),
  132815. (d = this._nonVRCamera) === null || d === void 0 || d.detachControl(),
  132816. this.scene.activeCamera = this.camera,
  132817. e !== "immersive-ar" ? this._nonXRToXRCamera() : (this.scene.autoClear = !1,
  132818. this.camera.compensateOnFirstFrame = !1),
  132819. this.sessionManager.onXRSessionEnded.addOnce(function() {
  132820. b.camera.rigCameras.forEach(function(j) {
  132821. j.outputRenderTarget = null
  132822. }),
  132823. b.scene.autoClear = b._originalSceneAutoClear,
  132824. b.scene.activeCamera = b._nonVRCamera,
  132825. b._attachedToElement && b._nonVRCamera && b._nonVRCamera.attachControl(!!b._nonVRCamera.inputs.noPreventDefault),
  132826. e !== "immersive-ar" && b.camera.compensateOnFirstFrame && (b._nonVRCamera.setPosition ? b._nonVRCamera.setPosition(b.camera.position) : b._nonVRCamera.position.copyFrom(b.camera.position)),
  132827. b._setState(WebXRState.NOT_IN_XR)
  132828. }),
  132829. this.sessionManager.onXRFrameObservable.addOnce(function() {
  132830. b._setState(WebXRState.IN_XR)
  132831. }),
  132832. [2, this.sessionManager];
  132833. case 7:
  132834. throw _ = k.sent(),
  132835. console.log(_),
  132836. console.log(_.message),
  132837. this._setState(WebXRState.NOT_IN_XR),
  132838. _;
  132839. case 8:
  132840. return [2]
  132841. }
  132842. })
  132843. })
  132844. }
  132845. ,
  132846. a.prototype.exitXRAsync = function() {
  132847. return this.state !== WebXRState.IN_XR ? Promise.resolve() : (this._setState(WebXRState.EXITING_XR),
  132848. this.sessionManager.exitXRAsync())
  132849. }
  132850. ,
  132851. a.prototype.enableSpectatorMode = function() {
  132852. var e = this;
  132853. if (!this._spectatorMode) {
  132854. var i = function() {
  132855. e._spectatorCamera && (e._spectatorCamera.position.copyFrom(e.camera.rigCameras[0].globalPosition),
  132856. e._spectatorCamera.rotationQuaternion.copyFrom(e.camera.rigCameras[0].absoluteRotation))
  132857. }
  132858. , o = function() {
  132859. e.state === WebXRState.IN_XR ? (e._spectatorCamera = new UniversalCamera("webxr-spectator",Vector3.Zero(),e.scene),
  132860. e._spectatorCamera.rotationQuaternion = new Quaternion,
  132861. e.scene.activeCameras = [e.camera, e._spectatorCamera],
  132862. e.sessionManager.onXRFrameObservable.add(i),
  132863. e.scene.onAfterRenderCameraObservable.add(function(s) {
  132864. s === e.camera && (e.scene.getEngine().framebufferDimensionsObject = null)
  132865. })) : e.state === WebXRState.EXITING_XR && (e.sessionManager.onXRFrameObservable.removeCallback(i),
  132866. e.scene.activeCameras = null)
  132867. };
  132868. this._spectatorMode = !0,
  132869. this.onStateChangedObservable.add(o),
  132870. o()
  132871. }
  132872. }
  132873. ,
  132874. a.prototype._nonXRToXRCamera = function() {
  132875. this.camera.setTransformationFromNonVRCamera(this._nonVRCamera),
  132876. this.onInitialXRPoseSetObservable.notifyObservers(this.camera)
  132877. }
  132878. ,
  132879. a.prototype._setState = function(e) {
  132880. this.state !== e && (this.state = e,
  132881. this.onStateChangedObservable.notifyObservers(this.state))
  132882. }
  132883. ,
  132884. a
  132885. }()
  132886. , WebXRControllerComponent = function() {
  132887. function a(e, i, o, s) {
  132888. o === void 0 && (o = -1),
  132889. s === void 0 && (s = []),
  132890. this.id = e,
  132891. this.type = i,
  132892. this._buttonIndex = o,
  132893. this._axesIndices = s,
  132894. this._axes = {
  132895. x: 0,
  132896. y: 0
  132897. },
  132898. this._changes = {},
  132899. this._currentValue = 0,
  132900. this._hasChanges = !1,
  132901. this._pressed = !1,
  132902. this._touched = !1,
  132903. this.onAxisValueChangedObservable = new Observable,
  132904. this.onButtonStateChangedObservable = new Observable
  132905. }
  132906. return Object.defineProperty(a.prototype, "axes", {
  132907. get: function() {
  132908. return this._axes
  132909. },
  132910. enumerable: !1,
  132911. configurable: !0
  132912. }),
  132913. Object.defineProperty(a.prototype, "changes", {
  132914. get: function() {
  132915. return this._changes
  132916. },
  132917. enumerable: !1,
  132918. configurable: !0
  132919. }),
  132920. Object.defineProperty(a.prototype, "hasChanges", {
  132921. get: function() {
  132922. return this._hasChanges
  132923. },
  132924. enumerable: !1,
  132925. configurable: !0
  132926. }),
  132927. Object.defineProperty(a.prototype, "pressed", {
  132928. get: function() {
  132929. return this._pressed
  132930. },
  132931. enumerable: !1,
  132932. configurable: !0
  132933. }),
  132934. Object.defineProperty(a.prototype, "touched", {
  132935. get: function() {
  132936. return this._touched
  132937. },
  132938. enumerable: !1,
  132939. configurable: !0
  132940. }),
  132941. Object.defineProperty(a.prototype, "value", {
  132942. get: function() {
  132943. return this._currentValue
  132944. },
  132945. enumerable: !1,
  132946. configurable: !0
  132947. }),
  132948. a.prototype.dispose = function() {
  132949. this.onAxisValueChangedObservable.clear(),
  132950. this.onButtonStateChangedObservable.clear()
  132951. }
  132952. ,
  132953. a.prototype.isAxes = function() {
  132954. return this._axesIndices.length !== 0
  132955. }
  132956. ,
  132957. a.prototype.isButton = function() {
  132958. return this._buttonIndex !== -1
  132959. }
  132960. ,
  132961. a.prototype.update = function(e) {
  132962. var i = !1
  132963. , o = !1;
  132964. if (this._hasChanges = !1,
  132965. this._changes = {},
  132966. this.isButton()) {
  132967. var s = e.buttons[this._buttonIndex];
  132968. if (!s)
  132969. return;
  132970. this._currentValue !== s.value && (this.changes.value = {
  132971. current: s.value,
  132972. previous: this._currentValue
  132973. },
  132974. i = !0,
  132975. this._currentValue = s.value),
  132976. this._touched !== s.touched && (this.changes.touched = {
  132977. current: s.touched,
  132978. previous: this._touched
  132979. },
  132980. i = !0,
  132981. this._touched = s.touched),
  132982. this._pressed !== s.pressed && (this.changes.pressed = {
  132983. current: s.pressed,
  132984. previous: this._pressed
  132985. },
  132986. i = !0,
  132987. this._pressed = s.pressed)
  132988. }
  132989. this.isAxes() && (this._axes.x !== e.axes[this._axesIndices[0]] && (this.changes.axes = {
  132990. current: {
  132991. x: e.axes[this._axesIndices[0]],
  132992. y: this._axes.y
  132993. },
  132994. previous: {
  132995. x: this._axes.x,
  132996. y: this._axes.y
  132997. }
  132998. },
  132999. this._axes.x = e.axes[this._axesIndices[0]],
  133000. o = !0),
  133001. this._axes.y !== e.axes[this._axesIndices[1]] && (this.changes.axes ? this.changes.axes.current.y = e.axes[this._axesIndices[1]] : this.changes.axes = {
  133002. current: {
  133003. x: this._axes.x,
  133004. y: e.axes[this._axesIndices[1]]
  133005. },
  133006. previous: {
  133007. x: this._axes.x,
  133008. y: this._axes.y
  133009. }
  133010. },
  133011. this._axes.y = e.axes[this._axesIndices[1]],
  133012. o = !0)),
  133013. i && (this._hasChanges = !0,
  133014. this.onButtonStateChangedObservable.notifyObservers(this)),
  133015. o && (this._hasChanges = !0,
  133016. this.onAxisValueChangedObservable.notifyObservers(this._axes))
  133017. }
  133018. ,
  133019. a.BUTTON_TYPE = "button",
  133020. a.SQUEEZE_TYPE = "squeeze",
  133021. a.THUMBSTICK_TYPE = "thumbstick",
  133022. a.TOUCHPAD_TYPE = "touchpad",
  133023. a.TRIGGER_TYPE = "trigger",
  133024. a
  133025. }()
  133026. , WebXRAbstractMotionController = function() {
  133027. function a(e, i, o, s, c, d) {
  133028. var _ = this;
  133029. c === void 0 && (c = !1),
  133030. this.scene = e,
  133031. this.layout = i,
  133032. this.gamepadObject = o,
  133033. this.handedness = s,
  133034. this._doNotLoadControllerMesh = c,
  133035. this._controllerCache = d,
  133036. this._initComponent = function(b) {
  133037. if (!!b) {
  133038. var k = _.layout.components[b]
  133039. , j = k.type
  133040. , $ = k.gamepadIndices.button
  133041. , _e = [];
  133042. k.gamepadIndices.xAxis !== void 0 && k.gamepadIndices.yAxis !== void 0 && _e.push(k.gamepadIndices.xAxis, k.gamepadIndices.yAxis),
  133043. _.components[b] = new WebXRControllerComponent(b,j,$,_e)
  133044. }
  133045. }
  133046. ,
  133047. this._modelReady = !1,
  133048. this.components = {},
  133049. this.disableAnimation = !1,
  133050. this.onModelLoadedObservable = new Observable,
  133051. i.components && Object.keys(i.components).forEach(this._initComponent)
  133052. }
  133053. return a.prototype.dispose = function() {
  133054. var e = this;
  133055. this.getComponentIds().forEach(function(i) {
  133056. return e.getComponent(i).dispose()
  133057. }),
  133058. this.rootMesh && (this.rootMesh.getChildren(void 0, !0).forEach(function(i) {
  133059. i.setEnabled(!1)
  133060. }),
  133061. this.rootMesh.dispose(!!this._controllerCache, !this._controllerCache))
  133062. }
  133063. ,
  133064. a.prototype.getAllComponentsOfType = function(e) {
  133065. var i = this;
  133066. return this.getComponentIds().map(function(o) {
  133067. return i.components[o]
  133068. }).filter(function(o) {
  133069. return o.type === e
  133070. })
  133071. }
  133072. ,
  133073. a.prototype.getComponent = function(e) {
  133074. return this.components[e]
  133075. }
  133076. ,
  133077. a.prototype.getComponentIds = function() {
  133078. return Object.keys(this.components)
  133079. }
  133080. ,
  133081. a.prototype.getComponentOfType = function(e) {
  133082. return this.getAllComponentsOfType(e)[0] || null
  133083. }
  133084. ,
  133085. a.prototype.getMainComponent = function() {
  133086. return this.getComponent(this.layout.selectComponentId)
  133087. }
  133088. ,
  133089. a.prototype.loadModel = function() {
  133090. return __awaiter(this, void 0, void 0, function() {
  133091. var e, i, o = this;
  133092. return __generator(this, function(s) {
  133093. return e = !this._getModelLoadingConstraints(),
  133094. i = this._getGenericFilenameAndPath(),
  133095. e ? Logger$2.Warn("Falling back to generic models") : i = this._getFilenameAndPath(),
  133096. [2, new Promise(function(c, d) {
  133097. var _ = function(k) {
  133098. e ? o._getGenericParentMesh(k) : o._setRootMesh(k),
  133099. o._processLoadedModel(k),
  133100. o._modelReady = !0,
  133101. o.onModelLoadedObservable.notifyObservers(o),
  133102. c(!0)
  133103. };
  133104. if (o._controllerCache) {
  133105. var b = o._controllerCache.filter(function(k) {
  133106. return k.filename === i.filename && k.path === i.path
  133107. });
  133108. if (b[0]) {
  133109. b[0].meshes.forEach(function(k) {
  133110. return k.setEnabled(!0)
  133111. }),
  133112. _(b[0].meshes);
  133113. return
  133114. }
  133115. }
  133116. SceneLoader.ImportMesh("", i.path, i.filename, o.scene, function(k) {
  133117. o._controllerCache && o._controllerCache.push(__assign(__assign({}, i), {
  133118. meshes: k
  133119. })),
  133120. _(k)
  133121. }, null, function(k, j) {
  133122. Logger$2.Log(j),
  133123. Logger$2.Warn("Failed to retrieve controller model of type " + o.profileId + " from the remote server: " + i.path + i.filename),
  133124. d(j)
  133125. })
  133126. }
  133127. )]
  133128. })
  133129. })
  133130. }
  133131. ,
  133132. a.prototype.updateFromXRFrame = function(e) {
  133133. var i = this;
  133134. this.getComponentIds().forEach(function(o) {
  133135. return i.getComponent(o).update(i.gamepadObject)
  133136. }),
  133137. this.updateModel(e)
  133138. }
  133139. ,
  133140. Object.defineProperty(a.prototype, "handness", {
  133141. get: function() {
  133142. return this.handedness
  133143. },
  133144. enumerable: !1,
  133145. configurable: !0
  133146. }),
  133147. a.prototype.pulse = function(e, i, o) {
  133148. return o === void 0 && (o = 0),
  133149. this.gamepadObject.hapticActuators && this.gamepadObject.hapticActuators[o] ? this.gamepadObject.hapticActuators[o].pulse(e, i) : Promise.resolve(!1)
  133150. }
  133151. ,
  133152. a.prototype._getChildByName = function(e, i) {
  133153. return e.getChildren(function(o) {
  133154. return o.name === i
  133155. }, !1)[0]
  133156. }
  133157. ,
  133158. a.prototype._getImmediateChildByName = function(e, i) {
  133159. return e.getChildren(function(o) {
  133160. return o.name == i
  133161. }, !0)[0]
  133162. }
  133163. ,
  133164. a.prototype._lerpTransform = function(e, i, o) {
  133165. if (!(!e.minMesh || !e.maxMesh || !e.valueMesh) && !(!e.minMesh.rotationQuaternion || !e.maxMesh.rotationQuaternion || !e.valueMesh.rotationQuaternion)) {
  133166. var s = o ? i * .5 + .5 : i;
  133167. Quaternion.SlerpToRef(e.minMesh.rotationQuaternion, e.maxMesh.rotationQuaternion, s, e.valueMesh.rotationQuaternion),
  133168. Vector3.LerpToRef(e.minMesh.position, e.maxMesh.position, s, e.valueMesh.position)
  133169. }
  133170. }
  133171. ,
  133172. a.prototype.updateModel = function(e) {
  133173. !this._modelReady || this._updateModel(e)
  133174. }
  133175. ,
  133176. a.prototype._getGenericFilenameAndPath = function() {
  133177. return {
  133178. filename: "generic.babylon",
  133179. path: "https://controllers.babylonjs.com/generic/"
  133180. }
  133181. }
  133182. ,
  133183. a.prototype._getGenericParentMesh = function(e) {
  133184. var i = this;
  133185. this.rootMesh = new Mesh(this.profileId + " " + this.handedness,this.scene),
  133186. e.forEach(function(o) {
  133187. o.parent || (o.isPickable = !1,
  133188. o.setParent(i.rootMesh))
  133189. }),
  133190. this.rootMesh.rotationQuaternion = Quaternion.FromEulerAngles(0, Math.PI, 0)
  133191. }
  133192. ,
  133193. a
  133194. }()
  133195. , WebXRGenericTriggerMotionController = function(a) {
  133196. __extends(e, a);
  133197. function e(i, o, s) {
  133198. var c = a.call(this, i, GenericTriggerLayout[s], o, s) || this;
  133199. return c.profileId = e.ProfileId,
  133200. c
  133201. }
  133202. return e.prototype._getFilenameAndPath = function() {
  133203. return {
  133204. filename: "generic.babylon",
  133205. path: "https://controllers.babylonjs.com/generic/"
  133206. }
  133207. }
  133208. ,
  133209. e.prototype._getModelLoadingConstraints = function() {
  133210. return !0
  133211. }
  133212. ,
  133213. e.prototype._processLoadedModel = function(i) {}
  133214. ,
  133215. e.prototype._setRootMesh = function(i) {
  133216. var o = this;
  133217. this.rootMesh = new Mesh(this.profileId + " " + this.handedness,this.scene),
  133218. i.forEach(function(s) {
  133219. s.isPickable = !1,
  133220. s.parent || s.setParent(o.rootMesh)
  133221. }),
  133222. this.rootMesh.rotationQuaternion = Quaternion.FromEulerAngles(0, Math.PI, 0)
  133223. }
  133224. ,
  133225. e.prototype._updateModel = function() {}
  133226. ,
  133227. e.ProfileId = "generic-trigger",
  133228. e
  133229. }(WebXRAbstractMotionController)
  133230. , GenericTriggerLayout = {
  133231. left: {
  133232. selectComponentId: "xr-standard-trigger",
  133233. components: {
  133234. "xr-standard-trigger": {
  133235. type: "trigger",
  133236. gamepadIndices: {
  133237. button: 0
  133238. },
  133239. rootNodeName: "xr_standard_trigger",
  133240. visualResponses: {}
  133241. }
  133242. },
  133243. gamepadMapping: "xr-standard",
  133244. rootNodeName: "generic-trigger-left",
  133245. assetPath: "left.glb"
  133246. },
  133247. right: {
  133248. selectComponentId: "xr-standard-trigger",
  133249. components: {
  133250. "xr-standard-trigger": {
  133251. type: "trigger",
  133252. gamepadIndices: {
  133253. button: 0
  133254. },
  133255. rootNodeName: "xr_standard_trigger",
  133256. visualResponses: {}
  133257. }
  133258. },
  133259. gamepadMapping: "xr-standard",
  133260. rootNodeName: "generic-trigger-right",
  133261. assetPath: "right.glb"
  133262. },
  133263. none: {
  133264. selectComponentId: "xr-standard-trigger",
  133265. components: {
  133266. "xr-standard-trigger": {
  133267. type: "trigger",
  133268. gamepadIndices: {
  133269. button: 0
  133270. },
  133271. rootNodeName: "xr_standard_trigger",
  133272. visualResponses: {}
  133273. }
  133274. },
  133275. gamepadMapping: "xr-standard",
  133276. rootNodeName: "generic-trigger-none",
  133277. assetPath: "none.glb"
  133278. }
  133279. }
  133280. , WebXRProfiledMotionController = function(a) {
  133281. __extends(e, a);
  133282. function e(i, o, s, c, d) {
  133283. var _ = a.call(this, i, s.layouts[o.handedness || "none"], o.gamepad, o.handedness, void 0, d) || this;
  133284. return _._repositoryUrl = c,
  133285. _.controllerCache = d,
  133286. _._buttonMeshMapping = {},
  133287. _._touchDots = {},
  133288. _.profileId = s.profileId,
  133289. _
  133290. }
  133291. return e.prototype.dispose = function() {
  133292. var i = this;
  133293. a.prototype.dispose.call(this),
  133294. this.controllerCache || Object.keys(this._touchDots).forEach(function(o) {
  133295. i._touchDots[o].dispose()
  133296. })
  133297. }
  133298. ,
  133299. e.prototype._getFilenameAndPath = function() {
  133300. return {
  133301. filename: this.layout.assetPath,
  133302. path: this._repositoryUrl + "/profiles/" + this.profileId + "/"
  133303. }
  133304. }
  133305. ,
  133306. e.prototype._getModelLoadingConstraints = function() {
  133307. var i = SceneLoader.IsPluginForExtensionAvailable(".glb");
  133308. return i || Logger$2.Warn("glTF / glb loader was not registered, using generic controller instead"),
  133309. i
  133310. }
  133311. ,
  133312. e.prototype._processLoadedModel = function(i) {
  133313. var o = this;
  133314. this.getComponentIds().forEach(function(s) {
  133315. var c = o.layout.components[s];
  133316. o._buttonMeshMapping[s] = {
  133317. mainMesh: o._getChildByName(o.rootMesh, c.rootNodeName),
  133318. states: {}
  133319. },
  133320. Object.keys(c.visualResponses).forEach(function(d) {
  133321. var _ = c.visualResponses[d];
  133322. if (_.valueNodeProperty === "transform")
  133323. o._buttonMeshMapping[s].states[d] = {
  133324. valueMesh: o._getChildByName(o.rootMesh, _.valueNodeName),
  133325. minMesh: o._getChildByName(o.rootMesh, _.minNodeName),
  133326. maxMesh: o._getChildByName(o.rootMesh, _.maxNodeName)
  133327. };
  133328. else {
  133329. var b = c.type === WebXRControllerComponent.TOUCHPAD_TYPE && c.touchPointNodeName ? c.touchPointNodeName : _.valueNodeName;
  133330. if (o._buttonMeshMapping[s].states[d] = {
  133331. valueMesh: o._getChildByName(o.rootMesh, b)
  133332. },
  133333. c.type === WebXRControllerComponent.TOUCHPAD_TYPE && !o._touchDots[d]) {
  133334. var k = CreateSphere(d + "dot", {
  133335. diameter: .0015,
  133336. segments: 8
  133337. }, o.scene);
  133338. k.material = new StandardMaterial(d + "mat",o.scene),
  133339. k.material.diffuseColor = Color3.Red(),
  133340. k.parent = o._buttonMeshMapping[s].states[d].valueMesh || null,
  133341. k.isVisible = !1,
  133342. o._touchDots[d] = k
  133343. }
  133344. }
  133345. })
  133346. })
  133347. }
  133348. ,
  133349. e.prototype._setRootMesh = function(i) {
  133350. this.rootMesh = new Mesh(this.profileId + "-" + this.handedness,this.scene),
  133351. this.rootMesh.isPickable = !1;
  133352. for (var o, s = 0; s < i.length; s++) {
  133353. var c = i[s];
  133354. c.isPickable = !1,
  133355. c.parent || (o = c)
  133356. }
  133357. o && o.setParent(this.rootMesh),
  133358. this.scene.useRightHandedSystem || this.rootMesh.rotate(Axis.Y, Math.PI, Space.WORLD)
  133359. }
  133360. ,
  133361. e.prototype._updateModel = function(i) {
  133362. var o = this;
  133363. this.disableAnimation || this.getComponentIds().forEach(function(s) {
  133364. var c = o.getComponent(s);
  133365. if (!!c.hasChanges) {
  133366. var d = o._buttonMeshMapping[s]
  133367. , _ = o.layout.components[s];
  133368. Object.keys(_.visualResponses).forEach(function(b) {
  133369. var k = _.visualResponses[b]
  133370. , j = c.value;
  133371. if (k.componentProperty === "xAxis" ? j = c.axes.x : k.componentProperty === "yAxis" && (j = c.axes.y),
  133372. k.valueNodeProperty === "transform")
  133373. o._lerpTransform(d.states[b], j, k.componentProperty !== "button");
  133374. else {
  133375. var $ = d.states[b].valueMesh;
  133376. $ && ($.isVisible = c.touched || c.pressed),
  133377. o._touchDots[b] && (o._touchDots[b].isVisible = c.touched || c.pressed)
  133378. }
  133379. })
  133380. }
  133381. })
  133382. }
  133383. ,
  133384. e
  133385. }(WebXRAbstractMotionController)
  133386. , controllerCache = []
  133387. , WebXRMotionControllerManager = function() {
  133388. function a() {}
  133389. return a.ClearProfilesCache = function() {
  133390. this._ProfilesList = null,
  133391. this._ProfileLoadingPromises = {}
  133392. }
  133393. ,
  133394. a.DefaultFallbacks = function() {
  133395. this.RegisterFallbacksForProfileId("google-daydream", ["generic-touchpad"]),
  133396. this.RegisterFallbacksForProfileId("htc-vive-focus", ["generic-trigger-touchpad"]),
  133397. this.RegisterFallbacksForProfileId("htc-vive", ["generic-trigger-squeeze-touchpad"]),
  133398. this.RegisterFallbacksForProfileId("magicleap-one", ["generic-trigger-squeeze-touchpad"]),
  133399. this.RegisterFallbacksForProfileId("windows-mixed-reality", ["generic-trigger-squeeze-touchpad-thumbstick"]),
  133400. this.RegisterFallbacksForProfileId("microsoft-mixed-reality", ["windows-mixed-reality", "generic-trigger-squeeze-touchpad-thumbstick"]),
  133401. this.RegisterFallbacksForProfileId("oculus-go", ["generic-trigger-touchpad"]),
  133402. this.RegisterFallbacksForProfileId("oculus-touch-v2", ["oculus-touch", "generic-trigger-squeeze-thumbstick"]),
  133403. this.RegisterFallbacksForProfileId("oculus-touch", ["generic-trigger-squeeze-thumbstick"]),
  133404. this.RegisterFallbacksForProfileId("samsung-gearvr", ["windows-mixed-reality", "generic-trigger-squeeze-touchpad-thumbstick"]),
  133405. this.RegisterFallbacksForProfileId("samsung-odyssey", ["generic-touchpad"]),
  133406. this.RegisterFallbacksForProfileId("valve-index", ["generic-trigger-squeeze-touchpad-thumbstick"]),
  133407. this.RegisterFallbacksForProfileId("generic-hand-select", ["generic-trigger"])
  133408. }
  133409. ,
  133410. a.FindFallbackWithProfileId = function(e) {
  133411. var i = this._Fallbacks[e] || [];
  133412. return i.unshift(e),
  133413. i
  133414. }
  133415. ,
  133416. a.GetMotionControllerWithXRInput = function(e, i, o) {
  133417. var s = this
  133418. , c = [];
  133419. if (o && c.push(o),
  133420. c.push.apply(c, e.profiles || []),
  133421. c.length && !c[0] && c.pop(),
  133422. e.gamepad && e.gamepad.id)
  133423. switch (e.gamepad.id) {
  133424. case (e.gamepad.id.match(/oculus touch/gi) ? e.gamepad.id : void 0):
  133425. c.push("oculus-touch-v2");
  133426. break
  133427. }
  133428. var d = c.indexOf("windows-mixed-reality");
  133429. if (d !== -1 && c.splice(d, 0, "microsoft-mixed-reality"),
  133430. c.length || c.push("generic-trigger"),
  133431. this.UseOnlineRepository) {
  133432. var _ = this.PrioritizeOnlineRepository ? this._LoadProfileFromRepository : this._LoadProfilesFromAvailableControllers
  133433. , b = this.PrioritizeOnlineRepository ? this._LoadProfilesFromAvailableControllers : this._LoadProfileFromRepository;
  133434. return _.call(this, c, e, i).catch(function() {
  133435. return b.call(s, c, e, i)
  133436. })
  133437. } else
  133438. return this._LoadProfilesFromAvailableControllers(c, e, i)
  133439. }
  133440. ,
  133441. a.RegisterController = function(e, i) {
  133442. this._AvailableControllers[e] = i
  133443. }
  133444. ,
  133445. a.RegisterFallbacksForProfileId = function(e, i) {
  133446. var o;
  133447. this._Fallbacks[e] ? (o = this._Fallbacks[e]).push.apply(o, i) : this._Fallbacks[e] = i
  133448. }
  133449. ,
  133450. a.UpdateProfilesList = function() {
  133451. return this._ProfilesList = Tools.LoadFileAsync(this.BaseRepositoryUrl + "/profiles/profilesList.json", !1).then(function(e) {
  133452. return JSON.parse(e.toString())
  133453. }),
  133454. this._ProfilesList
  133455. }
  133456. ,
  133457. a.ClearControllerCache = function() {
  133458. controllerCache.forEach(function(e) {
  133459. e.meshes.forEach(function(i) {
  133460. i.dispose(!1, !0)
  133461. })
  133462. }),
  133463. controllerCache.length = 0
  133464. }
  133465. ,
  133466. a._LoadProfileFromRepository = function(e, i, o) {
  133467. var s = this;
  133468. return Promise.resolve().then(function() {
  133469. return s._ProfilesList ? s._ProfilesList : s.UpdateProfilesList()
  133470. }).then(function(c) {
  133471. for (var d = 0; d < e.length; ++d)
  133472. if (!!e[d] && c[e[d]])
  133473. return e[d];
  133474. throw new Error("neither controller " + e[0] + " nor all fallbacks were found in the repository,")
  133475. }).then(function(c) {
  133476. return s._ProfileLoadingPromises[c] || (s._ProfileLoadingPromises[c] = Tools.LoadFileAsync(s.BaseRepositoryUrl + "/profiles/" + c + "/profile.json", !1).then(function(d) {
  133477. return JSON.parse(d)
  133478. })),
  133479. s._ProfileLoadingPromises[c]
  133480. }).then(function(c) {
  133481. return new WebXRProfiledMotionController(o,i,c,s.BaseRepositoryUrl,s.DisableControllerCache ? void 0 : controllerCache)
  133482. })
  133483. }
  133484. ,
  133485. a._LoadProfilesFromAvailableControllers = function(e, i, o) {
  133486. for (var s = 0; s < e.length; ++s)
  133487. if (!!e[s])
  133488. for (var c = this.FindFallbackWithProfileId(e[s]), d = 0; d < c.length; ++d) {
  133489. var _ = this._AvailableControllers[c[d]];
  133490. if (_)
  133491. return Promise.resolve(_(i, o))
  133492. }
  133493. throw new Error("no controller requested was found in the available controllers list")
  133494. }
  133495. ,
  133496. a._AvailableControllers = {},
  133497. a._Fallbacks = {},
  133498. a._ProfileLoadingPromises = {},
  133499. a.BaseRepositoryUrl = "https://immersive-web.github.io/webxr-input-profiles/packages/viewer/dist",
  133500. a.PrioritizeOnlineRepository = !0,
  133501. a.UseOnlineRepository = !0,
  133502. a.DisableControllerCache = !0,
  133503. a
  133504. }();
  133505. WebXRMotionControllerManager.RegisterController(WebXRGenericTriggerMotionController.ProfileId, function(a, e) {
  133506. return new WebXRGenericTriggerMotionController(e,a.gamepad,a.handedness)
  133507. });
  133508. WebXRMotionControllerManager.DefaultFallbacks();
  133509. var idCount = 0
  133510. , WebXRInputSource = function() {
  133511. function a(e, i, o) {
  133512. var s = this;
  133513. o === void 0 && (o = {}),
  133514. this._scene = e,
  133515. this.inputSource = i,
  133516. this._options = o,
  133517. this._tmpVector = new Vector3,
  133518. this._disposed = !1,
  133519. this.onDisposeObservable = new Observable,
  133520. this.onMeshLoadedObservable = new Observable,
  133521. this.onMotionControllerInitObservable = new Observable,
  133522. this._uniqueId = "controller-" + idCount++ + "-" + i.targetRayMode + "-" + i.handedness,
  133523. this.pointer = new AbstractMesh(this._uniqueId + "-pointer",e),
  133524. this.pointer.rotationQuaternion = new Quaternion,
  133525. this.inputSource.gripSpace && (this.grip = new AbstractMesh(this._uniqueId + "-grip",this._scene),
  133526. this.grip.rotationQuaternion = new Quaternion),
  133527. this._tmpVector.set(0, 0, this._scene.useRightHandedSystem ? -1 : 1),
  133528. this.inputSource.gamepad && this.inputSource.targetRayMode === "tracked-pointer" && WebXRMotionControllerManager.GetMotionControllerWithXRInput(i, e, this._options.forceControllerProfile).then(function(c) {
  133529. s.motionController = c,
  133530. s.onMotionControllerInitObservable.notifyObservers(c),
  133531. !s._options.doNotLoadControllerMesh && !s.motionController._doNotLoadControllerMesh && s.motionController.loadModel().then(function(d) {
  133532. var _;
  133533. d && s.motionController && s.motionController.rootMesh && (s._options.renderingGroupId && (s.motionController.rootMesh.renderingGroupId = s._options.renderingGroupId,
  133534. s.motionController.rootMesh.getChildMeshes(!1).forEach(function(b) {
  133535. return b.renderingGroupId = s._options.renderingGroupId
  133536. })),
  133537. s.onMeshLoadedObservable.notifyObservers(s.motionController.rootMesh),
  133538. s.motionController.rootMesh.parent = s.grip || s.pointer,
  133539. s.motionController.disableAnimation = !!s._options.disableMotionControllerAnimation),
  133540. s._disposed && ((_ = s.motionController) === null || _ === void 0 || _.dispose())
  133541. })
  133542. }, function() {
  133543. Tools.Warn("Could not find a matching motion controller for the registered input source")
  133544. })
  133545. }
  133546. return Object.defineProperty(a.prototype, "uniqueId", {
  133547. get: function() {
  133548. return this._uniqueId
  133549. },
  133550. enumerable: !1,
  133551. configurable: !0
  133552. }),
  133553. a.prototype.dispose = function() {
  133554. this.grip && this.grip.dispose(!0),
  133555. this.motionController && this.motionController.dispose(),
  133556. this.pointer.dispose(!0),
  133557. this.onMotionControllerInitObservable.clear(),
  133558. this.onMeshLoadedObservable.clear(),
  133559. this.onDisposeObservable.notifyObservers(this),
  133560. this.onDisposeObservable.clear(),
  133561. this._disposed = !0
  133562. }
  133563. ,
  133564. a.prototype.getWorldPointerRayToRef = function(e, i) {
  133565. i === void 0 && (i = !1);
  133566. var o = i && this.grip ? this.grip : this.pointer;
  133567. Vector3.TransformNormalToRef(this._tmpVector, o.getWorldMatrix(), e.direction),
  133568. e.direction.normalize(),
  133569. e.origin.copyFrom(o.absolutePosition),
  133570. e.length = 1e3
  133571. }
  133572. ,
  133573. a.prototype.updateFromXRFrame = function(e, i, o) {
  133574. var s = e.getPose(this.inputSource.targetRaySpace, i);
  133575. if (this._lastXRPose = s,
  133576. s) {
  133577. var c = s.transform.position;
  133578. this.pointer.position.set(c.x, c.y, c.z);
  133579. var d = s.transform.orientation;
  133580. this.pointer.rotationQuaternion.set(d.x, d.y, d.z, d.w),
  133581. this._scene.useRightHandedSystem || (this.pointer.position.z *= -1,
  133582. this.pointer.rotationQuaternion.z *= -1,
  133583. this.pointer.rotationQuaternion.w *= -1),
  133584. this.pointer.parent = o.parent
  133585. }
  133586. if (this.inputSource.gripSpace && this.grip) {
  133587. var _ = e.getPose(this.inputSource.gripSpace, i);
  133588. if (_) {
  133589. var c = _.transform.position
  133590. , b = _.transform.orientation;
  133591. this.grip.position.set(c.x, c.y, c.z),
  133592. this.grip.rotationQuaternion.set(b.x, b.y, b.z, b.w),
  133593. this._scene.useRightHandedSystem || (this.grip.position.z *= -1,
  133594. this.grip.rotationQuaternion.z *= -1,
  133595. this.grip.rotationQuaternion.w *= -1)
  133596. }
  133597. this.grip.parent = o.parent
  133598. }
  133599. this.motionController && this.motionController.updateFromXRFrame(e)
  133600. }
  133601. ,
  133602. a
  133603. }()
  133604. , WebXRInput = function() {
  133605. function a(e, i, o) {
  133606. var s = this;
  133607. if (o === void 0 && (o = {}),
  133608. this.xrSessionManager = e,
  133609. this.xrCamera = i,
  133610. this.options = o,
  133611. this.controllers = [],
  133612. this.onControllerAddedObservable = new Observable,
  133613. this.onControllerRemovedObservable = new Observable,
  133614. this._onInputSourcesChange = function(c) {
  133615. s._addAndRemoveControllers(c.added, c.removed)
  133616. }
  133617. ,
  133618. this._sessionEndedObserver = this.xrSessionManager.onXRSessionEnded.add(function() {
  133619. s._addAndRemoveControllers([], s.controllers.map(function(c) {
  133620. return c.inputSource
  133621. }))
  133622. }),
  133623. this._sessionInitObserver = this.xrSessionManager.onXRSessionInit.add(function(c) {
  133624. c.addEventListener("inputsourceschange", s._onInputSourcesChange)
  133625. }),
  133626. this._frameObserver = this.xrSessionManager.onXRFrameObservable.add(function(c) {
  133627. s.controllers.forEach(function(d) {
  133628. d.updateFromXRFrame(c, s.xrSessionManager.referenceSpace, s.xrCamera)
  133629. })
  133630. }),
  133631. this.options.customControllersRepositoryURL && (WebXRMotionControllerManager.BaseRepositoryUrl = this.options.customControllersRepositoryURL),
  133632. WebXRMotionControllerManager.UseOnlineRepository = !this.options.disableOnlineControllerRepository,
  133633. WebXRMotionControllerManager.UseOnlineRepository)
  133634. try {
  133635. WebXRMotionControllerManager.UpdateProfilesList().catch(function() {
  133636. WebXRMotionControllerManager.UseOnlineRepository = !1
  133637. })
  133638. } catch {
  133639. WebXRMotionControllerManager.UseOnlineRepository = !1
  133640. }
  133641. }
  133642. return a.prototype._addAndRemoveControllers = function(e, i) {
  133643. for (var o = this, s = this.controllers.map(function($) {
  133644. return $.inputSource
  133645. }), c = 0, d = e; c < d.length; c++) {
  133646. var _ = d[c];
  133647. if (s.indexOf(_) === -1) {
  133648. var b = new WebXRInputSource(this.xrSessionManager.scene,_,__assign(__assign({}, this.options.controllerOptions || {}), {
  133649. forceControllerProfile: this.options.forceInputProfile,
  133650. doNotLoadControllerMesh: this.options.doNotLoadControllerMeshes,
  133651. disableMotionControllerAnimation: this.options.disableControllerAnimation
  133652. }));
  133653. this.controllers.push(b),
  133654. this.onControllerAddedObservable.notifyObservers(b)
  133655. }
  133656. }
  133657. var k = []
  133658. , j = [];
  133659. this.controllers.forEach(function($) {
  133660. i.indexOf($.inputSource) === -1 ? k.push($) : j.push($)
  133661. }),
  133662. this.controllers = k,
  133663. j.forEach(function($) {
  133664. o.onControllerRemovedObservable.notifyObservers($),
  133665. $.dispose()
  133666. })
  133667. }
  133668. ,
  133669. a.prototype.dispose = function() {
  133670. this.controllers.forEach(function(e) {
  133671. e.dispose()
  133672. }),
  133673. this.xrSessionManager.onXRFrameObservable.remove(this._frameObserver),
  133674. this.xrSessionManager.onXRSessionInit.remove(this._sessionInitObserver),
  133675. this.xrSessionManager.onXRSessionEnded.remove(this._sessionEndedObserver),
  133676. this.onControllerAddedObservable.clear(),
  133677. this.onControllerRemovedObservable.clear(),
  133678. WebXRMotionControllerManager.ClearControllerCache()
  133679. }
  133680. ,
  133681. a
  133682. }()
  133683. , WebXRAbstractFeature = function() {
  133684. function a(e) {
  133685. this._xrSessionManager = e,
  133686. this._attached = !1,
  133687. this._removeOnDetach = [],
  133688. this.isDisposed = !1,
  133689. this.disableAutoAttach = !1,
  133690. this.xrNativeFeatureName = ""
  133691. }
  133692. return Object.defineProperty(a.prototype, "attached", {
  133693. get: function() {
  133694. return this._attached
  133695. },
  133696. enumerable: !1,
  133697. configurable: !0
  133698. }),
  133699. a.prototype.attach = function(e) {
  133700. var i = this;
  133701. if (this.isDisposed)
  133702. return !1;
  133703. if (e)
  133704. this.attached && this.detach();
  133705. else if (this.attached)
  133706. return !1;
  133707. return this._attached = !0,
  133708. this._addNewAttachObserver(this._xrSessionManager.onXRFrameObservable, function(o) {
  133709. return i._onXRFrame(o)
  133710. }),
  133711. !0
  133712. }
  133713. ,
  133714. a.prototype.detach = function() {
  133715. return this._attached ? (this._attached = !1,
  133716. this._removeOnDetach.forEach(function(e) {
  133717. e.observable.remove(e.observer)
  133718. }),
  133719. !0) : (this.disableAutoAttach = !0,
  133720. !1)
  133721. }
  133722. ,
  133723. a.prototype.dispose = function() {
  133724. this.detach(),
  133725. this.isDisposed = !0
  133726. }
  133727. ,
  133728. a.prototype.isCompatible = function() {
  133729. return !0
  133730. }
  133731. ,
  133732. a.prototype._addNewAttachObserver = function(e, i) {
  133733. this._removeOnDetach.push({
  133734. observable: e,
  133735. observer: e.add(i)
  133736. })
  133737. }
  133738. ,
  133739. a
  133740. }()
  133741. , WebXRControllerPointerSelection = function(a) {
  133742. __extends(e, a);
  133743. function e(i, o) {
  133744. var s = a.call(this, i) || this;
  133745. return s._options = o,
  133746. s._attachController = function(c) {
  133747. if (!s._controllers[c.uniqueId]) {
  133748. var d = s._generateNewMeshPair(c.pointer)
  133749. , _ = d.laserPointer
  133750. , b = d.selectionMesh;
  133751. switch (s._controllers[c.uniqueId] = {
  133752. xrController: c,
  133753. laserPointer: _,
  133754. selectionMesh: b,
  133755. meshUnderPointer: null,
  133756. pick: null,
  133757. tmpRay: new Ray(new Vector3,new Vector3),
  133758. disabledByNearInteraction: !1,
  133759. id: e._idCounter++
  133760. },
  133761. s._attachedController ? !s._options.enablePointerSelectionOnAllControllers && s._options.preferredHandedness && c.inputSource.handedness === s._options.preferredHandedness && (s._attachedController = c.uniqueId) : s._options.enablePointerSelectionOnAllControllers || (s._attachedController = c.uniqueId),
  133762. c.inputSource.targetRayMode) {
  133763. case "tracked-pointer":
  133764. return s._attachTrackedPointerRayMode(c);
  133765. case "gaze":
  133766. return s._attachGazeMode(c);
  133767. case "screen":
  133768. return s._attachScreenRayMode(c)
  133769. }
  133770. }
  133771. }
  133772. ,
  133773. s._controllers = {},
  133774. s._tmpVectorForPickCompare = new Vector3,
  133775. s.disablePointerLighting = !0,
  133776. s.disableSelectionMeshLighting = !0,
  133777. s.displayLaserPointer = !0,
  133778. s.displaySelectionMesh = !0,
  133779. s.laserPointerPickedColor = new Color3(.9,.9,.9),
  133780. s.laserPointerDefaultColor = new Color3(.7,.7,.7),
  133781. s.selectionMeshDefaultColor = new Color3(.8,.8,.8),
  133782. s.selectionMeshPickedColor = new Color3(.3,.3,1),
  133783. s._identityMatrix = Matrix.Identity(),
  133784. s._screenCoordinatesRef = Vector3.Zero(),
  133785. s._viewportRef = new Viewport(0,0,0,0),
  133786. s._scene = s._xrSessionManager.scene,
  133787. s
  133788. }
  133789. return e.prototype.attach = function() {
  133790. var i = this;
  133791. if (!a.prototype.attach.call(this))
  133792. return !1;
  133793. if (this._options.xrInput.controllers.forEach(this._attachController),
  133794. this._addNewAttachObserver(this._options.xrInput.onControllerAddedObservable, this._attachController),
  133795. this._addNewAttachObserver(this._options.xrInput.onControllerRemovedObservable, function(_) {
  133796. i._detachController(_.uniqueId)
  133797. }),
  133798. this._scene.constantlyUpdateMeshUnderPointer = !0,
  133799. this._options.gazeCamera) {
  133800. var o = this._options.gazeCamera
  133801. , s = this._generateNewMeshPair(o)
  133802. , c = s.laserPointer
  133803. , d = s.selectionMesh;
  133804. this._controllers.camera = {
  133805. webXRCamera: o,
  133806. laserPointer: c,
  133807. selectionMesh: d,
  133808. meshUnderPointer: null,
  133809. pick: null,
  133810. tmpRay: new Ray(new Vector3,new Vector3),
  133811. disabledByNearInteraction: !1,
  133812. id: e._idCounter++
  133813. },
  133814. this._attachGazeMode()
  133815. }
  133816. return !0
  133817. }
  133818. ,
  133819. e.prototype.detach = function() {
  133820. var i = this;
  133821. return a.prototype.detach.call(this) ? (Object.keys(this._controllers).forEach(function(o) {
  133822. i._detachController(o)
  133823. }),
  133824. !0) : !1
  133825. }
  133826. ,
  133827. e.prototype.getMeshUnderPointer = function(i) {
  133828. return this._controllers[i] ? this._controllers[i].meshUnderPointer : null
  133829. }
  133830. ,
  133831. e.prototype.getXRControllerByPointerId = function(i) {
  133832. for (var o = Object.keys(this._controllers), s = 0; s < o.length; ++s)
  133833. if (this._controllers[o[s]].id === i)
  133834. return this._controllers[o[s]].xrController || null;
  133835. return null
  133836. }
  133837. ,
  133838. e.prototype._getPointerSelectionDisabledByPointerId = function(i) {
  133839. for (var o = Object.keys(this._controllers), s = 0; s < o.length; ++s)
  133840. if (this._controllers[o[s]].id === i)
  133841. return this._controllers[o[s]].disabledByNearInteraction;
  133842. return !0
  133843. }
  133844. ,
  133845. e.prototype._setPointerSelectionDisabledByPointerId = function(i, o) {
  133846. for (var s = Object.keys(this._controllers), c = 0; c < s.length; ++c)
  133847. if (this._controllers[s[c]].id === i) {
  133848. this._controllers[s[c]].disabledByNearInteraction = o;
  133849. return
  133850. }
  133851. }
  133852. ,
  133853. e.prototype._onXRFrame = function(i) {
  133854. var o = this;
  133855. Object.keys(this._controllers).forEach(function(s) {
  133856. var c = o._controllers[s];
  133857. if (!o._options.enablePointerSelectionOnAllControllers && s !== o._attachedController || c.disabledByNearInteraction) {
  133858. c.selectionMesh.isVisible = !1,
  133859. c.laserPointer.isVisible = !1,
  133860. c.pick = null;
  133861. return
  133862. }
  133863. c.laserPointer.isVisible = o.displayLaserPointer;
  133864. var d;
  133865. if (c.xrController)
  133866. d = c.xrController.pointer.position,
  133867. c.xrController.getWorldPointerRayToRef(c.tmpRay);
  133868. else if (c.webXRCamera)
  133869. d = c.webXRCamera.position,
  133870. c.webXRCamera.getForwardRayToRef(c.tmpRay);
  133871. else
  133872. return;
  133873. if (o._options.maxPointerDistance && (c.tmpRay.length = o._options.maxPointerDistance),
  133874. !o._options.disableScenePointerVectorUpdate && d) {
  133875. var _ = o._xrSessionManager.scene
  133876. , b = o._options.xrInput.xrCamera;
  133877. b && (b.viewport.toGlobalToRef(_.getEngine().getRenderWidth(), _.getEngine().getRenderHeight(), o._viewportRef),
  133878. Vector3.ProjectToRef(d, o._identityMatrix, _.getTransformMatrix(), o._viewportRef, o._screenCoordinatesRef),
  133879. typeof o._screenCoordinatesRef.x == "number" && typeof o._screenCoordinatesRef.y == "number" && !isNaN(o._screenCoordinatesRef.x) && !isNaN(o._screenCoordinatesRef.y) && (_.pointerX = o._screenCoordinatesRef.x,
  133880. _.pointerY = o._screenCoordinatesRef.y,
  133881. c.screenCoordinates = {
  133882. x: o._screenCoordinatesRef.x,
  133883. y: o._screenCoordinatesRef.y
  133884. }))
  133885. }
  133886. var k = null;
  133887. o._utilityLayerScene && (k = o._utilityLayerScene.pickWithRay(c.tmpRay, o._utilityLayerScene.pointerMovePredicate || o.raySelectionPredicate));
  133888. var j = o._scene.pickWithRay(c.tmpRay, o._scene.pointerMovePredicate || o.raySelectionPredicate);
  133889. !k || !k.hit ? c.pick = j : !j || !j.hit || k.distance < j.distance ? c.pick = k : c.pick = j,
  133890. c.pick && c.xrController && (c.pick.aimTransform = c.xrController.pointer,
  133891. c.pick.gripTransform = c.xrController.grip || null);
  133892. var $ = c.pick;
  133893. if ($ && $.pickedPoint && $.hit) {
  133894. o._updatePointerDistance(c.laserPointer, $.distance),
  133895. c.selectionMesh.position.copyFrom($.pickedPoint),
  133896. c.selectionMesh.scaling.x = Math.sqrt($.distance),
  133897. c.selectionMesh.scaling.y = Math.sqrt($.distance),
  133898. c.selectionMesh.scaling.z = Math.sqrt($.distance);
  133899. var _e = o._convertNormalToDirectionOfRay($.getNormal(!0), c.tmpRay)
  133900. , et = .001;
  133901. if (c.selectionMesh.position.copyFrom($.pickedPoint),
  133902. _e) {
  133903. var tt = Vector3.Cross(Axis.Y, _e)
  133904. , rt = Vector3.Cross(_e, tt);
  133905. Vector3.RotationFromAxisToRef(rt, _e, tt, c.selectionMesh.rotation),
  133906. c.selectionMesh.position.addInPlace(_e.scale(et))
  133907. }
  133908. c.selectionMesh.isVisible = o.displaySelectionMesh,
  133909. c.meshUnderPointer = $.pickedMesh
  133910. } else
  133911. c.selectionMesh.isVisible = !1,
  133912. o._updatePointerDistance(c.laserPointer, 1),
  133913. c.meshUnderPointer = null
  133914. })
  133915. }
  133916. ,
  133917. Object.defineProperty(e.prototype, "_utilityLayerScene", {
  133918. get: function() {
  133919. return this._options.customUtilityLayerScene || UtilityLayerRenderer.DefaultUtilityLayer.utilityLayerScene
  133920. },
  133921. enumerable: !1,
  133922. configurable: !0
  133923. }),
  133924. e.prototype._attachGazeMode = function(i) {
  133925. var o = this
  133926. , s = this._controllers[i && i.uniqueId || "camera"]
  133927. , c = this._options.timeToSelect || 3e3
  133928. , d = this._options.useUtilityLayer ? this._utilityLayerScene : this._scene
  133929. , _ = new PickingInfo
  133930. , b = CreateTorus("selection", {
  133931. diameter: .0035 * 15,
  133932. thickness: .0025 * 6,
  133933. tessellation: 20
  133934. }, d);
  133935. b.isVisible = !1,
  133936. b.isPickable = !1,
  133937. b.parent = s.selectionMesh;
  133938. var k = 0
  133939. , j = !1
  133940. , $ = {
  133941. pointerId: s.id,
  133942. pointerType: "xr"
  133943. };
  133944. s.onFrameObserver = this._xrSessionManager.onXRFrameObservable.add(function() {
  133945. if (!!s.pick) {
  133946. if (o._augmentPointerInit($, s.id, s.screenCoordinates),
  133947. s.laserPointer.material.alpha = 0,
  133948. b.isVisible = !1,
  133949. s.pick.hit)
  133950. if (o._pickingMoved(_, s.pick))
  133951. j && (o._options.disablePointerUpOnTouchOut || o._scene.simulatePointerUp(s.pick, $)),
  133952. j = !1,
  133953. k = 0;
  133954. else if (k > c / 10 && (b.isVisible = !0),
  133955. k += o._scene.getEngine().getDeltaTime(),
  133956. k >= c)
  133957. o._scene.simulatePointerDown(s.pick, $),
  133958. j = !0,
  133959. o._options.disablePointerUpOnTouchOut && o._scene.simulatePointerUp(s.pick, $),
  133960. b.isVisible = !1;
  133961. else {
  133962. var _e = 1 - k / c;
  133963. b.scaling.set(_e, _e, _e)
  133964. }
  133965. else
  133966. j = !1,
  133967. k = 0;
  133968. o._scene.simulatePointerMove(s.pick, $),
  133969. _ = s.pick
  133970. }
  133971. }),
  133972. this._options.renderingGroupId !== void 0 && (b.renderingGroupId = this._options.renderingGroupId),
  133973. i && i.onDisposeObservable.addOnce(function() {
  133974. s.pick && !o._options.disablePointerUpOnTouchOut && j && (o._scene.simulatePointerUp(s.pick, $),
  133975. s.finalPointerUpTriggered = !0),
  133976. b.dispose()
  133977. })
  133978. }
  133979. ,
  133980. e.prototype._attachScreenRayMode = function(i) {
  133981. var o = this
  133982. , s = this._controllers[i.uniqueId]
  133983. , c = !1
  133984. , d = {
  133985. pointerId: s.id,
  133986. pointerType: "xr"
  133987. };
  133988. s.onFrameObserver = this._xrSessionManager.onXRFrameObservable.add(function() {
  133989. o._augmentPointerInit(d, s.id, s.screenCoordinates),
  133990. !(!s.pick || o._options.disablePointerUpOnTouchOut && c) && (c ? o._scene.simulatePointerMove(s.pick, d) : (o._scene.simulatePointerDown(s.pick, d),
  133991. c = !0,
  133992. o._options.disablePointerUpOnTouchOut && o._scene.simulatePointerUp(s.pick, d)))
  133993. }),
  133994. i.onDisposeObservable.addOnce(function() {
  133995. o._augmentPointerInit(d, s.id, s.screenCoordinates),
  133996. s.pick && c && !o._options.disablePointerUpOnTouchOut && (o._scene.simulatePointerUp(s.pick, d),
  133997. s.finalPointerUpTriggered = !0)
  133998. })
  133999. }
  134000. ,
  134001. e.prototype._attachTrackedPointerRayMode = function(i) {
  134002. var o = this
  134003. , s = this._controllers[i.uniqueId];
  134004. if (this._options.forceGazeMode)
  134005. return this._attachGazeMode(i);
  134006. var c = {
  134007. pointerId: s.id,
  134008. pointerType: "xr"
  134009. };
  134010. if (s.onFrameObserver = this._xrSessionManager.onXRFrameObservable.add(function() {
  134011. s.laserPointer.material.disableLighting = o.disablePointerLighting,
  134012. s.selectionMesh.material.disableLighting = o.disableSelectionMeshLighting,
  134013. s.pick && (o._augmentPointerInit(c, s.id, s.screenCoordinates),
  134014. o._scene.simulatePointerMove(s.pick, c))
  134015. }),
  134016. i.inputSource.gamepad) {
  134017. var d = function(k) {
  134018. o._options.overrideButtonId && (s.selectionComponent = k.getComponent(o._options.overrideButtonId)),
  134019. s.selectionComponent || (s.selectionComponent = k.getMainComponent()),
  134020. s.onButtonChangedObserver = s.selectionComponent.onButtonStateChangedObservable.add(function(j) {
  134021. if (j.changes.pressed) {
  134022. var $ = j.changes.pressed.current;
  134023. s.pick ? (o._options.enablePointerSelectionOnAllControllers || i.uniqueId === o._attachedController) && (o._augmentPointerInit(c, s.id, s.screenCoordinates),
  134024. $ ? (o._scene.simulatePointerDown(s.pick, c),
  134025. s.selectionMesh.material.emissiveColor = o.selectionMeshPickedColor,
  134026. s.laserPointer.material.emissiveColor = o.laserPointerPickedColor) : (o._scene.simulatePointerUp(s.pick, c),
  134027. s.selectionMesh.material.emissiveColor = o.selectionMeshDefaultColor,
  134028. s.laserPointer.material.emissiveColor = o.laserPointerDefaultColor)) : $ && !o._options.enablePointerSelectionOnAllControllers && !o._options.disableSwitchOnClick && (o._attachedController = i.uniqueId)
  134029. }
  134030. })
  134031. };
  134032. i.motionController ? d(i.motionController) : i.onMotionControllerInitObservable.add(d)
  134033. } else {
  134034. var _ = function(k) {
  134035. o._augmentPointerInit(c, s.id, s.screenCoordinates),
  134036. s.xrController && k.inputSource === s.xrController.inputSource && s.pick && (o._scene.simulatePointerDown(s.pick, c),
  134037. s.selectionMesh.material.emissiveColor = o.selectionMeshPickedColor,
  134038. s.laserPointer.material.emissiveColor = o.laserPointerPickedColor)
  134039. }
  134040. , b = function(k) {
  134041. o._augmentPointerInit(c, s.id, s.screenCoordinates),
  134042. s.xrController && k.inputSource === s.xrController.inputSource && s.pick && (o._scene.simulatePointerUp(s.pick, c),
  134043. s.selectionMesh.material.emissiveColor = o.selectionMeshDefaultColor,
  134044. s.laserPointer.material.emissiveColor = o.laserPointerDefaultColor)
  134045. };
  134046. s.eventListeners = {
  134047. selectend: b,
  134048. selectstart: _
  134049. },
  134050. this._xrSessionManager.session.addEventListener("selectstart", _),
  134051. this._xrSessionManager.session.addEventListener("selectend", b)
  134052. }
  134053. }
  134054. ,
  134055. e.prototype._convertNormalToDirectionOfRay = function(i, o) {
  134056. if (i) {
  134057. var s = Math.acos(Vector3.Dot(i, o.direction));
  134058. s < Math.PI / 2 && i.scaleInPlace(-1)
  134059. }
  134060. return i
  134061. }
  134062. ,
  134063. e.prototype._detachController = function(i) {
  134064. var o = this
  134065. , s = this._controllers[i];
  134066. !s || (s.selectionComponent && s.onButtonChangedObserver && s.selectionComponent.onButtonStateChangedObservable.remove(s.onButtonChangedObserver),
  134067. s.onFrameObserver && this._xrSessionManager.onXRFrameObservable.remove(s.onFrameObserver),
  134068. s.eventListeners && Object.keys(s.eventListeners).forEach(function(c) {
  134069. var d = s.eventListeners && s.eventListeners[c];
  134070. d && o._xrSessionManager.session.removeEventListener(c, d)
  134071. }),
  134072. this._xrSessionManager.scene.onBeforeRenderObservable.addOnce(function() {
  134073. try {
  134074. if (!s.finalPointerUpTriggered) {
  134075. var c = {
  134076. pointerId: s.id,
  134077. pointerType: "xr"
  134078. };
  134079. o._augmentPointerInit(c, s.id, s.screenCoordinates),
  134080. o._scene.simulatePointerUp(new PickingInfo, c)
  134081. }
  134082. if (s.selectionMesh.dispose(),
  134083. s.laserPointer.dispose(),
  134084. delete o._controllers[i],
  134085. o._attachedController === i) {
  134086. var d = Object.keys(o._controllers);
  134087. d.length ? o._attachedController = d[0] : o._attachedController = ""
  134088. }
  134089. } catch {
  134090. Tools.Warn("controller already detached.")
  134091. }
  134092. }))
  134093. }
  134094. ,
  134095. e.prototype._generateNewMeshPair = function(i) {
  134096. var o = this._options.useUtilityLayer ? this._options.customUtilityLayerScene || UtilityLayerRenderer.DefaultUtilityLayer.utilityLayerScene : this._scene
  134097. , s = this._options.customLasterPointerMeshGenerator ? this._options.customLasterPointerMeshGenerator() : CreateCylinder("laserPointer", {
  134098. height: 1,
  134099. diameterTop: 2e-4,
  134100. diameterBottom: .004,
  134101. tessellation: 20,
  134102. subdivisions: 1
  134103. }, o);
  134104. s.parent = i;
  134105. var c = new StandardMaterial("laserPointerMat",o);
  134106. c.emissiveColor = this.laserPointerDefaultColor,
  134107. c.alpha = .7,
  134108. s.material = c,
  134109. s.rotation.x = Math.PI / 2,
  134110. this._updatePointerDistance(s, 1),
  134111. s.isPickable = !1,
  134112. s.isVisible = !1;
  134113. var d = this._options.customSelectionMeshGenerator ? this._options.customSelectionMeshGenerator() : CreateTorus("gazeTracker", {
  134114. diameter: .0035 * 3,
  134115. thickness: .0025 * 3,
  134116. tessellation: 20
  134117. }, o);
  134118. d.bakeCurrentTransformIntoVertices(),
  134119. d.isPickable = !1,
  134120. d.isVisible = !1;
  134121. var _ = new StandardMaterial("targetMat",o);
  134122. return _.specularColor = Color3.Black(),
  134123. _.emissiveColor = this.selectionMeshDefaultColor,
  134124. _.backFaceCulling = !1,
  134125. d.material = _,
  134126. this._options.renderingGroupId !== void 0 && (s.renderingGroupId = this._options.renderingGroupId,
  134127. d.renderingGroupId = this._options.renderingGroupId),
  134128. {
  134129. laserPointer: s,
  134130. selectionMesh: d
  134131. }
  134132. }
  134133. ,
  134134. e.prototype._pickingMoved = function(i, o) {
  134135. var s;
  134136. if (!i.hit || !o.hit || !i.pickedMesh || !i.pickedPoint || !o.pickedMesh || !o.pickedPoint || i.pickedMesh !== o.pickedMesh)
  134137. return !0;
  134138. (s = i.pickedPoint) === null || s === void 0 || s.subtractToRef(o.pickedPoint, this._tmpVectorForPickCompare),
  134139. this._tmpVectorForPickCompare.set(Math.abs(this._tmpVectorForPickCompare.x), Math.abs(this._tmpVectorForPickCompare.y), Math.abs(this._tmpVectorForPickCompare.z));
  134140. var c = (this._options.gazeModePointerMovedFactor || 1) * .01 * o.distance
  134141. , d = this._tmpVectorForPickCompare.length();
  134142. return d > c
  134143. }
  134144. ,
  134145. e.prototype._updatePointerDistance = function(i, o) {
  134146. o === void 0 && (o = 100),
  134147. i.scaling.y = o,
  134148. this._scene.useRightHandedSystem && (o *= -1),
  134149. i.position.z = o / 2 + .05
  134150. }
  134151. ,
  134152. e.prototype._augmentPointerInit = function(i, o, s) {
  134153. i.pointerId = o,
  134154. i.pointerType = "xr",
  134155. s && (i.screenX = s.x,
  134156. i.screenY = s.y)
  134157. }
  134158. ,
  134159. Object.defineProperty(e.prototype, "lasterPointerDefaultColor", {
  134160. get: function() {
  134161. return this.laserPointerDefaultColor
  134162. },
  134163. enumerable: !1,
  134164. configurable: !0
  134165. }),
  134166. e._idCounter = 200,
  134167. e.Name = WebXRFeatureName.POINTER_SELECTION,
  134168. e.Version = 1,
  134169. e
  134170. }(WebXRAbstractFeature);
  134171. WebXRFeaturesManager.AddWebXRFeature(WebXRControllerPointerSelection.Name, function(a, e) {
  134172. return function() {
  134173. return new WebXRControllerPointerSelection(a,e)
  134174. }
  134175. }, WebXRControllerPointerSelection.Version, !0);
  134176. SubMesh.prototype._projectOnTrianglesToRef = function(a, e, i, o, s, c) {
  134177. for (var d = TmpVectors.Vector3[0], _ = TmpVectors.Vector3[1], b = 1 / 0, k = this.indexStart; k < this.indexStart + this.indexCount - (3 - o); k += o) {
  134178. var j = i[k]
  134179. , $ = i[k + 1]
  134180. , _e = i[k + 2];
  134181. if (s && _e === 4294967295) {
  134182. k += 2;
  134183. continue
  134184. }
  134185. var et = e[j]
  134186. , tt = e[$]
  134187. , rt = e[_e];
  134188. if (!(!et || !tt || !rt)) {
  134189. var it = Vector3.ProjectOnTriangleToRef(a, et, tt, rt, _);
  134190. it < b && (d.copyFrom(_),
  134191. b = it)
  134192. }
  134193. }
  134194. return c.copyFrom(d),
  134195. b
  134196. }
  134197. ;
  134198. SubMesh.prototype._projectOnUnIndexedTrianglesToRef = function(a, e, i, o) {
  134199. for (var s = TmpVectors.Vector3[0], c = TmpVectors.Vector3[1], d = 1 / 0, _ = this.verticesStart; _ < this.verticesStart + this.verticesCount; _ += 3) {
  134200. var b = e[_]
  134201. , k = e[_ + 1]
  134202. , j = e[_ + 2]
  134203. , $ = Vector3.ProjectOnTriangleToRef(a, b, k, j, c);
  134204. $ < d && (s.copyFrom(c),
  134205. d = $)
  134206. }
  134207. return o.copyFrom(s),
  134208. d
  134209. }
  134210. ;
  134211. SubMesh.prototype.projectToRef = function(a, e, i, o) {
  134212. var s = this.getMaterial();
  134213. if (!s)
  134214. return -1;
  134215. var c = 3
  134216. , d = !1;
  134217. switch (s.fillMode) {
  134218. case 3:
  134219. case 4:
  134220. case 5:
  134221. case 6:
  134222. case 8:
  134223. return -1;
  134224. case 7:
  134225. c = 1,
  134226. d = !0;
  134227. break
  134228. }
  134229. return this._mesh.getClassName() === "InstancedLinesMesh" || this._mesh.getClassName() === "LinesMesh" ? -1 : !i.length && this._mesh._unIndexed ? this._projectOnUnIndexedTrianglesToRef(a, e, i, o) : this._projectOnTrianglesToRef(a, e, i, c, d, o)
  134230. }
  134231. ;
  134232. var WebXRNearInteraction = function(a) {
  134233. __extends(e, a);
  134234. function e(i, o) {
  134235. var s = a.call(this, i) || this;
  134236. return s._options = o,
  134237. s._attachController = function(c) {
  134238. if (!s._controllers[c.uniqueId]) {
  134239. var d = s._generateNewHandTipMesh()
  134240. , _ = s._generateVisualCue();
  134241. switch (s._controllers[c.uniqueId] = {
  134242. xrController: c,
  134243. meshUnderPointer: null,
  134244. nearInteractionMesh: null,
  134245. pick: null,
  134246. pickIndexMeshTip: d,
  134247. grabRay: new Ray(new Vector3,new Vector3),
  134248. hoverInteraction: !1,
  134249. nearInteraction: !1,
  134250. grabInteraction: !1,
  134251. id: e._idCounter++,
  134252. pickedPointVisualCue: _
  134253. },
  134254. s._attachedController ? !s._options.enableNearInteractionOnAllControllers && s._options.preferredHandedness && c.inputSource.handedness === s._options.preferredHandedness && (s._attachedController = c.uniqueId) : s._options.enableNearInteractionOnAllControllers || (s._attachedController = c.uniqueId),
  134255. c.inputSource.targetRayMode) {
  134256. case "tracked-pointer":
  134257. return s._attachNearInteractionMode(c);
  134258. case "gaze":
  134259. return null;
  134260. case "screen":
  134261. return null
  134262. }
  134263. }
  134264. }
  134265. ,
  134266. s._controllers = {},
  134267. s._farInteractionFeature = null,
  134268. s.selectionMeshDefaultColor = new Color3(.8,.8,.8),
  134269. s.selectionMeshPickedColor = new Color3(.3,.3,1),
  134270. s._hoverRadius = .1,
  134271. s._pickRadius = .02,
  134272. s._nearGrabLengthScale = 5,
  134273. s._indexTipQuaternion = new Quaternion,
  134274. s._indexTipOrientationVector = Vector3.Zero(),
  134275. s._scene = s._xrSessionManager.scene,
  134276. s._options.farInteractionFeature && (s._farInteractionFeature = s._options.farInteractionFeature),
  134277. s
  134278. }
  134279. return e.prototype.attach = function() {
  134280. var i = this;
  134281. return a.prototype.attach.call(this) ? (this._options.xrInput.controllers.forEach(this._attachController),
  134282. this._addNewAttachObserver(this._options.xrInput.onControllerAddedObservable, this._attachController),
  134283. this._addNewAttachObserver(this._options.xrInput.onControllerRemovedObservable, function(o) {
  134284. i._detachController(o.uniqueId)
  134285. }),
  134286. this._scene.constantlyUpdateMeshUnderPointer = !0,
  134287. !0) : !1
  134288. }
  134289. ,
  134290. e.prototype.detach = function() {
  134291. var i = this;
  134292. return a.prototype.detach.call(this) ? (Object.keys(this._controllers).forEach(function(o) {
  134293. i._detachController(o)
  134294. }),
  134295. !0) : !1
  134296. }
  134297. ,
  134298. e.prototype.getMeshUnderPointer = function(i) {
  134299. return this._controllers[i] ? this._controllers[i].meshUnderPointer : null
  134300. }
  134301. ,
  134302. e.prototype.getXRControllerByPointerId = function(i) {
  134303. for (var o = Object.keys(this._controllers), s = 0; s < o.length; ++s)
  134304. if (this._controllers[o[s]].id === i)
  134305. return this._controllers[o[s]].xrController || null;
  134306. return null
  134307. }
  134308. ,
  134309. e.prototype.setFarInteractionFeature = function(i) {
  134310. this._farInteractionFeature = i
  134311. }
  134312. ,
  134313. e.prototype._nearPickPredicate = function(i) {
  134314. return i.isEnabled() && i.isVisible && i.isPickable && i.isNearPickable
  134315. }
  134316. ,
  134317. e.prototype._nearGrabPredicate = function(i) {
  134318. return i.isEnabled() && i.isVisible && i.isPickable && i.isNearGrabbable
  134319. }
  134320. ,
  134321. e.prototype._nearInteractionPredicate = function(i) {
  134322. return i.isEnabled() && i.isVisible && i.isPickable && (i.isNearPickable || i.isNearGrabbable)
  134323. }
  134324. ,
  134325. e.prototype._controllerAvailablePredicate = function(i, o) {
  134326. for (var s = i; s; ) {
  134327. if (s.reservedDataStore && s.reservedDataStore.nearInteraction && s.reservedDataStore.nearInteraction.excludedControllerId === o)
  134328. return !1;
  134329. s = s.parent
  134330. }
  134331. return !0
  134332. }
  134333. ,
  134334. e.prototype._onXRFrame = function(i) {
  134335. var o = this;
  134336. Object.keys(this._controllers).forEach(function(s) {
  134337. var c = o._controllers[s];
  134338. if (!o._options.enableNearInteractionOnAllControllers && s !== o._attachedController || !c.xrController || !c.xrController.inputSource.hand) {
  134339. c.pick = null;
  134340. return
  134341. }
  134342. if (c.hoverInteraction = !1,
  134343. c.nearInteraction = !1,
  134344. c.xrController) {
  134345. var d = c.xrController.inputSource.hand;
  134346. if (d) {
  134347. var _ = d.get("index-finger-tip");
  134348. if (_) {
  134349. var b = i.getJointPose(_, o._xrSessionManager.referenceSpace);
  134350. if (b && b.transform) {
  134351. var k = o._scene.useRightHandedSystem ? 1 : -1
  134352. , j = b.transform.position
  134353. , $ = b.transform.orientation;
  134354. o._indexTipQuaternion.set($.x, $.y, $.z * k, $.w * k),
  134355. c.pickIndexMeshTip && c.pickIndexMeshTip.position.set(j.x, j.y, j.z * k);
  134356. var _e = o._nearGrabLengthScale * o._hoverRadius;
  134357. c.grabRay.origin.set(j.x, j.y, j.z * k),
  134358. o._indexTipQuaternion.toEulerAnglesToRef(o._indexTipOrientationVector),
  134359. c.grabRay.direction.set(o._indexTipOrientationVector.x, o._indexTipOrientationVector.y, o._indexTipOrientationVector.z),
  134360. c.grabRay.length = _e
  134361. }
  134362. }
  134363. }
  134364. } else
  134365. return;
  134366. var et = function(lt, ft) {
  134367. var ht = null;
  134368. return !ft || !ft.hit ? ht = lt : !lt || !lt.hit || ft.distance < lt.distance ? ht = ft : ht = lt,
  134369. ht
  134370. }
  134371. , tt = function(lt) {
  134372. var ft = new PickingInfo
  134373. , ht = !1
  134374. , pt = lt && lt.pickedPoint && lt.hit;
  134375. return lt != null && lt.pickedPoint && (ht = lt.pickedPoint.x === 0 && lt.pickedPoint.y === 0 && lt.pickedPoint.z === 0),
  134376. pt && !ht && (ft = lt),
  134377. ft
  134378. };
  134379. if (!c.grabInteraction) {
  134380. var rt = null
  134381. , it = null;
  134382. o._options.useUtilityLayer && o._utilityLayerScene && (it = o._pickWithSphere(c, o._hoverRadius, o._utilityLayerScene, function(lt) {
  134383. return o._nearInteractionPredicate(lt)
  134384. }));
  134385. var nt = o._pickWithSphere(c, o._hoverRadius, o._scene, function(lt) {
  134386. return o._nearInteractionPredicate(lt)
  134387. })
  134388. , ot = et(nt, it);
  134389. if (ot && ot.hit && (rt = tt(ot),
  134390. rt.hit && (c.hoverInteraction = !0)),
  134391. c.pickIndexMeshTip && c.hoverInteraction) {
  134392. var at = null;
  134393. o._options.useUtilityLayer && o._utilityLayerScene && (at = o._pickWithSphere(c, o._pickRadius, o._utilityLayerScene, function(lt) {
  134394. return o._nearPickPredicate(lt)
  134395. }));
  134396. var st = o._pickWithSphere(c, o._pickRadius, o._scene, function(lt) {
  134397. return o._nearPickPredicate(lt)
  134398. })
  134399. , ut = et(st, at)
  134400. , ct = tt(ut);
  134401. ct.hit && (rt = ct,
  134402. c.nearInteraction = !0)
  134403. }
  134404. c.pick = rt,
  134405. c.pick && c.pick.pickedPoint && c.pick.hit ? (c.meshUnderPointer = c.pick.pickedMesh,
  134406. c.pickedPointVisualCue.position.copyFrom(c.pick.pickedPoint),
  134407. c.pickedPointVisualCue.isVisible = !0,
  134408. o._farInteractionFeature && o._farInteractionFeature.attached && o._farInteractionFeature._setPointerSelectionDisabledByPointerId(c.id, !0)) : (c.meshUnderPointer = null,
  134409. c.pickedPointVisualCue.isVisible = !1,
  134410. o._farInteractionFeature && o._farInteractionFeature.attached && o._farInteractionFeature._setPointerSelectionDisabledByPointerId(c.id, !1))
  134411. }
  134412. })
  134413. }
  134414. ,
  134415. Object.defineProperty(e.prototype, "_utilityLayerScene", {
  134416. get: function() {
  134417. return this._options.customUtilityLayerScene || UtilityLayerRenderer.DefaultUtilityLayer.utilityLayerScene
  134418. },
  134419. enumerable: !1,
  134420. configurable: !0
  134421. }),
  134422. e.prototype._generateVisualCue = function() {
  134423. var i = this._options.useUtilityLayer ? this._options.customUtilityLayerScene || UtilityLayerRenderer.DefaultUtilityLayer.utilityLayerScene : this._scene
  134424. , o = CreateSphere("nearInteraction", {
  134425. diameter: .0035 * 3
  134426. }, i);
  134427. o.bakeCurrentTransformIntoVertices(),
  134428. o.isPickable = !1,
  134429. o.isVisible = !1,
  134430. o.rotationQuaternion = Quaternion.Identity();
  134431. var s = new StandardMaterial("targetMat",i);
  134432. return s.specularColor = Color3.Black(),
  134433. s.emissiveColor = this.selectionMeshDefaultColor,
  134434. s.backFaceCulling = !1,
  134435. o.material = s,
  134436. o
  134437. }
  134438. ,
  134439. e.prototype._isControllerReadyForNearInteraction = function(i) {
  134440. return this._farInteractionFeature ? this._farInteractionFeature._getPointerSelectionDisabledByPointerId(i) : !0
  134441. }
  134442. ,
  134443. e.prototype._attachNearInteractionMode = function(i) {
  134444. var o = this
  134445. , s = this._controllers[i.uniqueId]
  134446. , c = {
  134447. pointerId: s.id,
  134448. pointerType: "xr"
  134449. };
  134450. s.onFrameObserver = this._xrSessionManager.onXRFrameObservable.add(function() {
  134451. !o._options.enableNearInteractionOnAllControllers && i.uniqueId !== o._attachedController || !s.xrController || !s.xrController.inputSource.hand || (s.pick && (s.pick.ray = s.grabRay),
  134452. s.pick && o._isControllerReadyForNearInteraction(s.id) && o._scene.simulatePointerMove(s.pick, c),
  134453. s.nearInteraction && s.pick && s.pick.hit ? s.nearInteractionMesh || (o._scene.simulatePointerDown(s.pick, c),
  134454. s.nearInteractionMesh = s.meshUnderPointer) : s.nearInteractionMesh && s.pick && (o._scene.simulatePointerUp(s.pick, c),
  134455. s.nearInteractionMesh = null))
  134456. });
  134457. var d = function(j) {
  134458. o._options.enableNearInteractionOnAllControllers || i.uniqueId === o._attachedController && o._isControllerReadyForNearInteraction(s.id) ? (s.pick && (s.pick.ray = s.grabRay),
  134459. j && s.pick && s.meshUnderPointer && o._nearGrabPredicate(s.meshUnderPointer) ? (s.grabInteraction = !0,
  134460. s.pickedPointVisualCue.isVisible = !1,
  134461. o._scene.simulatePointerDown(s.pick, c)) : !j && s.pick && s.grabInteraction && (o._scene.simulatePointerUp(s.pick, c),
  134462. s.grabInteraction = !1,
  134463. s.pickedPointVisualCue.isVisible = !0)) : j && !o._options.enableNearInteractionOnAllControllers && !o._options.disableSwitchOnClick && (o._attachedController = i.uniqueId)
  134464. };
  134465. if (i.inputSource.gamepad) {
  134466. var _ = function(j) {
  134467. s.squeezeComponent = j.getComponent("grasp"),
  134468. s.squeezeComponent ? s.onSqueezeButtonChangedObserver = s.squeezeComponent.onButtonStateChangedObservable.add(function($) {
  134469. if ($.changes.pressed) {
  134470. var _e = $.changes.pressed.current;
  134471. d(_e)
  134472. }
  134473. }) : (s.selectionComponent = j.getMainComponent(),
  134474. s.onButtonChangedObserver = s.selectionComponent.onButtonStateChangedObservable.add(function($) {
  134475. if ($.changes.pressed) {
  134476. var _e = $.changes.pressed.current;
  134477. d(_e)
  134478. }
  134479. }))
  134480. };
  134481. i.motionController ? _(i.motionController) : i.onMotionControllerInitObservable.add(_)
  134482. } else {
  134483. var b = function(j) {
  134484. s.xrController && j.inputSource === s.xrController.inputSource && s.pick && o._isControllerReadyForNearInteraction(s.id) && s.meshUnderPointer && o._nearGrabPredicate(s.meshUnderPointer) && (s.grabInteraction = !0,
  134485. s.pickedPointVisualCue.isVisible = !1,
  134486. o._scene.simulatePointerDown(s.pick, c))
  134487. }
  134488. , k = function(j) {
  134489. s.xrController && j.inputSource === s.xrController.inputSource && s.pick && o._isControllerReadyForNearInteraction(s.id) && (o._scene.simulatePointerUp(s.pick, c),
  134490. s.grabInteraction = !1,
  134491. s.pickedPointVisualCue.isVisible = !0)
  134492. };
  134493. s.eventListeners = {
  134494. selectend: k,
  134495. selectstart: b
  134496. },
  134497. this._xrSessionManager.session.addEventListener("selectstart", b),
  134498. this._xrSessionManager.session.addEventListener("selectend", k)
  134499. }
  134500. }
  134501. ,
  134502. e.prototype._detachController = function(i) {
  134503. var o = this, s, c = this._controllers[i];
  134504. if (!!c) {
  134505. c.squeezeComponent && c.onSqueezeButtonChangedObserver && c.squeezeComponent.onButtonStateChangedObservable.remove(c.onSqueezeButtonChangedObserver),
  134506. c.selectionComponent && c.onButtonChangedObserver && c.selectionComponent.onButtonStateChangedObservable.remove(c.onButtonChangedObserver),
  134507. c.onFrameObserver && this._xrSessionManager.onXRFrameObservable.remove(c.onFrameObserver),
  134508. c.eventListeners && Object.keys(c.eventListeners).forEach(function(b) {
  134509. var k = c.eventListeners && c.eventListeners[b];
  134510. k && o._xrSessionManager.session.removeEventListener(b, k)
  134511. }),
  134512. (s = c.pickIndexMeshTip) === null || s === void 0 || s.dispose(),
  134513. c.pickedPointVisualCue.dispose();
  134514. var d = {
  134515. pointerId: c.id,
  134516. pointerType: "xr"
  134517. };
  134518. if (this._scene.simulatePointerUp(new PickingInfo, d),
  134519. delete this._controllers[i],
  134520. this._attachedController === i) {
  134521. var _ = Object.keys(this._controllers);
  134522. _.length ? this._attachedController = _[0] : this._attachedController = ""
  134523. }
  134524. }
  134525. }
  134526. ,
  134527. e.prototype._generateNewHandTipMesh = function() {
  134528. var i = this._options.useUtilityLayer ? this._options.customUtilityLayerScene || UtilityLayerRenderer.DefaultUtilityLayer.utilityLayerScene : this._scene
  134529. , o = null
  134530. , s = function(c, d, _) {
  134531. var b = null;
  134532. return b = CreateSphere(c, {
  134533. diameter: 1
  134534. }, _),
  134535. b.scaling.set(d, d, d),
  134536. b.isVisible = !1,
  134537. b
  134538. };
  134539. return o = s("IndexPickSphere", this._pickRadius, i),
  134540. o
  134541. }
  134542. ,
  134543. e.prototype._pickWithSphere = function(i, o, s, c) {
  134544. var d = new PickingInfo;
  134545. if (d.distance = 1 / 0,
  134546. i.pickIndexMeshTip && i.xrController)
  134547. for (var _ = i.pickIndexMeshTip.position, b = BoundingSphere.CreateFromCenterAndRadius(_, o), k = 0; k < s.meshes.length; k++) {
  134548. var j = s.meshes[k];
  134549. if (!(!c(j) || !this._controllerAvailablePredicate(j, i.xrController.uniqueId))) {
  134550. var $ = e.PickMeshWithSphere(j, b);
  134551. $ && $.hit && $.distance < d.distance && (d.hit = $.hit,
  134552. d.pickedMesh = j,
  134553. d.pickedPoint = $.pickedPoint,
  134554. d.aimTransform = i.xrController.pointer,
  134555. d.gripTransform = i.xrController.grip || null,
  134556. d.originMesh = i.pickIndexMeshTip,
  134557. d.distance = $.distance)
  134558. }
  134559. }
  134560. return d
  134561. }
  134562. ,
  134563. e.PickMeshWithSphere = function(i, o, s) {
  134564. s === void 0 && (s = !1);
  134565. var c = i.subMeshes
  134566. , d = new PickingInfo
  134567. , _ = i.getBoundingInfo();
  134568. if (!i._generatePointsArray() || !i.subMeshes || !_ || !s && !BoundingSphere.Intersects(_.boundingSphere, o))
  134569. return d;
  134570. var b = TmpVectors.Vector3[0], k = TmpVectors.Vector3[1], j = 1 / 0, $, _e, et, tt = TmpVectors.Vector3[2], rt = TmpVectors.Matrix[0];
  134571. rt.copyFrom(i.getWorldMatrix()),
  134572. rt.invert(),
  134573. Vector3.TransformCoordinatesToRef(o.center, rt, tt);
  134574. for (var it = 0; it < c.length; it++) {
  134575. var nt = c[it];
  134576. nt.projectToRef(tt, i._positions, i.getIndices(), k),
  134577. Vector3.TransformCoordinatesToRef(k, i.getWorldMatrix(), k),
  134578. $ = Vector3.Distance(k, o.center),
  134579. et = Vector3.Distance(k, i.getAbsolutePosition()),
  134580. _e = Vector3.Distance(o.center, i.getAbsolutePosition()),
  134581. _e !== -1 && et !== -1 && et > _e && ($ = 0,
  134582. k.copyFrom(o.center)),
  134583. $ !== -1 && $ < j && (j = $,
  134584. b.copyFrom(k))
  134585. }
  134586. return j < o.radius && (d.hit = !0,
  134587. d.distance = j,
  134588. d.pickedMesh = i,
  134589. d.pickedPoint = b.clone()),
  134590. d
  134591. }
  134592. ,
  134593. e._idCounter = 200,
  134594. e.Name = WebXRFeatureName.NEAR_INTERACTION,
  134595. e.Version = 1,
  134596. e
  134597. }(WebXRAbstractFeature);
  134598. WebXRFeaturesManager.AddWebXRFeature(WebXRNearInteraction.Name, function(a, e) {
  134599. return function() {
  134600. return new WebXRNearInteraction(a,e)
  134601. }
  134602. }, WebXRNearInteraction.Version, !0);
  134603. var WebXREnterExitUIButton = function() {
  134604. function a(e, i, o) {
  134605. this.element = e,
  134606. this.sessionMode = i,
  134607. this.referenceSpaceType = o
  134608. }
  134609. return a.prototype.update = function(e) {}
  134610. ,
  134611. a
  134612. }(), WebXREnterExitUI = function() {
  134613. function a(e, i) {
  134614. var o = this;
  134615. if (this.scene = e,
  134616. this.options = i,
  134617. this._activeButton = null,
  134618. this._buttons = [],
  134619. this.activeButtonChangedObservable = new Observable,
  134620. this._onSessionGranted = function($) {
  134621. o._helper && o._enterXRWithButtonIndex(0)
  134622. }
  134623. ,
  134624. this.overlay = document.createElement("div"),
  134625. this.overlay.classList.add("xr-button-overlay"),
  134626. this.overlay.style.cssText = "z-index:11;position: absolute; right: 20px;bottom: 50px;",
  134627. !i.ignoreSessionGrantedEvent && navigator.xr && navigator.xr.addEventListener("sessiongranted", this._onSessionGranted),
  134628. typeof window != "undefined" && window.location && window.location.protocol === "http:" && window.location.hostname !== "localhost")
  134629. throw Tools.Warn("WebXR can only be served over HTTPS"),
  134630. new Error("WebXR can only be served over HTTPS");
  134631. if (i.customButtons)
  134632. this._buttons = i.customButtons;
  134633. else {
  134634. var s = i.sessionMode || "immersive-vr"
  134635. , c = i.referenceSpaceType || "local-floor"
  134636. , d = typeof SVGSVGElement == "undefined" ? "https://cdn.babylonjs.com/Assets/vrButton.png" : "data:image/svg+xml;charset=UTF-8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%222048%22%20height%3D%221152%22%20viewBox%3D%220%200%202048%201152%22%20version%3D%221.1%22%3E%3Cpath%20transform%3D%22rotate%28180%201024%2C576.0000000000001%29%22%20d%3D%22m1109%2C896q17%2C0%2030%2C-12t13%2C-30t-12.5%2C-30.5t-30.5%2C-12.5l-170%2C0q-18%2C0%20-30.5%2C12.5t-12.5%2C30.5t13%2C30t30%2C12l170%2C0zm-85%2C256q59%2C0%20132.5%2C-1.5t154.5%2C-5.5t164.5%2C-11.5t163%2C-20t150%2C-30t124.5%2C-41.5q23%2C-11%2042%2C-24t38%2C-30q27%2C-25%2041%2C-61.5t14%2C-72.5l0%2C-257q0%2C-123%20-47%2C-232t-128%2C-190t-190%2C-128t-232%2C-47l-81%2C0q-37%2C0%20-68.5%2C14t-60.5%2C34.5t-55.5%2C45t-53%2C45t-53%2C34.5t-55.5%2C14t-55.5%2C-14t-53%2C-34.5t-53%2C-45t-55.5%2C-45t-60.5%2C-34.5t-68.5%2C-14l-81%2C0q-123%2C0%20-232%2C47t-190%2C128t-128%2C190t-47%2C232l0%2C257q0%2C68%2038%2C115t97%2C73q54%2C24%20124.5%2C41.5t150%2C30t163%2C20t164.5%2C11.5t154.5%2C5.5t132.5%2C1.5zm939%2C-298q0%2C39%20-24.5%2C67t-58.5%2C42q-54%2C23%20-122%2C39.5t-143.5%2C28t-155.5%2C19t-157%2C11t-148.5%2C5t-129.5%2C1.5q-59%2C0%20-130%2C-1.5t-148%2C-5t-157%2C-11t-155.5%2C-19t-143.5%2C-28t-122%2C-39.5q-34%2C-14%20-58.5%2C-42t-24.5%2C-67l0%2C-257q0%2C-106%2040.5%2C-199t110%2C-162.5t162.5%2C-109.5t199%2C-40l81%2C0q27%2C0%2052%2C14t50%2C34.5t51%2C44.5t55.5%2C44.5t63.5%2C34.5t74%2C14t74%2C-14t63.5%2C-34.5t55.5%2C-44.5t51%2C-44.5t50%2C-34.5t52%2C-14l14%2C0q37%2C0%2070%2C0.5t64.5%2C4.5t63.5%2C12t68%2C23q71%2C30%20128.5%2C78.5t98.5%2C110t63.5%2C133.5t22.5%2C149l0%2C257z%22%20fill%3D%22white%22%20/%3E%3C/svg%3E%0A"
  134637. , _ = ".babylonVRicon { color: #868686; border-color: #868686; border-style: solid; margin-left: 10px; height: 50px; width: 80px; background-color: rgba(51,51,51,0.7); background-image: url(" + d + "); background-size: 80%; background-repeat:no-repeat; background-position: center; border: none; outline: none; transition: transform 0.125s ease-out } .babylonVRicon:hover { transform: scale(1.05) } .babylonVRicon:active {background-color: rgba(51,51,51,1) } .babylonVRicon:focus {background-color: rgba(51,51,51,1) }";
  134638. _ += '.babylonVRicon.vrdisplaypresenting { background-image: none;} .vrdisplaypresenting::after { content: "EXIT"} .xr-error::after { content: "ERROR"}';
  134639. var b = document.createElement("style");
  134640. b.appendChild(document.createTextNode(_)),
  134641. document.getElementsByTagName("head")[0].appendChild(b);
  134642. var k = document.createElement("button");
  134643. k.className = "babylonVRicon",
  134644. k.title = s + " - " + c,
  134645. this._buttons.push(new WebXREnterExitUIButton(k,s,c)),
  134646. this._buttons[this._buttons.length - 1].update = function($) {
  134647. this.element.style.display = $ === null || $ === this ? "" : "none",
  134648. k.className = "babylonVRicon" + ($ === this ? " vrdisplaypresenting" : "")
  134649. }
  134650. ,
  134651. this._updateButtons(null)
  134652. }
  134653. var j = e.getEngine().getInputElement();
  134654. j && j.parentNode && (j.parentNode.appendChild(this.overlay),
  134655. e.onDisposeObservable.addOnce(function() {
  134656. o.dispose()
  134657. }))
  134658. }
  134659. return a.prototype.setHelperAsync = function(e, i) {
  134660. return __awaiter(this, void 0, void 0, function() {
  134661. var o, s, c = this;
  134662. return __generator(this, function(d) {
  134663. switch (d.label) {
  134664. case 0:
  134665. return this._helper = e,
  134666. this._renderTarget = i,
  134667. o = this._buttons.map(function(_) {
  134668. return e.sessionManager.isSessionSupportedAsync(_.sessionMode)
  134669. }),
  134670. e.onStateChangedObservable.add(function(_) {
  134671. _ == WebXRState.NOT_IN_XR && c._updateButtons(null)
  134672. }),
  134673. [4, Promise.all(o)];
  134674. case 1:
  134675. return s = d.sent(),
  134676. s.forEach(function(_, b) {
  134677. _ ? (c.overlay.appendChild(c._buttons[b].element),
  134678. c._buttons[b].element.onclick = c._enterXRWithButtonIndex.bind(c, b)) : Tools.Warn('Session mode "' + c._buttons[b].sessionMode + '" not supported in browser')
  134679. }),
  134680. [2]
  134681. }
  134682. })
  134683. })
  134684. }
  134685. ,
  134686. a.CreateAsync = function(e, i, o) {
  134687. return __awaiter(this, void 0, void 0, function() {
  134688. var s;
  134689. return __generator(this, function(c) {
  134690. switch (c.label) {
  134691. case 0:
  134692. return s = new a(e,o),
  134693. [4, s.setHelperAsync(i, o.renderTarget || void 0)];
  134694. case 1:
  134695. return c.sent(),
  134696. [2, s]
  134697. }
  134698. })
  134699. })
  134700. }
  134701. ,
  134702. a.prototype._enterXRWithButtonIndex = function(e) {
  134703. return e === void 0 && (e = 0),
  134704. __awaiter(this, void 0, void 0, function() {
  134705. var i, o, s;
  134706. return __generator(this, function(c) {
  134707. switch (c.label) {
  134708. case 0:
  134709. return this._helper.state != WebXRState.IN_XR ? [3, 2] : [4, this._helper.exitXRAsync()];
  134710. case 1:
  134711. return c.sent(),
  134712. this._updateButtons(null),
  134713. [3, 6];
  134714. case 2:
  134715. if (this._helper.state != WebXRState.NOT_IN_XR)
  134716. return [3, 6];
  134717. c.label = 3;
  134718. case 3:
  134719. return c.trys.push([3, 5, , 6]),
  134720. [4, this._helper.enterXRAsync(this._buttons[e].sessionMode, this._buttons[e].referenceSpaceType, this._renderTarget, {
  134721. optionalFeatures: this.options.optionalFeatures,
  134722. requiredFeatures: this.options.requiredFeatures
  134723. })];
  134724. case 4:
  134725. return c.sent(),
  134726. this._updateButtons(this._buttons[e]),
  134727. [3, 6];
  134728. case 5:
  134729. return i = c.sent(),
  134730. this._updateButtons(null),
  134731. o = this._buttons[e].element,
  134732. s = o.title,
  134733. o.title = "Error entering XR session : " + s,
  134734. o.classList.add("xr-error"),
  134735. this.options.onError && this.options.onError(i),
  134736. [3, 6];
  134737. case 6:
  134738. return [2]
  134739. }
  134740. })
  134741. })
  134742. }
  134743. ,
  134744. a.prototype.dispose = function() {
  134745. var e = this.scene.getEngine().getInputElement();
  134746. e && e.parentNode && e.parentNode.contains(this.overlay) && e.parentNode.removeChild(this.overlay),
  134747. this.activeButtonChangedObservable.clear(),
  134748. navigator.xr.removeEventListener("sessiongranted", this._onSessionGranted)
  134749. }
  134750. ,
  134751. a.prototype._updateButtons = function(e) {
  134752. var i = this;
  134753. this._activeButton = e,
  134754. this._buttons.forEach(function(o) {
  134755. o.update(i._activeButton)
  134756. }),
  134757. this.activeButtonChangedObservable.notifyObservers(this._activeButton)
  134758. }
  134759. ,
  134760. a
  134761. }(), TimerState;
  134762. (function(a) {
  134763. a[a.INIT = 0] = "INIT",
  134764. a[a.STARTED = 1] = "STARTED",
  134765. a[a.ENDED = 2] = "ENDED"
  134766. }
  134767. )(TimerState || (TimerState = {}));
  134768. function setAndStartTimer(a) {
  134769. var e, i = 0, o = Date.now();
  134770. a.observableParameters = (e = a.observableParameters) !== null && e !== void 0 ? e : {};
  134771. var s = a.contextObservable.add(function(c) {
  134772. var d = Date.now();
  134773. i = d - o;
  134774. var _ = {
  134775. startTime: o,
  134776. currentTime: d,
  134777. deltaTime: i,
  134778. completeRate: i / a.timeout,
  134779. payload: c
  134780. };
  134781. a.onTick && a.onTick(_),
  134782. a.breakCondition && a.breakCondition() && (a.contextObservable.remove(s),
  134783. a.onAborted && a.onAborted(_)),
  134784. i >= a.timeout && (a.contextObservable.remove(s),
  134785. a.onEnded && a.onEnded(_))
  134786. }, a.observableParameters.mask, a.observableParameters.insertFirst, a.observableParameters.scope);
  134787. return s
  134788. }
  134789. (function() {
  134790. function a(e) {
  134791. var i = this, o, s;
  134792. this.onEachCountObservable = new Observable,
  134793. this.onTimerAbortedObservable = new Observable,
  134794. this.onTimerEndedObservable = new Observable,
  134795. this.onStateChangedObservable = new Observable,
  134796. this._observer = null,
  134797. this._breakOnNextTick = !1,
  134798. this._tick = function(c) {
  134799. var d = Date.now();
  134800. i._timer = d - i._startTime;
  134801. var _ = {
  134802. startTime: i._startTime,
  134803. currentTime: d,
  134804. deltaTime: i._timer,
  134805. completeRate: i._timer / i._timeToEnd,
  134806. payload: c
  134807. }
  134808. , b = i._breakOnNextTick || i._breakCondition(_);
  134809. b || i._timer >= i._timeToEnd ? i._stop(_, b) : i.onEachCountObservable.notifyObservers(_)
  134810. }
  134811. ,
  134812. this._setState(TimerState.INIT),
  134813. this._contextObservable = e.contextObservable,
  134814. this._observableParameters = (o = e.observableParameters) !== null && o !== void 0 ? o : {},
  134815. this._breakCondition = (s = e.breakCondition) !== null && s !== void 0 ? s : function() {
  134816. return !1
  134817. }
  134818. ,
  134819. e.onEnded && this.onTimerEndedObservable.add(e.onEnded),
  134820. e.onTick && this.onEachCountObservable.add(e.onTick),
  134821. e.onAborted && this.onTimerAbortedObservable.add(e.onAborted)
  134822. }
  134823. return Object.defineProperty(a.prototype, "breakCondition", {
  134824. set: function(e) {
  134825. this._breakCondition = e
  134826. },
  134827. enumerable: !1,
  134828. configurable: !0
  134829. }),
  134830. a.prototype.clearObservables = function() {
  134831. this.onEachCountObservable.clear(),
  134832. this.onTimerAbortedObservable.clear(),
  134833. this.onTimerEndedObservable.clear(),
  134834. this.onStateChangedObservable.clear()
  134835. }
  134836. ,
  134837. a.prototype.start = function(e) {
  134838. if (e === void 0 && (e = this._timeToEnd),
  134839. this._state === TimerState.STARTED)
  134840. throw new Error("Timer already started. Please stop it before starting again");
  134841. this._timeToEnd = e,
  134842. this._startTime = Date.now(),
  134843. this._timer = 0,
  134844. this._observer = this._contextObservable.add(this._tick, this._observableParameters.mask, this._observableParameters.insertFirst, this._observableParameters.scope),
  134845. this._setState(TimerState.STARTED)
  134846. }
  134847. ,
  134848. a.prototype.stop = function() {
  134849. this._state === TimerState.STARTED && (this._breakOnNextTick = !0)
  134850. }
  134851. ,
  134852. a.prototype.dispose = function() {
  134853. this._observer && this._contextObservable.remove(this._observer),
  134854. this.clearObservables()
  134855. }
  134856. ,
  134857. a.prototype._setState = function(e) {
  134858. this._state = e,
  134859. this.onStateChangedObservable.notifyObservers(this._state)
  134860. }
  134861. ,
  134862. a.prototype._stop = function(e, i) {
  134863. i === void 0 && (i = !1),
  134864. this._contextObservable.remove(this._observer),
  134865. this._setState(TimerState.ENDED),
  134866. i ? this.onTimerAbortedObservable.notifyObservers(e) : this.onTimerEndedObservable.notifyObservers(e)
  134867. }
  134868. ,
  134869. a
  134870. }
  134871. )();
  134872. var WebXRMotionControllerTeleportation = function(a) {
  134873. __extends(e, a);
  134874. function e(i, o) {
  134875. var s = a.call(this, i) || this;
  134876. return s._options = o,
  134877. s._controllers = {},
  134878. s._snappedToPoint = !1,
  134879. s._tmpRay = new Ray(new Vector3,new Vector3),
  134880. s._tmpVector = new Vector3,
  134881. s._tmpQuaternion = new Quaternion,
  134882. s.skipNextTeleportation = !1,
  134883. s.backwardsMovementEnabled = !0,
  134884. s.backwardsTeleportationDistance = .7,
  134885. s.parabolicCheckRadius = 5,
  134886. s.parabolicRayEnabled = !0,
  134887. s.straightRayEnabled = !0,
  134888. s.rotationAngle = Math.PI / 8,
  134889. s.onTargetMeshPositionUpdatedObservable = new Observable,
  134890. s.teleportationEnabled = !0,
  134891. s._rotationEnabled = !0,
  134892. s._attachController = function(c) {
  134893. if (!(s._controllers[c.uniqueId] || s._options.forceHandedness && c.inputSource.handedness !== s._options.forceHandedness)) {
  134894. s._controllers[c.uniqueId] = {
  134895. xrController: c,
  134896. teleportationState: {
  134897. forward: !1,
  134898. backwards: !1,
  134899. rotating: !1,
  134900. currentRotation: 0,
  134901. baseRotation: 0
  134902. }
  134903. };
  134904. var d = s._controllers[c.uniqueId];
  134905. if (d.xrController.inputSource.targetRayMode === "tracked-pointer" && d.xrController.inputSource.gamepad) {
  134906. var _ = function() {
  134907. if (c.motionController) {
  134908. var b = c.motionController.getComponentOfType(WebXRControllerComponent.THUMBSTICK_TYPE) || c.motionController.getComponentOfType(WebXRControllerComponent.TOUCHPAD_TYPE);
  134909. if (!b || s._options.useMainComponentOnly) {
  134910. var k = c.motionController.getMainComponent();
  134911. if (!k)
  134912. return;
  134913. d.teleportationComponent = k,
  134914. d.onButtonChangedObserver = k.onButtonStateChangedObservable.add(function() {
  134915. if (!!s.teleportationEnabled && k.changes.pressed)
  134916. if (k.changes.pressed.current) {
  134917. d.teleportationState.forward = !0,
  134918. s._currentTeleportationControllerId = d.xrController.uniqueId,
  134919. d.teleportationState.baseRotation = s._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y,
  134920. d.teleportationState.currentRotation = 0;
  134921. var j = s._options.timeToTeleport || 3e3;
  134922. setAndStartTimer({
  134923. timeout: j,
  134924. contextObservable: s._xrSessionManager.onXRFrameObservable,
  134925. breakCondition: function() {
  134926. return !k.pressed
  134927. },
  134928. onEnded: function() {
  134929. s._currentTeleportationControllerId === d.xrController.uniqueId && d.teleportationState.forward && s._teleportForward(c.uniqueId)
  134930. }
  134931. })
  134932. } else
  134933. d.teleportationState.forward = !1,
  134934. s._currentTeleportationControllerId = ""
  134935. })
  134936. } else
  134937. d.teleportationComponent = b,
  134938. d.onAxisChangedObserver = b.onAxisValueChangedObservable.add(function(j) {
  134939. if (j.y <= .7 && d.teleportationState.backwards && (d.teleportationState.backwards = !1),
  134940. j.y > .7 && !d.teleportationState.forward && s.backwardsMovementEnabled && !s.snapPointsOnly && !d.teleportationState.backwards) {
  134941. d.teleportationState.backwards = !0,
  134942. s._tmpQuaternion.copyFrom(s._options.xrInput.xrCamera.rotationQuaternion),
  134943. s._tmpQuaternion.toEulerAnglesToRef(s._tmpVector),
  134944. s._tmpVector.x = 0,
  134945. s._tmpVector.z = 0,
  134946. Quaternion.FromEulerVectorToRef(s._tmpVector, s._tmpQuaternion),
  134947. s._tmpVector.set(0, 0, s.backwardsTeleportationDistance * (s._xrSessionManager.scene.useRightHandedSystem ? 1 : -1)),
  134948. s._tmpVector.rotateByQuaternionToRef(s._tmpQuaternion, s._tmpVector),
  134949. s._tmpVector.addInPlace(s._options.xrInput.xrCamera.position),
  134950. s._tmpRay.origin.copyFrom(s._tmpVector),
  134951. s._tmpRay.length = s._options.xrInput.xrCamera.realWorldHeight + .1,
  134952. s._tmpRay.direction.set(0, -1, 0);
  134953. var $ = s._xrSessionManager.scene.pickWithRay(s._tmpRay, function(et) {
  134954. return s._floorMeshes.indexOf(et) !== -1
  134955. });
  134956. $ && $.pickedPoint && (s._options.xrInput.xrCamera.position.x = $.pickedPoint.x,
  134957. s._options.xrInput.xrCamera.position.z = $.pickedPoint.z)
  134958. }
  134959. if (j.y < -.7 && !s._currentTeleportationControllerId && !d.teleportationState.rotating && s.teleportationEnabled && (d.teleportationState.forward = !0,
  134960. s._currentTeleportationControllerId = d.xrController.uniqueId,
  134961. d.teleportationState.baseRotation = s._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y),
  134962. j.x) {
  134963. if (d.teleportationState.forward)
  134964. s._currentTeleportationControllerId === d.xrController.uniqueId && (s.rotationEnabled ? setTimeout(function() {
  134965. d.teleportationState.currentRotation = Math.atan2(j.x, j.y * (s._xrSessionManager.scene.useRightHandedSystem ? 1 : -1))
  134966. }) : d.teleportationState.currentRotation = 0);
  134967. else if (!d.teleportationState.rotating && Math.abs(j.x) > .7) {
  134968. d.teleportationState.rotating = !0;
  134969. var _e = s.rotationAngle * (j.x > 0 ? 1 : -1) * (s._xrSessionManager.scene.useRightHandedSystem ? -1 : 1);
  134970. Quaternion.FromEulerAngles(0, _e, 0).multiplyToRef(s._options.xrInput.xrCamera.rotationQuaternion, s._options.xrInput.xrCamera.rotationQuaternion)
  134971. }
  134972. } else
  134973. d.teleportationState.rotating = !1;
  134974. j.x === 0 && j.y === 0 && d.teleportationState.forward && s._teleportForward(c.uniqueId)
  134975. })
  134976. }
  134977. };
  134978. c.motionController ? _() : c.onMotionControllerInitObservable.addOnce(function() {
  134979. _()
  134980. })
  134981. } else
  134982. s._xrSessionManager.scene.onPointerObservable.add(function(b) {
  134983. if (b.type === PointerEventTypes.POINTERDOWN) {
  134984. d.teleportationState.forward = !0,
  134985. s._currentTeleportationControllerId = d.xrController.uniqueId,
  134986. d.teleportationState.baseRotation = s._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y,
  134987. d.teleportationState.currentRotation = 0;
  134988. var k = s._options.timeToTeleport || 3e3;
  134989. setAndStartTimer({
  134990. timeout: k,
  134991. contextObservable: s._xrSessionManager.onXRFrameObservable,
  134992. onEnded: function() {
  134993. s._currentTeleportationControllerId === d.xrController.uniqueId && d.teleportationState.forward && s._teleportForward(c.uniqueId)
  134994. }
  134995. })
  134996. } else
  134997. b.type === PointerEventTypes.POINTERUP && (d.teleportationState.forward = !1,
  134998. s._currentTeleportationControllerId = "")
  134999. })
  135000. }
  135001. }
  135002. ,
  135003. s._options.teleportationTargetMesh || s._createDefaultTargetMesh(),
  135004. s._floorMeshes = s._options.floorMeshes || [],
  135005. s._snapToPositions = s._options.snapPositions || [],
  135006. s._setTargetMeshVisibility(!1),
  135007. s
  135008. }
  135009. return Object.defineProperty(e.prototype, "rotationEnabled", {
  135010. get: function() {
  135011. return this._rotationEnabled
  135012. },
  135013. set: function(i) {
  135014. if (this._rotationEnabled = i,
  135015. this._options.teleportationTargetMesh) {
  135016. var o = this._options.teleportationTargetMesh.getChildMeshes(!1, function(s) {
  135017. return s.name === "rotationCone"
  135018. });
  135019. o[0] && o[0].setEnabled(i)
  135020. }
  135021. },
  135022. enumerable: !1,
  135023. configurable: !0
  135024. }),
  135025. Object.defineProperty(e.prototype, "teleportationTargetMesh", {
  135026. get: function() {
  135027. return this._options.teleportationTargetMesh || null
  135028. },
  135029. enumerable: !1,
  135030. configurable: !0
  135031. }),
  135032. Object.defineProperty(e.prototype, "snapPointsOnly", {
  135033. get: function() {
  135034. return !!this._options.snapPointsOnly
  135035. },
  135036. set: function(i) {
  135037. this._options.snapPointsOnly = i
  135038. },
  135039. enumerable: !1,
  135040. configurable: !0
  135041. }),
  135042. e.prototype.addFloorMesh = function(i) {
  135043. this._floorMeshes.push(i)
  135044. }
  135045. ,
  135046. e.prototype.addBlockerMesh = function(i) {
  135047. this._options.pickBlockerMeshes = this._options.pickBlockerMeshes || [],
  135048. this._options.pickBlockerMeshes.push(i)
  135049. }
  135050. ,
  135051. e.prototype.addSnapPoint = function(i) {
  135052. this._snapToPositions.push(i)
  135053. }
  135054. ,
  135055. e.prototype.attach = function() {
  135056. var i = this;
  135057. return a.prototype.attach.call(this) ? (this._currentTeleportationControllerId = "",
  135058. this._options.xrInput.controllers.forEach(this._attachController),
  135059. this._addNewAttachObserver(this._options.xrInput.onControllerAddedObservable, this._attachController),
  135060. this._addNewAttachObserver(this._options.xrInput.onControllerRemovedObservable, function(o) {
  135061. i._detachController(o.uniqueId)
  135062. }),
  135063. !0) : !1
  135064. }
  135065. ,
  135066. e.prototype.detach = function() {
  135067. var i = this;
  135068. return a.prototype.detach.call(this) ? (Object.keys(this._controllers).forEach(function(o) {
  135069. i._detachController(o)
  135070. }),
  135071. this._setTargetMeshVisibility(!1),
  135072. this._currentTeleportationControllerId = "",
  135073. this._controllers = {},
  135074. !0) : !1
  135075. }
  135076. ,
  135077. e.prototype.dispose = function() {
  135078. a.prototype.dispose.call(this),
  135079. this._options.teleportationTargetMesh && this._options.teleportationTargetMesh.dispose(!1, !0)
  135080. }
  135081. ,
  135082. e.prototype.removeFloorMesh = function(i) {
  135083. var o = this._floorMeshes.indexOf(i);
  135084. o !== -1 && this._floorMeshes.splice(o, 1)
  135085. }
  135086. ,
  135087. e.prototype.removeBlockerMesh = function(i) {
  135088. this._options.pickBlockerMeshes = this._options.pickBlockerMeshes || [];
  135089. var o = this._options.pickBlockerMeshes.indexOf(i);
  135090. o !== -1 && this._options.pickBlockerMeshes.splice(o, 1)
  135091. }
  135092. ,
  135093. e.prototype.removeFloorMeshByName = function(i) {
  135094. var o = this._xrSessionManager.scene.getMeshByName(i);
  135095. o && this.removeFloorMesh(o)
  135096. }
  135097. ,
  135098. e.prototype.removeSnapPoint = function(i) {
  135099. var o = this._snapToPositions.indexOf(i);
  135100. if (o === -1) {
  135101. for (var s = 0; s < this._snapToPositions.length; ++s)
  135102. if (this._snapToPositions[s].equals(i)) {
  135103. o = s;
  135104. break
  135105. }
  135106. }
  135107. return o !== -1 ? (this._snapToPositions.splice(o, 1),
  135108. !0) : !1
  135109. }
  135110. ,
  135111. e.prototype.setSelectionFeature = function(i) {
  135112. this._selectionFeature = i
  135113. }
  135114. ,
  135115. e.prototype._onXRFrame = function(i) {
  135116. var o = this
  135117. , s = this._xrSessionManager.currentFrame
  135118. , c = this._xrSessionManager.scene;
  135119. if (!(!this.attach || !s)) {
  135120. var d = this._options.teleportationTargetMesh;
  135121. if (this._currentTeleportationControllerId) {
  135122. if (!d)
  135123. return;
  135124. d.rotationQuaternion = d.rotationQuaternion || new Quaternion;
  135125. var _ = this._controllers[this._currentTeleportationControllerId];
  135126. if (_ && _.teleportationState.forward) {
  135127. Quaternion.RotationYawPitchRollToRef(_.teleportationState.currentRotation + _.teleportationState.baseRotation, 0, 0, d.rotationQuaternion);
  135128. var b = !1;
  135129. if (_.xrController.getWorldPointerRayToRef(this._tmpRay),
  135130. this.straightRayEnabled) {
  135131. var k = c.pickWithRay(this._tmpRay, function(et) {
  135132. if (o._options.pickBlockerMeshes && o._options.pickBlockerMeshes.indexOf(et) !== -1)
  135133. return !0;
  135134. var tt = o._floorMeshes.indexOf(et);
  135135. return tt === -1 ? !1 : o._floorMeshes[tt].absolutePosition.y < o._options.xrInput.xrCamera.globalPosition.y
  135136. });
  135137. if (k && k.pickedMesh && this._options.pickBlockerMeshes && this._options.pickBlockerMeshes.indexOf(k.pickedMesh) !== -1)
  135138. return;
  135139. k && k.pickedPoint && (b = !0,
  135140. this._setTargetMeshPosition(k),
  135141. this._setTargetMeshVisibility(!0),
  135142. this._showParabolicPath(k))
  135143. }
  135144. if (this.parabolicRayEnabled && !b) {
  135145. var j = _.xrController.pointer.rotationQuaternion.toEulerAngles().x
  135146. , $ = 1 + (Math.PI / 2 - Math.abs(j))
  135147. , _e = this.parabolicCheckRadius * $;
  135148. this._tmpRay.origin.addToRef(this._tmpRay.direction.scale(_e * 2), this._tmpVector),
  135149. this._tmpVector.y = this._tmpRay.origin.y,
  135150. this._tmpRay.origin.addInPlace(this._tmpRay.direction.scale(_e)),
  135151. this._tmpVector.subtractToRef(this._tmpRay.origin, this._tmpRay.direction),
  135152. this._tmpRay.direction.normalize();
  135153. var k = c.pickWithRay(this._tmpRay, function(tt) {
  135154. return o._options.pickBlockerMeshes && o._options.pickBlockerMeshes.indexOf(tt) !== -1 ? !0 : o._floorMeshes.indexOf(tt) !== -1
  135155. });
  135156. if (k && k.pickedMesh && this._options.pickBlockerMeshes && this._options.pickBlockerMeshes.indexOf(k.pickedMesh) !== -1)
  135157. return;
  135158. k && k.pickedPoint && (b = !0,
  135159. this._setTargetMeshPosition(k),
  135160. this._setTargetMeshVisibility(!0),
  135161. this._showParabolicPath(k))
  135162. }
  135163. this._setTargetMeshVisibility(b)
  135164. } else
  135165. this._setTargetMeshVisibility(!1)
  135166. } else
  135167. this._setTargetMeshVisibility(!1)
  135168. }
  135169. }
  135170. ,
  135171. e.prototype._createDefaultTargetMesh = function() {
  135172. this._options.defaultTargetMeshOptions = this._options.defaultTargetMeshOptions || {};
  135173. var i = this._options.useUtilityLayer ? this._options.customUtilityLayerScene || UtilityLayerRenderer.DefaultUtilityLayer.utilityLayerScene : this._xrSessionManager.scene
  135174. , o = CreateGround("teleportationTarget", {
  135175. width: 2,
  135176. height: 2,
  135177. subdivisions: 2
  135178. }, i);
  135179. o.isPickable = !1;
  135180. var s = 512
  135181. , c = new DynamicTexture("teleportationPlaneDynamicTexture",s,i,!0);
  135182. c.hasAlpha = !0;
  135183. var d = c.getContext()
  135184. , _ = s / 2
  135185. , b = s / 2
  135186. , k = 200;
  135187. d.beginPath(),
  135188. d.arc(_, b, k, 0, 2 * Math.PI, !1),
  135189. d.fillStyle = this._options.defaultTargetMeshOptions.teleportationFillColor || "#444444",
  135190. d.fill(),
  135191. d.lineWidth = 10,
  135192. d.strokeStyle = this._options.defaultTargetMeshOptions.teleportationBorderColor || "#FFFFFF",
  135193. d.stroke(),
  135194. d.closePath(),
  135195. c.update();
  135196. var j = new StandardMaterial("teleportationPlaneMaterial",i);
  135197. j.diffuseTexture = c,
  135198. o.material = j;
  135199. var $ = CreateTorus("torusTeleportation", {
  135200. diameter: .75,
  135201. thickness: .1,
  135202. tessellation: 20
  135203. }, i);
  135204. if ($.isPickable = !1,
  135205. $.parent = o,
  135206. !this._options.defaultTargetMeshOptions.disableAnimation) {
  135207. var _e = new Animation("animationInnerCircle","position.y",30,Animation.ANIMATIONTYPE_FLOAT,Animation.ANIMATIONLOOPMODE_CYCLE)
  135208. , et = [];
  135209. et.push({
  135210. frame: 0,
  135211. value: 0
  135212. }),
  135213. et.push({
  135214. frame: 30,
  135215. value: .4
  135216. }),
  135217. et.push({
  135218. frame: 60,
  135219. value: 0
  135220. }),
  135221. _e.setKeys(et);
  135222. var tt = new SineEase;
  135223. tt.setEasingMode(EasingFunction.EASINGMODE_EASEINOUT),
  135224. _e.setEasingFunction(tt),
  135225. $.animations = [],
  135226. $.animations.push(_e),
  135227. i.beginAnimation($, 0, 60, !0)
  135228. }
  135229. var rt = CreateCylinder("rotationCone", {
  135230. diameterTop: 0,
  135231. tessellation: 4
  135232. }, i);
  135233. if (rt.isPickable = !1,
  135234. rt.scaling.set(.5, .12, .2),
  135235. rt.rotate(Axis.X, Math.PI / 2),
  135236. rt.position.z = .6,
  135237. rt.parent = $,
  135238. this._options.defaultTargetMeshOptions.torusArrowMaterial)
  135239. $.material = this._options.defaultTargetMeshOptions.torusArrowMaterial,
  135240. rt.material = this._options.defaultTargetMeshOptions.torusArrowMaterial;
  135241. else {
  135242. var it = new StandardMaterial("torusConsMat",i);
  135243. it.disableLighting = !!this._options.defaultTargetMeshOptions.disableLighting,
  135244. it.disableLighting ? it.emissiveColor = new Color3(.3,.3,1) : it.diffuseColor = new Color3(.3,.3,1),
  135245. it.alpha = .9,
  135246. $.material = it,
  135247. rt.material = it,
  135248. this._teleportationRingMaterial = it
  135249. }
  135250. this._options.renderingGroupId !== void 0 && (o.renderingGroupId = this._options.renderingGroupId,
  135251. $.renderingGroupId = this._options.renderingGroupId,
  135252. rt.renderingGroupId = this._options.renderingGroupId),
  135253. this._options.teleportationTargetMesh = o
  135254. }
  135255. ,
  135256. e.prototype._detachController = function(i) {
  135257. var o = this._controllers[i];
  135258. !o || (o.teleportationComponent && (o.onAxisChangedObserver && o.teleportationComponent.onAxisValueChangedObservable.remove(o.onAxisChangedObserver),
  135259. o.onButtonChangedObserver && o.teleportationComponent.onButtonStateChangedObservable.remove(o.onButtonChangedObserver)),
  135260. delete this._controllers[i])
  135261. }
  135262. ,
  135263. e.prototype._findClosestSnapPointWithRadius = function(i, o) {
  135264. o === void 0 && (o = this._options.snapToPositionRadius || .8);
  135265. var s = null
  135266. , c = Number.MAX_VALUE;
  135267. if (this._snapToPositions.length) {
  135268. var d = o * o;
  135269. this._snapToPositions.forEach(function(_) {
  135270. var b = Vector3.DistanceSquared(_, i);
  135271. b <= d && b < c && (c = b,
  135272. s = _)
  135273. })
  135274. }
  135275. return s
  135276. }
  135277. ,
  135278. e.prototype._setTargetMeshPosition = function(i) {
  135279. var o = i.pickedPoint;
  135280. if (!(!this._options.teleportationTargetMesh || !o)) {
  135281. var s = this._findClosestSnapPointWithRadius(o);
  135282. this._snappedToPoint = !!s,
  135283. this.snapPointsOnly && !this._snappedToPoint && this._teleportationRingMaterial ? this._teleportationRingMaterial.diffuseColor.set(1, .3, .3) : this.snapPointsOnly && this._snappedToPoint && this._teleportationRingMaterial && this._teleportationRingMaterial.diffuseColor.set(.3, .3, 1),
  135284. this._options.teleportationTargetMesh.position.copyFrom(s || o),
  135285. this._options.teleportationTargetMesh.position.y += .01,
  135286. this.onTargetMeshPositionUpdatedObservable.notifyObservers(i)
  135287. }
  135288. }
  135289. ,
  135290. e.prototype._setTargetMeshVisibility = function(i) {
  135291. !this._options.teleportationTargetMesh || this._options.teleportationTargetMesh.isVisible !== i && (this._options.teleportationTargetMesh.isVisible = i,
  135292. this._options.teleportationTargetMesh.getChildren(void 0, !1).forEach(function(o) {
  135293. o.isVisible = i
  135294. }),
  135295. i ? this._selectionFeature && this._selectionFeature.detach() : (this._quadraticBezierCurve && (this._quadraticBezierCurve.dispose(),
  135296. this._quadraticBezierCurve = null),
  135297. this._selectionFeature && this._selectionFeature.attach()))
  135298. }
  135299. ,
  135300. e.prototype._showParabolicPath = function(i) {
  135301. if (!!i.pickedPoint) {
  135302. var o = this._options.useUtilityLayer ? this._options.customUtilityLayerScene || UtilityLayerRenderer.DefaultUtilityLayer.utilityLayerScene : this._xrSessionManager.scene
  135303. , s = this._controllers[this._currentTeleportationControllerId]
  135304. , c = Curve3.CreateQuadraticBezier(s.xrController.pointer.absolutePosition, i.ray.origin, i.pickedPoint, 25);
  135305. this._options.generateRayPathMesh ? this._quadraticBezierCurve = this._options.generateRayPathMesh(c.getPoints(), i) : this._quadraticBezierCurve = CreateLines("teleportation path line", {
  135306. points: c.getPoints(),
  135307. instance: this._quadraticBezierCurve,
  135308. updatable: !0
  135309. }, o),
  135310. this._quadraticBezierCurve.isPickable = !1,
  135311. this._options.renderingGroupId !== void 0 && (this._quadraticBezierCurve.renderingGroupId = this._options.renderingGroupId)
  135312. }
  135313. }
  135314. ,
  135315. e.prototype._teleportForward = function(i) {
  135316. var o = this._controllers[i];
  135317. if (!(!o || !o.teleportationState.forward || !this.teleportationEnabled) && (o.teleportationState.forward = !1,
  135318. this._currentTeleportationControllerId = "",
  135319. !(this.snapPointsOnly && !this._snappedToPoint))) {
  135320. if (this.skipNextTeleportation) {
  135321. this.skipNextTeleportation = !1;
  135322. return
  135323. }
  135324. if (this._options.teleportationTargetMesh && this._options.teleportationTargetMesh.isVisible) {
  135325. var s = this._options.xrInput.xrCamera.realWorldHeight;
  135326. this._options.xrInput.xrCamera.onBeforeCameraTeleport.notifyObservers(this._options.xrInput.xrCamera.position),
  135327. this._options.xrInput.xrCamera.position.copyFrom(this._options.teleportationTargetMesh.position),
  135328. this._options.xrInput.xrCamera.position.y += s,
  135329. Quaternion.FromEulerAngles(0, o.teleportationState.currentRotation - (this._xrSessionManager.scene.useRightHandedSystem ? Math.PI : 0), 0).multiplyToRef(this._options.xrInput.xrCamera.rotationQuaternion, this._options.xrInput.xrCamera.rotationQuaternion),
  135330. this._options.xrInput.xrCamera.onAfterCameraTeleport.notifyObservers(this._options.xrInput.xrCamera.position)
  135331. }
  135332. }
  135333. }
  135334. ,
  135335. e.Name = WebXRFeatureName.TELEPORTATION,
  135336. e.Version = 1,
  135337. e
  135338. }(WebXRAbstractFeature);
  135339. WebXRFeaturesManager.AddWebXRFeature(WebXRMotionControllerTeleportation.Name, function(a, e) {
  135340. return function() {
  135341. return new WebXRMotionControllerTeleportation(a,e)
  135342. }
  135343. }, WebXRMotionControllerTeleportation.Version, !0);
  135344. var WebXRDefaultExperience = function() {
  135345. function a() {}
  135346. return a.CreateAsync = function(e, i) {
  135347. i === void 0 && (i = {});
  135348. var o = new a;
  135349. if (!i.disableDefaultUI) {
  135350. var s = __assign({
  135351. renderTarget: o.renderTarget
  135352. }, i.uiOptions || {});
  135353. i.optionalFeatures && (typeof i.optionalFeatures == "boolean" ? s.optionalFeatures = ["hit-test", "anchors", "plane-detection", "hand-tracking"] : s.optionalFeatures = i.optionalFeatures),
  135354. o.enterExitUI = new WebXREnterExitUI(e,s)
  135355. }
  135356. return WebXRExperienceHelper.CreateAsync(e).then(function(c) {
  135357. if (o.baseExperience = c,
  135358. i.ignoreNativeCameraTransformation && (o.baseExperience.camera.compensateOnFirstFrame = !1),
  135359. o.input = new WebXRInput(c.sessionManager,c.camera,__assign({
  135360. controllerOptions: {
  135361. renderingGroupId: i.renderingGroupId
  135362. }
  135363. }, i.inputOptions || {})),
  135364. !i.disablePointerSelection) {
  135365. var d = __assign(__assign({}, i.pointerSelectionOptions), {
  135366. xrInput: o.input,
  135367. renderingGroupId: i.renderingGroupId
  135368. });
  135369. o.pointerSelection = o.baseExperience.featuresManager.enableFeature(WebXRControllerPointerSelection.Name, i.useStablePlugins ? "stable" : "latest", d),
  135370. i.disableTeleportation || (o.teleportation = o.baseExperience.featuresManager.enableFeature(WebXRMotionControllerTeleportation.Name, i.useStablePlugins ? "stable" : "latest", {
  135371. floorMeshes: i.floorMeshes,
  135372. xrInput: o.input,
  135373. renderingGroupId: i.renderingGroupId
  135374. }),
  135375. o.teleportation.setSelectionFeature(o.pointerSelection))
  135376. }
  135377. if (i.disableNearInteraction || (o.nearInteraction = o.baseExperience.featuresManager.enableFeature(WebXRNearInteraction.Name, i.useStablePlugins ? "stable" : "latest", {
  135378. xrInput: o.input,
  135379. farInteractionFeature: o.pointerSelection,
  135380. renderingGroupId: i.renderingGroupId,
  135381. useUtilityLayer: !0,
  135382. enableNearInteractionOnAllControllers: !0
  135383. })),
  135384. o.renderTarget = o.baseExperience.sessionManager.getWebXRRenderTarget(i.outputCanvasOptions),
  135385. !i.disableDefaultUI)
  135386. return o.enterExitUI.setHelperAsync(o.baseExperience, o.renderTarget)
  135387. }).then(function() {
  135388. return o
  135389. }).catch(function(c) {
  135390. return Logger$2.Error("Error initializing XR"),
  135391. Logger$2.Error(c),
  135392. o
  135393. })
  135394. }
  135395. ,
  135396. a.prototype.dispose = function() {
  135397. this.baseExperience && this.baseExperience.dispose(),
  135398. this.input && this.input.dispose(),
  135399. this.enterExitUI && this.enterExitUI.dispose(),
  135400. this.renderTarget && this.renderTarget.dispose()
  135401. }
  135402. ,
  135403. a
  135404. }();
  135405. Scene.prototype.createDefaultLight = function(a) {
  135406. if (a === void 0 && (a = !1),
  135407. a && this.lights)
  135408. for (var e = 0; e < this.lights.length; e++)
  135409. this.lights[e].dispose();
  135410. this.lights.length === 0 && new HemisphericLight("default light",Vector3.Up(),this)
  135411. }
  135412. ;
  135413. Scene.prototype.createDefaultCamera = function(a, e, i) {
  135414. if (a === void 0 && (a = !1),
  135415. e === void 0 && (e = !1),
  135416. i === void 0 && (i = !1),
  135417. e && this.activeCamera && (this.activeCamera.dispose(),
  135418. this.activeCamera = null),
  135419. !this.activeCamera) {
  135420. var o = this.getWorldExtends(function(j) {
  135421. return j.isVisible && j.isEnabled()
  135422. }), s = o.max.subtract(o.min), c = o.min.add(s.scale(.5)), d, _ = s.length() * 1.5;
  135423. if (isFinite(_) || (_ = 1,
  135424. c.copyFromFloats(0, 0, 0)),
  135425. a) {
  135426. var b = new ArcRotateCamera("default camera",-(Math.PI / 2),Math.PI / 2,_,c,this);
  135427. b.lowerRadiusLimit = _ * .01,
  135428. b.wheelPrecision = 100 / _,
  135429. d = b
  135430. } else {
  135431. var k = new FreeCamera("default camera",new Vector3(c.x,c.y,-_),this);
  135432. k.setTarget(c),
  135433. d = k
  135434. }
  135435. d.minZ = _ * .01,
  135436. d.maxZ = _ * 1e3,
  135437. d.speed = _ * .2,
  135438. this.activeCamera = d,
  135439. i && d.attachControl()
  135440. }
  135441. }
  135442. ;
  135443. Scene.prototype.createDefaultCameraOrLight = function(a, e, i) {
  135444. a === void 0 && (a = !1),
  135445. e === void 0 && (e = !1),
  135446. i === void 0 && (i = !1),
  135447. this.createDefaultLight(e),
  135448. this.createDefaultCamera(a, e, i)
  135449. }
  135450. ;
  135451. Scene.prototype.createDefaultSkybox = function(a, e, i, o, s) {
  135452. if (e === void 0 && (e = !1),
  135453. i === void 0 && (i = 1e3),
  135454. o === void 0 && (o = 0),
  135455. s === void 0 && (s = !0),
  135456. !a)
  135457. return Logger$2.Warn("Can not create default skybox without environment texture."),
  135458. null;
  135459. s && a && (this.environmentTexture = a);
  135460. var c = CreateBox("hdrSkyBox", {
  135461. size: i
  135462. }, this);
  135463. if (e) {
  135464. var d = new PBRMaterial("skyBox",this);
  135465. d.backFaceCulling = !1,
  135466. d.reflectionTexture = a.clone(),
  135467. d.reflectionTexture && (d.reflectionTexture.coordinatesMode = Texture.SKYBOX_MODE),
  135468. d.microSurface = 1 - o,
  135469. d.disableLighting = !0,
  135470. d.twoSidedLighting = !0,
  135471. c.material = d
  135472. } else {
  135473. var _ = new StandardMaterial("skyBox",this);
  135474. _.backFaceCulling = !1,
  135475. _.reflectionTexture = a.clone(),
  135476. _.reflectionTexture && (_.reflectionTexture.coordinatesMode = Texture.SKYBOX_MODE),
  135477. _.disableLighting = !0,
  135478. c.material = _
  135479. }
  135480. return c.isPickable = !1,
  135481. c.infiniteDistance = !0,
  135482. c.ignoreCameraMaxZ = !0,
  135483. c
  135484. }
  135485. ;
  135486. Scene.prototype.createDefaultEnvironment = function(a) {
  135487. return EnvironmentHelper ? new EnvironmentHelper(a,this) : null
  135488. }
  135489. ;
  135490. Scene.prototype.createDefaultVRExperience = function(a) {
  135491. return a === void 0 && (a = {}),
  135492. new VRExperienceHelper(this,a)
  135493. }
  135494. ;
  135495. Scene.prototype.createDefaultXRExperienceAsync = function(a) {
  135496. return a === void 0 && (a = {}),
  135497. WebXRDefaultExperience.CreateAsync(this, a).then(function(e) {
  135498. return e
  135499. })
  135500. }
  135501. ;
  135502. var EMeshType = (a=>(a.XAvatar = "XAvatar",
  135503. a.XStaticMesh = "XStaticMesh",
  135504. a.XBreathPoint = "breathpoint",
  135505. a.Decal = "decal",
  135506. a.Cgplane = "cgplane",
  135507. a.Tv = "tv",
  135508. a.XSubSequence = "XSubSequence",
  135509. a.XBillboard = "XBillboard",
  135510. a))(EMeshType || {});
  135511. const checkOS = ()=>{
  135512. const a = navigator.userAgent
  135513. , e = /(?:Windows Phone)/.test(a)
  135514. , i = /(?:SymbianOS)/.test(a) || e
  135515. , o = /(?:Android)/.test(a)
  135516. , s = /(?:Firefox)/.test(a);
  135517. /(?:Chrome|CriOS)/.test(a);
  135518. const c = /(?:iPad|PlayBook)/.test(a) || o && !/(?:Mobile)/.test(a) || s && /(?:Tablet)/.test(a)
  135519. , d = /(?:iPhone|ipad|ipod)/.test(a) && !c
  135520. , _ = !d && !o && !i;
  135521. return {
  135522. isTablet: c,
  135523. isPhone: d,
  135524. isIOS: /iPhone|iPod|iPad/.test(navigator.userAgent),
  135525. isAndroid: o,
  135526. isPc: _
  135527. }
  135528. }
  135529. , ue4Rotation2Xverse = a=>isRotationCorrect() ? (a.pitch >= 89.5 ? a.pitch = 89.5 : a.pitch <= -89.5 && (a.pitch = -89.5),
  135530. new Vector3(-1 * Math.PI * a.pitch / 180,Math.PI * a.yaw / 180 - Math.PI * 27 / 18,Math.PI * a.roll / 180 < .001 ? 0 : Math.PI * a.roll / 180)) : null
  135531. , ue4Rotation2Xverse_mesh = a=>isRotationCorrect() ? new Vector3(Math.PI * a.pitch / 180,Math.PI * a.yaw / 180,Math.abs(Math.PI * a.roll) / 180 < .001 ? 0 : -1 * (Math.PI * a.roll) / 180) : null
  135532. , scaleFromUE4toXverse = 100
  135533. , ue4Scaling2Xverse = a=>isScalingCorrect() ? new Vector3(a.x,a.z,-1 * a.y) : null
  135534. , ue4Position2Xverse = a=>isPositionCorrect() ? new Vector3(a.x * .01,a.z * .01,-1 * a.y * .01) : null
  135535. , xversePosition2Ue4 = a=>isPositionCorrect() ? {
  135536. x: a.x * 100,
  135537. y: -1 * a.z * 100,
  135538. z: a.y * 100
  135539. } : null
  135540. , xverseRotation2Ue4 = a=>{
  135541. if (isPositionCorrect()) {
  135542. let e = 0;
  135543. return a.z == 0 ? e = 0 : e = 180 * a.z / Math.PI,
  135544. {
  135545. pitch: 180 * a.x * -1 / Math.PI,
  135546. yaw: (a.y + Math.PI * 27 / 18) * 180 / Math.PI,
  135547. roll: e
  135548. }
  135549. } else
  135550. return null
  135551. }
  135552. , xverseRotation2Ue4_mesh = a=>{
  135553. if (isPositionCorrect()) {
  135554. let e = 0;
  135555. return a.z == 0 ? e = 0 : e = -1 * (180 * a.z) / Math.PI,
  135556. {
  135557. pitch: 180 * a.x / Math.PI,
  135558. yaw: a.y * 180 / Math.PI,
  135559. roll: e
  135560. }
  135561. } else
  135562. return null
  135563. }
  135564. , calcDistance3D = (a,e)=>Math.sqrt((a.x - e.x) * (a.x - e.x) + (a.y - e.y) * (a.y - e.y) + (a.z - e.z) * (a.z - e.z))
  135565. , calcDistance3DVector = (a,e)=>Math.sqrt((a.x - e.x) * (a.x - e.x) + (a.y - e.y) * (a.y - e.y) + (a.z - e.z) * (a.z - e.z))
  135566. , isPositionCorrect = a=>!0
  135567. , isScalingCorrect = a=>!0
  135568. , calcDistance3DAngle = (a,e)=>Math.sqrt((a.roll - e.roll) * (a.roll - e.roll) + (a.pitch - e.pitch) * (a.pitch - e.pitch) + (a.yaw - e.yaw) * (a.yaw - e.yaw))
  135569. , isRotationCorrect = a=>!0
  135570. , getStringBoundaries = (a,e,i=new Map)=>{
  135571. let o = 0
  135572. , s = ""
  135573. , c = -1
  135574. , d = 0;
  135575. const _ = [0];
  135576. for (let b = 0; b < a.length; b++) {
  135577. const k = a.codePointAt(b);
  135578. let j = i.get(k);
  135579. if (j)
  135580. o += j,
  135581. s += a[b],
  135582. k > 64 && k < 91 || k > 96 && k < 123 ? (c == -1 && (c = b),
  135583. d += j) : (c = -1,
  135584. d = 0);
  135585. else if (k < 975 || k > 1024 && k < 1920)
  135586. j = 1,
  135587. o++,
  135588. s += a[b],
  135589. k > 64 && k < 91 || k > 96 && k < 123 ? (c == -1 && (c = b),
  135590. d += j) : (c = -1,
  135591. d = 0);
  135592. else if (k > 4499 && k < 4600 || k > 8207 && k < 8232 || k > 8238 && k < 8287 || k > 8238 && k < 8287 || k > 8304 && k < 8384 || k > 8447 && k < 9211 || k > 11263 && k < 11624 || k > 11646 && k < 11671 || k > 11679 && k < 11845 || k > 11903 && k < 12020 || k > 12031 && k < 12246 || k > 12287 && k < 12544 || k > 12548 && k < 12728 || k > 12735 && k < 12772 || k > 12783 && k < 19894 || k > 19967 && k < 40918 || k > 42191 && k < 42240 || k > 44031 && k < 55204 || k > 59276 && k < 59287 || k > 59412 && k < 59493 || k > 63743 && k < 64207 || k > 65039 && k < 65050 || k > 65071 && k < 65510)
  135593. j = 2,
  135594. o += 2,
  135595. c = -1,
  135596. d = 0,
  135597. s += a[b];
  135598. else if (k > 9311 && k < 11158) {
  135599. j = 2,
  135600. o += 2,
  135601. c = -1,
  135602. d = 0,
  135603. s += a[b];
  135604. const $ = a.codePointAt(b + 1);
  135605. $ > 65023 && $ < 65040 && (s += a[b + 1],
  135606. b++)
  135607. } else
  135608. k > 126979 && k < 129783 && (j = 2,
  135609. o += 2,
  135610. c = -1,
  135611. d = 0,
  135612. b++,
  135613. s += String.fromCodePoint(k));
  135614. if (b == _[_.length - 1] + 1 && c > 0 ? (_[_.length - 1] = c,
  135615. o = 0 + d) : o > e && (_.push(b),
  135616. d >= o && (d = 0 + j,
  135617. c = 0),
  135618. o = 0 + j),
  135619. b >= a.length - 1)
  135620. break
  135621. }
  135622. return _[_.length - 1] != a.length && _.push(a.length),
  135623. [s, _]
  135624. }
  135625. , getAlphaWidthMap = (a,e)=>{
  135626. const i = new DynamicTexture("test",3,e)
  135627. , o = new Map;
  135628. for (let s = 32; s < 127; s++) {
  135629. const c = String.fromCodePoint(s)
  135630. , d = 2 + "px " + a;
  135631. i.drawText(c, null, null, d, "#000000", "#ffffff", !0);
  135632. const _ = i.getContext();
  135633. _.font = d;
  135634. const b = _.measureText(c).width;
  135635. o.set(s, b)
  135636. }
  135637. return i.dispose(),
  135638. o
  135639. }
  135640. , _RegisteredClass = {};
  135641. function RegisterXObjectClass(a, e) {
  135642. _RegisteredClass[a] = e
  135643. }
  135644. function GetXObjectClass(a) {
  135645. return _RegisteredClass[a]
  135646. }
  135647. const DEFAULT_LOGGER = {
  135648. debug: console.log,
  135649. info: console.log,
  135650. warn: console.warn,
  135651. error: console.error
  135652. }
  135653. , _Logger = class {
  135654. static setLogger(a) {
  135655. _Logger.instance = a
  135656. }
  135657. constructor(a) {
  135658. this.module = a
  135659. }
  135660. debug(...a) {
  135661. return _Logger.instance.debug(...a)
  135662. }
  135663. info(...a) {
  135664. return _Logger.instance.info(...a)
  135665. }
  135666. warn(...a) {
  135667. return _Logger.instance.warn(...a)
  135668. }
  135669. error(...a) {
  135670. return _Logger.instance.error(...a)
  135671. }
  135672. }
  135673. ;
  135674. let Logger$1 = _Logger;
  135675. Logger$1.instance = DEFAULT_LOGGER;
  135676. new Logger$1("Serialization");
  135677. const __decoratorInitialStore = {}
  135678. , __mergedStore = {}
  135679. , deepCopy = function(a, e, i) {
  135680. let o;
  135681. if (e || (e = ""),
  135682. i || (i = !1),
  135683. a == null || typeof a != "object")
  135684. return a;
  135685. if (a instanceof Date)
  135686. return o = new Date,
  135687. o.setTime(a.getTime()),
  135688. o;
  135689. if (a instanceof Array) {
  135690. o = [];
  135691. for (let s = 0, c = a.length; s < c; s++)
  135692. o[s] = deepCopy(a[s], e, i);
  135693. return o
  135694. }
  135695. if (a instanceof Object) {
  135696. if (a instanceof XObject)
  135697. return o = _copySource(a, e, i),
  135698. o;
  135699. if (a instanceof AssetContainer)
  135700. return i ? o = a.clone(e, !1, {
  135701. doNotInstantiate: !0
  135702. }, !1) : o = a.clone(e),
  135703. o;
  135704. for (const s in a)
  135705. Object.prototype.hasOwnProperty.call(a, s) && (o[s] = deepCopy(a[s]));
  135706. return o
  135707. }
  135708. throw new Error("Unable to copy obj! Its type isn't supported.")
  135709. }
  135710. , _copySource = function(a, e, i) {
  135711. const o = GetXObjectClass(a.getClassName())
  135712. , s = new o
  135713. , c = getPropertiesMarkAsSerializable(s);
  135714. e || (e = ""),
  135715. i || (i = !1);
  135716. for (const d in c) {
  135717. const _ = a[d];
  135718. if (_ != null) {
  135719. const b = s;
  135720. _ instanceof XObject ? b[d] = _copySource(_, e, i) : b[d] = deepCopy(_, e, i)
  135721. }
  135722. }
  135723. return s.name = e,
  135724. s
  135725. };
  135726. function getDirectStore(a) {
  135727. const e = a.getClassName();
  135728. return __decoratorInitialStore[e] || (__decoratorInitialStore[e] = {}),
  135729. __decoratorInitialStore[e]
  135730. }
  135731. function generateSerializableMember(a, e) {
  135732. return (i,o)=>{
  135733. const s = getDirectStore(i);
  135734. s[o] || (s[o] = {
  135735. type: a,
  135736. sourceName: e
  135737. })
  135738. }
  135739. }
  135740. function xProperty(a) {
  135741. return generateSerializableMember(0, a)
  135742. }
  135743. function getPropertiesMarkAsSerializable(a) {
  135744. const e = a.getClassName();
  135745. if (__mergedStore[e])
  135746. return __mergedStore[e];
  135747. __mergedStore[e] = {};
  135748. const i = __mergedStore[e];
  135749. let o = a
  135750. , s = e;
  135751. for (; s; ) {
  135752. const c = __decoratorInitialStore[s];
  135753. for (const b in c)
  135754. i[b] = c[b];
  135755. let d, _ = !1;
  135756. do {
  135757. if (d = Object.getPrototypeOf(o),
  135758. !d.getClassName) {
  135759. _ = !0;
  135760. break
  135761. }
  135762. if (d.getClassName() !== s)
  135763. break;
  135764. o = d
  135765. } while (d);
  135766. if (_)
  135767. break;
  135768. s = d.getClassName(),
  135769. o = d
  135770. }
  135771. return i
  135772. }
  135773. class XArchive {
  135774. constructor() {
  135775. this.loadingPromises = new Array
  135776. }
  135777. static serialize(e) {
  135778. if (!e.outer)
  135779. return {
  135780. className: "",
  135781. uuid: 0,
  135782. xobjectInfo: {},
  135783. sceneInfo: ""
  135784. };
  135785. const o = e.outer.uuid
  135786. , s = {
  135787. className: "",
  135788. uuid: 0,
  135789. xobjectInfo: {},
  135790. sceneInfo: ""
  135791. };
  135792. s.className = e.getClassName(),
  135793. s.uuid = o;
  135794. const c = getPropertiesMarkAsSerializable(e);
  135795. for (const d in c) {
  135796. const b = c[d].sourceName || d
  135797. , k = e[d];
  135798. s.xobjectInfo[b] = k
  135799. }
  135800. return s
  135801. }
  135802. async deserializeObject(e, i="") {
  135803. if (e == null || typeof e != "object" || e instanceof Date)
  135804. return e;
  135805. if (e instanceof Array) {
  135806. for (let o = 0, s = e.length; o < s; o++)
  135807. e[o] = this.deserializeObject(e[o], i);
  135808. return e
  135809. }
  135810. if (e instanceof Object) {
  135811. if (e.className)
  135812. GetXObjectClass(e.className) && this.deserialize(e, i);
  135813. else
  135814. return e;
  135815. return e
  135816. }
  135817. throw new Error("Unable to copy obj! Its type isn't supported.")
  135818. }
  135819. async deserialize(e, i="") {
  135820. const o = GetXObjectClass(e.className);
  135821. if (!o)
  135822. throw new Error("Unable to deserialize obj! Its type isn't XObject.");
  135823. const s = new o
  135824. , c = getPropertiesMarkAsSerializable(s);
  135825. for (const d in c) {
  135826. const _ = c[d]
  135827. , b = e.xobjectInfo[_.sourceName || d];
  135828. if (b != null)
  135829. if (s[d]instanceof AssetContainer) {
  135830. const k = await SceneLoader.LoadAssetContainerAsync(i, b.sceneInfo, EngineStore.LastCreatedScene);
  135831. s[d] = k,
  135832. k.addAllToScene()
  135833. } else
  135834. s[d]instanceof XObject ? s[d] = await this.deserialize(b, i) : s[d] = await this.deserializeObject(b, i)
  135835. }
  135836. return s.postLoad(),
  135837. s
  135838. }
  135839. static clone(e, i, o) {
  135840. return deepCopy(e, i, o)
  135841. }
  135842. }
  135843. var __defProp$3 = Object.defineProperty
  135844. , __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor
  135845. , __decorateClass$3 = (a,e,i,o)=>{
  135846. for (var s = o > 1 ? void 0 : o ? __getOwnPropDesc$3(e, i) : e, c = a.length - 1, d; c >= 0; c--)
  135847. (d = a[c]) && (s = (o ? d(e, i, s) : d(s)) || s);
  135848. return o && s && __defProp$3(e, i, s),
  135849. s
  135850. }
  135851. ;
  135852. class XObject {
  135853. constructor() {
  135854. this._name = "",
  135855. this._outer = null
  135856. }
  135857. set outer(e) {
  135858. this._outer = e
  135859. }
  135860. get outer() {
  135861. return this._outer
  135862. }
  135863. get name() {
  135864. return this._name
  135865. }
  135866. set name(e) {
  135867. this._name = e
  135868. }
  135869. getClassName() {
  135870. return "XObject"
  135871. }
  135872. toJSON() {
  135873. return XArchive.serialize(this)
  135874. }
  135875. dispose() {}
  135876. postLoad() {}
  135877. clone(e) {
  135878. return XArchive.clone(this, e)
  135879. }
  135880. }
  135881. __decorateClass$3([xProperty("name")], XObject.prototype, "_name", 2);
  135882. RegisterXObjectClass("XObject", XObject);
  135883. var Codes$2 = (a=>(a[a.Success = 0] = "Success",
  135884. a[a.Timeout = 1003] = "Timeout",
  135885. a))(Codes$2 || {});
  135886. const COMPONENT_LIST_PREFIX = "/component_list.json";
  135887. class XverseError$1 extends Error {
  135888. constructor(e, i) {
  135889. super(i),
  135890. this.code = e
  135891. }
  135892. toJSON() {
  135893. return {
  135894. code: this.code,
  135895. message: this.message
  135896. }
  135897. }
  135898. toString() {
  135899. if (Object(this) !== this)
  135900. throw new TypeError;
  135901. let i = this.name;
  135902. i = i === void 0 ? "Error" : String(i);
  135903. let o = this.message;
  135904. o = o === void 0 ? "" : String(o);
  135905. const s = this.code;
  135906. return o = s === void 0 ? o : s + "," + o,
  135907. i === "" ? o : o === "" ? i : i + ": " + o
  135908. }
  135909. }
  135910. class AvatarAssetLoadingError extends XverseError$1 {
  135911. constructor(e) {
  135912. super(5100, e || "[Engine] \u89D2\u8272\u8D44\u4EA7\u52A0\u8F7D\u5931\u8D25")
  135913. }
  135914. }
  135915. class AvatarAnimationError extends XverseError$1 {
  135916. constructor(e) {
  135917. super(5101, e || "[Engine] \u89D2\u8272\u52A8\u753B\u64AD\u653E\u5931\u8D25")
  135918. }
  135919. }
  135920. class TimeoutError$1 extends XverseError$1 {
  135921. constructor(e) {
  135922. super(Codes$2.Timeout, e || "[Engine] \u8D85\u65F6\u9519\u8BEF")
  135923. }
  135924. }
  135925. class DuplicateAvatarIDError extends XverseError$1 {
  135926. constructor(e) {
  135927. super(5103, e || "[Engine] \u89D2\u8272id\u91CD\u590D")
  135928. }
  135929. }
  135930. class ContainerLoadingFailedError extends XverseError$1 {
  135931. constructor(e) {
  135932. super(5104, e || "[Engine] \u89D2\u8272\u8D44\u4EA7\u62C9\u53D6\u9519\u8BEF")
  135933. }
  135934. }
  135935. class XTvMediaUrlError extends XverseError$1 {
  135936. constructor(e) {
  135937. super(5201, e || "[Engine] \u4F20\u5165Url\u9519\u8BEF")
  135938. }
  135939. }
  135940. class XTvVideoElementError extends XverseError$1 {
  135941. constructor(e) {
  135942. super(5202, e || "[Engine] \u4F20\u5165video DOM\u9519\u8BEF")
  135943. }
  135944. }
  135945. class XTvModelError extends XverseError$1 {
  135946. constructor(e) {
  135947. super(5203, e || "[Engine] \u4F20\u5165TV\u6A21\u578Burl\u9519\u8BEF")
  135948. }
  135949. }
  135950. class XLowpolyModelError extends XverseError$1 {
  135951. constructor(e) {
  135952. super(5204, e || "[Engine] \u4F20\u5165\u6A21\u578Burl\u9519\u8BEF")
  135953. }
  135954. }
  135955. class XLowpolyJsonError extends XverseError$1 {
  135956. constructor(e) {
  135957. super(5205, e || "[Engine] \u4F20\u5165\u6A21\u578Bjson\u9519\u8BEF")
  135958. }
  135959. }
  135960. class XDecalError extends XverseError$1 {
  135961. constructor(e) {
  135962. super(5206, e || "[Engine] Decal\u6A21\u578B\u9519\u8BEF")
  135963. }
  135964. }
  135965. class XDecalTextureError extends XverseError$1 {
  135966. constructor(e) {
  135967. super(5207, e || "[Engine] decal\u7EB9\u7406\u9519\u8BEF")
  135968. }
  135969. }
  135970. class XBreathPointError extends XverseError$1 {
  135971. constructor(e) {
  135972. super(5208, e || "[Engine] \u547C\u5438\u70B9\u9519\u8BEF")
  135973. }
  135974. }
  135975. class XMaterialError extends XverseError$1 {
  135976. constructor(e) {
  135977. super(5210, e || "[Engine] Material\u9519\u8BEF")
  135978. }
  135979. }
  135980. class ExceedMaxAvatarNumError extends XverseError$1 {
  135981. constructor(e) {
  135982. super(5211, e || "[Engine] \u89D2\u8272\u4E2A\u6570\u8D85\u51FA\u4E0A\u9650")
  135983. }
  135984. }
  135985. const avatarSetting = {
  135986. fileType: ".glb",
  135987. lodType: "_lod",
  135988. lod: [{
  135989. level: "lod0",
  135990. fileName: ".glb",
  135991. quota: 5,
  135992. dist: 1e3
  135993. }, {
  135994. level: "lod1",
  135995. fileName: "_lod2.glb",
  135996. quota: 5,
  135997. dist: 2e3
  135998. }, {
  135999. level: "lod2",
  136000. fileName: "_lod4.glb",
  136001. quota: 0,
  136002. dist: 7500
  136003. }],
  136004. isRayCastEnable: !0,
  136005. maxAvatarNum: 40,
  136006. maxBillBoardDist: 7500,
  136007. body: "body",
  136008. head: "head",
  136009. hair: "hair",
  136010. suit: "suit",
  136011. pants: "pants",
  136012. shoes: "shoes",
  136013. clothes: "clothes",
  136014. animations: "animations",
  136015. defaultIdle: "Idle",
  136016. cullingDistance: 200,
  136017. defaultMove: "Walking"
  136018. }
  136019. , avatarResources = {
  136020. ygb: {
  136021. name: "ygb",
  136022. mat: "NM_ygb",
  136023. mesh: "ygb"
  136024. }
  136025. }
  136026. , action = {
  136027. GiftClap: {
  136028. animName: "GiftClap",
  136029. keyTime: 1760
  136030. },
  136031. Cheering: {
  136032. animName: "Cheering",
  136033. attachPair: [{
  136034. bone: "mixamorig_MiddleFinger2_R",
  136035. obj: "ygb",
  136036. offset: {
  136037. x: 0,
  136038. y: 0,
  136039. z: 0
  136040. },
  136041. rotate: {
  136042. x: 0,
  136043. y: 3.84,
  136044. z: 0
  136045. },
  136046. scale: {
  136047. x: 1,
  136048. y: 1,
  136049. z: 1
  136050. }
  136051. }, {
  136052. bone: "mixamorig_MiddleFinger2_L",
  136053. obj: "ygb",
  136054. offset: {
  136055. x: 0,
  136056. y: 0,
  136057. z: 0
  136058. },
  136059. rotate: {
  136060. x: 0,
  136061. y: 3.49,
  136062. z: 0
  136063. },
  136064. scale: {
  136065. x: 1,
  136066. y: 1,
  136067. z: 1
  136068. }
  136069. }]
  136070. }
  136071. }
  136072. , getAnimationKey = (a,e)=>e + "_" + a;
  136073. var _GLTFUtilities = function() {
  136074. function a() {}
  136075. return a._CreateBufferView = function(e, i, o, s, c) {
  136076. var d = {
  136077. buffer: e,
  136078. byteLength: o
  136079. };
  136080. return i && (d.byteOffset = i),
  136081. c && (d.name = c),
  136082. s && (d.byteStride = s),
  136083. d
  136084. }
  136085. ,
  136086. a._CreateAccessor = function(e, i, o, s, c, d, _, b) {
  136087. var k = {
  136088. name: i,
  136089. bufferView: e,
  136090. componentType: s,
  136091. count: c,
  136092. type: o
  136093. };
  136094. return _ != null && (k.min = _),
  136095. b != null && (k.max = b),
  136096. d != null && (k.byteOffset = d),
  136097. k
  136098. }
  136099. ,
  136100. a._CalculateMinMaxPositions = function(e, i, o, s) {
  136101. var c = [1 / 0, 1 / 0, 1 / 0], d = [-1 / 0, -1 / 0, -1 / 0], _ = 3, b, k, j;
  136102. if (o)
  136103. for (var $ = i, _e = i + o; $ < _e; ++$) {
  136104. b = _ * $,
  136105. k = Vector3.FromArray(e, b),
  136106. s && a._GetRightHandedPositionVector3FromRef(k),
  136107. j = k.asArray();
  136108. for (var et = 0; et < _; ++et) {
  136109. var tt = j[et];
  136110. tt < c[et] && (c[et] = tt),
  136111. tt > d[et] && (d[et] = tt),
  136112. ++b
  136113. }
  136114. }
  136115. return {
  136116. min: c,
  136117. max: d
  136118. }
  136119. }
  136120. ,
  136121. a._GetRightHandedPositionVector3 = function(e) {
  136122. return new Vector3(e.x,e.y,-e.z)
  136123. }
  136124. ,
  136125. a._GetRightHandedPositionVector3FromRef = function(e) {
  136126. e.z *= -1
  136127. }
  136128. ,
  136129. a._GetRightHandedPositionArray3FromRef = function(e) {
  136130. e[2] *= -1
  136131. }
  136132. ,
  136133. a._GetRightHandedNormalVector3 = function(e) {
  136134. return new Vector3(e.x,e.y,-e.z)
  136135. }
  136136. ,
  136137. a._GetRightHandedNormalVector3FromRef = function(e) {
  136138. e.z *= -1
  136139. }
  136140. ,
  136141. a._GetRightHandedNormalArray3FromRef = function(e) {
  136142. e[2] *= -1
  136143. }
  136144. ,
  136145. a._GetRightHandedVector4FromRef = function(e) {
  136146. e.z *= -1,
  136147. e.w *= -1
  136148. }
  136149. ,
  136150. a._GetRightHandedArray4FromRef = function(e) {
  136151. e[2] *= -1,
  136152. e[3] *= -1
  136153. }
  136154. ,
  136155. a._GetRightHandedQuaternionFromRef = function(e) {
  136156. e.x *= -1,
  136157. e.y *= -1
  136158. }
  136159. ,
  136160. a._GetRightHandedQuaternionArrayFromRef = function(e) {
  136161. e[0] *= -1,
  136162. e[1] *= -1
  136163. }
  136164. ,
  136165. a._NormalizeTangentFromRef = function(e) {
  136166. var i = Math.sqrt(e.x * e.x + e.y * e.y + e.z * e.z);
  136167. i > 0 && (e.x /= i,
  136168. e.y /= i,
  136169. e.z /= i)
  136170. }
  136171. ,
  136172. a._GetDataAccessorElementCount = function(e) {
  136173. switch (e) {
  136174. case "MAT2":
  136175. return 4;
  136176. case "MAT3":
  136177. return 9;
  136178. case "MAT4":
  136179. return 16;
  136180. case "SCALAR":
  136181. return 1;
  136182. case "VEC2":
  136183. return 2;
  136184. case "VEC3":
  136185. return 3;
  136186. case "VEC4":
  136187. return 4
  136188. }
  136189. }
  136190. ,
  136191. a
  136192. }(), _TangentType;
  136193. (function(a) {
  136194. a[a.INTANGENT = 0] = "INTANGENT",
  136195. a[a.OUTTANGENT = 1] = "OUTTANGENT"
  136196. }
  136197. )(_TangentType || (_TangentType = {}));
  136198. var _GLTFAnimation = function() {
  136199. function a() {}
  136200. return a._CreateNodeAnimation = function(e, i, o, s, c, d) {
  136201. var _ = []
  136202. , b = []
  136203. , k = i.getKeys()
  136204. , j = a.calculateMinMaxKeyFrames(k)
  136205. , $ = a._DeduceInterpolation(k, o, c)
  136206. , _e = j.max - j.min
  136207. , et = $.interpolationType
  136208. , tt = $.shouldBakeAnimation;
  136209. if (tt ? a._CreateBakedAnimation(e, i, o, j.min, j.max, i.framePerSecond, d, _, b, j, s, c) : et === "LINEAR" || et === "STEP" ? a._CreateLinearOrStepAnimation(e, i, o, _e, _, b, s, c) : et === "CUBICSPLINE" ? a._CreateCubicSplineAnimation(e, i, o, _e, _, b, s, c) : a._CreateBakedAnimation(e, i, o, j.min, j.max, i.framePerSecond, d, _, b, j, s, c),
  136210. _.length && b.length) {
  136211. var rt = {
  136212. inputs: _,
  136213. outputs: b,
  136214. samplerInterpolation: et,
  136215. inputsMin: tt ? j.min : Tools.FloatRound(j.min / i.framePerSecond),
  136216. inputsMax: tt ? j.max : Tools.FloatRound(j.max / i.framePerSecond)
  136217. };
  136218. return rt
  136219. }
  136220. return null
  136221. }
  136222. ,
  136223. a._DeduceAnimationInfo = function(e) {
  136224. var i = null
  136225. , o = "VEC3"
  136226. , s = !1
  136227. , c = e.targetProperty.split(".");
  136228. switch (c[0]) {
  136229. case "scaling":
  136230. {
  136231. i = "scale";
  136232. break
  136233. }
  136234. case "position":
  136235. {
  136236. i = "translation";
  136237. break
  136238. }
  136239. case "rotation":
  136240. {
  136241. o = "VEC4",
  136242. i = "rotation";
  136243. break
  136244. }
  136245. case "rotationQuaternion":
  136246. {
  136247. o = "VEC4",
  136248. s = !0,
  136249. i = "rotation";
  136250. break
  136251. }
  136252. case "influence":
  136253. {
  136254. o = "SCALAR",
  136255. i = "weights";
  136256. break
  136257. }
  136258. default:
  136259. Tools.Error("Unsupported animatable property " + c[0])
  136260. }
  136261. return i ? {
  136262. animationChannelTargetPath: i,
  136263. dataAccessorType: o,
  136264. useQuaternion: s
  136265. } : (Tools.Error("animation channel target path and data accessor type could be deduced"),
  136266. null)
  136267. }
  136268. ,
  136269. a._CreateNodeAnimationFromNodeAnimations = function(e, i, o, s, c, d, _, b, k, j) {
  136270. var $;
  136271. if (e instanceof TransformNode && e.animations)
  136272. for (var _e = 0, et = e.animations; _e < et.length; _e++) {
  136273. var tt = et[_e]
  136274. , rt = a._DeduceAnimationInfo(tt);
  136275. rt && ($ = {
  136276. name: tt.name,
  136277. samplers: [],
  136278. channels: []
  136279. },
  136280. a.AddAnimation("" + tt.name, tt.hasRunningRuntimeAnimations ? i : $, e, tt, rt.dataAccessorType, rt.animationChannelTargetPath, s, d, _, b, k, rt.useQuaternion, j),
  136281. $.samplers.length && $.channels.length && o.push($))
  136282. }
  136283. }
  136284. ,
  136285. a._CreateMorphTargetAnimationFromMorphTargetAnimations = function(e, i, o, s, c, d, _, b, k, j) {
  136286. var $;
  136287. if (e instanceof Mesh) {
  136288. var _e = e.morphTargetManager;
  136289. if (_e)
  136290. for (var et = 0; et < _e.numTargets; ++et)
  136291. for (var tt = _e.getTarget(et), rt = 0, it = tt.animations; rt < it.length; rt++) {
  136292. for (var nt = it[rt], ot = new Animation("" + nt.name,"influence",nt.framePerSecond,nt.dataType,nt.loopMode,nt.enableBlending), at = [], st = nt.getKeys(), ut = 0; ut < st.length; ++ut)
  136293. for (var ct = st[ut], lt = 0; lt < _e.numTargets; ++lt)
  136294. lt == et ? at.push(ct) : at.push({
  136295. frame: ct.frame,
  136296. value: 0
  136297. });
  136298. ot.setKeys(at);
  136299. var ft = a._DeduceAnimationInfo(ot);
  136300. ft && ($ = {
  136301. name: ot.name,
  136302. samplers: [],
  136303. channels: []
  136304. },
  136305. a.AddAnimation(nt.name, nt.hasRunningRuntimeAnimations ? i : $, e, ot, ft.dataAccessorType, ft.animationChannelTargetPath, s, d, _, b, k, ft.useQuaternion, j, _e.numTargets),
  136306. $.samplers.length && $.channels.length && o.push($))
  136307. }
  136308. }
  136309. }
  136310. ,
  136311. a._CreateNodeAndMorphAnimationFromAnimationGroups = function(e, i, o, s, c, d, _, b, k) {
  136312. var j, $;
  136313. if (e.animationGroups)
  136314. for (var _e = e.animationGroups, et = function(nt) {
  136315. var ot = new Map
  136316. , at = new Map
  136317. , st = new Set
  136318. , ut = nt.to - nt.from;
  136319. $ = {
  136320. name: nt.name,
  136321. channels: [],
  136322. samplers: []
  136323. };
  136324. for (var ct = function(ft) {
  136325. var ht = nt.targetedAnimations[ft]
  136326. , pt = ht.target
  136327. , dt = ht.animation;
  136328. if (pt instanceof TransformNode || pt.length === 1 && pt[0]instanceof TransformNode) {
  136329. var _t = a._DeduceAnimationInfo(ht.animation);
  136330. if (_t) {
  136331. var mt = pt instanceof TransformNode ? pt : pt[0]
  136332. , vt = b[mt.uniqueId];
  136333. a.AddAnimation("" + dt.name, $, mt, dt, _t.dataAccessorType, _t.animationChannelTargetPath, o, c, d, _, vt, _t.useQuaternion, k)
  136334. }
  136335. } else if (pt instanceof MorphTarget || pt.length === 1 && pt[0]instanceof MorphTarget) {
  136336. var _t = a._DeduceAnimationInfo(ht.animation);
  136337. if (_t) {
  136338. var yt = pt instanceof MorphTarget ? pt : pt[0];
  136339. if (yt) {
  136340. var Et = e.morphTargetManagers.find(function(St) {
  136341. for (var xt = 0; xt < St.numTargets; ++xt)
  136342. if (St.getTarget(xt) === yt)
  136343. return !0;
  136344. return !1
  136345. });
  136346. if (Et) {
  136347. var At = e.meshes.find(function(St) {
  136348. return St.morphTargetManager === Et
  136349. });
  136350. At && (ot.has(At) || ot.set(At, new Map),
  136351. (j = ot.get(At)) === null || j === void 0 || j.set(yt, dt),
  136352. st.add(At),
  136353. at.set(At, dt))
  136354. }
  136355. }
  136356. }
  136357. }
  136358. }, lt = 0; lt < nt.targetedAnimations.length; ++lt)
  136359. ct(lt);
  136360. st.forEach(function(ft) {
  136361. for (var ht = ft.morphTargetManager, pt = null, dt = [], _t = at.get(ft), mt = _t.getKeys(), vt = mt.length, yt = 0; yt < vt; ++yt)
  136362. for (var Et = 0; Et < ht.numTargets; ++Et) {
  136363. var At = ht.getTarget(Et)
  136364. , gt = ot.get(ft);
  136365. if (gt) {
  136366. var St = gt.get(At);
  136367. St ? (pt || (pt = new Animation(nt.name + "_" + ft.name + "_MorphWeightAnimation","influence",St.framePerSecond,Animation.ANIMATIONTYPE_FLOAT,St.loopMode,St.enableBlending)),
  136368. dt.push(St.getKeys()[yt])) : dt.push({
  136369. frame: nt.from + ut / vt * yt,
  136370. value: At.influence,
  136371. inTangent: mt[0].inTangent ? 0 : void 0,
  136372. outTangent: mt[0].outTangent ? 0 : void 0
  136373. })
  136374. }
  136375. }
  136376. pt.setKeys(dt);
  136377. var xt = a._DeduceAnimationInfo(pt);
  136378. xt && a.AddAnimation(nt.name + "_" + ft.name + "_MorphWeightAnimation", $, ft, pt, xt.dataAccessorType, xt.animationChannelTargetPath, o, c, d, _, !1, xt.useQuaternion, k, ht == null ? void 0 : ht.numTargets)
  136379. }),
  136380. $.channels.length && $.samplers.length && i.push($)
  136381. }, tt = 0, rt = _e; tt < rt.length; tt++) {
  136382. var it = rt[tt];
  136383. et(it)
  136384. }
  136385. }
  136386. ,
  136387. a.AddAnimation = function(e, i, o, s, c, d, _, b, k, j, $, _e, et, tt) {
  136388. var rt = a._CreateNodeAnimation(o, s, d, $, _e, et), it, nt, ot, at, st, ut, ct;
  136389. if (rt) {
  136390. if (tt) {
  136391. for (var lt = 0, ft = 0, ht = []; rt.inputs.length > 0; )
  136392. ft = rt.inputs.shift(),
  136393. lt % tt == 0 && ht.push(ft),
  136394. lt++;
  136395. rt.inputs = ht
  136396. }
  136397. var pt = _[o.uniqueId]
  136398. , dt = rt.inputs.length * 4;
  136399. it = _GLTFUtilities._CreateBufferView(0, b.getByteOffset(), dt, void 0, e + " keyframe data view"),
  136400. k.push(it),
  136401. rt.inputs.forEach(function(_t) {
  136402. b.setFloat32(_t)
  136403. }),
  136404. nt = _GLTFUtilities._CreateAccessor(k.length - 1, e + " keyframes", "SCALAR", 5126, rt.inputs.length, null, [rt.inputsMin], [rt.inputsMax]),
  136405. j.push(nt),
  136406. ot = j.length - 1,
  136407. st = rt.outputs.length,
  136408. dt = _GLTFUtilities._GetDataAccessorElementCount(c) * 4 * rt.outputs.length,
  136409. it = _GLTFUtilities._CreateBufferView(0, b.getByteOffset(), dt, void 0, e + " data view"),
  136410. k.push(it),
  136411. rt.outputs.forEach(function(_t) {
  136412. _t.forEach(function(mt) {
  136413. b.setFloat32(mt)
  136414. })
  136415. }),
  136416. nt = _GLTFUtilities._CreateAccessor(k.length - 1, e + " data", c, 5126, st, null, null, null),
  136417. j.push(nt),
  136418. at = j.length - 1,
  136419. ut = {
  136420. interpolation: rt.samplerInterpolation,
  136421. input: ot,
  136422. output: at
  136423. },
  136424. i.samplers.push(ut),
  136425. ct = {
  136426. sampler: i.samplers.length - 1,
  136427. target: {
  136428. node: pt,
  136429. path: d
  136430. }
  136431. },
  136432. i.channels.push(ct)
  136433. }
  136434. }
  136435. ,
  136436. a._CreateBakedAnimation = function(e, i, o, s, c, d, _, b, k, j, $, _e) {
  136437. var et, tt = Quaternion.Identity(), rt = null, it, nt = null, ot = null, at = null, st = null, ut = null;
  136438. j.min = Tools.FloatRound(s / d);
  136439. for (var ct = i.getKeys(), lt = 0, ft = ct.length; lt < ft; ++lt) {
  136440. if (ut = null,
  136441. ot = ct[lt],
  136442. lt + 1 < ft)
  136443. if (at = ct[lt + 1],
  136444. ot.value.equals && ot.value.equals(at.value) || ot.value === at.value)
  136445. if (lt === 0)
  136446. ut = ot.frame;
  136447. else
  136448. continue;
  136449. else
  136450. ut = at.frame;
  136451. else {
  136452. if (st = ct[lt - 1],
  136453. ot.value.equals && ot.value.equals(st.value) || ot.value === st.value)
  136454. continue;
  136455. ut = c
  136456. }
  136457. if (ut) {
  136458. for (var ht = ot.frame; ht <= ut; ht += _)
  136459. if (it = Tools.FloatRound(ht / d),
  136460. it !== rt) {
  136461. rt = it,
  136462. nt = it;
  136463. var pt = {
  136464. key: 0,
  136465. repeatCount: 0,
  136466. loopMode: i.loopMode
  136467. };
  136468. et = i._interpolate(ht, pt),
  136469. a._SetInterpolatedValue(e, et, it, i, o, tt, b, k, $, _e)
  136470. }
  136471. }
  136472. }
  136473. nt && (j.max = nt)
  136474. }
  136475. ,
  136476. a._ConvertFactorToVector3OrQuaternion = function(e, i, o, s, c, d, _) {
  136477. var b, k, j = null, $ = a._GetBasePositionRotationOrScale(i, c, d, _);
  136478. if (s === Animation.ANIMATIONTYPE_FLOAT)
  136479. switch (b = o.targetProperty.split("."),
  136480. k = b ? b[1] : "",
  136481. j = _ ? Quaternion.FromArray($).normalize() : Vector3.FromArray($),
  136482. k) {
  136483. case "x":
  136484. {
  136485. j[k] = d && _ && c !== "scale" ? -e : e;
  136486. break
  136487. }
  136488. case "y":
  136489. {
  136490. j[k] = d && _ && c !== "scale" ? -e : e;
  136491. break
  136492. }
  136493. case "z":
  136494. {
  136495. j[k] = d && !_ && c !== "scale" ? -e : e;
  136496. break
  136497. }
  136498. case "w":
  136499. {
  136500. j.w = e;
  136501. break
  136502. }
  136503. default:
  136504. Tools.Error('glTFAnimation: Unsupported component type "' + k + '" for scale animation!')
  136505. }
  136506. return j
  136507. }
  136508. ,
  136509. a._SetInterpolatedValue = function(e, i, o, s, c, d, _, b, k, j) {
  136510. var $ = s.dataType, _e;
  136511. _.push(o),
  136512. typeof i == "number" && e instanceof TransformNode && (i = this._ConvertFactorToVector3OrQuaternion(i, e, s, $, c, k, j)),
  136513. i && (c === "rotation" ? (j ? d = i : (_e = i,
  136514. Quaternion.RotationYawPitchRollToRef(_e.y, _e.x, _e.z, d)),
  136515. k && (_GLTFUtilities._GetRightHandedQuaternionFromRef(d),
  136516. e.parent || (d = Quaternion.FromArray([0, 1, 0, 0]).multiply(d))),
  136517. b.push(d.asArray())) : c === "weights" ? b.push([i]) : (_e = i,
  136518. k && c !== "scale" && (_GLTFUtilities._GetRightHandedPositionVector3FromRef(_e),
  136519. e.parent || (_e.x *= -1,
  136520. _e.z *= -1)),
  136521. b.push(_e.asArray())))
  136522. }
  136523. ,
  136524. a._CreateLinearOrStepAnimation = function(e, i, o, s, c, d, _, b) {
  136525. for (var k = 0, j = i.getKeys(); k < j.length; k++) {
  136526. var $ = j[k];
  136527. c.push($.frame / i.framePerSecond),
  136528. a._AddKeyframeValue($, i, d, o, e, _, b)
  136529. }
  136530. }
  136531. ,
  136532. a._CreateCubicSplineAnimation = function(e, i, o, s, c, d, _, b) {
  136533. i.getKeys().forEach(function(k) {
  136534. c.push(k.frame / i.framePerSecond),
  136535. a.AddSplineTangent(e, _TangentType.INTANGENT, d, o, "CUBICSPLINE", k, s, b, _),
  136536. a._AddKeyframeValue(k, i, d, o, e, _, b),
  136537. a.AddSplineTangent(e, _TangentType.OUTTANGENT, d, o, "CUBICSPLINE", k, s, b, _)
  136538. })
  136539. }
  136540. ,
  136541. a._GetBasePositionRotationOrScale = function(e, i, o, s) {
  136542. var c;
  136543. return i === "rotation" ? s ? e.rotationQuaternion ? (c = e.rotationQuaternion.asArray(),
  136544. o && (_GLTFUtilities._GetRightHandedQuaternionArrayFromRef(c),
  136545. e.parent || (c = Quaternion.FromArray([0, 1, 0, 0]).multiply(Quaternion.FromArray(c)).asArray()))) : c = Quaternion.Identity().asArray() : (c = e.rotation.asArray(),
  136546. _GLTFUtilities._GetRightHandedNormalArray3FromRef(c)) : i === "translation" ? (c = e.position.asArray(),
  136547. o && _GLTFUtilities._GetRightHandedPositionArray3FromRef(c)) : c = e.scaling.asArray(),
  136548. c
  136549. }
  136550. ,
  136551. a._AddKeyframeValue = function(e, i, o, s, c, d, _) {
  136552. var b, k, j = i.dataType;
  136553. if (j === Animation.ANIMATIONTYPE_VECTOR3) {
  136554. if (b = e.value.asArray(),
  136555. s === "rotation") {
  136556. var $ = Vector3.FromArray(b)
  136557. , _e = Quaternion.RotationYawPitchRoll($.y, $.x, $.z);
  136558. d && (_GLTFUtilities._GetRightHandedQuaternionFromRef(_e),
  136559. c.parent || (_e = Quaternion.FromArray([0, 1, 0, 0]).multiply(_e))),
  136560. b = _e.asArray()
  136561. } else
  136562. s === "translation" && d && (_GLTFUtilities._GetRightHandedNormalArray3FromRef(b),
  136563. c.parent || (b[0] *= -1,
  136564. b[2] *= -1));
  136565. o.push(b)
  136566. } else if (j === Animation.ANIMATIONTYPE_FLOAT) {
  136567. if (s === "weights")
  136568. o.push([e.value]);
  136569. else if (k = this._ConvertFactorToVector3OrQuaternion(e.value, c, i, j, s, d, _),
  136570. k) {
  136571. if (s === "rotation") {
  136572. var et = _ ? k : Quaternion.RotationYawPitchRoll(k.y, k.x, k.z).normalize();
  136573. d && (_GLTFUtilities._GetRightHandedQuaternionFromRef(et),
  136574. c.parent || (et = Quaternion.FromArray([0, 1, 0, 0]).multiply(et))),
  136575. o.push(et.asArray())
  136576. } else
  136577. s === "translation" && d && (_GLTFUtilities._GetRightHandedNormalVector3FromRef(k),
  136578. c.parent || (k.x *= -1,
  136579. k.z *= -1));
  136580. o.push(k.asArray())
  136581. }
  136582. } else
  136583. j === Animation.ANIMATIONTYPE_QUATERNION ? (b = e.value.normalize().asArray(),
  136584. d && (_GLTFUtilities._GetRightHandedQuaternionArrayFromRef(b),
  136585. c.parent || (b = Quaternion.FromArray([0, 1, 0, 0]).multiply(Quaternion.FromArray(b)).asArray())),
  136586. o.push(b)) : Tools.Error("glTFAnimation: Unsupported key frame values for animation!")
  136587. }
  136588. ,
  136589. a._DeduceInterpolation = function(e, i, o) {
  136590. var s, c = !1, d;
  136591. if (i === "rotation" && !o)
  136592. return {
  136593. interpolationType: "LINEAR",
  136594. shouldBakeAnimation: !0
  136595. };
  136596. for (var _ = 0, b = e.length; _ < b; ++_)
  136597. if (d = e[_],
  136598. d.inTangent || d.outTangent)
  136599. if (s) {
  136600. if (s !== "CUBICSPLINE") {
  136601. s = "LINEAR",
  136602. c = !0;
  136603. break
  136604. }
  136605. } else
  136606. s = "CUBICSPLINE";
  136607. else if (s) {
  136608. if (s === "CUBICSPLINE" || d.interpolation && d.interpolation === AnimationKeyInterpolation.STEP && s !== "STEP") {
  136609. s = "LINEAR",
  136610. c = !0;
  136611. break
  136612. }
  136613. } else
  136614. d.interpolation && d.interpolation === AnimationKeyInterpolation.STEP ? s = "STEP" : s = "LINEAR";
  136615. return s || (s = "LINEAR"),
  136616. {
  136617. interpolationType: s,
  136618. shouldBakeAnimation: c
  136619. }
  136620. }
  136621. ,
  136622. a.AddSplineTangent = function(e, i, o, s, c, d, _, b, k) {
  136623. var j, $ = i === _TangentType.INTANGENT ? d.inTangent : d.outTangent;
  136624. if (c === "CUBICSPLINE") {
  136625. if (s === "rotation")
  136626. if ($) {
  136627. if (b)
  136628. j = $.asArray();
  136629. else {
  136630. var _e = $;
  136631. j = Quaternion.RotationYawPitchRoll(_e.y, _e.x, _e.z).asArray()
  136632. }
  136633. k && (_GLTFUtilities._GetRightHandedQuaternionArrayFromRef(j),
  136634. e.parent || (j = Quaternion.FromArray([0, 1, 0, 0]).multiply(Quaternion.FromArray(j)).asArray()))
  136635. } else
  136636. j = [0, 0, 0, 0];
  136637. else
  136638. s === "weights" ? $ ? j = [$] : j = [0] : $ ? (j = $.asArray(),
  136639. k && s === "translation" && (_GLTFUtilities._GetRightHandedPositionArray3FromRef(j),
  136640. e.parent || (j[0] *= -1,
  136641. j[2] *= -1))) : j = [0, 0, 0];
  136642. o.push(j)
  136643. }
  136644. }
  136645. ,
  136646. a.calculateMinMaxKeyFrames = function(e) {
  136647. var i = 1 / 0
  136648. , o = -1 / 0;
  136649. return e.forEach(function(s) {
  136650. i = Math.min(i, s.frame),
  136651. o = Math.max(o, s.frame)
  136652. }),
  136653. {
  136654. min: i,
  136655. max: o
  136656. }
  136657. }
  136658. ,
  136659. a
  136660. }()
  136661. , GLTFData = function() {
  136662. function a() {
  136663. this.glTFFiles = {}
  136664. }
  136665. return a.prototype.downloadFiles = function() {
  136666. function e(d, _) {
  136667. return d.indexOf(_, d.length - _.length) !== -1
  136668. }
  136669. for (var i in this.glTFFiles) {
  136670. var o = document.createElement("a");
  136671. document.body.appendChild(o),
  136672. o.setAttribute("type", "hidden"),
  136673. o.download = i;
  136674. var s = this.glTFFiles[i]
  136675. , c = void 0;
  136676. e(i, ".glb") ? c = {
  136677. type: "model/gltf-binary"
  136678. } : e(i, ".bin") ? c = {
  136679. type: "application/octet-stream"
  136680. } : e(i, ".gltf") ? c = {
  136681. type: "model/gltf+json"
  136682. } : e(i, ".jpeg") || e(i, ".jpg") ? c = {
  136683. type: "image/jpeg"
  136684. } : e(i, ".png") && (c = {
  136685. type: "image/png"
  136686. }),
  136687. o.href = window.URL.createObjectURL(new Blob([s],c)),
  136688. o.click()
  136689. }
  136690. }
  136691. ,
  136692. a
  136693. }()
  136694. , _GLTFMaterialExporter = function() {
  136695. function a(e) {
  136696. this._textureMap = {},
  136697. this._textureMap = {},
  136698. this._exporter = e
  136699. }
  136700. return a.FuzzyEquals = function(e, i, o) {
  136701. return Scalar.WithinEpsilon(e.r, i.r, o) && Scalar.WithinEpsilon(e.g, i.g, o) && Scalar.WithinEpsilon(e.b, i.b, o)
  136702. }
  136703. ,
  136704. a.prototype._convertMaterialsToGLTFAsync = function(e, i, o) {
  136705. for (var s = [], c = 0, d = e; c < d.length; c++) {
  136706. var _ = d[c];
  136707. _.getClassName() === "StandardMaterial" ? s.push(this._convertStandardMaterialAsync(_, i, o)) : _.getClassName().indexOf("PBR") !== -1 ? s.push(this._convertPBRMaterialAsync(_, i, o)) : Tools.Warn("Unsupported material type: " + _.name)
  136708. }
  136709. return Promise.all(s).then(function() {})
  136710. }
  136711. ,
  136712. a.prototype._stripTexturesFromMaterial = function(e) {
  136713. var i = {};
  136714. if (e) {
  136715. i.name = e.name,
  136716. i.doubleSided = e.doubleSided,
  136717. i.alphaMode = e.alphaMode,
  136718. i.alphaCutoff = e.alphaCutoff,
  136719. i.emissiveFactor = e.emissiveFactor;
  136720. var o = e.pbrMetallicRoughness;
  136721. o && (i.pbrMetallicRoughness = {},
  136722. i.pbrMetallicRoughness.baseColorFactor = o.baseColorFactor,
  136723. i.pbrMetallicRoughness.metallicFactor = o.metallicFactor,
  136724. i.pbrMetallicRoughness.roughnessFactor = o.roughnessFactor)
  136725. }
  136726. return i
  136727. }
  136728. ,
  136729. a.prototype._hasTexturesPresent = function(e) {
  136730. var i;
  136731. if (e.emissiveTexture || e.normalTexture || e.occlusionTexture)
  136732. return !0;
  136733. var o = e.pbrMetallicRoughness;
  136734. if (o && (o.baseColorTexture || o.metallicRoughnessTexture))
  136735. return !0;
  136736. if (e.extensions)
  136737. for (var s in e.extensions) {
  136738. var c = e.extensions[s];
  136739. if (c)
  136740. return (i = c.hasTextures) === null || i === void 0 ? void 0 : i.call(c)
  136741. }
  136742. return !1
  136743. }
  136744. ,
  136745. a.prototype._getTextureInfo = function(e) {
  136746. if (e) {
  136747. var i = e.uid;
  136748. if (i in this._textureMap)
  136749. return this._textureMap[i]
  136750. }
  136751. return null
  136752. }
  136753. ,
  136754. a.prototype._convertToGLTFPBRMetallicRoughness = function(e) {
  136755. var i = new Vector2(0,1)
  136756. , o = new Vector2(0,.1)
  136757. , s = new Vector2(0,.1)
  136758. , c = new Vector2(1300,.1);
  136759. function d(et, tt, rt, it, nt) {
  136760. return (1 - et) * (1 - et) * (1 - et) * tt + 3 * (1 - et) * (1 - et) * et * rt + 3 * (1 - et) * et * et * it + et * et * et * nt
  136761. }
  136762. function _(et) {
  136763. var tt = Math.pow(et / c.x, .333333);
  136764. return d(tt, i.y, o.y, s.y, c.y)
  136765. }
  136766. var b = e.diffuseColor.toLinearSpace().scale(.5)
  136767. , k = e.alpha
  136768. , j = Scalar.Clamp(e.specularPower, 0, a._MaxSpecularPower)
  136769. , $ = _(j)
  136770. , _e = {
  136771. baseColorFactor: [b.r, b.g, b.b, k],
  136772. metallicFactor: 0,
  136773. roughnessFactor: $
  136774. };
  136775. return _e
  136776. }
  136777. ,
  136778. a._SolveMetallic = function(e, i, o) {
  136779. if (i < this._DielectricSpecular.r)
  136780. return this._DielectricSpecular,
  136781. 0;
  136782. var s = this._DielectricSpecular.r
  136783. , c = e * o / (1 - this._DielectricSpecular.r) + i - 2 * this._DielectricSpecular.r
  136784. , d = this._DielectricSpecular.r - i
  136785. , _ = c * c - 4 * s * d;
  136786. return Scalar.Clamp((-c + Math.sqrt(_)) / (2 * s), 0, 1)
  136787. }
  136788. ,
  136789. a._SetAlphaMode = function(e, i) {
  136790. i.needAlphaBlending() ? e.alphaMode = "BLEND" : i.needAlphaTesting() && (e.alphaMode = "MASK",
  136791. e.alphaCutoff = i.alphaCutOff)
  136792. }
  136793. ,
  136794. a.prototype._convertStandardMaterialAsync = function(e, i, o) {
  136795. var s = this._exporter._materialMap
  136796. , c = this._exporter._materials
  136797. , d = []
  136798. , _ = this._convertToGLTFPBRMetallicRoughness(e)
  136799. , b = {
  136800. name: e.name
  136801. };
  136802. return e.backFaceCulling != null && !e.backFaceCulling && (e.twoSidedLighting || Tools.Warn(e.name + ": Back-face culling enabled and two-sided lighting disabled is not supported in glTF."),
  136803. b.doubleSided = !0),
  136804. o && (e.diffuseTexture && d.push(this._exportTextureAsync(e.diffuseTexture, i).then(function(k) {
  136805. k && (_.baseColorTexture = k)
  136806. })),
  136807. e.bumpTexture && d.push(this._exportTextureAsync(e.bumpTexture, i).then(function(k) {
  136808. k && (b.normalTexture = k,
  136809. e.bumpTexture != null && e.bumpTexture.level !== 1 && (b.normalTexture.scale = e.bumpTexture.level))
  136810. })),
  136811. e.emissiveTexture && (b.emissiveFactor = [1, 1, 1],
  136812. d.push(this._exportTextureAsync(e.emissiveTexture, i).then(function(k) {
  136813. k && (b.emissiveTexture = k)
  136814. }))),
  136815. e.ambientTexture && d.push(this._exportTextureAsync(e.ambientTexture, i).then(function(k) {
  136816. if (k) {
  136817. var j = {
  136818. index: k.index
  136819. };
  136820. b.occlusionTexture = j,
  136821. j.strength = 1
  136822. }
  136823. }))),
  136824. (e.alpha < 1 || e.opacityTexture) && (e.alphaMode === Constants.ALPHA_COMBINE ? b.alphaMode = "BLEND" : Tools.Warn(e.name + ": glTF 2.0 does not support alpha mode: " + e.alphaMode.toString())),
  136825. e.emissiveColor && !a.FuzzyEquals(e.emissiveColor, Color3.Black(), a._Epsilon) && (b.emissiveFactor = e.emissiveColor.asArray()),
  136826. b.pbrMetallicRoughness = _,
  136827. a._SetAlphaMode(b, e),
  136828. c.push(b),
  136829. s[e.uniqueId] = c.length - 1,
  136830. this._finishMaterial(d, b, e, i)
  136831. }
  136832. ,
  136833. a.prototype._finishMaterial = function(e, i, o, s) {
  136834. var c = this;
  136835. return Promise.all(e).then(function() {
  136836. for (var d = c._exporter._extensionsPostExportMaterialAdditionalTextures("exportMaterial", i, o), _ = null, b = 0, k = d; b < k.length; b++) {
  136837. var j = k[b];
  136838. _ || (_ = []),
  136839. _.push(c._exportTextureAsync(j, s))
  136840. }
  136841. return _ || (_ = [Promise.resolve(null)]),
  136842. Promise.all(_).then(function() {
  136843. var $ = c._exporter._extensionsPostExportMaterialAsync("exportMaterial", i, o);
  136844. return $ ? $.then(function() {
  136845. return i
  136846. }) : i
  136847. })
  136848. })
  136849. }
  136850. ,
  136851. a.prototype._convertPBRMetallicRoughnessMaterialAsync = function(e, i, o) {
  136852. var s = this._exporter._materialMap
  136853. , c = this._exporter._materials
  136854. , d = []
  136855. , _ = {};
  136856. e.baseColor && (_.baseColorFactor = [e.baseColor.r, e.baseColor.g, e.baseColor.b, e.alpha]),
  136857. e.metallic != null && e.metallic !== 1 && (_.metallicFactor = e.metallic),
  136858. e.roughness != null && e.roughness !== 1 && (_.roughnessFactor = e.roughness);
  136859. var b = {
  136860. name: e.name
  136861. };
  136862. return e.doubleSided && (b.doubleSided = e.doubleSided),
  136863. a._SetAlphaMode(b, e),
  136864. o && (e.baseTexture != null && d.push(this._exportTextureAsync(e.baseTexture, i).then(function(k) {
  136865. k && (_.baseColorTexture = k)
  136866. })),
  136867. e.normalTexture && d.push(this._exportTextureAsync(e.normalTexture, i).then(function(k) {
  136868. k && (b.normalTexture = k,
  136869. e.normalTexture.level !== 1 && (b.normalTexture.scale = e.normalTexture.level))
  136870. })),
  136871. e.occlusionTexture && d.push(this._exportTextureAsync(e.occlusionTexture, i).then(function(k) {
  136872. k && (b.occlusionTexture = k,
  136873. e.occlusionStrength != null && (b.occlusionTexture.strength = e.occlusionStrength))
  136874. })),
  136875. e.emissiveTexture && d.push(this._exportTextureAsync(e.emissiveTexture, i).then(function(k) {
  136876. k && (b.emissiveTexture = k)
  136877. }))),
  136878. a.FuzzyEquals(e.emissiveColor, Color3.Black(), a._Epsilon) && (b.emissiveFactor = e.emissiveColor.asArray()),
  136879. b.pbrMetallicRoughness = _,
  136880. c.push(b),
  136881. s[e.uniqueId] = c.length - 1,
  136882. this._finishMaterial(d, b, e, i)
  136883. }
  136884. ,
  136885. a.prototype._createBase64FromCanvasAsync = function(e, i, o, s) {
  136886. var c = this;
  136887. return new Promise(function(d, _) {
  136888. return __awaiter(c, void 0, void 0, function() {
  136889. var b, k, j, $, _e, et;
  136890. return __generator(this, function(tt) {
  136891. switch (tt.label) {
  136892. case 0:
  136893. return b = Constants.TEXTURETYPE_UNSIGNED_INT,
  136894. k = this._exporter._babylonScene,
  136895. j = k.getEngine(),
  136896. $ = j.createRawTexture(e, i, o, Constants.TEXTUREFORMAT_RGBA, !1, !0, Texture.NEAREST_SAMPLINGMODE, null, b),
  136897. [4, TextureTools.ApplyPostProcess("pass", $, k, b, Constants.TEXTURE_NEAREST_SAMPLINGMODE, Constants.TEXTUREFORMAT_RGBA)];
  136898. case 1:
  136899. return tt.sent(),
  136900. [4, j._readTexturePixels($, i, o)];
  136901. case 2:
  136902. return _e = tt.sent(),
  136903. [4, Tools.DumpDataAsync(i, o, _e, s, void 0, !0, !1)];
  136904. case 3:
  136905. return et = tt.sent(),
  136906. d(et),
  136907. [2]
  136908. }
  136909. })
  136910. })
  136911. }
  136912. )
  136913. }
  136914. ,
  136915. a.prototype._createWhiteTexture = function(e, i, o) {
  136916. for (var s = new Uint8Array(e * i * 4), c = 0; c < s.length; c = c + 4)
  136917. s[c] = s[c + 1] = s[c + 2] = s[c + 3] = 255;
  136918. var d = RawTexture.CreateRGBATexture(s, e, i, o);
  136919. return d
  136920. }
  136921. ,
  136922. a.prototype._resizeTexturesToSameDimensions = function(e, i, o) {
  136923. var s = e ? e.getSize() : {
  136924. width: 0,
  136925. height: 0
  136926. }, c = i ? i.getSize() : {
  136927. width: 0,
  136928. height: 0
  136929. }, d, _;
  136930. return s.width < c.width ? (e && e instanceof Texture ? d = TextureTools.CreateResizedCopy(e, c.width, c.height, !0) : d = this._createWhiteTexture(c.width, c.height, o),
  136931. _ = i) : s.width > c.width ? (i && i instanceof Texture ? _ = TextureTools.CreateResizedCopy(i, s.width, s.height, !0) : _ = this._createWhiteTexture(s.width, s.height, o),
  136932. d = e) : (d = e,
  136933. _ = i),
  136934. {
  136935. texture1: d,
  136936. texture2: _
  136937. }
  136938. }
  136939. ,
  136940. a.prototype._convertPixelArrayToFloat32 = function(e) {
  136941. if (e instanceof Uint8Array) {
  136942. for (var i = e.length, o = new Float32Array(e.length), s = 0; s < i; ++s)
  136943. o[s] = e[s] / 255;
  136944. return o
  136945. } else {
  136946. if (e instanceof Float32Array)
  136947. return e;
  136948. throw new Error("Unsupported pixel format!")
  136949. }
  136950. }
  136951. ,
  136952. a.prototype._convertSpecularGlossinessTexturesToMetallicRoughnessAsync = function(e, i, o, s) {
  136953. var c;
  136954. return __awaiter(this, void 0, void 0, function() {
  136955. var d, _, b, k, j, $, _e, et, tt, rt, it, nt, ot, at, st, ut, ct, Et, At, lt, ft, ht, pt, dt, _t, mt, vt, yt, Et, At, gt, St, xt, bt, Rt, Rt;
  136956. return __generator(this, function(Mt) {
  136957. switch (Mt.label) {
  136958. case 0:
  136959. return d = [],
  136960. e || i ? (_ = e ? e.getScene() : i ? i.getScene() : null,
  136961. _ ? (b = this._resizeTexturesToSameDimensions(e, i, _),
  136962. k = (c = b.texture1) === null || c === void 0 ? void 0 : c.getSize(),
  136963. j = void 0,
  136964. $ = void 0,
  136965. _e = k.width,
  136966. et = k.height,
  136967. [4, b.texture1.readPixels()]) : [3, 3]) : [2, Promise.reject("_ConvertSpecularGlosinessTexturesToMetallicRoughness: diffuse and specular glossiness textures are not defined!")];
  136968. case 1:
  136969. return tt = Mt.sent(),
  136970. [4, b.texture2.readPixels()];
  136971. case 2:
  136972. if (rt = Mt.sent(),
  136973. tt)
  136974. j = this._convertPixelArrayToFloat32(tt);
  136975. else
  136976. return [2, Promise.reject("Failed to retrieve pixels from diffuse texture!")];
  136977. if (rt)
  136978. $ = this._convertPixelArrayToFloat32(rt);
  136979. else
  136980. return [2, Promise.reject("Failed to retrieve pixels from specular glossiness texture!")];
  136981. for (it = $.byteLength,
  136982. nt = new Uint8Array(it),
  136983. ot = new Uint8Array(it),
  136984. at = 4,
  136985. st = Color3.Black(),
  136986. ut = 0,
  136987. ct = 0,
  136988. Et = 0; Et < et; ++Et)
  136989. for (At = 0; At < _e; ++At)
  136990. lt = (_e * Et + At) * at,
  136991. ft = new Color3(j[lt],j[lt + 1],j[lt + 2]).toLinearSpace().multiply(o.diffuseColor),
  136992. ht = new Color3($[lt],$[lt + 1],$[lt + 2]).toLinearSpace().multiply(o.specularColor),
  136993. pt = $[lt + 3] * o.glossiness,
  136994. dt = {
  136995. diffuseColor: ft,
  136996. specularColor: ht,
  136997. glossiness: pt
  136998. },
  136999. _t = this._convertSpecularGlossinessToMetallicRoughness(dt),
  137000. st.r = Math.max(st.r, _t.baseColor.r),
  137001. st.g = Math.max(st.g, _t.baseColor.g),
  137002. st.b = Math.max(st.b, _t.baseColor.b),
  137003. ut = Math.max(ut, _t.metallic),
  137004. ct = Math.max(ct, _t.roughness),
  137005. ot[lt] = _t.baseColor.r * 255,
  137006. ot[lt + 1] = _t.baseColor.g * 255,
  137007. ot[lt + 2] = _t.baseColor.b * 255,
  137008. ot[lt + 3] = b.texture1.hasAlpha ? j[lt + 3] * 255 : 255,
  137009. nt[lt] = 0,
  137010. nt[lt + 1] = _t.roughness * 255,
  137011. nt[lt + 2] = _t.metallic * 255,
  137012. nt[lt + 3] = 255;
  137013. for (mt = {
  137014. baseColor: st,
  137015. metallic: ut,
  137016. roughness: ct
  137017. },
  137018. vt = !1,
  137019. yt = !1,
  137020. Et = 0; Et < et; ++Et)
  137021. for (At = 0; At < _e; ++At)
  137022. gt = (_e * Et + At) * at,
  137023. ot[gt] /= mt.baseColor.r > a._Epsilon ? mt.baseColor.r : 1,
  137024. ot[gt + 1] /= mt.baseColor.g > a._Epsilon ? mt.baseColor.g : 1,
  137025. ot[gt + 2] /= mt.baseColor.b > a._Epsilon ? mt.baseColor.b : 1,
  137026. St = Color3.FromInts(ot[gt], ot[gt + 1], ot[gt + 2]),
  137027. xt = St.toGammaSpace(),
  137028. ot[gt] = xt.r * 255,
  137029. ot[gt + 1] = xt.g * 255,
  137030. ot[gt + 2] = xt.b * 255,
  137031. a.FuzzyEquals(xt, Color3.White(), a._Epsilon) || (yt = !0),
  137032. nt[gt + 1] /= mt.roughness > a._Epsilon ? mt.roughness : 1,
  137033. nt[gt + 2] /= mt.metallic > a._Epsilon ? mt.metallic : 1,
  137034. bt = Color3.FromInts(255, nt[gt + 1], nt[gt + 2]),
  137035. a.FuzzyEquals(bt, Color3.White(), a._Epsilon) || (vt = !0);
  137036. return vt && (Rt = this._createBase64FromCanvasAsync(nt, _e, et, s).then(function(Pt) {
  137037. mt.metallicRoughnessTextureBase64 = Pt
  137038. }),
  137039. d.push(Rt)),
  137040. yt && (Rt = this._createBase64FromCanvasAsync(ot, _e, et, s).then(function(Pt) {
  137041. mt.baseColorTextureBase64 = Pt
  137042. }),
  137043. d.push(Rt)),
  137044. [2, Promise.all(d).then(function() {
  137045. return mt
  137046. })];
  137047. case 3:
  137048. return [2, Promise.reject("_ConvertSpecularGlossinessTexturesToMetallicRoughness: Scene from textures is missing!")]
  137049. }
  137050. })
  137051. })
  137052. }
  137053. ,
  137054. a.prototype._convertSpecularGlossinessToMetallicRoughness = function(e) {
  137055. var i = this._getPerceivedBrightness(e.diffuseColor)
  137056. , o = this._getPerceivedBrightness(e.specularColor)
  137057. , s = 1 - this._getMaxComponent(e.specularColor)
  137058. , c = a._SolveMetallic(i, o, s)
  137059. , d = e.diffuseColor.scale(s / (1 - a._DielectricSpecular.r) / Math.max(1 - c, a._Epsilon))
  137060. , _ = e.specularColor.subtract(a._DielectricSpecular.scale(1 - c)).scale(1 / Math.max(c, a._Epsilon))
  137061. , b = Color3.Lerp(d, _, c * c);
  137062. b = b.clampToRef(0, 1, b);
  137063. var k = {
  137064. baseColor: b,
  137065. metallic: c,
  137066. roughness: 1 - e.glossiness
  137067. };
  137068. return k
  137069. }
  137070. ,
  137071. a.prototype._getPerceivedBrightness = function(e) {
  137072. return e ? Math.sqrt(.299 * e.r * e.r + .587 * e.g * e.g + .114 * e.b * e.b) : 0
  137073. }
  137074. ,
  137075. a.prototype._getMaxComponent = function(e) {
  137076. return e ? Math.max(e.r, Math.max(e.g, e.b)) : 0
  137077. }
  137078. ,
  137079. a.prototype._convertMetalRoughFactorsToMetallicRoughnessAsync = function(e, i, o, s) {
  137080. var c = []
  137081. , d = e._albedoColor
  137082. , _ = e._metallic
  137083. , b = e._roughness
  137084. , k = {
  137085. baseColor: d,
  137086. metallic: _,
  137087. roughness: b
  137088. };
  137089. if (s) {
  137090. var j = e._albedoTexture;
  137091. j && c.push(this._exportTextureAsync(e._albedoTexture, i).then(function(_e) {
  137092. _e && (o.baseColorTexture = _e)
  137093. }));
  137094. var $ = e._metallicTexture;
  137095. $ && c.push(this._exportTextureAsync($, i).then(function(_e) {
  137096. _e && (o.metallicRoughnessTexture = _e)
  137097. }))
  137098. }
  137099. return Promise.all(c).then(function() {
  137100. return k
  137101. })
  137102. }
  137103. ,
  137104. a.prototype._getGLTFTextureSampler = function(e) {
  137105. var i = this._getGLTFTextureWrapModesSampler(e)
  137106. , o = e instanceof Texture ? e.samplingMode : null;
  137107. if (o != null)
  137108. switch (o) {
  137109. case Texture.LINEAR_LINEAR:
  137110. {
  137111. i.magFilter = 9729,
  137112. i.minFilter = 9729;
  137113. break
  137114. }
  137115. case Texture.LINEAR_NEAREST:
  137116. {
  137117. i.magFilter = 9729,
  137118. i.minFilter = 9728;
  137119. break
  137120. }
  137121. case Texture.NEAREST_LINEAR:
  137122. {
  137123. i.magFilter = 9728,
  137124. i.minFilter = 9729;
  137125. break
  137126. }
  137127. case Texture.NEAREST_LINEAR_MIPLINEAR:
  137128. {
  137129. i.magFilter = 9728,
  137130. i.minFilter = 9987;
  137131. break
  137132. }
  137133. case Texture.NEAREST_NEAREST:
  137134. {
  137135. i.magFilter = 9728,
  137136. i.minFilter = 9728;
  137137. break
  137138. }
  137139. case Texture.NEAREST_LINEAR_MIPNEAREST:
  137140. {
  137141. i.magFilter = 9728,
  137142. i.minFilter = 9985;
  137143. break
  137144. }
  137145. case Texture.LINEAR_NEAREST_MIPNEAREST:
  137146. {
  137147. i.magFilter = 9729,
  137148. i.minFilter = 9984;
  137149. break
  137150. }
  137151. case Texture.LINEAR_NEAREST_MIPLINEAR:
  137152. {
  137153. i.magFilter = 9729,
  137154. i.minFilter = 9986;
  137155. break
  137156. }
  137157. case Texture.NEAREST_NEAREST_MIPLINEAR:
  137158. {
  137159. i.magFilter = 9728,
  137160. i.minFilter = 9986;
  137161. break
  137162. }
  137163. case Texture.LINEAR_LINEAR_MIPLINEAR:
  137164. {
  137165. i.magFilter = 9729,
  137166. i.minFilter = 9987;
  137167. break
  137168. }
  137169. case Texture.LINEAR_LINEAR_MIPNEAREST:
  137170. {
  137171. i.magFilter = 9729,
  137172. i.minFilter = 9985;
  137173. break
  137174. }
  137175. case Texture.NEAREST_NEAREST_MIPNEAREST:
  137176. {
  137177. i.magFilter = 9728,
  137178. i.minFilter = 9984;
  137179. break
  137180. }
  137181. }
  137182. return i
  137183. }
  137184. ,
  137185. a.prototype._getGLTFTextureWrapMode = function(e) {
  137186. switch (e) {
  137187. case Texture.WRAP_ADDRESSMODE:
  137188. return 10497;
  137189. case Texture.CLAMP_ADDRESSMODE:
  137190. return 33071;
  137191. case Texture.MIRROR_ADDRESSMODE:
  137192. return 33648;
  137193. default:
  137194. return Tools.Error("Unsupported Texture Wrap Mode " + e + "!"),
  137195. 10497
  137196. }
  137197. }
  137198. ,
  137199. a.prototype._getGLTFTextureWrapModesSampler = function(e) {
  137200. var i = this._getGLTFTextureWrapMode(e instanceof Texture ? e.wrapU : Texture.WRAP_ADDRESSMODE)
  137201. , o = this._getGLTFTextureWrapMode(e instanceof Texture ? e.wrapV : Texture.WRAP_ADDRESSMODE);
  137202. return i === 10497 && o === 10497 ? {} : {
  137203. wrapS: i,
  137204. wrapT: o
  137205. }
  137206. }
  137207. ,
  137208. a.prototype._convertSpecGlossFactorsToMetallicRoughnessAsync = function(e, i, o, s) {
  137209. var c = this;
  137210. return Promise.resolve().then(function() {
  137211. var d = c._exporter._samplers
  137212. , _ = c._exporter._textures
  137213. , b = e._albedoColor
  137214. , k = e._reflectivityColor
  137215. , j = e._microSurface
  137216. , $ = {
  137217. diffuseColor: b,
  137218. specularColor: k,
  137219. glossiness: j
  137220. }
  137221. , _e = null
  137222. , et = e._albedoTexture
  137223. , tt = e._reflectivityTexture;
  137224. if (et) {
  137225. var rt = c._getGLTFTextureSampler(et);
  137226. rt.magFilter != null && rt.minFilter != null && rt.wrapS != null && rt.wrapT != null && (d.push(rt),
  137227. _e = d.length - 1)
  137228. }
  137229. var it = e._useMicroSurfaceFromReflectivityMapAlpha;
  137230. return tt && !it ? Promise.reject("_ConvertPBRMaterial: Glossiness values not included in the reflectivity texture are currently not supported") : (et || tt) && s ? c._convertSpecularGlossinessTexturesToMetallicRoughnessAsync(et, tt, $, i).then(function(nt) {
  137231. if (nt.baseColorTextureBase64) {
  137232. var ot = c._getTextureInfoFromBase64(nt.baseColorTextureBase64, "bjsBaseColorTexture_" + _.length + ".png", i, et ? et.coordinatesIndex : null, _e);
  137233. ot && (o.baseColorTexture = ot)
  137234. }
  137235. if (nt.metallicRoughnessTextureBase64) {
  137236. var at = c._getTextureInfoFromBase64(nt.metallicRoughnessTextureBase64, "bjsMetallicRoughnessTexture_" + _.length + ".png", i, tt ? tt.coordinatesIndex : null, _e);
  137237. at && (o.metallicRoughnessTexture = at)
  137238. }
  137239. return nt
  137240. }) : c._convertSpecularGlossinessToMetallicRoughness($)
  137241. })
  137242. }
  137243. ,
  137244. a.prototype._convertPBRMaterialAsync = function(e, i, o) {
  137245. var s = this
  137246. , c = {}
  137247. , d = {
  137248. name: e.name
  137249. }
  137250. , _ = e.isMetallicWorkflow();
  137251. if (_) {
  137252. var b = e._albedoColor
  137253. , k = e.alpha;
  137254. return b && (c.baseColorFactor = [b.r, b.g, b.b, k]),
  137255. this._convertMetalRoughFactorsToMetallicRoughnessAsync(e, i, c, o).then(function(j) {
  137256. return s.setMetallicRoughnessPbrMaterial(j, e, d, c, i, o)
  137257. })
  137258. } else
  137259. return this._convertSpecGlossFactorsToMetallicRoughnessAsync(e, i, c, o).then(function(j) {
  137260. return s.setMetallicRoughnessPbrMaterial(j, e, d, c, i, o)
  137261. })
  137262. }
  137263. ,
  137264. a.prototype.setMetallicRoughnessPbrMaterial = function(e, i, o, s, c, d) {
  137265. var _ = this._exporter._materialMap
  137266. , b = this._exporter._materials
  137267. , k = [];
  137268. if (e) {
  137269. if (a._SetAlphaMode(o, i),
  137270. a.FuzzyEquals(e.baseColor, Color3.White(), a._Epsilon) && i.alpha >= a._Epsilon || (s.baseColorFactor = [e.baseColor.r, e.baseColor.g, e.baseColor.b, i.alpha]),
  137271. e.metallic != null && e.metallic !== 1 && (s.metallicFactor = e.metallic),
  137272. e.roughness != null && e.roughness !== 1 && (s.roughnessFactor = e.roughness),
  137273. i.backFaceCulling != null && !i.backFaceCulling && (i._twoSidedLighting || Tools.Warn(i.name + ": Back-face culling enabled and two-sided lighting disabled is not supported in glTF."),
  137274. o.doubleSided = !0),
  137275. d) {
  137276. var j = i._bumpTexture;
  137277. if (j) {
  137278. var $ = this._exportTextureAsync(j, c).then(function(rt) {
  137279. rt && (o.normalTexture = rt,
  137280. j.level !== 1 && (o.normalTexture.scale = j.level))
  137281. });
  137282. k.push($)
  137283. }
  137284. var _e = i._ambientTexture;
  137285. if (_e) {
  137286. var $ = this._exportTextureAsync(_e, c).then(function(it) {
  137287. if (it) {
  137288. var nt = {
  137289. index: it.index,
  137290. texCoord: it.texCoord
  137291. };
  137292. o.occlusionTexture = nt;
  137293. var ot = i._ambientTextureStrength;
  137294. ot && (nt.strength = ot)
  137295. }
  137296. });
  137297. k.push($)
  137298. }
  137299. var et = i._emissiveTexture;
  137300. if (et) {
  137301. var $ = this._exportTextureAsync(et, c).then(function(it) {
  137302. it && (o.emissiveTexture = it)
  137303. });
  137304. k.push($)
  137305. }
  137306. }
  137307. var tt = i._emissiveColor;
  137308. a.FuzzyEquals(tt, Color3.Black(), a._Epsilon) || (o.emissiveFactor = tt.asArray()),
  137309. o.pbrMetallicRoughness = s,
  137310. b.push(o),
  137311. _[i.uniqueId] = b.length - 1
  137312. }
  137313. return this._finishMaterial(k, o, i, c)
  137314. }
  137315. ,
  137316. a.prototype.getPixelsFromTexture = function(e) {
  137317. var i = (e.textureType === Constants.TEXTURETYPE_UNSIGNED_INT,
  137318. e.readPixels());
  137319. return i
  137320. }
  137321. ,
  137322. a.prototype._exportTextureAsync = function(e, i) {
  137323. var o = this
  137324. , s = this._exporter._extensionsPreExportTextureAsync("exporter", e, i);
  137325. return s ? s.then(function(c) {
  137326. return c ? o._exportTextureInfoAsync(c, i) : o._exportTextureInfoAsync(e, i)
  137327. }) : this._exportTextureInfoAsync(e, i)
  137328. }
  137329. ,
  137330. a.prototype._exportTextureInfoAsync = function(e, i) {
  137331. var o = this;
  137332. return Promise.resolve().then(function() {
  137333. return __awaiter(o, void 0, void 0, function() {
  137334. var s, c, d, _, b, k, j, $, _e, et = this;
  137335. return __generator(this, function(tt) {
  137336. switch (tt.label) {
  137337. case 0:
  137338. return s = e.uid,
  137339. s in this._textureMap ? [2, this._textureMap[s]] : [3, 1];
  137340. case 1:
  137341. return [4, this.getPixelsFromTexture(e)];
  137342. case 2:
  137343. if (c = tt.sent(),
  137344. !c)
  137345. return [2, null];
  137346. for (d = this._exporter._samplers,
  137347. _ = this._getGLTFTextureSampler(e),
  137348. b = null,
  137349. k = null,
  137350. j = 0; j < d.length; ++j)
  137351. if ($ = d[j],
  137352. $.minFilter === _.minFilter && $.magFilter === _.magFilter && $.wrapS === _.wrapS && $.wrapT === _.wrapT) {
  137353. k = j;
  137354. break
  137355. }
  137356. if (k == null ? (d.push(_),
  137357. b = d.length - 1) : b = k,
  137358. _e = e.getSize(),
  137359. e.mimeType)
  137360. switch (e.mimeType) {
  137361. case "image/jpeg":
  137362. i = "image/jpeg";
  137363. break;
  137364. case "image/png":
  137365. i = "image/png";
  137366. break
  137367. }
  137368. return [2, this._createBase64FromCanvasAsync(c, _e.width, _e.height, i).then(function(rt) {
  137369. var it = et._getTextureInfoFromBase64(rt, e.name.replace(/\.\/|\/|\.\\|\\/g, "_"), i, e.coordinatesIndex, b);
  137370. return it && (et._textureMap[s] = it,
  137371. et._exporter._extensionsPostExportTextures("linkTextureInfo", it, e)),
  137372. it
  137373. })]
  137374. }
  137375. })
  137376. })
  137377. })
  137378. }
  137379. ,
  137380. a.prototype._getTextureInfoFromBase64 = function(e, i, o, s, c) {
  137381. var d = this._exporter._textures
  137382. , _ = this._exporter._images
  137383. , b = this._exporter._imageData
  137384. , k = null
  137385. , j = {
  137386. source: _.length,
  137387. name: i
  137388. };
  137389. c != null && (j.sampler = c);
  137390. for (var $ = atob(e.split(",")[1]), _e = new ArrayBuffer($.length), et = new Uint8Array(_e), tt = 0, rt = $.length; tt < rt; ++tt)
  137391. et[tt] = $.charCodeAt(tt);
  137392. var it = {
  137393. data: et,
  137394. mimeType: o
  137395. }
  137396. , nt = o === "image/jpeg" ? ".jpeg" : ".png"
  137397. , ot = i + nt
  137398. , at = ot;
  137399. if (ot in b && (ot = i + "_" + Tools.RandomId() + nt),
  137400. b[ot] = it,
  137401. o === "image/jpeg" || o === "image/png") {
  137402. for (var st = {
  137403. name: i,
  137404. uri: ot
  137405. }, ut = null, tt = 0; tt < _.length; ++tt)
  137406. if (_[tt].uri === at) {
  137407. ut = tt;
  137408. break
  137409. }
  137410. ut == null ? (_.push(st),
  137411. j.source = _.length - 1) : j.source = ut,
  137412. d.push(j),
  137413. k = {
  137414. index: d.length - 1
  137415. },
  137416. s != null && (k.texCoord = s)
  137417. } else
  137418. Tools.Error("Unsupported texture mime type " + o);
  137419. return k
  137420. }
  137421. ,
  137422. a._DielectricSpecular = new Color3(.04,.04,.04),
  137423. a._MaxSpecularPower = 1024,
  137424. a._Epsilon = 1e-6,
  137425. a
  137426. }()
  137427. , _Exporter = function() {
  137428. function a(e, i) {
  137429. this._includeCoordinateSystemConversionNodes = !1,
  137430. this._extensions = {},
  137431. this._glTF = {
  137432. asset: {
  137433. generator: "BabylonJS",
  137434. version: "2.0"
  137435. }
  137436. },
  137437. this._babylonScene = e,
  137438. this._bufferViews = [],
  137439. this._accessors = [],
  137440. this._meshes = [],
  137441. this._scenes = [],
  137442. this._nodes = [],
  137443. this._images = [],
  137444. this._materials = [],
  137445. this._materialMap = [],
  137446. this._textures = [],
  137447. this._samplers = [],
  137448. this._skins = [],
  137449. this._animations = [],
  137450. this._imageData = {},
  137451. this._orderedImageData = [],
  137452. this._options = i || {},
  137453. this._animationSampleRate = i && i.animationSampleRate ? i.animationSampleRate : 1 / 60,
  137454. this._includeCoordinateSystemConversionNodes = !!(i && i.includeCoordinateSystemConversionNodes),
  137455. this._glTFMaterialExporter = new _GLTFMaterialExporter(this),
  137456. this._loadExtensions()
  137457. }
  137458. return a.prototype._applyExtension = function(e, i, o, s) {
  137459. var c = this;
  137460. if (o >= i.length)
  137461. return Promise.resolve(e);
  137462. var d = s(i[o], e);
  137463. return d ? d.then(function(_) {
  137464. return c._applyExtension(_, i, o + 1, s)
  137465. }) : this._applyExtension(e, i, o + 1, s)
  137466. }
  137467. ,
  137468. a.prototype._applyExtensions = function(e, i) {
  137469. for (var o = [], s = 0, c = a._ExtensionNames; s < c.length; s++) {
  137470. var d = c[s];
  137471. o.push(this._extensions[d])
  137472. }
  137473. return this._applyExtension(e, o, 0, i)
  137474. }
  137475. ,
  137476. a.prototype._extensionsPreExportTextureAsync = function(e, i, o) {
  137477. return this._applyExtensions(i, function(s, c) {
  137478. return s.preExportTextureAsync && s.preExportTextureAsync(e, c, o)
  137479. })
  137480. }
  137481. ,
  137482. a.prototype._extensionsPostExportMeshPrimitiveAsync = function(e, i, o, s) {
  137483. return this._applyExtensions(i, function(c, d) {
  137484. return c.postExportMeshPrimitiveAsync && c.postExportMeshPrimitiveAsync(e, d, o, s)
  137485. })
  137486. }
  137487. ,
  137488. a.prototype._extensionsPostExportNodeAsync = function(e, i, o, s) {
  137489. return this._applyExtensions(i, function(c, d) {
  137490. return c.postExportNodeAsync && c.postExportNodeAsync(e, d, o, s)
  137491. })
  137492. }
  137493. ,
  137494. a.prototype._extensionsPostExportMaterialAsync = function(e, i, o) {
  137495. return this._applyExtensions(i, function(s, c) {
  137496. return s.postExportMaterialAsync && s.postExportMaterialAsync(e, c, o)
  137497. })
  137498. }
  137499. ,
  137500. a.prototype._extensionsPostExportMaterialAdditionalTextures = function(e, i, o) {
  137501. for (var s = [], c = 0, d = a._ExtensionNames; c < d.length; c++) {
  137502. var _ = d[c]
  137503. , b = this._extensions[_];
  137504. b.postExportMaterialAdditionalTextures && s.push.apply(s, b.postExportMaterialAdditionalTextures(e, i, o))
  137505. }
  137506. return s
  137507. }
  137508. ,
  137509. a.prototype._extensionsPostExportTextures = function(e, i, o) {
  137510. for (var s = 0, c = a._ExtensionNames; s < c.length; s++) {
  137511. var d = c[s]
  137512. , _ = this._extensions[d];
  137513. _.postExportTexture && _.postExportTexture(e, i, o)
  137514. }
  137515. }
  137516. ,
  137517. a.prototype._forEachExtensions = function(e) {
  137518. for (var i = 0, o = a._ExtensionNames; i < o.length; i++) {
  137519. var s = o[i]
  137520. , c = this._extensions[s];
  137521. c.enabled && e(c)
  137522. }
  137523. }
  137524. ,
  137525. a.prototype._extensionsOnExporting = function() {
  137526. var e = this;
  137527. this._forEachExtensions(function(i) {
  137528. i.wasUsed && (e._glTF.extensionsUsed == null && (e._glTF.extensionsUsed = []),
  137529. e._glTF.extensionsUsed.indexOf(i.name) === -1 && e._glTF.extensionsUsed.push(i.name),
  137530. i.required && (e._glTF.extensionsRequired == null && (e._glTF.extensionsRequired = []),
  137531. e._glTF.extensionsRequired.indexOf(i.name) === -1 && e._glTF.extensionsRequired.push(i.name)),
  137532. e._glTF.extensions == null && (e._glTF.extensions = {}),
  137533. i.onExporting && i.onExporting())
  137534. })
  137535. }
  137536. ,
  137537. a.prototype._loadExtensions = function() {
  137538. for (var e = 0, i = a._ExtensionNames; e < i.length; e++) {
  137539. var o = i[e]
  137540. , s = a._ExtensionFactories[o](this);
  137541. this._extensions[o] = s
  137542. }
  137543. }
  137544. ,
  137545. a.prototype.dispose = function() {
  137546. for (var e in this._extensions) {
  137547. var i = this._extensions[e];
  137548. i.dispose()
  137549. }
  137550. }
  137551. ,
  137552. a.RegisterExtension = function(e, i) {
  137553. a.UnregisterExtension(e) && Tools.Warn("Extension with the name " + e + " already exists"),
  137554. a._ExtensionFactories[e] = i,
  137555. a._ExtensionNames.push(e)
  137556. }
  137557. ,
  137558. a.UnregisterExtension = function(e) {
  137559. if (!a._ExtensionFactories[e])
  137560. return !1;
  137561. delete a._ExtensionFactories[e];
  137562. var i = a._ExtensionNames.indexOf(e);
  137563. return i !== -1 && a._ExtensionNames.splice(i, 1),
  137564. !0
  137565. }
  137566. ,
  137567. a.prototype.reorderIndicesBasedOnPrimitiveMode = function(e, i, o, s, c) {
  137568. switch (i) {
  137569. case Material.TriangleFillMode:
  137570. {
  137571. s || (s = 0);
  137572. for (var d = e.indexStart, _ = e.indexStart + e.indexCount; d < _; d = d + 3) {
  137573. var b = s + d * 4
  137574. , k = c.getUInt32(b + 4)
  137575. , j = c.getUInt32(b + 8);
  137576. c.setUInt32(j, b + 4),
  137577. c.setUInt32(k, b + 8)
  137578. }
  137579. break
  137580. }
  137581. case Material.TriangleFanDrawMode:
  137582. {
  137583. for (var d = e.indexStart + e.indexCount - 1, $ = e.indexStart; d >= $; --d)
  137584. c.setUInt32(o[d], s),
  137585. s += 4;
  137586. break
  137587. }
  137588. case Material.TriangleStripDrawMode:
  137589. {
  137590. e.indexCount >= 3 && (c.setUInt32(o[e.indexStart + 2], s + 4),
  137591. c.setUInt32(o[e.indexStart + 1], s + 8));
  137592. break
  137593. }
  137594. }
  137595. }
  137596. ,
  137597. a.prototype.reorderVertexAttributeDataBasedOnPrimitiveMode = function(e, i, o, s, c, d, _, b) {
  137598. if (b && o === Material.ClockWiseSideOrientation)
  137599. switch (i) {
  137600. case Material.TriangleFillMode:
  137601. {
  137602. this.reorderTriangleFillMode(e, i, o, s, c, d, _, b);
  137603. break
  137604. }
  137605. case Material.TriangleStripDrawMode:
  137606. {
  137607. this.reorderTriangleStripDrawMode(e, i, o, s, c, d, _, b);
  137608. break
  137609. }
  137610. case Material.TriangleFanDrawMode:
  137611. {
  137612. this.reorderTriangleFanMode(e, i, o, s, c, d, _, b);
  137613. break
  137614. }
  137615. }
  137616. }
  137617. ,
  137618. a.prototype.reorderTriangleFillMode = function(e, i, o, s, c, d, _, b) {
  137619. var k = this.getVertexBufferFromMesh(s, e.getMesh());
  137620. if (k) {
  137621. var j = k.byteStride / VertexBuffer.GetTypeByteLength(k.type);
  137622. if (e.verticesCount % 3 !== 0)
  137623. Tools.Error("The submesh vertices for the triangle fill mode is not divisible by 3!");
  137624. else {
  137625. var $ = []
  137626. , _e = 0;
  137627. switch (s) {
  137628. case VertexBuffer.PositionKind:
  137629. case VertexBuffer.NormalKind:
  137630. {
  137631. for (var et = e.verticesStart; et < e.verticesStart + e.verticesCount; et = et + 3)
  137632. _e = et * j,
  137633. $.push(Vector3.FromArray(c, _e)),
  137634. $.push(Vector3.FromArray(c, _e + 2 * j)),
  137635. $.push(Vector3.FromArray(c, _e + j));
  137636. break
  137637. }
  137638. case VertexBuffer.TangentKind:
  137639. {
  137640. for (var et = e.verticesStart; et < e.verticesStart + e.verticesCount; et = et + 3)
  137641. _e = et * j,
  137642. $.push(Vector4.FromArray(c, _e)),
  137643. $.push(Vector4.FromArray(c, _e + 2 * j)),
  137644. $.push(Vector4.FromArray(c, _e + j));
  137645. break
  137646. }
  137647. case VertexBuffer.ColorKind:
  137648. {
  137649. for (var tt = k.getSize(), et = e.verticesStart; et < e.verticesStart + e.verticesCount; et = et + tt)
  137650. _e = et * j,
  137651. tt === 4 ? ($.push(Vector4.FromArray(c, _e)),
  137652. $.push(Vector4.FromArray(c, _e + 2 * j)),
  137653. $.push(Vector4.FromArray(c, _e + j))) : ($.push(Vector3.FromArray(c, _e)),
  137654. $.push(Vector3.FromArray(c, _e + 2 * j)),
  137655. $.push(Vector3.FromArray(c, _e + j)));
  137656. break
  137657. }
  137658. case VertexBuffer.UVKind:
  137659. case VertexBuffer.UV2Kind:
  137660. {
  137661. for (var et = e.verticesStart; et < e.verticesStart + e.verticesCount; et = et + 3)
  137662. _e = et * j,
  137663. $.push(Vector2.FromArray(c, _e)),
  137664. $.push(Vector2.FromArray(c, _e + 2 * j)),
  137665. $.push(Vector2.FromArray(c, _e + j));
  137666. break
  137667. }
  137668. default:
  137669. Tools.Error("Unsupported Vertex Buffer type: " + s)
  137670. }
  137671. this.writeVertexAttributeData($, d, s, c, _, b)
  137672. }
  137673. } else
  137674. Tools.Warn("reorderTriangleFillMode: Vertex Buffer Kind " + s + " not present!")
  137675. }
  137676. ,
  137677. a.prototype.reorderTriangleStripDrawMode = function(e, i, o, s, c, d, _, b) {
  137678. var k = this.getVertexBufferFromMesh(s, e.getMesh());
  137679. if (k) {
  137680. var j = k.byteStride / VertexBuffer.GetTypeByteLength(k.type)
  137681. , $ = []
  137682. , _e = 0;
  137683. switch (s) {
  137684. case VertexBuffer.PositionKind:
  137685. case VertexBuffer.NormalKind:
  137686. {
  137687. _e = e.verticesStart,
  137688. $.push(Vector3.FromArray(c, _e + 2 * j)),
  137689. $.push(Vector3.FromArray(c, _e + j));
  137690. break
  137691. }
  137692. case VertexBuffer.TangentKind:
  137693. {
  137694. for (var et = e.verticesStart + e.verticesCount - 1; et >= e.verticesStart; --et)
  137695. _e = et * j,
  137696. $.push(Vector4.FromArray(c, _e));
  137697. break
  137698. }
  137699. case VertexBuffer.ColorKind:
  137700. {
  137701. for (var et = e.verticesStart + e.verticesCount - 1; et >= e.verticesStart; --et)
  137702. _e = et * j,
  137703. k.getSize() === 4 ? $.push(Vector4.FromArray(c, _e)) : $.push(Vector3.FromArray(c, _e));
  137704. break
  137705. }
  137706. case VertexBuffer.UVKind:
  137707. case VertexBuffer.UV2Kind:
  137708. {
  137709. for (var et = e.verticesStart + e.verticesCount - 1; et >= e.verticesStart; --et)
  137710. _e = et * j,
  137711. $.push(Vector2.FromArray(c, _e));
  137712. break
  137713. }
  137714. default:
  137715. Tools.Error("Unsupported Vertex Buffer type: " + s)
  137716. }
  137717. this.writeVertexAttributeData($, d + 12, s, c, _, b)
  137718. } else
  137719. Tools.Warn("reorderTriangleStripDrawMode: Vertex buffer kind " + s + " not present!")
  137720. }
  137721. ,
  137722. a.prototype.reorderTriangleFanMode = function(e, i, o, s, c, d, _, b) {
  137723. var k = this.getVertexBufferFromMesh(s, e.getMesh());
  137724. if (k) {
  137725. var j = k.byteStride / VertexBuffer.GetTypeByteLength(k.type)
  137726. , $ = []
  137727. , _e = 0;
  137728. switch (s) {
  137729. case VertexBuffer.PositionKind:
  137730. case VertexBuffer.NormalKind:
  137731. {
  137732. for (var et = e.verticesStart + e.verticesCount - 1; et >= e.verticesStart; --et)
  137733. _e = et * j,
  137734. $.push(Vector3.FromArray(c, _e));
  137735. break
  137736. }
  137737. case VertexBuffer.TangentKind:
  137738. {
  137739. for (var et = e.verticesStart + e.verticesCount - 1; et >= e.verticesStart; --et)
  137740. _e = et * j,
  137741. $.push(Vector4.FromArray(c, _e));
  137742. break
  137743. }
  137744. case VertexBuffer.ColorKind:
  137745. {
  137746. for (var et = e.verticesStart + e.verticesCount - 1; et >= e.verticesStart; --et)
  137747. _e = et * j,
  137748. $.push(Vector4.FromArray(c, _e)),
  137749. k.getSize() === 4 ? $.push(Vector4.FromArray(c, _e)) : $.push(Vector3.FromArray(c, _e));
  137750. break
  137751. }
  137752. case VertexBuffer.UVKind:
  137753. case VertexBuffer.UV2Kind:
  137754. {
  137755. for (var et = e.verticesStart + e.verticesCount - 1; et >= e.verticesStart; --et)
  137756. _e = et * j,
  137757. $.push(Vector2.FromArray(c, _e));
  137758. break
  137759. }
  137760. default:
  137761. Tools.Error("Unsupported Vertex Buffer type: " + s)
  137762. }
  137763. this.writeVertexAttributeData($, d, s, c, _, b)
  137764. } else
  137765. Tools.Warn("reorderTriangleFanMode: Vertex buffer kind " + s + " not present!")
  137766. }
  137767. ,
  137768. a.prototype.writeVertexAttributeData = function(e, i, o, s, c, d) {
  137769. for (var _ = 0, b = e; _ < b.length; _++) {
  137770. var k = b[_];
  137771. d && o !== VertexBuffer.ColorKind && !(k instanceof Vector2) && (k instanceof Vector3 ? o === VertexBuffer.NormalKind ? _GLTFUtilities._GetRightHandedNormalVector3FromRef(k) : o === VertexBuffer.PositionKind ? _GLTFUtilities._GetRightHandedPositionVector3FromRef(k) : Tools.Error("Unsupported vertex attribute kind!") : _GLTFUtilities._GetRightHandedVector4FromRef(k)),
  137772. o === VertexBuffer.NormalKind ? k.normalize() : o === VertexBuffer.TangentKind && k instanceof Vector4 && _GLTFUtilities._NormalizeTangentFromRef(k);
  137773. for (var j = 0, $ = k.asArray(); j < $.length; j++) {
  137774. var _e = $[j];
  137775. c.setFloat32(_e, i),
  137776. i += 4
  137777. }
  137778. }
  137779. }
  137780. ,
  137781. a.prototype.writeAttributeData = function(e, i, o, s, c, d, _) {
  137782. var b = [], k;
  137783. switch (e) {
  137784. case VertexBuffer.PositionKind:
  137785. {
  137786. for (var j = 0, $ = o.length / s; j < $; ++j) {
  137787. k = j * s;
  137788. var _e = Vector3.FromArray(o, k);
  137789. d && _GLTFUtilities._GetRightHandedPositionVector3FromRef(_e),
  137790. b.push(_e.asArray())
  137791. }
  137792. break
  137793. }
  137794. case VertexBuffer.NormalKind:
  137795. {
  137796. for (var j = 0, et = o.length / s; j < et; ++j) {
  137797. k = j * s;
  137798. var _e = Vector3.FromArray(o, k);
  137799. d && _GLTFUtilities._GetRightHandedNormalVector3FromRef(_e),
  137800. _e.normalize(),
  137801. b.push(_e.asArray())
  137802. }
  137803. break
  137804. }
  137805. case VertexBuffer.TangentKind:
  137806. {
  137807. for (var j = 0, tt = o.length / s; j < tt; ++j) {
  137808. k = j * s;
  137809. var _e = Vector4.FromArray(o, k);
  137810. d && _GLTFUtilities._GetRightHandedVector4FromRef(_e),
  137811. _GLTFUtilities._NormalizeTangentFromRef(_e),
  137812. b.push(_e.asArray())
  137813. }
  137814. break
  137815. }
  137816. case VertexBuffer.ColorKind:
  137817. {
  137818. for (var rt = _.material, it = rt ? rt.getClassName() === "StandardMaterial" : !0, _e = s === 3 ? new Color3 : new Color4, j = 0, nt = o.length / s; j < nt; ++j)
  137819. k = j * s,
  137820. s === 3 ? (Color3.FromArrayToRef(o, k, _e),
  137821. it && _e.toLinearSpaceToRef(_e)) : (Color4.FromArrayToRef(o, k, _e),
  137822. it && _e.toLinearSpaceToRef(_e)),
  137823. b.push(_e.asArray());
  137824. break
  137825. }
  137826. case VertexBuffer.UVKind:
  137827. case VertexBuffer.UV2Kind:
  137828. {
  137829. for (var j = 0, ot = o.length / s; j < ot; ++j)
  137830. k = j * s,
  137831. b.push(d ? [o[k], o[k + 1]] : [o[k], o[k + 1]]);
  137832. break
  137833. }
  137834. case VertexBuffer.MatricesIndicesKind:
  137835. case VertexBuffer.MatricesIndicesExtraKind:
  137836. {
  137837. for (var j = 0, at = o.length / s; j < at; ++j) {
  137838. k = j * s;
  137839. var _e = Vector4.FromArray(o, k);
  137840. b.push(_e.asArray())
  137841. }
  137842. break
  137843. }
  137844. case VertexBuffer.MatricesWeightsKind:
  137845. case VertexBuffer.MatricesWeightsExtraKind:
  137846. {
  137847. for (var j = 0, st = o.length / s; j < st; ++j) {
  137848. k = j * s;
  137849. var _e = Vector4.FromArray(o, k);
  137850. b.push(_e.asArray())
  137851. }
  137852. break
  137853. }
  137854. default:
  137855. Tools.Warn("Unsupported Vertex Buffer Type: " + e),
  137856. b = []
  137857. }
  137858. var ut;
  137859. switch (i) {
  137860. case 5121:
  137861. {
  137862. ut = c.setUInt8.bind(c);
  137863. break
  137864. }
  137865. case 5123:
  137866. {
  137867. ut = c.setUInt16.bind(c);
  137868. break
  137869. }
  137870. case 5125:
  137871. ut = c.setUInt32.bind(c);
  137872. case 5126:
  137873. {
  137874. ut = c.setFloat32.bind(c);
  137875. break
  137876. }
  137877. default:
  137878. {
  137879. Tools.Warn("Unsupported Attribute Component kind: " + i);
  137880. return
  137881. }
  137882. }
  137883. for (var ct = 0, lt = b; ct < lt.length; ct++)
  137884. for (var ft = lt[ct], ht = 0, pt = ft; ht < pt.length; ht++) {
  137885. var dt = pt[ht];
  137886. ut(dt)
  137887. }
  137888. }
  137889. ,
  137890. a.prototype.writeMorphTargetAttributeData = function(e, i, o, s, c, d, _, b, k, j) {
  137891. var $ = [], _e, et = new Vector3, tt = new Vector4(0,0,0,0);
  137892. switch (e) {
  137893. case VertexBuffer.PositionKind:
  137894. {
  137895. for (var rt = o.verticesStart; rt < o.verticesCount; ++rt) {
  137896. _e = o.indexStart + rt * _;
  137897. var it = Vector3.FromArray(c, _e)
  137898. , nt = Vector3.FromArray(d, _e);
  137899. et = nt.subtractToRef(it, et),
  137900. k && _GLTFUtilities._GetRightHandedPositionVector3FromRef(et),
  137901. j && (j.min.copyFromFloats(Math.min(et.x, j.min.x), Math.min(et.y, j.min.y), Math.min(et.z, j.min.z)),
  137902. j.max.copyFromFloats(Math.max(et.x, j.max.x), Math.max(et.y, j.max.y), Math.max(et.z, j.max.z))),
  137903. $.push(et.asArray())
  137904. }
  137905. break
  137906. }
  137907. case VertexBuffer.NormalKind:
  137908. {
  137909. for (var rt = o.verticesStart; rt < o.verticesCount; ++rt) {
  137910. _e = o.indexStart + rt * _;
  137911. var it = Vector3.FromArray(c, _e);
  137912. it.normalize();
  137913. var nt = Vector3.FromArray(d, _e);
  137914. nt.normalize(),
  137915. et = nt.subtractToRef(it, et),
  137916. k && _GLTFUtilities._GetRightHandedNormalVector3FromRef(et),
  137917. $.push(et.asArray())
  137918. }
  137919. break
  137920. }
  137921. case VertexBuffer.TangentKind:
  137922. {
  137923. for (var rt = o.verticesStart; rt < o.verticesCount; ++rt) {
  137924. _e = o.indexStart + rt * (_ + 1);
  137925. var it = Vector4.FromArray(c, _e);
  137926. _GLTFUtilities._NormalizeTangentFromRef(it);
  137927. var nt = Vector4.FromArray(d, _e);
  137928. _GLTFUtilities._NormalizeTangentFromRef(nt),
  137929. tt = nt.subtractToRef(it, tt),
  137930. k && _GLTFUtilities._GetRightHandedVector4FromRef(tt),
  137931. $.push([tt.x, tt.y, tt.z])
  137932. }
  137933. break
  137934. }
  137935. default:
  137936. Tools.Warn("Unsupported Vertex Buffer Type: " + e),
  137937. $ = []
  137938. }
  137939. var ot;
  137940. switch (i) {
  137941. case 5121:
  137942. {
  137943. ot = b.setUInt8.bind(b);
  137944. break
  137945. }
  137946. case 5123:
  137947. {
  137948. ot = b.setUInt16.bind(b);
  137949. break
  137950. }
  137951. case 5125:
  137952. ot = b.setUInt32.bind(b);
  137953. case 5126:
  137954. {
  137955. ot = b.setFloat32.bind(b);
  137956. break
  137957. }
  137958. default:
  137959. {
  137960. Tools.Warn("Unsupported Attribute Component kind: " + i);
  137961. return
  137962. }
  137963. }
  137964. for (var at = 0, st = $; at < st.length; at++)
  137965. for (var ut = st[at], ct = 0, lt = ut; ct < lt.length; ct++) {
  137966. var ft = lt[ct];
  137967. ot(ft)
  137968. }
  137969. }
  137970. ,
  137971. a.prototype.generateJSON = function(e, i, o) {
  137972. var s = this, c = {
  137973. byteLength: this._totalByteLength
  137974. }, d, _, b, k = this._totalByteLength;
  137975. c.byteLength && (this._glTF.buffers = [c]),
  137976. this._nodes && this._nodes.length && (this._glTF.nodes = this._nodes),
  137977. this._meshes && this._meshes.length && (this._glTF.meshes = this._meshes),
  137978. this._scenes && this._scenes.length && (this._glTF.scenes = this._scenes,
  137979. this._glTF.scene = 0),
  137980. this._bufferViews && this._bufferViews.length && (this._glTF.bufferViews = this._bufferViews),
  137981. this._accessors && this._accessors.length && (this._glTF.accessors = this._accessors),
  137982. this._animations && this._animations.length && (this._glTF.animations = this._animations),
  137983. this._materials && this._materials.length && (this._glTF.materials = this._materials),
  137984. this._textures && this._textures.length && (this._glTF.textures = this._textures),
  137985. this._samplers && this._samplers.length && (this._glTF.samplers = this._samplers),
  137986. this._skins && this._skins.length && (this._glTF.skins = this._skins),
  137987. this._images && this._images.length && (e ? (this._glTF.images = [],
  137988. this._images.forEach(function($) {
  137989. $.uri && (_ = s._imageData[$.uri],
  137990. s._orderedImageData.push(_),
  137991. d = $.uri.split(".")[0] + " image",
  137992. b = _GLTFUtilities._CreateBufferView(0, k, _.data.length, void 0, d),
  137993. k += _.data.buffer.byteLength,
  137994. s._bufferViews.push(b),
  137995. $.bufferView = s._bufferViews.length - 1,
  137996. $.name = d,
  137997. $.mimeType = _.mimeType,
  137998. $.uri = void 0,
  137999. s._glTF.images || (s._glTF.images = []),
  138000. s._glTF.images.push($))
  138001. }),
  138002. c.byteLength = k) : this._glTF.images = this._images),
  138003. e || (c.uri = i + ".bin");
  138004. var j = o ? JSON.stringify(this._glTF, null, 2) : JSON.stringify(this._glTF);
  138005. return j
  138006. }
  138007. ,
  138008. a.prototype._generateGLTFAsync = function(e, i) {
  138009. var o = this;
  138010. return i === void 0 && (i = !0),
  138011. this._generateBinaryAsync().then(function(s) {
  138012. o._extensionsOnExporting();
  138013. var c = o.generateJSON(!1, e, !0)
  138014. , d = new Blob([s],{
  138015. type: "application/octet-stream"
  138016. })
  138017. , _ = e + ".gltf"
  138018. , b = e + ".bin"
  138019. , k = new GLTFData;
  138020. if (k.glTFFiles[_] = c,
  138021. k.glTFFiles[b] = d,
  138022. o._imageData)
  138023. for (var j in o._imageData)
  138024. k.glTFFiles[j] = new Blob([o._imageData[j].data],{
  138025. type: o._imageData[j].mimeType
  138026. });
  138027. return i && o.dispose(),
  138028. k
  138029. })
  138030. }
  138031. ,
  138032. a.prototype._generateBinaryAsync = function() {
  138033. var e = this
  138034. , i = new _BinaryWriter(4);
  138035. return this.createSceneAsync(this._babylonScene, i).then(function() {
  138036. return e._localEngine && e._localEngine.dispose(),
  138037. i.getArrayBuffer()
  138038. })
  138039. }
  138040. ,
  138041. a.prototype._getPadding = function(e) {
  138042. var i = e % 4
  138043. , o = i === 0 ? i : 4 - i;
  138044. return o
  138045. }
  138046. ,
  138047. a.prototype._generateGLBAsync = function(e, i) {
  138048. var o = this;
  138049. return i === void 0 && (i = !0),
  138050. this._generateBinaryAsync().then(function(s) {
  138051. o._extensionsOnExporting();
  138052. var c = o.generateJSON(!0), d = e + ".glb", _ = 12, b = 8, k = c.length, j, $ = 0;
  138053. if (typeof TextEncoder != "undefined") {
  138054. var _e = new TextEncoder;
  138055. j = _e.encode(c),
  138056. k = j.length
  138057. }
  138058. for (var et = 0; et < o._orderedImageData.length; ++et)
  138059. $ += o._orderedImageData[et].data.byteLength;
  138060. var tt = o._getPadding(k)
  138061. , rt = o._getPadding(s.byteLength)
  138062. , it = o._getPadding($)
  138063. , nt = _ + 2 * b + k + tt + s.byteLength + rt + $ + it
  138064. , ot = new ArrayBuffer(_)
  138065. , at = new DataView(ot);
  138066. at.setUint32(0, 1179937895, !0),
  138067. at.setUint32(4, 2, !0),
  138068. at.setUint32(8, nt, !0);
  138069. var st = new ArrayBuffer(b + k + tt)
  138070. , ut = new DataView(st);
  138071. ut.setUint32(0, k + tt, !0),
  138072. ut.setUint32(4, 1313821514, !0);
  138073. var ct = new Uint8Array(st,b);
  138074. if (j)
  138075. ct.set(j);
  138076. else
  138077. for (var lt = "_".charCodeAt(0), et = 0; et < k; ++et) {
  138078. var ft = c.charCodeAt(et);
  138079. ft != c.codePointAt(et) ? ct[et] = lt : ct[et] = ft
  138080. }
  138081. for (var ht = new Uint8Array(st,b + k), et = 0; et < tt; ++et)
  138082. ht[et] = 32;
  138083. var pt = new ArrayBuffer(b)
  138084. , dt = new DataView(pt);
  138085. dt.setUint32(0, s.byteLength + $ + it, !0),
  138086. dt.setUint32(4, 5130562, !0);
  138087. for (var _t = new ArrayBuffer(rt), mt = new Uint8Array(_t), et = 0; et < rt; ++et)
  138088. mt[et] = 0;
  138089. for (var vt = new ArrayBuffer(it), yt = new Uint8Array(vt), et = 0; et < it; ++et)
  138090. yt[et] = 0;
  138091. for (var Et = [ot, st, pt, s], et = 0; et < o._orderedImageData.length; ++et)
  138092. Et.push(o._orderedImageData[et].data.buffer);
  138093. Et.push(_t),
  138094. Et.push(vt);
  138095. var At = new Blob(Et,{
  138096. type: "application/octet-stream"
  138097. })
  138098. , gt = new GLTFData;
  138099. return gt.glTFFiles[d] = At,
  138100. o._localEngine != null && o._localEngine.dispose(),
  138101. i && o.dispose(),
  138102. gt
  138103. })
  138104. }
  138105. ,
  138106. a.prototype.setNodeTransformation = function(e, i, o) {
  138107. i.getPivotPoint().equalsToFloats(0, 0, 0) || Tools.Warn("Pivot points are not supported in the glTF serializer"),
  138108. i.position.equalsToFloats(0, 0, 0) || (e.translation = o ? _GLTFUtilities._GetRightHandedPositionVector3(i.position).asArray() : i.position.asArray()),
  138109. i.scaling.equalsToFloats(1, 1, 1) || (e.scale = i.scaling.asArray());
  138110. var s = Quaternion.RotationYawPitchRoll(i.rotation.y, i.rotation.x, i.rotation.z);
  138111. i.rotationQuaternion && s.multiplyInPlace(i.rotationQuaternion),
  138112. s.x === 0 && s.y === 0 && s.z === 0 && s.w === 1 || (o && _GLTFUtilities._GetRightHandedQuaternionFromRef(s),
  138113. e.rotation = s.normalize().asArray())
  138114. }
  138115. ,
  138116. a.prototype.getVertexBufferFromMesh = function(e, i) {
  138117. if (i.isVerticesDataPresent(e)) {
  138118. var o = i.getVertexBuffer(e);
  138119. if (o)
  138120. return o
  138121. }
  138122. return null
  138123. }
  138124. ,
  138125. a.prototype.createBufferViewKind = function(e, i, o, s, c, d) {
  138126. var _ = o instanceof Mesh ? o : o instanceof InstancedMesh ? o.sourceMesh : null;
  138127. if (_) {
  138128. var b = _.getVertexBuffer(e)
  138129. , k = _.getVerticesData(e);
  138130. if (b && k) {
  138131. var j = VertexBuffer.GetTypeByteLength(i)
  138132. , $ = k.length * j
  138133. , _e = _GLTFUtilities._CreateBufferView(0, s.getByteOffset(), $, c, e + " - " + _.name);
  138134. this._bufferViews.push(_e),
  138135. this.writeAttributeData(e, i, k, c / j, s, d, o)
  138136. }
  138137. }
  138138. }
  138139. ,
  138140. a.prototype.setMorphTargetAttributes = function(e, i, o, s, c) {
  138141. if (o) {
  138142. i.targets || (i.targets = []);
  138143. var d = {};
  138144. if (o.hasNormals) {
  138145. var _ = e.getMesh().getVerticesData(VertexBuffer.NormalKind)
  138146. , b = o.getNormals()
  138147. , k = e.verticesCount
  138148. , j = 12
  138149. , $ = k * j
  138150. , _e = _GLTFUtilities._CreateBufferView(0, s.getByteOffset(), $, j, o.name + "_NORMAL");
  138151. this._bufferViews.push(_e);
  138152. var et = this._bufferViews.length - 1
  138153. , tt = _GLTFUtilities._CreateAccessor(et, o.name + " - NORMAL", "VEC3", 5126, k, 0, null, null);
  138154. this._accessors.push(tt),
  138155. d.NORMAL = this._accessors.length - 1,
  138156. this.writeMorphTargetAttributeData(VertexBuffer.NormalKind, 5126, e, o, _, b, j / 4, s, c)
  138157. }
  138158. if (o.hasPositions) {
  138159. var rt = e.getMesh().getVerticesData(VertexBuffer.PositionKind)
  138160. , it = o.getPositions()
  138161. , k = e.verticesCount
  138162. , j = 12
  138163. , $ = k * j
  138164. , _e = _GLTFUtilities._CreateBufferView(0, s.getByteOffset(), $, j, o.name + "_POSITION");
  138165. this._bufferViews.push(_e);
  138166. var et = this._bufferViews.length - 1
  138167. , nt = {
  138168. min: new Vector3(1 / 0,1 / 0,1 / 0),
  138169. max: new Vector3(-1 / 0,-1 / 0,-1 / 0)
  138170. }
  138171. , tt = _GLTFUtilities._CreateAccessor(et, o.name + " - POSITION", "VEC3", 5126, k, 0, null, null);
  138172. this._accessors.push(tt),
  138173. d.POSITION = this._accessors.length - 1,
  138174. this.writeMorphTargetAttributeData(VertexBuffer.PositionKind, 5126, e, o, rt, it, j / 4, s, c, nt),
  138175. tt.min = nt.min.asArray(),
  138176. tt.max = nt.max.asArray()
  138177. }
  138178. if (o.hasTangents) {
  138179. var ot = e.getMesh().getVerticesData(VertexBuffer.TangentKind)
  138180. , at = o.getTangents()
  138181. , k = e.verticesCount
  138182. , j = 12
  138183. , $ = k * j
  138184. , _e = _GLTFUtilities._CreateBufferView(0, s.getByteOffset(), $, j, o.name + "_NORMAL");
  138185. this._bufferViews.push(_e);
  138186. var et = this._bufferViews.length - 1
  138187. , tt = _GLTFUtilities._CreateAccessor(et, o.name + " - TANGENT", "VEC3", 5126, k, 0, null, null);
  138188. this._accessors.push(tt),
  138189. d.TANGENT = this._accessors.length - 1,
  138190. this.writeMorphTargetAttributeData(VertexBuffer.TangentKind, 5126, e, o, ot, at, j / 4, s, c)
  138191. }
  138192. i.targets.push(d)
  138193. }
  138194. }
  138195. ,
  138196. a.prototype.getMeshPrimitiveMode = function(e) {
  138197. return e instanceof LinesMesh ? Material.LineListDrawMode : e.material ? e.material.fillMode : Material.TriangleFillMode
  138198. }
  138199. ,
  138200. a.prototype.setPrimitiveMode = function(e, i) {
  138201. switch (i) {
  138202. case Material.TriangleFillMode:
  138203. break;
  138204. case Material.TriangleStripDrawMode:
  138205. {
  138206. e.mode = 5;
  138207. break
  138208. }
  138209. case Material.TriangleFanDrawMode:
  138210. {
  138211. e.mode = 6;
  138212. break
  138213. }
  138214. case Material.PointListDrawMode:
  138215. e.mode = 0;
  138216. case Material.PointFillMode:
  138217. {
  138218. e.mode = 0;
  138219. break
  138220. }
  138221. case Material.LineLoopDrawMode:
  138222. {
  138223. e.mode = 2;
  138224. break
  138225. }
  138226. case Material.LineListDrawMode:
  138227. {
  138228. e.mode = 1;
  138229. break
  138230. }
  138231. case Material.LineStripDrawMode:
  138232. {
  138233. e.mode = 3;
  138234. break
  138235. }
  138236. }
  138237. }
  138238. ,
  138239. a.prototype.setAttributeKind = function(e, i) {
  138240. switch (i) {
  138241. case VertexBuffer.PositionKind:
  138242. {
  138243. e.attributes.POSITION = this._accessors.length - 1;
  138244. break
  138245. }
  138246. case VertexBuffer.NormalKind:
  138247. {
  138248. e.attributes.NORMAL = this._accessors.length - 1;
  138249. break
  138250. }
  138251. case VertexBuffer.ColorKind:
  138252. {
  138253. e.attributes.COLOR_0 = this._accessors.length - 1;
  138254. break
  138255. }
  138256. case VertexBuffer.TangentKind:
  138257. {
  138258. e.attributes.TANGENT = this._accessors.length - 1;
  138259. break
  138260. }
  138261. case VertexBuffer.UVKind:
  138262. {
  138263. e.attributes.TEXCOORD_0 = this._accessors.length - 1;
  138264. break
  138265. }
  138266. case VertexBuffer.UV2Kind:
  138267. {
  138268. e.attributes.TEXCOORD_1 = this._accessors.length - 1;
  138269. break
  138270. }
  138271. case VertexBuffer.MatricesIndicesKind:
  138272. {
  138273. e.attributes.JOINTS_0 = this._accessors.length - 1;
  138274. break
  138275. }
  138276. case VertexBuffer.MatricesIndicesExtraKind:
  138277. {
  138278. e.attributes.JOINTS_1 = this._accessors.length - 1;
  138279. break
  138280. }
  138281. case VertexBuffer.MatricesWeightsKind:
  138282. {
  138283. e.attributes.WEIGHTS_0 = this._accessors.length - 1;
  138284. break
  138285. }
  138286. case VertexBuffer.MatricesWeightsExtraKind:
  138287. {
  138288. e.attributes.WEIGHTS_1 = this._accessors.length - 1;
  138289. break
  138290. }
  138291. default:
  138292. Tools.Warn("Unsupported Vertex Buffer Type: " + i)
  138293. }
  138294. }
  138295. ,
  138296. a.prototype.setPrimitiveAttributesAsync = function(e, i, o, s) {
  138297. var c, d = [], _ = null, b, k;
  138298. i instanceof Mesh ? _ = i : i instanceof InstancedMesh && (_ = i.sourceMesh);
  138299. var j = [{
  138300. kind: VertexBuffer.PositionKind,
  138301. accessorType: "VEC3",
  138302. accessorComponentType: 5126,
  138303. byteStride: 12
  138304. }, {
  138305. kind: VertexBuffer.NormalKind,
  138306. accessorType: "VEC3",
  138307. accessorComponentType: 5126,
  138308. byteStride: 12
  138309. }, {
  138310. kind: VertexBuffer.ColorKind,
  138311. accessorType: "VEC4",
  138312. accessorComponentType: 5126,
  138313. byteStride: 16
  138314. }, {
  138315. kind: VertexBuffer.TangentKind,
  138316. accessorType: "VEC4",
  138317. accessorComponentType: 5126,
  138318. byteStride: 16
  138319. }, {
  138320. kind: VertexBuffer.UVKind,
  138321. accessorType: "VEC2",
  138322. accessorComponentType: 5126,
  138323. byteStride: 8
  138324. }, {
  138325. kind: VertexBuffer.UV2Kind,
  138326. accessorType: "VEC2",
  138327. accessorComponentType: 5126,
  138328. byteStride: 8
  138329. }, {
  138330. kind: VertexBuffer.MatricesIndicesKind,
  138331. accessorType: "VEC4",
  138332. accessorComponentType: 5123,
  138333. byteStride: 8
  138334. }, {
  138335. kind: VertexBuffer.MatricesIndicesExtraKind,
  138336. accessorType: "VEC4",
  138337. accessorComponentType: 5123,
  138338. byteStride: 8
  138339. }, {
  138340. kind: VertexBuffer.MatricesWeightsKind,
  138341. accessorType: "VEC4",
  138342. accessorComponentType: 5126,
  138343. byteStride: 16
  138344. }, {
  138345. kind: VertexBuffer.MatricesWeightsExtraKind,
  138346. accessorType: "VEC4",
  138347. accessorComponentType: 5126,
  138348. byteStride: 16
  138349. }];
  138350. if (_) {
  138351. for (var $ = null, _e = this.getMeshPrimitiveMode(_), et = {}, tt = _.morphTargetManager, rt = 0, it = j; rt < it.length; rt++) {
  138352. var nt = it[rt]
  138353. , ot = nt.kind
  138354. , at = nt.accessorComponentType;
  138355. if (_.isVerticesDataPresent(ot)) {
  138356. var st = this.getVertexBufferFromMesh(ot, _);
  138357. nt.byteStride = st ? st.getSize() * VertexBuffer.GetTypeByteLength(nt.accessorComponentType) : VertexBuffer.DeduceStride(ot) * 4,
  138358. nt.byteStride === 12 && (nt.accessorType = "VEC3"),
  138359. this.createBufferViewKind(ot, at, i, o, nt.byteStride, s),
  138360. nt.bufferViewIndex = this._bufferViews.length - 1,
  138361. et[ot] = nt.bufferViewIndex
  138362. }
  138363. }
  138364. if (_.getTotalIndices()) {
  138365. var ut = _.getIndices();
  138366. if (ut) {
  138367. var ct = ut.length * 4;
  138368. b = _GLTFUtilities._CreateBufferView(0, o.getByteOffset(), ct, void 0, "Indices - " + _.name),
  138369. this._bufferViews.push(b),
  138370. $ = this._bufferViews.length - 1;
  138371. for (var lt = 0, ft = ut.length; lt < ft; ++lt)
  138372. o.setUInt32(ut[lt])
  138373. }
  138374. }
  138375. if (_.subMeshes)
  138376. for (var ht = 0, pt = _.subMeshes; ht < pt.length; ht++) {
  138377. var dt = pt[ht]
  138378. , _t = dt.getMaterial() || _.getScene().defaultMaterial
  138379. , mt = null;
  138380. if (_t)
  138381. if (_ instanceof LinesMesh) {
  138382. var vt = {
  138383. name: _.name + " material"
  138384. };
  138385. (!_.color.equals(Color3.White()) || _.alpha < 1) && (vt.pbrMetallicRoughness = {
  138386. baseColorFactor: _.color.asArray().concat([_.alpha])
  138387. }),
  138388. this._materials.push(vt),
  138389. mt = this._materials.length - 1
  138390. } else if (_t.getClassName() === "MultiMaterial") {
  138391. var yt = _t.subMaterials[dt.materialIndex];
  138392. yt && (_t = yt,
  138393. mt = this._materialMap[_t.uniqueId])
  138394. } else
  138395. mt = this._materialMap[_t.uniqueId];
  138396. var Et = mt != null ? this._materials[mt] : null
  138397. , At = {
  138398. attributes: {}
  138399. };
  138400. this.setPrimitiveMode(At, _e);
  138401. for (var gt = 0, St = j; gt < St.length; gt++) {
  138402. var nt = St[gt]
  138403. , ot = nt.kind;
  138404. if (!((ot === VertexBuffer.UVKind || ot === VertexBuffer.UV2Kind) && !this._options.exportUnusedUVs && Et && !this._glTFMaterialExporter._hasTexturesPresent(Et))) {
  138405. var xt = _.getVerticesData(ot);
  138406. if (xt) {
  138407. var st = this.getVertexBufferFromMesh(ot, _);
  138408. if (st) {
  138409. var bt = st.getSize()
  138410. , Rt = nt.bufferViewIndex;
  138411. if (Rt != null) {
  138412. k = {
  138413. min: null,
  138414. max: null
  138415. },
  138416. ot == VertexBuffer.PositionKind && (k = _GLTFUtilities._CalculateMinMaxPositions(xt, 0, xt.length / bt, s));
  138417. var Mt = _GLTFUtilities._CreateAccessor(Rt, ot + " - " + i.name, nt.accessorType, nt.accessorComponentType, xt.length / bt, 0, k.min, k.max);
  138418. this._accessors.push(Mt),
  138419. this.setAttributeKind(At, ot)
  138420. }
  138421. }
  138422. }
  138423. }
  138424. }
  138425. if ($) {
  138426. var Mt = _GLTFUtilities._CreateAccessor($, "indices - " + i.name, "SCALAR", 5125, dt.indexCount, dt.indexStart * 4, null, null);
  138427. this._accessors.push(Mt),
  138428. At.indices = this._accessors.length - 1
  138429. }
  138430. if (mt != null && Object.keys(At.attributes).length > 0) {
  138431. var Pt = _.overrideMaterialSideOrientation !== null ? _.overrideMaterialSideOrientation : _t.sideOrientation;
  138432. if (Pt == Material.ClockWiseSideOrientation && this._babylonScene.useRightHandedSystem || Pt == Material.ClockWiseSideOrientation && s && _.overrideMaterialSideOrientation !== ((c = _.material) === null || c === void 0 ? void 0 : c.sideOrientation)) {
  138433. var It = $ != null ? this._bufferViews[$].byteOffset : null;
  138434. It == null && (It = 0);
  138435. var Dt = null;
  138436. if ($ != null && (Dt = _.getIndices()),
  138437. Dt)
  138438. this.reorderIndicesBasedOnPrimitiveMode(dt, _e, Dt, It, o);
  138439. else
  138440. for (var Ct = 0, Ot = j; Ct < Ot.length; Ct++) {
  138441. var nt = Ot[Ct]
  138442. , xt = _.getVerticesData(nt.kind);
  138443. if (xt) {
  138444. var wt = this._bufferViews[et[nt.kind]].byteOffset;
  138445. wt || (wt = 0),
  138446. this.reorderVertexAttributeDataBasedOnPrimitiveMode(dt, _e, Pt, nt.kind, xt, wt, o, s)
  138447. }
  138448. }
  138449. }
  138450. At.material = mt
  138451. }
  138452. if (tt)
  138453. for (var Nt = void 0, Ft = 0; Ft < tt.numTargets; ++Ft)
  138454. Nt = tt.getTarget(Ft),
  138455. this.setMorphTargetAttributes(dt, At, Nt, o, s);
  138456. e.primitives.push(At),
  138457. this._extensionsPostExportMeshPrimitiveAsync("postExport", At, dt, o),
  138458. d.push()
  138459. }
  138460. }
  138461. return Promise.all(d).then(function() {})
  138462. }
  138463. ,
  138464. a.prototype.isBabylonCoordinateSystemConvertingNode = function(e) {
  138465. if (e instanceof TransformNode) {
  138466. if (e.name !== "__root__")
  138467. return !1;
  138468. for (var i = e.getWorldMatrix(), o = Matrix.Compose(this._convertToRightHandedSystem ? new Vector3(-1,1,1) : Vector3.One(), Quaternion.Identity(), Vector3.Zero()), s = i.multiply(o), c = Matrix.IdentityReadOnly, d = 0; d < 16; d++)
  138469. if (Math.abs(s.m[d] - c.m[d]) > Epsilon)
  138470. return !1;
  138471. return !(e instanceof Mesh && e.geometry !== null || e instanceof InstancedMesh && e.sourceMesh.geometry !== null || this._includeCoordinateSystemConversionNodes)
  138472. }
  138473. return !1
  138474. }
  138475. ,
  138476. a.prototype.createSceneAsync = function(e, i) {
  138477. var o = this, s = {
  138478. nodes: []
  138479. }, c, d, _, b = __spreadArray(__spreadArray(__spreadArray([], e.transformNodes, !0), e.meshes, !0), e.lights, !0), k = [];
  138480. return this._convertToRightHandedSystem = !e.useRightHandedSystem,
  138481. this._convertToRightHandedSystemMap = {},
  138482. e.rootNodes.forEach(function(j) {
  138483. o._convertToRightHandedSystemMap[j.uniqueId] = o._convertToRightHandedSystem,
  138484. j.getDescendants(!1).forEach(function($) {
  138485. o._convertToRightHandedSystemMap[$.uniqueId] = o._convertToRightHandedSystem
  138486. })
  138487. }),
  138488. e.rootNodes.forEach(function(j) {
  138489. if (o.isBabylonCoordinateSystemConvertingNode(j)) {
  138490. k.push(j);
  138491. var $ = b.indexOf(j);
  138492. $ !== -1 && b.splice($, 1),
  138493. j.getDescendants(!1).forEach(function(_e) {
  138494. o._convertToRightHandedSystemMap[_e.uniqueId] = !1
  138495. })
  138496. }
  138497. }),
  138498. this._glTFMaterialExporter._convertMaterialsToGLTFAsync(e.materials, "image/png", !0).then(function() {
  138499. return o.createNodeMapAndAnimationsAsync(e, b, i).then(function(j) {
  138500. return o.createSkinsAsync(e, j, i).then(function($) {
  138501. if (o._nodeMap = j,
  138502. o._totalByteLength = i.getByteOffset(),
  138503. o._totalByteLength == null)
  138504. throw new Error("undefined byte length!");
  138505. for (var _e = 0, et = b; _e < et.length; _e++) {
  138506. var tt = et[_e];
  138507. if (c = o._nodeMap[tt.uniqueId],
  138508. c !== void 0) {
  138509. if (d = o._nodes[c],
  138510. tt.metadata && (o._options.metadataSelector ? d.extras = o._options.metadataSelector(tt.metadata) : tt.metadata.gltf && (d.extras = tt.metadata.gltf.extras)),
  138511. !tt.parent || k.indexOf(tt.parent) !== -1)
  138512. if (o._options.shouldExportNode && !o._options.shouldExportNode(tt))
  138513. Tools.Log("Omitting " + tt.name + " from scene.");
  138514. else {
  138515. var rt = o._convertToRightHandedSystemMap[tt.uniqueId];
  138516. rt && (d.translation && (d.translation[2] *= -1,
  138517. d.translation[0] *= -1),
  138518. d.rotation = d.rotation ? Quaternion.FromArray([0, 1, 0, 0]).multiply(Quaternion.FromArray(d.rotation)).asArray() : Quaternion.FromArray([0, 1, 0, 0]).asArray()),
  138519. s.nodes.push(c)
  138520. }
  138521. if (tt instanceof Mesh) {
  138522. var it = tt;
  138523. it.skeleton && (d.skin = $[it.skeleton.uniqueId])
  138524. }
  138525. if (_ = tt.getDescendants(!0),
  138526. !d.children && _ && _.length) {
  138527. for (var nt = [], ot = 0, at = _; ot < at.length; ot++) {
  138528. var st = at[ot];
  138529. o._nodeMap[st.uniqueId] != null && nt.push(o._nodeMap[st.uniqueId])
  138530. }
  138531. nt.length && (d.children = nt)
  138532. }
  138533. }
  138534. }
  138535. s.nodes.length && o._scenes.push(s)
  138536. })
  138537. })
  138538. })
  138539. }
  138540. ,
  138541. a.prototype.createNodeMapAndAnimationsAsync = function(e, i, o) {
  138542. for (var s = this, c = Promise.resolve(), d = {}, _, b = {
  138543. name: "runtime animations",
  138544. channels: [],
  138545. samplers: []
  138546. }, k = [], j = function(rt) {
  138547. !$._options.shouldExportNode || $._options.shouldExportNode(rt) ? c = c.then(function() {
  138548. var it = s._convertToRightHandedSystemMap[rt.uniqueId];
  138549. return s.createNodeAsync(rt, o, it, d).then(function(nt) {
  138550. var ot = s._extensionsPostExportNodeAsync("createNodeAsync", nt, rt, d);
  138551. return ot == null ? (Tools.Warn("Not exporting node " + rt.name),
  138552. Promise.resolve()) : ot.then(function(at) {
  138553. !at || (s._nodes.push(at),
  138554. _ = s._nodes.length - 1,
  138555. d[rt.uniqueId] = _,
  138556. e.animationGroups.length || (_GLTFAnimation._CreateMorphTargetAnimationFromMorphTargetAnimations(rt, b, k, d, s._nodes, o, s._bufferViews, s._accessors, it, s._animationSampleRate),
  138557. rt.animations.length && _GLTFAnimation._CreateNodeAnimationFromNodeAnimations(rt, b, k, d, s._nodes, o, s._bufferViews, s._accessors, it, s._animationSampleRate)))
  138558. })
  138559. })
  138560. }) : "" + rt.name
  138561. }, $ = this, _e = 0, et = i; _e < et.length; _e++) {
  138562. var tt = et[_e];
  138563. j(tt)
  138564. }
  138565. return c.then(function() {
  138566. return b.channels.length && b.samplers.length && s._animations.push(b),
  138567. k.forEach(function(rt) {
  138568. rt.channels.length && rt.samplers.length && s._animations.push(rt)
  138569. }),
  138570. e.animationGroups.length && _GLTFAnimation._CreateNodeAndMorphAnimationFromAnimationGroups(e, s._animations, d, s._nodes, o, s._bufferViews, s._accessors, s._convertToRightHandedSystemMap, s._animationSampleRate),
  138571. d
  138572. })
  138573. }
  138574. ,
  138575. a.prototype.createNodeAsync = function(e, i, o, s) {
  138576. var c = this;
  138577. return Promise.resolve().then(function() {
  138578. var d = {}
  138579. , _ = {
  138580. primitives: []
  138581. };
  138582. if (e.name && (d.name = e.name),
  138583. e instanceof TransformNode) {
  138584. if (c.setNodeTransformation(d, e, o),
  138585. e instanceof Mesh) {
  138586. var b = e.morphTargetManager;
  138587. if (b && b.numTargets > 0) {
  138588. _.weights = [];
  138589. for (var k = 0; k < b.numTargets; ++k)
  138590. _.weights.push(b.getTarget(k).influence)
  138591. }
  138592. }
  138593. return c.setPrimitiveAttributesAsync(_, e, i, o).then(function() {
  138594. return _.primitives.length && (c._meshes.push(_),
  138595. d.mesh = c._meshes.length - 1),
  138596. d
  138597. })
  138598. } else
  138599. return d
  138600. })
  138601. }
  138602. ,
  138603. a.prototype.createSkinsAsync = function(e, i, o) {
  138604. for (var s, c = Promise.resolve(), d = {}, _ = 0, b = e.skeletons; _ < b.length; _++) {
  138605. for (var k = b[_], j = {
  138606. joints: []
  138607. }, $ = [], _e = {}, et = -1, tt = 0; tt < k.bones.length; ++tt) {
  138608. var rt = k.bones[tt]
  138609. , it = (s = rt.getIndex()) !== null && s !== void 0 ? s : tt;
  138610. it !== -1 && (_e[it] = rt,
  138611. it > et && (et = it))
  138612. }
  138613. for (var it = 0; it <= et; ++it) {
  138614. var rt = _e[it];
  138615. $.push(rt.getInvertedAbsoluteTransform());
  138616. var nt = rt.getTransformNode();
  138617. nt ? j.joints.push(i[nt.uniqueId]) : Tools.Warn("Exporting a bone without a linked transform node is currently unsupported")
  138618. }
  138619. var ot = 64
  138620. , at = $.length * ot
  138621. , st = o.getByteOffset()
  138622. , ut = _GLTFUtilities._CreateBufferView(0, st, at, void 0, "InverseBindMatrices - " + k.name);
  138623. this._bufferViews.push(ut);
  138624. var ct = this._bufferViews.length - 1
  138625. , lt = _GLTFUtilities._CreateAccessor(ct, "InverseBindMatrices - " + k.name, "MAT4", 5126, $.length, null, null, null)
  138626. , ft = this._accessors.push(lt) - 1;
  138627. j.inverseBindMatrices = ft,
  138628. this._skins.push(j),
  138629. d[k.uniqueId] = this._skins.length - 1,
  138630. $.forEach(function(ht) {
  138631. ht.m.forEach(function(pt) {
  138632. o.setFloat32(pt)
  138633. })
  138634. })
  138635. }
  138636. return c.then(function() {
  138637. return d
  138638. })
  138639. }
  138640. ,
  138641. a._ExtensionNames = new Array,
  138642. a._ExtensionFactories = {},
  138643. a
  138644. }()
  138645. , _BinaryWriter = function() {
  138646. function a(e) {
  138647. this._arrayBuffer = new ArrayBuffer(e),
  138648. this._dataView = new DataView(this._arrayBuffer),
  138649. this._byteOffset = 0
  138650. }
  138651. return a.prototype.resizeBuffer = function(e) {
  138652. for (var i = new ArrayBuffer(e), o = new Uint8Array(this._arrayBuffer), s = new Uint8Array(i), c = 0, d = s.byteLength; c < d; ++c)
  138653. s[c] = o[c];
  138654. return this._arrayBuffer = i,
  138655. this._dataView = new DataView(this._arrayBuffer),
  138656. i
  138657. }
  138658. ,
  138659. a.prototype.getArrayBuffer = function() {
  138660. return this.resizeBuffer(this.getByteOffset())
  138661. }
  138662. ,
  138663. a.prototype.getByteOffset = function() {
  138664. if (this._byteOffset == null)
  138665. throw new Error("Byte offset is undefined!");
  138666. return this._byteOffset
  138667. }
  138668. ,
  138669. a.prototype.setUInt8 = function(e, i) {
  138670. i != null ? i < this._byteOffset ? this._dataView.setUint8(i, e) : Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!") : (this._byteOffset + 1 > this._arrayBuffer.byteLength && this.resizeBuffer(this._arrayBuffer.byteLength * 2),
  138671. this._dataView.setUint8(this._byteOffset, e),
  138672. this._byteOffset += 1)
  138673. }
  138674. ,
  138675. a.prototype.setUInt16 = function(e, i) {
  138676. i != null ? i < this._byteOffset ? this._dataView.setUint16(i, e, !0) : Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!") : (this._byteOffset + 2 > this._arrayBuffer.byteLength && this.resizeBuffer(this._arrayBuffer.byteLength * 2),
  138677. this._dataView.setUint16(this._byteOffset, e, !0),
  138678. this._byteOffset += 2)
  138679. }
  138680. ,
  138681. a.prototype.getUInt32 = function(e) {
  138682. if (e < this._byteOffset)
  138683. return this._dataView.getUint32(e, !0);
  138684. throw Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"),
  138685. new Error("BinaryWriter: byteoffset is greater than the current binary buffer length!")
  138686. }
  138687. ,
  138688. a.prototype.getVector3Float32FromRef = function(e, i) {
  138689. i + 8 > this._byteOffset ? Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!") : (e.x = this._dataView.getFloat32(i, !0),
  138690. e.y = this._dataView.getFloat32(i + 4, !0),
  138691. e.z = this._dataView.getFloat32(i + 8, !0))
  138692. }
  138693. ,
  138694. a.prototype.setVector3Float32FromRef = function(e, i) {
  138695. i + 8 > this._byteOffset ? Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!") : (this._dataView.setFloat32(i, e.x, !0),
  138696. this._dataView.setFloat32(i + 4, e.y, !0),
  138697. this._dataView.setFloat32(i + 8, e.z, !0))
  138698. }
  138699. ,
  138700. a.prototype.getVector4Float32FromRef = function(e, i) {
  138701. i + 12 > this._byteOffset ? Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!") : (e.x = this._dataView.getFloat32(i, !0),
  138702. e.y = this._dataView.getFloat32(i + 4, !0),
  138703. e.z = this._dataView.getFloat32(i + 8, !0),
  138704. e.w = this._dataView.getFloat32(i + 12, !0))
  138705. }
  138706. ,
  138707. a.prototype.setVector4Float32FromRef = function(e, i) {
  138708. i + 12 > this._byteOffset ? Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!") : (this._dataView.setFloat32(i, e.x, !0),
  138709. this._dataView.setFloat32(i + 4, e.y, !0),
  138710. this._dataView.setFloat32(i + 8, e.z, !0),
  138711. this._dataView.setFloat32(i + 12, e.w, !0))
  138712. }
  138713. ,
  138714. a.prototype.setFloat32 = function(e, i) {
  138715. isNaN(e) && Tools.Error("Invalid data being written!"),
  138716. i != null && (i < this._byteOffset ? this._dataView.setFloat32(i, e, !0) : Tools.Error("BinaryWriter: byteoffset is greater than the current binary length!")),
  138717. this._byteOffset + 4 > this._arrayBuffer.byteLength && this.resizeBuffer(this._arrayBuffer.byteLength * 2),
  138718. this._dataView.setFloat32(this._byteOffset, e, !0),
  138719. this._byteOffset += 4
  138720. }
  138721. ,
  138722. a.prototype.setUInt32 = function(e, i) {
  138723. i != null ? i < this._byteOffset ? this._dataView.setUint32(i, e, !0) : Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!") : (this._byteOffset + 4 > this._arrayBuffer.byteLength && this.resizeBuffer(this._arrayBuffer.byteLength * 2),
  138724. this._dataView.setUint32(this._byteOffset, e, !0),
  138725. this._byteOffset += 4)
  138726. }
  138727. ,
  138728. a
  138729. }()
  138730. , name = "textureTransformPixelShader"
  138731. , shader = `precision highp float;
  138732. varying vec2 vUV;
  138733. uniform sampler2D textureSampler;
  138734. uniform mat4 textureTransformMat;
  138735. void main(void) {
  138736. vec2 uvTransformed=(textureTransformMat*vec4(vUV.xy,1,1)).xy;
  138737. gl_FragColor=texture2D(textureSampler,uvTransformed);
  138738. }`;
  138739. ShaderStore.ShadersStore[name] = shader;
  138740. var NAME$4 = "KHR_texture_transform"
  138741. , KHR_texture_transform = function() {
  138742. function a(e) {
  138743. this._recordedTextures = [],
  138744. this.name = NAME$4,
  138745. this.enabled = !0,
  138746. this.required = !1,
  138747. this._wasUsed = !1
  138748. }
  138749. return a.prototype.dispose = function() {
  138750. for (var e = 0, i = this._recordedTextures; e < i.length; e++) {
  138751. var o = i[e];
  138752. o.dispose()
  138753. }
  138754. }
  138755. ,
  138756. Object.defineProperty(a.prototype, "wasUsed", {
  138757. get: function() {
  138758. return this._wasUsed
  138759. },
  138760. enumerable: !1,
  138761. configurable: !0
  138762. }),
  138763. a.prototype.postExportTexture = function(e, i, o) {
  138764. var s = o && (o.uAng === 0 && o.wAng === 0 && o.vAng === 0 || o.uRotationCenter === 0 && o.vRotationCenter === 0);
  138765. if (s) {
  138766. var c = {}
  138767. , d = !1;
  138768. if ((o.uOffset !== 0 || o.vOffset !== 0) && (c.offset = [o.uOffset, o.vOffset],
  138769. d = !0),
  138770. (o.uScale !== 1 || o.vScale !== 1) && (c.scale = [o.uScale, o.vScale],
  138771. d = !0),
  138772. o.wAng !== 0 && (c.rotation = o.wAng,
  138773. d = !0),
  138774. o.coordinatesIndex !== 0 && (c.texCoord = o.coordinatesIndex,
  138775. d = !0),
  138776. !d)
  138777. return;
  138778. this._wasUsed = !0,
  138779. i.extensions || (i.extensions = {}),
  138780. i.extensions[NAME$4] = c
  138781. }
  138782. }
  138783. ,
  138784. a.prototype.preExportTextureAsync = function(e, i, o) {
  138785. var s = this;
  138786. return new Promise(function(c, d) {
  138787. var _ = i.getScene();
  138788. if (!_) {
  138789. d(e + ': "scene" is not defined for Babylon texture ' + i.name + "!");
  138790. return
  138791. }
  138792. var b = !1;
  138793. if ((i.uAng !== 0 || i.wAng !== 0 || i.vAng !== 0) && (i.uRotationCenter !== 0 || i.vRotationCenter !== 0) && (b = !0),
  138794. !b) {
  138795. c(i);
  138796. return
  138797. }
  138798. return s._textureTransformTextureAsync(i, _).then(function(k) {
  138799. c(k)
  138800. }).catch(function(k) {
  138801. d(k)
  138802. })
  138803. }
  138804. )
  138805. }
  138806. ,
  138807. a.prototype._textureTransformTextureAsync = function(e, i) {
  138808. var o = this;
  138809. return new Promise(function(s) {
  138810. var c = new ProceduralTexture("" + e.name,e.getSize(),"textureTransform",i);
  138811. c || (Tools.Log("Cannot create procedural texture for " + e.name + "!"),
  138812. s(e)),
  138813. c.reservedDataStore = {
  138814. hidden: !0,
  138815. source: e
  138816. },
  138817. o._recordedTextures.push(c),
  138818. c.coordinatesIndex = e.coordinatesIndex,
  138819. c.setTexture("textureSampler", e),
  138820. c.setMatrix("textureTransformMat", e.getTextureMatrix()),
  138821. c.isReady() ? (c.render(),
  138822. s(c)) : c.getEffect().executeWhenCompiled(function() {
  138823. c.render(),
  138824. s(c)
  138825. })
  138826. }
  138827. )
  138828. }
  138829. ,
  138830. a
  138831. }();
  138832. _Exporter.RegisterExtension(NAME$4, function(a) {
  138833. return new KHR_texture_transform(a)
  138834. });
  138835. var NAME$3 = "KHR_lights_punctual"
  138836. , KHR_lights_punctual = function() {
  138837. function a(e) {
  138838. this.name = NAME$3,
  138839. this.enabled = !0,
  138840. this.required = !1,
  138841. this._exporter = e
  138842. }
  138843. return a.prototype.dispose = function() {
  138844. this._lights = null
  138845. }
  138846. ,
  138847. Object.defineProperty(a.prototype, "wasUsed", {
  138848. get: function() {
  138849. return !!this._lights
  138850. },
  138851. enumerable: !1,
  138852. configurable: !0
  138853. }),
  138854. a.prototype.onExporting = function() {
  138855. this._exporter._glTF.extensions[NAME$3] = this._lights
  138856. }
  138857. ,
  138858. a.prototype.postExportNodeAsync = function(e, i, o, s) {
  138859. var c = this;
  138860. return new Promise(function(d, _) {
  138861. if (i && o instanceof ShadowLight) {
  138862. var b = o
  138863. , k = void 0
  138864. , j = b.getTypeID() == Light.LIGHTTYPEID_POINTLIGHT ? "point" : b.getTypeID() == Light.LIGHTTYPEID_DIRECTIONALLIGHT ? "directional" : b.getTypeID() == Light.LIGHTTYPEID_SPOTLIGHT ? "spot" : null;
  138865. if (j == null)
  138866. Logger$2.Warn(e + ": Light " + b.name + " is not supported in " + NAME$3);
  138867. else {
  138868. var $ = b.position.clone()
  138869. , _e = c._exporter._convertToRightHandedSystemMap[o.uniqueId];
  138870. if ($.equals(Vector3.Zero()) || (_e && _GLTFUtilities._GetRightHandedPositionVector3FromRef($),
  138871. i.translation = $.asArray()),
  138872. j !== "point") {
  138873. var et = b.direction
  138874. , tt = -Math.atan2(et.z * (c._exporter._babylonScene.useRightHandedSystem ? -1 : 1), et.x) + Math.PI / 2
  138875. , rt = Math.sqrt(et.x * et.x + et.z * et.z)
  138876. , it = -Math.atan2(et.y, rt)
  138877. , nt = Quaternion.RotationYawPitchRoll(tt, it, 0);
  138878. _e && _GLTFUtilities._GetRightHandedQuaternionFromRef(nt),
  138879. nt.equals(Quaternion.Identity()) || (i.rotation = nt.asArray())
  138880. }
  138881. if (b.falloffType !== Light.FALLOFF_GLTF && Logger$2.Warn(e + ": Light falloff for " + b.name + " does not match the " + NAME$3 + " specification!"),
  138882. k = {
  138883. type: j
  138884. },
  138885. b.diffuse.equals(Color3.White()) || (k.color = b.diffuse.asArray()),
  138886. b.intensity !== 1 && (k.intensity = b.intensity),
  138887. b.range !== Number.MAX_VALUE && (k.range = b.range),
  138888. j === "spot") {
  138889. var ot = b;
  138890. ot.angle !== Math.PI / 2 && (k.spot == null && (k.spot = {}),
  138891. k.spot.outerConeAngle = ot.angle / 2),
  138892. ot.innerAngle !== 0 && (k.spot == null && (k.spot = {}),
  138893. k.spot.innerConeAngle = ot.innerAngle / 2)
  138894. }
  138895. c._lights == null && (c._lights = {
  138896. lights: []
  138897. }),
  138898. c._lights.lights.push(k);
  138899. var at = {
  138900. light: c._lights.lights.length - 1
  138901. }
  138902. , st = o.parent;
  138903. if (st && st.getChildren().length == 1) {
  138904. var ut = c._exporter._nodes[s[st.uniqueId]];
  138905. if (ut) {
  138906. var ct = TmpVectors.Matrix[0]
  138907. , lt = TmpVectors.Matrix[1]
  138908. , ft = ut.translation ? new Vector3(ut.translation[0],ut.translation[1],ut.translation[2]) : Vector3.Zero()
  138909. , ht = ut.rotation ? new Quaternion(ut.rotation[0],ut.rotation[1],ut.rotation[2],ut.rotation[3]) : Quaternion.Identity()
  138910. , pt = ut.scale ? new Vector3(ut.scale[0],ut.scale[1],ut.scale[2]) : Vector3.One();
  138911. Matrix.ComposeToRef(pt, ht, ft, ct),
  138912. ct.invertToRef(lt);
  138913. var dt = TmpVectors.Matrix[2]
  138914. , _t = i.translation ? new Vector3(i.translation[0],i.translation[1],i.translation[2]) : Vector3.Zero();
  138915. b instanceof DirectionalLight && _t.subtractInPlace(c._exporter._babylonScene.useRightHandedSystem ? b.direction : _GLTFUtilities._GetRightHandedPositionVector3(b.direction));
  138916. var mt = c._exporter._babylonScene.useRightHandedSystem ? Quaternion.Identity() : new Quaternion(0,1,0,0);
  138917. i.rotation && mt.multiplyInPlace(new Quaternion(i.rotation[0],i.rotation[1],i.rotation[2],i.rotation[3]));
  138918. var vt = i.scale ? new Vector3(i.scale[0],i.scale[1],i.scale[2]) : Vector3.One();
  138919. Matrix.ComposeToRef(vt, mt, _t, dt),
  138920. dt.multiplyToRef(lt, dt);
  138921. var yt = TmpVectors.Vector3[0]
  138922. , Et = TmpVectors.Quaternion[0]
  138923. , At = TmpVectors.Vector3[1];
  138924. dt.decompose(yt, Et, At),
  138925. ut.scale = yt.asArray(),
  138926. ut.rotation = Et.asArray(),
  138927. ut.translation = At.asArray(),
  138928. ut.extensions == null && (ut.extensions = {}),
  138929. ut.extensions[NAME$3] = at,
  138930. d(null);
  138931. return
  138932. }
  138933. }
  138934. i.extensions == null && (i.extensions = {}),
  138935. i.extensions[NAME$3] = at
  138936. }
  138937. }
  138938. d(i)
  138939. }
  138940. )
  138941. }
  138942. ,
  138943. a
  138944. }();
  138945. _Exporter.RegisterExtension(NAME$3, function(a) {
  138946. return new KHR_lights_punctual(a)
  138947. });
  138948. var NAME$2 = "KHR_materials_clearcoat"
  138949. , KHR_materials_clearcoat = function() {
  138950. function a(e) {
  138951. this.name = NAME$2,
  138952. this.enabled = !0,
  138953. this.required = !1,
  138954. this._wasUsed = !1,
  138955. this._exporter = e
  138956. }
  138957. return a.prototype.dispose = function() {}
  138958. ,
  138959. Object.defineProperty(a.prototype, "wasUsed", {
  138960. get: function() {
  138961. return this._wasUsed
  138962. },
  138963. enumerable: !1,
  138964. configurable: !0
  138965. }),
  138966. a.prototype.postExportMaterialAdditionalTextures = function(e, i, o) {
  138967. var s = [];
  138968. return o instanceof PBRBaseMaterial && o.clearCoat.isEnabled ? (o.clearCoat.texture && s.push(o.clearCoat.texture),
  138969. !o.clearCoat.useRoughnessFromMainTexture && o.clearCoat.textureRoughness && s.push(o.clearCoat.textureRoughness),
  138970. o.clearCoat.bumpTexture && s.push(o.clearCoat.bumpTexture),
  138971. s) : []
  138972. }
  138973. ,
  138974. a.prototype.postExportMaterialAsync = function(e, i, o) {
  138975. var s = this;
  138976. return new Promise(function(c, d) {
  138977. if (o instanceof PBRBaseMaterial) {
  138978. if (!o.clearCoat.isEnabled) {
  138979. c(i);
  138980. return
  138981. }
  138982. s._wasUsed = !0,
  138983. i.extensions = i.extensions || {};
  138984. var _ = s._exporter._glTFMaterialExporter._getTextureInfo(o.clearCoat.texture)
  138985. , b = void 0;
  138986. o.clearCoat.useRoughnessFromMainTexture ? b = s._exporter._glTFMaterialExporter._getTextureInfo(o.clearCoat.texture) : b = s._exporter._glTFMaterialExporter._getTextureInfo(o.clearCoat.textureRoughness),
  138987. o.clearCoat.isTintEnabled && Tools.Warn("Clear Color tint is not supported for glTF export. Ignoring for: " + o.name),
  138988. o.clearCoat.remapF0OnInterfaceChange && Tools.Warn("Clear Color F0 remapping is not supported for glTF export. Ignoring for: " + o.name);
  138989. var k = s._exporter._glTFMaterialExporter._getTextureInfo(o.clearCoat.bumpTexture)
  138990. , j = {
  138991. clearcoatFactor: o.clearCoat.intensity,
  138992. clearcoatTexture: _ != null ? _ : void 0,
  138993. clearcoatRoughnessFactor: o.clearCoat.roughness,
  138994. clearcoatRoughnessTexture: b != null ? b : void 0,
  138995. clearcoatNormalTexture: k != null ? k : void 0,
  138996. hasTextures: function() {
  138997. return j.clearcoatTexture !== null || j.clearcoatRoughnessTexture !== null || j.clearcoatRoughnessTexture !== null
  138998. }
  138999. };
  139000. i.extensions[NAME$2] = j
  139001. }
  139002. c(i)
  139003. }
  139004. )
  139005. }
  139006. ,
  139007. a
  139008. }();
  139009. _Exporter.RegisterExtension(NAME$2, function(a) {
  139010. return new KHR_materials_clearcoat(a)
  139011. });
  139012. var NAME$1 = "KHR_materials_sheen"
  139013. , KHR_materials_sheen = function() {
  139014. function a(e) {
  139015. this.name = NAME$1,
  139016. this.enabled = !0,
  139017. this.required = !1,
  139018. this._wasUsed = !1,
  139019. this._exporter = e
  139020. }
  139021. return a.prototype.dispose = function() {}
  139022. ,
  139023. Object.defineProperty(a.prototype, "wasUsed", {
  139024. get: function() {
  139025. return this._wasUsed
  139026. },
  139027. enumerable: !1,
  139028. configurable: !0
  139029. }),
  139030. a.prototype.postExportMaterialAdditionalTextures = function(e, i, o) {
  139031. return o instanceof PBRMaterial && o.sheen.isEnabled && o.sheen.texture ? [o.sheen.texture] : []
  139032. }
  139033. ,
  139034. a.prototype.postExportMaterialAsync = function(e, i, o) {
  139035. var s = this;
  139036. return new Promise(function(c, d) {
  139037. var _, b, k, j;
  139038. if (o instanceof PBRMaterial) {
  139039. if (!o.sheen.isEnabled) {
  139040. c(i);
  139041. return
  139042. }
  139043. s._wasUsed = !0,
  139044. i.extensions == null && (i.extensions = {});
  139045. var $ = {
  139046. sheenColorFactor: o.sheen.color.asArray(),
  139047. sheenRoughnessFactor: (_ = o.sheen.roughness) !== null && _ !== void 0 ? _ : 0,
  139048. hasTextures: function() {
  139049. return $.sheenColorTexture !== null || $.sheenRoughnessTexture !== null
  139050. }
  139051. };
  139052. o.sheen.texture && ($.sheenColorTexture = (b = s._exporter._glTFMaterialExporter._getTextureInfo(o.sheen.texture)) !== null && b !== void 0 ? b : void 0),
  139053. o.sheen.textureRoughness && !o.sheen.useRoughnessFromMainTexture ? $.sheenRoughnessTexture = (k = s._exporter._glTFMaterialExporter._getTextureInfo(o.sheen.textureRoughness)) !== null && k !== void 0 ? k : void 0 : o.sheen.texture && o.sheen.useRoughnessFromMainTexture && ($.sheenRoughnessTexture = (j = s._exporter._glTFMaterialExporter._getTextureInfo(o.sheen.texture)) !== null && j !== void 0 ? j : void 0),
  139054. i.extensions[NAME$1] = $
  139055. }
  139056. c(i)
  139057. }
  139058. )
  139059. }
  139060. ,
  139061. a
  139062. }();
  139063. _Exporter.RegisterExtension(NAME$1, function(a) {
  139064. return new KHR_materials_sheen(a)
  139065. });
  139066. var NAME = "KHR_materials_unlit"
  139067. , KHR_materials_unlit = function() {
  139068. function a(e) {
  139069. this.name = NAME,
  139070. this.enabled = !0,
  139071. this.required = !1,
  139072. this._wasUsed = !1
  139073. }
  139074. return Object.defineProperty(a.prototype, "wasUsed", {
  139075. get: function() {
  139076. return this._wasUsed
  139077. },
  139078. enumerable: !1,
  139079. configurable: !0
  139080. }),
  139081. a.prototype.dispose = function() {}
  139082. ,
  139083. a.prototype.postExportMaterialAsync = function(e, i, o) {
  139084. var s = this;
  139085. return new Promise(function(c, d) {
  139086. var _ = !1;
  139087. o instanceof PBRMaterial ? _ = o.unlit : o instanceof StandardMaterial && (_ = o.disableLighting),
  139088. _ && (s._wasUsed = !0,
  139089. i.extensions == null && (i.extensions = {}),
  139090. i.extensions[NAME] = {}),
  139091. c(i)
  139092. }
  139093. )
  139094. }
  139095. ,
  139096. a
  139097. }();
  139098. _Exporter.RegisterExtension(NAME, function(a) {
  139099. return new KHR_materials_unlit(a)
  139100. });
  139101. new Logger$1("XPackage");
  139102. function LoadXObject(a, e) {
  139103. return new Promise((i,o)=>{
  139104. const s = JSON.parse(e);
  139105. new XArchive().deserialize(s, a).then(d=>{
  139106. i(d)
  139107. }
  139108. ).catch(d=>{
  139109. o(d)
  139110. }
  139111. )
  139112. }
  139113. )
  139114. }
  139115. const log$K = new Logger$1("AvatarManager");
  139116. class XAvatarLoader {
  139117. constructor() {
  139118. this.containers = new Map,
  139119. this.meshes = new Map,
  139120. this.animations = new Map,
  139121. this.aniPath = new Map,
  139122. this.binPath = new Map,
  139123. this.texPath = new Map,
  139124. this.matPath = new Map,
  139125. this.mshPath = new Map,
  139126. this.rootPath = new Map,
  139127. this.meshTexList = new Map,
  139128. this._enableIdb = !0,
  139129. this._mappings = new Map,
  139130. this._sharedTex = new Map,
  139131. this.avaliableAnimation = new Map,
  139132. this.enableShareTexture = !0,
  139133. this.enableShareAnimation = !0,
  139134. this.fillEmptyLod = !0,
  139135. this.pendantMap = new Map;
  139136. const e = new GLTFFileLoader;
  139137. SceneLoader.RegisterPlugin(e),
  139138. e.preprocessUrlAsync = function(i) {
  139139. const o = avatarLoader._mappings.get(i);
  139140. return o ? Promise.resolve(o) : Promise.resolve(i)
  139141. }
  139142. }
  139143. _parsePendant(e, i) {
  139144. if (!e || !i) {
  139145. log$K.error("[Engine] invalid id or url when loading pendant");
  139146. return
  139147. }
  139148. const o = ".zip"
  139149. , s = i.replace(o, "/");
  139150. this.pendantMap.set(e, s)
  139151. }
  139152. pullAndLoadXObject(e, i) {
  139153. const o = avatarLoader.pendantMap.get(i);
  139154. return Tools.LoadFileAsync(o + `${i}.json`, !1).then(s=>{
  139155. if (!(s instanceof ArrayBuffer))
  139156. return LoadXObject(o, s).then(c=>c)
  139157. }
  139158. )
  139159. }
  139160. getParsedUrl(e, i, o, s="") {
  139161. return new Promise((c,d)=>{
  139162. if (!o || o.indexOf(".zip") === -1)
  139163. return c(o);
  139164. const _ = this.rootPath.get(o);
  139165. if (_)
  139166. return c(_);
  139167. {
  139168. const b = ".zip"
  139169. , k = o.replace(b, "") + COMPONENT_LIST_PREFIX;
  139170. e.urlTransformer(k, !0).then(j=>{
  139171. if (!j)
  139172. return d("Loading Failed");
  139173. new Response(j).json().then($=>{
  139174. var tt, rt, it, nt, ot, at, st;
  139175. const _e = o.replace(b, "")
  139176. , et = _e + ((tt = $ == null ? void 0 : $.components) == null ? void 0 : tt.url.replace("./", ""));
  139177. if (this.rootPath.set(o, et),
  139178. $.components ? ($.components.url && this.mshPath.set(i, _e + "/" + ((rt = $ == null ? void 0 : $.components) == null ? void 0 : rt.url.replace("./", ""))),
  139179. $.components.url_lod2 && this.mshPath.set(i + "_" + avatarSetting.lod[1].level, _e + "/" + ((it = $ == null ? void 0 : $.components) == null ? void 0 : it.url_lod2.replace("./", ""))),
  139180. $.components.url_lod4 && this.mshPath.set(i + "_" + avatarSetting.lod[2].level, _e + "/" + ((nt = $ == null ? void 0 : $.components) == null ? void 0 : nt.url_lod4.replace("./", "")))) : ($.meshes.url && this.mshPath.set(i, _e + "/" + ((ot = $ == null ? void 0 : $.meshes) == null ? void 0 : ot.url.replace("./", ""))),
  139181. $.meshes.url_lod2 && this.mshPath.set(i + "_" + avatarSetting.lod[1].level, _e + "/" + ((at = $ == null ? void 0 : $.meshes) == null ? void 0 : at.url_lod2.replace("./", ""))),
  139182. $.meshes.url_lod4 && this.mshPath.set(i + "_" + avatarSetting.lod[2].level, _e + "/" + ((st = $ == null ? void 0 : $.meshes) == null ? void 0 : st.url_lod4.replace("./", "")))),
  139183. $.materials && $.materials.forEach(ut=>{
  139184. const ct = _e + "/" + ut.url;
  139185. this.matPath.set(ut.name, ct)
  139186. }
  139187. ),
  139188. $.bin) {
  139189. const ut = _e + "/" + $.bin.url;
  139190. this.binPath.set(i, ut);
  139191. const ct = _e + "/" + $.bin.url_lod2;
  139192. this.binPath.set(i + "_" + avatarSetting.lod[1].level, ct);
  139193. const lt = _e + "/" + $.bin.url_lod4;
  139194. this.binPath.set(i + "_" + avatarSetting.lod[2].level, lt)
  139195. }
  139196. return $.textures && $.textures.forEach(ut=>{
  139197. const ct = _e + "/" + ut.url;
  139198. this.texPath.set(ut.url, ct);
  139199. const lt = this.meshTexList.get($.components.url);
  139200. ut.type === "png" && (lt ? lt.find(ft=>ft === ut.name) || lt.push(ut.url) : this.meshTexList.set(i, [ut.name]))
  139201. }
  139202. ),
  139203. c(et)
  139204. }
  139205. ).catch($=>{
  139206. d(`[Engine] parse json file error,${$}`)
  139207. }
  139208. )
  139209. }
  139210. ).catch(j=>{
  139211. d(`[Engine] ulrtransform error, cannot find resource in db,${j}`)
  139212. }
  139213. )
  139214. }
  139215. }
  139216. )
  139217. }
  139218. async parse(e, i) {
  139219. const o = [];
  139220. i.forEach(s=>{
  139221. this._setAnimationList(s.id, s.animations),
  139222. o.push(this.getParsedUrl(e, s.id, s.url)),
  139223. s.components.forEach(c=>{
  139224. c.name === "pendant" ? c.units.forEach(d=>{
  139225. this._parsePendant(d.id, d.url)
  139226. }
  139227. ) : c.units.forEach(d=>{
  139228. o.push(this.getParsedUrl(e, d.name, d.url))
  139229. }
  139230. )
  139231. }
  139232. )
  139233. }
  139234. ),
  139235. await Promise.all(o)
  139236. }
  139237. _setAnimationList(e, i) {
  139238. i ? i.forEach(o=>{
  139239. this.aniPath.set(e + "_" + o.name, o.url)
  139240. }
  139241. ) : log$K.error("[Engine] no animation list exist, please check config for details")
  139242. }
  139243. disposeContainer() {
  139244. const e = [];
  139245. this.containers.forEach((i,o)=>{
  139246. if (i.xReferenceCount < 1) {
  139247. if (this.enableShareTexture && i.textures.length > 0) {
  139248. for (let s = 0; s < i.textures.length; ++s)
  139249. i.textures[s].xReferenceCount != null ? i.textures[s].xReferenceCount-- : i.textures[s].xReferenceCount = 0,
  139250. i.textures[s]._parentContainer = null;
  139251. i.textures = []
  139252. }
  139253. e.push(o)
  139254. }
  139255. }
  139256. ),
  139257. e.forEach(i=>{
  139258. var o, s;
  139259. (o = this.containers.get(i)) == null || o.removeAllFromScene(),
  139260. (s = this.containers.get(i)) == null || s.dispose(),
  139261. this.containers.delete(i)
  139262. }
  139263. ),
  139264. this._sharedTex.forEach((i,o)=>{
  139265. i.xReferenceCount == 0 && (i.dispose(),
  139266. this._sharedTex.delete(o))
  139267. }
  139268. )
  139269. }
  139270. set enableIdb(e) {
  139271. this._enableIdb = e
  139272. }
  139273. getGlbPath(e) {
  139274. return this.aniPath.get(e + ".glb")
  139275. }
  139276. getGltfPath(e) {
  139277. return this.mshPath.get(e + ".gltf")
  139278. }
  139279. getPngUrl(e) {
  139280. return this.texPath.get(e + ".png")
  139281. }
  139282. getMeshUrl(e) {
  139283. return this.mshPath.get(e)
  139284. }
  139285. _getSourceKey(e, i) {
  139286. return i && avatarSetting.lod[i] ? e + avatarSetting.lod[i].fileName.split(".")[0] : e
  139287. }
  139288. _getAnimPath(e, i) {
  139289. let o = this.aniPath.get(i + "_animations_" + i.split("_")[1]);
  139290. return o || (o = this.aniPath.get(i + "_" + e)),
  139291. o
  139292. }
  139293. load(e, i, o, s) {
  139294. return this.loadGlb(e, i, o).then(c=>c || Promise.reject("[Engine] container load failed")).catch(()=>Promise.reject("[Engine] container load failed"))
  139295. }
  139296. _searchAnimation(e, i) {
  139297. let o;
  139298. return this.containers.forEach((s,c)=>{
  139299. const d = i.split("_")[0];
  139300. c.indexOf(d) != -1 && c.indexOf(e) != -1 && (o = s)
  139301. }
  139302. ),
  139303. o
  139304. }
  139305. loadAnimRes(e, i, o) {
  139306. const s = this._getAnimPath(i, o)
  139307. , c = getAnimationKey(i, o);
  139308. return s && this.containers.get(s) ? Promise.resolve(this.containers.get(s)) : s ? this._loadGlbFromBlob(e, c, s).then(d=>d.animationGroups.length == 0 ? (this.containers.delete(c),
  139309. d.dispose(),
  139310. Promise.reject("container does not contains animation data")) : d) : Promise.reject("no such url")
  139311. }
  139312. loadGlb(e, i, o) {
  139313. let s = this.getMeshUrl(this._getSourceKey(i, o));
  139314. return !s && this.fillEmptyLod && (o = 0,
  139315. s = this.getMeshUrl(this._getSourceKey(i, o))),
  139316. s && this.containers.get(s) ? Promise.resolve(this.containers.get(s)) : s ? this._enableIdb ? this._loadGlbFromBlob(e, this._getSourceKey(i, o), s) : this._loadGlbFromUrl(e, this._getSourceKey(i, o), s) : Promise.reject("no such url")
  139317. }
  139318. loadGltf(e, i, o, s) {
  139319. const c = this._getSourceKey(i, o || 0);
  139320. let d = this.getGltfPath(c);
  139321. return !d && this.fillEmptyLod && (d = this.getGltfPath(i)),
  139322. d && this.containers.get(d) ? Promise.resolve(this.containers.get(d)) : this._enableIdb ? this._loadGltfFromBlob(e, i, o, s) : d ? this._loadGltfFromUrl(e, i, d.replace(i + ".gltf", "")) : Promise.reject()
  139323. }
  139324. loadSubsequence() {}
  139325. loadVAT() {}
  139326. getResourceName(e) {
  139327. return this.meshTexList.get(e)
  139328. }
  139329. _loadGltfFromUrl(e, i, o) {
  139330. return SceneLoader.LoadAssetContainerAsync(o, i + ".gltf", e.Scene, null, ".gltf")
  139331. }
  139332. _loadGlbFromBlob(e, i, o) {
  139333. return e.urlTransformer(o).then(s=>SceneLoader.LoadAssetContainerAsync("", s, e.Scene, null, ".glb").then(c=>{
  139334. if (c) {
  139335. if (this.containers.get(o))
  139336. return c.dispose(),
  139337. this.containers.get(o);
  139338. if (c.addAllToScene(),
  139339. this.enableShareTexture && c.textures.length > 0) {
  139340. const d = [];
  139341. let _ = !1;
  139342. c.meshes.forEach(b=>{
  139343. if (b.material) {
  139344. const k = b.material._albedoTexture;
  139345. if (k) {
  139346. let j = k.name;
  139347. j = j.replace(" (Base Color)", "").split(".")[0];
  139348. const $ = this._sharedTex.get(j);
  139349. $ ? (_ = !0,
  139350. b.material._albedoTexture = $,
  139351. d.push($),
  139352. $._parentContainer = c,
  139353. $.xReferenceCount++) : (this._sharedTex.set(j, k),
  139354. c.textures[0].xReferenceCount = 1)
  139355. }
  139356. }
  139357. }
  139358. ),
  139359. _ && (c.textures.forEach(b=>{
  139360. e.Scene.removeTexture(b),
  139361. b.dispose()
  139362. }
  139363. ),
  139364. c.textures = d)
  139365. }
  139366. return c.xReferenceCount = 0,
  139367. c.meshes.forEach(d=>{
  139368. d.setEnabled(!1)
  139369. }
  139370. ),
  139371. this.containers.set(o, c),
  139372. Promise.resolve(c)
  139373. } else
  139374. return Promise.reject("glb file load failed")
  139375. }
  139376. ))
  139377. }
  139378. _loadGlbFromUrl(e, i, o) {
  139379. return SceneLoader.LoadAssetContainerAsync("", o, e.Scene, null, ".glb").then(s=>s ? (s.addAllToScene(),
  139380. s.meshes.forEach(c=>{
  139381. c.setEnabled(!1)
  139382. }
  139383. ),
  139384. this.enableShareTexture && s.textures.length > 0 ? (s.meshes.forEach(c=>{
  139385. if (c.material) {
  139386. const d = c.material._albedoTexture;
  139387. if (d) {
  139388. let _ = d.name;
  139389. _ = _.replace(" (Base Color)", "").split(".")[0];
  139390. const b = this._sharedTex.get(_);
  139391. b ? (c.material._albedoTexture = b,
  139392. b.xReferenceCount++) : (this._sharedTex.set(_, d),
  139393. s.textures[0].xReferenceCount = 1)
  139394. }
  139395. }
  139396. }
  139397. ),
  139398. s.xReferenceCount = 0,
  139399. this.containers.set(o, s),
  139400. Promise.resolve(s)) : Promise.reject("glb file load failed"),
  139401. s.xReferenceCount = 0,
  139402. this.containers.set(o, s),
  139403. Promise.resolve(s)) : Promise.reject("glb file load failed"))
  139404. }
  139405. _loadGltfFromBlob(e, i, o, s) {
  139406. return new Promise((c,d)=>{
  139407. const _ = [];
  139408. let b = this._getSourceKey(i, o)
  139409. , k = this.getGltfPath(b);
  139410. if (!k && this.fillEmptyLod && (o = 0,
  139411. b = this._getSourceKey(i, o),
  139412. k = this.getGltfPath(b)),
  139413. !k)
  139414. return d(`[Engine] gltf path incorrect ${b},cancel.`);
  139415. const j = this.mshPath.get(b + ".gltf");
  139416. if (!j)
  139417. return d("cannot find asset mshPath");
  139418. const $ = this.binPath.get(b + ".bin");
  139419. if (!$)
  139420. return d("cannot find asset binPath");
  139421. if (!s) {
  139422. const tt = this.meshTexList.get(i);
  139423. if (!tt || tt.length == 0)
  139424. return d("cannot find texture");
  139425. s = tt[0]
  139426. }
  139427. const _e = this.texPath.get(s + ".png");
  139428. if (!_e)
  139429. return d();
  139430. const et = this.texPath.get(s + "-astc.ktx");
  139431. if (!et)
  139432. return d();
  139433. _.push(this._blobMapping(e, j)),
  139434. _.push(this._blobMapping(e, $)),
  139435. _.push(this._blobMapping(e, _e)),
  139436. _.push(this._blobMapping(e, et)),
  139437. Promise.all(_).then(()=>{
  139438. const tt = k.replace(b + ".gltf", "");
  139439. SceneLoader.LoadAssetContainerAsync(tt, b + ".gltf", e.Scene, null, ".gltf").then(rt=>{
  139440. var nt;
  139441. this.containers.set(k, rt),
  139442. rt.addAllToScene(),
  139443. rt.meshes.forEach(ot=>{
  139444. ot.setEnabled(!1)
  139445. }
  139446. );
  139447. const it = this._sharedTex.get(i);
  139448. it ? ((nt = rt.meshes[1].material._albedoTexture) == null || nt.dispose(),
  139449. rt.meshes[1].material._albedoTexture = it) : this._sharedTex.set(i, rt.meshes[1].material._albedoTexture),
  139450. c(rt)
  139451. }
  139452. )
  139453. }
  139454. )
  139455. }
  139456. )
  139457. }
  139458. _blobMapping(e, i) {
  139459. return new Promise((o,s)=>{
  139460. e.urlTransformer(i).then(c=>c ? (this._mappings.set(i, c),
  139461. o(i)) : s(`[Engine] url urlTransformer parse error ${i}`))
  139462. }
  139463. )
  139464. }
  139465. }
  139466. const avatarLoader = new XAvatarLoader
  139467. , log$J = new Logger$1("AnimationController");
  139468. class XAnimationController {
  139469. constructor(e) {
  139470. this.iBodyAnim = void 0,
  139471. this.animations = [],
  139472. this.defaultAnimation = "Idle",
  139473. this.onPlay = "Idle",
  139474. this.loop = !0,
  139475. this.animationExtras = [],
  139476. this.enableBlend = !1,
  139477. this.enableSkLod = !1,
  139478. this._boneMap = new Map,
  139479. this._lodMask = new Map,
  139480. this.activeFaceAnimation = void 0,
  139481. this.iFaceAnim = void 0,
  139482. this.onPlayObservable = new Observable,
  139483. this.playAnimation = (i,o,s=0,c,d,_)=>new Promise((b,k)=>{
  139484. if (this._isPlaying(i, s) || (this._registerAnimInfo(i, o, s, c, d, _),
  139485. !this._isAnimate()))
  139486. return b(null);
  139487. this._prerocess(i, o),
  139488. this._avatar.avatarManager.loadAnimation(this._avatar.avatarType, i).then(j=>{
  139489. if (!j)
  139490. return k(new AvatarAnimationError("animation group does not exist"));
  139491. const $ = this._mappingSkeleton(j);
  139492. if (!$)
  139493. return k(new AvatarAnimationError("mapping animation failed"));
  139494. if ($ && this._isAnimationValid($))
  139495. return $.dispose(),
  139496. k(new AvatarAnimationError("mapping animation failed"));
  139497. if (this.enableSkLod && this.skeletonMask($, s),
  139498. this.detachAnimation(s),
  139499. s == 0 ? this.iBodyAnim.animGroup = $ : s == 1 && (this.iFaceAnim.animGroup = $),
  139500. !this._playAnimation(s))
  139501. return k(new AvatarAnimationError("[Engine] play animation failed, animtion resource does not match current character"));
  139502. this._playEffect(),
  139503. this.postObserver = $.onAnimationEndObservable.addOnce(()=>(this._postprocess(s),
  139504. b(null)))
  139505. }
  139506. )
  139507. }
  139508. ),
  139509. this.stopAnimation = (i=0)=>{
  139510. var o, s, c, d;
  139511. switch (i) {
  139512. case 0:
  139513. this.iBodyAnim && this.iBodyAnim.animGroup && ((o = this.iBodyAnim) == null || o.animGroup.stop());
  139514. break;
  139515. case 1:
  139516. this.iFaceAnim && this.iFaceAnim.animGroup && ((s = this.iFaceAnim) == null || s.animGroup.stop());
  139517. break;
  139518. case 2:
  139519. this.iBodyAnim && this.iBodyAnim.animGroup && ((c = this.iBodyAnim) == null || c.animGroup.stop()),
  139520. this.iFaceAnim && this.iFaceAnim.animGroup && ((d = this.iFaceAnim) == null || d.animGroup.stop());
  139521. break
  139522. }
  139523. }
  139524. ,
  139525. this.pauseAnimation = (i=0)=>{
  139526. var o, s, c, d;
  139527. switch (i) {
  139528. case 0:
  139529. this.iBodyAnim && this.iBodyAnim.animGroup && ((o = this.iBodyAnim) == null || o.animGroup.pause());
  139530. break;
  139531. case 1:
  139532. this.iFaceAnim && this.iFaceAnim.animGroup && ((s = this.iFaceAnim) == null || s.animGroup.pause());
  139533. break;
  139534. case 2:
  139535. this.iBodyAnim && this.iBodyAnim.animGroup && ((c = this.iBodyAnim) == null || c.animGroup.pause()),
  139536. this.iFaceAnim && this.iFaceAnim.animGroup && ((d = this.iFaceAnim) == null || d.animGroup.pause());
  139537. break
  139538. }
  139539. }
  139540. ,
  139541. this.resetAnimation = (i=0)=>{
  139542. var o, s, c, d;
  139543. switch (i) {
  139544. case 0:
  139545. this.iBodyAnim && this.iBodyAnim.animGroup && ((o = this.iBodyAnim) == null || o.animGroup.reset());
  139546. break;
  139547. case 1:
  139548. this.iFaceAnim && this.iFaceAnim.animGroup && ((s = this.iFaceAnim) == null || s.animGroup.reset());
  139549. break;
  139550. case 2:
  139551. this.iBodyAnim && this.iBodyAnim.animGroup && ((c = this.iBodyAnim) == null || c.animGroup.reset()),
  139552. this.iFaceAnim && this.iFaceAnim.animGroup && ((d = this.iFaceAnim) == null || d.animGroup.reset());
  139553. break
  139554. }
  139555. }
  139556. ,
  139557. this._avatar = e,
  139558. this._scene = e.avatarManager.scene,
  139559. this.animationExtras.push(action.Cheering.animName),
  139560. this._boneMap = new Map
  139561. }
  139562. _isPlaying(e, i) {
  139563. return i == 0 && this.iBodyAnim != null && this.iBodyAnim.animGroup && e == this.iBodyAnim.name ? !0 : !!(i == 1 && this.iFaceAnim != null && this.iFaceAnim.animGroup && e == this.iFaceAnim.name)
  139564. }
  139565. activeAnimation(e=0) {
  139566. var i, o;
  139567. switch (e) {
  139568. case 0:
  139569. return (i = this.iBodyAnim) == null ? void 0 : i.animGroup;
  139570. case 1:
  139571. return (o = this.iFaceAnim) == null ? void 0 : o.animGroup;
  139572. default:
  139573. return
  139574. }
  139575. }
  139576. enableAnimationBlend(e=.1, i=0) {
  139577. var o, s, c, d;
  139578. if (i == 0 && ((o = this.iBodyAnim) == null ? void 0 : o.animGroup))
  139579. for (const _ of (s = this.iBodyAnim) == null ? void 0 : s.animGroup.targetedAnimations)
  139580. _.animation.enableBlending = !0,
  139581. _.animation.blendingSpeed = e;
  139582. else if (i == 0 && ((c = this.iFaceAnim) == null ? void 0 : c.animGroup))
  139583. for (const _ of (d = this.iFaceAnim) == null ? void 0 : d.animGroup.targetedAnimations)
  139584. _.animation.enableBlending = !0,
  139585. _.animation.blendingSpeed = e
  139586. }
  139587. disableAnimationBlend(e=0) {
  139588. var i, o, s, c;
  139589. if (e == 0 && ((i = this.iBodyAnim) == null ? void 0 : i.animGroup))
  139590. for (const d of (o = this.iBodyAnim) == null ? void 0 : o.animGroup.targetedAnimations)
  139591. d.animation.enableBlending = !1;
  139592. else if (e == 0 && ((s = this.iFaceAnim) == null ? void 0 : s.animGroup))
  139593. for (const d of (c = this.iFaceAnim) == null ? void 0 : c.animGroup.targetedAnimations)
  139594. d.animation.enableBlending = !1
  139595. }
  139596. skeletonMask(e, i=0) {
  139597. if (i == 0) {
  139598. const o = this._lodMask.get(this._avatar.distLevel);
  139599. if (o)
  139600. for (let s = 0; s < e.targetedAnimations.length; ++s)
  139601. o.includes(e.targetedAnimations[s].target.name) || (e.targetedAnimations.splice(s, 1),
  139602. s--);
  139603. return !0
  139604. }
  139605. return !1
  139606. }
  139607. detachAnimation(e=2) {
  139608. var i, o;
  139609. switch (e) {
  139610. case 0:
  139611. this.iBodyAnim && this.iBodyAnim.animGroup && (this.iBodyAnim.animGroup._parentContainer.xReferenceCount && this.iBodyAnim.animGroup._parentContainer.xReferenceCount--,
  139612. this.iBodyAnim.animGroup.stop(),
  139613. this.iBodyAnim.animGroup.dispose(),
  139614. this.iBodyAnim.animGroup = void 0);
  139615. break;
  139616. case 1:
  139617. this.iFaceAnim && this.iFaceAnim.animGroup && (this.iFaceAnim.animGroup._parentContainer.xReferenceCount && this.iFaceAnim.animGroup._parentContainer.xReferenceCount--,
  139618. this.iFaceAnim.animGroup.stop(),
  139619. this.iFaceAnim.animGroup.dispose(),
  139620. this.iFaceAnim.animGroup = void 0);
  139621. break;
  139622. case 2:
  139623. this.iBodyAnim && this.iBodyAnim.animGroup && (this.iBodyAnim.animGroup._parentContainer.xReferenceCount && this.iBodyAnim.animGroup._parentContainer.xReferenceCount--,
  139624. (i = this.iBodyAnim) == null || i.animGroup.stop(),
  139625. (o = this.iBodyAnim) == null || o.animGroup.dispose(),
  139626. this.iBodyAnim.animGroup = void 0),
  139627. this.iFaceAnim && this.iFaceAnim.animGroup && (this.iFaceAnim.animGroup._parentContainer.xReferenceCount && this.iFaceAnim.animGroup._parentContainer.xReferenceCount--,
  139628. this.iFaceAnim.animGroup.stop(),
  139629. this.iFaceAnim.animGroup.dispose(),
  139630. this.iFaceAnim.animGroup = void 0);
  139631. break
  139632. }
  139633. }
  139634. blendAnimation() {}
  139635. getAnimation(e, i) {
  139636. return avatarLoader.animations.get(getAnimationKey(i, e))
  139637. }
  139638. _mappingSkeleton(e) {
  139639. if (e) {
  139640. const i = e.clone(e.name, o=>{
  139641. var c, d, _;
  139642. const s = o.name.split(" ").length > 2 ? o.name.split(" ")[2] : o.name;
  139643. if (this._boneMap.size === ((c = this._avatar.skeleton) == null ? void 0 : c.bones.length))
  139644. return this._boneMap.get(s);
  139645. {
  139646. const b = (_ = (d = this._avatar.skeleton) == null ? void 0 : d.bones.find(k=>k.name === o.name || k.name === o.name.split(" ")[2])) == null ? void 0 : _.getTransformNode();
  139647. return b && (b.name = s,
  139648. this._boneMap.set(s, b)),
  139649. b
  139650. }
  139651. }
  139652. );
  139653. return i._parentContainer = e._parentContainer,
  139654. i
  139655. } else
  139656. return
  139657. }
  139658. removeAnimation(e) {
  139659. const i = avatarLoader.containers.get(e.name);
  139660. i && (i.dispose(),
  139661. avatarLoader.containers.delete(e.name),
  139662. avatarLoader.animations.delete(getAnimationKey(e.name, e.skType)))
  139663. }
  139664. _setPosition(e, i) {
  139665. this._avatar.priority === 0 && this._avatar.isRender && e === this.defaultAnimation && e != this.onPlay && !this._avatar.isSelected && this._avatar.setPosition(this._avatar.position, !0)
  139666. }
  139667. _registerAnimInfo(e, i, o=0, s, c, d) {
  139668. const _ = {
  139669. name: e,
  139670. skType: this._avatar.avatarType,
  139671. loop: i,
  139672. playSpeed: s,
  139673. currentFrame: 0,
  139674. startFrame: c,
  139675. endFrame: d
  139676. };
  139677. o == 0 ? this.iBodyAnim == null ? this.iBodyAnim = _ : (this.iBodyAnim.name = e,
  139678. this.iBodyAnim.skType = this._avatar.avatarType,
  139679. this.iBodyAnim.loop = i,
  139680. this.iBodyAnim.playSpeed = s,
  139681. this.iBodyAnim.currentFrame = 0,
  139682. this.iBodyAnim.startFrame = c,
  139683. this.iBodyAnim.endFrame = d) : o == 1 && (this.iFaceAnim == null ? this.iFaceAnim = _ : (this.iFaceAnim.name = e,
  139684. this.iFaceAnim.skType = this._avatar.avatarType,
  139685. this.iFaceAnim.loop = i,
  139686. this.iFaceAnim.playSpeed = s,
  139687. this.iFaceAnim.currentFrame = 0,
  139688. this.iFaceAnim.startFrame = c,
  139689. this.iFaceAnim.endFrame = d)),
  139690. this.onPlay = e,
  139691. this.loop = i
  139692. }
  139693. _isAnimate() {
  139694. var e;
  139695. return !(!this._avatar.isRender || !this._avatar.skeleton || ((e = this._avatar.rootNode) == null ? void 0 : e.getChildMeshes().length) == 0)
  139696. }
  139697. _prerocess(e, i) {
  139698. this._avatar.isRayCastEnable && this._setPosition(e, i),
  139699. this._avatar.priority === 0 && log$J.info(`start play animation: ${e} on avatar ${this._avatar.id}`)
  139700. }
  139701. _playEffect() {
  139702. this.animationExtras.indexOf(this.iBodyAnim.name) != -1 && action.Cheering.attachPair.forEach(i=>{
  139703. this._avatar.attachExtraProp(i.obj, i.bone, new Vector3(i.offset.x,i.offset.y,i.offset.z), new Vector3(i.rotate.x,i.rotate.y,i.rotate.z)),
  139704. this._avatar.showExtra(i.obj)
  139705. }
  139706. )
  139707. }
  139708. _playAnimation(e=0) {
  139709. var i, o;
  139710. return e == 0 && this.iBodyAnim && ((i = this.iBodyAnim) == null ? void 0 : i.animGroup) ? (this.onPlayObservable.notifyObservers(this._scene),
  139711. this.iBodyAnim.animGroup.start(this.loop, this.iBodyAnim.playSpeed, this.iBodyAnim.startFrame, this.iBodyAnim.endFrame, !1),
  139712. !0) : e == 1 && this.iFaceAnim && ((o = this.iFaceAnim) == null ? void 0 : o.animGroup) ? (this.iFaceAnim.animGroup.start(this.loop, this.iFaceAnim.playSpeed, this.iFaceAnim.startFrame, this.iFaceAnim.endFrame, !1),
  139713. !0) : !1
  139714. }
  139715. _postprocess(e) {
  139716. var o, s;
  139717. let i;
  139718. e == 0 ? i = (o = this.iBodyAnim) == null ? void 0 : o.name : e == 1 && (i = (s = this.iFaceAnim) == null ? void 0 : s.name),
  139719. i === action.Cheering.animName && this._avatar.disposeExtra()
  139720. }
  139721. _isAnimationValid(e) {
  139722. for (let i = 0; i < e.targetedAnimations.length; ++i)
  139723. if (e.targetedAnimations[i].target)
  139724. return !1;
  139725. return !0
  139726. }
  139727. }
  139728. const log$I = new Logger$1("XAvatarComopnent");
  139729. class XAvatarComopnent {
  139730. constructor() {
  139731. this.resourceIdList = [],
  139732. this.skeleton = void 0,
  139733. this.extraProp = void 0,
  139734. this.extras = [],
  139735. this.body = void 0,
  139736. this.accessories = new Map
  139737. }
  139738. addBodyComp(e, i) {
  139739. return !e.rootNode || i.root.getChildMeshes().length === 0 ? (i.isRender = !1,
  139740. !1) : (this.body = i,
  139741. this.body.root.parent = e.rootNode,
  139742. i.isRender = !0,
  139743. this.body.root.getChildMeshes()[0] && (this.body.root.getChildMeshes()[0].xtype = EMeshType.XAvatar,
  139744. this.body.root.getChildMeshes()[0].xid = e.id),
  139745. this.skeleton = i.skeleton,
  139746. !0)
  139747. }
  139748. addClothesComp(e, i) {
  139749. return !e.rootNode || !this.skeleton || !i.root ? (i.isRender = !1,
  139750. !1) : (i.root.xtype = EMeshType.XAvatar,
  139751. i.root.xid = e.id,
  139752. i.isRender = !0,
  139753. i.root.parent = e.rootNode.getChildMeshes()[0],
  139754. this.resourceIdList.push(i),
  139755. i.root.skeleton = this.skeleton,
  139756. i.root.getChildMeshes().forEach(o=>{
  139757. o.skeleton = this.skeleton
  139758. }
  139759. ),
  139760. !0)
  139761. }
  139762. clearClothesComp(e) {
  139763. e.root.getChildMeshes().forEach(i=>{
  139764. i.skeleton = null,
  139765. i.dispose(),
  139766. i.xid = void 0
  139767. }
  139768. ),
  139769. e.root.dispose(),
  139770. this.resourceIdList = this.resourceIdList.filter(i=>i.uId != e.uId)
  139771. }
  139772. clearAllClothesComps() {
  139773. this.resourceIdList.forEach(e=>{
  139774. var i;
  139775. e.root.parent = null,
  139776. e.root._parentContainer.xReferenceCount && (e.root._parentContainer.xReferenceCount--,
  139777. e.root._parentContainer = null),
  139778. e.isRender = !1,
  139779. e.isSelected = !1,
  139780. e.root.getChildMeshes().forEach(o=>{
  139781. o.skeleton = null,
  139782. o.dispose()
  139783. }
  139784. ),
  139785. (i = e.root.skeleton) == null || i.dispose(),
  139786. e.root.dispose()
  139787. }
  139788. ),
  139789. this.resourceIdList = []
  139790. }
  139791. dispose(e) {
  139792. this.body ? (this.body.root._parentContainer.xReferenceCount && (this.body.root._parentContainer.xReferenceCount--,
  139793. this.body.root._parentContainer = null),
  139794. this.clearAllClothesComps(),
  139795. this.body.isRender = !1,
  139796. this.body.skeleton.dispose(),
  139797. this.body.skeleton = null,
  139798. this.body.root.dispose(),
  139799. this.body = void 0,
  139800. this.skeleton && (this.skeleton.dispose(),
  139801. this.skeleton = void 0)) : log$I.warn("[Engine] no body to dispose")
  139802. }
  139803. async attachPendant(e, i) {
  139804. return Promise.resolve(avatarLoader.pullAndLoadXObject(e.avatarManager.sceneManager, i).then(o=>{
  139805. const s = o
  139806. , c = this.accessories.get(s.pointId);
  139807. return c ? (c.dispose(),
  139808. this.accessories.set(s.pointId, s),
  139809. log$I.warn("[Engine] \u8BE5\u6302\u70B9\u5F53\u524D\u88AB\u5360\u7528\uFF0C\u5DF2\u66FF\u6362\u8BE5\u6302\u70B9")) : this.accessories.set(s.pointId, s),
  139810. s.attachTo(e),
  139811. s
  139812. }
  139813. ))
  139814. }
  139815. detachPendant(e, i=!0) {
  139816. const o = this.accessories.get(e);
  139817. o && (o.dispose(),
  139818. this.accessories.delete(e))
  139819. }
  139820. changeClothesComp(e, i, o, s, c) {
  139821. return new Promise(d=>{
  139822. if (this.resourceIdList.some(_=>_.name === i))
  139823. return d();
  139824. if (e.isHide || !e.isRender)
  139825. c.concat(o).forEach(b=>{
  139826. e.clothesList = e.clothesList.filter(j=>j.type != b);
  139827. const k = {
  139828. type: o,
  139829. id: i,
  139830. url: s,
  139831. lod: 0
  139832. };
  139833. e.clothesList.push(k)
  139834. }
  139835. ),
  139836. d();
  139837. else {
  139838. const _ = c.concat(o);
  139839. e.avatarManager.loadDecoration(o, i, 0).then(b=>{
  139840. if (b) {
  139841. e.attachDecoration(b);
  139842. const k = {
  139843. type: o,
  139844. id: i,
  139845. url: s
  139846. };
  139847. e.clothesList.push(k),
  139848. b.root.setEnabled(!0),
  139849. _.forEach(j=>{
  139850. const $ = this.resourceIdList.filter(_e=>_e.type === j);
  139851. if ($.length > 1) {
  139852. const _e = $.filter(et=>et.name === i);
  139853. if (_e.length > 1)
  139854. for (let et = 1; et < _e.length; ++et) {
  139855. e.detachDecoration(_e[et]),
  139856. e.clothesList = e.clothesList.filter(rt=>rt.id != _e[et].name);
  139857. const tt = {
  139858. type: o,
  139859. id: i,
  139860. url: s
  139861. };
  139862. e.clothesList.push(tt)
  139863. }
  139864. }
  139865. $[0] && $[0].name != i && this._readyToDetach(e, o) && (e.detachDecoration($[0]),
  139866. e.clothesList = e.clothesList.filter(_e=>_e.id != $[0].name))
  139867. }
  139868. )
  139869. }
  139870. return d()
  139871. }
  139872. )
  139873. }
  139874. }
  139875. )
  139876. }
  139877. _readyToDetach(e, i) {
  139878. return !((i == "clothes" || i == "pants") && e.clothesList.filter(s=>s.type === "suit").length == 1 && (!e.clothesList.some(s=>s.type === "pants") || !e.clothesList.some(s=>s.type === "clothes")))
  139879. }
  139880. addDecoComp(e, i, o, s, c) {
  139881. if (e.isRender) {
  139882. const d = e.avatarManager.extraComps.get(i)
  139883. , _ = d == null ? void 0 : d.clone(i, void 0);
  139884. if (!d) {
  139885. log$I.error("\u6CA1\u6709\u5BF9\u5E94\u7684\u7EC4\u4EF6");
  139886. return
  139887. }
  139888. this.extras.push(_);
  139889. const b = this.skeleton.bones.find(k=>k.name === o);
  139890. _.position = s,
  139891. _.rotation = c,
  139892. _.attachToBone(b, e.rootNode.getChildMeshes()[0])
  139893. }
  139894. }
  139895. showExtra(e) {
  139896. this.extras.forEach(i=>{
  139897. i.name.indexOf(e) > 0 && i.setEnabled(!0)
  139898. }
  139899. )
  139900. }
  139901. hideExtra(e) {
  139902. this.extras.forEach(i=>{
  139903. i.name.indexOf(e) > 0 && i.setEnabled(!1)
  139904. }
  139905. )
  139906. }
  139907. disposeExtra() {
  139908. this.extras.forEach(e=>{
  139909. e.dispose()
  139910. }
  139911. ),
  139912. this.extras = []
  139913. }
  139914. }
  139915. function LinearBezierCurves(a, e, i) {
  139916. return Vector3.Lerp(e, i, 1 - a)
  139917. }
  139918. function QuadraticBezierCurves(a, e, i, o) {
  139919. let s = LinearBezierCurves(a, e, i)
  139920. , c = LinearBezierCurves(a, i, o);
  139921. return LinearBezierCurves(a, s, c)
  139922. }
  139923. function CubicBezierCurves(a, e, i, o, s) {
  139924. let c = QuadraticBezierCurves(a, e, i, o)
  139925. , d = QuadraticBezierCurves(a, i, o, s);
  139926. return LinearBezierCurves(a, c, d)
  139927. }
  139928. function CardinalMultiply(a, e, i, o, s, c) {
  139929. var d, _, b, k;
  139930. return d = a[0] * e + a[1] * i + a[2] * o + a[3] * s,
  139931. _ = a[4] * e + a[5] * i + a[6] * o + a[7] * s,
  139932. b = a[8] * e + a[9] * i + a[10] * o + a[11] * s,
  139933. k = a[12] * e + a[13] * i + a[14] * o + a[15] * s,
  139934. k + c * (b + c * (_ + c * d))
  139935. }
  139936. function CardinalCurves(a, e, i, o, s, c) {
  139937. let d = new Array(16)
  139938. , _ = c;
  139939. return d[0] = -_,
  139940. d[1] = 2 - _,
  139941. d[2] = _ - 2,
  139942. d[3] = _,
  139943. d[4] = 2 * _,
  139944. d[5] = _ - 3,
  139945. d[8] = -_,
  139946. d[9] = 0,
  139947. d[12] = 0,
  139948. d[13] = 1,
  139949. d[6] = 3 - 2 * _,
  139950. d[7] = -_,
  139951. d[10] = _,
  139952. d[11] = 0,
  139953. d[14] = 0,
  139954. d[15] = 0,
  139955. new Vector3(CardinalMultiply(d, e.x, i.x, o.x, s.x, a),CardinalMultiply(d, e.y, i.y, o.y, s.x, a),CardinalMultiply(d, e.z, i.z, o.z, s.x, a))
  139956. }
  139957. function HermiteCurves(a, e, i, o, s) {
  139958. let c = Math.pow(a, 3)
  139959. , d = Math.pow(a, 2)
  139960. , _ = 2 * c - 3 * d + 1
  139961. , b = -2 * c + 3 * d
  139962. , k = c - 2 * d + a
  139963. , j = c - d
  139964. , $ = e.multiplyByFloats(_, _, _)
  139965. , _e = i.multiplyByFloats(b, b, b)
  139966. , et = o.multiplyByFloats(k, k, k)
  139967. , tt = s.multiplyByFloats(j, j, j);
  139968. return $.add(_e.add(et).add(tt))
  139969. }
  139970. const log$H = new Logger$1("XStateMachine");
  139971. class XStateMachine {
  139972. constructor(e) {
  139973. this._observer = void 0,
  139974. this._movingObserver = void 0,
  139975. this._scene = e
  139976. }
  139977. rotateTo(e, i, o, s) {
  139978. return new Promise((c,d)=>{
  139979. var $;
  139980. const _ = e.avatarManager.scene;
  139981. if (o && e.setRotation(o),
  139982. i == o)
  139983. return c();
  139984. e.priority === 0 && log$H.info(`avatar ${e.id} starts to rotate from ${o} to ${i}`);
  139985. let b = 0;
  139986. const k = 1e3 / 25
  139987. , j = calcDistance3DAngle(i, e.rotation) / k;
  139988. this._movingObserver && _.onBeforeRenderObservable.remove(this._movingObserver),
  139989. ($ = e.controller) == null || $.playAnimation(s || "Walking", !0),
  139990. this._movingObserver = _ == null ? void 0 : _.onBeforeRenderObservable.add(()=>{
  139991. var _e;
  139992. if (b < 1) {
  139993. if (!e.rootNode)
  139994. return e.setRotation(i),
  139995. c();
  139996. const et = Vector3.Lerp(e.rootNode.rotation, ue4Rotation2Xverse(i), b);
  139997. e.setRotation(xverseRotation2Ue4(et)),
  139998. b += k / (j * 1e3)
  139999. } else
  140000. return _.onBeforeRenderObservable.remove(this._movingObserver),
  140001. (_e = e.controller) == null || _e.playAnimation("Idle", !0),
  140002. c()
  140003. }
  140004. )
  140005. }
  140006. )
  140007. }
  140008. _filterPathPoint(e) {
  140009. let i = 0;
  140010. const o = 1e-4;
  140011. if (e.length <= 1)
  140012. return e;
  140013. for (; i < e.length - 1; )
  140014. calcDistance3D(e[i], e[i + 1]) < o ? e.splice(i, 1) : i++;
  140015. return e
  140016. }
  140017. moveToHermite(e, i, o, s, c, d, _) {
  140018. return new Promise((b,k)=>{
  140019. var ot;
  140020. const j = e.avatarManager.scene;
  140021. e.priority === 0 && log$H.info(`avatar ${e.id} starts to move from ${i} to ${o}`);
  140022. let$ = 0;
  140023. var _e = ue4Position2Xverse(i), et, tt = e.rootNode.rotation.y, rt = new Vector3(-Math.sin(tt) * c,0,-Math.cos(tt) * c), it = rt.clone();
  140024. it.x = -it.x,
  140025. it.z = -it.z;
  140026. const nt = 1e3 / 25;
  140027. this._movingObserver && j.onBeforeRenderObservable.remove(this._movingObserver),
  140028. (ot = e.controller) == null || ot.playAnimation(d, !0),
  140029. this._movingObserver = j == null ? void 0 : j.onBeforeRenderObservable.add(()=>{
  140030. var st;
  140031. et = HermiteCurves($, ue4Position2Xverse(i), ue4Position2Xverse(o), rt, it),
  140032. e.rootNode.lookAt(et);
  140033. const at = xverseRotation2Ue4({
  140034. x: e.rootNode.rotation.x,
  140035. y: e.rootNode.rotation.y,
  140036. z: e.rootNode.rotation.z
  140037. });
  140038. if (at && (at.roll = 0,
  140039. at.pitch = 0,
  140040. e.setRotation(at)),
  140041. $ <= 1) {
  140042. if (e.setPosition(xversePosition2Ue4(_e), _),
  140043. !e.rootNode)
  140044. return e.setPosition(o, _),
  140045. b();
  140046. $ += nt / s,
  140047. _e = et.clone()
  140048. } else
  140049. return e.setPosition(o, _),
  140050. j.onBeforeRenderObservable.remove(this._movingObserver),
  140051. (st = e.controller) == null || st.playAnimation("Idle", !0),
  140052. b()
  140053. }
  140054. )
  140055. }
  140056. )
  140057. }
  140058. moveToCardinal(e, i, o, s, c, d, _, b) {
  140059. return new Promise((k,j)=>{
  140060. var ot;
  140061. const $ = e.avatarManager.scene;
  140062. e.priority === 0 && log$H.info(`avatar ${e.id} starts to move from ${i} to ${o}`);
  140063. let _e = 0
  140064. , et = ue4Position2Xverse(d[0])
  140065. , tt = ue4Position2Xverse(d[1]);
  140066. var rt = ue4Position2Xverse(i), it;
  140067. const nt = 1e3 / 25;
  140068. this._movingObserver && $.onBeforeRenderObservable.remove(this._movingObserver),
  140069. (ot = e.controller) == null || ot.playAnimation(c, !0),
  140070. this._movingObserver = $ == null ? void 0 : $.onBeforeRenderObservable.add(()=>{
  140071. var st;
  140072. it = CardinalCurves(_e, ue4Position2Xverse(i), et, tt, ue4Position2Xverse(o), _),
  140073. e.rootNode.lookAt(it);
  140074. const at = xverseRotation2Ue4({
  140075. x: e.rootNode.rotation.x,
  140076. y: e.rootNode.rotation.y,
  140077. z: e.rootNode.rotation.z
  140078. });
  140079. if (at && (at.roll = 0,
  140080. at.pitch = 0,
  140081. e.setRotation(at)),
  140082. _e <= 1) {
  140083. if (e.setPosition(xversePosition2Ue4(rt), b),
  140084. !e.rootNode)
  140085. return e.setPosition(o, b),
  140086. k();
  140087. _e += nt / s,
  140088. rt = it.clone()
  140089. } else
  140090. return e.setPosition(o, b),
  140091. $.onBeforeRenderObservable.remove(this._movingObserver),
  140092. (st = e.controller) == null || st.playAnimation("Idle", !0),
  140093. k()
  140094. }
  140095. )
  140096. }
  140097. )
  140098. }
  140099. moveToBezier(e, i, o, s, c) {
  140100. return new Promise((d,_)=>{
  140101. var tt;
  140102. i.length < 2 && _("[Engine input Bezier control points error]");
  140103. const b = e.avatarManager.scene;
  140104. e.priority === 0 && log$H.info(`avatar ${e.id} starts to move in Bezier Curve, from ${i[0]} to ${i[i.length - 1]}`);
  140105. let k = 0
  140106. , j = new Array;
  140107. i.forEach(rt=>{
  140108. j.push(ue4Position2Xverse(rt))
  140109. }
  140110. );
  140111. var $ = j[0], _e;
  140112. const et = 1e3 / 25;
  140113. this._movingObserver && b.onBeforeRenderObservable.remove(this._movingObserver),
  140114. (tt = e.controller) == null || tt.playAnimation(s, !0),
  140115. this._movingObserver = b == null ? void 0 : b.onBeforeRenderObservable.add(()=>{
  140116. var rt;
  140117. switch (i.length) {
  140118. case 2:
  140119. _e = LinearBezierCurves(k, j[0], j[1]);
  140120. break;
  140121. case 3:
  140122. _e = QuadraticBezierCurves(k, j[0], j[1], j[2]);
  140123. break;
  140124. case 4:
  140125. _e = CubicBezierCurves(k, j[0], j[1], j[2], j[3]);
  140126. break
  140127. }
  140128. if (k != 0) {
  140129. e.rootNode.lookAt(_e);
  140130. const it = xverseRotation2Ue4({
  140131. x: e.rootNode.rotation.x,
  140132. y: e.rootNode.rotation.y,
  140133. z: e.rootNode.rotation.z
  140134. });
  140135. it && (it.roll = 0,
  140136. it.pitch = 0,
  140137. e.setRotation(it))
  140138. }
  140139. if (k < 1) {
  140140. if (e.setPosition(xversePosition2Ue4($), c),
  140141. !e.rootNode)
  140142. return e.setPosition(j[j.length - 1], c),
  140143. d();
  140144. k += et / o,
  140145. $ = _e.clone()
  140146. } else
  140147. return b.onBeforeRenderObservable.remove(this._movingObserver),
  140148. (rt = e.controller) == null || rt.playAnimation("Idle", !0),
  140149. d()
  140150. }
  140151. )
  140152. }
  140153. )
  140154. }
  140155. moveTo(e, i, o, s, c, d, _) {
  140156. return new Promise((b,k)=>{
  140157. var nt;
  140158. const j = e.avatarManager.scene;
  140159. e.priority === 0 && log$H.info(`avatar ${e.id} starts to move from ${i} to ${o}`);
  140160. let$ = 0;
  140161. d ? d = d.concat(o) : d = [o],
  140162. d = this._filterPathPoint(d);
  140163. let _e = i
  140164. , et = d.shift();
  140165. if (!et)
  140166. return k("[Engine input path error]");
  140167. let tt = calcDistance3D(_e, et) / s;
  140168. const rt = 1e3 / 25;
  140169. e.rootNode.lookAt(ue4Position2Xverse(et));
  140170. const it = xverseRotation2Ue4({
  140171. x: e.rootNode.rotation.x,
  140172. y: e.rootNode.rotation.y,
  140173. z: e.rootNode.rotation.z
  140174. });
  140175. it && (it.roll = 0,
  140176. it.pitch = 0,
  140177. e.setRotation(it)),
  140178. this._movingObserver && j.onBeforeRenderObservable.remove(this._movingObserver),
  140179. (nt = e.controller) == null || nt.playAnimation(c, !0),
  140180. this._movingObserver = j == null ? void 0 : j.onBeforeRenderObservable.add(()=>{
  140181. var ot;
  140182. if ($ < 1) {
  140183. const at = Vector3.Lerp(ue4Position2Xverse(_e), ue4Position2Xverse(et), $);
  140184. if (e.setPosition(xversePosition2Ue4(at), _),
  140185. !e.rootNode)
  140186. return e.setPosition(o, _),
  140187. b();
  140188. $ += rt / (tt * 1e3)
  140189. } else if (_e = et,
  140190. et = d.shift(),
  140191. et) {
  140192. tt = calcDistance3D(_e, et) / s,
  140193. e.rootNode.lookAt(ue4Position2Xverse(et));
  140194. const at = xverseRotation2Ue4({
  140195. x: e.rootNode.rotation.x,
  140196. y: e.rootNode.rotation.y,
  140197. z: e.rootNode.rotation.z
  140198. });
  140199. at && (at.roll = 0,
  140200. at.pitch = 0,
  140201. e.setRotation(at)),
  140202. $ = 0
  140203. } else
  140204. return j.onBeforeRenderObservable.remove(this._movingObserver),
  140205. (ot = e.controller) == null || ot.playAnimation("Idle", !0),
  140206. b()
  140207. }
  140208. )
  140209. }
  140210. )
  140211. }
  140212. lookAt(e, i, o) {
  140213. return new Promise(s=>{
  140214. var et, tt;
  140215. const c = ue4Position2Xverse(i)
  140216. , d = 1e-4;
  140217. if (calcDistance3D(e.position, i) <= d)
  140218. return s();
  140219. const _ = new Vector3(e.rootNode.rotation.x % (Math.PI * 2),e.rootNode.rotation.y % (Math.PI * 2),e.rootNode.rotation.z % (Math.PI * 2));
  140220. (et = e.rootNode) == null || et.lookAt(c);
  140221. const b = new Vector3(e.rootNode.rotation.x % (Math.PI * 2),(e.rootNode.rotation.y + Math.PI) % (Math.PI * 2),e.rootNode.rotation.z % (Math.PI * 2));
  140222. if (e.rootNode.rotation = _,
  140223. b.y - _.y > Math.PI && (b.y -= 2 * Math.PI),
  140224. b.y - _.y < -Math.PI && (b.y += 2 * Math.PI),
  140225. e.rootNode && Math.abs(_.x / _.z - b.x / b.z) <= d)
  140226. return s();
  140227. let k = 0;
  140228. const j = o || 1 / 100
  140229. , $ = (tt = e.rootNode) == null ? void 0 : tt.getScene()
  140230. , _e = $ == null ? void 0 : $.onBeforeRenderObservable.add(()=>{
  140231. var nt;
  140232. const rt = (nt = e.controller) == null ? void 0 : nt.animations.find(ot=>ot.name == "Idle");
  140233. (rt == null ? void 0 : rt.isPlaying) != !0 && (rt == null || rt.play());
  140234. const it = Vector3.Lerp(_, b, k);
  140235. if (k < 1) {
  140236. const ot = xverseRotation2Ue4({
  140237. x: it.x,
  140238. y: it.y - Math.PI,
  140239. z: it.z
  140240. });
  140241. ot && (ot.roll = 0,
  140242. ot.pitch = 0,
  140243. e.setRotation(ot)),
  140244. k += j
  140245. } else
  140246. _e && $.onBeforeRenderObservable.remove(_e),
  140247. s()
  140248. }
  140249. )
  140250. }
  140251. )
  140252. }
  140253. sendObjectTo(e, i, o, s=2, c=10, d={
  140254. x: 0,
  140255. y: 0,
  140256. z: 150
  140257. }) {
  140258. return new Promise((_,b)=>{
  140259. var k;
  140260. if (!o.loaded)
  140261. b("Gift has not inited!");
  140262. else {
  140263. const j = (k = e.rootNode) == null ? void 0 : k.getScene();
  140264. let$ = 0;
  140265. const _e = 1 / (s * 25)
  140266. , et = _e
  140267. , tt = c / 100
  140268. , rt = 8 * tt * _e * _e;
  140269. let it = .5 * rt / _e
  140270. , nt = ue4Position2Xverse(e.position);
  140271. const ot = ue4Position2Xverse(d)
  140272. , at = ue4Position2Xverse(e.position)
  140273. , st = j == null ? void 0 : j.onBeforeRenderObservable.add(()=>{
  140274. (!i || !e.position || !i.position) && (st && j.onBeforeRenderObservable.remove(st),
  140275. b("Invalid receiver when shoot gift!")),
  140276. o.loaded || (st && j.onBeforeRenderObservable.remove(st),
  140277. _());
  140278. const ut = ue4Position2Xverse(i.position)
  140279. , ct = new Vector3((ut.x - at.x) * _e,it,(ut.z - at.z) * _e);
  140280. it = it - rt,
  140281. $ < 1 ? (nt = nt.add(ct),
  140282. o.setPositionVector(nt.add(ot)),
  140283. $ += et) : (_(),
  140284. st && j.onBeforeRenderObservable.remove(st))
  140285. }
  140286. )
  140287. }
  140288. }
  140289. )
  140290. }
  140291. roll(e, i, o, s) {
  140292. var c, d;
  140293. this._observer && ((c = this._scene) == null || c.onBeforeRenderObservable.remove(this._observer)),
  140294. i && (o = o != null ? o : 1,
  140295. s = s != null ? s : 1,
  140296. this._observer = (d = this._scene) == null ? void 0 : d.onBeforeRenderObservable.add(()=>{
  140297. e.rootNode.rotation.y += o * .1 * s,
  140298. e.rootNode.rotation.y %= Math.PI * 2
  140299. }
  140300. ))
  140301. }
  140302. disposeObsever() {
  140303. this._movingObserver && this._scene.onBeforeRenderObservable.remove(this._movingObserver)
  140304. }
  140305. }
  140306. class PoolObject {
  140307. constructor(e, i, o, s=!0) {
  140308. this.data = e,
  140309. this.nextFree = i,
  140310. this.previousFree = o,
  140311. this.free = s
  140312. }
  140313. dispose() {
  140314. this.data && this.data instanceof Mesh && this.data.dispose(!0, !0),
  140315. this.previousFree = null,
  140316. this.nextFree = null,
  140317. this.data = null
  140318. }
  140319. }
  140320. class Pool {
  140321. constructor(e, i, o, s, ...c) {
  140322. this._pool = [],
  140323. this.objCreator = e,
  140324. this.objReseter = i;
  140325. for (let d = 0; d < s; d++)
  140326. this.addNewObject(this.newPoolObject(...c));
  140327. this.capacity = o
  140328. }
  140329. addNewObject(e) {
  140330. return this._pool.push(e),
  140331. this.release(e),
  140332. e
  140333. }
  140334. release(e) {
  140335. e.free = !0,
  140336. e.nextFree = null,
  140337. e.previousFree = this.lastFree,
  140338. this.lastFree ? this.lastFree.nextFree = e : this.nextFree = e,
  140339. this.lastFree = e,
  140340. this.objReseter(e)
  140341. }
  140342. getFree(...e) {
  140343. const i = this.nextFree ? this.nextFree : this.addNewObject(this.newPoolObject(...e));
  140344. return i.free = !1,
  140345. this.nextFree = i.nextFree,
  140346. this.nextFree || (this.lastFree = null),
  140347. i
  140348. }
  140349. newPoolObject(...e) {
  140350. const i = this.objCreator(...e);
  140351. return new PoolObject(i,this.nextFree,this.lastFree)
  140352. }
  140353. releaseAll() {
  140354. this._pool.forEach(e=>this.release(e))
  140355. }
  140356. clean(e=0, ...i) {
  140357. let o = this.nextFree;
  140358. if (!o)
  140359. return;
  140360. let s = 0;
  140361. for (; o; )
  140362. s += 1,
  140363. o = o.nextFree;
  140364. let c = !1;
  140365. if (s > e && this._pool.length > this.capacity && (c = !0),
  140366. c)
  140367. for (o = this.nextFree; o; ) {
  140368. o.free = !1,
  140369. this.nextFree = o.nextFree;
  140370. const d = this._pool.indexOf(o);
  140371. this._pool.splice(d, 1),
  140372. this.nextFree || (this.lastFree = null),
  140373. o == null || o.dispose(),
  140374. o = this.nextFree
  140375. }
  140376. }
  140377. }
  140378. const texRootDir = "https://app-asset-1258211750.file.myqcloud.com/1/textures/"
  140379. , _XBillboardManager = class {
  140380. constructor(a) {
  140381. this.billboardMap = new Map,
  140382. this.userBackGroundBlob = new Array,
  140383. this.npcBackGroundBlob = new Array,
  140384. this._updateLoopObserver = void 0,
  140385. this.sceneManager = a,
  140386. this.billboardPool = new Pool(this.createBillboardAsset,this.resetBillboardAsset,0,60,this.sceneManager.Scene,!1),
  140387. this.tickInterval = 250;
  140388. let e = 0;
  140389. this.tickObserver = this.sceneManager.Scene.onAfterRenderObservable.add(()=>{
  140390. e += 1,
  140391. e == this.tickInterval && (this.tick(),
  140392. e = 0)
  140393. }
  140394. ),
  140395. this.launchBillboardStatusLoop()
  140396. }
  140397. tick() {
  140398. this.billboardPool.clean(0, this.sceneManager.Scene, !1)
  140399. }
  140400. createBillboardAsset(a, e=!1) {
  140401. const i = MeshBuilder.CreatePlane("billboard-", {
  140402. height: .001,
  140403. width: .001,
  140404. sideOrientation: Mesh.DOUBLESIDE
  140405. }, a);
  140406. i.isPickable = !0,
  140407. i.setEnabled(!1);
  140408. const o = new DynamicTexture("billboard-tex-",{
  140409. width: .001 + 1,
  140410. height: .001 + 1
  140411. },a,e,Texture.BILINEAR_SAMPLINGMODE);
  140412. o.hasAlpha = !0;
  140413. const s = new StandardMaterial("billboard-mat-",a);
  140414. return s.diffuseTexture = o,
  140415. s.emissiveColor = new Color3(.95,.95,.95),
  140416. s.useAlphaFromDiffuseTexture = !0,
  140417. i.material = s,
  140418. i.billboardMode = Mesh.BILLBOARDMODE_Y,
  140419. i.position.y = 0,
  140420. i
  140421. }
  140422. resetBillboardAsset(a) {
  140423. const e = a.data;
  140424. return e.setEnabled(!1),
  140425. e.isPickable = !1,
  140426. a
  140427. }
  140428. async loadBackGroundTexToIDB() {
  140429. _XBillboardManager.userBubbleUrls.forEach(i=>{
  140430. this.sceneManager.urlTransformer(i).then(o=>{
  140431. this.userBackGroundBlob.push(o)
  140432. }
  140433. )
  140434. }
  140435. ),
  140436. _XBillboardManager.npcBubbleUrls.forEach(i=>{
  140437. this.sceneManager.urlTransformer(i).then(o=>{
  140438. this.npcBackGroundBlob.push(o)
  140439. }
  140440. )
  140441. }
  140442. )
  140443. }
  140444. addBillboardToMap(a, e) {
  140445. this.billboardMap.set(a, e)
  140446. }
  140447. addBillboard(a, e, i) {
  140448. let o = this.getBillboard(a);
  140449. return o || (o = new XBillboard(this,e,i),
  140450. this.addBillboardToMap(a, o)),
  140451. o
  140452. }
  140453. generateStaticBillboard(a, {id: e="billboard", isUser: i, background: o, font: s="Arial", fontsize: c=40, fontcolor: d="#ffffff", fontstyle: _="600", linesize: b=16, linelimit: k, scale: j=1, width: $=.01, height: _e=.01, position: et={
  140454. x: 0,
  140455. y: 0,
  140456. z: 0
  140457. }}) {
  140458. const tt = this.addBillboard(e, !1, !0);
  140459. tt.getMesh() == null && tt.init(e, $, _e);
  140460. let rt;
  140461. i != null && (rt = i ? _XBillboardManager.userBubbleUrls : _XBillboardManager.npcBubbleUrls),
  140462. tt && tt.getMesh() && (tt.DEFAULT_CONFIGS = {
  140463. id: e,
  140464. isUser: i,
  140465. background: o,
  140466. font: s,
  140467. fontsize: c,
  140468. fontcolor: d,
  140469. fontstyle: _,
  140470. linesize: b,
  140471. linelimit: k,
  140472. scale: j,
  140473. width: $,
  140474. height: _e,
  140475. position: et
  140476. },
  140477. tt.drawBillboard({
  140478. imageList: o || rt
  140479. }, {
  140480. texts: a,
  140481. font: s,
  140482. fontsize: c,
  140483. fontcolor: d,
  140484. fontstyle: _,
  140485. linesize: b,
  140486. linelimit: k
  140487. }, {
  140488. position: et,
  140489. scale: j
  140490. }),
  140491. e && tt.setId(e),
  140492. tt.setStatus(BillboardStatus.SHOW))
  140493. }
  140494. getBillboard(a) {
  140495. return this.billboardMap.get(a)
  140496. }
  140497. toggle(a, e) {
  140498. var i;
  140499. (i = this.getBillboard(a)) == null || i.setStatus(e ? BillboardStatus.SHOW : BillboardStatus.HIDE)
  140500. }
  140501. removeBillboard(a) {
  140502. const e = this.getBillboard(a);
  140503. e && (e.setStatus(BillboardStatus.DISPOSE),
  140504. this.billboardMap.delete(a))
  140505. }
  140506. launchBillboardStatusLoop() {
  140507. this._updateLoopObserver = this.sceneManager.Scene.onBeforeRenderObservable.add(()=>{
  140508. this.billboardMap.size <= 0 || this.billboardMap.forEach(a=>{
  140509. a.stageChanged && (a.status == BillboardStatus.SHOW ? a.show() : a.status == BillboardStatus.HIDE ? a.hide() : (a.hide(),
  140510. a.dispose()),
  140511. a.stageChanged = !1)
  140512. }
  140513. )
  140514. }
  140515. )
  140516. }
  140517. }
  140518. ;
  140519. let XBillboardManager = _XBillboardManager;
  140520. XBillboardManager.alphaWidthMap = new Map;
  140521. XBillboardManager.userBubbleUrls = [texRootDir + "bubble01.png", texRootDir + "bubble02.png", texRootDir + "bubble03.png"];
  140522. XBillboardManager.npcBubbleUrls = [texRootDir + "bubble01_npc.png", texRootDir + "bubble02_npc.png", texRootDir + "bubble03_npc.png"];
  140523. const log$G = new Logger$1("XAvatarBillboardComponent");
  140524. class XAvatarBillboardComponent {
  140525. constructor(e) {
  140526. this._nickName = "",
  140527. this._words = "",
  140528. this._isNameVisible = !0,
  140529. this._isBubbleVisible = !0,
  140530. this._isGiftButtonsVisible = !1,
  140531. this.withinVisualRange = !1,
  140532. this._bubble = void 0,
  140533. this._nameBoard = void 0,
  140534. this._giftButtons = new Map,
  140535. this._buttonTex = new Map,
  140536. this._nameLinesLimit = 2,
  140537. this._nameLengthPerLine = 16,
  140538. this._pickBbox = null,
  140539. this.bbox = void 0,
  140540. this._height = .26,
  140541. this._attachmentObservers = new Map,
  140542. this.attachToAvatar = (i,o,s=!1,c={
  140543. x: 0,
  140544. y: 0,
  140545. z: 0
  140546. },d=!1,_)=>{
  140547. const b = i.rootNode;
  140548. if (this.bbox || i.getBbox(),
  140549. o && b) {
  140550. let k = this._attachmentObservers.get(o);
  140551. if (k)
  140552. if (d)
  140553. this._scene.onBeforeRenderObservable.remove(k),
  140554. this._attachmentObservers.delete(o);
  140555. else
  140556. return;
  140557. const j = ue4Position2Xverse(c);
  140558. s ? (o.setParent(b),
  140559. o.position = j) : (k = this._scene.onBeforeRenderObservable.add(()=>{
  140560. let$ = 0;
  140561. _ ? ($ = i.rootNode.rotation.y / Math.PI * 180 + 90,
  140562. i.rootNode.rotation.y && (o.rotation.y = i.rootNode.rotation.y)) : $ = i.avatarManager.sceneManager.cameraComponent.getCameraPose().rotation.yaw,
  140563. $ || ($ = 0);
  140564. const _e = new Vector3(0,this._height,0);
  140565. i.controller && i.controller.activeAnimation() && i.controller.activeAnimation().animatables[0] && (this._height = _e.y = (i.controller.activeAnimation().animatables[0].target.position.y * .01 - .66) * i.scale),
  140566. _e.y < .07 * i.scale && (_e.y = 0),
  140567. o.position.x = b.position.x + j.x * Math.sin($ * Math.PI / 180) + j.z * Math.cos($ * Math.PI / 180),
  140568. o.position.z = b.position.z + j.x * Math.cos($ * Math.PI / 180) - j.z * Math.sin($ * Math.PI / 180),
  140569. o.position.y = b.position.y + this.bbox.maximum.y + j.y + _e.y
  140570. }
  140571. ),
  140572. this._attachmentObservers.set(o, k))
  140573. } else
  140574. log$G.error("avatar or attachment not found!")
  140575. }
  140576. ,
  140577. this.detachFromAvatar = (i,o,s=!1)=>{
  140578. const c = this._attachmentObservers.get(o);
  140579. c && this._scene.onBeforeRenderObservable.remove(c),
  140580. i.rootNode ? (o.setEnabled(!1),
  140581. o.parent = null,
  140582. s && o.dispose()) : log$G.error("avatar not found!")
  140583. }
  140584. ,
  140585. this.getBbox = (i,o={})=>{
  140586. const {isConst: s=!1, changeWithAvatar: c=!1} = o;
  140587. let {localCenter: d={
  140588. x: 0,
  140589. y: 0,
  140590. z: 75
  140591. }, width: _=1.32, height: b=1.5, depth: k=.44} = o;
  140592. if (c) {
  140593. const j = i.scale;
  140594. d = {
  140595. x: d.x * j,
  140596. y: d.y * j,
  140597. z: d.z * j
  140598. },
  140599. _ *= j,
  140600. b *= j,
  140601. k *= j
  140602. }
  140603. if (i.rootNode) {
  140604. let j = new Vector3(0,0,0)
  140605. , $ = new Vector3(0,0,0);
  140606. if (s) {
  140607. const et = ue4Position2Xverse(d);
  140608. j = j.add(et.add(new Vector3(-_ / 2,-b / 2,-k / 2))),
  140609. $ = $.add(et.add(new Vector3(_ / 2,b / 2,k / 2)))
  140610. } else if (j = j.add(new Vector3(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY)),
  140611. $ = $.add(new Vector3(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY)),
  140612. i.isRender) {
  140613. i.rootNode.getChildMeshes().forEach(rt=>{
  140614. const it = rt.getBoundingInfo().boundingBox.minimum
  140615. , nt = rt.getBoundingInfo().boundingBox.maximum;
  140616. j.x = Math.min(j.x, it.x),
  140617. $.x = Math.max($.x, nt.x),
  140618. j.y = Math.min(j.y, it.y),
  140619. $.y = Math.max($.y, nt.y),
  140620. j.z = Math.min(j.z, it.z),
  140621. $.z = Math.max($.z, nt.z)
  140622. }
  140623. );
  140624. const et = $.x - j.x
  140625. , tt = $.z - j.z;
  140626. j.x -= i.scale * et / 2,
  140627. $.x += i.scale * et / 2,
  140628. $.y *= i.scale,
  140629. j.z -= i.scale * tt / 2,
  140630. $.z += i.scale * tt / 2
  140631. } else {
  140632. const et = i.avatarManager.getMainAvatar();
  140633. et && et.bbComponent.bbox && (j.x = et.bbComponent.bbox.minimum.x,
  140634. $.x = et.bbComponent.bbox.maximum.x,
  140635. j.y = et.bbComponent.bbox.minimum.y,
  140636. $.y = et.bbComponent.bbox.maximum.y,
  140637. j.z = et.bbComponent.bbox.minimum.z,
  140638. $.z = et.bbComponent.bbox.maximum.z)
  140639. }
  140640. const _e = i.rootNode.computeWorldMatrix(!0);
  140641. this.bbox ? this.bbox.reConstruct(j, $, _e) : this.bbox = new BoundingBox(j,$,_e),
  140642. this._pickBbox == null
  140643. } else
  140644. log$G.error("avatar not found!")
  140645. }
  140646. ,
  140647. this._scene = e
  140648. }
  140649. get isNameVisible() {
  140650. return this._isNameVisible
  140651. }
  140652. get isBubbleVisible() {
  140653. return this._isBubbleVisible
  140654. }
  140655. get isGiftButtonsVisible() {
  140656. return this._isGiftButtonsVisible
  140657. }
  140658. get words() {
  140659. return this._words
  140660. }
  140661. get nickName() {
  140662. return this._nickName
  140663. }
  140664. get giftButtons() {
  140665. return this._giftButtons
  140666. }
  140667. get bubble() {
  140668. return this._bubble
  140669. }
  140670. get nameBoard() {
  140671. return this._nameBoard
  140672. }
  140673. setNicknameStatus(e) {
  140674. var i;
  140675. if (this.nameBoard && this.nameBoard.setStatus(e),
  140676. e == BillboardStatus.DISPOSE) {
  140677. const o = (i = this.nameBoard) == null ? void 0 : i.getMesh();
  140678. if (o) {
  140679. const s = this._attachmentObservers.get(o);
  140680. s && (this._scene.onBeforeRenderObservable.remove(s),
  140681. this._attachmentObservers.delete(o))
  140682. }
  140683. }
  140684. }
  140685. setBubbleStatus(e) {
  140686. var i;
  140687. if (this.bubble && this.bubble.setStatus(e),
  140688. e == BillboardStatus.DISPOSE) {
  140689. const o = (i = this.bubble) == null ? void 0 : i.getMesh();
  140690. if (o) {
  140691. const s = this._attachmentObservers.get(o);
  140692. s && (this._scene.onBeforeRenderObservable.remove(s),
  140693. this._attachmentObservers.delete(o))
  140694. }
  140695. }
  140696. }
  140697. setButtonsStatus(e) {
  140698. this.giftButtons && this.giftButtons.size != 0 && this.giftButtons.forEach(i=>{
  140699. if (i.setStatus(e),
  140700. e == BillboardStatus.DISPOSE && i.getMesh()) {
  140701. const o = i.getMesh();
  140702. if (o) {
  140703. const s = this._attachmentObservers.get(o);
  140704. s && (this._scene.onBeforeRenderObservable.remove(s),
  140705. this._attachmentObservers.delete(o))
  140706. }
  140707. }
  140708. }
  140709. )
  140710. }
  140711. setGiftButtonsVisible(e) {
  140712. this.setButtonsStatus(e ? BillboardStatus.SHOW : BillboardStatus.DISPOSE)
  140713. }
  140714. dispose(e) {
  140715. this._attachmentObservers.forEach(i=>{
  140716. this._scene.onBeforeRenderObservable.remove(i)
  140717. }
  140718. ),
  140719. this._attachmentObservers.clear(),
  140720. this.updateBillboardStatus(e, BillboardStatus.DISPOSE),
  140721. this._buttonTex.clear(),
  140722. this._pickBbox && (e.avatarManager.bboxMeshPool.release(this._pickBbox),
  140723. this._pickBbox = null)
  140724. }
  140725. updateBillboardStatus(e, i) {
  140726. this.bbox || e.getBbox(),
  140727. e.isRender ? (e.setBubbleStatus(i),
  140728. e.setButtonsStatus(i),
  140729. e.setNicknameStatus(i)) : (e.setBubbleStatus(BillboardStatus.DISPOSE),
  140730. e.setButtonsStatus(BillboardStatus.DISPOSE),
  140731. e.enableNickname ? e.setNicknameStatus(i) : e.setNicknameStatus(BillboardStatus.DISPOSE))
  140732. }
  140733. disposeBillBoard(e) {
  140734. this._attachmentObservers.forEach(i=>{
  140735. this._scene.onBeforeRenderObservable.remove(i)
  140736. }
  140737. ),
  140738. this._attachmentObservers.clear(),
  140739. this.updateBillboardStatus(e, BillboardStatus.DISPOSE),
  140740. this._buttonTex.clear(),
  140741. this._pickBbox && (e.avatarManager.bboxMeshPool.release(this._pickBbox),
  140742. this._pickBbox = null)
  140743. }
  140744. setPickBoxScale(e) {
  140745. this._pickBbox && this._pickBbox.data && (this._pickBbox.data.scaling = new Vector3(e,e,e))
  140746. }
  140747. setIsPickable(e, i) {
  140748. e.rootNode && e.rootNode.getChildMeshes().forEach(o=>{
  140749. o.isPickable = i
  140750. }
  140751. ),
  140752. this._pickBbox && this._pickBbox.data && (this._pickBbox.data.isPickable = i)
  140753. }
  140754. initNameboard(e, i=1) {
  140755. this._nameBoard == null && (this._nameBoard = e.avatarManager.sceneManager.billboardComponent.addBillboard("name-" + e.id, !1, !0)),
  140756. this._nameBoard.init("nickname", i / 300, i / 300)
  140757. }
  140758. initBubble(e, i=1) {
  140759. this._bubble == null && (this._bubble = e.avatarManager.sceneManager.billboardComponent.addBillboard("bubble-" + e.id, !1, !0)),
  140760. e.isRender && this._bubble.init("bubble", i / 250, i / 250)
  140761. }
  140762. say(e, i=this._words, {id: o, isUser: s, background: c, font: d="Arial", fontsize: _=38, fontcolor: b="#ffffff", fontstyle: k="bold", linesize: j=22, linelimit: $, offsets: _e={
  140763. x: 0,
  140764. y: 0,
  140765. z: 40
  140766. }, scale: et, compensationZ: tt=11.2, reregistAnyway: rt=!0}) {
  140767. (!this.bubble || this.bubble.getMesh() == null) && e.initBubble(),
  140768. this._words = i;
  140769. let it;
  140770. s != null && (it = s ? XBillboardManager.userBubbleUrls : XBillboardManager.npcBubbleUrls),
  140771. this._bubble && (this._bubble.DEFAULT_CONFIGS = {
  140772. id: o,
  140773. isUser: s,
  140774. background: c || it,
  140775. font: d,
  140776. fontsize: _,
  140777. fontcolor: b,
  140778. fontstyle: k,
  140779. linesize: j,
  140780. linelimit: $,
  140781. offsets: _e,
  140782. scale: et,
  140783. compensationZ: tt,
  140784. reregistAnyway: rt
  140785. },
  140786. this._bubble.getMesh() && (e.avatarManager.enableBubble ? (this._bubble.drawBillboard({
  140787. imageList: c || it
  140788. }, {
  140789. texts: this._words,
  140790. font: d,
  140791. fontsize: _,
  140792. fontcolor: b,
  140793. fontstyle: k,
  140794. linesize: j
  140795. }, {
  140796. offsets: _e,
  140797. scale: et,
  140798. compensationZ: tt
  140799. }),
  140800. this.attachToAvatar(e, this._bubble.getMesh(), !1, this._bubble.offsets, rt)) : this.setBubbleStatus(BillboardStatus.DISPOSE),
  140801. o && this._bubble.setId(o))),
  140802. this.setButtonsStatus(BillboardStatus.DISPOSE)
  140803. }
  140804. silent() {
  140805. this.setBubbleStatus(BillboardStatus.DISPOSE),
  140806. this._words = ""
  140807. }
  140808. setNickName(e, i, {id: o, isUser: s, background: c, font: d="Arial", fontsize: _=40, fontcolor: b="#ffffff", fontstyle: k="bold", linesize: j=22, linelimit: $, offsets: _e={
  140809. x: 0,
  140810. y: 0,
  140811. z: 15
  140812. }, scale: et, compensationZ: tt=0, reregistAnyway: rt=!1}) {
  140813. this._nickName = i,
  140814. (!this.nameBoard || this.nameBoard.getMesh() == null) && this.initNameboard(e),
  140815. this._nameBoard && this._nameBoard.getMesh() && (this._nameBoard.DEFAULT_CONFIGS = {
  140816. id: o,
  140817. isUser: s,
  140818. background: c,
  140819. font: d,
  140820. fontsize: _,
  140821. fontcolor: b,
  140822. fontstyle: k,
  140823. linesize: j,
  140824. linelimit: $,
  140825. offsets: _e,
  140826. scale: et,
  140827. compensationZ: tt,
  140828. reregistAnyway: rt
  140829. },
  140830. e.avatarManager.enableNickname ? (this._nameBoard.drawBillboard({}, {
  140831. texts: this._nickName,
  140832. font: d,
  140833. fontsize: _,
  140834. fontcolor: b,
  140835. fontstyle: k,
  140836. linesize: j,
  140837. linelimit: $
  140838. }, {
  140839. offsets: _e,
  140840. scale: et,
  140841. compensationZ: 0
  140842. }),
  140843. this.attachToAvatar(e, this._nameBoard.getMesh(), !1, this._nameBoard.offsets, rt)) : this.setNicknameStatus(BillboardStatus.DISPOSE),
  140844. o && this._nameBoard.setId(o))
  140845. }
  140846. generateButtons(e, i=null, o, s=85) {
  140847. if (i && (this._buttonTex = i,
  140848. this.clearButtons()),
  140849. this._buttonTex.size == 0)
  140850. return;
  140851. let c = (this._buttonTex.size - 1) / 2;
  140852. this._buttonTex.forEach((d,_)=>{
  140853. let b = this._giftButtons.get(_);
  140854. b || (b = e.avatarManager.sceneManager.billboardComponent.addBillboard("button-" + _ + e.id, !0, !1),
  140855. b.init(_, o / 240, o / 240));
  140856. const k = {
  140857. x: o * c * 70,
  140858. y: 0,
  140859. z: o * (s - 20 * (c * c))
  140860. };
  140861. b.drawBillboard({
  140862. imageList: [d]
  140863. }, {}, {
  140864. offsets: k,
  140865. scale: o
  140866. }),
  140867. this.attachToAvatar(e, b.getMesh(), !1, b.offsets, !0),
  140868. this._giftButtons.set(_, b),
  140869. c -= 1
  140870. }
  140871. ),
  140872. this.setBubbleStatus(BillboardStatus.DISPOSE)
  140873. }
  140874. clearButtons() {
  140875. this._giftButtons.forEach(e=>{
  140876. e.dispose()
  140877. }
  140878. ),
  140879. this._giftButtons.clear()
  140880. }
  140881. createPickBoundingbox(e, i) {
  140882. const o = i.extendSize.x * 2
  140883. , s = i.extendSize.y * 2
  140884. , c = i.extendSize.z * 2
  140885. , d = this._scene
  140886. , _ = Math.max(o, c)
  140887. , b = e.avatarManager.bboxMeshPool.getFree(d, _, s, _)
  140888. , k = b.data;
  140889. return k && (k.position = i.centerWorld,
  140890. k.setEnabled(!1),
  140891. k.isPickable = !0,
  140892. k.xtype = EMeshType.XAvatar,
  140893. k.xid = e.id),
  140894. b
  140895. }
  140896. }
  140897. const log$F = new Logger$1("Avatar")
  140898. , castRayOffsetY = .01
  140899. , castRayTeleportationOffset = 10;
  140900. class XAvatar {
  140901. constructor({id: e, avatarType: i, priority: o, avatarManager: s, assets: c, status: d}) {
  140902. this.id = "-1",
  140903. this.priority = 0,
  140904. this.isRender = !1,
  140905. this.distLevel = 0,
  140906. this.isInLoadingList = !1,
  140907. this.isHide = !1,
  140908. this.clothesList = [],
  140909. this.isSelected = !1,
  140910. this.pendingLod = !1,
  140911. this._previousReceivedPosition = new Vector3(0,1e4,0),
  140912. this.rootNode = void 0,
  140913. this.distToCam = 1e11,
  140914. this.enableNickname = !0,
  140915. this.distance = 1e11,
  140916. this.isCulling = !1,
  140917. this.reslevel = 0,
  140918. this.isInLoadingQueue = !1,
  140919. this._scene = void 0,
  140920. this._transparent = 0,
  140921. this.hide = ()=>(this.isHide = !0,
  140922. this._hide(),
  140923. !this.isRender),
  140924. this._show = ()=>{
  140925. var _;
  140926. this.isHide || (this.setIsPickable(!0),
  140927. this.bbComponent._attachmentObservers.forEach((b,k)=>{
  140928. k.setEnabled(!0)
  140929. }
  140930. ),
  140931. this.priority == 0 && (this.rootNode.setEnabled(!0),
  140932. this.isRender = !0,
  140933. this.avatarManager._updateBillboardStatus(this, BillboardStatus.SHOW),
  140934. this.component.accessories.forEach(b=>{
  140935. b.rootComponent.setEnabled(!0)
  140936. }
  140937. ),
  140938. (_ = this.controller) == null || _.playAnimation(this.controller.onPlay, this.controller.loop)),
  140939. this.component.accessories.forEach(b=>{
  140940. b.rootComponent.setEnabled(!0)
  140941. }
  140942. ))
  140943. }
  140944. ,
  140945. this.show = ()=>(this.isHide = !1,
  140946. this._show(),
  140947. !!this.isRender),
  140948. this.setAnimations = _=>{
  140949. this.controller.animations = _
  140950. }
  140951. ,
  140952. this.attachToAvatar = (_,b=!1,k={
  140953. x: 0,
  140954. y: 0,
  140955. z: 0
  140956. },j=!1,$,_e)=>this.bbComponent.attachToAvatar(this, _, b, k, j, _e),
  140957. this.detachFromAvatar = (_,b=!1)=>this.bbComponent.detachFromAvatar(this, _, b),
  140958. this.getBbox = (_={})=>this.bbComponent.getBbox(this, _),
  140959. this.id = e,
  140960. this._avatarManager = s,
  140961. this._scene = this.avatarManager.scene,
  140962. this.clothesList = c,
  140963. this._avatarType = i,
  140964. this.priority = o || 0,
  140965. this.controller = new XAnimationController(this),
  140966. this.component = new XAvatarComopnent,
  140967. this.stateMachine = new XStateMachine(this._scene),
  140968. this.bbComponent = new XAvatarBillboardComponent(this._scene),
  140969. this.rootNode = new TransformNode(e,this._avatarManager.scene),
  140970. this._avatarScale = d.avatarScale == null ? 1 : d.avatarScale,
  140971. this._avatarRotation = d.avatarRotation == null ? {
  140972. pitch: 0,
  140973. yaw: 0,
  140974. roll: 0
  140975. } : d.avatarRotation,
  140976. this._avatarPosition = d.avatarPosition == null ? {
  140977. x: 0,
  140978. y: 0,
  140979. z: 0
  140980. } : d.avatarPosition,
  140981. this._isRayCastEnable = avatarSetting.isRayCastEnable,
  140982. this.setPosition(this._avatarPosition, !0),
  140983. this.setRotation(this._avatarRotation),
  140984. this.setScale(this.scale),
  140985. this._isRayCastEnable = avatarSetting.isRayCastEnable,
  140986. this._scene.registerBeforeRender(()=>{
  140987. this.tick()
  140988. }
  140989. )
  140990. }
  140991. tick() {
  140992. this.cullingTick()
  140993. }
  140994. cullingTick() {
  140995. var e;
  140996. this.isCulling && ((e = this.rootNode) == null || e.getChildMeshes().forEach(i=>{
  140997. this.distToCam < 50 ? i.visibility = 0 : i.visibility = this._transparent
  140998. }
  140999. ))
  141000. }
  141001. setTransParentThresh(e) {
  141002. this._transparent = e
  141003. }
  141004. get isNameVisible() {
  141005. return this.bbComponent.isNameVisible
  141006. }
  141007. get isBubbleVisible() {
  141008. return this.bbComponent.isBubbleVisible
  141009. }
  141010. get isGiftButtonsVisible() {
  141011. return this.bbComponent.isGiftButtonsVisible
  141012. }
  141013. get words() {
  141014. return this.bbComponent.words
  141015. }
  141016. get nickName() {
  141017. return this.bbComponent.nickName
  141018. }
  141019. get giftButtons() {
  141020. return this.bbComponent.giftButtons
  141021. }
  141022. get bubble() {
  141023. return this.bbComponent.bubble
  141024. }
  141025. get nameBoard() {
  141026. return this.bbComponent.nameBoard
  141027. }
  141028. get avatarManager() {
  141029. return this._avatarManager
  141030. }
  141031. set withinVisibleRange(e) {
  141032. this.bbComponent.withinVisualRange = e
  141033. }
  141034. setNicknameStatus(e) {
  141035. return this.bbComponent.setNicknameStatus(e)
  141036. }
  141037. setBubbleStatus(e) {
  141038. return this.bbComponent.setBubbleStatus(e)
  141039. }
  141040. setButtonsStatus(e) {
  141041. return this.bbComponent.setBubbleStatus(e)
  141042. }
  141043. setGiftButtonsVisible(e) {
  141044. return this.bbComponent.setGiftButtonsVisible(e)
  141045. }
  141046. get avatarType() {
  141047. return this._avatarType
  141048. }
  141049. attachBody(e) {
  141050. return this.component.addBodyComp(this, e)
  141051. }
  141052. attachDecoration(e) {
  141053. return this.component.addClothesComp(this, e)
  141054. }
  141055. detachDecoration(e) {
  141056. return this.component.clearClothesComp(e)
  141057. }
  141058. detachDecorationAll() {
  141059. return this.component.clearAllClothesComps()
  141060. }
  141061. get skeleton() {
  141062. return this.component.skeleton
  141063. }
  141064. get position() {
  141065. return this._avatarPosition
  141066. }
  141067. get rotation() {
  141068. return this._avatarRotation
  141069. }
  141070. get scale() {
  141071. return this._avatarScale
  141072. }
  141073. _hide_culling() {
  141074. this.bbComponent.updateBillboardStatus(this, BillboardStatus.HIDE),
  141075. this.isCulling = !0
  141076. }
  141077. _show_culling() {
  141078. this.isCulling && (this.rootNode && this.rootNode.getChildMeshes().forEach(e=>{
  141079. e.visibility = 1
  141080. }
  141081. ),
  141082. this.bbComponent.updateBillboardStatus(this, BillboardStatus.SHOW),
  141083. this.isCulling = !1)
  141084. }
  141085. _hide() {
  141086. !this.isHide || (this.setIsPickable(!1),
  141087. this.bbComponent._attachmentObservers.forEach((e,i)=>{
  141088. i.setEnabled(!1)
  141089. }
  141090. ),
  141091. this.priority == 0 ? (this.rootNode.setEnabled(!1),
  141092. this.isRender = !1,
  141093. this.bbComponent.updateBillboardStatus(this, BillboardStatus.HIDE),
  141094. this.component.accessories.forEach(e=>{
  141095. e.rootComponent.setEnabled(!1)
  141096. }
  141097. )) : this.isRender && (this.avatarManager.currentLODUsers[this.distLevel]--,
  141098. this.removeAvatarFromScene()),
  141099. this.component.accessories.forEach(e=>{
  141100. e.rootComponent.setEnabled(!1)
  141101. }
  141102. ))
  141103. }
  141104. rotate(e, i, o) {
  141105. return this.stateMachine.roll(this, e, i, o)
  141106. }
  141107. set isRayCastEnable(e) {
  141108. this._isRayCastEnable = e
  141109. }
  141110. get isRayCastEnable() {
  141111. return this._isRayCastEnable
  141112. }
  141113. getAvatarId() {
  141114. return this.id
  141115. }
  141116. getAvaliableAnimations() {
  141117. const e = avatarLoader.avaliableAnimation.get(this.avatarType);
  141118. return e || []
  141119. }
  141120. setPosition(e, i=!1) {
  141121. if (this._avatarPosition = e,
  141122. this.rootNode) {
  141123. const o = ue4Position2Xverse(this._avatarPosition);
  141124. let s = !1;
  141125. this.avatarManager.getMainAvatar() && (this.id != this.avatarManager.getMainAvatar().id || (Math.abs(o.y - this._previousReceivedPosition.y) > castRayOffsetY && (s = !0),
  141126. o.subtract(this._previousReceivedPosition).length() > castRayTeleportationOffset && (s = !0))),
  141127. this._isRayCastEnable ? s || i ? this._castRay(e).then(c=>{
  141128. this.rootNode.position = o,
  141129. this.rootNode.position.y -= c
  141130. }
  141131. ).catch(c=>{
  141132. Promise.reject(c)
  141133. }
  141134. ) : (this.rootNode.position.x = o.x,
  141135. this.rootNode.position.z = o.z) : this.rootNode.position = o,
  141136. this._previousReceivedPosition = o.clone()
  141137. }
  141138. return Promise.resolve(e)
  141139. }
  141140. setRotation(e) {
  141141. if (this._avatarRotation = e,
  141142. this.rootNode) {
  141143. const i = {
  141144. pitch: e.pitch,
  141145. yaw: e.yaw + 180,
  141146. roll: e.roll
  141147. }
  141148. , o = ue4Rotation2Xverse(i);
  141149. this.rootNode.rotation = o
  141150. }
  141151. }
  141152. setAvatarVisible(e) {
  141153. this.rootNode && (this.rootNode.setEnabled(e),
  141154. this.rootNode.getChildMeshes().forEach(i=>{
  141155. i.setEnabled(e)
  141156. }
  141157. ))
  141158. }
  141159. setScale(e) {
  141160. this._avatarScale = e,
  141161. this.rootNode && (this.rootNode.scaling = new Vector3(e,e,e)),
  141162. this.bbComponent.bbox && this.getBbox()
  141163. }
  141164. _removeAvatarFromScene() {
  141165. var e, i;
  141166. this.isRender = !1,
  141167. (e = this.controller) == null || e.detachAnimation(),
  141168. this.component.dispose(this),
  141169. (i = this.avatarManager.sceneManager) == null || i.lightComponent.removeShadow(this),
  141170. this.component.accessories.forEach(o=>{
  141171. o.rootComponent.setEnabled(!1)
  141172. }
  141173. )
  141174. }
  141175. removeAvatarFromScene() {
  141176. this._removeAvatarFromScene(),
  141177. this._disposeBillBoard()
  141178. }
  141179. _disposeBillBoard() {
  141180. this.bbComponent.disposeBillBoard(this)
  141181. }
  141182. addComponent(e, i, o, s) {
  141183. return i === "pendant" ? this.component.attachPendant(this, e) : this.component.changeClothesComp(this, e, i, o, s)
  141184. }
  141185. removeComponent(e, i) {
  141186. if (e === "pendant")
  141187. i ? this.component.detachPendant(i) : this.component.accessories.forEach((o,s)=>{
  141188. this.component.detachPendant(s)
  141189. }
  141190. );
  141191. else {
  141192. const o = this.component.resourceIdList.find(s=>s.type == e);
  141193. o && (this.detachDecoration(o),
  141194. this.clothesList = this.clothesList.filter(s=>s.type != e))
  141195. }
  141196. }
  141197. getComponentByType(e, i) {
  141198. if (e === "pendant")
  141199. if (i) {
  141200. const o = this.component.accessories.get(i);
  141201. return o || []
  141202. } else
  141203. return Array.from(this.component.accessories).map(o=>o[1]);
  141204. else
  141205. return this.component.resourceIdList.find(o=>o.type == e)
  141206. }
  141207. _castRay(e) {
  141208. return new Promise((i,o)=>{
  141209. var et;
  141210. const s = ue4Position2Xverse(e)
  141211. , c = new Vector3(0,-1,0)
  141212. , d = 1.5 * this.scale
  141213. , _ = 100 * d
  141214. , b = d
  141215. , k = new Vector3(s.x,s.y + b,+s.z)
  141216. , j = new Ray(k,c,_)
  141217. , $ = (et = this.avatarManager.sceneManager) == null ? void 0 : et.getGround(e);
  141218. if (!$ || $.length <= 0)
  141219. return log$F.warn(`\u89D2\u8272 id= ${this.id} \u627E\u4E0D\u5230\u5730\u9762\uFF0C\u5F53\u524D\u9AD8\u5EA6\u4E3A\u4E0B\u53D1\u9AD8\u5EA6`),
  141220. i(0);
  141221. let _e = j.intersectsMeshes($);
  141222. if (_e.length > 0)
  141223. return i(_e[0].distance - b);
  141224. if (c.y = 1,
  141225. _e = j.intersectsMeshes($),
  141226. _e.length > 0)
  141227. return i(-(_e[0].distance - b))
  141228. }
  141229. )
  141230. }
  141231. setPickBoxScale(e) {
  141232. return this.bbComponent.setPickBoxScale(e)
  141233. }
  141234. setIsPickable(e) {
  141235. return this.bbComponent.setIsPickable(this, e)
  141236. }
  141237. createPickBoundingbox(e) {
  141238. return this.bbComponent.createPickBoundingbox(this, e)
  141239. }
  141240. scaleBbox(e) {
  141241. this.bbComponent.bbox && this.bbComponent.bbox.scale(e)
  141242. }
  141243. rotateTo(e, i, o) {
  141244. return this.stateMachine.rotateTo(this, e, i, o)
  141245. }
  141246. faceTo(e, i) {
  141247. return this.stateMachine.lookAt(this, e, i)
  141248. }
  141249. removeObserver() {
  141250. this.stateMachine.disposeObsever()
  141251. }
  141252. moveHermite(e, i, o, s, c, d) {
  141253. return this.stateMachine.moveToHermite(this, e, i, o, s, c, d)
  141254. }
  141255. moveCardinal(e, i, o, s, c, d, _=!1) {
  141256. return this.stateMachine.moveToCardinal(this, e, i, o, s, c, d, _)
  141257. }
  141258. move(e, i, o, s, c, d=!1) {
  141259. return this.stateMachine.moveTo(this, e, i, o, s, c, d)
  141260. }
  141261. initNameboard(e=1) {
  141262. return this.bbComponent.initNameboard(this, e)
  141263. }
  141264. initBubble(e=1) {
  141265. return this.bbComponent.initBubble(this, e)
  141266. }
  141267. say(e, {id: i, isUser: o, background: s, font: c="Arial", fontsize: d=38, fontcolor: _="#ffffff", fontstyle: b="bold", linesize: k=22, linelimit: j, offsets: $={
  141268. x: 0,
  141269. y: 0,
  141270. z: 40
  141271. }, scale: _e=this._avatarScale, compensationZ: et=11.2, reregistAnyway: tt=!0}) {
  141272. return this.bbComponent.say(this, e, {
  141273. id: i,
  141274. isUser: o,
  141275. background: s,
  141276. font: c,
  141277. fontsize: d,
  141278. fontcolor: _,
  141279. fontstyle: b,
  141280. linesize: k,
  141281. linelimit: j,
  141282. offsets: $,
  141283. scale: _e,
  141284. compensationZ: et,
  141285. reregistAnyway: tt
  141286. })
  141287. }
  141288. silent() {
  141289. return this.bbComponent.silent()
  141290. }
  141291. setNickName(e, {id: i, isUser: o, background: s, font: c="Arial", fontsize: d=40, fontcolor: _="#ffffff", fontstyle: b="bold", linesize: k=22, linelimit: j, offsets: $={
  141292. x: 0,
  141293. y: 0,
  141294. z: 15
  141295. }, scale: _e=this._avatarScale, compensationZ: et=0, reregistAnyway: tt=!1}) {
  141296. return this.bbComponent.setNickName(this, e, {
  141297. id: i,
  141298. isUser: o,
  141299. background: s,
  141300. font: c,
  141301. fontsize: d,
  141302. fontcolor: _,
  141303. fontstyle: b,
  141304. linesize: k,
  141305. linelimit: j,
  141306. offsets: $,
  141307. scale: _e,
  141308. compensationZ: et,
  141309. reregistAnyway: tt
  141310. })
  141311. }
  141312. generateButtons(e=null, i=this._avatarScale, o=85) {
  141313. return this.bbComponent.generateButtons(this, e, i, o)
  141314. }
  141315. clearButtons() {
  141316. return this.bbComponent.clearButtons()
  141317. }
  141318. attachExtraProp(e, i, o, s) {
  141319. return this.component.addDecoComp(this, e, i, o, s)
  141320. }
  141321. showExtra(e) {
  141322. return this.component.showExtra(e)
  141323. }
  141324. hideExtra(e) {
  141325. return this.component.hideExtra(e)
  141326. }
  141327. disposeExtra() {
  141328. return this.component.disposeExtra()
  141329. }
  141330. getSkeletonPositionByName(e) {
  141331. var i;
  141332. if (this.skeleton) {
  141333. const o = this.skeleton.bones.find(s=>s.name.replace("Clone of ", "") == e);
  141334. if (o && o.getTransformNode() && ((i = o.getTransformNode()) == null ? void 0 : i.position)) {
  141335. const s = o.getTransformNode().position;
  141336. return xversePosition2Ue4({
  141337. x: s.x,
  141338. y: s.y,
  141339. z: s.z
  141340. })
  141341. }
  141342. }
  141343. }
  141344. shootTo(e, i, o=2, s=10, c={
  141345. x: 0,
  141346. y: 0,
  141347. z: 150
  141348. }) {
  141349. return this.stateMachine.sendObjectTo(this, e, i, o, s, c)
  141350. }
  141351. }
  141352. const log$E = new Logger$1("AvatarManager");
  141353. var EAvatarRelationRank = (a=>(a[a.Self = 0] = "Self",
  141354. a[a.Npc = 1] = "Npc",
  141355. a[a.Friend = 2] = "Friend",
  141356. a[a.Stranger = 3] = "Stranger",
  141357. a[a.Robot = 4] = "Robot",
  141358. a[a.Unknown = 5] = "Unknown",
  141359. a))(EAvatarRelationRank || {});
  141360. class XAvatarManager {
  141361. constructor(e) {
  141362. this.characterMap = new Map,
  141363. this.curAnimList = [],
  141364. this.extraComps = new Map,
  141365. this._mainUser = void 0,
  141366. this._sceneManager = void 0,
  141367. this.maxBillBoardDist = 0,
  141368. this.maxAvatarNum = 0,
  141369. this.currentLODUsers = [],
  141370. this._distLevels = [],
  141371. this._maxLODUsers = [],
  141372. this._cullingDistance = 0,
  141373. this._delayTime = 100,
  141374. this._queueLength = -1,
  141375. this._queue = [],
  141376. this._processList = [],
  141377. this._process = void 0,
  141378. this._updateLoopObserver = void 0,
  141379. this._enableNickname = !0,
  141380. this._enableBubble = !0,
  141381. this._defaultAnims = void 0,
  141382. this._tickDispose = 0,
  141383. this._disposeTime = 10,
  141384. this.avatarLoader = avatarLoader,
  141385. this.onThingsLoading = !1,
  141386. this.compMap = new Map,
  141387. this._scene = e.mainScene,
  141388. this._sceneManager = e,
  141389. this.initAvatarMap(),
  141390. this._initSettings(),
  141391. this._maxDistRange = this._distLevels[this._distLevels.length - 1],
  141392. this.bboxMeshPool = new Pool(this.createBboxAsset,this.resetBboxAsset,0,0,this._sceneManager.Scene,0,0,0),
  141393. this._tickInterval = 250;
  141394. let i = 0;
  141395. this._tickObserver = this._scene.onAfterRenderObservable.add(()=>{
  141396. i += 1,
  141397. i == this._tickInterval && (this.tick(),
  141398. i = 0)
  141399. }
  141400. )
  141401. }
  141402. tick() {
  141403. this.bboxMeshPool.clean(0)
  141404. }
  141405. createBboxAsset(e, i, o, s) {
  141406. return MeshBuilder.CreateBox("avatarBbox", {
  141407. width: i,
  141408. height: o,
  141409. depth: s
  141410. }, e)
  141411. }
  141412. resetBboxAsset(e) {
  141413. const i = e.data;
  141414. return i.setEnabled(!1),
  141415. i.isPickable = !1,
  141416. e
  141417. }
  141418. _initSettings() {
  141419. this._defaultAnims = avatarSetting.defaultIdle,
  141420. this._lodSettings = avatarSetting.lod,
  141421. this._distLevels = avatarSetting.lod.map(e=>e.dist),
  141422. this._maxLODUsers = avatarSetting.lod.map(e=>e.quota),
  141423. this.currentLODUsers = new Array(this._distLevels.length).fill(0),
  141424. this.maxAvatarNum = avatarSetting.maxAvatarNum,
  141425. this.maxBillBoardDist = avatarSetting.maxBillBoardDist,
  141426. this._cullingDistance = avatarSetting.cullingDistance
  141427. }
  141428. maxRenderNum() {
  141429. let e = 0;
  141430. return this._maxLODUsers.forEach(i=>{
  141431. e += i
  141432. }
  141433. ),
  141434. e
  141435. }
  141436. curRenderNum() {
  141437. let e = 0;
  141438. return this.currentLODUsers.forEach(i=>{
  141439. e += i
  141440. }
  141441. ),
  141442. e
  141443. }
  141444. setLoDLevels(e) {
  141445. this._distLevels = e
  141446. }
  141447. set cullingDistance(e) {
  141448. this._cullingDistance = e
  141449. }
  141450. get cullingDistance() {
  141451. return this._cullingDistance
  141452. }
  141453. getLoDLevels() {
  141454. return this._distLevels
  141455. }
  141456. setLodUserLimits(e, i) {
  141457. this._maxLODUsers.length > e && (this._maxLODUsers[e] = i)
  141458. }
  141459. setLodDist(e, i) {
  141460. this._distLevels[e] = i
  141461. }
  141462. setMaxDistRange(e) {
  141463. this._maxDistRange = e,
  141464. this._distLevels[this._distLevels.length - 1] = e
  141465. }
  141466. get scene() {
  141467. return this._scene
  141468. }
  141469. setMainAvatar(e) {
  141470. var i;
  141471. this._mainUser = (i = this.characterMap.get(0)) == null ? void 0 : i.get(e)
  141472. }
  141473. getMainAvatar() {
  141474. return this._mainUser
  141475. }
  141476. get enableNickname() {
  141477. return this._enableNickname
  141478. }
  141479. get enableBubble() {
  141480. return this._enableBubble
  141481. }
  141482. enableAllNickname(e) {
  141483. this._enableNickname = e,
  141484. this.characterMap.forEach(i=>{
  141485. i.forEach(o=>{
  141486. e ? o.nameBoard && o.nickName.length > 0 && o.isRender && o.setNickName(o.nickName, o.nameBoard.DEFAULT_CONFIGS) : o.setNicknameStatus(BillboardStatus.DISPOSE)
  141487. }
  141488. )
  141489. }
  141490. )
  141491. }
  141492. enableAllBubbles(e) {
  141493. this._enableBubble = e,
  141494. this.characterMap.forEach(i=>{
  141495. i.forEach(o=>{
  141496. e ? o.bubble && o.words.length > 0 && o.isRender && o.say(o.words, o.bubble.DEFAULT_CONFIGS) : o.setBubbleStatus(BillboardStatus.DISPOSE)
  141497. }
  141498. )
  141499. }
  141500. )
  141501. }
  141502. getAvatarById(e) {
  141503. let i;
  141504. return this.characterMap.forEach((o,s)=>{
  141505. o.get(e) && (i = o.get(e))
  141506. }
  141507. ),
  141508. i
  141509. }
  141510. getAvatarNums() {
  141511. let e = 0;
  141512. return this.characterMap.forEach((i,o)=>{
  141513. e += i.size
  141514. }
  141515. ),
  141516. e
  141517. }
  141518. registerAvatar(e) {
  141519. this.characterMap.get(e.priority).set(e.id, e)
  141520. }
  141521. unregisterAvatar(e) {
  141522. this.characterMap.get(e.priority).delete(e.id)
  141523. }
  141524. initAvatarMap() {
  141525. this.characterMap.set(0, new Map),
  141526. this.characterMap.set(1, new Map),
  141527. this.characterMap.set(2, new Map),
  141528. this.characterMap.set(3, new Map),
  141529. this.characterMap.set(4, new Map),
  141530. this.characterMap.set(5, new Map)
  141531. }
  141532. loadAvatar({id: e, avatarType: i, priority: o, avatarManager: s, assets: c, status: d}) {
  141533. return new Promise((_,b)=>{
  141534. if (this.getAvatarById(e))
  141535. return b(new DuplicateAvatarIDError(`[Engine] cannot init avatar with the same id = ${e}`));
  141536. if (this.getAvatarNums() > this.maxAvatarNum)
  141537. return b(new ExceedMaxAvatarNumError(`[Engine] \u8D85\u51FA\u6700\u5927\u89D2\u8272\u9650\u5236 ${this.maxAvatarNum}`));
  141538. const k = new XAvatar({
  141539. id: e,
  141540. avatarType: i,
  141541. priority: o,
  141542. avatarManager: s,
  141543. assets: c,
  141544. status: d
  141545. });
  141546. if (this.registerAvatar(k),
  141547. o == 0)
  141548. this.setMainAvatar(k.id),
  141549. this.addAvatarToScene(k, 0).then(j=>(log$E.debug(`[Engine] avatar ${k.id} has been added to scene`),
  141550. j ? (this._updateBillboardStatus(j, BillboardStatus.SHOW),
  141551. setTimeout(()=>{
  141552. this.launchProcessLoadingLoop()
  141553. }
  141554. , this._delayTime),
  141555. _(j)) : (k.removeAvatarFromScene(),
  141556. b(new AvatarAssetLoadingError)))).catch(j=>(k.removeAvatarFromScene(),
  141557. b(new AvatarAssetLoadingError(j))));
  141558. else
  141559. return _(k)
  141560. }
  141561. )
  141562. }
  141563. deleteAvatar(e) {
  141564. return e.isRender ? (e.removeAvatarFromScene(),
  141565. this.currentLODUsers[e.distLevel]--) : e.bbComponent.disposeBillBoard(e),
  141566. this._processList = this._processList.filter(i=>i.id !== e.id),
  141567. this.unregisterAvatar(e),
  141568. e.rootNode && (e.rootNode.dispose(),
  141569. e.rootNode = void 0),
  141570. e.bbComponent.bbox && e.bbComponent.bbox.dispose(),
  141571. e.removeObserver(),
  141572. e
  141573. }
  141574. _checkLODLevel(e) {
  141575. if (e < this._distLevels[0])
  141576. return 0;
  141577. for (let i = 1; i < this._distLevels.length; ++i)
  141578. if (e >= this._distLevels[i - 1] && e < this._distLevels[i])
  141579. return i;
  141580. return this._distLevels.length - 1
  141581. }
  141582. get sceneManager() {
  141583. return this._sceneManager
  141584. }
  141585. launchProcessLoadingLoop() {
  141586. this._updateAvatarStatus()
  141587. }
  141588. stopProcessLoadingLoop() {
  141589. var e;
  141590. this._updateLoopObserver && ((e = this._scene) == null || e.onBeforeRenderObservable.remove(this._updateLoopObserver)),
  141591. this._queueLength = 0,
  141592. this._clear(this.compMap),
  141593. this._process && (this._process.isInLoadingList = !1,
  141594. this._process.removeAvatarFromScene(),
  141595. this._process = void 0),
  141596. this._processList.forEach(i=>{
  141597. i.isInLoadingList = !1
  141598. }
  141599. ),
  141600. this._processList = []
  141601. }
  141602. _distToMain(e) {
  141603. var c;
  141604. const i = (c = this._mainUser) == null ? void 0 : c.position
  141605. , o = e.position
  141606. , s = this.sceneManager.cameraComponent.MainCamera.position;
  141607. if (o && s) {
  141608. const d = this.sceneManager.cameraComponent.MainCamera.getFrontPosition(1).subtract(s)
  141609. , _ = e.rootNode.position.subtract(s)
  141610. , b = new Vector3(d.x,0,d.z).normalize()
  141611. , k = new Vector3(_.x,0,_.z).normalize();
  141612. let j = 1;
  141613. if (b && k) {
  141614. const $ = b.multiply(k);
  141615. j = Math.acos($.x + $.y + $.z) < this.sceneManager.cameraComponent.getCameraHorizonFov() * .6 ? 1 : 1e11
  141616. }
  141617. return calcDistance3D(i || s, o) * j
  141618. } else
  141619. return log$E.warn("user position or camera position is not correct!"),
  141620. 1e11
  141621. }
  141622. _distToCamera(e) {
  141623. var s;
  141624. const i = (s = this._sceneManager) == null ? void 0 : s.cameraComponent.getCameraPose().position
  141625. , o = e.position;
  141626. return o && i ? calcDistance3D(i, o) : (log$E.warn("user position or camera position is not correct!"),
  141627. 1e11)
  141628. }
  141629. showAll(e) {
  141630. this.characterMap.forEach((i,o)=>{
  141631. e && o == 0 && i.forEach((s,c)=>{
  141632. s.show()
  141633. }
  141634. ),
  141635. o != 0 && i.forEach((s,c)=>{
  141636. s.show()
  141637. }
  141638. )
  141639. }
  141640. )
  141641. }
  141642. hideAll(e) {
  141643. this.characterMap.forEach((i,o)=>{
  141644. e && o == 0 && i.forEach((s,c)=>{
  141645. s.hide()
  141646. }
  141647. ),
  141648. o != 0 && i.forEach((s,c)=>{
  141649. s.hide()
  141650. }
  141651. )
  141652. }
  141653. )
  141654. }
  141655. _assemblyAvatar(e, i) {
  141656. var s, c;
  141657. const o = e.get(avatarSetting.body);
  141658. if (o && !i.attachBody(o)) {
  141659. i.isInLoadingList = !1,
  141660. this._clear(e);
  141661. return
  141662. }
  141663. for (const d of e)
  141664. if (d[0] != avatarSetting.body && d[0] != avatarSetting.animations && !i.attachDecoration(d[1])) {
  141665. i.isInLoadingList = !1,
  141666. i.removeAvatarFromScene(),
  141667. this._clear(e);
  141668. return
  141669. }
  141670. i.isRender = !0,
  141671. (s = i.controller) == null || s.playAnimation(i.controller.onPlay, i.controller.loop),
  141672. (c = i.controller) == null || c.onPlayObservable.addOnce(()=>{
  141673. var d, _;
  141674. if (!this.getAvatarById(i.id)) {
  141675. i.isInLoadingList = !1,
  141676. i.removeAvatarFromScene(),
  141677. this.currentLODUsers[i.distLevel]--;
  141678. return
  141679. }
  141680. if (this.getAvatarById(i.id).rootNode.getChildMeshes().length < e.size) {
  141681. log$E.error(`this avatar does not have complete components, render failed. current list ${(d = this.getAvatarById(i.id)) == null ? void 0 : d.clothesList},avatar: ${i.id},${i.nickName}`),
  141682. i.isInLoadingList = !1,
  141683. i.removeAvatarFromScene(),
  141684. this.currentLODUsers[i.distLevel]--;
  141685. return
  141686. }
  141687. i.setIsPickable(!0),
  141688. i.isInLoadingList = !1,
  141689. i.setAvatarVisible(!0),
  141690. (_ = this._sceneManager) == null || _.lightComponent.setShadow(i),
  141691. i.getBbox(),
  141692. i.nameBoard && i.nickName.length > 0 && this._enableNickname && i.setNickName(i.nickName, i.nameBoard.DEFAULT_CONFIGS),
  141693. i.component.accessories.forEach(b=>{
  141694. b.rootComponent.setEnabled(!0)
  141695. }
  141696. ),
  141697. i.bubble && i.words.length > 0 && i.say(i.words, i.bubble.DEFAULT_CONFIGS),
  141698. log$E.debug(`[Engine] avatar ${i.id} has been added to scene, current number of users : ${this.currentLODUsers}`)
  141699. }
  141700. )
  141701. }
  141702. _disposeUnusedAssets() {
  141703. this._tickDispose++,
  141704. (this._tickDispose > this._disposeTime || avatarLoader.containers.size > 100) && (avatarLoader.disposeContainer(),
  141705. this._tickDispose = 0)
  141706. }
  141707. _addResourcesToList(e, i) {
  141708. return e.clothesList.forEach(o=>{
  141709. o.lod = i,
  141710. this._queue.push(o)
  141711. }
  141712. ),
  141713. this._queue.push({
  141714. type: avatarSetting.animations,
  141715. id: this._defaultAnims
  141716. }),
  141717. this._queue.push({
  141718. type: avatarSetting.body,
  141719. id: e.avatarType,
  141720. lod: i
  141721. }),
  141722. !0
  141723. }
  141724. _updateBillboardStatus(e, i) {
  141725. e.bbComponent.updateBillboardStatus(e, i)
  141726. }
  141727. _processLayer(e) {
  141728. const i = this.characterMap.get(e)
  141729. , o = [];
  141730. for (i == null || i.forEach(s=>{
  141731. s.distToCam = this._distToCamera(s);
  141732. const c = s.distToCam < this._cullingDistance;
  141733. if (s.isRender && (!s.isHide && c ? s._hide_culling() : s._show_culling()),
  141734. s.priority != 0) {
  141735. s.distance = this._distToMain(s);
  141736. let d = BillboardStatus.SHOW;
  141737. s.distance < this._maxDistRange && (c ? d = BillboardStatus.HIDE : s._show_culling(),
  141738. this._updateBillboardStatus(s, d)),
  141739. s.isHide || (s.isInLoadingList ? this.currentLODUsers[s.distLevel]++ : o.push(s))
  141740. }
  141741. }
  141742. ),
  141743. o.sort((s,c)=>c.distance - s.distance); o.length > 0 && this.curRenderNum() < this.maxRenderNum(); ) {
  141744. const s = o.pop();
  141745. let c = this._checkLODLevel(s.distance)
  141746. , d = !1;
  141747. for (let _ = 0; _ < this._maxLODUsers.length; ++_)
  141748. if (this.currentLODUsers[_] < this._maxLODUsers[_]) {
  141749. c = _,
  141750. d = !0;
  141751. break
  141752. }
  141753. if (!d || s.distance > this._maxDistRange) {
  141754. if (s.isRender) {
  141755. s._removeAvatarFromScene();
  141756. let _ = BillboardStatus.HIDE;
  141757. s.distance < this._maxDistRange && (_ = BillboardStatus.SHOW),
  141758. this._updateBillboardStatus(s, _)
  141759. }
  141760. break
  141761. }
  141762. c != s.distLevel ? (s.isRender && (s.pendingLod = !0),
  141763. s.distLevel = c,
  141764. this._processList.push(s),
  141765. s.isInLoadingList = !0) : s.isRender || (this._processList.push(s),
  141766. s.isInLoadingList = !0),
  141767. this.currentLODUsers[c]++
  141768. }
  141769. return this.curRenderNum() >= this.maxRenderNum() && o.forEach(s=>{
  141770. if (s.isRender) {
  141771. s._removeAvatarFromScene();
  141772. let c = BillboardStatus.HIDE;
  141773. s.distance < this._maxDistRange && (c = BillboardStatus.SHOW),
  141774. this._updateBillboardStatus(s, c)
  141775. }
  141776. }
  141777. ),
  141778. this.curRenderNum() < this.maxRenderNum()
  141779. }
  141780. _updateAvatar() {
  141781. this.currentLODUsers = [0, 0, 0];
  141782. const e = [5, 4, 3, 2, 1, 0];
  141783. for (; e.length > 0; ) {
  141784. const i = e.pop();
  141785. if (!this._processLayer(i)) {
  141786. e.forEach(s=>{
  141787. var c;
  141788. (c = this.characterMap.get(s)) == null || c.forEach(d=>{
  141789. d.distance = this._distToMain(d);
  141790. let _ = BillboardStatus.HIDE;
  141791. d.distToCam < this._maxDistRange && (_ = BillboardStatus.SHOW,
  141792. d.isRender && d._removeAvatarFromScene()),
  141793. this._updateBillboardStatus(d, _)
  141794. }
  141795. )
  141796. }
  141797. );
  141798. break
  141799. }
  141800. }
  141801. }
  141802. _updateAvatarStatus() {
  141803. this._updateLoopObserver = this.scene.onBeforeRenderObservable.add(()=>{
  141804. var e;
  141805. if (!(this.getAvatarNums() <= 0)) {
  141806. if (!this._process && this._processList.length == 0 && this._updateAvatar(),
  141807. !this._process && this._processList.length > 0) {
  141808. const i = this._processList.shift();
  141809. i != this._process && !i.isCulling ? this._addResourcesToList(i, i.distLevel) ? (this._process = i,
  141810. this._queueLength = this._queue.length) : (this._process = void 0,
  141811. this._queue = [],
  141812. i.isInLoadingList = !1) : i.isInLoadingList = !1
  141813. }
  141814. if (this.compMap.size === this._queueLength && this._process) {
  141815. this._process.pendingLod && (this._process.pendingLod = !1,
  141816. this._process._removeAvatarFromScene());
  141817. const i = Date.now();
  141818. this._assemblyAvatar(this.compMap, this._process),
  141819. (e = this._sceneManager) == null || e.engineRunTimeStats.timeArray_addAvatarToScene.add(Date.now() - i),
  141820. this._updateBillboardStatus(this._process, BillboardStatus.SHOW),
  141821. this.compMap.clear(),
  141822. this._queue = [],
  141823. this._process.isInLoadingList = !1,
  141824. this._process = void 0
  141825. }
  141826. this._disposeUnusedAssets(),
  141827. this._loadResByList(this.compMap)
  141828. }
  141829. }
  141830. )
  141831. }
  141832. _clear(e) {
  141833. e.forEach((i,o)=>{
  141834. o == avatarSetting.body && (i.root._parentContainer ? i.root._parentContainer.xReferenceCount-- : i.root.getChildMeshes().forEach(s=>{
  141835. s.dispose()
  141836. }
  141837. )),
  141838. (o == avatarSetting.clothes || o == avatarSetting.hair || o == avatarSetting.head || o == avatarSetting.pants || o == avatarSetting.head || o == avatarSetting.suit) && (i.root._parentContainer ? i.root._parentContainer.xReferenceCount-- : i.root.dispose())
  141839. }
  141840. )
  141841. }
  141842. _loadResByList(e) {
  141843. let i = 0;
  141844. const o = 5;
  141845. if (!this._process) {
  141846. e.clear();
  141847. return
  141848. }
  141849. for (; !this.onThingsLoading && i < o && this._queue.length > 0; ) {
  141850. const s = Date.now()
  141851. , c = this._queue.pop();
  141852. setTimeout(()=>{
  141853. c ? c.type === avatarSetting.body ? (this.onThingsLoading = !0,
  141854. this.loadBody(c.type, c.id, c.lod).then(d=>{
  141855. d && e.set(avatarSetting.body, d),
  141856. i += Date.now() - s,
  141857. this.onThingsLoading = !1
  141858. }
  141859. ).catch(d=>{
  141860. this._process && (this._process.isHide = !0,
  141861. this.currentLODUsers[this._process.distLevel]--,
  141862. this._clear(e),
  141863. this._queue = [],
  141864. this._process.isInLoadingList = !1,
  141865. this._process = void 0,
  141866. i += 100,
  141867. this.onThingsLoading = !1),
  141868. log$E.warn(`[Engine] body ${c.id} uri error, type ${c.type}, avatar has been hided` + d)
  141869. }
  141870. )) : c.type === avatarSetting.animations ? this.loadAnimation(this._process.avatarType, c.id).then(d=>{
  141871. d && e.set(avatarSetting.animations, d),
  141872. i += Date.now() - s,
  141873. this.onThingsLoading = !1
  141874. }
  141875. ).catch(d=>{
  141876. this._process && (this._process.isHide = !0,
  141877. this.currentLODUsers[this._process.distLevel]--,
  141878. this._clear(e),
  141879. this._queue = [],
  141880. this._process.isInLoadingList = !1,
  141881. this._process = void 0,
  141882. i += 100,
  141883. this.onThingsLoading = !1),
  141884. log$E.warn(`animation ${c.id} uri error, type ${c.type}, avatar has been hided` + d)
  141885. }
  141886. ) : this.loadDecoration(c.type, c.id, c.lod).then(d=>{
  141887. d && e.set(d.type, d),
  141888. i += Date.now() - s,
  141889. this.onThingsLoading = !1
  141890. }
  141891. ).catch(d=>{
  141892. this._process && (this._process.isHide = !0,
  141893. this.currentLODUsers[this._process.distLevel]--,
  141894. this._clear(e),
  141895. this._queue = [],
  141896. this._process.isInLoadingList = !1,
  141897. this._process = void 0,
  141898. i += 100,
  141899. this.onThingsLoading = !1),
  141900. log$E.warn(`component ${c.id} uri error, type ${c.type}, avatar has been hided` + d)
  141901. }
  141902. ) : i += 100
  141903. }
  141904. , 0)
  141905. }
  141906. }
  141907. _validateContainer(e) {
  141908. return !e.meshes || e.meshes.length <= 1 ? (log$E.warn("import container has no valid meshes"),
  141909. !1) : !e.skeletons || e.skeletons.length == 0 ? (log$E.warn("import container has no valid skeletons"),
  141910. !1) : !0
  141911. }
  141912. _getAssetContainer(e, i) {
  141913. return new Promise((o,s)=>{
  141914. const c = this._getSourceKey(e, i || 0)
  141915. , d = avatarLoader.containers.get(c);
  141916. if (d)
  141917. return o(d);
  141918. avatarLoader.load(this.sceneManager, e, i).then(_=>_ ? this._validateContainer(_) ? (avatarLoader.containers.set(c, _),
  141919. o(_)) : s(new ContainerLoadingFailedError(`[Engine] :: cannot load body type ${e}.`)) : s(new ContainerLoadingFailedError(`[Engine] container load failed cannot load body type ${e}.`))).catch(_=>s(new ContainerLoadingFailedError(`[Engine] ${_} :: cannot load body type ${e}.`)))
  141920. }
  141921. )
  141922. }
  141923. _clipContainerRes(e) {
  141924. e.transformNodes = [],
  141925. e.skeletons.forEach(i=>{
  141926. i.dispose()
  141927. }
  141928. ),
  141929. e.skeletons = []
  141930. }
  141931. loadBody(e, i, o) {
  141932. return avatarLoader.load(this.sceneManager, i, o).then(s=>{
  141933. if (s) {
  141934. const c = s.instantiateModelsToScene();
  141935. s.xReferenceCount++;
  141936. const d = {
  141937. isRender: !1,
  141938. uId: Math.random(),
  141939. root: c.rootNodes[0],
  141940. skeletonType: e,
  141941. name: i,
  141942. animations: c.animationGroups,
  141943. skeleton: c.skeletons[0],
  141944. lod: o
  141945. };
  141946. return c.rootNodes[0]._parentContainer = s,
  141947. c.rootNodes[0].setEnabled(!1),
  141948. d
  141949. } else
  141950. return Promise.reject(new ContainerLoadingFailedError("[Engine] container failed instanciates failed"))
  141951. }
  141952. ).catch(()=>Promise.reject(new ContainerLoadingFailedError(`[Engine] body type ${e} instanciates failed`)))
  141953. }
  141954. updateAnimationLists(e, i) {
  141955. return new Promise((o,s)=>(avatarLoader.avaliableAnimation.set(i, e),
  141956. o()))
  141957. }
  141958. loadAnimation(e, i) {
  141959. return avatarLoader.loadAnimRes(this.sceneManager, i, e).then(o=>{
  141960. if (o) {
  141961. let s;
  141962. const c = this.avatarLoader.animations;
  141963. return o.animationGroups.forEach(d=>{
  141964. d.stop(),
  141965. d.name === i && (s = d,
  141966. s.pContainer = o),
  141967. c.set(getAnimationKey(d.name, e), d)
  141968. }
  141969. ),
  141970. this._clipContainerRes(o),
  141971. o.xReferenceCount++,
  141972. s
  141973. } else
  141974. return Promise.reject(new ContainerLoadingFailedError("[Engine] container failed instanciates failed"))
  141975. }
  141976. )
  141977. }
  141978. loadDecoration(e, i, o) {
  141979. return avatarLoader.load(this.sceneManager, i, o).then(s=>{
  141980. if (s) {
  141981. if (s.meshes.length <= 1)
  141982. return console.error("\u3010\u5F02\u5E38\uFF0Ccontainer\u4E0D\u542Bmesh\u3011"),
  141983. Promise.reject(`\u3010\u5F02\u5E38\uFF0Ccontainer\u4E0D\u542Bmesh\u3011 ${i}`);
  141984. const c = s.meshes[1].clone(s.meshes[1].name, null);
  141985. if (!c)
  141986. return log$E.warn("[Engine] decoration does not exist!"),
  141987. null;
  141988. const d = {
  141989. isRender: !1,
  141990. uId: Math.random(),
  141991. root: c,
  141992. type: e,
  141993. name: i,
  141994. isSelected: !1,
  141995. lod: o
  141996. };
  141997. if (s.xReferenceCount++,
  141998. c._parentContainer = s,
  141999. s.meshes.length > 1)
  142000. for (let _ = 2; _ < s.meshes.length; _++)
  142001. c.addChild(s.meshes[_].clone(s.meshes[_].name, null));
  142002. return c.setEnabled(!1),
  142003. d.isSelected = !0,
  142004. d
  142005. } else
  142006. return Promise.reject(new ContainerLoadingFailedError("[Engine] container failed, instanciates failed."))
  142007. }
  142008. )
  142009. }
  142010. _getSourceKey(e, i) {
  142011. return i && avatarSetting.lod[i] ? e + avatarSetting.lod[i].fileName.split(".")[0] : e
  142012. }
  142013. addAvatarToScene(e, i) {
  142014. const o = Date.now();
  142015. return this.loadBody(e.avatarType, e.avatarType, i).then(s=>{
  142016. var c;
  142017. return s ? (e.attachBody(s),
  142018. s.animations.length > 0 ? (s.animations.forEach(d=>{
  142019. d.stop()
  142020. }
  142021. ),
  142022. e.setAnimations(s.animations),
  142023. (c = e.controller) == null || c.playAnimation(e.controller.onPlay, !0),
  142024. e.isRender = !0,
  142025. e.isInLoadingList = !1,
  142026. e.setAvatarVisible(!0),
  142027. e) : this.loadAnimation(e.avatarType, this._defaultAnims).then(d=>{
  142028. if (!d)
  142029. return e.removeAvatarFromScene(),
  142030. e.isInLoadingList = !1,
  142031. Promise.reject(new AvatarAnimationError);
  142032. const _ = [];
  142033. return e.clothesList.length > 0 && e.clothesList.forEach(b=>{
  142034. _.push(this.loadDecoration(b.type, b.id, i))
  142035. }
  142036. ),
  142037. Promise.all(_).then(b=>{
  142038. var $, _e, et, tt;
  142039. b.forEach(rt=>{
  142040. if (rt && !rt.isRender)
  142041. e.attachDecoration(rt);
  142042. else {
  142043. e.isInLoadingList = !1,
  142044. e.removeAvatarFromScene(),
  142045. Promise.reject(new AvatarAssetLoadingError);
  142046. return
  142047. }
  142048. }
  142049. ),
  142050. e.isRender = !0,
  142051. ($ = e.controller) == null || $.playAnimation(e.controller.onPlay, e.controller.loop),
  142052. e.setAvatarVisible(!0),
  142053. (_e = this._sceneManager) == null || _e.lightComponent.setShadow(e);
  142054. const k = avatarLoader.mshPath.get("meshes/ygb.glb")
  142055. , j = avatarLoader.matPath.get(avatarResources.ygb.mesh);
  142056. if (k && j)
  142057. this.loadExtra(j, k).then(rt=>{
  142058. var it;
  142059. return e.isRender = !0,
  142060. e.isInLoadingList = !1,
  142061. e.distLevel = i,
  142062. (it = this._sceneManager) == null || it.engineRunTimeStats.timeArray_addAvatarToScene.add(Date.now() - o),
  142063. e
  142064. }
  142065. );
  142066. else
  142067. return e.isRender = !0,
  142068. e.isInLoadingList = !1,
  142069. e.distLevel = i,
  142070. (et = this._sceneManager) == null || et.engineRunTimeStats.timeArray_addAvatarToScene.add(Date.now() - o),
  142071. e;
  142072. return e.isInLoadingList = !1,
  142073. e.distLevel = i,
  142074. (tt = this._sceneManager) == null || tt.engineRunTimeStats.timeArray_addAvatarToScene.add(Date.now() - o),
  142075. e
  142076. }
  142077. ).catch(()=>Promise.reject(new AvatarAssetLoadingError(`[Engine] avatar ${e.id} instanciates failed.`)))
  142078. }
  142079. ).catch(()=>Promise.reject(new AvatarAssetLoadingError(`[Engine] avatar ${e.id} instanciates failed.`)))) : (e.isInLoadingList = !1,
  142080. Promise.reject(new ContainerLoadingFailedError(`[Engine] avatar ${e.id} instanciates failed`)))
  142081. }
  142082. ).catch(()=>Promise.reject(new AvatarAssetLoadingError(`[Engine] avatar ${e.id} instanciates failed.`)))
  142083. }
  142084. loadExtra(e, i) {
  142085. const o = avatarResources.ygb.name;
  142086. return new Promise((s,c)=>{
  142087. var d;
  142088. (d = this.sceneManager) == null || d.urlTransformer(e).then(_=>{
  142089. SceneLoader.LoadAssetContainerAsync("", _, this.scene, null, avatarSetting.fileType).then(b=>{
  142090. var j;
  142091. this.extraComps.set(o, b.meshes[0]);
  142092. const k = new NodeMaterial(`material_${o}`,this._scene,{
  142093. emitComments: !1
  142094. });
  142095. (j = this.sceneManager) == null || j.urlTransformer(i).then($=>{
  142096. k.loadAsync($).then(()=>{
  142097. b.meshes[2].material.dispose(!0, !0),
  142098. k.build(!1),
  142099. b.meshes[2].material = k,
  142100. s(b.meshes[2])
  142101. }
  142102. )
  142103. }
  142104. )
  142105. }
  142106. )
  142107. }
  142108. )
  142109. }
  142110. )
  142111. }
  142112. getAvatarList() {
  142113. const e = [];
  142114. return this.characterMap.forEach((i,o)=>{
  142115. i.forEach((s,c)=>{
  142116. e.push(s)
  142117. }
  142118. )
  142119. }
  142120. ),
  142121. e
  142122. }
  142123. _debug_avatar() {
  142124. var i, o;
  142125. console.error("===>currentLODUsers", this.currentLODUsers),
  142126. console.error("===>maxLODUsers", this._maxLODUsers),
  142127. console.error("===>Loddist", this.getLoDLevels()),
  142128. console.error("===> main character loc", (o = (i = this._mainUser) == null ? void 0 : i.rootNode) == null ? void 0 : o.position);
  142129. let e = 0;
  142130. this.getAvatarList().forEach(s=>{
  142131. s.isRender && (console.error(`avatar id : ${s.id},lod ${s.distLevel},is Hide ${s.isHide}, distance ${s.distance}, is pending ${s.isInLoadingList}`),
  142132. e++)
  142133. }
  142134. ),
  142135. console.error("========= avatar num", e),
  142136. console.error("loop:", this._updateLoopObserver ? "on" : "false", "=> process", this._process, "===> comp", this._processList),
  142137. console.error("===>maxLODUsers", this._maxLODUsers)
  142138. }
  142139. }
  142140. const log$D = new Logger$1("XLightManager");
  142141. class XLightManager {
  142142. constructor(e) {
  142143. this.sceneManager = e,
  142144. this._scene = this.sceneManager.Scene,
  142145. this._envTexture = null,
  142146. this.shadowLean = .1;
  142147. const i = new Vector3(this.shadowLean,-1,0)
  142148. , o = 1024;
  142149. this._shadowLight = new DirectionalLight("AvatarLight",i,this._scene),
  142150. this._shadowLight.shadowMaxZ = 5e3,
  142151. this._shadowLight.intensity = 0,
  142152. this.attachLightToCamera(this._shadowLight),
  142153. this._shadowGenerator = new ShadowGenerator(o,this._shadowLight,!0),
  142154. this._avatarShadowMeshMap = new Map,
  142155. this._cullingShadowObservers = new Map
  142156. }
  142157. set shadowLean(e) {
  142158. e = Math.min(e, 1),
  142159. e = Math.max(e, -1),
  142160. this._shadowLight && (this._shadowLight.direction = new Vector3(e,-1,0))
  142161. }
  142162. setIBL(e) {
  142163. return new Promise((i,o)=>{
  142164. this.sceneManager.urlTransformer(e).then(s=>{
  142165. var c;
  142166. if (s == ((c = this._envTexture) == null ? void 0 : c.url))
  142167. return i("env set success");
  142168. this._envTexture != null && this.disposeIBL(),
  142169. this._envTexture = CubeTexture.CreateFromPrefilteredData(s, this._scene, ".env"),
  142170. this._scene.environmentTexture = this._envTexture,
  142171. this._envTexture.onLoadObservable.addOnce(()=>{
  142172. i("env set success"),
  142173. log$D.info("env set success")
  142174. }
  142175. )
  142176. }
  142177. ).catch(()=>{
  142178. o("env set fail")
  142179. }
  142180. )
  142181. }
  142182. )
  142183. }
  142184. disposeIBL() {
  142185. this._envTexture == null ? log$D.info("env not exist") : (this._envTexture.dispose(),
  142186. this._envTexture = null,
  142187. this._scene.environmentTexture = null,
  142188. log$D.info("env dispose success"))
  142189. }
  142190. removeShadow(e) {
  142191. var i;
  142192. if (this._avatarShadowMeshMap.has(e)) {
  142193. this._avatarShadowMeshMap.delete(e),
  142194. this._cullingShadowObservers.get(e) && (this._scene.onBeforeRenderObservable.remove(this._cullingShadowObservers.get(e)),
  142195. this._cullingShadowObservers.delete(e));
  142196. const o = e.rootNode;
  142197. o && ((i = this._shadowGenerator) == null || i.removeShadowCaster(o))
  142198. } else
  142199. return
  142200. }
  142201. setShadow(e) {
  142202. if (this._avatarShadowMeshMap.has(e))
  142203. return;
  142204. e.rootNode && this._avatarShadowMeshMap.set(e, e.rootNode.getChildMeshes());
  142205. const i = 20
  142206. , o = 10
  142207. , s = this.cullingShadow(i, o, e);
  142208. this._cullingShadowObservers.set(e, s)
  142209. }
  142210. cullingShadow(e, i, o) {
  142211. let s = 0;
  142212. const c = ()=>{
  142213. var _;
  142214. if (s == i) {
  142215. const b = this._avatarShadowMeshMap.get(o)
  142216. , k = (_ = o.rootNode) == null ? void 0 : _.getChildMeshes()
  142217. , j = this._scene.activeCamera;
  142218. b == null || b.forEach($=>{
  142219. var _e;
  142220. (_e = this._shadowGenerator) == null || _e.removeShadowCaster($, !1)
  142221. }
  142222. ),
  142223. k == null || k.forEach($=>{
  142224. var _e;
  142225. (_e = this._shadowGenerator) == null || _e.addShadowCaster($, !1)
  142226. }
  142227. ),
  142228. j && o.rootNode.position.subtract(j.position).length() > e && (k == null || k.forEach($=>{
  142229. var _e;
  142230. (_e = this._shadowGenerator) == null || _e.removeShadowCaster($, !1)
  142231. }
  142232. )),
  142233. k && this._avatarShadowMeshMap.set(o, k),
  142234. s = 0
  142235. } else
  142236. s += 1
  142237. }
  142238. ;
  142239. return this._scene.onBeforeRenderObservable.add(c)
  142240. }
  142241. attachLightToCamera(e) {
  142242. const i = e
  142243. , o = 15
  142244. , s = ()=>{
  142245. const c = this._scene.activeCamera;
  142246. if (c) {
  142247. const d = i.direction
  142248. , _ = new Vector3(o * d.x,o * d.y,o * d.z)
  142249. , b = c.position;
  142250. i.position = b.subtract(_)
  142251. }
  142252. }
  142253. ;
  142254. return i && this._scene.registerBeforeRender(s),
  142255. s
  142256. }
  142257. }
  142258. ParticleSystemSet.prototype.systems = new Array;
  142259. const _XParticleManager = class {
  142260. constructor(a) {
  142261. if (this.load = (e,i,o)=>new Promise(s=>{
  142262. ParticleSystemSet.BaseAssetsUrl = e;
  142263. const c = new XMLHttpRequest;
  142264. c.open("get", e + "/" + i),
  142265. c.send(null),
  142266. c.onload = ()=>{
  142267. if (c.status == 200) {
  142268. const d = JSON.parse(c.responseText);
  142269. let _ = null;
  142270. if (Object.keys(d).find(b=>b == "systems") == null) {
  142271. const b = ParticleSystem.Parse(d, this._scene, e);
  142272. _ = new ParticleSystemSet,
  142273. _.systems.push(b)
  142274. } else
  142275. _ = ParticleSystemSet.Parse(d, this._scene, !1);
  142276. s(_)
  142277. }
  142278. }
  142279. }
  142280. ),
  142281. this.get = e=>this._particles.get(e),
  142282. this.start = e=>{
  142283. const i = this._particles.get(e);
  142284. i && i.start()
  142285. }
  142286. ,
  142287. this.stop = e=>{
  142288. var o;
  142289. const i = ((o = this._particles.get(e)) == null ? void 0 : o.systems) || [];
  142290. for (let s = 0; s < i.length; s++)
  142291. i[s].stop()
  142292. }
  142293. ,
  142294. this.remove = e=>{
  142295. const i = this._particles.get(e);
  142296. i && i.dispose()
  142297. }
  142298. ,
  142299. this.setParticlePosition = (e,i)=>{
  142300. const o = this._particles.get(e);
  142301. o && (o.emitterNode = i)
  142302. }
  142303. ,
  142304. this.setParticleScalingInPlace = (e,i)=>{
  142305. const o = this._particles.get(e);
  142306. o == null || o.systems.forEach(s=>{
  142307. _XParticleManager.scalingInPlace(s, i)
  142308. }
  142309. )
  142310. }
  142311. ,
  142312. this._scene = a,
  142313. this._particles = new Map,
  142314. this._light = null,
  142315. this._scene.getLightByName("fireworkLight"))
  142316. this._light = this._scene.getLightByName("fireworkLight");
  142317. else {
  142318. const e = new PointLight("fireworkLight",new Vector3(0,0,0),a);
  142319. e.intensity = 0,
  142320. this._light = e
  142321. }
  142322. }
  142323. _flashBang(a=200) {
  142324. const e = this._scene.getLightByName("fireworkLight");
  142325. e.intensity = 1,
  142326. setTimeout(()=>{
  142327. e.intensity = 0
  142328. }
  142329. , a)
  142330. }
  142331. }
  142332. ;
  142333. let XParticleManager = _XParticleManager;
  142334. XParticleManager.disposeParticleSysSet = a=>{
  142335. !a.systems || (a.systems.forEach(e=>{
  142336. _XParticleManager.disposeParticleSystem(e)
  142337. }
  142338. ),
  142339. a.dispose())
  142340. }
  142341. ;
  142342. XParticleManager.disposeParticleSystem = a=>{
  142343. a.particleSystem && (a = a.particleSystem),
  142344. a.subEmitters && a.subEmitters.forEach(e=>{
  142345. e instanceof Array ? e.forEach(i=>{
  142346. _XParticleManager.disposeParticleSystem(i)
  142347. }
  142348. ) : _XParticleManager.disposeParticleSystem(e)
  142349. }
  142350. ),
  142351. a.dispose()
  142352. }
  142353. ;
  142354. XParticleManager.scalingInPlace = (a,e)=>{
  142355. a.getClassName() === "ParticleSystem" && (a.minSize *= e,
  142356. a.maxSize *= e,
  142357. a.subEmitters != null && a.subEmitters.forEach(i=>{
  142358. i instanceof SubEmitter && _XParticleManager.scalingInPlace(i.particleSystem, e),
  142359. i instanceof ParticleSystem && _XParticleManager.scalingInPlace(i, e),
  142360. i instanceof Array && i.forEach(o=>{
  142361. _XParticleManager.scalingInPlace(o.particleSystem, e)
  142362. }
  142363. )
  142364. }
  142365. ))
  142366. }
  142367. ;
  142368. const DefaultUrlTransformer$1 = async a=>a
  142369. , log$C = new Logger$1("subSequence")
  142370. , DEFAULT_FRAME_RATE = 30
  142371. , ROOT_MESH_ANIM_PROPERTY = ["scaling", "position", "rotation"]
  142372. , MESH_TAG = "XSubSequence";
  142373. class XSpriteManager extends SpriteManager {
  142374. constructor(e, i, o, s, c) {
  142375. super(e, i, o, s, c),
  142376. this.originalPositions = new Array,
  142377. this.sprites.forEach(d=>{
  142378. this.originalPositions.push(d.position)
  142379. }
  142380. )
  142381. }
  142382. static Parse(e, i, o) {
  142383. const s = new XSpriteManager(e.name,"",e.capacity,{
  142384. width: e.cellWidth,
  142385. height: e.cellHeight
  142386. },i);
  142387. e.texture ? s.texture = Texture.Parse(e.texture, i, o) : e.textureName && (s.texture = new Texture(o + e.textureUrl,i,!0,e.invertY !== void 0 ? e.invertY : !0));
  142388. for (const c of e.sprites) {
  142389. const d = Sprite.Parse(c, s);
  142390. s.originalPositions.push(d.position)
  142391. }
  142392. return s
  142393. }
  142394. }
  142395. class XSubSequence {
  142396. constructor(e, i, o=DefaultUrlTransformer$1) {
  142397. this._pickable = !1,
  142398. this.onLoadedObserverable = new Observable,
  142399. this.onSubSequenceTransformationChangeObservable = new Observable,
  142400. this.onIntersectionObservable = new Observable,
  142401. this._isDisposing = !1,
  142402. this.init = ()=>new Promise((s,c)=>{
  142403. this.urlTransformer(this._abosoluteUrl).then(d=>{
  142404. const _ = new XMLHttpRequest;
  142405. _.open("get", d),
  142406. _.send(null),
  142407. _.onload = ()=>{
  142408. if (_.status == 200) {
  142409. const b = JSON.parse(_.responseText);
  142410. this.load(b).then(()=>{
  142411. this.onLoadedObserverable.notifyObservers(this),
  142412. this._loaded = !0,
  142413. s()
  142414. }
  142415. , ()=>{
  142416. c(),
  142417. log$C.error("subSequence: Load ${jsonBlob} json fail")
  142418. }
  142419. )
  142420. }
  142421. }
  142422. ,
  142423. _.onerror = ()=>{
  142424. log$C.error("http: Get ${jsonBlob} json fail"),
  142425. c()
  142426. }
  142427. }
  142428. )
  142429. }
  142430. ),
  142431. this.play = async(s=!0)=>new Promise(c=>{
  142432. if (this._animGroup.isPlaying && this._animGroup.stop(),
  142433. this._particleGroups.forEach(d=>{
  142434. var _;
  142435. ((_ = d.emitterNode) == null ? void 0 : _.getClassName()) == "Mesh" && d.emitterNode instanceof Mesh ? d.emitterNode.isEnabled() && d.start() : d.start()
  142436. }
  142437. ),
  142438. this._animGroup.targetedAnimations.length == 0) {
  142439. this.show();
  142440. let d = 0;
  142441. this._spriteGroups.forEach(_=>{
  142442. _.sprites.forEach(b=>{
  142443. b.toIndex > d && (d = b.toIndex)
  142444. }
  142445. )
  142446. }
  142447. ),
  142448. this._spriteGroups.forEach(_=>{
  142449. _.sprites.forEach(b=>{
  142450. b.playAnimation(b.fromIndex, b.toIndex, s, b.delay, ()=>{
  142451. b.toIndex == d && (this._isPaused = !0,
  142452. this.hide(),
  142453. c())
  142454. }
  142455. )
  142456. }
  142457. )
  142458. }
  142459. )
  142460. } else
  142461. this._animGroup.play(s),
  142462. this._spriteGroups.forEach(d=>{
  142463. d.sprites.forEach(_=>{
  142464. _.playAnimation(_.fromIndex, _.toIndex, s, _.delay)
  142465. }
  142466. )
  142467. }
  142468. ),
  142469. s ? this._animGroup.onAnimationGroupLoopObservable.addOnce(()=>{
  142470. c()
  142471. }
  142472. ) : this._animGroup.onAnimationGroupEndObservable.addOnce(()=>{
  142473. this._spriteGroups.forEach(d=>{
  142474. d.sprites.forEach(_=>{
  142475. _.isVisible = !1,
  142476. _.isPickable = !1,
  142477. _.stopAnimation()
  142478. }
  142479. )
  142480. }
  142481. ),
  142482. c()
  142483. }
  142484. );
  142485. this._isStarted = !0,
  142486. this._isPaused = !1
  142487. }
  142488. ),
  142489. this.stop = ()=>{
  142490. this._animGroup.stop(),
  142491. this._particleGroups.forEach(s=>{
  142492. s.systems.forEach(c=>{
  142493. c.stop()
  142494. }
  142495. )
  142496. }
  142497. ),
  142498. this._spriteGroups.forEach(s=>{
  142499. s.sprites.forEach(c=>{
  142500. c.stopAnimation()
  142501. }
  142502. )
  142503. }
  142504. ),
  142505. this._isStarted = !1
  142506. }
  142507. ,
  142508. this.clone = (s="Clone")=>{
  142509. const c = new XSubSequence(this._scene,this._abosoluteUrl);
  142510. return c._centerNode.name = s + "_" + this._centerNode.name,
  142511. c._animGroup.name = s + "_" + this._animGroup.name,
  142512. this._meshGroups.forEach(d=>{
  142513. const _ = d.clone(s + "_", c._centerNode)
  142514. , b = _.getChildren(void 0, !1);
  142515. if (b.forEach(k=>{
  142516. k.setEnabled(!0)
  142517. }
  142518. ),
  142519. b.push(_),
  142520. _) {
  142521. const k = d.getChildren(void 0, !1);
  142522. k.push(d),
  142523. this.animGroup.targetedAnimations.forEach(j=>{
  142524. if (j.target instanceof Node$2) {
  142525. const $ = k.indexOf(j.target);
  142526. $ != -1 && c._animGroup.addTargetedAnimation(j.animation, b[$])
  142527. }
  142528. }
  142529. )
  142530. }
  142531. }
  142532. ),
  142533. c._loaded = !0,
  142534. c
  142535. }
  142536. ,
  142537. this.goToFrame = s=>{
  142538. this._animGroup.start(!0, 1, s, s)
  142539. }
  142540. ,
  142541. this.pause = ()=>{
  142542. this._isPaused = !0,
  142543. this._animGroup.pause()
  142544. }
  142545. ,
  142546. this.reset = ()=>{
  142547. this._animGroup.reset()
  142548. }
  142549. ,
  142550. this.loadTrackToAnim = s=>{
  142551. const c = Array();
  142552. let d = !0;
  142553. s.keyFrame.forEach(b=>{
  142554. if (b.frame > this._endFrame && (this._endFrame = b.frame),
  142555. b.value instanceof Array) {
  142556. const k = {
  142557. frame: b.frame,
  142558. value: new Vector3(0,0,0)
  142559. }
  142560. , j = new Vector3(b.value[0],b.value[1],b.value[2]);
  142561. k.value = j,
  142562. c.push(k)
  142563. } else
  142564. c.push(b),
  142565. d = !1
  142566. }
  142567. ),
  142568. s.loop == null && (s.loop = !1),
  142569. s.index == null && (s.index = 0);
  142570. let _ = null;
  142571. if ("blockName"in s) {
  142572. const b = {
  142573. keyFrame: c,
  142574. blockName: s.blockName,
  142575. property: s.property,
  142576. targetName: s.targetName,
  142577. index: s.index,
  142578. loop: s.loop
  142579. };
  142580. _ = this.transferTrackToAnim(b, d)
  142581. } else {
  142582. const b = {
  142583. keyFrame: c,
  142584. property: s.property,
  142585. targetName: s.targetName,
  142586. index: s.index,
  142587. loop: s.loop
  142588. };
  142589. _ = this.transferTrackToAnim(b, d)
  142590. }
  142591. return _
  142592. }
  142593. ,
  142594. this.transferTrackToAnim = (s,c)=>{
  142595. let d = null;
  142596. c ? (d = new Animation(s.targetName + "_" + s.property,s.property,DEFAULT_FRAME_RATE,Animation.ANIMATIONTYPE_VECTOR3,Animation.ANIMATIONLOOPMODE_CYCLE),
  142597. d.setKeys(s.keyFrame)) : (d = new Animation(s.targetName + "_" + s.property,s.property,DEFAULT_FRAME_RATE,Animation.ANIMATIONTYPE_FLOAT,Animation.ANIMATIONLOOPMODE_CYCLE),
  142598. d.setKeys(s.keyFrame));
  142599. let _ = null;
  142600. return "blockName"in s ? _ = {
  142601. animation: d,
  142602. blockName: s.blockName,
  142603. targetName: s.targetName,
  142604. nodeIndex: s.index,
  142605. loop: s.loop
  142606. } : _ = {
  142607. animation: d,
  142608. targetName: s.targetName,
  142609. nodeIndex: s.index,
  142610. loop: s.loop
  142611. },
  142612. _
  142613. }
  142614. ,
  142615. i.indexOf("./") == 0 && (i = i.slice(2)),
  142616. this._abosoluteUrl = i,
  142617. this._name = i.split("/").slice(-1)[0].split(".")[0].split("_")[1],
  142618. this._rootDir = i.split("/").slice(0, -1).join("/") + "/",
  142619. this._scene = e,
  142620. this._meshGroups = new Map,
  142621. this._animGroup = new AnimationGroup("SubSeqAnim_",this._scene),
  142622. this._particleGroups = new Map,
  142623. this._materialGroups = new Map,
  142624. this._glowGroups = new Map,
  142625. this._highLightGroups = new Map,
  142626. this._spriteGroups = new Map,
  142627. this._endFrame = 0,
  142628. this._centerNode = new TransformNode("__rootSubSeq__",e),
  142629. this._loaded = !1,
  142630. this._isPaused = !0,
  142631. this._isStarted = !1,
  142632. this._centerNode.setEnabled(!1),
  142633. this.urlTransformer = o,
  142634. this._centerNode.onAfterWorldMatrixUpdateObservable.add(()=>{
  142635. this.onSubSequenceTransformationChangeObservable.notifyObservers(this)
  142636. }
  142637. ),
  142638. this._animGroup.onAnimationGroupPlayObservable.add(()=>{
  142639. this._particleGroups.forEach(s=>{
  142640. s.systems.forEach(c=>{
  142641. c.isStarted() || c.start()
  142642. }
  142643. )
  142644. }
  142645. ),
  142646. this.show()
  142647. }
  142648. ),
  142649. this._animGroup.onAnimationGroupLoopObservable.add(()=>{
  142650. this._particleGroups.forEach(s=>{
  142651. s.systems.forEach(c=>{
  142652. c.isStarted() || c.start()
  142653. }
  142654. )
  142655. }
  142656. )
  142657. }
  142658. ),
  142659. this._animGroup.onAnimationGroupEndObservable.add(()=>{
  142660. this.hide()
  142661. }
  142662. )
  142663. }
  142664. dispose() {
  142665. this._isDisposing = !0,
  142666. this._spriteGroups.forEach(e=>{
  142667. e.dispose()
  142668. }
  142669. ),
  142670. this._glowGroups.forEach(e=>{
  142671. e.dispose()
  142672. }
  142673. ),
  142674. this._highLightGroups.forEach(e=>{
  142675. e.dispose()
  142676. }
  142677. ),
  142678. this._particleGroups.forEach(e=>{
  142679. XParticleManager.disposeParticleSysSet(e)
  142680. }
  142681. ),
  142682. this._animGroup.stop(),
  142683. this._animGroup.dispose(),
  142684. this._meshGroups.forEach(e=>{
  142685. e.getChildren(void 0, !1).forEach(i=>{
  142686. var o, s;
  142687. (i.getClassName() === "AbstractMesh" || i.getClassName() === "Mesh") && ((o = i.skeleton) == null || o.dispose(),
  142688. (s = i.material) == null || s.dispose(!0, !0)),
  142689. i.dispose(!0, !0)
  142690. }
  142691. ),
  142692. e.dispose(!1, !0)
  142693. }
  142694. ),
  142695. this._centerNode.dispose(!1, !0),
  142696. this._materialGroups.forEach(e=>{}
  142697. ),
  142698. this._materialGroups.clear(),
  142699. this._spriteGroups.clear(),
  142700. this._glowGroups.clear(),
  142701. this._highLightGroups.clear(),
  142702. this._meshGroups.clear(),
  142703. this._particleGroups.clear(),
  142704. this._loaded = !1
  142705. }
  142706. get animGroup() {
  142707. return this._animGroup
  142708. }
  142709. get name() {
  142710. return this._name
  142711. }
  142712. get path() {
  142713. return this._abosoluteUrl
  142714. }
  142715. get position() {
  142716. return xversePosition2Ue4(this.pos)
  142717. }
  142718. get rotation() {
  142719. return xverseRotation2Ue4(this.rot)
  142720. }
  142721. get scaling() {
  142722. return this.scal
  142723. }
  142724. get pos() {
  142725. return this._centerNode.position
  142726. }
  142727. get rot() {
  142728. return this._centerNode.rotation
  142729. }
  142730. get scal() {
  142731. return this._centerNode.scaling
  142732. }
  142733. get root() {
  142734. return this._centerNode
  142735. }
  142736. get loaded() {
  142737. return this._loaded
  142738. }
  142739. get isPlaying() {
  142740. return this._animGroup ? this._animGroup.isPlaying : this._isStarted && !this._isPaused
  142741. }
  142742. get isStarted() {
  142743. return this._animGroup ? this._animGroup.isStarted : this._isStarted
  142744. }
  142745. get isPickable() {
  142746. return this._pickable
  142747. }
  142748. set isPickable(e) {
  142749. this._meshGroups.forEach(i=>{
  142750. i.getChildMeshes().forEach(o=>{
  142751. o.isPickable = e
  142752. }
  142753. )
  142754. }
  142755. ),
  142756. this._spriteGroups.forEach(i=>{
  142757. i.isPickable = e,
  142758. i.sprites.forEach(o=>{
  142759. o.isPickable = e
  142760. }
  142761. )
  142762. }
  142763. ),
  142764. this._pickable = e
  142765. }
  142766. addAnimation(e) {
  142767. this._animGroup.addTargetedAnimation(e, this._centerNode),
  142768. this._spriteGroups.forEach(i=>{
  142769. i.sprites.forEach(o=>{
  142770. this._animGroup.addTargetedAnimation(e, o)
  142771. }
  142772. )
  142773. }
  142774. )
  142775. }
  142776. setStartFrame(e) {
  142777. this._animGroup.stop(),
  142778. this._animGroup.targetedAnimations.forEach(i=>{
  142779. const o = i.animation.getKeys();
  142780. o.forEach(s=>{
  142781. e + o[0].frame > 0 ? s.frame += e : s.frame -= o[0].frame
  142782. }
  142783. )
  142784. }
  142785. )
  142786. }
  142787. lookAt(e) {
  142788. ue4Position2Xverse(e) && this.root.lookAt(ue4Position2Xverse(e))
  142789. }
  142790. setPosition(e) {
  142791. this.setPositionVector(ue4Position2Xverse(e))
  142792. }
  142793. setPositionVector(e) {
  142794. this._centerNode.position = e,
  142795. this._particleGroups.forEach(i=>{
  142796. i.emitterNode == null || i.emitterNode instanceof Vector3 ? i.emitterNode = e : this._scene.getMeshByName(i.emitterNode.name) || (i.emitterNode = e)
  142797. }
  142798. ),
  142799. this._spriteGroups.forEach(i=>{
  142800. i.sprites.forEach((o,s)=>{
  142801. o.position = e
  142802. }
  142803. )
  142804. }
  142805. )
  142806. }
  142807. setScaling(e) {
  142808. this.setScalingVector(ue4Scaling2Xverse(e))
  142809. }
  142810. setScalingVector(e) {
  142811. var i;
  142812. this._centerNode.scaling = e,
  142813. (i = this._particleGroups) == null || i.forEach(o=>{
  142814. o.systems.forEach(s=>{
  142815. XParticleManager.scalingInPlace(s, e.x)
  142816. }
  142817. )
  142818. }
  142819. ),
  142820. this._spriteGroups.forEach(o=>{
  142821. o.sprites.forEach(s=>{
  142822. s.size *= e.x
  142823. }
  142824. )
  142825. }
  142826. )
  142827. }
  142828. setRotation(e) {
  142829. this.setRotationVector(ue4Rotation2Xverse(e))
  142830. }
  142831. setRotationVector(e) {
  142832. this._centerNode.rotation = e
  142833. }
  142834. hide() {
  142835. this._centerNode.setEnabled(!1),
  142836. this._particleGroups.forEach(e=>{
  142837. e.systems.forEach(i=>{
  142838. i.isStarted() && i.stop()
  142839. }
  142840. )
  142841. }
  142842. ),
  142843. this._spriteGroups.forEach(e=>{
  142844. e.sprites.forEach(i=>{
  142845. i.isVisible = !1
  142846. }
  142847. )
  142848. }
  142849. )
  142850. }
  142851. show() {
  142852. this._centerNode.setEnabled(!0),
  142853. this._centerNode.getChildren().forEach(e=>{
  142854. e.setEnabled(!0),
  142855. e.getChildMeshes().forEach(i=>{
  142856. i.setEnabled(!0)
  142857. }
  142858. )
  142859. }
  142860. ),
  142861. this._particleGroups.forEach(e=>{
  142862. e.systems.forEach(i=>{
  142863. i.start()
  142864. }
  142865. )
  142866. }
  142867. ),
  142868. this._spriteGroups.forEach(e=>{
  142869. e.sprites.forEach(i=>{
  142870. i.isVisible = !0
  142871. }
  142872. )
  142873. }
  142874. )
  142875. }
  142876. get totalFrame() {
  142877. return this._endFrame
  142878. }
  142879. load(e) {
  142880. return new Promise((i,o)=>{
  142881. const s = e.Mesh
  142882. , c = e.Sprite
  142883. , d = e.Material
  142884. , _ = e.Glow
  142885. , b = e.HighLight
  142886. , k = e.Particle
  142887. , j = e.MeshTrack
  142888. , $ = e.ParticleTrack
  142889. , _e = e.MaterialTrack;
  142890. this._animGroup.name += e.Type;
  142891. const et = Date.now();
  142892. this._centerNode.name += e.Type;
  142893. const tt = new Array
  142894. , rt = new Array;
  142895. s != null && s.forEach(it=>{
  142896. tt.push(this.loadMesh(it))
  142897. }
  142898. ),
  142899. c != null && c.forEach(it=>{
  142900. rt.push(this.loadSprite(it))
  142901. }
  142902. ),
  142903. Promise.all(tt).then(()=>{
  142904. d != null && d.forEach(it=>{
  142905. rt.push(this.loadMaterial(it))
  142906. }
  142907. ),
  142908. k != null && k.forEach(it=>{
  142909. rt.push(this.loadParticle(it))
  142910. }
  142911. ),
  142912. Promise.all(rt).then(()=>{
  142913. if (this._isDisposing) {
  142914. const nt = Date.now() - et;
  142915. log$C.info(`subSequence: Load ${e.Type} takes ${nt} ms`),
  142916. i(this);
  142917. return
  142918. }
  142919. if (_ != null)
  142920. for (const nt of _)
  142921. this.loadGlow(nt);
  142922. if (b != null)
  142923. for (const nt of b)
  142924. this.loadHighLight(nt);
  142925. j != null && j.forEach(nt=>{
  142926. const ot = this._meshGroups.get(nt.targetName);
  142927. if (ot != null) {
  142928. const at = this.loadTrackToAnim(nt);
  142929. ROOT_MESH_ANIM_PROPERTY.indexOf(at.animation.targetProperty) == -1 ? ot.getChildMeshes().forEach(st=>{
  142930. at.animation.targetProperty in st && this._animGroup.addTargetedAnimation(at.animation, st)
  142931. }
  142932. ) : this._animGroup.addTargetedAnimation(at.animation, ot)
  142933. }
  142934. }
  142935. ),
  142936. $ != null && $.forEach(nt=>{
  142937. var ut;
  142938. const ot = nt.index
  142939. , at = nt.targetName
  142940. , st = (ut = this._particleGroups.get(at)) == null ? void 0 : ut.systems[ot];
  142941. if (st != null) {
  142942. const ct = this.loadTrackToAnim(nt);
  142943. this._animGroup.addTargetedAnimation(ct.animation, st)
  142944. }
  142945. }
  142946. ),
  142947. _e != null && _e.forEach(nt=>{
  142948. const ot = this._materialGroups.get(nt.targetName);
  142949. if (ot) {
  142950. const at = ot[0];
  142951. if (at != null)
  142952. if (at.getBlockByName(nt.blockName) != null) {
  142953. const st = this.loadTrackToAnim(nt);
  142954. ot == null || ot.forEach(ut=>{
  142955. this._animGroup.addTargetedAnimation(st.animation, ut.getBlockByName(nt.blockName))
  142956. }
  142957. )
  142958. } else
  142959. console.error("property " + nt.property + "is not in " + at.name)
  142960. }
  142961. }
  142962. );
  142963. const it = Date.now() - et;
  142964. log$C.info(`subSequence: Load ${e.Type} takes ${it} ms`),
  142965. i(this)
  142966. }
  142967. , ()=>{
  142968. log$C.error(`subSequence: Load ${e.Type} fail`),
  142969. o()
  142970. }
  142971. )
  142972. }
  142973. , ()=>{
  142974. o()
  142975. }
  142976. )
  142977. }
  142978. )
  142979. }
  142980. loadMesh(e) {
  142981. return new Promise((i,o)=>{
  142982. const s = this._rootDir + e.uri;
  142983. this.urlTransformer(s).then(c=>{
  142984. if (this._isDisposing) {
  142985. i();
  142986. return
  142987. }
  142988. SceneLoader.LoadAssetContainer("", c, this._scene, d=>{
  142989. if (this._isDisposing) {
  142990. d.removeAllFromScene(),
  142991. i();
  142992. return
  142993. }
  142994. d.animationGroups.forEach(b=>{
  142995. b.stop()
  142996. }
  142997. ),
  142998. d.animationGroups.length != 0 && (d.animationGroups.forEach(b=>{
  142999. b.targetedAnimations.forEach(k=>{
  143000. this._animGroup.addTargetedAnimation(k.animation, k.target)
  143001. }
  143002. ),
  143003. b.dispose()
  143004. }
  143005. ),
  143006. d.animationGroups = [],
  143007. d.animations = [],
  143008. d.materials = []);
  143009. const _ = new TransformNode("__root__" + e.name,this._scene);
  143010. if (e.uri.split(".")[1] == "glb")
  143011. d.meshes[0].parent = _;
  143012. else if (e.uri.split(".")[1] == "obj") {
  143013. const b = new TransformNode("__root__",this._scene);
  143014. d.meshes.forEach(k=>{
  143015. k.parent = b,
  143016. k.Type = MESH_TAG
  143017. }
  143018. ),
  143019. b.parent = _
  143020. }
  143021. _.getChildMeshes().forEach(b=>{
  143022. e.isPickable != null ? b.isPickable = e.isPickable : b.isPickable = !1,
  143023. b.xtype = "XSubSequence"
  143024. }
  143025. ),
  143026. this._meshGroups.set(e.name, _),
  143027. _.parent = this._centerNode,
  143028. d.addAllToScene(),
  143029. i()
  143030. }
  143031. , ()=>{}
  143032. , ()=>{
  143033. log$C.error("subSequence:Load effect mesh fail"),
  143034. log$C.error(`Effect Mesh ${e.name} load error`),
  143035. o()
  143036. }
  143037. , ".glb")
  143038. }
  143039. , ()=>{
  143040. log$C.error("http:Get effect mesh fail"),
  143041. log$C.error(`Effect Mesh ${e.name} load error`),
  143042. o()
  143043. }
  143044. )
  143045. }
  143046. )
  143047. }
  143048. loadSprite(e) {
  143049. return new Promise((i,o)=>{
  143050. if (this._isDisposing) {
  143051. i();
  143052. return
  143053. }
  143054. const s = this._rootDir + e.uri;
  143055. if (e.uri !== "") {
  143056. e.name;
  143057. const c = new XMLHttpRequest;
  143058. c.open("get", s),
  143059. c.send(null),
  143060. c.onload = ()=>{
  143061. if (c.status == 200) {
  143062. const d = JSON.parse(c.responseText)
  143063. , _ = XSpriteManager.Parse(d, this._scene, this._rootDir);
  143064. _.sprites.forEach(b=>{
  143065. b.stopAnimation()
  143066. }
  143067. ),
  143068. this._spriteGroups.set(e.name, _),
  143069. i()
  143070. } else
  143071. log$C.error("subSequence:Load effect sprite fail"),
  143072. log$C.error(`Effect Sprite ${e.name} load error`),
  143073. o()
  143074. }
  143075. }
  143076. }
  143077. )
  143078. }
  143079. loadMaterial(e) {
  143080. return new Promise((i,o)=>{
  143081. if (this._isDisposing) {
  143082. i();
  143083. return
  143084. }
  143085. const s = this._rootDir + e.uri;
  143086. if (e.uri !== "") {
  143087. const c = e.name
  143088. , d = new NodeMaterial(`material_${c}`,this._scene,{
  143089. emitComments: !1
  143090. });
  143091. d.backFaceCulling = !1,
  143092. this.urlTransformer(s).then(_=>{
  143093. if (this._isDisposing) {
  143094. d.dispose(!1, !0, !1),
  143095. i();
  143096. return
  143097. }
  143098. d.loadAsync(_).then(()=>{
  143099. if (this._isDisposing) {
  143100. d.dispose(!0, !0, !1),
  143101. i();
  143102. return
  143103. }
  143104. d.build(!1);
  143105. const b = new Array;
  143106. let k = !1;
  143107. for (let j = 0; j < e.meshName.length; j++)
  143108. this._meshGroups.forEach($=>{
  143109. $.getChildMeshes().forEach(_e=>{
  143110. var et;
  143111. if (_e.name === e.meshName[j]) {
  143112. k = !0,
  143113. (et = _e.material) == null || et.dispose(!0, !0);
  143114. const tt = _e;
  143115. if (tt.skeleton == null) {
  143116. const rt = d;
  143117. tt.material = rt,
  143118. b.push(rt)
  143119. } else if (tt.numBoneInfluencers = 4,
  143120. tt.computeBonesUsingShaders = !0,
  143121. j == 0) {
  143122. const rt = d;
  143123. tt.material = rt,
  143124. b.push(rt)
  143125. } else {
  143126. const rt = d.clone(`material_${c}` + String(j), !1);
  143127. tt.material = rt,
  143128. b.push(rt)
  143129. }
  143130. }
  143131. }
  143132. )
  143133. }
  143134. );
  143135. k ? this._materialGroups.set(e.name, b) : d.dispose(!0, !0),
  143136. i()
  143137. }
  143138. , ()=>{
  143139. log$C.error("http:Get effect Material fail"),
  143140. log$C.error(`Effect NodeMaterial ${c} load error`),
  143141. o()
  143142. }
  143143. )
  143144. }
  143145. )
  143146. }
  143147. }
  143148. )
  143149. }
  143150. async loadGlow(e) {
  143151. const i = new GlowLayer(e.name,this._scene,{
  143152. blurKernelSize: e.blurKernelSize
  143153. });
  143154. i.intensity = e.intensity,
  143155. e.meshName.forEach(o=>{
  143156. const s = this._scene.getMeshByName(o);
  143157. s != null && i.addIncludedOnlyMesh(s)
  143158. }
  143159. ),
  143160. this._glowGroups.set(e.name, i)
  143161. }
  143162. loadHighLight(e) {
  143163. const i = new HighlightLayer(e.name,this._scene);
  143164. e.meshName.forEach(o=>{
  143165. const s = this._scene.getMeshByName(o);
  143166. if (s != null) {
  143167. const c = new Color3(e.color[0],e.color[1],e.color[2]);
  143168. i.addMesh(s, c)
  143169. }
  143170. }
  143171. ),
  143172. this._highLightGroups.set(e.name, i)
  143173. }
  143174. loadParticle(e) {
  143175. return new Promise((i,o)=>{
  143176. const s = this._rootDir + e.rootDir
  143177. , c = new XParticleManager(this._scene);
  143178. this.urlTransformer(s + e.uri).then(d=>{
  143179. if (this._isDisposing) {
  143180. i();
  143181. return
  143182. }
  143183. c.load(s, e.uri, e.name).then(_=>{
  143184. if (this._isDisposing) {
  143185. o();
  143186. return
  143187. }
  143188. this._particleGroups.set(e.name, _),
  143189. i()
  143190. }
  143191. , ()=>{
  143192. log$C.error(`SubSequence: ${e.name} particle load fail`),
  143193. o()
  143194. }
  143195. )
  143196. }
  143197. , ()=>{
  143198. log$C.error(`http: ${s + e.uri} load fail`),
  143199. o()
  143200. }
  143201. )
  143202. }
  143203. )
  143204. }
  143205. }
  143206. const DefaultUrlTransformer = async a=>a;
  143207. class XSequence {
  143208. constructor(e, i, o="test", s=DefaultUrlTransformer) {
  143209. this.init = async()=>new Promise(c=>{
  143210. this.urlTransformer(this._abosoluteUrl).then(d=>{
  143211. const _ = new XMLHttpRequest;
  143212. _.open("get", d),
  143213. _.send(null),
  143214. _.onload = ()=>{
  143215. if (_.status == 200) {
  143216. const b = JSON.parse(_.responseText);
  143217. this.load(b).then(()=>{
  143218. c()
  143219. }
  143220. )
  143221. }
  143222. }
  143223. }
  143224. )
  143225. }
  143226. ),
  143227. this.getRootOfSubSeqs = ()=>{
  143228. const c = new Array;
  143229. return this._subSeqs.forEach(d=>{
  143230. c.push(d.root)
  143231. }
  143232. ),
  143233. c
  143234. }
  143235. ,
  143236. this.play = async(c=!0)=>new Promise(d=>{
  143237. this._animGroup.play(c),
  143238. c ? this._animGroup.onAnimationGroupLoopObservable.addOnce(()=>{
  143239. d()
  143240. }
  143241. ) : this._animGroup.onAnimationGroupEndObservable.addOnce(()=>{
  143242. d()
  143243. }
  143244. )
  143245. }
  143246. ),
  143247. this.goToFrame = c=>{
  143248. this._animGroup.goToFrame(c)
  143249. }
  143250. ,
  143251. this.hide = ()=>{
  143252. this._subSeqs.forEach(c=>{
  143253. c.hide()
  143254. }
  143255. )
  143256. }
  143257. ,
  143258. this.show = ()=>{
  143259. this._subSeqs.forEach(c=>{
  143260. c.show()
  143261. }
  143262. )
  143263. }
  143264. ,
  143265. this.pause = ()=>{
  143266. this._animGroup.pause()
  143267. }
  143268. ,
  143269. this.reset = ()=>{
  143270. this._animGroup.reset()
  143271. }
  143272. ,
  143273. this._scene = e,
  143274. this._abosoluteUrl = i,
  143275. this._rootDir = i.split("/").slice(0, -1).join("/") + "/",
  143276. this._name = o,
  143277. this._subSeqs = new Map,
  143278. this._animGroup = new AnimationGroup("Seq_" + o,e),
  143279. this._targetSubSeqs = new Map,
  143280. this._animGroup.onAnimationGroupPlayObservable.add(()=>{
  143281. this._subSeqs.forEach(c=>{
  143282. c.show()
  143283. }
  143284. )
  143285. }
  143286. ),
  143287. this._animGroup.onAnimationGroupEndObservable.add(()=>{
  143288. this._subSeqs.forEach(c=>{
  143289. c.hide()
  143290. }
  143291. )
  143292. }
  143293. ),
  143294. this.urlTransformer = s
  143295. }
  143296. get animGroup() {
  143297. return this._animGroup
  143298. }
  143299. serialize() {
  143300. const e = {};
  143301. return e.SubSequence = new Array,
  143302. e.TimeLine = new Array,
  143303. this._subSeqs.forEach(i=>{
  143304. const o = {
  143305. name: i.name,
  143306. uri: i.path
  143307. };
  143308. e.SubSequence.push(o);
  143309. const s = this._targetSubSeqs.get(i);
  143310. s && e.TimeLine.push({
  143311. frame: s == null ? void 0 : s.frame,
  143312. position: s.position,
  143313. rotation: s.rotation,
  143314. scaling: s.scaling,
  143315. name: i.name
  143316. })
  143317. }
  143318. ),
  143319. e
  143320. }
  143321. get isPlaying() {
  143322. return this._animGroup.isPlaying
  143323. }
  143324. get isStarted() {
  143325. return this._animGroup.isStarted
  143326. }
  143327. get loaded() {
  143328. let e = !0;
  143329. return this._subSeqs.forEach(i=>{
  143330. e = e && i.loaded
  143331. }
  143332. ),
  143333. e
  143334. }
  143335. dispose() {
  143336. this._subSeqs.forEach(e=>{
  143337. e.dispose()
  143338. }
  143339. ),
  143340. this.animGroup.dispose()
  143341. }
  143342. setFrame(e, i) {
  143343. const o = this._subSeqs.get(e);
  143344. if (o) {
  143345. const s = this._targetSubSeqs.get(o);
  143346. s && (s.frame = i),
  143347. s && this.update(o, s)
  143348. }
  143349. }
  143350. get name() {
  143351. return this._name
  143352. }
  143353. update(e, i) {
  143354. if (i) {
  143355. const o = {
  143356. frame: i.frame,
  143357. scaling: new Vector3(i.scaling[0],i.scaling[1],i.scaling[2]),
  143358. position: new Vector3(i.position[0],i.position[1],i.position[2]),
  143359. rotation: new Vector3(i.rotation[0] / 180 * Math.PI,i.rotation[1] / 180 * Math.PI,i.rotation[2] / 180 * Math.PI),
  143360. name: i.name
  143361. }
  143362. , s = this._subSeqs.get(o.name);
  143363. s && (s.setPositionVector(o.position),
  143364. s.setRotationVector(o.rotation),
  143365. s.setScalingVector(o.scaling),
  143366. s.setStartFrame(o.frame),
  143367. this._targetSubSeqs.set(s, i),
  143368. s.onSubSequenceTransformationChangeObservable.add(()=>{
  143369. const c = this._targetSubSeqs.get(s);
  143370. c && (c.position = [s.pos.x, s.pos.y, s.pos.z]),
  143371. c && (c.rotation = [s.rot.x, s.rot.y, s.rot.z]),
  143372. c && (c.scaling = [s.scal.x, s.scal.y, s.scal.z])
  143373. }
  143374. ))
  143375. }
  143376. }
  143377. load(e) {
  143378. return new Promise((i,o)=>{
  143379. const s = new Array
  143380. , c = e.SubSequence
  143381. , d = e.TimeLine;
  143382. for (const _ of c) {
  143383. _.uri.indexOf("./") == 0 && (_.uri = _.uri.slice(2));
  143384. const b = new XSubSequence(this._scene,this._rootDir + _.uri,this.urlTransformer);
  143385. this._subSeqs.set(_.name, b),
  143386. s.push(b.init())
  143387. }
  143388. Promise.all(s).then(()=>{
  143389. d.forEach(_=>{
  143390. const b = this._subSeqs.get(_.name);
  143391. b && this.update(b, _)
  143392. }
  143393. ),
  143394. this._subSeqs.forEach(_=>{
  143395. _.animGroup.targetedAnimations.forEach(b=>{
  143396. this._animGroup.addTargetedAnimation(b.animation, b.target)
  143397. }
  143398. )
  143399. }
  143400. ),
  143401. i()
  143402. }
  143403. , ()=>{
  143404. o()
  143405. }
  143406. )
  143407. }
  143408. )
  143409. }
  143410. }
  143411. const log$B = new Logger$1("XStaticMesh");
  143412. class XStaticMesh {
  143413. constructor({id: e, mesh: i, group: o="default", lod: s=0, xtype: c=EMeshType.XStaticMesh, skinInfo: d="default", url: _=""}) {
  143414. this._mesh = void 0,
  143415. this._id = "-1",
  143416. this._isMoving = !1,
  143417. this._isRotating = !1,
  143418. this._isVisible = !0,
  143419. this.setVisibility = (b,k)=>{
  143420. Array.isArray(b) ? b.forEach(j=>{
  143421. this.setVisibility(j, k)
  143422. }
  143423. ) : b.isAnInstance || (b.visibility = k)
  143424. }
  143425. ,
  143426. this.setPickable = (b,k)=>{
  143427. Array.isArray(b) ? b.forEach(j=>{
  143428. this.setPickable(j, k)
  143429. }
  143430. ) : ("isPickable"in b && (b.isPickable = k),
  143431. b.setEnabled(k))
  143432. }
  143433. ,
  143434. this.hide = ()=>{
  143435. var b;
  143436. this._isVisible = !1,
  143437. this.mesh && this.setVisibility(this.mesh, 0),
  143438. this.mesh && this.setPickable(this.mesh, !1),
  143439. (b = this.mesh) == null || b.getChildMeshes().forEach(k=>{
  143440. this.setVisibility(k, 0),
  143441. this.setPickable(k, !1)
  143442. }
  143443. )
  143444. }
  143445. ,
  143446. this.show = ()=>{
  143447. var b;
  143448. this._isVisible = !0,
  143449. this.mesh && this.setVisibility(this.mesh, 1),
  143450. this.mesh && this.setPickable(this.mesh, !0),
  143451. (b = this.mesh) == null || b.getChildMeshes().forEach(k=>{
  143452. this.setVisibility(k, 1),
  143453. this.setPickable(k, !0)
  143454. }
  143455. )
  143456. }
  143457. ,
  143458. this.attachToAvatar = (b,k={
  143459. x: 0,
  143460. y: .5,
  143461. z: 0
  143462. },j={
  143463. yaw: 0,
  143464. pitch: 0,
  143465. roll: 0
  143466. },$={
  143467. x: .35,
  143468. y: .35,
  143469. z: .35
  143470. })=>{
  143471. const _e = ue4Scaling2Xverse($)
  143472. , et = ue4Rotation2Xverse(j)
  143473. , tt = ue4Position2Xverse(k)
  143474. , rt = this._mesh;
  143475. b && rt ? (b.setParent(rt),
  143476. b.position = tt,
  143477. b.rotation = et,
  143478. b.scaling = _e) : log$B.error("[Engine] avatar or attachment not found!")
  143479. }
  143480. ,
  143481. this.detachFromAvatar = (b,k=!1)=>{
  143482. this._mesh && b ? this._mesh.removeChild(b) : log$B.error("[Engine] avatar not found!")
  143483. }
  143484. ,
  143485. this._id = e,
  143486. this._mesh = i,
  143487. this._group = o,
  143488. this._lod = s,
  143489. this._skinInfo = d,
  143490. this.unallowMove(),
  143491. this._mesh.xtype = c,
  143492. this._mesh.xid = e,
  143493. this._mesh.xgroup = this._group,
  143494. this._mesh.xlod = this._lod,
  143495. this._mesh.xskinInfo = this._skinInfo,
  143496. this._mesh.xurl = _
  143497. }
  143498. get mesh() {
  143499. return this._mesh
  143500. }
  143501. get position() {
  143502. var c;
  143503. if (!this._mesh)
  143504. return null;
  143505. const {x: e, y: i, z: o} = (c = this._mesh) == null ? void 0 : c.position;
  143506. return xversePosition2Ue4({
  143507. x: e,
  143508. y: i,
  143509. z: o
  143510. })
  143511. }
  143512. get id() {
  143513. return this._id
  143514. }
  143515. get group() {
  143516. return this._group
  143517. }
  143518. get isMoving() {
  143519. return this._isMoving
  143520. }
  143521. get isVisible() {
  143522. return this._isVisible
  143523. }
  143524. get isRotating() {
  143525. return this._isRotating
  143526. }
  143527. get skinInfo() {
  143528. return this._skinInfo
  143529. }
  143530. allowMove() {
  143531. this._mesh != null && (this._mesh.getChildMeshes().forEach(e=>{
  143532. e.unfreezeWorldMatrix()
  143533. }
  143534. ),
  143535. this._mesh.unfreezeWorldMatrix())
  143536. }
  143537. unallowMove() {
  143538. this._mesh != null && (this._mesh.getChildMeshes().forEach(e=>{
  143539. e.freezeWorldMatrix()
  143540. }
  143541. ),
  143542. this._mesh.freezeWorldMatrix())
  143543. }
  143544. getID() {
  143545. return this._id
  143546. }
  143547. setPosition(e) {
  143548. if (this._mesh) {
  143549. const i = ue4Position2Xverse(e);
  143550. this._mesh.position = i
  143551. } else
  143552. log$B.error("[Engine] no root for positioning")
  143553. }
  143554. setRotation(e) {
  143555. const i = ue4Rotation2Xverse_mesh(e);
  143556. this._mesh ? this._mesh.rotation = i : log$B.error("[Engine] no root for rotating")
  143557. }
  143558. setScale(e) {
  143559. this._mesh ? this._mesh.scaling = new Vector3(e,e,-e) : log$B.error("[Engine] no root for scaling")
  143560. }
  143561. disableAvatar() {
  143562. var e;
  143563. (e = this._mesh) == null || e.setEnabled(!1)
  143564. }
  143565. enableAvatar() {
  143566. var e;
  143567. (e = this._mesh) == null || e.setEnabled(!0)
  143568. }
  143569. togglePickable(e) {
  143570. var i;
  143571. (i = this.mesh) == null || i.getChildMeshes().forEach(o=>{
  143572. "instances"in o && "isPickable"in o && (o.isPickable = e)
  143573. }
  143574. ),
  143575. this.mesh != null && "isPickable"in this.mesh && (this.mesh.isPickable = e)
  143576. }
  143577. setMaterial(e) {
  143578. var i;
  143579. (i = this.mesh) == null || i.getChildMeshes().forEach(o=>{
  143580. "instances"in o && "material"in o && (o.material = e)
  143581. }
  143582. ),
  143583. this.mesh != null && "material"in this.mesh && (this.mesh.material = e)
  143584. }
  143585. dispose(e=!1, i=!1) {
  143586. !this.mesh.isDisposed() && this.mesh.dispose(e, i)
  143587. }
  143588. }
  143589. class Timeout$1 {
  143590. constructor(e, i, o=!0) {
  143591. this._fn = e,
  143592. this._delay = i,
  143593. o && this.start()
  143594. }
  143595. get delay() {
  143596. return this._delay
  143597. }
  143598. get isSet() {
  143599. return !!this._timeout
  143600. }
  143601. setDelay(e) {
  143602. this._delay = e
  143603. }
  143604. start() {
  143605. this.isSet || (this._timeout = window.setTimeout(()=>{
  143606. const e = this._fn;
  143607. this.clear(),
  143608. e()
  143609. }
  143610. , this._delay))
  143611. }
  143612. clear() {
  143613. window.clearTimeout(this._timeout),
  143614. this._timeout = void 0
  143615. }
  143616. reset() {
  143617. this.clear(),
  143618. this.start()
  143619. }
  143620. }
  143621. class Stream$1 {
  143622. constructor(e) {
  143623. if (this._streamPlayTimer = null,
  143624. this.play = ()=>new Promise((i,o)=>{
  143625. this._streamPlayTimer = new Timeout$1(()=>{
  143626. o("Stream play timeout")
  143627. }
  143628. ,5e3),
  143629. this.el && this.el.play().then(()=>{
  143630. var s;
  143631. i(),
  143632. (s = this._streamPlayTimer) == null || s.clear()
  143633. }
  143634. ).catch(s=>{
  143635. var c;
  143636. o("Media Failed to autoplay"),
  143637. (c = this._streamPlayTimer) == null || c.clear()
  143638. }
  143639. )
  143640. }
  143641. ),
  143642. !e) {
  143643. this.el = this.createVideoElement();
  143644. return
  143645. }
  143646. this.el = e
  143647. }
  143648. createVideoElement() {
  143649. const e = document.createElement("video");
  143650. return e.muted = !0,
  143651. e.autoplay = !1,
  143652. e.playsInline = !0,
  143653. e.width = 360,
  143654. e.height = 640,
  143655. e.setAttribute("autostart", "false"),
  143656. e.setAttribute("controls", "controls"),
  143657. e.setAttribute("muted", "true"),
  143658. e.setAttribute("preload", "auto"),
  143659. e.setAttribute("hidden", "hidden"),
  143660. document.body.appendChild(e),
  143661. e
  143662. }
  143663. }
  143664. var tvFragment = `precision highp float;
  143665. varying vec2 vUV;
  143666. uniform float tvWidthHeightScale;
  143667. uniform float mvWidthHeightScale;
  143668. uniform float bforceforceKeepContent;
  143669. uniform sampler2D texture_video;
  143670. // \u7B49\u6BD4\u4F8B\u7F29\u653E\u753B\u9762\u5360\u6EE1\u5C4F\u5E55\uFF0C\u5B58\u5728\u5185\u5BB9\u7684\u4E22\u5931
  143671. vec2 equalScalingFitTvSize(vec2 uv, float tvWidthHeightScale, float mvWidthHeightScale)
  143672. {
  143673. if( tvWidthHeightScale > mvWidthHeightScale )
  143674. {
  143675. float scale = mvWidthHeightScale/tvWidthHeightScale;
  143676. uv.y = (uv.y - 0.5) * scale + 0.5;
  143677. }else if( tvWidthHeightScale < mvWidthHeightScale )
  143678. {
  143679. float scale = tvWidthHeightScale/mvWidthHeightScale;
  143680. uv.x = (uv.x - 0.5) * scale + 0.5;
  143681. }
  143682. return vec2( uv.x , uv.y);
  143683. }
  143684. // \u5F3A\u5236\u4FDD\u7559\u753B\u9762\u5185\u5BB9\uFF08\u5E26\u6709\u9ED1\u8FB9\uFF09
  143685. vec2 forceKeepContent(vec2 uv, float tvWidthHeightScale, float mvWidthHeightScale)
  143686. {
  143687. if( tvWidthHeightScale > mvWidthHeightScale )
  143688. {
  143689. float scale = mvWidthHeightScale/tvWidthHeightScale;
  143690. uv.x = (uv.x - 0.5) / scale + 0.5;
  143691. }else if( tvWidthHeightScale < mvWidthHeightScale )
  143692. {
  143693. float scale = tvWidthHeightScale/mvWidthHeightScale;
  143694. uv.y = (uv.y - 0.5) / scale + 0.5;
  143695. }
  143696. return vec2( uv.x , uv.y);
  143697. }
  143698. void main()
  143699. {
  143700. vec2 uv = vUV;
  143701. vec3 rgb;
  143702. vec3 color = vec3(0,0,0);
  143703. // \u4E00\u65E6\u8BBE\u7F6E\u4E86mvWidthHeightScale\uFF0C\u5C31\u4F1A\u89E6\u53D1\u7B49\u6BD4\u4F8B\u7F29\u653Eor\u5F3A\u5236\u4FDD\u5185\u5BB9
  143704. if(tvWidthHeightScale > 0.0 && mvWidthHeightScale > 0.0)
  143705. {
  143706. if(bforceforceKeepContent > 0.0){
  143707. uv = forceKeepContent(uv, tvWidthHeightScale, mvWidthHeightScale);
  143708. }else{
  143709. uv = equalScalingFitTvSize(uv, tvWidthHeightScale, mvWidthHeightScale);
  143710. }
  143711. }
  143712. color = texture2D(texture_video, uv).rgb;
  143713. if( uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0 )
  143714. {
  143715. color = vec3(0,0,0);
  143716. }
  143717. gl_FragColor = vec4(color, 1.0);
  143718. }
  143719. `
  143720. , tvVertex = `precision highp float;
  143721. varying vec2 vUV;
  143722. attribute vec2 uv;
  143723. attribute vec3 position;
  143724. uniform mat4 view;
  143725. uniform mat4 projection;
  143726. uniform mat4 world;
  143727. void main()
  143728. {
  143729. vUV = uv;
  143730. gl_Position = projection * view * world * vec4(position , 1.0);
  143731. }
  143732. `;
  143733. const log$A = new Logger$1("XTelevision");
  143734. var EFitMode = (a=>(a.fill = "fill",
  143735. a.contain = "contain",
  143736. a.cover = "cover",
  143737. a))(EFitMode || {});
  143738. class XTelevision {
  143739. constructor(e, i, o, s) {
  143740. if (this.tvMeshs = [],
  143741. this.scene = e,
  143742. this.meshPath = i,
  143743. this._scenemanager = o,
  143744. s != null) {
  143745. const {vAng: c=0, widthHeightScale: d=-1, fitMode: _="fill"} = s;
  143746. this.vAng = c,
  143747. this.widthHeightScale = d,
  143748. this.fitMode = _
  143749. }
  143750. }
  143751. set tvWidthHeightscale(e) {
  143752. this.widthHeightScale = e
  143753. }
  143754. get tvWidthHeightscale() {
  143755. return this.widthHeightScale
  143756. }
  143757. get tvFitMode() {
  143758. return this.fitMode
  143759. }
  143760. set tvFitMode(e) {
  143761. this.fitMode = e
  143762. }
  143763. setPlaySpeed(e) {
  143764. this.videoElement != null && (this.videoElement.playbackRate = e)
  143765. }
  143766. getMesh() {
  143767. return this.tvMeshs
  143768. }
  143769. createElement(e, i=!1) {
  143770. const s = new Stream$1().el;
  143771. return s.loop = i,
  143772. s.autoplay = !0,
  143773. s.src = e,
  143774. s
  143775. }
  143776. async setUrl(e) {
  143777. const {url: i, isLive: o=!1, poster: s=null, bLoop: c=!1, bMuted: d=!0} = e || {};
  143778. if (typeof i != "string")
  143779. return log$A.error("[Engine] Tv setUrl Error, url must be string: ", i),
  143780. Promise.reject(new XTvMediaUrlError("[Engine] url must be string"));
  143781. if (this.videoElement) {
  143782. this.videoElement.src = i,
  143783. s != null && s.length > 0 && (this.videoElement.poster = s);
  143784. const b = this.play();
  143785. return "bMuted"in e && b !== void 0 && b.then(()=>{
  143786. this.videoElement.muted = d
  143787. }
  143788. ),
  143789. this.videoElement.addEventListener("loadedmetadata", k=>{
  143790. this.videoElement.videoWidth > 0 ? this.videoMat.setFloat("mvWidthHeightScale", this.videoElement.videoWidth / this.videoElement.videoHeight) : this.videoMat.setFloat("mvWidthHeightScale", 16 / 9)
  143791. }
  143792. ),
  143793. Promise.resolve(this)
  143794. }
  143795. const _ = this.createElement(i, c);
  143796. return s != null && s.length > 0 && (_.poster = s),
  143797. this.setVideo(_, o).then(()=>{
  143798. var k;
  143799. const b = (k = this.videoElement) == null ? void 0 : k.play();
  143800. "bMuted"in e && b !== void 0 && b.then(()=>{
  143801. this.videoElement.muted = d
  143802. }
  143803. )
  143804. }
  143805. ).catch(b=>{
  143806. const k = new XTvMediaUrlError("[Engine] setUrl error! " + b);
  143807. return log$A.error(k),
  143808. Promise.reject(k)
  143809. }
  143810. )
  143811. }
  143812. setCurrentTime(e) {
  143813. if (!this.videoElement) {
  143814. log$A.warn("[Engine] The television is not been initialize succesfully");
  143815. return
  143816. }
  143817. const {currentTime: i} = e;
  143818. if (typeof i != "number") {
  143819. log$A.warn("[Engine] video currentTime must be number");
  143820. return
  143821. }
  143822. this.videoElement.currentTime = i / 1e3
  143823. }
  143824. getCurrentTime() {
  143825. return this.videoElement ? this.videoElement.currentTime * 1e3 : -1
  143826. }
  143827. play() {
  143828. return log$A.info("[Engine] Play television"),
  143829. this.toggle(!0),
  143830. this.videoElement ? this.videoElement.play() : Promise.resolve()
  143831. }
  143832. pause() {
  143833. var e;
  143834. return log$A.info("[Engine] Pause television"),
  143835. (e = this.videoElement) == null ? void 0 : e.pause()
  143836. }
  143837. stop() {
  143838. log$A.info("[Engine] Stop television"),
  143839. this.pause(),
  143840. setTimeout(()=>{
  143841. this.setCurrentTime({
  143842. currentTime: 0
  143843. })
  143844. }
  143845. ),
  143846. this.toggle(!1)
  143847. }
  143848. toggle(e) {
  143849. log$A.info(`[Engine] Set Tv visibility = ${e}`);
  143850. for (let i = 0; i < this.tvMeshs.length; ++i)
  143851. e == !0 ? this.tvMeshs[i].show() : this.tvMeshs[i].hide()
  143852. }
  143853. getVideoMat() {
  143854. return this.videoMat
  143855. }
  143856. changeTvFitMode() {
  143857. this.fitMode == "contain" ? (this.widthHeightScale < 0 && (this.widthHeightScale = 2.4),
  143858. this.videoMat.setFloat("tvWidthHeightScale", this.widthHeightScale),
  143859. this.videoMat.setFloat("bforceforceKeepContent", 1)) : this.fitMode == "cover" ? (this.widthHeightScale < 0 && (this.widthHeightScale = this.calWidthHeightScale()),
  143860. this.videoMat.setFloat("tvWidthHeightScale", this.widthHeightScale),
  143861. this.videoMat.setFloat("bforceforceKeepContent", -1)) : this.videoMat.setFloat("tvWidthHeightScale", -1)
  143862. }
  143863. async setVideo(e, i=!1, o=!0) {
  143864. return this.tvMeshs.length != 0 ? (log$A.warn(`[Engine] Set Video. length!=0, mesh: ${this.meshPath}, src: ${e.src}`),
  143865. new Promise((s,c)=>{
  143866. if (!(e instanceof HTMLVideoElement))
  143867. return log$A.error("[Engine] Error, param of setVideo must be a HTMLVideoElement"),
  143868. c(new XTvVideoElementError("[Engine] param of setVideo must be a HTMLVideoElement"));
  143869. this.videoElement = e,
  143870. o == !1 && (i == !1 || checkOS().isIOS) && e.crossOrigin !== "anonymous" && (e.crossOrigin = "anonymous",
  143871. e.load()),
  143872. this.videoElement.addEventListener("loadedmetadata", d=>{
  143873. this.videoElement.videoWidth > 0 ? this.videoMat.setFloat("mvWidthHeightScale", this.videoElement.videoWidth / this.videoElement.videoHeight) : this.videoMat.setFloat("mvWidthHeightScale", 16 / 9)
  143874. }
  143875. ),
  143876. this.videoTexture.updateURL(this.videoElement.src),
  143877. s(this)
  143878. }
  143879. )) : (log$A.warn(`[Engine] Set Video. length==0, mesh: ${this.meshPath}, src: ${e.src}`),
  143880. this.meshPath == "" ? (log$A.error("[Engine] Error, television meshPath is empty."),
  143881. Promise.reject(new XTvVideoElementError("[Engine] Error, television meshPath is empty."))) : this._scenemanager.urlTransformer(this.meshPath).then(s=>new Promise((c,d)=>e instanceof HTMLVideoElement ? (this.videoElement = e,
  143882. o == !1 && (i == !1 || checkOS().isIOS) && e.crossOrigin !== "anonymous" && (e.crossOrigin = "anonymous",
  143883. e.load()),
  143884. SceneLoader.LoadAssetContainerAsync("", s, this.scene, null, ".glb").then(_=>{
  143885. for (let k = _.materials.length - 1; k >= 0; --k)
  143886. _.materials[k].dispose();
  143887. const b = [];
  143888. this.videoTexture = new VideoTexture("videoTex_" + Date.now(),e,this.scene,!1,!0,void 0,{
  143889. autoPlay: !0,
  143890. autoUpdateTexture: !0,
  143891. muted: !0
  143892. }),
  143893. this.videoTexture.vAng = this.vAng,
  143894. this.videoMat = new ShaderMaterial("videoMat_" + Date.now(),this.scene,{
  143895. vertexSource: tvVertex,
  143896. fragmentSource: tvFragment
  143897. },{
  143898. attributes: ["uv", "position"],
  143899. uniforms: ["view", "projection", "worldViewProjection", "world"]
  143900. }),
  143901. this.videoMat.setTexture("texture_video", this.videoTexture),
  143902. this.videoMat.setFloat("tvWidthHeightScale", -1),
  143903. this.videoMat.setFloat("mvWidthHeightScale", 16 / 9),
  143904. this.videoMat.setFloat("bforceforceKeepContent", -1),
  143905. this.videoMat.backFaceCulling = !1,
  143906. this.videoMat.sideOrientation = Mesh.FRONTSIDE,
  143907. this.videoElement.addEventListener("loadedmetadata", k=>{
  143908. this.videoElement.videoWidth > 0 ? this.videoMat.setFloat("mvWidthHeightScale", this.videoElement.videoWidth / this.videoElement.videoHeight) : this.videoMat.setFloat("mvWidthHeightScale", 16 / 9)
  143909. }
  143910. );
  143911. for (let k = 0; k < _.meshes.length; ++k)
  143912. _.meshes[k].visibility = 1,
  143913. _.meshes[k].isPickable = !0,
  143914. _.meshes[k].checkCollisions = !1,
  143915. _.meshes[k].material = this.videoMat,
  143916. "hasVertexAlpha"in _.meshes[k] && (_.meshes[k].hasVertexAlpha = !1),
  143917. this.scene.addMesh(_.meshes[k]),
  143918. b.push(new XStaticMesh({
  143919. id: _.meshes[k].id,
  143920. mesh: _.meshes[k],
  143921. xtype: EMeshType.Tv
  143922. }));
  143923. this.changeTvFitMode(),
  143924. this.tvMeshs = b,
  143925. this.toggle(!0),
  143926. c(this)
  143927. }
  143928. ).catch(_=>{
  143929. log$A.error("[Engine] setVideo: create Tv by input mesh error! " + _),
  143930. d(new XTvModelError("[Engine] setVideo: create Tv by input mesh error! " + _))
  143931. }
  143932. )) : d(new XTvVideoElementError("[Engine] param of setVideo must be a HTMLVideoElement")))))
  143933. }
  143934. async setSameVideo(e, i="") {
  143935. return e == null || e == null ? (log$A.error("[Engine] setSameVideo: input material is null or undefined "),
  143936. Promise.reject(new XTvModelError("[Engine] setSameVideo input material is null or undefined !"))) : this.tvMeshs.length != 0 && i == "" ? (log$A.warn(`[Engine] Set mirror video. length!=0, mesh: ${this.meshPath}`),
  143937. new Promise((o,s)=>{
  143938. try {
  143939. this.videoMat = e,
  143940. this.tvMeshs.forEach(c=>{
  143941. c.setMaterial(e)
  143942. }
  143943. ),
  143944. this.changeTvFitMode(),
  143945. o(this)
  143946. } catch (c) {
  143947. log$A.error("[Engine] setSameVideo: create Tv by input mesh error! " + c),
  143948. s(new XTvModelError("[Engine] create Tv by input mesh error! " + c))
  143949. }
  143950. }
  143951. )) : (i != "" && (this.meshPath = i,
  143952. this.widthHeightScale = -1),
  143953. this.meshPath == "" ? (log$A.error("[Engine] Error, setSameVideo television meshPath is empty."),
  143954. Promise.reject(new XTvVideoElementError("[Engine] Error, setSameVideo television meshPath is empty."))) : (log$A.warn(`[Engine] Set mirror video. length==0, mesh: ${this.meshPath}`),
  143955. this._scenemanager.urlTransformer(this.meshPath).then(o=>new Promise((s,c)=>(this.videoMat = e,
  143956. e != null && e.getActiveTextures()[0] && (this.videoElement = e == null ? void 0 : e.getActiveTextures()[0].video),
  143957. SceneLoader.LoadAssetContainerAsync("", o, this.scene, null, ".glb").then(d=>{
  143958. for (let b = d.materials.length - 1; b >= 0; --b)
  143959. d.materials[b].dispose();
  143960. const _ = [];
  143961. for (let b = 0; b < d.meshes.length; ++b)
  143962. d.meshes[b].visibility = 0,
  143963. d.meshes[b].isPickable = !0,
  143964. d.meshes[b].checkCollisions = !1,
  143965. d.meshes[b].material = this.videoMat,
  143966. "hasVertexAlpha"in d.meshes[b] && (d.meshes[b].hasVertexAlpha = !1),
  143967. this.scene.addMesh(d.meshes[b]),
  143968. _.push(new XStaticMesh({
  143969. id: d.meshes[b].id,
  143970. mesh: d.meshes[b],
  143971. xtype: EMeshType.Tv
  143972. }));
  143973. i != "" && this.cleanTv(!1, !1),
  143974. this.tvMeshs = _,
  143975. this.changeTvFitMode(),
  143976. s(this)
  143977. }
  143978. ).catch(d=>{
  143979. log$A.error("[Engine] setSameVideo: create Tv by input mesh error! " + d),
  143980. c(new XTvModelError("[Engine] create Tv by input mesh error! " + d))
  143981. }
  143982. ))))))
  143983. }
  143984. async changeTvModel(e="") {
  143985. return e != "" && (this.meshPath = e,
  143986. this.widthHeightScale = -1),
  143987. this.meshPath == "" ? (log$A.error("[Engine] Error,changeTvModel television meshPath is empty."),
  143988. Promise.reject(new XTvVideoElementError("[Engine] Error, changeTvModel television meshPath is empty."))) : this.videoMat == null || this.videoMat == null ? (log$A.error("[Engine] changeTvModel: videoMat is null or undefined! "),
  143989. Promise.reject(new XTvModelError("[Engine] changeTvModel: videoMat is null or undefined!"))) : this._scenemanager.urlTransformer(this.meshPath).then(i=>new Promise((o,s)=>SceneLoader.LoadAssetContainerAsync("", i, this.scene, null, ".glb").then(c=>{
  143990. for (let _ = c.materials.length - 1; _ >= 0; --_)
  143991. c.materials[_].dispose();
  143992. const d = [];
  143993. for (let _ = 0; _ < c.meshes.length; ++_)
  143994. c.meshes[_].visibility = 0,
  143995. c.meshes[_].isPickable = !0,
  143996. c.meshes[_].checkCollisions = !1,
  143997. c.meshes[_].material = this.videoMat,
  143998. "hasVertexAlpha"in c.meshes[_] && (c.meshes[_].hasVertexAlpha = !1),
  143999. this.scene.addMesh(c.meshes[_]),
  144000. d.push(new XStaticMesh({
  144001. id: c.meshes[_].id,
  144002. mesh: c.meshes[_],
  144003. xtype: EMeshType.Tv
  144004. }));
  144005. e != "" && this.cleanTv(!1, !1),
  144006. this.tvMeshs = d,
  144007. this.changeTvFitMode(),
  144008. o(this)
  144009. }
  144010. ).catch(c=>{
  144011. log$A.error("[Engine] changeTvModel: create Tv by input mesh error! " + c),
  144012. s(new XTvModelError("[Engine] changeTvModel: create Tv by input mesh error! " + c))
  144013. }
  144014. )))
  144015. }
  144016. calWidthHeightScale() {
  144017. const e = [1e5, 1e5, 1e5]
  144018. , i = [-1e5, -1e5, -1e5];
  144019. for (let d = 0; d < this.tvMeshs.length; ++d)
  144020. if (this.tvMeshs[d].mesh.name != "__root__") {
  144021. const _ = this.tvMeshs[d].mesh.getBoundingInfo().boundingBox.vectorsWorld;
  144022. for (let b = 0; b < _.length; ++b)
  144023. e[0] > _[b].x && (e[0] = _[b].x),
  144024. e[1] > _[b].y && (e[1] = _[b].y),
  144025. e[2] > _[b].z && (e[2] = _[b].z),
  144026. i[0] < _[b].x && (i[0] = _[b].x),
  144027. i[1] < _[b].y && (i[1] = _[b].y),
  144028. i[2] < _[b].z && (i[2] = _[b].z);
  144029. break
  144030. }
  144031. const o = i[0] - e[0]
  144032. , s = i[1] - e[1]
  144033. , c = i[2] - e[2];
  144034. return Math.sqrt(o * o + c * c) / Math.abs(s)
  144035. }
  144036. cleanTv(e=!1, i=!0) {
  144037. log$A.warn("[Engine] cleanTV");
  144038. for (let o = 0; o < this.tvMeshs.length; ++o)
  144039. this.tvMeshs[o].dispose(e, i);
  144040. this.tvMeshs = [],
  144041. this.meshPath = ""
  144042. }
  144043. }
  144044. class XStats {
  144045. constructor(e) {
  144046. this._scenemanager = e,
  144047. this.scene = e.Scene,
  144048. this._canvas = e.canvas,
  144049. this.initSceneInstrument()
  144050. }
  144051. initSceneInstrument() {
  144052. this.sceneInstrumentation = new SceneInstrumentation(this.scene),
  144053. this.sceneInstrumentation.captureCameraRenderTime = !0,
  144054. this.sceneInstrumentation.captureActiveMeshesEvaluationTime = !0,
  144055. this.sceneInstrumentation.captureRenderTargetsRenderTime = !0,
  144056. this.sceneInstrumentation.captureFrameTime = !0,
  144057. this.sceneInstrumentation.captureRenderTime = !0,
  144058. this.sceneInstrumentation.captureInterFrameTime = !0,
  144059. this.sceneInstrumentation.captureParticlesRenderTime = !0,
  144060. this.sceneInstrumentation.captureSpritesRenderTime = !0,
  144061. this.sceneInstrumentation.capturePhysicsTime = !0,
  144062. this.sceneInstrumentation.captureAnimationsTime = !0,
  144063. this.engineInstrumentation = new EngineInstrumentation(this.scene.getEngine()),
  144064. this.caps = this.scene.getEngine().getCaps(),
  144065. this.engine = this.scene.getEngine(),
  144066. this._osversion = this.osVersion()
  144067. }
  144068. getFrameTimeCounter() {
  144069. return this.sceneInstrumentation.frameTimeCounter.current
  144070. }
  144071. getInterFrameTimeCounter() {
  144072. return this.sceneInstrumentation.interFrameTimeCounter.current
  144073. }
  144074. getActiveMeshEvaluationTime() {
  144075. return this.sceneInstrumentation.activeMeshesEvaluationTimeCounter.current
  144076. }
  144077. getDrawCall() {
  144078. return this.sceneInstrumentation.drawCallsCounter.current
  144079. }
  144080. getDrawCallTime() {
  144081. return this.sceneInstrumentation.renderTimeCounter.current
  144082. }
  144083. getAnimationTime() {
  144084. return this.sceneInstrumentation.animationsTimeCounter.current
  144085. }
  144086. getActiveMesh() {
  144087. return this.scene.getActiveMeshes().length
  144088. }
  144089. getActiveFaces() {
  144090. return Math.round(this.scene.getActiveIndices() / 3)
  144091. }
  144092. getActiveBones() {
  144093. return this.scene.getActiveBones()
  144094. }
  144095. getActiveAnimation() {
  144096. return this.scene._activeAnimatables.length
  144097. }
  144098. getActiveParticles() {
  144099. return this.scene.getActiveParticles()
  144100. }
  144101. getTotalMaterials() {
  144102. return this.scene.materials.length
  144103. }
  144104. getTotalTextures() {
  144105. return this.scene.textures.length
  144106. }
  144107. getTotalGeometries() {
  144108. return this.scene.geometries.length
  144109. }
  144110. getTotalMeshes() {
  144111. return this.scene.meshes.length
  144112. }
  144113. getCameraRenderTime() {
  144114. return this.sceneInstrumentation.cameraRenderTimeCounter.current
  144115. }
  144116. getTotalRootNodes() {
  144117. return this.scene.rootNodes.length
  144118. }
  144119. getRenderTargetRenderTime() {
  144120. const e = this.getDrawCallTime()
  144121. , i = this.getActiveMeshEvaluationTime()
  144122. , o = this.getCameraRenderTime() - (i + e);
  144123. return this.getRTT1Time() + o
  144124. }
  144125. getRegisterBeforeRenderTime() {
  144126. return this.sceneInstrumentation.registerBeforeTimeCounter.current
  144127. }
  144128. getRegisterAfterRenderTime() {
  144129. return this.sceneInstrumentation.registerAfterTimeCounter.current
  144130. }
  144131. getRTT1Time() {
  144132. return this.sceneInstrumentation.getRTT1TimeCounter.current
  144133. }
  144134. getRegisterBeforeRenderObserverLength() {
  144135. return this.scene.onBeforeRenderObservable.observers.length
  144136. }
  144137. getRegisterAfterRenderObserverLength() {
  144138. return this.scene.onAfterRenderObservable.observers.length
  144139. }
  144140. getTotalMeshByType() {
  144141. const e = new Map;
  144142. return this.scene.meshes.forEach(i=>{
  144143. e.has(i.xtype) ? e.set(i.xtype, e.get(i.xtype) + 1) : e.set(i.xtype, 1)
  144144. }
  144145. ),
  144146. e
  144147. }
  144148. getHardwareRenderInfo() {
  144149. return {
  144150. maxTexturesUnits: this.caps.maxTexturesImageUnits,
  144151. maxVertexTextureImageUnits: this.caps.maxVertexTextureImageUnits,
  144152. maxCombinedTexturesImageUnits: this.caps.maxCombinedTexturesImageUnits,
  144153. maxTextureSize: this.caps.maxTextureSize,
  144154. maxSamples: this.caps.maxSamples,
  144155. maxCubemapTextureSize: this.caps.maxCubemapTextureSize,
  144156. maxRenderTextureSize: this.caps.maxRenderTextureSize,
  144157. maxVertexAttribs: this.caps.maxVertexAttribs,
  144158. maxVaryingVectors: this.caps.maxVaryingVectors,
  144159. maxVertexUniformVectors: this.caps.maxVertexUniformVectors,
  144160. maxFragmentUniformVectors: this.caps.maxFragmentUniformVectors,
  144161. standardDerivatives: this.caps.standardDerivatives,
  144162. supportTextureCompress: {
  144163. s3tc: this.caps.s3tc !== void 0,
  144164. s3tc_srgb: this.caps.s3tc_srgb !== void 0,
  144165. pvrtc: this.caps.pvrtc !== void 0,
  144166. etc1: this.caps.etc1 !== void 0,
  144167. etc2: this.caps.etc2 !== void 0,
  144168. astc: this.caps.astc !== void 0,
  144169. bptc: this.caps.bptc !== void 0
  144170. },
  144171. textureFloat: this.caps.textureFloat,
  144172. vertexArrayObject: this.caps.vertexArrayObject,
  144173. textureAnisotropicFilterExtension: this.caps.textureAnisotropicFilterExtension !== void 0,
  144174. maxAnisotropy: this.caps.maxAnisotropy,
  144175. instancedArrays: this.caps.instancedArrays,
  144176. uintIndices: this.caps.uintIndices,
  144177. highPrecisionShaders: this.caps.highPrecisionShaderSupported,
  144178. fragmentDepth: this.caps.fragmentDepthSupported,
  144179. textureFloatLinearFiltering: this.caps.textureFloatLinearFiltering,
  144180. renderToTextureFloat: this.caps.textureFloatRender,
  144181. textureHalfFloat: this.caps.textureHalfFloat,
  144182. textureHalfFloatLinearFiltering: this.caps.textureHalfFloatLinearFiltering,
  144183. textureHalfFloatRender: this.caps.textureHalfFloatRender,
  144184. textureLOD: this.caps.textureLOD,
  144185. drawBuffersExtension: this.caps.drawBuffersExtension,
  144186. depthTextureExtension: this.caps.depthTextureExtension,
  144187. colorBufferFloat: this.caps.colorBufferFloat,
  144188. supportTimerQuery: this.caps.timerQuery !== void 0,
  144189. canUseTimestampForTimerQuery: this.caps.canUseTimestampForTimerQuery,
  144190. supportOcclusionQuery: this.caps.supportOcclusionQuery,
  144191. multiview: this.caps.multiview,
  144192. oculusMultiview: this.caps.oculusMultiview,
  144193. maxMSAASamples: this.caps.maxMSAASamples,
  144194. blendMinMax: this.caps.blendMinMax,
  144195. canUseGLInstanceID: this.caps.canUseGLInstanceID,
  144196. canUseGLVertexID: this.caps.canUseGLVertexID,
  144197. supportComputeShaders: this.caps.supportComputeShaders,
  144198. supportSRGBBuffers: this.caps.supportSRGBBuffers,
  144199. supportStencil: this.engine.isStencilEnable
  144200. }
  144201. }
  144202. getSystemInfo() {
  144203. return {
  144204. resolution: "real: " + this.engine.getRenderWidth() + "x" + this.engine.getRenderHeight() + " cavs: " + this._canvas.clientWidth + "x" + this._canvas.clientHeight,
  144205. hardwareScalingLevel: this.engine.getHardwareScalingLevel().toFixed(2).toString() + "_" + this._scenemanager.initEngineScaleNumber.toFixed(2).toString(),
  144206. driver: this.engine.getGlInfo().renderer,
  144207. vender: this.engine.getGlInfo().vendor,
  144208. version: this.engine.getGlInfo().version,
  144209. os: this._osversion
  144210. }
  144211. }
  144212. getFps() {
  144213. const e = this.sceneInstrumentation.frameTimeCounter.lastSecAverage
  144214. , i = this.sceneInstrumentation.interFrameTimeCounter.lastSecAverage;
  144215. return 1e3 / (e + i)
  144216. }
  144217. osVersion() {
  144218. const e = window.navigator.userAgent;
  144219. let i;
  144220. return /iphone|ipad|ipod/gi.test(e) ? i = e.match(/OS (\d+)_(\d+)_?(\d+)?/) : /android/gi.test(e) && (i = e.match(/Android (\d+)/)),
  144221. i != null && i.length > 0 ? i[0] : null
  144222. }
  144223. }
  144224. class RunTimeArray {
  144225. constructor() {
  144226. this.circularData = []
  144227. }
  144228. add(e) {
  144229. this.circularData.length > 1e3 && this.circularData.shift(),
  144230. this.circularData.push(e)
  144231. }
  144232. getAvg() {
  144233. let e = 0;
  144234. for (let i = 0; i < this.circularData.length; i++)
  144235. e += this.circularData[i];
  144236. return {
  144237. sum: e,
  144238. avg: e / this.circularData.length || 0
  144239. }
  144240. }
  144241. getMax() {
  144242. let e = 0;
  144243. for (let i = 0; i < this.circularData.length; i++)
  144244. e < this.circularData[i] && (e = this.circularData[i]);
  144245. return e || 0
  144246. }
  144247. clear() {
  144248. this.circularData = []
  144249. }
  144250. getStat() {
  144251. const e = this.getAvg()
  144252. , i = {
  144253. sum: e.sum,
  144254. avg: e.avg,
  144255. max: this.getMax()
  144256. };
  144257. return this.clear(),
  144258. i
  144259. }
  144260. }
  144261. class XEngineRunTimeStats {
  144262. constructor() {
  144263. this.timeArray_loadStaticMesh = new RunTimeArray,
  144264. this.timeArray_updateStaticMesh = new RunTimeArray,
  144265. this.timeArray_addAvatarToScene = new RunTimeArray
  144266. }
  144267. }
  144268. const log$z = new Logger$1("XDecalManager");
  144269. class XDecalManager {
  144270. get decals() {
  144271. return Array.from(this._decal.values())
  144272. }
  144273. getMesh() {
  144274. return this._decal
  144275. }
  144276. constructor(e) {
  144277. this._decal = new Map,
  144278. this._mat = new Map,
  144279. this._sharedMat = new Map,
  144280. this._scenemanager = e,
  144281. this.scene = e.Scene
  144282. }
  144283. async addDecal(e) {
  144284. const {id: i, meshPath: o, skinInfo: s="default"} = e;
  144285. return this._decal.get(i) ? (log$z.warn(`[Engine] Cannot add decal with an existing id: [${i}], meshPath: ${o}, skinInfo:${s}`),
  144286. Promise.resolve(!0)) : (log$z.info(`[Engine] addDecal wiht id:[${i}], meshPath: ${o}, skinInfo:${s}`),
  144287. new Promise((c,d)=>this._scenemanager.urlTransformer(o).then(_=>new Promise((b,k)=>{
  144288. if (this._decal.get(i))
  144289. b(!0);
  144290. else {
  144291. const j = new XDecal({
  144292. id: i,
  144293. scene: this.scene,
  144294. meshPath: _,
  144295. skinInfo: s
  144296. });
  144297. this._decal.set(i, j),
  144298. j.loadModel().then(()=>{
  144299. b(!0)
  144300. }
  144301. ).catch($=>{
  144302. log$z.error(`[Engine] addDecal Error! id: [${i}], meshpath:${o}, skin: ${s}. ${$}`),
  144303. k(new XDecalError(`[Engine] addDecal Error! id: [${i}], meshpath:${o}, skin: ${s}. ${$}`))
  144304. }
  144305. )
  144306. }
  144307. }
  144308. )).then(_=>{
  144309. _ == !0 ? c(!0) : d(!1)
  144310. }
  144311. ).catch(_=>{
  144312. log$z.error(`[Engine] Add Decal error! id: [${i}], meshpath:${o}, skin:${s}. ${_}`),
  144313. d(new XDecalError(`[Engine] addDecal error! id: [${i}], meshpath:${o}, skin:${s}. ${_}`))
  144314. }
  144315. )))
  144316. }
  144317. setDecalTexture(e) {
  144318. const {id: i, buffer: o, isDynamic: s=!1, width: c=1100, height: d=25, slots: _=1, visibleSlots: b=1} = e
  144319. , k = !0;
  144320. return log$z.info(`[Engine] setDecalTexture wiht id:[${i}]`),
  144321. new Promise((j,$)=>{
  144322. const _e = this._decal.get(i);
  144323. if (_e != null)
  144324. if (this._mat.get(i) != null)
  144325. this.changeDecalTexture({
  144326. id: i,
  144327. buffer: o,
  144328. isUrl: k,
  144329. isDynamic: s,
  144330. width: c,
  144331. height: d,
  144332. slots: _,
  144333. visibleSlots: b
  144334. }),
  144335. j(!0);
  144336. else {
  144337. const et = new XDecalMaterial(i,this.scene);
  144338. et.setTexture(o, k, s, c, d, _, b).then(()=>{
  144339. _e.setMat(et.getMat()),
  144340. this._decal.set(i, _e),
  144341. this._mat.set(i, et),
  144342. j(!0)
  144343. }
  144344. ).catch(tt=>{
  144345. log$z.error("[Engine] setDecalTexture Error! " + tt),
  144346. $(new XDecalTextureError(`[Engine] decal set texture error! ${tt}`))
  144347. }
  144348. )
  144349. }
  144350. else
  144351. log$z.error("[Engine] Error! decal id: [" + i + "] is not find!"),
  144352. $(new XDecalTextureError(`[Engine] decal id: [${i}] is not find!`))
  144353. }
  144354. )
  144355. }
  144356. async shareDecal(e) {
  144357. const {idTar: i, meshPath: o, idSrc: s, skinInfo: c="default"} = e;
  144358. return this._decal.has(s) && !this._decal.has(i) && this._mat.has(s) && !this._mat.has(i) ? (log$z.info(`[Engine] shareDecal wiht idTar:[${i}], idSrc:[${s}], skinInfo: ${c}, meshPath: ${o}`),
  144359. new Promise((d,_)=>this._scenemanager.urlTransformer(o).then(b=>{
  144360. const k = new XDecal({
  144361. id: i,
  144362. scene: this.scene,
  144363. meshPath: b,
  144364. skinInfo: c
  144365. })
  144366. , j = this._mat.get(s);
  144367. j != null && (k.setMat(j.getMat()),
  144368. k.sourceMatId = s,
  144369. this._decal.set(i, k),
  144370. this.addSharedMatCount(s)),
  144371. d(!0)
  144372. }
  144373. ).catch(b=>{
  144374. _(new XDecalError(`[Engine] decal shareDecal error! ${b}`))
  144375. }
  144376. ))) : (log$z.error(`[Engine] shareDecal Error. idSrc: [${s}] not exist! or idTar: [${i}] exists!`),
  144377. Promise.reject(`[Engine] shareDecal Error. idSrc: [${s}] not exist! or idTar: [${i}] exists!`))
  144378. }
  144379. changeDecalModel(e) {
  144380. const {id: i, meshPath: o} = e
  144381. , s = this._decal.get(i);
  144382. return new Promise((c,d)=>s != null ? (log$z.info(`[Engine] changeDecalModel id:${i}`),
  144383. s.changeModel(o).then(()=>{
  144384. this._decal.set(i, s),
  144385. c(!0)
  144386. }
  144387. )) : (log$z.warn(`[Engine] changeDecalModel id:${i} is not exist`),
  144388. d(`[Engine] changeDecalModel id:${i} is not exist`)))
  144389. }
  144390. changeDecalTexture(e) {
  144391. const {id: i, buffer: o, isUrl: s=!1, isDynamic: c=!1, width: d=1110, height: _=25, slots: b=1, visibleSlots: k=1} = e
  144392. , j = this._mat.get(i);
  144393. j != null && this._decal.has(i) ? (j.changeTexture(o, s, c, d, _, b, k),
  144394. this._mat.set(i, j)) : log$z.error(`[Engine] changeDecalTexture Error. id:${i} is not exist`)
  144395. }
  144396. deleteDecal(e) {
  144397. var i, o;
  144398. if (this._decal.has(e)) {
  144399. const s = this._decal.get(e);
  144400. s != null && s.cleanMesh(),
  144401. this._sharedMat.get(e) != null ? this.minusSharedMatCount(e) : this._mat.get(e) != null ? ((i = this._mat.get(e)) == null || i.cleanTexture(),
  144402. this._mat.delete(e)) : ((o = s.sourceMatId) == null ? void 0 : o.length) > 0 && this.minusSharedMatCount(s.sourceMatId),
  144403. this._decal.delete(e)
  144404. }
  144405. }
  144406. deleteDecalBySkinInfo(e) {
  144407. for (const [i,o] of this._decal.entries())
  144408. o.skinInfo == e && this.deleteDecal(i)
  144409. }
  144410. addSharedMatCount(e) {
  144411. const i = this._sharedMat.get(e);
  144412. i != null ? this._sharedMat.set(e, i + 1) : this._sharedMat.set(e, 1)
  144413. }
  144414. minusSharedMatCount(e) {
  144415. var o;
  144416. const i = this._sharedMat.get(e);
  144417. i != null && (this._sharedMat.set(e, i - 1),
  144418. i == 0 && (this._sharedMat.delete(e),
  144419. (o = this._mat.get(e)) == null || o.cleanTexture(),
  144420. this._mat.delete(e)))
  144421. }
  144422. toggle(e, i) {
  144423. const o = this._decal.get(e);
  144424. o == null || o.toggle(i)
  144425. }
  144426. toggleDecalBySkinInfo(e, i) {
  144427. for (const [o,s] of this._decal.entries())
  144428. s.skinInfo == e && s.toggle(i)
  144429. }
  144430. updateTexAsWords(e, i, o={}) {
  144431. const {clearArea: s=!0, w: c=480, h: d=480, y: _=d / 2, fontsize: b=70, slots: k=1, visibleSlots: j=1, font: $="black-body", color: _e="white", fontweight: et=100} = o;
  144432. let {x: tt=c / 2} = o;
  144433. const rt = this._mat.get(e);
  144434. if (rt) {
  144435. tt == -1 && (tt = (rt.getUOffset() + j / k) % 1 * c * k);
  144436. const nt = rt.getMat().diffuseTexture
  144437. , ot = nt.getContext();
  144438. s && ot.clearRect(tt - c / 2, _ - d / 2, c, d),
  144439. ot.textAlign = "center",
  144440. ot.textBaseline = "middle",
  144441. nt.drawText(i, tt, _, et + " " + b + "px " + $, _e, "transparent", !0),
  144442. nt.hasAlpha = !0,
  144443. nt.update()
  144444. }
  144445. }
  144446. async updateTexAsImg(e, i, o={}) {
  144447. const {clearArea: s=!0, w: c=480, h: d=480, x: _=c / 2, y: b=d / 2, clearW: k=c, clearH: j=d} = o;
  144448. return i == null || i == null || i == "" ? (log$z.error(`[Engine] updateTexAsImg Error. id: [${e}], newBuffer is Null or ""!`),
  144449. Promise.reject(new XDecalError(`[Engine] updateTexAsImg Error. id: [${e}], newBuffer is Null or ""!`))) : new Promise(($,_e)=>this._scenemanager.urlTransformer(i).then(et=>new Promise((tt,rt)=>{
  144450. const it = this._mat.get(e);
  144451. if (it) {
  144452. const ot = it.getMat().diffuseTexture;
  144453. if (typeof i == "string") {
  144454. const at = new Image;
  144455. at.crossOrigin = "anonymous",
  144456. at.src = et,
  144457. at.onload = ()=>{
  144458. const st = ot.getContext();
  144459. s && st.clearRect(_ - k / 2, b - j / 2, k, j),
  144460. st.drawImage(at, _ - c / 2, b - d / 2, c, d),
  144461. ot.update(),
  144462. tt(!0)
  144463. }
  144464. ,
  144465. at.onerror = ()=>{
  144466. log$z.error(`[Engine] updateTexAsImg Error.newImg load error. id: [${e}], decalMat is Null or undefined!`),
  144467. rt(new XDecalError(`[Engine] updateTexAsImg Error. id: [${e}], decalMat is Null or undefined!`))
  144468. }
  144469. } else
  144470. log$z.error(`[Engine] updateTexAsImg Error. id: [${e}], Buffer is not string!`),
  144471. rt(new XDecalError(`[Engine] updateTexAsImg Error. id: [${e}], Buffer is not string!`))
  144472. } else
  144473. log$z.error(`[Engine] updateTexAsImg Error. id: [${e}], decalMat is Null or undefined!`),
  144474. rt(new XDecalError(`[Engine] updateTexAsImg Error. id: [${e}], decalMat is Null or undefined!`))
  144475. }
  144476. ).then(tt=>{
  144477. tt == !0 ? $(!0) : (log$z.error(`[Engine] updateTexAsImg Error. id: [${e}] !`),
  144478. _e(new XDecalError(`[Engine] updateTexAsImg error! id: [${e}]`)))
  144479. }
  144480. ).catch(tt=>{
  144481. log$z.error(`[Engine] updateTexAsImg Error. id: [${e}]. ${tt}`)
  144482. }
  144483. )))
  144484. }
  144485. startAnime(e, i) {
  144486. log$z.info(`[Engine] Decal Start Anime. [${e}]`);
  144487. const {speed: o=.001, callback: s} = i
  144488. , c = this._mat.get(e);
  144489. c ? (c.do_animation(o),
  144490. s && c.uOffsetObserverable.add(s)) : (log$z.error(`[Engine] startAnime Error. id: [${e}] is not exist!`),
  144491. new XDecalError(`[Engine] startAnime Error. id: [${e}] is not exist!`))
  144492. }
  144493. }
  144494. class XDecalMaterial {
  144495. constructor(e, i) {
  144496. this._speed = .001,
  144497. this._slots = 1,
  144498. this._visibleSlots = 1,
  144499. this._animeObserver = null,
  144500. this.reg_mat_update = ()=>{
  144501. const o = this._mat.diffuseTexture;
  144502. o != null && (o.uOffset = o.uOffset + this._speed,
  144503. o.uOffset > 1 && (o.uOffset -= 1),
  144504. Math.round(o.uOffset % (1 / this._slots) / this._speed) == 0 && this._uOffsetObserverable.notifyObservers(this))
  144505. }
  144506. ,
  144507. this.setTexture = async(o,s=!0,c=!1,d=1,_=1,b=1,k=1)=>new Promise((j,$)=>{
  144508. this._slots = b,
  144509. this._visibleSlots = k;
  144510. const _e = this._tex;
  144511. c ? (this._tex = new DynamicTexture("dyTex",{
  144512. width: d,
  144513. height: _
  144514. },this.scene,!0,Texture.BILINEAR_SAMPLINGMODE),
  144515. this._tex.name = "decal_dy_" + this._id,
  144516. this._tex.uScale = k / b,
  144517. this._tex.vScale = -1,
  144518. this._tex.vOffset = 1,
  144519. this._tex.wrapU = 1,
  144520. this._mat.emissiveColor = new Color3(.95,.95,.95),
  144521. this._mat.diffuseTexture = this._tex,
  144522. this._mat.diffuseTexture.hasAlpha = !0,
  144523. this._mat.useAlphaFromDiffuseTexture = !0,
  144524. this._mat.backFaceCulling = !1,
  144525. this._mat.transparencyMode = Material.MATERIAL_ALPHATEST,
  144526. _e != null && _e.dispose(),
  144527. j(!0)) : !c && s && typeof o == "string" ? this._tex = new Texture(o,this.scene,!0,!1,Texture.BILINEAR_SAMPLINGMODE,()=>{
  144528. this._tex.name = "decal_" + this._id,
  144529. this._mat.emissiveTexture = this._tex,
  144530. this._mat.diffuseTexture = this._tex,
  144531. this._mat.diffuseTexture.hasAlpha = !0,
  144532. this._mat.useAlphaFromDiffuseTexture = !0,
  144533. this._mat.transparencyMode = Material.MATERIAL_ALPHATEST,
  144534. _e != null && _e.dispose(),
  144535. j(!0)
  144536. }
  144537. ,()=>{
  144538. log$z.error("[Engine] decal create texture error!"),
  144539. $(new XDecalTextureError("[Engine] decal create texture error!"))
  144540. }
  144541. ,null,!0) : this._tex = new Texture("data:decal_" + this._id,this.scene,!0,!1,Texture.BILINEAR_SAMPLINGMODE,()=>{
  144542. this._tex.name = "decal_" + this._id,
  144543. this._mat.emissiveTexture = this._tex,
  144544. this._mat.diffuseTexture = this._tex,
  144545. this._mat.diffuseTexture.hasAlpha = !0,
  144546. this._mat.useAlphaFromDiffuseTexture = !0,
  144547. this._mat.transparencyMode = Material.MATERIAL_ALPHATEST,
  144548. _e != null && _e.dispose(),
  144549. j(!0)
  144550. }
  144551. ,()=>{
  144552. log$z.error("[Engine] decal create texture error!"),
  144553. $(new XDecalTextureError("[Engine] decal create texture error!"))
  144554. }
  144555. ,o,!0)
  144556. }
  144557. ),
  144558. this._id = e,
  144559. this.scene = i,
  144560. this._mat = new StandardMaterial("decalMat_" + this._id,this.scene),
  144561. this._isRegisterAnimation = !1,
  144562. this._uOffsetObserverable = new Observable
  144563. }
  144564. get uOffsetObserverable() {
  144565. return this._uOffsetObserverable
  144566. }
  144567. getMat() {
  144568. return this._mat
  144569. }
  144570. set speed(e) {
  144571. this._speed = e
  144572. }
  144573. getUOffset() {
  144574. return this._tex.uOffset
  144575. }
  144576. do_animation(e) {
  144577. this._speed = e,
  144578. this._isRegisterAnimation == !1 && (this._isRegisterAnimation = !0,
  144579. this._animeObserver = this.scene.onBeforeRenderObservable.add(()=>{
  144580. this.reg_mat_update()
  144581. }
  144582. ))
  144583. }
  144584. changeTexture(e, i=!1, o=!1, s=1, c=1, d=1, _=1) {
  144585. return this._mat == null || this._tex == null ? (log$z.error("[Engine] Decal Mat is null or tex is null"),
  144586. Promise.reject(new XDecalTextureError("[Engine] Decal Mat is null or tex is null"))) : this.setTexture(e, i, o, s, c, d, _)
  144587. }
  144588. cleanTexture() {
  144589. log$z.info("[Engine] Decal clean Texture"),
  144590. this.scene.onBeforeRenderObservable.remove(this._animeObserver),
  144591. this._uOffsetObserverable.clear(),
  144592. this._tex.dispose(),
  144593. this._mat.dispose()
  144594. }
  144595. }
  144596. class XDecal {
  144597. constructor(e) {
  144598. this._low_model = [],
  144599. this._mat = null,
  144600. this.sourceMatId = "",
  144601. this.loadModel = async()=>new Promise((d,_)=>{
  144602. typeof this.meshPath == "string" ? SceneLoader.LoadAssetContainerAsync("", this.meshPath, this.scene, null, ".glb").then(b=>{
  144603. for (let k = b.materials.length - 1; k >= 0; --k)
  144604. b.materials[k].dispose();
  144605. for (let k = 0; k < b.meshes.length; ++k)
  144606. b.meshes[k].visibility = 1,
  144607. b.meshes[k].isPickable = !0,
  144608. b.meshes[k].checkCollisions = !1,
  144609. "hasVertexAlpha"in b.meshes[k] && (b.meshes[k].hasVertexAlpha = !1),
  144610. this.scene.addMesh(b.meshes[k]),
  144611. this._low_model.push(new XStaticMesh({
  144612. id: this._id,
  144613. mesh: b.meshes[k],
  144614. xtype: EMeshType.Decal,
  144615. skinInfo: this._skinInfo
  144616. })),
  144617. this.toggle(!1);
  144618. d(!0)
  144619. }
  144620. ).catch(b=>{
  144621. _(new XDecalError(`[Engine] decal load model error! ${b}`))
  144622. }
  144623. ) : _(new XDecalError("[Engine] decal inport mesh is not string!"))
  144624. }
  144625. ).catch(d=>{
  144626. new XDecalError(`[Engine] decal loadModel ${d}`)
  144627. }
  144628. );
  144629. const {id: i, scene: o, meshPath: s, skinInfo: c="default"} = e;
  144630. this._id = i,
  144631. this.scene = o,
  144632. this.meshPath = s,
  144633. this._skinInfo = c
  144634. }
  144635. get skinInfo() {
  144636. return this._skinInfo
  144637. }
  144638. getMesh() {
  144639. return this._low_model
  144640. }
  144641. getMat() {
  144642. return this._mat
  144643. }
  144644. get id() {
  144645. return this._id
  144646. }
  144647. toggle(e) {
  144648. for (let i = 0; i < this._low_model.length; ++i)
  144649. e == !0 ? this._low_model[i].show() : this._low_model[i].hide()
  144650. }
  144651. setMat(e) {
  144652. this._mat = e;
  144653. for (let i = 0; i < this._low_model.length; ++i)
  144654. this._low_model[i].mesh.material = this._mat;
  144655. this.toggle(!0)
  144656. }
  144657. changeModel(e="") {
  144658. return e != "" && (this.meshPath = e),
  144659. this.meshPath == "" ? (log$z.error("[Engine] changeModel Error! meshPath is empty"),
  144660. Promise.reject(new XDecalTextureError("[Engine] changeModel Error! meshPath is empty"))) : new Promise((i,o)=>SceneLoader.LoadAssetContainerAsync("", this.meshPath, this.scene, null, ".glb").then(s=>{
  144661. for (let d = s.materials.length - 1; d >= 0; --d)
  144662. s.materials[d].dispose();
  144663. const c = [];
  144664. for (let d = 0; d < s.meshes.length; ++d)
  144665. s.meshes[d].visibility = 0,
  144666. s.meshes[d].isPickable = !0,
  144667. s.meshes[d].checkCollisions = !1,
  144668. "hasVertexAlpha"in s.meshes[d] && (s.meshes[d].hasVertexAlpha = !1),
  144669. this._mat != null && (s.meshes[d].material = this._mat),
  144670. this.scene.addMesh(s.meshes[d]),
  144671. c.push(new XStaticMesh({
  144672. id: this._id,
  144673. mesh: s.meshes[d],
  144674. xtype: EMeshType.Decal,
  144675. skinInfo: this._skinInfo
  144676. }));
  144677. e != "" && this.cleanMesh(),
  144678. this._low_model = c,
  144679. this._mat != null && this.toggle(!0),
  144680. i(this)
  144681. }
  144682. ).catch(s=>{
  144683. log$z.error("[Engine] Create decal error! " + s),
  144684. o(new XDecalError("[Engine] Create decal error! " + s))
  144685. }
  144686. ))
  144687. }
  144688. cleanMesh(e=!1, i=!1) {
  144689. log$z.info("[Engine] Decal Model clean mesh");
  144690. for (let o = 0; o < this._low_model.length; ++o)
  144691. this._low_model[o].dispose(e, i)
  144692. }
  144693. }
  144694. const log$y = new Logger$1("XBreathPointManager");
  144695. class XBreathPointManager {
  144696. constructor(e) {
  144697. this.materialMap = new Map,
  144698. this.breathPoints = new Map,
  144699. this._allIds = new Set,
  144700. this._loopBPKeys = [],
  144701. this.addBreathPoint = async i=>{
  144702. const o = [{
  144703. url: "https://static.xverse.cn/qqktv/texture.png"
  144704. }];
  144705. if (o.length <= 0) {
  144706. log$y.warn("[Engine] BreathPoint get texture list error: textureList.length <= 0"),
  144707. new XBreathPointError("[Engine] BreathPoint get texture list error!");
  144708. return
  144709. }
  144710. const s = o[0]
  144711. , {id: c, spriteSheet: d=s.url, spriteWidthNumber: _=20, spriteHeightNumber: b=1, position: k, rotation: j={
  144712. pitch: -90,
  144713. yaw: 270,
  144714. roll: 0
  144715. }, size: $=.6, width: _e=-1, height: et=-1, fps: tt=30, billboardMode: rt=!1, forceLeaveGround: it=!1, type: nt="default", lifeTime: ot=-1, backfaceculling: at=!0, maxVisibleRegion: st=-1, skinInfo: ut="default"} = i;
  144716. if (this.breathPoints.get(c)) {
  144717. log$y.warn("[Engine] Cannot add breathPoint with an existing id: [" + c + "]"),
  144718. new XBreathPointError("[Engine] Cannot add breathPoint with an existing id: [" + c + "]");
  144719. return
  144720. }
  144721. if (it) {
  144722. const mt = this.castRay(new Vector3(k.x,k.y,k.z)) * scaleFromUE4toXverse;
  144723. mt != 0 ? k.z = k.z - mt + 1 : k.z = k.z + 1
  144724. }
  144725. let ct;
  144726. if (this.materialMap.get(nt)) {
  144727. const mt = this.materialMap.get(nt);
  144728. mt.count = mt.count + 1,
  144729. ct = mt.mat
  144730. } else {
  144731. const mt = new Texture(d,this._scene,!0,!0,Texture.BILINEAR_SAMPLINGMODE,null,()=>{
  144732. log$y.error("[Engine] Breathpoint create texture error."),
  144733. new XBreathPointError("[Engine] Breathpoint create texture error.")
  144734. }
  144735. ,null,!0);
  144736. mt.name = "TexBreathPoint_" + c,
  144737. ct = new StandardMaterial(`MaterialBreathPoint_${c}`,this._scene),
  144738. ct.alpha = 1,
  144739. ct.emissiveTexture = mt,
  144740. ct.backFaceCulling = at,
  144741. ct.diffuseTexture = mt,
  144742. ct.diffuseTexture.hasAlpha = !0,
  144743. ct.useAlphaFromDiffuseTexture = !0,
  144744. this.materialMap.set(nt, {
  144745. mat: ct,
  144746. count: 1,
  144747. lastRenderTime: Date.now(),
  144748. fps: tt,
  144749. spriteWidthNumber: _,
  144750. spriteHeightNumber: b,
  144751. spriteSheet: d,
  144752. texture: mt
  144753. })
  144754. }
  144755. const lt = new Array(6);
  144756. for (let mt = 0; mt < 6; mt++)
  144757. lt[mt] = new Vector4(0,0,0,0);
  144758. lt[0] = new Vector4(0,0,1 / _,1 / b),
  144759. lt[1] = new Vector4(0,0,1 / _,1 / b);
  144760. let ft = {};
  144761. _e > 0 && et > 0 ? ft = {
  144762. width: _e,
  144763. height: et,
  144764. depth: .01,
  144765. faceUV: lt
  144766. } : ft = {
  144767. size: $,
  144768. depth: .01,
  144769. faceUV: lt
  144770. };
  144771. const ht = MeshBuilder.CreateBox(c, ft, this._scene);
  144772. ht.material = ct;
  144773. const pt = new XStaticMesh({
  144774. id: c,
  144775. mesh: ht,
  144776. xtype: EMeshType.XBreathPoint,
  144777. skinInfo: ut
  144778. });
  144779. let dt = j;
  144780. rt && (ht.billboardMode = Mesh.BILLBOARDMODE_ALL,
  144781. pt.allowMove(),
  144782. dt = {
  144783. pitch: 0,
  144784. yaw: 270,
  144785. roll: 0
  144786. });
  144787. const _t = new BreathPoint({
  144788. type: nt,
  144789. mesh: pt,
  144790. id: c,
  144791. position: k,
  144792. rotation: dt,
  144793. mat: ct,
  144794. maxVisibleRegion: st,
  144795. scene: this._scene,
  144796. skinInfo: ut
  144797. });
  144798. this.breathPoints.set(c, _t),
  144799. this._allIds.add(c),
  144800. ot > 0 && setTimeout(()=>{
  144801. this.clearBreathPoints(c)
  144802. }
  144803. , ot * 1e3)
  144804. }
  144805. ,
  144806. this.reg_breathpoint_update = ()=>{
  144807. const i = new Date().getTime();
  144808. if (this.materialMap != null)
  144809. for (const [o,s] of this.materialMap)
  144810. i - s.lastRenderTime > 1e3 / s.fps && (s.lastRenderTime = i,
  144811. Math.abs(s.mat.diffuseTexture.uOffset - (1 - 1 / s.spriteWidthNumber)) < 1e-6 ? (s.mat.diffuseTexture.uOffset = 0,
  144812. Math.abs(s.mat.diffuseTexture.vOffset - (1 - 1 / s.spriteHeightNumber)) < 1e-6 ? s.mat.diffuseTexture.vOffset = 0 : s.mat.diffuseTexture.vOffset += 1 / s.spriteHeightNumber) : s.mat.diffuseTexture.uOffset += 1 / s.spriteWidthNumber)
  144813. }
  144814. ,
  144815. this.reg_breathpoint_autovisible = ()=>{
  144816. if (this._scene.getFrameId() % 2 == 0)
  144817. if (this._loopBPKeys.length == 0)
  144818. this._loopBPKeys = Array.from(this._allIds);
  144819. else {
  144820. const i = this._getMainPlayerPosition();
  144821. for (let o = 0; o < 5 && this._loopBPKeys.length > 0; ++o) {
  144822. const s = this._loopBPKeys.pop();
  144823. if (s != null) {
  144824. const c = this.getBreathPoint(s);
  144825. if (c != null && c.maxvisibleregion >= 0 && c.mesh.visibility == 1) {
  144826. const d = c.mesh.position;
  144827. calcDistance3DVector(i, d) >= c.maxvisibleregion ? c == null || c.removeFromScene() : c == null || c.addToScene()
  144828. }
  144829. }
  144830. }
  144831. }
  144832. }
  144833. ,
  144834. this._sceneManager = e,
  144835. this._scene = e.Scene,
  144836. this._scene.registerBeforeRender(this.reg_breathpoint_update),
  144837. this._scene.registerBeforeRender(this.reg_breathpoint_autovisible)
  144838. }
  144839. setAllBreathPointVisibility(e) {
  144840. for (const [i,o] of this.breathPoints.entries())
  144841. o.toggleVisibility(e)
  144842. }
  144843. toggleBPVisibilityBySkinInfo(e, i) {
  144844. for (const [o,s] of this.breathPoints.entries())
  144845. s.skinInfo == e && s.toggleVisibility(i)
  144846. }
  144847. toggleBPVisibilityById(e, i) {
  144848. const o = this.getBreathPoint(e);
  144849. o != null && o.toggleVisibility(i)
  144850. }
  144851. getBreathPointBySkinInfo(e) {
  144852. const i = [];
  144853. for (const [o,s] of this.breathPoints.entries())
  144854. s.skinInfo == e && i.push(s);
  144855. return i
  144856. }
  144857. getAllBreathPoint() {
  144858. return this.breathPoints
  144859. }
  144860. getBreathPoint(e) {
  144861. return this.breathPoints.get(e)
  144862. }
  144863. delete(e) {
  144864. const i = this.breathPoints.get(e);
  144865. if (i != null) {
  144866. i.dispose(),
  144867. this._allIds.delete(e);
  144868. const o = this.materialMap.get(i._type);
  144869. o != null && (o.count = o.count - 1,
  144870. o.count <= 0 && (o.count = 0,
  144871. o.texture.dispose(),
  144872. o.mat.dispose(!0, !0),
  144873. this.materialMap.delete(i._type))),
  144874. this.breathPoints.delete(e)
  144875. }
  144876. }
  144877. castRay(e) {
  144878. var _;
  144879. e = ue4Position2Xverse({
  144880. x: e.x,
  144881. y: e.y,
  144882. z: e.z
  144883. });
  144884. const i = new Vector3(0,-1,0)
  144885. , o = new Ray(e,i,length)
  144886. , s = []
  144887. , c = (_ = this._sceneManager) == null ? void 0 : _.getGround({
  144888. x: e.x,
  144889. y: e.y,
  144890. z: e.z
  144891. });
  144892. let d = o.intersectsMeshes(c);
  144893. if (d.length > 0) {
  144894. const b = d[0];
  144895. if (b && b.pickedMesh) {
  144896. const k = b.distance;
  144897. i.y = 1;
  144898. const j = o.intersectsMeshes(s);
  144899. let$ = 1e8;
  144900. if (j.length > 0) {
  144901. const _e = j[0];
  144902. return _e && _e.pickedMesh && ($ = -_e.distance),
  144903. $ == 1e8 ? k : Math.abs($) < Math.abs(k) ? $ : k
  144904. }
  144905. }
  144906. } else if (i.y = 1,
  144907. d = o.intersectsMeshes(s),
  144908. d.length > 0) {
  144909. const b = d[0];
  144910. if (b && b.pickedMesh)
  144911. return b.distance
  144912. }
  144913. return 0
  144914. }
  144915. changePickable(e) {
  144916. for (const [i,o] of this.breathPoints.entries())
  144917. o.changePickable(e)
  144918. }
  144919. clearBreathPoints(e) {
  144920. log$y.info(`[Engine] clearBreathPoints: ${e}`);
  144921. for (const [i,o] of this.breathPoints.entries())
  144922. (o._type == e || o._id == e) && this.delete(o._id)
  144923. }
  144924. clearBreathPointsBySkinInfo(e) {
  144925. log$y.info(`[Engine] clearBreathPointsBySkinInfo: ${e}`);
  144926. for (const [i,o] of this.breathPoints.entries())
  144927. o.skinInfo == e && this.delete(o._id)
  144928. }
  144929. clearAllBreathPoints() {
  144930. log$y.info("[Engine] ClearAllBreathPoints");
  144931. for (const [e,i] of this.breathPoints.entries())
  144932. this.delete(i._id)
  144933. }
  144934. _getMainPlayerPosition() {
  144935. var o;
  144936. const e = this._sceneManager.cameraComponent.MainCamera.position
  144937. , i = this._sceneManager.avatarComponent.getMainAvatar();
  144938. if (i != null && i != null) {
  144939. const s = (o = i == null ? void 0 : i.rootNode) == null ? void 0 : o.position;
  144940. if (s != null)
  144941. return s
  144942. }
  144943. return e
  144944. }
  144945. changeBreathPointPose(e, i, o) {
  144946. const s = new Vector3(e.position.x,e.position.y,e.position.z);
  144947. if (this.breathPoints.get(o) != null) {
  144948. log$y.info(`[Engine] changeBreathPointPose, id:${o}`);
  144949. const c = this.breathPoints.get(o)
  144950. , d = c.mesh.position;
  144951. let _ = d.subtract(s);
  144952. _ = Vector3.Normalize(_);
  144953. const b = Vector3.Distance(d, s)
  144954. , k = new Ray(s,_,b)
  144955. , j = this._scene.multiPickWithRay(k);
  144956. if (j) {
  144957. for (let$ = 0; $ < j.length; $++)
  144958. if (j[$].pickedMesh != null && i.mesh.name.indexOf(j[$].pickedMesh.name) >= 0) {
  144959. const _e = j[$].pickedPoint;
  144960. c.mesh.position = s.add(_e.subtract(s).scale(.99)),
  144961. this.breathPoints.set(o, c)
  144962. }
  144963. }
  144964. } else
  144965. log$y.warn(`[Engine] changeBreathPointPose, id:${o} is not existing!`)
  144966. }
  144967. }
  144968. class BreathPoint {
  144969. get isInScene() {
  144970. return this._isInScene
  144971. }
  144972. get skinInfo() {
  144973. return this._skinInfo
  144974. }
  144975. get maxvisibleregion() {
  144976. return this._maxVisibleRegion
  144977. }
  144978. getMesh() {
  144979. return this._staticmesh
  144980. }
  144981. get mesh() {
  144982. return this._staticmesh.mesh
  144983. }
  144984. toggleVisibility(e) {
  144985. e == !0 ? this._staticmesh.show() : this._staticmesh.hide()
  144986. }
  144987. changePickable(e) {
  144988. this._staticmesh.mesh.isPickable = e
  144989. }
  144990. constructor(e) {
  144991. const {mesh: i, id: o, position: s, rotation: c, mat: d, type: _="default", maxVisibleRegion: b=-1, scene: k, skinInfo: j="default"} = e;
  144992. this._id = o,
  144993. i.mesh.position = ue4Position2Xverse(s),
  144994. i.mesh.rotation = ue4Rotation2Xverse(c),
  144995. this._staticmesh = i,
  144996. this._mat = d,
  144997. this._type = _,
  144998. this._maxVisibleRegion = b,
  144999. this._scene = k,
  145000. this._skinInfo = j,
  145001. this._isInScene = !0
  145002. }
  145003. removeFromScene() {
  145004. this._isInScene && (this._staticmesh.mesh != null && this._scene.removeMesh(this._staticmesh.mesh),
  145005. this._isInScene = !1)
  145006. }
  145007. addToScene() {
  145008. this._isInScene == !1 && (this._staticmesh.mesh != null && this._scene.addMesh(this._staticmesh.mesh),
  145009. this._isInScene = !0)
  145010. }
  145011. dispose() {
  145012. var e;
  145013. (e = this._staticmesh.mesh) == null || e.dispose(!1, !1)
  145014. }
  145015. set position(e) {
  145016. this._staticmesh.mesh.position = ue4Position2Xverse(e)
  145017. }
  145018. get position() {
  145019. return xversePosition2Ue4(this._staticmesh.mesh.position)
  145020. }
  145021. set rotation(e) {
  145022. this._staticmesh.mesh.rotation = ue4Rotation2Xverse(e)
  145023. }
  145024. get rotation() {
  145025. return xverseRotation2Ue4(this._staticmesh.mesh.rotation)
  145026. }
  145027. }
  145028. var pureVideoFragment = `precision highp float;
  145029. varying vec3 ModelPos;
  145030. uniform float isYUV; // false: 0, true: 1.0
  145031. uniform sampler2D texture_video;
  145032. // uniform sampler2D chrominanceYTexture;
  145033. // uniform sampler2D chrominanceUTexture;
  145034. // uniform sampler2D chrominanceVTexture;
  145035. uniform float haveShadowLight;
  145036. varying vec4 vPositionFromLight;
  145037. uniform float fireworkLight;
  145038. varying float fireworkDistance;
  145039. varying float fireworkCosTheta;
  145040. uniform sampler2D shadowSampler;
  145041. // uniform float focal;
  145042. // uniform float captureWidth;
  145043. // uniform float captureHeight;
  145044. uniform vec3 focal_width_height;
  145045. const float inv_2_PI = 0.1591549; // 1 / (2 * pi)
  145046. const float inv_PI = 0.3183099; // 1 / ( pi)
  145047. const vec2 invAtan = vec2(0.1591549, 0.3183099);
  145048. float unpack(vec4 color)
  145049. {
  145050. const vec4 bit_shift = vec4(1.0 / (255.0 * 255.0 * 255.0), 1.0 / (255.0 * 255.0), 1.0 / 255.0, 1.0);
  145051. return dot(color, bit_shift);
  145052. }
  145053. float ShadowCalculation(vec4 vPositionFromLight, sampler2D ShadowMap)
  145054. {
  145055. vec3 projCoords = vPositionFromLight.xyz / vPositionFromLight.w;
  145056. vec3 depth = 0.5 * projCoords + vec3(0.5);
  145057. vec2 uv = depth.xy;
  145058. if (uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0)
  145059. {
  145060. return 1.0;
  145061. }
  145062. #ifndef SHADOWFULLFLOAT
  145063. float shadow = unpack(texture2D(ShadowMap, uv));
  145064. #else
  145065. float shadow = texture2D(ShadowMap, uv).x;
  145066. #endif
  145067. if (depth.z > shadow - 1e-4)
  145068. {
  145069. return 0.7;
  145070. }
  145071. else
  145072. {
  145073. return 1.0;
  145074. }
  145075. }
  145076. // const float f = 514.133282; //937.83246;
  145077. // const float w = 720.0;
  145078. // const float h = 1280.0;
  145079. // vec2 SampleTex(vec3 pt3d, vec2 widthHeight)
  145080. vec2 SampleTex(vec3 pt3d)
  145081. {
  145082. // // vec2 uv = vec2( f/w*pt3d.x/pt3d.z, f/h*pt3d.y/pt3d.z ); // \u6A21\u578B\u53D8\u6362\u5230\u76F8\u673A\u5750\u6807\u7CFB\u4E0B
  145083. // vec2 uv = vec2( focal/captureWidth*pt3d.x/pt3d.z, focal/captureHeight*pt3d.y/pt3d.z ); // \u6A21\u578B\u53D8\u6362\u5230\u76F8\u673A\u5750\u6807\u7CFB\u4E0B
  145084. // uv.x = uv.x + 0.5;
  145085. // uv.y = uv.y + 0.5;
  145086. // return uv;
  145087. return focal_width_height.x / focal_width_height.yz *pt3d.xy/pt3d.z + 0.5;
  145088. }
  145089. void main()
  145090. {
  145091. vec3 yuv;
  145092. vec3 rgb;
  145093. vec2 uv;
  145094. vec3 color = vec3(0,0,0);
  145095. vec3 flash_color = fireworkLight * 1000.0 / fireworkDistance * fireworkCosTheta * vec3(1,0,0);
  145096. float shadow = 1.0;
  145097. if (haveShadowLight > 0.5)
  145098. {
  145099. shadow = ShadowCalculation(vPositionFromLight, shadowSampler);
  145100. }
  145101. // uv = SampleTex( normalize(ModelPos), vec2(captureWidth, captureHeight));
  145102. uv = SampleTex( normalize(ModelPos) );
  145103. if( isYUV < 0.5 )
  145104. {
  145105. color = texture2D(texture_video, uv).rgb;
  145106. }else{
  145107. const mat4 YUV2RGB = mat4
  145108. (
  145109. 1.1643828125, 0, 1.59602734375, -.87078515625,
  145110. 1.1643828125, -.39176171875, -.81296875, .52959375,
  145111. 1.1643828125, 2.017234375, 0, -1.081390625,
  145112. 0, 0, 0, 1
  145113. );
  145114. vec4 result = vec4(
  145115. texture2D(texture_video, vec2(uv.x, uv.y*0.666666 + 0.333333 ) ).x,
  145116. texture2D(texture_video, vec2(uv.x * 0.5, uv.y*0.333333 ) ).x,
  145117. texture2D(texture_video, vec2(0.5 + uv.x * 0.5, uv.y*0.333333 ) ).x,
  145118. 1) * YUV2RGB;
  145119. color = clamp(result.rgb, 0.0, 1.0);
  145120. }
  145121. if( uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0 )
  145122. {
  145123. color = vec3(0,0,0);
  145124. }
  145125. // gl_FragColor = vec4(shadow, shadow, shadow, 1.0);
  145126. gl_FragColor = vec4(shadow * (color + flash_color) * 1.0, 1.0);
  145127. }
  145128. `
  145129. , pureVideoVertex = `precision highp float;
  145130. varying vec3 ModelPos;
  145131. varying vec4 vPositionFromLight;
  145132. varying float fireworkDistance;
  145133. varying float fireworkCosTheta;
  145134. attribute vec2 uv;
  145135. attribute vec3 position;
  145136. attribute vec4 world0;
  145137. attribute vec4 world1;
  145138. attribute vec4 world2;
  145139. attribute vec4 world3;
  145140. #ifdef NORMAL
  145141. attribute vec3 normal;
  145142. #endif
  145143. uniform vec3 fireworkLightPosition;
  145144. uniform mat4 view;
  145145. uniform mat4 projection;
  145146. uniform mat4 lightSpaceMatrix;
  145147. uniform mat4 world;
  145148. uniform mat4 worldViewProjection;
  145149. float DistanceCalculation(vec3 Q, vec3 P)
  145150. {
  145151. return (Q.x - P.x) * (Q.x - P.x) + (Q.y - P.y) * (Q.y - P.y) + (Q.z - P.z) * (Q.z - P.z);
  145152. }
  145153. float CosThetaCalculation(vec3 Q, vec3 P)
  145154. {
  145155. return max(0.,dot(Q, P));
  145156. }
  145157. void main()
  145158. {
  145159. #include<instancesVertex>
  145160. vPositionFromLight = lightSpaceMatrix * finalWorld * vec4(position, 1.0);
  145161. // fireworkDistance = DistanceCalculation(vec3(finalWorld * vec4(position, 1.0)), fireworkLightPosition);
  145162. fireworkDistance = distance(vec3(finalWorld * vec4(position, 1.0)), fireworkLightPosition);
  145163. fireworkCosTheta = 1.0;
  145164. #ifdef NORMAL
  145165. vec3 directionFirework = fireworkLightPosition.xyz - vec3(finalWorld * vec4(position, 1.0));
  145166. directionFirework = normalize(directionFirework);
  145167. // directionFirework = directionFirework / (directionFirework.x * directionFirework.x + directionFirework.y * directionFirework.y + directionFirework.z * directionFirework.z);
  145168. fireworkCosTheta = CosThetaCalculation(directionFirework, normal);
  145169. #endif
  145170. ModelPos = vec3( view * finalWorld * vec4(position , 1.0));
  145171. gl_Position = projection * view * finalWorld * vec4(position , 1.0);
  145172. }
  145173. `
  145174. , panoFragment = `precision highp float;
  145175. uniform float isYUV; // false: 0, true: 1.0
  145176. varying vec2 TexCoords;
  145177. varying vec3 WorldPos;
  145178. varying vec3 vNormal;
  145179. uniform float haveShadowLight;
  145180. varying vec4 vPositionFromLight;
  145181. uniform float fireworkLight;
  145182. varying float fireworkDistance;
  145183. varying float fireworkCosTheta;
  145184. uniform sampler2D shadowSampler;
  145185. uniform vec3 centre_pose;
  145186. uniform sampler2D texture_pano;
  145187. const float inv_2_PI = 0.1591549; // 1 / (2 * pi)
  145188. const float inv_PI = 0.3183099; // 1 / ( pi)
  145189. const vec2 invAtan = vec2(0.1591549, 0.3183099);
  145190. float unpack(vec4 color)
  145191. {
  145192. const vec4 bit_shift = vec4(1.0 / (255.0 * 255.0 * 255.0), 1.0 / (255.0 * 255.0), 1.0 / 255.0, 1.0);
  145193. return dot(color, bit_shift);
  145194. }
  145195. float ShadowCalculation(vec4 vPositionFromLight, sampler2D ShadowMap)
  145196. {
  145197. vec3 projCoords = vPositionFromLight.xyz / vPositionFromLight.w;
  145198. vec3 depth = 0.5 * projCoords + vec3(0.5);
  145199. vec2 uv = depth.xy;
  145200. if (uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0)
  145201. {
  145202. return 1.0;
  145203. }
  145204. #ifndef SHADOWFULLFLOAT
  145205. float shadow = unpack(texture2D(ShadowMap, uv));
  145206. #else
  145207. float shadow = texture2D(ShadowMap, uv).x;
  145208. #endif
  145209. if (depth.z > shadow)
  145210. {
  145211. return 0.7;
  145212. }
  145213. else
  145214. {
  145215. return 1.0;
  145216. }
  145217. }
  145218. vec2 SampleSphericalMap(vec3 pt3d)
  145219. {
  145220. vec2 uv = vec2( atan(-pt3d.z,pt3d.x), atan( pt3d.y, sqrt(pt3d.x*pt3d.x + pt3d.z * pt3d.z)));
  145221. uv.x = 0.5 + uv.x * inv_2_PI ; // yaw: \u6C34\u5E73\u65B9\u5411 \uFF0C0 \u5230 360 \uFF0C \u5BF9\u5E948k\u7684\u5BBD
  145222. uv.y = 0.5 + uv.y * inv_PI ; // pitch: \u7AD6\u76F4\u65B9\u5411\uFF0C -64 \u5230 64 \uFF0C\u5BF9\u5E944k\u7684\u957F
  145223. return vec2(uv.x,uv.y);
  145224. }
  145225. vec3 fitUint8Range(vec3 color)
  145226. {
  145227. if( color.x < 0.0 ){color.x = 0.0;}
  145228. if( color.x > 1.0 ){color.x = 1.0;}
  145229. if( color.y < 0.0 ){color.y = 0.0;}
  145230. if( color.y > 1.0 ){color.y = 1.0;}
  145231. if( color.z < 0.0 ){color.z = 0.0;}
  145232. if( color.z > 1.0 ){color.z = 1.0;}
  145233. return color;
  145234. }
  145235. void main()
  145236. {
  145237. // // Debug
  145238. // vec3 vLightPosition = vec3(0,10,100);
  145239. // // World values
  145240. // vec3 vPositionW = vec3( WorldPos.x, WorldPos.y, WorldPos.z );
  145241. // vec3 vNormalW = normalize( vNormal) ;
  145242. // vec3 viewDirectionW = normalize(vPositionW);
  145243. // // Light
  145244. // vec3 lightVectorW = normalize(vLightPosition - vPositionW);
  145245. // // diffuse
  145246. // float ndl = max(0., dot(vNormalW, lightVectorW));
  145247. // gl_FragColor = vec4( ndl, ndl, ndl, 1.);
  145248. vec2 uv;
  145249. vec3 color = vec3(0,0,0);
  145250. vec3 flash_color = fireworkLight * 1000.0 / fireworkDistance * fireworkCosTheta * vec3(1,0,0);
  145251. float shadow = 1.0;
  145252. if (haveShadowLight > 0.5)
  145253. {
  145254. shadow = ShadowCalculation(vPositionFromLight, shadowSampler);
  145255. }
  145256. uv = SampleSphericalMap(normalize( WorldPos - centre_pose ));
  145257. if( isYUV < 0.5 )
  145258. {
  145259. color = texture2D(texture_pano, uv).rgb;
  145260. }else{
  145261. const mat4 YUV2RGB = mat4
  145262. (
  145263. 1.1643828125, 0, 1.59602734375, -.87078515625,
  145264. 1.1643828125, -.39176171875, -.81296875, .52959375,
  145265. 1.1643828125, 2.017234375, 0, -1.081390625,
  145266. 0, 0, 0, 1
  145267. );
  145268. vec4 result = vec4(
  145269. texture2D(texture_pano, vec2(uv.x, uv.y*0.666666 + 0.333333 ) ).x,
  145270. texture2D(texture_pano, vec2(uv.x * 0.5, uv.y*0.333333 ) ).x,
  145271. texture2D(texture_pano, vec2(0.5 + uv.x * 0.5, uv.y*0.333333 ) ).x,
  145272. 1) * YUV2RGB;
  145273. color = fitUint8Range(result.rgb);
  145274. }
  145275. if( uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0 )
  145276. {
  145277. color = vec3(0,0,0);
  145278. }
  145279. gl_FragColor = vec4( shadow * (color + flash_color), 1.0);
  145280. }`
  145281. , panoVertex = `precision highp float;
  145282. varying vec2 TexCoords;
  145283. varying vec3 vNormal;
  145284. varying vec3 WorldPos;
  145285. varying vec4 vPositionFromLight;
  145286. varying float fireworkDistance;
  145287. varying float fireworkCosTheta;
  145288. uniform vec3 fireworkLightPosition;
  145289. uniform mat4 lightSpaceMatrix;
  145290. attribute vec3 normal;
  145291. attribute vec2 uv;
  145292. attribute vec3 position;
  145293. uniform mat4 view;
  145294. uniform mat4 projection;
  145295. uniform mat4 world;
  145296. uniform mat4 worldViewProjection;
  145297. attribute vec4 world0;
  145298. attribute vec4 world1;
  145299. attribute vec4 world2;
  145300. attribute vec4 world3;
  145301. float DistanceCalculation(vec3 Q, vec3 P)
  145302. {
  145303. return (Q.x - P.x) * (Q.x - P.x) + (Q.y - P.y) * (Q.y - P.y) + (Q.z - P.z) * (Q.z - P.z);
  145304. }
  145305. float CosThetaCalculation(vec3 Q, vec3 P)
  145306. {
  145307. return max(0.,dot(Q, P));
  145308. }
  145309. void main()
  145310. {
  145311. #include<instancesVertex>
  145312. vPositionFromLight = lightSpaceMatrix * world * vec4(position, 1.0);
  145313. fireworkDistance = DistanceCalculation(vec3(finalWorld * vec4(position, 1.0)), fireworkLightPosition);
  145314. fireworkCosTheta = 1.0;
  145315. vec3 newP = vec3( finalWorld * vec4(position, 1.0) );
  145316. WorldPos = newP;
  145317. TexCoords = uv;
  145318. vNormal = normal;
  145319. gl_Position = projection * view * vec4(newP , 1.0);
  145320. }
  145321. `;
  145322. class XVideoRawYUV {
  145323. constructor(e, i) {
  145324. this.scene = e,
  145325. this._videoRawYUVTexture = [],
  145326. this.videosResOriArray = i,
  145327. this._currentVideoId = -1;
  145328. for (let o = 0; o < i.length; ++o)
  145329. (s=>{
  145330. const c = RawTexture.CreateLuminanceTexture(null, i[s].width, i[s].height * 1.5, this.scene, !1, !0);
  145331. c.name = "videoTex_" + i[s].width + "_" + i[s].height,
  145332. this._videoRawYUVTexture.push(c)
  145333. }
  145334. )(o)
  145335. }
  145336. inRange(e) {
  145337. return e >= 0 && e < this._videoRawYUVTexture.length
  145338. }
  145339. getVideoYUVTex(e) {
  145340. return this.inRange(e) ? this._videoRawYUVTexture[e] : null
  145341. }
  145342. findId(e, i) {
  145343. let o = 0;
  145344. for (let s = 0; s < this.videosResOriArray.length; ++s)
  145345. if (this.videosResOriArray[s].width == e && this.videosResOriArray[s].height == i) {
  145346. o = s;
  145347. break
  145348. }
  145349. return o
  145350. }
  145351. getCurrentVideoTexId() {
  145352. return this._currentVideoId
  145353. }
  145354. setCurrentVideoTexId(e) {
  145355. this._currentVideoId = e
  145356. }
  145357. }
  145358. const log$x = new Logger$1("XMaterial");
  145359. var EShaderMode = (a=>(a[a.default = 0] = "default",
  145360. a[a.video = 1] = "video",
  145361. a[a.videoAndPano = 2] = "videoAndPano",
  145362. a))(EShaderMode || {});
  145363. class XMaterialComponent {
  145364. constructor(e, i) {
  145365. this._inputYUV420 = !0,
  145366. this._inputPanoYUV420 = !0,
  145367. this._isUpdateYUV = !0,
  145368. this.initMaterial = async()=>new Promise((o,s)=>{
  145369. this._initDefaultShader(),
  145370. this.shaderMode == 2 ? this.initDynamicData(this._panoInfo.dynamicRange, this._panoInfo.width, this._panoInfo.height).then(()=>{
  145371. this._initPureVideoShader(),
  145372. this._prepareRender(this.yuvInfo)
  145373. }
  145374. ) : this.shaderMode == 1 ? (this._initPureVideoShader(),
  145375. this._prepareRender(this.yuvInfo)) : this.shaderMode == 0,
  145376. o(!0)
  145377. }
  145378. ),
  145379. this._initPureVideoContent = o=>{
  145380. this._inputYUV420 ? this._videoRawYUVTexArray.getVideoYUVTex(0) != null && (this._lowModelShader.setTexture("texture_video", this._videoRawYUVTexArray.getVideoYUVTex(0)),
  145381. this._lowModelShader.setFloat("isYUV", 1),
  145382. Texture.WhenAllReady([this._videoRawYUVTexArray.getVideoYUVTex(0)], ()=>{
  145383. this._changePureVideoLowModelShaderCanvasSize(o)
  145384. }
  145385. )) : (this._videoElement = o.videoElement,
  145386. this._videoTexture || (this._videoTexture = new VideoTexture("InterVideoTexture",this._videoElement,this.scene,!0,!1)),
  145387. Texture.WhenAllReady([this._videoTexture], ()=>{
  145388. this._changePureVideoLowModelShaderCanvasSize({
  145389. width: this._videoElement.height,
  145390. height: this._videoElement.width,
  145391. fov: o.fov
  145392. })
  145393. }
  145394. ),
  145395. this._lowModelShader.setTexture("texture_video", this._videoTexture),
  145396. this._lowModelShader.setFloat("isYUV", 0))
  145397. }
  145398. ,
  145399. this._changePureVideoLowModelShaderCanvasSize = o=>{
  145400. var b;
  145401. const s = o.fov || 50
  145402. , c = o.width || 720
  145403. , d = o.height || 1280
  145404. , _ = c / (2 * Math.tan(Math.PI * s / 360));
  145405. (b = this._lowModelShader) == null || b.setVector3("focal_width_height", new Vector3(_,c,d))
  145406. }
  145407. ,
  145408. this.updateRawYUVData = (o,s,c,d=-1)=>{
  145409. var _, b;
  145410. if (d == -1 && (d = this.yuvInfo.fov),
  145411. this._isUpdateYUV == !0) {
  145412. const k = {
  145413. width: s,
  145414. height: c,
  145415. fov: d
  145416. }
  145417. , j = this._videoRawYUVTexArray.findId(s, c)
  145418. , $ = this._videoRawYUVTexArray.getCurrentVideoTexId();
  145419. ($ < 0 || j != $ || d != this.yuvInfo.fov) && (this.yuvInfo.width = s,
  145420. this.yuvInfo.height = c,
  145421. this.yuvInfo.fov = d,
  145422. this._videoRawYUVTexArray.setCurrentVideoTexId(j),
  145423. this._changeVideoRes(j),
  145424. this.changeCameraFovWithShaderUpdate(k),
  145425. this._scenemanager.yuvInfo = k),
  145426. (_ = this._videoRawYUVTexArray.getVideoYUVTex(j)) == null || _.update(o),
  145427. (b = this._videoRawYUVTexArray.getVideoYUVTex(j)) == null || b.updateSamplingMode(Texture.BILINEAR_SAMPLINGMODE)
  145428. }
  145429. }
  145430. ,
  145431. this._changeVideoRes = o=>{
  145432. this._lowModelShader.setTexture("texture_video", this._videoRawYUVTexArray.getVideoYUVTex(o))
  145433. }
  145434. ,
  145435. this.initDynamicData = (o,s,c)=>new Promise((d,_)=>{
  145436. this.setDynamicSize(o).then(b=>{
  145437. if (b) {
  145438. for (let k = 0; k < o; ++k)
  145439. (j=>{
  145440. this.initDynamicTexture(j, s, c),
  145441. this.initDynamicShaders(j).then(()=>{
  145442. this._updatePanoShaderInput(j)
  145443. }
  145444. )
  145445. }
  145446. )(k);
  145447. d(!0)
  145448. } else
  145449. _(new XMaterialError(`[Engine] DynamicRoomSize (${o}) is too small`))
  145450. }
  145451. )
  145452. }
  145453. ).catch(d=>log$x.error(`[Engine] ${d}`)),
  145454. this._initDefaultShader = ()=>{
  145455. this._defaultShader == null && (this._defaultShader = new GridMaterial("GridShader",this.scene),
  145456. this._defaultShader.gridRatio = 50,
  145457. this._defaultShader.lineColor = new Color3(0,0,.5),
  145458. this._defaultShader.majorUnitFrequency = 1,
  145459. this._defaultShader.mainColor = new Color3(.6,.6,.6),
  145460. this._defaultShader.backFaceCulling = !1)
  145461. }
  145462. ,
  145463. this._initPureVideoShader = ()=>{
  145464. if (this._lowModelShader == null) {
  145465. const o = new ShaderMaterial("PureVideoShader",this.scene,{
  145466. vertexSource: pureVideoVertex,
  145467. fragmentSource: pureVideoFragment
  145468. },{
  145469. attributes: ["uv", "position", "world0", "world1", "world2", "world3"],
  145470. uniforms: ["view", "projection", "worldViewProjection", "world"],
  145471. defines: ["#define SHADOWFULLFLOAT"]
  145472. });
  145473. o.setTexture("shadowSampler", null),
  145474. o.setMatrix("lightSpaceMatrix", null),
  145475. o.setFloat("haveShadowLight", 0),
  145476. o.setTexture("texture_video", null),
  145477. o.setFloat("isYUV", this._inputYUV420 ? 1 : 0),
  145478. o.setFloat("fireworkLight", 0),
  145479. o.setVector3("fireworkLightPosition", new Vector3(0,0,0)),
  145480. o.setVector3("focal_width_height", new Vector3(772.022491,720,1280)),
  145481. o.backFaceCulling = !1,
  145482. this._lowModelShader = o
  145483. }
  145484. }
  145485. ,
  145486. this.setDynamicSize = o=>new Promise((s,c)=>{
  145487. o >= 1 && o <= 100 ? (this._dynamic_size = o,
  145488. s(!0)) : (this._dynamic_size = 1,
  145489. s(!1))
  145490. }
  145491. ),
  145492. this._isInDynamicRange = o=>o < this._dynamic_size && o >= 0,
  145493. this.initDynamicTexture = (o,s,c)=>{
  145494. this._isInDynamicRange(o) && (this._dynamic_textures[o] != null && (this._dynamic_textures[o].dispose(),
  145495. this._dynamic_textures[o] = null),
  145496. this._dynamic_textures[o] = new RawTexture(null,s,c * 1.5,Engine.TEXTUREFORMAT_LUMINANCE,this.scene,!1,!0,Texture.NEAREST_SAMPLINGMODE,Engine.TEXTURETYPE_UNSIGNED_BYTE),
  145497. this._dynamic_textures[o].name = "Pano_Dynamic_" + o + "_" + Date.now())
  145498. }
  145499. ,
  145500. this.initDynamicShaders = o=>(log$x.info("[Engine] Material init dynamic shader."),
  145501. new Promise((s,c)=>{
  145502. this._dynamic_shaders[o] != null && this._dynamic_shaders[o].dispose();
  145503. const d = new ShaderMaterial("Pano_Shader_" + o,this.scene,{
  145504. vertexSource: panoVertex,
  145505. fragmentSource: panoFragment
  145506. },{
  145507. attributes: ["uv", "position", "world0", "world1", "world2", "world3"],
  145508. uniforms: ["view", "projection", "worldViewProjection", "world"],
  145509. defines: ["#define SHADOWFULLFLOAT"]
  145510. });
  145511. d.setTexture("texture_pano", null),
  145512. d.setVector3("centre_pose", new Vector3(0,0,0)),
  145513. d.setFloat("isYUV", this._inputPanoYUV420 ? 1 : 0),
  145514. d.setTexture("shadowSampler", null),
  145515. d.setMatrix("lightSpaceMatrix", null),
  145516. d.setFloat("haveShadowLight", 0),
  145517. d.setFloat("fireworkLight", 0),
  145518. d.setVector3("fireworkLightPosition", new Vector3(0,0,0)),
  145519. d.backFaceCulling = !1,
  145520. this._dynamic_shaders[o] = d,
  145521. s(!0)
  145522. }
  145523. )),
  145524. this._scenemanager = e,
  145525. this.scene = e.Scene,
  145526. this.engine = this.scene.getEngine(),
  145527. this.shaderMode = 1,
  145528. this._dynamic_textures = [],
  145529. this._dynamic_shaders = [],
  145530. this._dynamic_babylonpose = [],
  145531. this._videoRawYUVTexArray = new XVideoRawYUV(this.scene,i.videoResOriArray),
  145532. this.shaderMode = i.shaderMode,
  145533. i.yuvInfo != null && (this.yuvInfo = i.yuvInfo),
  145534. i.panoInfo != null && this.setPanoInfo(i.panoInfo)
  145535. }
  145536. stopYUVUpdate() {
  145537. this._isUpdateYUV = !1
  145538. }
  145539. allowYUVUpdate() {
  145540. this._isUpdateYUV = !0
  145541. }
  145542. setPanoInfo(e) {
  145543. this._panoInfo = e
  145544. }
  145545. _prepareRender(e) {
  145546. e && (this._initPureVideoContent(e),
  145547. this._updatePureVideoShaderInput())
  145548. }
  145549. changeCameraFovWithShaderUpdate(e) {
  145550. this._changePureVideoLowModelShaderCanvasSize(e),
  145551. this._scenemanager.cameraComponent.cameraFovChange(e)
  145552. }
  145553. getPureVideoShader() {
  145554. return this._lowModelShader
  145555. }
  145556. getDefaultShader() {
  145557. return this._defaultShader
  145558. }
  145559. updatePanoPartYUV(e, i, o) {
  145560. const s = i.subarray(0, o.width * o.height)
  145561. , c = i.subarray(o.width * o.height, o.width * o.height * 1.25)
  145562. , d = i.subarray(o.width * o.height * 1.25)
  145563. , _ = this._panoInfo.width
  145564. , b = this._panoInfo.height;
  145565. if (this._dynamic_textures[e] != null) {
  145566. const k = this._dynamic_textures[e].getInternalTexture();
  145567. if (k != null && k != null) {
  145568. const j = this.engine._getTextureTarget(k);
  145569. this.engine._bindTextureDirectly(j, k, !0),
  145570. this.engine.updateTextureData(k, s, o.startX, b * 1.5 - o.startY - o.height, o.width, o.height),
  145571. this.engine.updateTextureData(k, c, o.startX * .5, (b - o.startY - o.height) * .5, o.width * .5 - 1, o.height * .5 - 1),
  145572. this.engine.updateTextureData(k, d, o.startX * .5 + _ * .5, (b - o.startY - o.height) * .5, o.width * .5, o.height * .5),
  145573. this.engine._bindTextureDirectly(j, null)
  145574. }
  145575. }
  145576. }
  145577. changePanoImg(e, i) {
  145578. if (log$x.info(`[Engine] changePanoImg, id=${e}, pose=${i.pose.position.x},${i.pose.position.y},${i.pose.position.z}`),
  145579. !this._isInDynamicRange(e))
  145580. return log$x.error(`[Engine] ${e} is bigger than dynamic size set in PanoInfo`),
  145581. Promise.reject(new XMaterialError(`[Engine] ${e} is bigger than dynamic size set in PanoInfo`));
  145582. const o = ue4Position2Xverse(i.pose.position);
  145583. return o && (this._dynamic_babylonpose[e] = {
  145584. position: o
  145585. }),
  145586. new Promise((s,c)=>{
  145587. try {
  145588. typeof i.data == "string" ? (this.setPanoYUV420(!1),
  145589. this._dynamic_textures[e].updateURL(i.data, null, ()=>{
  145590. this._dynamic_textures[e].updateSamplingMode(Texture.NEAREST_SAMPLINGMODE)
  145591. }
  145592. )) : (this.isPanoYUV420() == !1 && this.initDynamicTexture(e, this._panoInfo.width, this._panoInfo.height),
  145593. this.setPanoYUV420(!0),
  145594. this._dynamic_textures[e].update(i.data),
  145595. this._dynamic_textures[e].updateSamplingMode(Texture.NEAREST_SAMPLINGMODE)),
  145596. s(this)
  145597. } catch (d) {
  145598. c(new XMaterialError(`[Engine] ChangePanoImg Error! ${d}`))
  145599. }
  145600. }
  145601. ).then(s=>(i.fov != null && this._scenemanager.cameraComponent.changeCameraFov(i.fov * Math.PI / 180),
  145602. this._dynamic_shaders[e].setFloat("isYUV", this._inputPanoYUV420 ? 1 : 0),
  145603. this._dynamic_shaders[e].setTexture("texture_pano", this._dynamic_textures[e]),
  145604. this._dynamic_shaders[e].setVector3("centre_pose", this._dynamic_babylonpose[e].position),
  145605. !0))
  145606. }
  145607. setYUV420(e) {
  145608. this._inputYUV420 = e
  145609. }
  145610. isYUV420() {
  145611. return this._inputYUV420
  145612. }
  145613. setPanoYUV420(e) {
  145614. this._inputPanoYUV420 = e
  145615. }
  145616. isPanoYUV420() {
  145617. return this._inputPanoYUV420
  145618. }
  145619. getDynamicShader(e) {
  145620. return this._dynamic_shaders[e]
  145621. }
  145622. _updatePureVideoShaderInput() {
  145623. var e, i, o, s, c, d, _, b, k, j;
  145624. if (this.scene.getLightByName("AvatarLight") ? ((e = this._lowModelShader) == null || e.setFloat("haveShadowLight", 1),
  145625. (s = this._lowModelShader) == null || s.setTexture("shadowSampler", (o = (i = this.scene.getLightByName("AvatarLight")) == null ? void 0 : i.getShadowGenerator()) == null ? void 0 : o.getShadowMapForRendering()),
  145626. (_ = this._lowModelShader) == null || _.setMatrix("lightSpaceMatrix", (d = (c = this.scene.getLightByName("AvatarLight")) == null ? void 0 : c.getShadowGenerator()) == null ? void 0 : d.getTransformMatrix())) : ((b = this._lowModelShader) == null || b.setTexture("shadowSampler", this._videoRawYUVTexArray.getVideoYUVTex(0)),
  145627. (k = this._lowModelShader) == null || k.setMatrix("lightSpaceMatrix", new Matrix),
  145628. (j = this._lowModelShader) == null || j.setFloat("haveShadowLight", 0)),
  145629. this.scene.getLightByName("fireworkLight"))
  145630. this.scene.registerBeforeRender(()=>{
  145631. var $;
  145632. this._lowModelShader.setFloat("fireworkLight", this.scene.getLightByName("fireworkLight").getScaledIntensity()),
  145633. this._lowModelShader.setVector3("fireworkLightPosition", ($ = this.scene.getLightByName("fireworkLight")) == null ? void 0 : $.position)
  145634. }
  145635. );
  145636. else {
  145637. const $ = new PointLight("fireworkLight",new Vector3(0,0,0),this.scene);
  145638. $.intensity = 0
  145639. }
  145640. }
  145641. _updatePanoShaderInput(e) {
  145642. var i, o, s, c, d, _, b, k, j, $;
  145643. if (this._isInDynamicRange(e))
  145644. if (this.scene.getLightByName("AvatarLight") ? ((i = this._dynamic_shaders[e]) == null || i.setFloat("haveShadowLight", 1),
  145645. (c = this._dynamic_shaders[e]) == null || c.setTexture("shadowSampler", (s = (o = this.scene.getLightByName("AvatarLight")) == null ? void 0 : o.getShadowGenerator()) == null ? void 0 : s.getShadowMapForRendering()),
  145646. (b = this._dynamic_shaders[e]) == null || b.setMatrix("lightSpaceMatrix", (_ = (d = this.scene.getLightByName("AvatarLight")) == null ? void 0 : d.getShadowGenerator()) == null ? void 0 : _.getTransformMatrix())) : ((k = this._lowModelShader) == null || k.setTexture("shadowSampler", this._videoRawYUVTexArray.getVideoYUVTex(0)),
  145647. (j = this._lowModelShader) == null || j.setMatrix("lightSpaceMatrix", new Matrix),
  145648. ($ = this._lowModelShader) == null || $.setFloat("haveShadowLight", 0)),
  145649. this.scene.getLightByName("fireworkLight"))
  145650. this.scene.registerBeforeRender(()=>{
  145651. var _e;
  145652. this._dynamic_shaders[e].setFloat("fireworkLight", this.scene.getLightByName("fireworkLight").getScaledIntensity()),
  145653. this._dynamic_shaders[e].setVector3("fireworkLightPosition", (_e = this.scene.getLightByName("fireworkLight")) == null ? void 0 : _e.position)
  145654. }
  145655. );
  145656. else {
  145657. const _e = new PointLight("fireworkLight",new Vector3(0,0,0),this.scene);
  145658. _e.intensity = 0
  145659. }
  145660. }
  145661. }
  145662. class XCameraComponent {
  145663. constructor(e, i, o) {
  145664. this.maincameraRotLimitObserver = null,
  145665. this.forceKeepVertical = !1,
  145666. this.initCamera = s=>{
  145667. const {maxZ: c=1e4, minZ: d=.1, angularSensibility: _=2e3} = s;
  145668. this.mainCamera = new FreeCamera("camera_main",new Vector3(0,1e3,0),this.scene),
  145669. this.mainCamera.mode = Camera$1.PERSPECTIVE_CAMERA,
  145670. this.mainCamera.speed = .1,
  145671. this.mainCamera.angularSensibility = _,
  145672. this.mainCamera.setTarget(new Vector3(0,1010,0)),
  145673. this.mainCamera.minZ = d,
  145674. this.mainCamera.fov = Math.PI * this.yuvInfo.fov / 180,
  145675. this.mainCamera.maxZ = c,
  145676. this.mainCamera.fovMode = Camera$1.FOVMODE_HORIZONTAL_FIXED,
  145677. this.cgCamera = new FreeCamera("camera_temp",new Vector3(0,1e3,0),this.scene),
  145678. this.cgCamera.mode = Camera$1.PERSPECTIVE_CAMERA,
  145679. this.cgCamera.speed = .1,
  145680. this.cgCamera.setTarget(new Vector3(0,1010,0)),
  145681. this.cgCamera.maxZ = c,
  145682. this.cgCamera.minZ = d,
  145683. this.cgCamera.fovMode = Camera$1.FOVMODE_HORIZONTAL_FIXED,
  145684. this.cameraFovChange(this.yuvInfo)
  145685. }
  145686. ,
  145687. this.cameraFovChange = s=>{
  145688. this.yuvInfo = s;
  145689. const c = s.width
  145690. , d = s.height
  145691. , _ = this.canvas.width
  145692. , b = this.canvas.height
  145693. , k = s.fov;
  145694. if (this.forceKeepVertical == !0) {
  145695. const j = c / (2 * Math.tan(Math.PI * k / 360))
  145696. , $ = 2 * Math.atan(d / (2 * j));
  145697. this.mainCamera.fov = $,
  145698. this.cgCamera.fov = $,
  145699. this.mainCamera.fovMode = Camera$1.FOVMODE_VERTICAL_FIXED,
  145700. this.cgCamera.fovMode = Camera$1.FOVMODE_VERTICAL_FIXED
  145701. } else if (this.mainCamera.fovMode = Camera$1.FOVMODE_HORIZONTAL_FIXED,
  145702. this.cgCamera.fovMode = Camera$1.FOVMODE_HORIZONTAL_FIXED,
  145703. _ / b < c / d && this.mainCamera.fov) {
  145704. const j = b
  145705. , $ = _
  145706. , _e = j * c / d / (2 * Math.tan(k * Math.PI / 360))
  145707. , et = 2 * Math.atan($ / (2 * _e));
  145708. this.mainCamera.fov = et,
  145709. this.cgCamera.fov = et
  145710. } else
  145711. this.mainCamera.fov = Math.PI * k / 180,
  145712. this.cgCamera.fov = Math.PI * k / 180
  145713. }
  145714. ,
  145715. this.setCameraPose = s=>{
  145716. var _;
  145717. const c = ue4Position2Xverse(s.position);
  145718. let d = null;
  145719. s.rotation != null && (d = ue4Rotation2Xverse(s.rotation)),
  145720. this._cameraPose = {
  145721. position: c
  145722. },
  145723. d != null && (this._cameraPose.rotation = d),
  145724. this.scene.activeCamera === this.mainCamera && !((_ = this.mainCamera) != null && _.isDisposed()) && this._setCamPositionRotation(this.mainCamera, this._cameraPose)
  145725. }
  145726. ,
  145727. this._setCamPositionRotation = (s,c)=>{
  145728. var d, _;
  145729. c.position && (s.position = (d = c.position) == null ? void 0 : d.clone()),
  145730. c.rotation && (s.rotation = (_ = c.rotation) == null ? void 0 : _.clone())
  145731. }
  145732. ,
  145733. this.switchCamera = s=>{
  145734. var c;
  145735. (c = this.scene.activeCamera) == null || c.detachControl(this.canvas),
  145736. this.scene.activeCamera = s
  145737. }
  145738. ,
  145739. this.reCalXYZRot = (s,c)=>(s = s % (2 * Math.PI),
  145740. Math.abs(c - s) >= Math.PI && (s = s - 2 * Math.PI),
  145741. s),
  145742. this._moveCam = (s,c,d,_,b,k,j,$)=>{
  145743. const _e = (st,ut,ct)=>(st.x = this.reCalXYZRot(st.x, ut.x),
  145744. st.y = this.reCalXYZRot(st.y, ut.y),
  145745. st.z = this.reCalXYZRot(st.z, ut.z),
  145746. new Vector3((ut.x - st.x) * ct + st.x,(ut.y - st.y) * ct + st.y,(ut.z - st.z) * ct + st.z))
  145747. , et = function(st, ut, ct) {
  145748. return new Vector3((ut.x - st.x) * ct + st.x,(ut.y - st.y) * ct + st.y,(ut.z - st.z) * ct + st.z)
  145749. }
  145750. , tt = new Animation("myAnimation1","position",j,Animation.ANIMATIONTYPE_VECTOR3,Animation.ANIMATIONLOOPMODE_CONSTANT);
  145751. let rt = []
  145752. , it = c
  145753. , nt = d;
  145754. for (let st = 0; st < k; ++st)
  145755. rt.push({
  145756. frame: st,
  145757. value: et(it, nt, st / k)
  145758. });
  145759. rt.push({
  145760. frame: rt.length,
  145761. value: et(it, nt, 1)
  145762. }),
  145763. tt.setKeys(rt);
  145764. const ot = new Animation("myAnimation2","rotation",j,Animation.ANIMATIONTYPE_VECTOR3,Animation.ANIMATIONLOOPMODE_CONSTANT);
  145765. rt = [],
  145766. it = _,
  145767. nt = b;
  145768. for (let st = 0; st < k; ++st)
  145769. rt.push({
  145770. frame: st,
  145771. value: _e(it, nt, st / k)
  145772. });
  145773. rt.push({
  145774. frame: rt.length,
  145775. value: _e(it, nt, 1)
  145776. }),
  145777. ot.setKeys(rt),
  145778. s.animations.push(ot),
  145779. s.animations.push(tt);
  145780. const at = this.scene.beginAnimation(s, 0, k, !1);
  145781. at.onAnimationEnd = ()=>{
  145782. $(),
  145783. at.stop(),
  145784. at.animationStarted = !1
  145785. }
  145786. }
  145787. ,
  145788. this.scene = i,
  145789. this.canvas = e,
  145790. this.yuvInfo = o.yuvInfo,
  145791. o.forceKeepVertical != null && (this.forceKeepVertical = o.forceKeepVertical),
  145792. this.initCamera(o.cameraParam)
  145793. }
  145794. get MainCamera() {
  145795. return this.mainCamera
  145796. }
  145797. get CgCamera() {
  145798. return this.cgCamera
  145799. }
  145800. getCameraHorizonFov() {
  145801. return this.mainCamera.fovMode == Camera$1.FOVMODE_HORIZONTAL_FIXED ? this.mainCamera.fov : Math.PI * this.yuvInfo.fov / 180
  145802. }
  145803. changeMainCameraRotationDamping(e=2e3) {
  145804. this.mainCamera.angularSensibility = e
  145805. }
  145806. removeMainCameraRotationLimit() {
  145807. this.maincameraRotLimitObserver != null && this.mainCamera.onAfterCheckInputsObservable.remove(this.maincameraRotLimitObserver)
  145808. }
  145809. setMainCameraInfo(e) {
  145810. const {maxZ: i=1e4, minZ: o=.1, angularSensibility: s=2e3} = e;
  145811. this.mainCamera.maxZ = i,
  145812. this.mainCamera.minZ = o,
  145813. this.mainCamera.angularSensibility = s
  145814. }
  145815. getMainCameraInfo() {
  145816. return {
  145817. maxZ: this.mainCamera.maxZ,
  145818. minZ: this.mainCamera.minZ,
  145819. angularSensibility: this.mainCamera.angularSensibility
  145820. }
  145821. }
  145822. _limitAngle(e, i) {
  145823. return Math.abs(Math.abs(i[0] - i[1]) - 360) < 1e-6 || (e = (e % 360 + 360) % 360,
  145824. i[0] = (i[0] % 360 + 360) % 360,
  145825. i[1] = (i[1] % 360 + 360) % 360,
  145826. i[0] > i[1] ? e > i[1] && e < i[0] && (Math.abs(e - i[0]) < Math.abs(e - i[1]) ? e = i[0] : e = i[1]) : e < i[0] ? e = i[0] : e > i[1] && (e = i[1])),
  145827. e
  145828. }
  145829. setMainCameraRotationLimit(e, i) {
  145830. this.maincameraRotLimitObserver != null && this.removeMainCameraRotationLimit();
  145831. const o = this.mainCamera
  145832. , {yaw: s, pitch: c, roll: d} = e
  145833. , {yaw: _, pitch: b, roll: k} = i;
  145834. if (_ < 0 || b < 0 || k < 0)
  145835. throw new Error("\u76F8\u673A\u65CB\u8F6C\u9650\u5236\u53EA\u80FD\u8BBE\u7F6E\u4E3A\u5927\u4E8E0");
  145836. const j = [c - b, c + b]
  145837. , $ = [s - _, s + _]
  145838. , _e = [d - k, d + k];
  145839. this.maincameraRotLimitObserver = o.onAfterCheckInputsObservable.add(()=>{
  145840. let {pitch: et, yaw: tt, roll: rt} = xverseRotation2Ue4(o.rotation);
  145841. et = this._limitAngle(et, j),
  145842. tt = this._limitAngle(tt, $),
  145843. rt = this._limitAngle(rt, _e),
  145844. o.rotation = ue4Rotation2Xverse({
  145845. pitch: et,
  145846. yaw: tt,
  145847. roll: rt
  145848. })
  145849. }
  145850. )
  145851. }
  145852. setMainCameraRotationLimitByAnchor(e, i, o) {
  145853. this.maincameraRotLimitObserver != null && this.removeMainCameraRotationLimit();
  145854. const s = this.mainCamera
  145855. , c = ue4Rotation2Xverse_mesh(i)
  145856. , d = ue4Rotation2Xverse_mesh(o);
  145857. d != null && c != null && e.mesh != null && (this.maincameraRotLimitObserver = s.onAfterCheckInputsObservable.add(()=>{
  145858. const _ = e.mesh.rotation;
  145859. o.yaw > 0 && (s.rotation.y <= _.y - d.y + c.y ? s.rotation.y = _.y - d.y + c.y : s.rotation.y >= _.y + d.y + c.y && (s.rotation.y = _.y + d.y + c.y)),
  145860. o.pitch > 0 && (s.rotation.x <= _.x - d.x + c.x ? s.rotation.x = _.x - d.x + c.x : s.rotation.x >= _.x + d.x + c.x && (s.rotation.x = _.x + d.x + c.x)),
  145861. o.roll > 0 && (s.rotation.z <= _.z - d.z + c.z ? s.rotation.z = _.z - d.z + c.z : s.rotation.z >= _.z + d.z + c.z && (s.rotation.z = _.z + d.z + c.z))
  145862. }
  145863. ))
  145864. }
  145865. getCameraPose() {
  145866. const e = xversePosition2Ue4({
  145867. x: this.mainCamera.position.x,
  145868. y: this.mainCamera.position.y,
  145869. z: this.mainCamera.position.z
  145870. })
  145871. , i = xverseRotation2Ue4({
  145872. x: this.mainCamera.rotation.x,
  145873. y: this.mainCamera.rotation.y,
  145874. z: this.mainCamera.rotation.z
  145875. });
  145876. return {
  145877. position: e,
  145878. rotation: i
  145879. }
  145880. }
  145881. changeCameraFov(e, i) {
  145882. this.mainCamera.fov = e,
  145883. i != null && (this.mainCamera.fovMode = i == 0 ? Camera$1.FOVMODE_HORIZONTAL_FIXED : Camera$1.FOVMODE_VERTICAL_FIXED)
  145884. }
  145885. controlCameraRotation(e, i, o=.5, s=.5) {
  145886. const c = {
  145887. pitch: s * i * 180,
  145888. yaw: o * e * 180,
  145889. roll: 0
  145890. };
  145891. this.addRot(c)
  145892. }
  145893. addRot(e) {
  145894. const i = this.mainCamera
  145895. , o = ue4Rotation2Xverse_mesh(e);
  145896. o != null && i.rotation.addInPlace(o)
  145897. }
  145898. getCameraFov() {
  145899. return this.mainCamera.fov
  145900. }
  145901. allowMainCameraController() {
  145902. this.mainCamera.attachControl(this.canvas, !0)
  145903. }
  145904. detachMainCameraController() {
  145905. this.mainCamera.detachControl(this.canvas)
  145906. }
  145907. forceChangeSavedCameraPose(e) {
  145908. this.saveCameraPose != null && (e.position != null && (this.saveCameraPose.position = ue4Position2Xverse(e.position)),
  145909. e.rotation != null && (this.saveCameraPose.rotation = ue4Rotation2Xverse(e.rotation)))
  145910. }
  145911. changeToFirstPersonView(e) {
  145912. this.saveCameraPose = {
  145913. position: this.mainCamera.position.clone(),
  145914. rotation: this.mainCamera.rotation.clone()
  145915. },
  145916. this.mainCamera.attachControl(this.canvas, !0),
  145917. e.position != null && (this.mainCamera.position = ue4Position2Xverse(e.position)),
  145918. e.rotation != null && (this.mainCamera.rotation = ue4Rotation2Xverse(e.rotation))
  145919. }
  145920. changeToThirdPersonView() {
  145921. this.saveCameraPose != null && this.mainCamera != null && (this.mainCamera.position = this.saveCameraPose.position.clone(),
  145922. this.mainCamera.rotation = this.saveCameraPose.rotation.clone(),
  145923. this.mainCamera.detachControl(this.canvas))
  145924. }
  145925. switchToMainCamera() {
  145926. this.switchCamera(this.mainCamera)
  145927. }
  145928. switchToCgCamera() {
  145929. this.switchCamera(this.cgCamera)
  145930. }
  145931. moveMainCamera(e, i, o, s, c) {
  145932. this._moveCam(this.mainCamera, this.mainCamera.position, e, this.mainCamera.rotation, i, o, s, c)
  145933. }
  145934. }
  145935. function uuid$2() {
  145936. return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, a=>{
  145937. const e = Math.random() * 16 | 0;
  145938. return (a === "x" ? e : e & 3 | 8).toString(16)
  145939. }
  145940. )
  145941. }
  145942. function hashCode(a) {
  145943. let e = 0, i, o;
  145944. if (a == null || a.length === 0)
  145945. return e;
  145946. for (i = 0; i < a.length; i++)
  145947. o = a.charCodeAt(i),
  145948. e = (e << 5) - e + o,
  145949. e |= 0;
  145950. return e
  145951. }
  145952. const log$w = new Logger$1("XStaticMeshComponent")
  145953. , _XStaticMeshComponent = class {
  145954. constructor(a) {
  145955. this.reg_staticmesh_partupdate = ()=>{
  145956. if (this._allowRegionUpdate && (this.scene.getFrameId(),
  145957. this._meshUpdateFrame()),
  145958. this._allowRegionForceLod) {
  145959. this.scene.getFrameId() % 2 == 0 && this.setOneRegionLod(this._meshInfoKeys[this._currentUpdateRegionCount % this._meshInfoKeys.length].toString(), this._forceLod);
  145960. let i = !0;
  145961. const o = Array.from(this._currentMeshUsedLod.keys());
  145962. if (o.length > 0) {
  145963. for (let s = 0; s < o.length; ++s)
  145964. this._currentMeshUsedLod.get(o[s]) != this._forceLod && (i = !1);
  145965. i && (this._allowRegionForceLod = !1)
  145966. }
  145967. }
  145968. }
  145969. ,
  145970. this.setMeshInfo = (e,i="")=>{
  145971. this._abosoluteUrl != e && (this._abosoluteUrl.length > 0 && this.deleteLastRegionMesh(),
  145972. this._partMeshSkinInfo = i,
  145973. this._abosoluteUrl = e,
  145974. this._rootDir = this._abosoluteUrl.slice(0, -4) + "/",
  145975. this.parseJson(this._rootDir + "meshInfo.json").then(()=>{
  145976. this.startMeshUpdate()
  145977. }
  145978. ))
  145979. }
  145980. ,
  145981. this._meshUpdateFrame = ()=>{
  145982. {
  145983. let e = this._meshInfoKeys[this._currentUpdateRegionCount % this._meshInfoKeys.length];
  145984. const i = !0;
  145985. let o = 3;
  145986. if (this._scenemanager != null && this._scenemanager.cameraComponent != null) {
  145987. const s = this._getMainPlayerPosition();
  145988. if (s != null) {
  145989. if (this._cameraInRegionId >= 0) {
  145990. const d = this.getRegionIdWhichIncludeCamera(s);
  145991. (this._cameraInRegionId != d || this.regionIdInCamera.length == 0) && (this._cameraInRegionId = d,
  145992. this.regionIdInCamera = this._getNeighborId(this._cameraInRegionId.toString()),
  145993. this.regionIdInCameraConst = this.regionIdInCamera.slice());
  145994. let _ = this.regionIdInCamera.pop();
  145995. for (; _ != null; )
  145996. if (this._notUsedRegionLists.indexOf(_) >= 0)
  145997. _ = this.regionIdInCamera.pop();
  145998. else
  145999. break;
  146000. _ != null && (e = _.toString())
  146001. } else
  146002. this._cameraInRegionId = this.getRegionIdWhichIncludeCamera(s);
  146003. if (this._currentMeshUsedLod.size == 0 || this._notUsedRegionLists.indexOf(parseInt(e)) >= 0) {
  146004. e = this._cameraInRegionId.toString();
  146005. const d = this._getNeighborId(e);
  146006. for (; d.length == 0 && (e = this.getNearestRegionIdWithCamera(s).toString()),
  146007. this._notUsedRegionLists.indexOf(parseInt(e)) >= 0; )
  146008. e = d.pop().toString()
  146009. }
  146010. const c = this._meshInfoJson[this._cameraInRegionId.toString()].lod;
  146011. o = 3,
  146012. this._cameraInRegionId.toString() == e ? o = this._regionLodRule[0] : c[0].indexOf(parseInt(e)) >= 0 ? o = this._regionLodRule[1] : c[1].indexOf(parseInt(e)) >= 0 ? o = this._regionLodRule[2] : c[2].indexOf(parseInt(e)) >= 0 ? o = this._regionLodRule[3] : o = this._regionLodRule[4]
  146013. }
  146014. }
  146015. this.setOneRegionLod(e, o, i),
  146016. this.updateRegionNotInLocalNeighbor(),
  146017. this.cleanRootNodes()
  146018. }
  146019. }
  146020. ,
  146021. this.updateRegionNotInLocalNeighbor = ()=>{
  146022. Array.from(this._currentMeshUsedLod.keys()).forEach(i=>{
  146023. this.regionIdInCameraConst.indexOf(parseInt(i)) < 0 && this.setOneRegionLod(i, -1)
  146024. }
  146025. )
  146026. }
  146027. ,
  146028. this.cleanRootNodes = ()=>{
  146029. if (this.scene.getFrameId() % 3 == 0) {
  146030. const e = [];
  146031. this.scene.rootNodes.forEach(i=>{
  146032. (i.getClassName() == "TransformNode" && i.getChildren().length == 0 || i.getClassName() == "Mesh" && i.name == "__root__" && i.getChildren().length == 0) && e.push(i)
  146033. }
  146034. ),
  146035. e.forEach(i=>{
  146036. i.dispose()
  146037. }
  146038. )
  146039. }
  146040. }
  146041. ,
  146042. this.setOneRegionLod = (e,i,o=!0)=>{
  146043. this._currentUpdateRegionCount++;
  146044. const s = this._calHashCode(this._rootDir)
  146045. , c = "region_" + s + "_" + e;
  146046. if (i < 0) {
  146047. this._currentMeshUsedLod.has(e) && (this._currentMeshUsedLod.delete(e),
  146048. this._currentPartGroup.delete(c),
  146049. this.deleteMeshesByCustomProperty("group", "region_" + s + "_" + e));
  146050. return
  146051. }
  146052. const d = this._rootDir + e + "_lod" + i + "_xverse.glb"
  146053. , _ = this._currentMeshUsedLod.get(e);
  146054. this._currentPartGroup.add(c),
  146055. _ != null ? _ != i && (this._currentMeshUsedLod.set(e, i),
  146056. this._scenemanager.addNewLowPolyMesh({
  146057. url: d,
  146058. group: "region_" + s + "_" + e,
  146059. pick: !0,
  146060. lod: i,
  146061. skinInfo: this._partMeshSkinInfo
  146062. }, [{
  146063. group: "region_" + s + "_" + e,
  146064. mode: 0
  146065. }])) : (this._currentMeshUsedLod.set(e, i),
  146066. this._scenemanager.addNewLowPolyMesh({
  146067. url: d,
  146068. group: "region_" + s + "_" + e,
  146069. pick: !0,
  146070. lod: i,
  146071. skinInfo: this._partMeshSkinInfo
  146072. }))
  146073. }
  146074. ,
  146075. this.checkPointInView = ({x: e, y: i, z: o})=>{
  146076. const s = ue4Position2Xverse({
  146077. x: e,
  146078. y: i,
  146079. z: o
  146080. });
  146081. if (!s)
  146082. return !1;
  146083. for (let c = 0; c < 6; c++)
  146084. if (this.scene.frustumPlanes[c].dotCoordinate(s) < 0)
  146085. return !1;
  146086. return !0
  146087. }
  146088. ,
  146089. this.addNewLowPolyMesh = (e,i,o)=>{
  146090. if (!e.url.endsWith("glb") && !e.url.startsWith("blob:"))
  146091. return e.url.endsWith("zip") ? (this.setMeshInfo(e.url, e.skinInfo),
  146092. Promise.resolve(!0)) : (log$w.error("[Engine] input model path is error! ", e.url),
  146093. Promise.reject(new XLowpolyModelError("[Engine] input model path is error! " + e.url)));
  146094. {
  146095. const s = e.url;
  146096. return new Promise((c,d)=>this._scenemanager.urlTransformer(e.url).then(_=>{
  146097. e.url = _;
  146098. const b = new XStaticMeshFromOneGltf(this.scene,e)
  146099. , k = Date.now();
  146100. return new Promise((j,$)=>{
  146101. b.loadMesh(o, !0).then(_e=>{
  146102. const et = Date.now();
  146103. if (this._scenemanager.engineRunTimeStats.timeArray_loadStaticMesh.add(et - k),
  146104. _e == !0) {
  146105. const tt = this.getLowModelType(e);
  146106. let rt = 0;
  146107. if (this._lowModel_group.has(tt) && (rt = this._lowModel_group.get(tt).length),
  146108. o != null && this._scenemanager.currentShader != null && this._scenemanager.currentShader.name != o.name && b.setMaterial(this._scenemanager.currentShader),
  146109. this._allowRegionUpdate == !1 && tt.startsWith("region_"))
  146110. b.dispose();
  146111. else if (this._staticmeshes.push(b),
  146112. this.lowmodelGroupMapAddValue(tt, b),
  146113. i != null && i.length > 0) {
  146114. const it = [];
  146115. for (let nt = 0; nt < i.length; ++nt)
  146116. it.push(i[nt].group),
  146117. this.updateLowModelGroup(i[nt], tt, rt)
  146118. }
  146119. this._scenemanager.engineRunTimeStats.timeArray_updateStaticMesh.add(Date.now() - et),
  146120. j(!0)
  146121. } else
  146122. $(new XLowpolyModelError("[Engine] after lowmodel error!"))
  146123. }
  146124. ).catch(_e=>{
  146125. log$w.error("[Engine] load Mesh [" + s + "] error! " + _e),
  146126. $(new XLowpolyModelError(`[Engine] load Mesh [${s}] error! ${_e}`))
  146127. }
  146128. )
  146129. }
  146130. )
  146131. }
  146132. ).then(_=>{
  146133. _ == !0 ? (log$w.info(`[Engine] load Mesh [${s}] successfully.`),
  146134. c(!0)) : d(!1)
  146135. }
  146136. ).catch(_=>{
  146137. log$w.error("[Engine] addNewLowPolyMesh [" + s + "] error! " + _),
  146138. d(new XLowpolyModelError(`[Engine] addNewLowPolyMesh [${s}] error! ${_}`))
  146139. }
  146140. ))
  146141. }
  146142. }
  146143. ,
  146144. this.toggleLowModelVisibility = e=>{
  146145. const {vis: i, groupName: o="", skinInfo: s=""} = e;
  146146. this._meshVis = i,
  146147. this._meshVisTypeName = {
  146148. groupName: o,
  146149. skinInfo: s
  146150. },
  146151. this._doMeshVisChangeNumber = 0,
  146152. o == _XStaticMeshComponent.ALL_MESHES || this._currentPartGroup.has(o) == !0 || this._partMeshSkinInfo == s ? i == !1 ? (this._visCheckDurationFrameNumber = 100,
  146153. this.stopMeshUpdate()) : (this._visCheckDurationFrameNumber = 1,
  146154. this.startMeshUpdate()) : this._visCheckDurationFrameNumber = 1
  146155. }
  146156. ,
  146157. this.reg_staticmesh_visibility = ()=>{
  146158. if (this._doMeshVisChangeNumber >= 0)
  146159. if (this._doMeshVisChangeNumber < this._visCheckDurationFrameNumber)
  146160. if (this._doMeshVisChangeNumber = this._doMeshVisChangeNumber + 1,
  146161. this._meshVisTypeName.groupName == _XStaticMeshComponent.ALL_MESHES)
  146162. this._lowModel_group.forEach((e,i)=>{
  146163. for (let o = 0, s = e.length; o < s; ++o)
  146164. e[o].toggleVisibility(this._meshVis)
  146165. }
  146166. );
  146167. else {
  146168. if (this._lowModel_group.has(this._meshVisTypeName.groupName))
  146169. for (let e = 0; e < this._lowModel_group.get(this._meshVisTypeName.groupName).length; ++e)
  146170. this._lowModel_group.get(this._meshVisTypeName.groupName)[e].toggleVisibility(this._meshVis);
  146171. if (this._meshVisTypeName.skinInfo != "")
  146172. for (let e = 0; e < this._staticmeshes.length; ++e)
  146173. this._staticmeshes[e].skinInfo == this._meshVisTypeName.skinInfo && this._staticmeshes[e].toggleVisibility(this._meshVis)
  146174. }
  146175. else
  146176. this._meshVis = !0,
  146177. this._meshVisTypeName = {
  146178. groupName: "",
  146179. skinInfo: ""
  146180. },
  146181. this._doMeshVisChangeNumber = -1
  146182. }
  146183. ,
  146184. this._getMeshesByCustomProperty = (e,i)=>{
  146185. let o = [];
  146186. return this._staticmeshes.forEach(s=>{
  146187. s[e] != null && s[e] == i && (o = o.concat(s.meshes))
  146188. }
  146189. ),
  146190. o
  146191. }
  146192. ,
  146193. this._lowModel_group = new Map,
  146194. this._staticmeshes = [],
  146195. this._meshInfoJson = null,
  146196. this._meshInfoKeys = [],
  146197. this._currentUpdateRegionCount = 0,
  146198. this._abosoluteUrl = "",
  146199. this._partMeshSkinInfo = "",
  146200. this._forceLod = 3,
  146201. this._allowRegionUpdate = !1,
  146202. this._allowRegionForceLod = !1,
  146203. this._currentMeshUsedLod = new Map,
  146204. this._currentPartGroup = new Set,
  146205. this._scenemanager = a,
  146206. this.scene = a.Scene,
  146207. this.regionIdInCamera = [],
  146208. this.regionIdInCameraConst = [],
  146209. this._cameraInRegionId = -1,
  146210. this._rootDir = "",
  146211. this._meshVis = !0,
  146212. this._meshVisTypeName = {
  146213. groupName: "",
  146214. skinInfo: ""
  146215. },
  146216. this._doMeshVisChangeNumber = -1,
  146217. this._visCheckDurationFrameNumber = -1,
  146218. this._regionLodRule = [0, 1, 3, 3, -1],
  146219. this.initCgLowModel(),
  146220. this._regionPartLoop()
  146221. }
  146222. get cameraInRegionId() {
  146223. return this._cameraInRegionId
  146224. }
  146225. setRegionLodRule(a) {
  146226. return a.length != 5 ? !1 : (a.forEach(e=>{}
  146227. ),
  146228. this._regionLodRule = a,
  146229. !0)
  146230. }
  146231. get lowModel_group() {
  146232. return this._lowModel_group
  146233. }
  146234. _regionPartLoop() {
  146235. this.scene.registerBeforeRender(this.reg_staticmesh_partupdate),
  146236. this.scene.registerAfterRender(this.reg_staticmesh_visibility)
  146237. }
  146238. _globalSearchCameraInWhichRegion(a, e) {
  146239. let i = -1;
  146240. for (let o = 0; o < e.length; ++o) {
  146241. const s = this._meshInfoJson[e[o].toString()].boundingbox
  146242. , c = s[0]
  146243. , d = s[1];
  146244. if (a.x >= c[0] && a.x <= d[0] && a.y >= c[1] && a.y <= d[1] && a.z >= c[2] && a.z <= d[2] || a.x >= d[0] && a.x <= c[0] && a.y >= d[1] && a.y <= c[1] && a.z >= d[2] && a.z <= c[2]) {
  146245. i = parseInt(e[o].toString());
  146246. break
  146247. }
  146248. }
  146249. return i
  146250. }
  146251. getRegionIdByPosition(a) {
  146252. return this.getRegionIdWhichIncludeCamera(a)
  146253. }
  146254. getRegionIdWhichIncludeCamera(a) {
  146255. let e = -1;
  146256. if (this._allowRegionUpdate == !1)
  146257. return e;
  146258. if (this._cameraInRegionId == -1 ? e = this._globalSearchCameraInWhichRegion(a, this._meshInfoKeys) : (e = this._globalSearchCameraInWhichRegion(a, this.regionIdInCameraConst),
  146259. e == -1 && (e = this._globalSearchCameraInWhichRegion(a, this._meshInfoKeys))),
  146260. e == -1) {
  146261. let i = 1e7;
  146262. for (let o = 0; o < this._meshInfoKeys.length; ++o) {
  146263. const s = this._meshInfoJson[this._meshInfoKeys[o]].center
  146264. , c = Math.abs(a.x - s[0]) + Math.abs(a.y - s[1]);
  146265. i > c && (i = c,
  146266. e = parseInt(this._meshInfoKeys[o]))
  146267. }
  146268. }
  146269. return e
  146270. }
  146271. getNearestRegionIdWithCamera(a) {
  146272. let e = 1
  146273. , i = 1e7;
  146274. for (let o = 0; o < this._meshInfoKeys.length; ++o) {
  146275. if (this._notUsedRegionLists.indexOf(parseInt(this._meshInfoKeys[o])) >= 0)
  146276. continue;
  146277. const s = this._meshInfoJson[this._meshInfoKeys[o]].center
  146278. , c = Math.abs(a.x - s[0]) + Math.abs(a.y - s[1]);
  146279. i > c && (i = c,
  146280. e = parseInt(this._meshInfoKeys[o]))
  146281. }
  146282. return e
  146283. }
  146284. _getNeighborId(a) {
  146285. const e = this._meshInfoJson[a].lod;
  146286. let i = [];
  146287. const o = Object.keys(e);
  146288. for (let s = o.length - 1; s >= 0; --s)
  146289. i = i.concat(e[o[s]]);
  146290. return i.push(parseInt(a)),
  146291. i
  146292. }
  146293. _getMainPlayerPosition() {
  146294. const a = this._scenemanager.cameraComponent.getCameraPose().position
  146295. , e = this._scenemanager.avatarComponent.getMainAvatar();
  146296. if (e != null && e != null) {
  146297. const i = e.position;
  146298. if (i != null)
  146299. return i
  146300. }
  146301. return a
  146302. }
  146303. _calHashCode(a) {
  146304. return hashCode(a) + "_" + this._partMeshSkinInfo
  146305. }
  146306. forceAllRegionLod(a=3) {
  146307. a < 0 && (a = 0),
  146308. a > 3 && (a = 3),
  146309. this.stopMeshUpdate(),
  146310. this._allowRegionForceLod = !0,
  146311. this._forceLod = a
  146312. }
  146313. deleteLastRegionMesh() {
  146314. if (this._rootDir != "") {
  146315. const a = this._calHashCode(this._rootDir);
  146316. this._currentMeshUsedLod.clear(),
  146317. this._currentPartGroup.clear(),
  146318. this._meshInfoJson = null,
  146319. this._meshInfoKeys = [],
  146320. this._currentUpdateRegionCount = 0,
  146321. this._orijson = null,
  146322. this._notUsedRegionLists = [],
  146323. this._partMeshSkinInfo = "",
  146324. this._abosoluteUrl = "",
  146325. this.stopMeshUpdate(),
  146326. this.deleteMeshesByCustomProperty("group", "region_" + a, !0)
  146327. }
  146328. }
  146329. startMeshUpdate() {
  146330. this._allowRegionUpdate == !1 && this._meshInfoJson != null && this._abosoluteUrl != "" && this._meshInfoKeys.length > 0 && (this._allowRegionUpdate = !0)
  146331. }
  146332. stopMeshUpdate() {
  146333. this._allowRegionUpdate = !1
  146334. }
  146335. parseJson(a) {
  146336. return new Promise((e,i)=>this._scenemanager.urlTransformer(a).then(o=>{
  146337. const s = new XMLHttpRequest;
  146338. s.open("get", o),
  146339. s.send(null),
  146340. s.onload = ()=>{
  146341. if (s.status == 200) {
  146342. const c = JSON.parse(s.responseText);
  146343. this._orijson = c,
  146344. this._meshInfoJson = this._orijson.usedRegion,
  146345. this._notUsedRegionLists = this._orijson.notUsedRegion,
  146346. this._meshInfoKeys = Object.keys(this._meshInfoJson),
  146347. log$w.info("[Engine] parse zip mesh info successful"),
  146348. e()
  146349. }
  146350. }
  146351. ,
  146352. s.onerror = ()=>{
  146353. log$w.error(`[Engine] load zip mesh info json error, (provided by blob): ${o}`),
  146354. i(new XLowpolyJsonError(`[Engine] load zip mesh info json error, (provided by blob): ${o}`))
  146355. }
  146356. }
  146357. ).catch(o=>{
  146358. log$w.error(`[Engine] load zip mesh info json error: ${o}, link:${a}`),
  146359. i(new XLowpolyJsonError(`[Engine] load zip mesh info json error: ${o}, link: ${a}`))
  146360. }
  146361. ))
  146362. }
  146363. initCgLowModel() {
  146364. const a = MeshBuilder.CreatePlane("CgPlane", {
  146365. size: 400
  146366. });
  146367. a.position = new Vector3(0,1010,0),
  146368. a.rotation = new Vector3(3 * Math.PI / 2,0,0),
  146369. this._CgPlane = new XStaticMesh({
  146370. id: "CgPlane",
  146371. mesh: a,
  146372. xtype: EMeshType.Cgplane
  146373. }),
  146374. this._CgPlane.hide()
  146375. }
  146376. getLowModelType(a) {
  146377. let e = "";
  146378. return a.group != null ? e = a.group : e = "default",
  146379. e
  146380. }
  146381. lowmodelGroupMapAddValue(a, e) {
  146382. const i = this._lowModel_group.get(a);
  146383. i != null ? (i.push(e),
  146384. this._lowModel_group.set(a, i)) : this._lowModel_group.set(a, [e])
  146385. }
  146386. updateLowModelGroup(a, e, i) {
  146387. let o = i;
  146388. a.group == e || (o = -1),
  146389. a.mode == 0 ? this.deleteLowModelGroup(a.group, o) : a.mode == 1 ? this.toggleVisibleLowModelGroup(!1, a.group, o) : a.mode == 2 && this.toggleVisibleLowModelGroup(!0, a.group, o)
  146390. }
  146391. toggleVisibleLowModelGroup(a, e, i=-1) {
  146392. if (this._lowModel_group.has(e)) {
  146393. const o = this._lowModel_group.get(e);
  146394. let s = o.length;
  146395. i >= 0 && s >= i && (s = i);
  146396. for (let c = 0; c < s; ++c)
  146397. o[c].toggleVisibility(a)
  146398. }
  146399. }
  146400. deleteLowModelGroup(a, e=-1) {
  146401. if (this._lowModel_group.has(a)) {
  146402. const s = this._lowModel_group.get(a);
  146403. let c = s.length;
  146404. e >= 0 && c >= e && (c = e);
  146405. for (let d = 0; d < c; ++d)
  146406. s[d].dispose();
  146407. e >= 0 ? this._lowModel_group.set(a, this._lowModel_group.get(a).slice(c)) : this._lowModel_group.delete(a)
  146408. }
  146409. const i = this._lowModel_group.get(a)
  146410. , o = [];
  146411. i != null && i.length > 0 ? this._staticmeshes.forEach(s=>{
  146412. if (s.group != a)
  146413. o.push(s);
  146414. else
  146415. for (let c = 0; c < i.length; ++c)
  146416. s.groupUuid == i[c].groupUuid && o.push(s)
  146417. }
  146418. ) : this._staticmeshes.forEach(s=>{
  146419. s.group != a && o.push(s)
  146420. }
  146421. ),
  146422. this._staticmeshes = o
  146423. }
  146424. deleteMeshesByGroup(a) {
  146425. this.deleteLowModelGroup(a)
  146426. }
  146427. deleteMeshesById(a) {
  146428. this.deleteMeshesByCustomProperty("id", a)
  146429. }
  146430. deleteMeshesByLoD(a) {
  146431. this.deleteMeshesByCustomProperty("lod", a)
  146432. }
  146433. deleteMeshesBySkinInfo(a) {
  146434. this.deleteMeshesByCustomProperty("skinInfo", a)
  146435. }
  146436. removeMeshesFromSceneByGroup(a) {
  146437. this.removeMeshesFromSceneByCustomProperty("group", a)
  146438. }
  146439. removeMeshesFromSceneById(a) {
  146440. this.removeMeshesFromSceneByCustomProperty("id", a)
  146441. }
  146442. addMeshesToSceneByGroup(a) {
  146443. this.addMeshesToSceneByCustomProperty("group", a)
  146444. }
  146445. addMeshesToSceneById(a) {
  146446. this.addMeshesToSceneByCustomProperty("id", a)
  146447. }
  146448. removeMeshesFromSceneByCustomProperty(a, e, i=!1) {
  146449. this._staticmeshes.forEach(o=>{
  146450. o.isinscene && o[a] != null && (i ? o[a].indexOf(e) < 0 || o.removeFromScene() : o[a] != e || o.removeFromScene())
  146451. }
  146452. )
  146453. }
  146454. addMeshesToSceneByCustomProperty(a, e, i=!1) {
  146455. this._staticmeshes.forEach(o=>{
  146456. o.isinscene == !1 && o[a] != null && (i ? o[a].indexOf(e) < 0 || o.addToScene() : o[a] != e || o.addToScene())
  146457. }
  146458. )
  146459. }
  146460. deleteMeshesByCustomProperty(a, e, i=!1) {
  146461. const o = [];
  146462. this._staticmeshes.forEach(c=>{
  146463. c[a] != null && (i ? c[a].indexOf(e) < 0 ? o.push(c) : c.dispose() : c[a] != e ? o.push(c) : c.dispose())
  146464. }
  146465. ),
  146466. this._staticmeshes = o;
  146467. const s = Array.from(this._lowModel_group.keys());
  146468. for (let c = 0; c < s.length; ++c) {
  146469. const d = s[c]
  146470. , _ = this._lowModel_group.get(d);
  146471. if (_ != null) {
  146472. const b = [];
  146473. for (let k = 0; k < _.length; ++k)
  146474. _[k][a] != null && (i ? _[k][a].indexOf(e) < 0 && b.push(_[k]) : _[k][a] != e && b.push(_[k]));
  146475. b.length > 0 ? this._lowModel_group.set(d, b) : this._lowModel_group.delete(d)
  146476. }
  146477. }
  146478. }
  146479. getMeshes() {
  146480. let a = [];
  146481. for (let e = 0; e < this._staticmeshes.length; ++e)
  146482. a = a.concat(this._staticmeshes[e].meshes);
  146483. return a
  146484. }
  146485. getCgMesh() {
  146486. return this._CgPlane
  146487. }
  146488. getMeshesByGroup(a="default") {
  146489. const e = this._lowModel_group.get(a);
  146490. if (e != null) {
  146491. let i = [];
  146492. for (let o = 0; o < e.length; ++o)
  146493. i = i.concat(e[o].meshes);
  146494. return i
  146495. } else
  146496. return null
  146497. }
  146498. getMeshesByGroup2(a="default") {
  146499. return this._getMeshesByCustomProperty("group", a)
  146500. }
  146501. }
  146502. ;
  146503. let XStaticMeshComponent = _XStaticMeshComponent;
  146504. XStaticMeshComponent.ALL_MESHES = "ALL_MESHES";
  146505. class XStaticMeshFromOneGltf {
  146506. constructor(e, i) {
  146507. this.loadMesh = (o,s)=>{
  146508. const c = this._meshes.length
  146509. , d = s ? 1 : 0
  146510. , _ = this._url;
  146511. return SceneLoader.LoadAssetContainerAsync("", _, this._scene, ()=>{
  146512. this._scene.blockMaterialDirtyMechanism = !0
  146513. }
  146514. , ".glb").then(b=>{
  146515. for (let k = b.materials.length - 1; k >= 0; --k)
  146516. b.materials[k].dispose();
  146517. this._scene.blockMaterialDirtyMechanism = !0;
  146518. for (let k = 0; k < b.meshes.length; ++k) {
  146519. const j = b.meshes[k];
  146520. if ("instances"in j) {
  146521. "visibility"in j && (j.visibility = 0),
  146522. "isPickable"in j && (j.isPickable = this._pickable),
  146523. o != null && (j.material = o),
  146524. "hasVertexAlpha"in j && (j.hasVertexAlpha = !1);
  146525. const $ = new XStaticMesh({
  146526. id: this._groupUuid + "-" + Math.random().toString(36).substr(2, 5),
  146527. mesh: j,
  146528. lod: this._lod,
  146529. group: this._group,
  146530. url: this._url,
  146531. xtype: EMeshType.XStaticMesh,
  146532. skinInfo: this._skinInfo
  146533. });
  146534. this._meshes.push($)
  146535. }
  146536. this._scene.addMesh(j)
  146537. }
  146538. return !0
  146539. }
  146540. ).then(()=>{
  146541. this._isInScene = !0;
  146542. for (let b = c; b < this._meshes.length; ++b)
  146543. this._meshes[b].mesh.visibility = d;
  146544. return Promise.resolve(!0)
  146545. }
  146546. ).catch(b=>{
  146547. log$w.error("[Engine] input gltf mesh uri error! " + b),
  146548. Promise.reject(new XLowpolyModelError("[Engine] input gltf mesh uri error! " + b))
  146549. }
  146550. )
  146551. }
  146552. ,
  146553. this._meshes = [],
  146554. this._scene = e,
  146555. this._url = i.url,
  146556. i.group != null ? this._group = i.group : this._group = "default",
  146557. i.pick != null ? this._pickable = i.pick : this._pickable = !1,
  146558. i.id != null ? this._id = i.id : this._id = "default",
  146559. i.lod != null ? this._lod = i.lod : this._lod = -1,
  146560. i.skinInfo != null ? this._skinInfo = i.skinInfo : this._skinInfo = "default",
  146561. this._groupUuid = uuid$2(),
  146562. this._isInScene = !1
  146563. }
  146564. get isinscene() {
  146565. return this._isInScene
  146566. }
  146567. get groupUuid() {
  146568. return this._groupUuid
  146569. }
  146570. get skinInfo() {
  146571. return this._skinInfo
  146572. }
  146573. get group() {
  146574. return this._group
  146575. }
  146576. get meshes() {
  146577. return this._meshes
  146578. }
  146579. get url() {
  146580. return this._url
  146581. }
  146582. get id() {
  146583. return this._id
  146584. }
  146585. get lod() {
  146586. return this._lod
  146587. }
  146588. removeFromScene() {
  146589. if (this._isInScene) {
  146590. this._isInScene = !1;
  146591. for (let e = 0, i = this._meshes.length; e < i; ++e)
  146592. this._meshes[e].mesh != null && this._scene.removeMesh(this._meshes[e].mesh)
  146593. }
  146594. }
  146595. addToScene() {
  146596. if (this._isInScene == !1) {
  146597. this._isInScene = !0;
  146598. for (let e = 0, i = this._meshes.length; e < i; ++e)
  146599. this._meshes[e].mesh != null && this._scene.addMesh(this._meshes[e].mesh)
  146600. }
  146601. }
  146602. toggleVisibility(e) {
  146603. const i = e ? 1 : 0;
  146604. for (let o = 0, s = this._meshes.length; o < s; ++o)
  146605. "visibility"in this._meshes[o].mesh && (this._meshes[o].mesh.visibility = i)
  146606. }
  146607. togglePickable(e) {
  146608. for (let i = 0, o = this._meshes.length; i < o; ++i)
  146609. "isPickable"in this._meshes[i].mesh && (this._meshes[i].mesh.isPickable = e)
  146610. }
  146611. setMaterial(e) {
  146612. for (let i = 0, o = this._meshes.length; i < o; ++i)
  146613. "material"in this._meshes[i].mesh && (this._meshes[i].mesh.material = e)
  146614. }
  146615. dispose() {
  146616. for (let e = 0, i = this._meshes.length; e < i; ++e)
  146617. this._meshes[e].mesh.dispose(!1, !1)
  146618. }
  146619. }
  146620. const log$v = new Logger$1("XSceneManager");
  146621. var ECurrentShaderMode = (a=>(a[a.default = 0] = "default",
  146622. a[a.video = 1] = "video",
  146623. a[a.pano = 2] = "pano",
  146624. a))(ECurrentShaderMode || {})
  146625. , EImageQuality = (a=>(a[a.low = 0] = "low",
  146626. a[a.mid = 1] = "mid",
  146627. a[a.high = 2] = "high",
  146628. a))(EImageQuality || {});
  146629. class XSceneManager {
  146630. constructor(e, i, o, s, c) {
  146631. this._forceKeepVertical = !1,
  146632. this._renderStatusCheckCount = 0,
  146633. this._renderStatusNotChecktCount = 0,
  146634. this._nonlinearCanvasResize = !1,
  146635. this._bChangeEngineSize = !0,
  146636. this._mv = [],
  146637. this.uploadHardwareSystemInfo = ()=>{
  146638. const j = this.statisticComponent.getHardwareRenderInfo()
  146639. , $ = this.statisticComponent.getSystemInfo()
  146640. , _e = {
  146641. driver: $.driver,
  146642. vender: $.vender,
  146643. webgl: $.version,
  146644. os: $.os
  146645. };
  146646. log$v.warn(JSON.stringify(j)),
  146647. log$v.warn(JSON.stringify(_e))
  146648. }
  146649. ,
  146650. this.addNewLowPolyMesh = async(j,$)=>(this._currentShader == null && await this.initSceneManager(),
  146651. this._lowpolyManager.addNewLowPolyMesh(j, $, this._currentShader)),
  146652. this.initSceneManager = async()=>(await this._materialManager.initMaterial(),
  146653. this.applyShader()),
  146654. this.registerAfterRender = ()=>{
  146655. var j;
  146656. if (this._forceKeepVertical) {
  146657. const $ = this.canvas.width
  146658. , _e = this.canvas.height;
  146659. let et = 0
  146660. , tt = [[0, 0, 0, 0], [0, 0, 0, 0]];
  146661. if (((j = this._cameraManager.MainCamera) == null ? void 0 : j.fovMode) === Camera$1.FOVMODE_HORIZONTAL_FIXED ? (et = Math.ceil((_e - this._yuvInfo.height * $ / this._yuvInfo.width) / 2),
  146662. tt = [[0, 0, $, et], [0, _e - et, $, et]]) : (et = Math.ceil(($ - this._yuvInfo.width * _e / this._yuvInfo.height) / 2),
  146663. tt = [[0, 0, et, _e], [$ - et, 0, et, _e]]),
  146664. et > 0) {
  146665. this.gl.enable(this.gl.SCISSOR_TEST);
  146666. for (let rt = 0; rt < tt.length; ++rt)
  146667. this.gl.scissor(tt[rt][0], tt[rt][1], tt[rt][2], tt[rt][3]),
  146668. this.gl.clearColor(0, 0, 0, 1),
  146669. this.gl.clear(this.gl.COLOR_BUFFER_BIT);
  146670. this.gl.disable(this.gl.SCISSOR_TEST)
  146671. }
  146672. }
  146673. }
  146674. ,
  146675. this.resetRender = ()=>{
  146676. this.scene.environmentTexture && (this.scene.environmentTexture._texture ? this.lightComponent.setIBL(this.scene.environmentTexture._texture.url) : this.scene.environmentTexture.url && this.lightComponent.setIBL(this.scene.environmentTexture.url))
  146677. }
  146678. ;
  146679. const d = /iphone|ipad/gi.test(window.navigator.userAgent) || i.disableWebGL2;
  146680. o || (o = new Engine(e,!0,{
  146681. preserveDrawingBuffer: !0,
  146682. stencil: !0,
  146683. disableWebGL2Support: d
  146684. },!0)),
  146685. s || (s = new Scene(o)),
  146686. this.scene = s,
  146687. this.engine = o,
  146688. this.canvas = e,
  146689. this.scene.clearColor = new Color4(.7,.7,.7,1),
  146690. this.engine.getCaps().parallelShaderCompile = void 0,
  146691. this._initEngineScaleNumber = this.engine.getHardwareScalingLevel(),
  146692. this.engine.enableOfflineSupport = !1,
  146693. this.engine.doNotHandleContextLost = !0,
  146694. this.scene.clearCachedVertexData(),
  146695. this.scene.cleanCachedTextureBuffer(),
  146696. this.urlTransformer = i.urlTransformer || (j=>Promise.resolve(j)),
  146697. i.logger && Logger$1.setLogger(i.logger),
  146698. this.gl = e.getContext("webgl2", {
  146699. preserveDrawingBuffer: !0
  146700. }) || e.getContext("webgl", {
  146701. preserveDrawingBuffer: !0
  146702. }) || e.getContext("experimental-webgl", {
  146703. preserveDrawingBuffer: !0
  146704. }),
  146705. this.gl.pixelStorei(this.gl.UNPACK_ALIGNMENT, 1),
  146706. this._currentPanoId = 0,
  146707. i.forceKeepVertical != null && (this._forceKeepVertical = i.forceKeepVertical),
  146708. i.panoInfo != null && (this.panoInfo = i.panoInfo),
  146709. i.shaderMode != null && (this.shaderMode = i.shaderMode),
  146710. i.yuvInfo != null ? this._yuvInfo = i.yuvInfo : this._yuvInfo = {
  146711. width: i.videoResOriArray[0].width,
  146712. height: i.videoResOriArray[0].height,
  146713. fov: 50
  146714. },
  146715. i.cameraParam != null && (this.cameraParam = i.cameraParam),
  146716. i.nonlinearCanvasResize != null && (this._nonlinearCanvasResize = i.nonlinearCanvasResize),
  146717. this._cameraManager = new XCameraComponent(this.canvas,this.scene,{
  146718. cameraParam: this.cameraParam,
  146719. yuvInfo: this._yuvInfo,
  146720. forceKeepVertical: this._forceKeepVertical
  146721. }),
  146722. this._lowpolyManager = new XStaticMeshComponent(this),
  146723. this._materialManager = new XMaterialComponent(this,{
  146724. videoResOriArray: i.videoResOriArray,
  146725. yuvInfo: this._yuvInfo,
  146726. panoInfo: this.panoInfo,
  146727. shaderMode: this.shaderMode
  146728. }),
  146729. this._statisticManager = new XStats(this),
  146730. this._breathPointManager = new XBreathPointManager(this),
  146731. this._decalManager = new XDecalManager(this),
  146732. this._avatarManager = new XAvatarManager(this),
  146733. this._billboardManager = new XBillboardManager(this),
  146734. this.billboardComponent.loadBackGroundTexToIDB();
  146735. let _ = !1
  146736. , b = !1;
  146737. i.disableLight != null && (_ = i.disableLight),
  146738. i.disablePostprocess != null && (b = i.disablePostprocess),
  146739. _ || (this._lightManager = new XLightManager(this)),
  146740. b || this.postprocessing(),
  146741. this.initSceneManager(),
  146742. this.engineRunTimeStats = new XEngineRunTimeStats,
  146743. /iphone/gi.test(window.navigator.userAgent) && window.devicePixelRatio && window.devicePixelRatio === 3 && window.screen.width === 375 && window.screen.height === 812 ? this.engine.setHardwareScalingLevel(this._initEngineScaleNumber * 2) : this.engine.setHardwareScalingLevel(this._initEngineScaleNumber * (c || 1.8)),
  146744. this.scene.registerBeforeRender(()=>{
  146745. this._nonlinearCanvasResize && this._bChangeEngineSize && (this.setEngineSize(this._yuvInfo),
  146746. this._bChangeEngineSize = !1)
  146747. }
  146748. ),
  146749. this.scene.registerAfterRender(()=>{
  146750. this._nonlinearCanvasResize || this.registerAfterRender()
  146751. }
  146752. ),
  146753. window.addEventListener("resize", ()=>{
  146754. this._nonlinearCanvasResize ? this._bChangeEngineSize = !0 : this.engine.resize()
  146755. }
  146756. ),
  146757. XBillboardManager.alphaWidthMap = getAlphaWidthMap("Arial", this.scene),
  146758. this.uploadHardwareSystemInfo()
  146759. }
  146760. get yuvInfo() {
  146761. return this.getCurrentShaderMode() == 1 ? this._yuvInfo : {
  146762. width: -1,
  146763. height: -1,
  146764. fov: -1
  146765. }
  146766. }
  146767. set yuvInfo(e) {
  146768. this.getCurrentShaderMode() == 1 && (this._yuvInfo = e,
  146769. this._cameraManager.cameraFovChange(e))
  146770. }
  146771. get mainScene() {
  146772. return this.scene
  146773. }
  146774. get cameraComponent() {
  146775. return this._cameraManager
  146776. }
  146777. get staticmeshComponent() {
  146778. return this._lowpolyManager
  146779. }
  146780. get materialComponent() {
  146781. return this._materialManager
  146782. }
  146783. get statisticComponent() {
  146784. return this._statisticManager
  146785. }
  146786. get avatarComponent() {
  146787. return this._avatarManager
  146788. }
  146789. get lightComponent() {
  146790. return this._lightManager
  146791. }
  146792. get Engine() {
  146793. return this.engine
  146794. }
  146795. get Scene() {
  146796. return this.scene
  146797. }
  146798. get billboardComponent() {
  146799. return this._billboardManager
  146800. }
  146801. get breathPointComponent() {
  146802. return this._breathPointManager
  146803. }
  146804. get skytvComponent() {
  146805. return this._skytv
  146806. }
  146807. get mvComponent() {
  146808. return this._mv
  146809. }
  146810. get decalComponent() {
  146811. return this._decalManager
  146812. }
  146813. get currentShader() {
  146814. return this._currentShader
  146815. }
  146816. get initEngineScaleNumber() {
  146817. return this._initEngineScaleNumber
  146818. }
  146819. setImageQuality(e) {
  146820. e == 0 ? (this.engine.setHardwareScalingLevel(this.adaptRatio(this._initEngineScaleNumber, 1.8)),
  146821. log$v.info("[Engine] change image quality to low")) : e == 1 ? (this.engine.setHardwareScalingLevel(this.adaptRatio(this._initEngineScaleNumber, 1.5)),
  146822. log$v.info("[Engine] change image quality to mid")) : e == 2 && (this.engine.setHardwareScalingLevel(this.adaptRatio(this._initEngineScaleNumber, 1)),
  146823. log$v.info("[Engine] change image quality to high"))
  146824. }
  146825. adaptRatio(e, i) {
  146826. const o = Math.max(this.canvas.clientWidth, this.canvas.clientHeight);
  146827. for (; o / (e * i) < 1e3; )
  146828. if (i = i - .1,
  146829. i < 1.1) {
  146830. i = 1;
  146831. break
  146832. }
  146833. const s = Math.min(this.canvas.clientWidth, this.canvas.clientHeight);
  146834. for (; s / (e * i) > 1e3; )
  146835. if (i = i + .1,
  146836. i >= 2) {
  146837. i = 2;
  146838. break
  146839. }
  146840. return e * i
  146841. }
  146842. setNonlinearCanvasResize(e) {
  146843. this._nonlinearCanvasResize = e,
  146844. this._bChangeEngineSize = e,
  146845. e || this.engine.resize()
  146846. }
  146847. changeCameraFovWithShaderUpdate(e) {
  146848. this.materialComponent.changeCameraFovWithShaderUpdate(e)
  146849. }
  146850. setBackgroundColor(e) {
  146851. this.scene.clearColor = new Color4(e.r,e.g,e.b,e.a)
  146852. }
  146853. setBackgroundImg(e) {
  146854. return this._backgroundImg != null && this._backgroundImg.url == e ? Promise.resolve(!0) : new Promise((i,o)=>{
  146855. this.urlTransformer(e).then(s=>{
  146856. this._backgroundImg == null ? this._backgroundImg = {
  146857. layer: new Layer("tex_background_" + Date.now(),s,this.Scene,!0),
  146858. url: e
  146859. } : this._backgroundImg.url != e && this._backgroundImg.layer != null && this._backgroundImg.layer.texture != null && (this._backgroundImg.layer.texture.updateURL(s),
  146860. this._backgroundImg.layer.name = "tex_background_" + Date.now(),
  146861. this._backgroundImg.url = e),
  146862. i(!0)
  146863. }
  146864. ).catch(s=>{
  146865. log$v.error(`[Engine] set background image Error: ${s}`),
  146866. o(`[Engine] set background image Error: ${s}`)
  146867. }
  146868. )
  146869. }
  146870. )
  146871. }
  146872. cleanTheWholeScene() {
  146873. const e = this.scene.getFrameId();
  146874. this.scene.onBeforeRenderObservable.clear(),
  146875. this.scene.onAfterRenderObservable.clear(),
  146876. this.scene.clearCachedVertexData(),
  146877. this.scene.cleanCachedTextureBuffer(),
  146878. this.scene.registerBeforeRender(()=>{
  146879. this.scene.getFrameId() - e > 5 && this.scene.dispose()
  146880. }
  146881. )
  146882. }
  146883. getAreaAvatar(e, i) {
  146884. const o = [];
  146885. return this._avatarManager.getAvatarList().forEach(s=>{
  146886. const c = e
  146887. , d = s.position;
  146888. d && c && calcDistance3D(c, d) < i && o.push(s.id)
  146889. }
  146890. ),
  146891. o
  146892. }
  146893. setEngineSize(e) {
  146894. const i = e.width
  146895. , o = e.height
  146896. , s = this.canvas.width;
  146897. this.canvas.height,
  146898. this.engine.setSize(Math.round(s), Math.round(s * (o / i)))
  146899. }
  146900. getCurrentShaderMode() {
  146901. return this._currentShader === this._materialManager.getDefaultShader() ? 0 : this._currentShader === this._materialManager.getPureVideoShader() ? 1 : 2
  146902. }
  146903. addSkyTV(e, i) {
  146904. return this._skytv = new XTelevision(this.scene,e,this,i),
  146905. this._skytv
  146906. }
  146907. addMv(e, i) {
  146908. this._mv.push(new XTelevision(this.scene,e,this,i))
  146909. }
  146910. addMeshInfo(e) {
  146911. this._lowpolyManager.setMeshInfo(e)
  146912. }
  146913. applyShader() {
  146914. return new Promise((e,i)=>{
  146915. this.shaderMode == EShaderMode.videoAndPano || this.shaderMode == EShaderMode.video ? this.changeVideoShaderForLowModel() : this.shaderMode == EShaderMode.default && this.changeDefaultShaderForLowModel(),
  146916. e(!0)
  146917. }
  146918. )
  146919. }
  146920. changeHardwareScaling(e) {
  146921. e < 1 ? e = 1 : e > 2.5 && (e = 2.5),
  146922. this._bChangeEngineSize = !0,
  146923. this.engine.setHardwareScalingLevel(this._initEngineScaleNumber * e)
  146924. }
  146925. getCurrentUsedPanoId() {
  146926. return this._currentPanoId
  146927. }
  146928. render() {
  146929. try {
  146930. this.scene.render()
  146931. } catch (e) {
  146932. throw log$v.error(`[Engine] Render Error: ${e}`),
  146933. e
  146934. }
  146935. }
  146936. isReadyToRender(e) {
  146937. const {checkMesh: i=!0, checkEffect: o=!1, checkPostProgress: s=!1, checkParticle: c=!1, checkAnimation: d=!1, materialNameWhiteLists: _=[]} = e;
  146938. if (this.scene._isDisposed)
  146939. return log$v.error("[Engine] this.scene._isDisposed== false "),
  146940. !1;
  146941. let b;
  146942. const k = this.scene.getEngine();
  146943. if (o && !k.areAllEffectsReady())
  146944. return log$v.error("[Engine] engine.areAllEffectsReady == false"),
  146945. !1;
  146946. if (d && this.scene._pendingData.length > 0)
  146947. return log$v.error("[Engine] scene._pendingData.length > 0 && animation error"),
  146948. !1;
  146949. if (i) {
  146950. for (b = 0; b < this.scene.meshes.length; b++) {
  146951. const j = this.scene.meshes[b];
  146952. if (!j.isEnabled() || !j.subMeshes || j.subMeshes.length === 0 || j != null && j.material != null && !(j.material.name.startsWith("Pure") || j.material.name.startsWith("Pano")))
  146953. continue;
  146954. if (!j.isReady(!0))
  146955. return log$v.error(`[Engine] scene. mesh isReady == false, mesh name:${j.name}, mesh xtype: ${j == null ? void 0 : j.xtype}, mesh xgroup: ${j == null ? void 0 : j.xgroup}, mesh xskinInfo: ${j == null ? void 0 : j.xskinInfo}`),
  146956. !1;
  146957. const $ = j.hasThinInstances || j.getClassName() === "InstancedMesh" || j.getClassName() === "InstancedLinesMesh" || k.getCaps().instancedArrays && j.instances.length > 0;
  146958. for (const _e of this.scene._isReadyForMeshStage)
  146959. if (!_e.action(j, $))
  146960. return log$v.error(`[Engine] scene._isReadyForMeshStage == false, mesh name:${j.name}, mesh xtype: ${j == null ? void 0 : j.xtype}, mesh xgroup: ${j == null ? void 0 : j.xgroup}, mesh xskinInfo: ${j == null ? void 0 : j.xskinInfo}`),
  146961. !1
  146962. }
  146963. for (b = 0; b < this.scene.geometries.length; b++)
  146964. if (this.scene.geometries[b].delayLoadState === 2)
  146965. return log$v.error("[Engine] geometry.delayLoadState === 2"),
  146966. !1
  146967. }
  146968. if (s) {
  146969. if (this.scene.activeCameras && this.scene.activeCameras.length > 0) {
  146970. for (const j of this.scene.activeCameras)
  146971. if (!j.isReady(!0))
  146972. return log$v.error("[Engine] camera not ready === false, ", j.name),
  146973. !1
  146974. } else if (this.scene.activeCamera && !this.scene.activeCamera.isReady(!0))
  146975. return log$v.error("[Engine] activeCamera ready === false, ", this.scene.activeCamera.name),
  146976. !1
  146977. }
  146978. if (c) {
  146979. for (const j of this.scene.particleSystems)
  146980. if (!j.isReady())
  146981. return log$v.error("[Engine] particleSystem ready === false, ", j.name),
  146982. !1
  146983. }
  146984. return !0
  146985. }
  146986. changePanoShaderForLowModel(e) {
  146987. return log$v.info(`[Engine] changePanoShaderForLowModel: ${e}`),
  146988. this._materialManager.allowYUVUpdate(),
  146989. new Promise((i,o)=>{
  146990. this._materialManager._isInDynamicRange(e) == !1 && o(!1),
  146991. this._currentPanoId = e,
  146992. this._currentShader = this._materialManager.getDynamicShader(e),
  146993. this.changeShaderForLowModel().then(()=>{
  146994. i(!0)
  146995. }
  146996. )
  146997. }
  146998. )
  146999. }
  147000. changeVideoShaderForLowModel() {
  147001. return log$v.info("[Engine] changeVideoShaderForLowModel"),
  147002. this._currentShader = this._materialManager.getPureVideoShader(),
  147003. this._materialManager.allowYUVUpdate(),
  147004. this.changeShaderForLowModel()
  147005. }
  147006. changeDefaultShaderForLowModel() {
  147007. return log$v.info("[Engine] changeDefaultShaderForLowModel"),
  147008. this._currentShader = this._materialManager.getDefaultShader(),
  147009. this._materialManager.stopYUVUpdate(),
  147010. this.changeShaderForLowModel()
  147011. }
  147012. changeShaderForLowModel() {
  147013. return new Promise((e,i)=>{
  147014. this._lowpolyManager.getMeshes().forEach(o=>{
  147015. o.setMaterial(this._currentShader)
  147016. }
  147017. ),
  147018. this._lowpolyManager.getCgMesh().mesh.material = this._currentShader,
  147019. e(!0)
  147020. }
  147021. )
  147022. }
  147023. setIBL(e) {
  147024. this._lightManager.setIBL(e)
  147025. }
  147026. postprocessing() {
  147027. const e = new DefaultRenderingPipeline("default",!0,this.scene);
  147028. e.imageProcessingEnabled = !1,
  147029. e.bloomEnabled = !0,
  147030. e.bloomThreshold = 1,
  147031. e.bloomWeight = 1,
  147032. e.bloomKernel = 64,
  147033. e.bloomScale = .1
  147034. }
  147035. getGround(e) {
  147036. const i = this._lowpolyManager.getMeshes()
  147037. , o = [];
  147038. return i.forEach(s=>{
  147039. s.mesh.name.indexOf("SM_Stage") >= 0 && o.push(s.mesh)
  147040. }
  147041. ),
  147042. this.Scene.meshes.forEach(s=>{
  147043. s.name.split("_")[0] === "ground" && o.push(s)
  147044. }
  147045. ),
  147046. o
  147047. }
  147048. }
  147049. new Logger$1("XVolume");
  147050. class WorldStore {
  147051. static get DefaultWorld() {
  147052. return this.Instances.length === 0 ? null : this.Instances[this.Instances.length - 1]
  147053. }
  147054. }
  147055. WorldStore.Instances = new Array;
  147056. class XLevel extends XObject {
  147057. constructor() {
  147058. var e;
  147059. super(),
  147060. this._OwningWorld = null,
  147061. (e = XWorld.GetDefaultWorld()) == null || e.Levels.push(this),
  147062. this.Actors = new Array,
  147063. this.Components = new Array
  147064. }
  147065. get OwningWorld() {
  147066. return this._OwningWorld
  147067. }
  147068. set OWningWorld(e) {
  147069. this._OwningWorld = e
  147070. }
  147071. dispose() {
  147072. var i;
  147073. const e = XWorld.GetDefaultWorld().Levels.indexOf(this);
  147074. (i = XWorld.GetDefaultWorld()) == null || i.Levels.splice(e, 1)
  147075. }
  147076. }
  147077. class XWorld extends XObject {
  147078. constructor() {
  147079. super(),
  147080. XWorld.Instances.push(this),
  147081. this._persistentLevel = null,
  147082. this.Levels = new Array,
  147083. this.Components = new Array
  147084. }
  147085. static GetDefaultWorld() {
  147086. return WorldStore.DefaultWorld
  147087. }
  147088. static get Instances() {
  147089. return WorldStore.Instances
  147090. }
  147091. get persistentLevel() {
  147092. return this._persistentLevel == null && (this._persistentLevel = new XLevel),
  147093. this._persistentLevel
  147094. }
  147095. set persistentLevel(e) {
  147096. this._persistentLevel = e
  147097. }
  147098. dispose() {
  147099. const e = XWorld.Instances.indexOf(this);
  147100. XWorld.Instances.splice(e, 1),
  147101. this.Levels = [],
  147102. this.Components = [],
  147103. this._persistentLevel = null
  147104. }
  147105. }
  147106. class XActorComponent extends XObject {
  147107. constructor() {
  147108. super(),
  147109. this._ownerPrivate = null,
  147110. this._worldPrivate = XWorld.GetDefaultWorld(),
  147111. this._tickEnabled = !0
  147112. }
  147113. Tick() {}
  147114. ReceiveTick() {
  147115. this.tickEnabled && this.Tick()
  147116. }
  147117. get tickEnabled() {
  147118. return this._tickEnabled
  147119. }
  147120. set tickEnabled(e) {
  147121. this._tickEnabled = e
  147122. }
  147123. get owner() {
  147124. return this._ownerPrivate
  147125. }
  147126. set owner(e) {
  147127. e && (this._ownerPrivate = e,
  147128. this._outer = e == null ? void 0 : e.outer)
  147129. }
  147130. set outer(e) {
  147131. this._outer = e
  147132. }
  147133. get outer() {
  147134. return this.owner && (this._outer = this.owner.outer),
  147135. this._outer
  147136. }
  147137. RegisterComponentWithWorld(e) {}
  147138. }
  147139. var __defProp$2 = Object.defineProperty
  147140. , __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor
  147141. , __decorateClass$2 = (a,e,i,o)=>{
  147142. for (var s = o > 1 ? void 0 : o ? __getOwnPropDesc$2(e, i) : e, c = a.length - 1, d; c >= 0; c--)
  147143. (d = a[c]) && (s = (o ? d(e, i, s) : d(s)) || s);
  147144. return o && s && __defProp$2(e, i, s),
  147145. s
  147146. }
  147147. ;
  147148. AssetContainer.prototype.clone = function(a, e=!0, i, o=!0) {
  147149. const s = new AssetContainer(this.scene);
  147150. a || (a = "");
  147151. const c = $=>a + "_CloneOf_" + $
  147152. , d = {}
  147153. , _ = {}
  147154. , b = []
  147155. , k = [];
  147156. i || (i = {
  147157. doNotInstantiate: !0
  147158. });
  147159. const j = ($,_e)=>{
  147160. if (d[$.uniqueId] = _e.uniqueId,
  147161. _[_e.uniqueId] = _e,
  147162. c && (_e.name = c($.name)),
  147163. _e instanceof Mesh) {
  147164. const et = _e;
  147165. if (s.meshes.push(_e),
  147166. _e.geometry && s.geometries.push(_e.geometry),
  147167. et.morphTargetManager) {
  147168. const tt = $.morphTargetManager;
  147169. et.morphTargetManager = tt.clone(),
  147170. s.morphTargetManagers.push(et.morphTargetManager);
  147171. for (let rt = 0; rt < tt.numTargets; rt++) {
  147172. const it = tt.getTarget(rt)
  147173. , nt = et.morphTargetManager.getTarget(rt);
  147174. d[it.uniqueId] = nt.uniqueId,
  147175. _[nt.uniqueId] = nt
  147176. }
  147177. }
  147178. } else
  147179. _e instanceof TransformNode && s.transformNodes.push(_e)
  147180. }
  147181. ;
  147182. return this.transformNodes.forEach($=>{
  147183. if (!$.parent) {
  147184. const _e = $.instantiateHierarchy(null, i, (et,tt)=>{
  147185. j(et, tt)
  147186. }
  147187. );
  147188. _e && s.rootNodes.push(_e)
  147189. }
  147190. }
  147191. ),
  147192. this.meshes.forEach($=>{
  147193. if (!$.parent) {
  147194. const _e = $.instantiateHierarchy(null, i, (et,tt)=>{
  147195. if (j(et, tt),
  147196. tt.material) {
  147197. const rt = tt;
  147198. if (rt.material)
  147199. if (e) {
  147200. const it = et.material;
  147201. if (k.indexOf(it) === -1) {
  147202. let nt = it.clone(c ? c(it.name) : "Clone of " + it.name);
  147203. if (s.materials.push(nt),
  147204. k.push(it),
  147205. d[it.uniqueId] = nt.uniqueId,
  147206. _[nt.uniqueId] = nt,
  147207. it.getClassName() === "MultiMaterial") {
  147208. const ot = it;
  147209. for (const at of ot.subMaterials)
  147210. !at || (nt = at.clone(c ? c(at.name) : "Clone of " + at.name),
  147211. k.push(at),
  147212. d[at.uniqueId] = nt.uniqueId,
  147213. _[nt.uniqueId] = nt);
  147214. ot.subMaterials = ot.subMaterials.map(at=>at && _[d[at.uniqueId]]),
  147215. s.multiMaterials.push(ot)
  147216. }
  147217. }
  147218. rt.getClassName() !== "InstancedMesh" && (rt.material = _[d[it.uniqueId]])
  147219. } else
  147220. rt.material.getClassName() === "MultiMaterial" ? (this.scene.multiMaterials.indexOf(rt.material) === -1 && this.scene.addMultiMaterial(rt.material),
  147221. s.multiMaterials.indexOf(rt.material) === -1 && s.multiMaterials.push(rt.material)) : (this.scene.materials.indexOf(rt.material) === -1 && this.scene.addMaterial(rt.material),
  147222. s.materials.indexOf(rt.material) === -1 && s.materials.push(rt.material))
  147223. }
  147224. }
  147225. );
  147226. _e && s.rootNodes.push(_e)
  147227. }
  147228. }
  147229. ),
  147230. this.skeletons.forEach($=>{
  147231. const _e = $.clone(c ? c($.name) : "Clone of " + $.name);
  147232. $.overrideMesh && (_e.overrideMesh = _[d[$.overrideMesh.uniqueId]]);
  147233. for (const et of this.meshes)
  147234. if (et.skeleton === $ && !et.isAnInstance) {
  147235. const tt = _[d[et.uniqueId]];
  147236. if (tt.isAnInstance || (tt.skeleton = _e,
  147237. b.indexOf(_e) !== -1))
  147238. continue;
  147239. b.push(_e);
  147240. for (const rt of _e.bones)
  147241. rt._linkedTransformNode && (rt._linkedTransformNode = _[d[rt._linkedTransformNode.uniqueId]])
  147242. }
  147243. s.skeletons.push(_e)
  147244. }
  147245. ),
  147246. this.animationGroups.forEach($=>{
  147247. const _e = $.clone($.name, et=>_[d[et.uniqueId]] || et, o);
  147248. s.animationGroups.push(_e)
  147249. }
  147250. ),
  147251. this.textures.forEach($=>{
  147252. const _e = $.clone();
  147253. _e && s.textures.push(_e)
  147254. }
  147255. ),
  147256. this.cameras.forEach($=>{
  147257. s.cameras.push($.clone(c($.name)))
  147258. }
  147259. ),
  147260. this.lights.forEach($=>{
  147261. const _e = $.clone(c($.name));
  147262. _e && s.lights.push(_e)
  147263. }
  147264. ),
  147265. s
  147266. }
  147267. ;
  147268. AssetContainer.prototype.GetName = function() {
  147269. return this._name || (this._name = ""),
  147270. this._name
  147271. }
  147272. ;
  147273. AssetContainer.prototype.SetName = function(a) {
  147274. this._name = a
  147275. }
  147276. ;
  147277. AssetContainer.prototype.GetRootNode = function() {
  147278. return this._rootNode || (this._rootNode = this.meshes[0]),
  147279. this._rootNode
  147280. }
  147281. ;
  147282. AssetContainer.prototype.CreateRootNodeByName = function(a) {
  147283. const e = new Mesh("assetContainerRootMesh_" + a,this.scene);
  147284. return this.meshes.forEach(i=>{
  147285. i.parent || e.addChild(i)
  147286. }
  147287. ),
  147288. this.meshes.unshift(e),
  147289. e
  147290. }
  147291. ;
  147292. AssetContainer.prototype.GetMeshesWithoutParent = function() {
  147293. const a = new Array;
  147294. return this.meshes.forEach(e=>{
  147295. e.parent || a.push(e)
  147296. }
  147297. ),
  147298. a
  147299. }
  147300. ;
  147301. AssetContainer.prototype.GetOwner = function() {
  147302. return this._owner
  147303. }
  147304. ;
  147305. AssetContainer.prototype.SetOwner = function(a) {
  147306. this._owner || (this._owner = new XObject),
  147307. this._owner = a
  147308. }
  147309. ;
  147310. AssetContainer.prototype.toJSON = function() {
  147311. const a = this.GetOwner()
  147312. , e = a == null ? void 0 : a.outer;
  147313. return e ? e.SaveAsset(this) : ""
  147314. }
  147315. ;
  147316. AssetContainer.prototype.getClassName = function() {
  147317. return "AssetContainer"
  147318. }
  147319. ;
  147320. new Logger$1("XSceneComponent");
  147321. class XSceneComponent extends XActorComponent {
  147322. constructor() {
  147323. super(),
  147324. this._billboardMode = 0,
  147325. this._castShadow = !0,
  147326. this.getBbox = (i={})=>{
  147327. const {isConst: o=!1, changeWithAvatar: s=!1} = i;
  147328. let {localCenter: c={
  147329. x: 0,
  147330. y: 0,
  147331. z: 75
  147332. }, width: d=1.32, height: _=1.5, depth: b=.44} = i;
  147333. if (s) {
  147334. const k = this.scaling;
  147335. c = {
  147336. x: c.x * k.x,
  147337. y: c.y * k.y,
  147338. z: c.z * k.z
  147339. },
  147340. d *= k.x,
  147341. _ *= k.y,
  147342. b *= k.z
  147343. }
  147344. if (this.rootNode) {
  147345. let k = new Vector3(0,0,0)
  147346. , j = new Vector3(0,0,0);
  147347. if (o) {
  147348. const _e = ue4Position2Xverse(c);
  147349. k = k.add(_e.add(new Vector3(-d / 2,-_ / 2,-b / 2))),
  147350. j = j.add(_e.add(new Vector3(d / 2,_ / 2,b / 2)))
  147351. } else {
  147352. k = k.add(new Vector3(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY)),
  147353. j = j.add(new Vector3(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY)),
  147354. this.rootNode.getChildMeshes().forEach(tt=>{
  147355. const rt = tt.getBoundingInfo().boundingBox.minimum
  147356. , it = tt.getBoundingInfo().boundingBox.maximum;
  147357. k.x = Math.min(k.x, rt.x),
  147358. j.x = Math.max(j.x, it.x),
  147359. k.y = Math.min(k.y, rt.y),
  147360. j.y = Math.max(j.y, it.y),
  147361. k.z = Math.min(k.z, rt.z),
  147362. j.z = Math.max(j.z, it.z)
  147363. }
  147364. );
  147365. const _e = j.x - k.x
  147366. , et = j.z - k.z;
  147367. k.x -= this.scaling.x * _e / 2,
  147368. j.x += this.scaling.x * _e / 2,
  147369. j.y *= this.scaling.y,
  147370. k.z -= this.scaling.z * et / 2,
  147371. j.z += this.scaling.z * et / 2
  147372. }
  147373. const $ = this.rootNode.computeWorldMatrix(!0);
  147374. this.bbox ? this.bbox.reConstruct(k, j, $) : this.bbox = new BoundingBox(k,j,$)
  147375. }
  147376. }
  147377. ;
  147378. const e = EngineStore.LastCreatedScene;
  147379. this._bbox = null,
  147380. this._attachChildren = new Array,
  147381. this._attachParent = null,
  147382. this._asset = new AssetContainer(e),
  147383. this._rootNode = this._asset.GetRootNode()
  147384. }
  147385. getClassName() {
  147386. return "XSceneComponent"
  147387. }
  147388. set asset(e) {
  147389. !e || (this._asset = e,
  147390. this._asset.SetOwner(this),
  147391. this._rootNode = this._asset.GetRootNode())
  147392. }
  147393. get asset() {
  147394. return this._asset
  147395. }
  147396. set castShadow(e) {
  147397. !this._rootNode || (this._rootNode.getChildMeshes().forEach(i=>{}
  147398. ),
  147399. this._castShadow = e)
  147400. }
  147401. get castShadow() {
  147402. return this._castShadow
  147403. }
  147404. set position(e) {
  147405. if (!this.rootNode || !e)
  147406. return;
  147407. const i = ue4Position2Xverse(e);
  147408. i && (this.rootNode.position = i)
  147409. }
  147410. get position() {
  147411. return this.rootNode ? xversePosition2Ue4(this.rootNode.position) : {
  147412. x: 0,
  147413. y: 0,
  147414. z: 0
  147415. }
  147416. }
  147417. set rotation(e) {
  147418. if (!this.rootNode || !e)
  147419. return;
  147420. const i = ue4Rotation2Xverse(e);
  147421. i && (this.rootNode.rotation = i)
  147422. }
  147423. get rotation() {
  147424. return this.rootNode ? xverseRotation2Ue4(this.rootNode.rotation) : {
  147425. pitch: 0,
  147426. yaw: 0,
  147427. roll: 0
  147428. }
  147429. }
  147430. set scaling(e) {
  147431. if (!this.rootNode || !e)
  147432. return;
  147433. const i = ue4Scaling2Xverse(e);
  147434. i && (this.rootNode.scaling = i)
  147435. }
  147436. get scaling() {
  147437. if (!this.rootNode)
  147438. return {
  147439. x: 0,
  147440. y: 0,
  147441. z: 0
  147442. };
  147443. const e = this.rootNode.scaling;
  147444. return {
  147445. x: e.x,
  147446. y: -e.z,
  147447. z: e.y
  147448. }
  147449. }
  147450. setEnabled(e) {
  147451. !this.rootNode || (this.rootNode.setEnabled(e),
  147452. this._attachChildren.forEach(i=>{
  147453. i.setEnabled(e)
  147454. }
  147455. ))
  147456. }
  147457. isEnabled() {
  147458. return this.rootNode ? this.rootNode.isEnabled : null
  147459. }
  147460. get billboardMode() {
  147461. return this._billboardMode
  147462. }
  147463. set bllboardMode(e) {
  147464. this._billboardMode !== e && (!this.rootNode || this._rootNode.getChildMeshes().forEach(i=>{
  147465. i.billboardMode = e
  147466. }
  147467. ))
  147468. }
  147469. set name(e) {
  147470. !this.rootNode || (this.rootNode.name = e)
  147471. }
  147472. get name() {
  147473. return this.rootNode ? this.rootNode.name : ""
  147474. }
  147475. get bbox() {
  147476. return this._bbox
  147477. }
  147478. set bbox(e) {
  147479. this._bbox = e
  147480. }
  147481. get rootNode() {
  147482. return this._rootNode
  147483. }
  147484. postLoad() {
  147485. var e;
  147486. this._asset && (this.asset = this._asset,
  147487. this._rootNode = (e = this._asset) == null ? void 0 : e.GetRootNode())
  147488. }
  147489. dispose() {
  147490. var e, i;
  147491. (e = this._asset) == null || e.dispose(),
  147492. (i = this._bbox) == null || i.dispose(),
  147493. this._attachChildren = [],
  147494. this._attachParent = null
  147495. }
  147496. DetachFromComponent(e) {
  147497. !this.rootNode || (this.rootNode.parent = null,
  147498. e._attachChildren.splice(e._attachChildren.indexOf(this), 1),
  147499. this._attachParent = null)
  147500. }
  147501. AttachToComponent(e, i={
  147502. x: 0,
  147503. y: 0,
  147504. z: 0
  147505. }) {
  147506. if (!this.asset || !this.rootNode)
  147507. return;
  147508. const o = this.rootNode;
  147509. this.asset.scene;
  147510. const s = ue4Position2Xverse(i);
  147511. o.setParent(e.rootNode),
  147512. o.position = s,
  147513. e._attachChildren.push(this),
  147514. this._attachParent = e
  147515. }
  147516. }
  147517. __decorateClass$2([xProperty("xAsset")], XSceneComponent.prototype, "_asset", 2);
  147518. RegisterXObjectClass("XSceneComponent", XSceneComponent);
  147519. var __defProp$1 = Object.defineProperty
  147520. , __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor
  147521. , __decorateClass$1 = (a,e,i,o)=>{
  147522. for (var s = o > 1 ? void 0 : o ? __getOwnPropDesc$1(e, i) : e, c = a.length - 1, d; c >= 0; c--)
  147523. (d = a[c]) && (s = (o ? d(e, i, s) : d(s)) || s);
  147524. return o && s && __defProp$1(e, i, s),
  147525. s
  147526. }
  147527. ;
  147528. new Logger$1("XActor");
  147529. class XActor extends XObject {
  147530. constructor() {
  147531. super();
  147532. const e = EngineStore.LastCreatedScene;
  147533. this._children = new Array,
  147534. this._ownedComponent = new Set,
  147535. this._rootComponent = new XSceneComponent,
  147536. this._rootComponent.owner = this,
  147537. this._tickInterval = 1;
  147538. let i = 0;
  147539. this._tickObserver = e.onAfterRenderObservable.add(()=>{
  147540. i += 1,
  147541. i == this._tickInterval && (this._tick(),
  147542. i = 0)
  147543. }
  147544. )
  147545. }
  147546. set outer(e) {
  147547. this._outer = e,
  147548. this._ownedComponent.forEach(i=>{
  147549. i.outer = e
  147550. }
  147551. )
  147552. }
  147553. get outer() {
  147554. return this._outer
  147555. }
  147556. get rootComponent() {
  147557. return this._rootComponent
  147558. }
  147559. getClassName() {
  147560. return "XActor"
  147561. }
  147562. _tick() {
  147563. this._ownedComponent.forEach(e=>{
  147564. e.ReceiveTick()
  147565. }
  147566. )
  147567. }
  147568. get tickInterval() {
  147569. return this._tickInterval
  147570. }
  147571. set tickInterval(e) {
  147572. this._tickInterval = e
  147573. }
  147574. AttachToActor(e) {
  147575. e._children.push(this),
  147576. this._rootComponent.AttachToComponent(e.rootComponent)
  147577. }
  147578. postLoad() {
  147579. this._ownedComponent.add(this._rootComponent)
  147580. }
  147581. dispose() {
  147582. this._children = [],
  147583. this._ownedComponent.clear(),
  147584. this._rootComponent.dispose(),
  147585. this._tickObserver.unregisterOnNextCall = !0
  147586. }
  147587. }
  147588. __decorateClass$1([xProperty("rootComponent")], XActor.prototype, "_rootComponent", 2);
  147589. RegisterXObjectClass("XActor", XActor);
  147590. var __defProp = Object.defineProperty
  147591. , __getOwnPropDesc = Object.getOwnPropertyDescriptor
  147592. , __decorateClass = (a,e,i,o)=>{
  147593. for (var s = o > 1 ? void 0 : o ? __getOwnPropDesc(e, i) : e, c = a.length - 1, d; c >= 0; c--)
  147594. (d = a[c]) && (s = (o ? d(e, i, s) : d(s)) || s);
  147595. return o && s && __defProp(e, i, s),
  147596. s
  147597. }
  147598. ;
  147599. class XAccessory extends XActor {
  147600. constructor() {
  147601. super()
  147602. }
  147603. getClassName() {
  147604. return "XAccessory"
  147605. }
  147606. set attachType(e) {
  147607. this._attachType = e
  147608. }
  147609. get attachType() {
  147610. return this._attachType
  147611. }
  147612. set attachBoneId(e) {
  147613. this._attachBoneId = e
  147614. }
  147615. get attachBoneId() {
  147616. return this._attachBoneId
  147617. }
  147618. set attachPointOffset(e) {
  147619. this._attachPointOffset = e
  147620. }
  147621. get attachPointOffset() {
  147622. return this._attachPointOffset
  147623. }
  147624. set attachPointRotation(e) {
  147625. this._attachPointRotation = e
  147626. }
  147627. get attachPointScale() {
  147628. return this._attachPointScale
  147629. }
  147630. set pointId(e) {
  147631. this._pointId = e
  147632. }
  147633. get pointId() {
  147634. return this._pointId
  147635. }
  147636. set attachPointOffsetVector3(e) {
  147637. this._attachPointOffset = xversePosition2Ue4(e)
  147638. }
  147639. set attachPointScaleVector3(e) {
  147640. this._attachPointScale = {
  147641. x: e.x,
  147642. y: -e.z,
  147643. z: e.y
  147644. }
  147645. }
  147646. set attachPointRotationVector3(e) {
  147647. this._attachPointRotation = xverseRotation2Ue4_mesh(e)
  147648. }
  147649. setLocalRTS(e) {
  147650. if (e) {
  147651. const i = ue4Scaling2Xverse(this._attachPointScale);
  147652. i && (e.scaling = i);
  147653. const o = ue4Position2Xverse(this._attachPointOffset);
  147654. o && (e.position = o);
  147655. const s = ue4Rotation2Xverse_mesh(this._attachPointRotation);
  147656. s && (e.rotation = s)
  147657. }
  147658. }
  147659. setParentTo(e) {
  147660. this.rootComponent && this.rootComponent.rootNode && (this.rootComponent.rootNode.parent = e,
  147661. this.setLocalRTS(this.rootComponent.rootNode))
  147662. }
  147663. detachFrom(e=!0) {
  147664. e ? this.dispose() : this.rootComponent && this.rootComponent.rootNode && (this.rootComponent.rootNode.parent = null,
  147665. this.rootComponent.rootNode.detachFromBone(!1))
  147666. }
  147667. attachTo(e) {
  147668. switch (this._attachType) {
  147669. case 0:
  147670. this.rootComponent && this.rootComponent.rootNode && e.component.body && (this.rootComponent.rootNode.parent = e.component.body.root,
  147671. this.setLocalRTS(this.rootComponent.rootNode));
  147672. break;
  147673. case 1:
  147674. {
  147675. const i = e.skeleton.bones.find(o=>o.name === this._attachBoneId);
  147676. i && this.rootComponent && this.rootComponent.rootNode && e.component.body && (this.rootComponent.rootNode.attachToBone(i, e.component.body.root),
  147677. this.setLocalRTS(this.rootComponent.rootNode));
  147678. break
  147679. }
  147680. }
  147681. }
  147682. async play() {
  147683. this.rootComponent.asset && this.rootComponent.asset.animationGroups && this.rootComponent.asset.animationGroups.length > 0 && (this.rootComponent.asset.animationGroups[0].play(),
  147684. this.rootComponent.asset.animationGroups[0].onAnimationGroupEndObservable.addOnce(()=>Promise.resolve(null)))
  147685. }
  147686. stop() {
  147687. this.rootComponent.asset && this.rootComponent.asset.animationGroups && this.rootComponent.asset.animationGroups.length > 0 && this.rootComponent.asset.animationGroups[0].stop()
  147688. }
  147689. }
  147690. __decorateClass([xProperty("_pointId")], XAccessory.prototype, "_pointId", 2);
  147691. __decorateClass([xProperty("_attachBoneId")], XAccessory.prototype, "_attachBoneId", 2);
  147692. __decorateClass([xProperty("_attachType")], XAccessory.prototype, "_attachType", 2);
  147693. __decorateClass([xProperty("_attachPointOffset")], XAccessory.prototype, "_attachPointOffset", 2);
  147694. __decorateClass([xProperty("_attachPointRotation")], XAccessory.prototype, "_attachPointRotation", 2);
  147695. __decorateClass([xProperty("_attachPointScale")], XAccessory.prototype, "_attachPointScale", 2);
  147696. RegisterXObjectClass("XAccessory", XAccessory);
  147697. const log$u = new Logger$1("ScreenShot");
  147698. function CreateScreenshot(a, e, i, o, s="image/png", c=!1) {
  147699. const {height: d, width: _} = _getScreenshotSize(a, e, i);
  147700. if (log$u.info("[Engine]CreateScreenshot!"),
  147701. !(d && _)) {
  147702. log$u.error("[Engine]CreateScreenshot Invalid 'size' parameter !");
  147703. return
  147704. }
  147705. Tools._ScreenshotCanvas || (Tools._ScreenshotCanvas = document.createElement("canvas")),
  147706. Tools._ScreenshotCanvas.width = _,
  147707. Tools._ScreenshotCanvas.height = d;
  147708. const b = Tools._ScreenshotCanvas.getContext("2d")
  147709. , k = a.getRenderWidth() / a.getRenderHeight();
  147710. let j = _
  147711. , $ = j / k;
  147712. $ > d && ($ = d,
  147713. j = $ * k);
  147714. const _e = Math.max(0, _ - j) / 2
  147715. , et = Math.max(0, d - $) / 2;
  147716. e.getScene().onAfterRenderObservable.addOnce(function() {
  147717. const rt = a.getRenderingCanvas();
  147718. b && rt ? b.drawImage(rt, _e, et, j, $) : log$u.error("[Engine]CreateScreenshot Invalid renderContext and renderingCanvas!"),
  147719. c ? (Tools.EncodeScreenshotCanvasData(void 0, s),
  147720. o && o("")) : Tools.EncodeScreenshotCanvasData(o, s)
  147721. })
  147722. }
  147723. function CreateScreenshotAsync(a, e, i, o="image/png") {
  147724. return new Promise((s,c)=>{
  147725. CreateScreenshot(a, e, i, d=>{
  147726. typeof d != "undefined" ? s(d) : c(new Error("Data is undefined"))
  147727. }
  147728. , o)
  147729. }
  147730. )
  147731. }
  147732. function CreateScreenshotUsingRenderTarget(a, e, i, o, s="image/png", c=1, d=!1, _, b=!1, k=!1) {
  147733. const {height: j, width: $} = _getScreenshotSize(a, e, i)
  147734. , _e = {
  147735. width: $,
  147736. height: j
  147737. };
  147738. if (!(j && $)) {
  147739. log$u.error("Invalid 'size' parameter !");
  147740. return
  147741. }
  147742. const et = e.getScene();
  147743. let tt = null;
  147744. const rt = et.activeCameras;
  147745. et.activeCameras = null,
  147746. et.activeCamera !== e && (tt = et.activeCamera,
  147747. et.activeCamera = e),
  147748. et.render();
  147749. const it = new RenderTargetTexture("screenShot",_e,et,!1,!1,Constants.TEXTURETYPE_UNSIGNED_INT,!1,Texture.NEAREST_SAMPLINGMODE,void 0,k,void 0,void 0,void 0,c);
  147750. it.renderList = null,
  147751. it.samples = c,
  147752. it.renderSprites = b,
  147753. et.onAfterRenderTargetsRenderObservable.addOnce(function() {
  147754. it.readPixels(void 0, void 0, void 0, !1).then(ot=>{
  147755. Tools.DumpData($, j, ot, o, s, _, !0),
  147756. it.dispose()
  147757. }
  147758. )
  147759. });
  147760. const nt = ()=>{
  147761. et.incrementRenderId(),
  147762. et.resetCachedMaterial(),
  147763. it.render(!0),
  147764. et.incrementRenderId(),
  147765. et.resetCachedMaterial(),
  147766. tt && (et.activeCamera = tt),
  147767. et.activeCameras = rt,
  147768. e.getProjectionMatrix(!0),
  147769. et.render()
  147770. }
  147771. ;
  147772. if (d) {
  147773. const ot = new FxaaPostProcess("antialiasing",1,et.activeCamera);
  147774. it.addPostProcess(ot),
  147775. ot.getEffect().isReady() ? nt() : ot.getEffect().onCompiled = ()=>{
  147776. nt()
  147777. }
  147778. } else
  147779. nt()
  147780. }
  147781. function CreateScreenshotUsingRenderTargetAsync(a, e, i, o="image/png", s=1, c=!1, d, _=!1) {
  147782. return new Promise((b,k)=>{
  147783. CreateScreenshotUsingRenderTarget(a, e, i, j=>{
  147784. typeof j != "undefined" ? b(j) : k(new Error("Data is undefined"))
  147785. }
  147786. , o, s, c, d, _)
  147787. }
  147788. )
  147789. }
  147790. function _getScreenshotSize(a, e, i) {
  147791. let o = 0
  147792. , s = 0;
  147793. if (typeof i == "object") {
  147794. const c = i.precision ? Math.abs(i.precision) : 1;
  147795. i.width && i.height ? (o = i.height * c,
  147796. s = i.width * c) : i.width && !i.height ? (s = i.width * c,
  147797. o = Math.round(s / a.getAspectRatio(e))) : i.height && !i.width ? (o = i.height * c,
  147798. s = Math.round(o * a.getAspectRatio(e))) : (s = Math.round(a.getRenderWidth() * c),
  147799. o = Math.round(s / a.getAspectRatio(e)))
  147800. } else
  147801. isNaN(i) || (o = i,
  147802. s = i);
  147803. return s && (s = Math.floor(s)),
  147804. o && (o = Math.floor(o)),
  147805. {
  147806. height: o | 0,
  147807. width: s | 0
  147808. }
  147809. }
  147810. const initSideEffects = ()=>{
  147811. Tools.CreateScreenshot = CreateScreenshot,
  147812. Tools.CreateScreenshotAsync = CreateScreenshotAsync,
  147813. Tools.CreateScreenshotUsingRenderTarget = CreateScreenshotUsingRenderTarget,
  147814. Tools.CreateScreenshotUsingRenderTargetAsync = CreateScreenshotUsingRenderTargetAsync
  147815. }
  147816. ;
  147817. initSideEffects();
  147818. const VERSION$1 = "1.0.92";
  147819. ParticleSystem.prototype.isReady = function() {
  147820. if (!this.emitter || this._imageProcessingConfiguration && !this._imageProcessingConfiguration.isReady())
  147821. return !1;
  147822. if (this.blendMode !== ParticleSystem.BLENDMODE_MULTIPLYADD) {
  147823. if (!this._getWrapper(this.blendMode).effect.isReady())
  147824. return !1
  147825. } else if (!this._getWrapper(ParticleSystem.BLENDMODE_MULTIPLY).effect.isReady() || !this._getWrapper(ParticleSystem.BLENDMODE_ADD).effect.isReady())
  147826. return !1;
  147827. return !0
  147828. }
  147829. ;
  147830. const animationMap = new Map;
  147831. animationMap.set("Falling", new AnimationRange("Falling1",0,15));
  147832. animationMap.set("Click", new AnimationRange("Click",16,39));
  147833. animationMap.set("Disappear", new AnimationRange("Disappear",40,47));
  147834. class XRain extends XSubSequence {
  147835. constructor(e, i, o) {
  147836. super(e, i, o),
  147837. this.onLoadedObserverable.addOnce(()=>{
  147838. this._particleGroups.forEach(s=>{
  147839. const c = s.systems[0];
  147840. c.getClassName() == "ParticleSystem" && (c.startPositionFunction = function(d, _) {
  147841. const k = 2 * Math.random() * Math.PI
  147842. , j = Math.random() * 15 * Math.sin(k)
  147843. , $ = this.minEmitBox.y
  147844. , _e = Math.random() * 15 * Math.cos(k);
  147845. Vector3.TransformCoordinatesFromFloatsToRef(j, $, _e, d, _)
  147846. }
  147847. )
  147848. }
  147849. )
  147850. }
  147851. )
  147852. }
  147853. }
  147854. const log$t = new Logger$1("Billboard");
  147855. var BillboardStatus = (a=>(a[a.SHOW = 1] = "SHOW",
  147856. a[a.HIDE = 0] = "HIDE",
  147857. a[a.DISPOSE = -1] = "DISPOSE",
  147858. a))(BillboardStatus || {});
  147859. class XBillboard {
  147860. constructor(e, i=!1, o=!1) {
  147861. this._mesh = null,
  147862. this._texture = null,
  147863. this._scalingFactor = 1,
  147864. this.offsets = null,
  147865. this._background = null,
  147866. this.poolobj = null,
  147867. this._initMeshScale = new Vector3(1,1,1),
  147868. this._status = -1,
  147869. this._stageChanged = !1,
  147870. this.DEFAULT_CONFIGS = {},
  147871. this._billboardManager = e,
  147872. this._pickable = i,
  147873. this._usePool = o
  147874. }
  147875. set scalingFactor(e) {
  147876. this._scalingFactor = e
  147877. }
  147878. set background(e) {
  147879. this._background = e
  147880. }
  147881. get size() {
  147882. return -1
  147883. }
  147884. setStatus(e) {
  147885. e != this._status && (this._stageChanged = !0,
  147886. this._status = e)
  147887. }
  147888. get status() {
  147889. return this._status
  147890. }
  147891. get stageChanged() {
  147892. return this._stageChanged
  147893. }
  147894. set stageChanged(e) {
  147895. this._stageChanged = e
  147896. }
  147897. init(e="", i=.001, o=.001, s=!1) {
  147898. const c = this._billboardManager.sceneManager.Scene;
  147899. if (this._usePool) {
  147900. const d = this._billboardManager.billboardPool.getFree(c, i, o, s);
  147901. this._mesh = d.data,
  147902. this._mesh.isPickable = this._pickable,
  147903. this._mesh.xid = e,
  147904. this._mesh.xtype = EMeshType.XBillboard,
  147905. this._texture = this._mesh.material.diffuseTexture,
  147906. this.poolobj = d
  147907. } else
  147908. this._mesh = this._billboardManager.createBillboardAsset(c, s);
  147909. this._mesh.isPickable = this._pickable,
  147910. this._initMeshScale.x = i * 1e3,
  147911. this._initMeshScale.y = o * 1e3,
  147912. this._mesh.xid = e,
  147913. this._mesh.xtype = EMeshType.XBillboard,
  147914. this._texture = this._mesh.material.diffuseTexture,
  147915. this.setStatus(1),
  147916. this._stageChanged = !0
  147917. }
  147918. dispose() {
  147919. this._usePool ? this.poolobj && (this._billboardManager.billboardPool.release(this.poolobj),
  147920. this._mesh = null,
  147921. this._texture = null,
  147922. this.poolobj = null) : this._mesh && (this._mesh.dispose(!0, !0),
  147923. this._mesh = null,
  147924. this._texture = null),
  147925. this._background = null
  147926. }
  147927. getMesh() {
  147928. return this._mesh
  147929. }
  147930. updateImage(e) {
  147931. return new Promise(i=>{
  147932. if (this._texture == null) {
  147933. log$t.error("[Engine]Billboard texture not found");
  147934. return
  147935. }
  147936. const o = this._mesh
  147937. , s = this._texture
  147938. , c = this._scalingFactor
  147939. , d = this._initMeshScale.x
  147940. , _ = this._initMeshScale.y
  147941. , b = this._texture.getContext()
  147942. , k = this._texture.getSize();
  147943. b.clearRect(0, 0, k.width, k.height);
  147944. const j = new Image;
  147945. j.crossOrigin = "anonymous",
  147946. j.src = e,
  147947. j.onload = ()=>{
  147948. const $ = j.width * c
  147949. , _e = j.height * c;
  147950. o.scaling.x = $ * d,
  147951. o.scaling.y = _e * _,
  147952. s.scaleTo($, _e),
  147953. b.drawImage(j, 0, 0, $, _e),
  147954. s.hasAlpha = !0,
  147955. s.update(),
  147956. i()
  147957. }
  147958. }
  147959. )
  147960. }
  147961. show() {
  147962. this._mesh && (this._mesh.setEnabled(!0),
  147963. this._mesh.isPickable = this._pickable)
  147964. }
  147965. hide() {
  147966. this._mesh && (this._mesh.setEnabled(!1),
  147967. this._mesh.isPickable = !1)
  147968. }
  147969. setId(e) {
  147970. this._mesh && (this._mesh.xid = e)
  147971. }
  147972. setPosition(e) {
  147973. if (e && this._mesh) {
  147974. const i = ue4Position2Xverse(e);
  147975. this._mesh.position = i
  147976. }
  147977. }
  147978. updateText(e, i, o=!0, s=[], c=30, d="monospace", _="black", b="bold", k) {
  147979. if (this._texture == null) {
  147980. log$t.error("[Engine]Billboard texture not found");
  147981. return
  147982. }
  147983. const j = this._texture
  147984. , $ = this._mesh
  147985. , _e = this._scalingFactor
  147986. , et = this._initMeshScale.x
  147987. , tt = this._initMeshScale.y;
  147988. if (e != "") {
  147989. const rt = this._texture.getContext()
  147990. , it = this._texture.getSize();
  147991. rt.clearRect(0, 0, it.width, it.height);
  147992. const nt = new Image;
  147993. if (o) {
  147994. i != null ? i ? this._background = this._billboardManager.userBackGroundBlob : this._background = this._billboardManager.npcBackGroundBlob : this._background || (this._background = this._billboardManager.userBackGroundBlob);
  147995. let ot = e
  147996. , at = k && k < s.length - 1 ? k : s.length - 1;
  147997. if (this._background) {
  147998. if (at > this._background.length) {
  147999. for (let st = 0; st < at - this._background.length; st++)
  148000. s.pop();
  148001. at = s.length - 1,
  148002. ot = e.slice(0, s[at] - 1) + String.fromCharCode(8230)
  148003. }
  148004. nt.crossOrigin = "anonymous",
  148005. nt.src = this._background[at - 1],
  148006. nt.onload = function() {
  148007. const st = nt.width * _e
  148008. , ut = nt.height * _e;
  148009. $.scaling.x = st * et,
  148010. $.scaling.y = ut * tt,
  148011. j.scaleTo(st, ut),
  148012. rt.textAlign = "center",
  148013. rt.textBaseline = "middle",
  148014. rt.drawImage(nt, 0, 0, st, ut);
  148015. for (let ct = 0; ct < at; ct++)
  148016. j.drawText(ot.slice(s[0 + ct], s[1 + ct]), st / 2, ut * (ct + 1) / (at + 1) + (ct - (at - 1) / 2) * _e * 10, b + " " + c * _e + "px " + d, _, "transparent", !0);
  148017. j.hasAlpha = !0
  148018. }
  148019. }
  148020. } else {
  148021. const ot = k && k < s.length - 1 ? k : s.length - 1
  148022. , at = 480 * _e
  148023. , st = 60 * _e * ot;
  148024. this._mesh.scaling = new Vector3(at * et,st * tt,1),
  148025. j.scaleTo(at, st);
  148026. const ut = j.getContext();
  148027. ut.textAlign = "center",
  148028. ut.textBaseline = "middle";
  148029. for (let ct = 0; ct < ot; ct++)
  148030. setTimeout(()=>{
  148031. j.drawText(e.slice(s[0 + ct], s[1 + ct]), at / 2 + 2 * _e, st * (ct + 1) / (ot + 1) + (ct - (ot - 1) / 2) * _e * 10 + 2 * _e, b + " " + c * _e + "px " + d, "#333333", "transparent", !0),
  148032. j.drawText(e.slice(s[0 + ct], s[1 + ct]), at / 2, st * (ct + 1) / (ot + 1) + (ct - (ot - 1) / 2) * _e * 10, b + " " + c * _e + "px " + d, _, "transparent", !0)
  148033. }
  148034. , 0);
  148035. j.hasAlpha = !0
  148036. }
  148037. } else
  148038. this.clearText()
  148039. }
  148040. drawBillboard(e, i, o) {
  148041. var it;
  148042. const {imageList: s} = e
  148043. , {texts: c, font: d="monospace", fontsize: _=40, fontcolor: b="#ffffff", fontstyle: k="", linesize: j=20, linelimit: $} = i
  148044. , {position: _e, offsets: et, scale: tt, compensationZ: rt=0} = o;
  148045. if (this.scalingFactor = tt || 1,
  148046. et && (this.offsets = {
  148047. x: et.x * this._scalingFactor,
  148048. y: et.y * this._scalingFactor,
  148049. z: et.z * this._scalingFactor
  148050. }),
  148051. this.offsets || (this.offsets = {
  148052. x: 0,
  148053. y: 0,
  148054. z: 0
  148055. }),
  148056. this.setPosition(_e),
  148057. s && !c)
  148058. (it = this._billboardManager.sceneManager) == null || it.urlTransformer(s[0]).then(nt=>{
  148059. this.updateImage(nt)
  148060. }
  148061. );
  148062. else if (c && !s) {
  148063. const [nt,ot] = getStringBoundaries(c, j, XBillboardManager.alphaWidthMap);
  148064. this.offsets.z += this._scalingFactor * rt * (ot.length - 1),
  148065. this.updateText(nt, void 0, !1, ot, _, d, b, k, $)
  148066. } else if (c && s) {
  148067. this.background = s;
  148068. const [nt,ot] = getStringBoundaries(c, j, XBillboardManager.alphaWidthMap);
  148069. this.offsets.z += this._scalingFactor * rt * (ot.length - 1),
  148070. this.updateText(nt, void 0, !0, ot, _, d, b, k, $)
  148071. }
  148072. this.setStatus(1)
  148073. }
  148074. clearText() {
  148075. if (this._texture != null) {
  148076. const e = this._texture.getContext()
  148077. , i = this._texture.getSize();
  148078. e.clearRect(0, 0, i.width, i.height),
  148079. this._texture.update()
  148080. }
  148081. }
  148082. }
  148083. var AvatarGroup = (a=>(a.Npc = "npc",
  148084. a.User = "user",
  148085. a))(AvatarGroup || {})
  148086. , ChangeComponentsMode = (a=>(a[a.Preview = 0] = "Preview",
  148087. a[a.Confirm = 1] = "Confirm",
  148088. a[a.Cancel = 2] = "Cancel",
  148089. a))(ChangeComponentsMode || {})
  148090. , MotionType = (a=>(a.Walk = "walk",
  148091. a.Run = "run",
  148092. a.Fly = "fly",
  148093. a))(MotionType || {});
  148094. class XverseError extends Error {
  148095. constructor(i, o) {
  148096. super(o);
  148097. Tt(this, "code");
  148098. this.code = i
  148099. }
  148100. toJSON() {
  148101. return {
  148102. code: this.code,
  148103. message: this.message
  148104. }
  148105. }
  148106. toString() {
  148107. if (Object(this) !== this)
  148108. throw new TypeError;
  148109. let o = this.name;
  148110. o = o === void 0 ? "Error" : String(o);
  148111. let s = this.message;
  148112. s = s === void 0 ? "" : String(s);
  148113. const c = this.code;
  148114. return s = c === void 0 ? s : c + "," + s,
  148115. o === "" ? s : s === "" ? o : o + ": " + s
  148116. }
  148117. }
  148118. class ParamError extends XverseError {
  148119. constructor(e) {
  148120. super(1001, e || "\u53C2\u6570\u9519\u8BEF")
  148121. }
  148122. }
  148123. class InternalError extends XverseError {
  148124. constructor(e) {
  148125. super(1002, e || "\u5185\u90E8\u9519\u8BEF")
  148126. }
  148127. }
  148128. class TimeoutError extends XverseError {
  148129. constructor(e) {
  148130. super(1003, e || "\u8D85\u65F6")
  148131. }
  148132. }
  148133. class AuthenticationError extends XverseError {
  148134. constructor(e) {
  148135. super(1004, e || "\u9274\u6743\u5931\u8D25")
  148136. }
  148137. }
  148138. class TokenExpiredError extends XverseError {
  148139. constructor(e) {
  148140. super(1005, e || "Token \u5DF2\u8FC7\u671F")
  148141. }
  148142. }
  148143. class UnsupportedError extends XverseError {
  148144. constructor(e) {
  148145. super(1006, e || "\u624B\u673A\u7CFB\u7EDF\u4E0D\u652F\u6301XVerse")
  148146. }
  148147. }
  148148. class InitNetworkTimeoutError extends XverseError {
  148149. constructor(e) {
  148150. super(1007, e || "\u7F51\u7EDC\u521D\u59CB\u5316\u8D85\u65F6")
  148151. }
  148152. }
  148153. class InitDecoderTimeoutError extends XverseError {
  148154. constructor(e) {
  148155. super(1008, e || "Decoder \u521D\u59CB\u5316\u8D85\u65F6")
  148156. }
  148157. }
  148158. class InitConfigTimeoutError extends XverseError {
  148159. constructor(e) {
  148160. super(1009, e || "\u914D\u7F6E\u521D\u59CB\u5316\u8D85\u65F6")
  148161. }
  148162. }
  148163. class InitEngineTimeoutError extends XverseError {
  148164. constructor(e) {
  148165. super(1010, e || "\u5F15\u64CE\u521D\u59CB\u5316\u8D85\u65F6")
  148166. }
  148167. }
  148168. class InitEngineError extends XverseError {
  148169. constructor(e) {
  148170. super(1011, e || "\u5F15\u64CE\u521D\u59CB\u5316\u9519\u8BEF")
  148171. }
  148172. }
  148173. class ActionBlockedError extends XverseError {
  148174. constructor(e) {
  148175. super(1012, e || "\u52A8\u4F5C\u88AB\u5C4F\u853D")
  148176. }
  148177. }
  148178. class PreloadCanceledError extends XverseError {
  148179. constructor(e) {
  148180. super(1013, e || "\u9884\u52A0\u8F7D\u88AB\u53D6\u6D88")
  148181. }
  148182. }
  148183. class FrequencyLimitError extends XverseError {
  148184. constructor(e) {
  148185. super(1014, e || "\u9891\u7387\u9650\u5236")
  148186. }
  148187. }
  148188. class UsersUpperLimitError extends XverseError {
  148189. constructor(e) {
  148190. super(2e3, e || "\u76F4\u64AD\u95F4\u4EBA\u6570\u5DF2\u6EE1")
  148191. }
  148192. }
  148193. class RoomsUpperLimitError extends XverseError {
  148194. constructor(e) {
  148195. super(2001, e || "\u623F\u95F4\u5230\u8FBE\u4E0A\u9650")
  148196. }
  148197. }
  148198. class ServerParamError extends XverseError {
  148199. constructor(e) {
  148200. super(2002, e || "\u670D\u52A1\u5668\u53C2\u6570\u9519\u8BEF")
  148201. }
  148202. }
  148203. class LackOfTokenError extends XverseError {
  148204. constructor(e) {
  148205. super(2003, e || "\u7F3A\u5C11 Token")
  148206. }
  148207. }
  148208. class LoginFailedError extends XverseError {
  148209. constructor(e) {
  148210. super(2004, e || "\u8FDB\u5165\u623F\u95F4\u5931\u8D25")
  148211. }
  148212. }
  148213. class VerifyServiceDownError extends XverseError {
  148214. constructor(e) {
  148215. super(2005, e || "\u9274\u6743\u670D\u52A1\u5F02\u5E38")
  148216. }
  148217. }
  148218. class CreateSessionFailedError extends XverseError {
  148219. constructor(e) {
  148220. super(2006, e || "\u521B\u5EFA session \u5931\u8D25")
  148221. }
  148222. }
  148223. class RtcConnectionError extends XverseError {
  148224. constructor(e) {
  148225. super(2008, e || "RTC\u5EFA\u8054\u5931\u8D25")
  148226. }
  148227. }
  148228. class DoActionFailedError extends XverseError {
  148229. constructor(e) {
  148230. super(2009, e || "\u52A8\u4F5C\u6267\u884C\u5931\u8D25")
  148231. }
  148232. }
  148233. class StateSyncFailedError extends XverseError {
  148234. constructor(e) {
  148235. super(2010, e || "\u72B6\u6001\u540C\u6B65\u5931\u8D25")
  148236. }
  148237. }
  148238. class BroadcastFailedError extends XverseError {
  148239. constructor(e) {
  148240. super(2011, e || "\u5E7F\u64AD\u63A5\u53E3\u63A5\u53E3\u5F02\u5E38")
  148241. }
  148242. }
  148243. class DataAbnormalError extends XverseError {
  148244. constructor(e) {
  148245. super(2012, e || "\u6570\u636E\u5F02\u5E38")
  148246. }
  148247. }
  148248. class GetOnVehicleError extends XverseError {
  148249. constructor(e) {
  148250. super(2015, e || "\u4E0A\u8F7D\u5177\u5931\u8D25\u9700\u8981\u9884\u7EA6")
  148251. }
  148252. }
  148253. class RepeatLoginError extends XverseError {
  148254. constructor(e) {
  148255. super(2017, e || "\u5F02\u5730\u767B\u5F55")
  148256. }
  148257. }
  148258. class RoomDoseNotExistError extends XverseError {
  148259. constructor(e) {
  148260. super(2018, e || "\u6307\u5B9A\u623F\u95F4\u4E0D\u5B58\u5728")
  148261. }
  148262. }
  148263. class TicketExpireError extends XverseError {
  148264. constructor(e) {
  148265. super(2019, e || "\u7968\u636E\u8FC7\u671F")
  148266. }
  148267. }
  148268. class ServerRateLimitError extends XverseError {
  148269. constructor(e) {
  148270. super(2020, e || "\u670D\u52A1\u7AEF\u9891\u7387\u9650\u5236")
  148271. }
  148272. }
  148273. class DoActionBlockedError extends XverseError {
  148274. constructor(e) {
  148275. super(2333, e || "\u52A8\u4F5C\u88AB\u5C4F\u853D")
  148276. }
  148277. }
  148278. class UnReachableError extends XverseError {
  148279. constructor(e) {
  148280. super(2335, e || "\u533A\u57DF\u4E0D\u53EF\u5230\u8FBE")
  148281. }
  148282. }
  148283. class ActionMaybeDelayError extends XverseError {
  148284. constructor(e) {
  148285. super(2334, e || "\u52A8\u4F5C\u53EF\u80FD\u5EF6\u8FDF\u6267\u884C")
  148286. }
  148287. }
  148288. class ActionResponseTimeoutError extends XverseError {
  148289. constructor(e) {
  148290. super(2999, e || "action\u56DE\u5305\u8D85\u65F6")
  148291. }
  148292. }
  148293. var Codes$1 = (a=>(a[a.Success = 0] = "Success",
  148294. a[a.Param = 1001] = "Param",
  148295. a[a.Internal = 1002] = "Internal",
  148296. a[a.Timeout = 1003] = "Timeout",
  148297. a[a.Authentication = 1004] = "Authentication",
  148298. a[a.TokenExpired = 1005] = "TokenExpired",
  148299. a[a.Unsupported = 1006] = "Unsupported",
  148300. a[a.InitNetworkTimeout = 1007] = "InitNetworkTimeout",
  148301. a[a.InitDecoderTimeout = 1008] = "InitDecoderTimeout",
  148302. a[a.InitConfigTimeout = 1009] = "InitConfigTimeout",
  148303. a[a.InitEngineTimeout = 1010] = "InitEngineTimeout",
  148304. a[a.InitEngine = 1011] = "InitEngine",
  148305. a[a.ActionBlocked = 1012] = "ActionBlocked",
  148306. a[a.PreloadCanceled = 1013] = "PreloadCanceled",
  148307. a[a.FrequencyLimit = 1014] = "FrequencyLimit",
  148308. a[a.UsersUpperLimit = 2e3] = "UsersUpperLimit",
  148309. a[a.RoomsUpperLimit = 2001] = "RoomsUpperLimit",
  148310. a[a.ServerParam = 2002] = "ServerParam",
  148311. a[a.LackOfToken = 2003] = "LackOfToken",
  148312. a[a.LoginFailed = 2004] = "LoginFailed",
  148313. a[a.VerifyServiceDown = 2005] = "VerifyServiceDown",
  148314. a[a.CreateSessionFailed = 2006] = "CreateSessionFailed",
  148315. a[a.RtcConnection = 2008] = "RtcConnection",
  148316. a[a.DoActionFailed = 2009] = "DoActionFailed",
  148317. a[a.StateSyncFailed = 2010] = "StateSyncFailed",
  148318. a[a.BroadcastFailed = 2011] = "BroadcastFailed",
  148319. a[a.DataAbnormal = 2012] = "DataAbnormal",
  148320. a[a.GetOnVehicle = 2015] = "GetOnVehicle",
  148321. a[a.RepeatLogin = 2017] = "RepeatLogin",
  148322. a[a.RoomDoseNotExist = 2018] = "RoomDoseNotExist",
  148323. a[a.TicketExpire = 2019] = "TicketExpire",
  148324. a[a.ServerRateLimit = 2020] = "ServerRateLimit",
  148325. a[a.DoActionBlocked = 2333] = "DoActionBlocked",
  148326. a[a.UnReachable = 2335] = "UnReachable",
  148327. a[a.ActionMaybeDelay = 2334] = "ActionMaybeDelay",
  148328. a[a.ActionResponseTimeout = 2999] = "ActionResponseTimeout",
  148329. a))(Codes$1 || {});
  148330. const CodeErrorMap = {
  148331. 1001: ParamError,
  148332. 1002: InternalError,
  148333. 1003: TimeoutError,
  148334. 1004: AuthenticationError,
  148335. 1005: TokenExpiredError,
  148336. 1006: UnsupportedError,
  148337. 1007: InitNetworkTimeoutError,
  148338. 1008: InitDecoderTimeoutError,
  148339. 1009: InitConfigTimeoutError,
  148340. 1010: InitEngineTimeoutError,
  148341. 1011: InitEngineError,
  148342. 1012: ActionBlockedError,
  148343. 1013: PreloadCanceledError,
  148344. 1014: FrequencyLimitError,
  148345. 2e3: UsersUpperLimitError,
  148346. 2001: RoomsUpperLimitError,
  148347. 2002: ServerParamError,
  148348. 2003: LackOfTokenError,
  148349. 2004: LoginFailedError,
  148350. 2005: VerifyServiceDownError,
  148351. 2006: CreateSessionFailedError,
  148352. 2008: RtcConnectionError,
  148353. 2009: DoActionFailedError,
  148354. 2010: StateSyncFailedError,
  148355. 2011: BroadcastFailedError,
  148356. 2012: DataAbnormalError,
  148357. 2015: GetOnVehicleError,
  148358. 2017: RepeatLoginError,
  148359. 2018: RoomDoseNotExistError,
  148360. 2019: TicketExpireError,
  148361. 2020: ServerRateLimitError,
  148362. 2333: DoActionBlockedError,
  148363. 2335: UnReachableError,
  148364. 2334: ActionMaybeDelayError,
  148365. 2999: ActionResponseTimeoutError
  148366. };
  148367. class EventEmitter {
  148368. constructor() {
  148369. Tt(this, "topics", {});
  148370. Tt(this, "on", (e,i,o)=>this.register(!1, e, i, o));
  148371. Tt(this, "once", (e,i,o)=>this.register(!0, e, i, o));
  148372. Tt(this, "register", (e,i,o,s)=>{
  148373. this.topics[i] || (this.topics[i] = {
  148374. once: e,
  148375. listeners: [],
  148376. excuted: !1
  148377. });
  148378. const c = {
  148379. order: s || 0,
  148380. listener: o,
  148381. once: e
  148382. };
  148383. return this.topics[i].listeners.push(c),
  148384. this.topics[i].listeners.sort((d,_)=>d.order - _.order),
  148385. {
  148386. unsub: ()=>{
  148387. this.off(i, o)
  148388. }
  148389. }
  148390. }
  148391. );
  148392. Tt(this, "off", (e,i)=>{
  148393. const o = this.topics[e];
  148394. if (!o)
  148395. return;
  148396. const s = o.listeners.findIndex(c=>c.listener === i);
  148397. this.topics[e].listeners.splice(s, 1),
  148398. this.topics[e].listeners.length === 0 && delete this.topics[e]
  148399. }
  148400. );
  148401. Tt(this, "removeAllListener", ()=>{
  148402. this.topics = {}
  148403. }
  148404. );
  148405. Tt(this, "emit", (e,i)=>{
  148406. !this.topics[e] || !this.topics[e].listeners || this.topics[e].listeners.length < 1 || this.topics[e].excuted || (this.topics[e].listeners.forEach(o=>{
  148407. try {
  148408. o.listener(i !== void 0 ? i : {})
  148409. } catch (s) {
  148410. console.error(s)
  148411. }
  148412. }
  148413. ),
  148414. this.topics[e] && this.topics[e].once && (this.topics[e].excuted = !0))
  148415. }
  148416. )
  148417. }
  148418. }
  148419. const safeDecodeURIComponent = a=>{
  148420. let e = "";
  148421. try {
  148422. e = decodeURIComponent(a)
  148423. } catch {
  148424. e = a
  148425. }
  148426. return e
  148427. }
  148428. , safelyJsonParse = a=>{
  148429. let e = {};
  148430. try {
  148431. e = JSON.parse(a)
  148432. } catch {}
  148433. return e
  148434. }
  148435. , getRandomItem = a=>a.length === 0 ? null : a[Math.floor(Math.random() * a.length)]
  148436. , ENV = "production";
  148437. function getFormattedDate(a) {
  148438. const e = a.getMonth() + 1
  148439. , i = a.getDate()
  148440. , o = a.getHours()
  148441. , s = a.getMinutes()
  148442. , c = a.getSeconds()
  148443. , d = a.getMilliseconds()
  148444. , _ = (e < 10 ? "0" : "") + e
  148445. , b = (i < 10 ? "0" : "") + i
  148446. , k = (o < 10 ? "0" : "") + o
  148447. , j = (s < 10 ? "0" : "") + s
  148448. , $ = (c < 10 ? "0" : "") + c;
  148449. return a.getFullYear() + "-" + _ + "-" + b + " " + k + ":" + j + ":" + $ + "." + d
  148450. }
  148451. const SERVER_URLS = {
  148452. DEV: "wss://sit-eks.xverse.cn/ws",
  148453. PROD: "wss://eks.xverse.cn/ws"
  148454. }
  148455. , REPORT_URL = {
  148456. DEV: "https://xa.xverse.cn:6680/collect",
  148457. PROD: "https://xa.xverse.cn/collect"
  148458. }
  148459. , MAX_RECONNECT_COUNT = 3
  148460. , DEFAULT_JOINROOM_TIMEOUT = 15e3
  148461. , DEFAULT_MAIN_CAMERA_FOV = 50
  148462. , DEFAULT_AVATAR_SCALE = 1
  148463. , REPORT_NUM_PER_REQUEST = 20
  148464. , DEFAULT_OPEN_TIMEOUT_MS = 6e3
  148465. , WS_CLOSE_NORMAL = 1e3
  148466. , WS_CLOSE_RECONNECT = 3008
  148467. , PING_INTERVAL_MS = 1e3
  148468. , TEXTURE_URL = "https://static.xverse.cn/qqktv/texture.png"
  148469. , REPORT_MODULE_TYPE = "xverse-js"
  148470. , authenticationErrorCodes = [3001, 3002, 3003, 3005]
  148471. , RTT_MAX_VALUE = 200
  148472. , HB_MAX_VALUE = 500
  148473. , DURATION = 5
  148474. , lr = class extends EventEmitter {
  148475. constructor() {
  148476. super();
  148477. Tt(this, "_header", {});
  148478. Tt(this, "_body", {});
  148479. Tt(this, "_queue", []);
  148480. Tt(this, "_disabled", !1);
  148481. Tt(this, "_interval", null);
  148482. Tt(this, "_reportUrl");
  148483. Tt(this, "isDocumentLoaded", ()=>document.readyState === "complete");
  148484. this._header.logModuleId = REPORT_MODULE_TYPE,
  148485. this._header.url = location.href,
  148486. this._header.enviroment = ENV,
  148487. this._header.networkType = window.navigator.connection ? window.navigator.connection.type : "unknown",
  148488. this._interval = window.setInterval(()=>{
  148489. this._flushReport()
  148490. }
  148491. , 10 * 1e3)
  148492. }
  148493. static appendExtraMetrics(i) {
  148494. this.VALID_METRICS.push(...i)
  148495. }
  148496. disable() {
  148497. this._disabled = !0,
  148498. this._interval && window.clearInterval(this._interval)
  148499. }
  148500. updateHeader(i) {
  148501. Object.assign(this._header, i)
  148502. }
  148503. updateBody(i) {
  148504. Object.assign(this._body, i)
  148505. }
  148506. updateReportUrl(i) {
  148507. this._reportUrl = i
  148508. }
  148509. report(i, o, s) {
  148510. if (i === "measurement" && (Array.isArray(o) || (o = [o]),
  148511. o.forEach(b=>{
  148512. var k;
  148513. (k = b.metric) != null && k.endsWith("Action") || lr.VALID_METRICS.includes(b.metric) || console.warn("invalid upload metric", b.metric)
  148514. }
  148515. )),
  148516. this._disabled)
  148517. return;
  148518. s || (s = {});
  148519. const {immediate: c, sampleRate: d} = s;
  148520. if (d && d > Math.random())
  148521. return;
  148522. this.updateBody({
  148523. logTime: getFormattedDate(new Date),
  148524. logTimestamp: Date.now()
  148525. });
  148526. const _ = b=>{
  148527. const k = $t(Zt($t({}, this._body), {
  148528. type: i
  148529. }), b);
  148530. this._queue.push(k),
  148531. i === "measurement" && this.emit("report", b)
  148532. }
  148533. ;
  148534. Array.isArray(o) ? o.forEach(b=>_(b)) : _(o),
  148535. (c || this._queue.length >= REPORT_NUM_PER_REQUEST) && this._flushReport()
  148536. }
  148537. _flushReport() {
  148538. if (this._disabled || !this._queue.length || !this.isDocumentLoaded())
  148539. return;
  148540. const i = {
  148541. header: this._header,
  148542. body: this._queue.splice(0, REPORT_NUM_PER_REQUEST)
  148543. };
  148544. this._post(i)
  148545. }
  148546. _post(i) {
  148547. const o = this._reportUrl || REPORT_URL.DEV;
  148548. return new Promise((s,c)=>{
  148549. const d = new XMLHttpRequest;
  148550. d.open("POST", o),
  148551. d.setRequestHeader("Content-Type", "application/json");
  148552. try {
  148553. d.send(JSON.stringify(i))
  148554. } catch (_) {
  148555. console.error(_)
  148556. }
  148557. d.addEventListener("readystatechange", ()=>{
  148558. if (d.readyState == 4)
  148559. return d.status == 200 ? s(d) : c("Unable to send log")
  148560. }
  148561. )
  148562. }
  148563. )
  148564. }
  148565. }
  148566. ;
  148567. let Reporter = lr;
  148568. Tt(Reporter, "VALID_METRICS", ["assetsPreload", "joinRoom", "changeSkin", "getOnVehicle", "getOffVehicle", "getOnWatchTower", "getOffWatchTower", "setPerson", "sendGift", "photobooth", "photoboothExit", "reconnect", "observer", "telescope", "telescopeExit", "avatarLoadDuration", "avatarLoadAt", "changeComponents", "playEffect", "startJoinRoomAt", "initRoomDuration", "webglInitCost", "webglInitAt", "configInitAt", "configInitCost", "networkInitAt", "networkInitCost", "wasmInitAt", "wasmInitCost", "wsOpenedCost", "datachannelOpenedAt", "datachannelOpenedCost", "wsOpenedAt", "baiduRtt", "workerRtt", "loadAssets", "playAnimationStart", "playAnimationEnd", "userAvatarStopMoving", "userAvatarStartMoving", "userAvatarStopRotating", "userAvatarStartRotating", "liveEntranceClick", "sdkInit", "networkQualityChange", "pageShow", "pageHide", "http", "renderError", "firstMediaArravalAt", "firstRenderAt", "firstUpdateStreamLength", "firstYUVDecodedAt", "startGame", "wasmDownloadCost", "getUserWithAvatar"]);
  148569. const reporter = new Reporter;
  148570. var LoggerLevels = (a=>(a[a.Debug = 1] = "Debug",
  148571. a[a.Info = 2] = "Info",
  148572. a[a.Warn = 3] = "Warn",
  148573. a[a.Error = 4] = "Error",
  148574. a[a.Off = 5] = "Off",
  148575. a))(LoggerLevels || {});
  148576. const ur = class {
  148577. constructor(e) {
  148578. Tt(this, "module", "log");
  148579. Tt(this, "level", 1);
  148580. this.module = e
  148581. }
  148582. static setLevel(e) {
  148583. this.level = e
  148584. }
  148585. setLevel(e) {
  148586. this.level = e
  148587. }
  148588. atleast(e) {
  148589. return e >= this.level && e >= ur.level
  148590. }
  148591. print(e, i, ...o) {
  148592. if (this.atleast(i)) {
  148593. const s = e == "debug" ? "info" : e
  148594. , c = this.prefix(e);
  148595. console[s].call(null, c, ...o)
  148596. }
  148597. if (e !== "debug" && e !== "info") {
  148598. const s = o.map(c=>{
  148599. if (c instanceof Object)
  148600. try {
  148601. return JSON.stringify(c)
  148602. } catch {
  148603. return c
  148604. }
  148605. else
  148606. return c
  148607. }
  148608. ).join(",");
  148609. reporter.report("log", {
  148610. message: s,
  148611. level: e,
  148612. module: this.module
  148613. })
  148614. }
  148615. }
  148616. debug(...e) {
  148617. return this.print("debug", 1, ...e)
  148618. }
  148619. info(...e) {
  148620. return this.print("info", 2, ...e)
  148621. }
  148622. infoAndReportLog(e, ...i) {
  148623. const {reportOptions: o} = e;
  148624. delete e.reportOptions,
  148625. reporter.report("log", e, o),
  148626. i.length || (i = [e.message]),
  148627. this.debug(...i)
  148628. }
  148629. infoAndReportMeasurement(e, ...i) {
  148630. var s;
  148631. const {reportOptions: o} = e;
  148632. if (e.startTime) {
  148633. const c = Date.now();
  148634. e.value === void 0 && (e.endTime = c),
  148635. e.value === void 0 && (e.value = c - e.startTime)
  148636. }
  148637. if (e.error ? e.code = ((s = e.error) == null ? void 0 : s.code) || Codes$1.Internal : e.code = Codes$1.Success,
  148638. reporter.report("measurement", e, o),
  148639. i.length || (i = [e]),
  148640. e.level === 4 || e.error) {
  148641. this.error(...i);
  148642. return
  148643. }
  148644. this.warn(...i)
  148645. }
  148646. warn(...e) {
  148647. return this.print("warn", 3, ...e)
  148648. }
  148649. error(...e) {
  148650. return this.print("error", 4, ...e)
  148651. }
  148652. prefix(e) {
  148653. return `[${this.module}][${e}] ${getFormattedDate(new Date)}:`
  148654. }
  148655. }
  148656. ;
  148657. let Logger = ur;
  148658. Tt(Logger, "level", 4);
  148659. function getDistance(a, e) {
  148660. const {x: i, y: o, z: s} = a
  148661. , {x: c, y: d, z: _} = e;
  148662. return Math.sqrt(Math.abs(i - c) ** 2 + Math.abs(o - d) ** 2 + Math.abs(s - _) ** 2)
  148663. }
  148664. function uuid$1() {
  148665. return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, a=>{
  148666. const e = Math.random() * 16 | 0;
  148667. return (a === "x" ? e : e & 3 | 8).toString(16)
  148668. }
  148669. )
  148670. }
  148671. function getErrorByCode(a) {
  148672. if (a === Codes$1.Success)
  148673. return InternalError;
  148674. const e = CodeErrorMap[a];
  148675. return e || console.warn("unkown code", a),
  148676. e || InternalError
  148677. }
  148678. const log$s = new Logger("events");
  148679. class EventsManager extends EventEmitter {
  148680. constructor() {
  148681. super(...arguments);
  148682. Tt(this, "events", new Map);
  148683. Tt(this, "specialEvents", new Map)
  148684. }
  148685. remove(i, o, s, c) {
  148686. if (this.specialEvents.has(i) && !c && o === Codes$1.Success)
  148687. return;
  148688. this.events.get(i) && (this.emit(i, {
  148689. code: o,
  148690. data: s
  148691. }),
  148692. this.events.delete(i),
  148693. this.specialEvents.delete(i))
  148694. }
  148695. async track(i, o) {
  148696. const s = i.traceId
  148697. , {sampleRate: c=1, noReport: d=!1, special: _} = o || {}
  148698. , b = Actions[i.event] + "Action"
  148699. , k = i.tag;
  148700. this.events.set(s, !0),
  148701. _ && this.specialEvents.set(s, !0);
  148702. const j = Date.now();
  148703. let$ = null;
  148704. return new Promise((_e,et)=>{
  148705. if (d)
  148706. return this.off(s),
  148707. this.events.delete(s),
  148708. _e(void 0);
  148709. this.on(s, ({code: rt, data: it, msg: nt})=>{
  148710. if (rt === Codes$1.Success)
  148711. _e(it),
  148712. this.off(s),
  148713. Math.random() < c && log$s.infoAndReportMeasurement({
  148714. metric: b,
  148715. tag: k,
  148716. extra: i.extra,
  148717. startTime: j,
  148718. traceId: s
  148719. });
  148720. else {
  148721. if (rt === Codes$1.ActionMaybeDelay)
  148722. return;
  148723. if (rt === Codes$1.DoActionBlocked && i.event === Actions.Rotation) {
  148724. log$s.debug(b + " response code: " + rt);
  148725. return
  148726. }
  148727. const ot = getErrorByCode(rt)
  148728. , at = new ot(nt);
  148729. this.off(s),
  148730. et(at),
  148731. this.emit("actionResponseError", {
  148732. error: at,
  148733. event: i,
  148734. tag: k
  148735. }),
  148736. log$s.infoAndReportMeasurement({
  148737. metric: b,
  148738. tag: k,
  148739. extra: i.extra,
  148740. error: at,
  148741. startTime: j,
  148742. traceId: s
  148743. })
  148744. }
  148745. }
  148746. );
  148747. const tt = i.timeout || 2e3;
  148748. $ = window.setTimeout(()=>{
  148749. if ($ && clearTimeout($),
  148750. !this.events.get(s))
  148751. return;
  148752. const rt = new ActionResponseTimeoutError(`${b} timeout in ${tt}ms`);
  148753. this.emit("actionResponseTimeout", {
  148754. error: rt,
  148755. event: i,
  148756. tag: k
  148757. }),
  148758. et(rt),
  148759. this.events.delete(s),
  148760. this.off(s),
  148761. log$s.infoAndReportMeasurement({
  148762. metric: b,
  148763. tag: k,
  148764. extra: i.extra,
  148765. error: rt,
  148766. startTime: j,
  148767. traceId: s
  148768. })
  148769. }
  148770. , tt)
  148771. }
  148772. )
  148773. }
  148774. emitTraceIdToDecoder(i, o) {
  148775. if (i === Actions.Rotation || i === Actions.Clicking || i === Actions.GetOnVehicle || i === Actions.GetOffVehicle || i === Actions.Joystick) {
  148776. const s = {
  148777. [Actions.Rotation]: "Rotation",
  148778. [Actions.GetOnVehicle]: "GetOnVehicle",
  148779. [Actions.GetOffVehicle]: "GetOffVehicle",
  148780. [Actions.Clicking]: "MoveTo",
  148781. [Actions.Joystick]: "Joystick"
  148782. };
  148783. this.emit("traceId", {
  148784. traceId: o,
  148785. timestamp: Date.now(),
  148786. event: s[i]
  148787. })
  148788. }
  148789. }
  148790. }
  148791. const eventsManager = new EventsManager;
  148792. var Actions = (a=>(a[a.Clicking = 1] = "Clicking",
  148793. a[a.PlayCG = 6] = "PlayCG",
  148794. a[a.Back = 7] = "Back",
  148795. a[a.ChangeRoom = 8] = "ChangeRoom",
  148796. a[a.ChangeSkin = 13] = "ChangeSkin",
  148797. a[a.Joystick = 15] = "Joystick",
  148798. a[a.Transfer = 18] = "Transfer",
  148799. a[a.GetOnVehicle = 22] = "GetOnVehicle",
  148800. a[a.GetOffVehicle = 23] = "GetOffVehicle",
  148801. a[a.StopMoving = 34] = "StopMoving",
  148802. a[a.UnaryActionLine = 1e3] = "UnaryActionLine",
  148803. a[a.Init = 1001] = "Init",
  148804. a[a.Exit = 1002] = "Exit",
  148805. a[a.SetIFrameInfo = 1003] = "SetIFrameInfo",
  148806. a[a.GetNeighborPoints = 1004] = "GetNeighborPoints",
  148807. a[a.ReserveSeat = 1005] = "ReserveSeat",
  148808. a[a.GetReserveStatus = 1006] = "GetReserveStatus",
  148809. a[a.ChangeNickname = 1007] = "ChangeNickname",
  148810. a[a.ChangeBitRateInfo = 1008] = "ChangeBitRateInfo",
  148811. a[a.Echo = 1009] = "Echo",
  148812. a[a.SetPlayerState = 1010] = "SetPlayerState",
  148813. a[a.TurnTo = 1011] = "TurnTo",
  148814. a[a.TurnToFace = 1012] = "TurnToFace",
  148815. a[a.RotateTo = 1013] = "RotateTo",
  148816. a[a.Rotation = 1014] = "Rotation",
  148817. a[a.CameraTurnTo = 1015] = "CameraTurnTo",
  148818. a[a.ConfirmEvent = 1016] = "ConfirmEvent",
  148819. a[a.Broadcast = 1017] = "Broadcast",
  148820. a[a.NotifyActionLine = 2e4] = "NotifyActionLine",
  148821. a[a.AudienceChangeToVisitor = 1020] = "AudienceChangeToVisitor",
  148822. a[a.VisitorChangeToAudience = 1021] = "VisitorChangeToAudience",
  148823. a[a.RemoveVisitor = 1022] = "RemoveVisitor",
  148824. a[a.GetUserWithAvatar = 1023] = "GetUserWithAvatar",
  148825. a[a.GetNewUserState = 1024] = "GetNewUserState",
  148826. a[a.SetSyncPolicy = 1025] = "SetSyncPolicy",
  148827. a))(Actions || {})
  148828. , RemoveVisitorType = (a=>(a[a.RVT_ChangeToObserver = 1] = "RVT_ChangeToObserver",
  148829. a[a.RVT_MoveOutOfTheRoom = 2] = "RVT_MoveOutOfTheRoom",
  148830. a))(RemoveVisitorType || {})
  148831. , NewUserStateType = (a=>(a[a.NUST_Undefined = 0] = "NUST_Undefined",
  148832. a[a.NUST_Myself = 1] = "NUST_Myself",
  148833. a[a.NUST_FollowingList = 2] = "NUST_FollowingList",
  148834. a))(NewUserStateType || {})
  148835. , CoreBroadcastType = (a=>(a.PlayAnimation = "PlayAnimation",
  148836. a))(CoreBroadcastType || {})
  148837. , MessageHandleType = (a=>(a[a.MHT_Undefined = 0] = "MHT_Undefined",
  148838. a[a.MHT_RoomMulticast = 1] = "MHT_RoomMulticast",
  148839. a[a.MHT_FollowListMulticast = 2] = "MHT_FollowListMulticast",
  148840. a[a.MHT_CustomTargetSync = 3] = "MHT_CustomTargetSync",
  148841. a))(MessageHandleType || {});
  148842. new Logger("xverse-broadcast");
  148843. const cr = class {
  148844. constructor(e, i) {
  148845. this.room = e,
  148846. cr.handlers.push(i)
  148847. }
  148848. broadcast(e) {
  148849. const {data: i, msgType: o=MessageHandleType.MHT_FollowListMulticast, targetUserIds: s, sampleRate: c=1} = e;
  148850. return this.room.actionsHandler.broadcast({
  148851. data: i,
  148852. msgType: o,
  148853. targetUserIds: s,
  148854. sampleRate: c
  148855. })
  148856. }
  148857. }
  148858. ;
  148859. let Broadcast = cr;
  148860. Tt(Broadcast, "handlers", []);
  148861. const log$r = new Logger("actions-handler")
  148862. , QueueActions = [Actions.Transfer, Actions.ChangeSkin, Actions.GetOnVehicle, Actions.GetOffVehicle];
  148863. class ActionsHandler {
  148864. constructor(e) {
  148865. Tt(this, "room");
  148866. Tt(this, "currentActiveAction");
  148867. Tt(this, "blockedActions", []);
  148868. Tt(this, "avatarComponentsSync", e=>{
  148869. const i = {
  148870. action_type: Actions.SetPlayerState,
  148871. set_player_state_action: {
  148872. player_state: {
  148873. avatar_components: JSON.stringify(e)
  148874. }
  148875. }
  148876. };
  148877. this.sendData({
  148878. data: i
  148879. })
  148880. }
  148881. );
  148882. this.room = e
  148883. }
  148884. addBlockedActions(e) {
  148885. this.blockedActions.push(...e)
  148886. }
  148887. removeBlockedActions(e) {
  148888. if (!e) {
  148889. this.blockedActions = [];
  148890. return
  148891. }
  148892. const i = this.blockedActions.indexOf(e);
  148893. this.blockedActions.splice(i, 1)
  148894. }
  148895. async sendData(e) {
  148896. await this.beforeSend(e);
  148897. const i = uuid$1();
  148898. if (this.room.networkController.sendRtcData(Zt($t({}, e.data), {
  148899. trace_id: i,
  148900. user_id: this.room.options.userId
  148901. })),
  148902. eventsManager.emitTraceIdToDecoder(e.data.action_type, i),
  148903. this.blockedActions.includes(e.data.action_type))
  148904. return new Promise(()=>{}
  148905. );
  148906. if (e.track === !1)
  148907. return Promise.resolve(null);
  148908. const {sampleRate: o=1, timeout: s=2e3, tag: c, data: d, special: _} = e;
  148909. return eventsManager.track({
  148910. timeout: s,
  148911. traceId: i,
  148912. event: d.action_type,
  148913. tag: c,
  148914. extra: d
  148915. }, {
  148916. special: _,
  148917. sampleRate: o,
  148918. noReport: this.room.viewMode === "serverless" || this.room.options.viewMode === "serverless"
  148919. }).finally(()=>{
  148920. QueueActions.includes(e.data.action_type) && (this.currentActiveAction = void 0)
  148921. }
  148922. )
  148923. }
  148924. async beforeSend(e) {
  148925. var c;
  148926. const i = (c = this.room._userAvatar) == null ? void 0 : c.isMoving
  148927. , o = e.data.action_type;
  148928. if (QueueActions.includes(o)) {
  148929. if (this.currentActiveAction)
  148930. return log$r.error(`${Actions[this.currentActiveAction]} still pending, reject ${Actions[o]}`),
  148931. Promise.reject(new FrequencyLimitError(`${Actions[o]} action request frequency limit`));
  148932. this.currentActiveAction = o
  148933. }
  148934. if (i && QueueActions.includes(e.data.action_type))
  148935. try {
  148936. await this.stopMoving()
  148937. } catch (d) {
  148938. this.currentActiveAction = void 0,
  148939. log$r.error("before action stopMoving failed", d)
  148940. }
  148941. }
  148942. async moveTo(e) {
  148943. const {point: i, extra: o="", motionType: s} = e
  148944. , c = {
  148945. action_type: Actions.Clicking,
  148946. clicking_action: {
  148947. clicking_point: i,
  148948. clicking_type: ClickType.IgnoreView,
  148949. extra: encodeURIComponent(o),
  148950. attitude: s
  148951. },
  148952. clicking_state: this.room._currentClickingState
  148953. };
  148954. return this.sendData({
  148955. data: c
  148956. })
  148957. }
  148958. transfer(e) {
  148959. const {renderType: i, player: o, camera: s, areaName: c, attitude: d, pathName: _, person: b, noMedia: k, timeout: j, tag: $, special: _e} = e
  148960. , et = {
  148961. data: {
  148962. action_type: Actions.Transfer,
  148963. transfer_action: {
  148964. render_type: i,
  148965. player: o,
  148966. camera: s,
  148967. areaName: c,
  148968. attitude: d,
  148969. pathName: _,
  148970. person: {
  148971. type: b
  148972. },
  148973. noMedia: k,
  148974. tiles: [0, 1, 2, 4]
  148975. }
  148976. },
  148977. special: _e,
  148978. timeout: j || 4e3,
  148979. tag: $
  148980. };
  148981. return this.sendData(et).then(tt=>(typeof b != "undefined" && this.room.updateCurrentNetworkOptions({
  148982. person: b,
  148983. rotationRenderType: i
  148984. }),
  148985. tt))
  148986. }
  148987. changeRotationRenderType(e) {
  148988. const {renderType: i, player: o, camera: s, areaName: c, attitude: d, pathName: _} = e;
  148989. return this.transfer({
  148990. renderType: i,
  148991. player: o,
  148992. camera: s,
  148993. areaName: c,
  148994. attitude: d,
  148995. pathName: _,
  148996. tag: "changeToRotationVideo"
  148997. })
  148998. }
  148999. requestPanorama(e, i, o) {
  149000. const {camera: s, player: c, areaName: d, attitude: _, pathName: b, tag: k} = e;
  149001. return this.transfer({
  149002. renderType: RenderType.ClientRotationPano,
  149003. player: c,
  149004. camera: s,
  149005. person: Person.First,
  149006. areaName: d,
  149007. attitude: _,
  149008. pathName: b,
  149009. noMedia: i,
  149010. timeout: o,
  149011. tag: k || "requestPanorama",
  149012. special: !i
  149013. })
  149014. }
  149015. setMotionType(e) {
  149016. return this.transfer({
  149017. attitude: e,
  149018. tag: "setMotionType"
  149019. })
  149020. }
  149021. setNickName(e) {
  149022. const i = {
  149023. action_type: Actions.ChangeNickname,
  149024. change_nickname_action: {
  149025. nickname: e
  149026. }
  149027. };
  149028. return this.sendData({
  149029. data: i
  149030. })
  149031. }
  149032. getReserveSeat({routeId: e, name: i}) {
  149033. const o = {
  149034. action_type: Actions.ReserveSeat,
  149035. reserve_seat_action: {
  149036. route_id: e,
  149037. name: i
  149038. }
  149039. };
  149040. return this.sendData({
  149041. data: o
  149042. })
  149043. }
  149044. getReserveStatus({routeId: e, name: i, need_detail: o}) {
  149045. const s = {
  149046. action_type: Actions.GetReserveStatus,
  149047. get_reserve_status_action: {
  149048. route_id: e,
  149049. name: i,
  149050. need_detail: o
  149051. }
  149052. };
  149053. return this.sendData({
  149054. data: s,
  149055. timeout: 2e3
  149056. }).then(c=>c.reserveDetail)
  149057. }
  149058. stopMoving() {
  149059. const e = {
  149060. action_type: Actions.StopMoving,
  149061. stop_move_action: {}
  149062. };
  149063. return this.sendData({
  149064. data: e
  149065. })
  149066. }
  149067. getOnVehicle({routeId: e, name: i, camera: o}) {
  149068. const s = {
  149069. action_type: Actions.GetOnVehicle,
  149070. get_on_vehicle_action: {
  149071. route_id: e,
  149072. name: i,
  149073. camera: o
  149074. }
  149075. };
  149076. return this.sendData({
  149077. data: s
  149078. })
  149079. }
  149080. getOffVehicle({renderType: e, player: i, camera: o}) {
  149081. const s = {
  149082. action_type: Actions.GetOffVehicle,
  149083. get_off_vehicle_action: {
  149084. render_type: e,
  149085. player: i,
  149086. camera: o
  149087. }
  149088. };
  149089. return this.sendData({
  149090. data: s
  149091. })
  149092. }
  149093. confirmEvent(e) {
  149094. const i = {
  149095. action_type: Actions.ConfirmEvent,
  149096. confirm_event_action: {
  149097. id: e
  149098. }
  149099. };
  149100. return this.sendData({
  149101. data: i,
  149102. track: !1
  149103. })
  149104. }
  149105. echo(e) {
  149106. const i = {
  149107. action_type: Actions.Echo,
  149108. echo_msg: {
  149109. echoMsg: e
  149110. }
  149111. };
  149112. return this.sendData({
  149113. data: i,
  149114. track: !1
  149115. })
  149116. }
  149117. async changeSkin(e) {
  149118. const i = e.special === void 0 ? e.renderType === RenderType.ClientRotationPano : e.special
  149119. , {skinId: o, mode: s, landingType: c=LandingType.Stay, landingPoint: d, landingCamera: _, renderType: b, areaName: k, attitude: j, pathName: $, person: _e, noMedia: et, timeout: tt, roomTypeId: rt=""} = e
  149120. , it = this.room.skinList.filter(ot=>ot.id === o)[0];
  149121. if (!it) {
  149122. const ot = `skin ${o} is invalid`;
  149123. return log$r.error(ot),
  149124. Promise.reject(new ParamError(ot))
  149125. }
  149126. const nt = {
  149127. action_type: Actions.ChangeSkin,
  149128. change_skin_action: {
  149129. skinID: o,
  149130. mode: s === ChangeMode.Preview ? ChangeMode.Preview : ChangeMode.Confirm,
  149131. skin_data_version: o + it.versionId,
  149132. landing_type: c,
  149133. landing_point: d,
  149134. landing_camera: _,
  149135. render_wrapper: {
  149136. render_type: b
  149137. },
  149138. areaName: k,
  149139. attitude: j,
  149140. noMedia: et,
  149141. person: _e,
  149142. pathName: $,
  149143. roomTypeId: rt
  149144. }
  149145. };
  149146. return this.sendData({
  149147. data: nt,
  149148. timeout: tt || 6e3,
  149149. special: i
  149150. }).then(async ot=>(b === RenderType.ClientRotationPano && ot && await this.room.panorama.handleReceivePanorama(ot),
  149151. this.handleChangeSkin(e))).catch(ot=>et ? this.handleChangeSkin(e) : Promise.reject(ot))
  149152. }
  149153. handleChangeSkin(e) {
  149154. const {skinId: i, mode: o, renderType: s, areaName: c, attitude: d, pathName: _} = e;
  149155. return this.room.sceneManager.staticmeshComponent.getCgMesh().show(),
  149156. this.room.sceneManager.cameraComponent.switchToCgCamera(),
  149157. this.room.engineProxy._updateSkinAssets(i).then(()=>{
  149158. this.room.sceneManager.staticmeshComponent.getCgMesh().hide(),
  149159. this.room.sceneManager.cameraComponent.switchToMainCamera(),
  149160. this.room.pathManager.currentArea = c,
  149161. log$r.info("changeSkin _updateSkinAssets susccss"),
  149162. this.room.updateCurrentNetworkOptions({
  149163. pathName: _,
  149164. attitude: d,
  149165. areaName: c
  149166. }),
  149167. this.room.skinChangedHook(),
  149168. this.room.emit("skinChanged", {
  149169. skin: {
  149170. id: i
  149171. },
  149172. mode: o
  149173. }),
  149174. s === RenderType.ClientRotationPano && this.room.sceneManager.cameraComponent.allowMainCameraController()
  149175. }
  149176. )
  149177. }
  149178. rotate({pitch: e, yaw: i}) {
  149179. var s;
  149180. if (this.room.isPano || ((s = this.room._userAvatar) == null ? void 0 : s._isChangingComponentsMode))
  149181. return;
  149182. const o = {
  149183. action_type: Actions.Rotation,
  149184. rotation_action: {
  149185. vertical_move: e,
  149186. horizontal_move: -i
  149187. }
  149188. };
  149189. this.sendData({
  149190. data: o,
  149191. track: !1
  149192. })
  149193. }
  149194. turnTo(e) {
  149195. const {point: i, timeout: o=2e3, offset: s=8} = e || {}
  149196. , c = {
  149197. action_type: Actions.TurnTo,
  149198. turn_to_action: {
  149199. turn_to_point: i,
  149200. offset: s
  149201. }
  149202. };
  149203. return this.sendData({
  149204. data: c,
  149205. timeout: o
  149206. })
  149207. }
  149208. rotateTo(e) {
  149209. const {point: i, offset: o=0, speed: s=3} = e || {}
  149210. , c = {
  149211. action_type: Actions.RotateTo,
  149212. rotate_to_action: {
  149213. rotate_to_point: i,
  149214. offset: o,
  149215. speed: s
  149216. }
  149217. };
  149218. return this.sendData({
  149219. data: c
  149220. })
  149221. }
  149222. broadcast(e) {
  149223. const {data: i, msgType: o=MessageHandleType.MHT_FollowListMulticast, targetUserIds: s, sampleRate: c=1} = e;
  149224. if (o === MessageHandleType.MHT_CustomTargetSync && !Array.isArray(s))
  149225. return Promise.reject(new ParamError(`param targetUserIds is required when msgType is ${MessageHandleType[o]}`));
  149226. const d = {
  149227. action_type: Actions.Broadcast,
  149228. broadcast_action: {
  149229. data: JSON.stringify(i),
  149230. user_id: this.room.options.userId,
  149231. msgType: o
  149232. }
  149233. };
  149234. return Array.isArray(s) && o === MessageHandleType.MHT_CustomTargetSync && (d.broadcast_action.target_user_ids = s),
  149235. this.room.actionsHandler.sendData({
  149236. data: d,
  149237. tag: i.broadcastType,
  149238. sampleRate: c
  149239. })
  149240. }
  149241. getNeighborPoints(e) {
  149242. const {point: i, containSelf: o=!1, searchRange: s=500} = e
  149243. , c = {
  149244. action_type: Actions.GetNeighborPoints,
  149245. get_neighbor_points_action: {
  149246. point: i,
  149247. level: 1,
  149248. containSelf: o,
  149249. searchRange: s
  149250. }
  149251. };
  149252. return this.sendData({
  149253. data: c
  149254. }).then(d=>d.nps)
  149255. }
  149256. playCG(e) {
  149257. const i = {
  149258. action_type: Actions.PlayCG,
  149259. play_cg_action: {
  149260. cg_name: e
  149261. }
  149262. };
  149263. return this.sendData({
  149264. data: i
  149265. })
  149266. }
  149267. audienceToVisitor(e) {
  149268. const {avatarId: i, avatarComponents: o, player: s, camera: c} = e
  149269. , d = {
  149270. action_type: Actions.AudienceChangeToVisitor,
  149271. audienceChangeToVisitorAction: {
  149272. avatarID: i,
  149273. avatarComponents: o,
  149274. player: s,
  149275. camera: c
  149276. }
  149277. };
  149278. return log$r.debug("send data: audience to visitor"),
  149279. this.sendData({
  149280. data: d
  149281. })
  149282. }
  149283. visitorToAudience(e) {
  149284. const {renderType: i, player: o, camera: s, areaName: c, attitude: d, pathName: _, person: b, noMedia: k} = e
  149285. , j = {
  149286. action_type: Actions.VisitorChangeToAudience,
  149287. visitorChangeToAudienceAction: {
  149288. transferAction: {
  149289. render_type: i,
  149290. player: o,
  149291. camera: s,
  149292. areaName: c,
  149293. attitude: d,
  149294. pathName: _,
  149295. person: {
  149296. type: b
  149297. },
  149298. noMedia: k,
  149299. tiles: [0, 1, 2, 4]
  149300. }
  149301. }
  149302. };
  149303. return log$r.debug("send data: visitor to audience"),
  149304. this.sendData({
  149305. data: j
  149306. })
  149307. }
  149308. removeVisitor(e) {
  149309. const {removeType: i, userIDList: o, extraInfo: s=""} = e
  149310. , c = {
  149311. action_type: Actions.RemoveVisitor,
  149312. removeVisitorAction: {
  149313. removeVisitorEvent: i,
  149314. userIDList: o.map(d=>String(d)),
  149315. extraInfo: encodeURIComponent(s)
  149316. }
  149317. };
  149318. return log$r.debug("send data: remove visitor"),
  149319. this.sendData({
  149320. data: c
  149321. })
  149322. }
  149323. getUserWithAvatar(e, i) {
  149324. const o = {
  149325. action_type: Actions.GetUserWithAvatar,
  149326. getUserWithAvatarAction: {
  149327. userType: e,
  149328. roomID: i
  149329. }
  149330. };
  149331. return log$r.debug("send data: get user with avatar"),
  149332. this.sendData({
  149333. data: o,
  149334. sampleRate: 0
  149335. }).then(s=>(Math.random() < .1 && log$r.infoAndReportMeasurement({
  149336. metric: "getUserWithAvatar",
  149337. startTime: Date.now(),
  149338. extra: {
  149339. visitors: s.userWithAvatarList,
  149340. avatars: this.room.avatars.filter(c=>c.withModel).map(c=>({
  149341. isHost: c.isHost,
  149342. userID: c.userId
  149343. }))
  149344. }
  149345. }),
  149346. s.userWithAvatarList))
  149347. }
  149348. getNewUserState(e) {
  149349. const i = {
  149350. action_type: Actions.GetNewUserState,
  149351. getNewUserStateAction: {
  149352. userType: e
  149353. }
  149354. };
  149355. return this.sendData({
  149356. data: i,
  149357. sampleRate: 0
  149358. }).then(o=>o)
  149359. }
  149360. setSyncPolicy({syncPolicy: e}) {
  149361. const i = {
  149362. action_type: Actions.SetSyncPolicy,
  149363. setSyncPolicyAction: {
  149364. syncPolicy: e
  149365. }
  149366. };
  149367. return this.sendData({
  149368. data: i
  149369. })
  149370. }
  149371. joystick(e) {
  149372. const {degree: i, level: o=1} = e
  149373. , s = uuid$1();
  149374. let c = -i + 90 + 360;
  149375. c >= 360 && (c -= 360);
  149376. const d = {
  149377. action_type: Actions.Joystick,
  149378. dir_action: {
  149379. move_angle: c,
  149380. speed_level: o
  149381. },
  149382. trace_id: s,
  149383. user_id: this.room.options.userId,
  149384. packet_id: s
  149385. };
  149386. return this.sendData({
  149387. data: d,
  149388. track: !1
  149389. })
  149390. }
  149391. }
  149392. const log$q = new Logger("db");
  149393. class BaseTable {
  149394. constructor(e, i) {
  149395. Tt(this, "db");
  149396. Tt(this, "isCreatingTable", !1);
  149397. Tt(this, "hasCleared", !1);
  149398. this.dbName = e,
  149399. this.dbVersion = i
  149400. }
  149401. async clearDataBase(e) {
  149402. return this.hasCleared || (e && (this.hasCleared = !0),
  149403. !window.indexedDB.databases) ? Promise.resolve() : new Promise((i,o)=>{
  149404. const s = window.indexedDB.deleteDatabase(this.dbName);
  149405. s.onsuccess = ()=>{
  149406. i()
  149407. }
  149408. ,
  149409. s.onerror = o
  149410. }
  149411. )
  149412. }
  149413. tableName() {
  149414. throw new Error("Derived class have to override 'tableName', and set a proper table name!")
  149415. }
  149416. keyPath() {
  149417. throw new Error("Derived class have to override 'keyPath', and set a proper index name!")
  149418. }
  149419. index() {
  149420. throw new Error("Derived class have to override 'index', and set a proper index name!")
  149421. }
  149422. async checkAndOpenDatabase() {
  149423. return this.db ? Promise.resolve(this.db) : new Promise((e,i)=>{
  149424. const s = setTimeout(()=>{
  149425. log$q.warn("wait db to open for", 200),
  149426. this.db ? e(this.db) : e(this.checkAndOpenDatabase()),
  149427. clearTimeout(s)
  149428. }
  149429. , 200);
  149430. this.openDatabase(this.dbName, this.dbVersion || 1, ()=>{
  149431. this.db && !this.isCreatingTable && e(this.db),
  149432. log$q.warn(`successCallback called, this.db: ${!!this.db}, this.isCreatingStore: ${this.isCreatingTable}`),
  149433. clearTimeout(s)
  149434. }
  149435. , ()=>{
  149436. i(new Error("Failed to open database!")),
  149437. clearTimeout(s)
  149438. }
  149439. , ()=>{
  149440. this.db && e(this.db),
  149441. clearTimeout(s),
  149442. log$q.warn(`successCallback called, this.db: ${!!this.db}, this.isCreatingStore: ${this.isCreatingTable}`)
  149443. }
  149444. )
  149445. }
  149446. )
  149447. }
  149448. openDatabase(e, i, o, s, c) {
  149449. if (this.isCreatingTable)
  149450. return;
  149451. this.isCreatingTable = !0,
  149452. log$q.warn({
  149453. database: e,
  149454. version: i
  149455. });
  149456. const d = window.indexedDB.open(e, i)
  149457. , _ = this.tableName();
  149458. d.onsuccess = b=>{
  149459. this.db = d.result,
  149460. log$q.warn(`IndexedDb ${e} is opened.`),
  149461. this.db.objectStoreNames.contains(_) && (this.isCreatingTable = !1),
  149462. o && o(b)
  149463. }
  149464. ,
  149465. d.onerror = b=>{
  149466. var k;
  149467. log$q.error("Failed to open database", (k = b == null ? void 0 : b.srcElement) == null ? void 0 : k.error),
  149468. this.isCreatingTable = !1,
  149469. s && s(b),
  149470. this.clearDataBase(!0)
  149471. }
  149472. ,
  149473. d.onupgradeneeded = b=>{
  149474. const k = b.target.result
  149475. , j = this.index();
  149476. log$q.warn(`Creating table ${_}.`);
  149477. let$ = k.objectStoreNames.contains(_);
  149478. if ($)
  149479. $ = k.transaction([_], "readwrite").objectStore(_);
  149480. else {
  149481. const _e = this.keyPath();
  149482. $ = k.createObjectStore(_, {
  149483. keyPath: _e
  149484. })
  149485. }
  149486. j.map(_e=>{
  149487. $.createIndex(_e, _e, {
  149488. unique: !1
  149489. })
  149490. }
  149491. ),
  149492. this.isCreatingTable = !1,
  149493. log$q.warn(`Table ${_} opened`),
  149494. c && c(b)
  149495. }
  149496. }
  149497. async add(e) {
  149498. const i = this.tableName()
  149499. , c = (await this.checkAndOpenDatabase()).transaction([i], "readwrite").objectStore(i).add(e);
  149500. return new Promise(function(d, _) {
  149501. c.onsuccess = b=>{
  149502. d(b)
  149503. }
  149504. ,
  149505. c.onerror = b=>{
  149506. var k;
  149507. log$q.error((k = b.srcElement) == null ? void 0 : k.error),
  149508. _(b)
  149509. }
  149510. }
  149511. )
  149512. }
  149513. async put(e) {
  149514. const i = this.tableName()
  149515. , c = (await this.checkAndOpenDatabase()).transaction([i], "readwrite").objectStore(i).put(e);
  149516. return new Promise(function(d, _) {
  149517. c.onsuccess = b=>{
  149518. d(b)
  149519. }
  149520. ,
  149521. c.onerror = b=>{
  149522. var k;
  149523. log$q.error("db put error", (k = b.srcElement) == null ? void 0 : k.error),
  149524. _(b)
  149525. }
  149526. }
  149527. )
  149528. }
  149529. delete(e, i, o) {
  149530. const s = this.tableName();
  149531. this.checkAndOpenDatabase().then(c=>{
  149532. const _ = c.transaction([s], "readwrite").objectStore(s).delete(e);
  149533. _.onsuccess = i,
  149534. _.onerror = o
  149535. }
  149536. )
  149537. }
  149538. update() {
  149539. this.checkAndOpenDatabase().then(e=>{}
  149540. )
  149541. }
  149542. async getAllKeys() {
  149543. const e = this.tableName()
  149544. , i = await this.checkAndOpenDatabase();
  149545. return new Promise((o,s)=>{
  149546. const d = i.transaction([e], "readonly").objectStore(e).getAllKeys();
  149547. d.onsuccess = _=>{
  149548. o(_.target.result)
  149549. }
  149550. ,
  149551. d.onerror = _=>{
  149552. log$q.error("db getAllKeys error", _),
  149553. s(_)
  149554. }
  149555. }
  149556. )
  149557. }
  149558. async query(e, i) {
  149559. const o = this.tableName()
  149560. , s = await this.checkAndOpenDatabase();
  149561. return new Promise((c,d)=>{
  149562. const k = s.transaction([o], "readonly").objectStore(o).index(e).get(i);
  149563. k.onsuccess = function(j) {
  149564. var _e;
  149565. const $ = (_e = j == null ? void 0 : j.target) == null ? void 0 : _e.result;
  149566. c && c($)
  149567. }
  149568. ,
  149569. k.onerror = j=>{
  149570. log$q.error("db query error", j),
  149571. d(j)
  149572. }
  149573. }
  149574. )
  149575. }
  149576. async sleep(e) {
  149577. return new Promise(i=>{
  149578. setTimeout(()=>{
  149579. i("")
  149580. }
  149581. , e)
  149582. }
  149583. )
  149584. }
  149585. }
  149586. class ModelTable extends BaseTable {
  149587. constructor() {
  149588. super("XverseDatabase", 1)
  149589. }
  149590. tableName() {
  149591. return "models"
  149592. }
  149593. index() {
  149594. return ["url"]
  149595. }
  149596. keyPath() {
  149597. return "url"
  149598. }
  149599. }
  149600. const modelTable = new ModelTable;
  149601. var axios$2 = {
  149602. exports: {}
  149603. }
  149604. , bind$2 = function(e, i) {
  149605. return function() {
  149606. for (var s = new Array(arguments.length), c = 0; c < s.length; c++)
  149607. s[c] = arguments[c];
  149608. return e.apply(i, s)
  149609. }
  149610. }
  149611. , bind$1 = bind$2
  149612. , toString = Object.prototype.toString;
  149613. function isArray$1(a) {
  149614. return toString.call(a) === "[object Array]"
  149615. }
  149616. function isUndefined(a) {
  149617. return typeof a == "undefined"
  149618. }
  149619. function isBuffer(a) {
  149620. return a !== null && !isUndefined(a) && a.constructor !== null && !isUndefined(a.constructor) && typeof a.constructor.isBuffer == "function" && a.constructor.isBuffer(a)
  149621. }
  149622. function isArrayBuffer(a) {
  149623. return toString.call(a) === "[object ArrayBuffer]"
  149624. }
  149625. function isFormData(a) {
  149626. return typeof FormData != "undefined" && a instanceof FormData
  149627. }
  149628. function isArrayBufferView(a) {
  149629. var e;
  149630. return typeof ArrayBuffer != "undefined" && ArrayBuffer.isView ? e = ArrayBuffer.isView(a) : e = a && a.buffer && a.buffer instanceof ArrayBuffer,
  149631. e
  149632. }
  149633. function isString(a) {
  149634. return typeof a == "string"
  149635. }
  149636. function isNumber(a) {
  149637. return typeof a == "number"
  149638. }
  149639. function isObject(a) {
  149640. return a !== null && typeof a == "object"
  149641. }
  149642. function isPlainObject(a) {
  149643. if (toString.call(a) !== "[object Object]")
  149644. return !1;
  149645. var e = Object.getPrototypeOf(a);
  149646. return e === null || e === Object.prototype
  149647. }
  149648. function isDate(a) {
  149649. return toString.call(a) === "[object Date]"
  149650. }
  149651. function isFile(a) {
  149652. return toString.call(a) === "[object File]"
  149653. }
  149654. function isBlob(a) {
  149655. return toString.call(a) === "[object Blob]"
  149656. }
  149657. function isFunction$1(a) {
  149658. return toString.call(a) === "[object Function]"
  149659. }
  149660. function isStream(a) {
  149661. return isObject(a) && isFunction$1(a.pipe)
  149662. }
  149663. function isURLSearchParams(a) {
  149664. return typeof URLSearchParams != "undefined" && a instanceof URLSearchParams
  149665. }
  149666. function trim(a) {
  149667. return a.trim ? a.trim() : a.replace(/^\s+|\s+$/g, "")
  149668. }
  149669. function isStandardBrowserEnv() {
  149670. return typeof navigator != "undefined" && (navigator.product === "ReactNative" || navigator.product === "NativeScript" || navigator.product === "NS") ? !1 : typeof window != "undefined" && typeof document != "undefined"
  149671. }
  149672. function forEach(a, e) {
  149673. if (!(a === null || typeof a == "undefined"))
  149674. if (typeof a != "object" && (a = [a]),
  149675. isArray$1(a))
  149676. for (var i = 0, o = a.length; i < o; i++)
  149677. e.call(null, a[i], i, a);
  149678. else
  149679. for (var s in a)
  149680. Object.prototype.hasOwnProperty.call(a, s) && e.call(null, a[s], s, a)
  149681. }
  149682. function merge() {
  149683. var a = {};
  149684. function e(s, c) {
  149685. isPlainObject(a[c]) && isPlainObject(s) ? a[c] = merge(a[c], s) : isPlainObject(s) ? a[c] = merge({}, s) : isArray$1(s) ? a[c] = s.slice() : a[c] = s
  149686. }
  149687. for (var i = 0, o = arguments.length; i < o; i++)
  149688. forEach(arguments[i], e);
  149689. return a
  149690. }
  149691. function extend$2(a, e, i) {
  149692. return forEach(e, function(s, c) {
  149693. i && typeof s == "function" ? a[c] = bind$1(s, i) : a[c] = s
  149694. }),
  149695. a
  149696. }
  149697. function stripBOM(a) {
  149698. return a.charCodeAt(0) === 65279 && (a = a.slice(1)),
  149699. a
  149700. }
  149701. var utils$d = {
  149702. isArray: isArray$1,
  149703. isArrayBuffer,
  149704. isBuffer,
  149705. isFormData,
  149706. isArrayBufferView,
  149707. isString,
  149708. isNumber,
  149709. isObject,
  149710. isPlainObject,
  149711. isUndefined,
  149712. isDate,
  149713. isFile,
  149714. isBlob,
  149715. isFunction: isFunction$1,
  149716. isStream,
  149717. isURLSearchParams,
  149718. isStandardBrowserEnv,
  149719. forEach,
  149720. merge,
  149721. extend: extend$2,
  149722. trim,
  149723. stripBOM
  149724. }
  149725. , utils$c = utils$d;
  149726. function encode(a) {
  149727. return encodeURIComponent(a).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+").replace(/%5B/gi, "[").replace(/%5D/gi, "]")
  149728. }
  149729. var buildURL$2 = function(e, i, o) {
  149730. if (!i)
  149731. return e;
  149732. var s;
  149733. if (o)
  149734. s = o(i);
  149735. else if (utils$c.isURLSearchParams(i))
  149736. s = i.toString();
  149737. else {
  149738. var c = [];
  149739. utils$c.forEach(i, function(b, k) {
  149740. b === null || typeof b == "undefined" || (utils$c.isArray(b) ? k = k + "[]" : b = [b],
  149741. utils$c.forEach(b, function($) {
  149742. utils$c.isDate($) ? $ = $.toISOString() : utils$c.isObject($) && ($ = JSON.stringify($)),
  149743. c.push(encode(k) + "=" + encode($))
  149744. }))
  149745. }),
  149746. s = c.join("&")
  149747. }
  149748. if (s) {
  149749. var d = e.indexOf("#");
  149750. d !== -1 && (e = e.slice(0, d)),
  149751. e += (e.indexOf("?") === -1 ? "?" : "&") + s
  149752. }
  149753. return e
  149754. }
  149755. , utils$b = utils$d;
  149756. function InterceptorManager$1() {
  149757. this.handlers = []
  149758. }
  149759. InterceptorManager$1.prototype.use = function(e, i, o) {
  149760. return this.handlers.push({
  149761. fulfilled: e,
  149762. rejected: i,
  149763. synchronous: o ? o.synchronous : !1,
  149764. runWhen: o ? o.runWhen : null
  149765. }),
  149766. this.handlers.length - 1
  149767. }
  149768. ;
  149769. InterceptorManager$1.prototype.eject = function(e) {
  149770. this.handlers[e] && (this.handlers[e] = null)
  149771. }
  149772. ;
  149773. InterceptorManager$1.prototype.forEach = function(e) {
  149774. utils$b.forEach(this.handlers, function(o) {
  149775. o !== null && e(o)
  149776. })
  149777. }
  149778. ;
  149779. var InterceptorManager_1 = InterceptorManager$1
  149780. , utils$a = utils$d
  149781. , normalizeHeaderName$1 = function(e, i) {
  149782. utils$a.forEach(e, function(s, c) {
  149783. c !== i && c.toUpperCase() === i.toUpperCase() && (e[i] = s,
  149784. delete e[c])
  149785. })
  149786. }
  149787. , enhanceError$2 = function(e, i, o, s, c) {
  149788. return e.config = i,
  149789. o && (e.code = o),
  149790. e.request = s,
  149791. e.response = c,
  149792. e.isAxiosError = !0,
  149793. e.toJSON = function() {
  149794. return {
  149795. message: this.message,
  149796. name: this.name,
  149797. description: this.description,
  149798. number: this.number,
  149799. fileName: this.fileName,
  149800. lineNumber: this.lineNumber,
  149801. columnNumber: this.columnNumber,
  149802. stack: this.stack,
  149803. config: this.config,
  149804. code: this.code,
  149805. status: this.response && this.response.status ? this.response.status : null
  149806. }
  149807. }
  149808. ,
  149809. e
  149810. }
  149811. , enhanceError$1 = enhanceError$2
  149812. , createError$2 = function(e, i, o, s, c) {
  149813. var d = new Error(e);
  149814. return enhanceError$1(d, i, o, s, c)
  149815. }
  149816. , createError$1 = createError$2
  149817. , settle$1 = function(e, i, o) {
  149818. var s = o.config.validateStatus;
  149819. !o.status || !s || s(o.status) ? e(o) : i(createError$1("Request failed with status code " + o.status, o.config, null, o.request, o))
  149820. }
  149821. , utils$9 = utils$d
  149822. , cookies$1 = utils$9.isStandardBrowserEnv() ? function() {
  149823. return {
  149824. write: function(i, o, s, c, d, _) {
  149825. var b = [];
  149826. b.push(i + "=" + encodeURIComponent(o)),
  149827. utils$9.isNumber(s) && b.push("expires=" + new Date(s).toGMTString()),
  149828. utils$9.isString(c) && b.push("path=" + c),
  149829. utils$9.isString(d) && b.push("domain=" + d),
  149830. _ === !0 && b.push("secure"),
  149831. document.cookie = b.join("; ")
  149832. },
  149833. read: function(i) {
  149834. var o = document.cookie.match(new RegExp("(^|;\\s*)(" + i + ")=([^;]*)"));
  149835. return o ? decodeURIComponent(o[3]) : null
  149836. },
  149837. remove: function(i) {
  149838. this.write(i, "", Date.now() - 864e5)
  149839. }
  149840. }
  149841. }() : function() {
  149842. return {
  149843. write: function() {},
  149844. read: function() {
  149845. return null
  149846. },
  149847. remove: function() {}
  149848. }
  149849. }()
  149850. , isAbsoluteURL$1 = function(e) {
  149851. return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)
  149852. }
  149853. , combineURLs$1 = function(e, i) {
  149854. return i ? e.replace(/\/+$/, "") + "/" + i.replace(/^\/+/, "") : e
  149855. }
  149856. , isAbsoluteURL = isAbsoluteURL$1
  149857. , combineURLs = combineURLs$1
  149858. , buildFullPath$1 = function(e, i) {
  149859. return e && !isAbsoluteURL(i) ? combineURLs(e, i) : i
  149860. }
  149861. , utils$8 = utils$d
  149862. , ignoreDuplicateOf = ["age", "authorization", "content-length", "content-type", "etag", "expires", "from", "host", "if-modified-since", "if-unmodified-since", "last-modified", "location", "max-forwards", "proxy-authorization", "referer", "retry-after", "user-agent"]
  149863. , parseHeaders$1 = function(e) {
  149864. var i = {}, o, s, c;
  149865. return e && utils$8.forEach(e.split(`
  149866. `), function(_) {
  149867. if (c = _.indexOf(":"),
  149868. o = utils$8.trim(_.substr(0, c)).toLowerCase(),
  149869. s = utils$8.trim(_.substr(c + 1)),
  149870. o) {
  149871. if (i[o] && ignoreDuplicateOf.indexOf(o) >= 0)
  149872. return;
  149873. o === "set-cookie" ? i[o] = (i[o] ? i[o] : []).concat([s]) : i[o] = i[o] ? i[o] + ", " + s : s
  149874. }
  149875. }),
  149876. i
  149877. }
  149878. , utils$7 = utils$d
  149879. , isURLSameOrigin$1 = utils$7.isStandardBrowserEnv() ? function() {
  149880. var e = /(msie|trident)/i.test(navigator.userAgent), i = document.createElement("a"), o;
  149881. function s(c) {
  149882. var d = c;
  149883. return e && (i.setAttribute("href", d),
  149884. d = i.href),
  149885. i.setAttribute("href", d),
  149886. {
  149887. href: i.href,
  149888. protocol: i.protocol ? i.protocol.replace(/:$/, "") : "",
  149889. host: i.host,
  149890. search: i.search ? i.search.replace(/^\?/, "") : "",
  149891. hash: i.hash ? i.hash.replace(/^#/, "") : "",
  149892. hostname: i.hostname,
  149893. port: i.port,
  149894. pathname: i.pathname.charAt(0) === "/" ? i.pathname : "/" + i.pathname
  149895. }
  149896. }
  149897. return o = s(window.location.href),
  149898. function(d) {
  149899. var _ = utils$7.isString(d) ? s(d) : d;
  149900. return _.protocol === o.protocol && _.host === o.host
  149901. }
  149902. }() : function() {
  149903. return function() {
  149904. return !0
  149905. }
  149906. }();
  149907. function Cancel$3(a) {
  149908. this.message = a
  149909. }
  149910. Cancel$3.prototype.toString = function() {
  149911. return "Cancel" + (this.message ? ": " + this.message : "")
  149912. }
  149913. ;
  149914. Cancel$3.prototype.__CANCEL__ = !0;
  149915. var Cancel_1 = Cancel$3
  149916. , utils$6 = utils$d
  149917. , settle = settle$1
  149918. , cookies = cookies$1
  149919. , buildURL$1 = buildURL$2
  149920. , buildFullPath = buildFullPath$1
  149921. , parseHeaders = parseHeaders$1
  149922. , isURLSameOrigin = isURLSameOrigin$1
  149923. , createError = createError$2
  149924. , defaults$4 = defaults_1
  149925. , Cancel$2 = Cancel_1
  149926. , xhr = function(e) {
  149927. return new Promise(function(o, s) {
  149928. var c = e.data, d = e.headers, _ = e.responseType, b;
  149929. function k() {
  149930. e.cancelToken && e.cancelToken.unsubscribe(b),
  149931. e.signal && e.signal.removeEventListener("abort", b)
  149932. }
  149933. utils$6.isFormData(c) && delete d["Content-Type"];
  149934. var j = new XMLHttpRequest;
  149935. if (e.auth) {
  149936. var $ = e.auth.username || ""
  149937. , _e = e.auth.password ? unescape(encodeURIComponent(e.auth.password)) : "";
  149938. d.Authorization = "Basic " + btoa($ + ":" + _e)
  149939. }
  149940. var et = buildFullPath(e.baseURL, e.url);
  149941. j.open(e.method.toUpperCase(), buildURL$1(et, e.params, e.paramsSerializer), !0),
  149942. j.timeout = e.timeout;
  149943. function tt() {
  149944. if (!!j) {
  149945. var it = "getAllResponseHeaders"in j ? parseHeaders(j.getAllResponseHeaders()) : null
  149946. , nt = !_ || _ === "text" || _ === "json" ? j.responseText : j.response
  149947. , ot = {
  149948. data: nt,
  149949. status: j.status,
  149950. statusText: j.statusText,
  149951. headers: it,
  149952. config: e,
  149953. request: j
  149954. };
  149955. settle(function(st) {
  149956. o(st),
  149957. k()
  149958. }, function(st) {
  149959. s(st),
  149960. k()
  149961. }, ot),
  149962. j = null
  149963. }
  149964. }
  149965. if ("onloadend"in j ? j.onloadend = tt : j.onreadystatechange = function() {
  149966. !j || j.readyState !== 4 || j.status === 0 && !(j.responseURL && j.responseURL.indexOf("file:") === 0) || setTimeout(tt)
  149967. }
  149968. ,
  149969. j.onabort = function() {
  149970. !j || (s(createError("Request aborted", e, "ECONNABORTED", j)),
  149971. j = null)
  149972. }
  149973. ,
  149974. j.onerror = function() {
  149975. s(createError("Network Error", e, null, j)),
  149976. j = null
  149977. }
  149978. ,
  149979. j.ontimeout = function() {
  149980. var nt = e.timeout ? "timeout of " + e.timeout + "ms exceeded" : "timeout exceeded"
  149981. , ot = e.transitional || defaults$4.transitional;
  149982. e.timeoutErrorMessage && (nt = e.timeoutErrorMessage),
  149983. s(createError(nt, e, ot.clarifyTimeoutError ? "ETIMEDOUT" : "ECONNABORTED", j)),
  149984. j = null
  149985. }
  149986. ,
  149987. utils$6.isStandardBrowserEnv()) {
  149988. var rt = (e.withCredentials || isURLSameOrigin(et)) && e.xsrfCookieName ? cookies.read(e.xsrfCookieName) : void 0;
  149989. rt && (d[e.xsrfHeaderName] = rt)
  149990. }
  149991. "setRequestHeader"in j && utils$6.forEach(d, function(nt, ot) {
  149992. typeof c == "undefined" && ot.toLowerCase() === "content-type" ? delete d[ot] : j.setRequestHeader(ot, nt)
  149993. }),
  149994. utils$6.isUndefined(e.withCredentials) || (j.withCredentials = !!e.withCredentials),
  149995. _ && _ !== "json" && (j.responseType = e.responseType),
  149996. typeof e.onDownloadProgress == "function" && j.addEventListener("progress", e.onDownloadProgress),
  149997. typeof e.onUploadProgress == "function" && j.upload && j.upload.addEventListener("progress", e.onUploadProgress),
  149998. (e.cancelToken || e.signal) && (b = function(it) {
  149999. !j || (s(!it || it && it.type ? new Cancel$2("canceled") : it),
  150000. j.abort(),
  150001. j = null)
  150002. }
  150003. ,
  150004. e.cancelToken && e.cancelToken.subscribe(b),
  150005. e.signal && (e.signal.aborted ? b() : e.signal.addEventListener("abort", b))),
  150006. c || (c = null),
  150007. j.send(c)
  150008. }
  150009. )
  150010. }
  150011. , utils$5 = utils$d
  150012. , normalizeHeaderName = normalizeHeaderName$1
  150013. , enhanceError = enhanceError$2
  150014. , DEFAULT_CONTENT_TYPE = {
  150015. "Content-Type": "application/x-www-form-urlencoded"
  150016. };
  150017. function setContentTypeIfUnset(a, e) {
  150018. !utils$5.isUndefined(a) && utils$5.isUndefined(a["Content-Type"]) && (a["Content-Type"] = e)
  150019. }
  150020. function getDefaultAdapter() {
  150021. var a;
  150022. return (typeof XMLHttpRequest != "undefined" || typeof process != "undefined" && Object.prototype.toString.call(process) === "[object process]") && (a = xhr),
  150023. a
  150024. }
  150025. function stringifySafely(a, e, i) {
  150026. if (utils$5.isString(a))
  150027. try {
  150028. return (e || JSON.parse)(a),
  150029. utils$5.trim(a)
  150030. } catch (o) {
  150031. if (o.name !== "SyntaxError")
  150032. throw o
  150033. }
  150034. return (i || JSON.stringify)(a)
  150035. }
  150036. var defaults$3 = {
  150037. transitional: {
  150038. silentJSONParsing: !0,
  150039. forcedJSONParsing: !0,
  150040. clarifyTimeoutError: !1
  150041. },
  150042. adapter: getDefaultAdapter(),
  150043. transformRequest: [function(e, i) {
  150044. return normalizeHeaderName(i, "Accept"),
  150045. normalizeHeaderName(i, "Content-Type"),
  150046. utils$5.isFormData(e) || utils$5.isArrayBuffer(e) || utils$5.isBuffer(e) || utils$5.isStream(e) || utils$5.isFile(e) || utils$5.isBlob(e) ? e : utils$5.isArrayBufferView(e) ? e.buffer : utils$5.isURLSearchParams(e) ? (setContentTypeIfUnset(i, "application/x-www-form-urlencoded;charset=utf-8"),
  150047. e.toString()) : utils$5.isObject(e) || i && i["Content-Type"] === "application/json" ? (setContentTypeIfUnset(i, "application/json"),
  150048. stringifySafely(e)) : e
  150049. }
  150050. ],
  150051. transformResponse: [function(e) {
  150052. var i = this.transitional || defaults$3.transitional
  150053. , o = i && i.silentJSONParsing
  150054. , s = i && i.forcedJSONParsing
  150055. , c = !o && this.responseType === "json";
  150056. if (c || s && utils$5.isString(e) && e.length)
  150057. try {
  150058. return JSON.parse(e)
  150059. } catch (d) {
  150060. if (c)
  150061. throw d.name === "SyntaxError" ? enhanceError(d, this, "E_JSON_PARSE") : d
  150062. }
  150063. return e
  150064. }
  150065. ],
  150066. timeout: 0,
  150067. xsrfCookieName: "XSRF-TOKEN",
  150068. xsrfHeaderName: "X-XSRF-TOKEN",
  150069. maxContentLength: -1,
  150070. maxBodyLength: -1,
  150071. validateStatus: function(e) {
  150072. return e >= 200 && e < 300
  150073. },
  150074. headers: {
  150075. common: {
  150076. Accept: "application/json, text/plain, */*"
  150077. }
  150078. }
  150079. };
  150080. utils$5.forEach(["delete", "get", "head"], function(e) {
  150081. defaults$3.headers[e] = {}
  150082. });
  150083. utils$5.forEach(["post", "put", "patch"], function(e) {
  150084. defaults$3.headers[e] = utils$5.merge(DEFAULT_CONTENT_TYPE)
  150085. });
  150086. var defaults_1 = defaults$3
  150087. , utils$4 = utils$d
  150088. , defaults$2 = defaults_1
  150089. , transformData$1 = function(e, i, o) {
  150090. var s = this || defaults$2;
  150091. return utils$4.forEach(o, function(d) {
  150092. e = d.call(s, e, i)
  150093. }),
  150094. e
  150095. }
  150096. , isCancel$1 = function(e) {
  150097. return !!(e && e.__CANCEL__)
  150098. }
  150099. , utils$3 = utils$d
  150100. , transformData = transformData$1
  150101. , isCancel = isCancel$1
  150102. , defaults$1 = defaults_1
  150103. , Cancel$1 = Cancel_1;
  150104. function throwIfCancellationRequested(a) {
  150105. if (a.cancelToken && a.cancelToken.throwIfRequested(),
  150106. a.signal && a.signal.aborted)
  150107. throw new Cancel$1("canceled")
  150108. }
  150109. var dispatchRequest$1 = function(e) {
  150110. throwIfCancellationRequested(e),
  150111. e.headers = e.headers || {},
  150112. e.data = transformData.call(e, e.data, e.headers, e.transformRequest),
  150113. e.headers = utils$3.merge(e.headers.common || {}, e.headers[e.method] || {}, e.headers),
  150114. utils$3.forEach(["delete", "get", "head", "post", "put", "patch", "common"], function(s) {
  150115. delete e.headers[s]
  150116. });
  150117. var i = e.adapter || defaults$1.adapter;
  150118. return i(e).then(function(s) {
  150119. return throwIfCancellationRequested(e),
  150120. s.data = transformData.call(e, s.data, s.headers, e.transformResponse),
  150121. s
  150122. }, function(s) {
  150123. return isCancel(s) || (throwIfCancellationRequested(e),
  150124. s && s.response && (s.response.data = transformData.call(e, s.response.data, s.response.headers, e.transformResponse))),
  150125. Promise.reject(s)
  150126. })
  150127. }
  150128. , utils$2 = utils$d
  150129. , mergeConfig$2 = function(e, i) {
  150130. i = i || {};
  150131. var o = {};
  150132. function s(j, $) {
  150133. return utils$2.isPlainObject(j) && utils$2.isPlainObject($) ? utils$2.merge(j, $) : utils$2.isPlainObject($) ? utils$2.merge({}, $) : utils$2.isArray($) ? $.slice() : $
  150134. }
  150135. function c(j) {
  150136. if (utils$2.isUndefined(i[j])) {
  150137. if (!utils$2.isUndefined(e[j]))
  150138. return s(void 0, e[j])
  150139. } else
  150140. return s(e[j], i[j])
  150141. }
  150142. function d(j) {
  150143. if (!utils$2.isUndefined(i[j]))
  150144. return s(void 0, i[j])
  150145. }
  150146. function _(j) {
  150147. if (utils$2.isUndefined(i[j])) {
  150148. if (!utils$2.isUndefined(e[j]))
  150149. return s(void 0, e[j])
  150150. } else
  150151. return s(void 0, i[j])
  150152. }
  150153. function b(j) {
  150154. if (j in i)
  150155. return s(e[j], i[j]);
  150156. if (j in e)
  150157. return s(void 0, e[j])
  150158. }
  150159. var k = {
  150160. url: d,
  150161. method: d,
  150162. data: d,
  150163. baseURL: _,
  150164. transformRequest: _,
  150165. transformResponse: _,
  150166. paramsSerializer: _,
  150167. timeout: _,
  150168. timeoutMessage: _,
  150169. withCredentials: _,
  150170. adapter: _,
  150171. responseType: _,
  150172. xsrfCookieName: _,
  150173. xsrfHeaderName: _,
  150174. onUploadProgress: _,
  150175. onDownloadProgress: _,
  150176. decompress: _,
  150177. maxContentLength: _,
  150178. maxBodyLength: _,
  150179. transport: _,
  150180. httpAgent: _,
  150181. httpsAgent: _,
  150182. cancelToken: _,
  150183. socketPath: _,
  150184. responseEncoding: _,
  150185. validateStatus: b
  150186. };
  150187. return utils$2.forEach(Object.keys(e).concat(Object.keys(i)), function($) {
  150188. var _e = k[$] || c
  150189. , et = _e($);
  150190. utils$2.isUndefined(et) && _e !== b || (o[$] = et)
  150191. }),
  150192. o
  150193. }
  150194. , data = {
  150195. version: "0.24.0"
  150196. }
  150197. , VERSION = data.version
  150198. , validators$1 = {};
  150199. ["object", "boolean", "number", "function", "string", "symbol"].forEach(function(a, e) {
  150200. validators$1[a] = function(o) {
  150201. return typeof o === a || "a" + (e < 1 ? "n " : " ") + a
  150202. }
  150203. });
  150204. var deprecatedWarnings = {};
  150205. validators$1.transitional = function(e, i, o) {
  150206. function s(c, d) {
  150207. return "[Axios v" + VERSION + "] Transitional option '" + c + "'" + d + (o ? ". " + o : "")
  150208. }
  150209. return function(c, d, _) {
  150210. if (e === !1)
  150211. throw new Error(s(d, " has been removed" + (i ? " in " + i : "")));
  150212. return i && !deprecatedWarnings[d] && (deprecatedWarnings[d] = !0,
  150213. console.warn(s(d, " has been deprecated since v" + i + " and will be removed in the near future"))),
  150214. e ? e(c, d, _) : !0
  150215. }
  150216. }
  150217. ;
  150218. function assertOptions(a, e, i) {
  150219. if (typeof a != "object")
  150220. throw new TypeError("options must be an object");
  150221. for (var o = Object.keys(a), s = o.length; s-- > 0; ) {
  150222. var c = o[s]
  150223. , d = e[c];
  150224. if (d) {
  150225. var _ = a[c]
  150226. , b = _ === void 0 || d(_, c, a);
  150227. if (b !== !0)
  150228. throw new TypeError("option " + c + " must be " + b);
  150229. continue
  150230. }
  150231. if (i !== !0)
  150232. throw Error("Unknown option " + c)
  150233. }
  150234. }
  150235. var validator$1 = {
  150236. assertOptions,
  150237. validators: validators$1
  150238. }
  150239. , utils$1 = utils$d
  150240. , buildURL = buildURL$2
  150241. , InterceptorManager = InterceptorManager_1
  150242. , dispatchRequest = dispatchRequest$1
  150243. , mergeConfig$1 = mergeConfig$2
  150244. , validator = validator$1
  150245. , validators = validator.validators;
  150246. function Axios$1(a) {
  150247. this.defaults = a,
  150248. this.interceptors = {
  150249. request: new InterceptorManager,
  150250. response: new InterceptorManager
  150251. }
  150252. }
  150253. Axios$1.prototype.request = function(e) {
  150254. typeof e == "string" ? (e = arguments[1] || {},
  150255. e.url = arguments[0]) : e = e || {},
  150256. e = mergeConfig$1(this.defaults, e),
  150257. e.method ? e.method = e.method.toLowerCase() : this.defaults.method ? e.method = this.defaults.method.toLowerCase() : e.method = "get";
  150258. var i = e.transitional;
  150259. i !== void 0 && validator.assertOptions(i, {
  150260. silentJSONParsing: validators.transitional(validators.boolean),
  150261. forcedJSONParsing: validators.transitional(validators.boolean),
  150262. clarifyTimeoutError: validators.transitional(validators.boolean)
  150263. }, !1);
  150264. var o = []
  150265. , s = !0;
  150266. this.interceptors.request.forEach(function(_e) {
  150267. typeof _e.runWhen == "function" && _e.runWhen(e) === !1 || (s = s && _e.synchronous,
  150268. o.unshift(_e.fulfilled, _e.rejected))
  150269. });
  150270. var c = [];
  150271. this.interceptors.response.forEach(function(_e) {
  150272. c.push(_e.fulfilled, _e.rejected)
  150273. });
  150274. var d;
  150275. if (!s) {
  150276. var _ = [dispatchRequest, void 0];
  150277. for (Array.prototype.unshift.apply(_, o),
  150278. _ = _.concat(c),
  150279. d = Promise.resolve(e); _.length; )
  150280. d = d.then(_.shift(), _.shift());
  150281. return d
  150282. }
  150283. for (var b = e; o.length; ) {
  150284. var k = o.shift()
  150285. , j = o.shift();
  150286. try {
  150287. b = k(b)
  150288. } catch ($) {
  150289. j($);
  150290. break
  150291. }
  150292. }
  150293. try {
  150294. d = dispatchRequest(b)
  150295. } catch ($) {
  150296. return Promise.reject($)
  150297. }
  150298. for (; c.length; )
  150299. d = d.then(c.shift(), c.shift());
  150300. return d
  150301. }
  150302. ;
  150303. Axios$1.prototype.getUri = function(e) {
  150304. return e = mergeConfig$1(this.defaults, e),
  150305. buildURL(e.url, e.params, e.paramsSerializer).replace(/^\?/, "")
  150306. }
  150307. ;
  150308. utils$1.forEach(["delete", "get", "head", "options"], function(e) {
  150309. Axios$1.prototype[e] = function(i, o) {
  150310. return this.request(mergeConfig$1(o || {}, {
  150311. method: e,
  150312. url: i,
  150313. data: (o || {}).data
  150314. }))
  150315. }
  150316. });
  150317. utils$1.forEach(["post", "put", "patch"], function(e) {
  150318. Axios$1.prototype[e] = function(i, o, s) {
  150319. return this.request(mergeConfig$1(s || {}, {
  150320. method: e,
  150321. url: i,
  150322. data: o
  150323. }))
  150324. }
  150325. });
  150326. var Axios_1 = Axios$1
  150327. , Cancel = Cancel_1;
  150328. function CancelToken(a) {
  150329. if (typeof a != "function")
  150330. throw new TypeError("executor must be a function.");
  150331. var e;
  150332. this.promise = new Promise(function(s) {
  150333. e = s
  150334. }
  150335. );
  150336. var i = this;
  150337. this.promise.then(function(o) {
  150338. if (!!i._listeners) {
  150339. var s, c = i._listeners.length;
  150340. for (s = 0; s < c; s++)
  150341. i._listeners[s](o);
  150342. i._listeners = null
  150343. }
  150344. }),
  150345. this.promise.then = function(o) {
  150346. var s, c = new Promise(function(d) {
  150347. i.subscribe(d),
  150348. s = d
  150349. }
  150350. ).then(o);
  150351. return c.cancel = function() {
  150352. i.unsubscribe(s)
  150353. }
  150354. ,
  150355. c
  150356. }
  150357. ,
  150358. a(function(s) {
  150359. i.reason || (i.reason = new Cancel(s),
  150360. e(i.reason))
  150361. })
  150362. }
  150363. CancelToken.prototype.throwIfRequested = function() {
  150364. if (this.reason)
  150365. throw this.reason
  150366. }
  150367. ;
  150368. CancelToken.prototype.subscribe = function(e) {
  150369. if (this.reason) {
  150370. e(this.reason);
  150371. return
  150372. }
  150373. this._listeners ? this._listeners.push(e) : this._listeners = [e]
  150374. }
  150375. ;
  150376. CancelToken.prototype.unsubscribe = function(e) {
  150377. if (!!this._listeners) {
  150378. var i = this._listeners.indexOf(e);
  150379. i !== -1 && this._listeners.splice(i, 1)
  150380. }
  150381. }
  150382. ;
  150383. CancelToken.source = function() {
  150384. var e, i = new CancelToken(function(s) {
  150385. e = s
  150386. }
  150387. );
  150388. return {
  150389. token: i,
  150390. cancel: e
  150391. }
  150392. }
  150393. ;
  150394. var CancelToken_1 = CancelToken
  150395. , spread = function(e) {
  150396. return function(o) {
  150397. return e.apply(null, o)
  150398. }
  150399. }
  150400. , isAxiosError = function(e) {
  150401. return typeof e == "object" && e.isAxiosError === !0
  150402. }
  150403. , utils = utils$d
  150404. , bind = bind$2
  150405. , Axios = Axios_1
  150406. , mergeConfig = mergeConfig$2
  150407. , defaults = defaults_1;
  150408. function createInstance(a) {
  150409. var e = new Axios(a)
  150410. , i = bind(Axios.prototype.request, e);
  150411. return utils.extend(i, Axios.prototype, e),
  150412. utils.extend(i, e),
  150413. i.create = function(s) {
  150414. return createInstance(mergeConfig(a, s))
  150415. }
  150416. ,
  150417. i
  150418. }
  150419. var axios$1 = createInstance(defaults);
  150420. axios$1.Axios = Axios;
  150421. axios$1.Cancel = Cancel_1;
  150422. axios$1.CancelToken = CancelToken_1;
  150423. axios$1.isCancel = isCancel$1;
  150424. axios$1.VERSION = data.version;
  150425. axios$1.all = function(e) {
  150426. return Promise.all(e)
  150427. }
  150428. ;
  150429. axios$1.spread = spread;
  150430. axios$1.isAxiosError = isAxiosError;
  150431. axios$2.exports = axios$1;
  150432. axios$2.exports.default = axios$1;
  150433. var axios = axios$2.exports;
  150434. const isFunction = a=>typeof a == "function";
  150435. class AxiosCanceler {
  150436. constructor() {
  150437. Tt(this, "pendingMap", new Map)
  150438. }
  150439. addPending(e) {
  150440. return new axios.CancelToken(i=>{
  150441. this.pendingMap.has(e) || this.pendingMap.set(e, i)
  150442. }
  150443. )
  150444. }
  150445. removeAllPending() {
  150446. this.pendingMap.forEach(e=>{
  150447. e && isFunction(e) && e()
  150448. }
  150449. ),
  150450. this.pendingMap.clear()
  150451. }
  150452. removePending(e) {
  150453. if (this.pendingMap.has(e)) {
  150454. const i = this.pendingMap.get(e);
  150455. i && i(e),
  150456. this.pendingMap.delete(e)
  150457. }
  150458. }
  150459. removeCancelToken(e) {
  150460. this.pendingMap.has(e) && this.pendingMap.delete(e)
  150461. }
  150462. reset() {
  150463. this.pendingMap = new Map
  150464. }
  150465. }
  150466. const log$p = new Logger("http");
  150467. class Http$1 {
  150468. constructor() {
  150469. Tt(this, "instatnce");
  150470. Tt(this, "canceler");
  150471. Tt(this, "requestParams", e=>$t({}, e.params));
  150472. Tt(this, "requestConstant", ()=>({
  150473. x_nounce: this.randomString(),
  150474. x_timestamp: new Date().getTime(),
  150475. x_os: "web"
  150476. }));
  150477. this.instatnce = axios.create(),
  150478. this.canceler = new AxiosCanceler
  150479. }
  150480. get(e) {
  150481. return this.request(Zt($t({}, e), {
  150482. method: "GET"
  150483. }))
  150484. }
  150485. post(e) {
  150486. return this.request(Zt($t({}, e), {
  150487. method: "POST"
  150488. }))
  150489. }
  150490. request(e) {
  150491. const {url: i, timeout: o=1e4, method: s, key: c, beforeRequest: d, responseType: _, data: b} = e;
  150492. let {retry: k=0} = e;
  150493. const j = this.transformUrlHook(i)
  150494. , $ = this.canceler.addPending(i);
  150495. d && isFunction(d) && d(e);
  150496. const _e = this.requestParams(e);
  150497. let et = {
  150498. url: j,
  150499. method: s,
  150500. timeout: o,
  150501. cancelToken: $,
  150502. responseType: _,
  150503. params: _e
  150504. };
  150505. s === "POST" && (et = $t({
  150506. data: b
  150507. }, et));
  150508. const tt = Date.now()
  150509. , rt = ()=>this.instatnce.request(et).then(it=>(c && log$p.infoAndReportMeasurement({
  150510. metric: "http",
  150511. startTime: tt,
  150512. extra: i,
  150513. group: "http",
  150514. tag: c
  150515. }),
  150516. this.canceler.removeCancelToken(i),
  150517. it)).catch(it=>{
  150518. const nt = axios.isCancel(it);
  150519. return k > 0 && !nt ? (k--,
  150520. log$p.warn(`request ${i} retry, left retry count`, k),
  150521. rt()) : (log$p.infoAndReportMeasurement({
  150522. metric: "http",
  150523. startTime: tt,
  150524. error: it,
  150525. extra: {
  150526. url: i,
  150527. isCanceled: nt
  150528. },
  150529. tag: c,
  150530. group: "http"
  150531. }),
  150532. this.canceler.removeCancelToken(i),
  150533. Promise.reject(it))
  150534. }
  150535. );
  150536. return rt()
  150537. }
  150538. transformUrlHook(e) {
  150539. return e
  150540. }
  150541. randomString() {
  150542. let e = "";
  150543. const i = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
  150544. , o = i.length;
  150545. for (let s = 0; s < 8; s++)
  150546. e += i.charAt(Math.floor(Math.random() * o));
  150547. return e
  150548. }
  150549. }
  150550. const http$1 = new Http$1
  150551. , log$o = new Logger("AssetsStorage");
  150552. class AssetsStorage {
  150553. static async readOrRequest(e, i) {
  150554. let o = null;
  150555. try {
  150556. o = await modelTable.query("url", e)
  150557. } catch (c) {
  150558. return log$o.debug(c),
  150559. log$o.warn("cache query error", e),
  150560. Promise.resolve(e)
  150561. }
  150562. let s = o && o.model;
  150563. return s || (s = await this.requestAndPut({
  150564. url: e,
  150565. responseType: "blob",
  150566. retry: 2
  150567. })),
  150568. typeof s == "string" && (s = this.dataURItoBlob(s)),
  150569. i && i.returnBlob ? s : URL.createObjectURL(s)
  150570. }
  150571. static async requestAndPut(e) {
  150572. try {
  150573. const i = await http$1.get(e);
  150574. return await modelTable.put({
  150575. url: e.url,
  150576. model: i.data
  150577. }),
  150578. i.data
  150579. } catch {
  150580. return Promise.reject(new InternalError("request and put error"))
  150581. }
  150582. }
  150583. }
  150584. Tt(AssetsStorage, "dataURItoBlob", e=>{
  150585. let i;
  150586. e.split(",")[0].indexOf("base64") >= 0 ? i = atob(e.split(",")[1]) : i = unescape(e.split(",")[1]);
  150587. const o = e.split(",")[0].split(":")[1].split(";")[0]
  150588. , s = new Uint8Array(i.length);
  150589. for (let d = 0; d < i.length; d++)
  150590. s[d] = i.charCodeAt(d);
  150591. return new Blob([s],{
  150592. type: o
  150593. })
  150594. }
  150595. );
  150596. const fr = class {
  150597. static _GetStorage() {
  150598. try {
  150599. return localStorage.setItem("test", ""),
  150600. localStorage.removeItem("test"),
  150601. localStorage
  150602. } catch {
  150603. const e = {};
  150604. return {
  150605. getItem: i=>{
  150606. const o = e[i];
  150607. return o === void 0 ? null : o
  150608. }
  150609. ,
  150610. setItem: (i,o)=>{
  150611. e[i] = o
  150612. }
  150613. }
  150614. }
  150615. }
  150616. static ReadString(e, i) {
  150617. const o = this._Storage.getItem(e);
  150618. return o !== null ? o : i
  150619. }
  150620. static WriteString(e, i) {
  150621. this._Storage.setItem(e, i)
  150622. }
  150623. static ReadBoolean(e, i) {
  150624. const o = this._Storage.getItem(e);
  150625. return o !== null ? o === "true" : i
  150626. }
  150627. static WriteBoolean(e, i) {
  150628. this._Storage.setItem(e, i ? "true" : "false")
  150629. }
  150630. static ReadNumber(e, i) {
  150631. const o = this._Storage.getItem(e);
  150632. return o !== null ? parseFloat(o) : i
  150633. }
  150634. static WriteNumber(e, i) {
  150635. this._Storage.setItem(e, i.toString())
  150636. }
  150637. }
  150638. ;
  150639. let DataStorage = fr;
  150640. Tt(DataStorage, "_Storage", fr._GetStorage());
  150641. const urlMap = new Map
  150642. , urlTransformer = async(a,e=!1)=>typeof a != "string" ? (console.warn("url transformer error", a),
  150643. a) : a.startsWith("blob:") ? a : e ? AssetsStorage.readOrRequest(a, {
  150644. returnBlob: !0
  150645. }) : urlMap.has(a) ? urlMap.get(a) : AssetsStorage.readOrRequest(a).then(i=>(urlMap.set(a, i),
  150646. i));
  150647. var workerSourceCode = `onmessage = function (event) {
  150648. const data = event.data
  150649. if (!data) return
  150650. if (data.type === 'start') {
  150651. const startTime = Date.now()
  150652. const request = new XMLHttpRequest()
  150653. request.open('GET', data.url)
  150654. try {
  150655. request.send()
  150656. } catch (error) {
  150657. console.error(error)
  150658. }
  150659. request.addEventListener('readystatechange', () => {
  150660. if (request.readyState == 4) {
  150661. if (request.status == 200) {
  150662. postMessage(Date.now() - startTime)
  150663. }
  150664. }
  150665. })
  150666. }
  150667. }
  150668. `;
  150669. const log$n = new Logger("detect");
  150670. let worker = null;
  150671. function checkNetworkQuality(a) {
  150672. if (!a)
  150673. return;
  150674. const e = Date.now();
  150675. if (pingOthers("https://www.baidu.com", function(i, o) {
  150676. log$n.infoAndReportMeasurement({
  150677. metric: "baiduRtt",
  150678. group: "http",
  150679. value: o,
  150680. startTime: e
  150681. })
  150682. }),
  150683. !worker) {
  150684. const i = new Blob([workerSourceCode],{
  150685. type: "application/javascript"
  150686. });
  150687. worker = new Worker(URL.createObjectURL(i)),
  150688. worker.onmessage = function(o) {
  150689. log$n.infoAndReportMeasurement({
  150690. metric: "workerRtt",
  150691. group: "http",
  150692. startTime: e,
  150693. value: o.data
  150694. })
  150695. }
  150696. }
  150697. }
  150698. function pingOthers(a, e) {
  150699. let i = !1;
  150700. const o = new Image;
  150701. o.onload = c,
  150702. o.onerror = d;
  150703. const s = Date.now();
  150704. function c(b) {
  150705. i = !0,
  150706. _()
  150707. }
  150708. function d(b) {}
  150709. function _() {
  150710. const b = Date.now() - s;
  150711. if (typeof e == "function")
  150712. return i ? e(null, b) : (console.error("error loading resource"),
  150713. e("error", b))
  150714. }
  150715. o.src = a + "/favicon.ico?" + +new Date
  150716. }
  150717. const log$m = new Logger("heartbeat");
  150718. class Heartbeat {
  150719. constructor(e) {
  150720. Tt(this, "_interval", null);
  150721. Tt(this, "ping", ()=>{
  150722. const e = Date.now().toString();
  150723. this.handler.ping(e)
  150724. }
  150725. );
  150726. this.handler = e
  150727. }
  150728. start() {
  150729. this.stop(),
  150730. log$m.debug(`Setting ping interval to ${PING_INTERVAL_MS}ms`),
  150731. this._interval = window.setInterval(this.ping, PING_INTERVAL_MS)
  150732. }
  150733. stop() {
  150734. log$m.debug("stop heartbeat"),
  150735. this._interval && window.clearInterval(this._interval)
  150736. }
  150737. pong(e, i) {
  150738. !e || typeof e == "string" && this.handler.pong(Date.now() - Number(e), i)
  150739. }
  150740. }
  150741. class NetworkMonitor {
  150742. constructor(e) {
  150743. Tt(this, "_listener");
  150744. this._listener = e
  150745. }
  150746. get isOnline() {
  150747. const e = window.navigator;
  150748. return typeof e.onLine == "boolean" ? e.onLine : !0
  150749. }
  150750. start() {
  150751. window.addEventListener("online", this._listener),
  150752. window.addEventListener("offline", this._listener)
  150753. }
  150754. stop() {
  150755. window.removeEventListener("online", this._listener),
  150756. window.removeEventListener("offline", this._listener)
  150757. }
  150758. }
  150759. function VisibilityChangeHandler() {
  150760. this.subscribers = [],
  150761. this.bindFunc = void 0,
  150762. this.id = 1,
  150763. this.addListener()
  150764. }
  150765. VisibilityChangeHandler.prototype = {
  150766. subscribe(a) {
  150767. if (!a)
  150768. return;
  150769. const e = ++this.id
  150770. , i = {
  150771. id: e,
  150772. handler: a
  150773. };
  150774. return this.subscribers.push(i),
  150775. ()=>{
  150776. this.subscribers = this.subscribers.filter(s=>s.id == e)
  150777. }
  150778. },
  150779. destroy() {
  150780. !this.bindFunc || (document.hidden !== void 0 ? document.removeEventListener("visibilitychange", this.bindFunc, !1) : document.webkitHidden && document.removeEventListener("webkitvisibilitychange", this.bindFunc, !1))
  150781. },
  150782. broadcast(a) {
  150783. this.subscribers.forEach(e=>e.handler(a))
  150784. },
  150785. addListener() {
  150786. document.hidden !== void 0 ? (this.bindFunc = ()=>this.broadcast(document.hidden),
  150787. document.addEventListener("visibilitychange", this.bindFunc, !1)) : document.webkitHidden && (this.bindFunc = ()=>this.broadcast(document.webkitHidden),
  150788. document.addEventListener("webkitvisibilitychange", this.bindFunc, !1))
  150789. }
  150790. };
  150791. const WASM_Version = "h264"
  150792. , DECODER_VERSION = "v0.9.3"
  150793. , WASM_URLS = {
  150794. h264: "https://static.xverse.cn/wasm/v17/lib_ff264dec.js",
  150795. xv265: "https://static.xverse.cn/wasm/codec-release/h265-dec-sw-wasm/v-0-9-1/libxv265dec.js",
  150796. h265: ""
  150797. }
  150798. , STUCK_STAGE_GOOD = 45
  150799. , STUCK_STAGE_WELL = 85
  150800. , STUCK_STAGE_FAIR = 125
  150801. , STUCK_STAGE_BAD = 165
  150802. , DECODER_PASSIVE_JITTER = 0;
  150803. function add(a, e) {
  150804. return e == -1 && (e = 0),
  150805. a + e
  150806. }
  150807. function count_valid(a, e) {
  150808. let i = 0;
  150809. return e != -1 && (i = 1),
  150810. a + i
  150811. }
  150812. function count_less(a, e) {
  150813. function i(o, s) {
  150814. let c = 0;
  150815. return s != -1 && s < e && (c = 1),
  150816. o + c
  150817. }
  150818. return a.reduce(i, 0)
  150819. }
  150820. function count_sd(a, e) {
  150821. function i(o, s) {
  150822. let c = 0;
  150823. return s == -1 ? c = 0 : c = (s - e) * (s - e),
  150824. o + c
  150825. }
  150826. return Math.sqrt(a.reduce(i, 0) / a.reduce(count_valid, 0)) || 0
  150827. }
  150828. function max(a, e) {
  150829. return Math.max(a, e)
  150830. }
  150831. class CircularArray {
  150832. constructor(e, i, o) {
  150833. this.sum = 0,
  150834. this.incomingSum = 0,
  150835. this.count = 0,
  150836. this.incomingCount = 0,
  150837. this.max = 0,
  150838. this.incomingMax = 0,
  150839. this.goodLess = 0,
  150840. this.wellLess = 0,
  150841. this.fairLess = 0,
  150842. this.badLess = 0,
  150843. this.countLess = !1,
  150844. this.lessThreshes = [],
  150845. this.incomingData = [],
  150846. this.circularData = Array(e).fill(-1),
  150847. this.circularPtr = 0,
  150848. this.circularLength = e,
  150849. i && (this.countLess = !0,
  150850. this.lessThreshes = o)
  150851. }
  150852. add(e) {
  150853. e < 0 || (this.circularData[this.circularPtr] != -1 ? (this.sum -= this.circularData[this.circularPtr],
  150854. Math.abs(this.circularData[this.circularPtr] - this.max) < .01 && (this.circularData[this.circularPtr] = -1,
  150855. this.max = this.computeMax(this.circularData))) : this.count += 1,
  150856. this.sum += e,
  150857. this.incomingSum += e,
  150858. this.incomingCount += 1,
  150859. this.max < e && (this.max = e),
  150860. this.incomingMax < e && (this.incomingMax = e),
  150861. this.circularData[this.circularPtr] = e,
  150862. this.circularPtr = (this.circularPtr + 1) % this.circularLength,
  150863. this.incomingData.push(e),
  150864. this.incomingData.length > this.circularLength && (this.clearIncoming(),
  150865. this.incomingCount = 0,
  150866. this.incomingSum = 0))
  150867. }
  150868. computeAvg(e) {
  150869. return e.reduce(add, 0) / e.reduce(count_valid, 0) || 0
  150870. }
  150871. computeMax(e) {
  150872. return e.reduce(max, 0) || 0
  150873. }
  150874. computeThreshPercent(e) {
  150875. if (this.countLess) {
  150876. const i = count_less(e, this.lessThreshes[0]) || 0
  150877. , o = count_less(e, this.lessThreshes[1]) || 0
  150878. , s = count_less(e, this.lessThreshes[2]) || 0
  150879. , c = count_less(e, this.lessThreshes[3]) || 0
  150880. , d = e.reduce(count_valid, 0);
  150881. return [i, o, s, c, d]
  150882. } else
  150883. return [0, 0, 0, 0, 0]
  150884. }
  150885. getAvg() {
  150886. return this.sum / this.count || 0 || 0
  150887. }
  150888. getMax(e=!0) {
  150889. return this.max || 0
  150890. }
  150891. getStandardDeviation() {
  150892. return count_sd(this.circularData, this.getAvg())
  150893. }
  150894. getThreshPercent() {
  150895. return this.computeThreshPercent(this.circularData)
  150896. }
  150897. getIncomingMax() {
  150898. return this.computeMax(this.incomingData) || 0
  150899. }
  150900. getIncomingAvg() {
  150901. return this.computeAvg(this.incomingData) || 0
  150902. }
  150903. getIncomingStandardDeviation() {
  150904. return count_sd(this.incomingData, this.getIncomingAvg())
  150905. }
  150906. getIncomingThreshPercent() {
  150907. return this.computeThreshPercent(this.incomingData)
  150908. }
  150909. clearFastComputeItem() {
  150910. this.sum = 0,
  150911. this.incomingSum = 0,
  150912. this.count = 0,
  150913. this.incomingCount = 0,
  150914. this.max = 0,
  150915. this.incomingMax = 0,
  150916. this.goodLess = 0,
  150917. this.wellLess = 0,
  150918. this.fairLess = 0,
  150919. this.badLess = 0
  150920. }
  150921. clearIncoming() {
  150922. for (; this.incomingData.length > 0; )
  150923. this.incomingData.pop()
  150924. }
  150925. clear() {
  150926. this.circularData.fill(-1),
  150927. this.circularPtr = 0,
  150928. this.clearFastComputeItem(),
  150929. this.clearIncoming()
  150930. }
  150931. }
  150932. class SecondArray {
  150933. constructor() {
  150934. this.circularData = []
  150935. }
  150936. add(e) {
  150937. this.circularData.push(e)
  150938. }
  150939. getAvg() {
  150940. let e = 0;
  150941. for (let i = 0; i < this.circularData.length; i++)
  150942. e += this.circularData[i];
  150943. return {
  150944. sum: e,
  150945. avg: e / this.circularData.length || 0
  150946. }
  150947. }
  150948. getMax() {
  150949. let e = 0;
  150950. for (let i = 0; i < this.circularData.length; i++)
  150951. e < this.circularData[i] && (e = this.circularData[i]);
  150952. return e || 0
  150953. }
  150954. clear() {
  150955. this.circularData = []
  150956. }
  150957. getStat() {
  150958. const e = this.getAvg()
  150959. , i = {
  150960. sum: e.sum,
  150961. avg: e.avg,
  150962. max: this.getMax()
  150963. };
  150964. return this.clear(),
  150965. i
  150966. }
  150967. }
  150968. var decoder = `/* eslint-disable no-inner-declarations */
  150969. /* eslint-disable default-case */
  150970. /* eslint-disable no-restricted-globals */
  150971. // import { arrayBuffer } from "stream/consumers"
  150972. // import { addSyntheticLeadingComment, textChangeRangeIsUnchanged } from "typescript"
  150973. /* eslint-disable no-undef */
  150974. const CACHE_BUF_LENGTH = 16
  150975. const YUV_BUF_LENGTH = 16
  150976. if ('function' === typeof importScripts) {
  150977. const startTime = Date.now()
  150978. // self.importScripts('https://static.xverse.cn/wasm/zx_test_exclusive/v2/libxv265dec.js')
  150979. // printConsole.log('Decoder update time is 2021/10/14 12:13 ')
  150980. const YUVArray = []
  150981. const mediaArray = []
  150982. let IframesReceived = 0
  150983. let IframesDecoded = 0
  150984. let lastReceivePts = 0
  150985. let lastProcessPts = 0
  150986. let framesReturned = 0
  150987. let send_out_buffer = 0
  150988. let lastPoc = 0
  150989. let cachedFirstFrame = undefined
  150990. let cachedPanoramaFirstFrame = undefined
  150991. const printConsole = {
  150992. log: (msg) => self.postMessage({ t: MessageEvent.ConsoleLog, printMsg: msg }),
  150993. error: (msg, code) => self.postMessage({ t: MessageEvent.ConsoleError, printMsg: msg, code: code }),
  150994. }
  150995. const MessageEvent = {
  150996. DecodeMessage: 0,
  150997. UpdateStats: 1,
  150998. WASMReady: 2,
  150999. CacheFrame: 3,
  151000. RecordVideo: 4,
  151001. OnlyEmitSignal: 5,
  151002. WASMReadyCost: 6,
  151003. PanoramaMessage: 7,
  151004. RequestIFrame: 8,
  151005. ConsoleLog: 9,
  151006. ConsoleError: 10,
  151007. }
  151008. let lastReceiveContentPts = 0
  151009. let saveMediaBytes = 0 // Just for test use
  151010. const IFrameCacheBuffer = {}
  151011. for (var i = 0; i < CACHE_BUF_LENGTH; ++i) {
  151012. mediaArray.push({
  151013. pts: -1,
  151014. receive_ts: 0,
  151015. decode_ts: 0,
  151016. yuv_ts: 0,
  151017. render_ts: 0,
  151018. media: null,
  151019. meta: null,
  151020. isIDR: false,
  151021. })
  151022. }
  151023. let downloadBlob = (data, fileName, mimeType) => {
  151024. const blob = new Blob([data], {
  151025. type: mimeType,
  151026. })
  151027. const url = URL.createObjectURL(blob)
  151028. self.postMessage({ t: MessageEvent.RecordVideo, fileObj: blob, link: url })
  151029. //downloadURL(url, fileName)
  151030. setTimeout(function () {
  151031. return URL.revokeObjectURL(url)
  151032. }, 3000)
  151033. }
  151034. function Decoder() {
  151035. this.expected_frameCnt = 1
  151036. this.inited = false
  151037. this.wasminited = false
  151038. this.cacheMap = new Map()
  151039. this.receivedMedia = 0
  151040. this.receivedFrame = 0
  151041. this.receivedYUV = 0
  151042. this.receivedEmit = 0
  151043. this.lastReceivedEmit = 0
  151044. this.mediaBytesReceived = 0
  151045. this.metaBytesReceived = 0
  151046. this.prevSeq = 0
  151047. this.packetsLost = 0
  151048. this.packetsDrop = 0
  151049. this.dtpf = 0
  151050. this.dtmf = 0
  151051. this.getFrameInterval = 10
  151052. this.jumpI = false
  151053. this.startEmit = false
  151054. this.JankTimes = 0
  151055. this.bigJankTimes = 0
  151056. this.mediaCacheBuffer = new Uint8Array(1024 * 1024 * 10) // 10MB for video recording
  151057. this.errorCacheBuffer = new Uint8Array(1024 * 1024 * 10) // 10MB for error stream recording
  151058. this.mediaCacheSize = 0
  151059. this.errorCacheSize = 0
  151060. this.startRecord = false
  151061. this.saveRecord = false
  151062. this.requestingIFrame = false
  151063. this.decoderId = 0 // 0 for 720p, 1 for 480p.
  151064. this.DecodablePts = 0
  151065. this.BlockedFrames = []
  151066. this.decodeTimeCircular = Array(120).fill(-1)
  151067. this.dtcPtr = 0
  151068. this.readPtr = 1
  151069. this.writePtr = 1
  151070. this.cntBufInc = 0
  151071. this.prevBufNum = 0
  151072. this.MAX_TRY_TO_DEC_BUFNUM = 3
  151073. this.skipFrameUntilI = true
  151074. this.enable_logging = false
  151075. this.framesReceivedBetweenTimerInterval = 0
  151076. this.maxFramesReceivedBetweenTimerInterval = 0
  151077. this.isFirstFrame = 1
  151078. this.consumerPrevPts = -1
  151079. this.consumerCurrPts = -1
  151080. this.consumerWaitingIDR = false
  151081. this.lastObj = null
  151082. this.bufferIFrame = 0
  151083. this.passiveJitterLength = 0
  151084. }
  151085. //refactor:
  151086. Decoder.prototype.isBufEmpty = function () {
  151087. return this.readPtr == this.writePtr
  151088. }
  151089. Decoder.prototype.isBufFull = function () {
  151090. return (this.writePtr + 1) % CACHE_BUF_LENGTH == this.readPtr
  151091. }
  151092. Decoder.prototype.getNumOfPktToBeDec = function () {
  151093. return (this.writePtr + CACHE_BUF_LENGTH - this.readPtr) % CACHE_BUF_LENGTH
  151094. }
  151095. Decoder.prototype.getNumOfEmptySlot = function () {
  151096. return CACHE_BUF_LENGTH - this.getNumOfPktToBeDec() - 1
  151097. }
  151098. Decoder.prototype.aheadof = function (a, b) {
  151099. return (a - b + 65536) % 65536 > 65536 / 2
  151100. }
  151101. Decoder.prototype.distance = function (a, b) {
  151102. var res
  151103. if (this.aheadof(a, b)) {
  151104. res = this.seqDiff(b, a, 65536)
  151105. } else {
  151106. res = this.seqDiff(a, b, 65536)
  151107. }
  151108. return res
  151109. }
  151110. Decoder.prototype.isSeqJump = function (a, b) {
  151111. return this.distance(a, b) >= CACHE_BUF_LENGTH - 1
  151112. }
  151113. Decoder.prototype.seqDiff = function (a, b, mod) {
  151114. return (a + mod - b) % mod
  151115. }
  151116. //notice: n could be nagative
  151117. Decoder.prototype.seqAdd = function (seq, n, mod) {
  151118. return (seq + mod + n) % mod
  151119. }
  151120. //end refactor
  151121. Decoder.prototype.resetDecoder = function () {
  151122. this.isFirstFrame = 1
  151123. this.expected_frameCnt = 1
  151124. this.receivedMedia = 0
  151125. this.receivedYUV = 0
  151126. this.receivedEmit = 0
  151127. this.lastReceivedEmit = 0
  151128. this.mediaBytesReceived = 0
  151129. this.metaBytesReceived = 0
  151130. this.prevSeq = 0
  151131. this.packetsLost = 0
  151132. this.packetsDrop = 0
  151133. this.dtpf = 0
  151134. this.dtmf = 0
  151135. this.JankTimes = 0
  151136. this.bigJankTimes = 0
  151137. this.getFrameInterval = 10
  151138. this.jumpI = false
  151139. IframesReceived = 0
  151140. IframesDecoded = 0
  151141. lastReceivePts = 0
  151142. lastProcessPts = 0
  151143. lastReceiveContentPts = 0
  151144. this.requestingIFrame = false
  151145. this.DecodablePts = 0
  151146. this.BlockedFrames = []
  151147. this.decodeTimeCircular.fill(-1)
  151148. this.dtcPtr = 0
  151149. for (var i = 0; i < CACHE_BUF_LENGTH; ++i) {
  151150. mediaArray[i].media = null
  151151. mediaArray[i].meta = null
  151152. mediaArray[i] = {
  151153. pts: -1,
  151154. receive_ts: 0,
  151155. decode_ts: 0,
  151156. yuv_ts: 0,
  151157. render_ts: 0,
  151158. media: null,
  151159. meta: null,
  151160. isIDR: false,
  151161. }
  151162. }
  151163. //refactor:
  151164. this.readPtr = this.writePtr = 1
  151165. this.cntBufInc = 0
  151166. this.prevBufNum = 0
  151167. this.MAX_TRY_TO_DEC_BUFNUM = 3
  151168. this.skipFrameUntilI = true
  151169. this.consumerPrevPts = -1
  151170. this.consumerCurrPts = -1
  151171. this.consumerWaitingIDR = false
  151172. this.lastObj = null
  151173. this.bufferIFrame = 0
  151174. //end refactor
  151175. }
  151176. //refactor:
  151177. Decoder.prototype.changeLogSwitch = function (status) {
  151178. this.enable_logging = status
  151179. }
  151180. const MAX_LOG_NUM = 128
  151181. logBufQueue = []
  151182. Decoder.prototype.dumpLogBuf = function () {
  151183. while (logBufQueue.length > 0) {
  151184. console.log(logBufQueue.shift())
  151185. }
  151186. }
  151187. Decoder.prototype.dumpJitterBufInfo = function (label, pts = -1) {
  151188. // if (!this.enable_logging) {
  151189. // return
  151190. // }
  151191. logInfo =
  151192. 'WritePtr: ' +
  151193. this.writePtr +
  151194. ', ReadPtr: ' +
  151195. this.readPtr +
  151196. '\\n' +
  151197. ', Producer Prev/Curr: ' +
  151198. this.prevSeq +
  151199. '/' +
  151200. pts +
  151201. '\\n' +
  151202. ', Consumer Prev/Curr: ' +
  151203. this.consumerPrevPts +
  151204. '/' +
  151205. this.consumerCurrPts +
  151206. '\\n' +
  151207. 'awaitingBuf: ' +
  151208. this.getNumOfPktToBeDec() +
  151209. ', emptySlotNum: ' +
  151210. this.getNumOfEmptySlot() +
  151211. ', skipFrameUntilI: ' +
  151212. this.skipFrameUntilI +
  151213. '\\n' +
  151214. ' framesReceivedBetweenTimerInterval: ' +
  151215. this.framesReceivedBetweenTimerInterval +
  151216. ', maxFramesReceivedBetweenTimerInterval: ' +
  151217. this.maxFramesReceivedBetweenTimerInterval +
  151218. '\\n' +
  151219. ' label: ' +
  151220. label +
  151221. '\\n'
  151222. if (pts != -1) {
  151223. logInfo += ' this.notEnoughSlots(' + pts + '): ' + this.notEnoughSlots(pts) + '\\n'
  151224. }
  151225. if (this.enable_logging) {
  151226. console.log(logInfo)
  151227. } else {
  151228. logBufQueue.push(logInfo)
  151229. if (logBufQueue.length > MAX_LOG_NUM) {
  151230. logBufQueue.shift()
  151231. }
  151232. }
  151233. }
  151234. Decoder.prototype.resetBufItem = function (index) {
  151235. mediaArray[index].media = null
  151236. mediaArray[index].meta = null
  151237. if (mediaArray[index].isIDR == true) {
  151238. this.bufferIFrame -= 1
  151239. }
  151240. mediaArray[index] = {
  151241. pts: -1,
  151242. receive_ts: 0,
  151243. decode_ts: 0,
  151244. yuv_ts: 0,
  151245. render_ts: 0,
  151246. media: null,
  151247. meta: null,
  151248. isIDR: false,
  151249. }
  151250. this.readPtr = this.seqAdd(this.readPtr, 1, CACHE_BUF_LENGTH)
  151251. }
  151252. Decoder.prototype.checkPktOrderInConsumer = function (index) {
  151253. if (this.consumerPrevPts == -1) {
  151254. if (!this.isSlotEmpty(index)) {
  151255. this.consumerPrevPts = mediaArray[index].pts
  151256. }
  151257. return true
  151258. }
  151259. if (this.isSlotEmpty(index)) {
  151260. //lost
  151261. // debugger
  151262. // console.log("[xmedia] return on SLOT EMPTY, prev: %s", prev)
  151263. this.consumerWaitingIDR = true
  151264. this.consumerPrevPts = this.seqAdd(this.consumerPrevPts, 1, 65536)
  151265. return true
  151266. }
  151267. if (!this.slotHasMedia(index)) {
  151268. // pure meta
  151269. // debugger
  151270. // console.log("[xmedia] return on meta, prev: %s, cur: %s", this., mediaArray[index].pts)
  151271. this.consumerPrevPts = mediaArray[index].pts
  151272. return true
  151273. }
  151274. this.consumerCurrPts = mediaArray[index].pts
  151275. if (this.consumerWaitingIDR || this.seqDiff(this.consumerCurrPts, this.consumerPrevPts, 65536) != 1) {
  151276. // if (!mediaArray[index].isIDR && mediaArray[index].media.byteLength!=0) {
  151277. if (this.isPFrame(mediaArray[index].isIDR, mediaArray[index].media.byteLength)) {
  151278. console.error('[INFO][XMEDIA] optimize to further reduce clutter chance. copy console log to developer')
  151279. this.dumpLogBuf()
  151280. this.dumpJitterBufInfo('go away.')
  151281. // debugger
  151282. this.consumerPrevPts = -1
  151283. // this.resetDecoder()
  151284. return false
  151285. }
  151286. }
  151287. // console.log("[xmedia] return finally, prev: %s, cur: %s", prev, cur)
  151288. this.consumerPrevPts = this.consumerCurrPts
  151289. this.consumerWaitingIDR = false
  151290. return true
  151291. }
  151292. Decoder.prototype.slotHasMedia = function (index) {
  151293. return mediaArray[index].media != null && mediaArray[index].media.byteLength != 0
  151294. }
  151295. Decoder.prototype.slotHasContent = function (index) {
  151296. return mediaArray[index].media != null && mediaArray[index].meta != null && mediaArray[index].pts != -1
  151297. }
  151298. Decoder.prototype.procBufItem = function (index) {
  151299. this.dumpJitterBufInfo('Entering Decoder.prototype.procBufItem')
  151300. // console.log('[][Core][WASM], pts: %s, isIDR: %s, length: %s', mediaArray[index].pts, mediaArray[index].isIDR, mediaArray[index].media.length)
  151301. // var loginfo = 'pts: %s, isIDR: %s, length: %s', mediaArray[index].pts, mediaArray[index].isIDR, mediaArray[index].media.length
  151302. needToSkip = this.skipFrameUntilI && !mediaArray[index].isIDR
  151303. var loginfo =
  151304. 'pts: ' +
  151305. mediaArray[index].pts +
  151306. ', isidr: ' +
  151307. mediaArray[index].isIDR +
  151308. ', slotHasMedia: ' +
  151309. this.slotHasMedia(index) +
  151310. ', slotHasMeta: ' +
  151311. (mediaArray[index].meta != null) +
  151312. ', needToSkip: ' +
  151313. needToSkip
  151314. if (this.slotHasContent(index) && !needToSkip) {
  151315. // console.log("[xmedia] %s ------------ 001", mediaArray[index].pts)
  151316. let objData = {
  151317. media: mediaArray[index].media,
  151318. frameCnt: mediaArray[index].pts,
  151319. meta: mediaArray[index].meta,
  151320. metadata: mediaArray[index].metadata,
  151321. isIDR: mediaArray[index].isIDR,
  151322. }
  151323. // -------------------
  151324. if (this.checkPktOrderInConsumer(index)) {
  151325. // console.log("[xmedia] %s ------------ 002", mediaArray[index].pts)
  151326. this.decodeFrame(objData)
  151327. }
  151328. if (mediaArray[index].isIDR) {
  151329. // console.log("[xmedia] %s ------------ 003", mediaArray[index].pts)
  151330. // console.log("mediaArray[index].isIDR: this.skipFrameUntilI = false")
  151331. this.skipFrameUntilI = false
  151332. }
  151333. } else {
  151334. // console.log("[xmedia] %s ------------ 004", mediaArray[index].pts)
  151335. if (this.slotHasMedia(index)) {
  151336. // console.log("[xmedia] %s ------------ 005", mediaArray[index].pts)
  151337. //need to skip, waiting I Frame
  151338. //dropCache++
  151339. this.dropPkt += 1
  151340. // MARKER META1META2
  151341. // self.postMessage({ t: MessageEvent.OnlyEmitSignal, meta_only: true, meta: mediaArray[index].meta, metadata: mediaArray[index].metadata })
  151342. } else {
  151343. // console.log("[xmedia] %s ------------ 006", mediaArray[index].pts)
  151344. // no media
  151345. if (mediaArray[index].meta != null) {
  151346. this.checkPktOrderInConsumer(index)
  151347. // console.log("[xmedia] %s ------------ 007", mediaArray[index].pts)
  151348. // Still frame
  151349. // console.log('[send signal]', mediaArray[index].pts)
  151350. self.postMessage({
  151351. t: MessageEvent.OnlyEmitSignal,
  151352. meta_only: true,
  151353. meta: mediaArray[index].meta,
  151354. metadata: mediaArray[index].metadata,
  151355. })
  151356. } else {
  151357. // console.log("[xmedia] %s ------------ 008", mediaArray[index].pts)
  151358. // Lost_rcv++
  151359. // console.log("lost_rcv++: this.skipFrameUntilI = true")
  151360. // console.info('[xmedia] FFFFF This code should not be executed!!!!')
  151361. console.info('[xmedia] null pkt sneaked into profBufItem without harm')
  151362. this.skipFrameUntilI = true
  151363. }
  151364. }
  151365. }
  151366. this.dumpJitterBufInfo('Leaving Decoder.prototype.procBufItem, ' + loginfo)
  151367. this.lastObj = mediaArray[index]
  151368. this.resetBufItem(index)
  151369. }
  151370. Decoder.prototype.flushBuffer = function (untilIDR) {
  151371. this.dumpJitterBufInfo('Entering Decoder.prototype.flushBuffer')
  151372. this.skipFrameUntilI = true
  151373. var breakWhenIDR = false
  151374. while (this.getNumOfPktToBeDec() > 0) {
  151375. index = this.readPtr
  151376. if (this.slotHasMedia(index)) {
  151377. // dropMedia until IDR // \u6765\u4E0D\u53CA\u89E3\u7801\u4E22\u5E27
  151378. this.packetsDrop += 1
  151379. if (untilIDR) {
  151380. if (mediaArray[index].isIDR == true) {
  151381. breakWhenIDR = true
  151382. break
  151383. }
  151384. }
  151385. } else if (mediaArray[index].meta != null) {
  151386. self.postMessage({
  151387. t: MessageEvent.OnlyEmitSignal,
  151388. meta_only: true,
  151389. meta: mediaArray[index].meta,
  151390. metadata: mediaArray[index].metadata,
  151391. })
  151392. }
  151393. this.resetBufItem(index)
  151394. }
  151395. if (!breakWhenIDR) {
  151396. this.isFirstFrame = true
  151397. }
  151398. this.dumpJitterBufInfo('Leaving Decoder.prototype.flushBuffer')
  151399. return this.isFirstFrame
  151400. }
  151401. // var cnt = 0
  151402. Decoder.prototype.getFrameToDecode = function () {
  151403. this.dumpJitterBufInfo('Entering Decoder.prototype.getFrameToDecode')
  151404. if (this.getNumOfPktToBeDec() == 0) {
  151405. return false
  151406. }
  151407. //bufNum awaiting increase counter
  151408. // while (this.getNumOfPktToBeDec() > CACHE_BUF_LENGTH / 2) {
  151409. // needToCheck = true
  151410. // if (this.cntBufInc > this.MAX_TRY_TO_DEC_BUFNUM) {
  151411. // console.log('ringbuffer is deteriorating, flush until IDR')
  151412. // var untilIDR = true
  151413. // this.flushBuffer(untilIDR)
  151414. // this.cntBufInc = 0
  151415. // break
  151416. // }
  151417. // this.procBufItem(this.readPtr)
  151418. // }
  151419. // if (this.getNumOfPktToBeDec() == 0) {
  151420. // return false
  151421. // }
  151422. let IFrmInBuffer = 0
  151423. let frmInBuffer = 0
  151424. for (var i = 0; i < CACHE_BUF_LENGTH; ++i) {
  151425. if (mediaArray[i].isIDR) {
  151426. IFrmInBuffer += 1
  151427. }
  151428. if (this.slotHasMedia(i)) {
  151429. frmInBuffer += 1
  151430. }
  151431. }
  151432. if (!this.slotHasContent(this.readPtr) && IFrmInBuffer == 0) {
  151433. if (frmInBuffer > 0) {
  151434. // There is P frame in buffer but cannot be decoded.
  151435. // Due to ordered data channel, this is packet loss.
  151436. // So request for I frame here.
  151437. printConsole.log('detect packet lost. Request for I frame.')
  151438. self.postMessage({ t: MessageEvent.RequestIFrame })
  151439. }
  151440. return false
  151441. }
  151442. this.procBufItem(this.readPtr)
  151443. // if (this.getNumOfPktToBeDec() > this.prevBufNum) {
  151444. // this.cntBufInc++
  151445. // } else {
  151446. // if (this.cntBufInc > 2) {
  151447. // // aimd
  151448. // this.cntBufInc / 2
  151449. // }
  151450. // }
  151451. // this.prevBufNum = this.getNumOfPktToBeDec()
  151452. this.dumpJitterBufInfo('Leaving Decoder.prototype.getFrameToDecode')
  151453. return true
  151454. }
  151455. //refactor end:
  151456. var cacheBuffer
  151457. var resultBuffer
  151458. Decoder.prototype.startDecoding = function () {
  151459. function iterative_getFrameToDecode() {
  151460. self.decoder.framesReceivedBetweenTimerInterval = 0
  151461. self.decoder.dumpJitterBufInfo('Entering Decoder.prototype.iterative_getFrameToDecode')
  151462. var start_ts = Date.now()
  151463. let hasDecodeFrame = self.decoder.getFrameToDecode()
  151464. var end_ts = Date.now()
  151465. // refactor
  151466. let expect_interval =
  151467. 1000 / (30 + Math.max(self.decoder.getNumOfPktToBeDec() - self.decoder.passiveJitterLength, 0))
  151468. //let expect_interval = 1000 / (Decoder.prototype.getNumOfPktToBeDec() + 30)
  151469. if (hasDecodeFrame) {
  151470. let usedTime = end_ts - start_ts
  151471. self.decoder.getFrameInterval = expect_interval - Math.max(usedTime, self.decoder.dtpf)
  151472. if (self.decoder.getFrameInterval < 1) {
  151473. self.decoder.getFrameInterval = 0
  151474. }
  151475. } else {
  151476. self.decoder.getFrameInterval = 5
  151477. }
  151478. // let usedTime = end_ts - start_ts
  151479. // FPS = 30
  151480. // if (usedTime * FPS < 1000) {
  151481. // self.decoder.getFrameInterval = 1000 / (FPS + Decoder.prototype.getNumOfPktToBeDec())
  151482. // } else {
  151483. // self.decoder.getFrameInterval = 1 //ms
  151484. // }
  151485. // if (Decoder.prototype.getNumOfPktToBeDec() == 0) {
  151486. // //Hinse: have to get buf to send asap.
  151487. // self.decoder.getFrameInterval = 5 //ms
  151488. // }
  151489. setTimeout(iterative_getFrameToDecode, self.decoder.getFrameInterval)
  151490. self.decoder.dumpJitterBufInfo('Leaving Decoder.prototype.iterative_getFrameToDecode')
  151491. // refactor end
  151492. }
  151493. function postStats() {
  151494. function add(accumulator, a) {
  151495. if (a == -1) {
  151496. a = 0
  151497. }
  151498. return accumulator + a
  151499. }
  151500. function count_valid(accumulator, a) {
  151501. let non_zero = 0
  151502. if (a != -1) {
  151503. non_zero = 1
  151504. }
  151505. return accumulator + non_zero
  151506. }
  151507. function max(maxer, a) {
  151508. return Math.max(maxer, a)
  151509. }
  151510. const dtpf =
  151511. self.decoder.decodeTimeCircular.reduce(add, 0) / self.decoder.decodeTimeCircular.reduce(count_valid, 0) || 0
  151512. const dtmf = self.decoder.decodeTimeCircular.reduce(max, 0)
  151513. let objData = {
  151514. t: MessageEvent.UpdateStats,
  151515. mediaBytesReceived: self.decoder.mediaBytesReceived,
  151516. metaBytesReceived: self.decoder.metaBytesReceived,
  151517. packetsLost: self.decoder.packetsLost, // \u7F51\u7EDC\u4E22\u5E27
  151518. packetsDrop: self.decoder.packetsDrop, // \u6765\u4E0D\u53CA\u89E3\u7801\u4E22\u5E27
  151519. framesReceived: self.decoder.receivedMedia,
  151520. framesDecoded: self.decoder.receivedYUV,
  151521. framesRendered: self.decoder.receivedEmit,
  151522. framesReturned: framesReturned,
  151523. // framesAwait: leastReceivePts - lastProcessPts,
  151524. framesAwait: self.decoder.getNumOfPktToBeDec(), // \u7B49\u5F85\u89E3\u7801\u7684\u5E27
  151525. decodeTimePerFrame: dtpf,
  151526. decodeTimeMaxFrame: dtmf,
  151527. sendOutBuffer: send_out_buffer,
  151528. JankTimes: self.decoder.JankTimes,
  151529. bigJankTimes: self.decoder.bigJankTimes,
  151530. receivedIframe: self.decoder.IframesReceived,
  151531. decodedIframe: self.decoder.IframesDecoded,
  151532. }
  151533. self.postMessage(objData)
  151534. self.decoder.dtmf = 0
  151535. }
  151536. setTimeout(iterative_getFrameToDecode, this.getFrameInterval)
  151537. setInterval(postStats, 1000)
  151538. }
  151539. Decoder.prototype.initAll = function (config) {
  151540. if (typeof wasmSource != 'undefined') {
  151541. if (wasmSource == 0) {
  151542. // Load from indexedDB
  151543. // console.log('Load WASM from indexedDB')
  151544. printConsole.log('Load WASM from indexedDB')
  151545. wasmSource = undefined
  151546. } else if (wasmSource == 1) {
  151547. // Load by fetch
  151548. // console.log('Load WASM by fetch')
  151549. printConsole.log('Load WASM by fetch')
  151550. wasmSource = undefined
  151551. } else {
  151552. printConsole.log('WASM not ready now, wait for 200 ms.')
  151553. }
  151554. } else {
  151555. printConsole.log('wasm variable is not defined. Probably libffmpeg.js file is not loaded properly.')
  151556. }
  151557. if (typeof wasmTable === 'undefined') {
  151558. setTimeout(self.decoder.initAll, 200, config)
  151559. return 0
  151560. }
  151561. cacheBuffer = Module._malloc(1024 * 1024)
  151562. resultBuffer = Module._malloc(64)
  151563. self.postMessage({
  151564. t: MessageEvent.WASMReadyCost,
  151565. type: 'report',
  151566. data: {
  151567. metric: 'wasmDownloadCost',
  151568. value: Date.now() - startTime,
  151569. group: 'costs',
  151570. },
  151571. })
  151572. // WASM already initialized. Now we open decoder.
  151573. const LOG_LEVEL_WASM = 2
  151574. const DECODER_H264 = 0
  151575. const decoder_type = DECODER_H264
  151576. for (var j = 0; j < YUV_BUF_LENGTH; ++j) {
  151577. YUVArray.push({ status: 0, buffer: new Uint8Array((config.width * config.height * 3) / 2) })
  151578. }
  151579. printConsole.log('Going to open decoder ' + String(Date.now()))
  151580. var ret0 = Module._openDecoder(0, decoder_type, LOG_LEVEL_WASM)
  151581. if (ret0 == 0) {
  151582. self.decoder.startDecoding()
  151583. self.postMessage({ t: MessageEvent.WASMReady, wasm_ready: true, updateStats: false })
  151584. } else {
  151585. printConsole.error('openDecoder failed with error ' + String(ret0), '5001')
  151586. return 1
  151587. }
  151588. return 0
  151589. }
  151590. Decoder.prototype.cacheFrame = function (data) {
  151591. if (data.position != undefined) {
  151592. var media = data.data.subarray(data.metaLen, data.metaLen + data.mediaLen)
  151593. if (IFrameCacheBuffer[JSON.stringify(data.position)] == undefined) {
  151594. for (var key in IFrameCacheBuffer) delete IFrameCacheBuffer[key] // Clear Frame Cache
  151595. IFrameCacheBuffer[JSON.stringify(data.position)] = {}
  151596. }
  151597. IFrameCacheBuffer[JSON.stringify(data.position)][data.cachedKey] = media
  151598. self.postMessage({
  151599. t: MessageEvent.CacheFrame,
  151600. cacheFrame: true,
  151601. cachedKey: data.cachedKey,
  151602. metadata: data.metadata,
  151603. })
  151604. }
  151605. }
  151606. Decoder.prototype.updateMediaMetaStats = function (data) {
  151607. this.metaBytesReceived += data.metaLen
  151608. this.mediaBytesReceived += data.mediaLen
  151609. if (data.mediaLen != 0) {
  151610. this.receivedMedia++
  151611. }
  151612. }
  151613. Decoder.prototype.isIFrame = function (isIDR, mediaLen) {
  151614. // return data.isIDR && media.byteLength !=0
  151615. return isIDR && mediaLen != 0
  151616. }
  151617. Decoder.prototype.isPFrame = function (isIDR, mediaLen) {
  151618. // return !data.isIDR && media.byteLength !=0
  151619. return !isIDR && mediaLen != 0
  151620. }
  151621. Decoder.prototype.isPureMeta = function (metaLen, mediaLen) {
  151622. // return media.byteLength == 0 && meta.byteLength !=0
  151623. return mediaLen == 0 && metaLen != 0
  151624. }
  151625. Decoder.prototype.isInvalidPkt = function (isIDR, mediaLen, metaLen) {
  151626. return !this.isIFrame(isIDR, mediaLen) && !this.isPFrame(isIDR, mediaLen) && !this.isPureMeta(metaLen, mediaLen)
  151627. }
  151628. Decoder.prototype.isSlotEmpty = function (index) {
  151629. return !this.slotHasMedia(index) && mediaArray[index].meta == null
  151630. }
  151631. Decoder.prototype.handleNewPktOnFlush = function (isIDR, mediaLen) {
  151632. var dropPkt = false
  151633. // console.log("[xmedia] 000-1 isFirstFrame %s", this.isFirstFrame)
  151634. if (this.isFirstFrame) {
  151635. // let IDR/meta pass
  151636. // console.log("[xmedia] 000-2 isIDR: %s, mediaLen: %s", isIDR, mediaLen)
  151637. // console.log("[xmedia] 000-3 this.isPFrame(isIDR, mediaLen): %s", this.isPFrame(isIDR, mediaLen))
  151638. if (this.isPFrame(isIDR, mediaLen)) {
  151639. // console.log("[xmedia] 001: isPFrame TRUE")
  151640. this.packetsDrop += 1
  151641. // MARKER META1META2
  151642. dropPkt = true
  151643. }
  151644. if (this.isIFrame(isIDR, mediaLen)) {
  151645. // console.log("[xmedia] 002: isIFrame TRUE")
  151646. this.isFirstFrame = false
  151647. }
  151648. }
  151649. // console.log("[xmedia] 003: dropPkt: %s", dropPkt)
  151650. return dropPkt
  151651. }
  151652. Decoder.prototype.notEnoughSlots = function (pts) {
  151653. return this.isBufFull() || this.seqDiff(pts, this.prevSeq, CACHE_BUF_LENGTH) > this.getNumOfEmptySlot()
  151654. }
  151655. Decoder.prototype.receiveFrame = function (data) {
  151656. var key = data.cachedKey
  151657. var pts = data.frameCnt
  151658. var meta = data.data.subarray(0, data.metaLen)
  151659. var media
  151660. if (data.cached) {
  151661. media = IFrameCacheBuffer[JSON.stringify(data.position)][key]
  151662. } else if (data.cacheRequest) {
  151663. media = data.data.subarray(data.metaLen, data.metaLen + data.mediaLen)
  151664. self.decoder.cacheFrame(data)
  151665. } else {
  151666. media = data.data.subarray(data.metaLen, data.metaLen + data.mediaLen)
  151667. }
  151668. this.updateMediaMetaStats(data)
  151669. if (this.isFirstFrame) {
  151670. // console.log('[xmedia] isFirstFrame = true. pts:%s', pts)
  151671. if (this.isPFrame(data.isIDR, media.byteLength)) {
  151672. // MARKER META1META2
  151673. this.packetsDrop += 1
  151674. return
  151675. }
  151676. this.prevSeq = this.seqDiff(pts, 1, 65536)
  151677. this.readPtr = this.writePtr = pts % CACHE_BUF_LENGTH
  151678. if (data.isIDR) {
  151679. this.isFirstFrame = false
  151680. }
  151681. }
  151682. if (pts !== this.seqAdd(this.prevSeq, 1, 65536) && pts !== this.prevSeq) {
  151683. this.packetsLost += 1
  151684. }
  151685. const index = pts % CACHE_BUF_LENGTH
  151686. if (this.startRecord) {
  151687. this.mediaCacheBuffer.set(media, this.mediaCacheSize)
  151688. this.mediaCacheSize += media.byteLength
  151689. }
  151690. if (this.saveRecord) {
  151691. downloadBlob(this.mediaCacheBuffer.subarray(0, this.mediaCacheSize), 'test.264', 'application/octet-stream')
  151692. this.mediaCacheSize = 0
  151693. this.saveRecord = false
  151694. this.startRecord = false
  151695. }
  151696. //refactor:
  151697. // Step 1, big jump detected. we cannot handle it, flush all.
  151698. var untilIDR, pktDrop
  151699. if (this.isSeqJump(this.prevSeq, pts)) {
  151700. // console.log('[resetdecoder] Fatal: decoder seq jump from ' + this.prevSeq + ' to ' + pts)
  151701. untilIDR = false
  151702. this.flushBuffer(untilIDR)
  151703. pktDrop = this.handleNewPktOnFlush(data.isIDR, media.byteLength)
  151704. if (pktDrop) return
  151705. }
  151706. this.dumpJitterBufInfo('Entering Decoder.prototype.receiveFrame', pts)
  151707. // console.log("--->> this.notEnoughSlots(pts): %s", this.notEnoughSlots(pts))
  151708. // Step 2,
  151709. if (this.aheadof(pts, this.prevSeq)) {
  151710. // pts before prevSeq
  151711. // pkts in wrong order
  151712. if (this.packetsLost > 0) {
  151713. this.packetsLost -= 1
  151714. // this.packetdisorder +=1
  151715. }
  151716. // console.log("[xmedia] disorder frame received. preSeq: %s, pts: %s", this.prevSeq, pts)
  151717. if (this.seqDiff(this.prevSeq, pts, 65536) < this.getNumOfPktToBeDec()) {
  151718. // slot for pts is not handled yet. just put it back:
  151719. // console.log('put disorder frame to enc_queue, pkt:%s, prevPts: %s, numOfPktToBeDec: %s', pts, this.prevSeq, this.getNumOfPktToBeDec())
  151720. } else {
  151721. //dropDisorder++
  151722. console.error(
  151723. 'drop disorder pkt:%s, prevPts: %s, numOfPktToBeDec: %s',
  151724. pts,
  151725. this.prevSeq,
  151726. this.getNumOfPktToBeDec(),
  151727. )
  151728. this.packetsDrop += 1
  151729. // ---------------------
  151730. // Note:
  151731. //
  151732. // Three principles for meta data:
  151733. // step 1 step 2
  151734. // 1. backend -----> frontend (decoder.js) -----> frontend (worker.js), meta pkts must be kept in order in the whole pipeline
  151735. // 2. if media presents and needs to be dropped, the meta companion needs to be dropped together.
  151736. // 3. if media is absent (media.bytelength == 0), send meta anyway
  151737. // ---------------------
  151738. // According to rule 1, drop meta at this point is reasonable.
  151739. return
  151740. }
  151741. } else {
  151742. // pts after prevSeq
  151743. // make sure the ringbuffer has empty slot for new pkt
  151744. if (this.notEnoughSlots(pts)) {
  151745. this.dumpJitterBufInfo('Fatal: decoder buf is full', pts)
  151746. //dropIncoming
  151747. untilIDR = true
  151748. this.flushBuffer(untilIDR)
  151749. if (this.notEnoughSlots(pts)) {
  151750. untilIDR = false
  151751. this.flushBuffer(untilIDR)
  151752. }
  151753. pktDrop = this.handleNewPktOnFlush(data.isIDR, media.byteLength)
  151754. if (pktDrop) return
  151755. }
  151756. }
  151757. mediaArray[index] = {
  151758. pts: pts,
  151759. receive_ts: Date.now(),
  151760. decode_ts: 0,
  151761. yuv_ts: 0,
  151762. render_ts: 0,
  151763. media: media,
  151764. meta: meta,
  151765. metadata: data.metadata,
  151766. isIDR: data.isIDR,
  151767. }
  151768. if (data.isIDR == true) {
  151769. this.bufferIFrame += 1
  151770. }
  151771. this.framesReceivedBetweenTimerInterval += 1
  151772. if (this.framesReceivedBetweenTimerInterval > this.maxFramesReceivedBetweenTimerInterval) {
  151773. this.maxFramesReceivedBetweenTimerInterval = this.framesReceivedBetweenTimerInterval
  151774. }
  151775. if (!this.aheadof(pts, this.prevSeq)) {
  151776. // writePtr += (cur - prev)
  151777. this.writePtr = this.seqAdd(this.writePtr, this.seqDiff(pts, this.prevSeq, CACHE_BUF_LENGTH), CACHE_BUF_LENGTH)
  151778. if (this.seqAdd(index, 1, CACHE_BUF_LENGTH) != this.writePtr) {
  151779. this.dumpJitterBufInfo('dec worker internal info: index (' + index + ') != write_ptr (' + this.writePtr + ')')
  151780. // debugger
  151781. }
  151782. this.prevSeq = pts
  151783. }
  151784. this.dumpJitterBufInfo('Leaving Decoder.prototype.receiveFrame')
  151785. //refactor end
  151786. }
  151787. Decoder.prototype.startEmiter = function () {
  151788. self.decoder.startEmit = true
  151789. if (cachedFirstFrame != undefined) {
  151790. self.postMessage(cachedFirstFrame, [cachedFirstFrame.data.buffer])
  151791. send_out_buffer += 1
  151792. this.receivedEmit++
  151793. cachedFirstFrame = undefined
  151794. }
  151795. if (cachedPanoramaFirstFrame != undefined) {
  151796. self.postMessage(cachedPanoramaFirstFrame)
  151797. send_out_buffer += 1
  151798. this.receivedEmit++
  151799. cachedPanoramaFirstFrame = undefined
  151800. }
  151801. }
  151802. Decoder.prototype.decodePanorama = function (data) {
  151803. console.log('upload pano data')
  151804. var content = data.data.data
  151805. var content_size = data.data.mediaLen
  151806. // var cacheBuffer = Module._malloc(content_size)
  151807. // var resultBuffer = Module._malloc(64)
  151808. Module.HEAPU8.set(content, cacheBuffer)
  151809. let ret = 0
  151810. try {
  151811. ret = Module._decodeData(0, 0, cacheBuffer, content_size, resultBuffer)
  151812. // currently only need to use flushDecoder for pano mode.
  151813. ret = Module._flushDecoder(0, 0, resultBuffer)
  151814. // // console.log('[][Core][WASM] return value %s',ret)
  151815. // if(ret!=0){
  151816. // // console.log('[][Core][WASM],-abcdefg-----> ', ret)
  151817. // var ret_close = Module._closeDecoder(0)
  151818. // // eslint-disable-next-line no-empty
  151819. // if (ret_close === 0) {
  151820. // // console.log('[][Core][WASM] decoder closed for restart')
  151821. // } else {
  151822. // printConsole.error('close decoder failed after decode pano.')
  151823. // return 1
  151824. // }
  151825. // var ret0 = Module._openDecoder(0, 0, 2)
  151826. // // console.log('[][Core][WASM] decoder restart success')
  151827. // // var ret1 = Module._openDecoder(1, decoder_type, LOG_LEVEL_WASM)
  151828. // if (ret0 === 0) {
  151829. // ret = Module._decodeData(0, 0, cacheBuffer, content_size, resultBuffer)
  151830. // } else {
  151831. // printConsole.error('openDecoder failed with error ' + String(ret0) , '5001')
  151832. // return 1
  151833. // }
  151834. // }
  151835. } catch (e) {
  151836. console.log('catch error ', e)
  151837. printConsole.error(e.message, '5002')
  151838. }
  151839. // let ret = Module._decodeData(0, 0, cacheBuffer, content_size, resultBuffer)
  151840. var width = Module.getValue(resultBuffer, 'i32')
  151841. var height = Module.getValue(resultBuffer + 4, 'i32')
  151842. var stride_y = Module.getValue(resultBuffer + 20, 'i32')
  151843. var stride_u = Module.getValue(resultBuffer + 24, 'i32')
  151844. var stride_v = Module.getValue(resultBuffer + 28, 'i32')
  151845. var addr_y = Module.getValue(resultBuffer + 8, 'i32')
  151846. var addr_u = Module.getValue(resultBuffer + 12, 'i32')
  151847. var addr_v = Module.getValue(resultBuffer + 16, 'i32')
  151848. var poc = Module.getValue(resultBuffer + 32, 'i32')
  151849. if (ret != 0) {
  151850. printConsole.log(
  151851. 'Decode Data error for panorama, ret value is ' + String(ret) + ', frame content size: ' + String(content_size),
  151852. )
  151853. return
  151854. }
  151855. var yuv_data = new Uint8Array((width * height * 3) / 2)
  151856. let pos = 0
  151857. for (let i = 0; i < height; i++) {
  151858. let src = addr_y + i * stride_y
  151859. let tmp = HEAPU8.subarray(src, src + width)
  151860. tmp = new Uint8Array(tmp)
  151861. yuv_data.set(tmp, pos)
  151862. pos += tmp.length
  151863. }
  151864. for (let i = 0; i < height / 2; i++) {
  151865. let src = addr_u + i * stride_u
  151866. let tmp = HEAPU8.subarray(src, src + width / 2)
  151867. tmp = new Uint8Array(tmp)
  151868. yuv_data.set(tmp, pos)
  151869. pos += tmp.length
  151870. let src2 = addr_v + i * stride_v
  151871. let tmp2 = HEAPU8.subarray(src2, src2 + width / 2)
  151872. tmp2 = new Uint8Array(tmp2)
  151873. yuv_data.set(tmp2, pos)
  151874. pos += tmp2.length
  151875. }
  151876. const objData = {
  151877. t: MessageEvent.PanoramaMessage,
  151878. tileId: data.data.tileId,
  151879. // uuid: data.data.uuid,
  151880. data: yuv_data,
  151881. metadata: data.data.metadata,
  151882. // x: data.data.x,
  151883. // y: data.data.y,
  151884. // z: data.data.z,
  151885. }
  151886. //TODO: remove debug
  151887. if (this.startEmit) {
  151888. self.postMessage(objData)
  151889. } else {
  151890. cachedPanoramaFirstFrame = objData
  151891. }
  151892. // console.log('upload pano data with dataLength:', len(yuv_data))
  151893. var ret_close = Module._closeDecoder(0)
  151894. // eslint-disable-next-line no-empty
  151895. if (ret_close === 0) {
  151896. // console.log('[][Core][WASM] decoder closed for restart')
  151897. } else {
  151898. printConsole.error('close decoder failed after decode pano.')
  151899. return 1
  151900. }
  151901. var ret0 = Module._openDecoder(0, 0, 2)
  151902. // var ret1 = Module._openDecoder(1, decoder_type, LOG_LEVEL_WASM)
  151903. if (ret0 === 0) {
  151904. // console.log('[][Core][WASM] decoder restart success')
  151905. self.decoder.startDecoding()
  151906. self.postMessage({ t: MessageEvent.WASMReady, wasm_ready: true, updateStats: false })
  151907. } else {
  151908. printConsole.error('openDecoder failed with error ' + String(ret0), '5001')
  151909. return 1
  151910. }
  151911. }
  151912. Decoder.prototype.decodeFrame = function (data) {
  151913. var content = data.media
  151914. if (typeof content == 'undefined') {
  151915. printConsole.error('null content in decoder', '5999')
  151916. return
  151917. }
  151918. var content_size = content.byteLength
  151919. // var cacheBuffer = Module._malloc(content_size)
  151920. // var resultBuffer = Module._malloc(64)
  151921. Module.HEAPU8.set(content, cacheBuffer)
  151922. const index = data.frameCnt % CACHE_BUF_LENGTH
  151923. mediaArray[index].decode_ts = Date.now()
  151924. var objData
  151925. if (content_size != 0) {
  151926. // var date = Date.now()
  151927. // var curDate = Date.now()
  151928. // while (curDate - date < 100) {
  151929. // curDate = Date.now()
  151930. // }
  151931. // TODO: Enable/Disable it by config
  151932. if (data.isIDR) {
  151933. this.errorCacheSize = 0
  151934. }
  151935. // Guarantee that stream start from I frame
  151936. if (this.errorCacheSize != 0 || data.isIDR) {
  151937. this.errorCacheBuffer.set(content, this.mediaCacheSize)
  151938. this.errorCacheSize += content.byteLength
  151939. }
  151940. let start_ts = Date.now()
  151941. let ret = 0
  151942. try {
  151943. ret = Module._decodeData(0, data.frameCnt, cacheBuffer, content_size, resultBuffer)
  151944. // if(ret==8){
  151945. // // console.log('[][Core][WASM],-abcdefg-----> ', ret)
  151946. // var ret_close = Module._closeDecoder(0)
  151947. // // eslint-disable-next-line no-empty
  151948. // if (ret_close === 0) {
  151949. // // console.log('[][Core][WASM] decoder closed for restart')
  151950. // } else {
  151951. // printConsole.error('close decoder failed after decode pano.')
  151952. // return 1
  151953. // }
  151954. // var ret0 = Module._openDecoder(0, 0, 2)
  151955. // // console.log('[][Core][WASM] decoder restart success')
  151956. // // var ret1 = Module._openDecoder(1, decoder_type, LOG_LEVEL_WASM)
  151957. // if (ret0 === 0) {
  151958. // ret = Module._decodeData(0, data.frameCnt, cacheBuffer, content_size, resultBuffer)
  151959. // } else {
  151960. // printConsole.error('openDecoder failed with error ' + String(ret0) , '5001')
  151961. // return 1
  151962. // }
  151963. // }
  151964. } catch (e) {
  151965. console.log('catch error ', e)
  151966. if (this.errorCacheSize > 0) {
  151967. downloadBlob(this.errorCacheBuffer.subarray(0, this.errorCacheSize), 'error.264', 'application/octet-stream')
  151968. this.errorCacheSize = 0
  151969. }
  151970. printConsole.error(e.message, '5002')
  151971. }
  151972. var width = Module.getValue(resultBuffer, 'i32')
  151973. var height = Module.getValue(resultBuffer + 4, 'i32')
  151974. var stride_y = Module.getValue(resultBuffer + 20, 'i32')
  151975. var stride_u = Module.getValue(resultBuffer + 24, 'i32')
  151976. var stride_v = Module.getValue(resultBuffer + 28, 'i32')
  151977. var addr_y = Module.getValue(resultBuffer + 8, 'i32')
  151978. var addr_u = Module.getValue(resultBuffer + 12, 'i32')
  151979. var addr_v = Module.getValue(resultBuffer + 16, 'i32')
  151980. var poc = Module.getValue(resultBuffer + 32, 'i32')
  151981. var pts = data.frameCnt
  151982. if (ret != 0) {
  151983. printConsole.log(
  151984. 'Decode Data error for video stream, ret value is ' +
  151985. String(ret) +
  151986. ', frame content size: ' +
  151987. String(content_size),
  151988. )
  151989. if (this.errorCacheSize > 0) {
  151990. downloadBlob(this.errorCacheBuffer.subarray(0, this.errorCacheSize), 'error.264', 'application/octet-stream')
  151991. this.errorCacheSize = 0
  151992. }
  151993. printConsole.log('current poc is ' + String(poc) + ', last poc is ' + String(lastPoc))
  151994. return
  151995. }
  151996. lastPoc = poc
  151997. this.receivedYUV++
  151998. let end_ts = Date.now()
  151999. fdt = end_ts - start_ts
  152000. if (fdt + self.decoder.getFrameInterval > 84) {
  152001. this.JankTimes++
  152002. }
  152003. if (fdt + self.decoder.getFrameInterval > 125) {
  152004. this.bigJankTimes++
  152005. }
  152006. self.decoder.dtpf = self.decoder.dtpf * 0.9 + fdt * 0.1
  152007. // if (fdt > self.decoder.dtmf) {
  152008. // self.decoder.dtmf = fdt
  152009. // }
  152010. self.decoder.decodeTimeCircular[self.decoder.dtcPtr] = fdt
  152011. self.decoder.dtcPtr = (self.decoder.dtcPtr + 1) % self.decoder.decodeTimeCircular.length
  152012. if (YUVArray.length <= 0) {
  152013. // printConsole.error('No buffer to save YUV after decoding, pts is ' + String(pts), '5002')
  152014. return
  152015. }
  152016. var first_available_buffer = YUVArray.shift()
  152017. var yuv_data = first_available_buffer.buffer
  152018. let pos = 0
  152019. for (let i = 0; i < height; i++) {
  152020. let src = addr_y + i * stride_y
  152021. let tmp = HEAPU8.subarray(src, src + width)
  152022. tmp = new Uint8Array(tmp)
  152023. yuv_data.set(tmp, pos)
  152024. pos += tmp.length
  152025. }
  152026. for (let i = 0; i < height / 2; i++) {
  152027. let src = addr_u + i * stride_u
  152028. let tmp = HEAPU8.subarray(src, src + width / 2)
  152029. tmp = new Uint8Array(tmp)
  152030. yuv_data.set(tmp, pos)
  152031. pos += tmp.length
  152032. let src2 = addr_v + i * stride_v
  152033. let tmp2 = HEAPU8.subarray(src2, src2 + width / 2)
  152034. tmp2 = new Uint8Array(tmp2)
  152035. yuv_data.set(tmp2, pos)
  152036. pos += tmp2.length
  152037. }
  152038. objData = {
  152039. t: MessageEvent.DecodeMessage,
  152040. data: yuv_data,
  152041. width: width,
  152042. height: height,
  152043. pts: data.frameCnt,
  152044. yuv_ts: Date.now(),
  152045. meta: data.meta,
  152046. metadata: data.metadata,
  152047. }
  152048. } else {
  152049. objData = {
  152050. t: MessageEvent.DecodeMessage,
  152051. data: null,
  152052. width: 0,
  152053. height: 0,
  152054. pts: data.frameCnt,
  152055. yuv_ts: Date.now(),
  152056. meta: data.meta,
  152057. metadata: data.metadata,
  152058. }
  152059. }
  152060. if (this.startEmit) {
  152061. if (objData.data != null) {
  152062. objData.postTs = Date.now()
  152063. self.postMessage(objData, [objData.data.buffer])
  152064. send_out_buffer += 1
  152065. this.receivedEmit++
  152066. } else {
  152067. objData.postTs = Date.now()
  152068. self.postMessage(objData)
  152069. this.receivedEmit++
  152070. }
  152071. } else {
  152072. if (objData.data != null) {
  152073. cachedFirstFrame = objData
  152074. }
  152075. }
  152076. // if (cacheBuffer != null) {
  152077. // Module._free(cacheBuffer)
  152078. // cacheBuffer = null
  152079. // }
  152080. // if (resultBuffer != null) {
  152081. // Module._free(resultBuffer)
  152082. // resultBuffer = null
  152083. // }
  152084. return
  152085. }
  152086. Decoder.prototype.receiveBuffer = function (data) {
  152087. framesReturned++
  152088. send_out_buffer -= 1
  152089. YUVArray.push({ status: 0, buffer: data.buffer })
  152090. }
  152091. Decoder.prototype.setPassiveJitter = function (len) {
  152092. this.passiveJitterLength = len
  152093. }
  152094. Decoder.prototype.uninitDecoder = function () {
  152095. printConsole.log('Going to uninit decoder.')
  152096. }
  152097. Decoder.prototype.StartRecord = function () {
  152098. printConsole.log('Start Record')
  152099. this.startRecord = true
  152100. }
  152101. Decoder.prototype.SaveRecord = function () {
  152102. printConsole.log('Save Record')
  152103. this.saveRecord = true
  152104. }
  152105. Decoder.prototype.ReceivePanorama = function (data) {
  152106. self.decoder.resetDecoder()
  152107. self.decoder.decodePanorama(data)
  152108. }
  152109. Decoder.prototype.LoadWASM = function (url) {
  152110. printConsole.log('Load WASM from ' + String(url))
  152111. try {
  152112. self.importScripts(url)
  152113. } catch (e) {
  152114. console.log('catch error ', e)
  152115. printConsole.error(e.message, '5003')
  152116. }
  152117. }
  152118. // self.incoming_pkt_queue = new array()
  152119. function getRandomInt(max) {
  152120. return Math.floor(Math.random() * max)
  152121. }
  152122. // console.log(getRandomInt(30));
  152123. self.decoder = new Decoder()
  152124. netArray = []
  152125. var gTmpIdx = 0
  152126. var gLossCnt = 0
  152127. self.onmessage = function (evt) {
  152128. switch (evt.data.t) {
  152129. case 1: // Init Message
  152130. self.decoder.initAll(evt.data.config)
  152131. break
  152132. case 0: // Decode Message
  152133. // console.log('[][Core][WASM],------> ', evt.data)
  152134. gTmpIdx += 1
  152135. randLen = 16
  152136. // randLen = getRandomInt(30)
  152137. // eslint-disable-next-line no-constant-condition
  152138. if (gTmpIdx > 100 && false) {
  152139. var test_jitter_buffer = true
  152140. if (test_jitter_buffer == true) {
  152141. if (netArray.length % 5 == 4) {
  152142. // netArray.insert(netArray.length -1, evt.data)
  152143. netArray.splice(netArray.length - 1, 0, evt.data)
  152144. } else {
  152145. netArray.push(evt.data)
  152146. }
  152147. if (netArray.length > randLen) {
  152148. // 1. jitter
  152149. while (netArray.length > 0) {
  152150. // console.log("[xmedia] array len: %s", netArray.length)
  152151. gLossCnt += 1
  152152. var pkt = netArray.shift()
  152153. // lose pkt
  152154. var dropInterval = 50
  152155. var dropContinousPkts = 3
  152156. if (gLossCnt % dropInterval < dropContinousPkts) {
  152157. if (gLossCnt == dropInterval + dropContinousPkts - 1) {
  152158. gLossCnt = 0
  152159. }
  152160. } else {
  152161. self.decoder.receiveFrame(pkt)
  152162. }
  152163. }
  152164. // // 2. disorder
  152165. // if (incoming_pkt_queue.length % 3) {
  152166. // in[0]
  152167. // in[2]
  152168. // in[1]
  152169. // }
  152170. }
  152171. } else {
  152172. self.decoder.receiveFrame(evt.data)
  152173. }
  152174. } else {
  152175. self.decoder.receiveFrame(evt.data)
  152176. }
  152177. break
  152178. case 2: // Receive used buffer
  152179. self.decoder.receiveBuffer(evt.data)
  152180. break
  152181. case 3: // Unint Message
  152182. self.decoder.uninitDecoder()
  152183. break
  152184. case 4: // Reset status
  152185. self.decoder.resetDecoder()
  152186. break
  152187. case 5: // Start emit
  152188. self.decoder.startEmiter()
  152189. break
  152190. case 6: // Start Record
  152191. self.decoder.StartRecord()
  152192. break
  152193. case 7: // Save Record
  152194. self.decoder.SaveRecord()
  152195. break
  152196. case 8: // Panorama Decode Message
  152197. self.decoder.ReceivePanorama(evt.data)
  152198. break
  152199. case 9: // Select WASM Version
  152200. self.decoder.setPassiveJitter(evt.data.jitterLength)
  152201. self.decoder.LoadWASM(evt.data.url)
  152202. break
  152203. case 100: // change decoder worker status
  152204. self.decoder.changeLogSwitch(evt.data.status)
  152205. break
  152206. }
  152207. }
  152208. }
  152209. `;
  152210. const panorama_width = 4096
  152211. , panorama_height = 2048
  152212. , tile_width = 512
  152213. , tile_height = 256;
  152214. function ToRadius(a) {
  152215. return a / 180 * Math.PI
  152216. }
  152217. function ToAngle(a) {
  152218. return a / Math.PI * 180
  152219. }
  152220. function getAngleInView(a, e) {
  152221. const i = {}
  152222. , o = e.x - a.width * .5
  152223. , s = a.height * .5 - e.y
  152224. , c = -1 * ToRadius(a.angle.pitch)
  152225. , d = ToRadius(a.angle.yaw)
  152226. , _ = a.width / 2 / Math.tan(ToRadius(a.horz_fov / 2))
  152227. , b = Math.sin(c)
  152228. , k = Math.cos(c);
  152229. for (i.yaw = Math.atan2(o, _ * k + s * b),
  152230. i.pitch = Math.atan2((s - _ * Math.tan(c)) * Math.cos(i.yaw), _ + s * Math.tan(c)),
  152231. i.pitch = ToAngle(i.pitch),
  152232. i.yaw = ToAngle(d + i.yaw); i.yaw > 359.9; )
  152233. i.yaw -= 360;
  152234. for (; i.yaw < 0; )
  152235. i.yaw += 360;
  152236. return i
  152237. }
  152238. function getRectangleInView(a) {
  152239. const e = {}
  152240. , i = Array(9)
  152241. , o = a.height
  152242. , s = a.width;
  152243. for (let d = 0, _ = 0; _ <= o; _ += o / 2)
  152244. for (let b = 0; b <= s; b += s / 2,
  152245. d++) {
  152246. const k = {};
  152247. k.x = b,
  152248. k.y = _;
  152249. let j = {};
  152250. j = a,
  152251. j.angle.pitch >= 90 && (j.angle.pitch = 89.999),
  152252. j.angle.pitch <= -90 && (j.angle.pitch = -89.999),
  152253. j.angle.yaw = 0,
  152254. i[d] = getAngleInView(a, k),
  152255. i[d].pitch < -90 ? i[d].pitch = 90 : i[d].pitch > 90 && (i[d].pitch = -90)
  152256. }
  152257. let c = i[0].yaw > i[3].yaw ? 3 : 0;
  152258. return i[c].yaw > i[6].yaw && (c = 6),
  152259. i[c].yaw > i[c + 2].yaw && (i[c + 2].yaw += 360),
  152260. i[c + 2].yaw > i[c].yaw + 180 ? (e.x = 0,
  152261. e.width = panorama_width) : (e.x = (i[c].yaw / 360 - .5) * panorama_width,
  152262. e.width = (i[c + 2].yaw / 360 - .5) * panorama_width - e.x),
  152263. e.y = (.5 - i[i[0].pitch > i[1].pitch ? 0 : 1].pitch / 180) * panorama_height,
  152264. e.height = (.5 - i[i[6].pitch > i[7].pitch ? 7 : 6].pitch / 180) * panorama_height - e.y,
  152265. e
  152266. }
  152267. function MaskSetToOne(a, e) {
  152268. const i = a / 8
  152269. , o = a % 8;
  152270. e.setUint8(i, e.getUint8(i) | 1 << 7 - o)
  152271. }
  152272. function IsAll0(a) {
  152273. return a.getUint32(0) == 0 && a.getUint32(4) == 0
  152274. }
  152275. function getMaskFromTiles(a, e) {
  152276. const i = new DataView(e);
  152277. a.forEach(function(o, s) {
  152278. MaskSetToOne(o, i)
  152279. })
  152280. }
  152281. function operateForDataView(a, e, i, o) {
  152282. i.setUint32(0, o(a.getUint32(0), e.getUint32(0))),
  152283. i.setUint32(4, o(a.getUint32(4), e.getUint32(4)))
  152284. }
  152285. function getTilesInView(a, e) {
  152286. const i = getRectangleInView(a)
  152287. , o = Math.floor(i.x / tile_width)
  152288. , s = Math.floor((i.x + i.width - 1) / tile_width)
  152289. , c = Math.floor(i.y / tile_height)
  152290. , d = Math.floor((i.y + i.height - 1) / tile_height);
  152291. console.log({
  152292. left: o,
  152293. right: s,
  152294. top: c,
  152295. bottom: d
  152296. });
  152297. const b = []
  152298. , k = panorama_height / tile_height;
  152299. for (let j = o; j <= s; j++)
  152300. for (let$ = c; $ <= d; $++)
  152301. b.push(j * k + $);
  152302. return console.log(b),
  152303. getMaskFromTiles(b, e),
  152304. b
  152305. }
  152306. var md5$1 = {
  152307. exports: {}
  152308. };
  152309. (function(module) {
  152310. (function() {
  152311. var ERROR = "input is invalid type"
  152312. , WINDOW = typeof window == "object"
  152313. , root = WINDOW ? window : {};
  152314. root.JS_MD5_NO_WINDOW && (WINDOW = !1);
  152315. var WEB_WORKER = !WINDOW && typeof self == "object"
  152316. , NODE_JS = !root.JS_MD5_NO_NODE_JS && typeof process == "object" && process.versions && process.versions.node;
  152317. NODE_JS ? root = commonjsGlobal : WEB_WORKER && (root = self);
  152318. var COMMON_JS = !root.JS_MD5_NO_COMMON_JS && !0 && module.exports, ARRAY_BUFFER = !root.JS_MD5_NO_ARRAY_BUFFER && typeof ArrayBuffer != "undefined", HEX_CHARS = "0123456789abcdef".split(""), EXTRA = [128, 32768, 8388608, -2147483648], SHIFT = [0, 8, 16, 24], OUTPUT_TYPES = ["hex", "array", "digest", "buffer", "arrayBuffer", "base64"], BASE64_ENCODE_CHAR = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""), blocks = [], buffer8;
  152319. if (ARRAY_BUFFER) {
  152320. var buffer = new ArrayBuffer(68);
  152321. buffer8 = new Uint8Array(buffer),
  152322. blocks = new Uint32Array(buffer)
  152323. }
  152324. (root.JS_MD5_NO_NODE_JS || !Array.isArray) && (Array.isArray = function(a) {
  152325. return Object.prototype.toString.call(a) === "[object Array]"
  152326. }
  152327. ),
  152328. ARRAY_BUFFER && (root.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView) && (ArrayBuffer.isView = function(a) {
  152329. return typeof a == "object" && a.buffer && a.buffer.constructor === ArrayBuffer
  152330. }
  152331. );
  152332. var createOutputMethod = function(a) {
  152333. return function(e, i) {
  152334. return new Md5(!0).update(e, i)[a]()
  152335. }
  152336. }
  152337. , createMethod = function() {
  152338. var a = createOutputMethod("hex");
  152339. NODE_JS && (a = nodeWrap(a)),
  152340. a.getCtx = a.create = function() {
  152341. return new Md5
  152342. }
  152343. ,
  152344. a.update = function(o) {
  152345. return a.create().update(o)
  152346. }
  152347. ;
  152348. for (var e = 0; e < OUTPUT_TYPES.length; ++e) {
  152349. var i = OUTPUT_TYPES[e];
  152350. a[i] = createOutputMethod(i)
  152351. }
  152352. return a
  152353. }
  152354. , nodeWrap = function(method) {
  152355. var crypto = eval("require('crypto')")
  152356. , Buffer = eval("require('buffer').Buffer")
  152357. , nodeMethod = function(a) {
  152358. if (typeof a == "string")
  152359. return crypto.createHash("md5").update(a, "utf8").digest("hex");
  152360. if (a == null)
  152361. throw ERROR;
  152362. return a.constructor === ArrayBuffer && (a = new Uint8Array(a)),
  152363. Array.isArray(a) || ArrayBuffer.isView(a) || a.constructor === Buffer ? crypto.createHash("md5").update(new Buffer(a)).digest("hex") : method(a)
  152364. };
  152365. return nodeMethod
  152366. };
  152367. function Md5(a) {
  152368. if (a)
  152369. blocks[0] = blocks[16] = blocks[1] = blocks[2] = blocks[3] = blocks[4] = blocks[5] = blocks[6] = blocks[7] = blocks[8] = blocks[9] = blocks[10] = blocks[11] = blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0,
  152370. this.blocks = blocks,
  152371. this.buffer8 = buffer8;
  152372. else if (ARRAY_BUFFER) {
  152373. var e = new ArrayBuffer(68);
  152374. this.buffer8 = new Uint8Array(e),
  152375. this.blocks = new Uint32Array(e)
  152376. } else
  152377. this.blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
  152378. this.h0 = this.h1 = this.h2 = this.h3 = this.start = this.bytes = this.hBytes = 0,
  152379. this.finalized = this.hashed = !1,
  152380. this.first = !0
  152381. }
  152382. Md5.prototype.update = function(a, e) {
  152383. if (!this.finalized) {
  152384. for (var i, o = 0, s, c = a.length, d = this.blocks, _ = this.buffer8; o < c; ) {
  152385. if (this.hashed && (this.hashed = !1,
  152386. d[0] = d[16],
  152387. d[16] = d[1] = d[2] = d[3] = d[4] = d[5] = d[6] = d[7] = d[8] = d[9] = d[10] = d[11] = d[12] = d[13] = d[14] = d[15] = 0),
  152388. ARRAY_BUFFER)
  152389. for (s = this.start; o < c && s < 64; ++o)
  152390. i = a.charCodeAt(o),
  152391. e || i < 128 ? _[s++] = i : i < 2048 ? (_[s++] = 192 | i >> 6,
  152392. _[s++] = 128 | i & 63) : i < 55296 || i >= 57344 ? (_[s++] = 224 | i >> 12,
  152393. _[s++] = 128 | i >> 6 & 63,
  152394. _[s++] = 128 | i & 63) : (i = 65536 + ((i & 1023) << 10 | a.charCodeAt(++o) & 1023),
  152395. _[s++] = 240 | i >> 18,
  152396. _[s++] = 128 | i >> 12 & 63,
  152397. _[s++] = 128 | i >> 6 & 63,
  152398. _[s++] = 128 | i & 63);
  152399. else
  152400. for (s = this.start; o < c && s < 64; ++o)
  152401. i = a.charCodeAt(o),
  152402. e || i < 128 ? d[s >> 2] |= i << SHIFT[s++ & 3] : i < 2048 ? (d[s >> 2] |= (192 | i >> 6) << SHIFT[s++ & 3],
  152403. d[s >> 2] |= (128 | i & 63) << SHIFT[s++ & 3]) : i < 55296 || i >= 57344 ? (d[s >> 2] |= (224 | i >> 12) << SHIFT[s++ & 3],
  152404. d[s >> 2] |= (128 | i >> 6 & 63) << SHIFT[s++ & 3],
  152405. d[s >> 2] |= (128 | i & 63) << SHIFT[s++ & 3]) : (i = 65536 + ((i & 1023) << 10 | a.charCodeAt(++o) & 1023),
  152406. d[s >> 2] |= (240 | i >> 18) << SHIFT[s++ & 3],
  152407. d[s >> 2] |= (128 | i >> 12 & 63) << SHIFT[s++ & 3],
  152408. d[s >> 2] |= (128 | i >> 6 & 63) << SHIFT[s++ & 3],
  152409. d[s >> 2] |= (128 | i & 63) << SHIFT[s++ & 3]);
  152410. this.lastByteIndex = s,
  152411. this.bytes += s - this.start,
  152412. s >= 64 ? (this.start = s - 64,
  152413. this.hash(),
  152414. this.hashed = !0) : this.start = s
  152415. }
  152416. return this.bytes > 4294967295 && (this.hBytes += this.bytes / 4294967296 << 0,
  152417. this.bytes = this.bytes % 4294967296),
  152418. this
  152419. }
  152420. }
  152421. ,
  152422. Md5.prototype.finalize = function() {
  152423. if (!this.finalized) {
  152424. this.finalized = !0;
  152425. var a = this.blocks
  152426. , e = this.lastByteIndex;
  152427. a[e >> 2] |= EXTRA[e & 3],
  152428. e >= 56 && (this.hashed || this.hash(),
  152429. a[0] = a[16],
  152430. a[16] = a[1] = a[2] = a[3] = a[4] = a[5] = a[6] = a[7] = a[8] = a[9] = a[10] = a[11] = a[12] = a[13] = a[14] = a[15] = 0),
  152431. a[14] = this.bytes << 3,
  152432. a[15] = this.hBytes << 3 | this.bytes >>> 29,
  152433. this.hash()
  152434. }
  152435. }
  152436. ,
  152437. Md5.prototype.hash = function() {
  152438. var a, e, i, o, s, c, d = this.blocks;
  152439. this.first ? (a = d[0] - 680876937,
  152440. a = (a << 7 | a >>> 25) - 271733879 << 0,
  152441. o = (-1732584194 ^ a & 2004318071) + d[1] - 117830708,
  152442. o = (o << 12 | o >>> 20) + a << 0,
  152443. i = (-271733879 ^ o & (a ^ -271733879)) + d[2] - 1126478375,
  152444. i = (i << 17 | i >>> 15) + o << 0,
  152445. e = (a ^ i & (o ^ a)) + d[3] - 1316259209,
  152446. e = (e << 22 | e >>> 10) + i << 0) : (a = this.h0,
  152447. e = this.h1,
  152448. i = this.h2,
  152449. o = this.h3,
  152450. a += (o ^ e & (i ^ o)) + d[0] - 680876936,
  152451. a = (a << 7 | a >>> 25) + e << 0,
  152452. o += (i ^ a & (e ^ i)) + d[1] - 389564586,
  152453. o = (o << 12 | o >>> 20) + a << 0,
  152454. i += (e ^ o & (a ^ e)) + d[2] + 606105819,
  152455. i = (i << 17 | i >>> 15) + o << 0,
  152456. e += (a ^ i & (o ^ a)) + d[3] - 1044525330,
  152457. e = (e << 22 | e >>> 10) + i << 0),
  152458. a += (o ^ e & (i ^ o)) + d[4] - 176418897,
  152459. a = (a << 7 | a >>> 25) + e << 0,
  152460. o += (i ^ a & (e ^ i)) + d[5] + 1200080426,
  152461. o = (o << 12 | o >>> 20) + a << 0,
  152462. i += (e ^ o & (a ^ e)) + d[6] - 1473231341,
  152463. i = (i << 17 | i >>> 15) + o << 0,
  152464. e += (a ^ i & (o ^ a)) + d[7] - 45705983,
  152465. e = (e << 22 | e >>> 10) + i << 0,
  152466. a += (o ^ e & (i ^ o)) + d[8] + 1770035416,
  152467. a = (a << 7 | a >>> 25) + e << 0,
  152468. o += (i ^ a & (e ^ i)) + d[9] - 1958414417,
  152469. o = (o << 12 | o >>> 20) + a << 0,
  152470. i += (e ^ o & (a ^ e)) + d[10] - 42063,
  152471. i = (i << 17 | i >>> 15) + o << 0,
  152472. e += (a ^ i & (o ^ a)) + d[11] - 1990404162,
  152473. e = (e << 22 | e >>> 10) + i << 0,
  152474. a += (o ^ e & (i ^ o)) + d[12] + 1804603682,
  152475. a = (a << 7 | a >>> 25) + e << 0,
  152476. o += (i ^ a & (e ^ i)) + d[13] - 40341101,
  152477. o = (o << 12 | o >>> 20) + a << 0,
  152478. i += (e ^ o & (a ^ e)) + d[14] - 1502002290,
  152479. i = (i << 17 | i >>> 15) + o << 0,
  152480. e += (a ^ i & (o ^ a)) + d[15] + 1236535329,
  152481. e = (e << 22 | e >>> 10) + i << 0,
  152482. a += (i ^ o & (e ^ i)) + d[1] - 165796510,
  152483. a = (a << 5 | a >>> 27) + e << 0,
  152484. o += (e ^ i & (a ^ e)) + d[6] - 1069501632,
  152485. o = (o << 9 | o >>> 23) + a << 0,
  152486. i += (a ^ e & (o ^ a)) + d[11] + 643717713,
  152487. i = (i << 14 | i >>> 18) + o << 0,
  152488. e += (o ^ a & (i ^ o)) + d[0] - 373897302,
  152489. e = (e << 20 | e >>> 12) + i << 0,
  152490. a += (i ^ o & (e ^ i)) + d[5] - 701558691,
  152491. a = (a << 5 | a >>> 27) + e << 0,
  152492. o += (e ^ i & (a ^ e)) + d[10] + 38016083,
  152493. o = (o << 9 | o >>> 23) + a << 0,
  152494. i += (a ^ e & (o ^ a)) + d[15] - 660478335,
  152495. i = (i << 14 | i >>> 18) + o << 0,
  152496. e += (o ^ a & (i ^ o)) + d[4] - 405537848,
  152497. e = (e << 20 | e >>> 12) + i << 0,
  152498. a += (i ^ o & (e ^ i)) + d[9] + 568446438,
  152499. a = (a << 5 | a >>> 27) + e << 0,
  152500. o += (e ^ i & (a ^ e)) + d[14] - 1019803690,
  152501. o = (o << 9 | o >>> 23) + a << 0,
  152502. i += (a ^ e & (o ^ a)) + d[3] - 187363961,
  152503. i = (i << 14 | i >>> 18) + o << 0,
  152504. e += (o ^ a & (i ^ o)) + d[8] + 1163531501,
  152505. e = (e << 20 | e >>> 12) + i << 0,
  152506. a += (i ^ o & (e ^ i)) + d[13] - 1444681467,
  152507. a = (a << 5 | a >>> 27) + e << 0,
  152508. o += (e ^ i & (a ^ e)) + d[2] - 51403784,
  152509. o = (o << 9 | o >>> 23) + a << 0,
  152510. i += (a ^ e & (o ^ a)) + d[7] + 1735328473,
  152511. i = (i << 14 | i >>> 18) + o << 0,
  152512. e += (o ^ a & (i ^ o)) + d[12] - 1926607734,
  152513. e = (e << 20 | e >>> 12) + i << 0,
  152514. s = e ^ i,
  152515. a += (s ^ o) + d[5] - 378558,
  152516. a = (a << 4 | a >>> 28) + e << 0,
  152517. o += (s ^ a) + d[8] - 2022574463,
  152518. o = (o << 11 | o >>> 21) + a << 0,
  152519. c = o ^ a,
  152520. i += (c ^ e) + d[11] + 1839030562,
  152521. i = (i << 16 | i >>> 16) + o << 0,
  152522. e += (c ^ i) + d[14] - 35309556,
  152523. e = (e << 23 | e >>> 9) + i << 0,
  152524. s = e ^ i,
  152525. a += (s ^ o) + d[1] - 1530992060,
  152526. a = (a << 4 | a >>> 28) + e << 0,
  152527. o += (s ^ a) + d[4] + 1272893353,
  152528. o = (o << 11 | o >>> 21) + a << 0,
  152529. c = o ^ a,
  152530. i += (c ^ e) + d[7] - 155497632,
  152531. i = (i << 16 | i >>> 16) + o << 0,
  152532. e += (c ^ i) + d[10] - 1094730640,
  152533. e = (e << 23 | e >>> 9) + i << 0,
  152534. s = e ^ i,
  152535. a += (s ^ o) + d[13] + 681279174,
  152536. a = (a << 4 | a >>> 28) + e << 0,
  152537. o += (s ^ a) + d[0] - 358537222,
  152538. o = (o << 11 | o >>> 21) + a << 0,
  152539. c = o ^ a,
  152540. i += (c ^ e) + d[3] - 722521979,
  152541. i = (i << 16 | i >>> 16) + o << 0,
  152542. e += (c ^ i) + d[6] + 76029189,
  152543. e = (e << 23 | e >>> 9) + i << 0,
  152544. s = e ^ i,
  152545. a += (s ^ o) + d[9] - 640364487,
  152546. a = (a << 4 | a >>> 28) + e << 0,
  152547. o += (s ^ a) + d[12] - 421815835,
  152548. o = (o << 11 | o >>> 21) + a << 0,
  152549. c = o ^ a,
  152550. i += (c ^ e) + d[15] + 530742520,
  152551. i = (i << 16 | i >>> 16) + o << 0,
  152552. e += (c ^ i) + d[2] - 995338651,
  152553. e = (e << 23 | e >>> 9) + i << 0,
  152554. a += (i ^ (e | ~o)) + d[0] - 198630844,
  152555. a = (a << 6 | a >>> 26) + e << 0,
  152556. o += (e ^ (a | ~i)) + d[7] + 1126891415,
  152557. o = (o << 10 | o >>> 22) + a << 0,
  152558. i += (a ^ (o | ~e)) + d[14] - 1416354905,
  152559. i = (i << 15 | i >>> 17) + o << 0,
  152560. e += (o ^ (i | ~a)) + d[5] - 57434055,
  152561. e = (e << 21 | e >>> 11) + i << 0,
  152562. a += (i ^ (e | ~o)) + d[12] + 1700485571,
  152563. a = (a << 6 | a >>> 26) + e << 0,
  152564. o += (e ^ (a | ~i)) + d[3] - 1894986606,
  152565. o = (o << 10 | o >>> 22) + a << 0,
  152566. i += (a ^ (o | ~e)) + d[10] - 1051523,
  152567. i = (i << 15 | i >>> 17) + o << 0,
  152568. e += (o ^ (i | ~a)) + d[1] - 2054922799,
  152569. e = (e << 21 | e >>> 11) + i << 0,
  152570. a += (i ^ (e | ~o)) + d[8] + 1873313359,
  152571. a = (a << 6 | a >>> 26) + e << 0,
  152572. o += (e ^ (a | ~i)) + d[15] - 30611744,
  152573. o = (o << 10 | o >>> 22) + a << 0,
  152574. i += (a ^ (o | ~e)) + d[6] - 1560198380,
  152575. i = (i << 15 | i >>> 17) + o << 0,
  152576. e += (o ^ (i | ~a)) + d[13] + 1309151649,
  152577. e = (e << 21 | e >>> 11) + i << 0,
  152578. a += (i ^ (e | ~o)) + d[4] - 145523070,
  152579. a = (a << 6 | a >>> 26) + e << 0,
  152580. o += (e ^ (a | ~i)) + d[11] - 1120210379,
  152581. o = (o << 10 | o >>> 22) + a << 0,
  152582. i += (a ^ (o | ~e)) + d[2] + 718787259,
  152583. i = (i << 15 | i >>> 17) + o << 0,
  152584. e += (o ^ (i | ~a)) + d[9] - 343485551,
  152585. e = (e << 21 | e >>> 11) + i << 0,
  152586. this.first ? (this.h0 = a + 1732584193 << 0,
  152587. this.h1 = e - 271733879 << 0,
  152588. this.h2 = i - 1732584194 << 0,
  152589. this.h3 = o + 271733878 << 0,
  152590. this.first = !1) : (this.h0 = this.h0 + a << 0,
  152591. this.h1 = this.h1 + e << 0,
  152592. this.h2 = this.h2 + i << 0,
  152593. this.h3 = this.h3 + o << 0)
  152594. }
  152595. ,
  152596. Md5.prototype.hex = function() {
  152597. this.finalize();
  152598. var a = this.h0
  152599. , e = this.h1
  152600. , i = this.h2
  152601. , o = this.h3;
  152602. return HEX_CHARS[a >> 4 & 15] + HEX_CHARS[a & 15] + HEX_CHARS[a >> 12 & 15] + HEX_CHARS[a >> 8 & 15] + HEX_CHARS[a >> 20 & 15] + HEX_CHARS[a >> 16 & 15] + HEX_CHARS[a >> 28 & 15] + HEX_CHARS[a >> 24 & 15] + HEX_CHARS[e >> 4 & 15] + HEX_CHARS[e & 15] + HEX_CHARS[e >> 12 & 15] + HEX_CHARS[e >> 8 & 15] + HEX_CHARS[e >> 20 & 15] + HEX_CHARS[e >> 16 & 15] + HEX_CHARS[e >> 28 & 15] + HEX_CHARS[e >> 24 & 15] + HEX_CHARS[i >> 4 & 15] + HEX_CHARS[i & 15] + HEX_CHARS[i >> 12 & 15] + HEX_CHARS[i >> 8 & 15] + HEX_CHARS[i >> 20 & 15] + HEX_CHARS[i >> 16 & 15] + HEX_CHARS[i >> 28 & 15] + HEX_CHARS[i >> 24 & 15] + HEX_CHARS[o >> 4 & 15] + HEX_CHARS[o & 15] + HEX_CHARS[o >> 12 & 15] + HEX_CHARS[o >> 8 & 15] + HEX_CHARS[o >> 20 & 15] + HEX_CHARS[o >> 16 & 15] + HEX_CHARS[o >> 28 & 15] + HEX_CHARS[o >> 24 & 15]
  152603. }
  152604. ,
  152605. Md5.prototype.toString = Md5.prototype.hex,
  152606. Md5.prototype.digest = function(a) {
  152607. if (a === "hex")
  152608. return this.hex();
  152609. this.finalize();
  152610. var e = this.h0
  152611. , i = this.h1
  152612. , o = this.h2
  152613. , s = this.h3
  152614. , c = [e & 255, e >> 8 & 255, e >> 16 & 255, e >> 24 & 255, i & 255, i >> 8 & 255, i >> 16 & 255, i >> 24 & 255, o & 255, o >> 8 & 255, o >> 16 & 255, o >> 24 & 255, s & 255, s >> 8 & 255, s >> 16 & 255, s >> 24 & 255];
  152615. return c
  152616. }
  152617. ,
  152618. Md5.prototype.array = Md5.prototype.digest,
  152619. Md5.prototype.arrayBuffer = function() {
  152620. this.finalize();
  152621. var a = new ArrayBuffer(16)
  152622. , e = new Uint32Array(a);
  152623. return e[0] = this.h0,
  152624. e[1] = this.h1,
  152625. e[2] = this.h2,
  152626. e[3] = this.h3,
  152627. a
  152628. }
  152629. ,
  152630. Md5.prototype.buffer = Md5.prototype.arrayBuffer,
  152631. Md5.prototype.base64 = function() {
  152632. for (var a, e, i, o = "", s = this.array(), c = 0; c < 15; )
  152633. a = s[c++],
  152634. e = s[c++],
  152635. i = s[c++],
  152636. o += BASE64_ENCODE_CHAR[a >>> 2] + BASE64_ENCODE_CHAR[(a << 4 | e >>> 4) & 63] + BASE64_ENCODE_CHAR[(e << 2 | i >>> 6) & 63] + BASE64_ENCODE_CHAR[i & 63];
  152637. return a = s[c],
  152638. o += BASE64_ENCODE_CHAR[a >>> 2] + BASE64_ENCODE_CHAR[a << 4 & 63] + "==",
  152639. o
  152640. }
  152641. ;
  152642. var exports = createMethod();
  152643. COMMON_JS ? module.exports = exports : root.md5 = exports
  152644. }
  152645. )()
  152646. }
  152647. )(md5$1);
  152648. var crypto = {
  152649. exports: {}
  152650. };
  152651. (function(a) {
  152652. var e = e || function(i, o) {
  152653. var s = {}
  152654. , c = s.lib = {}
  152655. , d = function() {}
  152656. , _ = c.Base = {
  152657. extend: function(rt) {
  152658. d.prototype = this;
  152659. var it = new d;
  152660. return rt && it.mixIn(rt),
  152661. it.hasOwnProperty("init") || (it.init = function() {
  152662. it.$super.init.apply(this, arguments)
  152663. }
  152664. ),
  152665. it.init.prototype = it,
  152666. it.$super = this,
  152667. it
  152668. },
  152669. create: function() {
  152670. var rt = this.extend();
  152671. return rt.init.apply(rt, arguments),
  152672. rt
  152673. },
  152674. init: function() {},
  152675. mixIn: function(rt) {
  152676. for (var it in rt)
  152677. rt.hasOwnProperty(it) && (this[it] = rt[it]);
  152678. rt.hasOwnProperty("toString") && (this.toString = rt.toString)
  152679. },
  152680. clone: function() {
  152681. return this.init.prototype.extend(this)
  152682. }
  152683. }
  152684. , b = c.WordArray = _.extend({
  152685. init: function(rt, it) {
  152686. rt = this.words = rt || [],
  152687. this.sigBytes = it != o ? it : 4 * rt.length
  152688. },
  152689. toString: function(rt) {
  152690. return (rt || j).stringify(this)
  152691. },
  152692. concat: function(rt) {
  152693. var it = this.words
  152694. , nt = rt.words
  152695. , ot = this.sigBytes;
  152696. if (rt = rt.sigBytes,
  152697. this.clamp(),
  152698. ot % 4)
  152699. for (var at = 0; at < rt; at++)
  152700. it[ot + at >>> 2] |= (nt[at >>> 2] >>> 24 - 8 * (at % 4) & 255) << 24 - 8 * ((ot + at) % 4);
  152701. else if (65535 < nt.length)
  152702. for (at = 0; at < rt; at += 4)
  152703. it[ot + at >>> 2] = nt[at >>> 2];
  152704. else
  152705. it.push.apply(it, nt);
  152706. return this.sigBytes += rt,
  152707. this
  152708. },
  152709. clamp: function() {
  152710. var rt = this.words
  152711. , it = this.sigBytes;
  152712. rt[it >>> 2] &= 4294967295 << 32 - 8 * (it % 4),
  152713. rt.length = i.ceil(it / 4)
  152714. },
  152715. clone: function() {
  152716. var rt = _.clone.call(this);
  152717. return rt.words = this.words.slice(0),
  152718. rt
  152719. },
  152720. random: function(rt) {
  152721. for (var it = [], nt = 0; nt < rt; nt += 4)
  152722. it.push(4294967296 * i.random() | 0);
  152723. return new b.init(it,rt)
  152724. }
  152725. })
  152726. , k = s.enc = {}
  152727. , j = k.Hex = {
  152728. stringify: function(rt) {
  152729. var it = rt.words;
  152730. rt = rt.sigBytes;
  152731. for (var nt = [], ot = 0; ot < rt; ot++) {
  152732. var at = it[ot >>> 2] >>> 24 - 8 * (ot % 4) & 255;
  152733. nt.push((at >>> 4).toString(16)),
  152734. nt.push((at & 15).toString(16))
  152735. }
  152736. return nt.join("")
  152737. },
  152738. parse: function(rt) {
  152739. for (var it = rt.length, nt = [], ot = 0; ot < it; ot += 2)
  152740. nt[ot >>> 3] |= parseInt(rt.substr(ot, 2), 16) << 24 - 4 * (ot % 8);
  152741. return new b.init(nt,it / 2)
  152742. }
  152743. }
  152744. , $ = k.Latin1 = {
  152745. stringify: function(rt) {
  152746. var it = rt.words;
  152747. rt = rt.sigBytes;
  152748. for (var nt = [], ot = 0; ot < rt; ot++)
  152749. nt.push(String.fromCharCode(it[ot >>> 2] >>> 24 - 8 * (ot % 4) & 255));
  152750. return nt.join("")
  152751. },
  152752. parse: function(rt) {
  152753. for (var it = rt.length, nt = [], ot = 0; ot < it; ot++)
  152754. nt[ot >>> 2] |= (rt.charCodeAt(ot) & 255) << 24 - 8 * (ot % 4);
  152755. return new b.init(nt,it)
  152756. }
  152757. }
  152758. , _e = k.Utf8 = {
  152759. stringify: function(rt) {
  152760. try {
  152761. return decodeURIComponent(escape($.stringify(rt)))
  152762. } catch {
  152763. throw Error("Malformed UTF-8 data")
  152764. }
  152765. },
  152766. parse: function(rt) {
  152767. return $.parse(unescape(encodeURIComponent(rt)))
  152768. }
  152769. }
  152770. , et = c.BufferedBlockAlgorithm = _.extend({
  152771. reset: function() {
  152772. this._data = new b.init,
  152773. this._nDataBytes = 0
  152774. },
  152775. _append: function(rt) {
  152776. typeof rt == "string" && (rt = _e.parse(rt)),
  152777. this._data.concat(rt),
  152778. this._nDataBytes += rt.sigBytes
  152779. },
  152780. _process: function(rt) {
  152781. var it = this._data
  152782. , nt = it.words
  152783. , ot = it.sigBytes
  152784. , at = this.blockSize
  152785. , st = ot / (4 * at)
  152786. , st = rt ? i.ceil(st) : i.max((st | 0) - this._minBufferSize, 0);
  152787. if (rt = st * at,
  152788. ot = i.min(4 * rt, ot),
  152789. rt) {
  152790. for (var ut = 0; ut < rt; ut += at)
  152791. this._doProcessBlock(nt, ut);
  152792. ut = nt.splice(0, rt),
  152793. it.sigBytes -= ot
  152794. }
  152795. return new b.init(ut,ot)
  152796. },
  152797. clone: function() {
  152798. var rt = _.clone.call(this);
  152799. return rt._data = this._data.clone(),
  152800. rt
  152801. },
  152802. _minBufferSize: 0
  152803. });
  152804. c.Hasher = et.extend({
  152805. cfg: _.extend(),
  152806. init: function(rt) {
  152807. this.cfg = this.cfg.extend(rt),
  152808. this.reset()
  152809. },
  152810. reset: function() {
  152811. et.reset.call(this),
  152812. this._doReset()
  152813. },
  152814. update: function(rt) {
  152815. return this._append(rt),
  152816. this._process(),
  152817. this
  152818. },
  152819. finalize: function(rt) {
  152820. return rt && this._append(rt),
  152821. this._doFinalize()
  152822. },
  152823. blockSize: 16,
  152824. _createHelper: function(rt) {
  152825. return function(it, nt) {
  152826. return new rt.init(nt).finalize(it)
  152827. }
  152828. },
  152829. _createHmacHelper: function(rt) {
  152830. return function(it, nt) {
  152831. return new tt.HMAC.init(rt,nt).finalize(it)
  152832. }
  152833. }
  152834. });
  152835. var tt = s.algo = {};
  152836. return s
  152837. }(Math);
  152838. (function() {
  152839. var i = e
  152840. , d = i.lib
  152841. , o = d.WordArray
  152842. , s = d.Hasher
  152843. , c = []
  152844. , d = i.algo.SHA1 = s.extend({
  152845. _doReset: function() {
  152846. this._hash = new o.init([1732584193, 4023233417, 2562383102, 271733878, 3285377520])
  152847. },
  152848. _doProcessBlock: function(_, b) {
  152849. for (var k = this._hash.words, j = k[0], $ = k[1], _e = k[2], et = k[3], tt = k[4], rt = 0; 80 > rt; rt++) {
  152850. if (16 > rt)
  152851. c[rt] = _[b + rt] | 0;
  152852. else {
  152853. var it = c[rt - 3] ^ c[rt - 8] ^ c[rt - 14] ^ c[rt - 16];
  152854. c[rt] = it << 1 | it >>> 31
  152855. }
  152856. it = (j << 5 | j >>> 27) + tt + c[rt],
  152857. it = 20 > rt ? it + (($ & _e | ~$ & et) + 1518500249) : 40 > rt ? it + (($ ^ _e ^ et) + 1859775393) : 60 > rt ? it + (($ & _e | $ & et | _e & et) - 1894007588) : it + (($ ^ _e ^ et) - 899497514),
  152858. tt = et,
  152859. et = _e,
  152860. _e = $ << 30 | $ >>> 2,
  152861. $ = j,
  152862. j = it
  152863. }
  152864. k[0] = k[0] + j | 0,
  152865. k[1] = k[1] + $ | 0,
  152866. k[2] = k[2] + _e | 0,
  152867. k[3] = k[3] + et | 0,
  152868. k[4] = k[4] + tt | 0
  152869. },
  152870. _doFinalize: function() {
  152871. var _ = this._data
  152872. , b = _.words
  152873. , k = 8 * this._nDataBytes
  152874. , j = 8 * _.sigBytes;
  152875. return b[j >>> 5] |= 128 << 24 - j % 32,
  152876. b[(j + 64 >>> 9 << 4) + 14] = Math.floor(k / 4294967296),
  152877. b[(j + 64 >>> 9 << 4) + 15] = k,
  152878. _.sigBytes = 4 * b.length,
  152879. this._process(),
  152880. this._hash
  152881. },
  152882. clone: function() {
  152883. var _ = s.clone.call(this);
  152884. return _._hash = this._hash.clone(),
  152885. _
  152886. }
  152887. });
  152888. i.SHA1 = s._createHelper(d),
  152889. i.HmacSHA1 = s._createHmacHelper(d)
  152890. }
  152891. )(),
  152892. function() {
  152893. var i = e
  152894. , o = i.enc.Utf8;
  152895. i.algo.HMAC = i.lib.Base.extend({
  152896. init: function(s, c) {
  152897. s = this._hasher = new s.init,
  152898. typeof c == "string" && (c = o.parse(c));
  152899. var d = s.blockSize
  152900. , _ = 4 * d;
  152901. c.sigBytes > _ && (c = s.finalize(c)),
  152902. c.clamp();
  152903. for (var b = this._oKey = c.clone(), k = this._iKey = c.clone(), j = b.words, $ = k.words, _e = 0; _e < d; _e++)
  152904. j[_e] ^= 1549556828,
  152905. $[_e] ^= 909522486;
  152906. b.sigBytes = k.sigBytes = _,
  152907. this.reset()
  152908. },
  152909. reset: function() {
  152910. var s = this._hasher;
  152911. s.reset(),
  152912. s.update(this._iKey)
  152913. },
  152914. update: function(s) {
  152915. return this._hasher.update(s),
  152916. this
  152917. },
  152918. finalize: function(s) {
  152919. var c = this._hasher;
  152920. return s = c.finalize(s),
  152921. c.reset(),
  152922. c.finalize(this._oKey.clone().concat(s))
  152923. }
  152924. })
  152925. }(),
  152926. function() {
  152927. var i = e
  152928. , o = i.lib
  152929. , s = o.WordArray
  152930. , c = i.enc;
  152931. c.Base64 = {
  152932. stringify: function(d) {
  152933. var _ = d.words
  152934. , b = d.sigBytes
  152935. , k = this._map;
  152936. d.clamp();
  152937. for (var j = [], $ = 0; $ < b; $ += 3)
  152938. for (var _e = _[$ >>> 2] >>> 24 - $ % 4 * 8 & 255, et = _[$ + 1 >>> 2] >>> 24 - ($ + 1) % 4 * 8 & 255, tt = _[$ + 2 >>> 2] >>> 24 - ($ + 2) % 4 * 8 & 255, rt = _e << 16 | et << 8 | tt, it = 0; it < 4 && $ + it * .75 < b; it++)
  152939. j.push(k.charAt(rt >>> 6 * (3 - it) & 63));
  152940. var nt = k.charAt(64);
  152941. if (nt)
  152942. for (; j.length % 4; )
  152943. j.push(nt);
  152944. return j.join("")
  152945. },
  152946. parse: function(d) {
  152947. var _ = d.length
  152948. , b = this._map
  152949. , k = b.charAt(64);
  152950. if (k) {
  152951. var j = d.indexOf(k);
  152952. j != -1 && (_ = j)
  152953. }
  152954. for (var $ = [], _e = 0, et = 0; et < _; et++)
  152955. if (et % 4) {
  152956. var tt = b.indexOf(d.charAt(et - 1)) << et % 4 * 2
  152957. , rt = b.indexOf(d.charAt(et)) >>> 6 - et % 4 * 2;
  152958. $[_e >>> 2] |= (tt | rt) << 24 - _e % 4 * 8,
  152959. _e++
  152960. }
  152961. return s.create($, _e)
  152962. },
  152963. _map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
  152964. }
  152965. }(),
  152966. a.exports = e
  152967. }
  152968. )(crypto);
  152969. var domParser = {}
  152970. , sax = {}
  152971. , nameStartChar = /[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/
  152972. , nameChar = new RegExp("[\\-\\.0-9" + nameStartChar.source.slice(1, -1) + "\\u00B7\\u0300-\\u036F\\u203F-\\u2040]")
  152973. , tagNamePattern = new RegExp("^" + nameStartChar.source + nameChar.source + "*(?::" + nameStartChar.source + nameChar.source + "*)?$")
  152974. , S_TAG = 0
  152975. , S_ATTR = 1
  152976. , S_ATTR_SPACE = 2
  152977. , S_EQ = 3
  152978. , S_ATTR_NOQUOT_VALUE = 4
  152979. , S_ATTR_END = 5
  152980. , S_TAG_SPACE = 6
  152981. , S_TAG_CLOSE = 7;
  152982. function XMLReader$1() {}
  152983. XMLReader$1.prototype = {
  152984. parse: function(a, e, i) {
  152985. var o = this.domBuilder;
  152986. o.startDocument(),
  152987. _copy(e, e = {}),
  152988. parse(a, e, i, o, this.errorHandler),
  152989. o.endDocument()
  152990. }
  152991. };
  152992. function parse(a, e, i, o, s) {
  152993. function c(Et) {
  152994. if (Et > 65535) {
  152995. Et -= 65536;
  152996. var At = 55296 + (Et >> 10)
  152997. , gt = 56320 + (Et & 1023);
  152998. return String.fromCharCode(At, gt)
  152999. } else
  153000. return String.fromCharCode(Et)
  153001. }
  153002. function d(Et) {
  153003. var At = Et.slice(1, -1);
  153004. return At in i ? i[At] : At.charAt(0) === "#" ? c(parseInt(At.substr(1).replace("x", "0x"))) : (s.error("entity not found:" + Et),
  153005. Et)
  153006. }
  153007. function _(Et) {
  153008. if (Et > rt) {
  153009. var At = a.substring(rt, Et).replace(/&#?\w+;/g, d);
  153010. _e && b(rt),
  153011. o.characters(At, 0, Et - rt),
  153012. rt = Et
  153013. }
  153014. }
  153015. function b(Et, At) {
  153016. for (; Et >= j && (At = $.exec(a)); )
  153017. k = At.index,
  153018. j = k + At[0].length,
  153019. _e.lineNumber++;
  153020. _e.columnNumber = Et - k + 1
  153021. }
  153022. for (var k = 0, j = 0, $ = /.*(?:\r\n?|\n)|.*$/g, _e = o.locator, et = [{
  153023. currentNSMap: e
  153024. }], tt = {}, rt = 0; ; ) {
  153025. try {
  153026. var it = a.indexOf("<", rt);
  153027. if (it < 0) {
  153028. if (!a.substr(rt).match(/^\s*$/)) {
  153029. var nt = o.doc
  153030. , ot = nt.createTextNode(a.substr(rt));
  153031. nt.appendChild(ot),
  153032. o.currentElement = ot
  153033. }
  153034. return
  153035. }
  153036. switch (it > rt && _(it),
  153037. a.charAt(it + 1)) {
  153038. case "/":
  153039. var dt = a.indexOf(">", it + 3)
  153040. , at = a.substring(it + 2, dt)
  153041. , st = et.pop();
  153042. dt < 0 ? (at = a.substring(it + 2).replace(/[\s<].*/, ""),
  153043. s.error("end tag name: " + at + " is not complete:" + st.tagName),
  153044. dt = it + 1 + at.length) : at.match(/\s</) && (at = at.replace(/[\s<].*/, ""),
  153045. s.error("end tag name: " + at + " maybe not complete"),
  153046. dt = it + 1 + at.length);
  153047. var ut = st.localNSMap
  153048. , ct = st.tagName == at
  153049. , lt = ct || st.tagName && st.tagName.toLowerCase() == at.toLowerCase();
  153050. if (lt) {
  153051. if (o.endElement(st.uri, st.localName, at),
  153052. ut)
  153053. for (var ft in ut)
  153054. o.endPrefixMapping(ft);
  153055. ct || s.fatalError("end tag name: " + at + " is not match the current start tagName:" + st.tagName)
  153056. } else
  153057. et.push(st);
  153058. dt++;
  153059. break;
  153060. case "?":
  153061. _e && b(it),
  153062. dt = parseInstruction(a, it, o);
  153063. break;
  153064. case "!":
  153065. _e && b(it),
  153066. dt = parseDCC(a, it, o, s);
  153067. break;
  153068. default:
  153069. _e && b(it);
  153070. var ht = new ElementAttributes
  153071. , pt = et[et.length - 1].currentNSMap
  153072. , dt = parseElementStartPart(a, it, ht, pt, d, s)
  153073. , _t = ht.length;
  153074. if (!ht.closed && fixSelfClosed(a, dt, ht.tagName, tt) && (ht.closed = !0,
  153075. i.nbsp || s.warning("unclosed xml attribute")),
  153076. _e && _t) {
  153077. for (var mt = copyLocator(_e, {}), vt = 0; vt < _t; vt++) {
  153078. var yt = ht[vt];
  153079. b(yt.offset),
  153080. yt.locator = copyLocator(_e, {})
  153081. }
  153082. o.locator = mt,
  153083. appendElement$1(ht, o, pt) && et.push(ht),
  153084. o.locator = _e
  153085. } else
  153086. appendElement$1(ht, o, pt) && et.push(ht);
  153087. ht.uri === "http://www.w3.org/1999/xhtml" && !ht.closed ? dt = parseHtmlSpecialContent(a, dt, ht.tagName, d, o) : dt++
  153088. }
  153089. } catch (Et) {
  153090. s.error("element parse error: " + Et),
  153091. dt = -1
  153092. }
  153093. dt > rt ? rt = dt : _(Math.max(it, rt) + 1)
  153094. }
  153095. }
  153096. function copyLocator(a, e) {
  153097. return e.lineNumber = a.lineNumber,
  153098. e.columnNumber = a.columnNumber,
  153099. e
  153100. }
  153101. function parseElementStartPart(a, e, i, o, s, c) {
  153102. for (var d, _, b = ++e, k = S_TAG; ; ) {
  153103. var j = a.charAt(b);
  153104. switch (j) {
  153105. case "=":
  153106. if (k === S_ATTR)
  153107. d = a.slice(e, b),
  153108. k = S_EQ;
  153109. else if (k === S_ATTR_SPACE)
  153110. k = S_EQ;
  153111. else
  153112. throw new Error("attribute equal must after attrName");
  153113. break;
  153114. case "'":
  153115. case '"':
  153116. if (k === S_EQ || k === S_ATTR)
  153117. if (k === S_ATTR && (c.warning('attribute value must after "="'),
  153118. d = a.slice(e, b)),
  153119. e = b + 1,
  153120. b = a.indexOf(j, e),
  153121. b > 0)
  153122. _ = a.slice(e, b).replace(/&#?\w+;/g, s),
  153123. i.add(d, _, e - 1),
  153124. k = S_ATTR_END;
  153125. else
  153126. throw new Error("attribute value no end '" + j + "' match");
  153127. else if (k == S_ATTR_NOQUOT_VALUE)
  153128. _ = a.slice(e, b).replace(/&#?\w+;/g, s),
  153129. i.add(d, _, e),
  153130. c.warning('attribute "' + d + '" missed start quot(' + j + ")!!"),
  153131. e = b + 1,
  153132. k = S_ATTR_END;
  153133. else
  153134. throw new Error('attribute value must after "="');
  153135. break;
  153136. case "/":
  153137. switch (k) {
  153138. case S_TAG:
  153139. i.setTagName(a.slice(e, b));
  153140. case S_ATTR_END:
  153141. case S_TAG_SPACE:
  153142. case S_TAG_CLOSE:
  153143. k = S_TAG_CLOSE,
  153144. i.closed = !0;
  153145. case S_ATTR_NOQUOT_VALUE:
  153146. case S_ATTR:
  153147. case S_ATTR_SPACE:
  153148. break;
  153149. default:
  153150. throw new Error("attribute invalid close char('/')")
  153151. }
  153152. break;
  153153. case "":
  153154. return c.error("unexpected end of input"),
  153155. k == S_TAG && i.setTagName(a.slice(e, b)),
  153156. b;
  153157. case ">":
  153158. switch (k) {
  153159. case S_TAG:
  153160. i.setTagName(a.slice(e, b));
  153161. case S_ATTR_END:
  153162. case S_TAG_SPACE:
  153163. case S_TAG_CLOSE:
  153164. break;
  153165. case S_ATTR_NOQUOT_VALUE:
  153166. case S_ATTR:
  153167. _ = a.slice(e, b),
  153168. _.slice(-1) === "/" && (i.closed = !0,
  153169. _ = _.slice(0, -1));
  153170. case S_ATTR_SPACE:
  153171. k === S_ATTR_SPACE && (_ = d),
  153172. k == S_ATTR_NOQUOT_VALUE ? (c.warning('attribute "' + _ + '" missed quot(")!!'),
  153173. i.add(d, _.replace(/&#?\w+;/g, s), e)) : ((o[""] !== "http://www.w3.org/1999/xhtml" || !_.match(/^(?:disabled|checked|selected)$/i)) && c.warning('attribute "' + _ + '" missed value!! "' + _ + '" instead!!'),
  153174. i.add(_, _, e));
  153175. break;
  153176. case S_EQ:
  153177. throw new Error("attribute value missed!!")
  153178. }
  153179. return b;
  153180. case "\x80":
  153181. j = " ";
  153182. default:
  153183. if (j <= " ")
  153184. switch (k) {
  153185. case S_TAG:
  153186. i.setTagName(a.slice(e, b)),
  153187. k = S_TAG_SPACE;
  153188. break;
  153189. case S_ATTR:
  153190. d = a.slice(e, b),
  153191. k = S_ATTR_SPACE;
  153192. break;
  153193. case S_ATTR_NOQUOT_VALUE:
  153194. var _ = a.slice(e, b).replace(/&#?\w+;/g, s);
  153195. c.warning('attribute "' + _ + '" missed quot(")!!'),
  153196. i.add(d, _, e);
  153197. case S_ATTR_END:
  153198. k = S_TAG_SPACE;
  153199. break
  153200. }
  153201. else
  153202. switch (k) {
  153203. case S_ATTR_SPACE:
  153204. i.tagName,
  153205. (o[""] !== "http://www.w3.org/1999/xhtml" || !d.match(/^(?:disabled|checked|selected)$/i)) && c.warning('attribute "' + d + '" missed value!! "' + d + '" instead2!!'),
  153206. i.add(d, d, e),
  153207. e = b,
  153208. k = S_ATTR;
  153209. break;
  153210. case S_ATTR_END:
  153211. c.warning('attribute space is required"' + d + '"!!');
  153212. case S_TAG_SPACE:
  153213. k = S_ATTR,
  153214. e = b;
  153215. break;
  153216. case S_EQ:
  153217. k = S_ATTR_NOQUOT_VALUE,
  153218. e = b;
  153219. break;
  153220. case S_TAG_CLOSE:
  153221. throw new Error("elements closed character '/' and '>' must be connected to")
  153222. }
  153223. }
  153224. b++
  153225. }
  153226. }
  153227. function appendElement$1(a, e, i) {
  153228. for (var o = a.tagName, s = null, $ = a.length; $--; ) {
  153229. var c = a[$]
  153230. , d = c.qName
  153231. , _ = c.value
  153232. , _e = d.indexOf(":");
  153233. if (_e > 0)
  153234. var b = c.prefix = d.slice(0, _e)
  153235. , k = d.slice(_e + 1)
  153236. , j = b === "xmlns" && k;
  153237. else
  153238. k = d,
  153239. b = null,
  153240. j = d === "xmlns" && "";
  153241. c.localName = k,
  153242. j !== !1 && (s == null && (s = {},
  153243. _copy(i, i = {})),
  153244. i[j] = s[j] = _,
  153245. c.uri = "http://www.w3.org/2000/xmlns/",
  153246. e.startPrefixMapping(j, _))
  153247. }
  153248. for (var $ = a.length; $--; ) {
  153249. c = a[$];
  153250. var b = c.prefix;
  153251. b && (b === "xml" && (c.uri = "http://www.w3.org/XML/1998/namespace"),
  153252. b !== "xmlns" && (c.uri = i[b || ""]))
  153253. }
  153254. var _e = o.indexOf(":");
  153255. _e > 0 ? (b = a.prefix = o.slice(0, _e),
  153256. k = a.localName = o.slice(_e + 1)) : (b = null,
  153257. k = a.localName = o);
  153258. var et = a.uri = i[b || ""];
  153259. if (e.startElement(et, k, o, a),
  153260. a.closed) {
  153261. if (e.endElement(et, k, o),
  153262. s)
  153263. for (b in s)
  153264. e.endPrefixMapping(b)
  153265. } else
  153266. return a.currentNSMap = i,
  153267. a.localNSMap = s,
  153268. !0
  153269. }
  153270. function parseHtmlSpecialContent(a, e, i, o, s) {
  153271. if (/^(?:script|textarea)$/i.test(i)) {
  153272. var c = a.indexOf("</" + i + ">", e)
  153273. , d = a.substring(e + 1, c);
  153274. if (/[&<]/.test(d))
  153275. return /^script$/i.test(i) ? (s.characters(d, 0, d.length),
  153276. c) : (d = d.replace(/&#?\w+;/g, o),
  153277. s.characters(d, 0, d.length),
  153278. c)
  153279. }
  153280. return e + 1
  153281. }
  153282. function fixSelfClosed(a, e, i, o) {
  153283. var s = o[i];
  153284. return s == null && (s = a.lastIndexOf("</" + i + ">"),
  153285. s < e && (s = a.lastIndexOf("</" + i)),
  153286. o[i] = s),
  153287. s < e
  153288. }
  153289. function _copy(a, e) {
  153290. for (var i in a)
  153291. e[i] = a[i]
  153292. }
  153293. function parseDCC(a, e, i, o) {
  153294. var s = a.charAt(e + 2);
  153295. switch (s) {
  153296. case "-":
  153297. if (a.charAt(e + 3) === "-") {
  153298. var c = a.indexOf("-->", e + 4);
  153299. return c > e ? (i.comment(a, e + 4, c - e - 4),
  153300. c + 3) : (o.error("Unclosed comment"),
  153301. -1)
  153302. } else
  153303. return -1;
  153304. default:
  153305. if (a.substr(e + 3, 6) == "CDATA[") {
  153306. var c = a.indexOf("]]>", e + 9);
  153307. return i.startCDATA(),
  153308. i.characters(a, e + 9, c - e - 9),
  153309. i.endCDATA(),
  153310. c + 3
  153311. }
  153312. var d = split(a, e)
  153313. , _ = d.length;
  153314. if (_ > 1 && /!doctype/i.test(d[0][0])) {
  153315. var b = d[1][0]
  153316. , k = _ > 3 && /^public$/i.test(d[2][0]) && d[3][0]
  153317. , j = _ > 4 && d[4][0]
  153318. , $ = d[_ - 1];
  153319. return i.startDTD(b, k && k.replace(/^(['"])(.*?)\1$/, "$2"), j && j.replace(/^(['"])(.*?)\1$/, "$2")),
  153320. i.endDTD(),
  153321. $.index + $[0].length
  153322. }
  153323. }
  153324. return -1
  153325. }
  153326. function parseInstruction(a, e, i) {
  153327. var o = a.indexOf("?>", e);
  153328. if (o) {
  153329. var s = a.substring(e, o).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);
  153330. return s ? (s[0].length,
  153331. i.processingInstruction(s[1], s[2]),
  153332. o + 2) : -1
  153333. }
  153334. return -1
  153335. }
  153336. function ElementAttributes(a) {}
  153337. ElementAttributes.prototype = {
  153338. setTagName: function(a) {
  153339. if (!tagNamePattern.test(a))
  153340. throw new Error("invalid tagName:" + a);
  153341. this.tagName = a
  153342. },
  153343. add: function(a, e, i) {
  153344. if (!tagNamePattern.test(a))
  153345. throw new Error("invalid attribute:" + a);
  153346. this[this.length++] = {
  153347. qName: a,
  153348. value: e,
  153349. offset: i
  153350. }
  153351. },
  153352. length: 0,
  153353. getLocalName: function(a) {
  153354. return this[a].localName
  153355. },
  153356. getLocator: function(a) {
  153357. return this[a].locator
  153358. },
  153359. getQName: function(a) {
  153360. return this[a].qName
  153361. },
  153362. getURI: function(a) {
  153363. return this[a].uri
  153364. },
  153365. getValue: function(a) {
  153366. return this[a].value
  153367. }
  153368. };
  153369. function _set_proto_(a, e) {
  153370. return a.__proto__ = e,
  153371. a
  153372. }
  153373. _set_proto_({}, _set_proto_.prototype)instanceof _set_proto_ || (_set_proto_ = function(a, e) {
  153374. function i() {}
  153375. i.prototype = e,
  153376. i = new i;
  153377. for (e in a)
  153378. i[e] = a[e];
  153379. return i
  153380. }
  153381. );
  153382. function split(a, e) {
  153383. var i, o = [], s = /'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;
  153384. for (s.lastIndex = e,
  153385. s.exec(a); i = s.exec(a); )
  153386. if (o.push(i),
  153387. i[1])
  153388. return o
  153389. }
  153390. sax.XMLReader = XMLReader$1;
  153391. var dom = {};
  153392. function copy(a, e) {
  153393. for (var i in a)
  153394. e[i] = a[i]
  153395. }
  153396. function _extends(a, e) {
  153397. var i = a.prototype;
  153398. if (Object.create) {
  153399. var o = Object.create(e.prototype);
  153400. i.__proto__ = o
  153401. }
  153402. if (!(i instanceof e)) {
  153403. let c = function() {};
  153404. var s = c;
  153405. c.prototype = e.prototype,
  153406. c = new c,
  153407. copy(i, c),
  153408. a.prototype = i = c
  153409. }
  153410. i.constructor != a && (typeof a != "function" && console.error("unknow Class:" + a),
  153411. i.constructor = a)
  153412. }
  153413. var htmlns = "http://www.w3.org/1999/xhtml"
  153414. , NodeType = {}
  153415. , ELEMENT_NODE = NodeType.ELEMENT_NODE = 1
  153416. , ATTRIBUTE_NODE = NodeType.ATTRIBUTE_NODE = 2
  153417. , TEXT_NODE = NodeType.TEXT_NODE = 3
  153418. , CDATA_SECTION_NODE = NodeType.CDATA_SECTION_NODE = 4
  153419. , ENTITY_REFERENCE_NODE = NodeType.ENTITY_REFERENCE_NODE = 5
  153420. , ENTITY_NODE = NodeType.ENTITY_NODE = 6
  153421. , PROCESSING_INSTRUCTION_NODE = NodeType.PROCESSING_INSTRUCTION_NODE = 7
  153422. , COMMENT_NODE = NodeType.COMMENT_NODE = 8
  153423. , DOCUMENT_NODE = NodeType.DOCUMENT_NODE = 9
  153424. , DOCUMENT_TYPE_NODE = NodeType.DOCUMENT_TYPE_NODE = 10
  153425. , DOCUMENT_FRAGMENT_NODE = NodeType.DOCUMENT_FRAGMENT_NODE = 11
  153426. , NOTATION_NODE = NodeType.NOTATION_NODE = 12
  153427. , ExceptionCode = {}
  153428. , ExceptionMessage = {};
  153429. ExceptionCode.INDEX_SIZE_ERR = (ExceptionMessage[1] = "Index size error",
  153430. 1);
  153431. ExceptionCode.DOMSTRING_SIZE_ERR = (ExceptionMessage[2] = "DOMString size error",
  153432. 2);
  153433. var HIERARCHY_REQUEST_ERR = ExceptionCode.HIERARCHY_REQUEST_ERR = (ExceptionMessage[3] = "Hierarchy request error",
  153434. 3);
  153435. ExceptionCode.WRONG_DOCUMENT_ERR = (ExceptionMessage[4] = "Wrong document",
  153436. 4);
  153437. ExceptionCode.INVALID_CHARACTER_ERR = (ExceptionMessage[5] = "Invalid character",
  153438. 5);
  153439. ExceptionCode.NO_DATA_ALLOWED_ERR = (ExceptionMessage[6] = "No data allowed",
  153440. 6);
  153441. ExceptionCode.NO_MODIFICATION_ALLOWED_ERR = (ExceptionMessage[7] = "No modification allowed",
  153442. 7);
  153443. var NOT_FOUND_ERR = ExceptionCode.NOT_FOUND_ERR = (ExceptionMessage[8] = "Not found",
  153444. 8);
  153445. ExceptionCode.NOT_SUPPORTED_ERR = (ExceptionMessage[9] = "Not supported",
  153446. 9);
  153447. var INUSE_ATTRIBUTE_ERR = ExceptionCode.INUSE_ATTRIBUTE_ERR = (ExceptionMessage[10] = "Attribute in use",
  153448. 10);
  153449. ExceptionCode.INVALID_STATE_ERR = (ExceptionMessage[11] = "Invalid state",
  153450. 11);
  153451. ExceptionCode.SYNTAX_ERR = (ExceptionMessage[12] = "Syntax error",
  153452. 12);
  153453. ExceptionCode.INVALID_MODIFICATION_ERR = (ExceptionMessage[13] = "Invalid modification",
  153454. 13);
  153455. ExceptionCode.NAMESPACE_ERR = (ExceptionMessage[14] = "Invalid namespace",
  153456. 14);
  153457. ExceptionCode.INVALID_ACCESS_ERR = (ExceptionMessage[15] = "Invalid access",
  153458. 15);
  153459. function DOMException$1(a, e) {
  153460. if (e instanceof Error)
  153461. var i = e;
  153462. else
  153463. i = this,
  153464. Error.call(this, ExceptionMessage[a]),
  153465. this.message = ExceptionMessage[a],
  153466. Error.captureStackTrace && Error.captureStackTrace(this, DOMException$1);
  153467. return i.code = a,
  153468. e && (this.message = this.message + ": " + e),
  153469. i
  153470. }
  153471. DOMException$1.prototype = Error.prototype;
  153472. copy(ExceptionCode, DOMException$1);
  153473. function NodeList() {}
  153474. NodeList.prototype = {
  153475. length: 0,
  153476. item: function(a) {
  153477. return this[a] || null
  153478. },
  153479. toString: function(a, e) {
  153480. for (var i = [], o = 0; o < this.length; o++)
  153481. serializeToString(this[o], i, a, e);
  153482. return i.join("")
  153483. }
  153484. };
  153485. function LiveNodeList(a, e) {
  153486. this._node = a,
  153487. this._refresh = e,
  153488. _updateLiveList(this)
  153489. }
  153490. function _updateLiveList(a) {
  153491. var e = a._node._inc || a._node.ownerDocument._inc;
  153492. if (a._inc != e) {
  153493. var i = a._refresh(a._node);
  153494. __set__(a, "length", i.length),
  153495. copy(i, a),
  153496. a._inc = e
  153497. }
  153498. }
  153499. LiveNodeList.prototype.item = function(a) {
  153500. return _updateLiveList(this),
  153501. this[a]
  153502. }
  153503. ;
  153504. _extends(LiveNodeList, NodeList);
  153505. function NamedNodeMap() {}
  153506. function _findNodeIndex(a, e) {
  153507. for (var i = a.length; i--; )
  153508. if (a[i] === e)
  153509. return i
  153510. }
  153511. function _addNamedNode(a, e, i, o) {
  153512. if (o ? e[_findNodeIndex(e, o)] = i : e[e.length++] = i,
  153513. a) {
  153514. i.ownerElement = a;
  153515. var s = a.ownerDocument;
  153516. s && (o && _onRemoveAttribute(s, a, o),
  153517. _onAddAttribute(s, a, i))
  153518. }
  153519. }
  153520. function _removeNamedNode(a, e, i) {
  153521. var o = _findNodeIndex(e, i);
  153522. if (o >= 0) {
  153523. for (var s = e.length - 1; o < s; )
  153524. e[o] = e[++o];
  153525. if (e.length = s,
  153526. a) {
  153527. var c = a.ownerDocument;
  153528. c && (_onRemoveAttribute(c, a, i),
  153529. i.ownerElement = null)
  153530. }
  153531. } else
  153532. throw DOMException$1(NOT_FOUND_ERR, new Error(a.tagName + "@" + i))
  153533. }
  153534. NamedNodeMap.prototype = {
  153535. length: 0,
  153536. item: NodeList.prototype.item,
  153537. getNamedItem: function(a) {
  153538. for (var e = this.length; e--; ) {
  153539. var i = this[e];
  153540. if (i.nodeName == a)
  153541. return i
  153542. }
  153543. },
  153544. setNamedItem: function(a) {
  153545. var e = a.ownerElement;
  153546. if (e && e != this._ownerElement)
  153547. throw new DOMException$1(INUSE_ATTRIBUTE_ERR);
  153548. var i = this.getNamedItem(a.nodeName);
  153549. return _addNamedNode(this._ownerElement, this, a, i),
  153550. i
  153551. },
  153552. setNamedItemNS: function(a) {
  153553. var e = a.ownerElement, i;
  153554. if (e && e != this._ownerElement)
  153555. throw new DOMException$1(INUSE_ATTRIBUTE_ERR);
  153556. return i = this.getNamedItemNS(a.namespaceURI, a.localName),
  153557. _addNamedNode(this._ownerElement, this, a, i),
  153558. i
  153559. },
  153560. removeNamedItem: function(a) {
  153561. var e = this.getNamedItem(a);
  153562. return _removeNamedNode(this._ownerElement, this, e),
  153563. e
  153564. },
  153565. removeNamedItemNS: function(a, e) {
  153566. var i = this.getNamedItemNS(a, e);
  153567. return _removeNamedNode(this._ownerElement, this, i),
  153568. i
  153569. },
  153570. getNamedItemNS: function(a, e) {
  153571. for (var i = this.length; i--; ) {
  153572. var o = this[i];
  153573. if (o.localName == e && o.namespaceURI == a)
  153574. return o
  153575. }
  153576. return null
  153577. }
  153578. };
  153579. function DOMImplementation$1(a) {
  153580. if (this._features = {},
  153581. a)
  153582. for (var e in a)
  153583. this._features = a[e]
  153584. }
  153585. DOMImplementation$1.prototype = {
  153586. hasFeature: function(a, e) {
  153587. var i = this._features[a.toLowerCase()];
  153588. return !!(i && (!e || e in i))
  153589. },
  153590. createDocument: function(a, e, i) {
  153591. var o = new Document;
  153592. if (o.implementation = this,
  153593. o.childNodes = new NodeList,
  153594. o.doctype = i,
  153595. i && o.appendChild(i),
  153596. e) {
  153597. var s = o.createElementNS(a, e);
  153598. o.appendChild(s)
  153599. }
  153600. return o
  153601. },
  153602. createDocumentType: function(a, e, i) {
  153603. var o = new DocumentType;
  153604. return o.name = a,
  153605. o.nodeName = a,
  153606. o.publicId = e,
  153607. o.systemId = i,
  153608. o
  153609. }
  153610. };
  153611. function Node$1() {}
  153612. Node$1.prototype = {
  153613. firstChild: null,
  153614. lastChild: null,
  153615. previousSibling: null,
  153616. nextSibling: null,
  153617. attributes: null,
  153618. parentNode: null,
  153619. childNodes: null,
  153620. ownerDocument: null,
  153621. nodeValue: null,
  153622. namespaceURI: null,
  153623. prefix: null,
  153624. localName: null,
  153625. insertBefore: function(a, e) {
  153626. return _insertBefore(this, a, e)
  153627. },
  153628. replaceChild: function(a, e) {
  153629. this.insertBefore(a, e),
  153630. e && this.removeChild(e)
  153631. },
  153632. removeChild: function(a) {
  153633. return _removeChild(this, a)
  153634. },
  153635. appendChild: function(a) {
  153636. return this.insertBefore(a, null)
  153637. },
  153638. hasChildNodes: function() {
  153639. return this.firstChild != null
  153640. },
  153641. cloneNode: function(a) {
  153642. return cloneNode(this.ownerDocument || this, this, a)
  153643. },
  153644. normalize: function() {
  153645. for (var a = this.firstChild; a; ) {
  153646. var e = a.nextSibling;
  153647. e && e.nodeType == TEXT_NODE && a.nodeType == TEXT_NODE ? (this.removeChild(e),
  153648. a.appendData(e.data)) : (a.normalize(),
  153649. a = e)
  153650. }
  153651. },
  153652. isSupported: function(a, e) {
  153653. return this.ownerDocument.implementation.hasFeature(a, e)
  153654. },
  153655. hasAttributes: function() {
  153656. return this.attributes.length > 0
  153657. },
  153658. lookupPrefix: function(a) {
  153659. for (var e = this; e; ) {
  153660. var i = e._nsMap;
  153661. if (i) {
  153662. for (var o in i)
  153663. if (i[o] == a)
  153664. return o
  153665. }
  153666. e = e.nodeType == ATTRIBUTE_NODE ? e.ownerDocument : e.parentNode
  153667. }
  153668. return null
  153669. },
  153670. lookupNamespaceURI: function(a) {
  153671. for (var e = this; e; ) {
  153672. var i = e._nsMap;
  153673. if (i && a in i)
  153674. return i[a];
  153675. e = e.nodeType == ATTRIBUTE_NODE ? e.ownerDocument : e.parentNode
  153676. }
  153677. return null
  153678. },
  153679. isDefaultNamespace: function(a) {
  153680. var e = this.lookupPrefix(a);
  153681. return e == null
  153682. }
  153683. };
  153684. function _xmlEncoder(a) {
  153685. return a == "<" && "&lt;" || a == ">" && "&gt;" || a == "&" && "&amp;" || a == '"' && "&quot;" || "&#" + a.charCodeAt() + ";"
  153686. }
  153687. copy(NodeType, Node$1);
  153688. copy(NodeType, Node$1.prototype);
  153689. function _visitNode(a, e) {
  153690. if (e(a))
  153691. return !0;
  153692. if (a = a.firstChild)
  153693. do
  153694. if (_visitNode(a, e))
  153695. return !0;
  153696. while (a = a.nextSibling)
  153697. }
  153698. function Document() {}
  153699. function _onAddAttribute(a, e, i) {
  153700. a && a._inc++;
  153701. var o = i.namespaceURI;
  153702. o == "http://www.w3.org/2000/xmlns/" && (e._nsMap[i.prefix ? i.localName : ""] = i.value)
  153703. }
  153704. function _onRemoveAttribute(a, e, i, o) {
  153705. a && a._inc++;
  153706. var s = i.namespaceURI;
  153707. s == "http://www.w3.org/2000/xmlns/" && delete e._nsMap[i.prefix ? i.localName : ""]
  153708. }
  153709. function _onUpdateChild(a, e, i) {
  153710. if (a && a._inc) {
  153711. a._inc++;
  153712. var o = e.childNodes;
  153713. if (i)
  153714. o[o.length++] = i;
  153715. else {
  153716. for (var s = e.firstChild, c = 0; s; )
  153717. o[c++] = s,
  153718. s = s.nextSibling;
  153719. o.length = c
  153720. }
  153721. }
  153722. }
  153723. function _removeChild(a, e) {
  153724. var i = e.previousSibling
  153725. , o = e.nextSibling;
  153726. return i ? i.nextSibling = o : a.firstChild = o,
  153727. o ? o.previousSibling = i : a.lastChild = i,
  153728. _onUpdateChild(a.ownerDocument, a),
  153729. e
  153730. }
  153731. function _insertBefore(a, e, i) {
  153732. var o = e.parentNode;
  153733. if (o && o.removeChild(e),
  153734. e.nodeType === DOCUMENT_FRAGMENT_NODE) {
  153735. var s = e.firstChild;
  153736. if (s == null)
  153737. return e;
  153738. var c = e.lastChild
  153739. } else
  153740. s = c = e;
  153741. var d = i ? i.previousSibling : a.lastChild;
  153742. s.previousSibling = d,
  153743. c.nextSibling = i,
  153744. d ? d.nextSibling = s : a.firstChild = s,
  153745. i == null ? a.lastChild = c : i.previousSibling = c;
  153746. do
  153747. s.parentNode = a;
  153748. while (s !== c && (s = s.nextSibling));
  153749. return _onUpdateChild(a.ownerDocument || a, a),
  153750. e.nodeType == DOCUMENT_FRAGMENT_NODE && (e.firstChild = e.lastChild = null),
  153751. e
  153752. }
  153753. function _appendSingleChild(a, e) {
  153754. var i = e.parentNode;
  153755. if (i) {
  153756. var o = a.lastChild;
  153757. i.removeChild(e);
  153758. var o = a.lastChild
  153759. }
  153760. var o = a.lastChild;
  153761. return e.parentNode = a,
  153762. e.previousSibling = o,
  153763. e.nextSibling = null,
  153764. o ? o.nextSibling = e : a.firstChild = e,
  153765. a.lastChild = e,
  153766. _onUpdateChild(a.ownerDocument, a, e),
  153767. e
  153768. }
  153769. Document.prototype = {
  153770. nodeName: "#document",
  153771. nodeType: DOCUMENT_NODE,
  153772. doctype: null,
  153773. documentElement: null,
  153774. _inc: 1,
  153775. insertBefore: function(a, e) {
  153776. if (a.nodeType == DOCUMENT_FRAGMENT_NODE) {
  153777. for (var i = a.firstChild; i; ) {
  153778. var o = i.nextSibling;
  153779. this.insertBefore(i, e),
  153780. i = o
  153781. }
  153782. return a
  153783. }
  153784. return this.documentElement == null && a.nodeType == ELEMENT_NODE && (this.documentElement = a),
  153785. _insertBefore(this, a, e),
  153786. a.ownerDocument = this,
  153787. a
  153788. },
  153789. removeChild: function(a) {
  153790. return this.documentElement == a && (this.documentElement = null),
  153791. _removeChild(this, a)
  153792. },
  153793. importNode: function(a, e) {
  153794. return importNode(this, a, e)
  153795. },
  153796. getElementById: function(a) {
  153797. var e = null;
  153798. return _visitNode(this.documentElement, function(i) {
  153799. if (i.nodeType == ELEMENT_NODE && i.getAttribute("id") == a)
  153800. return e = i,
  153801. !0
  153802. }),
  153803. e
  153804. },
  153805. createElement: function(a) {
  153806. var e = new Element;
  153807. e.ownerDocument = this,
  153808. e.nodeName = a,
  153809. e.tagName = a,
  153810. e.childNodes = new NodeList;
  153811. var i = e.attributes = new NamedNodeMap;
  153812. return i._ownerElement = e,
  153813. e
  153814. },
  153815. createDocumentFragment: function() {
  153816. var a = new DocumentFragment;
  153817. return a.ownerDocument = this,
  153818. a.childNodes = new NodeList,
  153819. a
  153820. },
  153821. createTextNode: function(a) {
  153822. var e = new Text;
  153823. return e.ownerDocument = this,
  153824. e.appendData(a),
  153825. e
  153826. },
  153827. createComment: function(a) {
  153828. var e = new Comment;
  153829. return e.ownerDocument = this,
  153830. e.appendData(a),
  153831. e
  153832. },
  153833. createCDATASection: function(a) {
  153834. var e = new CDATASection;
  153835. return e.ownerDocument = this,
  153836. e.appendData(a),
  153837. e
  153838. },
  153839. createProcessingInstruction: function(a, e) {
  153840. var i = new ProcessingInstruction;
  153841. return i.ownerDocument = this,
  153842. i.tagName = i.target = a,
  153843. i.nodeValue = i.data = e,
  153844. i
  153845. },
  153846. createAttribute: function(a) {
  153847. var e = new Attr;
  153848. return e.ownerDocument = this,
  153849. e.name = a,
  153850. e.nodeName = a,
  153851. e.localName = a,
  153852. e.specified = !0,
  153853. e
  153854. },
  153855. createEntityReference: function(a) {
  153856. var e = new EntityReference;
  153857. return e.ownerDocument = this,
  153858. e.nodeName = a,
  153859. e
  153860. },
  153861. createElementNS: function(a, e) {
  153862. var i = new Element
  153863. , o = e.split(":")
  153864. , s = i.attributes = new NamedNodeMap;
  153865. return i.childNodes = new NodeList,
  153866. i.ownerDocument = this,
  153867. i.nodeName = e,
  153868. i.tagName = e,
  153869. i.namespaceURI = a,
  153870. o.length == 2 ? (i.prefix = o[0],
  153871. i.localName = o[1]) : i.localName = e,
  153872. s._ownerElement = i,
  153873. i
  153874. },
  153875. createAttributeNS: function(a, e) {
  153876. var i = new Attr
  153877. , o = e.split(":");
  153878. return i.ownerDocument = this,
  153879. i.nodeName = e,
  153880. i.name = e,
  153881. i.namespaceURI = a,
  153882. i.specified = !0,
  153883. o.length == 2 ? (i.prefix = o[0],
  153884. i.localName = o[1]) : i.localName = e,
  153885. i
  153886. }
  153887. };
  153888. _extends(Document, Node$1);
  153889. function Element() {
  153890. this._nsMap = {}
  153891. }
  153892. Element.prototype = {
  153893. nodeType: ELEMENT_NODE,
  153894. hasAttribute: function(a) {
  153895. return this.getAttributeNode(a) != null
  153896. },
  153897. getAttribute: function(a) {
  153898. var e = this.getAttributeNode(a);
  153899. return e && e.value || ""
  153900. },
  153901. getAttributeNode: function(a) {
  153902. return this.attributes.getNamedItem(a)
  153903. },
  153904. setAttribute: function(a, e) {
  153905. var i = this.ownerDocument.createAttribute(a);
  153906. i.value = i.nodeValue = "" + e,
  153907. this.setAttributeNode(i)
  153908. },
  153909. removeAttribute: function(a) {
  153910. var e = this.getAttributeNode(a);
  153911. e && this.removeAttributeNode(e)
  153912. },
  153913. appendChild: function(a) {
  153914. return a.nodeType === DOCUMENT_FRAGMENT_NODE ? this.insertBefore(a, null) : _appendSingleChild(this, a)
  153915. },
  153916. setAttributeNode: function(a) {
  153917. return this.attributes.setNamedItem(a)
  153918. },
  153919. setAttributeNodeNS: function(a) {
  153920. return this.attributes.setNamedItemNS(a)
  153921. },
  153922. removeAttributeNode: function(a) {
  153923. return this.attributes.removeNamedItem(a.nodeName)
  153924. },
  153925. removeAttributeNS: function(a, e) {
  153926. var i = this.getAttributeNodeNS(a, e);
  153927. i && this.removeAttributeNode(i)
  153928. },
  153929. hasAttributeNS: function(a, e) {
  153930. return this.getAttributeNodeNS(a, e) != null
  153931. },
  153932. getAttributeNS: function(a, e) {
  153933. var i = this.getAttributeNodeNS(a, e);
  153934. return i && i.value || ""
  153935. },
  153936. setAttributeNS: function(a, e, i) {
  153937. var o = this.ownerDocument.createAttributeNS(a, e);
  153938. o.value = o.nodeValue = "" + i,
  153939. this.setAttributeNode(o)
  153940. },
  153941. getAttributeNodeNS: function(a, e) {
  153942. return this.attributes.getNamedItemNS(a, e)
  153943. },
  153944. getElementsByTagName: function(a) {
  153945. return new LiveNodeList(this,function(e) {
  153946. var i = [];
  153947. return _visitNode(e, function(o) {
  153948. o !== e && o.nodeType == ELEMENT_NODE && (a === "*" || o.tagName == a) && i.push(o)
  153949. }),
  153950. i
  153951. }
  153952. )
  153953. },
  153954. getElementsByTagNameNS: function(a, e) {
  153955. return new LiveNodeList(this,function(i) {
  153956. var o = [];
  153957. return _visitNode(i, function(s) {
  153958. s !== i && s.nodeType === ELEMENT_NODE && (a === "*" || s.namespaceURI === a) && (e === "*" || s.localName == e) && o.push(s)
  153959. }),
  153960. o
  153961. }
  153962. )
  153963. }
  153964. };
  153965. Document.prototype.getElementsByTagName = Element.prototype.getElementsByTagName;
  153966. Document.prototype.getElementsByTagNameNS = Element.prototype.getElementsByTagNameNS;
  153967. _extends(Element, Node$1);
  153968. function Attr() {}
  153969. Attr.prototype.nodeType = ATTRIBUTE_NODE;
  153970. _extends(Attr, Node$1);
  153971. function CharacterData() {}
  153972. CharacterData.prototype = {
  153973. data: "",
  153974. substringData: function(a, e) {
  153975. return this.data.substring(a, a + e)
  153976. },
  153977. appendData: function(a) {
  153978. a = this.data + a,
  153979. this.nodeValue = this.data = a,
  153980. this.length = a.length
  153981. },
  153982. insertData: function(a, e) {
  153983. this.replaceData(a, 0, e)
  153984. },
  153985. appendChild: function(a) {
  153986. throw new Error(ExceptionMessage[HIERARCHY_REQUEST_ERR])
  153987. },
  153988. deleteData: function(a, e) {
  153989. this.replaceData(a, e, "")
  153990. },
  153991. replaceData: function(a, e, i) {
  153992. var o = this.data.substring(0, a)
  153993. , s = this.data.substring(a + e);
  153994. i = o + i + s,
  153995. this.nodeValue = this.data = i,
  153996. this.length = i.length
  153997. }
  153998. };
  153999. _extends(CharacterData, Node$1);
  154000. function Text() {}
  154001. Text.prototype = {
  154002. nodeName: "#text",
  154003. nodeType: TEXT_NODE,
  154004. splitText: function(a) {
  154005. var e = this.data
  154006. , i = e.substring(a);
  154007. e = e.substring(0, a),
  154008. this.data = this.nodeValue = e,
  154009. this.length = e.length;
  154010. var o = this.ownerDocument.createTextNode(i);
  154011. return this.parentNode && this.parentNode.insertBefore(o, this.nextSibling),
  154012. o
  154013. }
  154014. };
  154015. _extends(Text, CharacterData);
  154016. function Comment() {}
  154017. Comment.prototype = {
  154018. nodeName: "#comment",
  154019. nodeType: COMMENT_NODE
  154020. };
  154021. _extends(Comment, CharacterData);
  154022. function CDATASection() {}
  154023. CDATASection.prototype = {
  154024. nodeName: "#cdata-section",
  154025. nodeType: CDATA_SECTION_NODE
  154026. };
  154027. _extends(CDATASection, CharacterData);
  154028. function DocumentType() {}
  154029. DocumentType.prototype.nodeType = DOCUMENT_TYPE_NODE;
  154030. _extends(DocumentType, Node$1);
  154031. function Notation() {}
  154032. Notation.prototype.nodeType = NOTATION_NODE;
  154033. _extends(Notation, Node$1);
  154034. function Entity() {}
  154035. Entity.prototype.nodeType = ENTITY_NODE;
  154036. _extends(Entity, Node$1);
  154037. function EntityReference() {}
  154038. EntityReference.prototype.nodeType = ENTITY_REFERENCE_NODE;
  154039. _extends(EntityReference, Node$1);
  154040. function DocumentFragment() {}
  154041. DocumentFragment.prototype.nodeName = "#document-fragment";
  154042. DocumentFragment.prototype.nodeType = DOCUMENT_FRAGMENT_NODE;
  154043. _extends(DocumentFragment, Node$1);
  154044. function ProcessingInstruction() {}
  154045. ProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE;
  154046. _extends(ProcessingInstruction, Node$1);
  154047. function XMLSerializer$1() {}
  154048. XMLSerializer$1.prototype.serializeToString = function(a, e, i) {
  154049. return nodeSerializeToString.call(a, e, i)
  154050. }
  154051. ;
  154052. Node$1.prototype.toString = nodeSerializeToString;
  154053. function nodeSerializeToString(a, e) {
  154054. var i = []
  154055. , o = this.nodeType == 9 ? this.documentElement : this
  154056. , s = o.prefix
  154057. , c = o.namespaceURI;
  154058. if (c && s == null) {
  154059. var s = o.lookupPrefix(c);
  154060. if (s == null)
  154061. var d = [{
  154062. namespace: c,
  154063. prefix: null
  154064. }]
  154065. }
  154066. return serializeToString(this, i, a, e, d),
  154067. i.join("")
  154068. }
  154069. function needNamespaceDefine(a, e, i) {
  154070. var o = a.prefix || ""
  154071. , s = a.namespaceURI;
  154072. if (!o && !s || o === "xml" && s === "http://www.w3.org/XML/1998/namespace" || s == "http://www.w3.org/2000/xmlns/")
  154073. return !1;
  154074. for (var c = i.length; c--; ) {
  154075. var d = i[c];
  154076. if (d.prefix == o)
  154077. return d.namespace != s
  154078. }
  154079. return !0
  154080. }
  154081. function serializeToString(a, e, i, o, s) {
  154082. if (o)
  154083. if (a = o(a),
  154084. a) {
  154085. if (typeof a == "string") {
  154086. e.push(a);
  154087. return
  154088. }
  154089. } else
  154090. return;
  154091. switch (a.nodeType) {
  154092. case ELEMENT_NODE:
  154093. s || (s = []),
  154094. s.length;
  154095. var c = a.attributes
  154096. , d = c.length
  154097. , et = a.firstChild
  154098. , _ = a.tagName;
  154099. i = htmlns === a.namespaceURI || i,
  154100. e.push("<", _);
  154101. for (var b = 0; b < d; b++) {
  154102. var k = c.item(b);
  154103. k.prefix == "xmlns" ? s.push({
  154104. prefix: k.localName,
  154105. namespace: k.value
  154106. }) : k.nodeName == "xmlns" && s.push({
  154107. prefix: "",
  154108. namespace: k.value
  154109. })
  154110. }
  154111. for (var b = 0; b < d; b++) {
  154112. var k = c.item(b);
  154113. if (needNamespaceDefine(k, i, s)) {
  154114. var j = k.prefix || ""
  154115. , $ = k.namespaceURI
  154116. , _e = j ? " xmlns:" + j : " xmlns";
  154117. e.push(_e, '="', $, '"'),
  154118. s.push({
  154119. prefix: j,
  154120. namespace: $
  154121. })
  154122. }
  154123. serializeToString(k, e, i, o, s)
  154124. }
  154125. if (needNamespaceDefine(a, i, s)) {
  154126. var j = a.prefix || ""
  154127. , $ = a.namespaceURI
  154128. , _e = j ? " xmlns:" + j : " xmlns";
  154129. e.push(_e, '="', $, '"'),
  154130. s.push({
  154131. prefix: j,
  154132. namespace: $
  154133. })
  154134. }
  154135. if (et || i && !/^(?:meta|link|img|br|hr|input)$/i.test(_)) {
  154136. if (e.push(">"),
  154137. i && /^script$/i.test(_))
  154138. for (; et; )
  154139. et.data ? e.push(et.data) : serializeToString(et, e, i, o, s),
  154140. et = et.nextSibling;
  154141. else
  154142. for (; et; )
  154143. serializeToString(et, e, i, o, s),
  154144. et = et.nextSibling;
  154145. e.push("</", _, ">")
  154146. } else
  154147. e.push("/>");
  154148. return;
  154149. case DOCUMENT_NODE:
  154150. case DOCUMENT_FRAGMENT_NODE:
  154151. for (var et = a.firstChild; et; )
  154152. serializeToString(et, e, i, o, s),
  154153. et = et.nextSibling;
  154154. return;
  154155. case ATTRIBUTE_NODE:
  154156. return e.push(" ", a.name, '="', a.value.replace(/[<&"]/g, _xmlEncoder), '"');
  154157. case TEXT_NODE:
  154158. return e.push(a.data.replace(/[<&]/g, _xmlEncoder));
  154159. case CDATA_SECTION_NODE:
  154160. return e.push("<![CDATA[", a.data, "]]>");
  154161. case COMMENT_NODE:
  154162. return e.push("<!--", a.data, "-->");
  154163. case DOCUMENT_TYPE_NODE:
  154164. var tt = a.publicId
  154165. , rt = a.systemId;
  154166. if (e.push("<!DOCTYPE ", a.name),
  154167. tt)
  154168. e.push(' PUBLIC "', tt),
  154169. rt && rt != "." && e.push('" "', rt),
  154170. e.push('">');
  154171. else if (rt && rt != ".")
  154172. e.push(' SYSTEM "', rt, '">');
  154173. else {
  154174. var it = a.internalSubset;
  154175. it && e.push(" [", it, "]"),
  154176. e.push(">")
  154177. }
  154178. return;
  154179. case PROCESSING_INSTRUCTION_NODE:
  154180. return e.push("<?", a.target, " ", a.data, "?>");
  154181. case ENTITY_REFERENCE_NODE:
  154182. return e.push("&", a.nodeName, ";");
  154183. default:
  154184. e.push("??", a.nodeName)
  154185. }
  154186. }
  154187. function importNode(a, e, i) {
  154188. var o;
  154189. switch (e.nodeType) {
  154190. case ELEMENT_NODE:
  154191. o = e.cloneNode(!1),
  154192. o.ownerDocument = a;
  154193. case DOCUMENT_FRAGMENT_NODE:
  154194. break;
  154195. case ATTRIBUTE_NODE:
  154196. i = !0;
  154197. break
  154198. }
  154199. if (o || (o = e.cloneNode(!1)),
  154200. o.ownerDocument = a,
  154201. o.parentNode = null,
  154202. i)
  154203. for (var s = e.firstChild; s; )
  154204. o.appendChild(importNode(a, s, i)),
  154205. s = s.nextSibling;
  154206. return o
  154207. }
  154208. function cloneNode(a, e, i) {
  154209. var o = new e.constructor;
  154210. for (var s in e) {
  154211. var c = e[s];
  154212. typeof c != "object" && c != o[s] && (o[s] = c)
  154213. }
  154214. switch (e.childNodes && (o.childNodes = new NodeList),
  154215. o.ownerDocument = a,
  154216. o.nodeType) {
  154217. case ELEMENT_NODE:
  154218. var d = e.attributes
  154219. , _ = o.attributes = new NamedNodeMap
  154220. , b = d.length;
  154221. _._ownerElement = o;
  154222. for (var k = 0; k < b; k++)
  154223. o.setAttributeNode(cloneNode(a, d.item(k), !0));
  154224. break;
  154225. case ATTRIBUTE_NODE:
  154226. i = !0
  154227. }
  154228. if (i)
  154229. for (var j = e.firstChild; j; )
  154230. o.appendChild(cloneNode(a, j, i)),
  154231. j = j.nextSibling;
  154232. return o
  154233. }
  154234. function __set__(a, e, i) {
  154235. a[e] = i
  154236. }
  154237. try {
  154238. if (Object.defineProperty) {
  154239. let a = function(e) {
  154240. switch (e.nodeType) {
  154241. case ELEMENT_NODE:
  154242. case DOCUMENT_FRAGMENT_NODE:
  154243. var i = [];
  154244. for (e = e.firstChild; e; )
  154245. e.nodeType !== 7 && e.nodeType !== 8 && i.push(a(e)),
  154246. e = e.nextSibling;
  154247. return i.join("");
  154248. default:
  154249. return e.nodeValue
  154250. }
  154251. };
  154252. var getTextContent = a;
  154253. Object.defineProperty(LiveNodeList.prototype, "length", {
  154254. get: function() {
  154255. return _updateLiveList(this),
  154256. this.$$length
  154257. }
  154258. }),
  154259. Object.defineProperty(Node$1.prototype, "textContent", {
  154260. get: function() {
  154261. return a(this)
  154262. },
  154263. set: function(e) {
  154264. switch (this.nodeType) {
  154265. case ELEMENT_NODE:
  154266. case DOCUMENT_FRAGMENT_NODE:
  154267. for (; this.firstChild; )
  154268. this.removeChild(this.firstChild);
  154269. (e || String(e)) && this.appendChild(this.ownerDocument.createTextNode(e));
  154270. break;
  154271. default:
  154272. this.data = e,
  154273. this.value = e,
  154274. this.nodeValue = e
  154275. }
  154276. }
  154277. }),
  154278. __set__ = function(e, i, o) {
  154279. e["$$" + i] = o
  154280. }
  154281. }
  154282. } catch (a) {}
  154283. dom.DOMImplementation = DOMImplementation$1;
  154284. dom.XMLSerializer = XMLSerializer$1;
  154285. function DOMParser$1(a) {
  154286. this.options = a || {
  154287. locator: {}
  154288. }
  154289. }
  154290. DOMParser$1.prototype.parseFromString = function(a, e) {
  154291. var i = this.options
  154292. , o = new XMLReader
  154293. , s = i.domBuilder || new DOMHandler
  154294. , c = i.errorHandler
  154295. , d = i.locator
  154296. , _ = i.xmlns || {}
  154297. , b = {
  154298. lt: "<",
  154299. gt: ">",
  154300. amp: "&",
  154301. quot: '"',
  154302. apos: "'"
  154303. };
  154304. return d && s.setDocumentLocator(d),
  154305. o.errorHandler = buildErrorHandler(c, s, d),
  154306. o.domBuilder = i.domBuilder || s,
  154307. /\/x?html?$/.test(e) && (b.nbsp = "\xA0",
  154308. b.copy = "\xA9",
  154309. _[""] = "http://www.w3.org/1999/xhtml"),
  154310. _.xml = _.xml || "http://www.w3.org/XML/1998/namespace",
  154311. a ? o.parse(a, _, b) : o.errorHandler.error("invalid doc source"),
  154312. s.doc
  154313. }
  154314. ;
  154315. function buildErrorHandler(a, e, i) {
  154316. if (!a) {
  154317. if (e instanceof DOMHandler)
  154318. return e;
  154319. a = e
  154320. }
  154321. var o = {}
  154322. , s = a instanceof Function;
  154323. i = i || {};
  154324. function c(d) {
  154325. var _ = a[d];
  154326. !_ && s && (_ = a.length == 2 ? function(b) {
  154327. a(d, b)
  154328. }
  154329. : a),
  154330. o[d] = _ && function(b) {
  154331. _("[xmldom " + d + "] " + b + _locator(i))
  154332. }
  154333. || function() {}
  154334. }
  154335. return c("warning"),
  154336. c("error"),
  154337. c("fatalError"),
  154338. o
  154339. }
  154340. function DOMHandler() {
  154341. this.cdata = !1
  154342. }
  154343. function position(a, e) {
  154344. e.lineNumber = a.lineNumber,
  154345. e.columnNumber = a.columnNumber
  154346. }
  154347. DOMHandler.prototype = {
  154348. startDocument: function() {
  154349. this.doc = new DOMImplementation().createDocument(null, null, null),
  154350. this.locator && (this.doc.documentURI = this.locator.systemId)
  154351. },
  154352. startElement: function(a, e, i, o) {
  154353. var s = this.doc
  154354. , c = s.createElementNS(a, i || e)
  154355. , d = o.length;
  154356. appendElement(this, c),
  154357. this.currentElement = c,
  154358. this.locator && position(this.locator, c);
  154359. for (var _ = 0; _ < d; _++) {
  154360. var a = o.getURI(_)
  154361. , b = o.getValue(_)
  154362. , i = o.getQName(_)
  154363. , k = s.createAttributeNS(a, i);
  154364. this.locator && position(o.getLocator(_), k),
  154365. k.value = k.nodeValue = b,
  154366. c.setAttributeNode(k)
  154367. }
  154368. },
  154369. endElement: function(a, e, i) {
  154370. var o = this.currentElement;
  154371. o.tagName,
  154372. this.currentElement = o.parentNode
  154373. },
  154374. startPrefixMapping: function(a, e) {},
  154375. endPrefixMapping: function(a) {},
  154376. processingInstruction: function(a, e) {
  154377. var i = this.doc.createProcessingInstruction(a, e);
  154378. this.locator && position(this.locator, i),
  154379. appendElement(this, i)
  154380. },
  154381. ignorableWhitespace: function(a, e, i) {},
  154382. characters: function(a, e, i) {
  154383. if (a = _toString.apply(this, arguments),
  154384. a) {
  154385. if (this.cdata)
  154386. var o = this.doc.createCDATASection(a);
  154387. else
  154388. var o = this.doc.createTextNode(a);
  154389. this.currentElement ? this.currentElement.appendChild(o) : /^\s*$/.test(a) && this.doc.appendChild(o),
  154390. this.locator && position(this.locator, o)
  154391. }
  154392. },
  154393. skippedEntity: function(a) {},
  154394. endDocument: function() {
  154395. this.doc.normalize()
  154396. },
  154397. setDocumentLocator: function(a) {
  154398. (this.locator = a) && (a.lineNumber = 0)
  154399. },
  154400. comment: function(a, e, i) {
  154401. a = _toString.apply(this, arguments);
  154402. var o = this.doc.createComment(a);
  154403. this.locator && position(this.locator, o),
  154404. appendElement(this, o)
  154405. },
  154406. startCDATA: function() {
  154407. this.cdata = !0
  154408. },
  154409. endCDATA: function() {
  154410. this.cdata = !1
  154411. },
  154412. startDTD: function(a, e, i) {
  154413. var o = this.doc.implementation;
  154414. if (o && o.createDocumentType) {
  154415. var s = o.createDocumentType(a, e, i);
  154416. this.locator && position(this.locator, s),
  154417. appendElement(this, s)
  154418. }
  154419. },
  154420. warning: function(a) {
  154421. console.warn("[xmldom warning] " + a, _locator(this.locator))
  154422. },
  154423. error: function(a) {
  154424. console.error("[xmldom error] " + a, _locator(this.locator))
  154425. },
  154426. fatalError: function(a) {
  154427. throw console.error("[xmldom fatalError] " + a, _locator(this.locator)),
  154428. a
  154429. }
  154430. };
  154431. function _locator(a) {
  154432. if (a)
  154433. return `
  154434. @` + (a.systemId || "") + "#[line:" + a.lineNumber + ",col:" + a.columnNumber + "]"
  154435. }
  154436. function _toString(a, e, i) {
  154437. return typeof a == "string" ? a.substr(e, i) : a.length >= e + i || e ? new java.lang.String(a,e,i) + "" : a
  154438. }
  154439. "endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g, function(a) {
  154440. DOMHandler.prototype[a] = function() {
  154441. return null
  154442. }
  154443. });
  154444. function appendElement(a, e) {
  154445. a.currentElement ? a.currentElement.appendChild(e) : a.doc.appendChild(e)
  154446. }
  154447. var XMLReader = sax.XMLReader
  154448. , DOMImplementation = domParser.DOMImplementation = dom.DOMImplementation;
  154449. domParser.XMLSerializer = dom.XMLSerializer;
  154450. domParser.DOMParser = DOMParser$1;
  154451. var DOMParser = domParser.DOMParser
  154452. , xmlToJSON = function() {
  154453. this.version = "1.3.5";
  154454. var a = {
  154455. mergeCDATA: !0,
  154456. normalize: !0,
  154457. stripElemPrefix: !0
  154458. }
  154459. , e = new RegExp(/(?!xmlns)^.*:/);
  154460. return this.grokType = function(i) {
  154461. return /^\s*$/.test(i) ? null : /^(?:true|false)$/i.test(i) ? i.toLowerCase() === "true" : isFinite(i) ? parseFloat(i) : i
  154462. }
  154463. ,
  154464. this.parseString = function(i, o) {
  154465. if (i) {
  154466. var s = this.stringToXML(i);
  154467. return s.getElementsByTagName("parsererror").length ? null : this.parseXML(s, o)
  154468. } else
  154469. return null
  154470. }
  154471. ,
  154472. this.parseXML = function(i, o) {
  154473. for (var s in o)
  154474. a[s] = o[s];
  154475. var c = {}
  154476. , d = 0
  154477. , _ = ""
  154478. , b = i.childNodes.length;
  154479. if (b)
  154480. for (var k, j, $, _e = 0; _e < i.childNodes.length; _e++)
  154481. k = i.childNodes.item(_e),
  154482. k.nodeType === 4 ? a.mergeCDATA && (_ += k.nodeValue) : k.nodeType === 3 ? _ += k.nodeValue : k.nodeType === 1 && (d === 0 && (c = {}),
  154483. a.stripElemPrefix ? j = k.nodeName.replace(e, "") : j = k.nodeName,
  154484. $ = xmlToJSON.parseXML(k),
  154485. c.hasOwnProperty(j) ? (c[j].constructor !== Array && (c[j] = [c[j]]),
  154486. c[j].push($)) : (c[j] = $,
  154487. d++));
  154488. return Object.keys(c).length || (c = _ || ""),
  154489. c
  154490. }
  154491. ,
  154492. this.xmlToString = function(i) {
  154493. try {
  154494. var o = i.xml ? i.xml : new XMLSerializer().serializeToString(i);
  154495. return o
  154496. } catch {
  154497. return null
  154498. }
  154499. }
  154500. ,
  154501. this.stringToXML = function(i) {
  154502. try {
  154503. var o = null;
  154504. if (window.DOMParser) {
  154505. var s = new DOMParser;
  154506. return o = s.parseFromString(i, "text/xml"),
  154507. o
  154508. } else
  154509. return o = new ActiveXObject("Microsoft.XMLDOM"),
  154510. o.async = !1,
  154511. o.loadXML(i),
  154512. o
  154513. } catch {
  154514. return null
  154515. }
  154516. }
  154517. ,
  154518. this
  154519. }
  154520. .call({})
  154521. , xml2json$1 = function(a) {
  154522. return xmlToJSON.parseString(a)
  154523. }
  154524. , xml2json_1 = xml2json$1
  154525. , element_start_char = "a-zA-Z_\xC0-\xD6\xD8-\xF6\xF8-\xFF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FFF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD"
  154526. , element_non_start_char = "-.0-9\xB7\u0300-\u036F\u203F\u2040"
  154527. , element_replace = new RegExp("^([^" + element_start_char + "])|^((x|X)(m|M)(l|L))|([^" + element_start_char + element_non_start_char + "])","g")
  154528. , not_safe_in_xml = /[^\x09\x0A\x0D\x20-\xFF\x85\xA0-\uD7FF\uE000-\uFDCF\uFDE0-\uFFFD]/gm
  154529. , objKeys = function(a) {
  154530. var e = [];
  154531. if (a instanceof Object)
  154532. for (var i in a)
  154533. a.hasOwnProperty(i) && e.push(i);
  154534. return e
  154535. }
  154536. , process_to_xml = function(a, e) {
  154537. var i = function(o, s, c, d, _) {
  154538. var b = e.indent !== void 0 ? e.indent : " "
  154539. , k = e.prettyPrint ? `
  154540. ` + new Array(d).join(b) : "";
  154541. e.removeIllegalNameCharacters && (o = o.replace(element_replace, "_"));
  154542. var j = [k, "<", o, c || ""];
  154543. return s && s.length > 0 ? (j.push(">"),
  154544. j.push(s),
  154545. _ && j.push(k),
  154546. j.push("</"),
  154547. j.push(o),
  154548. j.push(">")) : j.push("/>"),
  154549. j.join("")
  154550. };
  154551. return function o(s, c, d) {
  154552. var _ = typeof s;
  154553. switch ((Array.isArray ? Array.isArray(s) : s instanceof Array) ? _ = "array" : s instanceof Date && (_ = "date"),
  154554. _) {
  154555. case "array":
  154556. var b = [];
  154557. return s.map(function(_e) {
  154558. b.push(o(_e, 1, d + 1))
  154559. }),
  154560. e.prettyPrint && b.push(`
  154561. `),
  154562. b.join("");
  154563. case "date":
  154564. return s.toJSON ? s.toJSON() : s + "";
  154565. case "object":
  154566. var k = [];
  154567. for (var j in s)
  154568. if (s.hasOwnProperty(j))
  154569. if (s[j]instanceof Array)
  154570. for (var $ = 0; $ < s[j].length; $++)
  154571. s[j].hasOwnProperty($) && k.push(i(j, o(s[j][$], 0, d + 1), null, d + 1, objKeys(s[j][$]).length));
  154572. else
  154573. k.push(i(j, o(s[j], 0, d + 1), null, d + 1));
  154574. return e.prettyPrint && k.length > 0 && k.push(`
  154575. `),
  154576. k.join("");
  154577. case "function":
  154578. return s();
  154579. default:
  154580. return e.escape ? esc(s) : "" + s
  154581. }
  154582. }(a, 0, 0)
  154583. }
  154584. , xml_header = function(a) {
  154585. var e = ['<?xml version="1.0" encoding="UTF-8"'];
  154586. return a && e.push(' standalone="yes"'),
  154587. e.push("?>"),
  154588. e.join("")
  154589. };
  154590. function esc(a) {
  154591. return ("" + a).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/'/g, "&apos;").replace(/"/g, "&quot;").replace(not_safe_in_xml, "")
  154592. }
  154593. var json2xml$1 = function(a, e) {
  154594. if (e || (e = {
  154595. xmlHeader: {
  154596. standalone: !0
  154597. },
  154598. prettyPrint: !0,
  154599. indent: " ",
  154600. escape: !0
  154601. }),
  154602. typeof a == "string")
  154603. try {
  154604. a = JSON.parse(a.toString())
  154605. } catch {
  154606. return !1
  154607. }
  154608. var i = ""
  154609. , o = "";
  154610. e && (typeof e == "object" ? (e.xmlHeader && (i = xml_header(!!e.xmlHeader.standalone)),
  154611. typeof e.docType != "undefined" && (o = "<!DOCTYPE " + e.docType + ">")) : i = xml_header()),
  154612. e = e || {};
  154613. var s = [i, e.prettyPrint && o ? `
  154614. ` : "", o, process_to_xml(a, e)];
  154615. return s.join("").replace(/\n{2,}/g, `
  154616. `).replace(/\s+$/g, "")
  154617. }
  154618. , md5 = md5$1.exports
  154619. , CryptoJS = crypto.exports
  154620. , xml2json = xml2json_1
  154621. , json2xml = json2xml$1;
  154622. function camSafeUrlEncode(a) {
  154623. return encodeURIComponent(a).replace(/!/g, "%21").replace(/'/g, "%27").replace(/\(/g, "%28").replace(/\)/g, "%29").replace(/\*/g, "%2A")
  154624. }
  154625. function getObjectKeys(a, e) {
  154626. var i = [];
  154627. for (var o in a)
  154628. a.hasOwnProperty(o) && i.push(e ? camSafeUrlEncode(o).toLowerCase() : o);
  154629. return i.sort(function(s, c) {
  154630. return s = s.toLowerCase(),
  154631. c = c.toLowerCase(),
  154632. s === c ? 0 : s > c ? 1 : -1
  154633. })
  154634. }
  154635. var obj2str = function(a, e) {
  154636. var i, o, s, c = [], d = getObjectKeys(a);
  154637. for (i = 0; i < d.length; i++)
  154638. o = d[i],
  154639. s = a[o] === void 0 || a[o] === null ? "" : "" + a[o],
  154640. o = e ? camSafeUrlEncode(o).toLowerCase() : camSafeUrlEncode(o),
  154641. s = camSafeUrlEncode(s) || "",
  154642. c.push(o + "=" + s);
  154643. return c.join("&")
  154644. }
  154645. , signHeaders = ["content-disposition", "content-encoding", "content-length", "content-md5", "expect", "host", "if-match", "if-modified-since", "if-none-match", "if-unmodified-since", "origin", "range", "response-cache-control", "response-content-disposition", "response-content-encoding", "response-content-language", "response-content-type", "response-expires", "transfer-encoding", "versionid"]
  154646. , getSignHeaderObj = function(a) {
  154647. var e = {};
  154648. for (var i in a) {
  154649. var o = i.toLowerCase();
  154650. (o.indexOf("x-cos-") > -1 || signHeaders.indexOf(o) > -1) && (e[i] = a[i])
  154651. }
  154652. return e
  154653. }
  154654. , getAuth$1 = function(a) {
  154655. a = a || {};
  154656. var e = a.SecretId, i = a.SecretKey, o = a.KeyTime, s = (a.method || a.Method || "get").toLowerCase(), c = clone(a.Query || a.params || {}), d = getSignHeaderObj(clone(a.Headers || a.headers || {})), _ = a.Key || "", b;
  154657. a.UseRawKey ? b = a.Pathname || a.pathname || "/" + _ : (b = a.Pathname || a.pathname || _,
  154658. b.indexOf("/") !== 0 && (b = "/" + b));
  154659. var k = a.ForceSignHost !== !1;
  154660. if (!d.Host && !d.host && a.Bucket && a.Region && k && (d.Host = a.Bucket + ".cos." + a.Region + ".myqcloud.com"),
  154661. !e)
  154662. throw new Error("missing param SecretId");
  154663. if (!i)
  154664. throw new Error("missing param SecretKey");
  154665. var j = Math.round(getSkewTime(a.SystemClockOffset) / 1e3) - 1
  154666. , $ = j
  154667. , _e = a.Expires || a.expires;
  154668. _e === void 0 ? $ += 900 : $ += _e * 1 || 0;
  154669. var et = "sha1"
  154670. , tt = e
  154671. , rt = o || j + ";" + $
  154672. , it = o || j + ";" + $
  154673. , nt = getObjectKeys(d, !0).join(";").toLowerCase()
  154674. , ot = getObjectKeys(c, !0).join(";").toLowerCase()
  154675. , at = CryptoJS.HmacSHA1(it, i).toString()
  154676. , st = [s, b, util$5.obj2str(c, !0), util$5.obj2str(d, !0), ""].join(`
  154677. `)
  154678. , ut = ["sha1", rt, CryptoJS.SHA1(st).toString(), ""].join(`
  154679. `)
  154680. , ct = CryptoJS.HmacSHA1(ut, at).toString()
  154681. , lt = ["q-sign-algorithm=" + et, "q-ak=" + tt, "q-sign-time=" + rt, "q-key-time=" + it, "q-header-list=" + nt, "q-url-param-list=" + ot, "q-signature=" + ct].join("&");
  154682. return lt
  154683. }
  154684. , readIntBE = function(a, e, i) {
  154685. var o = e / 8
  154686. , s = a.slice(i, i + o);
  154687. return new Uint8Array(s).reverse(),
  154688. new {
  154689. 8: Uint8Array,
  154690. 16: Uint16Array,
  154691. 32: Uint32Array
  154692. }[e](s)[0]
  154693. }
  154694. , buf2str = function(a, e, i, o) {
  154695. var s = a.slice(e, i)
  154696. , c = "";
  154697. return new Uint8Array(s).forEach(function(d) {
  154698. c += String.fromCharCode(d)
  154699. }),
  154700. o && (c = decodeURIComponent(escape(c))),
  154701. c
  154702. }
  154703. , parseSelectPayload = function(a) {
  154704. for (var e = {}, i = buf2str(a), o = {
  154705. records: []
  154706. }; a.byteLength; ) {
  154707. var s = readIntBE(a, 32, 0), c = readIntBE(a, 32, 4), d = s - c - 16, _ = 0, b;
  154708. for (a = a.slice(12); _ < c; ) {
  154709. var k = readIntBE(a, 8, _)
  154710. , j = buf2str(a, _ + 1, _ + 1 + k)
  154711. , $ = readIntBE(a, 16, _ + k + 2)
  154712. , _e = buf2str(a, _ + k + 4, _ + k + 4 + $);
  154713. e[j] = _e,
  154714. _ += k + 4 + $
  154715. }
  154716. if (e[":event-type"] === "Records")
  154717. b = buf2str(a, _, _ + d, !0),
  154718. o.records.push(b);
  154719. else if (e[":event-type"] === "Stats")
  154720. b = buf2str(a, _, _ + d, !0),
  154721. o.stats = util$5.xml2json(b).Stats;
  154722. else if (e[":event-type"] === "error") {
  154723. var et = e[":error-code"]
  154724. , tt = e[":error-message"]
  154725. , rt = new Error(tt);
  154726. rt.message = tt,
  154727. rt.name = rt.code = et,
  154728. o.error = rt
  154729. } else
  154730. ["Progress", "Continuation", "End"].includes(e[":event-type"]);
  154731. a = a.slice(_ + d + 4)
  154732. }
  154733. return {
  154734. payload: o.records.join(""),
  154735. body: i
  154736. }
  154737. }
  154738. , getSourceParams = function(a) {
  154739. var e = this.options.CopySourceParser;
  154740. if (e)
  154741. return e(a);
  154742. var i = a.match(/^([^.]+-\d+)\.cos(v6|-cdc)?\.([^.]+)\.myqcloud\.com\/(.+)$/);
  154743. return i ? {
  154744. Bucket: i[1],
  154745. Region: i[3],
  154746. Key: i[4]
  154747. } : null
  154748. }
  154749. , noop = function() {}
  154750. , clearKey = function(a) {
  154751. var e = {};
  154752. for (var i in a)
  154753. a.hasOwnProperty(i) && a[i] !== void 0 && a[i] !== null && (e[i] = a[i]);
  154754. return e
  154755. }
  154756. , readAsBinaryString = function(a, e) {
  154757. var i, o = new FileReader;
  154758. FileReader.prototype.readAsBinaryString ? (i = FileReader.prototype.readAsBinaryString,
  154759. o.onload = function() {
  154760. e(this.result)
  154761. }
  154762. ) : FileReader.prototype.readAsArrayBuffer ? i = function(s) {
  154763. var c = ""
  154764. , d = new FileReader;
  154765. d.onload = function(_) {
  154766. for (var b = new Uint8Array(d.result), k = b.byteLength, j = 0; j < k; j++)
  154767. c += String.fromCharCode(b[j]);
  154768. e(c)
  154769. }
  154770. ,
  154771. d.readAsArrayBuffer(s)
  154772. }
  154773. : console.error("FileReader not support readAsBinaryString"),
  154774. i.call(o, a)
  154775. }
  154776. , fileSliceNeedCopy = function() {
  154777. var a = function(i, o) {
  154778. i = i.split("."),
  154779. o = o.split(".");
  154780. for (var s = 0; s < o.length; s++)
  154781. if (i[s] !== o[s])
  154782. return parseInt(i[s]) > parseInt(o[s]) ? 1 : -1;
  154783. return 0
  154784. }
  154785. , e = function(i) {
  154786. if (!i)
  154787. return !1;
  154788. var o = (i.match(/Chrome\/([.\d]+)/) || [])[1]
  154789. , s = (i.match(/QBCore\/([.\d]+)/) || [])[1]
  154790. , c = (i.match(/QQBrowser\/([.\d]+)/) || [])[1]
  154791. , d = o && a(o, "53.0.2785.116") < 0 && s && a(s, "3.53.991.400") < 0 && c && a(c, "9.0.2524.400") <= 0 || !1;
  154792. return d
  154793. };
  154794. return e(typeof navigator != "undefined" && navigator.userAgent)
  154795. }()
  154796. , fileSlice = function(a, e, i, o, s) {
  154797. var c;
  154798. if (a.slice ? c = a.slice(e, i) : a.mozSlice ? c = a.mozSlice(e, i) : a.webkitSlice && (c = a.webkitSlice(e, i)),
  154799. o && fileSliceNeedCopy) {
  154800. var d = new FileReader;
  154801. d.onload = function(_) {
  154802. c = null,
  154803. s(new Blob([d.result]))
  154804. }
  154805. ,
  154806. d.readAsArrayBuffer(c)
  154807. } else
  154808. s(c)
  154809. }
  154810. , getBodyMd5 = function(a, e, i, o) {
  154811. i = i || noop,
  154812. a ? typeof e == "string" ? i(util$5.md5(e, !0)) : Blob && e instanceof Blob ? util$5.getFileMd5(e, function(s, c) {
  154813. i(c)
  154814. }, o) : i() : i()
  154815. }
  154816. , md5ChunkSize = 1024 * 1024
  154817. , getFileMd5 = function(a, e, i) {
  154818. var o = a.size
  154819. , s = 0
  154820. , c = md5.getCtx()
  154821. , d = function(_) {
  154822. if (_ >= o) {
  154823. var b = c.digest("hex");
  154824. e(null, b);
  154825. return
  154826. }
  154827. var k = Math.min(o, _ + md5ChunkSize);
  154828. util$5.fileSlice(a, _, k, !1, function(j) {
  154829. readAsBinaryString(j, function($) {
  154830. j = null,
  154831. c = c.update($, !0),
  154832. s += $.length,
  154833. $ = null,
  154834. i && i({
  154835. loaded: s,
  154836. total: o,
  154837. percent: Math.round(s / o * 1e4) / 1e4
  154838. }),
  154839. d(_ + md5ChunkSize)
  154840. })
  154841. })
  154842. };
  154843. d(0)
  154844. };
  154845. function clone(a) {
  154846. return map$1(a, function(e) {
  154847. return typeof e == "object" && e !== null ? clone(e) : e
  154848. })
  154849. }
  154850. function attr(a, e, i) {
  154851. return a && e in a ? a[e] : i
  154852. }
  154853. function extend$1(a, e) {
  154854. return each(e, function(i, o) {
  154855. a[o] = e[o]
  154856. }),
  154857. a
  154858. }
  154859. function isArray(a) {
  154860. return a instanceof Array
  154861. }
  154862. function isInArray(a, e) {
  154863. for (var i = !1, o = 0; o < a.length; o++)
  154864. if (e === a[o]) {
  154865. i = !0;
  154866. break
  154867. }
  154868. return i
  154869. }
  154870. function makeArray(a) {
  154871. return isArray(a) ? a : [a]
  154872. }
  154873. function each(a, e) {
  154874. for (var i in a)
  154875. a.hasOwnProperty(i) && e(a[i], i)
  154876. }
  154877. function map$1(a, e) {
  154878. var i = isArray(a) ? [] : {};
  154879. for (var o in a)
  154880. a.hasOwnProperty(o) && (i[o] = e(a[o], o));
  154881. return i
  154882. }
  154883. function filter(a, e) {
  154884. var i = isArray(a)
  154885. , o = i ? [] : {};
  154886. for (var s in a)
  154887. a.hasOwnProperty(s) && e(a[s], s) && (i ? o.push(a[s]) : o[s] = a[s]);
  154888. return o
  154889. }
  154890. var binaryBase64 = function(a) {
  154891. var e, i, o, s = "";
  154892. for (e = 0,
  154893. i = a.length / 2; e < i; e++)
  154894. o = parseInt(a[e * 2] + a[e * 2 + 1], 16),
  154895. s += String.fromCharCode(o);
  154896. return btoa(s)
  154897. }
  154898. , uuid = function() {
  154899. var a = function() {
  154900. return ((1 + Math.random()) * 65536 | 0).toString(16).substring(1)
  154901. };
  154902. return a() + a() + "-" + a() + "-" + a() + "-" + a() + "-" + a() + a() + a()
  154903. }
  154904. , hasMissingParams = function(a, e) {
  154905. var i = e.Bucket
  154906. , o = e.Region
  154907. , s = e.Key
  154908. , c = this.options.Domain
  154909. , d = !c || c.indexOf("{Bucket}") > -1
  154910. , _ = !c || c.indexOf("{Region}") > -1;
  154911. if (a.indexOf("Bucket") > -1 || a === "deleteMultipleObject" || a === "multipartList" || a === "listObjectVersions") {
  154912. if (d && !i)
  154913. return "Bucket";
  154914. if (_ && !o)
  154915. return "Region"
  154916. } else if (a.indexOf("Object") > -1 || a.indexOf("multipart") > -1 || a === "sliceUploadFile" || a === "abortUploadTask") {
  154917. if (d && !i)
  154918. return "Bucket";
  154919. if (_ && !o)
  154920. return "Region";
  154921. if (!s)
  154922. return "Key"
  154923. }
  154924. return !1
  154925. }
  154926. , formatParams = function(a, e) {
  154927. if (e = extend$1({}, e),
  154928. a !== "getAuth" && a !== "getV4Auth" && a !== "getObjectUrl") {
  154929. var i = e.Headers || {};
  154930. if (e && typeof e == "object") {
  154931. (function() {
  154932. for (var s in e)
  154933. e.hasOwnProperty(s) && s.indexOf("x-cos-") > -1 && (i[s] = e[s])
  154934. }
  154935. )();
  154936. var o = {
  154937. "x-cos-mfa": "MFA",
  154938. "Content-MD5": "ContentMD5",
  154939. "Content-Length": "ContentLength",
  154940. "Content-Type": "ContentType",
  154941. Expect: "Expect",
  154942. Expires: "Expires",
  154943. "Cache-Control": "CacheControl",
  154944. "Content-Disposition": "ContentDisposition",
  154945. "Content-Encoding": "ContentEncoding",
  154946. Range: "Range",
  154947. "If-Modified-Since": "IfModifiedSince",
  154948. "If-Unmodified-Since": "IfUnmodifiedSince",
  154949. "If-Match": "IfMatch",
  154950. "If-None-Match": "IfNoneMatch",
  154951. "x-cos-copy-source": "CopySource",
  154952. "x-cos-copy-source-Range": "CopySourceRange",
  154953. "x-cos-metadata-directive": "MetadataDirective",
  154954. "x-cos-copy-source-If-Modified-Since": "CopySourceIfModifiedSince",
  154955. "x-cos-copy-source-If-Unmodified-Since": "CopySourceIfUnmodifiedSince",
  154956. "x-cos-copy-source-If-Match": "CopySourceIfMatch",
  154957. "x-cos-copy-source-If-None-Match": "CopySourceIfNoneMatch",
  154958. "x-cos-acl": "ACL",
  154959. "x-cos-grant-read": "GrantRead",
  154960. "x-cos-grant-write": "GrantWrite",
  154961. "x-cos-grant-full-control": "GrantFullControl",
  154962. "x-cos-grant-read-acp": "GrantReadAcp",
  154963. "x-cos-grant-write-acp": "GrantWriteAcp",
  154964. "x-cos-storage-class": "StorageClass",
  154965. "x-cos-traffic-limit": "TrafficLimit",
  154966. "x-cos-mime-limit": "MimeLimit",
  154967. "x-cos-server-side-encryption-customer-algorithm": "SSECustomerAlgorithm",
  154968. "x-cos-server-side-encryption-customer-key": "SSECustomerKey",
  154969. "x-cos-server-side-encryption-customer-key-MD5": "SSECustomerKeyMD5",
  154970. "x-cos-server-side-encryption": "ServerSideEncryption",
  154971. "x-cos-server-side-encryption-cos-kms-key-id": "SSEKMSKeyId",
  154972. "x-cos-server-side-encryption-context": "SSEContext"
  154973. };
  154974. util$5.each(o, function(s, c) {
  154975. e[s] !== void 0 && (i[c] = e[s])
  154976. }),
  154977. e.Headers = clearKey(i)
  154978. }
  154979. }
  154980. return e
  154981. }
  154982. , apiWrapper = function(a, e) {
  154983. return function(i, o) {
  154984. var s = this;
  154985. typeof i == "function" && (o = i,
  154986. i = {}),
  154987. i = formatParams(a, i);
  154988. var c = function($) {
  154989. return $ && $.headers && ($.headers["x-cos-request-id"] && ($.RequestId = $.headers["x-cos-request-id"]),
  154990. $.headers["x-ci-request-id"] && ($.RequestId = $.headers["x-ci-request-id"]),
  154991. $.headers["x-cos-version-id"] && ($.VersionId = $.headers["x-cos-version-id"]),
  154992. $.headers["x-cos-delete-marker"] && ($.DeleteMarker = $.headers["x-cos-delete-marker"])),
  154993. $
  154994. }
  154995. , d = function($, _e) {
  154996. o && o(c($), c(_e))
  154997. }
  154998. , _ = function() {
  154999. if (a !== "getService" && a !== "abortUploadTask") {
  155000. var $ = hasMissingParams.call(s, a, i);
  155001. if ($)
  155002. return "missing param " + $;
  155003. if (i.Region) {
  155004. if (s.options.CompatibilityMode) {
  155005. if (!/^([a-z\d-.]+)$/.test(i.Region))
  155006. return "Region format error."
  155007. } else {
  155008. if (i.Region.indexOf("cos.") > -1)
  155009. return 'param Region should not be start with "cos."';
  155010. if (!/^([a-z\d-]+)$/.test(i.Region))
  155011. return "Region format error."
  155012. }
  155013. !s.options.CompatibilityMode && i.Region.indexOf("-") === -1 && i.Region !== "yfb" && i.Region !== "default" && i.Region !== "accelerate" && console.warn("warning: param Region format error, find help here: https://cloud.tencent.com/document/product/436/6224")
  155014. }
  155015. if (i.Bucket) {
  155016. if (!/^([a-z\d-]+)-(\d+)$/.test(i.Bucket))
  155017. if (i.AppId)
  155018. i.Bucket = i.Bucket + "-" + i.AppId;
  155019. else if (s.options.AppId)
  155020. i.Bucket = i.Bucket + "-" + s.options.AppId;
  155021. else
  155022. return 'Bucket should format as "test-1250000000".';
  155023. i.AppId && (console.warn('warning: AppId has been deprecated, Please put it at the end of parameter Bucket(E.g Bucket:"test-1250000000" ).'),
  155024. delete i.AppId)
  155025. }
  155026. !s.options.UseRawKey && i.Key && i.Key.substr(0, 1) === "/" && (i.Key = i.Key.substr(1))
  155027. }
  155028. }
  155029. , b = _()
  155030. , k = a === "getAuth" || a === "getObjectUrl";
  155031. if (window.Promise && !k && !o)
  155032. return new Promise(function($, _e) {
  155033. if (o = function(et, tt) {
  155034. et ? _e(et) : $(tt)
  155035. }
  155036. ,
  155037. b)
  155038. return d(util$5.error(new Error(b)));
  155039. e.call(s, i, d)
  155040. }
  155041. );
  155042. if (b)
  155043. return d(util$5.error(new Error(b)));
  155044. var j = e.call(s, i, d);
  155045. if (k)
  155046. return j
  155047. }
  155048. }
  155049. , throttleOnProgress = function(a, e) {
  155050. var i = this, o = 0, s = 0, c = Date.now(), d, _;
  155051. function b() {
  155052. if (_ = 0,
  155053. e && typeof e == "function") {
  155054. d = Date.now();
  155055. var k = Math.max(0, Math.round((s - o) / ((d - c) / 1e3) * 100) / 100) || 0, j;
  155056. s === 0 && a === 0 ? j = 1 : j = Math.floor(s / a * 100) / 100 || 0,
  155057. c = d,
  155058. o = s;
  155059. try {
  155060. e({
  155061. loaded: s,
  155062. total: a,
  155063. speed: k,
  155064. percent: j
  155065. })
  155066. } catch {}
  155067. }
  155068. }
  155069. return function(k, j) {
  155070. if (k && (s = k.loaded,
  155071. a = k.total),
  155072. j)
  155073. clearTimeout(_),
  155074. b();
  155075. else {
  155076. if (_)
  155077. return;
  155078. _ = setTimeout(b, i.options.ProgressInterval)
  155079. }
  155080. }
  155081. }
  155082. , getFileSize = function(a, e, i) {
  155083. var o;
  155084. if (typeof e.Body == "string" ? e.Body = new Blob([e.Body],{
  155085. type: "text/plain"
  155086. }) : e.Body instanceof ArrayBuffer && (e.Body = new Blob([e.Body])),
  155087. e.Body && (e.Body instanceof Blob || e.Body.toString() === "[object File]" || e.Body.toString() === "[object Blob]"))
  155088. o = e.Body.size;
  155089. else {
  155090. i(util$5.error(new Error("params body format error, Only allow File|Blob|String.")));
  155091. return
  155092. }
  155093. e.ContentLength = o,
  155094. i(null, o)
  155095. }
  155096. , getSkewTime = function(a) {
  155097. return Date.now() + (a || 0)
  155098. }
  155099. , error = function(a, e) {
  155100. var i = a;
  155101. return a.message = a.message || null,
  155102. typeof e == "string" ? (a.error = e,
  155103. a.message = e) : typeof e == "object" && e !== null && (extend$1(a, e),
  155104. (e.code || e.name) && (a.code = e.code || e.name),
  155105. e.message && (a.message = e.message),
  155106. e.stack && (a.stack = e.stack)),
  155107. typeof Object.defineProperty == "function" && (Object.defineProperty(a, "name", {
  155108. writable: !0,
  155109. enumerable: !1
  155110. }),
  155111. Object.defineProperty(a, "message", {
  155112. enumerable: !0
  155113. })),
  155114. a.name = e && e.name || a.name || a.code || "Error",
  155115. a.code || (a.code = a.name),
  155116. a.error || (a.error = clone(i)),
  155117. a
  155118. }
  155119. , isNode = function() {
  155120. return typeof window != "object" && typeof process == "object" && typeof commonjsRequire == "function"
  155121. }
  155122. , isCIHost = function(a) {
  155123. return /^https?:\/\/([^/]+\.)?ci\.[^/]+/.test(a)
  155124. }
  155125. , util$5 = {
  155126. noop,
  155127. formatParams,
  155128. apiWrapper,
  155129. xml2json,
  155130. json2xml,
  155131. md5,
  155132. clearKey,
  155133. fileSlice,
  155134. getBodyMd5,
  155135. getFileMd5,
  155136. binaryBase64,
  155137. extend: extend$1,
  155138. isArray,
  155139. isInArray,
  155140. makeArray,
  155141. each,
  155142. map: map$1,
  155143. filter,
  155144. clone,
  155145. attr,
  155146. uuid,
  155147. camSafeUrlEncode,
  155148. throttleOnProgress,
  155149. getFileSize,
  155150. getSkewTime,
  155151. error,
  155152. obj2str,
  155153. getAuth: getAuth$1,
  155154. parseSelectPayload,
  155155. getSourceParams,
  155156. isBrowser: !0,
  155157. isNode,
  155158. isCIHost
  155159. }
  155160. , util_1 = util$5
  155161. , event$1 = {}
  155162. , initEvent = function(a) {
  155163. var e = {}
  155164. , i = function(o) {
  155165. return !e[o] && (e[o] = []),
  155166. e[o]
  155167. };
  155168. a.on = function(o, s) {
  155169. o === "task-list-update" && console.warn('warning: Event "' + o + '" has been deprecated. Please use "list-update" instead.'),
  155170. i(o).push(s)
  155171. }
  155172. ,
  155173. a.off = function(o, s) {
  155174. for (var c = i(o), d = c.length - 1; d >= 0; d--)
  155175. s === c[d] && c.splice(d, 1)
  155176. }
  155177. ,
  155178. a.emit = function(o, s) {
  155179. for (var c = i(o).map(function(_) {
  155180. return _
  155181. }), d = 0; d < c.length; d++)
  155182. c[d](s)
  155183. }
  155184. }
  155185. , EventProxy$1 = function() {
  155186. initEvent(this)
  155187. };
  155188. event$1.init = initEvent;
  155189. event$1.EventProxy = EventProxy$1;
  155190. var task$1 = {}, util$4 = util_1, cacheKey = "cos_sdk_upload_cache", expires = 30 * 24 * 3600, cache, timer, getCache = function() {
  155191. try {
  155192. var a = JSON.parse(localStorage.getItem(cacheKey))
  155193. } catch {}
  155194. a || (a = []),
  155195. cache = a
  155196. }, setCache = function() {
  155197. try {
  155198. localStorage.setItem(cacheKey, JSON.stringify(cache))
  155199. } catch {}
  155200. }, init = function() {
  155201. if (!cache) {
  155202. getCache.call(this);
  155203. for (var a = !1, e = Math.round(Date.now() / 1e3), i = cache.length - 1; i >= 0; i--) {
  155204. var o = cache[i][2];
  155205. (!o || o + expires < e) && (cache.splice(i, 1),
  155206. a = !0)
  155207. }
  155208. a && setCache()
  155209. }
  155210. }, save = function() {
  155211. timer || (timer = setTimeout(function() {
  155212. setCache(),
  155213. timer = null
  155214. }, 400))
  155215. }, mod = {
  155216. using: {},
  155217. setUsing: function(a) {
  155218. mod.using[a] = !0
  155219. },
  155220. removeUsing: function(a) {
  155221. delete mod.using[a]
  155222. },
  155223. getFileId: function(a, e, i, o) {
  155224. return a.name && a.size && a.lastModifiedDate && e ? util$4.md5([a.name, a.size, a.lastModifiedDate, e, i, o].join("::")) : null
  155225. },
  155226. getUploadIdList: function(a) {
  155227. if (!a)
  155228. return null;
  155229. init.call(this);
  155230. for (var e = [], i = 0; i < cache.length; i++)
  155231. cache[i][0] === a && e.push(cache[i][1]);
  155232. return e.length ? e : null
  155233. },
  155234. saveUploadId: function(a, e, i) {
  155235. if (init.call(this),
  155236. !!a) {
  155237. for (var o = cache.length - 1; o >= 0; o--) {
  155238. var s = cache[o];
  155239. s[0] === a && s[1] === e && cache.splice(o, 1)
  155240. }
  155241. cache.unshift([a, e, Math.round(Date.now() / 1e3)]),
  155242. cache.length > i && cache.splice(i),
  155243. save()
  155244. }
  155245. },
  155246. removeUploadId: function(a) {
  155247. init.call(this),
  155248. delete mod.using[a];
  155249. for (var e = cache.length - 1; e >= 0; e--)
  155250. cache[e][1] === a && cache.splice(e, 1);
  155251. save()
  155252. }
  155253. }, session$2 = mod, session$1 = session$2, util$3 = util_1, originApiMap = {}, transferToTaskMethod = function(a, e) {
  155254. originApiMap[e] = a[e],
  155255. a[e] = function(i, o) {
  155256. i.SkipTask ? originApiMap[e].call(this, i, o) : this._addTask(e, i, o)
  155257. }
  155258. }, initTask = function(a) {
  155259. var e = []
  155260. , i = {}
  155261. , o = 0
  155262. , s = 0
  155263. , c = function($) {
  155264. var _e = {
  155265. id: $.id,
  155266. Bucket: $.Bucket,
  155267. Region: $.Region,
  155268. Key: $.Key,
  155269. FilePath: $.FilePath,
  155270. state: $.state,
  155271. loaded: $.loaded,
  155272. size: $.size,
  155273. speed: $.speed,
  155274. percent: $.percent,
  155275. hashPercent: $.hashPercent,
  155276. error: $.error
  155277. };
  155278. return $.FilePath && (_e.FilePath = $.FilePath),
  155279. $._custom && (_e._custom = $._custom),
  155280. _e
  155281. }
  155282. , d = function() {
  155283. var $, _e = function() {
  155284. $ = 0,
  155285. a.emit("task-list-update", {
  155286. list: util$3.map(e, c)
  155287. }),
  155288. a.emit("list-update", {
  155289. list: util$3.map(e, c)
  155290. })
  155291. };
  155292. return function() {
  155293. $ || ($ = setTimeout(_e))
  155294. }
  155295. }()
  155296. , _ = function() {
  155297. if (!(e.length <= a.options.UploadQueueSize)) {
  155298. for (var $ = 0; $ < s && $ < e.length && e.length > a.options.UploadQueueSize; ) {
  155299. var _e = e[$].state === "waiting" || e[$].state === "checking" || e[$].state === "uploading";
  155300. !e[$] || !_e ? (i[e[$].id] && delete i[e[$].id],
  155301. e.splice($, 1),
  155302. s--) : $++
  155303. }
  155304. d()
  155305. }
  155306. }
  155307. , b = function() {
  155308. if (!(o >= a.options.FileParallelLimit)) {
  155309. for (; e[s] && e[s].state !== "waiting"; )
  155310. s++;
  155311. if (!(s >= e.length)) {
  155312. var $ = e[s];
  155313. s++,
  155314. o++,
  155315. $.state = "checking",
  155316. $.params.onTaskStart && $.params.onTaskStart(c($)),
  155317. !$.params.UploadData && ($.params.UploadData = {});
  155318. var _e = util$3.formatParams($.api, $.params);
  155319. originApiMap[$.api].call(a, _e, function(et, tt) {
  155320. !a._isRunningTask($.id) || (($.state === "checking" || $.state === "uploading") && ($.state = et ? "error" : "success",
  155321. et && ($.error = et),
  155322. o--,
  155323. d(),
  155324. b(),
  155325. $.callback && $.callback(et, tt),
  155326. $.state === "success" && ($.params && (delete $.params.UploadData,
  155327. delete $.params.Body,
  155328. delete $.params),
  155329. delete $.callback)),
  155330. _())
  155331. }),
  155332. d(),
  155333. setTimeout(b)
  155334. }
  155335. }
  155336. }
  155337. , k = function($, _e) {
  155338. var et = i[$];
  155339. if (!!et) {
  155340. var tt = et && et.state === "waiting"
  155341. , rt = et && (et.state === "checking" || et.state === "uploading");
  155342. if (_e === "canceled" && et.state !== "canceled" || _e === "paused" && tt || _e === "paused" && rt) {
  155343. if (_e === "paused" && et.params.Body && typeof et.params.Body.pipe == "function") {
  155344. console.error("stream not support pause");
  155345. return
  155346. }
  155347. et.state = _e,
  155348. a.emit("inner-kill-task", {
  155349. TaskId: $,
  155350. toState: _e
  155351. });
  155352. try {
  155353. var it = et && et.params && et.params.UploadData.UploadId
  155354. } catch {}
  155355. _e === "canceled" && it && session$1.removeUsing(it),
  155356. d(),
  155357. rt && (o--,
  155358. b()),
  155359. _e === "canceled" && (et.params && (delete et.params.UploadData,
  155360. delete et.params.Body,
  155361. delete et.params),
  155362. delete et.callback)
  155363. }
  155364. _()
  155365. }
  155366. };
  155367. a._addTasks = function($) {
  155368. util$3.each($, function(_e) {
  155369. a._addTask(_e.api, _e.params, _e.callback, !0)
  155370. }),
  155371. d()
  155372. }
  155373. ;
  155374. var j = !0;
  155375. a._addTask = function($, _e, et, tt) {
  155376. _e = util$3.formatParams($, _e);
  155377. var rt = util$3.uuid();
  155378. _e.TaskId = rt,
  155379. _e.onTaskReady && _e.onTaskReady(rt),
  155380. _e.TaskReady && (_e.TaskReady(rt),
  155381. j && console.warn('warning: Param "TaskReady" has been deprecated. Please use "onTaskReady" instead.'),
  155382. j = !1);
  155383. var it = {
  155384. params: _e,
  155385. callback: et,
  155386. api: $,
  155387. index: e.length,
  155388. id: rt,
  155389. Bucket: _e.Bucket,
  155390. Region: _e.Region,
  155391. Key: _e.Key,
  155392. FilePath: _e.FilePath || "",
  155393. state: "waiting",
  155394. loaded: 0,
  155395. size: 0,
  155396. speed: 0,
  155397. percent: 0,
  155398. hashPercent: 0,
  155399. error: null,
  155400. _custom: _e._custom
  155401. }
  155402. , nt = _e.onHashProgress;
  155403. _e.onHashProgress = function(at) {
  155404. !a._isRunningTask(it.id) || (it.hashPercent = at.percent,
  155405. nt && nt(at),
  155406. d())
  155407. }
  155408. ;
  155409. var ot = _e.onProgress;
  155410. return _e.onProgress = function(at) {
  155411. !a._isRunningTask(it.id) || (it.state === "checking" && (it.state = "uploading"),
  155412. it.loaded = at.loaded,
  155413. it.speed = at.speed,
  155414. it.percent = at.percent,
  155415. ot && ot(at),
  155416. d())
  155417. }
  155418. ,
  155419. util$3.getFileSize($, _e, function(at, st) {
  155420. if (at)
  155421. return et(util$3.error(at));
  155422. i[rt] = it,
  155423. e.push(it),
  155424. it.size = st,
  155425. !tt && d(),
  155426. b(),
  155427. _()
  155428. }),
  155429. rt
  155430. }
  155431. ,
  155432. a._isRunningTask = function($) {
  155433. var _e = i[$];
  155434. return !!(_e && (_e.state === "checking" || _e.state === "uploading"))
  155435. }
  155436. ,
  155437. a.getTaskList = function() {
  155438. return util$3.map(e, c)
  155439. }
  155440. ,
  155441. a.cancelTask = function($) {
  155442. k($, "canceled")
  155443. }
  155444. ,
  155445. a.pauseTask = function($) {
  155446. k($, "paused")
  155447. }
  155448. ,
  155449. a.restartTask = function($) {
  155450. var _e = i[$];
  155451. _e && (_e.state === "paused" || _e.state === "error") && (_e.state = "waiting",
  155452. d(),
  155453. s = Math.min(s, _e.index),
  155454. b())
  155455. }
  155456. ,
  155457. a.isUploadRunning = function() {
  155458. return o || s < e.length
  155459. }
  155460. };
  155461. task$1.transferToTaskMethod = transferToTaskMethod;
  155462. task$1.init = initTask;
  155463. var base$1 = {}
  155464. , stringifyPrimitive = function(a) {
  155465. switch (typeof a) {
  155466. case "string":
  155467. return a;
  155468. case "boolean":
  155469. return a ? "true" : "false";
  155470. case "number":
  155471. return isFinite(a) ? a : "";
  155472. default:
  155473. return ""
  155474. }
  155475. }
  155476. , queryStringify = function(a, e, i, o) {
  155477. return e = e || "&",
  155478. i = i || "=",
  155479. a === null && (a = void 0),
  155480. typeof a == "object" ? Object.keys(a).map(function(s) {
  155481. var c = encodeURIComponent(stringifyPrimitive(s)) + i;
  155482. return Array.isArray(a[s]) ? a[s].map(function(d) {
  155483. return c + encodeURIComponent(stringifyPrimitive(d))
  155484. }).join(e) : c + encodeURIComponent(stringifyPrimitive(a[s]))
  155485. }).filter(Boolean).join(e) : o ? encodeURIComponent(stringifyPrimitive(o)) + i + encodeURIComponent(stringifyPrimitive(a)) : ""
  155486. }
  155487. , xhrRes = function(a, e, i) {
  155488. var o = {};
  155489. return e.getAllResponseHeaders().trim().split(`
  155490. `).forEach(function(s) {
  155491. if (s) {
  155492. var c = s.indexOf(":")
  155493. , d = s.substr(0, c).trim().toLowerCase()
  155494. , _ = s.substr(c + 1).trim();
  155495. o[d] = _
  155496. }
  155497. }),
  155498. {
  155499. error: a,
  155500. statusCode: e.status,
  155501. statusMessage: e.statusText,
  155502. headers: o,
  155503. body: i
  155504. }
  155505. }
  155506. , xhrBody = function(a, e) {
  155507. return !e && e === "text" ? a.responseText : a.response
  155508. }
  155509. , request$1 = function(a, e) {
  155510. var i = (a.method || "GET").toUpperCase()
  155511. , o = a.url;
  155512. if (a.qs) {
  155513. var s = queryStringify(a.qs);
  155514. s && (o += (o.indexOf("?") === -1 ? "?" : "&") + s)
  155515. }
  155516. var c = new XMLHttpRequest;
  155517. if (c.open(i, o, !0),
  155518. c.responseType = a.dataType || "text",
  155519. a.xhrFields)
  155520. for (var d in a.xhrFields)
  155521. c[d] = a.xhrFields[d];
  155522. var _ = a.headers;
  155523. if (_)
  155524. for (var b in _)
  155525. _.hasOwnProperty(b) && b.toLowerCase() !== "content-length" && b.toLowerCase() !== "user-agent" && b.toLowerCase() !== "origin" && b.toLowerCase() !== "host" && c.setRequestHeader(b, _[b]);
  155526. return a.onProgress && c.upload && (c.upload.onprogress = a.onProgress),
  155527. a.onDownloadProgress && (c.onprogress = a.onDownloadProgress),
  155528. a.timeout && (c.timeout = a.timeout),
  155529. c.ontimeout = function(k) {
  155530. var j = new Error("timeout");
  155531. e(xhrRes(j, c))
  155532. }
  155533. ,
  155534. c.onload = function() {
  155535. e(xhrRes(null, c, xhrBody(c, a.dataType)))
  155536. }
  155537. ,
  155538. c.onerror = function(k) {
  155539. var j = xhrBody(c, a.dataType);
  155540. if (j)
  155541. e(xhrRes(null, c, j));
  155542. else {
  155543. var $ = c.statusText;
  155544. !$ && c.status === 0 && ($ = new Error("CORS blocked or network error")),
  155545. e(xhrRes($, c, j))
  155546. }
  155547. }
  155548. ,
  155549. c.send(a.body || ""),
  155550. c
  155551. }
  155552. , request_1 = request$1
  155553. , REQUEST = request_1
  155554. , util$2 = util_1;
  155555. function getService(a, e) {
  155556. typeof a == "function" && (e = a,
  155557. a = {});
  155558. var i = this.options.Protocol || (util$2.isBrowser && location.protocol === "http:" ? "http:" : "https:")
  155559. , o = this.options.ServiceDomain
  155560. , s = a.AppId || this.options.appId
  155561. , c = a.Region;
  155562. o ? (o = o.replace(/\{\{AppId\}\}/ig, s || "").replace(/\{\{Region\}\}/ig, c || "").replace(/\{\{.*?\}\}/ig, ""),
  155563. /^[a-zA-Z]+:\/\//.test(o) || (o = i + "//" + o),
  155564. o.slice(-1) === "/" && (o = o.slice(0, -1))) : c ? o = i + "//cos." + c + ".myqcloud.com" : o = i + "//service.cos.myqcloud.com";
  155565. var d = ""
  155566. , _ = c ? "cos." + c + ".myqcloud.com" : "service.cos.myqcloud.com"
  155567. , b = o.replace(/^https?:\/\/([^/]+)(\/.*)?$/, "$1");
  155568. _ === b && (d = _),
  155569. submitRequest.call(this, {
  155570. Action: "name/cos:GetService",
  155571. url: o,
  155572. method: "GET",
  155573. headers: a.Headers,
  155574. SignHost: d
  155575. }, function(k, j) {
  155576. if (k)
  155577. return e(k);
  155578. var $ = j && j.ListAllMyBucketsResult && j.ListAllMyBucketsResult.Buckets && j.ListAllMyBucketsResult.Buckets.Bucket || [];
  155579. $ = util$2.isArray($) ? $ : [$];
  155580. var _e = j && j.ListAllMyBucketsResult && j.ListAllMyBucketsResult.Owner || {};
  155581. e(null, {
  155582. Buckets: $,
  155583. Owner: _e,
  155584. statusCode: j.statusCode,
  155585. headers: j.headers
  155586. })
  155587. })
  155588. }
  155589. function putBucket(a, e) {
  155590. var i = this
  155591. , o = "";
  155592. if (a.BucketAZConfig) {
  155593. var s = {
  155594. BucketAZConfig: a.BucketAZConfig
  155595. };
  155596. o = util$2.json2xml({
  155597. CreateBucketConfiguration: s
  155598. })
  155599. }
  155600. submitRequest.call(this, {
  155601. Action: "name/cos:PutBucket",
  155602. method: "PUT",
  155603. Bucket: a.Bucket,
  155604. Region: a.Region,
  155605. headers: a.Headers,
  155606. body: o
  155607. }, function(c, d) {
  155608. if (c)
  155609. return e(c);
  155610. var _ = getUrl({
  155611. protocol: i.options.Protocol,
  155612. domain: i.options.Domain,
  155613. bucket: a.Bucket,
  155614. region: a.Region,
  155615. isLocation: !0
  155616. });
  155617. e(null, {
  155618. Location: _,
  155619. statusCode: d.statusCode,
  155620. headers: d.headers
  155621. })
  155622. })
  155623. }
  155624. function headBucket(a, e) {
  155625. submitRequest.call(this, {
  155626. Action: "name/cos:HeadBucket",
  155627. Bucket: a.Bucket,
  155628. Region: a.Region,
  155629. headers: a.Headers,
  155630. method: "HEAD"
  155631. }, e)
  155632. }
  155633. function getBucket(a, e) {
  155634. var i = {};
  155635. i.prefix = a.Prefix || "",
  155636. i.delimiter = a.Delimiter,
  155637. i.marker = a.Marker,
  155638. i["max-keys"] = a.MaxKeys,
  155639. i["encoding-type"] = a.EncodingType,
  155640. submitRequest.call(this, {
  155641. Action: "name/cos:GetBucket",
  155642. ResourceKey: i.prefix,
  155643. method: "GET",
  155644. Bucket: a.Bucket,
  155645. Region: a.Region,
  155646. headers: a.Headers,
  155647. qs: i
  155648. }, function(o, s) {
  155649. if (o)
  155650. return e(o);
  155651. var c = s.ListBucketResult || {}
  155652. , d = c.Contents || []
  155653. , _ = c.CommonPrefixes || [];
  155654. d = util$2.isArray(d) ? d : [d],
  155655. _ = util$2.isArray(_) ? _ : [_];
  155656. var b = util$2.clone(c);
  155657. util$2.extend(b, {
  155658. Contents: d,
  155659. CommonPrefixes: _,
  155660. statusCode: s.statusCode,
  155661. headers: s.headers
  155662. }),
  155663. e(null, b)
  155664. })
  155665. }
  155666. function deleteBucket(a, e) {
  155667. submitRequest.call(this, {
  155668. Action: "name/cos:DeleteBucket",
  155669. Bucket: a.Bucket,
  155670. Region: a.Region,
  155671. headers: a.Headers,
  155672. method: "DELETE"
  155673. }, function(i, o) {
  155674. if (i && i.statusCode === 204)
  155675. return e(null, {
  155676. statusCode: i.statusCode
  155677. });
  155678. if (i)
  155679. return e(i);
  155680. e(null, {
  155681. statusCode: o.statusCode,
  155682. headers: o.headers
  155683. })
  155684. })
  155685. }
  155686. function putBucketAcl(a, e) {
  155687. var i = a.Headers
  155688. , o = "";
  155689. if (a.AccessControlPolicy) {
  155690. var s = util$2.clone(a.AccessControlPolicy || {})
  155691. , c = s.Grants || s.Grant;
  155692. c = util$2.isArray(c) ? c : [c],
  155693. delete s.Grant,
  155694. delete s.Grants,
  155695. s.AccessControlList = {
  155696. Grant: c
  155697. },
  155698. o = util$2.json2xml({
  155699. AccessControlPolicy: s
  155700. }),
  155701. i["Content-Type"] = "application/xml",
  155702. i["Content-MD5"] = util$2.binaryBase64(util$2.md5(o))
  155703. }
  155704. util$2.each(i, function(d, _) {
  155705. _.indexOf("x-cos-grant-") === 0 && (i[_] = uniqGrant(i[_]))
  155706. }),
  155707. submitRequest.call(this, {
  155708. Action: "name/cos:PutBucketACL",
  155709. method: "PUT",
  155710. Bucket: a.Bucket,
  155711. Region: a.Region,
  155712. headers: i,
  155713. action: "acl",
  155714. body: o
  155715. }, function(d, _) {
  155716. if (d)
  155717. return e(d);
  155718. e(null, {
  155719. statusCode: _.statusCode,
  155720. headers: _.headers
  155721. })
  155722. })
  155723. }
  155724. function getBucketAcl(a, e) {
  155725. submitRequest.call(this, {
  155726. Action: "name/cos:GetBucketACL",
  155727. method: "GET",
  155728. Bucket: a.Bucket,
  155729. Region: a.Region,
  155730. headers: a.Headers,
  155731. action: "acl"
  155732. }, function(i, o) {
  155733. if (i)
  155734. return e(i);
  155735. var s = o.AccessControlPolicy || {}
  155736. , c = s.Owner || {}
  155737. , d = s.AccessControlList.Grant || [];
  155738. d = util$2.isArray(d) ? d : [d];
  155739. var _ = decodeAcl(s);
  155740. o.headers && o.headers["x-cos-acl"] && (_.ACL = o.headers["x-cos-acl"]),
  155741. _ = util$2.extend(_, {
  155742. Owner: c,
  155743. Grants: d,
  155744. statusCode: o.statusCode,
  155745. headers: o.headers
  155746. }),
  155747. e(null, _)
  155748. })
  155749. }
  155750. function putBucketCors(a, e) {
  155751. var i = a.CORSConfiguration || {}
  155752. , o = i.CORSRules || a.CORSRules || [];
  155753. o = util$2.clone(util$2.isArray(o) ? o : [o]),
  155754. util$2.each(o, function(d) {
  155755. util$2.each(["AllowedOrigin", "AllowedHeader", "AllowedMethod", "ExposeHeader"], function(_) {
  155756. var b = _ + "s"
  155757. , k = d[b] || d[_] || [];
  155758. delete d[b],
  155759. d[_] = util$2.isArray(k) ? k : [k]
  155760. })
  155761. });
  155762. var s = util$2.json2xml({
  155763. CORSConfiguration: {
  155764. CORSRule: o
  155765. }
  155766. })
  155767. , c = a.Headers;
  155768. c["Content-Type"] = "application/xml",
  155769. c["Content-MD5"] = util$2.binaryBase64(util$2.md5(s)),
  155770. submitRequest.call(this, {
  155771. Action: "name/cos:PutBucketCORS",
  155772. method: "PUT",
  155773. Bucket: a.Bucket,
  155774. Region: a.Region,
  155775. body: s,
  155776. action: "cors",
  155777. headers: c
  155778. }, function(d, _) {
  155779. if (d)
  155780. return e(d);
  155781. e(null, {
  155782. statusCode: _.statusCode,
  155783. headers: _.headers
  155784. })
  155785. })
  155786. }
  155787. function getBucketCors(a, e) {
  155788. submitRequest.call(this, {
  155789. Action: "name/cos:GetBucketCORS",
  155790. method: "GET",
  155791. Bucket: a.Bucket,
  155792. Region: a.Region,
  155793. headers: a.Headers,
  155794. action: "cors"
  155795. }, function(i, o) {
  155796. if (i) {
  155797. if (i.statusCode === 404 && i.error && i.error.Code === "NoSuchCORSConfiguration") {
  155798. var s = {
  155799. CORSRules: [],
  155800. statusCode: i.statusCode
  155801. };
  155802. i.headers && (s.headers = i.headers),
  155803. e(null, s)
  155804. } else
  155805. e(i);
  155806. return
  155807. }
  155808. var c = o.CORSConfiguration || {}
  155809. , d = c.CORSRules || c.CORSRule || [];
  155810. d = util$2.clone(util$2.isArray(d) ? d : [d]),
  155811. util$2.each(d, function(_) {
  155812. util$2.each(["AllowedOrigin", "AllowedHeader", "AllowedMethod", "ExposeHeader"], function(b) {
  155813. var k = b + "s"
  155814. , j = _[k] || _[b] || [];
  155815. delete _[b],
  155816. _[k] = util$2.isArray(j) ? j : [j]
  155817. })
  155818. }),
  155819. e(null, {
  155820. CORSRules: d,
  155821. statusCode: o.statusCode,
  155822. headers: o.headers
  155823. })
  155824. })
  155825. }
  155826. function deleteBucketCors(a, e) {
  155827. submitRequest.call(this, {
  155828. Action: "name/cos:DeleteBucketCORS",
  155829. method: "DELETE",
  155830. Bucket: a.Bucket,
  155831. Region: a.Region,
  155832. headers: a.Headers,
  155833. action: "cors"
  155834. }, function(i, o) {
  155835. if (i && i.statusCode === 204)
  155836. return e(null, {
  155837. statusCode: i.statusCode
  155838. });
  155839. if (i)
  155840. return e(i);
  155841. e(null, {
  155842. statusCode: o.statusCode || i.statusCode,
  155843. headers: o.headers
  155844. })
  155845. })
  155846. }
  155847. function getBucketLocation(a, e) {
  155848. submitRequest.call(this, {
  155849. Action: "name/cos:GetBucketLocation",
  155850. method: "GET",
  155851. Bucket: a.Bucket,
  155852. Region: a.Region,
  155853. headers: a.Headers,
  155854. action: "location"
  155855. }, e)
  155856. }
  155857. function putBucketPolicy(a, e) {
  155858. var i = a.Policy;
  155859. try {
  155860. typeof i == "string" && (i = JSON.parse(i))
  155861. } catch {}
  155862. if (!i || typeof i == "string")
  155863. return e(util$2.error(new Error("Policy format error")));
  155864. var o = JSON.stringify(i);
  155865. i.version || (i.version = "2.0");
  155866. var s = a.Headers;
  155867. s["Content-Type"] = "application/json",
  155868. s["Content-MD5"] = util$2.binaryBase64(util$2.md5(o)),
  155869. submitRequest.call(this, {
  155870. Action: "name/cos:PutBucketPolicy",
  155871. method: "PUT",
  155872. Bucket: a.Bucket,
  155873. Region: a.Region,
  155874. action: "policy",
  155875. body: o,
  155876. headers: s
  155877. }, function(c, d) {
  155878. if (c && c.statusCode === 204)
  155879. return e(null, {
  155880. statusCode: c.statusCode
  155881. });
  155882. if (c)
  155883. return e(c);
  155884. e(null, {
  155885. statusCode: d.statusCode,
  155886. headers: d.headers
  155887. })
  155888. })
  155889. }
  155890. function getBucketPolicy(a, e) {
  155891. submitRequest.call(this, {
  155892. Action: "name/cos:GetBucketPolicy",
  155893. method: "GET",
  155894. Bucket: a.Bucket,
  155895. Region: a.Region,
  155896. headers: a.Headers,
  155897. action: "policy",
  155898. rawBody: !0
  155899. }, function(i, o) {
  155900. if (i)
  155901. return i.statusCode && i.statusCode === 403 ? e(util$2.error(i, {
  155902. ErrorStatus: "Access Denied"
  155903. })) : i.statusCode && i.statusCode === 405 ? e(util$2.error(i, {
  155904. ErrorStatus: "Method Not Allowed"
  155905. })) : i.statusCode && i.statusCode === 404 ? e(util$2.error(i, {
  155906. ErrorStatus: "Policy Not Found"
  155907. })) : e(i);
  155908. var s = {};
  155909. try {
  155910. s = JSON.parse(o.body)
  155911. } catch {}
  155912. e(null, {
  155913. Policy: s,
  155914. statusCode: o.statusCode,
  155915. headers: o.headers
  155916. })
  155917. })
  155918. }
  155919. function deleteBucketPolicy(a, e) {
  155920. submitRequest.call(this, {
  155921. Action: "name/cos:DeleteBucketPolicy",
  155922. method: "DELETE",
  155923. Bucket: a.Bucket,
  155924. Region: a.Region,
  155925. headers: a.Headers,
  155926. action: "policy"
  155927. }, function(i, o) {
  155928. if (i && i.statusCode === 204)
  155929. return e(null, {
  155930. statusCode: i.statusCode
  155931. });
  155932. if (i)
  155933. return e(i);
  155934. e(null, {
  155935. statusCode: o.statusCode || i.statusCode,
  155936. headers: o.headers
  155937. })
  155938. })
  155939. }
  155940. function putBucketTagging(a, e) {
  155941. var i = a.Tagging || {}
  155942. , o = i.TagSet || i.Tags || a.Tags || [];
  155943. o = util$2.clone(util$2.isArray(o) ? o : [o]);
  155944. var s = util$2.json2xml({
  155945. Tagging: {
  155946. TagSet: {
  155947. Tag: o
  155948. }
  155949. }
  155950. })
  155951. , c = a.Headers;
  155952. c["Content-Type"] = "application/xml",
  155953. c["Content-MD5"] = util$2.binaryBase64(util$2.md5(s)),
  155954. submitRequest.call(this, {
  155955. Action: "name/cos:PutBucketTagging",
  155956. method: "PUT",
  155957. Bucket: a.Bucket,
  155958. Region: a.Region,
  155959. body: s,
  155960. action: "tagging",
  155961. headers: c
  155962. }, function(d, _) {
  155963. if (d && d.statusCode === 204)
  155964. return e(null, {
  155965. statusCode: d.statusCode
  155966. });
  155967. if (d)
  155968. return e(d);
  155969. e(null, {
  155970. statusCode: _.statusCode,
  155971. headers: _.headers
  155972. })
  155973. })
  155974. }
  155975. function getBucketTagging(a, e) {
  155976. submitRequest.call(this, {
  155977. Action: "name/cos:GetBucketTagging",
  155978. method: "GET",
  155979. Bucket: a.Bucket,
  155980. Region: a.Region,
  155981. headers: a.Headers,
  155982. action: "tagging"
  155983. }, function(i, o) {
  155984. if (i) {
  155985. if (i.statusCode === 404 && i.error && (i.error === "Not Found" || i.error.Code === "NoSuchTagSet")) {
  155986. var s = {
  155987. Tags: [],
  155988. statusCode: i.statusCode
  155989. };
  155990. i.headers && (s.headers = i.headers),
  155991. e(null, s)
  155992. } else
  155993. e(i);
  155994. return
  155995. }
  155996. var c = [];
  155997. try {
  155998. c = o.Tagging.TagSet.Tag || []
  155999. } catch {}
  156000. c = util$2.clone(util$2.isArray(c) ? c : [c]),
  156001. e(null, {
  156002. Tags: c,
  156003. statusCode: o.statusCode,
  156004. headers: o.headers
  156005. })
  156006. })
  156007. }
  156008. function deleteBucketTagging(a, e) {
  156009. submitRequest.call(this, {
  156010. Action: "name/cos:DeleteBucketTagging",
  156011. method: "DELETE",
  156012. Bucket: a.Bucket,
  156013. Region: a.Region,
  156014. headers: a.Headers,
  156015. action: "tagging"
  156016. }, function(i, o) {
  156017. if (i && i.statusCode === 204)
  156018. return e(null, {
  156019. statusCode: i.statusCode
  156020. });
  156021. if (i)
  156022. return e(i);
  156023. e(null, {
  156024. statusCode: o.statusCode,
  156025. headers: o.headers
  156026. })
  156027. })
  156028. }
  156029. function putBucketLifecycle(a, e) {
  156030. var i = a.LifecycleConfiguration || {}
  156031. , o = i.Rules || a.Rules || [];
  156032. o = util$2.clone(o);
  156033. var s = util$2.json2xml({
  156034. LifecycleConfiguration: {
  156035. Rule: o
  156036. }
  156037. })
  156038. , c = a.Headers;
  156039. c["Content-Type"] = "application/xml",
  156040. c["Content-MD5"] = util$2.binaryBase64(util$2.md5(s)),
  156041. submitRequest.call(this, {
  156042. Action: "name/cos:PutBucketLifecycle",
  156043. method: "PUT",
  156044. Bucket: a.Bucket,
  156045. Region: a.Region,
  156046. body: s,
  156047. action: "lifecycle",
  156048. headers: c
  156049. }, function(d, _) {
  156050. if (d && d.statusCode === 204)
  156051. return e(null, {
  156052. statusCode: d.statusCode
  156053. });
  156054. if (d)
  156055. return e(d);
  156056. e(null, {
  156057. statusCode: _.statusCode,
  156058. headers: _.headers
  156059. })
  156060. })
  156061. }
  156062. function getBucketLifecycle(a, e) {
  156063. submitRequest.call(this, {
  156064. Action: "name/cos:GetBucketLifecycle",
  156065. method: "GET",
  156066. Bucket: a.Bucket,
  156067. Region: a.Region,
  156068. headers: a.Headers,
  156069. action: "lifecycle"
  156070. }, function(i, o) {
  156071. if (i) {
  156072. if (i.statusCode === 404 && i.error && i.error.Code === "NoSuchLifecycleConfiguration") {
  156073. var s = {
  156074. Rules: [],
  156075. statusCode: i.statusCode
  156076. };
  156077. i.headers && (s.headers = i.headers),
  156078. e(null, s)
  156079. } else
  156080. e(i);
  156081. return
  156082. }
  156083. var c = [];
  156084. try {
  156085. c = o.LifecycleConfiguration.Rule || []
  156086. } catch {}
  156087. c = util$2.clone(util$2.isArray(c) ? c : [c]),
  156088. e(null, {
  156089. Rules: c,
  156090. statusCode: o.statusCode,
  156091. headers: o.headers
  156092. })
  156093. })
  156094. }
  156095. function deleteBucketLifecycle(a, e) {
  156096. submitRequest.call(this, {
  156097. Action: "name/cos:DeleteBucketLifecycle",
  156098. method: "DELETE",
  156099. Bucket: a.Bucket,
  156100. Region: a.Region,
  156101. headers: a.Headers,
  156102. action: "lifecycle"
  156103. }, function(i, o) {
  156104. if (i && i.statusCode === 204)
  156105. return e(null, {
  156106. statusCode: i.statusCode
  156107. });
  156108. if (i)
  156109. return e(i);
  156110. e(null, {
  156111. statusCode: o.statusCode,
  156112. headers: o.headers
  156113. })
  156114. })
  156115. }
  156116. function putBucketVersioning(a, e) {
  156117. if (!a.VersioningConfiguration) {
  156118. e(util$2.error(new Error("missing param VersioningConfiguration")));
  156119. return
  156120. }
  156121. var i = a.VersioningConfiguration || {}
  156122. , o = util$2.json2xml({
  156123. VersioningConfiguration: i
  156124. })
  156125. , s = a.Headers;
  156126. s["Content-Type"] = "application/xml",
  156127. s["Content-MD5"] = util$2.binaryBase64(util$2.md5(o)),
  156128. submitRequest.call(this, {
  156129. Action: "name/cos:PutBucketVersioning",
  156130. method: "PUT",
  156131. Bucket: a.Bucket,
  156132. Region: a.Region,
  156133. body: o,
  156134. action: "versioning",
  156135. headers: s
  156136. }, function(c, d) {
  156137. if (c && c.statusCode === 204)
  156138. return e(null, {
  156139. statusCode: c.statusCode
  156140. });
  156141. if (c)
  156142. return e(c);
  156143. e(null, {
  156144. statusCode: d.statusCode,
  156145. headers: d.headers
  156146. })
  156147. })
  156148. }
  156149. function getBucketVersioning(a, e) {
  156150. submitRequest.call(this, {
  156151. Action: "name/cos:GetBucketVersioning",
  156152. method: "GET",
  156153. Bucket: a.Bucket,
  156154. Region: a.Region,
  156155. headers: a.Headers,
  156156. action: "versioning"
  156157. }, function(i, o) {
  156158. i || !o.VersioningConfiguration && (o.VersioningConfiguration = {}),
  156159. e(i, o)
  156160. })
  156161. }
  156162. function putBucketReplication(a, e) {
  156163. var i = util$2.clone(a.ReplicationConfiguration)
  156164. , o = util$2.json2xml({
  156165. ReplicationConfiguration: i
  156166. });
  156167. o = o.replace(/<(\/?)Rules>/ig, "<$1Rule>"),
  156168. o = o.replace(/<(\/?)Tags>/ig, "<$1Tag>");
  156169. var s = a.Headers;
  156170. s["Content-Type"] = "application/xml",
  156171. s["Content-MD5"] = util$2.binaryBase64(util$2.md5(o)),
  156172. submitRequest.call(this, {
  156173. Action: "name/cos:PutBucketReplication",
  156174. method: "PUT",
  156175. Bucket: a.Bucket,
  156176. Region: a.Region,
  156177. body: o,
  156178. action: "replication",
  156179. headers: s
  156180. }, function(c, d) {
  156181. if (c && c.statusCode === 204)
  156182. return e(null, {
  156183. statusCode: c.statusCode
  156184. });
  156185. if (c)
  156186. return e(c);
  156187. e(null, {
  156188. statusCode: d.statusCode,
  156189. headers: d.headers
  156190. })
  156191. })
  156192. }
  156193. function getBucketReplication(a, e) {
  156194. submitRequest.call(this, {
  156195. Action: "name/cos:GetBucketReplication",
  156196. method: "GET",
  156197. Bucket: a.Bucket,
  156198. Region: a.Region,
  156199. headers: a.Headers,
  156200. action: "replication"
  156201. }, function(i, o) {
  156202. if (i) {
  156203. if (i.statusCode === 404 && i.error && (i.error === "Not Found" || i.error.Code === "ReplicationConfigurationnotFoundError")) {
  156204. var s = {
  156205. ReplicationConfiguration: {
  156206. Rules: []
  156207. },
  156208. statusCode: i.statusCode
  156209. };
  156210. i.headers && (s.headers = i.headers),
  156211. e(null, s)
  156212. } else
  156213. e(i);
  156214. return
  156215. }
  156216. !o.ReplicationConfiguration && (o.ReplicationConfiguration = {}),
  156217. o.ReplicationConfiguration.Rule && (o.ReplicationConfiguration.Rules = util$2.makeArray(o.ReplicationConfiguration.Rule),
  156218. delete o.ReplicationConfiguration.Rule),
  156219. e(i, o)
  156220. })
  156221. }
  156222. function deleteBucketReplication(a, e) {
  156223. submitRequest.call(this, {
  156224. Action: "name/cos:DeleteBucketReplication",
  156225. method: "DELETE",
  156226. Bucket: a.Bucket,
  156227. Region: a.Region,
  156228. headers: a.Headers,
  156229. action: "replication"
  156230. }, function(i, o) {
  156231. if (i && i.statusCode === 204)
  156232. return e(null, {
  156233. statusCode: i.statusCode
  156234. });
  156235. if (i)
  156236. return e(i);
  156237. e(null, {
  156238. statusCode: o.statusCode,
  156239. headers: o.headers
  156240. })
  156241. })
  156242. }
  156243. function putBucketWebsite(a, e) {
  156244. if (!a.WebsiteConfiguration) {
  156245. e(util$2.error(new Error("missing param WebsiteConfiguration")));
  156246. return
  156247. }
  156248. var i = util$2.clone(a.WebsiteConfiguration || {})
  156249. , o = i.RoutingRules || i.RoutingRule || [];
  156250. o = util$2.isArray(o) ? o : [o],
  156251. delete i.RoutingRule,
  156252. delete i.RoutingRules,
  156253. o.length && (i.RoutingRules = {
  156254. RoutingRule: o
  156255. });
  156256. var s = util$2.json2xml({
  156257. WebsiteConfiguration: i
  156258. })
  156259. , c = a.Headers;
  156260. c["Content-Type"] = "application/xml",
  156261. c["Content-MD5"] = util$2.binaryBase64(util$2.md5(s)),
  156262. submitRequest.call(this, {
  156263. Action: "name/cos:PutBucketWebsite",
  156264. method: "PUT",
  156265. Bucket: a.Bucket,
  156266. Region: a.Region,
  156267. body: s,
  156268. action: "website",
  156269. headers: c
  156270. }, function(d, _) {
  156271. if (d && d.statusCode === 204)
  156272. return e(null, {
  156273. statusCode: d.statusCode
  156274. });
  156275. if (d)
  156276. return e(d);
  156277. e(null, {
  156278. statusCode: _.statusCode,
  156279. headers: _.headers
  156280. })
  156281. })
  156282. }
  156283. function getBucketWebsite(a, e) {
  156284. submitRequest.call(this, {
  156285. Action: "name/cos:GetBucketWebsite",
  156286. method: "GET",
  156287. Bucket: a.Bucket,
  156288. Region: a.Region,
  156289. Key: a.Key,
  156290. headers: a.Headers,
  156291. action: "website"
  156292. }, function(i, o) {
  156293. if (i) {
  156294. if (i.statusCode === 404 && i.error.Code === "NoSuchWebsiteConfiguration") {
  156295. var s = {
  156296. WebsiteConfiguration: {},
  156297. statusCode: i.statusCode
  156298. };
  156299. i.headers && (s.headers = i.headers),
  156300. e(null, s)
  156301. } else
  156302. e(i);
  156303. return
  156304. }
  156305. var c = o.WebsiteConfiguration || {};
  156306. if (c.RoutingRules) {
  156307. var d = util$2.clone(c.RoutingRules.RoutingRule || []);
  156308. d = util$2.makeArray(d),
  156309. c.RoutingRules = d
  156310. }
  156311. e(null, {
  156312. WebsiteConfiguration: c,
  156313. statusCode: o.statusCode,
  156314. headers: o.headers
  156315. })
  156316. })
  156317. }
  156318. function deleteBucketWebsite(a, e) {
  156319. submitRequest.call(this, {
  156320. Action: "name/cos:DeleteBucketWebsite",
  156321. method: "DELETE",
  156322. Bucket: a.Bucket,
  156323. Region: a.Region,
  156324. headers: a.Headers,
  156325. action: "website"
  156326. }, function(i, o) {
  156327. if (i && i.statusCode === 204)
  156328. return e(null, {
  156329. statusCode: i.statusCode
  156330. });
  156331. if (i)
  156332. return e(i);
  156333. e(null, {
  156334. statusCode: o.statusCode,
  156335. headers: o.headers
  156336. })
  156337. })
  156338. }
  156339. function putBucketReferer(a, e) {
  156340. if (!a.RefererConfiguration) {
  156341. e(util$2.error(new Error("missing param RefererConfiguration")));
  156342. return
  156343. }
  156344. var i = util$2.clone(a.RefererConfiguration || {})
  156345. , o = i.DomainList || {}
  156346. , s = o.Domains || o.Domain || [];
  156347. s = util$2.isArray(s) ? s : [s],
  156348. s.length && (i.DomainList = {
  156349. Domain: s
  156350. });
  156351. var c = util$2.json2xml({
  156352. RefererConfiguration: i
  156353. })
  156354. , d = a.Headers;
  156355. d["Content-Type"] = "application/xml",
  156356. d["Content-MD5"] = util$2.binaryBase64(util$2.md5(c)),
  156357. submitRequest.call(this, {
  156358. Action: "name/cos:PutBucketReferer",
  156359. method: "PUT",
  156360. Bucket: a.Bucket,
  156361. Region: a.Region,
  156362. body: c,
  156363. action: "referer",
  156364. headers: d
  156365. }, function(_, b) {
  156366. if (_ && _.statusCode === 204)
  156367. return e(null, {
  156368. statusCode: _.statusCode
  156369. });
  156370. if (_)
  156371. return e(_);
  156372. e(null, {
  156373. statusCode: b.statusCode,
  156374. headers: b.headers
  156375. })
  156376. })
  156377. }
  156378. function getBucketReferer(a, e) {
  156379. submitRequest.call(this, {
  156380. Action: "name/cos:GetBucketReferer",
  156381. method: "GET",
  156382. Bucket: a.Bucket,
  156383. Region: a.Region,
  156384. Key: a.Key,
  156385. headers: a.Headers,
  156386. action: "referer"
  156387. }, function(i, o) {
  156388. if (i) {
  156389. if (i.statusCode === 404 && i.error.Code === "NoSuchRefererConfiguration") {
  156390. var s = {
  156391. WebsiteConfiguration: {},
  156392. statusCode: i.statusCode
  156393. };
  156394. i.headers && (s.headers = i.headers),
  156395. e(null, s)
  156396. } else
  156397. e(i);
  156398. return
  156399. }
  156400. var c = o.RefererConfiguration || {};
  156401. if (c.DomainList) {
  156402. var d = util$2.makeArray(c.DomainList.Domain || []);
  156403. c.DomainList = {
  156404. Domains: d
  156405. }
  156406. }
  156407. e(null, {
  156408. RefererConfiguration: c,
  156409. statusCode: o.statusCode,
  156410. headers: o.headers
  156411. })
  156412. })
  156413. }
  156414. function putBucketDomain(a, e) {
  156415. var i = a.DomainConfiguration || {}
  156416. , o = i.DomainRule || a.DomainRule || [];
  156417. o = util$2.clone(o);
  156418. var s = util$2.json2xml({
  156419. DomainConfiguration: {
  156420. DomainRule: o
  156421. }
  156422. })
  156423. , c = a.Headers;
  156424. c["Content-Type"] = "application/xml",
  156425. c["Content-MD5"] = util$2.binaryBase64(util$2.md5(s)),
  156426. submitRequest.call(this, {
  156427. Action: "name/cos:PutBucketDomain",
  156428. method: "PUT",
  156429. Bucket: a.Bucket,
  156430. Region: a.Region,
  156431. body: s,
  156432. action: "domain",
  156433. headers: c
  156434. }, function(d, _) {
  156435. if (d && d.statusCode === 204)
  156436. return e(null, {
  156437. statusCode: d.statusCode
  156438. });
  156439. if (d)
  156440. return e(d);
  156441. e(null, {
  156442. statusCode: _.statusCode,
  156443. headers: _.headers
  156444. })
  156445. })
  156446. }
  156447. function getBucketDomain(a, e) {
  156448. submitRequest.call(this, {
  156449. Action: "name/cos:GetBucketDomain",
  156450. method: "GET",
  156451. Bucket: a.Bucket,
  156452. Region: a.Region,
  156453. headers: a.Headers,
  156454. action: "domain"
  156455. }, function(i, o) {
  156456. if (i)
  156457. return e(i);
  156458. var s = [];
  156459. try {
  156460. s = o.DomainConfiguration.DomainRule || []
  156461. } catch {}
  156462. s = util$2.clone(util$2.isArray(s) ? s : [s]),
  156463. e(null, {
  156464. DomainRule: s,
  156465. statusCode: o.statusCode,
  156466. headers: o.headers
  156467. })
  156468. })
  156469. }
  156470. function deleteBucketDomain(a, e) {
  156471. submitRequest.call(this, {
  156472. Action: "name/cos:DeleteBucketDomain",
  156473. method: "DELETE",
  156474. Bucket: a.Bucket,
  156475. Region: a.Region,
  156476. headers: a.Headers,
  156477. action: "domain"
  156478. }, function(i, o) {
  156479. if (i && i.statusCode === 204)
  156480. return e(null, {
  156481. statusCode: i.statusCode
  156482. });
  156483. if (i)
  156484. return e(i);
  156485. e(null, {
  156486. statusCode: o.statusCode,
  156487. headers: o.headers
  156488. })
  156489. })
  156490. }
  156491. function putBucketOrigin(a, e) {
  156492. var i = a.OriginConfiguration || {}
  156493. , o = i.OriginRule || a.OriginRule || [];
  156494. o = util$2.clone(o);
  156495. var s = util$2.json2xml({
  156496. OriginConfiguration: {
  156497. OriginRule: o
  156498. }
  156499. })
  156500. , c = a.Headers;
  156501. c["Content-Type"] = "application/xml",
  156502. c["Content-MD5"] = util$2.binaryBase64(util$2.md5(s)),
  156503. submitRequest.call(this, {
  156504. Action: "name/cos:PutBucketOrigin",
  156505. method: "PUT",
  156506. Bucket: a.Bucket,
  156507. Region: a.Region,
  156508. body: s,
  156509. action: "origin",
  156510. headers: c
  156511. }, function(d, _) {
  156512. if (d && d.statusCode === 204)
  156513. return e(null, {
  156514. statusCode: d.statusCode
  156515. });
  156516. if (d)
  156517. return e(d);
  156518. e(null, {
  156519. statusCode: _.statusCode,
  156520. headers: _.headers
  156521. })
  156522. })
  156523. }
  156524. function getBucketOrigin(a, e) {
  156525. submitRequest.call(this, {
  156526. Action: "name/cos:GetBucketOrigin",
  156527. method: "GET",
  156528. Bucket: a.Bucket,
  156529. Region: a.Region,
  156530. headers: a.Headers,
  156531. action: "origin"
  156532. }, function(i, o) {
  156533. if (i)
  156534. return e(i);
  156535. var s = [];
  156536. try {
  156537. s = o.OriginConfiguration.OriginRule || []
  156538. } catch {}
  156539. s = util$2.clone(util$2.isArray(s) ? s : [s]),
  156540. e(null, {
  156541. OriginRule: s,
  156542. statusCode: o.statusCode,
  156543. headers: o.headers
  156544. })
  156545. })
  156546. }
  156547. function deleteBucketOrigin(a, e) {
  156548. submitRequest.call(this, {
  156549. Action: "name/cos:DeleteBucketOrigin",
  156550. method: "DELETE",
  156551. Bucket: a.Bucket,
  156552. Region: a.Region,
  156553. headers: a.Headers,
  156554. action: "origin"
  156555. }, function(i, o) {
  156556. if (i && i.statusCode === 204)
  156557. return e(null, {
  156558. statusCode: i.statusCode
  156559. });
  156560. if (i)
  156561. return e(i);
  156562. e(null, {
  156563. statusCode: o.statusCode,
  156564. headers: o.headers
  156565. })
  156566. })
  156567. }
  156568. function putBucketLogging(a, e) {
  156569. var i = util$2.json2xml({
  156570. BucketLoggingStatus: a.BucketLoggingStatus || ""
  156571. })
  156572. , o = a.Headers;
  156573. o["Content-Type"] = "application/xml",
  156574. o["Content-MD5"] = util$2.binaryBase64(util$2.md5(i)),
  156575. submitRequest.call(this, {
  156576. Action: "name/cos:PutBucketLogging",
  156577. method: "PUT",
  156578. Bucket: a.Bucket,
  156579. Region: a.Region,
  156580. body: i,
  156581. action: "logging",
  156582. headers: o
  156583. }, function(s, c) {
  156584. if (s && s.statusCode === 204)
  156585. return e(null, {
  156586. statusCode: s.statusCode
  156587. });
  156588. if (s)
  156589. return e(s);
  156590. e(null, {
  156591. statusCode: c.statusCode,
  156592. headers: c.headers
  156593. })
  156594. })
  156595. }
  156596. function getBucketLogging(a, e) {
  156597. submitRequest.call(this, {
  156598. Action: "name/cos:GetBucketLogging",
  156599. method: "GET",
  156600. Bucket: a.Bucket,
  156601. Region: a.Region,
  156602. headers: a.Headers,
  156603. action: "logging"
  156604. }, function(i, o) {
  156605. if (i)
  156606. return e(i);
  156607. e(null, {
  156608. BucketLoggingStatus: o.BucketLoggingStatus,
  156609. statusCode: o.statusCode,
  156610. headers: o.headers
  156611. })
  156612. })
  156613. }
  156614. function putBucketInventory(a, e) {
  156615. var i = util$2.clone(a.InventoryConfiguration);
  156616. if (i.OptionalFields) {
  156617. var o = i.OptionalFields || [];
  156618. i.OptionalFields = {
  156619. Field: o
  156620. }
  156621. }
  156622. if (i.Destination && i.Destination.COSBucketDestination && i.Destination.COSBucketDestination.Encryption) {
  156623. var s = i.Destination.COSBucketDestination.Encryption;
  156624. Object.keys(s).indexOf("SSECOS") > -1 && (s["SSE-COS"] = s.SSECOS,
  156625. delete s.SSECOS)
  156626. }
  156627. var c = util$2.json2xml({
  156628. InventoryConfiguration: i
  156629. })
  156630. , d = a.Headers;
  156631. d["Content-Type"] = "application/xml",
  156632. d["Content-MD5"] = util$2.binaryBase64(util$2.md5(c)),
  156633. submitRequest.call(this, {
  156634. Action: "name/cos:PutBucketInventory",
  156635. method: "PUT",
  156636. Bucket: a.Bucket,
  156637. Region: a.Region,
  156638. body: c,
  156639. action: "inventory",
  156640. qs: {
  156641. id: a.Id
  156642. },
  156643. headers: d
  156644. }, function(_, b) {
  156645. if (_ && _.statusCode === 204)
  156646. return e(null, {
  156647. statusCode: _.statusCode
  156648. });
  156649. if (_)
  156650. return e(_);
  156651. e(null, {
  156652. statusCode: b.statusCode,
  156653. headers: b.headers
  156654. })
  156655. })
  156656. }
  156657. function getBucketInventory(a, e) {
  156658. submitRequest.call(this, {
  156659. Action: "name/cos:GetBucketInventory",
  156660. method: "GET",
  156661. Bucket: a.Bucket,
  156662. Region: a.Region,
  156663. headers: a.Headers,
  156664. action: "inventory",
  156665. qs: {
  156666. id: a.Id
  156667. }
  156668. }, function(i, o) {
  156669. if (i)
  156670. return e(i);
  156671. var s = o.InventoryConfiguration;
  156672. if (s && s.OptionalFields && s.OptionalFields.Field) {
  156673. var c = s.OptionalFields.Field;
  156674. util$2.isArray(c) || (c = [c]),
  156675. s.OptionalFields = c
  156676. }
  156677. if (s.Destination && s.Destination.COSBucketDestination && s.Destination.COSBucketDestination.Encryption) {
  156678. var d = s.Destination.COSBucketDestination.Encryption;
  156679. Object.keys(d).indexOf("SSE-COS") > -1 && (d.SSECOS = d["SSE-COS"],
  156680. delete d["SSE-COS"])
  156681. }
  156682. e(null, {
  156683. InventoryConfiguration: s,
  156684. statusCode: o.statusCode,
  156685. headers: o.headers
  156686. })
  156687. })
  156688. }
  156689. function listBucketInventory(a, e) {
  156690. submitRequest.call(this, {
  156691. Action: "name/cos:ListBucketInventory",
  156692. method: "GET",
  156693. Bucket: a.Bucket,
  156694. Region: a.Region,
  156695. headers: a.Headers,
  156696. action: "inventory",
  156697. qs: {
  156698. "continuation-token": a.ContinuationToken
  156699. }
  156700. }, function(i, o) {
  156701. if (i)
  156702. return e(i);
  156703. var s = o.ListInventoryConfigurationResult
  156704. , c = s.InventoryConfiguration || [];
  156705. c = util$2.isArray(c) ? c : [c],
  156706. delete s.InventoryConfiguration,
  156707. util$2.each(c, function(d) {
  156708. if (d && d.OptionalFields && d.OptionalFields.Field) {
  156709. var _ = d.OptionalFields.Field;
  156710. util$2.isArray(_) || (_ = [_]),
  156711. d.OptionalFields = _
  156712. }
  156713. if (d.Destination && d.Destination.COSBucketDestination && d.Destination.COSBucketDestination.Encryption) {
  156714. var b = d.Destination.COSBucketDestination.Encryption;
  156715. Object.keys(b).indexOf("SSE-COS") > -1 && (b.SSECOS = b["SSE-COS"],
  156716. delete b["SSE-COS"])
  156717. }
  156718. }),
  156719. s.InventoryConfigurations = c,
  156720. util$2.extend(s, {
  156721. statusCode: o.statusCode,
  156722. headers: o.headers
  156723. }),
  156724. e(null, s)
  156725. })
  156726. }
  156727. function deleteBucketInventory(a, e) {
  156728. submitRequest.call(this, {
  156729. Action: "name/cos:DeleteBucketInventory",
  156730. method: "DELETE",
  156731. Bucket: a.Bucket,
  156732. Region: a.Region,
  156733. headers: a.Headers,
  156734. action: "inventory",
  156735. qs: {
  156736. id: a.Id
  156737. }
  156738. }, function(i, o) {
  156739. if (i && i.statusCode === 204)
  156740. return e(null, {
  156741. statusCode: i.statusCode
  156742. });
  156743. if (i)
  156744. return e(i);
  156745. e(null, {
  156746. statusCode: o.statusCode,
  156747. headers: o.headers
  156748. })
  156749. })
  156750. }
  156751. function putBucketAccelerate(a, e) {
  156752. if (!a.AccelerateConfiguration) {
  156753. e(util$2.error(new Error("missing param AccelerateConfiguration")));
  156754. return
  156755. }
  156756. var i = {
  156757. AccelerateConfiguration: a.AccelerateConfiguration || {}
  156758. }
  156759. , o = util$2.json2xml(i)
  156760. , s = {};
  156761. s["Content-Type"] = "application/xml",
  156762. s["Content-MD5"] = util$2.binaryBase64(util$2.md5(o)),
  156763. submitRequest.call(this, {
  156764. Action: "name/cos:PutBucketAccelerate",
  156765. method: "PUT",
  156766. Bucket: a.Bucket,
  156767. Region: a.Region,
  156768. body: o,
  156769. action: "accelerate",
  156770. headers: s
  156771. }, function(c, d) {
  156772. if (c)
  156773. return e(c);
  156774. e(null, {
  156775. statusCode: d.statusCode,
  156776. headers: d.headers
  156777. })
  156778. })
  156779. }
  156780. function getBucketAccelerate(a, e) {
  156781. submitRequest.call(this, {
  156782. Action: "name/cos:GetBucketAccelerate",
  156783. method: "GET",
  156784. Bucket: a.Bucket,
  156785. Region: a.Region,
  156786. action: "accelerate"
  156787. }, function(i, o) {
  156788. i || !o.AccelerateConfiguration && (o.AccelerateConfiguration = {}),
  156789. e(i, o)
  156790. })
  156791. }
  156792. function putBucketEncryption(a, e) {
  156793. var i = a.ServerSideEncryptionConfiguration || {}
  156794. , o = i.Rule || i.Rules || []
  156795. , s = util$2.json2xml({
  156796. ServerSideEncryptionConfiguration: {
  156797. Rule: o
  156798. }
  156799. })
  156800. , c = a.Headers;
  156801. c["Content-Type"] = "application/xml",
  156802. c["Content-MD5"] = util$2.binaryBase64(util$2.md5(s)),
  156803. submitRequest.call(this, {
  156804. Action: "name/cos:PutBucketEncryption",
  156805. method: "PUT",
  156806. Bucket: a.Bucket,
  156807. Region: a.Region,
  156808. body: s,
  156809. action: "encryption",
  156810. headers: c
  156811. }, function(d, _) {
  156812. if (d && d.statusCode === 204)
  156813. return e(null, {
  156814. statusCode: d.statusCode
  156815. });
  156816. if (d)
  156817. return e(d);
  156818. e(null, {
  156819. statusCode: _.statusCode,
  156820. headers: _.headers
  156821. })
  156822. })
  156823. }
  156824. function getBucketEncryption(a, e) {
  156825. submitRequest.call(this, {
  156826. Action: "name/cos:GetBucketEncryption",
  156827. method: "GET",
  156828. Bucket: a.Bucket,
  156829. Region: a.Region,
  156830. headers: a.Headers,
  156831. action: "encryption"
  156832. }, function(i, o) {
  156833. if (i) {
  156834. if (i.statusCode === 404 && i.code === "NoSuchEncryptionConfiguration") {
  156835. var s = {
  156836. EncryptionConfiguration: {
  156837. Rules: []
  156838. },
  156839. statusCode: i.statusCode
  156840. };
  156841. i.headers && (s.headers = i.headers),
  156842. e(null, s)
  156843. } else
  156844. e(i);
  156845. return
  156846. }
  156847. var c = util$2.makeArray(o.EncryptionConfiguration && o.EncryptionConfiguration.Rule || []);
  156848. o.EncryptionConfiguration = {
  156849. Rules: c
  156850. },
  156851. e(i, o)
  156852. })
  156853. }
  156854. function deleteBucketEncryption(a, e) {
  156855. submitRequest.call(this, {
  156856. Action: "name/cos:DeleteBucketReplication",
  156857. method: "DELETE",
  156858. Bucket: a.Bucket,
  156859. Region: a.Region,
  156860. headers: a.Headers,
  156861. action: "encryption"
  156862. }, function(i, o) {
  156863. if (i && i.statusCode === 204)
  156864. return e(null, {
  156865. statusCode: i.statusCode
  156866. });
  156867. if (i)
  156868. return e(i);
  156869. e(null, {
  156870. statusCode: o.statusCode,
  156871. headers: o.headers
  156872. })
  156873. })
  156874. }
  156875. function headObject(a, e) {
  156876. submitRequest.call(this, {
  156877. Action: "name/cos:HeadObject",
  156878. method: "HEAD",
  156879. Bucket: a.Bucket,
  156880. Region: a.Region,
  156881. Key: a.Key,
  156882. VersionId: a.VersionId,
  156883. headers: a.Headers
  156884. }, function(i, o) {
  156885. if (i) {
  156886. var s = i.statusCode;
  156887. return a.Headers["If-Modified-Since"] && s && s === 304 ? e(null, {
  156888. NotModified: !0,
  156889. statusCode: s
  156890. }) : e(i)
  156891. }
  156892. o.ETag = util$2.attr(o.headers, "etag", ""),
  156893. e(null, o)
  156894. })
  156895. }
  156896. function listObjectVersions(a, e) {
  156897. var i = {};
  156898. i.prefix = a.Prefix || "",
  156899. i.delimiter = a.Delimiter,
  156900. i["key-marker"] = a.KeyMarker,
  156901. i["version-id-marker"] = a.VersionIdMarker,
  156902. i["max-keys"] = a.MaxKeys,
  156903. i["encoding-type"] = a.EncodingType,
  156904. submitRequest.call(this, {
  156905. Action: "name/cos:GetBucketObjectVersions",
  156906. ResourceKey: i.prefix,
  156907. method: "GET",
  156908. Bucket: a.Bucket,
  156909. Region: a.Region,
  156910. headers: a.Headers,
  156911. qs: i,
  156912. action: "versions"
  156913. }, function(o, s) {
  156914. if (o)
  156915. return e(o);
  156916. var c = s.ListVersionsResult || {}
  156917. , d = c.DeleteMarker || [];
  156918. d = util$2.isArray(d) ? d : [d];
  156919. var _ = c.Version || [];
  156920. _ = util$2.isArray(_) ? _ : [_];
  156921. var b = util$2.clone(c);
  156922. delete b.DeleteMarker,
  156923. delete b.Version,
  156924. util$2.extend(b, {
  156925. DeleteMarkers: d,
  156926. Versions: _,
  156927. statusCode: s.statusCode,
  156928. headers: s.headers
  156929. }),
  156930. e(null, b)
  156931. })
  156932. }
  156933. function getObject(a, e) {
  156934. var i = a.Query || {}
  156935. , o = a.QueryString || ""
  156936. , s = util$2.throttleOnProgress.call(this, 0, a.onProgress);
  156937. i["response-content-type"] = a.ResponseContentType,
  156938. i["response-content-language"] = a.ResponseContentLanguage,
  156939. i["response-expires"] = a.ResponseExpires,
  156940. i["response-cache-control"] = a.ResponseCacheControl,
  156941. i["response-content-disposition"] = a.ResponseContentDisposition,
  156942. i["response-content-encoding"] = a.ResponseContentEncoding,
  156943. submitRequest.call(this, {
  156944. Action: "name/cos:GetObject",
  156945. method: "GET",
  156946. Bucket: a.Bucket,
  156947. Region: a.Region,
  156948. Key: a.Key,
  156949. VersionId: a.VersionId,
  156950. DataType: a.DataType,
  156951. headers: a.Headers,
  156952. qs: i,
  156953. qsStr: o,
  156954. rawBody: !0,
  156955. onDownloadProgress: s
  156956. }, function(c, d) {
  156957. if (s(null, !0),
  156958. c) {
  156959. var _ = c.statusCode;
  156960. return a.Headers["If-Modified-Since"] && _ && _ === 304 ? e(null, {
  156961. NotModified: !0
  156962. }) : e(c)
  156963. }
  156964. e(null, {
  156965. Body: d.body,
  156966. ETag: util$2.attr(d.headers, "etag", ""),
  156967. statusCode: d.statusCode,
  156968. headers: d.headers
  156969. })
  156970. })
  156971. }
  156972. function putObject(a, e) {
  156973. var i = this
  156974. , o = a.ContentLength
  156975. , s = util$2.throttleOnProgress.call(i, o, a.onProgress)
  156976. , c = a.Headers;
  156977. !c["Cache-Control"] && !c["cache-control"] && (c["Cache-Control"] = ""),
  156978. !c["Content-Type"] && !c["content-type"] && (c["Content-Type"] = a.Body && a.Body.type || "");
  156979. var d = a.UploadAddMetaMd5 || i.options.UploadAddMetaMd5 || i.options.UploadCheckContentMd5;
  156980. util$2.getBodyMd5(d, a.Body, function(_) {
  156981. _ && (i.options.UploadCheckContentMd5 && (c["Content-MD5"] = util$2.binaryBase64(_)),
  156982. (a.UploadAddMetaMd5 || i.options.UploadAddMetaMd5) && (c["x-cos-meta-md5"] = _)),
  156983. a.ContentLength !== void 0 && (c["Content-Length"] = a.ContentLength),
  156984. s(null, !0),
  156985. submitRequest.call(i, {
  156986. Action: "name/cos:PutObject",
  156987. TaskId: a.TaskId,
  156988. method: "PUT",
  156989. Bucket: a.Bucket,
  156990. Region: a.Region,
  156991. Key: a.Key,
  156992. headers: a.Headers,
  156993. qs: a.Query,
  156994. body: a.Body,
  156995. onProgress: s
  156996. }, function(b, k) {
  156997. if (b)
  156998. return s(null, !0),
  156999. e(b);
  157000. s({
  157001. loaded: o,
  157002. total: o
  157003. }, !0);
  157004. var j = getUrl({
  157005. ForcePathStyle: i.options.ForcePathStyle,
  157006. protocol: i.options.Protocol,
  157007. domain: i.options.Domain,
  157008. bucket: a.Bucket,
  157009. region: i.options.UseAccelerate ? "accelerate" : a.Region,
  157010. object: a.Key
  157011. });
  157012. j = j.substr(j.indexOf("://") + 3),
  157013. k.Location = j,
  157014. k.ETag = util$2.attr(k.headers, "etag", ""),
  157015. e(null, k)
  157016. })
  157017. }, a.onHashProgress)
  157018. }
  157019. function deleteObject(a, e) {
  157020. submitRequest.call(this, {
  157021. Action: "name/cos:DeleteObject",
  157022. method: "DELETE",
  157023. Bucket: a.Bucket,
  157024. Region: a.Region,
  157025. Key: a.Key,
  157026. headers: a.Headers,
  157027. VersionId: a.VersionId,
  157028. action: a.Recursive ? "recursive" : ""
  157029. }, function(i, o) {
  157030. if (i) {
  157031. var s = i.statusCode;
  157032. return s && s === 404 ? e(null, {
  157033. BucketNotFound: !0,
  157034. statusCode: s
  157035. }) : e(i)
  157036. }
  157037. e(null, {
  157038. statusCode: o.statusCode,
  157039. headers: o.headers
  157040. })
  157041. })
  157042. }
  157043. function getObjectAcl(a, e) {
  157044. submitRequest.call(this, {
  157045. Action: "name/cos:GetObjectACL",
  157046. method: "GET",
  157047. Bucket: a.Bucket,
  157048. Region: a.Region,
  157049. Key: a.Key,
  157050. headers: a.Headers,
  157051. action: "acl"
  157052. }, function(i, o) {
  157053. if (i)
  157054. return e(i);
  157055. var s = o.AccessControlPolicy || {}
  157056. , c = s.Owner || {}
  157057. , d = s.AccessControlList && s.AccessControlList.Grant || [];
  157058. d = util$2.isArray(d) ? d : [d];
  157059. var _ = decodeAcl(s);
  157060. delete _.GrantWrite,
  157061. o.headers && o.headers["x-cos-acl"] && (_.ACL = o.headers["x-cos-acl"]),
  157062. _ = util$2.extend(_, {
  157063. Owner: c,
  157064. Grants: d,
  157065. statusCode: o.statusCode,
  157066. headers: o.headers
  157067. }),
  157068. e(null, _)
  157069. })
  157070. }
  157071. function putObjectAcl(a, e) {
  157072. var i = a.Headers
  157073. , o = "";
  157074. if (a.AccessControlPolicy) {
  157075. var s = util$2.clone(a.AccessControlPolicy || {})
  157076. , c = s.Grants || s.Grant;
  157077. c = util$2.isArray(c) ? c : [c],
  157078. delete s.Grant,
  157079. delete s.Grants,
  157080. s.AccessControlList = {
  157081. Grant: c
  157082. },
  157083. o = util$2.json2xml({
  157084. AccessControlPolicy: s
  157085. }),
  157086. i["Content-Type"] = "application/xml",
  157087. i["Content-MD5"] = util$2.binaryBase64(util$2.md5(o))
  157088. }
  157089. util$2.each(i, function(d, _) {
  157090. _.indexOf("x-cos-grant-") === 0 && (i[_] = uniqGrant(i[_]))
  157091. }),
  157092. submitRequest.call(this, {
  157093. Action: "name/cos:PutObjectACL",
  157094. method: "PUT",
  157095. Bucket: a.Bucket,
  157096. Region: a.Region,
  157097. Key: a.Key,
  157098. action: "acl",
  157099. headers: i,
  157100. body: o
  157101. }, function(d, _) {
  157102. if (d)
  157103. return e(d);
  157104. e(null, {
  157105. statusCode: _.statusCode,
  157106. headers: _.headers
  157107. })
  157108. })
  157109. }
  157110. function optionsObject(a, e) {
  157111. var i = a.Headers;
  157112. i.Origin = a.Origin,
  157113. i["Access-Control-Request-Method"] = a.AccessControlRequestMethod,
  157114. i["Access-Control-Request-Headers"] = a.AccessControlRequestHeaders,
  157115. submitRequest.call(this, {
  157116. Action: "name/cos:OptionsObject",
  157117. method: "OPTIONS",
  157118. Bucket: a.Bucket,
  157119. Region: a.Region,
  157120. Key: a.Key,
  157121. headers: i
  157122. }, function(o, s) {
  157123. if (o)
  157124. return o.statusCode && o.statusCode === 403 ? e(null, {
  157125. OptionsForbidden: !0,
  157126. statusCode: o.statusCode
  157127. }) : e(o);
  157128. var c = s.headers || {};
  157129. e(null, {
  157130. AccessControlAllowOrigin: c["access-control-allow-origin"],
  157131. AccessControlAllowMethods: c["access-control-allow-methods"],
  157132. AccessControlAllowHeaders: c["access-control-allow-headers"],
  157133. AccessControlExposeHeaders: c["access-control-expose-headers"],
  157134. AccessControlMaxAge: c["access-control-max-age"],
  157135. statusCode: s.statusCode,
  157136. headers: s.headers
  157137. })
  157138. })
  157139. }
  157140. function putObjectCopy(a, e) {
  157141. var i = this
  157142. , o = a.Headers;
  157143. !o["Cache-Control"] && !o["cache-control"] && (o["Cache-Control"] = "");
  157144. var s = a.CopySource || ""
  157145. , c = util$2.getSourceParams.call(this, s);
  157146. if (!c) {
  157147. e(util$2.error(new Error("CopySource format error")));
  157148. return
  157149. }
  157150. var d = c[1]
  157151. , _ = c[3]
  157152. , b = decodeURIComponent(c[4]);
  157153. submitRequest.call(this, {
  157154. Scope: [{
  157155. action: "name/cos:GetObject",
  157156. bucket: d,
  157157. region: _,
  157158. prefix: b
  157159. }, {
  157160. action: "name/cos:PutObject",
  157161. bucket: a.Bucket,
  157162. region: a.Region,
  157163. prefix: a.Key
  157164. }],
  157165. method: "PUT",
  157166. Bucket: a.Bucket,
  157167. Region: a.Region,
  157168. Key: a.Key,
  157169. VersionId: a.VersionId,
  157170. headers: a.Headers
  157171. }, function(k, j) {
  157172. if (k)
  157173. return e(k);
  157174. var $ = util$2.clone(j.CopyObjectResult || {})
  157175. , _e = getUrl({
  157176. ForcePathStyle: i.options.ForcePathStyle,
  157177. protocol: i.options.Protocol,
  157178. domain: i.options.Domain,
  157179. bucket: a.Bucket,
  157180. region: a.Region,
  157181. object: a.Key,
  157182. isLocation: !0
  157183. });
  157184. util$2.extend($, {
  157185. Location: _e,
  157186. statusCode: j.statusCode,
  157187. headers: j.headers
  157188. }),
  157189. e(null, $)
  157190. })
  157191. }
  157192. function uploadPartCopy(a, e) {
  157193. var i = a.CopySource || ""
  157194. , o = util$2.getSourceParams.call(this, i);
  157195. if (!o) {
  157196. e(util$2.error(new Error("CopySource format error")));
  157197. return
  157198. }
  157199. var s = o[1]
  157200. , c = o[3]
  157201. , d = decodeURIComponent(o[4]);
  157202. submitRequest.call(this, {
  157203. Scope: [{
  157204. action: "name/cos:GetObject",
  157205. bucket: s,
  157206. region: c,
  157207. prefix: d
  157208. }, {
  157209. action: "name/cos:PutObject",
  157210. bucket: a.Bucket,
  157211. region: a.Region,
  157212. prefix: a.Key
  157213. }],
  157214. method: "PUT",
  157215. Bucket: a.Bucket,
  157216. Region: a.Region,
  157217. Key: a.Key,
  157218. VersionId: a.VersionId,
  157219. qs: {
  157220. partNumber: a.PartNumber,
  157221. uploadId: a.UploadId
  157222. },
  157223. headers: a.Headers
  157224. }, function(_, b) {
  157225. if (_)
  157226. return e(_);
  157227. var k = util$2.clone(b.CopyPartResult || {});
  157228. util$2.extend(k, {
  157229. statusCode: b.statusCode,
  157230. headers: b.headers
  157231. }),
  157232. e(null, k)
  157233. })
  157234. }
  157235. function deleteMultipleObject(a, e) {
  157236. var i = a.Objects || []
  157237. , o = a.Quiet;
  157238. i = util$2.isArray(i) ? i : [i];
  157239. var s = util$2.json2xml({
  157240. Delete: {
  157241. Object: i,
  157242. Quiet: o || !1
  157243. }
  157244. })
  157245. , c = a.Headers;
  157246. c["Content-Type"] = "application/xml",
  157247. c["Content-MD5"] = util$2.binaryBase64(util$2.md5(s));
  157248. var d = util$2.map(i, function(_) {
  157249. return {
  157250. action: "name/cos:DeleteObject",
  157251. bucket: a.Bucket,
  157252. region: a.Region,
  157253. prefix: _.Key
  157254. }
  157255. });
  157256. submitRequest.call(this, {
  157257. Scope: d,
  157258. method: "POST",
  157259. Bucket: a.Bucket,
  157260. Region: a.Region,
  157261. body: s,
  157262. action: "delete",
  157263. headers: c
  157264. }, function(_, b) {
  157265. if (_)
  157266. return e(_);
  157267. var k = b.DeleteResult || {}
  157268. , j = k.Deleted || []
  157269. , $ = k.Error || [];
  157270. j = util$2.isArray(j) ? j : [j],
  157271. $ = util$2.isArray($) ? $ : [$];
  157272. var _e = util$2.clone(k);
  157273. util$2.extend(_e, {
  157274. Error: $,
  157275. Deleted: j,
  157276. statusCode: b.statusCode,
  157277. headers: b.headers
  157278. }),
  157279. e(null, _e)
  157280. })
  157281. }
  157282. function restoreObject(a, e) {
  157283. var i = a.Headers;
  157284. if (!a.RestoreRequest) {
  157285. e(util$2.error(new Error("missing param RestoreRequest")));
  157286. return
  157287. }
  157288. var o = a.RestoreRequest || {}
  157289. , s = util$2.json2xml({
  157290. RestoreRequest: o
  157291. });
  157292. i["Content-Type"] = "application/xml",
  157293. i["Content-MD5"] = util$2.binaryBase64(util$2.md5(s)),
  157294. submitRequest.call(this, {
  157295. Action: "name/cos:RestoreObject",
  157296. method: "POST",
  157297. Bucket: a.Bucket,
  157298. Region: a.Region,
  157299. Key: a.Key,
  157300. VersionId: a.VersionId,
  157301. body: s,
  157302. action: "restore",
  157303. headers: i
  157304. }, e)
  157305. }
  157306. function putObjectTagging(a, e) {
  157307. var i = a.Tagging || {}
  157308. , o = i.TagSet || i.Tags || a.Tags || [];
  157309. o = util$2.clone(util$2.isArray(o) ? o : [o]);
  157310. var s = util$2.json2xml({
  157311. Tagging: {
  157312. TagSet: {
  157313. Tag: o
  157314. }
  157315. }
  157316. })
  157317. , c = a.Headers;
  157318. c["Content-Type"] = "application/xml",
  157319. c["Content-MD5"] = util$2.binaryBase64(util$2.md5(s)),
  157320. submitRequest.call(this, {
  157321. Action: "name/cos:PutObjectTagging",
  157322. method: "PUT",
  157323. Bucket: a.Bucket,
  157324. Key: a.Key,
  157325. Region: a.Region,
  157326. body: s,
  157327. action: "tagging",
  157328. headers: c,
  157329. VersionId: a.VersionId
  157330. }, function(d, _) {
  157331. if (d && d.statusCode === 204)
  157332. return e(null, {
  157333. statusCode: d.statusCode
  157334. });
  157335. if (d)
  157336. return e(d);
  157337. e(null, {
  157338. statusCode: _.statusCode,
  157339. headers: _.headers
  157340. })
  157341. })
  157342. }
  157343. function getObjectTagging(a, e) {
  157344. submitRequest.call(this, {
  157345. Action: "name/cos:GetObjectTagging",
  157346. method: "GET",
  157347. Key: a.Key,
  157348. Bucket: a.Bucket,
  157349. Region: a.Region,
  157350. headers: a.Headers,
  157351. action: "tagging",
  157352. VersionId: a.VersionId
  157353. }, function(i, o) {
  157354. if (i) {
  157355. if (i.statusCode === 404 && i.error && (i.error === "Not Found" || i.error.Code === "NoSuchTagSet")) {
  157356. var s = {
  157357. Tags: [],
  157358. statusCode: i.statusCode
  157359. };
  157360. i.headers && (s.headers = i.headers),
  157361. e(null, s)
  157362. } else
  157363. e(i);
  157364. return
  157365. }
  157366. var c = [];
  157367. try {
  157368. c = o.Tagging.TagSet.Tag || []
  157369. } catch {}
  157370. c = util$2.clone(util$2.isArray(c) ? c : [c]),
  157371. e(null, {
  157372. Tags: c,
  157373. statusCode: o.statusCode,
  157374. headers: o.headers
  157375. })
  157376. })
  157377. }
  157378. function deleteObjectTagging(a, e) {
  157379. submitRequest.call(this, {
  157380. Action: "name/cos:DeleteObjectTagging",
  157381. method: "DELETE",
  157382. Bucket: a.Bucket,
  157383. Region: a.Region,
  157384. Key: a.Key,
  157385. headers: a.Headers,
  157386. action: "tagging",
  157387. VersionId: a.VersionId
  157388. }, function(i, o) {
  157389. if (i && i.statusCode === 204)
  157390. return e(null, {
  157391. statusCode: i.statusCode
  157392. });
  157393. if (i)
  157394. return e(i);
  157395. e(null, {
  157396. statusCode: o.statusCode,
  157397. headers: o.headers
  157398. })
  157399. })
  157400. }
  157401. function selectObjectContent(a, e) {
  157402. var i = a.SelectType;
  157403. if (!i)
  157404. return e(util$2.error(new Error("missing param SelectType")));
  157405. var o = a.SelectRequest || {}
  157406. , s = util$2.json2xml({
  157407. SelectRequest: o
  157408. })
  157409. , c = a.Headers;
  157410. c["Content-Type"] = "application/xml",
  157411. c["Content-MD5"] = util$2.binaryBase64(util$2.md5(s)),
  157412. submitRequest.call(this, {
  157413. Action: "name/cos:GetObject",
  157414. method: "POST",
  157415. Bucket: a.Bucket,
  157416. Region: a.Region,
  157417. Key: a.Key,
  157418. headers: a.Headers,
  157419. action: "select",
  157420. qs: {
  157421. "select-type": a.SelectType
  157422. },
  157423. VersionId: a.VersionId,
  157424. body: s,
  157425. DataType: "arraybuffer",
  157426. rawBody: !0
  157427. }, function(d, _) {
  157428. if (d && d.statusCode === 204)
  157429. return e(null, {
  157430. statusCode: d.statusCode
  157431. });
  157432. if (d)
  157433. return e(d);
  157434. var b = util$2.parseSelectPayload(_.body);
  157435. e(null, {
  157436. statusCode: _.statusCode,
  157437. headers: _.headers,
  157438. Body: b.body,
  157439. Payload: b.payload
  157440. })
  157441. })
  157442. }
  157443. function multipartInit(a, e) {
  157444. var i = this
  157445. , o = a.Headers;
  157446. !o["Cache-Control"] && !o["cache-control"] && (o["Cache-Control"] = ""),
  157447. !o["Content-Type"] && !o["content-type"] && (o["Content-Type"] = a.Body && a.Body.type || ""),
  157448. util$2.getBodyMd5(a.Body && (a.UploadAddMetaMd5 || i.options.UploadAddMetaMd5), a.Body, function(s) {
  157449. s && (a.Headers["x-cos-meta-md5"] = s),
  157450. submitRequest.call(i, {
  157451. Action: "name/cos:InitiateMultipartUpload",
  157452. method: "POST",
  157453. Bucket: a.Bucket,
  157454. Region: a.Region,
  157455. Key: a.Key,
  157456. action: "uploads",
  157457. headers: a.Headers,
  157458. qs: a.Query
  157459. }, function(c, d) {
  157460. if (c)
  157461. return e(c);
  157462. if (d = util$2.clone(d || {}),
  157463. d && d.InitiateMultipartUploadResult)
  157464. return e(null, util$2.extend(d.InitiateMultipartUploadResult, {
  157465. statusCode: d.statusCode,
  157466. headers: d.headers
  157467. }));
  157468. e(null, d)
  157469. })
  157470. }, a.onHashProgress)
  157471. }
  157472. function multipartUpload(a, e) {
  157473. var i = this;
  157474. util$2.getFileSize("multipartUpload", a, function() {
  157475. util$2.getBodyMd5(i.options.UploadCheckContentMd5, a.Body, function(o) {
  157476. o && (a.Headers["Content-MD5"] = util$2.binaryBase64(o)),
  157477. submitRequest.call(i, {
  157478. Action: "name/cos:UploadPart",
  157479. TaskId: a.TaskId,
  157480. method: "PUT",
  157481. Bucket: a.Bucket,
  157482. Region: a.Region,
  157483. Key: a.Key,
  157484. qs: {
  157485. partNumber: a.PartNumber,
  157486. uploadId: a.UploadId
  157487. },
  157488. headers: a.Headers,
  157489. onProgress: a.onProgress,
  157490. body: a.Body || null
  157491. }, function(s, c) {
  157492. if (s)
  157493. return e(s);
  157494. e(null, {
  157495. ETag: util$2.attr(c.headers, "etag", ""),
  157496. statusCode: c.statusCode,
  157497. headers: c.headers
  157498. })
  157499. })
  157500. })
  157501. })
  157502. }
  157503. function multipartComplete(a, e) {
  157504. for (var i = this, o = a.UploadId, s = a.Parts, c = 0, d = s.length; c < d; c++)
  157505. s[c].ETag && s[c].ETag.indexOf('"') === 0 || (s[c].ETag = '"' + s[c].ETag + '"');
  157506. var _ = util$2.json2xml({
  157507. CompleteMultipartUpload: {
  157508. Part: s
  157509. }
  157510. });
  157511. _ = _.replace(/\n\s*/g, "");
  157512. var b = a.Headers;
  157513. b["Content-Type"] = "application/xml",
  157514. b["Content-MD5"] = util$2.binaryBase64(util$2.md5(_)),
  157515. submitRequest.call(this, {
  157516. Action: "name/cos:CompleteMultipartUpload",
  157517. method: "POST",
  157518. Bucket: a.Bucket,
  157519. Region: a.Region,
  157520. Key: a.Key,
  157521. qs: {
  157522. uploadId: o
  157523. },
  157524. body: _,
  157525. headers: b
  157526. }, function(k, j) {
  157527. if (k)
  157528. return e(k);
  157529. var $ = getUrl({
  157530. ForcePathStyle: i.options.ForcePathStyle,
  157531. protocol: i.options.Protocol,
  157532. domain: i.options.Domain,
  157533. bucket: a.Bucket,
  157534. region: a.Region,
  157535. object: a.Key,
  157536. isLocation: !0
  157537. })
  157538. , _e = j.CompleteMultipartUploadResult || {};
  157539. _e.ProcessResults && _e && _e.ProcessResults && (_e.UploadResult = {
  157540. OriginalInfo: {
  157541. Key: _e.Key,
  157542. Location: $,
  157543. ETag: _e.ETag,
  157544. ImageInfo: _e.ImageInfo
  157545. },
  157546. ProcessResults: _e.ProcessResults
  157547. },
  157548. delete _e.ImageInfo,
  157549. delete _e.ProcessResults);
  157550. var et = util$2.extend(_e, {
  157551. Location: $,
  157552. statusCode: j.statusCode,
  157553. headers: j.headers
  157554. });
  157555. e(null, et)
  157556. })
  157557. }
  157558. function multipartList(a, e) {
  157559. var i = {};
  157560. i.delimiter = a.Delimiter,
  157561. i["encoding-type"] = a.EncodingType,
  157562. i.prefix = a.Prefix || "",
  157563. i["max-uploads"] = a.MaxUploads,
  157564. i["key-marker"] = a.KeyMarker,
  157565. i["upload-id-marker"] = a.UploadIdMarker,
  157566. i = util$2.clearKey(i),
  157567. submitRequest.call(this, {
  157568. Action: "name/cos:ListMultipartUploads",
  157569. ResourceKey: i.prefix,
  157570. method: "GET",
  157571. Bucket: a.Bucket,
  157572. Region: a.Region,
  157573. headers: a.Headers,
  157574. qs: i,
  157575. action: "uploads"
  157576. }, function(o, s) {
  157577. if (o)
  157578. return e(o);
  157579. if (s && s.ListMultipartUploadsResult) {
  157580. var c = s.ListMultipartUploadsResult.Upload || [];
  157581. c = util$2.isArray(c) ? c : [c],
  157582. s.ListMultipartUploadsResult.Upload = c
  157583. }
  157584. var d = util$2.clone(s.ListMultipartUploadsResult || {});
  157585. util$2.extend(d, {
  157586. statusCode: s.statusCode,
  157587. headers: s.headers
  157588. }),
  157589. e(null, d)
  157590. })
  157591. }
  157592. function multipartListPart(a, e) {
  157593. var i = {};
  157594. i.uploadId = a.UploadId,
  157595. i["encoding-type"] = a.EncodingType,
  157596. i["max-parts"] = a.MaxParts,
  157597. i["part-number-marker"] = a.PartNumberMarker,
  157598. submitRequest.call(this, {
  157599. Action: "name/cos:ListParts",
  157600. method: "GET",
  157601. Bucket: a.Bucket,
  157602. Region: a.Region,
  157603. Key: a.Key,
  157604. headers: a.Headers,
  157605. qs: i
  157606. }, function(o, s) {
  157607. if (o)
  157608. return e(o);
  157609. var c = s.ListPartsResult || {}
  157610. , d = c.Part || [];
  157611. d = util$2.isArray(d) ? d : [d],
  157612. c.Part = d;
  157613. var _ = util$2.clone(c);
  157614. util$2.extend(_, {
  157615. statusCode: s.statusCode,
  157616. headers: s.headers
  157617. }),
  157618. e(null, _)
  157619. })
  157620. }
  157621. function multipartAbort(a, e) {
  157622. var i = {};
  157623. i.uploadId = a.UploadId,
  157624. submitRequest.call(this, {
  157625. Action: "name/cos:AbortMultipartUpload",
  157626. method: "DELETE",
  157627. Bucket: a.Bucket,
  157628. Region: a.Region,
  157629. Key: a.Key,
  157630. headers: a.Headers,
  157631. qs: i
  157632. }, function(o, s) {
  157633. if (o)
  157634. return e(o);
  157635. e(null, {
  157636. statusCode: s.statusCode,
  157637. headers: s.headers
  157638. })
  157639. })
  157640. }
  157641. function request(a, e) {
  157642. submitRequest.call(this, {
  157643. method: a.Method,
  157644. Bucket: a.Bucket,
  157645. Region: a.Region,
  157646. Key: a.Key,
  157647. action: a.Action,
  157648. headers: a.Headers,
  157649. qs: a.Query,
  157650. body: a.Body,
  157651. Url: a.Url,
  157652. rawBody: a.RawBody,
  157653. DataType: a.DataType
  157654. }, function(i, o) {
  157655. if (i)
  157656. return e(i);
  157657. o && o.body && (o.Body = o.body,
  157658. delete o.body),
  157659. e(i, o)
  157660. })
  157661. }
  157662. function appendObject(a, e) {
  157663. var i = a.Headers;
  157664. !i["Cache-Control"] && !i["cache-control"] && (i["Cache-Control"] = ""),
  157665. !i["Content-Type"] && !i["content-type"] && (i["Content-Type"] = a.Body && a.Body.type || ""),
  157666. submitRequest.call(this, {
  157667. Action: "name/cos:AppendObject",
  157668. method: "POST",
  157669. Bucket: a.Bucket,
  157670. Region: a.Region,
  157671. action: "append",
  157672. Key: a.Key,
  157673. body: a.Body,
  157674. qs: {
  157675. position: a.Position
  157676. },
  157677. headers: a.Headers
  157678. }, function(o, s) {
  157679. if (o)
  157680. return e(o);
  157681. e(null, s)
  157682. })
  157683. }
  157684. function getAuth(a) {
  157685. var e = this;
  157686. return util$2.getAuth({
  157687. SecretId: a.SecretId || this.options.SecretId || "",
  157688. SecretKey: a.SecretKey || this.options.SecretKey || "",
  157689. Bucket: a.Bucket,
  157690. Region: a.Region,
  157691. Method: a.Method,
  157692. Key: a.Key,
  157693. Query: a.Query,
  157694. Headers: a.Headers,
  157695. Expires: a.Expires,
  157696. UseRawKey: e.options.UseRawKey,
  157697. SystemClockOffset: e.options.SystemClockOffset
  157698. })
  157699. }
  157700. function getObjectUrl(a, e) {
  157701. var i = this
  157702. , o = a.UseAccelerate === void 0 ? i.options.UseAccelerate : a.UseAccelerate
  157703. , s = getUrl({
  157704. ForcePathStyle: i.options.ForcePathStyle,
  157705. protocol: a.Protocol || i.options.Protocol,
  157706. domain: a.Domain || i.options.Domain,
  157707. bucket: a.Bucket,
  157708. region: o ? "accelerate" : a.Region,
  157709. object: a.Key
  157710. })
  157711. , c = "";
  157712. a.Query && (c += util$2.obj2str(a.Query)),
  157713. a.QueryString && (c += (c ? "&" : "") + a.QueryString);
  157714. var d = s;
  157715. if (a.Sign !== void 0 && !a.Sign)
  157716. return c && (d += "?" + c),
  157717. e(null, {
  157718. Url: d
  157719. }),
  157720. d;
  157721. var _ = getSignHost.call(this, {
  157722. Bucket: a.Bucket,
  157723. Region: a.Region,
  157724. UseAccelerate: a.UseAccelerate,
  157725. Url: s
  157726. })
  157727. , b = getAuthorizationAsync.call(this, {
  157728. Action: (a.Method || "").toUpperCase() === "PUT" ? "name/cos:PutObject" : "name/cos:GetObject",
  157729. Bucket: a.Bucket || "",
  157730. Region: a.Region || "",
  157731. Method: a.Method || "get",
  157732. Key: a.Key,
  157733. Expires: a.Expires,
  157734. Headers: a.Headers,
  157735. Query: a.Query,
  157736. SignHost: _,
  157737. ForceSignHost: a.ForceSignHost === !1 ? !1 : i.options.ForceSignHost
  157738. }, function(k, j) {
  157739. if (!!e) {
  157740. if (k) {
  157741. e(k);
  157742. return
  157743. }
  157744. var $ = function(et) {
  157745. var tt = et.match(/q-url-param-list.*?(?=&)/g)[0]
  157746. , rt = "q-url-param-list=" + encodeURIComponent(tt.replace(/q-url-param-list=/, "")).toLowerCase()
  157747. , it = new RegExp(tt,"g")
  157748. , nt = et.replace(it, rt);
  157749. return nt
  157750. }
  157751. , _e = s;
  157752. _e += "?" + (j.Authorization.indexOf("q-signature") > -1 ? $(j.Authorization) : "sign=" + encodeURIComponent(j.Authorization)),
  157753. j.SecurityToken && (_e += "&x-cos-security-token=" + j.SecurityToken),
  157754. j.ClientIP && (_e += "&clientIP=" + j.ClientIP),
  157755. j.ClientUA && (_e += "&clientUA=" + j.ClientUA),
  157756. j.Token && (_e += "&token=" + j.Token),
  157757. c && (_e += "&" + c),
  157758. setTimeout(function() {
  157759. e(null, {
  157760. Url: _e
  157761. })
  157762. })
  157763. }
  157764. });
  157765. return b ? (d += "?" + b.Authorization + (b.SecurityToken ? "&x-cos-security-token=" + b.SecurityToken : ""),
  157766. c && (d += "&" + c)) : c && (d += "?" + c),
  157767. d
  157768. }
  157769. function decodeAcl(a) {
  157770. var e = {
  157771. GrantFullControl: [],
  157772. GrantWrite: [],
  157773. GrantRead: [],
  157774. GrantReadAcp: [],
  157775. GrantWriteAcp: [],
  157776. ACL: ""
  157777. }
  157778. , i = {
  157779. FULL_CONTROL: "GrantFullControl",
  157780. WRITE: "GrantWrite",
  157781. READ: "GrantRead",
  157782. READ_ACP: "GrantReadAcp",
  157783. WRITE_ACP: "GrantWriteAcp"
  157784. }
  157785. , o = a && a.AccessControlList || {}
  157786. , s = o.Grant;
  157787. s && (s = util$2.isArray(s) ? s : [s]);
  157788. var c = {
  157789. READ: 0,
  157790. WRITE: 0,
  157791. FULL_CONTROL: 0
  157792. };
  157793. return s && s.length && util$2.each(s, function(d) {
  157794. d.Grantee.ID === "qcs::cam::anyone:anyone" || d.Grantee.URI === "http://cam.qcloud.com/groups/global/AllUsers" ? c[d.Permission] = 1 : d.Grantee.ID !== a.Owner.ID && e[i[d.Permission]].push('id="' + d.Grantee.ID + '"')
  157795. }),
  157796. c.FULL_CONTROL || c.WRITE && c.READ ? e.ACL = "public-read-write" : c.READ ? e.ACL = "public-read" : e.ACL = "private",
  157797. util$2.each(i, function(d) {
  157798. e[d] = uniqGrant(e[d].join(","))
  157799. }),
  157800. e
  157801. }
  157802. function uniqGrant(a) {
  157803. var e = a.split(","), i = {}, o, s;
  157804. for (o = 0; o < e.length; )
  157805. s = e[o].trim(),
  157806. i[s] ? e.splice(o, 1) : (i[s] = !0,
  157807. e[o] = s,
  157808. o++);
  157809. return e.join(",")
  157810. }
  157811. function getUrl(a) {
  157812. var e = a.region || ""
  157813. , i = a.bucket || ""
  157814. , o = i.substr(0, i.lastIndexOf("-"))
  157815. , s = i.substr(i.lastIndexOf("-") + 1)
  157816. , c = a.domain
  157817. , d = a.object;
  157818. typeof c == "function" && (c = c({
  157819. Bucket: i,
  157820. Region: e
  157821. }));
  157822. var _ = a.protocol || (util$2.isBrowser && location.protocol === "http:" ? "http:" : "https:");
  157823. c || (["cn-south", "cn-south-2", "cn-north", "cn-east", "cn-southwest", "sg"].indexOf(e) > -1 ? c = "{Region}.myqcloud.com" : c = "cos.{Region}.myqcloud.com",
  157824. a.ForcePathStyle || (c = "{Bucket}." + c)),
  157825. c = c.replace(/\{\{AppId\}\}/ig, s).replace(/\{\{Bucket\}\}/ig, o).replace(/\{\{Region\}\}/ig, e).replace(/\{\{.*?\}\}/ig, ""),
  157826. c = c.replace(/\{AppId\}/ig, s).replace(/\{BucketName\}/ig, o).replace(/\{Bucket\}/ig, i).replace(/\{Region\}/ig, e).replace(/\{.*?\}/ig, ""),
  157827. /^[a-zA-Z]+:\/\//.test(c) || (c = _ + "//" + c),
  157828. c.slice(-1) === "/" && (c = c.slice(0, -1));
  157829. var b = c;
  157830. return a.ForcePathStyle && (b += "/" + i),
  157831. b += "/",
  157832. d && (b += util$2.camSafeUrlEncode(d).replace(/%2F/g, "/")),
  157833. a.isLocation && (b = b.replace(/^https?:\/\//, "")),
  157834. b
  157835. }
  157836. var getSignHost = function(a) {
  157837. if (!a.Bucket || !a.Region)
  157838. return "";
  157839. var e = a.UseAccelerate === void 0 ? this.options.UseAccelerate : a.UseAccelerate
  157840. , i = a.Url || getUrl({
  157841. ForcePathStyle: this.options.ForcePathStyle,
  157842. protocol: this.options.Protocol,
  157843. domain: this.options.Domain,
  157844. bucket: a.Bucket,
  157845. region: e ? "accelerate" : a.Region
  157846. })
  157847. , o = i.replace(/^https?:\/\/([^/]+)(\/.*)?$/, "$1")
  157848. , s = new RegExp("^([a-z\\d-]+-\\d+\\.)?(cos|cosv6|ci|pic)\\.([a-z\\d-]+)\\.myqcloud\\.com$");
  157849. return s.test(o) ? o : ""
  157850. };
  157851. function getAuthorizationAsync(a, e) {
  157852. var i = util$2.clone(a.Headers)
  157853. , o = "";
  157854. util$2.each(i, function(at, st) {
  157855. (at === "" || ["content-type", "cache-control", "expires"].indexOf(st.toLowerCase()) > -1) && delete i[st],
  157856. st.toLowerCase() === "host" && (o = at)
  157857. });
  157858. var s = a.ForceSignHost !== !1;
  157859. !o && a.SignHost && s && (i.Host = a.SignHost);
  157860. var c = !1
  157861. , d = function(at, st) {
  157862. c || (c = !0,
  157863. st && st.XCosSecurityToken && !st.SecurityToken && (st = util$2.clone(st),
  157864. st.SecurityToken = st.XCosSecurityToken,
  157865. delete st.XCosSecurityToken),
  157866. e && e(at, st))
  157867. }
  157868. , _ = this
  157869. , b = a.Bucket || ""
  157870. , k = a.Region || ""
  157871. , j = a.Key || "";
  157872. _.options.ForcePathStyle && b && (j = b + "/" + j);
  157873. var $ = "/" + j
  157874. , _e = {}
  157875. , et = a.Scope;
  157876. if (!et) {
  157877. var tt = a.Action || ""
  157878. , rt = a.ResourceKey || a.Key || "";
  157879. et = a.Scope || [{
  157880. action: tt,
  157881. bucket: b,
  157882. region: k,
  157883. prefix: rt
  157884. }]
  157885. }
  157886. var it = util$2.md5(JSON.stringify(et));
  157887. _._StsCache = _._StsCache || [],
  157888. function() {
  157889. var at, st;
  157890. for (at = _._StsCache.length - 1; at >= 0; at--) {
  157891. st = _._StsCache[at];
  157892. var ut = Math.round(util$2.getSkewTime(_.options.SystemClockOffset) / 1e3) + 30;
  157893. if (st.StartTime && ut < st.StartTime || ut >= st.ExpiredTime) {
  157894. _._StsCache.splice(at, 1);
  157895. continue
  157896. }
  157897. if (!st.ScopeLimit || st.ScopeLimit && st.ScopeKey === it) {
  157898. _e = st;
  157899. break
  157900. }
  157901. }
  157902. }();
  157903. var nt = function() {
  157904. var at = _e.StartTime && _e.ExpiredTime ? _e.StartTime + ";" + _e.ExpiredTime : ""
  157905. , st = util$2.getAuth({
  157906. SecretId: _e.TmpSecretId,
  157907. SecretKey: _e.TmpSecretKey,
  157908. Method: a.Method,
  157909. Pathname: $,
  157910. Query: a.Query,
  157911. Headers: i,
  157912. Expires: a.Expires,
  157913. UseRawKey: _.options.UseRawKey,
  157914. SystemClockOffset: _.options.SystemClockOffset,
  157915. KeyTime: at,
  157916. ForceSignHost: _.options.ForceSignHost
  157917. })
  157918. , ut = {
  157919. Authorization: st,
  157920. SecurityToken: _e.SecurityToken || _e.XCosSecurityToken || "",
  157921. Token: _e.Token || "",
  157922. ClientIP: _e.ClientIP || "",
  157923. ClientUA: _e.ClientUA || ""
  157924. };
  157925. d(null, ut)
  157926. }
  157927. , ot = function(at) {
  157928. if (at.Authorization) {
  157929. var st = !1
  157930. , ut = at.Authorization;
  157931. if (ut)
  157932. if (ut.indexOf(" ") > -1)
  157933. st = !1;
  157934. else if (ut.indexOf("q-sign-algorithm=") > -1 && ut.indexOf("q-ak=") > -1 && ut.indexOf("q-sign-time=") > -1 && ut.indexOf("q-key-time=") > -1 && ut.indexOf("q-url-param-list=") > -1)
  157935. st = !0;
  157936. else
  157937. try {
  157938. ut = atob(ut),
  157939. ut.indexOf("a=") > -1 && ut.indexOf("k=") > -1 && ut.indexOf("t=") > -1 && ut.indexOf("r=") > -1 && ut.indexOf("b=") > -1 && (st = !0)
  157940. } catch {}
  157941. if (!st)
  157942. return util$2.error(new Error("getAuthorization callback params format error"))
  157943. } else {
  157944. if (!at.TmpSecretId)
  157945. return util$2.error(new Error('getAuthorization callback params missing "TmpSecretId"'));
  157946. if (!at.TmpSecretKey)
  157947. return util$2.error(new Error('getAuthorization callback params missing "TmpSecretKey"'));
  157948. if (!at.SecurityToken && !at.XCosSecurityToken)
  157949. return util$2.error(new Error('getAuthorization callback params missing "SecurityToken"'));
  157950. if (!at.ExpiredTime)
  157951. return util$2.error(new Error('getAuthorization callback params missing "ExpiredTime"'));
  157952. if (at.ExpiredTime && at.ExpiredTime.toString().length !== 10)
  157953. return util$2.error(new Error('getAuthorization callback params "ExpiredTime" should be 10 digits'));
  157954. if (at.StartTime && at.StartTime.toString().length !== 10)
  157955. return util$2.error(new Error('getAuthorization callback params "StartTime" should be 10 StartTime'))
  157956. }
  157957. return !1
  157958. };
  157959. if (_e.ExpiredTime && _e.ExpiredTime - util$2.getSkewTime(_.options.SystemClockOffset) / 1e3 > 60)
  157960. nt();
  157961. else if (_.options.getAuthorization)
  157962. _.options.getAuthorization.call(_, {
  157963. Bucket: b,
  157964. Region: k,
  157965. Method: a.Method,
  157966. Key: j,
  157967. Pathname: $,
  157968. Query: a.Query,
  157969. Headers: i,
  157970. Scope: et,
  157971. SystemClockOffset: _.options.SystemClockOffset,
  157972. ForceSignHost: _.options.ForceSignHost
  157973. }, function(at) {
  157974. typeof at == "string" && (at = {
  157975. Authorization: at
  157976. });
  157977. var st = ot(at);
  157978. if (st)
  157979. return d(st);
  157980. at.Authorization ? d(null, at) : (_e = at || {},
  157981. _e.Scope = et,
  157982. _e.ScopeKey = it,
  157983. _._StsCache.push(_e),
  157984. nt())
  157985. });
  157986. else if (_.options.getSTS)
  157987. _.options.getSTS.call(_, {
  157988. Bucket: b,
  157989. Region: k
  157990. }, function(at) {
  157991. _e = at || {},
  157992. _e.Scope = et,
  157993. _e.ScopeKey = it,
  157994. _e.TmpSecretId || (_e.TmpSecretId = _e.SecretId),
  157995. _e.TmpSecretKey || (_e.TmpSecretKey = _e.SecretKey);
  157996. var st = ot(_e);
  157997. if (st)
  157998. return d(st);
  157999. _._StsCache.push(_e),
  158000. nt()
  158001. });
  158002. else
  158003. return function() {
  158004. var at = util$2.getAuth({
  158005. SecretId: a.SecretId || _.options.SecretId,
  158006. SecretKey: a.SecretKey || _.options.SecretKey,
  158007. Method: a.Method,
  158008. Pathname: $,
  158009. Query: a.Query,
  158010. Headers: i,
  158011. Expires: a.Expires,
  158012. UseRawKey: _.options.UseRawKey,
  158013. SystemClockOffset: _.options.SystemClockOffset,
  158014. ForceSignHost: _.options.ForceSignHost
  158015. })
  158016. , st = {
  158017. Authorization: at,
  158018. SecurityToken: _.options.SecurityToken || _.options.XCosSecurityToken
  158019. };
  158020. return d(null, st),
  158021. st
  158022. }();
  158023. return ""
  158024. }
  158025. function allowRetry(a) {
  158026. var e = !1
  158027. , i = !1
  158028. , o = a.headers && (a.headers.date || a.headers.Date) || a.error && a.error.ServerTime;
  158029. try {
  158030. var s = a.error.Code
  158031. , c = a.error.Message;
  158032. (s === "RequestTimeTooSkewed" || s === "AccessDenied" && c === "Request has expired") && (i = !0)
  158033. } catch {}
  158034. if (a)
  158035. if (i && o) {
  158036. var d = Date.parse(o);
  158037. this.options.CorrectClockSkew && Math.abs(util$2.getSkewTime(this.options.SystemClockOffset) - d) >= 3e4 && (console.error("error: Local time is too skewed."),
  158038. this.options.SystemClockOffset = d - Date.now(),
  158039. e = !0)
  158040. } else
  158041. Math.floor(a.statusCode / 100) === 5 && (e = !0);
  158042. return e
  158043. }
  158044. function submitRequest(a, e) {
  158045. var i = this;
  158046. !a.headers && (a.headers = {}),
  158047. !a.qs && (a.qs = {}),
  158048. a.VersionId && (a.qs.versionId = a.VersionId),
  158049. a.qs = util$2.clearKey(a.qs),
  158050. a.headers && (a.headers = util$2.clearKey(a.headers)),
  158051. a.qs && (a.qs = util$2.clearKey(a.qs));
  158052. var o = util$2.clone(a.qs);
  158053. a.action && (o[a.action] = "");
  158054. var s = a.url || a.Url
  158055. , c = a.SignHost || getSignHost.call(this, {
  158056. Bucket: a.Bucket,
  158057. Region: a.Region,
  158058. Url: s
  158059. })
  158060. , d = function(_) {
  158061. var b = i.options.SystemClockOffset;
  158062. getAuthorizationAsync.call(i, {
  158063. Bucket: a.Bucket || "",
  158064. Region: a.Region || "",
  158065. Method: a.method,
  158066. Key: a.Key,
  158067. Query: o,
  158068. Headers: a.headers,
  158069. SignHost: c,
  158070. Action: a.Action,
  158071. ResourceKey: a.ResourceKey,
  158072. Scope: a.Scope,
  158073. ForceSignHost: i.options.ForceSignHost
  158074. }, function(k, j) {
  158075. if (k) {
  158076. e(k);
  158077. return
  158078. }
  158079. a.AuthData = j,
  158080. _submitRequest.call(i, a, function($, _e) {
  158081. $ && _ < 2 && (b !== i.options.SystemClockOffset || allowRetry.call(i, $)) ? (a.headers && (delete a.headers.Authorization,
  158082. delete a.headers.token,
  158083. delete a.headers.clientIP,
  158084. delete a.headers.clientUA,
  158085. a.headers["x-cos-security-token"] && delete a.headers["x-cos-security-token"],
  158086. a.headers["x-ci-security-token"] && delete a.headers["x-ci-security-token"]),
  158087. d(_ + 1)) : e($, _e)
  158088. })
  158089. })
  158090. };
  158091. d(1)
  158092. }
  158093. function _submitRequest(a, e) {
  158094. var i = this
  158095. , o = a.TaskId;
  158096. if (!(o && !i._isRunningTask(o))) {
  158097. var s = a.Bucket
  158098. , c = a.Region
  158099. , d = a.Key
  158100. , _ = a.method || "GET"
  158101. , b = a.Url || a.url
  158102. , k = a.body
  158103. , j = a.rawBody;
  158104. i.options.UseAccelerate && (c = "accelerate"),
  158105. b = b || getUrl({
  158106. ForcePathStyle: i.options.ForcePathStyle,
  158107. protocol: i.options.Protocol,
  158108. domain: i.options.Domain,
  158109. bucket: s,
  158110. region: c,
  158111. object: d
  158112. }),
  158113. a.action && (b = b + "?" + a.action),
  158114. a.qsStr && (b.indexOf("?") > -1 ? b = b + "&" + a.qsStr : b = b + "?" + a.qsStr);
  158115. var $ = {
  158116. method: _,
  158117. url: b,
  158118. headers: a.headers,
  158119. qs: a.qs,
  158120. body: k
  158121. }
  158122. , _e = "x-cos-security-token";
  158123. if (util$2.isCIHost(b) && (_e = "x-ci-security-token"),
  158124. $.headers.Authorization = a.AuthData.Authorization,
  158125. a.AuthData.Token && ($.headers.token = a.AuthData.Token),
  158126. a.AuthData.ClientIP && ($.headers.clientIP = a.AuthData.ClientIP),
  158127. a.AuthData.ClientUA && ($.headers.clientUA = a.AuthData.ClientUA),
  158128. a.AuthData.SecurityToken && ($.headers[_e] = a.AuthData.SecurityToken),
  158129. $.headers && ($.headers = util$2.clearKey($.headers)),
  158130. $ = util$2.clearKey($),
  158131. a.onProgress && typeof a.onProgress == "function") {
  158132. var et = k && (k.size || k.length) || 0;
  158133. $.onProgress = function(it) {
  158134. if (!(o && !i._isRunningTask(o))) {
  158135. var nt = it ? it.loaded : 0;
  158136. a.onProgress({
  158137. loaded: nt,
  158138. total: et
  158139. })
  158140. }
  158141. }
  158142. }
  158143. a.onDownloadProgress && ($.onDownloadProgress = a.onDownloadProgress),
  158144. a.DataType && ($.dataType = a.DataType),
  158145. this.options.Timeout && ($.timeout = this.options.Timeout),
  158146. i.options.ForcePathStyle && ($.pathStyle = i.options.ForcePathStyle),
  158147. i.emit("before-send", $);
  158148. var tt = (i.options.Request || REQUEST)($, function(it) {
  158149. if (it.error !== "abort") {
  158150. var nt = {
  158151. options: $,
  158152. error: at,
  158153. statusCode: ot && ot.statusCode || 0,
  158154. headers: ot && ot.headers || {},
  158155. body: st
  158156. };
  158157. i.emit("after-receive", nt),
  158158. at = nt.error,
  158159. st = nt.body,
  158160. ot = {
  158161. statusCode: nt.statusCode,
  158162. headers: nt.headers
  158163. },
  158164. i.emit("after-receive", it);
  158165. var ot = {
  158166. statusCode: it.statusCode,
  158167. statusMessage: it.statusMessage,
  158168. headers: it.headers
  158169. }, at = it.error, st = it.body, ut, ct = function(dt, _t) {
  158170. if (o && i.off("inner-kill-task", rt),
  158171. !ut) {
  158172. ut = !0;
  158173. var mt = {};
  158174. ot && ot.statusCode && (mt.statusCode = ot.statusCode),
  158175. ot && ot.headers && (mt.headers = ot.headers),
  158176. dt ? (dt = util$2.extend(dt || {}, mt),
  158177. e(dt, null)) : (_t = util$2.extend(_t || {}, mt),
  158178. e(null, _t)),
  158179. tt = null
  158180. }
  158181. };
  158182. if (at)
  158183. return ct(util$2.error(at));
  158184. var lt = ot.statusCode
  158185. , ft = Math.floor(lt / 100) === 2;
  158186. if (j && ft)
  158187. return ct(null, {
  158188. body: st
  158189. });
  158190. var ht;
  158191. try {
  158192. ht = st && st.indexOf("<") > -1 && st.indexOf(">") > -1 && util$2.xml2json(st) || {}
  158193. } catch {
  158194. ht = {}
  158195. }
  158196. var pt = ht && ht.Error;
  158197. ft ? ct(null, ht) : pt ? ct(util$2.error(new Error(pt.Message), {
  158198. code: pt.Code,
  158199. error: pt
  158200. })) : lt ? ct(util$2.error(new Error(ot.statusMessage), {
  158201. code: "" + lt
  158202. })) : lt && ct(util$2.error(new Error("statusCode error")))
  158203. }
  158204. })
  158205. , rt = function(it) {
  158206. it.TaskId === o && (tt && tt.abort && tt.abort(),
  158207. i.off("inner-kill-task", rt))
  158208. };
  158209. o && i.on("inner-kill-task", rt)
  158210. }
  158211. }
  158212. var API_MAP$1 = {
  158213. getService,
  158214. putBucket,
  158215. headBucket,
  158216. getBucket,
  158217. deleteBucket,
  158218. putBucketAcl,
  158219. getBucketAcl,
  158220. putBucketCors,
  158221. getBucketCors,
  158222. deleteBucketCors,
  158223. getBucketLocation,
  158224. getBucketPolicy,
  158225. putBucketPolicy,
  158226. deleteBucketPolicy,
  158227. putBucketTagging,
  158228. getBucketTagging,
  158229. deleteBucketTagging,
  158230. putBucketLifecycle,
  158231. getBucketLifecycle,
  158232. deleteBucketLifecycle,
  158233. putBucketVersioning,
  158234. getBucketVersioning,
  158235. putBucketReplication,
  158236. getBucketReplication,
  158237. deleteBucketReplication,
  158238. putBucketWebsite,
  158239. getBucketWebsite,
  158240. deleteBucketWebsite,
  158241. putBucketReferer,
  158242. getBucketReferer,
  158243. putBucketDomain,
  158244. getBucketDomain,
  158245. deleteBucketDomain,
  158246. putBucketOrigin,
  158247. getBucketOrigin,
  158248. deleteBucketOrigin,
  158249. putBucketLogging,
  158250. getBucketLogging,
  158251. putBucketInventory,
  158252. getBucketInventory,
  158253. listBucketInventory,
  158254. deleteBucketInventory,
  158255. putBucketAccelerate,
  158256. getBucketAccelerate,
  158257. putBucketEncryption,
  158258. getBucketEncryption,
  158259. deleteBucketEncryption,
  158260. getObject,
  158261. headObject,
  158262. listObjectVersions,
  158263. putObject,
  158264. deleteObject,
  158265. getObjectAcl,
  158266. putObjectAcl,
  158267. optionsObject,
  158268. putObjectCopy,
  158269. deleteMultipleObject,
  158270. restoreObject,
  158271. putObjectTagging,
  158272. getObjectTagging,
  158273. deleteObjectTagging,
  158274. selectObjectContent,
  158275. appendObject,
  158276. uploadPartCopy,
  158277. multipartInit,
  158278. multipartUpload,
  158279. multipartComplete,
  158280. multipartList,
  158281. multipartListPart,
  158282. multipartAbort,
  158283. request,
  158284. getObjectUrl,
  158285. getAuth
  158286. };
  158287. function warnOldApi(a, e, i) {
  158288. util$2.each(["Cors", "Acl"], function(o) {
  158289. if (a.slice(-o.length) === o) {
  158290. var s = a.slice(0, -o.length) + o.toUpperCase()
  158291. , c = util$2.apiWrapper(a, e)
  158292. , d = !1;
  158293. i[s] = function() {
  158294. !d && console.warn("warning: cos." + s + " has been deprecated. Please Use cos." + a + " instead."),
  158295. d = !0,
  158296. c.apply(this, arguments)
  158297. }
  158298. }
  158299. })
  158300. }
  158301. base$1.init = function(a, e) {
  158302. e.transferToTaskMethod(API_MAP$1, "putObject"),
  158303. util$2.each(API_MAP$1, function(i, o) {
  158304. a.prototype[o] = util$2.apiWrapper(o, i),
  158305. warnOldApi(o, i, a.prototype)
  158306. })
  158307. }
  158308. ;
  158309. var advance$1 = {}
  158310. , eachLimit = function(a, e, i, o) {
  158311. if (o = o || function() {}
  158312. ,
  158313. !a.length || e <= 0)
  158314. return o();
  158315. var s = 0
  158316. , c = 0
  158317. , d = 0;
  158318. (function _() {
  158319. if (s >= a.length)
  158320. return o();
  158321. for (; d < e && c < a.length; )
  158322. c += 1,
  158323. d += 1,
  158324. i(a[c - 1], function(b) {
  158325. b ? (o(b),
  158326. o = function() {}
  158327. ) : (s += 1,
  158328. d -= 1,
  158329. s >= a.length ? o() : _())
  158330. })
  158331. }
  158332. )()
  158333. }
  158334. , retry = function(a, e, i) {
  158335. var o = function(s) {
  158336. e(function(c, d) {
  158337. c && s < a ? o(s + 1) : i(c, d)
  158338. })
  158339. };
  158340. a < 1 ? i() : o(1)
  158341. }
  158342. , async = {
  158343. eachLimit,
  158344. retry
  158345. }
  158346. , async_1 = async
  158347. , session = session$2
  158348. , Async = async_1
  158349. , EventProxy = event$1.EventProxy
  158350. , util$1 = util_1;
  158351. function sliceUploadFile(a, e) {
  158352. var i = this, o = new EventProxy, s = a.TaskId, c = a.Bucket, d = a.Region, _ = a.Key, b = a.Body, k = a.ChunkSize || a.SliceSize || i.options.ChunkSize, j = a.AsyncLimit, $ = a.StorageClass, _e = a.ServerSideEncryption, et, tt, rt = a.onHashProgress;
  158353. o.on("error", function(it) {
  158354. if (!!i._isRunningTask(s))
  158355. return it.UploadId = a.UploadData.UploadId || "",
  158356. e(it)
  158357. }),
  158358. o.on("upload_complete", function(it) {
  158359. var nt = util$1.extend({
  158360. UploadId: a.UploadData.UploadId || ""
  158361. }, it);
  158362. e(null, nt)
  158363. }),
  158364. o.on("upload_slice_complete", function(it) {
  158365. var nt = {};
  158366. util$1.each(a.Headers, function(ot, at) {
  158367. var st = at.toLowerCase();
  158368. (st.indexOf("x-cos-meta-") === 0 || st === "pic-operations") && (nt[at] = ot)
  158369. }),
  158370. uploadSliceComplete.call(i, {
  158371. Bucket: c,
  158372. Region: d,
  158373. Key: _,
  158374. UploadId: it.UploadId,
  158375. SliceList: it.SliceList,
  158376. Headers: nt
  158377. }, function(ot, at) {
  158378. if (!!i._isRunningTask(s)) {
  158379. if (session.removeUsing(it.UploadId),
  158380. ot)
  158381. return tt(null, !0),
  158382. o.emit("error", ot);
  158383. session.removeUploadId.call(i, it.UploadId),
  158384. tt({
  158385. loaded: et,
  158386. total: et
  158387. }, !0),
  158388. o.emit("upload_complete", at)
  158389. }
  158390. })
  158391. }),
  158392. o.on("get_upload_data_finish", function(it) {
  158393. var nt = session.getFileId(b, a.ChunkSize, c, _);
  158394. nt && session.saveUploadId.call(i, nt, it.UploadId, i.options.UploadIdCacheLimit),
  158395. session.setUsing(it.UploadId),
  158396. tt(null, !0),
  158397. uploadSliceList.call(i, {
  158398. TaskId: s,
  158399. Bucket: c,
  158400. Region: d,
  158401. Key: _,
  158402. Body: b,
  158403. FileSize: et,
  158404. SliceSize: k,
  158405. AsyncLimit: j,
  158406. ServerSideEncryption: _e,
  158407. UploadData: it,
  158408. Headers: a.Headers,
  158409. onProgress: tt
  158410. }, function(ot, at) {
  158411. if (!!i._isRunningTask(s)) {
  158412. if (ot)
  158413. return tt(null, !0),
  158414. o.emit("error", ot);
  158415. o.emit("upload_slice_complete", at)
  158416. }
  158417. })
  158418. }),
  158419. o.on("get_file_size_finish", function() {
  158420. if (tt = util$1.throttleOnProgress.call(i, et, a.onProgress),
  158421. a.UploadData.UploadId)
  158422. o.emit("get_upload_data_finish", a.UploadData);
  158423. else {
  158424. var it = util$1.extend({
  158425. TaskId: s,
  158426. Bucket: c,
  158427. Region: d,
  158428. Key: _,
  158429. Headers: a.Headers,
  158430. StorageClass: $,
  158431. Body: b,
  158432. FileSize: et,
  158433. SliceSize: k,
  158434. onHashProgress: rt
  158435. }, a);
  158436. getUploadIdAndPartList.call(i, it, function(nt, ot) {
  158437. if (!!i._isRunningTask(s)) {
  158438. if (nt)
  158439. return o.emit("error", nt);
  158440. a.UploadData.UploadId = ot.UploadId,
  158441. a.UploadData.PartList = ot.PartList,
  158442. o.emit("get_upload_data_finish", a.UploadData)
  158443. }
  158444. })
  158445. }
  158446. }),
  158447. et = a.ContentLength,
  158448. delete a.ContentLength,
  158449. !a.Headers && (a.Headers = {}),
  158450. util$1.each(a.Headers, function(it, nt) {
  158451. nt.toLowerCase() === "content-length" && delete a.Headers[nt]
  158452. }),
  158453. function() {
  158454. for (var it = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 5120], nt = 1024 * 1024, ot = 0; ot < it.length && (nt = it[ot] * 1024 * 1024,
  158455. !(et / nt <= i.options.MaxPartNumber)); ot++)
  158456. ;
  158457. a.ChunkSize = a.SliceSize = k = Math.max(k, nt)
  158458. }(),
  158459. et === 0 ? (a.Body = "",
  158460. a.ContentLength = 0,
  158461. a.SkipTask = !0,
  158462. i.putObject(a, e)) : o.emit("get_file_size_finish")
  158463. }
  158464. function getUploadIdAndPartList(a, e) {
  158465. var i = a.TaskId
  158466. , o = a.Bucket
  158467. , s = a.Region
  158468. , c = a.Key
  158469. , d = a.StorageClass
  158470. , _ = this
  158471. , b = {}
  158472. , k = a.FileSize
  158473. , j = a.SliceSize
  158474. , $ = Math.ceil(k / j)
  158475. , _e = 0
  158476. , et = util$1.throttleOnProgress.call(_, k, a.onHashProgress)
  158477. , tt = function(nt, ot) {
  158478. var at = j * (nt - 1)
  158479. , st = Math.min(at + j, k)
  158480. , ut = st - at;
  158481. b[nt] ? ot(null, {
  158482. PartNumber: nt,
  158483. ETag: b[nt],
  158484. Size: ut
  158485. }) : util$1.fileSlice(a.Body, at, st, !1, function(ct) {
  158486. util$1.getFileMd5(ct, function(lt, ft) {
  158487. if (lt)
  158488. return ot(util$1.error(lt));
  158489. var ht = '"' + ft + '"';
  158490. b[nt] = ht,
  158491. _e += ut,
  158492. et({
  158493. loaded: _e,
  158494. total: k
  158495. }),
  158496. ot(null, {
  158497. PartNumber: nt,
  158498. ETag: ht,
  158499. Size: ut
  158500. })
  158501. })
  158502. })
  158503. }
  158504. , rt = function(nt, ot) {
  158505. var at = nt.length;
  158506. if (at === 0)
  158507. return ot(null, !0);
  158508. if (at > $)
  158509. return ot(null, !1);
  158510. if (at > 1) {
  158511. var st = Math.max(nt[0].Size, nt[1].Size);
  158512. if (st !== j)
  158513. return ot(null, !1)
  158514. }
  158515. var ut = function(ct) {
  158516. if (ct < at) {
  158517. var lt = nt[ct];
  158518. tt(lt.PartNumber, function(ft, ht) {
  158519. ht && ht.ETag === lt.ETag && ht.Size === lt.Size ? ut(ct + 1) : ot(null, !1)
  158520. })
  158521. } else
  158522. ot(null, !0)
  158523. };
  158524. ut(0)
  158525. }
  158526. , it = new EventProxy;
  158527. it.on("error", function(nt) {
  158528. if (!!_._isRunningTask(i))
  158529. return e(nt)
  158530. }),
  158531. it.on("upload_id_available", function(nt) {
  158532. var ot = {}
  158533. , at = [];
  158534. util$1.each(nt.PartList, function(ct) {
  158535. ot[ct.PartNumber] = ct
  158536. });
  158537. for (var st = 1; st <= $; st++) {
  158538. var ut = ot[st];
  158539. ut ? (ut.PartNumber = st,
  158540. ut.Uploaded = !0) : ut = {
  158541. PartNumber: st,
  158542. ETag: null,
  158543. Uploaded: !1
  158544. },
  158545. at.push(ut)
  158546. }
  158547. nt.PartList = at,
  158548. e(null, nt)
  158549. }),
  158550. it.on("no_available_upload_id", function() {
  158551. if (!!_._isRunningTask(i)) {
  158552. var nt = util$1.extend({
  158553. Bucket: o,
  158554. Region: s,
  158555. Key: c,
  158556. Query: util$1.clone(a.Query),
  158557. StorageClass: d,
  158558. Body: a.Body
  158559. }, a)
  158560. , ot = util$1.clone(a.Headers);
  158561. delete ot["x-cos-mime-limit"],
  158562. nt.Headers = ot,
  158563. _.multipartInit(nt, function(at, st) {
  158564. if (!!_._isRunningTask(i)) {
  158565. if (at)
  158566. return it.emit("error", at);
  158567. var ut = st.UploadId;
  158568. if (!ut)
  158569. return e(util$1.error(new Error("no such upload id")));
  158570. it.emit("upload_id_available", {
  158571. UploadId: ut,
  158572. PartList: []
  158573. })
  158574. }
  158575. })
  158576. }
  158577. }),
  158578. it.on("has_and_check_upload_id", function(nt) {
  158579. nt = nt.reverse(),
  158580. Async.eachLimit(nt, 1, function(ot, at) {
  158581. if (!!_._isRunningTask(i)) {
  158582. if (session.using[ot]) {
  158583. at();
  158584. return
  158585. }
  158586. wholeMultipartListPart.call(_, {
  158587. Bucket: o,
  158588. Region: s,
  158589. Key: c,
  158590. UploadId: ot
  158591. }, function(st, ut) {
  158592. if (!!_._isRunningTask(i)) {
  158593. if (st)
  158594. return session.removeUsing(ot),
  158595. it.emit("error", st);
  158596. var ct = ut.PartList;
  158597. ct.forEach(function(lt) {
  158598. lt.PartNumber *= 1,
  158599. lt.Size *= 1,
  158600. lt.ETag = lt.ETag || ""
  158601. }),
  158602. rt(ct, function(lt, ft) {
  158603. if (!!_._isRunningTask(i)) {
  158604. if (lt)
  158605. return it.emit("error", lt);
  158606. ft ? at({
  158607. UploadId: ot,
  158608. PartList: ct
  158609. }) : at()
  158610. }
  158611. })
  158612. }
  158613. })
  158614. }
  158615. }, function(ot) {
  158616. !_._isRunningTask(i) || (et(null, !0),
  158617. ot && ot.UploadId ? it.emit("upload_id_available", ot) : it.emit("no_available_upload_id"))
  158618. })
  158619. }),
  158620. it.on("seek_local_avail_upload_id", function(nt) {
  158621. var ot = session.getFileId(a.Body, a.ChunkSize, o, c)
  158622. , at = session.getUploadIdList.call(_, ot);
  158623. if (!ot || !at) {
  158624. it.emit("has_and_check_upload_id", nt);
  158625. return
  158626. }
  158627. var st = function(ut) {
  158628. if (ut >= at.length) {
  158629. it.emit("has_and_check_upload_id", nt);
  158630. return
  158631. }
  158632. var ct = at[ut];
  158633. if (!util$1.isInArray(nt, ct)) {
  158634. session.removeUploadId.call(_, ct),
  158635. st(ut + 1);
  158636. return
  158637. }
  158638. if (session.using[ct]) {
  158639. st(ut + 1);
  158640. return
  158641. }
  158642. wholeMultipartListPart.call(_, {
  158643. Bucket: o,
  158644. Region: s,
  158645. Key: c,
  158646. UploadId: ct
  158647. }, function(lt, ft) {
  158648. !_._isRunningTask(i) || (lt ? (session.removeUploadId.call(_, ct),
  158649. st(ut + 1)) : it.emit("upload_id_available", {
  158650. UploadId: ct,
  158651. PartList: ft.PartList
  158652. }))
  158653. })
  158654. };
  158655. st(0)
  158656. }),
  158657. it.on("get_remote_upload_id_list", function() {
  158658. wholeMultipartList.call(_, {
  158659. Bucket: o,
  158660. Region: s,
  158661. Key: c
  158662. }, function(nt, ot) {
  158663. if (!!_._isRunningTask(i)) {
  158664. if (nt)
  158665. return it.emit("error", nt);
  158666. var at = util$1.filter(ot.UploadList, function(ct) {
  158667. return ct.Key === c && (!d || ct.StorageClass.toUpperCase() === d.toUpperCase())
  158668. }).reverse().map(function(ct) {
  158669. return ct.UploadId || ct.UploadID
  158670. });
  158671. if (at.length)
  158672. it.emit("seek_local_avail_upload_id", at);
  158673. else {
  158674. var st = session.getFileId(a.Body, a.ChunkSize, o, c), ut;
  158675. st && (ut = session.getUploadIdList.call(_, st)) && util$1.each(ut, function(ct) {
  158676. session.removeUploadId.call(_, ct)
  158677. }),
  158678. it.emit("no_available_upload_id")
  158679. }
  158680. }
  158681. })
  158682. }),
  158683. it.emit("get_remote_upload_id_list")
  158684. }
  158685. function wholeMultipartList(a, e) {
  158686. var i = this
  158687. , o = []
  158688. , s = {
  158689. Bucket: a.Bucket,
  158690. Region: a.Region,
  158691. Prefix: a.Key
  158692. }
  158693. , c = function() {
  158694. i.multipartList(s, function(d, _) {
  158695. if (d)
  158696. return e(d);
  158697. o.push.apply(o, _.Upload || []),
  158698. _.IsTruncated === "true" ? (s.KeyMarker = _.NextKeyMarker,
  158699. s.UploadIdMarker = _.NextUploadIdMarker,
  158700. c()) : e(null, {
  158701. UploadList: o
  158702. })
  158703. })
  158704. };
  158705. c()
  158706. }
  158707. function wholeMultipartListPart(a, e) {
  158708. var i = this
  158709. , o = []
  158710. , s = {
  158711. Bucket: a.Bucket,
  158712. Region: a.Region,
  158713. Key: a.Key,
  158714. UploadId: a.UploadId
  158715. }
  158716. , c = function() {
  158717. i.multipartListPart(s, function(d, _) {
  158718. if (d)
  158719. return e(d);
  158720. o.push.apply(o, _.Part || []),
  158721. _.IsTruncated === "true" ? (s.PartNumberMarker = _.NextPartNumberMarker,
  158722. c()) : e(null, {
  158723. PartList: o
  158724. })
  158725. })
  158726. };
  158727. c()
  158728. }
  158729. function uploadSliceList(a, e) {
  158730. var i = this
  158731. , o = a.TaskId
  158732. , s = a.Bucket
  158733. , c = a.Region
  158734. , d = a.Key
  158735. , _ = a.UploadData
  158736. , b = a.FileSize
  158737. , k = a.SliceSize
  158738. , j = Math.min(a.AsyncLimit || i.options.ChunkParallelLimit || 1, 256)
  158739. , $ = a.Body
  158740. , _e = Math.ceil(b / k)
  158741. , et = 0
  158742. , tt = a.ServerSideEncryption
  158743. , rt = a.Headers
  158744. , it = util$1.filter(_.PartList, function(ot) {
  158745. return ot.Uploaded && (et += ot.PartNumber >= _e && b % k || k),
  158746. !ot.Uploaded
  158747. })
  158748. , nt = a.onProgress;
  158749. Async.eachLimit(it, j, function(ot, at) {
  158750. if (!!i._isRunningTask(o)) {
  158751. var st = ot.PartNumber
  158752. , ut = Math.min(b, ot.PartNumber * k) - (ot.PartNumber - 1) * k
  158753. , ct = 0;
  158754. uploadSliceItem.call(i, {
  158755. TaskId: o,
  158756. Bucket: s,
  158757. Region: c,
  158758. Key: d,
  158759. SliceSize: k,
  158760. FileSize: b,
  158761. PartNumber: st,
  158762. ServerSideEncryption: tt,
  158763. Body: $,
  158764. UploadData: _,
  158765. Headers: rt,
  158766. onProgress: function(lt) {
  158767. et += lt.loaded - ct,
  158768. ct = lt.loaded,
  158769. nt({
  158770. loaded: et,
  158771. total: b
  158772. })
  158773. }
  158774. }, function(lt, ft) {
  158775. !i._isRunningTask(o) || (!lt && !ft.ETag && (lt = 'get ETag error, please add "ETag" to CORS ExposeHeader setting.( \u83B7\u53D6ETag\u5931\u8D25\uFF0C\u8BF7\u5728CORS ExposeHeader\u8BBE\u7F6E\u4E2D\u6DFB\u52A0ETag\uFF0C\u8BF7\u53C2\u8003\u6587\u6863\uFF1Ahttps://cloud.tencent.com/document/product/436/13318 )'),
  158776. lt ? et -= ct : (et += ut - ct,
  158777. ot.ETag = ft.ETag),
  158778. nt({
  158779. loaded: et,
  158780. total: b
  158781. }),
  158782. at(lt || null, ft))
  158783. })
  158784. }
  158785. }, function(ot) {
  158786. if (!!i._isRunningTask(o)) {
  158787. if (ot)
  158788. return e(ot);
  158789. e(null, {
  158790. UploadId: _.UploadId,
  158791. SliceList: _.PartList
  158792. })
  158793. }
  158794. })
  158795. }
  158796. function uploadSliceItem(a, e) {
  158797. var i = this
  158798. , o = a.TaskId
  158799. , s = a.Bucket
  158800. , c = a.Region
  158801. , d = a.Key
  158802. , _ = a.FileSize
  158803. , b = a.Body
  158804. , k = a.PartNumber * 1
  158805. , j = a.SliceSize
  158806. , $ = a.ServerSideEncryption
  158807. , _e = a.UploadData
  158808. , et = a.Headers || {}
  158809. , tt = i.options.ChunkRetryTimes + 1
  158810. , rt = j * (k - 1)
  158811. , it = j
  158812. , nt = rt + j;
  158813. nt > _ && (nt = _,
  158814. it = nt - rt);
  158815. var ot = ["x-cos-traffic-limit", "x-cos-mime-limit"]
  158816. , at = {};
  158817. util$1.each(et, function(ut, ct) {
  158818. ot.indexOf(ct) > -1 && (at[ct] = ut)
  158819. });
  158820. var st = _e.PartList[k - 1];
  158821. Async.retry(tt, function(ut) {
  158822. !i._isRunningTask(o) || util$1.fileSlice(b, rt, nt, !0, function(ct) {
  158823. i.multipartUpload({
  158824. TaskId: o,
  158825. Bucket: s,
  158826. Region: c,
  158827. Key: d,
  158828. ContentLength: it,
  158829. PartNumber: k,
  158830. UploadId: _e.UploadId,
  158831. ServerSideEncryption: $,
  158832. Body: ct,
  158833. Headers: at,
  158834. onProgress: a.onProgress
  158835. }, function(lt, ft) {
  158836. if (!!i._isRunningTask(o))
  158837. return lt ? ut(lt) : (st.Uploaded = !0,
  158838. ut(null, ft))
  158839. })
  158840. })
  158841. }, function(ut, ct) {
  158842. if (!!i._isRunningTask(o))
  158843. return e(ut, ct)
  158844. })
  158845. }
  158846. function uploadSliceComplete(a, e) {
  158847. var i = a.Bucket
  158848. , o = a.Region
  158849. , s = a.Key
  158850. , c = a.UploadId
  158851. , d = a.SliceList
  158852. , _ = this
  158853. , b = this.options.ChunkRetryTimes + 1
  158854. , k = a.Headers
  158855. , j = d.map(function($) {
  158856. return {
  158857. PartNumber: $.PartNumber,
  158858. ETag: $.ETag
  158859. }
  158860. });
  158861. Async.retry(b, function($) {
  158862. _.multipartComplete({
  158863. Bucket: i,
  158864. Region: o,
  158865. Key: s,
  158866. UploadId: c,
  158867. Parts: j,
  158868. Headers: k
  158869. }, $)
  158870. }, function($, _e) {
  158871. e($, _e)
  158872. })
  158873. }
  158874. function abortUploadTask(a, e) {
  158875. var i = a.Bucket
  158876. , o = a.Region
  158877. , s = a.Key
  158878. , c = a.UploadId
  158879. , d = a.Level || "task"
  158880. , _ = a.AsyncLimit
  158881. , b = this
  158882. , k = new EventProxy;
  158883. if (k.on("error", function(j) {
  158884. return e(j)
  158885. }),
  158886. k.on("get_abort_array", function(j) {
  158887. abortUploadTaskArray.call(b, {
  158888. Bucket: i,
  158889. Region: o,
  158890. Key: s,
  158891. Headers: a.Headers,
  158892. AsyncLimit: _,
  158893. AbortArray: j
  158894. }, e)
  158895. }),
  158896. d === "bucket")
  158897. wholeMultipartList.call(b, {
  158898. Bucket: i,
  158899. Region: o
  158900. }, function(j, $) {
  158901. if (j)
  158902. return e(j);
  158903. k.emit("get_abort_array", $.UploadList || [])
  158904. });
  158905. else if (d === "file") {
  158906. if (!s)
  158907. return e(util$1.error(new Error("abort_upload_task_no_key")));
  158908. wholeMultipartList.call(b, {
  158909. Bucket: i,
  158910. Region: o,
  158911. Key: s
  158912. }, function(j, $) {
  158913. if (j)
  158914. return e(j);
  158915. k.emit("get_abort_array", $.UploadList || [])
  158916. })
  158917. } else if (d === "task") {
  158918. if (!c)
  158919. return e(util$1.error(new Error("abort_upload_task_no_id")));
  158920. if (!s)
  158921. return e(util$1.error(new Error("abort_upload_task_no_key")));
  158922. k.emit("get_abort_array", [{
  158923. Key: s,
  158924. UploadId: c
  158925. }])
  158926. } else
  158927. return e(util$1.error(new Error("abort_unknown_level")))
  158928. }
  158929. function abortUploadTaskArray(a, e) {
  158930. var i = a.Bucket
  158931. , o = a.Region
  158932. , s = a.Key
  158933. , c = a.AbortArray
  158934. , d = a.AsyncLimit || 1
  158935. , _ = this
  158936. , b = 0
  158937. , k = new Array(c.length);
  158938. Async.eachLimit(c, d, function(j, $) {
  158939. var _e = b;
  158940. if (s && s !== j.Key) {
  158941. k[_e] = {
  158942. error: {
  158943. KeyNotMatch: !0
  158944. }
  158945. },
  158946. $(null);
  158947. return
  158948. }
  158949. var et = j.UploadId || j.UploadID;
  158950. _.multipartAbort({
  158951. Bucket: i,
  158952. Region: o,
  158953. Key: j.Key,
  158954. Headers: a.Headers,
  158955. UploadId: et
  158956. }, function(tt) {
  158957. var rt = {
  158958. Bucket: i,
  158959. Region: o,
  158960. Key: j.Key,
  158961. UploadId: et
  158962. };
  158963. k[_e] = {
  158964. error: tt,
  158965. task: rt
  158966. },
  158967. $(null)
  158968. }),
  158969. b++
  158970. }, function(j) {
  158971. if (j)
  158972. return e(j);
  158973. for (var $ = [], _e = [], et = 0, tt = k.length; et < tt; et++) {
  158974. var rt = k[et];
  158975. rt.task && (rt.error ? _e.push(rt.task) : $.push(rt.task))
  158976. }
  158977. return e(null, {
  158978. successList: $,
  158979. errorList: _e
  158980. })
  158981. })
  158982. }
  158983. function uploadFile(a, e) {
  158984. var i = this
  158985. , o = a.SliceSize === void 0 ? i.options.SliceSize : a.SliceSize
  158986. , s = []
  158987. , c = a.Body
  158988. , d = c.size || c.length || 0
  158989. , _ = {
  158990. TaskId: ""
  158991. };
  158992. util$1.each(a, function(et, tt) {
  158993. typeof et != "object" && typeof et != "function" && (_[tt] = et)
  158994. });
  158995. var b = a.onTaskReady
  158996. , k = function(et) {
  158997. _.TaskId = et,
  158998. b && b(et)
  158999. };
  159000. a.onTaskReady = k;
  159001. var j = a.onFileFinish
  159002. , $ = function(et, tt) {
  159003. j && j(et, tt, _),
  159004. e && e(et, tt)
  159005. }
  159006. , _e = d > o ? "sliceUploadFile" : "putObject";
  159007. s.push({
  159008. api: _e,
  159009. params: a,
  159010. callback: $
  159011. }),
  159012. i._addTasks(s)
  159013. }
  159014. function uploadFiles(a, e) {
  159015. var i = this
  159016. , o = a.SliceSize === void 0 ? i.options.SliceSize : a.SliceSize
  159017. , s = 0
  159018. , c = 0
  159019. , d = util$1.throttleOnProgress.call(i, c, a.onProgress)
  159020. , _ = a.files.length
  159021. , b = a.onFileFinish
  159022. , k = Array(_)
  159023. , j = function(_e, et, tt) {
  159024. d(null, !0),
  159025. b && b(_e, et, tt),
  159026. k[tt.Index] = {
  159027. options: tt,
  159028. error: _e,
  159029. data: et
  159030. },
  159031. --_ <= 0 && e && e(null, {
  159032. files: k
  159033. })
  159034. }
  159035. , $ = [];
  159036. util$1.each(a.files, function(_e, et) {
  159037. (function() {
  159038. var tt = _e.Body
  159039. , rt = tt.size || tt.length || 0
  159040. , it = {
  159041. Index: et,
  159042. TaskId: ""
  159043. };
  159044. s += rt,
  159045. util$1.each(_e, function(ht, pt) {
  159046. typeof ht != "object" && typeof ht != "function" && (it[pt] = ht)
  159047. });
  159048. var nt = _e.onTaskReady
  159049. , ot = function(ht) {
  159050. it.TaskId = ht,
  159051. nt && nt(ht)
  159052. };
  159053. _e.onTaskReady = ot;
  159054. var at = 0
  159055. , st = _e.onProgress
  159056. , ut = function(ht) {
  159057. c = c - at + ht.loaded,
  159058. at = ht.loaded,
  159059. st && st(ht),
  159060. d({
  159061. loaded: c,
  159062. total: s
  159063. })
  159064. };
  159065. _e.onProgress = ut;
  159066. var ct = _e.onFileFinish
  159067. , lt = function(ht, pt) {
  159068. ct && ct(ht, pt),
  159069. j && j(ht, pt, it)
  159070. }
  159071. , ft = rt > o ? "sliceUploadFile" : "putObject";
  159072. $.push({
  159073. api: ft,
  159074. params: _e,
  159075. callback: lt
  159076. })
  159077. }
  159078. )()
  159079. }),
  159080. i._addTasks($)
  159081. }
  159082. function sliceCopyFile(a, e) {
  159083. var i = new EventProxy
  159084. , o = this
  159085. , s = a.Bucket
  159086. , c = a.Region
  159087. , d = a.Key
  159088. , _ = a.CopySource
  159089. , b = util$1.getSourceParams.call(this, _);
  159090. if (!b) {
  159091. e(util$1.error(new Error("CopySource format error")));
  159092. return
  159093. }
  159094. var k = b.Bucket
  159095. , j = b.Region
  159096. , $ = decodeURIComponent(b.Key)
  159097. , _e = a.CopySliceSize === void 0 ? o.options.CopySliceSize : a.CopySliceSize;
  159098. _e = Math.max(0, _e);
  159099. var et = a.CopyChunkSize || this.options.CopyChunkSize, tt = this.options.CopyChunkParallelLimit, rt = 0, it, nt;
  159100. i.on("copy_slice_complete", function(ot) {
  159101. var at = {};
  159102. util$1.each(a.Headers, function(ut, ct) {
  159103. ct.toLowerCase().indexOf("x-cos-meta-") === 0 && (at[ct] = ut)
  159104. });
  159105. var st = util$1.map(ot.PartList, function(ut) {
  159106. return {
  159107. PartNumber: ut.PartNumber,
  159108. ETag: ut.ETag
  159109. }
  159110. });
  159111. o.multipartComplete({
  159112. Bucket: s,
  159113. Region: c,
  159114. Key: d,
  159115. UploadId: ot.UploadId,
  159116. Parts: st
  159117. }, function(ut, ct) {
  159118. if (ut)
  159119. return nt(null, !0),
  159120. e(ut);
  159121. nt({
  159122. loaded: it,
  159123. total: it
  159124. }, !0),
  159125. e(null, ct)
  159126. })
  159127. }),
  159128. i.on("get_copy_data_finish", function(ot) {
  159129. Async.eachLimit(ot.PartList, tt, function(at, st) {
  159130. var ut = at.PartNumber
  159131. , ct = at.CopySourceRange
  159132. , lt = at.end - at.start;
  159133. copySliceItem.call(o, {
  159134. Bucket: s,
  159135. Region: c,
  159136. Key: d,
  159137. CopySource: _,
  159138. UploadId: ot.UploadId,
  159139. PartNumber: ut,
  159140. CopySourceRange: ct
  159141. }, function(ft, ht) {
  159142. if (ft)
  159143. return st(ft);
  159144. rt += lt,
  159145. nt({
  159146. loaded: rt,
  159147. total: it
  159148. }),
  159149. at.ETag = ht.ETag,
  159150. st(ft || null, ht)
  159151. })
  159152. }, function(at) {
  159153. if (at)
  159154. return nt(null, !0),
  159155. e(at);
  159156. i.emit("copy_slice_complete", ot)
  159157. })
  159158. }),
  159159. i.on("get_file_size_finish", function(ot) {
  159160. (function() {
  159161. for (var ut = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 5120], ct = 1024 * 1024, lt = 0; lt < ut.length && (ct = ut[lt] * 1024 * 1024,
  159162. !(it / ct <= o.options.MaxPartNumber)); lt++)
  159163. ;
  159164. a.ChunkSize = et = Math.max(et, ct);
  159165. for (var ft = Math.ceil(it / et), ht = [], pt = 1; pt <= ft; pt++) {
  159166. var dt = (pt - 1) * et
  159167. , _t = pt * et < it ? pt * et - 1 : it - 1
  159168. , mt = {
  159169. PartNumber: pt,
  159170. start: dt,
  159171. end: _t,
  159172. CopySourceRange: "bytes=" + dt + "-" + _t
  159173. };
  159174. ht.push(mt)
  159175. }
  159176. a.PartList = ht
  159177. }
  159178. )();
  159179. var at;
  159180. if (a.Headers["x-cos-metadata-directive"] === "Replaced" ? at = a.Headers : at = ot,
  159181. at["x-cos-storage-class"] = a.Headers["x-cos-storage-class"] || ot["x-cos-storage-class"],
  159182. at = util$1.clearKey(at),
  159183. ot["x-cos-storage-class"] === "ARCHIVE" || ot["x-cos-storage-class"] === "DEEP_ARCHIVE") {
  159184. var st = ot["x-cos-restore"];
  159185. if (!st || st === 'ongoing-request="true"') {
  159186. e(util$1.error(new Error("Unrestored archive object is not allowed to be copied")));
  159187. return
  159188. }
  159189. }
  159190. delete at["x-cos-copy-source"],
  159191. delete at["x-cos-metadata-directive"],
  159192. delete at["x-cos-copy-source-If-Modified-Since"],
  159193. delete at["x-cos-copy-source-If-Unmodified-Since"],
  159194. delete at["x-cos-copy-source-If-Match"],
  159195. delete at["x-cos-copy-source-If-None-Match"],
  159196. o.multipartInit({
  159197. Bucket: s,
  159198. Region: c,
  159199. Key: d,
  159200. Headers: at
  159201. }, function(ut, ct) {
  159202. if (ut)
  159203. return e(ut);
  159204. a.UploadId = ct.UploadId,
  159205. i.emit("get_copy_data_finish", a)
  159206. })
  159207. }),
  159208. o.headObject({
  159209. Bucket: k,
  159210. Region: j,
  159211. Key: $
  159212. }, function(ot, at) {
  159213. if (ot) {
  159214. ot.statusCode && ot.statusCode === 404 ? e(util$1.error(ot, {
  159215. ErrorStatus: $ + " Not Exist"
  159216. })) : e(ot);
  159217. return
  159218. }
  159219. if (it = a.FileSize = at.headers["content-length"],
  159220. it === void 0 || !it) {
  159221. e(util$1.error(new Error('get Content-Length error, please add "Content-Length" to CORS ExposeHeader setting.\uFF08 \u83B7\u53D6Content-Length\u5931\u8D25\uFF0C\u8BF7\u5728CORS ExposeHeader\u8BBE\u7F6E\u4E2D\u6DFB\u52A0Content-Length\uFF0C\u8BF7\u53C2\u8003\u6587\u6863\uFF1Ahttps://cloud.tencent.com/document/product/436/13318 \uFF09')));
  159222. return
  159223. }
  159224. if (nt = util$1.throttleOnProgress.call(o, it, a.onProgress),
  159225. it <= _e)
  159226. a.Headers["x-cos-metadata-directive"] || (a.Headers["x-cos-metadata-directive"] = "Copy"),
  159227. o.putObjectCopy(a, function(ct, lt) {
  159228. if (ct)
  159229. return nt(null, !0),
  159230. e(ct);
  159231. nt({
  159232. loaded: it,
  159233. total: it
  159234. }, !0),
  159235. e(ct, lt)
  159236. });
  159237. else {
  159238. var st = at.headers
  159239. , ut = {
  159240. "Cache-Control": st["cache-control"],
  159241. "Content-Disposition": st["content-disposition"],
  159242. "Content-Encoding": st["content-encoding"],
  159243. "Content-Type": st["content-type"],
  159244. Expires: st.expires,
  159245. "x-cos-storage-class": st["x-cos-storage-class"]
  159246. };
  159247. util$1.each(st, function(ct, lt) {
  159248. var ft = "x-cos-meta-";
  159249. lt.indexOf(ft) === 0 && lt.length > ft.length && (ut[lt] = ct)
  159250. }),
  159251. i.emit("get_file_size_finish", ut)
  159252. }
  159253. })
  159254. }
  159255. function copySliceItem(a, e) {
  159256. var i = a.TaskId
  159257. , o = a.Bucket
  159258. , s = a.Region
  159259. , c = a.Key
  159260. , d = a.CopySource
  159261. , _ = a.UploadId
  159262. , b = a.PartNumber * 1
  159263. , k = a.CopySourceRange
  159264. , j = this.options.ChunkRetryTimes + 1
  159265. , $ = this;
  159266. Async.retry(j, function(_e) {
  159267. $.uploadPartCopy({
  159268. TaskId: i,
  159269. Bucket: o,
  159270. Region: s,
  159271. Key: c,
  159272. CopySource: d,
  159273. UploadId: _,
  159274. PartNumber: b,
  159275. CopySourceRange: k
  159276. }, function(et, tt) {
  159277. _e(et || null, tt)
  159278. })
  159279. }, function(_e, et) {
  159280. return e(_e, et)
  159281. })
  159282. }
  159283. var API_MAP = {
  159284. sliceUploadFile,
  159285. abortUploadTask,
  159286. uploadFile,
  159287. uploadFiles,
  159288. sliceCopyFile
  159289. };
  159290. advance$1.init = function(a, e) {
  159291. e.transferToTaskMethod(API_MAP, "sliceUploadFile"),
  159292. util$1.each(API_MAP, function(i, o) {
  159293. a.prototype[o] = util$1.apiWrapper(o, i)
  159294. })
  159295. }
  159296. ;
  159297. var util = util_1
  159298. , event = event$1
  159299. , task = task$1
  159300. , base = base$1
  159301. , advance = advance$1
  159302. , defaultOptions = {
  159303. AppId: "",
  159304. SecretId: "",
  159305. SecretKey: "",
  159306. SecurityToken: "",
  159307. ChunkRetryTimes: 2,
  159308. FileParallelLimit: 3,
  159309. ChunkParallelLimit: 3,
  159310. ChunkSize: 1024 * 1024,
  159311. SliceSize: 1024 * 1024,
  159312. CopyChunkParallelLimit: 20,
  159313. CopyChunkSize: 1024 * 1024 * 10,
  159314. CopySliceSize: 1024 * 1024 * 10,
  159315. MaxPartNumber: 1e4,
  159316. ProgressInterval: 1e3,
  159317. Domain: "",
  159318. ServiceDomain: "",
  159319. Protocol: "",
  159320. CompatibilityMode: !1,
  159321. ForcePathStyle: !1,
  159322. UseRawKey: !1,
  159323. Timeout: 0,
  159324. CorrectClockSkew: !0,
  159325. SystemClockOffset: 0,
  159326. UploadCheckContentMd5: !1,
  159327. UploadQueueSize: 1e4,
  159328. UploadAddMetaMd5: !1,
  159329. UploadIdCacheLimit: 50,
  159330. UseAccelerate: !1,
  159331. ForceSignHost: !0
  159332. }
  159333. , COS$1 = function(a) {
  159334. this.options = util.extend(util.clone(defaultOptions), a || {}),
  159335. this.options.FileParallelLimit = Math.max(1, this.options.FileParallelLimit),
  159336. this.options.ChunkParallelLimit = Math.max(1, this.options.ChunkParallelLimit),
  159337. this.options.ChunkRetryTimes = Math.max(0, this.options.ChunkRetryTimes),
  159338. this.options.ChunkSize = Math.max(1024 * 1024, this.options.ChunkSize),
  159339. this.options.CopyChunkParallelLimit = Math.max(1, this.options.CopyChunkParallelLimit),
  159340. this.options.CopyChunkSize = Math.max(1024 * 1024, this.options.CopyChunkSize),
  159341. this.options.CopySliceSize = Math.max(0, this.options.CopySliceSize),
  159342. this.options.MaxPartNumber = Math.max(1024, Math.min(1e4, this.options.MaxPartNumber)),
  159343. this.options.Timeout = Math.max(0, this.options.Timeout),
  159344. this.options.AppId && console.warn('warning: AppId has been deprecated, Please put it at the end of parameter Bucket(E.g: "test-1250000000").'),
  159345. this.options.SecretId && this.options.SecretId.indexOf(" ") > -1 && (console.error("error: SecretId\u683C\u5F0F\u9519\u8BEF\uFF0C\u8BF7\u68C0\u67E5"),
  159346. console.error("error: SecretId format is incorrect. Please check")),
  159347. this.options.SecretKey && this.options.SecretKey.indexOf(" ") > -1 && (console.error("error: SecretKey\u683C\u5F0F\u9519\u8BEF\uFF0C\u8BF7\u68C0\u67E5"),
  159348. console.error("error: SecretKey format is incorrect. Please check")),
  159349. util.isNode() && (console.warn("warning: cos-js-sdk-v5 \u4E0D\u652F\u6301 nodejs \u73AF\u5883\u4F7F\u7528\uFF0C\u8BF7\u6539\u7528 cos-nodejs-sdk-v5\uFF0C\u53C2\u8003\u6587\u6863\uFF1A https://cloud.tencent.com/document/product/436/8629"),
  159350. console.warn("warning: cos-js-sdk-v5 does not support nodejs environment. Please use cos-nodejs-sdk-v5 instead. See: https://cloud.tencent.com/document/product/436/8629")),
  159351. event.init(this),
  159352. task.init(this)
  159353. };
  159354. base.init(COS$1, task);
  159355. advance.init(COS$1, task);
  159356. COS$1.util = {
  159357. md5: util.md5,
  159358. xml2json: util.xml2json,
  159359. json2xml: util.json2xml
  159360. };
  159361. COS$1.getAuthorization = util.getAuth;
  159362. COS$1.version = "1.3.6";
  159363. var cos = COS$1
  159364. , COS = cos
  159365. , cosJsSdkV5 = COS;
  159366. const SERVER_URL = "https://cos-auth.xversepro.com/sts"
  159367. , COS_BUCKET = "xvbs-1258211750"
  159368. , COS_REGION = "ap-guangzhou";
  159369. var myCos = new cosJsSdkV5({
  159370. getAuthorization: function(a, e) {
  159371. var i = SERVER_URL
  159372. , o = new XMLHttpRequest;
  159373. o.open("GET", i, !0),
  159374. o.onload = function(s) {
  159375. try {
  159376. var c = JSON.parse(s.target.responseText)
  159377. , d = c.credentials
  159378. } catch (_) {
  159379. console.error(_)
  159380. }
  159381. if (!c || !d)
  159382. return console.error(`credentials invalid:
  159383. ` + JSON.stringify(c, null, 2));
  159384. e({
  159385. TmpSecretId: d.tmpSecretId,
  159386. TmpSecretKey: d.tmpSecretKey,
  159387. SecurityToken: d.sessionToken,
  159388. StartTime: c.startTime,
  159389. ExpiredTime: c.expiredTime
  159390. })
  159391. }
  159392. ,
  159393. o.send()
  159394. }
  159395. });
  159396. function uploadStream(a, e) {
  159397. myCos.putObject({
  159398. Bucket: COS_BUCKET,
  159399. Region: COS_REGION,
  159400. Key: a,
  159401. StorageClass: "STANDARD",
  159402. Body: e,
  159403. onProgress: function(i) {
  159404. console.log(JSON.stringify(i))
  159405. }
  159406. }, function(i, o) {
  159407. console.log(i || o)
  159408. })
  159409. }
  159410. const defaultLogger = {
  159411. info: console.log,
  159412. debug: console.log,
  159413. error: console.error,
  159414. infoAndReportMeasurement: (...a)=>{}
  159415. };
  159416. let log$l = defaultLogger
  159417. , USER_ID = "987412365"
  159418. , PAGE_SESSION = "aaabbbccc"
  159419. , SERVER_SESSION = "cccbbbaaa";
  159420. const COS_PREFIX = "error-bitstreams-auto-uploaded-from-application/"
  159421. , FRAME_COMPOSE_LENGTH = 5;
  159422. class Workers {
  159423. constructor(e, i) {
  159424. this.rtcp = e,
  159425. this.cacheSize = 0,
  159426. this.cacheBuffer = new Uint8Array(262144),
  159427. this.cacheFrameCnt = 0,
  159428. this.startReceiveTime = 0,
  159429. this.cacheFrameComposes = new Array(0),
  159430. this.cacheSizes = new Array(5).fill(0),
  159431. this.cacheFrameCnts = new Array(5).fill(-1),
  159432. this.cacheStartReceiveTimes = new Array(5).fill(0),
  159433. this.cacheBuffers = [new Uint8Array(262144), new Uint8Array(262144), new Uint8Array(262144), new Uint8Array(262144), new Uint8Array(262144)],
  159434. this.panoCacheSize = 0,
  159435. this.panoCacheBuffer = new Uint8Array(2097152),
  159436. this.cachePanoTileID = 0,
  159437. this.receivedMedia = 0,
  159438. this.receivedMedia_worker = 0,
  159439. this.receivedYUV = 0,
  159440. this.receivedEmit = 0,
  159441. this.returnFrames = 0,
  159442. this.lastReturnFrames = 0,
  159443. this.lastReceivedEmit = 0,
  159444. this.mediaBytesReceived = 0,
  159445. this.metaBytesReceived = 0,
  159446. this.noWasmBytesReceived = 0,
  159447. this.rtcBytesReceived = 0,
  159448. this.rtcMessageReceived = 0,
  159449. this.packetsDrop = 0,
  159450. this.framesAwait = 0,
  159451. this.sendOutBuffer = 0,
  159452. this.decodeTimePerFrame = 0,
  159453. this.decodeTimeMaxFrame = 0,
  159454. this.lastRenderTs = 0,
  159455. this.JankTimes = 0,
  159456. this.bigJankTimes = 0,
  159457. this.DecodeJankTimes = 0,
  159458. this.bigDecodeJankTimes = 0,
  159459. this.saveframe = !1,
  159460. this.SaveMediaStream = !1,
  159461. this.packetsLost = 0,
  159462. this.showAllReceivedMetadata = !1,
  159463. this.firstMediaArraval = 0,
  159464. this.firstMediaReceived = !1,
  159465. this.firstYUVDecoded = 0,
  159466. this.firstRender = 0,
  159467. this.firstYUVReceived = !1,
  159468. this.reconnectSignal = !1,
  159469. this.serverFrameSlow = 0,
  159470. this.serverFrameFast = 0,
  159471. this.clientFrameSlow = 0,
  159472. this.clientFrameFast = 0,
  159473. this.lastServerTS = 0,
  159474. this.lastClientTS = 0,
  159475. this.lastSeq = 0,
  159476. this.lastIsPureMeta = !1,
  159477. this.lastHBPacketTs = 0,
  159478. this.HBPacketInterval = 0,
  159479. this.lastHBPacketSrvSentTs = 0,
  159480. this.HBPacketIntervalSrvSent = 0,
  159481. this.cachedLength = 2,
  159482. this.cachedStreams = new Array(this.cachedLength),
  159483. this.cachedMetas = new Array(this.cachedLength),
  159484. this.cachedPtss = new Array(this.cachedLength),
  159485. this.cachedRender = Array(this.cachedLength).fill(!1),
  159486. this.cachedResolution = new Array(this.cachedLength),
  159487. this.getPtr = 0,
  159488. this.setPtr = 0,
  159489. this.receiveIframes = 0,
  159490. this.decodeIframes = 0,
  159491. this.prevSenderTs = -1,
  159492. this.serverSendTimeArray = new CircularArray(120,!1,[]),
  159493. this.inPanoMode = !1,
  159494. this.PanoStatus = {
  159495. x: 0,
  159496. y: 0,
  159497. z: 0,
  159498. tiles: []
  159499. },
  159500. this.DynamicPanoTest = !1,
  159501. this.PanoMask = new ArrayBuffer(8),
  159502. this.PanoView = new DataView(this.PanoMask),
  159503. this.userId_test = "",
  159504. this.PendingMasks = [],
  159505. this.traceIdMap = new Map,
  159506. this.responseTimeArray = [],
  159507. this.processTimeArray = [],
  159508. this.displayTimeArray = [],
  159509. this.overallTimeArray = [],
  159510. this.responseMiss = 0,
  159511. this.processMiss = 0,
  159512. this.displayMiss = 0,
  159513. this.joyStickTraceIdMap = new Map,
  159514. this.joyStickResponseTimeArray = [],
  159515. this.joyStickProcessTimeArray = [],
  159516. this.joyStickDisplayTimeArray = [],
  159517. this.joyStickOverallTimeArray = [],
  159518. this.joyStickResponseMiss = 0,
  159519. this.joyStickProcessMiss = 0,
  159520. this.joyStickDisplayMiss = 0,
  159521. this.updateYUVCircular = new CircularArray(120,!1,[]),
  159522. this.updateDropFrame = 0,
  159523. this.metaParseAraay = [],
  159524. this.responseMoveMiss = 0,
  159525. this.processMoveMiss = 0,
  159526. this.displayMoveMiss = 0,
  159527. this.MovingTraceId = "",
  159528. this.PendingMovingTraceId = "",
  159529. this.inMovingMode = !1,
  159530. this.StartMovingTs = 0,
  159531. this.PendingStartMovingTs = 0,
  159532. this.moveEvent = "",
  159533. this.MoveToFrameCnt = 0,
  159534. this.lastIsMoving = 0,
  159535. this.MoveResponseDelay = 0,
  159536. this.MoveProcessDelay = 0,
  159537. this.MoveDisplayDelay = 0,
  159538. this.lastMoveResponseTime = 0,
  159539. this.lastMoveProcessTime = 0,
  159540. this.lastMoveDisplayTime = 0,
  159541. this.moveResponseCircular = new CircularArray(120,!0,[STUCK_STAGE_GOOD, STUCK_STAGE_WELL, STUCK_STAGE_FAIR, STUCK_STAGE_BAD]),
  159542. this.moveProcessCircular = new CircularArray(120,!0,[STUCK_STAGE_GOOD, STUCK_STAGE_WELL, STUCK_STAGE_FAIR, STUCK_STAGE_BAD]),
  159543. this.moveDisplayCircular = new CircularArray(120,!0,[STUCK_STAGE_GOOD, STUCK_STAGE_WELL, STUCK_STAGE_FAIR, STUCK_STAGE_BAD]),
  159544. this.moveStartPts = -1,
  159545. this.frameServerCircular = new CircularArray(120,!1,[]),
  159546. this.srvMetaIntervalCircular = new CircularArray(120,!1,[]),
  159547. this.srvMediaIntervalCircular = new CircularArray(120,!1,[]),
  159548. this.srvHBMetaIntervalCircular = new CircularArray(120,!1,[]),
  159549. this.srvHBMetaIntervalSrvSentCircular = new CircularArray(120,!1,[]),
  159550. this.frameClientCircular = new CircularArray(120,!1,[]),
  159551. this.unmarshalStreamExecutionArray = new SecondArray,
  159552. this.receiveYUVExecutionArray = new SecondArray,
  159553. this.postMessageWaitArray = new SecondArray,
  159554. this.firstUpdateYUV = !0,
  159555. this.functionMap = new Map,
  159556. this.WASM_VERSION = "WASM-1.1",
  159557. this.frameHistory = [],
  159558. this.getVersion = function() {
  159559. return DECODER_VERSION
  159560. }
  159561. ,
  159562. this.downloadBlob = (o,s,c)=>{
  159563. const d = new Blob([o],{
  159564. type: c
  159565. })
  159566. , _ = window.URL.createObjectURL(d);
  159567. this.downloadURL(_, s),
  159568. setTimeout(function() {
  159569. return window.URL.revokeObjectURL(_)
  159570. }, 1e3)
  159571. }
  159572. ,
  159573. this.downloadURL = function(o, s) {
  159574. const c = document.createElement("a");
  159575. c.href = o,
  159576. c.download = s,
  159577. document.body.appendChild(c),
  159578. c.style.display = "none",
  159579. c.click(),
  159580. c.remove()
  159581. }
  159582. ,
  159583. this.Stringify = function(o) {
  159584. let s = "";
  159585. for (let d = 0; d < o.length / 8192; d++)
  159586. s += String.fromCharCode.apply(null, o.slice(d * 8192, (d + 1) * 8192));
  159587. return s
  159588. }
  159589. ,
  159590. this._rtcp = e
  159591. }
  159592. registerLogger(e) {
  159593. log$l = e
  159594. }
  159595. registerFunction(e, i) {
  159596. this.functionMap.set(e, i)
  159597. }
  159598. hasFrmCntInCache(e) {
  159599. let i = -1;
  159600. for (let o = 0; o < this.cacheFrameComposes.length; o++)
  159601. this.cacheFrameComposes[o].frameCnt == e && (i = o);
  159602. return i
  159603. }
  159604. requestPanoramaTest(e, i, o, s, c) {
  159605. const d = c
  159606. , _ = {
  159607. action_type: 16,
  159608. change_rotation_render_type_action: {
  159609. render_type: 5,
  159610. player: {
  159611. position: {
  159612. x: 0,
  159613. y: 0,
  159614. z: 0
  159615. },
  159616. angle: {
  159617. yaw: 0,
  159618. pitch: 0,
  159619. roll: 0
  159620. }
  159621. },
  159622. camera: {
  159623. position: {
  159624. x: e,
  159625. y: i,
  159626. z: o
  159627. },
  159628. angle: {
  159629. yaw: 0,
  159630. pitch: 0,
  159631. roll: 0
  159632. }
  159633. },
  159634. client_pano_titles_bitmap: s
  159635. },
  159636. trace_id: d,
  159637. user_id: this.userId_test,
  159638. packet_id: d
  159639. };
  159640. log$l.debug("send data: ", _),
  159641. this._rtcp.sendData(_)
  159642. }
  159643. onRotateInPanoMode(e) {
  159644. const i = e.traceId
  159645. , o = {};
  159646. o.width = 1280,
  159647. o.height = 720,
  159648. o.horz_fov = 92,
  159649. o.angle = {
  159650. yaw: 100,
  159651. pitch: 30
  159652. };
  159653. const s = new ArrayBuffer(8)
  159654. , c = new DataView(s);
  159655. getTilesInView(o, s);
  159656. const d = s.slice(0);
  159657. this.PendingMasks.unshift({
  159658. buffer: d,
  159659. angle: o.angle
  159660. }),
  159661. MaskSetToOne(18, this.PanoView),
  159662. operateForDataView(c, this.PanoView, c, (_,b)=>_ ^ _ & b),
  159663. this.requestPanoramaTest(0, 0, 0, [c.getUint8(0), c.getUint8(1), c.getUint8(2), c.getUint8(3), c.getUint8(4), c.getUint8(5), c.getUint8(6), c.getUint8(7)], i)
  159664. }
  159665. processMetaWithTraceId(e) {
  159666. for (const i of e.traceIds) {
  159667. if (this.traceIdMap.has(i)) {
  159668. const o = this.traceIdMap.get(i);
  159669. o != null && (o.receiveTime = Date.now(),
  159670. o.status = 1)
  159671. }
  159672. if (this.joyStickTraceIdMap.has(i)) {
  159673. const o = this.joyStickTraceIdMap.get(i);
  159674. o != null && (o.receiveTime = Date.now(),
  159675. o.status = 1)
  159676. }
  159677. if (i == this.PendingMovingTraceId) {
  159678. this.inMovingMode = !0,
  159679. this.MovingTraceId = this.PendingMovingTraceId,
  159680. this.StartMovingTs = this.PendingStartMovingTs,
  159681. this.PendingMovingTraceId = "",
  159682. this.PendingStartMovingTs = 0,
  159683. log$l.info("MoveTo TraceId match", this.StartMovingTs, Date.now());
  159684. const o = Date.now();
  159685. this.lastMoveResponseTime = o,
  159686. this.lastMoveProcessTime = o,
  159687. this.lastMoveDisplayTime = o,
  159688. this.frameServerCircular.clear(),
  159689. this.frameClientCircular.clear()
  159690. }
  159691. }
  159692. }
  159693. onTraceId(e, i=this) {
  159694. const o = e.traceId
  159695. , s = e.timestamp
  159696. , c = e.event;
  159697. if (c === "Rotation") {
  159698. const d = {
  159699. traceId: o,
  159700. pts: 0,
  159701. startTime: s,
  159702. receiveTime: 0,
  159703. readyTime: 0,
  159704. displayTime: 0,
  159705. status: 0
  159706. };
  159707. this.traceIdMap.set(o, d);
  159708. const _ = setTimeout(()=>{
  159709. if (_ && clearTimeout(_),
  159710. this.traceIdMap.has(o)) {
  159711. const b = this.traceIdMap.get(o);
  159712. switch (b == null ? void 0 : b.status) {
  159713. case 0:
  159714. {
  159715. this.responseMiss += 1;
  159716. break
  159717. }
  159718. case 1:
  159719. {
  159720. this.processMiss += 1;
  159721. const k = b.receiveTime - b.startTime;
  159722. this.responseTimeArray.push(k);
  159723. break
  159724. }
  159725. case 2:
  159726. {
  159727. this.displayMiss += 1;
  159728. const k = b.receiveTime - b.startTime
  159729. , j = b.readyTime - b.receiveTime;
  159730. this.responseTimeArray.push(k),
  159731. this.processTimeArray.push(j);
  159732. break
  159733. }
  159734. case 3:
  159735. log$l.debug("status is 3")
  159736. }
  159737. }
  159738. }
  159739. , 1e3)
  159740. } else if (c === "Joystick") {
  159741. const d = {
  159742. traceId: o,
  159743. pts: 0,
  159744. startTime: s,
  159745. receiveTime: 0,
  159746. readyTime: 0,
  159747. displayTime: 0,
  159748. status: 0
  159749. };
  159750. this.joyStickTraceIdMap.set(o, d);
  159751. const _ = setTimeout(()=>{
  159752. if (_ && clearTimeout(_),
  159753. this.joyStickTraceIdMap.has(o)) {
  159754. const b = this.joyStickTraceIdMap.get(o);
  159755. switch (b == null ? void 0 : b.status) {
  159756. case 0:
  159757. {
  159758. this.joyStickResponseMiss += 1;
  159759. break
  159760. }
  159761. case 1:
  159762. {
  159763. this.joyStickProcessMiss += 1;
  159764. const k = b.receiveTime - b.startTime;
  159765. this.joyStickResponseTimeArray.push(k);
  159766. break
  159767. }
  159768. case 2:
  159769. {
  159770. this.joyStickDisplayMiss += 1;
  159771. const k = b.receiveTime - b.startTime
  159772. , j = b.readyTime - b.receiveTime;
  159773. this.joyStickResponseTimeArray.push(k),
  159774. this.joyStickProcessTimeArray.push(j);
  159775. break
  159776. }
  159777. case 3:
  159778. log$l.debug("status is 3")
  159779. }
  159780. }
  159781. }
  159782. , 1e3)
  159783. } else
  159784. c === "MoveTo" ? (log$l.info("receive moveto traceId ", o, " at timestamp", s),
  159785. this.PendingMovingTraceId = o,
  159786. this.PendingStartMovingTs = s,
  159787. this.moveEvent = c,
  159788. this.frameServerCircular.clear()) : c === "GetOnAirship" || c === "GetOnVehicle" ? (log$l.info("receive airship traceId ", o, " at timestamp ", s),
  159789. this.PendingMovingTraceId = o,
  159790. this.PendingStartMovingTs = s,
  159791. this.moveEvent = c,
  159792. this.frameServerCircular.clear()) : (c === "GetOffAirship" || c === "GetOffVehicle") && this.clearMoveArray()
  159793. }
  159794. executeFunction(e, i) {
  159795. if (this.functionMap.has(e)) {
  159796. const o = this.functionMap.get(e);
  159797. o != null && o(i)
  159798. }
  159799. }
  159800. UpdateStats(e) {
  159801. var i;
  159802. (i = this._rtcp.connection) == null || i.getStats(null).then(o=>{
  159803. o.forEach(s=>{
  159804. s.type == "data-channel" && (this.rtcMessageReceived = s.messagesReceived - s.messagesSent,
  159805. this.rtcBytesReceived = s.bytesReceived)
  159806. }
  159807. )
  159808. }
  159809. ),
  159810. this.receivedMedia_worker = e.data.framesReceived,
  159811. this.receivedYUV = e.data.framesDecoded,
  159812. this.receivedEmit = e.data.framesRendered,
  159813. this.mediaBytesReceived = e.data.mediaBytesReceived,
  159814. this.metaBytesReceived = e.data.metaBytesReceived,
  159815. this.packetsLost = e.data.packetsLost,
  159816. this.packetsDrop = e.data.packetsDrop,
  159817. this.framesAwait = e.data.framesAwait,
  159818. this.decodeTimePerFrame = e.data.decodeTimePerFrame,
  159819. this.decodeTimeMaxFrame = e.data.decodeTimeMaxFrame,
  159820. this.returnFrames = e.data.framesReturned,
  159821. this.sendOutBuffer = e.data.sendOutBuffer,
  159822. this.DecodeJankTimes = e.data.JankTimes,
  159823. this.bigDecodeJankTimes = e.data.bigJankTimes,
  159824. this.receiveIframes = e.data.receivedIframe,
  159825. this.decodeIframes = e.data.decodedIframe
  159826. }
  159827. ReceiveDecodeMessage(e) {
  159828. var b;
  159829. const i = Date.now()
  159830. , o = i - e.data.postTs;
  159831. if (this.postMessageWaitArray.add(o),
  159832. !this.firstYUVReceived) {
  159833. this.firstYUVDecoded = e.data.yuv_ts;
  159834. const k = this.firstYUVDecoded - this.rtcp.network.room._startTime;
  159835. log$l.infoAndReportMeasurement({
  159836. metric: "firstYUVDecodedAt",
  159837. value: k,
  159838. group: "joinRoom"
  159839. }),
  159840. this.firstRender = Date.now();
  159841. const j = this.firstYUVDecoded - this.rtcp.network.room._startTime;
  159842. log$l.infoAndReportMeasurement({
  159843. metric: "firstRenderAt",
  159844. value: j,
  159845. group: "joinRoom"
  159846. }),
  159847. this.firstYUVReceived = !0,
  159848. this.lastRenderTs = Date.now()
  159849. }
  159850. !this.cachedRender[this.setPtr] && this.cachedMetas[this.setPtr] != null && (this.cachedStreams[this.setPtr] != null && this.cachedStreams[this.setPtr].byteLength != 0 && (e.data.data == null ? (this.executeFunction("stream", {
  159851. stream: this.cachedStreams[this.setPtr],
  159852. width: this.cachedResolution[this.setPtr].width,
  159853. height: this.cachedResolution[this.setPtr].height,
  159854. pts: this.cachedPtss[this.setPtr]
  159855. }),
  159856. this.executeFunction("signal", {
  159857. signal: this.cachedMetas[this.setPtr],
  159858. pts: this.cachedPtss[this.setPtr],
  159859. alreadyUpdateYUV: !0
  159860. })) : this.updateDropFrame += 1,
  159861. this.decoderWorker.postMessage({
  159862. t: 2,
  159863. frameCnt: this.cachedPtss[this.setPtr],
  159864. buffer: this.cachedStreams[this.setPtr]
  159865. }, [this.cachedStreams[this.setPtr].buffer])),
  159866. this.getPtr = (this.getPtr + 1) % this.cachedLength);
  159867. const s = e.data.metadata;
  159868. if ((b = s == null ? void 0 : s.traceIds) != null && b.length)
  159869. for (const k of s.traceIds) {
  159870. if (this.traceIdMap.has(k)) {
  159871. const j = this.traceIdMap.get(k);
  159872. j != null && (j.readyTime = Date.now(),
  159873. j.status = 2)
  159874. }
  159875. if (this.joyStickTraceIdMap.has(k)) {
  159876. const j = this.joyStickTraceIdMap.get(k);
  159877. j != null && (j.readyTime = Date.now(),
  159878. j.status = 2)
  159879. }
  159880. }
  159881. if (e.data.pts == this.moveStartPts && (this.MoveProcessDelay = Date.now() - this.StartMovingTs),
  159882. this.userId_test = this.rtcp.network.room.userId,
  159883. this.inMovingMode) {
  159884. const k = Date.now()
  159885. , j = k - this.lastMoveProcessTime;
  159886. this.moveProcessCircular.add(j),
  159887. this.lastMoveProcessTime = k
  159888. }
  159889. const c = this.setPtr;
  159890. this.cachedStreams[c] = e.data.data,
  159891. this.cachedMetas[c] = e.data.metadata,
  159892. this.cachedPtss[c] = e.data.pts,
  159893. this.cachedRender[c] = !1,
  159894. this.cachedResolution[c] = {
  159895. width: e.data.width,
  159896. height: e.data.height
  159897. },
  159898. this.setPtr = (this.setPtr + 1) % this.cachedLength;
  159899. const _ = Date.now() - i;
  159900. this.receiveYUVExecutionArray.add(_)
  159901. }
  159902. SendCacheFrameInfo(e) {
  159903. var $, _e, et, tt, rt, it, nt;
  159904. const i = e.data.cachedKey
  159905. , o = e.data.metadata
  159906. , s = i
  159907. , c = o
  159908. , d = (et = (_e = ($ = c.newUserStates) == null ? void 0 : $.find(ot=>ot.userId === this.rtcp.network.room.userId)) == null ? void 0 : _e.playerState) == null ? void 0 : et.roomTypeId
  159909. , _ = this.rtcp.network.room.skinId
  159910. , b = (nt = (it = (rt = (tt = c.newUserStates) == null ? void 0 : tt.find(ot=>ot.userId === this._rtcp.network.room.userId)) == null ? void 0 : rt.playerState) == null ? void 0 : it.player) == null ? void 0 : nt.position
  159911. , k = {
  159912. MsgType: 1,
  159913. FrameCacheMsg: {
  159914. FrameIndex: s,
  159915. RoomTypeId: d,
  159916. SkinID: _,
  159917. Position: b
  159918. }
  159919. };
  159920. let j = "";
  159921. try {
  159922. j = JSON.stringify(k)
  159923. } catch (ot) {
  159924. log$l.error(ot);
  159925. return
  159926. }
  159927. }
  159928. ReceivePanoramaDecodeMessage(e) {
  159929. log$l.info("Receive Panorama Image in Workers.ts"),
  159930. MaskSetToOne(e.data.tileId, this.PanoView);
  159931. let i = 0, o;
  159932. const s = this.PendingMasks.length;
  159933. for (i = 0; i < s; i++) {
  159934. const c = this.PendingMasks[i].buffer
  159935. , d = new DataView(c)
  159936. , _ = new ArrayBuffer(8)
  159937. , b = new DataView(_);
  159938. if (operateForDataView(this.PanoView, d, b, (k,j)=>j ^ k & j),
  159939. IsAll0(b)) {
  159940. o = this.PendingMasks[i].angle;
  159941. break
  159942. }
  159943. }
  159944. for (let c = i; c < s; c++)
  159945. this.PendingMasks.pop();
  159946. this.executeFunction("panorama", {
  159947. data: e.data.data,
  159948. metadata: e.data.metadata,
  159949. tileId: e.data.tileId,
  159950. finished: !0,
  159951. matchAngle: o
  159952. })
  159953. }
  159954. enable_decoder_queue_logging() {
  159955. this.decoderWorker.postMessage({
  159956. t: 100,
  159957. status: !0
  159958. })
  159959. }
  159960. disable_decoder_queue_logging() {
  159961. this.decoderWorker.postMessage({
  159962. t: 100,
  159963. status: !1
  159964. })
  159965. }
  159966. async init(e={
  159967. width: 1280,
  159968. height: 720,
  159969. userID: "testUserId",
  159970. pageSession: "pagesession1",
  159971. serverSession: "serversession1"
  159972. }) {
  159973. for (let o = 0; o < FRAME_COMPOSE_LENGTH; o++) {
  159974. const s = {
  159975. buffer: new Uint8Array(262144),
  159976. size: 0,
  159977. startReceiveTime: 0,
  159978. serverTime: 0,
  159979. frameCnt: -1
  159980. };
  159981. this.cacheFrameComposes.push(s)
  159982. }
  159983. USER_ID = e.userID,
  159984. PAGE_SESSION = e.pageSession,
  159985. SERVER_SESSION = e.serverSession;
  159986. const i = new Blob([decoder],{
  159987. type: "application/javascript"
  159988. });
  159989. return this.decoderWorker = new Worker(URL.createObjectURL(i)),
  159990. this.decoderWorker.postMessage({
  159991. t: 9,
  159992. url: WASM_URLS[WASM_Version],
  159993. jitterLength: DECODER_PASSIVE_JITTER
  159994. }),
  159995. this.decoderWorker.postMessage({
  159996. t: 1,
  159997. config: e
  159998. }),
  159999. new Promise(o=>{
  160000. this.decoderWorker.onmessage = s=>{
  160001. switch (s.data.t) {
  160002. case 0:
  160003. this.ReceiveDecodeMessage(s);
  160004. break;
  160005. case 1:
  160006. this.UpdateStats(s);
  160007. break;
  160008. case 2:
  160009. o();
  160010. break;
  160011. case 3:
  160012. this.SendCacheFrameInfo(s);
  160013. break;
  160014. case 4:
  160015. {
  160016. const c = new Date().toISOString()
  160017. , d = USER_ID + "-" + PAGE_SESSION + "-" + SERVER_SESSION + "-" + c + ".264";
  160018. uploadStream(COS_PREFIX + d, s.data.fileObj);
  160019. break
  160020. }
  160021. case 5:
  160022. this.executeFunction("signal", {
  160023. signal: s.data.metadata,
  160024. pts: -1,
  160025. alreadyUpdateYUV: !1
  160026. });
  160027. break;
  160028. case 6:
  160029. log$l.infoAndReportMeasurement(s.data.data),
  160030. log$l.debug("WASM Ready Cost");
  160031. break;
  160032. case 7:
  160033. this.ReceivePanoramaDecodeMessage(s);
  160034. break;
  160035. case 8:
  160036. {
  160037. const c = {
  160038. MstType: 0
  160039. };
  160040. let d = "";
  160041. try {
  160042. d = JSON.stringify(c)
  160043. } catch (b) {
  160044. log$l.error(b);
  160045. return
  160046. }
  160047. const _ = "wasm:" + d;
  160048. this._rtcp.sendStringData(_);
  160049. break
  160050. }
  160051. case 9:
  160052. {
  160053. log$l.info(s.data.printMsg);
  160054. break
  160055. }
  160056. case 10:
  160057. {
  160058. log$l.error(s.data.printMsg),
  160059. this.executeFunction("error", {
  160060. code: s.data.code,
  160061. message: s.data.printMsg
  160062. });
  160063. break
  160064. }
  160065. default:
  160066. log$l.error("Receive unknown message event from decoder"),
  160067. log$l.debug(s.data);
  160068. break
  160069. }
  160070. }
  160071. }
  160072. )
  160073. }
  160074. setPageSession(e) {
  160075. PAGE_SESSION = e
  160076. }
  160077. UpdateYUV() {
  160078. var i, o;
  160079. const e = this.getPtr;
  160080. if (this.cachedMetas[e] != null && !this.cachedRender[e]) {
  160081. const s = Date.now();
  160082. if (this.firstUpdateYUV) {
  160083. const $ = ((i = this.cachedStreams[e]) == null ? void 0 : i.byteLength) || 0;
  160084. log$l.infoAndReportMeasurement({
  160085. metric: "firstUpdateStreamLength",
  160086. value: $,
  160087. group: "joinRoom"
  160088. }),
  160089. this.firstUpdateYUV = !1
  160090. }
  160091. this.cachedStreams[e] != null && this.executeFunction("stream", {
  160092. stream: this.cachedStreams[e],
  160093. width: this.cachedResolution[e].width,
  160094. height: this.cachedResolution[e].height,
  160095. pts: this.cachedPtss[e]
  160096. });
  160097. const c = Date.now();
  160098. this.cachedStreams[e] != null && this.decoderWorker.postMessage({
  160099. t: 2,
  160100. frameCnt: this.cachedPtss[e],
  160101. buffer: this.cachedStreams[e]
  160102. }, [this.cachedStreams[e].buffer]);
  160103. const d = Date.now()
  160104. , _ = c - s
  160105. , b = d - c;
  160106. (_ > 33 || b > 10) && log$l.debug("[wwwarning] updateYUV takes ", _, " ms, postMessage takes ", b, " ms for index ", this.cachedPtss[e]),
  160107. c - this.lastRenderTs > 84 && this.JankTimes++,
  160108. c - this.lastRenderTs > 125 && this.bigJankTimes++,
  160109. this.lastRenderTs = c;
  160110. const k = c - s;
  160111. this.updateYUVCircular.add(k);
  160112. const j = this.cachedMetas[e];
  160113. if ((o = j == null ? void 0 : j.traceIds) != null && o.length)
  160114. for (const $ of j.traceIds) {
  160115. if (this.traceIdMap.has($)) {
  160116. const _e = this.traceIdMap.get($);
  160117. if (_e != null) {
  160118. _e.displayTime = Date.now(),
  160119. _e.status = 3;
  160120. const et = _e.receiveTime - _e.startTime
  160121. , tt = _e.readyTime - _e.receiveTime
  160122. , rt = _e.displayTime - _e.readyTime
  160123. , it = _e.displayTime - _e.startTime;
  160124. this.responseTimeArray.push(et),
  160125. this.processTimeArray.push(tt),
  160126. this.displayTimeArray.push(rt),
  160127. this.overallTimeArray.push(it),
  160128. this.traceIdMap.delete($)
  160129. }
  160130. }
  160131. if (this.joyStickTraceIdMap.has($)) {
  160132. const _e = this.joyStickTraceIdMap.get($);
  160133. if (_e != null) {
  160134. _e.displayTime = Date.now(),
  160135. _e.status = 3;
  160136. const et = _e.receiveTime - _e.startTime
  160137. , tt = _e.readyTime - _e.receiveTime
  160138. , rt = _e.displayTime - _e.readyTime
  160139. , it = _e.displayTime - _e.startTime;
  160140. this.joyStickResponseTimeArray.push(et),
  160141. this.joyStickProcessTimeArray.push(tt),
  160142. this.joyStickDisplayTimeArray.push(rt),
  160143. this.joyStickOverallTimeArray.push(it),
  160144. this.joyStickTraceIdMap.delete($)
  160145. }
  160146. }
  160147. }
  160148. if (this.cachedPtss[e] == this.moveStartPts && (this.MoveDisplayDelay = Date.now() - this.StartMovingTs),
  160149. this.inMovingMode) {
  160150. const $ = Date.now()
  160151. , _e = $ - this.lastMoveDisplayTime;
  160152. this.moveDisplayCircular.add(_e),
  160153. this.lastMoveDisplayTime = $
  160154. }
  160155. this.executeFunction("signal", {
  160156. signal: this.cachedMetas[e],
  160157. pts: this.cachedPtss[e],
  160158. alreadyUpdateYUV: !0
  160159. }),
  160160. this.cachedRender[e] = !0,
  160161. this.getPtr = (this.getPtr + 1) % this.cachedLength
  160162. }
  160163. }
  160164. unmarshalPano(e) {
  160165. const i = new DataView(e)
  160166. , o = i.getUint32(0);
  160167. if (o == 1723558763)
  160168. return !0;
  160169. if (o != 2296221069)
  160170. return !1;
  160171. console.log("Receive Pano Message"),
  160172. i.getUint16(4);
  160173. const s = i.getUint16(6)
  160174. , c = i.getUint32(8)
  160175. , d = i.getUint32(12)
  160176. , _ = i.getUint32(16)
  160177. , b = i.getUint32(20)
  160178. , k = e.byteLength - s;
  160179. if (k == d) {
  160180. const j = new Uint8Array(e).subarray(s).slice(0, _)
  160181. , _e = {
  160182. data: new Uint8Array(e).subarray(s).slice(_, d),
  160183. mediaLen: d - _,
  160184. metadata: j,
  160185. metaLen: _,
  160186. tileId: c
  160187. };
  160188. this.decoderWorker.postMessage({
  160189. t: 8,
  160190. data: _e
  160191. })
  160192. } else {
  160193. const j = new Uint8Array(e,s,k);
  160194. if (this.cachePanoTileID == c) {
  160195. if (this.panoCacheBuffer.set(j, b),
  160196. this.panoCacheSize += k,
  160197. this.panoCacheSize === d) {
  160198. const $ = new Uint8Array(this.panoCacheBuffer).slice(0, _)
  160199. , et = {
  160200. data: new Uint8Array(this.panoCacheBuffer).slice(_, d),
  160201. mediaLen: d - _,
  160202. metadata: $,
  160203. metaLen: _,
  160204. tileId: c
  160205. };
  160206. this.decoderWorker.postMessage({
  160207. t: 8,
  160208. data: et
  160209. }),
  160210. this.panoCacheSize = 0
  160211. }
  160212. } else
  160213. this.panoCacheBuffer.set(j, b),
  160214. this.panoCacheSize = k,
  160215. this.cachePanoTileID = c
  160216. }
  160217. return !0
  160218. }
  160219. clearMoveArray() {
  160220. this.MovingTraceId = "",
  160221. this.inMovingMode = !1,
  160222. this.StartMovingTs = 0,
  160223. this.MoveToFrameCnt = 0,
  160224. this.MoveResponseDelay = 0,
  160225. this.MoveProcessDelay = 0,
  160226. this.MoveDisplayDelay = 0,
  160227. this.moveStartPts = -1,
  160228. this.moveResponseCircular.clear(),
  160229. this.moveProcessCircular.clear(),
  160230. this.moveDisplayCircular.clear(),
  160231. this.moveEvent = ""
  160232. }
  160233. getIsMoving(e) {
  160234. let i;
  160235. if (typeof e.newUserStates != "undefined")
  160236. for (let o = 0; o < e.newUserStates.length; o++) {
  160237. const s = e.newUserStates[o];
  160238. if (s.userId == this.rtcp.network.room.userId) {
  160239. i = s.renderInfo.isMoving;
  160240. break
  160241. }
  160242. }
  160243. return i
  160244. }
  160245. isHeartBeatPacket(e, i) {
  160246. return new DataView(e).getUint32(0) == 2009889916
  160247. }
  160248. resetSendTimeDiff() {
  160249. this.prevSenderTs = 0,
  160250. this.serverSendTimeArray.clear()
  160251. }
  160252. calcSendTimeDiff(e) {
  160253. if (this.prevSenderTs == -1) {
  160254. this.prevSenderTs = e;
  160255. return
  160256. }
  160257. const i = e - this.prevSenderTs;
  160258. this.serverSendTimeArray.add(i),
  160259. this.prevSenderTs = e
  160260. }
  160261. unmarshalStream(e) {
  160262. var lt, ft, ht, pt, dt, _t, mt, vt, yt, Et;
  160263. const i = Date.now()
  160264. , o = new DataView(e);
  160265. if (o.getUint32(0) != 1437227610)
  160266. return !1;
  160267. o.getUint16(4);
  160268. const c = o.getUint16(6)
  160269. , d = o.getUint16(8)
  160270. , _ = d
  160271. , b = o.getUint16(10);
  160272. let k = !1;
  160273. b == 1 && (k = !0);
  160274. const j = o.getUint32(12)
  160275. , $ = o.getUint32(16)
  160276. , _e = o.getUint32(20)
  160277. , et = o.getUint16(24)
  160278. , tt = o.getUint16(26)
  160279. , rt = o.getUint32(28)
  160280. , it = o.getUint32(c - 4)
  160281. , nt = j + $
  160282. , ot = e.byteLength - c
  160283. , at = new Uint8Array(e,c,ot);
  160284. this.calcSendTimeDiff(_e);
  160285. let st;
  160286. if (this.inPanoMode && ($ > 0 || et))
  160287. return log$l.error("Stream Protocal Violation: receive illegal stream in Pano mode"),
  160288. !0;
  160289. if (ot === nt) {
  160290. this.receivedMedia++;
  160291. const At = new Uint8Array(e).subarray(c);
  160292. _e - this.lastServerTS > 60 ? this.serverFrameSlow++ : _e - this.lastServerTS < 16 && this.serverFrameFast++;
  160293. const gt = Date.now();
  160294. gt - this.lastClientTS > 60 ? this.clientFrameSlow++ : gt - this.lastClientTS < 16 && this.clientFrameFast++;
  160295. const St = $ === 0
  160296. , xt = _e - this.lastServerTS;
  160297. this.lastServerTS != 0 && ((d + 65536 - this.lastSeq) % 65536 === 1 && this.lastIsPureMeta == St && (St ? this.srvMetaIntervalCircular.add(xt) : this.srvMediaIntervalCircular.add(xt)),
  160298. this.frameServerCircular.add(xt),
  160299. this.frameClientCircular.add(gt - this.lastClientTS)),
  160300. this.lastSeq = d,
  160301. this.lastIsPureMeta = St,
  160302. this.lastServerTS = _e,
  160303. this.lastClientTS = gt;
  160304. const bt = At.subarray(0, j)
  160305. , Rt = Date.now()
  160306. , Mt = JSON.parse(this.Stringify(bt))
  160307. , Pt = Date.now();
  160308. this.showAllReceivedMetadata && console.log(_e, gt, Mt),
  160309. this.metaParseAraay.push(Pt - Rt),
  160310. (lt = Mt.traceIds) != null && lt.length && this.processMetaWithTraceId(Mt),
  160311. $ != 0 && this.moveStartPts == -1 && this.inMovingMode && (this.moveStartPts = d),
  160312. this.moveStartPts == d && (this.MoveResponseDelay = Date.now() - this.StartMovingTs,
  160313. console.log("move response delay: ", d, this.moveStartPts, this.MoveResponseDelay));
  160314. const It = this.getIsMoving(Mt);
  160315. if (this.inMovingMode && It == 0 && this.lastIsMoving == 1 && this.clearMoveArray(),
  160316. typeof It != "undefined" && (this.lastIsMoving = It),
  160317. this.inMovingMode) {
  160318. const Ct = Date.now()
  160319. , Ot = Ct - this.lastMoveResponseTime;
  160320. this.moveResponseCircular.add(Ot),
  160321. this.lastMoveResponseTime = Ct
  160322. }
  160323. (et || tt) && (st = (dt = (pt = (ht = (ft = Mt.newUserStates) == null ? void 0 : ft.find(Ct=>Ct.userId === this._rtcp.network.room.userId)) == null ? void 0 : ht.playerState) == null ? void 0 : pt.player) == null ? void 0 : dt.position);
  160324. const Dt = {
  160325. t: 0,
  160326. data: At,
  160327. mediaLen: $,
  160328. metaLen: j,
  160329. metadata: Mt,
  160330. frameCnt: _,
  160331. server_ts: _e,
  160332. isIDR: k,
  160333. cacheRequest: tt,
  160334. cached: et,
  160335. cachedKey: rt,
  160336. position: st
  160337. };
  160338. if (this.inPanoMode)
  160339. return this.executeFunction("signal", {
  160340. signal: Mt,
  160341. pts: -1,
  160342. alreadyUpdateYUV: !0
  160343. }),
  160344. !0;
  160345. if (this.decoderWorker.postMessage(Dt, [At.buffer]),
  160346. !this.firstMediaReceived) {
  160347. this.firstMediaArraval = Date.now();
  160348. const Ct = this.firstMediaArraval - this.rtcp.network.room._startTime;
  160349. log$l.infoAndReportMeasurement({
  160350. metric: "firstMediaArravalAt",
  160351. value: Ct,
  160352. group: "joinRoom"
  160353. }),
  160354. this.firstMediaReceived = !0
  160355. }
  160356. } else {
  160357. const At = this.hasFrmCntInCache(_);
  160358. if (At != -1)
  160359. if (this.cacheFrameComposes[At].buffer.set(at, it),
  160360. this.cacheFrameComposes[At].size += ot,
  160361. this.cacheFrameComposes[At].size === nt) {
  160362. const gt = new Uint8Array(this.cacheFrameComposes[At].buffer).slice(0, nt);
  160363. this.cacheFrameComposes[At].frameCnt = -1,
  160364. this.cacheFrameComposes[At].size = 0,
  160365. this.cacheFrameComposes[At].startReceiveTime = 0,
  160366. this.cacheFrameComposes[At].serverTime = 0,
  160367. this.receivedMedia++,
  160368. _e - this.lastServerTS > 60 ? this.serverFrameSlow++ : _e - this.lastServerTS < 16 && this.serverFrameFast++;
  160369. const St = Date.now();
  160370. St - this.lastClientTS > 60 ? this.clientFrameSlow++ : St - this.lastClientTS < 16 && this.clientFrameFast++,
  160371. this.lastServerTS != 0 && (this.frameServerCircular.add(_e - this.lastServerTS),
  160372. this.frameClientCircular.add(St - this.lastClientTS)),
  160373. this.lastServerTS = _e,
  160374. this.lastClientTS = St;
  160375. const xt = gt.subarray(0, j)
  160376. , bt = Date.now()
  160377. , Rt = JSON.parse(this.Stringify(xt))
  160378. , Mt = Date.now();
  160379. this.showAllReceivedMetadata && console.log(_e, St, Rt),
  160380. this.metaParseAraay.push(Mt - bt),
  160381. (_t = Rt.traceIds) != null && _t.length && this.processMetaWithTraceId(Rt),
  160382. $ != 0 && this.moveStartPts == -1 && this.inMovingMode && (this.moveStartPts = d),
  160383. this.moveStartPts == d && (this.MoveResponseDelay = Date.now() - this.StartMovingTs);
  160384. const Pt = this.getIsMoving(Rt);
  160385. if (this.inMovingMode && Pt == 0 && this.lastIsMoving == 1 && this.clearMoveArray(),
  160386. typeof Pt != "undefined" && (this.lastIsMoving = Pt),
  160387. this.inMovingMode) {
  160388. const Dt = Date.now()
  160389. , Ct = Dt - this.lastMoveResponseTime;
  160390. this.moveResponseCircular.add(Ct),
  160391. this.lastMoveResponseTime = Dt
  160392. }
  160393. (et || tt) && (st = (Et = (yt = (vt = (mt = Rt.newUserStates) == null ? void 0 : mt.find(Dt=>Dt.userId === this._rtcp.network.room.userId)) == null ? void 0 : vt.playerState) == null ? void 0 : yt.player) == null ? void 0 : Et.position);
  160394. const It = {
  160395. t: 0,
  160396. data: gt,
  160397. mediaLen: $,
  160398. metaLen: j,
  160399. metadata: Rt,
  160400. frameCnt: _,
  160401. server_ts: _e,
  160402. isIDR: k,
  160403. cacheRequest: tt,
  160404. cached: et,
  160405. cachedKey: rt,
  160406. position: st
  160407. };
  160408. if (this.inPanoMode)
  160409. return this.executeFunction("signal", {
  160410. signal: Rt,
  160411. pts: -1,
  160412. alreadyUpdateYUV: !0
  160413. }),
  160414. !0;
  160415. if (this.decoderWorker.postMessage(It, [gt.buffer]),
  160416. !this.firstMediaReceived) {
  160417. this.firstMediaArraval = Date.now();
  160418. const Dt = this.firstMediaArraval - this.rtcp.network.room._startTime;
  160419. log$l.infoAndReportMeasurement({
  160420. metric: "firstMediaArravalAt",
  160421. value: Dt,
  160422. group: "joinRoom"
  160423. }),
  160424. this.firstMediaReceived = !0
  160425. }
  160426. } else
  160427. this.cacheFrameComposes[At].size > nt && log$l.debug("I frame exceed, cache size is ", this.cacheSize, ", total size is ", nt);
  160428. else if (At == -1) {
  160429. let gt = this.hasFrmCntInCache(-1);
  160430. if (gt == -1) {
  160431. let St = Date.now() + 1e18
  160432. , xt = -1;
  160433. for (let bt = 0; bt < this.cacheFrameComposes.length; bt++)
  160434. this.cacheFrameComposes[bt].serverTime < St && (St = this.cacheFrameComposes[bt].serverTime,
  160435. xt = bt);
  160436. gt = xt
  160437. }
  160438. this.cacheFrameComposes[gt].buffer.set(at, it),
  160439. this.cacheFrameComposes[gt].size = ot,
  160440. this.cacheFrameComposes[gt].frameCnt = _,
  160441. this.cacheFrameComposes[gt].startReceiveTime = Date.now(),
  160442. this.cacheFrameComposes[gt].serverTime = _e
  160443. }
  160444. }
  160445. const ct = Date.now() - i;
  160446. return this.unmarshalStreamExecutionArray.add(ct),
  160447. !0
  160448. }
  160449. reset() {
  160450. log$l.debug("Worker reset is called"),
  160451. this.cacheFrameCnt = 0,
  160452. this.receivedMedia = 0,
  160453. this.reconnectSignal = !0,
  160454. this.decoderWorker.postMessage({
  160455. t: 4
  160456. })
  160457. }
  160458. dataHandleOff(e) {
  160459. log$l.debug("hhh")
  160460. }
  160461. dataHandle(e) {
  160462. this.saveframe && (this.decoderWorker.postMessage({
  160463. t: 6
  160464. }),
  160465. this.saveframe = !1),
  160466. this.SaveMediaStream && (this.decoderWorker.postMessage({
  160467. t: 7
  160468. }),
  160469. this.SaveMediaStream = !1);
  160470. const i = new Uint8Array(e);
  160471. if (i.length >= 4 && this.isHeartBeatPacket(i.buffer, i.length) == !0)
  160472. return;
  160473. if (i.length > 36 && this.unmarshalStream(i.buffer) == !0) {
  160474. this.reconnectSignal && (this.executeFunction("reconnectedFrame", {}),
  160475. this.reconnectSignal = !1);
  160476. return
  160477. }
  160478. if (i.length > 20 && this.unmarshalPano(i.buffer) == !0)
  160479. return;
  160480. this.noWasmBytesReceived += e.byteLength;
  160481. const o = JSON.parse(this.Stringify(i));
  160482. this.executeFunction("signal", {
  160483. signal: o,
  160484. pts: -1,
  160485. alreadyUpdateYUV: !0
  160486. })
  160487. }
  160488. changePanoMode(e) {
  160489. this.inPanoMode = e
  160490. }
  160491. uploadDataToServer() {
  160492. this.DynamicPanoTest == !0 && (this.onRotateInPanoMode({
  160493. traceId: "b2e1a296-6438-4371-8a31-687beb724ebe"
  160494. }),
  160495. this.DynamicPanoTest = !1);
  160496. function e(ar, rr) {
  160497. return rr == -1 && (rr = 0),
  160498. ar + rr
  160499. }
  160500. function i(ar, rr) {
  160501. return Math.max(ar, rr)
  160502. }
  160503. const o = this.responseTimeArray.reduce(e, 0) / this.responseTimeArray.length || 0
  160504. , s = this.processTimeArray.reduce(e, 0) / this.processTimeArray.length || 0
  160505. , c = this.displayTimeArray.reduce(e, 0) / this.displayTimeArray.length || 0
  160506. , d = this.overallTimeArray.reduce(e, 0) / this.overallTimeArray.length || 0
  160507. , _ = this.overallTimeArray.length;
  160508. this.responseTimeArray = [],
  160509. this.processTimeArray = [],
  160510. this.displayTimeArray = [],
  160511. this.overallTimeArray = [];
  160512. const b = this.joyStickResponseTimeArray.reduce(e, 0) / this.joyStickResponseTimeArray.length || 0
  160513. , k = this.joyStickProcessTimeArray.reduce(e, 0) / this.joyStickProcessTimeArray.length || 0
  160514. , j = this.joyStickDisplayTimeArray.reduce(e, 0) / this.joyStickDisplayTimeArray.length || 0
  160515. , $ = this.joyStickOverallTimeArray.reduce(e, 0) / this.joyStickOverallTimeArray.length || 0
  160516. , _e = this.joyStickResponseTimeArray.reduce(i, 0)
  160517. , et = this.joyStickProcessTimeArray.reduce(i, 0)
  160518. , tt = this.joyStickDisplayTimeArray.reduce(i, 0)
  160519. , rt = this.joyStickOverallTimeArray.reduce(i, 0);
  160520. this.joyStickResponseTimeArray = [],
  160521. this.joyStickProcessTimeArray = [],
  160522. this.joyStickDisplayTimeArray = [],
  160523. this.joyStickOverallTimeArray = [];
  160524. const it = this.moveResponseCircular.getThreshPercent()
  160525. , nt = it[0]
  160526. , ot = it[1]
  160527. , at = it[2]
  160528. , st = it[3]
  160529. , ut = it[4]
  160530. , ct = ut - st
  160531. , lt = 1 - ot / ut || 0
  160532. , ft = [nt, ot - nt, at - ot, st - at, ct]
  160533. , ht = this.moveProcessCircular.getThreshPercent()
  160534. , pt = ht[0]
  160535. , dt = ht[1]
  160536. , _t = ht[2]
  160537. , mt = ht[3]
  160538. , vt = ht[4]
  160539. , yt = vt - mt
  160540. , Et = 1 - dt / vt || 0
  160541. , At = [pt, dt - pt, _t - dt, mt - _t, yt]
  160542. , gt = this.moveDisplayCircular.getThreshPercent()
  160543. , St = gt[0]
  160544. , xt = gt[1]
  160545. , bt = gt[2]
  160546. , Rt = gt[3]
  160547. , Mt = gt[4]
  160548. , Pt = Mt - Rt
  160549. , It = 1 - xt / Mt || 0
  160550. , Dt = [St, xt - St, bt - xt, Rt - bt, Pt]
  160551. , Ct = St
  160552. , Ot = xt - St
  160553. , wt = bt - xt
  160554. , Nt = Rt - bt
  160555. , Ft = Pt
  160556. , Vt = this.moveResponseCircular.getAvg()
  160557. , Lt = this.moveProcessCircular.getAvg()
  160558. , kt = this.moveDisplayCircular.getAvg()
  160559. , Bt = this.moveResponseCircular.getMax()
  160560. , Ut = this.moveProcessCircular.getMax()
  160561. , Gt = this.moveDisplayCircular.getMax()
  160562. , Ht = this.moveResponseCircular.getStandardDeviation()
  160563. , zt = this.moveProcessCircular.getStandardDeviation()
  160564. , Wt = this.moveDisplayCircular.getStandardDeviation();
  160565. this.moveResponseCircular.getIncomingAvg(),
  160566. this.moveProcessCircular.getIncomingAvg(),
  160567. this.moveDisplayCircular.getIncomingAvg(),
  160568. this.moveResponseCircular.getIncomingMax(),
  160569. this.moveProcessCircular.getIncomingMax(),
  160570. this.moveDisplayCircular.getIncomingMax(),
  160571. this.moveResponseCircular.clearIncoming(),
  160572. this.moveProcessCircular.clearIncoming(),
  160573. this.moveDisplayCircular.clearIncoming();
  160574. const Kt = this.frameServerCircular.getAvg()
  160575. , Qt = this.frameServerCircular.getMax();
  160576. this.frameClientCircular.getAvg(),
  160577. this.frameClientCircular.getMax();
  160578. const qt = this.metaParseAraay.reduce(e, 0) / this.metaParseAraay.length || 0
  160579. , Yt = this.metaParseAraay.reduce(i, 0);
  160580. this.metaParseAraay = [];
  160581. const Jt = this.unmarshalStreamExecutionArray.getStat()
  160582. , jt = this.receiveYUVExecutionArray.getStat()
  160583. , Xt = this.postMessageWaitArray.getStat().max
  160584. , nr = {
  160585. mediaBytesReceived: this.mediaBytesReceived,
  160586. metaBytesReceived: this.metaBytesReceived,
  160587. packetsLost: this.packetsLost,
  160588. timestamp: Date.now(),
  160589. frameHeight: 1280,
  160590. frameWidth: 720,
  160591. framesReceived: this.receivedMedia,
  160592. framesReceivedWorker: this.receivedMedia_worker,
  160593. framesDecoded: this.receivedYUV,
  160594. framesEmited: this.receivedEmit,
  160595. decodeTimePerFrame: this.decodeTimePerFrame,
  160596. decodeTimeMaxFrame: this.decodeTimeMaxFrame,
  160597. packetsDrop: this.packetsDrop,
  160598. framesAwait: this.framesAwait,
  160599. firstMediaArraval: this.firstMediaArraval,
  160600. firstYUVDecoded: this.firstYUVDecoded,
  160601. firstRender: this.firstRender,
  160602. returnFrames: this.returnFrames,
  160603. sendOutBuffer: this.sendOutBuffer,
  160604. maxGraphicTime: this.updateYUVCircular.getMax(),
  160605. averageGraphicTime: this.updateYUVCircular.getAvg(),
  160606. jankTimes: this.JankTimes,
  160607. bigJankTimes: this.bigJankTimes,
  160608. decodeJankTimes: this.DecodeJankTimes,
  160609. bigDecodeJankTimes: this.bigDecodeJankTimes,
  160610. serverFrameSlow: this.serverFrameSlow,
  160611. serverFrameFast: this.serverFrameFast,
  160612. clientFrameSlow: this.clientFrameSlow,
  160613. clientFrameFast: this.clientFrameFast,
  160614. rtcMessageReceived: this.rtcMessageReceived,
  160615. rtcBytesReceived: this.rtcBytesReceived - this.noWasmBytesReceived,
  160616. noWasmBytesReceived: this.noWasmBytesReceived,
  160617. receiveIframes: this.receiveIframes,
  160618. decodeIframes: this.decodeIframes,
  160619. avgResponseTime: o,
  160620. avgProcessTime: s,
  160621. avgDisplayTime: c,
  160622. avgOverallTime: d,
  160623. overallTimeCount: _,
  160624. responseMiss: this.responseMiss,
  160625. processMiss: this.processMiss,
  160626. displayMiss: this.displayMiss,
  160627. updateDropFrame: this.updateDropFrame,
  160628. moveEvent: this.moveEvent,
  160629. avgResponseMoveDiff: this.moveEvent == "MoveTo" ? Vt : 0,
  160630. avgProcessMoveDiff: this.moveEvent == "MoveTo" ? Lt : 0,
  160631. avgDisplayMoveDiff: this.moveEvent == "MoveTo" ? kt : 0,
  160632. maxResponseMoveDiff: this.moveEvent == "MoveTo" ? Bt : 0,
  160633. maxProcessMoveDiff: this.moveEvent == "MoveTo" ? Ut : 0,
  160634. maxDisplayMoveDiff: this.moveEvent == "MoveTo" ? Gt : 0,
  160635. moveResponseJank: this.moveEvent == "MoveTo" ? lt : 0,
  160636. moveProcessJank: this.moveEvent == "MoveTo" ? Et : 0,
  160637. moveDisplayJank: this.moveEvent == "MoveTo" ? It : 0,
  160638. moveResponseCounts: this.moveEvent == "MoveTo" ? ft.toString() : "0,0,0,0,0",
  160639. moveProcessCounts: this.moveEvent == "MoveTo" ? At.toString() : "0,0,0,0,0",
  160640. moveDisplayCounts: this.moveEvent == "MoveTo" ? Dt.toString() : "0,0,0,0,0",
  160641. MoveDisplayCountGood: this.moveEvent == "MoveTo" ? Ct.toString() : "0",
  160642. MoveDisplayCountWell: this.moveEvent == "MoveTo" ? Ot.toString() : "0",
  160643. MoveDisplayCountFair: this.moveEvent == "MoveTo" ? wt.toString() : "0",
  160644. MoveDisplayCountBad: this.moveEvent == "MoveTo" ? Nt.toString() : "0",
  160645. MoveDisplayCountRest: this.moveEvent == "MoveTo" ? Ft.toString() : "0",
  160646. moveResponseDelay: this.moveEvent == "MoveTo" ? this.MoveResponseDelay : 0,
  160647. moveProcessDelay: this.moveEvent == "MoveTo" ? this.MoveProcessDelay : 0,
  160648. moveDisplayDelay: this.moveEvent == "MoveTo" ? this.MoveDisplayDelay : 0,
  160649. sdMoveResponseLongTime: Ht,
  160650. sdMoveProcessLongTime: zt,
  160651. sdMoveDisplayLongTime: Wt,
  160652. avgResponseFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? Vt : 0,
  160653. avgProcessFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? Lt : 0,
  160654. avgDisplayFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? kt : 0,
  160655. maxResponseFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? Bt : 0,
  160656. maxProcessFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? Ut : 0,
  160657. maxDisplayFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? Gt : 0,
  160658. flyResponseJank: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? lt : 0,
  160659. flyProcessJank: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? Et : 0,
  160660. flyDisplayJank: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? It : 0,
  160661. flyResponseCounts: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? ft.toString() : "0,0,0,0,0",
  160662. flyProcessCounts: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? At.toString() : "0,0,0,0,0",
  160663. flyDisplayCounts: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? Dt.toString() : "0,0,0,0,0",
  160664. flyResponseDelay: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? this.MoveResponseDelay : 0,
  160665. flyProcessDelay: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? this.MoveProcessDelay : 0,
  160666. flyDisplayDelay: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? this.MoveDisplayDelay : 0,
  160667. avgMetaParseTime: qt,
  160668. maxMetaParseTime: Yt,
  160669. avgServerDiff: Kt,
  160670. maxServerDiff: Qt,
  160671. unmarshalStreamStat: Jt,
  160672. receiveYUVStat: jt,
  160673. maxPostMsgDiff: Xt,
  160674. streamType: WASM_Version,
  160675. avgJoyStickResponseTime: b,
  160676. avgJoyStickProcessTime: k,
  160677. avgJoyStickDisplayTime: j,
  160678. avgJoyStickOverallTime: $,
  160679. maxJoyStickResponseTime: _e,
  160680. maxJoyStickProcessTime: et,
  160681. maxJoyStickDisplayTime: tt,
  160682. maxJoyStickOverallTime: rt
  160683. };
  160684. return this.lastReturnFrames = this.returnFrames,
  160685. this.lastReceivedEmit = this.receivedEmit,
  160686. nr
  160687. }
  160688. }
  160689. const log$k = new Logger("rtcp");
  160690. class Rtcp extends EventEmitter {
  160691. constructor(i) {
  160692. super();
  160693. Tt(this, "connection", null);
  160694. Tt(this, "inputChannel", null);
  160695. Tt(this, "mediaStream");
  160696. Tt(this, "socket");
  160697. Tt(this, "connected", !1);
  160698. Tt(this, "candidates", []);
  160699. Tt(this, "isAnswered", !1);
  160700. Tt(this, "isFlushing", !1);
  160701. Tt(this, "inputReady", !1);
  160702. Tt(this, "workers");
  160703. Tt(this, "actived", !0);
  160704. Tt(this, "heartbeat");
  160705. Tt(this, "onIcecandidate", i=>{
  160706. if (i.candidate != null) {
  160707. const o = JSON.stringify(i.candidate);
  160708. log$k.debug(`Got ice candidate: ${o}`),
  160709. this.network.socket.send({
  160710. id: "ice_candidate",
  160711. data: btoa(o)
  160712. })
  160713. }
  160714. }
  160715. );
  160716. Tt(this, "onIcecandidateerror", i=>{
  160717. log$k.error("onicecandidateerror", i.errorCode, i.errorText, i)
  160718. }
  160719. );
  160720. Tt(this, "onIceStateChange", i=>{
  160721. switch (i.target.iceGatheringState) {
  160722. case "gathering":
  160723. log$k.info("ice gathering");
  160724. break;
  160725. case "complete":
  160726. log$k.info("Ice gathering completed")
  160727. }
  160728. }
  160729. );
  160730. Tt(this, "onIceConnectionStateChange", ()=>{
  160731. if (!!this.connection)
  160732. switch (log$k.info(`iceConnectionState: ${this.connection.iceConnectionState}`),
  160733. this.connection.iceConnectionState) {
  160734. case "connected":
  160735. {
  160736. this.connected = !0;
  160737. break
  160738. }
  160739. case "disconnected":
  160740. {
  160741. this.connected = !1,
  160742. this.emit("rtcDisconnected");
  160743. break
  160744. }
  160745. case "failed":
  160746. {
  160747. this.emit("rtcDisconnected"),
  160748. this.connected = !1;
  160749. break
  160750. }
  160751. }
  160752. }
  160753. );
  160754. Tt(this, "setRemoteDescription", async(i,o)=>{
  160755. var _, b, k;
  160756. if (!this.connection)
  160757. return;
  160758. const s = JSON.parse(atob(i))
  160759. , c = new RTCSessionDescription(s);
  160760. await this.connection.setRemoteDescription(c);
  160761. const d = await this.connection.createAnswer();
  160762. if (d.sdp = (_ = d.sdp) == null ? void 0 : _.replace(/(a=fmtp:111 .*)/g, "$1;stereo=1;sprop-stereo=1"),
  160763. ((k = (b = d.sdp) == null ? void 0 : b.match(/a=mid:1/g)) == null ? void 0 : k.length) == 2) {
  160764. const j = d.sdp.lastIndexOf("a=mid:1");
  160765. d.sdp = d.sdp.slice(0, j) + "a=mid:2" + d.sdp.slice(j + 7)
  160766. }
  160767. try {
  160768. await this.connection.setLocalDescription(d)
  160769. } catch (j) {
  160770. log$k.error("error", j)
  160771. }
  160772. this.isAnswered = !0,
  160773. this.network.rtcp.flushCandidate(),
  160774. this.network.socket.send({
  160775. id: "answer",
  160776. data: btoa(JSON.stringify(d))
  160777. }),
  160778. o.srcObject = this.mediaStream
  160779. }
  160780. );
  160781. Tt(this, "flushCandidate", ()=>{
  160782. this.isFlushing || !this.isAnswered || (this.isFlushing = !0,
  160783. this.candidates.forEach(i=>{
  160784. const o = atob(i)
  160785. , s = JSON.parse(o);
  160786. if (/172\./.test(s.candidate))
  160787. return;
  160788. const c = new RTCIceCandidate(s);
  160789. this.connection && this.connection.addIceCandidate(c).then(()=>{}
  160790. , d=>{
  160791. log$k.info("add candidate failed", d)
  160792. }
  160793. )
  160794. }
  160795. ),
  160796. this.isFlushing = !1)
  160797. }
  160798. );
  160799. Tt(this, "input", i=>{
  160800. var o;
  160801. !this.actived || !this.inputChannel || this.inputChannel.readyState === "open" && ((o = this.inputChannel) == null || o.send(i))
  160802. }
  160803. );
  160804. this.network = i,
  160805. this.workers = new Workers(this,new Logger("decode")),
  160806. this.workers.registerLogger(new Logger("decode")),
  160807. this.workers.registerFunction("data", o=>{
  160808. this.emit("data", o)
  160809. }
  160810. ),
  160811. this.heartbeat = new Heartbeat({
  160812. ping: o=>{
  160813. i.room.actionsHandler.echo(o)
  160814. }
  160815. ,
  160816. pong(o, s) {
  160817. var c;
  160818. s && o > 500 && log$k.warn(`high hb value ${o}, traceId:` + s),
  160819. (c = i.room.stats) == null || c.assign({
  160820. hb: o
  160821. })
  160822. }
  160823. })
  160824. }
  160825. start() {
  160826. this.connection = new RTCPeerConnection;
  160827. const i = Date.now();
  160828. this.connection.ondatachannel = o=>{
  160829. log$k.info(`ondatachannel: ${o.channel.label}`),
  160830. this.inputChannel = o.channel,
  160831. this.inputChannel.onopen = ()=>{
  160832. var s;
  160833. log$k.info("The input channel has opened, id:", (s = this.inputChannel) == null ? void 0 : s.id),
  160834. this.inputReady = !0,
  160835. this.emit("rtcConnected"),
  160836. this.network.room.currentNetworkOptions.reconnect || (log$k.infoAndReportMeasurement({
  160837. metric: "datachannelOpenedAt",
  160838. startTime: this.network.room._startTime,
  160839. group: "joinRoom"
  160840. }),
  160841. log$k.infoAndReportMeasurement({
  160842. metric: "datachannelOpenedCost",
  160843. startTime: i,
  160844. group: "joinRoom"
  160845. }))
  160846. }
  160847. ,
  160848. this.inputChannel.onclose = ()=>{
  160849. var s;
  160850. return log$k.info("The input channel has closed, id:", (s = this.inputChannel) == null ? void 0 : s.id)
  160851. }
  160852. ,
  160853. this.inputChannel.onmessage = s=>{
  160854. this.workers.dataHandle(s.data)
  160855. }
  160856. }
  160857. ,
  160858. this.connection.oniceconnectionstatechange = this.onIceConnectionStateChange,
  160859. this.connection.onicegatheringstatechange = this.onIceStateChange,
  160860. this.connection.onicecandidate = this.onIcecandidate,
  160861. this.connection.onicecandidateerror = this.onIcecandidateerror,
  160862. this.network.socket.send({
  160863. id: "init_webrtc",
  160864. data: JSON.stringify({
  160865. is_mobile: !0
  160866. })
  160867. })
  160868. }
  160869. addCandidate(i) {
  160870. i === "" ? this.network.rtcp.flushCandidate() : this.candidates.push(i)
  160871. }
  160872. disconnect() {
  160873. var i, o, s;
  160874. this.heartbeat.stop(),
  160875. log$k.info("ready to close datachannel, id", (i = this.inputChannel) == null ? void 0 : i.id),
  160876. (o = this.inputChannel) == null || o.close(),
  160877. (s = this.connection) == null || s.close(),
  160878. this.connection = null,
  160879. this.inputChannel = null
  160880. }
  160881. sendStringData(i) {
  160882. this.input(i)
  160883. }
  160884. sendData(i) {
  160885. let o = "";
  160886. try {
  160887. o = JSON.stringify(i)
  160888. } catch (s) {
  160889. log$k.error(s);
  160890. return
  160891. }
  160892. this.input(o)
  160893. }
  160894. }
  160895. class Timeout {
  160896. constructor(e, i, o=!0) {
  160897. Tt(this, "_fn");
  160898. Tt(this, "_delay");
  160899. Tt(this, "_timeout");
  160900. this._fn = e,
  160901. this._delay = i,
  160902. o && this.start()
  160903. }
  160904. get delay() {
  160905. return this._delay
  160906. }
  160907. get isSet() {
  160908. return !!this._timeout
  160909. }
  160910. setDelay(e) {
  160911. this._delay = e
  160912. }
  160913. start() {
  160914. this.isSet || (this._timeout = window.setTimeout(()=>{
  160915. const e = this._fn;
  160916. this.clear(),
  160917. e()
  160918. }
  160919. , this._delay))
  160920. }
  160921. clear() {
  160922. window.clearTimeout(this._timeout),
  160923. this._timeout = void 0
  160924. }
  160925. reset() {
  160926. this.clear(),
  160927. this.start()
  160928. }
  160929. }
  160930. const log$j = new Logger("ws");
  160931. class Socket extends EventEmitter {
  160932. constructor(i) {
  160933. super();
  160934. Tt(this, "_ws");
  160935. Tt(this, "_openTimer");
  160936. Tt(this, "connected", !1);
  160937. Tt(this, "_hasTimeout", !1);
  160938. Tt(this, "heartbeat");
  160939. Tt(this, "latency", (i,o)=>this.send({
  160940. id: "checkLatency",
  160941. data: JSON.stringify(i),
  160942. packet_id: o
  160943. }));
  160944. Tt(this, "send", i=>{
  160945. if (this.wsNoReady())
  160946. return;
  160947. const o = JSON.stringify(i);
  160948. i.id !== "heartbeat" && log$j.info("send ws frame", o),
  160949. this._ws.send(o)
  160950. }
  160951. );
  160952. Tt(this, "startGame", ()=>{
  160953. const {roomId: i, userId: o, avatarId: s, skinId: c, role: d, avatarComponents: _, versionId: b, rotationRenderType: k, isAllSync: j, nickname: $, avatarScale: _e, appId: et, camera: tt, player: rt, firends: it, syncByEvent: nt, areaName: ot, attitude: at, pathName: st, person: ut, roomTypeId: ct="", syncToOthers: lt, hasAvatar: ft, prioritySync: ht, extra: pt={}, removeWhenDisconnected: dt} = this.network.room.currentNetworkOptions;
  160954. pt.removeWhenDisconnected = dt;
  160955. const _t = {
  160956. id: "start",
  160957. room_id: i,
  160958. user_id: o,
  160959. trace_id: uuid$1(),
  160960. data: JSON.stringify({
  160961. avatar_components: JSON.stringify(_),
  160962. avatar_id: s,
  160963. skin_id: c,
  160964. is_host: d ? d == "host" : !0,
  160965. skin_data_version: c !== void 0 && b !== void 0 ? c + b : void 0,
  160966. rotation_render_type: k,
  160967. is_all_sync: j,
  160968. nick_name: encodeURIComponent($ || ""),
  160969. app_id: et,
  160970. camera: tt,
  160971. player: rt,
  160972. person: ut,
  160973. firends: JSON.stringify(it),
  160974. sync_by_event: nt,
  160975. area_name: ot,
  160976. path_name: st,
  160977. attitude: at,
  160978. room_type_id: ct,
  160979. syncToOthers: lt,
  160980. hasAvatar: ft,
  160981. avatarSize: _e,
  160982. prioritySync: ht,
  160983. extra: JSON.stringify(pt)
  160984. })
  160985. };
  160986. this.send(_t);
  160987. const mt = JSON.parse(_t.data);
  160988. delete mt.token,
  160989. log$j.infoAndReportMeasurement({
  160990. metric: "startGame",
  160991. extra: mt,
  160992. startTime: Date.now()
  160993. })
  160994. }
  160995. );
  160996. this.network = i,
  160997. this.heartbeat = new Heartbeat({
  160998. ping: o=>{
  160999. var s;
  161000. if (!this.connected) {
  161001. this.heartbeat.stop(),
  161002. (s = i.room.stats) == null || s.assign({
  161003. rtt: 0
  161004. });
  161005. return
  161006. }
  161007. this.send({
  161008. id: "heartbeat",
  161009. data: o
  161010. })
  161011. }
  161012. ,
  161013. pong(o) {
  161014. var s;
  161015. (s = i.room.stats) == null || s.assign({
  161016. rtt: o
  161017. })
  161018. }
  161019. })
  161020. }
  161021. get connection() {
  161022. return this._ws
  161023. }
  161024. start() {
  161025. this._hasTimeout = !1;
  161026. const i = this.getAddress();
  161027. log$j.info(`connecting to ${i}`);
  161028. const o = Date.now();
  161029. this._ws = new WebSocket(i),
  161030. this._openTimer = new Timeout(()=>{
  161031. const s = `Failed to open websocket in ${DEFAULT_OPEN_TIMEOUT_MS} ms`;
  161032. this._hasTimeout = !0,
  161033. this.emit("socketClosed", new InitNetworkTimeoutError(s))
  161034. }
  161035. ,DEFAULT_OPEN_TIMEOUT_MS),
  161036. this._ws.onopen = ()=>{
  161037. var s;
  161038. (s = this._openTimer) == null || s.clear(),
  161039. this.connected = !0,
  161040. this.heartbeat.start(),
  161041. this.network.room.currentNetworkOptions.reconnect || (log$j.infoAndReportMeasurement({
  161042. metric: "wsOpenedAt",
  161043. group: "joinRoom",
  161044. startTime: this.network.room._startTime
  161045. }),
  161046. log$j.infoAndReportMeasurement({
  161047. metric: "wsOpenedCost",
  161048. group: "joinRoom",
  161049. startTime: o
  161050. }))
  161051. }
  161052. ,
  161053. this.handleWSEvent()
  161054. }
  161055. getAddress() {
  161056. const {wsServerUrl: i, reconnect: o, sessionId: s, token: c, roomId: d, userId: _, pageSession: b} = this.network.room.currentNetworkOptions
  161057. , k = this.network.room.skinId;
  161058. let j = i;
  161059. o && (j = j + `?reconnect=true&lastSessionID=${s}`);
  161060. const $ = `userId=${_}&roomId=${d}&pageSession=${b}` + (this.network.room.isHost ? `&skinId=${k}` : "") + (c ? `&token=${c}` : "");
  161061. return j = j.indexOf("?") > -1 ? j + "&" + $ : j + "?" + $,
  161062. j
  161063. }
  161064. handleWSEvent() {
  161065. const i = this._ws;
  161066. i.addEventListener("error", o=>{
  161067. this.connected = !1,
  161068. log$j.error("webscoket error", o),
  161069. this.emit("socketClosed", new InternalError("connect to address error: " + this.network.room.currentNetworkOptions.wsServerUrl))
  161070. }
  161071. ),
  161072. i.addEventListener("close", o=>{
  161073. this.connected = !1,
  161074. this._onClose(o)
  161075. }
  161076. ),
  161077. i.addEventListener("message", o=>{
  161078. if (!o || this._hasTimeout || !this.connected)
  161079. return;
  161080. let s = null;
  161081. try {
  161082. s = JSON.parse(o.data)
  161083. } catch (d) {
  161084. log$j.error(d);
  161085. return
  161086. }
  161087. if (!s)
  161088. return;
  161089. const c = s.id;
  161090. if (!!c)
  161091. switch (c !== "heartbeat" && log$j.info(`receive ws frame: ${o.data}`),
  161092. c) {
  161093. case "fail":
  161094. break;
  161095. case "init":
  161096. try {
  161097. const d = s.data.slice(-37, -1);
  161098. reporter.updateBody({
  161099. serverSession: d
  161100. })
  161101. } catch (d) {
  161102. console.error(d)
  161103. }
  161104. this.network.rtcp.start();
  161105. break;
  161106. case "heartbeat":
  161107. this.heartbeat.pong(s.data);
  161108. break;
  161109. case "offer":
  161110. this.network.rtcp.setRemoteDescription(s.data, this.network.stream.el);
  161111. break;
  161112. case "ice_candidate":
  161113. this.network.rtcp.addCandidate(s.data);
  161114. break;
  161115. case "start":
  161116. this.emit("gameRoomAvailable", s);
  161117. break;
  161118. case "error":
  161119. try {
  161120. const {Code: d, Msg: _} = JSON.parse(s.data);
  161121. if (d) {
  161122. if (d == 3003)
  161123. return this.emit("socketClosed", new TokenExpiredError);
  161124. if (authenticationErrorCodes.indexOf(d) > -1)
  161125. return this.emit("socketClosed", new AuthenticationError("\u9274\u6743\u9519\u8BEF:" + _));
  161126. {
  161127. const b = getErrorByCode(d);
  161128. this.emit("socketClosed", new b(_))
  161129. }
  161130. }
  161131. } catch (d) {
  161132. const _ = new InternalError("JSON.parse websocket data error: " + s.data);
  161133. log$j.error(d, _),
  161134. this.emit("socketClosed", _)
  161135. }
  161136. break;
  161137. case "checkLatency":
  161138. {
  161139. const d = s.packet_id
  161140. , _ = s.data.split(",");
  161141. this.onLatencyCheck({
  161142. packetId: d,
  161143. addresses: _
  161144. });
  161145. break
  161146. }
  161147. default:
  161148. log$j.warn("unkown ws message type", c, s)
  161149. }
  161150. }
  161151. )
  161152. }
  161153. onLatencyCheck(i) {
  161154. const o = [...new Set(i.addresses || [])];
  161155. Promise.all(o.map(s=>({
  161156. [s]: 9999
  161157. }))).then(s=>{
  161158. const c = Object.assign({}, ...s);
  161159. this.latency(c, i.packetId)
  161160. }
  161161. )
  161162. }
  161163. wsNoReady() {
  161164. return this._ws.readyState == WebSocket.CLOSED || this._ws.readyState == WebSocket.CLOSING || this._ws.readyState == WebSocket.CONNECTING
  161165. }
  161166. prepareReconnect() {
  161167. this._close({
  161168. code: WS_CLOSE_RECONNECT,
  161169. reason: "reconnect"
  161170. })
  161171. }
  161172. _onClose({code: i, reason: o}) {
  161173. this._openTimer && this._openTimer.clear(),
  161174. log$j.warn(`ws closed: ${i} ` + o),
  161175. [WS_CLOSE_RECONNECT, WS_CLOSE_NORMAL].includes(i) || this.emit("socketClosed", new InternalError("Websocket error"))
  161176. }
  161177. _close({code: i, reason: o}) {
  161178. var s;
  161179. (s = this._ws) == null || s.close(i, o)
  161180. }
  161181. quit() {
  161182. this._close({
  161183. code: WS_CLOSE_NORMAL,
  161184. reason: "quit"
  161185. })
  161186. }
  161187. }
  161188. const log$i = new Logger("stream");
  161189. class Stream {
  161190. constructor(e) {
  161191. Tt(this, "el");
  161192. Tt(this, "_streamPlayTimer", null);
  161193. Tt(this, "play", ()=>new Promise((e,i)=>{
  161194. this._streamPlayTimer = new Timeout(()=>{
  161195. i(new InternalError("Stream play timeout"))
  161196. }
  161197. ,5e3),
  161198. this.el && this.el.play().then(()=>{
  161199. var o;
  161200. e(),
  161201. log$i.info("Media can autoplay"),
  161202. (o = this._streamPlayTimer) == null || o.clear()
  161203. }
  161204. ).catch(o=>{
  161205. var s;
  161206. log$i.error("Media Failed to autoplay"),
  161207. log$i.error(o),
  161208. i(new InternalError("Media Failed to autoplay")),
  161209. (s = this._streamPlayTimer) == null || s.clear()
  161210. }
  161211. )
  161212. }
  161213. ));
  161214. if (!e) {
  161215. this.el = this.createVideoElement();
  161216. return
  161217. }
  161218. this.el = e
  161219. }
  161220. createVideoElement() {
  161221. const e = document.createElement("video");
  161222. return e.muted = !0,
  161223. e.autoplay = !1,
  161224. e.playsInline = !0,
  161225. e.setAttribute("autostart", "false"),
  161226. e.setAttribute("controls", "controls"),
  161227. e.setAttribute("muted", "true"),
  161228. e.setAttribute("preload", "auto"),
  161229. e.setAttribute("hidden", "hidden"),
  161230. document.body.appendChild(e),
  161231. e
  161232. }
  161233. }
  161234. const log$h = new Logger("NetworkController")
  161235. , hr = class extends EventEmitter {
  161236. constructor(i) {
  161237. super();
  161238. Tt(this, "socket");
  161239. Tt(this, "rtcp");
  161240. Tt(this, "stream");
  161241. Tt(this, "_state", "connecting");
  161242. Tt(this, "_networkMonitor");
  161243. Tt(this, "reconnectCount", 0);
  161244. Tt(this, "startGame", ()=>new Promise((i,o)=>{
  161245. if (!this.rtcp.connected)
  161246. return o(new InternalError("Game cannot load. Please refresh"));
  161247. if (!this.rtcp.inputReady)
  161248. return o(new InternalError("Game is not ready yet. Please wait"));
  161249. this.socket.on("gameRoomAvailable", s=>{
  161250. this.setState("connected"),
  161251. i(s),
  161252. this.rtcp.heartbeat.start()
  161253. }
  161254. ),
  161255. this.socket.on("socketClosed", s=>{
  161256. o(s)
  161257. }
  161258. ),
  161259. this.socket.startGame()
  161260. }
  161261. ));
  161262. this.room = i,
  161263. this.socket = new Socket(this),
  161264. this.rtcp = new Rtcp(this),
  161265. this.stream = new Stream,
  161266. this._networkMonitor = new NetworkMonitor(()=>{
  161267. log$h.info("network changed, online:", this._networkMonitor.isOnline),
  161268. this._state === "disconnected" && this._networkMonitor.isOnline && (log$h.info("network back to online, try to reconnect"),
  161269. this.reconnect())
  161270. }
  161271. ),
  161272. checkNetworkQuality(this.room.currentNetworkOptions.wsServerUrl),
  161273. this._networkMonitor.start(),
  161274. new VisibilityChangeHandler().subscribe(s=>{
  161275. var c, d;
  161276. s ? ((d = this.room.stats) == null || d.disable(),
  161277. this.room.pageHideHandler(),
  161278. log$h.infoAndReportMeasurement({
  161279. metric: "pageHide",
  161280. startTime: Date.now()
  161281. })) : ((c = this.room.stats) == null || c.enable(),
  161282. this.room.pageShowHandler(),
  161283. log$h.infoAndReportMeasurement({
  161284. metric: "pageShow",
  161285. startTime: Date.now(),
  161286. extra: {
  161287. state: this._state
  161288. }
  161289. }),
  161290. this._state === "disconnected" && this.reconnect())
  161291. }
  161292. )
  161293. }
  161294. setState(i) {
  161295. this._state !== i && (this._state === "closed" && !hr.ALLOW_RECONNECT_AFTER_QUIT || (log$h.info("Set network state to ", i),
  161296. this._state = i))
  161297. }
  161298. async connectAndStart(i) {
  161299. return this.connect(i).then(this.startGame)
  161300. }
  161301. async connect(i=!1) {
  161302. return this.room.updateCurrentNetworkOptions({
  161303. reconnect: i
  161304. }),
  161305. new Promise((o,s)=>{
  161306. this.rtcp.on("rtcConnected", ()=>{
  161307. this.setState("connected"),
  161308. o()
  161309. }
  161310. ),
  161311. this.rtcp.on("rtcDisconnected", ()=>{
  161312. log$h.info("rtc disconnected"),
  161313. this._state === "connecting" ? (this.setState("disconnected"),
  161314. s(new InternalError("rtc connect failed"))) : (this.setState("disconnected"),
  161315. log$h.info("rtc disconnected, start to reconnect"),
  161316. this.reconnect())
  161317. }
  161318. ),
  161319. this.socket.on("socketQuit", ()=>{
  161320. log$h.info("socket quit success"),
  161321. this.setState("closed")
  161322. }
  161323. ),
  161324. this.socket.on("socketClosed", c=>{
  161325. this._state === "connecting" && (this.setState("disconnected"),
  161326. s(c)),
  161327. s(c)
  161328. }
  161329. ),
  161330. this.socket.start()
  161331. }
  161332. )
  161333. }
  161334. reconnect() {
  161335. const i = Date.now();
  161336. if (this.reconnectCount++,
  161337. this.reconnectCount > MAX_RECONNECT_COUNT) {
  161338. log$h.error("reconnect failed, reached max reconnect count", MAX_RECONNECT_COUNT),
  161339. this.reconnectCount = 0,
  161340. this.emit("stateChanged", {
  161341. state: "disconnected"
  161342. });
  161343. return
  161344. }
  161345. return log$h.info("start reconnect, count:", this.reconnectCount),
  161346. this._reconnect().then(()=>{
  161347. log$h.infoAndReportMeasurement({
  161348. startTime: i,
  161349. metric: "reconnect"
  161350. })
  161351. }
  161352. ).catch(o=>{
  161353. if (log$h.infoAndReportMeasurement({
  161354. startTime: i,
  161355. metric: "reconnect",
  161356. error: o
  161357. }),
  161358. (o == null ? void 0 : o.code) === Codes$1.RepeatLogin) {
  161359. this.room.handleRepetLogin();
  161360. return
  161361. }
  161362. const s = 1e3;
  161363. log$h.info("reconnect failed, wait " + s + " ms for next reconnect"),
  161364. setTimeout(()=>{
  161365. this.reconnect()
  161366. }
  161367. , s)
  161368. }
  161369. )
  161370. }
  161371. _reconnect() {
  161372. return this._state === "closed" ? (log$h.warn("connection closed already"),
  161373. Promise.reject()) : this._state === "connecting" ? (log$h.warn("connection is already in connecting state"),
  161374. Promise.reject()) : this._state !== "disconnected" ? Promise.reject() : (this.prepareReconnect(),
  161375. this._state = "connecting",
  161376. this.emit("stateChanged", {
  161377. state: "reconnecting",
  161378. count: this.reconnectCount
  161379. }),
  161380. this.socket.off("gameRoomAvailable"),
  161381. this.socket.off("socketClosed"),
  161382. this.rtcp.off("rtcDisconnected"),
  161383. this.rtcp.off("rtcConnected"),
  161384. this.connectAndStart(!0).then(({session_id: i})=>{
  161385. this.room.updateCurrentNetworkOptions({
  161386. sessionId: i
  161387. }),
  161388. reporter.updateBody({
  161389. serverSession: i
  161390. }),
  161391. log$h.info("reconnect success"),
  161392. this.setState("connected"),
  161393. this.reconnectCount = 0,
  161394. this.emit("stateChanged", {
  161395. state: "reconnected"
  161396. })
  161397. }
  161398. ))
  161399. }
  161400. prepareReconnect() {
  161401. this.rtcp.disconnect(),
  161402. this.socket.prepareReconnect(),
  161403. this.prepareReconnectOptions()
  161404. }
  161405. prepareReconnectOptions() {
  161406. const {camera: i, player: o} = this.room.currentClickingState || {};
  161407. i && o && this.room.updateCurrentNetworkOptions({
  161408. camera: i,
  161409. player: o
  161410. })
  161411. }
  161412. sendRtcData(i) {
  161413. this.rtcp.sendData(i)
  161414. }
  161415. sendSocketData(i) {
  161416. log$h.debug("ws send ->", i),
  161417. this.socket.send(i)
  161418. }
  161419. quit() {
  161420. const i = uuid$1()
  161421. , o = {
  161422. action_type: Actions.Exit,
  161423. trace_id: i,
  161424. exit_action: {},
  161425. user_id: this.room.options.userId,
  161426. packet_id: i
  161427. };
  161428. this.setState("closed"),
  161429. this.socket.quit(),
  161430. this.sendRtcData(o)
  161431. }
  161432. }
  161433. ;
  161434. let NetworkController = hr;
  161435. Tt(NetworkController, "ALLOW_RECONNECT_AFTER_QUIT", !0);
  161436. let DecodeFunctionTimeList = []
  161437. , SDKFunctionTimeList = []
  161438. , EngineFunctionTimeList = []
  161439. , OtherFunctionTimeList = []
  161440. , HeavyFunctionList = [];
  161441. function getSum(a) {
  161442. let e = 0;
  161443. for (let i = 0; i < a.length; i++)
  161444. e += a[i];
  161445. return e || 0
  161446. }
  161447. function getMax(a) {
  161448. let e = 0;
  161449. for (let i = 0; i < a.length; i++)
  161450. e < a[i] && (e = a[i]);
  161451. return e
  161452. }
  161453. function getFuncStat() {
  161454. const a = {
  161455. sum: getSum(DecodeFunctionTimeList),
  161456. max: getMax(DecodeFunctionTimeList)
  161457. }
  161458. , e = {
  161459. sum: getSum(SDKFunctionTimeList),
  161460. max: getMax(SDKFunctionTimeList)
  161461. }
  161462. , i = {
  161463. sum: getSum(EngineFunctionTimeList),
  161464. max: getMax(EngineFunctionTimeList)
  161465. }
  161466. , o = {
  161467. sum: getSum(OtherFunctionTimeList),
  161468. max: getMax(OtherFunctionTimeList)
  161469. }
  161470. , s = HeavyFunctionList;
  161471. return DecodeFunctionTimeList = [],
  161472. SDKFunctionTimeList = [],
  161473. EngineFunctionTimeList = [],
  161474. OtherFunctionTimeList = [],
  161475. HeavyFunctionList = [],
  161476. {
  161477. function: s,
  161478. decode: a,
  161479. sdk: e,
  161480. engine: i,
  161481. other: o
  161482. }
  161483. }
  161484. const SAMPLES_LENGTH = 10
  161485. , log$g = new Logger("stats")
  161486. , numberFormat = new Intl.NumberFormat(window.navigator.language,{
  161487. maximumFractionDigits: 0
  161488. });
  161489. class Stats extends EventEmitter {
  161490. constructor(i) {
  161491. super();
  161492. Tt(this, "_netInterval", null);
  161493. Tt(this, "_disabled", !1);
  161494. Tt(this, "_aggregatedStats", {});
  161495. Tt(this, "isNetworkGood", !0);
  161496. Tt(this, "_displayElements", {});
  161497. Tt(this, "showStatus", {
  161498. default: !1,
  161499. extra: !1
  161500. });
  161501. Tt(this, "_extraStats", {});
  161502. Tt(this, "_networkSamples", []);
  161503. Tt(this, "externalStats");
  161504. Tt(this, "constructedTime");
  161505. Tt(this, "_interval");
  161506. this.room = i,
  161507. this.constructedTime = Date.now(),
  161508. this._interval = window.setInterval(()=>{
  161509. if (this._disabled || !i.joined)
  161510. return;
  161511. this.onStats(i.networkController.rtcp.workers.uploadDataToServer());
  161512. const o = i.signal.getSignalStat()
  161513. , s = i.sceneManager.engineRunTimeStats
  161514. , c = s.timeArray_addAvatarToScene.getStat()
  161515. , d = s.timeArray_loadStaticMesh.getStat()
  161516. , _ = s.timeArray_updateStaticMesh.getStat();
  161517. this._aggregatedStats.engineCPUSum = c.sum + d.sum + _.sum,
  161518. this._aggregatedStats.engineCPUMax = Math.max(c.max, d.max, _.max),
  161519. this._aggregatedStats.sdkSignalPartial = o.partialMax.toString(),
  161520. this._aggregatedStats.sdkCPUAvg = o.sdkAvg,
  161521. this._aggregatedStats.sdkCPUMax = o.sdkMax,
  161522. this._aggregatedStats.sdkBlobSum = o.blobSum,
  161523. this._aggregatedStats.sdkBlobMax = o.blobMax;
  161524. const k = getFuncStat().function;
  161525. let j = "<br />";
  161526. for (let$ = 0; $ < k.length; $++)
  161527. j += k[$].name + ": " + k[$].time.toFixed(0) + "<br />";
  161528. this._aggregatedStats.heavyFunc = j
  161529. }
  161530. , 1e3),
  161531. this._netInterval = window.setInterval(()=>{
  161532. this.checkNetworkQuality()
  161533. }
  161534. , DURATION * 1e3)
  161535. }
  161536. get isShow() {
  161537. return this.showStatus.default || this.showStatus.extra
  161538. }
  161539. isStatsShow(i="default") {
  161540. return this.showStatus[i]
  161541. }
  161542. assign(i) {
  161543. Object.assign(this._extraStats, i),
  161544. ((i == null ? void 0 : i.hb) || (i == null ? void 0 : i.rtt)) && this.startStatsNetSamples()
  161545. }
  161546. appendExternalStats(i) {
  161547. const o = {};
  161548. if (!i || typeof i != "object") {
  161549. console.warn("appendExternalStats should be plain object");
  161550. return
  161551. }
  161552. Object.keys(i).forEach(s=>{
  161553. Object.prototype.hasOwnProperty.call(this._aggregatedStats, s) ? console.warn(`${s} is duplicate with internal stats`) : o[s] = i[s]
  161554. }
  161555. ),
  161556. !(Object.keys(o).length > 10) && (this.externalStats = o)
  161557. }
  161558. getRtt() {
  161559. const i = this._extraStats.rtt;
  161560. return typeof i != "number" ? 0 : i > 999 ? 999 : i
  161561. }
  161562. enable() {
  161563. this._disabled = !1
  161564. }
  161565. disable() {
  161566. this._disabled = !0
  161567. }
  161568. disableNet() {
  161569. this._netInterval && window.clearInterval(this._netInterval)
  161570. }
  161571. show(i="default") {
  161572. this.showStatus[i] = !0,
  161573. this._render(i)
  161574. }
  161575. hide(i="default") {
  161576. this.showStatus[i] = !1;
  161577. const o = this._displayElements[i];
  161578. o && document.body.removeChild(o),
  161579. this._displayElements[i] = null
  161580. }
  161581. checkNetworkQuality() {
  161582. if (this._networkSamples.length < SAMPLES_LENGTH || this.room.networkController._state !== "connected")
  161583. return;
  161584. const o = this._networkSamples.map($=>this.isNetDelay($, "rtt"))
  161585. , s = this._networkSamples.map($=>this.isNetDelay($, "hb"))
  161586. , c = o.reduce(($,_e)=>$ + _e, 0)
  161587. , d = s.reduce(($,_e)=>$ + _e, 0)
  161588. , _ = Math.floor(c / this._networkSamples.length) * 100
  161589. , b = Math.floor(d / this._networkSamples.length) * 100
  161590. , k = 70;
  161591. let j = !0;
  161592. (_ >= k || b >= k) && (j = !1),
  161593. this.isNetworkGood = j,
  161594. this.emit("networkQuality", {
  161595. good: j
  161596. }),
  161597. j || this.emit("weakNetwork"),
  161598. this.isNetworkGood !== j && log$g.infoAndReportMeasurement({
  161599. metric: "networkQualityChange",
  161600. startTime: Date.now(),
  161601. extra: {
  161602. msg: this._networkSamples,
  161603. netDelayRTTValues: c,
  161604. netDelayHBValues: d,
  161605. isNetworkGood: j
  161606. }
  161607. })
  161608. }
  161609. startStatsNetSamples() {
  161610. const {rtt: i, hb: o} = this._extraStats;
  161611. if (i || o) {
  161612. const s = {
  161613. rtt: i,
  161614. hb: o,
  161615. time: Date.now()
  161616. };
  161617. this._networkSamples.unshift(s),
  161618. this._networkSamples.splice(SAMPLES_LENGTH)
  161619. }
  161620. }
  161621. isNetDelay(i, o) {
  161622. return o === "rtt" ? i.rtt > RTT_MAX_VALUE ? 1 : 0 : o === "hb" && i.hb > HB_MAX_VALUE ? 1 : 0
  161623. }
  161624. _render(i) {
  161625. var $, _e, et, tt, rt, it, nt, ot, at, st, ut, ct, lt, ft, ht, pt, dt, _t, mt, vt, yt, Et, At, gt, St, xt, bt, Rt, Mt, Pt, It, Dt, Ct;
  161626. if (!this._aggregatedStats)
  161627. return;
  161628. const o = []
  161629. , s = Date.now() - this.constructedTime
  161630. , c = Math.floor(s / 1e3 % 60)
  161631. , d = Math.floor(s / (1e3 * 60) % 60)
  161632. , _ = Math.floor(s / (1e3 * 60 * 60) % 24)
  161633. , b = _ < 10 ? "0" + _.toString() : _.toString()
  161634. , k = d < 10 ? "0" + d : d
  161635. , j = c < 10 ? "0" + c : c;
  161636. if (o.push({
  161637. key: new Date(Math.floor(this._aggregatedStats.timestamp || 0)).toLocaleString("en-GB"),
  161638. value: b + ":" + k + ":" + j
  161639. }),
  161640. o.push({
  161641. key: "rtt: " + this._extraStats.rtt + " hb: " + this._extraStats.hb,
  161642. value: "FPS: " + this._extraStats.fps + " avatar: " + (($ = this.room._userAvatar) == null ? void 0 : $.state)
  161643. }),
  161644. o.push({
  161645. key: "SDK: " + Xverse$1.SUB_PACKAGE_VERSION,
  161646. value: "ENGINE:" + VERSION$1 + " uid:" + this._extraStats.userId
  161647. }),
  161648. o.push({
  161649. key: "\u540C\u6B65/\u6709\u6548/\u663E\u793A\u73A9\u5BB6",
  161650. value: `${this._extraStats.syncUserNum || 0}/${this._extraStats.userNum || 0}/${this._extraStats.renderedUserNum || 0}`
  161651. }),
  161652. o.push({
  161653. key: "media/meta bitrate(kbps)",
  161654. value: numberFormat.format(this._aggregatedStats.mediaBitrate || 0) + "/" + numberFormat.format(this._aggregatedStats.metaBitrate || 0)
  161655. }),
  161656. o.push({
  161657. key: ":----------------Decoding---------------",
  161658. value: ""
  161659. }),
  161660. o.push({
  161661. key: "-max/avg decodeTime(ms)",
  161662. value: numberFormat.format(this._aggregatedStats.decodeTimeMaxFrame || 0) + "/" + numberFormat.format(this._aggregatedStats.decodeTimePerFrame || 0)
  161663. }),
  161664. o.push({
  161665. key: "-frmAwait/Lost/Drop",
  161666. value: numberFormat.format(this._aggregatedStats.framesAwait || 0) + "/" + numberFormat.format(this._aggregatedStats.packetsLost || 0) + "/" + numberFormat.format(this._aggregatedStats.packetsDrop || 0) + "/" + numberFormat.format(this._aggregatedStats.updateDropFrame) || 0
  161667. }),
  161668. o.push({
  161669. key: ":----------------FrameLoop-------------",
  161670. value: ""
  161671. }),
  161672. o.push({
  161673. key: "interval(max/avg/>40)",
  161674. value: (((_e = this._extraStats.maxFrameTime) == null ? void 0 : _e.toFixed(1)) || 0) + "/" + (((et = this._extraStats.avgFrameTime) == null ? void 0 : et.toFixed(0)) || 0) + "/" + this._extraStats.engineSloppyCnt
  161675. }),
  161676. o.push({
  161677. key: "systemStuck",
  161678. value: this._extraStats.systemStuckCnt
  161679. }),
  161680. o.push({
  161681. key: "--update",
  161682. value: (this._aggregatedStats.maxGraphicTime.toFixed(1) || 0) + "/" + (((tt = this._aggregatedStats.averageGraphicTime) == null ? void 0 : tt.toFixed(0)) || 0)
  161683. }),
  161684. o.push({
  161685. key: "--timeout",
  161686. value: (((rt = this._extraStats.maxTimeoutTime) == null ? void 0 : rt.toFixed(1)) || 0) + "/" + ((it = this._extraStats.avgTimeoutTime) == null ? void 0 : it.toFixed(0)) || 0
  161687. }),
  161688. o.push({
  161689. key: "--render",
  161690. value: (((nt = this._extraStats.maxRenderFrameTime) == null ? void 0 : nt.toFixed(1)) || 0) + "/" + (((ot = this._extraStats.renderFrameTime) == null ? void 0 : ot.toFixed(0)) || 0)
  161691. }),
  161692. o.push({
  161693. key: "---anim/regBR/clip(avg ms)",
  161694. value: (this._extraStats.animationTime.toFixed(2) || 0) + " / " + (this._extraStats.registerBeforeRenderTime.toFixed(2) || 0) + " / " + (this._extraStats.meshSelectTime.toFixed(2) || 0)
  161695. }),
  161696. o.push({
  161697. key: "---anim/regBR/clip(max ms)",
  161698. value: (this._extraStats.maxAnimationTime.toFixed(2) || 0) + " / " + (this._extraStats.maxRegisterBeforeRenderTime.toFixed(2) || 0) + " / " + (this._extraStats.maxMeshSelectTime.toFixed(2) || 0)
  161699. }),
  161700. o.push({
  161701. key: "---rTR/drC/regAF(avg ms)",
  161702. value: (this._extraStats.renderTargetRenderTime.toFixed(2) || 0) + " / " + (this._extraStats.drawcallTime.toFixed(2) || 0) + " / " + (this._extraStats.registerAfterRenderTime.toFixed(2) || 0)
  161703. }),
  161704. o.push({
  161705. key: "---rTR/drC/regAF(max ms)",
  161706. value: (this._extraStats.maxRenderTargetRenderTime.toFixed(2) || 0) + " / " + (this._extraStats.maxDrawcallTime.toFixed(2) || 0) + " / " + (this._extraStats.maxRegisterAfterRenderTime.toFixed(2) || 0)
  161707. }),
  161708. o.push({
  161709. key: "--tri/drC/pati/bones/anim(Num)",
  161710. value: (this._extraStats.triangle || 0) + " / " + (this._extraStats.drawcall.toFixed(0) || 0) + " / " + (this._extraStats.activeParticles.toFixed(0) || 0) + " / " + (this._extraStats.activeBones.toFixed(0) || 0) + " / " + (this._extraStats.activeAnimation.toFixed(0) || 0)
  161711. }),
  161712. o.push({
  161713. key: "--rootN/mesh/geo/tex/mat(Num)",
  161714. value: (this._extraStats.totalRootNodes.toFixed(0) || 0) + " / " + (this._extraStats.totalMeshes.toFixed(0) || 0) + " / " + (this._extraStats.totalGeometries.toFixed(0) || 0) + " / " + (this._extraStats.totalTextures.toFixed(0) || 0) + " / " + (this._extraStats.totalMaterials.toFixed(0) || 0)
  161715. }),
  161716. o.push({
  161717. key: "--registerBF/AF(Num)",
  161718. value: (this._extraStats.registerBeforeCount.toFixed(0) || 0) + " / " + (this._extraStats.registerAfterCount.toFixed(0) || 0)
  161719. }),
  161720. o.push({
  161721. key: ":----------------JoyStick----------------------",
  161722. value: ""
  161723. }),
  161724. o.push({
  161725. key: "Total(avg/max)",
  161726. value: (((at = this._aggregatedStats.avgJoyStickOverallTime) == null ? void 0 : at.toFixed(2)) || 0) + "/" + (((st = this._aggregatedStats.maxJoyStickOverallTime) == null ? void 0 : st.toFixed(2)) || 0)
  161727. }),
  161728. o.push({
  161729. key: "--Rsp(avg/max)",
  161730. value: (((ut = this._aggregatedStats.avgJoyStickResponseTime) == null ? void 0 : ut.toFixed(1)) || 0) + "/" + this._aggregatedStats.maxJoyStickResponseTime
  161731. }),
  161732. o.push({
  161733. key: "--Proc(avg/max)",
  161734. value: (((ct = this._aggregatedStats.avgJoyStickProcessTime) == null ? void 0 : ct.toFixed(1)) || 0) + "/" + this._aggregatedStats.maxJoyStickProcessTime
  161735. }),
  161736. o.push({
  161737. key: "--Show(avg/max)",
  161738. value: (((lt = this._aggregatedStats.avgJoyStickDisplayTime) == null ? void 0 : lt.toFixed(1)) || 0) + "/" + this._aggregatedStats.maxJoyStickDisplayTime
  161739. }),
  161740. o.push({
  161741. key: ":----------------Rotation-------------------",
  161742. value: ""
  161743. }),
  161744. o.push({
  161745. key: "Total(ms/miss)",
  161746. value: (((ft = this._aggregatedStats.avgOverallTime) == null ? void 0 : ft.toFixed(2)) || 0) + "/" + (this._aggregatedStats.responseMissPs + this._aggregatedStats.processMissPs + this._aggregatedStats.displayMissPs)
  161747. }),
  161748. o.push({
  161749. key: "--rotateRsp",
  161750. value: (((ht = this._aggregatedStats.avgResponseTime) == null ? void 0 : ht.toFixed(1)) || 0) + "/" + this._aggregatedStats.responseMissPs
  161751. }),
  161752. o.push({
  161753. key: "--rotateProc",
  161754. value: (((pt = this._aggregatedStats.avgProcessTime) == null ? void 0 : pt.toFixed(1)) || 0) + "/" + this._aggregatedStats.processMissPs
  161755. }),
  161756. o.push({
  161757. key: "--rotateShow",
  161758. value: (((dt = this._aggregatedStats.avgDisplayTime) == null ? void 0 : dt.toFixed(1)) || 0) + "/" + this._aggregatedStats.displayMissPs
  161759. }),
  161760. ((_t = this.room._userAvatar) == null ? void 0 : _t.state) == "moving",
  161761. o.push({
  161762. key: ":----------------Move----------------------",
  161763. value: ""
  161764. }),
  161765. o.push({
  161766. key: "-startDelay",
  161767. value: (this._aggregatedStats.moveEvent == "MoveTo" ? this._aggregatedStats.moveResponseDelay || 0 : this._aggregatedStats.flyResponseDelay || 0) + "/" + (this._aggregatedStats.moveEvent == "MoveTo" ? this._aggregatedStats.moveProcessDelay || 0 : this._aggregatedStats.flyProcessDelay || 0) + "/" + (this._aggregatedStats.moveEvent == "MoveTo" ? this._aggregatedStats.moveDisplayDelay || 0 : this._aggregatedStats.flyDisplayDelay || 0)
  161768. }),
  161769. (((mt = this.room._userAvatar) == null ? void 0 : mt.state) == "moving" || this._aggregatedStats.moveEvent == "GetOnAirship" || this._aggregatedStats.moveEvent == "GetOnVehicle") && o.push({
  161770. key: "-srvInterFrm(max/avg)",
  161771. value: (this._aggregatedStats.maxServerDiff || 0) + "/" + (this._aggregatedStats.avgServerDiff.toFixed(1) || 0)
  161772. }),
  161773. o.push({
  161774. key: "-interFrameDelay",
  161775. value: "(max/avg/jank)"
  161776. }),
  161777. o.push({
  161778. key: "--toDisplay",
  161779. value: (this._aggregatedStats.moveEvent == "MoveTo" ? this._aggregatedStats.maxDisplayMoveDiff || 0 : this._aggregatedStats.maxDisplayFlyDiff || 0) + "/" + (this._aggregatedStats.moveEvent == "MoveTo" ? this._aggregatedStats.avgDisplayMoveDiff.toFixed(1) || 0 : this._aggregatedStats.avgDisplayFlyDiff.toFixed(1) || 0) + "/" + (this._aggregatedStats.moveEvent == "MoveTo" ? ((vt = this._aggregatedStats.moveDisplayJank) == null ? void 0 : vt.toFixed(3)) || 0 : ((yt = this._aggregatedStats.flyDisplayJank) == null ? void 0 : yt.toFixed(3)) || 0)
  161780. }),
  161781. o.push({
  161782. key: "--received",
  161783. value: (this._aggregatedStats.moveEvent == "MoveTo" ? this._aggregatedStats.maxResponseMoveDiff || 0 : this._aggregatedStats.maxResponseFlyDiff || 0) + "/" + (this._aggregatedStats.moveEvent == "MoveTo" ? this._aggregatedStats.avgResponseMoveDiff.toFixed(1) || 0 : this._aggregatedStats.avgResponseFlyDiff.toFixed(1) || 0) + "/" + (this._aggregatedStats.moveEvent == "MoveTo" ? ((Et = this._aggregatedStats.moveResponseJank) == null ? void 0 : Et.toFixed(3)) || 0 : ((At = this._aggregatedStats.flyResponseJank) == null ? void 0 : At.toFixed(3)) || 0)
  161784. }),
  161785. o.push({
  161786. key: "--decoded",
  161787. value: (this._aggregatedStats.moveEvent == "MoveTo" ? this._aggregatedStats.maxProcessMoveDiff || 0 : this._aggregatedStats.maxProcessFlyDiff || 0) + "/" + (this._aggregatedStats.moveEvent == "MoveTo" ? this._aggregatedStats.avgProcessMoveDiff.toFixed(1) || 0 : this._aggregatedStats.avgProcessFlyDiff.toFixed(1) || 0) + "/" + (this._aggregatedStats.moveEvent == "MoveTo" ? ((gt = this._aggregatedStats.moveProcessJank) == null ? void 0 : gt.toFixed(3)) || 0 : ((St = this._aggregatedStats.flyProcessJank) == null ? void 0 : St.toFixed(3)) || 0)
  161788. }),
  161789. o.push({
  161790. key: ":----------------DevInfo-----------------",
  161791. value: ""
  161792. }),
  161793. o.push({
  161794. key: "sd",
  161795. value: (this._aggregatedStats.sdMoveResponseLongTime.toFixed(1) || 0) + "/" + (this._aggregatedStats.sdMoveProcessLongTime.toFixed(1) || 0) + "/" + (this._aggregatedStats.sdMoveDisplayLongTime.toFixed(1) || 0)
  161796. }),
  161797. o.push({
  161798. key: "----hardwareInfo",
  161799. value: this._extraStats.hardwareInfo
  161800. }),
  161801. i === "default")
  161802. this.createAndRender(o, i);
  161803. else {
  161804. const Ot = [];
  161805. Ot.push({
  161806. key: "rtt: " + this._extraStats.rtt + " hb: " + this._extraStats.hb,
  161807. value: ""
  161808. }),
  161809. Ot.push({
  161810. key: ":----------------PerFrame-------------",
  161811. value: ""
  161812. }),
  161813. Ot.push({
  161814. key: "render(max/avg)",
  161815. value: (((xt = this._extraStats.maxRenderFrameTime) == null ? void 0 : xt.toFixed(1)) || 0) + "/" + (((bt = this._extraStats.renderFrameTime) == null ? void 0 : bt.toFixed(2)) || 0)
  161816. }),
  161817. Ot.push({
  161818. key: "update(max/avg)",
  161819. value: (this._aggregatedStats.maxGraphicTime.toFixed(1) || 0) + "/" + (((Rt = this._aggregatedStats.averageGraphicTime) == null ? void 0 : Rt.toFixed(2)) || 0)
  161820. }),
  161821. Ot.push({
  161822. key: "receive(max/avg)",
  161823. value: this._aggregatedStats.decodeCPUMax + "/" + ((Mt = this._aggregatedStats.decodeCPUAvg) == null ? void 0 : Mt.toFixed(2))
  161824. }),
  161825. Ot.push({
  161826. key: "handleSignal(max/avg)",
  161827. value: this._aggregatedStats.sdkCPUMax + "/" + ((Pt = this._aggregatedStats.sdkCPUAvg) == null ? void 0 : Pt.toFixed(2))
  161828. }),
  161829. Ot.push({
  161830. key: ":----------------LowFrequent-------------",
  161831. value: ""
  161832. }),
  161833. Ot.push({
  161834. key: "engine(max/sum)",
  161835. value: this._aggregatedStats.engineCPUMax + "/" + this._aggregatedStats.engineCPUSum
  161836. }),
  161837. Ot.push({
  161838. key: "blob(max/sum)",
  161839. value: this._aggregatedStats.sdkBlobMax + "/" + this._aggregatedStats.sdkBlobSum
  161840. }),
  161841. ((It = this.room._userAvatar) == null ? void 0 : It.state) == "moving",
  161842. Ot.push({
  161843. key: ":----------------Move----------------------",
  161844. value: ""
  161845. }),
  161846. (((Dt = this.room._userAvatar) == null ? void 0 : Dt.state) == "moving" || this._aggregatedStats.moveEvent == "GetOnAirship" || this._aggregatedStats.moveEvent == "GetOnVehicle") && Ot.push({
  161847. key: "-srvInterFrm(max/avg)",
  161848. value: (this._aggregatedStats.maxServerDiff || 0) + "/" + (this._aggregatedStats.avgServerDiff.toFixed(1) || 0)
  161849. }),
  161850. Ot.push({
  161851. key: "-interFrameDelay",
  161852. value: "(max/avg)"
  161853. }),
  161854. Ot.push({
  161855. key: "--received",
  161856. value: (this._aggregatedStats.moveEvent == "MoveTo" ? this._aggregatedStats.maxResponseMoveDiff || 0 : this._aggregatedStats.maxResponseFlyDiff || 0) + "/" + (this._aggregatedStats.moveEvent == "MoveTo" ? this._aggregatedStats.avgResponseMoveDiff.toFixed(1) || 0 : this._aggregatedStats.avgResponseFlyDiff.toFixed(1) || 0)
  161857. }),
  161858. Ot.push({
  161859. key: "postMsg",
  161860. value: this._aggregatedStats.postMsgMaxTime || 0
  161861. }),
  161862. Ot.push({
  161863. key: "timeoutGap",
  161864. value: ((Ct = this._extraStats.maxTimeoutGap) == null ? void 0 : Ct.toFixed(1)) || 0
  161865. }),
  161866. Ot.push({
  161867. key: ":----------------DevInfo-------------",
  161868. value: ""
  161869. }),
  161870. Ot.push({
  161871. key: "handleSignalPartial",
  161872. value: this._aggregatedStats.sdkSignalPartial || ""
  161873. }),
  161874. Ot.push({
  161875. key: "heavyFunc",
  161876. value: this._aggregatedStats.heavyFunc || ""
  161877. }),
  161878. this.createAndRender(Ot, i)
  161879. }
  161880. }
  161881. createAndRender(i, o="default") {
  161882. if (!this._displayElements[o]) {
  161883. const c = document.createElement("div");
  161884. this._displayElements[o] = c,
  161885. c.style.position = "absolute",
  161886. c.style.top = "10px",
  161887. c.style.left = "120px",
  161888. c.style.width = "200px",
  161889. c.style.backgroundColor = "rgba(0,0,0,.5)",
  161890. c.style.color = "white",
  161891. c.style.textAlign = "left",
  161892. c.style.fontSize = "8px",
  161893. c.style.lineHeight = "10px",
  161894. document.body.appendChild(c)
  161895. }
  161896. let s = "";
  161897. for (const c of i)
  161898. s += `<div><span>${c.key}</span>: <span>${c.value}</span> </div>`;
  161899. this._displayElements[o].innerHTML = s
  161900. }
  161901. onStats(i) {
  161902. var _;
  161903. if (!i)
  161904. return;
  161905. const o = {}
  161906. , s = this;
  161907. s._aggregatedStats || (s._aggregatedStats = {}),
  161908. o.timestamp = i.timestamp,
  161909. o.mediaBytesReceived = i.mediaBytesReceived,
  161910. o.metaBytesReceived = i.metaBytesReceived,
  161911. o.packetsLost = i.packetsLost,
  161912. o.frameHeight = i.frameHeight,
  161913. o.frameWidth = i.frameWidth,
  161914. o.framesReceivedUI = i.framesReceived,
  161915. o.framesReceived = i.framesReceivedWorker,
  161916. o.framesDecoded = i.framesDecoded,
  161917. o.framesEmited = i.framesEmited,
  161918. o.decodeTimePerFrame = i.decodeTimePerFrame,
  161919. o.decodeTimeMaxFrame = i.decodeTimeMaxFrame,
  161920. o.packetsDrop = i.packetsDrop,
  161921. o.framesAwait = i.framesAwait,
  161922. o.updateDropFrame = i.updateDropFrame,
  161923. o.firstMediaArraval = i.firstMediaArraval,
  161924. o.firstYUVDecoded = i.firstYUVDecoded,
  161925. o.firstRender = i.firstRender,
  161926. o.returnFrames = i.returnFrames,
  161927. o.sendOutBuffer = i.sendOutBuffer,
  161928. o.averageGraphicTime = i.averageGraphicTime,
  161929. o.maxGraphicTime = i.maxGraphicTime,
  161930. o.jankTimes = i.jankTimes,
  161931. o.bigJankTimes = i.bigJankTimes,
  161932. o.decodeJankTimes = i.decodeJankTimes,
  161933. o.bigDecodeJankTimes = i.bigDecodeJankTimes,
  161934. o.serverFrameFast = i.serverFrameFast,
  161935. o.serverFrameSlow = i.serverFrameSlow,
  161936. o.clientFrameFast = i.clientFrameFast,
  161937. o.clientFrameSlow = i.clientFrameSlow,
  161938. o.rtcMessageReceived = i.rtcMessageReceived,
  161939. o.rtcBytesReceived = i.rtcBytesReceived,
  161940. o.receiveIframes = i.receiveIframes,
  161941. o.decodeIframes = i.decodeIframes,
  161942. o.avgResponseTime = i.avgResponseTime,
  161943. o.avgProcessTime = i.avgProcessTime,
  161944. o.avgDisplayTime = i.avgDisplayTime,
  161945. o.avgOverallTime = i.avgOverallTime,
  161946. o.overallTimeCount = i.overallTimeCount,
  161947. o.responseMiss = i.responseMiss,
  161948. o.processMiss = i.processMiss,
  161949. o.displayMiss = i.displayMiss,
  161950. o.avgResponseMoveDiff = i.avgResponseMoveDiff,
  161951. o.avgProcessMoveDiff = i.avgProcessMoveDiff,
  161952. o.avgDisplayMoveDiff = i.avgDisplayMoveDiff,
  161953. o.maxResponseMoveDiff = i.maxResponseMoveDiff,
  161954. o.maxProcessMoveDiff = i.maxProcessMoveDiff,
  161955. o.maxDisplayMoveDiff = i.maxDisplayMoveDiff,
  161956. o.moveResponseDelay = i.moveResponseDelay,
  161957. o.moveProcessDelay = i.moveProcessDelay,
  161958. o.moveDisplayDelay = i.moveDisplayDelay,
  161959. o.moveResponseJank = i.moveResponseJank,
  161960. o.moveProcessJank = i.moveProcessJank,
  161961. o.moveDisplayJank = i.moveDisplayJank,
  161962. o.avgMetaParseTime = i.avgMetaParseTime,
  161963. o.maxMetaParseTime = i.maxMetaParseTime,
  161964. o.moveResponseCounts = i.moveResponseCounts,
  161965. o.moveProcessCounts = i.moveProcessCounts,
  161966. o.moveDisplayCounts = i.moveDisplayCounts,
  161967. o.MoveDisplayCountGood = i.MoveDisplayCountGood,
  161968. o.MoveDisplayCountWell = i.MoveDisplayCountWell,
  161969. o.MoveDisplayCountFair = i.MoveDisplayCountFair,
  161970. o.MoveDisplayCountBad = i.MoveDisplayCountBad,
  161971. o.MoveDisplayCountRest = i.MoveDisplayCountRest,
  161972. o.avgServerDiff = i.avgServerDiff,
  161973. o.maxServerDiff = i.maxServerDiff,
  161974. o.avgResponseFlyDiff = i.avgResponseFlyDiff,
  161975. o.avgProcessFlyDiff = i.avgProcessFlyDiff,
  161976. o.avgDisplayFlyDiff = i.avgDisplayFlyDiff,
  161977. o.maxResponseFlyDiff = i.maxResponseFlyDiff,
  161978. o.maxProcessFlyDiff = i.maxProcessFlyDiff,
  161979. o.maxDisplayFlyDiff = i.maxDisplayFlyDiff,
  161980. o.flyResponseCounts = i.flyResponseCounts,
  161981. o.flyProcessCounts = i.flyProcessCounts,
  161982. o.flyDisplayCounts = i.flyDisplayCounts,
  161983. o.flyResponseJank = i.flyResponseJank,
  161984. o.flyProcessJank = i.flyProcessJank,
  161985. o.flyDisplayJank = i.flyDisplayJank,
  161986. o.flyResponseDelay = i.flyResponseDelay,
  161987. o.flyProcessDelay = i.flyProcessDelay,
  161988. o.flyDisplayDelay = i.flyDisplayDelay,
  161989. o.moveEvent = i.moveEvent,
  161990. o.sdMoveResponseLongTime = i.sdMoveResponseLongTime,
  161991. o.sdMoveProcessLongTime = i.sdMoveProcessLongTime,
  161992. o.sdMoveDisplayLongTime = i.sdMoveDisplayLongTime,
  161993. o.avgJoyStickResponseTime = i.avgJoyStickResponseTime,
  161994. o.avgJoyStickProcessTime = i.avgJoyStickProcessTime,
  161995. o.avgJoyStickDisplayTime = i.avgJoyStickDisplayTime,
  161996. o.avgJoyStickOverallTime = i.avgJoyStickOverallTime,
  161997. o.maxJoyStickResponseTime = i.maxJoyStickResponseTime,
  161998. o.maxJoyStickProcessTime = i.maxJoyStickProcessTime,
  161999. o.maxJoyStickDisplayTime = i.maxJoyStickDisplayTime,
  162000. o.maxJoyStickOverallTime = i.maxJoyStickOverallTime;
  162001. const c = i.unmarshalStreamStat
  162002. , d = i.receiveYUVStat;
  162003. o.decodeCPUMax = Math.max(c.max, d.max),
  162004. o.decodeCPUAvg = c.avg + d.avg,
  162005. o.postMsgMaxTime = i.maxPostMsgDiff,
  162006. s._aggregatedStats && s._aggregatedStats.timestamp && (o.mediaBitrate = 8 * (o.mediaBytesReceived - s._aggregatedStats.mediaBytesReceived) / 1e3,
  162007. o.mediaBitrate = Math.round(o.mediaBitrate || 0),
  162008. o.metaBitrate = 8 * (o.metaBytesReceived - s._aggregatedStats.metaBytesReceived) / 1e3,
  162009. o.metaBitrate = Math.round(o.metaBitrate || 0),
  162010. o.rtcMessagePs = o.rtcMessageReceived - s._aggregatedStats.rtcMessageReceived,
  162011. o.rtcBitrate = 8 * (o.rtcBytesReceived - s._aggregatedStats.rtcBytesReceived) / 1e3,
  162012. o.rtcBitrate = Math.round(o.rtcBitrate || 0),
  162013. o.framesEmitedPs = o.framesEmited - s._aggregatedStats.framesEmited,
  162014. o.framesEmitedPs = Math.round(o.framesEmitedPs || 0),
  162015. o.framesReceivedPs = o.framesReceived - s._aggregatedStats.framesReceived,
  162016. o.framesReceivedPs = Math.round(o.framesReceivedPs || 0),
  162017. o.framesDecodedPs = o.framesDecoded - s._aggregatedStats.framesDecoded,
  162018. o.framesDecodedPs = Math.round(o.framesDecodedPs || 0),
  162019. o.returnFramesPs = o.returnFrames - s._aggregatedStats.returnFrames,
  162020. o.returnFramesPs = Math.round(o.returnFramesPs || 0),
  162021. o.responseMissPs = o.responseMiss - s._aggregatedStats.responseMiss,
  162022. o.processMissPs = o.processMiss - s._aggregatedStats.processMiss,
  162023. o.displayMissPs = o.displayMiss - s._aggregatedStats.displayMiss,
  162024. o.returnFrames = i.returnFrames),
  162025. this.showStatus.default ? this._render("default") : this.showStatus.extra && this._render("extra"),
  162026. o.registerBeforeRenderTime = this._extraStats.registerBeforeRenderTime,
  162027. o.registerAfterRenderTime = this._extraStats.registerAfterRenderTime,
  162028. o.renderTargetRenderTime = this._extraStats.renderTargetRenderTime,
  162029. o.renderFrameTime = this._extraStats.renderFrameTime,
  162030. o.maxRenderFrameTime = this._extraStats.maxRenderFrameTime,
  162031. o.interFrameTime = this._extraStats.interFrameTime,
  162032. o.animationTime = this._extraStats.animationTime,
  162033. o.meshSelectTime = this._extraStats.meshSelectTime,
  162034. o.drawcall = this._extraStats.drawcall,
  162035. o.drawcallTime = this._extraStats.drawcallTime,
  162036. o.triangle = this._extraStats.triangle,
  162037. o.registerAfterCount = this._extraStats.registerAfterCount,
  162038. o.registerBeforeCount = this._extraStats.registerBeforeCount,
  162039. o.fps = this._extraStats.fps,
  162040. o.rtt = this._extraStats.rtt,
  162041. o.hb = this._extraStats.hb,
  162042. o.avgFrameTime = this._extraStats.avgFrameTime,
  162043. o.avgTimeoutTime = this._extraStats.avgTimeoutTime,
  162044. o.engineSloppyCnt = this._extraStats.engineSloppyCnt,
  162045. o.systemStuckCnt = this._extraStats.systemStuckCnt,
  162046. o.avatarState = (_ = this.room._userAvatar) == null ? void 0 : _.state,
  162047. o.maxFrameTime = this._extraStats.maxFrameTime,
  162048. o.maxTimeoutTime = this._extraStats.maxTimeoutTime,
  162049. o.activeParticles = this._extraStats.activeParticles,
  162050. o.activeBones = this._extraStats.activeBones,
  162051. o.activeAnimation = this._extraStats.activeAnimation,
  162052. o.totalRootNodes = this._extraStats.totalRootNodes,
  162053. o.totalGeometries = this._extraStats.totalGeometries,
  162054. o.totalMeshes = this._extraStats.totalMeshes,
  162055. o.totalTextures = this._extraStats.totalTextures,
  162056. o.totalMaterials = this._extraStats.totalMaterials,
  162057. o.hardwareInfo = this._extraStats.hardwareInfo,
  162058. o.maxInterFrameTime = this._extraStats.maxInterFrameTime,
  162059. o.maxDrawcallTime = this._extraStats.maxDrawcallTime,
  162060. o.maxMeshSelectTime = this._extraStats.maxMeshSelectTime,
  162061. o.maxAnimationTime = this._extraStats.maxAnimationTime,
  162062. o.maxRegisterBeforeRenderTime = this._extraStats.maxRegisterBeforeRenderTime,
  162063. o.maxRegisterAfterRenderTime = this._extraStats.maxRegisterAfterRenderTime,
  162064. o.maxRenderTargetRenderTime = this._extraStats.maxRenderTargetRenderTime,
  162065. this.externalStats && Object.keys(this.externalStats || {}).forEach(b=>{
  162066. o[b] = this.externalStats[b]
  162067. }
  162068. ),
  162069. s._aggregatedStats = o,
  162070. this.emit("stats", {
  162071. stats: o
  162072. })
  162073. }
  162074. }
  162075. const isWebAssemblySupported = ()=>{
  162076. try {
  162077. if (typeof WebAssembly == "object" && typeof WebAssembly.instantiate == "function") {
  162078. const a = new WebAssembly.Module(Uint8Array.of(0, 97, 115, 109, 1, 0, 0, 0));
  162079. if (a instanceof WebAssembly.Module)
  162080. return new WebAssembly.Instance(a)instanceof WebAssembly.Instance
  162081. }
  162082. } catch {}
  162083. return console.log("wasm is not supported"),
  162084. !1
  162085. }
  162086. ;
  162087. function isSupported() {
  162088. return typeof RTCPeerConnection == "function" && isWebAssemblySupported()
  162089. }
  162090. const log$f = new Logger("xverse")
  162091. , er = class {
  162092. constructor(e) {
  162093. Tt(this, "debug", !1);
  162094. Tt(this, "pageSession");
  162095. Tt(this, "preload");
  162096. Tt(this, "appId");
  162097. Tt(this, "releaseId");
  162098. e || (e = {});
  162099. const {onLog: i, env: o, appId: s, releaseId: c, subPackageVersion: d} = e;
  162100. er.NO_CACHE = !1,
  162101. er.env = o || "PROD",
  162102. er.SUB_PACKAGE_VERSION = d,
  162103. this.debug && Logger.setLevel(LoggerLevels.Debug);
  162104. const _ = this.pageSession = uuid$1();
  162105. if (reporter.updateHeader({
  162106. pageSession: _
  162107. }),
  162108. // reporter.updateReportUrl(REPORT_URL[er.env]),
  162109. // d && reporter.updateBody({
  162110. // sdkVersion: d,
  162111. // appId: s
  162112. // }),
  162113. log$f.infoAndReportMeasurement({
  162114. metric: "sdkInit",
  162115. startTime: Date.now(),
  162116. extra: {
  162117. version: d,
  162118. enviroment: o,
  162119. pageSession: _,
  162120. engineVersion: VERSION$1
  162121. }
  162122. }),
  162123. log$f.debug("debug mode:", this.debug),
  162124. reporter.on("report", b=>{
  162125. i && i(b)
  162126. }
  162127. ),
  162128. s) {
  162129. this.appId = s,
  162130. this.releaseId = c;
  162131. const b = ModelManager.getInstance(s, c);
  162132. this.preload = new Preload(b)
  162133. }
  162134. }
  162135. get isSupported() {
  162136. return isSupported()
  162137. }
  162138. disableLogUpload() {
  162139. reporter.disable(),
  162140. log$f.debug("log upload has been disabled")
  162141. }
  162142. async getSkinList() {
  162143. return []
  162144. }
  162145. async getAvatarList() {
  162146. return []
  162147. }
  162148. async getGiftList() {
  162149. return [{
  162150. id: "hack "
  162151. }]
  162152. }
  162153. }
  162154. ;
  162155. let Xverse$1 = er;
  162156. Tt(Xverse$1, "NO_CACHE"),
  162157. Tt(Xverse$1, "USE_TME_CDN"),
  162158. Tt(Xverse$1, "env"),
  162159. Tt(Xverse$1, "SUB_PACKAGE_VERSION");
  162160. const objectParseFloat = a=>{
  162161. const e = {};
  162162. return a && Object.keys(a).forEach(i=>{
  162163. e[i] = parseFloat(a[i])
  162164. }
  162165. ),
  162166. e
  162167. }
  162168. , log$e = new Logger("model-manager")
  162169. , tr = class {
  162170. constructor(e, i) {
  162171. Tt(this, "avatarModelList", []);
  162172. Tt(this, "skinList", []);
  162173. Tt(this, "applicationConfig");
  162174. Tt(this, "config");
  162175. Tt(this, "appId");
  162176. Tt(this, "releaseId");
  162177. this.appId = e,
  162178. this.releaseId = i
  162179. }
  162180. static getInstance(e, i) {
  162181. return tr.instance || (tr.instance = new tr(e,i)),
  162182. tr.instance
  162183. }
  162184. static findModels(e, i, o) {
  162185. return e.filter(c=>c.typeName === i && c.className === o)
  162186. }
  162187. static findModel(e, i, o) {
  162188. const s = e.filter(c=>c.typeName === i && c.className === o)[0];
  162189. return s || null
  162190. }
  162191. async findSkinConfig(e) {
  162192. let i = null;
  162193. if (i = (this.skinList = await this.getSkinsList()).find(s=>s.id === e),
  162194. i)
  162195. return i;
  162196. {
  162197. const s = `skin is invalid: skinId: ${e}`;
  162198. return Promise.reject(new ParamError(s))
  162199. }
  162200. }
  162201. async findRoute(e, i) {
  162202. const s = (await this.findSkinConfig(e)).routeList.find(c=>c.pathName === i);
  162203. if (!s) {
  162204. const c = `find path failed: skinId: ${e}, pathName: ${i}`;
  162205. return Promise.reject(new ParamError(c))
  162206. }
  162207. return log$e.debug("find route success", s),
  162208. s
  162209. }
  162210. async findAssetList(e) {
  162211. const o = (await this.findSkinConfig(e)).assetList;
  162212. if (!o) {
  162213. const s = `find path failed: skinId: ${e}`;
  162214. return Promise.reject(new ParamError(s))
  162215. }
  162216. return log$e.debug("find route success", o),
  162217. o
  162218. }
  162219. async findAsset(e, i, o="id") {
  162220. const s = await this.findSkinConfig(e);
  162221. if (Array.isArray(i))
  162222. return i.map(d=>s.models.find(_=>_[o] === d)).filter(Boolean);
  162223. const c = s.models.find(d=>d[o] === i);
  162224. if (!c) {
  162225. const d = `find asset failed: skinId: ${e}, keyValue: ${i}`;
  162226. return Promise.reject(new ParamError(d))
  162227. }
  162228. return log$e.debug("find asset success", c),
  162229. c
  162230. }
  162231. async findPoint(e, i) {
  162232. const s = (await this.findSkinConfig(e)).pointList.find(c=>c.id === i);
  162233. if (!s) {
  162234. const c = `find point failed: skinId: ${e}, id: ${i}`;
  162235. return Promise.reject(new ParamError(c))
  162236. }
  162237. return log$e.debug("find point success", s),
  162238. s
  162239. }
  162240. async requestConfig() {
  162241. if (this.config)
  162242. return this.config;
  162243. let e = `https://static.xverse.cn/console/config/${this.appId}/config.json`;
  162244. this.releaseId && (e = `https://static.xverse.cn/console/config/${this.appId}/${this.releaseId}/config.json`);
  162245. const i = Xverse$1.USE_TME_CDN ? "https://static.xverse.cn/tmeland/config/tme_config.json" : e;
  162246. try {
  162247. const o = await http$1.get({
  162248. url: `${i}?t=${Date.now()}`,
  162249. key: "config",
  162250. timeout: 6e3,
  162251. retry: 2
  162252. })
  162253. , {config: s, preload: c} = o.data.data || {};
  162254. if (!s)
  162255. throw new Error("config data parse error" + o.data);
  162256. return this.config = {
  162257. config: s,
  162258. preload: c
  162259. },
  162260. log$e.debug("get config success", this.config),
  162261. this.config
  162262. } catch (o) {
  162263. return Promise.reject(o)
  162264. }
  162265. }
  162266. async getApplicationConfig() {
  162267. if (this.applicationConfig)
  162268. return this.applicationConfig;
  162269. try {
  162270. const e = await this.requestConfig();
  162271. return this.applicationConfig = e.config,
  162272. this.applicationConfig
  162273. } catch (e) {
  162274. return Promise.reject(e)
  162275. }
  162276. }
  162277. async getAvatarModelList() {
  162278. if (this.avatarModelList.length)
  162279. return this.avatarModelList;
  162280. try {
  162281. const {avatars: e} = await this.getApplicationConfig();
  162282. return this.avatarModelList = e.map(i=>({
  162283. name: i.name,
  162284. id: i.id,
  162285. modelUrl: i.url,
  162286. gender: i.gender,
  162287. components: i.components
  162288. })),
  162289. this.avatarModelList
  162290. } catch (e) {
  162291. return log$e.error(e),
  162292. Promise.reject(new InitConfigTimeoutError(e || "getAvatarModelList error"))
  162293. }
  162294. }
  162295. async getSkinsList() {
  162296. if (this.skinList.length)
  162297. return this.skinList;
  162298. try {
  162299. const {skins: e} = await this.getApplicationConfig();
  162300. return this.skinList = e.map(i=>{
  162301. var o;
  162302. return {
  162303. name: i.name,
  162304. dataVersion: i.id + i.versionId,
  162305. id: i.id,
  162306. fov: parseInt(i.fov || 90),
  162307. models: i.assetList.map(s=>{
  162308. const {assetId: c, url: d, thumbnailUrl: _, typeName: b, className: k} = s;
  162309. return {
  162310. id: c,
  162311. modelUrl: d,
  162312. name: s.name,
  162313. thumbnailUrl: _,
  162314. typeName: b,
  162315. className: k === "\u4F4E\u6A21" ? "\u7C97\u6A21" : k
  162316. }
  162317. }
  162318. ),
  162319. routeList: (o = i.routeList) == null ? void 0 : o.map(s=>{
  162320. const {areaName: c, attitude: d, id: _, pathName: b, step: k, birthPointList: j} = s;
  162321. return {
  162322. areaName: c,
  162323. attitude: d,
  162324. id: _,
  162325. pathName: b,
  162326. step: k,
  162327. birthPointList: j.map($=>({
  162328. camera: $.camera && {
  162329. position: objectParseFloat($.camera.position),
  162330. angle: objectParseFloat($.camera.rotation)
  162331. },
  162332. player: $.player && {
  162333. position: objectParseFloat($.player.position),
  162334. angle: objectParseFloat($.player.rotation)
  162335. }
  162336. }))
  162337. }
  162338. }
  162339. ),
  162340. pointList: i.pointList.map(s=>Zt($t({}, s), {
  162341. position: objectParseFloat(s.position),
  162342. rotation: objectParseFloat(s.rotation)
  162343. })),
  162344. versionId: i.versionId,
  162345. isEnable: i.isEnable,
  162346. assetList: i.assetList,
  162347. visibleRules: i.visibleRules,
  162348. animationList: i.animationList,
  162349. resolution: i.resolution
  162350. }
  162351. }
  162352. ),
  162353. this.skinList
  162354. } catch (e) {
  162355. return log$e.error(e),
  162356. Promise.reject(new InitConfigTimeoutError(e || "getSkinsList error"))
  162357. }
  162358. }
  162359. async getBreathPointTextrueList() {
  162360. return [{
  162361. url: TEXTURE_URL
  162362. }]
  162363. }
  162364. async findEffectList(e) {
  162365. const o = (await this.findSkinConfig(e)).assetList.filter(s=>s.typeName === "EFFECTS");
  162366. if (!o) {
  162367. const s = `find effect failed: skinId: ${e}`;
  162368. return Promise.reject(new ParamError(s))
  162369. }
  162370. return log$e.debug("find asset success", o),
  162371. o
  162372. }
  162373. }
  162374. ;
  162375. let ModelManager = tr;
  162376. Tt(ModelManager, "instance");
  162377. var AssetTypeName = (a=>(a.Config = "CONFIG",
  162378. a.Model = "MODEL",
  162379. a.Vedio = "VEDIO",
  162380. a.Media = "MEDIA",
  162381. a.Effects = "EFFECTS",
  162382. a.Gift = "GIFT",
  162383. a.Textures = "TEXTURES",
  162384. a))(AssetTypeName || {})
  162385. , AssetClassName = (a=>(a.Effects = "\u7279\u6548",
  162386. a.Tv = "TV",
  162387. a.Lpm = "\u7C97\u6A21",
  162388. a.Reward = "\u571F\u8C6A\u699C",
  162389. a.Env = "\u73AF\u5883\u5149",
  162390. a.Gbq = "\u544A\u767D\u5899",
  162391. a.BreathPoint = "\u547C\u5438\u70B9",
  162392. a.Gifts = "\u9001\u793C",
  162393. a.Panorama = "\u5168\u666F\u56FE",
  162394. a.GiftBubble = "\u9001\u793C\u6C14\u6CE1",
  162395. a.SayBubble = "\u804A\u5929\u6C14\u6CE1",
  162396. a))(AssetClassName || {});
  162397. function mapLimit(a, e, i) {
  162398. return new Promise((o,s)=>{
  162399. const c = a.length;
  162400. let d = e - 1
  162401. , _ = 0;
  162402. const b = k=>{
  162403. k.forEach(j=>{
  162404. i(j).then(()=>{
  162405. if (_++,
  162406. _ === c) {
  162407. o();
  162408. return
  162409. }
  162410. d++;
  162411. const $ = a[d];
  162412. $ && b([$])
  162413. }
  162414. , $=>{
  162415. s($)
  162416. }
  162417. )
  162418. }
  162419. )
  162420. }
  162421. ;
  162422. b(a.slice(0, e))
  162423. }
  162424. )
  162425. }
  162426. const log$d = new Logger("preload");
  162427. class Preload {
  162428. constructor(e) {
  162429. Tt(this, "config");
  162430. Tt(this, "allKeys", []);
  162431. Tt(this, "oldResourcesDeleted", !1);
  162432. Tt(this, "requests", {
  162433. simple: {
  162434. stopped: !0,
  162435. requests: {}
  162436. },
  162437. observer: {
  162438. stopped: !0,
  162439. requests: {}
  162440. },
  162441. full: {
  162442. stopped: !0,
  162443. requests: {}
  162444. }
  162445. });
  162446. this.modelManager = e,
  162447. this.init(e.appId)
  162448. }
  162449. init(e) {
  162450. reporter.updateBody({
  162451. appId: e
  162452. })
  162453. }
  162454. static getTimeoutBySize(e) {
  162455. return e ? e < 500 * 1e3 ? 30 * 1e3 : e < 1e3 * 1e3 ? 60 * 1e3 : 100 * 1e3 : 100 * 1e3
  162456. }
  162457. async getConfig(e) {
  162458. if (this.config)
  162459. return this.config;
  162460. const {preload: i} = await this.modelManager.requestConfig();
  162461. return i ? (this.config = i,
  162462. Promise.resolve(i)) : Promise.reject("no preload config")
  162463. }
  162464. async getAllKeys() {
  162465. if (this.allKeys.length)
  162466. return this.allKeys;
  162467. try {
  162468. const e = await modelTable.getAllKeys()._timeout(3e3, new TimeoutError("db getAllKeys timeout"));
  162469. return this.allKeys = e,
  162470. e
  162471. } catch {
  162472. const i = "preload getAllKeys error";
  162473. return log$d.error(i),
  162474. Promise.reject(i)
  162475. }
  162476. }
  162477. stop(e) {
  162478. e === "serverless" && (e = "observer"),
  162479. this.requests[e].stopped = !0;
  162480. const i = this.requests[e].requests;
  162481. Object.keys(i).forEach(o=>{
  162482. http$1.canceler.removePending(o),
  162483. delete i[o]
  162484. }
  162485. )
  162486. }
  162487. clearPreload(e) {
  162488. this.requests[e].stopped = !1,
  162489. this.allKeys = []
  162490. }
  162491. async start(e, i, o) {
  162492. let s = Date.now()
  162493. , c = 0;
  162494. try {
  162495. if (e === "serverless" && (e = "observer"),
  162496. !this.requests[e])
  162497. return Promise.reject(new ParamError("invalid stage name: " + e));
  162498. this.clearPreload(e);
  162499. const d = await this.getConfig(e);
  162500. let _ = [];
  162501. const b = d.assetUrls.map(et=>et.url);
  162502. try {
  162503. _ = await this.getAllKeys(),
  162504. await this.deleteOldResources(b, _)
  162505. } catch {
  162506. log$d.error("getAllKeys error, deleting db"),
  162507. await modelTable.clearDataBase()
  162508. }
  162509. const {baseUrls: k, assetUrls: j} = d;
  162510. let$;
  162511. switch (e) {
  162512. case "simple":
  162513. $ = k;
  162514. break;
  162515. case "observer":
  162516. $ = j;
  162517. break;
  162518. case "full":
  162519. $ = j;
  162520. break;
  162521. default:
  162522. $ = j
  162523. }
  162524. let _e = $.filter(et=>!_.includes(et.url));
  162525. o && isFunction(o) && (_e = _e.filter(o)),
  162526. c = _e.length,
  162527. log$d.debug("keysNeedToPreload", _e),
  162528. log$d.warn("preloadStart", _e.length),
  162529. _e.length || i && i($.length, $.length),
  162530. s = Date.now(),
  162531. await this._preload(e, _e, i),
  162532. log$d.infoAndReportMeasurement({
  162533. tag: e,
  162534. startTime: s,
  162535. metric: "assetsPreload",
  162536. extra: {
  162537. total: c
  162538. }
  162539. });
  162540. return
  162541. } catch (d) {
  162542. let _ = d;
  162543. return (this.requests[e].stopped || axios.isCancel(d)) && (_ = new PreloadCanceledError),
  162544. log$d.infoAndReportMeasurement({
  162545. tag: e,
  162546. startTime: s,
  162547. metric: "assetsPreload",
  162548. extra: {
  162549. total: c
  162550. },
  162551. error: _,
  162552. reportOptions: {
  162553. immediate: !0
  162554. }
  162555. }),
  162556. Promise.reject(_)
  162557. }
  162558. }
  162559. async deleteOldResources(e, i) {
  162560. if (!this.oldResourcesDeleted)
  162561. this.oldResourcesDeleted = !0;
  162562. else
  162563. return Promise.resolve();
  162564. const o = i.filter(c=>!e.includes(c));
  162565. log$d.debug("keysNeedToDelete", o),
  162566. log$d.warn("keysNeedToDelete", o.length);
  162567. const s = Promise.all(o.map(c=>modelTable.delete(c)));
  162568. try {
  162569. await s
  162570. } catch (c) {
  162571. log$d.error("deleteOldResources error", c)
  162572. }
  162573. }
  162574. async _preload(e, i, o) {
  162575. const s = i.length;
  162576. if (!s)
  162577. return Promise.resolve();
  162578. let c = 0;
  162579. const d = window.setInterval(()=>{
  162580. o && o(c, s),
  162581. c >= s && window.clearInterval(d)
  162582. }
  162583. , 1e3);
  162584. return mapLimit(i, 10, async _=>{
  162585. const {size: b, url: k} = _;
  162586. return this.requests[e].stopped ? Promise.reject(new PreloadCanceledError) : AssetsStorage.requestAndPut({
  162587. url: k,
  162588. timeout: Preload.getTimeoutBySize(b),
  162589. responseType: "blob",
  162590. retry: 2,
  162591. beforeRequest: ()=>{
  162592. this.requests[e].requests[k] = !0
  162593. }
  162594. }).then(()=>{
  162595. c++,
  162596. delete this.requests[e].requests[k]
  162597. }
  162598. , j=>(delete this.requests[e].requests[k],
  162599. window.clearInterval(d),
  162600. Promise.reject(j)))
  162601. }
  162602. )
  162603. }
  162604. }
  162605. let sceneManager;
  162606. function getSceneManager(a, e) {
  162607. return sceneManager || (sceneManager = new XSceneManager(a,e)),
  162608. sceneManager
  162609. }
  162610. const log$c = new Logger("tv");
  162611. class TV extends XTelevision {
  162612. constructor(i, o, s, c) {
  162613. super(s.scene, o, s.sceneManager, c);
  162614. Tt(this, "decal");
  162615. Tt(this, "id");
  162616. Tt(this, "imageUrl");
  162617. Tt(this, "mode", "video");
  162618. Tt(this, "room");
  162619. Tt(this, "_isStoped", !1);
  162620. Tt(this, "setVideo", (i,o=!1,s=!0)=>(log$c.warn("setVideo", {
  162621. isLive: o,
  162622. fixElement: s,
  162623. src: i.src
  162624. }),
  162625. super.setVideo(i, o, s).then(()=>(this._isStoped = !1,
  162626. log$c.warn("setVideo Success", {
  162627. isLive: o,
  162628. fixElement: s,
  162629. src: i.src
  162630. }),
  162631. this))));
  162632. this.id = i,
  162633. this.room = s,
  162634. this.decal = new XDecalManager(s.sceneManager)
  162635. }
  162636. get isStoped() {
  162637. return this._isStoped
  162638. }
  162639. get objectFit() {
  162640. return this.tvFitMode
  162641. }
  162642. set objectFit(i) {
  162643. this.objectFit !== i && (this.tvFitMode = i,
  162644. this.getVideoMat() && this.changeTvFitMode())
  162645. }
  162646. show() {
  162647. this.mode === "video" ? this.toggle(!0) : this.mode === "poster" && this.showPoster()
  162648. }
  162649. hide() {
  162650. this.mode === "video" ? this.toggle(!1) : this.mode === "poster" && this.hidePoster()
  162651. }
  162652. showVideo() {
  162653. this.mode = "video",
  162654. this.toggle(!0)
  162655. }
  162656. hideVideo() {
  162657. this.toggle(!1)
  162658. }
  162659. showPoster() {
  162660. const i = this.imageUrl;
  162661. if (!i)
  162662. return Promise.reject("set poster url before show it");
  162663. if (!this.decal)
  162664. return Promise.reject("decal was not found");
  162665. const o = this.id;
  162666. return this.decal.addDecal({
  162667. id: o,
  162668. meshPath: this.meshPath
  162669. }).then(()=>{
  162670. var s;
  162671. this.mode = "poster",
  162672. (s = this.decal) == null || s.setDecalTexture({
  162673. id: o,
  162674. buffer: i
  162675. }).then(()=>{
  162676. var c;
  162677. (c = this.decal) == null || c.toggle(o, !0)
  162678. }
  162679. )
  162680. }
  162681. )
  162682. }
  162683. setPoster(i) {
  162684. return this.imageUrl = i,
  162685. this.showPoster()
  162686. }
  162687. hidePoster() {
  162688. return this.decal ? this.decal.toggle(this.id, !1) : Promise.reject("decal was not found")
  162689. }
  162690. async setUrl(i) {
  162691. const o = Date.now()
  162692. , {url: s, loop: c=!1, muted: d} = i || {};
  162693. if (log$c.warn("setUrl", {
  162694. url: s,
  162695. loop: c,
  162696. muted: d
  162697. }),
  162698. !s)
  162699. return log$c.error("tv url is required"),
  162700. Promise.reject("tv url is required");
  162701. await super.setUrl({
  162702. url: s,
  162703. bLoop: c,
  162704. bMuted: d
  162705. });
  162706. const _ = this.videoElement;
  162707. if (!_)
  162708. return Promise.reject(new InternalError("video element is not found"));
  162709. _.crossOrigin = "anonymous",
  162710. _.playsInline = !0,
  162711. _.load(),
  162712. this.mode = "video",
  162713. this._isStoped = !1;
  162714. try {
  162715. await new Promise(b=>{
  162716. _.oncanplay = ()=>{
  162717. log$c.warn(`setUrl success, video oncanplay within ${(Date.now() - o) / 1e3}s`, {
  162718. url: s,
  162719. loop: c,
  162720. muted: d
  162721. }),
  162722. this.room.afterSetUrlHook(),
  162723. _.play(),
  162724. b(this)
  162725. }
  162726. }
  162727. )._timeout(15e3, new InternalError("video oncanplay timeout in 15s"))
  162728. } catch (b) {
  162729. return log$c.error(b),
  162730. Promise.reject(b)
  162731. }
  162732. return this
  162733. }
  162734. stop() {
  162735. return log$c.warn("tv stop success"),
  162736. this._isStoped = !0,
  162737. this.room.afterTvStopedHook(),
  162738. super.stop()
  162739. }
  162740. play() {
  162741. return this._isStoped = !1,
  162742. this.room.afterTvPlayedHook(),
  162743. super.play().then(()=>{
  162744. log$c.warn("tv play success"),
  162745. !this.videoElement && log$c.error("tv play fake success, videoElement is not found")
  162746. }
  162747. ).catch(i=>(log$c.error("tv play error", i),
  162748. Promise.reject(i)))
  162749. }
  162750. mirrorFrom(i) {
  162751. const o = i.getVideoMat();
  162752. return this.setSameVideo(o).then(()=>{
  162753. this.toggle(!0)
  162754. }
  162755. )
  162756. }
  162757. clean() {
  162758. var i;
  162759. this.cleanTv(!1, !0),
  162760. (i = this.decal) == null || i.deleteDecal(this.id)
  162761. }
  162762. }
  162763. const log$b = new Logger("xverse-bus")
  162764. , ir = class {
  162765. constructor(e) {
  162766. Tt(this, "_tvs", []);
  162767. Tt(this, "isRenderFirstFrame", !1);
  162768. Tt(this, "_idleTime", 0);
  162769. Tt(this, "renderTimer");
  162770. Tt(this, "lightManager");
  162771. Tt(this, "_checkSceneNotReadyCount", 0);
  162772. Tt(this, "_checkSceneDurationFrameNum", 0);
  162773. Tt(this, "_checkSceneFrameCount", 0);
  162774. Tt(this, "timeoutCircularArray", new CircularArray(120,!1,[]));
  162775. Tt(this, "frameCircularArray", new CircularArray(120,!1,[]));
  162776. Tt(this, "interFrameCircularArray", new CircularArray(120,!1,[]));
  162777. Tt(this, "drawCallCntCircularArray", new CircularArray(120,!1,[]));
  162778. Tt(this, "activeFacesCircularArray", new CircularArray(120,!1,[]));
  162779. Tt(this, "renderTimeCircularArray", new CircularArray(120,!1,[]));
  162780. Tt(this, "drawCallTimeCircularArray", new CircularArray(120,!1,[]));
  162781. Tt(this, "animationCircularArray", new CircularArray(120,!1,[]));
  162782. Tt(this, "meshSelectCircularArray", new CircularArray(120,!1,[]));
  162783. Tt(this, "renderTargetCircularArray", new CircularArray(120,!1,[]));
  162784. Tt(this, "regBeforeRenderCircularArray", new CircularArray(120,!1,[]));
  162785. Tt(this, "regAfterRenderCircularArray", new CircularArray(120,!1,[]));
  162786. Tt(this, "renderCnt", 0);
  162787. Tt(this, "renderErrorCount", 0);
  162788. Tt(this, "engineSloppyCnt", 0);
  162789. Tt(this, "systemStuckCnt", 0);
  162790. Tt(this, "timeoutSecondArray", new SecondArray);
  162791. Tt(this, "frameRenderNumber", 0);
  162792. Tt(this, "_setFPS", (e,i=25)=>{
  162793. log$b.info("Set fps to", i);
  162794. const o = i > 60 ? 60 : i < 24 ? 24 : i;
  162795. e.Engine.stopRenderLoop();
  162796. const s = 1e3 / o;
  162797. let c = Date.now()
  162798. , d = Date.now()
  162799. , _ = s
  162800. , b = 1;
  162801. const k = ()=>{
  162802. var st;
  162803. const j = Date.now()
  162804. , $ = j - c
  162805. , _e = j - d;
  162806. d = j,
  162807. this.frameCircularArray.add(_e),
  162808. $ - _ > s && (this.systemStuckCnt += 1),
  162809. this.timeoutSecondArray.add($ - _);
  162810. const et = $ / _;
  162811. b = .9 * b + .1 * et;
  162812. const tt = Date.now();
  162813. let rt = 0
  162814. , it = 0;
  162815. if (this.room.isUpdatedRawYUVData || this.room.isPano) {
  162816. if (this.isRenderFirstFrame = !0,
  162817. this._checkSceneDurationFrameNum > 0)
  162818. this._checkSceneFrameCount++,
  162819. this.room.sceneManager.isReadyToRender({}) && this._checkSceneDurationFrameNum--,
  162820. this._checkSceneFrameCount > ir._CHECK_DURATION && (this._checkSceneDurationFrameNum = ir._CHECK_DURATION,
  162821. this._checkSceneFrameCount = 0,
  162822. this._checkSceneNotReadyCount++,
  162823. (this._checkSceneNotReadyCount == 1 || this._checkSceneNotReadyCount % 100 == 0) && log$b.error(`[SDK] Scene not ready, skip render. loop: ${this._checkSceneNotReadyCount}`),
  162824. this._checkSceneNotReadyCount > 10 && (log$b.error("[SDK] Scene not ready, reload later"),
  162825. this.room.proxyEvents("renderError", {
  162826. error: new Error("[SDK] Scene not ready, skip render and reload.")
  162827. })),
  162828. this.room.stats.assign({
  162829. renderErrorCount: this._checkSceneNotReadyCount
  162830. }),
  162831. log$b.infoAndReportMeasurement({
  162832. value: 0,
  162833. startTime: Date.now(),
  162834. metric: "renderError",
  162835. error: new Error("[SDK] Scene not ready, skip render and reload."),
  162836. reportOptions: {
  162837. sampleRate: .1
  162838. }
  162839. }));
  162840. else
  162841. try {
  162842. this.room.allowRender && e.render()
  162843. } catch (ut) {
  162844. this.renderErrorCount++,
  162845. this.renderErrorCount > 10 && this.room.proxyEvents("renderError", {
  162846. error: ut
  162847. }),
  162848. this.room.stats.assign({
  162849. renderErrorCount: this.renderErrorCount
  162850. }),
  162851. log$b.infoAndReportMeasurement({
  162852. value: 0,
  162853. startTime: Date.now(),
  162854. metric: "renderError",
  162855. error: ut,
  162856. reportOptions: {
  162857. sampleRate: .1
  162858. }
  162859. })
  162860. }
  162861. rt = Date.now() - tt,
  162862. this.frameRenderNumber < 1e3 && this.frameRenderNumber++,
  162863. this.room.networkController.rtcp.workers.UpdateYUV(),
  162864. it = Date.now() - tt - rt
  162865. }
  162866. this.isRenderFirstFrame || this.room.networkController.rtcp.workers.UpdateYUV();
  162867. const ot = Date.now() - tt;
  162868. c = j + ot,
  162869. _ = Math.min(Math.max((s - ot) / b, 5), 200),
  162870. ot > s && (_ = 10,
  162871. this.engineSloppyCnt += 1),
  162872. this._idleTime = _;
  162873. const at = _;
  162874. if (_ > 150 && console.log("lastGap is ", _, ", ratio is ", b, ", usedTimeMs is ", ot, ", cpuRenderTime is ", rt, ", cpuUpdateYUVTime is ", it),
  162875. this.timeoutCircularArray.add(at),
  162876. this.renderCnt % 25 == 0) {
  162877. const ut = this.frameCircularArray.getAvg()
  162878. , ct = this.timeoutCircularArray.getAvg()
  162879. , lt = this.frameCircularArray.getMax()
  162880. , ft = this.timeoutCircularArray.getMax();
  162881. (st = this.room.stats) == null || st.assign({
  162882. avgFrameTime: ut,
  162883. avgTimeoutTime: ct,
  162884. maxFrameTime: lt,
  162885. maxTimeoutTime: ft,
  162886. systemStuckCnt: this.systemStuckCnt
  162887. })
  162888. }
  162889. this.renderTimer = window.setTimeout(k, _)
  162890. }
  162891. ;
  162892. this.renderTimer = window.setTimeout(k, s / b)
  162893. }
  162894. );
  162895. Tt(this, "updateStats", ()=>{
  162896. var i;
  162897. const e = this.timeoutSecondArray.getStat();
  162898. (i = this.room.stats) == null || i.assign({
  162899. renderFrameTime: this.renderTimeCircularArray.getAvg(),
  162900. maxRenderFrameTime: this.renderTimeCircularArray.getMax(),
  162901. interFrameTime: this.interFrameCircularArray.getAvg(),
  162902. animationTime: this.animationCircularArray.getAvg(),
  162903. meshSelectTime: this.meshSelectCircularArray.getAvg(),
  162904. drawcallTime: this.drawCallTimeCircularArray.getAvg(),
  162905. idleTime: this._idleTime,
  162906. registerBeforeRenderTime: this.regBeforeRenderCircularArray.getAvg(),
  162907. registerAfterRenderTime: this.regAfterRenderCircularArray.getAvg(),
  162908. renderTargetRenderTime: this.renderTargetCircularArray.getAvg(),
  162909. fps: (1e3 / (this.renderTimeCircularArray.getAvg() + this.interFrameCircularArray.getAvg())).toFixed(2),
  162910. drawcall: this.drawCallCntCircularArray.getAvg(),
  162911. engineSloppyCnt: this.engineSloppyCnt,
  162912. maxInterFrameTime: this.interFrameCircularArray.getMax(),
  162913. maxDrawcallTime: this.drawCallTimeCircularArray.getMax(),
  162914. maxMeshSelectTime: this.meshSelectCircularArray.getMax(),
  162915. maxAnimationTime: this.animationCircularArray.getMax(),
  162916. maxRegisterBeforeRenderTime: this.regBeforeRenderCircularArray.getMax(),
  162917. maxRegisterAfterRenderTime: this.regAfterRenderCircularArray.getMax(),
  162918. maxRenderTargetRenderTime: this.renderTargetCircularArray.getMax(),
  162919. avgFrameTime: this.frameCircularArray.getAvg(),
  162920. avgTimeoutTime: this.timeoutCircularArray.getAvg(),
  162921. maxFrameTime: this.frameCircularArray.getMax(),
  162922. maxTimeoutTime: this.timeoutCircularArray.getMax(),
  162923. maxTimeoutGap: e.max
  162924. })
  162925. }
  162926. );
  162927. this.room = e
  162928. }
  162929. async initEngine(e) {
  162930. var d, _;
  162931. await this.updateBillboard(),
  162932. log$b.info("engine version:", VERSION$1);
  162933. const i = new Logger("engine");
  162934. i.setLevel(LoggerLevels.Warn);
  162935. const o = {
  162936. videoResOriArray: [{
  162937. width: 720,
  162938. height: 1280
  162939. }, {
  162940. width: 1280,
  162941. height: 720
  162942. }, {
  162943. width: 480,
  162944. height: 654
  162945. }, {
  162946. width: 654,
  162947. height: 480
  162948. }, {
  162949. width: 1920,
  162950. height: 1080
  162951. }, {
  162952. width: 1080,
  162953. height: 1920
  162954. }, {
  162955. width: 414,
  162956. height: 896
  162957. }],
  162958. forceKeepVertical: this.room.options.objectFit !== "cover",
  162959. panoInfo: {
  162960. dynamicRange: 1,
  162961. width: 4096,
  162962. height: 2048
  162963. },
  162964. shaderMode: EShaderMode.videoAndPano,
  162965. yuvInfo: {
  162966. width: 1280,
  162967. height: 720,
  162968. fov: e.fov || DEFAULT_MAIN_CAMERA_FOV
  162969. },
  162970. cameraParam: {
  162971. maxZ: 1e4
  162972. },
  162973. urlTransformer,
  162974. logger: i,
  162975. disableWebGL2: this.room.options.disableWebGL2 || !1
  162976. }
  162977. , s = (_ = (d = this.room) == null ? void 0 : d.skin) == null ? void 0 : _.resolution;
  162978. s && (o.videoResOriArray.some(k=>k.width === s.width && k.height === s.height) || o.videoResOriArray.push(s));
  162979. const c = this.room.sceneManager = getSceneManager(this.room.canvas, o);
  162980. this.room.setPictureQualityLevel(this.room.options.pictureQualityLevel || "high"),
  162981. this.room.sceneManager.staticmeshComponent.setRegionLodRule([2, 2, -1, -1, -1]),
  162982. this.room.scene = c.Scene,
  162983. this.room.breathPointManager = c.breathPointComponent,
  162984. this.lightManager = c.lightComponent,
  162985. this.registerStats(),
  162986. await this.setEnv(e),
  162987. await this.room.avatarManager.init(),
  162988. await this._updateSkinAssets(e.id),
  162989. this._setFPS(c)
  162990. }
  162991. pause() {
  162992. clearTimeout(this.renderTimer),
  162993. log$b.info("Invoke room.pause to pause render");
  162994. const e = {
  162995. roomId: this.room.id,
  162996. effects: [],
  162997. lowPolyModels: [],
  162998. breathPointsConfig: [],
  162999. skinId: this.room.skinId
  163000. };
  163001. return this.loadAssets(e, this.room.skinId)
  163002. }
  163003. async resume() {
  163004. this._setFPS(this.room.sceneManager),
  163005. this.room.sceneManager.cameraComponent.cameraFovChange(this.room.sceneManager.yuvInfo),
  163006. log$b.info("Invoke room.resume to render");
  163007. const e = this._createAssetList(this.room.skin);
  163008. await this.loadAssets(e, "")
  163009. }
  163010. async setEnv(e) {
  163011. var o;
  163012. this.lightManager || (this.lightManager = this.room.sceneManager.lightComponent),
  163013. e = e || this.room.skin;
  163014. const i = ModelManager.findModel(e.models, AssetTypeName.Config, AssetClassName.Env);
  163015. return i ? (o = this.lightManager) == null ? void 0 : o.setIBL(i.modelUrl) : (log$b.error("env file not found"),
  163016. Promise.resolve())
  163017. }
  163018. async _parseModelsAndLoad(e, i, o) {
  163019. log$b.info("Invoke _parseModelsAndLoad start", i);
  163020. const s = ["airship", "balloon", "default", "ground_feiting", "ground_reqiqiu"]
  163021. , c = new Map;
  163022. o == null && (o = "xxxx");
  163023. let d = !0;
  163024. for (let k = 0; k < e.length; ++k) {
  163025. d = !0;
  163026. for (let j = 0; j < s.length; ++j)
  163027. if (e[k].modelUrl.toLowerCase().indexOf(s[j]) >= 0) {
  163028. const $ = c.get(s[j]);
  163029. $ ? ($.push(e[k]),
  163030. c.set(s[j], $)) : c.set(s[j], [e[k]]),
  163031. d = !1;
  163032. break
  163033. }
  163034. if (d) {
  163035. const j = c.get("default");
  163036. j ? (j.push(e[k]),
  163037. c.set("default", j)) : c.set("default", [e[k]])
  163038. }
  163039. }
  163040. let _ = c.get(i) || [];
  163041. if (this.room.viewMode === "simple" && (_ = _.filter(k=>!k.modelUrl.endsWith("zip"))),
  163042. !_)
  163043. return Promise.reject(`no invalid scene model with group name: ${i}`);
  163044. const b = [];
  163045. for (let k = 0; k < _.length; ++k) {
  163046. const j = _[k];
  163047. if (j.modelUrl.toLowerCase().endsWith("zip"))
  163048. j.modelUrl.toLowerCase().endsWith("zip") && b.push(this.room.sceneManager.addNewLowPolyMesh({
  163049. url: j.modelUrl,
  163050. skinInfo: o
  163051. }));
  163052. else {
  163053. const $ = i;
  163054. b.push(this.room.sceneManager.addNewLowPolyMesh({
  163055. url: j.modelUrl,
  163056. group: $,
  163057. pick: !0,
  163058. skinInfo: o
  163059. }))
  163060. }
  163061. }
  163062. return Promise.all(b)
  163063. }
  163064. async _deleteAssetsLowpolyModel(e) {
  163065. this.room.sceneManager.staticmeshComponent.deleteMeshesBySkinInfo(e),
  163066. this.room.sceneManager.breathPointComponent.clearBreathPointsBySkinInfo(e),
  163067. this.room.sceneManager.decalComponent.deleteDecalBySkinInfo(e);
  163068. const i = [];
  163069. this.room.sceneManager.Scene.meshes.forEach(o=>{
  163070. o.xskinInfo == e && i.push(o)
  163071. }
  163072. ),
  163073. i.forEach(o=>{
  163074. o.dispose(!1, !1)
  163075. }
  163076. )
  163077. }
  163078. async loadLandAssets() {
  163079. const e = this._createAssetList(this.room.skin);
  163080. return this.loadAssets(e, this.room.skinId).catch(()=>this.loadAssets(e, this.room.skinId))
  163081. }
  163082. async loadAssets(e, i="", o=8e3) {
  163083. const s = Date.now();
  163084. return this._loadAssets(e, i)._timeout(o, new InitEngineTimeoutError(`loadAssets timeout(${o}ms)`)).then(c=>(log$b.infoAndReportMeasurement({
  163085. tag: "loadAssets",
  163086. startTime: s,
  163087. metric: "loadAssets"
  163088. }),
  163089. c)).catch(c=>(log$b.infoAndReportMeasurement({
  163090. tag: "loadAssets",
  163091. startTime: s,
  163092. metric: "loadAssets",
  163093. error: c
  163094. }),
  163095. Promise.reject(c)))
  163096. }
  163097. async _loadAssets(e, i="") {
  163098. try {
  163099. const o = [];
  163100. o.push(this._loadAssetsLowpolyModel(e, i)),
  163101. await Promise.all(o),
  163102. this._checkSceneDurationFrameNum = ir._CHECK_DURATION,
  163103. this._checkSceneNotReadyCount = 0,
  163104. this._checkSceneFrameCount = 0,
  163105. this.updateAnimationList()
  163106. } catch (o) {
  163107. return Promise.reject(o)
  163108. }
  163109. }
  163110. updateAnimationList() {
  163111. if (this.room.avatarManager && this.room.avatarManager.xAvatarManager) {
  163112. const e = this.room.skin.animationList;
  163113. if (!e)
  163114. return;
  163115. e.forEach(i=>{
  163116. this.room.avatarManager.xAvatarManager.updateAnimationLists(i.animations, i.avatarId)
  163117. }
  163118. )
  163119. }
  163120. }
  163121. async _loadAssetsLowpolyModel(e, i="") {
  163122. const o = []
  163123. , s = []
  163124. , c = [];
  163125. e.lowPolyModels.forEach($=>{
  163126. $.group === "TV" ? s.push({
  163127. id: "",
  163128. name: "",
  163129. thumbnailUrl: "",
  163130. typeName: AssetTypeName.Model,
  163131. className: AssetClassName.Tv,
  163132. modelUrl: $.url
  163133. }) : $.group === "\u544A\u767D\u5899" ? c.push({
  163134. id: "",
  163135. name: "",
  163136. thumbnailUrl: "",
  163137. typeName: AssetTypeName.Model,
  163138. className: AssetClassName.Lpm,
  163139. modelUrl: $.url
  163140. }) : o.push({
  163141. id: "",
  163142. name: "",
  163143. thumbnailUrl: "",
  163144. typeName: AssetTypeName.Model,
  163145. className: AssetClassName.Lpm,
  163146. modelUrl: $.url
  163147. })
  163148. }
  163149. ),
  163150. i != "" && i != null && this._deleteAssetsLowpolyModel(i);
  163151. const d = e.skinId;
  163152. log$b.info("====> from ", i, " to ", d),
  163153. this._tvs.forEach($=>$.clean()),
  163154. this._tvs = [],
  163155. Array.isArray(s) && s.forEach(($,_e)=>{
  163156. this._tvs.push(new TV("squareTv" + _e,$.modelUrl,this.room,{
  163157. fitMode: EFitMode.cover
  163158. }))
  163159. }
  163160. ),
  163161. e.breathPointsConfig.forEach(async$=>{
  163162. let _e;
  163163. try {
  163164. _e = await urlTransformer($.imageUrl)
  163165. } catch (et) {
  163166. _e = $.imageUrl,
  163167. log$b.error("urlTransformer error", et)
  163168. }
  163169. this.room.breathPointManager.addBreathPoint({
  163170. id: $.id,
  163171. position: $.position,
  163172. spriteSheet: _e,
  163173. rotation: $.rotation || {
  163174. pitch: 0,
  163175. yaw: 270,
  163176. roll: 0
  163177. },
  163178. billboardMode: !0,
  163179. type: $.type || "no_type",
  163180. spriteWidthNumber: $.spriteWidthNum || 1,
  163181. spriteHeightNumber: $.spriteHeightNum || 1,
  163182. maxVisibleRegion: $.maxVisibleRegion || 150,
  163183. width: $.width,
  163184. height: $.height,
  163185. skinInfo: $.skinId
  163186. })
  163187. }
  163188. ),
  163189. c.forEach($=>{
  163190. this.room.sceneManager.decalComponent.addDecal({
  163191. id: $.id || "gbq",
  163192. meshPath: $.modelUrl,
  163193. skinInfo: d
  163194. })
  163195. }
  163196. );
  163197. const b = this.room.sceneManager.staticmeshComponent.lowModel_group
  163198. , k = Array.from(b.keys()).filter($=>!$.startsWith("region_"))
  163199. , j = ["airship", "balloon", "ground_feiting", "ground_reqiqiu", "default"];
  163200. return new Promise(($,_e)=>{
  163201. Promise.all(j.map(et=>this._parseModelsAndLoad(o, et, d))).then(()=>{
  163202. let et = !1;
  163203. o.forEach(it=>{
  163204. it.modelUrl.endsWith("zip") && (et = !0)
  163205. }
  163206. ),
  163207. et == !1 && this.room.sceneManager.staticmeshComponent.deleteLastRegionMesh(),
  163208. this.room.sceneManager.staticmeshComponent.lowModel_group;
  163209. const tt = Array.from(b.keys()).filter(it=>!it.startsWith("region_"))
  163210. , rt = k.filter(it=>tt.indexOf(it) < 0);
  163211. rt.length > 0 && rt.forEach(it=>{
  163212. this.room.sceneManager.staticmeshComponent.deleteMeshesByGroup(it)
  163213. }
  163214. ),
  163215. $(!0)
  163216. }
  163217. ).catch(et=>{
  163218. _e(et)
  163219. }
  163220. )
  163221. }
  163222. )
  163223. }
  163224. async _updateSkinAssets(e) {
  163225. const i = this.room.currentState.skinId
  163226. , o = await this.room.getSkin(e)
  163227. , s = this._createAssetList(o);
  163228. try {
  163229. await this.loadAssets(s, i),
  163230. this.room.updateCurrentState({
  163231. versionId: o.versionId,
  163232. skinId: o.id,
  163233. skin: o
  163234. })
  163235. } catch {
  163236. await this.loadAssets(s, i),
  163237. this.room.updateCurrentState({
  163238. versionId: o.versionId,
  163239. skinId: o.id,
  163240. skin: o
  163241. })
  163242. }
  163243. const c = this.room.sceneManager.yuvInfo;
  163244. this.room.sceneManager.changeCameraFovWithShaderUpdate(Zt($t({}, c), {
  163245. fov: o.fov
  163246. })),
  163247. this.room.afterLoadAssetsHook(),
  163248. await this.setEnv(o)
  163249. }
  163250. _createAssetList(e) {
  163251. const i = []
  163252. , o = []
  163253. , s = [];
  163254. let c = e.models;
  163255. const d = this.room.modelManager.config.preload;
  163256. return this.room.viewMode === "simple" ? d && (c = d.baseUrls.map(b=>(b.modelUrl = b.url,
  163257. b))) : this.room.viewMode,
  163258. ModelManager.findModels(c, AssetTypeName.Effects, AssetClassName.Effects).forEach(b=>{
  163259. i.push({
  163260. url: b.modelUrl,
  163261. group: b.className,
  163262. name: b.name
  163263. })
  163264. }
  163265. ),
  163266. ModelManager.findModels(c, AssetTypeName.Model, AssetClassName.Lpm).forEach(b=>{
  163267. o.push({
  163268. url: b.modelUrl,
  163269. group: b.className
  163270. })
  163271. }
  163272. ),
  163273. ModelManager.findModels(c, AssetTypeName.Model, AssetClassName.Gbq).forEach(b=>{
  163274. o.push({
  163275. url: b.modelUrl,
  163276. group: b.className
  163277. })
  163278. }
  163279. ),
  163280. ModelManager.findModels(c, AssetTypeName.Model, AssetClassName.Tv).forEach(b=>{
  163281. o.push({
  163282. url: b.modelUrl,
  163283. group: b.className
  163284. })
  163285. }
  163286. ),
  163287. [].forEach(b=>{
  163288. b.skinId == e.id && s.push(b)
  163289. }
  163290. ),
  163291. {
  163292. roomId: this.room.id,
  163293. effects: i,
  163294. lowPolyModels: o,
  163295. breathPointsConfig: s,
  163296. skinId: e.id
  163297. }
  163298. }
  163299. registerStats() {
  163300. const e = this.room.sceneManager;
  163301. this.room.scene.registerAfterRender(()=>{
  163302. var _t;
  163303. const i = e.statisticComponent.getInterFrameTimeCounter()
  163304. , o = e.statisticComponent.getDrawCall()
  163305. , s = e.statisticComponent.getActiveFaces()
  163306. , c = e.statisticComponent.getFrameTimeCounter()
  163307. , d = e.statisticComponent.getDrawCallTime()
  163308. , _ = e.statisticComponent.getAnimationTime()
  163309. , b = e.statisticComponent.getActiveMeshEvaluationTime()
  163310. , k = e.statisticComponent.getRenderTargetRenderTime()
  163311. , j = e.statisticComponent.getRegisterBeforeRenderTime()
  163312. , $ = e.statisticComponent.getRegisterAfterRenderTime()
  163313. , _e = e.statisticComponent.getActiveParticles()
  163314. , et = e.statisticComponent.getActiveBones()
  163315. , tt = e.Scene._activeAnimatables.length
  163316. , rt = e.statisticComponent.getTotalRootNodes()
  163317. , it = e.Scene.geometries.length
  163318. , nt = e.Scene.onBeforeRenderObservable.observers.length
  163319. , ot = e.Scene.onAfterRenderObservable.observers.length
  163320. , at = e.statisticComponent.getTotalMeshes()
  163321. , st = e.statisticComponent.getTotalTextures()
  163322. , ut = e.statisticComponent.getTotalMaterials()
  163323. , ct = e.statisticComponent.getSystemInfo()
  163324. , lt = ct.resolution
  163325. , ft = ct.driver;
  163326. ct.vender;
  163327. const ht = ct.version
  163328. , pt = ct.hardwareScalingLevel
  163329. , dt = lt + "_" + ft + "_" + ht + "_" + pt;
  163330. this.interFrameCircularArray.add(i),
  163331. this.renderTimeCircularArray.add(c),
  163332. this.animationCircularArray.add(_),
  163333. this.meshSelectCircularArray.add(b),
  163334. this.drawCallTimeCircularArray.add(d),
  163335. this.regAfterRenderCircularArray.add($),
  163336. this.regBeforeRenderCircularArray.add(j),
  163337. this.renderTargetCircularArray.add(k),
  163338. this.drawCallCntCircularArray.add(o),
  163339. this.renderCnt += 1,
  163340. this.renderCnt % 25 == 0 && ((_t = this.room.stats) == null || _t.assign({
  163341. renderFrameTime: this.renderTimeCircularArray.getAvg(),
  163342. maxRenderFrameTime: this.renderTimeCircularArray.getMax(),
  163343. interFrameTime: this.interFrameCircularArray.getAvg(),
  163344. animationTime: this.animationCircularArray.getAvg(),
  163345. meshSelectTime: this.meshSelectCircularArray.getAvg(),
  163346. drawcallTime: this.drawCallTimeCircularArray.getAvg(),
  163347. idleTime: this._idleTime,
  163348. registerBeforeRenderTime: this.regBeforeRenderCircularArray.getAvg(),
  163349. registerAfterRenderTime: this.regAfterRenderCircularArray.getAvg(),
  163350. renderTargetRenderTime: this.renderTargetCircularArray.getAvg(),
  163351. fps: (1e3 / (this.renderTimeCircularArray.getAvg() + this.interFrameCircularArray.getAvg())).toFixed(2),
  163352. drawcall: this.drawCallCntCircularArray.getAvg(),
  163353. triangle: s.toString(),
  163354. engineSloppyCnt: this.engineSloppyCnt,
  163355. maxInterFrameTime: this.interFrameCircularArray.getMax(),
  163356. maxDrawcallTime: this.drawCallTimeCircularArray.getMax(),
  163357. maxMeshSelectTime: this.meshSelectCircularArray.getMax(),
  163358. maxAnimationTime: this.animationCircularArray.getMax(),
  163359. maxRegisterBeforeRenderTime: this.regBeforeRenderCircularArray.getMax(),
  163360. maxRegisterAfterRenderTime: this.regAfterRenderCircularArray.getMax(),
  163361. maxRenderTargetRenderTime: this.renderTargetCircularArray.getMax(),
  163362. activeParticles: _e,
  163363. activeBones: et,
  163364. activeAnimation: tt,
  163365. totalMeshes: at,
  163366. totalRootNodes: rt,
  163367. totalGeometries: it,
  163368. totalTextures: st,
  163369. totalMaterials: ut,
  163370. registerBeforeCount: nt,
  163371. registerAfterCount: ot,
  163372. hardwareInfo: dt
  163373. }))
  163374. }
  163375. )
  163376. }
  163377. async updateBillboard() {
  163378. const {options: {skinId: e}} = this.room
  163379. , o = (await this.room.modelManager.findAssetList(e)).filter(d=>d.typeName === AssetTypeName.Textures && d.className === AssetClassName.SayBubble)
  163380. , s = ["bubble01", "bubble02", "bubble03"]
  163381. , c = ["bubble01_npc", "bubble02_npc", "bubble03_npc"];
  163382. if (o.length) {
  163383. const d = o.filter(b=>s.includes(b.name)).map(b=>b.url)
  163384. , _ = o.filter(b=>c.includes(b.name)).map(b=>b.url);
  163385. d.length && (XBillboardManager.userBubbleUrls = d),
  163386. _.length && (XBillboardManager.npcBubbleUrls = _)
  163387. }
  163388. }
  163389. }
  163390. ;
  163391. let EngineProxy = ir;
  163392. Tt(EngineProxy, "_CHECK_DURATION", 2);
  163393. var CameraStates = (a=>(a[a.Normal = 0] = "Normal",
  163394. a[a.ItemView = 1] = "ItemView",
  163395. a[a.CGView = 2] = "CGView",
  163396. a[a.PathView = 3] = "PathView",
  163397. a))(CameraStates || {})
  163398. , Direction = (a=>(a.Left = "left",
  163399. a.Right = "right",
  163400. a))(Direction || {});
  163401. const calNormVector = (a,e)=>{
  163402. let i = 0;
  163403. for (let s = 0; s < 3; ++s)
  163404. i = i + (e[s] - a[s]) * (e[s] - a[s]);
  163405. return i = Math.sqrt(i),
  163406. [(e[0] - a[0]) / i, (e[1] - a[1]) / i, (e[2] - a[2]) / i]
  163407. }
  163408. , vectorCrossMulti = (a,e)=>{
  163409. const i = a[0]
  163410. , o = a[2]
  163411. , s = e[0]
  163412. , c = e[2];
  163413. return i * c - o * s
  163414. }
  163415. , log$a = new Logger("camera");
  163416. class Camera extends EventEmitter {
  163417. constructor(i) {
  163418. super();
  163419. Tt(this, "initialFov", 0);
  163420. Tt(this, "_state", CameraStates.Normal);
  163421. Tt(this, "_person", Person.Third);
  163422. Tt(this, "_room");
  163423. Tt(this, "_cameraFollowing", !0);
  163424. Tt(this, "checkPointOnLeftOrRight", i=>{
  163425. const o = ue4Position2Xverse(i);
  163426. if (!o || this.checkPointInView(i))
  163427. return;
  163428. const d = this._room.scene.activeCamera;
  163429. if (!d)
  163430. return;
  163431. const _ = [d.target.x, d.target.y, d.target.z]
  163432. , b = [d.position.x, d.position.y, d.position.z]
  163433. , {x: k, y: j, z: $} = o
  163434. , _e = calNormVector(b, _)
  163435. , et = calNormVector(b, [k, j, $]);
  163436. return vectorCrossMulti(_e, et) < 0 ? Direction.Right : Direction.Left
  163437. }
  163438. );
  163439. Tt(this, "checkPointInView", ({x: i, y: o, z: s})=>{
  163440. const c = ue4Position2Xverse({
  163441. x: i,
  163442. y: o,
  163443. z: s
  163444. });
  163445. if (!c)
  163446. return !1;
  163447. for (let d = 0; d < 6; d++)
  163448. if (this._room.scene.frustumPlanes[d].dotCoordinate(c) < 0)
  163449. return !1;
  163450. return !0
  163451. }
  163452. );
  163453. this._room = i
  163454. }
  163455. get person() {
  163456. return this._person
  163457. }
  163458. get state() {
  163459. return this._state
  163460. }
  163461. get pose() {
  163462. return this._room.currentClickingState.camera
  163463. }
  163464. set cameraFollowing(i) {
  163465. log$a.info("cameraFollowing setter", i),
  163466. this.setCameraFollowing({
  163467. isFollowHost: i
  163468. })
  163469. }
  163470. get cameraFollowing() {
  163471. return this._cameraFollowing
  163472. }
  163473. setCameraFollowing({isFollowHost: i}) {}
  163474. handleRenderInfo(i) {
  163475. const {cameraStateType: o} = i.renderInfo
  163476. , s = this._room.sceneManager;
  163477. if (o !== this._state && (this._state = o,
  163478. log$a.debug("camera._state changed to", CameraStates[o]),
  163479. o === CameraStates.CGView ? (s.cameraComponent.switchToCgCamera(),
  163480. s.staticmeshComponent.getCgMesh().show()) : (s.cameraComponent.switchToMainCamera(),
  163481. s.staticmeshComponent.getCgMesh().hide()),
  163482. this.emit("stateChanged", {
  163483. state: o
  163484. })),
  163485. this._room.isHost)
  163486. return;
  163487. const {isFollowHost: c} = i.playerState;
  163488. !!c !== this._cameraFollowing && (this._cameraFollowing = !!c,
  163489. this.emit("cameraFollowingChanged", {
  163490. cameraFollowing: !!c
  163491. }))
  163492. }
  163493. setCameraState({state: i}) {
  163494. if (this._state === i) {
  163495. log$a.warn(`You are already in ${CameraStates[i]} camera state`);
  163496. return
  163497. }
  163498. i === CameraStates.Normal || this._state === CameraStates.ItemView && log$a.warn("CloseUp camera state can only be triggerd by room internally")
  163499. }
  163500. turnToFace({extra: i="", offset: o=0}) {
  163501. const s = {
  163502. action_type: Actions.TurnToFace,
  163503. turn_to_face_action: {
  163504. offset: o
  163505. }
  163506. };
  163507. return this.emit("viewChanged", {
  163508. extra: i
  163509. }),
  163510. this._room.actionsHandler.sendData({
  163511. data: s
  163512. })
  163513. }
  163514. isInDefaultView() {
  163515. if (!this._room.isHost) {
  163516. log$a.warn("It is recommended to call the function on the host side");
  163517. return
  163518. }
  163519. if (!this._room._currentClickingState)
  163520. return log$a.error("CurrentState should not be empty"),
  163521. !1;
  163522. const {camera: i, player: o} = this._room._currentClickingState;
  163523. return Math.abs(o.angle.yaw - 180 - i.angle.yaw) % 360 <= 4
  163524. }
  163525. async screenShot({name: i, autoSave: o=!1}) {
  163526. const s = this._room.scene.getEngine()
  163527. , c = this._room.scene.activeCamera;
  163528. try {
  163529. this._room.sceneManager.setImageQuality(EImageQuality.high);
  163530. const d = await CreateScreenshotAsync(s, c, {
  163531. precision: 1
  163532. });
  163533. return this._room.sceneManager.setImageQuality(EImageQuality.low),
  163534. o === !0 && downloadFileByBase64(d, i),
  163535. Promise.resolve(d)
  163536. } catch (d) {
  163537. return this._room.sceneManager.setImageQuality(EImageQuality.low),
  163538. Promise.reject(d)
  163539. }
  163540. }
  163541. changeToFirstPerson(i, o, s) {
  163542. const {camera: c, player: d, attitude: _, areaName: b, pathName: k} = i;
  163543. return this._room.actionsHandler.requestPanorama({
  163544. camera: c,
  163545. player: d,
  163546. attitude: _,
  163547. areaName: b,
  163548. pathName: k
  163549. }, o, s).then(()=>{
  163550. this._room.networkController.rtcp.workers.changePanoMode(!0);
  163551. const {position: j, angle: $} = d || {};
  163552. this._room.sceneManager.cameraComponent.changeToFirstPersonView({
  163553. position: j,
  163554. rotation: $
  163555. })
  163556. }
  163557. )
  163558. }
  163559. setPerson(i, o={
  163560. camera: this._room._currentClickingState.camera,
  163561. player: this._room._currentClickingState.player
  163562. }) {
  163563. const s = Date.now();
  163564. return this._setPerson(i, o).then(c=>(log$a.infoAndReportMeasurement({
  163565. tag: Person[i],
  163566. startTime: s,
  163567. metric: "setPerson"
  163568. }),
  163569. c)).catch(c=>(log$a.infoAndReportMeasurement({
  163570. tag: Person[i],
  163571. startTime: s,
  163572. metric: "setPerson",
  163573. error: c
  163574. }),
  163575. Promise.reject(c)))
  163576. }
  163577. _setPerson(i, o={
  163578. camera: this._room._currentClickingState.camera,
  163579. player: this._room._currentClickingState.player
  163580. }) {
  163581. return i !== Person.First && i !== Person.Third ? Promise.reject("invalid person " + i) : !o.camera || !o.player ? Promise.reject(new ParamError("wrong camera or player")) : i === Person.First ? this._room.panorama.access({
  163582. camera: o.camera,
  163583. player: o.player,
  163584. tag: "setPerson"
  163585. }).then(()=>{
  163586. var d, _;
  163587. this._person = i,
  163588. (d = this._room._userAvatar) == null || d.hide();
  163589. const {position: s, angle: c} = ((_ = this._room.currentClickingState) == null ? void 0 : _.camera) || {};
  163590. !s || !c || this._room.sceneManager.cameraComponent.changeToFirstPersonView({
  163591. position: s,
  163592. rotation: c
  163593. })
  163594. }
  163595. ) : this._room.panorama.exit({
  163596. camera: o.camera,
  163597. player: o.player
  163598. }).then(()=>{
  163599. var s, c;
  163600. this._person = i,
  163601. (s = this._room._userAvatar) != null && s.xAvatar && ((c = this._room._userAvatar) == null || c.xAvatar.show())
  163602. }
  163603. )
  163604. }
  163605. setCameraPose(i) {
  163606. this._room.sceneManager.cameraComponent.setCameraPose({
  163607. position: i.position,
  163608. rotation: i.angle
  163609. })
  163610. }
  163611. async setMainCameraRotationLimit(i) {
  163612. if (!this._room.panorama.actived)
  163613. return Promise.reject(new Error("panorama not actived when setMainCameraRotationLimit"));
  163614. const {limitAxis: o, limitRotation: s} = i;
  163615. await this._room.sceneManager.cameraComponent.setMainCameraRotationLimit(o, s)
  163616. }
  163617. removeMainCameraRotationLimit() {
  163618. this._room.sceneManager.cameraComponent.removeMainCameraRotationLimit()
  163619. }
  163620. }
  163621. var IEffectType = (a=>(a.Sequence = "sequence",
  163622. a.SubSequence = "subSequence",
  163623. a))(IEffectType || {});
  163624. const log$9 = new Logger("effectManager");
  163625. class XverseEffect extends EventEmitter {
  163626. constructor({id: i, jsonPath: o, type: s, room: c, scale: d=1}) {
  163627. super();
  163628. Tt(this, "_id");
  163629. Tt(this, "type");
  163630. Tt(this, "effect");
  163631. Tt(this, "_room");
  163632. Tt(this, "_isLoading", !0);
  163633. Tt(this, "_failed", !1);
  163634. Tt(this, "_scale", 1);
  163635. this._room = c,
  163636. this._id = i,
  163637. this.type = s,
  163638. this._scale = d,
  163639. this.effect = i === "Rain" || i === "Boom" ? new XRain(this._room.scene,o,urlTransformer) : s === IEffectType.Sequence ? new XSequence(this._room.scene,o,"",urlTransformer) : new XSubSequence(this._room.scene,o,urlTransformer)
  163640. }
  163641. get failed() {
  163642. return this._failed
  163643. }
  163644. get position() {
  163645. if (this.type !== IEffectType.Sequence)
  163646. return this.effect.position
  163647. }
  163648. get rotation() {
  163649. if (this.type !== IEffectType.Sequence)
  163650. return this.effect.rotation
  163651. }
  163652. get isLoading() {
  163653. return this._isLoading
  163654. }
  163655. get id() {
  163656. return this._id
  163657. }
  163658. get name() {
  163659. return this.effect.name
  163660. }
  163661. get isPlaying() {
  163662. var i;
  163663. return !!((i = this.effect) != null && i.isPlaying)
  163664. }
  163665. async init() {
  163666. try {
  163667. await this.effect.init()._timeout(1e4, new TimeoutError("effect init timeout(10s)")),
  163668. this._isLoading = !1,
  163669. this._failed = !1
  163670. } catch (i) {
  163671. throw this._isLoading = !1,
  163672. this._failed = !0,
  163673. log$9.error(`effect: ${this.id} init error`, i),
  163674. i
  163675. }
  163676. }
  163677. play(i=!1) {
  163678. return new Promise((o,s)=>{
  163679. this.effect.play(i),
  163680. o()
  163681. }
  163682. )
  163683. }
  163684. hide() {
  163685. return this.effect.hide()
  163686. }
  163687. show() {
  163688. return this.effect.show()
  163689. }
  163690. setRotation(i) {
  163691. var o;
  163692. return this.type === IEffectType.Sequence ? Promise.reject("setRotation failed, sequence unSuported") : (o = this.effect) == null ? void 0 : o.setRotation(i)
  163693. }
  163694. setPosition(i) {
  163695. var o;
  163696. return this.type === IEffectType.Sequence ? Promise.reject("setPosition failed, sequence unSuported") : (o = this.effect) == null ? void 0 : o.setPosition(i)
  163697. }
  163698. setScaling(i) {
  163699. var o;
  163700. return this.type === IEffectType.Sequence ? Promise.reject("setScaling failed, sequence unSuported") : (this._scale = i,
  163701. (o = this.effect) == null ? void 0 : o.setScaling({
  163702. x: i,
  163703. y: -i,
  163704. z: i
  163705. }))
  163706. }
  163707. dispose() {
  163708. this.effect.dispose()
  163709. }
  163710. }
  163711. const log$8 = new Logger("xverse-effect-manager")
  163712. , dr = class extends EventEmitter {
  163713. constructor(i) {
  163714. super();
  163715. Tt(this, "effects", new Map);
  163716. Tt(this, "room");
  163717. this.room = i
  163718. }
  163719. async addEffect(i) {
  163720. var d;
  163721. const {jsonPath: o, id: s, type: c=IEffectType.SubSequence} = i;
  163722. try {
  163723. this.effects.get(s) && ((d = this.effects.get(s)) == null || d.dispose());
  163724. const _ = new dr.subEffect({
  163725. id: s,
  163726. jsonPath: o,
  163727. type: c,
  163728. room: this.room
  163729. });
  163730. return this.effects.set(s, _),
  163731. await _.init(),
  163732. _
  163733. } catch (_) {
  163734. return this.effects.delete(s),
  163735. log$8.error(_),
  163736. Promise.reject(_)
  163737. }
  163738. }
  163739. clearEffects() {
  163740. this.effects.forEach(i=>{
  163741. i.dispose(),
  163742. this.effects.delete(i.id)
  163743. }
  163744. )
  163745. }
  163746. removeEffect(i) {
  163747. const o = this.effects.get(i);
  163748. o == null || o.dispose(),
  163749. o && this.effects.delete(o.id)
  163750. }
  163751. }
  163752. ;
  163753. let XverseEffectManager = dr;
  163754. Tt(XverseEffectManager, "subEffect", XverseEffect);
  163755. Scene.DoubleClickDelay = 500;
  163756. class StaticMeshEvent extends EventEmitter {
  163757. constructor(i) {
  163758. super();
  163759. Tt(this, "scene");
  163760. Tt(this, "_staringPointerTime", -1);
  163761. Tt(this, "_pickedMeshID", "0");
  163762. Tt(this, "_pointerDownTime", -1);
  163763. Tt(this, "_currentPickPoint");
  163764. Tt(this, "_longPressDelay", 500);
  163765. Tt(this, "_pointerTapDelay", 200);
  163766. Tt(this, "_pickedMeshType");
  163767. Tt(this, "registerEvent", ()=>{
  163768. this.scene.onPrePointerObservable.add(this.onDown, PointerEventTypes.POINTERDOWN),
  163769. this.scene.onPrePointerObservable.add(this.onUp, PointerEventTypes.POINTERUP),
  163770. this.scene.onPrePointerObservable.add(this.onDoubleTap, PointerEventTypes.POINTERDOUBLETAP),
  163771. this.scene.onDispose = ()=>{
  163772. this.scene.onPrePointerObservable.removeCallback(this.onUp),
  163773. this.scene.onPrePointerObservable.removeCallback(this.onDown),
  163774. this.scene.onPrePointerObservable.removeCallback(this.onDoubleTap)
  163775. }
  163776. }
  163777. );
  163778. Tt(this, "onUp", ()=>{
  163779. if (Date.now() - this._pointerDownTime < this._pointerTapDelay && !this.scene._inputManager._isPointerSwiping()) {
  163780. this.scene._inputManager._totalPointersPressed = 0;
  163781. const i = this._currentPickPoint;
  163782. i != null && this.emit("pointTap", i)
  163783. }
  163784. }
  163785. );
  163786. Tt(this, "onDown", ()=>{
  163787. const i = this.onPointerTap(o=>o.isPickable);
  163788. this._currentPickPoint = i,
  163789. this._pointerDownTime = Date.now()
  163790. }
  163791. );
  163792. Tt(this, "onDoubleTap", ()=>{
  163793. const i = this.onPointerTap(void 0);
  163794. i != null && this.emit("pointDoubleTap", i)
  163795. }
  163796. );
  163797. this.manager = i,
  163798. this.scene = i.Scene,
  163799. this.registerEvent(),
  163800. this._currentPickPoint = null,
  163801. this._pickedMeshType = null
  163802. }
  163803. onPointerTap(i, o=!1) {
  163804. var c, d;
  163805. let s = new PickingInfo;
  163806. if (o) {
  163807. const _ = this.scene.multiPick(this.scene.pointerX, this.scene.pointerY, i, void 0, void 0);
  163808. _ && _.length > 1 ? s = _[1] : _ && (s = _[0])
  163809. } else
  163810. s = this.scene.pick(this.scene.pointerX, this.scene.pointerY, i, !1, null);
  163811. if (s.hit) {
  163812. const _ = (c = s == null ? void 0 : s.pickedPoint) == null ? void 0 : c.asArray();
  163813. if (_) {
  163814. const [b,k,j] = _
  163815. , $ = xversePosition2Ue4({
  163816. x: b,
  163817. y: k,
  163818. z: j
  163819. });
  163820. return {
  163821. name: (d = s.pickedMesh) == null ? void 0 : d.name,
  163822. type: s.pickedMesh.xtype,
  163823. id: s.pickedMesh.xid,
  163824. point: $
  163825. }
  163826. }
  163827. }
  163828. return null
  163829. }
  163830. }
  163831. class RotationEvent {
  163832. constructor(e) {
  163833. Tt(this, "touchStartX");
  163834. Tt(this, "touchStartY");
  163835. Tt(this, "handelResize");
  163836. Tt(this, "_room");
  163837. Tt(this, "_canvas");
  163838. Tt(this, "handleTouchStart", e=>{
  163839. const i = e.touches[0];
  163840. this.touchStartX = i.pageX,
  163841. this.touchStartY = i.pageY,
  163842. this._room.emit("touchStart", {
  163843. event: e
  163844. })
  163845. }
  163846. );
  163847. Tt(this, "handleMouseDown", e=>{
  163848. this.touchStartX = e.pageX,
  163849. this.touchStartY = e.pageY
  163850. }
  163851. );
  163852. Tt(this, "handleMouseMove", e=>{
  163853. if (!this.touchStartX || !this.touchStartY)
  163854. return;
  163855. const i = e.pageX
  163856. , o = e.pageY
  163857. , s = i - this.touchStartX
  163858. , c = o - this.touchStartY
  163859. , d = this._room.options.canvas.offsetHeight
  163860. , _ = this._room.options.canvas.offsetWidth;
  163861. let b = 2 * c / d
  163862. , k = 2 * s / _;
  163863. b > 1 && (b = 1),
  163864. k > 1 && (k = 1),
  163865. this._room.actionsHandler.rotate({
  163866. pitch: b,
  163867. yaw: k
  163868. }),
  163869. this.touchStartX = i,
  163870. this.touchStartY = o
  163871. }
  163872. );
  163873. Tt(this, "handleMouseUp", e=>{
  163874. this.touchStartX = void 0,
  163875. this.touchStartY = void 0,
  163876. this._room.emit("mouseUp", {
  163877. event: e
  163878. })
  163879. }
  163880. );
  163881. Tt(this, "handleTouchMove", e=>{
  163882. if (!this.touchStartX || !this.touchStartY)
  163883. return;
  163884. const i = e.touches[0]
  163885. , o = i.pageX
  163886. , s = i.pageY
  163887. , c = o - this.touchStartX
  163888. , d = s - this.touchStartY
  163889. , _ = this._room.options.canvas.offsetHeight
  163890. , b = this._room.options.canvas.offsetWidth;
  163891. let k = 2 * d / _
  163892. , j = 2 * c / b;
  163893. k > 1 && (k = 1),
  163894. j > 1 && (j = 1),
  163895. this._room.actionsHandler.rotate({
  163896. pitch: k,
  163897. yaw: j
  163898. }),
  163899. this.touchStartX = o,
  163900. this.touchStartY = s,
  163901. this._room.emit("touchMove", {
  163902. pitch: k,
  163903. yaw: j,
  163904. event: e
  163905. })
  163906. }
  163907. );
  163908. Tt(this, "handleTouchEnd", e=>{
  163909. this._room.emit("touchEnd", {
  163910. event: e
  163911. })
  163912. }
  163913. );
  163914. this._room = e,
  163915. this._canvas = e.canvas,
  163916. this.handelResize = this.reiszeChange()
  163917. }
  163918. init() {
  163919. this._canvas.addEventListener("touchstart", this.handleTouchStart),
  163920. this._canvas.addEventListener("touchmove", this.handleTouchMove),
  163921. this._canvas.addEventListener("touchend", this.handleTouchEnd),
  163922. this._room.scene.preventDefaultOnPointerDown = !1,
  163923. this._room.scene.preventDefaultOnPointerUp = !1,
  163924. this._canvas.addEventListener("mousedown", this.handleMouseDown),
  163925. this._canvas.addEventListener("mousemove", this.handleMouseMove),
  163926. this._canvas.addEventListener("mouseup", this.handleMouseUp)
  163927. }
  163928. clear() {
  163929. this._canvas.removeEventListener("touchstart", this.handleTouchStart),
  163930. this._canvas.removeEventListener("touchmove", this.handleTouchMove),
  163931. this._canvas.removeEventListener("touchend", this.handleTouchEnd),
  163932. this._canvas.removeEventListener("mousedown", this.handleMouseDown),
  163933. this._canvas.removeEventListener("mousemove", this.handleMouseMove),
  163934. this._canvas.removeEventListener("mouseup", this.handleMouseUp)
  163935. }
  163936. reiszeChange() {
  163937. window.addEventListener("resize", ()=>{}
  163938. )
  163939. }
  163940. }
  163941. const log$7 = new Logger("eventsController");
  163942. class EventsController {
  163943. constructor(e) {
  163944. Tt(this, "staticmeshEvent");
  163945. Tt(this, "rotationEvent");
  163946. Tt(this, "resize", ()=>{
  163947. this.room.panorama.actived || this.room.sceneManager.cameraComponent.cameraFovChange(this.room.sceneManager.yuvInfo)
  163948. }
  163949. );
  163950. Tt(this, "clickEvent", e=>{
  163951. const {point: i, name: o, type: s, id: c} = e;
  163952. log$7.debug("pointEvent", e),
  163953. this.room.proxyEvents("pointTap", {
  163954. point: i,
  163955. meshName: o,
  163956. type: s,
  163957. id: c
  163958. }),
  163959. this.room.proxyEvents("_coreClick", e)
  163960. }
  163961. );
  163962. Tt(this, "longPressEvent", e=>{
  163963. this.room.proxyEvents("_corePress", e)
  163964. }
  163965. );
  163966. Tt(this, "handleActionResponseTimeout", ({error: e, event: i})=>{
  163967. this.room.proxyEvents("actionResponseTimeout", {
  163968. error: e,
  163969. event: i
  163970. })
  163971. }
  163972. );
  163973. Tt(this, "handleNetworkStateChange", e=>{
  163974. const {state: i, count: o} = e;
  163975. i == "reconnecting" ? this.room.proxyEvents("reconnecting", {
  163976. count: o || 1
  163977. }) : i === "reconnected" ? (this.room.networkController.rtcp.workers.reset(),
  163978. this.room.proxyEvents("reconnected"),
  163979. this.room.afterReconnected()) : i === "disconnected" && this.room.proxyEvents("disconnected")
  163980. }
  163981. );
  163982. this.room = e,
  163983. this.staticmeshEvent = new StaticMeshEvent(this.room.sceneManager),
  163984. this.rotationEvent = new RotationEvent(e)
  163985. }
  163986. bindEvents() {
  163987. window.addEventListener("orientationchange"in window ? "orientationchange" : "resize", this.resize),
  163988. this.staticmeshEvent.on("pointTap", this.clickEvent),
  163989. this.staticmeshEvent.on("longPress", this.longPressEvent),
  163990. this.rotationEvent.init(),
  163991. eventsManager.on("actionResponseTimeout", this.handleActionResponseTimeout),
  163992. this.room.networkController.on("stateChanged", this.handleNetworkStateChange)
  163993. }
  163994. clearEvents() {
  163995. window.removeEventListener("orientationchange"in window ? "orientationchange" : "resize", this.resize),
  163996. this.staticmeshEvent.off("pointTap", this.clickEvent),
  163997. this.staticmeshEvent.off("longPress", this.longPressEvent),
  163998. eventsManager.off("actionResponseTimeout", this.handleActionResponseTimeout),
  163999. this.room.networkController.off("stateChanged", this.handleNetworkStateChange),
  164000. this.rotationEvent.clear()
  164001. }
  164002. }
  164003. const log$6 = new Logger("panorama");
  164004. class Panorama {
  164005. constructor(e) {
  164006. Tt(this, "_actived", !1);
  164007. Tt(this, "isLoading", !1);
  164008. Tt(this, "handleReceivePanorama", async e=>{
  164009. const i = e.camera;
  164010. log$6.warn("handle panorama", i);
  164011. const o = {
  164012. data: e.data,
  164013. pose: {
  164014. position: i.position,
  164015. rotation: i == null ? void 0 : i.angle
  164016. }
  164017. }
  164018. , s = this.room.sceneManager;
  164019. if (this.room.networkController.rtcp.workers.changePanoMode(!0),
  164020. await s.materialComponent.changePanoImg(0, o),
  164021. !!e.finished)
  164022. if (await s.changePanoShaderForLowModel(0),
  164023. this.room.isPano = !0,
  164024. this._actived = !0,
  164025. i)
  164026. this.room.sceneManager.cameraComponent.changeToFirstPersonView({
  164027. position: i.position,
  164028. rotation: i.angle
  164029. });
  164030. else {
  164031. const {skinId: c, pathName: d} = this.room.currentState;
  164032. if (!c || !d)
  164033. return;
  164034. const _ = await this.room.modelManager.findRoute(c, d)
  164035. , {camera: b} = getRandomItem(_.birthPointList) || {};
  164036. b && this.room.sceneManager.cameraComponent.changeToFirstPersonView(Zt($t({}, b), {
  164037. rotation: b.angle
  164038. }))
  164039. }
  164040. }
  164041. );
  164042. this.room = e
  164043. }
  164044. get actived() {
  164045. return this._actived
  164046. }
  164047. bindListener(e) {
  164048. this.room.networkController.rtcp.workers.registerFunction("panorama", o=>{
  164049. var b;
  164050. log$6.warn("receive panorama");
  164051. const {metadata: s} = o
  164052. , c = JSON.parse(String.fromCharCode.apply(null, s));
  164053. o.parsedMetaData = c;
  164054. const d = (b = o.parsedMetaData.newUserStates) == null ? void 0 : b.find(k=>k.userId === this.room.userId)
  164055. , _ = d == null ? void 0 : d.playerState.camera;
  164056. o.camera = _,
  164057. eventsManager.remove(o.parsedMetaData.traceIds[0], Codes$1.Success, o, !0),
  164058. this.room.isFirstDataUsed || (this.room.isFirstDataUsed = !0,
  164059. this.handleReceivePanorama(o).then(e))
  164060. }
  164061. )
  164062. }
  164063. access(e, i, o) {
  164064. this.isLoading = !0;
  164065. const {camera: s, player: c, attitude: d, areaName: _, pathName: b, tag: k} = e;
  164066. return this.room.actionsHandler.requestPanorama({
  164067. camera: s,
  164068. player: c,
  164069. attitude: d,
  164070. areaName: _,
  164071. pathName: b,
  164072. tag: k
  164073. }, i, o).then(j=>(this.isLoading = !1,
  164074. this.handleReceivePanorama(j))).catch(j=>(this.isLoading = !1,
  164075. Promise.reject(j)))
  164076. }
  164077. exit(e) {
  164078. const {camera: i, player: o, attitude: s, areaName: c, pathName: d} = e;
  164079. return this.room.networkController.rtcp.workers.changePanoMode(!1),
  164080. this.room.actionsHandler.changeRotationRenderType({
  164081. renderType: RenderType.RotationVideo,
  164082. player: o,
  164083. camera: i,
  164084. attitude: s,
  164085. areaName: c,
  164086. pathName: d
  164087. }).then(()=>this.handleExitPanorama()).catch(_=>(this.room.networkController.rtcp.workers.changePanoMode(!0),
  164088. Promise.reject(_)))
  164089. }
  164090. handleExitPanorama() {
  164091. var e, i, o, s, c, d;
  164092. this.room.isPano = !1,
  164093. this._actived = !1,
  164094. (s = (e = this.room.sceneManager) == null ? void 0 : e.cameraComponent) == null || s.forceChangeSavedCameraPose({
  164095. position: (i = this.room._currentClickingState) == null ? void 0 : i.camera.position,
  164096. rotation: (o = this.room._currentClickingState) == null ? void 0 : o.camera.angle
  164097. }),
  164098. this.room.sceneManager.changeVideoShaderForLowModel(),
  164099. (d = (c = this.room.sceneManager) == null ? void 0 : c.cameraComponent) == null || d.changeToThirdPersonView()
  164100. }
  164101. }
  164102. class PathManager {
  164103. constructor() {
  164104. Tt(this, "currentArea", "");
  164105. Tt(this, "currentPathName", "");
  164106. Tt(this, "currentAttitude", "");
  164107. Tt(this, "speed", 0)
  164108. }
  164109. getSpeed(e) {
  164110. const i = {
  164111. guangchang: {
  164112. [MotionType.Walk]: 17,
  164113. [MotionType.Run]: 51
  164114. },
  164115. tower: {
  164116. [MotionType.Walk]: 12.5,
  164117. [MotionType.Run]: 25
  164118. },
  164119. zhiboting: {
  164120. [MotionType.Walk]: 12.5,
  164121. [MotionType.Run]: 25
  164122. },
  164123. youxiting: {
  164124. [MotionType.Walk]: 12.5,
  164125. [MotionType.Run]: 25
  164126. },
  164127. diqing: {
  164128. [MotionType.Walk]: 12.5,
  164129. [MotionType.Run]: 25
  164130. }
  164131. }
  164132. , o = i[this.currentArea] || i.guangchang;
  164133. return this.speed = o[e] * 30,
  164134. this.speed
  164135. }
  164136. }
  164137. const log$5 = new Logger("http");
  164138. class Http extends EventEmitter {
  164139. constructor() {
  164140. super(...arguments);
  164141. Tt(this, "secondArray", new SecondArray)
  164142. }
  164143. async get({url: i, useIndexedDb: o=!1, timeout: s=15e3, key: c, isOutPutObjectURL: d=!0}) {
  164144. if (Xverse$1.NO_CACHE !== void 0 && (o = !Xverse$1.NO_CACHE),
  164145. o)
  164146. if (isIndexedDbSupported()) {
  164147. window.performance.now();
  164148. let _ = null;
  164149. try {
  164150. _ = await modelTable.query("url", i)
  164151. } catch (b) {
  164152. return log$5.debug(b),
  164153. log$5.warn("cache query error", i),
  164154. Promise.resolve(i)
  164155. }
  164156. if (_ && _.model) {
  164157. let b = null;
  164158. const k = Date.now();
  164159. if (_.model instanceof Blob ? b = _.model : b = dataURItoBlob(_.model),
  164160. !b)
  164161. return Promise.reject("blob is null");
  164162. const j = Date.now();
  164163. this.secondArray.add(j - k);
  164164. const $ = Promise.resolve(d ? URL.createObjectURL(b) : b);
  164165. return window.performance.now(),
  164166. $
  164167. } else
  164168. return this.request({
  164169. url: i,
  164170. timeout: s,
  164171. contentType: "blob",
  164172. key: c
  164173. }).then(async b=>{
  164174. const k = await blobToDataURI(b.response);
  164175. try {
  164176. await modelTable.put({
  164177. url: i,
  164178. model: k
  164179. })
  164180. } catch (j) {
  164181. log$5.warn("unable to add data to indexedDB", j)
  164182. }
  164183. return Promise.resolve(d ? URL.createObjectURL(b.response) : b.response)
  164184. }
  164185. )
  164186. } else
  164187. return this.request({
  164188. url: i,
  164189. timeout: s,
  164190. contentType: "blob",
  164191. key: c
  164192. }).then(_=>{
  164193. const b = _.response;
  164194. return Promise.resolve(d ? URL.createObjectURL(b) : b)
  164195. }
  164196. ).catch(_=>Promise.reject(_));
  164197. else
  164198. return this.request({
  164199. url: i,
  164200. timeout: s,
  164201. key: c
  164202. }).then(_=>_.getResponseHeader("content-type") === "application/json" ? Promise.resolve(JSON.parse(_.responseText)) : Promise.resolve(_.responseText))
  164203. }
  164204. request(i) {
  164205. const {timeout: o=3e4, contentType: s, key: c, onRequestStart: d} = i
  164206. , {url: _} = i;
  164207. return new Promise((b,k)=>{
  164208. window.performance.now();
  164209. const j = new XMLHttpRequest;
  164210. s && (j.responseType = s),
  164211. j.timeout = o,
  164212. j.addEventListener("readystatechange", ()=>{
  164213. if (j.readyState == 4) {
  164214. if (j.status == 200)
  164215. return window.performance.now(),
  164216. this.emit("loadend", {
  164217. message: `request ${_} load success`
  164218. }),
  164219. b(j);
  164220. {
  164221. const $ = `Unable to load the request ${_}`;
  164222. return this.emit("error", {
  164223. message: $
  164224. }),
  164225. log$5.error($),
  164226. k($)
  164227. }
  164228. }
  164229. }
  164230. ),
  164231. d && d(j),
  164232. j.open("GET", _),
  164233. j.send()
  164234. }
  164235. )
  164236. }
  164237. }
  164238. const http = new Http
  164239. , isIndexedDbSupported = ()=>(window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB) !== void 0
  164240. , blobToDataURI = async a=>new Promise((e,i)=>{
  164241. const o = new FileReader;
  164242. o.readAsDataURL(a),
  164243. o.onload = function(s) {
  164244. var c;
  164245. e((c = s.target) == null ? void 0 : c.result)
  164246. }
  164247. ,
  164248. o.onerror = function(s) {
  164249. i(s)
  164250. }
  164251. }
  164252. )
  164253. , dataURItoBlob = a=>{
  164254. let e;
  164255. a.split(",")[0].indexOf("base64") >= 0 ? e = atob(a.split(",")[1]) : e = unescape(a.split(",")[1]);
  164256. const i = a.split(",")[0].split(":")[1].split(";")[0]
  164257. , o = new Uint8Array(e.length);
  164258. for (let c = 0; c < e.length; c++)
  164259. o[c] = e.charCodeAt(c);
  164260. return new Blob([o],{
  164261. type: i
  164262. })
  164263. }
  164264. , log$4 = new Logger("xverse-signal");
  164265. class Signal {
  164266. constructor(e) {
  164267. Tt(this, "_room");
  164268. Tt(this, "signalHandleActived", !0);
  164269. Tt(this, "isUpdatedYUV", !0);
  164270. Tt(this, "handleSignalSecondArray", new SecondArray);
  164271. Tt(this, "handleSignalPartialArray2", new SecondArray);
  164272. Tt(this, "handleSignalPartialArray3", new SecondArray);
  164273. Tt(this, "handleSignalPartialArray4", new SecondArray);
  164274. Tt(this, "handleSignalPartialArray5", new SecondArray);
  164275. Tt(this, "handleSignalPartialArray6", new SecondArray);
  164276. Tt(this, "handleSignalPartialArray7", new SecondArray);
  164277. this._room = e
  164278. }
  164279. getSignalStat() {
  164280. const e = this.handleSignalSecondArray.getStat()
  164281. , i = this.handleSignalPartialArray2.getStat().max
  164282. , o = this.handleSignalPartialArray3.getStat().max
  164283. , s = this.handleSignalPartialArray4.getStat().max
  164284. , c = this.handleSignalPartialArray5.getStat().max
  164285. , d = this.handleSignalPartialArray6.getStat().max
  164286. , _ = this.handleSignalPartialArray7.getStat().max
  164287. , b = http.secondArray.getStat();
  164288. return {
  164289. sdkAvg: e.avg,
  164290. sdkMax: e.max,
  164291. blobSum: b.sum,
  164292. blobMax: b.max,
  164293. partialMax: [i, o, s, c, d, _]
  164294. }
  164295. }
  164296. handleSignal(e, i) {
  164297. var tt, rt, it;
  164298. if (!this.signalHandleActived)
  164299. return;
  164300. const o = Date.now()
  164301. , {signal: s, alreadyUpdateYUV: c} = e;
  164302. this.handleActionResponses(s),
  164303. this._room.handleSignalHook(s);
  164304. const d = Date.now();
  164305. if (this.handleSignalPartialArray2.add(d - o),
  164306. !c) {
  164307. const nt = (tt = s.newUserStates) == null ? void 0 : tt.find(ot=>ot.userId === this._room.userId);
  164308. if ((nt == null ? void 0 : nt.renderInfo) && ((rt = this._room._userAvatar) == null ? void 0 : rt.isMoving)) {
  164309. log$4.debug("stream stoped, make avatar to stop");
  164310. const {isMoving: ot, isRotating: at} = nt.renderInfo;
  164311. this._room.avatarManager._updateAvatarMovingStatus({
  164312. id: nt.userId,
  164313. isMoving: !!ot,
  164314. isRotating: !!at
  164315. })
  164316. }
  164317. return
  164318. }
  164319. this.isUpdatedYUV = c;
  164320. const _ = s;
  164321. if (!s) {
  164322. log$4.warn("metadata signal is empty");
  164323. return
  164324. }
  164325. if (_.actionType === Actions.GetNewUserState) {
  164326. eventsManager.remove(_.traceId, _.code, _);
  164327. return
  164328. }
  164329. if (_.code === Codes$1.RepeatLogin) {
  164330. this._room.handleRepetLogin();
  164331. return
  164332. }
  164333. if (_.code !== void 0 && _.code !== Codes$1.Success && _.code !== Codes$1.ActionMaybeDelay && _.code !== Codes$1.DoActionBlocked && _.code !== Codes$1.GetOnVehicle)
  164334. if (_.code === Codes$1.UnReachable)
  164335. log$4.debug("signal errcode: ", _.code),
  164336. this._room.proxyEvents("unreachable");
  164337. else {
  164338. if (!this._room.joined) {
  164339. const nt = getErrorByCode(_.code)
  164340. , ot = new nt(_.msg);
  164341. i(ot)
  164342. }
  164343. log$4.error("signal errcode: ", _),
  164344. this._room.emit("error", _)
  164345. }
  164346. const b = Date.now();
  164347. this.handleSignalPartialArray3.add(b - d);
  164348. const k = (it = _.newUserStates) == null ? void 0 : it.find(nt=>nt.userId === this._room.userId);
  164349. if (_.broadcastAction)
  164350. try {
  164351. const nt = JSON.parse(_.broadcastAction.data);
  164352. Broadcast.handlers.forEach(ot=>ot(nt))
  164353. } catch (nt) {
  164354. log$4.error(nt)
  164355. }
  164356. const j = Date.now();
  164357. this.handleSignalPartialArray4.add(j - b),
  164358. _.newUserStates && _.newUserStates.length > 0 && this._room.avatarManager.handleAvatar(_);
  164359. const $ = Date.now();
  164360. if (this.handleSignalPartialArray5.add($ - j),
  164361. k != null && k.playerState) {
  164362. this._room._currentClickingState = k.playerState;
  164363. const {pathName: nt, attitude: ot, areaName: at, skinId: st} = k.playerState;
  164364. if (nt && (this._room.pathManager.currentPathName = nt,
  164365. this._room.updateCurrentState({
  164366. pathName: nt
  164367. })),
  164368. at && this._room.updateCurrentState({
  164369. areaName: at
  164370. }),
  164371. ot) {
  164372. const ut = this._room.skin.routeList.find(lt=>lt.areaName === this._room.currentState.areaName)
  164373. , ct = ((ut == null ? void 0 : ut.step) || 7.5) * 30;
  164374. this._room.updateCurrentState({
  164375. speed: ct,
  164376. attitude: ot
  164377. }),
  164378. this._room.pathManager.currentAttitude = ot,
  164379. this._room._userAvatar && (this._room._userAvatar.motionType = ot)
  164380. }
  164381. this._room.sceneManager.getCurrentShaderMode() !== ECurrentShaderMode.pano && !this._room.isPano && k.playerState.camera && !this._room.panorama.isLoading && this._room.camera.setCameraPose(k.playerState.camera)
  164382. }
  164383. k != null && k.renderInfo && this._room.camera.handleRenderInfo(k);
  164384. const _e = Date.now();
  164385. if (this.handleSignalPartialArray6.add(_e - $),
  164386. _.actionType !== void 0) {
  164387. const {actionType: nt, code: ot, echoMsg: at, traceId: st} = _;
  164388. nt === Actions.Echo && ot === Codes$1.Success && this._room.networkController.rtcp.heartbeat.pong(at, st),
  164389. ot !== Codes$1.Success ? eventsManager.remove(st, ot) : [Actions.GetReserveStatus, Actions.Broadcast, Actions.ChangeNickname, Actions.ConfirmEvent, Actions.ReserveSeat, Actions.Rotation, Actions.TurnTo, Actions.RotateTo, Actions.SetPlayerState, Actions.GetNeighborPoints, Actions.TurnToFace, Actions.AudienceChangeToVisitor, Actions.RemoveVisitor, Actions.GetUserWithAvatar, Actions.GetNewUserState, Actions.SetSyncPolicy].includes(nt) && eventsManager.remove(st, ot, _)
  164390. }
  164391. const et = Date.now();
  164392. this.handleSignalSecondArray.add(et - o),
  164393. this.handleSignalPartialArray7.add(et - _e)
  164394. }
  164395. handleActionResponses(e) {
  164396. !(e != null && e.actionResponses) || e.actionResponses.length === 0 || e.actionResponses.forEach(i=>{
  164397. if (i.actionType == null)
  164398. return;
  164399. const {pointType: o, extra: s, actionType: c, traceId: d, code: _, msg: b} = i;
  164400. c === Actions.GetNeighborPoints ? eventsManager.remove(d, _, i.nps) : c === Actions.GetUserWithAvatar ? eventsManager.remove(d, _, i.userWithAvatarList) : eventsManager.remove(d, _, b),
  164401. o === PointType.Path && c === Actions.Clicking && (this._room.moveToExtra = decodeURIComponent(s))
  164402. }
  164403. )
  164404. }
  164405. }
  164406. const BREATH_POINT_TYPE = "debugBreathPoint"
  164407. , TAP_BREATH_POINT_TYPE = "debugTapBreathPoint"
  164408. , DEFAULT_SEARCH_RANGE = 1e3;
  164409. class Debug {
  164410. constructor(e) {
  164411. Tt(this, "isShowNearbyBreathPoints", !1);
  164412. Tt(this, "isShowTapBreathPoints", !1);
  164413. Tt(this, "isSceneShading", !0);
  164414. Tt(this, "searchRange", DEFAULT_SEARCH_RANGE);
  164415. Tt(this, "nearbyBreathPointListening", !1);
  164416. Tt(this, "tapBreathPointListening", !1);
  164417. Tt(this, "dumpStreamTimer", 0);
  164418. this.room = e
  164419. }
  164420. toggleStats() {
  164421. return this.room.stats.isShow ? this.room.stats.hide() : this.room.stats.show()
  164422. }
  164423. toggleNearbyBreathPoint(e=DEFAULT_SEARCH_RANGE) {
  164424. this.searchRange = e,
  164425. this.isShowNearbyBreathPoints = !this.isShowNearbyBreathPoints,
  164426. this.isShowNearbyBreathPoints ? (this.getPointsAndRender(),
  164427. this.setupNearbyBreathPointListener()) : this.room.breathPointManager.clearBreathPoints(BREATH_POINT_TYPE)
  164428. }
  164429. toggleTapBreathPoint() {
  164430. this.isShowTapBreathPoints = !this.isShowTapBreathPoints,
  164431. this.isShowTapBreathPoints ? this.setupTapPointListener() : this.room.breathPointManager.clearBreathPoints(TAP_BREATH_POINT_TYPE)
  164432. }
  164433. dumpStream(e, i=10 * 1e3) {
  164434. if (this.dumpStreamTimer)
  164435. throw new Error("dumpStream running");
  164436. this.room.networkController.rtcp.workers.saveframe = !0,
  164437. this.dumpStreamTimer = window.setTimeout(()=>{
  164438. this.room.networkController.rtcp.workers.SaveMediaStream = !0,
  164439. this.dumpStreamTimer = 0,
  164440. e && e()
  164441. }
  164442. , i)
  164443. }
  164444. toggleSceneshading() {
  164445. this.isSceneShading = !this.isSceneShading,
  164446. this.isSceneShading ? this.room.sceneManager.changeVideoShaderForLowModel() : this.room.sceneManager.changeDefaultShaderForLowModel()
  164447. }
  164448. setupTapPointListener() {
  164449. this.tapBreathPointListening || (this.tapBreathPointListening = !0,
  164450. this.room.on("_coreClick", ({point: e})=>{
  164451. this.isShowTapBreathPoints && this.renderTapBreathPoint({
  164452. id: "tapToint",
  164453. position: e
  164454. })
  164455. }
  164456. ))
  164457. }
  164458. renderTapBreathPoint({position: e, id: i}) {
  164459. let o;
  164460. if (o = this.room.breathPointManager.breathPoints.get(i)) {
  164461. o.position = e;
  164462. return
  164463. }
  164464. this.room.breathPointManager.addBreathPoint({
  164465. id: i,
  164466. position: e,
  164467. type: TAP_BREATH_POINT_TYPE,
  164468. size: .8,
  164469. forceLeaveGround: !0,
  164470. billboardMode: !0,
  164471. rotation: Math.abs(e.z) < 20 ? {
  164472. pitch: 90,
  164473. yaw: 0,
  164474. roll: 0
  164475. } : {
  164476. pitch: 0,
  164477. yaw: 270,
  164478. roll: 0
  164479. }
  164480. })
  164481. }
  164482. setupNearbyBreathPointListener() {
  164483. var e;
  164484. this.nearbyBreathPointListening || (this.nearbyBreathPointListening = !0,
  164485. (e = this.room._userAvatar) == null || e.on("stopMoving", ()=>{
  164486. this.isShowNearbyBreathPoints && this.getPointsAndRender()
  164487. }
  164488. ))
  164489. }
  164490. async getPointsAndRender() {
  164491. var o, s;
  164492. const e = this.searchRange
  164493. , i = ((o = this.room._userAvatar) == null ? void 0 : o.position) && await this.getNeighborPoints({
  164494. point: (s = this.room._userAvatar) == null ? void 0 : s.position,
  164495. containSelf: !0,
  164496. searchRange: e
  164497. }) || [];
  164498. this.room.breathPointManager.breathPoints.forEach(c=>{
  164499. !!i.find(_=>JSON.stringify(_) === c._id) || this.room.breathPointManager.clearBreathPoints(c._id)
  164500. }
  164501. ),
  164502. i.forEach(c=>{
  164503. const d = JSON.stringify(c);
  164504. this.room.breathPointManager.breathPoints.get(d) || this.room.breathPointManager.addBreathPoint({
  164505. id: d,
  164506. position: c,
  164507. type: BREATH_POINT_TYPE,
  164508. rotation: {
  164509. pitch: 90,
  164510. yaw: 0,
  164511. roll: 0
  164512. },
  164513. forceLeaveGround: !0
  164514. })
  164515. }
  164516. )
  164517. }
  164518. getNeighborPoints(e) {
  164519. const {point: i, containSelf: o=!1, searchRange: s=500} = e;
  164520. return this.room.actionsHandler.getNeighborPoints({
  164521. point: i,
  164522. containSelf: o,
  164523. searchRange: s
  164524. })
  164525. }
  164526. }
  164527. const log$3 = new Logger("xverse-room");
  164528. class XverseRoom$1 extends EventEmitter {
  164529. constructor(i) {
  164530. super();
  164531. Tt(this, "disableAutoTurn", !1);
  164532. Tt(this, "options");
  164533. Tt(this, "_currentNetworkOptions");
  164534. Tt(this, "lastSkinId");
  164535. Tt(this, "debug");
  164536. Tt(this, "isFirstDataUsed", !1);
  164537. Tt(this, "userId", null);
  164538. Tt(this, "pathManager", new PathManager);
  164539. Tt(this, "networkController");
  164540. Tt(this, "_startTime", Date.now());
  164541. Tt(this, "canvas");
  164542. Tt(this, "modelManager");
  164543. Tt(this, "eventsController");
  164544. Tt(this, "panorama");
  164545. Tt(this, "engineProxy");
  164546. Tt(this, "_id");
  164547. Tt(this, "skinList", []);
  164548. Tt(this, "isHost", !1);
  164549. Tt(this, "avatarManager", new XverseAvatarManager(this));
  164550. Tt(this, "effectManager", new XverseEffectManager(this));
  164551. Tt(this, "sceneManager");
  164552. Tt(this, "scene");
  164553. Tt(this, "breathPointManager");
  164554. Tt(this, "_currentState");
  164555. Tt(this, "joined", !1);
  164556. Tt(this, "disableRotate", !1);
  164557. Tt(this, "isPano", !1);
  164558. Tt(this, "movingByClick", !1);
  164559. Tt(this, "camera", new Camera(this));
  164560. Tt(this, "stats", new Stats(this));
  164561. Tt(this, "isUpdatedRawYUVData", !1);
  164562. Tt(this, "actionsHandler", new ActionsHandler(this));
  164563. Tt(this, "_currentClickingState", null);
  164564. Tt(this, "signal", new Signal(this));
  164565. Tt(this, "allowRender", !0);
  164566. Tt(this, "firstFrameTimestamp");
  164567. Tt(this, "receiveRtcData", async()=>{
  164568. log$3.info("Invoke receiveRtcData");
  164569. let i = !1
  164570. , o = !1
  164571. , s = !1
  164572. , c = !1;
  164573. return this.viewMode === "serverless" ? (log$3.warn("set view mode to serverless"),
  164574. this.setViewMode("observer").then(()=>this, ()=>this)) : new Promise((d,_)=>{
  164575. const b = this.networkController.rtcp.workers;
  164576. b.registerFunction("signal", k=>{
  164577. this.signal.handleSignal(k, _)
  164578. }
  164579. ),
  164580. b.registerFunction("stream", k=>{
  164581. var j;
  164582. if (this.emit("streamTimestamp", {
  164583. timestamp: Date.now()
  164584. }),
  164585. o || (o = !0,
  164586. log$3.info("Invoke stream event")),
  164587. k.stream) {
  164588. s || (s = !0,
  164589. log$3.info("Invoke updateRawYUVData")),
  164590. this.isUpdatedRawYUVData = !1;
  164591. const $ = (j = this._currentState.skin) == null ? void 0 : j.fov;
  164592. this.sceneManager.materialComponent.updateRawYUVData(k.stream, k.width, k.height, $),
  164593. this.isUpdatedRawYUVData = !0
  164594. }
  164595. i || (log$3.info("Invoke isAfterRenderRegistered"),
  164596. i = !0,
  164597. this.scene.registerAfterRender(()=>{
  164598. this.engineProxy.frameRenderNumber >= 2 && (c || (c = !0,
  164599. log$3.info("Invoke registerAfterRender")),
  164600. this.isFirstDataUsed || (log$3.info("Invoke isStreamAvailable"),
  164601. this.isFirstDataUsed = !0,
  164602. this.firstFrameTimestamp = Date.now(),
  164603. d(this),
  164604. this.afterJoinRoom()))
  164605. }
  164606. ))
  164607. }
  164608. ),
  164609. this.panorama.bindListener(()=>{
  164610. d(this),
  164611. this.afterJoinRoom()
  164612. }
  164613. ),
  164614. b.registerFunction("reconnectedFrame", ()=>{}
  164615. ),
  164616. log$3.info("Invoke decoderWorker.postMessage"),
  164617. b.decoderWorker.postMessage({
  164618. t: 5
  164619. })
  164620. }
  164621. )
  164622. }
  164623. );
  164624. Tt(this, "moveToExtra", "");
  164625. this.options = i,
  164626. this.options.wsServerUrl || (this.options.wsServerUrl = SERVER_URLS.DEV),
  164627. this.modelManager = ModelManager.getInstance(i.appId, i.releaseId),
  164628. this.updateReporter();
  164629. const c = i
  164630. , {canvas: o} = c
  164631. , s = gr(c, ["canvas"]);
  164632. log$3.infoAndReportMeasurement({
  164633. metric: "startJoinRoomAt",
  164634. startTime: Date.now(),
  164635. group: "joinRoom",
  164636. extra: s,
  164637. value: 0
  164638. })
  164639. }
  164640. get currentNetworkOptions() {
  164641. return this._currentNetworkOptions
  164642. }
  164643. get viewMode() {
  164644. var i;
  164645. return ((i = this._currentState) == null ? void 0 : i.viewMode) || "full"
  164646. }
  164647. get id() {
  164648. return this._id
  164649. }
  164650. get skinId() {
  164651. return this._currentState.skinId
  164652. }
  164653. get skin() {
  164654. return this._currentState.skin
  164655. }
  164656. get sessionId() {
  164657. return this.currentNetworkOptions.sessionId
  164658. }
  164659. get pictureQualityLevel() {
  164660. return this.currentState.pictureQualityLevel
  164661. }
  164662. get avatars() {
  164663. return Array.from(this.avatarManager.avatars.values())
  164664. }
  164665. get currentState() {
  164666. var i;
  164667. return Zt($t({}, this._currentState), {
  164668. state: (i = this.networkController) == null ? void 0 : i._state
  164669. })
  164670. }
  164671. get _userAvatar() {
  164672. return this.avatars.find(i=>i.userId === this.userId)
  164673. }
  164674. get tvs() {
  164675. return this.engineProxy._tvs
  164676. }
  164677. get tv() {
  164678. return this.tvs[0]
  164679. }
  164680. get currentClickingState() {
  164681. return this._currentClickingState
  164682. }
  164683. afterJoinRoomHook() {}
  164684. beforeJoinRoomResolveHook() {}
  164685. afterReconnectedHook() {}
  164686. handleSignalHook(i) {}
  164687. skinChangedHook() {}
  164688. async beforeStartGameHook(i) {}
  164689. afterLoadAssetsHook() {}
  164690. afterUserAvatarLoadedHook() {}
  164691. audienceViewModeHook(i) {}
  164692. setViewModeToObserver() {}
  164693. handleVehicleHook(i) {}
  164694. updateReporter() {
  164695. const {avatarId: i, skinId: o, userId: s, roomId: c, role: d, appId: _, wsServerUrl: b} = this.options;
  164696. reporter.updateHeader({
  164697. userId: s
  164698. }),
  164699. reporter.updateBody({
  164700. roomId: c,
  164701. role: d,
  164702. skinId: o,
  164703. avatarId: i,
  164704. appId: _,
  164705. wsServerUrl: b
  164706. })
  164707. }
  164708. async initRoom() {
  164709. const {timeout: i=DEFAULT_JOINROOM_TIMEOUT} = this.options;
  164710. return isSupported() ? this._initRoom()._timeout(i, new TimeoutError("initRoom timeout")) : Promise.reject(new UnsupportedError)
  164711. }
  164712. async _initRoom() {
  164713. const i = this.validateOptions(this.options);
  164714. if (i)
  164715. return log$3.error("initRoom param error", i),
  164716. Promise.reject(i);
  164717. const {canvas: o, avatarId: s, skinId: c, userId: d, wsServerUrl: _, role: b, token: k, pageSession: j, rotationRenderType: $, isAllSync: _e=!1, appId: et, camera: tt, player: rt, avatarComponents: it, nickname: nt, avatarScale: ot, firends: at=[], syncByEvent: st=!1, areaName: ut, attitude: ct=MotionType.Walk, pathName: lt, viewMode: ft="full", person: ht, roomId: pt, roomTypeId: dt, hasAvatar: _t=!1, syncToOthers: mt=!1, prioritySync: vt=!1, removeWhenDisconnected: yt=!0, extra: Et} = this.options;
  164718. this.setCurrentNetworkOptions({
  164719. avatarId: s,
  164720. skinId: c,
  164721. roomId: pt,
  164722. userId: d,
  164723. wsServerUrl: _,
  164724. role: b,
  164725. token: k,
  164726. pageSession: j,
  164727. rotationRenderType: $,
  164728. isAllSync: _e,
  164729. appId: et,
  164730. camera: tt,
  164731. player: rt,
  164732. avatarComponents: it,
  164733. nickname: nt,
  164734. avatarScale: ot,
  164735. firends: at,
  164736. syncByEvent: st,
  164737. areaName: ut,
  164738. attitude: ct,
  164739. pathName: lt,
  164740. person: ht,
  164741. roomTypeId: dt,
  164742. hasAvatar: _t,
  164743. syncToOthers: mt,
  164744. prioritySync: vt,
  164745. extra: Et,
  164746. removeWhenDisconnected: yt
  164747. }),
  164748. this.userId = d,
  164749. this.canvas = o,
  164750. ut && (this.pathManager.currentArea = ut),
  164751. this.networkController = new NetworkController(this),
  164752. this.setCurrentState({
  164753. areaName: ut,
  164754. pathName: lt,
  164755. attitude: ct,
  164756. speed: 0,
  164757. viewMode: ft,
  164758. state: this.networkController._state,
  164759. skinId: c
  164760. });
  164761. try {
  164762. await Promise.all([this.initNetwork(), this.initConfig(), this.initWasm()]),
  164763. log$3.info("network config wasm all ready, start to create game");
  164764. const At = await this.requestCreateRoom({
  164765. skinId: c
  164766. })
  164767. , gt = At.routeList.find(xt=>xt.areaName === ut)
  164768. , St = ((gt == null ? void 0 : gt.step) || 7.5) * 30;
  164769. this.updateCurrentState({
  164770. skin: At,
  164771. skinId: At.id,
  164772. versionId: At.versionId,
  164773. speed: St
  164774. }),
  164775. await this.initEngine(At)
  164776. } catch (At) {
  164777. return Promise.reject(At)
  164778. }
  164779. return this.beforeJoinRoomResolve(),
  164780. this.receiveRtcData()
  164781. }
  164782. beforeJoinRoomResolve() {
  164783. this.setupStats(),
  164784. this.eventsController = new EventsController(this),
  164785. this.eventsController.bindEvents(),
  164786. this.panorama = new Panorama(this),
  164787. this.beforeJoinRoomResolveHook()
  164788. }
  164789. afterJoinRoom() {
  164790. this.joined = !0,
  164791. this.viewMode === "observer" && this.setViewModeToObserver(),
  164792. log$3.infoAndReportMeasurement({
  164793. tag: this.viewMode,
  164794. value: this.firstFrameTimestamp || Date.now() - this._startTime,
  164795. startTime: Date.now(),
  164796. metric: "joinRoom",
  164797. reportOptions: {
  164798. immediate: !0
  164799. }
  164800. }),
  164801. this.camera.initialFov = this.sceneManager.cameraComponent.getCameraFov(),
  164802. this.stats.on("stats", ({stats: i})=>{
  164803. reporter.report("stats", $t({}, i))
  164804. }
  164805. ),
  164806. this.debug = new Debug(this),
  164807. this.afterJoinRoomHook(),
  164808. setInterval(()=>{
  164809. this.actionsHandler.getNewUserState(NewUserStateType.NUST_Undefined).then(i=>{
  164810. this.avatarManager.handleAvatar(i)
  164811. }
  164812. ).catch(()=>{}
  164813. )
  164814. }
  164815. , 2e3)
  164816. }
  164817. afterReconnected() {
  164818. this.avatarManager.clearOtherUsers(),
  164819. this.afterReconnectedHook()
  164820. }
  164821. leave() {
  164822. var i, o;
  164823. return log$3.info("Invoke room.leave"),
  164824. (i = this.eventsController) == null || i.clearEvents(),
  164825. (o = this.networkController) == null || o.quit(),
  164826. this
  164827. }
  164828. validateOptions(i) {
  164829. const {canvas: o, avatarId: s, skinId: c, userId: d, role: _, roomId: b, token: k, appId: j, avatarComponents: $} = i || {}
  164830. , _e = [];
  164831. return o instanceof HTMLCanvasElement || _e.push(new ParamError("`canvas` must be instanceof of HTMLCanvasElement")),
  164832. (!d || typeof d != "string") && _e.push(new ParamError("`userId` must be string")),
  164833. (!k || typeof k != "string") && _e.push(new ParamError("`token` must be string")),
  164834. (!j || typeof j != "string") && _e.push(new ParamError("`appId` must be string")),
  164835. _ == "audience" || (!s || !c) && _e.push(new ParamError("`avatarId` and `skinId` is required when create room")),
  164836. _e[0]
  164837. }
  164838. async initNetwork() {
  164839. if (this.viewMode === "serverless")
  164840. return Promise.resolve();
  164841. const i = Date.now();
  164842. try {
  164843. await this.networkController.connect()._timeout(8e3, new InitNetworkTimeoutError),
  164844. log$3.infoAndReportMeasurement({
  164845. metric: "networkInitAt",
  164846. startTime: this._startTime,
  164847. group: "joinRoom"
  164848. }),
  164849. log$3.infoAndReportMeasurement({
  164850. metric: "networkInitCost",
  164851. startTime: i,
  164852. group: "joinRoom"
  164853. })
  164854. } catch (o) {
  164855. throw log$3.infoAndReportMeasurement({
  164856. metric: "networkInitAt",
  164857. startTime: i,
  164858. group: "joinRoom",
  164859. error: o
  164860. }),
  164861. o
  164862. }
  164863. }
  164864. async initConfig() {
  164865. const i = Date.now();
  164866. try {
  164867. await this.modelManager.getApplicationConfig()._timeout(8e3, new InitConfigTimeoutError),
  164868. log$3.infoAndReportMeasurement({
  164869. metric: "configInitAt",
  164870. startTime: this._startTime,
  164871. group: "joinRoom"
  164872. }),
  164873. log$3.infoAndReportMeasurement({
  164874. metric: "configInitCost",
  164875. startTime: i,
  164876. group: "joinRoom"
  164877. })
  164878. } catch (o) {
  164879. throw log$3.infoAndReportMeasurement({
  164880. metric: "configInitAt",
  164881. startTime: i,
  164882. group: "joinRoom",
  164883. error: o
  164884. }),
  164885. o
  164886. }
  164887. }
  164888. async initEngine(i) {
  164889. const o = Date.now();
  164890. try {
  164891. this.engineProxy = new EngineProxy(this),
  164892. await this.engineProxy.initEngine(i)._timeout(8e3, new InitEngineError("init engine timeout in 8s")),
  164893. log$3.infoAndReportMeasurement({
  164894. metric: "webglInitAt",
  164895. startTime: this._startTime,
  164896. group: "joinRoom"
  164897. }),
  164898. log$3.infoAndReportMeasurement({
  164899. metric: "webglInitCost",
  164900. startTime: o,
  164901. group: "joinRoom"
  164902. });
  164903. return
  164904. } catch (s) {
  164905. let c = s;
  164906. return s.code !== Codes$1.InitEngineTimeout && (c = new InitEngineError(s)),
  164907. log$3.error(s),
  164908. log$3.infoAndReportMeasurement({
  164909. metric: "webglInitAt",
  164910. startTime: o,
  164911. group: "joinRoom",
  164912. error: c
  164913. }),
  164914. Promise.reject(c)
  164915. }
  164916. }
  164917. async initWasm() {
  164918. if (this.viewMode === "serverless")
  164919. return Promise.resolve();
  164920. const i = Date.now();
  164921. try {
  164922. await this.networkController.rtcp.workers.init({
  164923. width: 1920,
  164924. height: 1080,
  164925. userID: this.userId,
  164926. pageSession: this.options.pageSession,
  164927. serverSession: ""
  164928. })._timeout(8e3, new InitDecoderTimeoutError),
  164929. this.networkController.rtcp.workers.registerFunction("error", o=>{
  164930. log$3.error("decode error", o);
  164931. const {code: s, message: c} = o;
  164932. this.emit("error", {
  164933. code: s,
  164934. msg: c
  164935. })
  164936. }
  164937. ),
  164938. log$3.infoAndReportMeasurement({
  164939. metric: "wasmInitAt",
  164940. group: "joinRoom",
  164941. startTime: this._startTime
  164942. }),
  164943. log$3.infoAndReportMeasurement({
  164944. metric: "wasmInitCost",
  164945. group: "joinRoom",
  164946. startTime: i
  164947. }),
  164948. eventsManager.on("traceId", o=>{
  164949. this.networkController.rtcp.workers.onTraceId(o)
  164950. }
  164951. )
  164952. } catch (o) {
  164953. throw log$3.infoAndReportMeasurement({
  164954. metric: "wasmInitAt",
  164955. group: "joinRoom",
  164956. startTime: i,
  164957. error: o
  164958. }),
  164959. o
  164960. }
  164961. }
  164962. async requestCreateRoom({skinId: i}) {
  164963. let o;
  164964. if (i) {
  164965. o = await this.getSkin(i),
  164966. this.updateCurrentState({
  164967. skin: o
  164968. });
  164969. const s = await this.modelManager.findRoute(i, this.options.pathName);
  164970. this.updateCurrentNetworkOptions({
  164971. areaName: s.areaName,
  164972. attitude: s.attitude,
  164973. versionId: o.versionId
  164974. });
  164975. const {camera: c, player: d} = getRandomItem(s.birthPointList) || this.options;
  164976. this.options.camera || this.updateCurrentNetworkOptions({
  164977. camera: c
  164978. }),
  164979. this.options.player || this.updateCurrentNetworkOptions({
  164980. player: d
  164981. })
  164982. }
  164983. if (this.viewMode === "serverless")
  164984. return o;
  164985. try {
  164986. await this.beforeStartGameHook(this.options);
  164987. const {room_id: s, data: c, session_id: d} = await this.networkController.startGame();
  164988. this._id = s;
  164989. const _ = JSON.parse(c);
  164990. this.isHost = _.IsHost,
  164991. i = _.SkinID || i;
  164992. const b = await this.getSkin(i);
  164993. return this.updateCurrentNetworkOptions({
  164994. roomId: s,
  164995. sessionId: d
  164996. }),
  164997. reporter.updateBody({
  164998. roomId: s,
  164999. skinId: i,
  165000. serverSession: d
  165001. }),
  165002. b
  165003. } catch (s) {
  165004. return log$3.error("requestCreateRoom error:", s),
  165005. Promise.reject(s)
  165006. }
  165007. }
  165008. pause() {
  165009. return this.engineProxy.pause()
  165010. }
  165011. resume() {
  165012. return this.engineProxy.resume()
  165013. }
  165014. reconnect() {
  165015. this.networkController.reconnect()
  165016. }
  165017. async setViewMode(i) {}
  165018. handleRepetLogin() {
  165019. log$3.warn("receive " + Codes$1.RepeatLogin + " for repeat login"),
  165020. this.emit("repeatLogin"),
  165021. reporter.disable(),
  165022. this.networkController.quit()
  165023. }
  165024. setPictureQualityLevel(i) {
  165025. const o = {
  165026. high: EImageQuality.high,
  165027. low: EImageQuality.low,
  165028. average: EImageQuality.mid
  165029. };
  165030. return this.updateCurrentState({
  165031. pictureQualityLevel: i
  165032. }),
  165033. this.sceneManager.setImageQuality(o[i])
  165034. }
  165035. async getSkin(i) {
  165036. let o = null;
  165037. if (o = (this.skinList = await this.modelManager.getSkinsList()).find(c=>c.id === i || c.id === i),
  165038. o)
  165039. return o;
  165040. {
  165041. const c = `skin is invalid: skinId: ${i}`;
  165042. return Promise.reject(new ParamError(c))
  165043. }
  165044. }
  165045. setupStats() {
  165046. this.stats.assign({
  165047. roomId: this.id,
  165048. userId: this.userId
  165049. }),
  165050. setInterval(this.engineProxy.updateStats, 1e3)
  165051. }
  165052. proxyEvents(i, o) {
  165053. this.emit(i, o)
  165054. }
  165055. setCurrentNetworkOptions(i) {
  165056. this._currentNetworkOptions = i
  165057. }
  165058. updateCurrentNetworkOptions(i) {
  165059. Object.assign(this._currentNetworkOptions, i),
  165060. Object.assign(this.options, i)
  165061. }
  165062. setCurrentState(i) {
  165063. this._currentState = i
  165064. }
  165065. updateCurrentState(i) {
  165066. i.skinId && (this.lastSkinId = this.currentState.skinId,
  165067. this.updateCurrentNetworkOptions({
  165068. skinId: i.skinId
  165069. })),
  165070. i.versionId && this.updateCurrentNetworkOptions({
  165071. versionId: i.versionId
  165072. }),
  165073. Object.assign(this._currentState, i)
  165074. }
  165075. afterSetUrlHook() {}
  165076. afterTvStopedHook() {}
  165077. afterTvPlayedHook() {}
  165078. pageShowHandler() {
  165079. this.engineProxy.setEnv(this.skin),
  165080. this.allowRender = !0
  165081. }
  165082. pageHideHandler() {
  165083. this.allowRender = !1
  165084. }
  165085. }
  165086. var RenderType = (a=>(a[a.PathVideo = 0] = "PathVideo",
  165087. a[a.RotationVideo = 1] = "RotationVideo",
  165088. a[a.RotationImage = 2] = "RotationImage",
  165089. a[a.PanoramaImage = 3] = "PanoramaImage",
  165090. a[a.CGVideo = 4] = "CGVideo",
  165091. a[a.ClientRotationPano = 5] = "ClientRotationPano",
  165092. a[a.CloudRotationPano = 6] = "CloudRotationPano",
  165093. a))(RenderType || {})
  165094. , Person = (a=>(a[a.Third = 0] = "Third",
  165095. a[a.First = 1] = "First",
  165096. a))(Person || {})
  165097. , LandingType = (a=>(a[a.Stay = 0] = "Stay",
  165098. a[a.InitPoint = 1] = "InitPoint",
  165099. a[a.NewPoint = 2] = "NewPoint",
  165100. a))(LandingType || {})
  165101. , ClickType = (a=>(a[a.Screen = 0] = "Screen",
  165102. a[a.ThreeDimension = 1] = "ThreeDimension",
  165103. a[a.ThreeDimensionQuick = 2] = "ThreeDimensionQuick",
  165104. a[a.IgnoreView = 3] = "IgnoreView",
  165105. a))(ClickType || {})
  165106. , ChangeMode = (a=>(a[a.Preview = 0] = "Preview",
  165107. a[a.Confirm = 1] = "Confirm",
  165108. a[a.Cancel = 2] = "Cancel",
  165109. a))(ChangeMode || {})
  165110. , PointType = (a=>(a[a.Path = 0] = "Path",
  165111. a[a.Item = 1] = "Item",
  165112. a[a.Closeup = 2] = "Closeup",
  165113. a[a.NoValidMatched = 3] = "NoValidMatched",
  165114. a))(PointType || {});
  165115. const log$2 = new Logger("xverse-avatar-tools")
  165116. , isSuit = a=>a === "suit"
  165117. , avatarComponentsParser = async(a=null,e,i=[])=>new Promise(async(o,s)=>{
  165118. var k, j;
  165119. if (e.find($=>isSuit($.type))) {
  165120. const $ = (j = (k = a == null ? void 0 : a.components) == null ? void 0 : k.find(_e=>isSuit(_e.type))) == null ? void 0 : j.suitComb;
  165121. e = e.filter(_e=>($ == null ? void 0 : $.indexOf(_e.type)) === -1)
  165122. }
  165123. const d = e.filter($=>!i.some(_e=>_e.id === $.id));
  165124. d.length === 0 && o([]);
  165125. const _ = [];
  165126. d.forEach(async$=>{
  165127. var tt;
  165128. let _e = (tt = a == null ? void 0 : a.components) == null ? void 0 : tt.find(rt=>rt.type === $.type);
  165129. if (!_e) {
  165130. const rt = `changeComponents, no such component with type: ${$.type}`;
  165131. log$2.error(rt),
  165132. s(rt)
  165133. }
  165134. _e = JSON.parse(JSON.stringify(_e));
  165135. let et = _e == null ? void 0 : _e.units.find(rt=>rt.id === $.id);
  165136. et || (log$2.warn(`changeComponents, no unit with type: ${$.type}, id: ${$.id}`),
  165137. et = _e == null ? void 0 : _e.units.find(rt=>rt.isDefault),
  165138. !et && log$2.warn(`changeComponents, no default unit with type: ${$.type}`)),
  165139. et && _.push({
  165140. id: et.id,
  165141. url: et.url,
  165142. suitComb: (_e == null ? void 0 : _e.suitComb) || [],
  165143. type: $.type
  165144. })
  165145. }
  165146. );
  165147. const b = [];
  165148. Promise.all(b).then($=>{
  165149. _.forEach((_e,et)=>{
  165150. var tt, rt;
  165151. if (!isSuit(_e.type)) {
  165152. const it = ((rt = (tt = a == null ? void 0 : a.components) == null ? void 0 : tt.find(nt=>isSuit(nt.type))) == null ? void 0 : rt.suitComb) || [];
  165153. it.length > 0 && (it == null ? void 0 : it.indexOf(_e.type)) !== -1 && (_e.suitComb = ["suit"])
  165154. }
  165155. _e.url = $[et]
  165156. }
  165157. ),
  165158. o(_)
  165159. }
  165160. ).catch($=>{
  165161. s($)
  165162. }
  165163. )
  165164. }
  165165. )
  165166. , avatarComponentsModify = (a,e)=>new Promise((i,o)=>{
  165167. var b;
  165168. let s = [];
  165169. const c = []
  165170. , d = [];
  165171. let _ = e.some(k=>isSuit(k.type));
  165172. if ((b = a == null ? void 0 : a.components) == null || b.forEach(k=>{
  165173. var _e;
  165174. const j = e.find(et=>et.type === k.type)
  165175. , $ = j && ((_e = a == null ? void 0 : a.components) == null ? void 0 : _e.find(et=>et.type === j.type && et.units.some(tt=>tt.id === j.id))) !== void 0;
  165176. if (j)
  165177. if ($)
  165178. s.push(j);
  165179. else {
  165180. const et = k.units.find(tt=>tt.isDefault) || k.units[0];
  165181. et ? s.push({
  165182. type: k.type,
  165183. id: et.id
  165184. }) : c.push(`component with type: ${k.type} without default and available unit`)
  165185. }
  165186. else if (isSuit(k.type)) {
  165187. const et = k.units.find(tt=>tt.isDefault);
  165188. et && s.push({
  165189. type: k.type,
  165190. id: et.id
  165191. })
  165192. } else {
  165193. const et = k.units.find(tt=>tt.isDefault) || k.units[0];
  165194. et ? s.push({
  165195. type: k.type,
  165196. id: et.id
  165197. }) : c.push(`component with type: ${k.type} without default and available unit`)
  165198. }
  165199. }
  165200. ),
  165201. _ = s.some(k=>isSuit(k.type)),
  165202. _) {
  165203. const k = a == null ? void 0 : a.components.find(j=>isSuit(j.type));
  165204. s = s.filter(j=>(k == null ? void 0 : k.suitComb.indexOf(j.type)) === -1)
  165205. }
  165206. c.length > 0 && (log$2.error(c.join(", ")),
  165207. o(c.join(", "))),
  165208. d.length > 0 && log$2.warn(d.join(", ")),
  165209. i(s)
  165210. }
  165211. )
  165212. , positionPrecisionProtect = a=>{
  165213. const {x: e, y: i, z: o} = a;
  165214. return {
  165215. x: +e.toFixed(2),
  165216. y: +i.toFixed(2),
  165217. z: +o.toFixed(2)
  165218. }
  165219. }
  165220. , rotationPrecisionProtect = a=>{
  165221. const {pitch: e, yaw: i, roll: o} = a;
  165222. return {
  165223. pitch: +e.toFixed(2),
  165224. yaw: +i.toFixed(2),
  165225. roll: +o.toFixed(2)
  165226. }
  165227. }
  165228. , avatarComponentsValidate = (a,e)=>{
  165229. a = a.filter(s=>s.type !== "effect");
  165230. const i = []
  165231. , o = {};
  165232. return Array.isArray(a) ? (a.forEach(s=>{
  165233. o[s.type] ? o[s.type].num++ : o[s.type] = {
  165234. num: 1,
  165235. isSuit: isSuit(s.type)
  165236. }
  165237. }
  165238. ),
  165239. Object.keys(o).forEach(s=>{
  165240. if (o[s].num > 1 && i.push(new ParamError(`avatarComponent with type: ${s} repeated`)),
  165241. o[s].isSuit) {
  165242. const c = e.components.find(d=>isSuit(d.type));
  165243. c == null || c.suitComb.forEach(d=>{
  165244. Object.keys(o).indexOf(d) > -1 && i.push(new ParamError(`suit already contains: ${d}, ${d} repeated`))
  165245. }
  165246. )
  165247. }
  165248. }
  165249. ),
  165250. i[0]) : (i.push(new ParamError("avatarComponents must be array")),
  165251. i[0])
  165252. }
  165253. , safeParseComponents = a=>{
  165254. let e = [];
  165255. try {
  165256. e = JSON.parse(a || "[]")
  165257. } catch {
  165258. e = [],
  165259. log$2.error(`avatarComponents parse error: ${a}`)
  165260. }
  165261. return e
  165262. }
  165263. ;
  165264. var QueueType = (a=>(a.Move = "Move",
  165265. a.Rotate = "Rotate",
  165266. a))(QueueType || {});
  165267. class Queue {
  165268. constructor() {
  165269. Tt(this, "queue", []);
  165270. Tt(this, "currentAction")
  165271. }
  165272. async append(e) {
  165273. var i, o;
  165274. this.queue.length === 0 || ((i = this.currentAction) == null ? void 0 : i.type) === e.type && this.queue.length === 1 ? (this.queue = [],
  165275. this.queue.push(e),
  165276. await this.go()) : (((o = this.queue[this.queue.length - 1]) == null ? void 0 : o.type) === e.type && this.queue.pop(),
  165277. this.queue.push(e))
  165278. }
  165279. async go() {
  165280. if (this.queue.length !== 0) {
  165281. const e = this.queue[0];
  165282. this.currentAction = e,
  165283. await e.action(),
  165284. this.currentAction = void 0,
  165285. this.queue.splice(0, 1),
  165286. await this.go()
  165287. }
  165288. }
  165289. async reject() {
  165290. this.queue = []
  165291. }
  165292. }
  165293. const log$1 = new Logger("xverse-avatar");
  165294. class XverseAvatar extends EventEmitter {
  165295. constructor({userId: i, isHost: o, room: s, avatarId: c, isSelf: d, group: _=AvatarGroup.Npc}) {
  165296. super();
  165297. Tt(this, "xAvatar");
  165298. Tt(this, "_isHost", !1);
  165299. Tt(this, "_room");
  165300. Tt(this, "_withModel", !1);
  165301. Tt(this, "_userId");
  165302. Tt(this, "group", AvatarGroup.User);
  165303. Tt(this, "state", "idle");
  165304. Tt(this, "isLoading", !0);
  165305. Tt(this, "_isMoving", !1);
  165306. Tt(this, "_isRotating", !1);
  165307. Tt(this, "_failed", !1);
  165308. Tt(this, "disconnected", !1);
  165309. Tt(this, "_avatarId");
  165310. Tt(this, "prioritySync", !1);
  165311. Tt(this, "priority", EAvatarRelationRank.Stranger);
  165312. Tt(this, "_avatarModel");
  165313. Tt(this, "_motionType", MotionType.Walk);
  165314. Tt(this, "isSelf", !1);
  165315. Tt(this, "_lastAnimTraceId", "");
  165316. Tt(this, "statusSyncQueue", new Queue);
  165317. Tt(this, "extraInfo", {});
  165318. Tt(this, "attachedEffects", new Set);
  165319. Tt(this, "currentPathName", "");
  165320. Tt(this, "setPosition", i=>{
  165321. var o;
  165322. !this._room.signal.isUpdatedYUV || (o = this.xAvatar) == null || o.setPosition(positionPrecisionProtect(i), !0)
  165323. }
  165324. );
  165325. Tt(this, "setRotation", i=>{
  165326. var o;
  165327. !this._room.signal.isUpdatedYUV || (o = this.xAvatar) == null || o.setRotation(rotationPrecisionProtect(i))
  165328. }
  165329. );
  165330. Tt(this, "stopAnimation", ()=>{
  165331. var i, o;
  165332. (o = (i = this.xAvatar) == null ? void 0 : i.controller) == null || o.stopAnimation()
  165333. }
  165334. );
  165335. Tt(this, "_playAnimation", async(i,o=!0,s=!1)=>{
  165336. var d;
  165337. if (!this._room.signal.isUpdatedYUV)
  165338. return;
  165339. if (this.state !== "idle" && !s)
  165340. return log$1.warn("_playAnimation", i, "state is not idle, play animation failed"),
  165341. Promise.resolve("_playAnimation, state is not idle");
  165342. const c = Date.now();
  165343. try {
  165344. if (!((d = this.xAvatar) != null && d.controller))
  165345. return Promise.reject(new InternalError(`[avatar: ${this.userId}] Play animation failed: ${i}, no controller`));
  165346. this.isSelf && setTimeout(()=>{
  165347. log$1.infoAndReportMeasurement({
  165348. tag: i,
  165349. startTime: c,
  165350. value: 0,
  165351. metric: "playAnimationStart"
  165352. })
  165353. }
  165354. );
  165355. const _ = uuid$1();
  165356. this._lastAnimTraceId = _,
  165357. await this.xAvatar.controller.playAnimation(i, o),
  165358. _ === this._lastAnimTraceId && !this.isMoving && !o && i !== "Idle" && this.xAvatar.controller.playAnimation("Idle", o).catch(b=>{
  165359. log$1.error(`[avatar: ${this.userId}] Play animation failed [force idle]`, b)
  165360. }
  165361. ),
  165362. this.isSelf && log$1.infoAndReportMeasurement({
  165363. tag: i,
  165364. startTime: c,
  165365. extra: {
  165366. loop: o
  165367. },
  165368. metric: "playAnimationEnd"
  165369. })
  165370. } catch (_) {
  165371. return log$1.error(`[avatar: ${this.userId}] Play animation failed: ${i}`, _),
  165372. this.isSelf && log$1.infoAndReportMeasurement({
  165373. tag: i,
  165374. startTime: c,
  165375. metric: "playAnimationEnd",
  165376. error: _,
  165377. extra: {
  165378. loop: o
  165379. }
  165380. }),
  165381. Promise.reject(_)
  165382. }
  165383. }
  165384. );
  165385. Tt(this, "avatarComponentsSync", i=>{
  165386. i = i.map(o=>({
  165387. type: o.type,
  165388. id: o.id
  165389. })),
  165390. this._room.actionsHandler.avatarComponentsSync(i)
  165391. }
  165392. );
  165393. Tt(this, "hide", ()=>{
  165394. var i;
  165395. if ((i = this.xAvatar) != null && i.hide())
  165396. return Promise.resolve(`avatar: ${this.userId} hide success`);
  165397. {
  165398. const o = `avatar: ${this.userId} hide failed ${!this.xAvatar && "without instance: xAvatar"}`;
  165399. return log$1.warn(o),
  165400. Promise.reject(o)
  165401. }
  165402. }
  165403. );
  165404. Tt(this, "show", ()=>{
  165405. var i;
  165406. if ((i = this.xAvatar) != null && i.show())
  165407. return Promise.resolve(`avatar: ${this.userId} show success`);
  165408. {
  165409. const o = `avatar: ${this.userId} show failed ${!this.xAvatar && "without instance: xAvatar"}`;
  165410. return log$1.warn(o),
  165411. Promise.reject(o)
  165412. }
  165413. }
  165414. );
  165415. Tt(this, "sayTimer");
  165416. this._userId = i,
  165417. this._room = s,
  165418. this.isSelf = d || !1,
  165419. this._withModel = !!c,
  165420. this._isHost = o || !1,
  165421. this._avatarId = c,
  165422. this.group = _,
  165423. this._room.modelManager.getAvatarModelList().then(b=>{
  165424. const k = b.find(j=>j.id === c);
  165425. k && (this._avatarModel = k)
  165426. }
  165427. )
  165428. }
  165429. get avatarId() {
  165430. return this._avatarId
  165431. }
  165432. get isRender() {
  165433. var i;
  165434. return !!((i = this.xAvatar) != null && i.isRender)
  165435. }
  165436. get isHidden() {
  165437. var i;
  165438. return !!((i = this.xAvatar) != null && i.isHide)
  165439. }
  165440. get motionType() {
  165441. return this._motionType
  165442. }
  165443. set motionType(i) {
  165444. this._motionType = i
  165445. }
  165446. get nickname() {
  165447. var i;
  165448. return (i = this.xAvatar) == null ? void 0 : i.nickName
  165449. }
  165450. get words() {
  165451. var i;
  165452. return (i = this.xAvatar) == null ? void 0 : i.words
  165453. }
  165454. get isHost() {
  165455. return this._isHost
  165456. }
  165457. get failed() {
  165458. return this._failed
  165459. }
  165460. get scale() {
  165461. var i;
  165462. return (i = this.xAvatar) == null ? void 0 : i.scale
  165463. }
  165464. get animations() {
  165465. var i;
  165466. return !this.xAvatar || !this.xAvatar.controller ? [] : ((i = this.xAvatar) == null ? void 0 : i.getAvaliableAnimations()) || []
  165467. }
  165468. get position() {
  165469. var i;
  165470. return (i = this.xAvatar) == null ? void 0 : i.position
  165471. }
  165472. get rotation() {
  165473. var i;
  165474. return (i = this.xAvatar) == null ? void 0 : i.rotation
  165475. }
  165476. get pose() {
  165477. return {
  165478. position: this.position,
  165479. angle: this.rotation
  165480. }
  165481. }
  165482. get id() {
  165483. return this.userId
  165484. }
  165485. get isMoving() {
  165486. return this._isMoving
  165487. }
  165488. set isMoving(i) {
  165489. this._isMoving = i,
  165490. this.state = i ? "moving" : "idle"
  165491. }
  165492. get isRotating() {
  165493. return this._isRotating
  165494. }
  165495. set isRotating(i) {
  165496. this._isRotating = i,
  165497. this.state = i ? "rotating" : "idle"
  165498. }
  165499. get withModel() {
  165500. return this._withModel
  165501. }
  165502. get avatarComponents() {
  165503. var i;
  165504. return JSON.parse(JSON.stringify(((i = this.xAvatar) == null ? void 0 : i.clothesList) || []))
  165505. }
  165506. get userId() {
  165507. return this._userId
  165508. }
  165509. get removeWhenDisconnected() {
  165510. return this.extraInfo && this.extraInfo.removeWhenDisconnected !== void 0 ? this.extraInfo.removeWhenDisconnected : !0
  165511. }
  165512. setConnectionStatus(i) {
  165513. this.disconnected !== i && (this.disconnected = i,
  165514. i ? this.emit("disconnected") : this.emit("reconnected"),
  165515. log$1.warn(`avatar ${this.userId} status changed, disconnected:`, i))
  165516. }
  165517. setScale(i) {
  165518. var o;
  165519. this.scale !== i && ((o = this.xAvatar) == null || o.setScale(i > 0 ? i : 1))
  165520. }
  165521. async playAnimation(i) {
  165522. const {animationName: o, loop: s, extra: c} = i || {};
  165523. if (this.isSelf) {
  165524. if (this.isMoving)
  165525. try {
  165526. await this.stopMoving()
  165527. } catch (_) {
  165528. return log$1.error(`stopMoving error before playAnimation ${o}`, _),
  165529. Promise.reject(`stopMoving error before playAnimation ${o}`)
  165530. }
  165531. const d = {
  165532. info: {
  165533. userId: this.userId,
  165534. animation: o,
  165535. loop: s,
  165536. extra: encodeURIComponent(c || "")
  165537. },
  165538. broadcastType: CoreBroadcastType.PlayAnimation
  165539. };
  165540. this._room.avatarManager.broadcast.broadcast({
  165541. data: d
  165542. })
  165543. }
  165544. return this.isSelf && (log$1.warn("animationStart emit", o),
  165545. this.emit("animationStart", {
  165546. animationName: o,
  165547. extra: safeDecodeURIComponent(c || "")
  165548. })),
  165549. this._playAnimation(o, s).then(()=>{
  165550. this.isSelf && (log$1.warn("animationEnd emit", o),
  165551. this.emit("animationEnd", {
  165552. animationName: o,
  165553. extra: safeDecodeURIComponent(c || "")
  165554. }))
  165555. }
  165556. )
  165557. }
  165558. async changeComponents(i) {
  165559. const {mode: o, endAnimation: s=""} = i || {}
  165560. , c = JSON.parse(JSON.stringify(i.avatarComponents));
  165561. let d = avatarComponentsValidate(c, this._avatarModel);
  165562. return !ChangeComponentsMode[o] && !d && (d = new ParamError(`changeComponents failed, mode: ${o} is invalid`)),
  165563. d ? (log$1.error(d),
  165564. Promise.reject(d)) : this._changeComponents({
  165565. avatarComponents: c,
  165566. mode: o,
  165567. endAnimation: s
  165568. }).then(()=>{
  165569. this.isSelf && o !== ChangeComponentsMode.Preview && this.avatarComponentsSync(this.avatarComponents)
  165570. }
  165571. )
  165572. }
  165573. async _changeComponents(i) {
  165574. var d;
  165575. const {avatarComponents: o=[], mode: s} = i || {}
  165576. , c = Date.now();
  165577. try {
  165578. if (!this.xAvatar)
  165579. return Promise.reject(new InternalError("changeComponents failed, without instance: xAvatar"));
  165580. const _ = await avatarComponentsModify(this._avatarModel, o)
  165581. , b = []
  165582. , k = await avatarComponentsParser(this._avatarModel, _, this.avatarComponents);
  165583. if (k.length === 0)
  165584. return this.avatarComponents;
  165585. await this.beforeChangeComponentsHook(i);
  165586. for (const j of k) {
  165587. const {id: $, type: _e, url: et, suitComb: tt} = j;
  165588. b.push((d = this.xAvatar) == null ? void 0 : d.addComponent($, _e, et, tt))
  165589. }
  165590. return await Promise.all(b),
  165591. this.emit("componentsChanged", {
  165592. components: this.avatarComponents,
  165593. mode: s
  165594. }),
  165595. this.isSelf && log$1.infoAndReportMeasurement({
  165596. tag: "changeComponents",
  165597. startTime: c,
  165598. metric: "changeComponents",
  165599. extra: {
  165600. inputComponents: o,
  165601. finalComponents: this.avatarComponents,
  165602. mode: ChangeComponentsMode[s]
  165603. }
  165604. }),
  165605. this.avatarComponents
  165606. } catch (_) {
  165607. return this.isSelf && log$1.infoAndReportMeasurement({
  165608. tag: "changeComponents",
  165609. startTime: c,
  165610. metric: "changeComponents",
  165611. error: _,
  165612. extra: {
  165613. inputComponents: o,
  165614. finalComponents: this.avatarComponents,
  165615. mode: ChangeComponentsMode[s]
  165616. }
  165617. }),
  165618. Promise.reject(_)
  165619. }
  165620. }
  165621. async beforeChangeComponentsHook(i) {}
  165622. turnTo(i) {
  165623. if (this._room.viewMode === "observer") {
  165624. this._room.sceneManager.cameraComponent.MainCamera.setTarget(ue4Position2Xverse(i.point));
  165625. return
  165626. }
  165627. return this._room.actionsHandler.turnTo(i).then(()=>{
  165628. this.emit("viewChanged", {
  165629. extra: (i == null ? void 0 : i.extra) || ""
  165630. })
  165631. }
  165632. )
  165633. }
  165634. async moveTo(i) {
  165635. const {point: o, extra: s=""} = i || {};
  165636. if (!this.position)
  165637. return Promise.reject(new ParamError("avatar position is empty"));
  165638. if (typeof s != "string" || typeof s == "string" && s.length > 64) {
  165639. const _ = "extra shoud be string which length less than 64";
  165640. return log$1.warn(_),
  165641. Promise.reject(new ParamError(_))
  165642. }
  165643. const d = getDistance(this.position, o) / 100 > 100 ? MotionType.Run : MotionType.Walk;
  165644. return this._room.actionsHandler.moveTo({
  165645. point: o,
  165646. motionType: d,
  165647. extra: s
  165648. })
  165649. }
  165650. async stopMoving() {
  165651. if (!!this.isMoving)
  165652. return this._room.actionsHandler.stopMoving()
  165653. }
  165654. rotateTo(i) {
  165655. return this._room.actionsHandler.rotateTo(i)
  165656. }
  165657. setRayCast(i) {
  165658. this.xAvatar && (this.xAvatar.isRayCastEnable = i)
  165659. }
  165660. say(i, o) {
  165661. let s, c, d, _;
  165662. if (typeof o == "object" ? (s = o.duration,
  165663. c = o.background,
  165664. d = o.fontSize,
  165665. _ = o.fontColor) : typeof o == "number" && (s = o),
  165666. this.sayTimer && window.clearTimeout(this.sayTimer),
  165667. !this.xAvatar) {
  165668. log$1.error("say failed, without instance: xAvatar");
  165669. return
  165670. }
  165671. this.xAvatar.say(i, {
  165672. scale: this.xAvatar.scale,
  165673. isUser: this.group === AvatarGroup.User,
  165674. background: c,
  165675. fontsize: d,
  165676. fontcolor: _
  165677. }),
  165678. !(s === void 0 || s <= 0) && (this.sayTimer = window.setTimeout(()=>{
  165679. this.silent()
  165680. }
  165681. , s))
  165682. }
  165683. silent() {
  165684. var i;
  165685. if (!this.xAvatar) {
  165686. log$1.error("silent failed, without instance: xAvatar");
  165687. return
  165688. }
  165689. (i = this.xAvatar) == null || i.silent()
  165690. }
  165691. setMotionType({type: i=MotionType.Walk}) {
  165692. return this.motionType === i ? Promise.resolve() : this._room.actionsHandler.setMotionType(i).then(()=>{
  165693. this._motionType = i
  165694. }
  165695. )
  165696. }
  165697. setNickname(i) {
  165698. return this._room.actionsHandler.setNickName(encodeURIComponent(i))
  165699. }
  165700. _setNickname(i) {
  165701. var s, c;
  165702. if (!i)
  165703. return;
  165704. const o = safeDecodeURIComponent(i);
  165705. ((s = this.xAvatar) == null ? void 0 : s.nickName) !== o && (this.isSelf && (this._room.updateCurrentNetworkOptions({
  165706. nickname: o
  165707. }),
  165708. this._room.options.nickname = o),
  165709. (c = this.xAvatar) == null || c.setNickName(o, {
  165710. scale: this.xAvatar.scale
  165711. }))
  165712. }
  165713. _move(i) {
  165714. var k;
  165715. const {start: o, end: s, walkSpeed: c, moveAnimation: d="Walking", inter: _=[], enforceRaycast: b=!0} = i || {};
  165716. return (k = this.xAvatar) == null ? void 0 : k.move(o, s, c, d, _, b)
  165717. }
  165718. moveHermite(i) {
  165719. var k;
  165720. const {start: o, end: s, moveAnimation: c="Walking", duration: d, tension: _, enforceRaycast: b=!1} = i || {};
  165721. return (k = this.xAvatar) == null ? void 0 : k.moveHermite(o, s, d, _, c, b)
  165722. }
  165723. move(i) {
  165724. return this._move(i)
  165725. }
  165726. setPickBoxScale(i=1) {
  165727. return this.xAvatar ? (this.xAvatar.setPickBoxScale(i),
  165728. !0) : (log$1.error("setPickBoxScale failed, without instance: xAvatar"),
  165729. !1)
  165730. }
  165731. transfer(i) {
  165732. const {player: o, camera: s, areaName: c, attitude: d, pathName: _} = i;
  165733. return this._room.actionsHandler.transfer({
  165734. renderType: RenderType.RotationVideo,
  165735. player: o,
  165736. camera: s,
  165737. areaName: c,
  165738. attitude: d,
  165739. pathName: _,
  165740. tag: "transfer"
  165741. })
  165742. }
  165743. avatarLoadedHook() {}
  165744. avatarStartMovingHook() {}
  165745. avatarStopMovingHook() {}
  165746. async statusSync(i) {
  165747. var o, s, c;
  165748. try {
  165749. if ((o = i.event) != null && o.rotateEvent) {
  165750. const {angle: d, speed: _} = i.event.rotateEvent
  165751. , b = this.motionType === MotionType.Run ? "Running" : "Walking";
  165752. this.rotation && (this.rotation.yaw = this.rotation.yaw % 360,
  165753. d.yaw - this.rotation.yaw > 180 && (d.yaw = 180 - d.yaw),
  165754. this.isRotating = !0,
  165755. await this.xAvatar.rotateTo(d, this.rotation, b).then(()=>{
  165756. this._playAnimation("Idle", !0),
  165757. this.isRotating = !1
  165758. }
  165759. ))
  165760. }
  165761. if (i.event && (((s = i.event) == null ? void 0 : s.points.length) || 0) > 1 && !this.isSelf) {
  165762. this.isMoving = !0,
  165763. i.playerState.attitude && (this._motionType = i.playerState.attitude);
  165764. const d = this.motionType === MotionType.Run ? "Running" : "Walking"
  165765. , _ = this._room.skin.routeList.find(k=>k.areaName === this.currentPathName)
  165766. , b = ((_ == null ? void 0 : _.step) || 7.5) * 30 * (25 / 30);
  165767. this.position && await this._move({
  165768. start: this.position,
  165769. end: i.event.points[i.event.points.length - 1],
  165770. walkSpeed: b,
  165771. moveAnimation: d,
  165772. inter: (c = i.event) == null ? void 0 : c.points.slice(0, -1)
  165773. }).then(()=>{
  165774. this.isMoving = !1
  165775. }
  165776. )
  165777. }
  165778. } catch {
  165779. return
  165780. }
  165781. }
  165782. removeAttachedEffects() {
  165783. this.attachedEffects.forEach((i,o)=>{
  165784. this._room.effectManager.removeEffect(o)
  165785. }
  165786. ),
  165787. this.attachedEffects.clear()
  165788. }
  165789. removeAttachedEffect(i) {
  165790. this.attachedEffects.delete(i),
  165791. this._room.effectManager.removeEffect(i)
  165792. }
  165793. faceTo({point: i, rotateSpeed: o=.1}) {
  165794. return this.xAvatar.faceTo(i, o)
  165795. }
  165796. }
  165797. var SyncEventType = (a=>(a[a.Reset = 0] = "Reset",
  165798. a[a.Appear = 1] = "Appear",
  165799. a[a.Disappear = 2] = "Disappear",
  165800. a[a.Move = 3] = "Move",
  165801. a[a.ChangeRenderInfo = 4] = "ChangeRenderInfo",
  165802. a[a.KeepAlive = 5] = "KeepAlive",
  165803. a[a.Rotate = 6] = "Rotate",
  165804. a[a.ET_RemoveVisitor = 7] = "ET_RemoveVisitor",
  165805. a))(SyncEventType || {});
  165806. const log = new Logger("xverse-avatar-manager")
  165807. , pr = class {
  165808. constructor(e) {
  165809. Tt(this, "xAvatarManager");
  165810. Tt(this, "_room");
  165811. Tt(this, "avatars", new Map);
  165812. Tt(this, "syncAvatarsLength", 0);
  165813. Tt(this, "broadcast");
  165814. this._room = e,
  165815. this._usersStatistics(),
  165816. this.broadcast = this.setupBroadcast(),
  165817. e.on("skinChanged", ()=>{
  165818. this.avatars.forEach(i=>{
  165819. i.disconnected && this.removeAvatar(i.userId, !0)
  165820. }
  165821. )
  165822. }
  165823. )
  165824. }
  165825. setupBroadcast() {
  165826. return new Broadcast(this._room,async e=>{
  165827. const {broadcastType: i, info: o} = e;
  165828. if (i !== CoreBroadcastType.PlayAnimation)
  165829. return;
  165830. const {userId: s, animation: c, extra: d, loop: _=!1} = o
  165831. , b = this.avatars.get(s);
  165832. b && !b.isSelf && (b.emit("animationStart", {
  165833. animationName: c,
  165834. extra: decodeURIComponent(d)
  165835. }),
  165836. await (b == null ? void 0 : b._playAnimation(c, _)),
  165837. b.emit("animationEnd", {
  165838. animationName: c,
  165839. extra: decodeURIComponent(d)
  165840. }))
  165841. }
  165842. )
  165843. }
  165844. hideAll(e=!0) {
  165845. this.xAvatarManager.hideAll(e)
  165846. }
  165847. showAll(e=!0) {
  165848. this.xAvatarManager.showAll(e)
  165849. }
  165850. async init() {
  165851. this.xAvatarManager = this._room.sceneManager.avatarComponent;
  165852. try {
  165853. const e = await this._room.modelManager.getApplicationConfig()
  165854. , {avatars: i} = e;
  165855. if (i) {
  165856. await avatarLoader.parse(this._room.sceneManager, i);
  165857. return
  165858. }
  165859. return Promise.reject("cannot find avatar config list")
  165860. } catch (e) {
  165861. return log.error(e),
  165862. Promise.reject("avatar mananger init error!" + e)
  165863. }
  165864. }
  165865. async handleAvatar(e) {
  165866. if (this._room.viewMode === "simple" || !this._room.joined || !e.newUserStates)
  165867. return;
  165868. const i = e.newUserStates;
  165869. if (e.actionType === Actions.GetNewUserState) {
  165870. this.syncAvatarsLength = (i || []).length;
  165871. const o = this._room.avatars.filter(d=>d.group == AvatarGroup.User);
  165872. o.filter(d=>!(i != null && i.find(_=>_.userId == d.userId))).forEach(d=>{
  165873. this.removeAvatar(d.userId)
  165874. }
  165875. );
  165876. const c = i.filter(d=>!o.find(_=>_.userId == d.userId));
  165877. this._handleAvatar(c)
  165878. } else
  165879. this._handleAvatar(i)
  165880. }
  165881. async _handleAvatar(e) {
  165882. e == null || e.forEach(i=>{
  165883. var s, c, d, _, b, k, j, $, _e;
  165884. const o = this._room.userId === i.userId;
  165885. if (((s = i.event) == null ? void 0 : s.type) === SyncEventType.ET_RemoveVisitor) {
  165886. const et = (d = (c = i.event) == null ? void 0 : c.removeVisitorEvent) == null ? void 0 : d.removeVisitorEvent
  165887. , tt = JSON.parse(safeDecodeURIComponent(((b = (_ = i.event) == null ? void 0 : _.removeVisitorEvent) == null ? void 0 : b.extraInfo) || ""))
  165888. , {code: rt, msg: it} = tt;
  165889. et === RemoveVisitorType.RVT_ChangeToObserver ? this._room.audienceViewModeHook(tt) : et === RemoveVisitorType.RVT_MoveOutOfTheRoom && this._room.leave(),
  165890. this._room.proxyEvents("kicked", {
  165891. code: rt,
  165892. msg: it
  165893. }),
  165894. log.warn("kicked emit: ", {
  165895. code: rt,
  165896. msg: it
  165897. })
  165898. }
  165899. if (i.event && [SyncEventType.Appear, SyncEventType.Reset].includes(i.event.type)) {
  165900. let et = this.avatars.get(i.userId);
  165901. if (et && i.playerState.avatarId && (et == null ? void 0 : et.avatarId) !== i.playerState.avatarId && (et = void 0,
  165902. this.removeAvatar(i.userId, !0)),
  165903. et) {
  165904. if (i.playerState.pathName && (et.currentPathName = i.playerState.pathName),
  165905. et.disconnected && et.setConnectionStatus(!1),
  165906. (k = i.event) != null && k.id && this._room.actionsHandler.confirmEvent(i.event.id),
  165907. i.playerState.nickName && (et == null || et._setNickname(i.playerState.nickName)),
  165908. i.playerState.avatarComponents && !et.isSelf && et.xAvatar) {
  165909. const tt = safeParseComponents(i.playerState.avatarComponents);
  165910. et._changeComponents({
  165911. avatarComponents: tt,
  165912. mode: ChangeComponentsMode.Preview
  165913. })
  165914. }
  165915. if (!et.isSelf && et.position && (et.statusSyncQueue.queue.length === 0 || !et.statusSyncQueue.currentAction)) {
  165916. const {x: tt, y: rt} = et.position
  165917. , {x: it, y: nt} = i.playerState.player.position;
  165918. (Math.abs(tt - it) > 50 || Math.abs(rt - nt) > 50) && (et.setPosition(i.playerState.player.position),
  165919. et.setRotation(i.playerState.player.angle))
  165920. }
  165921. } else {
  165922. if (!i.playerState.player)
  165923. return;
  165924. const {position: tt, angle: rt} = i.playerState.player
  165925. , it = i.playerState.avatarId
  165926. , nt = i.playerState.prioritySync
  165927. , ot = safelyJsonParse(i.playerState.extra)
  165928. , at = safeParseComponents(i.playerState.avatarComponents)
  165929. , st = safeDecodeURIComponent(i.playerState.nickName)
  165930. , ut = this.calculatePriority(i.userId, ot);
  165931. this.addAvatar({
  165932. userId: i.userId,
  165933. isHost: i.playerState.isHost,
  165934. nickname: st,
  165935. avatarPosition: tt,
  165936. avatarRotation: rt,
  165937. avatarScale: i.playerState.avatarSize,
  165938. avatarId: it,
  165939. avatarComponents: i.playerState.person === Person.First ? [] : at,
  165940. priority: ut,
  165941. group: AvatarGroup.User,
  165942. prioritySync: nt,
  165943. extraInfo: ot
  165944. }).then(ct=>{
  165945. var lt;
  165946. i.playerState.pathName && (ct.currentPathName = i.playerState.pathName),
  165947. (lt = i.event) != null && lt.id && this._room.actionsHandler.confirmEvent(i.event.id),
  165948. this.updateAvatarPositionAndRotation(i),
  165949. o && (this.xAvatarManager.setMainAvatar(i.userId),
  165950. this._room.emit("userAvatarLoaded"),
  165951. log.info("userAvatarLoaded"))
  165952. }
  165953. ).catch(ct=>{
  165954. o && (this.xAvatarManager.setMainAvatar(i.userId),
  165955. this._room.emit("userAvatarFailed", {
  165956. error: ct
  165957. }),
  165958. log.error("userAvatarFailed", ct))
  165959. }
  165960. )
  165961. }
  165962. }
  165963. if (i.event && SyncEventType.Disappear === i.event.type && ((j = i == null ? void 0 : i.event) != null && j.id && this._room.actionsHandler.confirmEvent(i.event.id),
  165964. this.removeAvatar(i.userId)),
  165965. i.event && [SyncEventType.Move, SyncEventType.ChangeRenderInfo].includes(i.event.type) || !i.event) {
  165966. ($ = i == null ? void 0 : i.event) != null && $.id && this._room.actionsHandler.confirmEvent(i.event.id);
  165967. const et = this.avatars.get(i.userId);
  165968. et && et.withModel && !et.isLoading && this.updateAvatarPositionAndRotation(i)
  165969. }
  165970. if (!o && ((_e = i.event) == null ? void 0 : _e.type) === SyncEventType.Rotate) {
  165971. const et = this.avatars.get(i.userId);
  165972. et.statusSyncQueue.append({
  165973. type: QueueType.Rotate,
  165974. action: ()=>et.statusSync(i)
  165975. })
  165976. }
  165977. }
  165978. )
  165979. }
  165980. calculatePriority(e, i) {
  165981. var s;
  165982. return e === this._room.userId ? EAvatarRelationRank.Self : (s = this._room.options.firends) != null && s.includes(e) ? EAvatarRelationRank.Friend : EAvatarRelationRank.Stranger
  165983. }
  165984. updateAvatarPositionAndRotation(e) {
  165985. var i, o;
  165986. if ((i = e == null ? void 0 : e.playerState) != null && i.player) {
  165987. let {position: s, angle: c} = e.playerState.player;
  165988. const d = this.avatars.get(e.userId);
  165989. if (!d)
  165990. return;
  165991. if (s = positionPrecisionProtect(s),
  165992. c = rotationPrecisionProtect(c),
  165993. d.isSelf && !this._room.networkController.rtcp.workers.inPanoMode && (d.setPosition(s),
  165994. d.setRotation(c)),
  165995. e.event && (((o = e.event) == null ? void 0 : o.points.length) || 0) > 1 && !d.isSelf && d.statusSyncQueue.append({
  165996. type: QueueType.Move,
  165997. action: ()=>d.statusSync(e)
  165998. }),
  165999. e.renderInfo && d.isSelf) {
  166000. const {isMoving: _, isRotating: b} = e.renderInfo;
  166001. this._updateAvatarMovingStatus({
  166002. id: e.userId,
  166003. isMoving: !!_,
  166004. isRotating: !!b
  166005. })
  166006. }
  166007. }
  166008. }
  166009. async addAvatar(e) {
  166010. const {userId: i, isHost: o, avatarPosition: s, avatarId: c, avatarRotation: d, nickname: _, avatarComponents: b=[], priority: k, group: j=AvatarGroup.Npc, avatarScale: $=DEFAULT_AVATAR_SCALE, extraInfo: _e, prioritySync: et} = e
  166011. , tt = i === this._room.userId;
  166012. let rt = this.avatars.get(i);
  166013. if (rt)
  166014. return Promise.resolve(rt);
  166015. if (rt = new pr.subAvatar({
  166016. userId: i,
  166017. isHost: o,
  166018. isSelf: tt,
  166019. room: this._room,
  166020. avatarComponents: b,
  166021. avatarId: c,
  166022. nickname: _,
  166023. group: j
  166024. }),
  166025. this.avatars.set(i, rt),
  166026. !rt.withModel)
  166027. return rt.isLoading = !1,
  166028. rt.avatarLoadedHook(),
  166029. this._room.emit("avatarChanged", {
  166030. avatars: this._room.avatars
  166031. }),
  166032. rt;
  166033. const nt = (await this._room.modelManager.getAvatarModelList()).find(at=>at.id === c)
  166034. , ot = Date.now();
  166035. if (!nt)
  166036. return this._room.emit("avatarChanged", {
  166037. avatars: this._room.avatars
  166038. }),
  166039. this.avatars.delete(i),
  166040. Promise.reject(`no such avatar model with id: ${c}`);
  166041. try {
  166042. let at = await avatarComponentsModify(nt, b);
  166043. at = at.filter(ct=>ct.type != "pendant");
  166044. const st = await avatarComponentsParser(nt, at)
  166045. , ut = await this.xAvatarManager.loadAvatar({
  166046. id: i,
  166047. avatarType: c,
  166048. priority: k,
  166049. avatarManager: this.xAvatarManager,
  166050. assets: st,
  166051. status: {
  166052. avatarPosition: s,
  166053. avatarRotation: d,
  166054. avatarScale: $
  166055. }
  166056. })._timeout(8e3, new TimeoutError$1("loadAvatar timeout(8s)"));
  166057. return ut.setPickBoxScale(i === this._room.userId ? 0 : 1),
  166058. rt.xAvatar = ut,
  166059. rt.setScale($),
  166060. s && rt.setPosition(s),
  166061. rt.extraInfo = _e,
  166062. rt.priority = k,
  166063. rt.isLoading = !1,
  166064. rt.prioritySync = !!et,
  166065. rt._playAnimation("Idle", !0, !0),
  166066. rt.avatarLoadedHook(),
  166067. this._room.emit("avatarChanged", {
  166068. avatars: this._room.avatars
  166069. }),
  166070. _ && rt._setNickname(_),
  166071. i === this._room.userId && (log.infoAndReportMeasurement({
  166072. metric: "avatarLoadDuration",
  166073. startTime: ot,
  166074. group: "costs"
  166075. }),
  166076. log.infoAndReportMeasurement({
  166077. metric: "avatarLoadAt",
  166078. startTime: this._room._startTime,
  166079. group: "costs"
  166080. })),
  166081. rt
  166082. } catch (at) {
  166083. return rt.isLoading = !1,
  166084. this._room.emit("avatarChanged", {
  166085. avatars: this._room.avatars
  166086. }),
  166087. log.error(at),
  166088. Promise.reject(at)
  166089. }
  166090. }
  166091. removeAvatar(e, i=!1) {
  166092. const o = this.avatars.get(e);
  166093. if (!!o) {
  166094. if (o.removeWhenDisconnected || i) {
  166095. o.removeAttachedEffects(),
  166096. o.xAvatar && this.xAvatarManager.deleteAvatar(o.xAvatar),
  166097. this.avatars.delete(e),
  166098. this._room.emit("avatarChanged", {
  166099. avatars: this._room.avatars
  166100. });
  166101. return
  166102. }
  166103. o.setConnectionStatus(!0)
  166104. }
  166105. }
  166106. clearOtherUsers() {
  166107. this.avatars.forEach(e=>{
  166108. !e.isSelf && e.group === AvatarGroup.User && this.removeAvatar(e.userId)
  166109. }
  166110. )
  166111. }
  166112. async _updateAvatarMovingStatus(e) {
  166113. var d, _;
  166114. const {id: i, isMoving: o, isRotating: s} = e
  166115. , c = this.avatars.get(i);
  166116. if (!!c) {
  166117. if (c.isRotating !== s) {
  166118. c.isRotating = s;
  166119. let b = "Idle";
  166120. s && (b = "Walking",
  166121. c.motionType === MotionType.Run && (b = "Running")),
  166122. c._playAnimation(b, !0, !0),
  166123. log.infoAndReportMeasurement({
  166124. startTime: Date.now(),
  166125. value: 0,
  166126. metric: s ? "userAvatarStartRotating" : "userAvatarStopRotating",
  166127. extra: {
  166128. motionType: c.motionType,
  166129. moveToExtra: this._room.moveToExtra
  166130. }
  166131. })
  166132. }
  166133. if (c.isMoving !== o) {
  166134. c.isMoving = o;
  166135. let b = "Idle";
  166136. o && (b = "Walking",
  166137. c.motionType === MotionType.Run && (b = "Running")),
  166138. o ? (c.avatarStartMovingHook(),
  166139. c.isSelf && (log.warn("startMoving emit", this._room.moveToExtra),
  166140. c.emit("startMoving", {
  166141. target: c,
  166142. extra: this._room.moveToExtra
  166143. }))) : (c.avatarStopMovingHook(),
  166144. c.isSelf && (log.warn("stopMoving emit", this._room.moveToExtra),
  166145. c.emit("stopMoving", {
  166146. target: c,
  166147. extra: this._room.moveToExtra
  166148. }))),
  166149. c._playAnimation(b, !0, !0),
  166150. log.infoAndReportMeasurement({
  166151. startTime: Date.now(),
  166152. value: 0,
  166153. metric: o ? "userAvatarStartMoving" : "userAvatarStopMoving",
  166154. extra: {
  166155. motionType: c.motionType,
  166156. moveToExtra: this._room.moveToExtra
  166157. }
  166158. })
  166159. }
  166160. if (o && ((_ = (d = c.xAvatar) == null ? void 0 : d.controller) == null ? void 0 : _.onPlay) === "Idle") {
  166161. let b = "Walking";
  166162. c.motionType === MotionType.Run && (b = "Running"),
  166163. log.error("force avoiding slide step"),
  166164. c._playAnimation(b, !0, !0)
  166165. }
  166166. }
  166167. }
  166168. _usersStatistics() {
  166169. this._room.on("userAvatarLoaded", ()=>{
  166170. window.setInterval(()=>{
  166171. const e = this._room.avatars.filter(o=>o.group === AvatarGroup.User).length || 0
  166172. , i = this._room.avatars.filter(o=>o.group === AvatarGroup.User && o.isRender).length || 0;
  166173. this._room.stats.assign({
  166174. userNum: e,
  166175. syncUserNum: this.syncAvatarsLength,
  166176. renderedUserNum: i
  166177. })
  166178. }
  166179. , 3e3)
  166180. }
  166181. )
  166182. }
  166183. }
  166184. ;
  166185. let XverseAvatarManager = pr;
  166186. Tt(XverseAvatarManager, "subAvatar", XverseAvatar);
  166187. new Logger("Wsutils");
  166188. function downloadFileByBase64(a, e) {
  166189. const i = dataURLtoBlob(a)
  166190. , o = URL.createObjectURL(i);
  166191. downloadFile(o, e)
  166192. }
  166193. function dataURLtoBlob(a) {
  166194. var d;
  166195. const e = a.split(",")
  166196. , i = (d = e[0].match(/:(.*?);/)) == null ? void 0 : d[1]
  166197. , o = atob(e[1]);
  166198. let s = o.length;
  166199. const c = new Uint8Array(s);
  166200. for (; s--; )
  166201. c[s] = o.charCodeAt(s);
  166202. return new Blob([c],{
  166203. type: i
  166204. })
  166205. }
  166206. function downloadFile(a, e="screenShot.png") {
  166207. const i = document.createElement("a");
  166208. i.setAttribute("href", a),
  166209. i.setAttribute("download", e),
  166210. i.setAttribute("target", "_blank");
  166211. const o = document.createEvent("MouseEvents");
  166212. o.initEvent("click", !0, !0),
  166213. i.dispatchEvent(o)
  166214. }
  166215. const distance = (a,e)=>{
  166216. const i = e.x - a.x
  166217. , o = e.y - a.y;
  166218. return Math.sqrt(i * i + o * o)
  166219. }
  166220. , angle = (a,e)=>{
  166221. const i = e.x - a.x
  166222. , o = e.y - a.y;
  166223. return degrees(Math.atan2(o, i))
  166224. }
  166225. , findCoord = (a,e,i)=>{
  166226. const o = {
  166227. x: 0,
  166228. y: 0
  166229. };
  166230. return i = radians(i),
  166231. o.x = a.x - e * Math.cos(i),
  166232. o.y = a.y - e * Math.sin(i),
  166233. o
  166234. }
  166235. , radians = a=>a * (Math.PI / 180)
  166236. , degrees = a=>a * (180 / Math.PI)
  166237. , isPressed = a=>isNaN(a.buttons) ? a.pressure !== 0 : a.buttons !== 0
  166238. , timers = new Map
  166239. , throttle = a=>{
  166240. timers.has(a) && clearTimeout(timers.get(a)),
  166241. timers.set(a, setTimeout(a, 100))
  166242. }
  166243. , bindEvt = (a,e,i)=>{
  166244. const o = e.split(/[ ,]+/g);
  166245. let s;
  166246. for (let c = 0; c < o.length; c += 1)
  166247. s = o[c],
  166248. a.addEventListener ? a.addEventListener(s, i, !1) : a.attachEvent && a.attachEvent(s, i)
  166249. }
  166250. , unbindEvt = (a,e,i)=>{
  166251. const o = e.split(/[ ,]+/g);
  166252. let s;
  166253. for (let c = 0; c < o.length; c += 1)
  166254. s = o[c],
  166255. a.removeEventListener ? a.removeEventListener(s, i) : a.detachEvent && a.detachEvent(s, i)
  166256. }
  166257. , prepareEvent = a=>(a.preventDefault(),
  166258. a.type.match(/^touch/) ? a.changedTouches : a)
  166259. , getScroll = ()=>{
  166260. const a = window.pageXOffset !== void 0 ? window.pageXOffset : (document.documentElement || document.body.parentNode || document.body).scrollLeft
  166261. , e = window.pageYOffset !== void 0 ? window.pageYOffset : (document.documentElement || document.body.parentNode || document.body).scrollTop;
  166262. return {
  166263. x: a,
  166264. y: e
  166265. }
  166266. }
  166267. , applyPosition = (a,e)=>{
  166268. e.top || e.right || e.bottom || e.left ? (a.style.top = e.top,
  166269. a.style.right = e.right,
  166270. a.style.bottom = e.bottom,
  166271. a.style.left = e.left) : (a.style.left = e.x + "px",
  166272. a.style.top = e.y + "px")
  166273. }
  166274. , getTransitionStyle = (a,e,i)=>{
  166275. const o = configStylePropertyObject(a);
  166276. for (let s in o)
  166277. if (o.hasOwnProperty(s))
  166278. if (typeof e == "string")
  166279. o[s] = e + " " + i;
  166280. else {
  166281. let c = "";
  166282. for (let d = 0, _ = e.length; d < _; d += 1)
  166283. c += e[d] + " " + i + ", ";
  166284. o[s] = c.slice(0, -2)
  166285. }
  166286. return o
  166287. }
  166288. , getVendorStyle = (a,e)=>{
  166289. const i = configStylePropertyObject(a);
  166290. for (let o in i)
  166291. i.hasOwnProperty(o) && (i[o] = e);
  166292. return i
  166293. }
  166294. , configStylePropertyObject = a=>{
  166295. const e = {};
  166296. return e[a] = "",
  166297. ["webkit", "Moz", "o"].forEach(function(o) {
  166298. e[o + a.charAt(0).toUpperCase() + a.slice(1)] = ""
  166299. }),
  166300. e
  166301. }
  166302. , extend = (a,e)=>{
  166303. for (let i in e)
  166304. e.hasOwnProperty(i) && (a[i] = e[i]);
  166305. return a
  166306. }
  166307. , safeExtend = (a,e)=>{
  166308. const i = {};
  166309. for (let o in a)
  166310. a.hasOwnProperty(o) && e.hasOwnProperty(o) ? i[o] = e[o] : a.hasOwnProperty(o) && (i[o] = a[o]);
  166311. return i
  166312. }
  166313. , map = (a,e)=>{
  166314. if (a.length)
  166315. for (let i = 0, o = a.length; i < o; i += 1)
  166316. e(a[i]);
  166317. else
  166318. e(a)
  166319. }
  166320. , clamp = (a,e,i)=>({
  166321. x: Math.min(Math.max(a.x, e.x - i), e.x + i),
  166322. y: Math.min(Math.max(a.y, e.y - i), e.y + i)
  166323. });
  166324. var isTouch = "ontouchstart"in window, isPointer = !!window.PointerEvent, isMSPointer = !!window.MSPointerEvent, events = {
  166325. touch: {
  166326. start: "touchstart",
  166327. move: "touchmove",
  166328. end: "touchend, touchcancel"
  166329. },
  166330. mouse: {
  166331. start: "mousedown",
  166332. move: "mousemove",
  166333. end: "mouseup"
  166334. },
  166335. pointer: {
  166336. start: "pointerdown",
  166337. move: "pointermove",
  166338. end: "pointerup, pointercancel"
  166339. },
  166340. MSPointer: {
  166341. start: "MSPointerDown",
  166342. move: "MSPointerMove",
  166343. end: "MSPointerUp"
  166344. }
  166345. }, toBind, secondBind = {};
  166346. isPointer ? toBind = events.pointer : isMSPointer ? toBind = events.MSPointer : isTouch ? (toBind = events.touch,
  166347. secondBind = events.mouse) : toBind = events.mouse;
  166348. function Super() {}
  166349. Super.prototype.on = function(a, e) {
  166350. var i = this, o = a.split(/[ ,]+/g), s;
  166351. i._handlers_ = i._handlers_ || {};
  166352. for (var c = 0; c < o.length; c += 1)
  166353. s = o[c],
  166354. i._handlers_[s] = i._handlers_[s] || [],
  166355. i._handlers_[s].push(e);
  166356. return i
  166357. }
  166358. ;
  166359. Super.prototype.off = function(a, e) {
  166360. var i = this;
  166361. return i._handlers_ = i._handlers_ || {},
  166362. a === void 0 ? i._handlers_ = {} : e === void 0 ? i._handlers_[a] = null : i._handlers_[a] && i._handlers_[a].indexOf(e) >= 0 && i._handlers_[a].splice(i._handlers_[a].indexOf(e), 1),
  166363. i
  166364. }
  166365. ;
  166366. Super.prototype.trigger = function(a, e) {
  166367. var i = this, o = a.split(/[ ,]+/g), s;
  166368. i._handlers_ = i._handlers_ || {};
  166369. for (var c = 0; c < o.length; c += 1)
  166370. s = o[c],
  166371. i._handlers_[s] && i._handlers_[s].length && i._handlers_[s].forEach(function(d) {
  166372. d.call(i, {
  166373. type: s,
  166374. target: i
  166375. }, e)
  166376. })
  166377. }
  166378. ;
  166379. Super.prototype.config = function(a) {
  166380. var e = this;
  166381. e.options = e.defaults || {},
  166382. a && (e.options = safeExtend(e.options, a))
  166383. }
  166384. ;
  166385. Super.prototype.bindEvt = function(a, e) {
  166386. var i = this;
  166387. return i._domHandlers_ = i._domHandlers_ || {},
  166388. i._domHandlers_[e] = function() {
  166389. typeof i["on" + e] == "function" ? i["on" + e].apply(i, arguments) : console.warn('[WARNING] : Missing "on' + e + '" handler.')
  166390. }
  166391. ,
  166392. bindEvt(a, toBind[e], i._domHandlers_[e]),
  166393. secondBind[e] && bindEvt(a, secondBind[e], i._domHandlers_[e]),
  166394. i
  166395. }
  166396. ;
  166397. Super.prototype.unbindEvt = function(a, e) {
  166398. var i = this;
  166399. return i._domHandlers_ = i._domHandlers_ || {},
  166400. unbindEvt(a, toBind[e], i._domHandlers_[e]),
  166401. secondBind[e] && unbindEvt(a, secondBind[e], i._domHandlers_[e]),
  166402. delete i._domHandlers_[e],
  166403. this
  166404. }
  166405. ;
  166406. function Nipple(a, e) {
  166407. return this.identifier = e.identifier,
  166408. this.position = e.position,
  166409. this.frontPosition = e.frontPosition,
  166410. this.collection = a,
  166411. this.defaults = {
  166412. size: 100,
  166413. threshold: .1,
  166414. color: "white",
  166415. fadeTime: 250,
  166416. dataOnly: !1,
  166417. restJoystick: !0,
  166418. restOpacity: .5,
  166419. mode: "dynamic",
  166420. zone: document.body,
  166421. lockX: !1,
  166422. lockY: !1,
  166423. shape: "circle"
  166424. },
  166425. this.config(e),
  166426. this.options.mode === "dynamic" && (this.options.restOpacity = 0),
  166427. this.id = Nipple.id,
  166428. Nipple.id += 1,
  166429. this.buildEl().stylize(),
  166430. this.instance = {
  166431. el: this.ui.el,
  166432. on: this.on.bind(this),
  166433. off: this.off.bind(this),
  166434. show: this.show.bind(this),
  166435. hide: this.hide.bind(this),
  166436. add: this.addToDom.bind(this),
  166437. remove: this.removeFromDom.bind(this),
  166438. destroy: this.destroy.bind(this),
  166439. setPosition: this.setPosition.bind(this),
  166440. resetDirection: this.resetDirection.bind(this),
  166441. computeDirection: this.computeDirection.bind(this),
  166442. trigger: this.trigger.bind(this),
  166443. position: this.position,
  166444. frontPosition: this.frontPosition,
  166445. ui: this.ui,
  166446. identifier: this.identifier,
  166447. id: this.id,
  166448. options: this.options
  166449. },
  166450. this.instance
  166451. }
  166452. Nipple.prototype = new Super;
  166453. Nipple.constructor = Nipple;
  166454. Nipple.id = 0;
  166455. Nipple.prototype.buildEl = function(a) {
  166456. return this.ui = {},
  166457. this.options.dataOnly ? this : (this.ui.el = document.createElement("div"),
  166458. this.ui.back = document.createElement("div"),
  166459. this.ui.front = document.createElement("div"),
  166460. this.ui.el.className = "nipple collection_" + this.collection.id,
  166461. this.ui.back.className = "back",
  166462. this.ui.front.className = "front",
  166463. this.ui.el.setAttribute("id", "nipple_" + this.collection.id + "_" + this.id),
  166464. this.ui.el.appendChild(this.ui.back),
  166465. this.ui.el.appendChild(this.ui.front),
  166466. this)
  166467. }
  166468. ;
  166469. Nipple.prototype.stylize = function() {
  166470. if (this.options.dataOnly)
  166471. return this;
  166472. var a = this.options.fadeTime + "ms"
  166473. , e = getVendorStyle("borderRadius", "50%")
  166474. , i = getTransitionStyle("transition", "opacity", a)
  166475. , o = {};
  166476. return o.el = {
  166477. position: "absolute",
  166478. opacity: this.options.restOpacity,
  166479. display: "block",
  166480. zIndex: 999
  166481. },
  166482. o.back = {
  166483. position: "absolute",
  166484. display: "block",
  166485. width: this.options.size + "px",
  166486. height: this.options.size + "px",
  166487. marginLeft: -this.options.size / 2 + "px",
  166488. marginTop: -this.options.size / 2 + "px",
  166489. background: this.options.color,
  166490. opacity: ".5"
  166491. },
  166492. o.front = {
  166493. width: this.options.size / 2 + "px",
  166494. height: this.options.size / 2 + "px",
  166495. position: "absolute",
  166496. display: "block",
  166497. marginLeft: -this.options.size / 4 + "px",
  166498. marginTop: -this.options.size / 4 + "px",
  166499. background: this.options.color,
  166500. opacity: ".5"
  166501. },
  166502. extend(o.el, i),
  166503. this.options.shape === "circle" && extend(o.back, e),
  166504. extend(o.front, e),
  166505. this.applyStyles(o),
  166506. this
  166507. }
  166508. ;
  166509. Nipple.prototype.applyStyles = function(a) {
  166510. for (var e in this.ui)
  166511. if (this.ui.hasOwnProperty(e))
  166512. for (var i in a[e])
  166513. this.ui[e].style[i] = a[e][i];
  166514. return this
  166515. }
  166516. ;
  166517. Nipple.prototype.addToDom = function() {
  166518. return this.options.dataOnly || document.body.contains(this.ui.el) ? this : (this.options.zone.appendChild(this.ui.el),
  166519. this)
  166520. }
  166521. ;
  166522. Nipple.prototype.removeFromDom = function() {
  166523. return this.options.dataOnly || !document.body.contains(this.ui.el) ? this : (this.options.zone.removeChild(this.ui.el),
  166524. this)
  166525. }
  166526. ;
  166527. Nipple.prototype.destroy = function() {
  166528. clearTimeout(this.removeTimeout),
  166529. clearTimeout(this.showTimeout),
  166530. clearTimeout(this.restTimeout),
  166531. this.trigger("destroyed", this.instance),
  166532. this.removeFromDom(),
  166533. this.off()
  166534. }
  166535. ;
  166536. Nipple.prototype.show = function(a) {
  166537. var e = this;
  166538. return e.options.dataOnly || (clearTimeout(e.removeTimeout),
  166539. clearTimeout(e.showTimeout),
  166540. clearTimeout(e.restTimeout),
  166541. e.addToDom(),
  166542. e.restCallback(),
  166543. setTimeout(function() {
  166544. e.ui.el.style.opacity = 1
  166545. }, 0),
  166546. e.showTimeout = setTimeout(function() {
  166547. e.trigger("shown", e.instance),
  166548. typeof a == "function" && a.call(this)
  166549. }, e.options.fadeTime)),
  166550. e
  166551. }
  166552. ;
  166553. Nipple.prototype.hide = function(a) {
  166554. var e = this;
  166555. if (e.options.dataOnly)
  166556. return e;
  166557. if (e.ui.el.style.opacity = e.options.restOpacity,
  166558. clearTimeout(e.removeTimeout),
  166559. clearTimeout(e.showTimeout),
  166560. clearTimeout(e.restTimeout),
  166561. e.removeTimeout = setTimeout(function() {
  166562. var i = e.options.mode === "dynamic" ? "none" : "block";
  166563. e.ui.el.style.display = i,
  166564. typeof a == "function" && a.call(e),
  166565. e.trigger("hidden", e.instance)
  166566. }, e.options.fadeTime),
  166567. e.options.restJoystick) {
  166568. const i = e.options.restJoystick
  166569. , o = {};
  166570. o.x = i === !0 || i.x !== !1 ? 0 : e.instance.frontPosition.x,
  166571. o.y = i === !0 || i.y !== !1 ? 0 : e.instance.frontPosition.y,
  166572. e.setPosition(a, o)
  166573. }
  166574. return e
  166575. }
  166576. ;
  166577. Nipple.prototype.setPosition = function(a, e) {
  166578. var i = this;
  166579. i.frontPosition = {
  166580. x: e.x,
  166581. y: e.y
  166582. };
  166583. var o = i.options.fadeTime + "ms"
  166584. , s = {};
  166585. s.front = getTransitionStyle("transition", ["top", "left"], o);
  166586. var c = {
  166587. front: {}
  166588. };
  166589. c.front = {
  166590. left: i.frontPosition.x + "px",
  166591. top: i.frontPosition.y + "px"
  166592. },
  166593. i.applyStyles(s),
  166594. i.applyStyles(c),
  166595. i.restTimeout = setTimeout(function() {
  166596. typeof a == "function" && a.call(i),
  166597. i.restCallback()
  166598. }, i.options.fadeTime)
  166599. }
  166600. ;
  166601. Nipple.prototype.restCallback = function() {
  166602. var a = this
  166603. , e = {};
  166604. e.front = getTransitionStyle("transition", "none", ""),
  166605. a.applyStyles(e),
  166606. a.trigger("rested", a.instance)
  166607. }
  166608. ;
  166609. Nipple.prototype.resetDirection = function() {
  166610. this.direction = {
  166611. x: !1,
  166612. y: !1,
  166613. angle: !1
  166614. }
  166615. }
  166616. ;
  166617. Nipple.prototype.computeDirection = function(a) {
  166618. var e = a.angle.radian, i = Math.PI / 4, o = Math.PI / 2, s, c, d;
  166619. if (e > i && e < i * 3 && !a.lockX ? s = "up" : e > -i && e <= i && !a.lockY ? s = "left" : e > -i * 3 && e <= -i && !a.lockX ? s = "down" : a.lockY || (s = "right"),
  166620. a.lockY || (e > -o && e < o ? c = "left" : c = "right"),
  166621. a.lockX || (e > 0 ? d = "up" : d = "down"),
  166622. a.force > this.options.threshold) {
  166623. var _ = {}, b;
  166624. for (b in this.direction)
  166625. this.direction.hasOwnProperty(b) && (_[b] = this.direction[b]);
  166626. var k = {};
  166627. this.direction = {
  166628. x: c,
  166629. y: d,
  166630. angle: s
  166631. },
  166632. a.direction = this.direction;
  166633. for (b in _)
  166634. _[b] === this.direction[b] && (k[b] = !0);
  166635. if (k.x && k.y && k.angle)
  166636. return a;
  166637. (!k.x || !k.y) && this.trigger("plain", a),
  166638. k.x || this.trigger("plain:" + c, a),
  166639. k.y || this.trigger("plain:" + d, a),
  166640. k.angle || this.trigger("dir dir:" + s, a)
  166641. } else
  166642. this.resetDirection();
  166643. return a
  166644. }
  166645. ;
  166646. function Collection(a, e) {
  166647. var i = this;
  166648. i.nipples = [],
  166649. i.idles = [],
  166650. i.actives = [],
  166651. i.ids = [],
  166652. i.pressureIntervals = {},
  166653. i.manager = a,
  166654. i.id = Collection.id,
  166655. Collection.id += 1,
  166656. i.defaults = {
  166657. zone: document.body,
  166658. multitouch: !1,
  166659. maxNumberOfNipples: 10,
  166660. mode: "dynamic",
  166661. position: {
  166662. top: 0,
  166663. left: 0
  166664. },
  166665. catchDistance: 200,
  166666. size: 100,
  166667. threshold: .1,
  166668. color: "white",
  166669. fadeTime: 250,
  166670. dataOnly: !1,
  166671. restJoystick: !0,
  166672. restOpacity: .5,
  166673. lockX: !1,
  166674. lockY: !1,
  166675. shape: "circle",
  166676. dynamicPage: !1,
  166677. follow: !1
  166678. },
  166679. i.config(e),
  166680. (i.options.mode === "static" || i.options.mode === "semi") && (i.options.multitouch = !1),
  166681. i.options.multitouch || (i.options.maxNumberOfNipples = 1);
  166682. const o = getComputedStyle(i.options.zone.parentElement);
  166683. return o && o.display === "flex" && (i.parentIsFlex = !0),
  166684. i.updateBox(),
  166685. i.prepareNipples(),
  166686. i.bindings(),
  166687. i.begin(),
  166688. i.nipples
  166689. }
  166690. Collection.prototype = new Super;
  166691. Collection.constructor = Collection;
  166692. Collection.id = 0;
  166693. Collection.prototype.prepareNipples = function() {
  166694. var a = this
  166695. , e = a.nipples;
  166696. e.on = a.on.bind(a),
  166697. e.off = a.off.bind(a),
  166698. e.options = a.options,
  166699. e.destroy = a.destroy.bind(a),
  166700. e.ids = a.ids,
  166701. e.id = a.id,
  166702. e.processOnMove = a.processOnMove.bind(a),
  166703. e.processOnEnd = a.processOnEnd.bind(a),
  166704. e.get = function(i) {
  166705. if (i === void 0)
  166706. return e[0];
  166707. for (var o = 0, s = e.length; o < s; o += 1)
  166708. if (e[o].identifier === i)
  166709. return e[o];
  166710. return !1
  166711. }
  166712. }
  166713. ;
  166714. Collection.prototype.bindings = function() {
  166715. var a = this;
  166716. a.bindEvt(a.options.zone, "start"),
  166717. a.options.zone.style.touchAction = "none",
  166718. a.options.zone.style.msTouchAction = "none"
  166719. }
  166720. ;
  166721. Collection.prototype.begin = function() {
  166722. var a = this
  166723. , e = a.options;
  166724. if (e.mode === "static") {
  166725. var i = a.createNipple(e.position, a.manager.getIdentifier());
  166726. i.add(),
  166727. a.idles.push(i)
  166728. }
  166729. }
  166730. ;
  166731. Collection.prototype.createNipple = function(a, e) {
  166732. var i = this
  166733. , o = i.manager.scroll
  166734. , s = {}
  166735. , c = i.options
  166736. , d = {
  166737. x: i.parentIsFlex ? o.x : o.x + i.box.left,
  166738. y: i.parentIsFlex ? o.y : o.y + i.box.top
  166739. };
  166740. if (a.x && a.y)
  166741. s = {
  166742. x: a.x - d.x,
  166743. y: a.y - d.y
  166744. };
  166745. else if (a.top || a.right || a.bottom || a.left) {
  166746. var _ = document.createElement("DIV");
  166747. _.style.display = "hidden",
  166748. _.style.top = a.top,
  166749. _.style.right = a.right,
  166750. _.style.bottom = a.bottom,
  166751. _.style.left = a.left,
  166752. _.style.position = "absolute",
  166753. c.zone.appendChild(_);
  166754. var b = _.getBoundingClientRect();
  166755. c.zone.removeChild(_),
  166756. s = a,
  166757. a = {
  166758. x: b.left + o.x,
  166759. y: b.top + o.y
  166760. }
  166761. }
  166762. var k = new Nipple(i,{
  166763. color: c.color,
  166764. size: c.size,
  166765. threshold: c.threshold,
  166766. fadeTime: c.fadeTime,
  166767. dataOnly: c.dataOnly,
  166768. restJoystick: c.restJoystick,
  166769. restOpacity: c.restOpacity,
  166770. mode: c.mode,
  166771. identifier: e,
  166772. position: a,
  166773. zone: c.zone,
  166774. frontPosition: {
  166775. x: 0,
  166776. y: 0
  166777. },
  166778. shape: c.shape
  166779. });
  166780. return c.dataOnly || (applyPosition(k.ui.el, s),
  166781. applyPosition(k.ui.front, k.frontPosition)),
  166782. i.nipples.push(k),
  166783. i.trigger("added " + k.identifier + ":added", k),
  166784. i.manager.trigger("added " + k.identifier + ":added", k),
  166785. i.bindNipple(k),
  166786. k
  166787. }
  166788. ;
  166789. Collection.prototype.updateBox = function() {
  166790. var a = this;
  166791. a.box = a.options.zone.getBoundingClientRect()
  166792. }
  166793. ;
  166794. Collection.prototype.bindNipple = function(a) {
  166795. var e = this, i, o = function(s, c) {
  166796. i = s.type + " " + c.id + ":" + s.type,
  166797. e.trigger(i, c)
  166798. };
  166799. a.on("destroyed", e.onDestroyed.bind(e)),
  166800. a.on("shown hidden rested dir plain", o),
  166801. a.on("dir:up dir:right dir:down dir:left", o),
  166802. a.on("plain:up plain:right plain:down plain:left", o)
  166803. }
  166804. ;
  166805. Collection.prototype.pressureFn = function(a, e, i) {
  166806. var o = this
  166807. , s = 0;
  166808. clearInterval(o.pressureIntervals[i]),
  166809. o.pressureIntervals[i] = setInterval(function() {
  166810. var c = a.force || a.pressure || a.webkitForce || 0;
  166811. c !== s && (e.trigger("pressure", c),
  166812. o.trigger("pressure " + e.identifier + ":pressure", c),
  166813. s = c)
  166814. }
  166815. .bind(o), 100)
  166816. }
  166817. ;
  166818. Collection.prototype.onstart = function(a) {
  166819. var e = this
  166820. , i = e.options
  166821. , o = a;
  166822. a = prepareEvent(a),
  166823. e.updateBox();
  166824. var s = function(c) {
  166825. e.actives.length < i.maxNumberOfNipples ? e.processOnStart(c) : o.type.match(/^touch/) && (Object.keys(e.manager.ids).forEach(function(d) {
  166826. if (Object.values(o.touches).findIndex(function(b) {
  166827. return b.identifier === d
  166828. }) < 0) {
  166829. var _ = [a[0]];
  166830. _.identifier = d,
  166831. e.processOnEnd(_)
  166832. }
  166833. }),
  166834. e.actives.length < i.maxNumberOfNipples && e.processOnStart(c))
  166835. };
  166836. return map(a, s),
  166837. e.manager.bindDocument(),
  166838. !1
  166839. }
  166840. ;
  166841. Collection.prototype.processOnStart = function(a) {
  166842. var e = this, i = e.options, o, s = e.manager.getIdentifier(a), c = a.force || a.pressure || a.webkitForce || 0, d = {
  166843. x: a.pageX,
  166844. y: a.pageY
  166845. }, _ = e.getOrCreate(s, d);
  166846. _.identifier !== s && e.manager.removeIdentifier(_.identifier),
  166847. _.identifier = s;
  166848. var b = function(j) {
  166849. j.trigger("start", j),
  166850. e.trigger("start " + j.id + ":start", j),
  166851. j.show(),
  166852. c > 0 && e.pressureFn(a, j, j.identifier),
  166853. e.processOnMove(a)
  166854. };
  166855. if ((o = e.idles.indexOf(_)) >= 0 && e.idles.splice(o, 1),
  166856. e.actives.push(_),
  166857. e.ids.push(_.identifier),
  166858. i.mode !== "semi")
  166859. b(_);
  166860. else {
  166861. var k = distance(d, _.position);
  166862. if (k <= i.catchDistance)
  166863. b(_);
  166864. else {
  166865. _.destroy(),
  166866. e.processOnStart(a);
  166867. return
  166868. }
  166869. }
  166870. return _
  166871. }
  166872. ;
  166873. Collection.prototype.getOrCreate = function(a, e) {
  166874. var i = this, o = i.options, s;
  166875. return /(semi|static)/.test(o.mode) ? (s = i.idles[0],
  166876. s ? (i.idles.splice(0, 1),
  166877. s) : o.mode === "semi" ? i.createNipple(e, a) : (console.warn("Coudln't find the needed nipple."),
  166878. !1)) : (s = i.createNipple(e, a),
  166879. s)
  166880. }
  166881. ;
  166882. Collection.prototype.processOnMove = function(a) {
  166883. var e = this
  166884. , i = e.options
  166885. , o = e.manager.getIdentifier(a)
  166886. , s = e.nipples.get(o)
  166887. , c = e.manager.scroll;
  166888. if (!isPressed(a)) {
  166889. this.processOnEnd(a);
  166890. return
  166891. }
  166892. if (!s) {
  166893. console.error("Found zombie joystick with ID " + o),
  166894. e.manager.removeIdentifier(o);
  166895. return
  166896. }
  166897. if (i.dynamicPage) {
  166898. var d = s.el.getBoundingClientRect();
  166899. s.position = {
  166900. x: c.x + d.left,
  166901. y: c.y + d.top
  166902. }
  166903. }
  166904. s.identifier = o;
  166905. var _ = s.options.size / 2
  166906. , b = {
  166907. x: a.pageX,
  166908. y: a.pageY
  166909. };
  166910. i.lockX && (b.y = s.position.y),
  166911. i.lockY && (b.x = s.position.x);
  166912. var k = distance(b, s.position), j = angle(b, s.position), $ = radians(j), _e = k / _, et = {
  166913. distance: k,
  166914. position: b
  166915. }, tt, rt;
  166916. if (s.options.shape === "circle" ? (tt = Math.min(k, _),
  166917. rt = findCoord(s.position, tt, j)) : (rt = clamp(b, s.position, _),
  166918. tt = distance(rt, s.position)),
  166919. i.follow) {
  166920. if (k > _) {
  166921. let at = b.x - rt.x
  166922. , st = b.y - rt.y;
  166923. s.position.x += at,
  166924. s.position.y += st,
  166925. s.el.style.top = s.position.y - (e.box.top + c.y) + "px",
  166926. s.el.style.left = s.position.x - (e.box.left + c.x) + "px",
  166927. k = distance(b, s.position)
  166928. }
  166929. } else
  166930. b = rt,
  166931. k = tt;
  166932. var it = b.x - s.position.x
  166933. , nt = b.y - s.position.y;
  166934. s.frontPosition = {
  166935. x: it,
  166936. y: nt
  166937. },
  166938. i.dataOnly || applyPosition(s.ui.front, s.frontPosition);
  166939. var ot = {
  166940. identifier: s.identifier,
  166941. position: b,
  166942. force: _e,
  166943. pressure: a.force || a.pressure || a.webkitForce || 0,
  166944. distance: k,
  166945. angle: {
  166946. radian: $,
  166947. degree: j
  166948. },
  166949. vector: {
  166950. x: it / _,
  166951. y: -nt / _
  166952. },
  166953. raw: et,
  166954. instance: s,
  166955. lockX: i.lockX,
  166956. lockY: i.lockY
  166957. };
  166958. ot = s.computeDirection(ot),
  166959. ot.angle = {
  166960. radian: radians(180 - j),
  166961. degree: 180 - j
  166962. },
  166963. s.trigger("move", ot),
  166964. e.trigger("move " + s.id + ":move", ot)
  166965. }
  166966. ;
  166967. Collection.prototype.processOnEnd = function(a) {
  166968. var e = this
  166969. , i = e.options
  166970. , o = e.manager.getIdentifier(a)
  166971. , s = e.nipples.get(o)
  166972. , c = e.manager.removeIdentifier(s.identifier);
  166973. !s || (i.dataOnly || s.hide(function() {
  166974. i.mode === "dynamic" && (s.trigger("removed", s),
  166975. e.trigger("removed " + s.id + ":removed", s),
  166976. e.manager.trigger("removed " + s.id + ":removed", s),
  166977. s.destroy())
  166978. }),
  166979. clearInterval(e.pressureIntervals[s.identifier]),
  166980. s.resetDirection(),
  166981. s.trigger("end", s),
  166982. e.trigger("end " + s.id + ":end", s),
  166983. e.ids.indexOf(s.identifier) >= 0 && e.ids.splice(e.ids.indexOf(s.identifier), 1),
  166984. e.actives.indexOf(s) >= 0 && e.actives.splice(e.actives.indexOf(s), 1),
  166985. /(semi|static)/.test(i.mode) ? e.idles.push(s) : e.nipples.indexOf(s) >= 0 && e.nipples.splice(e.nipples.indexOf(s), 1),
  166986. e.manager.unbindDocument(),
  166987. /(semi|static)/.test(i.mode) && (e.manager.ids[c.id] = c.identifier))
  166988. }
  166989. ;
  166990. Collection.prototype.onDestroyed = function(a, e) {
  166991. var i = this;
  166992. i.nipples.indexOf(e) >= 0 && i.nipples.splice(i.nipples.indexOf(e), 1),
  166993. i.actives.indexOf(e) >= 0 && i.actives.splice(i.actives.indexOf(e), 1),
  166994. i.idles.indexOf(e) >= 0 && i.idles.splice(i.idles.indexOf(e), 1),
  166995. i.ids.indexOf(e.identifier) >= 0 && i.ids.splice(i.ids.indexOf(e.identifier), 1),
  166996. i.manager.removeIdentifier(e.identifier),
  166997. i.manager.unbindDocument()
  166998. }
  166999. ;
  167000. Collection.prototype.destroy = function() {
  167001. var a = this;
  167002. a.unbindEvt(a.options.zone, "start"),
  167003. a.nipples.forEach(function(i) {
  167004. i.destroy()
  167005. });
  167006. for (var e in a.pressureIntervals)
  167007. a.pressureIntervals.hasOwnProperty(e) && clearInterval(a.pressureIntervals[e]);
  167008. a.trigger("destroyed", a.nipples),
  167009. a.manager.unbindDocument(),
  167010. a.off()
  167011. }
  167012. ;
  167013. function Manager(a) {
  167014. var e = this;
  167015. e.ids = {},
  167016. e.index = 0,
  167017. e.collections = [],
  167018. e.scroll = getScroll(),
  167019. e.config(a),
  167020. e.prepareCollections();
  167021. var i = function() {
  167022. var s;
  167023. e.collections.forEach(function(c) {
  167024. c.forEach(function(d) {
  167025. s = d.el.getBoundingClientRect(),
  167026. d.position = {
  167027. x: e.scroll.x + s.left,
  167028. y: e.scroll.y + s.top
  167029. }
  167030. })
  167031. })
  167032. };
  167033. bindEvt(window, "resize", function() {
  167034. throttle(i)
  167035. });
  167036. var o = function() {
  167037. e.scroll = getScroll()
  167038. };
  167039. return bindEvt(window, "scroll", function() {
  167040. throttle(o)
  167041. }),
  167042. e.collections
  167043. }
  167044. Manager.prototype = new Super;
  167045. Manager.constructor = Manager;
  167046. Manager.prototype.prepareCollections = function() {
  167047. var a = this;
  167048. a.collections.create = a.create.bind(a),
  167049. a.collections.on = a.on.bind(a),
  167050. a.collections.off = a.off.bind(a),
  167051. a.collections.destroy = a.destroy.bind(a),
  167052. a.collections.get = function(e) {
  167053. var i;
  167054. return a.collections.every(function(o) {
  167055. return i = o.get(e),
  167056. !i
  167057. }),
  167058. i
  167059. }
  167060. }
  167061. ;
  167062. Manager.prototype.create = function(a) {
  167063. return this.createCollection(a)
  167064. }
  167065. ;
  167066. Manager.prototype.createCollection = function(a) {
  167067. var e = this
  167068. , i = new Collection(e,a);
  167069. return e.bindCollection(i),
  167070. e.collections.push(i),
  167071. i
  167072. }
  167073. ;
  167074. Manager.prototype.bindCollection = function(a) {
  167075. var e = this, i, o = function(s, c) {
  167076. i = s.type + " " + c.id + ":" + s.type,
  167077. e.trigger(i, c)
  167078. };
  167079. a.on("destroyed", e.onDestroyed.bind(e)),
  167080. a.on("shown hidden rested dir plain", o),
  167081. a.on("dir:up dir:right dir:down dir:left", o),
  167082. a.on("plain:up plain:right plain:down plain:left", o)
  167083. }
  167084. ;
  167085. Manager.prototype.bindDocument = function() {
  167086. var a = this;
  167087. a.binded || (a.bindEvt(document, "move").bindEvt(document, "end"),
  167088. a.binded = !0)
  167089. }
  167090. ;
  167091. Manager.prototype.unbindDocument = function(a) {
  167092. var e = this;
  167093. (!Object.keys(e.ids).length || a === !0) && (e.unbindEvt(document, "move").unbindEvt(document, "end"),
  167094. e.binded = !1)
  167095. }
  167096. ;
  167097. Manager.prototype.getIdentifier = function(a) {
  167098. var e;
  167099. return a ? (e = a.identifier === void 0 ? a.pointerId : a.identifier,
  167100. e === void 0 && (e = this.latest || 0)) : e = this.index,
  167101. this.ids[e] === void 0 && (this.ids[e] = this.index,
  167102. this.index += 1),
  167103. this.latest = e,
  167104. this.ids[e]
  167105. }
  167106. ;
  167107. Manager.prototype.removeIdentifier = function(a) {
  167108. var e = {};
  167109. for (var i in this.ids)
  167110. if (this.ids[i] === a) {
  167111. e.id = i,
  167112. e.identifier = this.ids[i],
  167113. delete this.ids[i];
  167114. break
  167115. }
  167116. return e
  167117. }
  167118. ;
  167119. Manager.prototype.onmove = function(a) {
  167120. var e = this;
  167121. return e.onAny("move", a),
  167122. !1
  167123. }
  167124. ;
  167125. Manager.prototype.onend = function(a) {
  167126. var e = this;
  167127. return e.onAny("end", a),
  167128. !1
  167129. }
  167130. ;
  167131. Manager.prototype.oncancel = function(a) {
  167132. var e = this;
  167133. return e.onAny("end", a),
  167134. !1
  167135. }
  167136. ;
  167137. Manager.prototype.onAny = function(a, e) {
  167138. var i = this, o, s = "processOn" + a.charAt(0).toUpperCase() + a.slice(1);
  167139. e = prepareEvent(e);
  167140. var c = function(_, b, k) {
  167141. k.ids.indexOf(b) >= 0 && (k[s](_),
  167142. _._found_ = !0)
  167143. }
  167144. , d = function(_) {
  167145. o = i.getIdentifier(_),
  167146. map(i.collections, c.bind(null, _, o)),
  167147. _._found_ || i.removeIdentifier(o)
  167148. };
  167149. return map(e, d),
  167150. !1
  167151. }
  167152. ;
  167153. Manager.prototype.destroy = function() {
  167154. var a = this;
  167155. a.unbindDocument(!0),
  167156. a.ids = {},
  167157. a.index = 0,
  167158. a.collections.forEach(function(e) {
  167159. e.destroy()
  167160. }),
  167161. a.off()
  167162. }
  167163. ;
  167164. Manager.prototype.onDestroyed = function(a, e) {
  167165. var i = this;
  167166. if (i.collections.indexOf(e) < 0)
  167167. return !1;
  167168. i.collections.splice(i.collections.indexOf(e), 1)
  167169. }
  167170. ;
  167171. const factory = new Manager;
  167172. var nipplejs = {
  167173. create: function(a) {
  167174. return factory.create(a)
  167175. },
  167176. factory
  167177. };
  167178. class JoyStick {
  167179. constructor(e) {
  167180. Tt(this, "_zone");
  167181. Tt(this, "_joystick", null);
  167182. Tt(this, "_room");
  167183. this._room = e
  167184. }
  167185. get zone() {
  167186. return this._zone
  167187. }
  167188. init(e) {
  167189. var _e, et;
  167190. this.destroy();
  167191. const i = {
  167192. position: "absolute",
  167193. width: "200px",
  167194. height: "200px",
  167195. left: "0px",
  167196. bottom: "0px",
  167197. zIndex: "999",
  167198. userSelect: "none",
  167199. webkitUserSelect: "none"
  167200. }
  167201. , {interval: o=33, triggerDistance: s=25, size: c=110, zoneClassName: d="xverse-joystick-zone"} = e || {};
  167202. typeof ((_e = e == null ? void 0 : e.style) == null ? void 0 : _e.left) == "number" && (e.style.left = e.style.left + "px"),
  167203. typeof ((et = e == null ? void 0 : e.style) == null ? void 0 : et.bottom) == "number" && (e.style.bottom = e.style.bottom + "px");
  167204. const _ = Object.assign(i, e == null ? void 0 : e.style)
  167205. , b = (tt,rt)=>{
  167206. this._room.actionsHandler.joystick({
  167207. degree: Math.floor(tt),
  167208. level: Math.floor(rt / 5)
  167209. })
  167210. }
  167211. , k = this._zone = document.createElement("div");
  167212. document.body.appendChild(k),
  167213. k.className = d,
  167214. Object.keys(_).forEach(tt=>{
  167215. const rt = _[tt];
  167216. rt !== void 0 && (k.style[tt] = rt)
  167217. }
  167218. ),
  167219. this._joystick = nipplejs.create({
  167220. zone: k,
  167221. mode: "static",
  167222. position: {
  167223. left: "50%",
  167224. top: "50%"
  167225. },
  167226. color: "white",
  167227. restOpacity: .3,
  167228. size: c
  167229. }),
  167230. this.customizeStyle();
  167231. let j, $;
  167232. return this._joystick.on("move", (tt,rt)=>{
  167233. j = rt
  167234. }
  167235. ),
  167236. this._joystick.on("start", ()=>{
  167237. $ = window.setInterval(()=>{
  167238. j && j.distance > s && b && b(j.angle.degree, j.distance)
  167239. }
  167240. , o)
  167241. }
  167242. ),
  167243. this._joystick.on("end", ()=>{
  167244. $ && window.clearInterval($),
  167245. $ = void 0
  167246. }
  167247. ),
  167248. this._joystick
  167249. }
  167250. destroy() {
  167251. if (!!this._joystick) {
  167252. this._joystick.destroy();
  167253. try {
  167254. this._zone && document.body.removeChild(this._zone)
  167255. } catch {}
  167256. }
  167257. }
  167258. customizeStyle() {
  167259. var c, d;
  167260. const e = this._zone;
  167261. if (!e)
  167262. return;
  167263. const i = e.querySelector(".front")
  167264. , o = e.querySelector(".back")
  167265. , s = 30;
  167266. i.style.width = s + "px",
  167267. i.style.height = s + "px",
  167268. i.style.marginLeft = s / -2 + "px",
  167269. i.style.marginTop = s / -2 + "px",
  167270. o.style.boxSizing = "border-box",
  167271. o.style.backgroundColor = "black",
  167272. o.style.backgroundClip = "padding-box",
  167273. o.style.border = "2px solid white",
  167274. (c = this._joystick) == null || c.on("start", ()=>{
  167275. o.style.border = "2px solid #FFEA95",
  167276. o.style.boxShadow = "inset 0px 0px 8px rgba(255, 255, 255, 0.25)",
  167277. i.style.opacity = "1"
  167278. }
  167279. ),
  167280. (d = this._joystick) == null || d.on("end", ()=>{
  167281. o.style.border = "2px solid white",
  167282. o.style.boxShadow = "none"
  167283. }
  167284. )
  167285. }
  167286. show() {
  167287. if (!this._joystick || !this._zone)
  167288. throw new Error("joystick is not created");
  167289. this._zone.style.display = "block"
  167290. }
  167291. hide() {
  167292. this._zone && (this._zone.style.display = "none")
  167293. }
  167294. }
  167295. var app = "";
  167296. function toast(a, e) {
  167297. const {onClick: i, duration: o} = e || {};
  167298. return window.Toastify({
  167299. text: a,
  167300. duration: o || 3e3,
  167301. position: "center",
  167302. onClick: function() {
  167303. i && i()
  167304. }
  167305. }).showToast()
  167306. }
  167307. class XverseRoom extends XverseRoom$1 {
  167308. constructor() {
  167309. super(...arguments);
  167310. Tt(this, "joyStick", new JoyStick(this))
  167311. }
  167312. afterJoinRoomHook() {
  167313. this.joyStick.init({
  167314. style: {
  167315. width: "150px",
  167316. height: "150px"
  167317. }
  167318. })
  167319. }
  167320. }
  167321. class Xverse extends Xverse$1 {
  167322. async joinRoom(e) {
  167323. const i = e.pathName || "thirdwalk"
  167324. , o = e.rotationRenderType || RenderType.RotationVideo
  167325. , s = e.person || Person.Third
  167326. , c = new XverseRoom(Zt($t({}, e), {
  167327. appId: e.appId || this.appId,
  167328. releaseId: e.releaseId || this.releaseId,
  167329. pageSession: this.pageSession,
  167330. isAllSync: !0,
  167331. rotationRenderType: o,
  167332. syncByEvent: !0,
  167333. pathName: i,
  167334. person: s,
  167335. role: e.role || "audience"
  167336. }));
  167337. return c.initRoom().then(()=>c)
  167338. }
  167339. }
  167340. var loadingImage = "./assets/loading.f375926b.png"
  167341. , jsxRuntime = {
  167342. exports: {}
  167343. }
  167344. , reactJsxRuntime_production_min = {};
  167345. /** @license React v17.0.2
  167346. * react-jsx-runtime.production.min.js
  167347. *
  167348. * Copyright (c) Facebook, Inc. and its affiliates.
  167349. *
  167350. * This source code is licensed under the MIT license found in the
  167351. * LICENSE file in the root directory of this source tree.
  167352. */
  167353. var f = react.exports
  167354. , g = 60103;
  167355. reactJsxRuntime_production_min.Fragment = 60107;
  167356. if (typeof Symbol == "function" && Symbol.for) {
  167357. var h = Symbol.for;
  167358. g = h("react.element"),
  167359. reactJsxRuntime_production_min.Fragment = h("react.fragment")
  167360. }
  167361. var m = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner
  167362. , n = Object.prototype.hasOwnProperty
  167363. , p = {
  167364. key: !0,
  167365. ref: !0,
  167366. __self: !0,
  167367. __source: !0
  167368. };
  167369. function q(a, e, i) {
  167370. var o, s = {}, c = null, d = null;
  167371. i !== void 0 && (c = "" + i),
  167372. e.key !== void 0 && (c = "" + e.key),
  167373. e.ref !== void 0 && (d = e.ref);
  167374. for (o in e)
  167375. n.call(e, o) && !p.hasOwnProperty(o) && (s[o] = e[o]);
  167376. if (a && a.defaultProps)
  167377. for (o in e = a.defaultProps,
  167378. e)
  167379. s[o] === void 0 && (s[o] = e[o]);
  167380. return {
  167381. $$typeof: g,
  167382. type: a,
  167383. key: c,
  167384. ref: d,
  167385. props: s,
  167386. _owner: m.current
  167387. }
  167388. }
  167389. reactJsxRuntime_production_min.jsx = q;
  167390. reactJsxRuntime_production_min.jsxs = q;
  167391. jsxRuntime.exports = reactJsxRuntime_production_min;
  167392. const jsx = jsxRuntime.exports.jsx
  167393. , jsxs = jsxRuntime.exports.jsxs
  167394. , urlParam = new window.URLSearchParams(location.search)
  167395. , appId = urlParam.get("appId") || void 0
  167396. , releaseId = urlParam.get("releaseId") || void 0
  167397. , scale = Number(urlParam.get("scale") || 1)
  167398. , isDebug = !!urlParam.get("debug");
  167399. appId || alert("AppId \u4E0D\u80FD\u4E3A\u7A7A");
  167400. const xverse = new Xverse({
  167401. env: "DEV",
  167402. appId,
  167403. releaseId
  167404. });
  167405. let room;
  167406. function App() {
  167407. const [a,e] = react.exports.useState(!0)
  167408. , [i,o] = react.exports.useState(!0)
  167409. , [s,c] = react.exports.useState("high")
  167410. , [d,_] = react.exports.useState("");
  167411. react.exports.useEffect(()=>{
  167412. b()
  167413. }
  167414. , []);
  167415. const b = async()=>{
  167416. var ft;
  167417. const _e = document.querySelector("#canvas")
  167418. , et = urlParam.get("roomId") || "e629ef3e-022d-4e64-8654-703bb96410eb"
  167419. , tt = urlParam.get("userId") || Math.random().toString(16).slice(2)
  167420. , rt = urlParam.get("avatarId") || void 0
  167421. , it = urlParam.get("appId") || void 0
  167422. , nt = urlParam.get("skinId") || void 0
  167423. , ot = urlParam.get("pathName") || void 0
  167424. , at = urlParam.get("objectFit") || void 0
  167425. , st = {
  167426. width: parseInt(urlParam.get("width") || "1920"),
  167427. height: parseInt(urlParam.get("height") || "1080")
  167428. }
  167429. , ut = urlParam.get("ws") ? decodeURIComponent(urlParam.get("ws")) : "wss://uat-eks.xverse.cn/ws"
  167430. , ct = !!urlParam.get("preload")
  167431. , lt = "full";
  167432. if (Logger.setLevel(isDebug ? LoggerLevels.Debug : LoggerLevels.Warn),
  167433. ct)
  167434. try {
  167435. await ((ft = xverse.preload) == null ? void 0 : ft.start(lt, (ht,pt)=>{
  167436. const dt = `(${ht}/${pt})`;
  167437. _(dt)
  167438. }
  167439. ))
  167440. } catch (ht) {
  167441. if (console.error(ht),
  167442. ht.code === Codes.PreloadCanceled) {
  167443. toast("\u9884\u52A0\u8F7D\u88AB\u53D6\u6D88");
  167444. return
  167445. }
  167446. toast("\u8FDB\u5165\u5931\u8D25, \u8BF7\u91CD\u8BD5");
  167447. return
  167448. }
  167449. try {
  167450. room = await xverse.joinRoom({
  167451. canvas: _e,
  167452. skinId: nt,
  167453. avatarId: rt,
  167454. roomId: et,
  167455. userId: tt,
  167456. wsServerUrl: ut,
  167457. appId: it,
  167458. token: " ",
  167459. nickname: tt,
  167460. firends: ["user1"],
  167461. viewMode: "full",
  167462. resolution: st,
  167463. pathName: ot,
  167464. objectFit: at,
  167465. hasAvatar: !0,
  167466. syncToOthers: !0,
  167467. avatarScale: scale
  167468. }),
  167469. k(),
  167470. j(),
  167471. window.room = room,
  167472. e(!1)
  167473. } catch (ht) {
  167474. console.error(ht),
  167475. alert(ht);
  167476. return
  167477. }
  167478. }
  167479. , k = ()=>{
  167480. room.on("_coreClick", ({point: _e})=>{
  167481. room._userAvatar.moveTo({
  167482. point: _e
  167483. })
  167484. }
  167485. )
  167486. }
  167487. , j = ()=>{
  167488. room.on("repeatLogin", function() {
  167489. toast("\u8BE5\u7528\u6237\u5DF2\u7ECF\u5728\u5176\u4ED6\u5730\u70B9\u767B\u5F55", {
  167490. duration: 1e4
  167491. })
  167492. }),
  167493. room.on("reconnecting", function({count: _e}) {
  167494. toast(`\u5C1D\u8BD5\u7B2C${_e}\u6B21\u91CD\u8FDE`)
  167495. }),
  167496. room.on("reconnected", function() {
  167497. toast("\u91CD\u8FDE\u6210\u529F")
  167498. }),
  167499. room.on("disconnected", function() {
  167500. const _e = toast("\u8FDE\u63A5\u5931\u8D25\uFF0C\u624B\u52A8\u70B9\u51FB\u91CD\u8BD5", {
  167501. duration: 1e5,
  167502. onClick() {
  167503. _e.hideToast(),
  167504. room.reconnect()
  167505. }
  167506. })
  167507. })
  167508. }
  167509. ;
  167510. return jsxs("div", {
  167511. className: "App",
  167512. children: [jsx("canvas", {
  167513. id: "canvas",
  167514. className: "stream unselect"
  167515. }), !a && isDebug && (()=>jsxs("div", {
  167516. className: "debug_control_btns",
  167517. children: [jsx("button", {
  167518. onClick: ()=>{
  167519. var at, st;
  167520. (at = room.stats) != null && at.isShow ? room.stats.hide() : (st = room.stats) == null || st.show()
  167521. }
  167522. ,
  167523. children: "Toggle Stats"
  167524. }), jsx("button", {
  167525. onClick: ()=>{
  167526. room.debug.toggleSceneshading(),
  167527. o(room.debug.isSceneShading)
  167528. }
  167529. ,
  167530. children: i ? "\u53D6\u6D88\u4F4E\u6A21\u7740\u8272" : "\u4F4E\u6A21\u7740\u8272"
  167531. }), jsxs("button", {
  167532. onClick: ()=>{
  167533. let at = "average";
  167534. s === "high" ? at = "average" : s === "average" ? at = "low" : s === "low" ? at = "high" : at = "average",
  167535. c(at),
  167536. room.setPictureQualityLevel(at)
  167537. }
  167538. ,
  167539. children: ["\u753B\u8D28\uFF1A", s === "high" ? "\u9AD8" : s === "low" ? "\u4F4E" : "\u4E2D"]
  167540. }), jsx("button", {
  167541. onClick: ()=>{
  167542. room.debug.toggleNearbyBreathPoint()
  167543. }
  167544. ,
  167545. className: "font-size-small",
  167546. children: "Toggle\u5468\u8FB9\u547C\u5438\u70B9"
  167547. }), jsx("button", {
  167548. onClick: ()=>{
  167549. room.debug.toggleTapBreathPoint()
  167550. }
  167551. ,
  167552. className: "font-size-small",
  167553. children: "Toggle\u70B9\u51FB\u547C\u5438\u70B9"
  167554. }), jsx("button", {
  167555. onClick: ()=>{
  167556. try {
  167557. room.debug.dumpStream(()=>{
  167558. toast("\u5F55\u5236\u5B8C\u6210")
  167559. }
  167560. ),
  167561. toast("\u5F00\u59CB\u5F55\u5236")
  167562. } catch {
  167563. toast("\u7801\u6D41\u5F55\u5236\u4E2D\uFF0C\u8BF7\u7A0D\u7B49")
  167564. }
  167565. }
  167566. ,
  167567. className: "font-size-small",
  167568. children: "\u5F55\u5236\u7801\u6D41\uFF0810s\uFF09"
  167569. }), jsx("input", {
  167570. onBlur: at=>{
  167571. at.preventDefault();
  167572. const st = at.target.value
  167573. , ut = Number(st);
  167574. if (ut > 0) {
  167575. urlParam.set("scale", String(ut));
  167576. const ct = urlParam.toString();
  167577. location.href = location.origin + location.pathname + "?" + ct
  167578. }
  167579. }
  167580. ,
  167581. placeholder: "\u81EA\u5B9A\u4E49Avatar\u7F29\u653E",
  167582. defaultValue: scale || ""
  167583. })]
  167584. }))(), a && jsxs("div", {
  167585. className: "loading",
  167586. id: "loading",
  167587. children: [jsx("img", {
  167588. src: loadingImage,
  167589. alt: ""
  167590. }), jsxs("div", {
  167591. children: ["\u5373\u5C06\u8FDB\u5165\u573A\u666F ", d]
  167592. })]
  167593. })]
  167594. })
  167595. }
  167596. ReactDOM.render(jsx(React.StrictMode, {
  167597. children: jsx(App, {})
  167598. }), document.getElementById("root"));